You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wire extract-cli fully into the contract-ops suite's agent conventions:
- extract --catalog json: the suite-wide discovery contract
{name, bin, version, description, commands[], exitCodes}, mirroring
nda-review-cli/docx2pdf/sign. Agents call it at startup instead of
hardcoding commands/flags. A test asserts it never drifts from the
real argparse parser. Added to bash/zsh completion flag lists.
- AGENTS.md: agent contract in the canonical section order
(output contract / exit codes / discovery / failure -> recovery).
- llms.txt: machine-readable tool summary at the repo root.
- pyproject: suite-standard keywords (contract-ops, agent-first,
legal-tech); ship AGENTS.md + llms.txt in the sdist.
- README opens with Run this / Where to go next; --catalog documented
in README + docs/INTEROP.md.
No schema or extraction-logic change (extractor_version unchanged).
mypy --strict clean; 110 passed / 2 skipped; spec-check OK.
also printed by `extract schema`. Validate against it instead of trusting
24
+
field shapes by convention. (Note: the `--no-confidence` projection is a
25
+
reduced convenience view, **not** governed by the schema.)
26
+
-**stderr** is for humans only: `--why` rationale, warnings, and errors.
27
+
stdout stays clean JSON even under `--why`.
28
+
-**Failure**: a one-line `error: <message>` on **stderr**, non-zero exit.
29
+
The error shape is a flat string (the suite is not uniform on error-object
30
+
shape) — **branch on the exit code, never on the human-readable message.**
31
+
32
+
## Exit codes
33
+
34
+
| Code | Meaning |
35
+
|------|---------|
36
+
|`0`| Success. |
37
+
|`1`| Low-signal document — no high-signal fields (parties/clauses/dates) could be extracted; e.g. a scanned/image-only or empty file. A **finding**, not a crash: valid JSON is still emitted on stdout. |
38
+
|`2`| Bad usage / user-actionable error (unreadable path, bad flag value, unsupported completion shell). |
39
+
40
+
## Discovery
41
+
42
+
Never hardcode command or flag names — call the catalog at startup:
`sign --catalog json`). It is **complete, accurate, and stable across minor
51
+
versions** — a test asserts it never drifts from the real parser.
52
+
53
+
Tool-specific discovery extras:
54
+
55
+
```bash
56
+
extract schema # the output JSON Schema (the cross-CLI data contract)
57
+
extract fields # extractable fields and the tier that produces each
58
+
extract fields --json # ...as JSON
59
+
extract demo # run on a bundled fixture (zero-config first run)
60
+
extract --version
61
+
```
62
+
63
+
## Failure → recovery
64
+
65
+
| Symptom | Diagnose | Recover |
66
+
|---|---|---|
67
+
| Exit `1`, warning "no high-signal fields" | The document is likely scanned/image-only or has no recognizable structure. JSON is still emitted. | OCR the source first, or feed a text/`.docx`/`.md` version. The empty-but-valid JSON is safe to pass downstream. |
68
+
| Exit `2`, `error: ...`|`extract --catalog json` (or `extract <cmd> --help`) for the real surface. | Fix the path/flag and retry. |
69
+
|`clauses: []` on a real contract | The `.docx` likely auto-numbers via Word's numbering with no heading style (its numbers live only in `numbering.xml`), so the deterministic cascade sees no headings. | Re-run with `--llm` (opt-in): when no clauses are detected, the LLM is asked for section headings, normalized through the same canonical vocabulary and emitted with `tier: "llm"`, `source: "llm"`, and a modest confidence. Requires `~/.config/contract-ops/llm.json`. |
70
+
| Low-fidelity `.docx`/`.pdf` text | The stdlib best-effort reader ran (no extras installed). |`pip install "extract-cli[docx]"` and/or `"extract-cli[pdf]"` for higher fidelity. The core always works without them. |
71
+
|`--llm` only printed a warning | No LLM config found. | Copy [`config/llm.json.example`](config/llm.json.example) to `~/.config/contract-ops/llm.json`. Without it, deterministic output is still returned in full. |
72
+
73
+
## Recommended usage
74
+
75
+
```bash
76
+
# Inspect any contract's structure, one tool for five formats.
0 commit comments