Skip to content

ThomasMoreAI/legal-skills-open / br/litigation/skills/juriscan-brunobracaioli

juriscan-brunobracaioli

Verified

Análise forense de processos judiciais brasileiros. Extrai, classifica e cruza peças processuais, detecta contradições, calcula prazos CPC e gera relatórios de risco com exportação para Obsidian. Use quando mencionar: processo judicial, petição, sentença, acórdão, contradições, prazos, timeline, análise forense, Obsidian.

FileKindSize
.claude/agents/juriscan-advogado-autor.mdmarkdown4.3 KB
.claude/agents/juriscan-advogado-reu.mdmarkdown3.6 KB
.claude/agents/juriscan-auditor-processual.mdmarkdown7.0 KB
.claude/agents/juriscan-echo.mdmarkdown2.0 KB
.claude/agents/juriscan-parser.mdmarkdown4.7 KB
.claude/agents/juriscan-segmenter.mdmarkdown4.9 KB
.claude/agents/juriscan-sintetizador.mdmarkdown3.1 KB
.claude/agents/juriscan-verificador.mdmarkdown4.8 KB
.github/FUNDING.ymlconfig77 B
.github/workflows/ci.ymlconfig1.0 KB
.gitignoreother121 B
CHANGELOG.mdmarkdown20.6 KB
CLAUDE.mdmarkdown10.6 KB
LICENSEother1.0 KB
README.mdmarkdown16.9 KB
SKILL.mdskill md26.3 KB
assets/banner.svgother4.7 KB
docs/architecture.mdmarkdown10.3 KB
docs/index.htmlother4.3 KB
docs/operations.mdmarkdown6.7 KB
docs/subagent_contract.mdmarkdown6.0 KB
docs/subagents.mdmarkdown5.5 KB
install.shscript3.2 KB
pyproject.tomlmanifest272 B
references/agent_schemas/advogado_output.jsonconfig2.7 KB
references/agent_schemas/auditor_output.jsonconfig4.8 KB
references/agent_schemas/echo_output.jsonconfig666 B
references/agent_schemas/parser_output.jsonconfig4.4 KB
references/agent_schemas/recommendations_output.jsonconfig2.5 KB
references/agent_schemas/segmenter_output.jsonconfig2.9 KB
references/agent_schemas/sintetizador_output.jsonconfig2.7 KB
references/agent_schemas/verificador_output.jsonconfig2.3 KB
references/appellate_structure.mdmarkdown2.0 KB
references/binding_precedents.mdmarkdown2.2 KB
references/brazilian_legal_entities.mdmarkdown3.2 KB
references/chunk_analysis_schema.jsonconfig6.7 KB
references/cpc_prazos.jsonconfig4.4 KB
references/feriados_forenses.jsonconfig2.1 KB
references/output_schema.jsonconfig11.0 KB
references/output_schema_v2.jsonconfig11.0 KB
references/output_schema_v3.jsonconfig5.3 KB
references/piece_type_taxonomy.jsonconfig7.5 KB
references/prompt_templates.mdmarkdown11.8 KB
references/risk_scoring_rubric.mdmarkdown2.4 KB
references/whitelist_fontes.jsonconfig1.8 KB
requirements.txtmanifest250 B
scripts/__init__.pyscript0 B
scripts/agent_io.pyscript12.2 KB
scripts/analyzed_init.pyscript3.3 KB
scripts/audit.pyscript4.8 KB
scripts/cleanup_audit.pyscript2.0 KB
scripts/confidence_rules.pyscript6.4 KB
scripts/content_quality_check.pyscript11.1 KB
scripts/enrich_deterministic.pyscript10.3 KB
scripts/extract_and_chunk.pyscript14.3 KB
scripts/finalize.pyscript10.2 KB
scripts/finalize_legacy.pyscript7.4 KB
scripts/generate_report.pyscript29.8 KB
scripts/instance_tracker.pyscript6.7 KB
scripts/integrity_check.pyscript11.0 KB
scripts/integrity_gate.pyscript4.6 KB
scripts/legacy/__init__.pyscript0 B
scripts/legacy/contradiction_report.pyscript11.9 KB
scripts/legacy/risk_scorer.pyscript10.2 KB
scripts/merge_chunk_analysis.pyscript14.8 KB
scripts/migrate_v2_to_v3.pyscript3.1 KB
scripts/obsidian_export.pyscript28.0 KB
scripts/persist_chunks.pyscript6.2 KB
scripts/prazo_calculator.pyscript14.2 KB
scripts/report_metrics.pyscript8.4 KB
scripts/schema_validator.pyscript5.2 KB
scripts/utils/__init__.pyscript0 B
scripts/utils/cnj.pyscript4.4 KB
scripts/utils/dates.pyscript7.8 KB
scripts/utils/filenames.pyscript2.6 KB
scripts/utils/monetary.pyscript5.2 KB
tests/__init__.pyscript0 B
tests/conftest.pyscript1.1 KB
tests/fixtures/agent_io/echo_invalid_missing_field.jsonconfig45 B
tests/fixtures/agent_io/echo_invalid_wrong_const.jsonconfig70 B
tests/fixtures/agent_io/echo_valid.jsonconfig103 B
tests/fixtures/agent_io/segmenter_valid.jsonconfig359 B
tests/fixtures/sample_analyzed.jsonconfig10.0 KB
tests/fixtures/sample_analyzed_with_prazos.jsonconfig470 B
tests/fixtures/sample_chunk_acordao.txtmarkdown3.4 KB
tests/fixtures/sample_chunk_peticao.txtmarkdown3.4 KB
tests/fixtures/sample_chunk_sentenca.txtmarkdown2.9 KB
tests/fixtures/sample_index.jsonconfig1.6 KB
tests/golden/_pdf_builder.pyscript6.1 KB
tests/golden/processo_01_sintetico_simples/expected_invariants.jsonconfig993 B
tests/golden/processo_01_sintetico_simples/source.txtmarkdown3.3 KB
tests/golden/processo_02_sintetico_art942/expected_art_942.jsonconfig898 B
tests/golden/processo_02_sintetico_art942/expected_invariants.jsonconfig1.3 KB
tests/golden/processo_02_sintetico_art942/source.txtmarkdown7.8 KB
tests/test_agent_io.pyscript4.4 KB
tests/test_analyzed_init.pyscript5.6 KB
tests/test_audit.pyscript4.4 KB
tests/test_cnj.pyscript2.9 KB
tests/test_confidence_rules.pyscript4.8 KB
tests/test_content_quality_check.pyscript14.5 KB
tests/test_contradiction_report.pyscript3.5 KB
tests/test_dates.pyscript5.0 KB
tests/test_enrich_deterministic.pyscript6.3 KB
tests/test_filenames.pyscript2.1 KB
tests/test_finalize.pyscript5.8 KB
tests/test_finalize_legacy.pyscript6.5 KB
tests/test_generate_report.pyscript24.0 KB
tests/test_golden_regression.pyscript6.3 KB
tests/test_instance_tracker.pyscript4.2 KB
tests/test_integrity_check.pyscript4.8 KB
tests/test_integrity_gate.pyscript3.6 KB
tests/test_merge_chunk_analysis.pyscript20.9 KB
tests/test_migrate_v2_to_v3.pyscript4.3 KB
tests/test_monetary.pyscript3.4 KB
tests/test_obsidian_export_v3.pyscript6.9 KB
tests/test_persist_chunks.pyscript6.1 KB
tests/test_prazo_calculator.pyscript14.1 KB
tests/test_report_metrics.pyscript5.3 KB
tests/test_risk_scorer.pyscript5.7 KB
tests/test_whitelist_enforcement.pyscript6.1 KB

scripts/legacy/risk_scorer.py

View on GitHub
#!/usr/bin/env python3
"""
risk_scorer.py — Litigation risk scoring.

DEPRECATED (Phase 5 Step 5.1, 2026-04-11): moved to scripts/legacy/. Still
consumed by SKILL.md when `--pipeline=legacy` is explicit. The agents
pipeline uses juriscan-advogado-autor + juriscan-advogado-reu (two-polo
perspectives) instead. Removal scheduled 3 releases after Phase 6.4 flip.

Computes structural risk indicators from the analysis JSON.
Strategic analysis (Claude-dependent) is handled via prompt templates.

Usage:
    python3 risk_scorer.py --analysis analyzed.json --output risk.json
"""

from __future__ import annotations

import argparse
import json
import os
import re
import sys
import warnings as _warnings

_warnings.warn(
    "scripts.legacy.risk_scorer is deprecated; prefer perspectives.autor / "
    "perspectives.reu from the agents pipeline.",
    DeprecationWarning,
    stacklevel=2,
)

sys.path.insert(0, os.path.dirname(__file__))
# risk_scorer previously imported from scripts/utils — after the move to
# scripts/legacy/, point to the parent scripts/ so utils.monetary still works.
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from utils.monetary import normalize_brl


def score_procedural_risk(analysis: dict) -> dict:
    """Score procedural risk based on structural indicators.

    Checks:
    - Missing expected pieces
    - Prazo compliance (from prazos_calculados if available)
    - Integrity anomalies
    - Chronological consistency
    """
    score = 10.0  # Start perfect, deduct
    factors = []
    chunks = analysis.get('chunks', [])
    labels = [c.get('label', '') for c in chunks]

    # Missing contestação when petição + sentença exist
    if 'PETIÇÃO INICIAL' in labels and 'SENTENÇA' in labels and 'CONTESTAÇÃO' not in labels:
        score -= 2.0
        factors.append({
            'fator': 'Contestação ausente — possível revelia',
            'impacto': -2.0,
            'peca_fonte': 'Análise de peças',
        })

    # Prazo violations
    prazos = analysis.get('prazos_calculados', [])
    vencidos = [p for p in prazos if p.get('status') == 'vencido']
    if vencidos:
        penalty = min(len(vencidos) * 2.0, 5.0)
        score -= penalty
        factors.append({
            'fator': f'{len(vencidos)} prazo(s) vencido(s)',
            'impacto': -penalty,
            'peca_fonte': 'Cálculo de prazos',
        })

    # Integrity issues
    integrity = analysis.get('integrity_report', {})
    anomalies = integrity.get('anomalies', [])
    high_impact = [a for a in anomalies if a.get('impacto') == 'ALTO']
    if high_impact:
        penalty = min(len(high_impact) * 1.5, 3.0)
        score -= penalty
        factors.append({
            'fator': f'{len(high_impact)} anomalia(s) de alto impacto na integridade documental',
            'impacto': -penalty,
            'peca_fonte': 'Relatório de integridade',
        })

    # Low OCR confidence
    ocr_scores = integrity.get('ocr_scores', [])
    low_ocr = [s for s in ocr_scores if s.get('score', 1) < 0.5]
    if low_ocr:
        score -= 1.0
        factors.append({
            'fator': f'{len(low_ocr)} chunk(s) com OCR confidence < 50%',
            'impacto': -1.0,
            'peca_fonte': 'Relatório de integridade',
        })

    return {
        'score': round(max(score, 0.0), 1),
        'factors': factors,
    }


def score_merit_indicators(analysis: dict) -> dict:
    """Score merit indicators from structural data.

    Analyzes: contradiction count/severity, evidence presence, jurisprudence alignment.
    """
    score = 5.0  # Neutral start
    favorable = []
    unfavorable = []
    chunks = analysis.get('chunks', [])

    # Contradictions analysis
    contradictions = analysis.get('contradictions', [])
    high_contradictions = [c for c in contradictions if c.get('impacto') == 'ALTO']
    if high_contradictions:
        score -= 1.5
        unfavorable.append({
            'fator': f'{len(high_contradictions)} contradição(ões) de alto impacto',
            'fundamentacao': '; '.join(c.get('descricao', '')[:100] for c in high_contradictions[:3]),
        })

    # Evidence: laudo pericial present?
    has_laudo = any(c.get('label') == 'LAUDO PERICIAL' for c in chunks)
    if has_laudo:
        score += 1.0
        favorable.append({
            'fator': 'Laudo pericial presente no processo',
            'fundamentacao': 'Prova técnica disponível para fundamentação',
        })

    # Evidence: ata de audiência (witnesses)
    has_audiencia = any(c.get('label') == 'ATA DE AUDIÊNCIA' for c in chunks)
    if has_audiencia:
        score += 0.5
        favorable.append({
            'fator': 'Audiência de instrução realizada',
            'fundamentacao': 'Prova oral produzida',
        })

    # Jurisprudence: binding precedents
    all_binding = []
    for c in chunks:
        all_binding.extend(c.get('binding_precedents', []))

    favoraveis = [b for b in all_binding if b.get('alinhamento') == 'FAVORAVEL_AUTOR']
    desfavoraveis = [b for b in all_binding if b.get('alinhamento') == 'FAVORAVEL_REU']

    if favoraveis:
        score += min(len(favoraveis) * 0.5, 2.0)
        favorable.append({
            'fator': f'{len(favoraveis)} precedente(s) vinculante(s) favorável(is)',
            'fundamentacao': ', '.join(b.get('numero', '?') for b in favoraveis[:3]),
        })

    if desfavoraveis:
        score -= min(len(desfavoraveis) * 0.5, 2.0)
        unfavorable.append({
            'fator': f'{len(desfavoraveis)} precedente(s) vinculante(s) desfavorável(is)',
            'fundamentacao': ', '.join(b.get('numero', '?') for b in desfavoraveis[:3]),
        })

    # Sentença result (if available)
    for c in chunks:
        if c.get('label') == 'SENTENÇA' and c.get('decisao'):
            decisao = c['decisao'].lower()
            if 'procedente' in decisao and 'improcedente' not in decisao:
                score += 1.5
                favorable.append({
                    'fator': 'Sentença procedente (total ou parcial)',
                    'fundamentacao': c['decisao'][:150],
                    'peca_fonte': 'SENTENÇA',
                })

    return {
        'score': round(max(min(score, 10.0), 0.0), 1),
        'favorable_factors': favorable,
        'unfavorable_factors': unfavorable,
    }


def score_monetary_exposure(analysis: dict) -> dict:
    """Calculate monetary exposure from available data."""
    chunks = analysis.get('chunks', [])

    max_exposure = 0.0
    likely_value = 0.0
    min_value = 0.0

    for c in chunks:
        valores = c.get('valores', {})

        # Maximum: valor da causa or sum of pedidos
        causa = normalize_brl(valores.get('causa', '') or '')
        if causa and causa > max_exposure:
            max_exposure = causa

        # Likely: condenação value (from sentença/acórdão)
        cond = normalize_brl(valores.get('condenacao', '') or '')
        if cond and c.get('label') in ('SENTENÇA', 'ACÓRDÃO'):
            likely_value = cond

        # Values from "outros"
        for outro in valores.get('outros', []):
            val = normalize_brl(outro.get('valor', '') or '')
            if val:
                if val > min_value:
                    min_value = val

    # If no condenação, estimate likely as 60% of max
    if not likely_value and max_exposure:
        likely_value = max_exposure * 0.6

    # Min is the smallest acknowledged value or 30% of likely
    if not min_value:
        min_value = likely_value * 0.3 if likely_value else 0.0

    # Costs estimation
    honorarios = likely_value * 0.15 if likely_value else max_exposure * 0.10
    custas = max_exposure * 0.01 if max_exposure else 0.0

    # Ensure invariant: likely_range.min <= likely_range.max.
    # Previously min_value could exceed likely_value when "outros" valores
    # (e.g. aggregated pedidos) were larger than the actual condenação,
    # producing a nonsense range with min > max.
    range_min, range_max = sorted([min_value, likely_value])
    assert range_min <= range_max, (
        f"likely_range invariant violated: min={range_min}, max={range_max}"
    )

    def fmt(v: float) -> str | None:
        if v <= 0:
            return None
        return f"R$ {v:,.2f}".replace(',', 'X').replace('.', ',').replace('X', '.')

    return {
        'max_exposure': fmt(max_exposure),
        'likely_range': {
            'min': fmt(range_min),
            'max': fmt(range_max),
        },
        'costs': {
            'custas_estimadas': fmt(custas),
            'honorarios_sucumbencia': fmt(honorarios),
        },
    }


def generate_risk_report(analysis: dict) -> dict:
    """Generate composite risk report."""
    procedural = score_procedural_risk(analysis)
    merit = score_merit_indicators(analysis)
    monetary = score_monetary_exposure(analysis)

    # Weighted composite score (from author's perspective)
    overall = procedural['score'] * 0.3 + merit['score'] * 0.5 + (procedural['score'] * 0.2)
    overall = round(overall, 1)

    if overall < 4.0:
        level = 'ALTO'
    elif overall < 7.0:
        level = 'MÉDIO'
    else:
        level = 'BAIXO'

    return {
        'risk_level': level,
        'overall_score': overall,
        'procedural_risk': procedural,
        'merit_indicators': merit,
        'monetary_exposure': monetary,
        'strategic_recommendations': [],  # Populated by Claude via prompt
    }


def main():
    parser = argparse.ArgumentParser(description='Litigation risk scorer')
    parser.add_argument('--analysis', '-a', required=True, help='Path to analyzed.json')
    parser.add_argument('--output', '-o', help='Output path')
    args = parser.parse_args()

    with open(args.analysis, 'r', encoding='utf-8') as f:
        analysis = json.load(f)

    report = generate_risk_report(analysis)

    output_path = args.output or os.path.join(os.path.dirname(args.analysis), 'risk.json')
    with open(output_path, 'w', encoding='utf-8') as f:
        json.dump(report, f, ensure_ascii=False, indent=2)

    print(f"\nRisk Assessment:")
    print(f"  Level: {report['risk_level']}")
    print(f"  Score: {report['overall_score']}/10")
    print(f"  Procedural: {report['procedural_risk']['score']}/10")
    print(f"  Merit: {report['merit_indicators']['score']}/10")
    print(f"  Output: {output_path}")


if __name__ == '__main__':
    main()
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 196kUpdated Claude CodeCodexVerifiedInstall