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/finalize.py

View on GitHub
"""Deterministic monetary recalculations — Phase 5 Step 5.3.

Runs at the very end of the agents pipeline, after juriscan-sintetizador
and scripts/confidence_rules.py. Reads ``auditor_findings`` and for each
entry with ``tipo == "RECALCULO_NECESSARIO"`` applies the appropriate
deterministic formula. Everything here uses ``decimal.Decimal`` to avoid
the rounding traps of binary floats on money.

Two recalculations are supported in this version:

1. **Lei 14.905/2024 (juros mistos)** — from ``2024-08-30`` onward the
   legal interest rate changed from 1% a.m. (Código Civil art. 406) to
   SELIC - IPCA. Condemnations whose update period straddles that date
   must be split in two and each half computed independently. We do NOT
   have a SELIC/IPCA time series bundled with the repo; we emit the
   **structure** (two periods with periods, taxas, and placeholders) so
   that the practitioner or a specialized module can fill in the rates
   without touching the pipeline plumbing. The first period is fully
   computable because 1% a.m. is deterministic.

2. **Honorários após reforma parcial** — when a lower-court condemnation
   is reformed on appeal and the appellate decision is silent about the
   honorarios base, this script emits the alternative calculations for
   both possible bases (original vs. reformed) so the practitioner sees
   the quantitative delta behind the art. 1022 CPC omission.
"""

from __future__ import annotations

import argparse
import json
import sys
from dataclasses import dataclass, field
from datetime import date
from decimal import Decimal, ROUND_HALF_UP
from pathlib import Path


LEI_14905_CUTOVER = date(2024, 8, 30)
LEGAL_RATE_BEFORE_CUTOVER = Decimal("0.01")  # 1% per month, CC art. 406
MONEY_PRECISION = Decimal("0.01")


class FinalizeError(Exception):
    pass


def _to_decimal(value: object) -> Decimal:
    if isinstance(value, Decimal):
        return value
    if isinstance(value, (int, float)):
        return Decimal(str(value))
    if isinstance(value, str):
        cleaned = value.replace("R$", "").strip().replace(".", "").replace(",", ".")
        return Decimal(cleaned)
    raise FinalizeError(f"cannot coerce to Decimal: {value!r}")


def _parse_date(value: str | date) -> date:
    if isinstance(value, date):
        return value
    return date.fromisoformat(value)


def _money(d: Decimal) -> Decimal:
    return d.quantize(MONEY_PRECISION, rounding=ROUND_HALF_UP)


def _months_between(start: date, end: date) -> Decimal:
    """Whole months + fractional month based on days in the final month.

    Matches the convention used in civil monetary updates: cada mês cheio
    conta inteiro, e o mês parcial é fracionado por dias corridos.
    """
    if end < start:
        return Decimal("0")
    years = end.year - start.year
    months = end.month - start.month
    full_months = years * 12 + months
    # Fractional remainder based on day delta.
    if end.day < start.day:
        full_months -= 1
        # Compute leftover as a fraction of the final month length.
        # Approximate the final-month length as 30 days.
        day_delta = (end - date(end.year, end.month, 1)).days + (
            30 - start.day + 1
        )
        fractional = Decimal(day_delta) / Decimal(30)
    else:
        day_delta = end.day - start.day
        fractional = Decimal(day_delta) / Decimal(30)
    return Decimal(full_months) + fractional


# ---------- Lei 14.905 ----------

@dataclass
class Lei14905Period:
    de: str
    ate: str
    taxa: str
    base: str
    juros: str | None
    valor_com_juros: str | None
    note: str = ""


def recalcular_juros_lei_14905(
    base_value: object,
    data_inicio: str | date,
    data_fim: str | date,
) -> dict:
    """Split the interest period around 2024-08-30 and compute period 1 fully.

    Returns a dict with ``periodo_1`` (fully computable at 1% a.m.) and
    ``periodo_2`` (structurally present but with ``valor_com_juros=None``
    because SELIC - IPCA is not bundled here).
    """
    base = _to_decimal(base_value)
    start = _parse_date(data_inicio)
    end = _parse_date(data_fim)
    if end <= start:
        raise FinalizeError(f"data_fim must be after data_inicio: {start}..{end}")
    if base <= 0:
        raise FinalizeError(f"base must be positive, got {base}")

    periods: list[Lei14905Period] = []

    if end <= LEI_14905_CUTOVER:
        # Entirely before the cutover — simple case.
        months = _months_between(start, end)
        juros = base * LEGAL_RATE_BEFORE_CUTOVER * months
        periods.append(Lei14905Period(
            de=start.isoformat(),
            ate=end.isoformat(),
            taxa="1% a.m. (CC art. 406 — redação anterior à Lei 14.905/2024)",
            base=str(_money(base)),
            juros=str(_money(juros)),
            valor_com_juros=str(_money(base + juros)),
            note="Sem incidência da Lei 14.905/2024 — período totalmente anterior a 30/08/2024.",
        ))
    elif start >= LEI_14905_CUTOVER:
        # Entirely after the cutover — structure only, rates not bundled.
        periods.append(Lei14905Period(
            de=start.isoformat(),
            ate=end.isoformat(),
            taxa="SELIC - IPCA (Lei 14.905/2024)",
            base=str(_money(base)),
            juros=None,
            valor_com_juros=None,
            note="Regime pós-Lei 14.905/2024. Requer série histórica SELIC/IPCA para o cálculo final.",
        ))
    else:
        # Straddles the cutover — split.
        p1_end = LEI_14905_CUTOVER
        p1_months = _months_between(start, p1_end)
        p1_juros = base * LEGAL_RATE_BEFORE_CUTOVER * p1_months
        base_after = base + p1_juros
        periods.append(Lei14905Period(
            de=start.isoformat(),
            ate=p1_end.isoformat(),
            taxa="1% a.m. (CC art. 406 — redação anterior)",
            base=str(_money(base)),
            juros=str(_money(p1_juros)),
            valor_com_juros=str(_money(base_after)),
            note="Período anterior à Lei 14.905/2024.",
        ))
        periods.append(Lei14905Period(
            de=p1_end.isoformat(),
            ate=end.isoformat(),
            taxa="SELIC - IPCA (Lei 14.905/2024)",
            base=str(_money(base_after)),
            juros=None,
            valor_com_juros=None,
            note="Período pós-Lei 14.905/2024. Requer série histórica SELIC/IPCA.",
        ))

    return {
        "tipo": "JUROS_LEI_14905",
        "base_original": str(_money(base)),
        "data_inicio": start.isoformat(),
        "data_fim": end.isoformat(),
        "cutover": LEI_14905_CUTOVER.isoformat(),
        "periods": [p.__dict__ for p in periods],
    }


# ---------- Honorários após reforma ----------

def recalcular_honorarios(
    percentual: object,
    base_original: object,
    base_reformada: object,
) -> dict:
    """Compute both candidate honorarios amounts after a partial reform.

    When the appellate decision is silent about the base of honorarios,
    practitioners need the quantitative delta to justify embargos de
    declaração by omission (CPC art. 1022).
    """
    pct = _to_decimal(percentual)
    if pct > Decimal("1"):
        # Accept 15 for 15% as well as 0.15.
        pct = pct / Decimal("100")
    base_orig = _to_decimal(base_original)
    base_ref = _to_decimal(base_reformada)
    hon_original = base_orig * pct
    hon_reformada = base_ref * pct
    return {
        "tipo": "HONORARIOS_APOS_REFORMA",
        "percentual": f"{(pct * 100).quantize(Decimal('0.01'))}%",
        "base_original": str(_money(base_orig)),
        "base_reformada": str(_money(base_ref)),
        "honorarios_sobre_base_original": str(_money(hon_original)),
        "honorarios_sobre_base_reformada": str(_money(hon_reformada)),
        "delta": str(_money(abs(hon_original - hon_reformada))),
        "note": (
            "O acórdão é silente sobre a base de cálculo dos honorários. "
            "Ambas as bases são plausíveis sem esclarecimento expresso — "
            "cabem embargos de declaração por omissão (CPC art. 1022)."
        ),
    }


# ---------- Top-level apply ----------

def apply_recalculations(analysis: dict) -> dict:
    """Read auditor_findings and emit monetary_recalculations[] in-place."""
    findings = analysis.get("auditor_findings") or []
    recalculations: list[dict] = []

    for f in findings:
        if f.get("tipo") != "RECALCULO_NECESSARIO":
            continue
        fundamento = (f.get("fundamento") or "").lower()
        payload = f.get("payload") or {}
        try:
            if "14.905" in fundamento or "14905" in fundamento:
                recalc = recalcular_juros_lei_14905(
                    base_value=payload.get("base"),
                    data_inicio=payload.get("data_inicio"),
                    data_fim=payload.get("data_fim"),
                )
                recalc["source_finding"] = f.get("fundamento")
                recalculations.append(recalc)
            elif "1022" in fundamento or "honorár" in fundamento or "honorar" in fundamento:
                recalc = recalcular_honorarios(
                    percentual=payload.get("percentual"),
                    base_original=payload.get("base_original"),
                    base_reformada=payload.get("base_reformada"),
                )
                recalc["source_finding"] = f.get("fundamento")
                recalculations.append(recalc)
        except FinalizeError as e:
            recalculations.append({
                "tipo": "ERROR",
                "source_finding": f.get("fundamento"),
                "error": str(e),
            })

    analysis["monetary_recalculations"] = recalculations
    return analysis


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(
        description="Apply deterministic monetary recalculations to analyzed.json"
    )
    parser.add_argument("--input", required=True)
    parser.add_argument("--output", required=True)
    args = parser.parse_args(argv)

    doc = json.loads(Path(args.input).read_text(encoding="utf-8"))
    apply_recalculations(doc)
    Path(args.output).write_text(
        json.dumps(doc, ensure_ascii=False, indent=2),
        encoding="utf-8",
    )
    print(f"[OK] finalize: {len(doc.get('monetary_recalculations') or [])} recálculo(s) aplicado(s)")
    return 0


if __name__ == "__main__":
    raise SystemExit(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