Skip to content

ThomasMoreAI/legal-skills-open / br/employment/skills/legal-process-parser-lucianum7

legal-process-parser-lucianum7

Verified

Ingere e audita processos em PDF, TXT ou Markdown, preserva o original, extrai cada página e imagem com rastreabilidade e prepara análises processuais, petições e peças de trabalho com citações internas, controle de lacunas e revisão humana. Use para ingerir autos, localizar trechos, comparar peças, analisar provas e decisões, controlar pendências ou redigir minutas sem inventar fatos.

FileKindSize
LICENSEother1.1 KB
SKILL.mdskill md15.4 KB
agents/openai.yamlconfig450 B
references/document_types.mdmarkdown955 B
references/extraction_rules.mdmarkdown2.1 KB
references/legal_analysis_rules.mdmarkdown975 B
references/pleading_generation_rules.mdmarkdown1.8 KB
references/procedural_analysis_rules.mdmarkdown1.2 KB
references/procedural_progression_rules.mdmarkdown1.9 KB
references/request_intake_rules.mdmarkdown2.9 KB
references/security_rules.mdmarkdown694 B
references/source_policy.mdmarkdown647 B
references/vision_processing_rules.mdmarkdown2.8 KB
references/visual_description_rules.mdmarkdown2.3 KB
schemas/chronology.schema.jsonconfig495 B
schemas/controversy.schema.jsonconfig606 B
schemas/document_piece.schema.jsonconfig712 B
schemas/evidence.schema.jsonconfig580 B
schemas/page.schema.jsonconfig1.4 KB
schemas/procedural_summary.schema.jsonconfig868 B
schemas/process_manifest.schema.jsonconfig4.7 KB
schemas/vision_review.schema.jsonconfig1.3 KB
schemas/visual_element.schema.jsonconfig1.8 KB
scripts/__init__.pyscript71 B
scripts/build_index.pyscript998 B
scripts/build_markdown.pyscript889 B
scripts/compute_hash.pyscript627 B
scripts/detect_scanned_pages.pyscript625 B
scripts/extract_pdf_text.pyscript1.1 KB
scripts/helpers.pyscript87.4 KB
scripts/identify_documents.pyscript849 B
scripts/ingest_document.pyscript24.1 KB
scripts/scope_questions.pyscript2.1 KB
scripts/validate_extraction.pyscript5.8 KB
scripts/validate_links.pyscript2.8 KB
templates/audit_report.mdmarkdown327 B
templates/chronology.mdmarkdown225 B
templates/controversy_matrix.mdmarkdown210 B
templates/image_descriptions.jsonconfig950 B
templates/petition_draft.mdmarkdown1.0 KB
templates/procedural_analysis.mdmarkdown468 B
templates/process_markdown.mdmarkdown1.9 KB
templates/vision_review.jsonconfig856 B
tests/__init__.pyscript1 B
tests/test_pipeline.pyscript16.4 KB
tests/test_platform_adapters.pyscript1.9 KB
tests/test_visual_correction.pyscript4.1 KB

scripts/validate_extraction.py

View on GitHub
from __future__ import annotations

import argparse
import json
import re
import sys
from pathlib import Path

try:
    from .validate_links import validate_links
except ImportError:  # direct execution
    from validate_links import validate_links  # type: ignore


def validate(output: Path) -> list[str]:
    errors: list[str] = []
    manifest_path = output / "manifest.json"
    if not manifest_path.exists():
        return ["manifest.json não encontrado"]
    try:
        manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
    except json.JSONDecodeError as exc:
        return [f"manifest.json inválido: {exc}"]
    coverage = manifest.get("coverage", {})
    total = coverage.get("pages_total", 0)
    processed = coverage.get("pages_processed", 0)
    pages_path = output / "processo_estruturado.md"
    page_headers = re.findall(r"^## \[Página PDF (\d+)\]", pages_path.read_text(encoding="utf-8-sig"), flags=re.M) if pages_path.exists() else []
    numbers = [int(item) for item in page_headers]
    if processed != len(numbers):
        errors.append(f"manifesto informa {processed} páginas, Markdown contém {len(numbers)}")
    if numbers != list(range(1, len(numbers) + 1)):
        errors.append("sequência de páginas do Markdown não é contínua")
    if processed != total:
        errors.append(f"processamento incompleto: {processed}/{total} páginas")
    generated_files = manifest.get("generated_files")
    required_files = (
        [name for name in generated_files if isinstance(name, str) and not name.endswith("/")]
        if isinstance(generated_files, list)
        else [
            "index.jsonl",
            "indice_pecas.md",
            "cronologia.md",
            "matriz_controversias.md",
            "relatorio_auditoria.md",
            "image_inventory.json",
            "relatorio_processual.md",
            "andamento_processual.json",
            "relatorio_andamento.md",
            "pendencias_e_prazos.md",
            "matriz_documental.md",
            "mapa_provas.md",
            "checklist_manifestacao.md",
            "minuta_peca.md",
            "relatorio_conformidade.md",
        ]
    )
    for required in required_files:
        if not (output / required).exists():
            errors.append(f"arquivo ausente: {required}")
    if pages_path.exists():
        markdown = pages_path.read_text(encoding="utf-8-sig")
        if markdown.count("### Resumo sem") < processed:
            errors.append("Markdown sem resumo semântico para todas as páginas")
            visual_sections = markdown.count("### Imagens e elementos visuais") + markdown.count("### Imagens visuais relevantes")
            if visual_sections < processed:
                errors.append("Markdown sem seção visual para todas as páginas")
    procedural_path = output / "andamento_processual.json"
    if procedural_path.exists():
        try:
            procedural = json.loads(procedural_path.read_text(encoding="utf-8-sig"))
        except (OSError, json.JSONDecodeError):
            errors.append("andamento_processual.json inválido")
        else:
            for collection in ("events", "deadlines", "evidence", "pending_pages", "tasks"):
                if not isinstance(procedural.get(collection), list):
                    errors.append(f"andamento_processual.json sem lista {collection}")
    pages_jsonl = output / "pages.jsonl"
    if pages_jsonl.exists():
        page_records: list[dict] = []
        for line_number, line in enumerate(pages_jsonl.read_text(encoding="utf-8-sig").splitlines(), start=1):
            try:
                record = json.loads(line)
            except json.JSONDecodeError:
                errors.append(f"pages.jsonl linha {line_number} inválida")
                continue
            page_records.append(record)
            for key in ("summary", "entities", "keywords", "content_blocks", "visuals"):
                if key not in record:
                    errors.append(f"pages.jsonl linha {line_number} sem campo {key}")
    return errors


def main() -> int:
    parser = argparse.ArgumentParser(description="Valida cobertura e artefatos sem interpretar o mérito jurídico.")
    parser.add_argument("output", type=Path)
    args = parser.parse_args()
    errors = validate(args.output.resolve())
    if errors:
        print("\n".join(f"ERRO: {error}" for error in errors))
        return 1
    print("OK: cobertura, sequência e artefatos básicos válidos")
    return 0


_validate_legacy = validate


def validate(output: Path) -> list[str]:
    errors = _validate_legacy(output)
    manifest_path = output / "manifest.json"
    pages_path = output / "pages.jsonl"
    if not manifest_path.exists() or not pages_path.exists():
        return errors
    try:
        manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
        records = [json.loads(line) for line in pages_path.read_text(encoding="utf-8-sig").splitlines() if line.strip()]
    except (OSError, json.JSONDecodeError):
        return errors
    for index, record in enumerate(records, start=1):
        if record.get("status") == "COMPLETE":
            render = record.get("render", {})
            vision = record.get("vision", {})
            if render.get("required") and not render.get("validated"):
                errors.append(f"pages.jsonl linha {index} marca COMPLETE sem renderização validada")
            if vision.get("required") and not vision.get("semantic_checked"):
                errors.append(f"pages.jsonl linha {index} marca COMPLETE sem visão semântica")
    if manifest.get("coverage", {}).get("full_conversion_complete") and any(record.get("status") != "COMPLETE" for record in records):
        errors.append("manifesto marca conversão integral com páginas não COMPLETE")
    errors.extend(validate_links(output))
    return errors


if __name__ == "__main__":
    raise SystemExit(main())

rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall