@rvdbreemen/adr-kit-opencode 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/.claude-plugin/plugin.json +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +850 -0
  4. package/bin/adr +1552 -0
  5. package/bin/adr-audit +454 -0
  6. package/bin/adr-context +584 -0
  7. package/bin/adr-discover +546 -0
  8. package/bin/adr-doctor +166 -0
  9. package/bin/adr-generate-scripts +421 -0
  10. package/bin/adr-grill-signal +131 -0
  11. package/bin/adr-guardian +1263 -0
  12. package/bin/adr-index +199 -0
  13. package/bin/adr-judge +2832 -0
  14. package/bin/adr-judge-precommit +87 -0
  15. package/bin/adr-lint +2087 -0
  16. package/bin/adr-mcp +1093 -0
  17. package/bin/adr-migrate +644 -0
  18. package/bin/adr-quality +275 -0
  19. package/bin/adr-readiness +211 -0
  20. package/bin/adr-readiness-ci +111 -0
  21. package/bin/adr-related +401 -0
  22. package/bin/adr-renumber +254 -0
  23. package/bin/adr-retire +467 -0
  24. package/bin/adr-settings +399 -0
  25. package/bin/adr-status +797 -0
  26. package/bin/adr-suggest +803 -0
  27. package/bin/adr-watch +674 -0
  28. package/bin/adr_catalog.py +536 -0
  29. package/bin/adr_config.py +280 -0
  30. package/bin/adr_doctor_checks.py +407 -0
  31. package/bin/adr_doctor_core.py +342 -0
  32. package/bin/adr_doctor_models.py +186 -0
  33. package/bin/adr_doctor_probes.py +216 -0
  34. package/bin/adr_format.py +786 -0
  35. package/bin/adr_grill_signal.py +123 -0
  36. package/bin/adr_guardian_queue.py +218 -0
  37. package/bin/adr_history_scan.py +278 -0
  38. package/bin/adr_index_core.py +443 -0
  39. package/bin/adr_llm.py +333 -0
  40. package/bin/adr_llm_judge_migration.py +314 -0
  41. package/bin/adr_quality_core.py +674 -0
  42. package/bin/adr_query.py +678 -0
  43. package/bin/adr_readiness.py +442 -0
  44. package/bin/adr_readiness_ci.py +123 -0
  45. package/bin/adr_regex.py +165 -0
  46. package/bin/adr_regex_worker.py +30 -0
  47. package/bin/adr_retrieval_health.py +385 -0
  48. package/bin/adr_schema.py +448 -0
  49. package/bin/adr_state.py +172 -0
  50. package/bin/bump-version +71 -0
  51. package/clients/workflows.json +229 -0
  52. package/hooks/__init__.py +1 -0
  53. package/hooks/adapters/__init__.py +13 -0
  54. package/hooks/adapters/claude.py +27 -0
  55. package/hooks/adapters/codex.py +26 -0
  56. package/hooks/adapters/copilot.py +11 -0
  57. package/hooks/adr-hook.py +128 -0
  58. package/hooks/adr_hook_core.py +843 -0
  59. package/hooks/adr_pr_guard.py +367 -0
  60. package/instructions/ADR-guide.md +48 -0
  61. package/instructions/adr.coding.md +82 -0
  62. package/instructions/adr.review.md +182 -0
  63. package/opencode/plugin.ts +451 -0
  64. package/package.json +41 -0
  65. package/schemas/adr-context-probes.schema.json +56 -0
  66. package/schemas/adr-enforcement.schema.json +57 -0
  67. package/schemas/adr-frontmatter.schema.json +144 -0
  68. package/schemas/adr-index.schema.json +276 -0
  69. package/schemas/adr-kit-config.schema.json +371 -0
  70. package/schemas/adr-readiness.schema.json +41 -0
  71. package/schemas/client-capabilities.schema.json +503 -0
  72. package/schemas/client-certification.schema.json +101 -0
  73. package/schemas/doctor-output.schema.json +92 -0
  74. package/schemas/marketplace.json.schema.json +70 -0
  75. package/schemas/plugin.json.schema.json +67 -0
  76. package/scripts/adr_settings.py +239 -0
  77. package/scripts/benchmark-adr-grilling.py +323 -0
  78. package/scripts/benchmark-client-generation.py +178 -0
  79. package/scripts/build-client-adapters.py +139 -0
  80. package/scripts/bump-version.py +304 -0
  81. package/scripts/check-branch-sync.py +243 -0
  82. package/scripts/check-release-version.py +81 -0
  83. package/scripts/client_certification.py +153 -0
  84. package/scripts/client_evidence.py +280 -0
  85. package/scripts/client_generation.py +288 -0
  86. package/scripts/client_generation_artifacts.py +351 -0
  87. package/scripts/client_generation_model.py +173 -0
  88. package/scripts/client_generation_state.py +260 -0
  89. package/scripts/client_support_matrix.py +360 -0
  90. package/scripts/install-agent-envs.py +300 -0
  91. package/scripts/probe-client-events.py +183 -0
  92. package/scripts/project_setup.py +379 -0
  93. package/scripts/refresh-otgw-corpus.py +219 -0
  94. package/scripts/settings.py +81 -0
  95. package/scripts/setup-project.py +205 -0
  96. package/scripts/sync-agent-plugins.py +17 -0
  97. package/scripts/version_sites.py +377 -0
  98. package/skills/adr/SKILL.md +780 -0
  99. package/skills/audit/SKILL.md +103 -0
  100. package/skills/context/SKILL.md +77 -0
  101. package/skills/grill/SKILL.md +84 -0
  102. package/skills/grill/agents/openai.yaml +4 -0
  103. package/skills/guardian/SKILL.md +316 -0
  104. package/skills/init/SKILL.md +499 -0
  105. package/skills/install-hooks/SKILL.md +154 -0
  106. package/skills/judge/SKILL.md +168 -0
  107. package/skills/lint/SKILL.md +321 -0
  108. package/skills/migrate/SKILL.md +313 -0
  109. package/skills/related/SKILL.md +62 -0
  110. package/skills/retire/SKILL.md +41 -0
  111. package/skills/review/SKILL.md +167 -0
  112. package/skills/settings/SKILL.md +73 -0
  113. package/skills/setup/SKILL.md +128 -0
  114. package/skills/supersede/SKILL.md +136 -0
  115. package/skills/upgrade/SKILL.md +273 -0
  116. package/templates/adr-kit-guide.md +354 -0
  117. package/templates/adr-template.canonical.md +115 -0
  118. package/templates/adr-template.madr.md +131 -0
  119. package/templates/adr-template.md +131 -0
  120. package/templates/adr-template.nygard.md +111 -0
  121. package/templates/cc-settings/guardian-hook-entry.json +9 -0
  122. package/templates/githooks/pre-commit +337 -0
  123. package/templates/github-workflows/adr-audit.yml +58 -0
  124. package/templates/github-workflows/adr-guardian-audit.yml +133 -0
  125. package/templates/github-workflows/adr-index-check.yml +30 -0
  126. package/templates/github-workflows/adr-judge.yml +31 -0
  127. package/templates/github-workflows/adr-readiness.yml +18 -0
  128. package/templates/validate_adr_template.py +38 -0
  129. package/templates/validate_adr_template.sh +74 -0
package/bin/adr-audit ADDED
@@ -0,0 +1,454 @@
1
+ #!/usr/bin/env python3
2
+ """adr-audit: are we still on course? (spec R15, TASK-84)
3
+
4
+ Two questions, one command, because either answer alone is misleading:
5
+
6
+ * **Are the decisions any good?** -- `adr-lint`. A clean judge over vague
7
+ ADRs proves nothing, because a vague rule cannot be violated.
8
+ * **Does the code obey them?** -- `adr-judge`. A sharp ADR set nobody checks
9
+ the code against is documentation, not governance.
10
+
11
+ The caller should not have to know these come from two binaries, nor that the
12
+ guardian already runs a version of this combination on a cadence nobody asked
13
+ for. `adr-audit` is the on-demand form: a person, a hook or a CI job can
14
+ simply demand it.
15
+
16
+ Two modes:
17
+
18
+ --diff PATH|- judge that diff (the hook and pull-request case)
19
+ --whole-codebase judge every tracked file as if it were newly added
20
+
21
+ Whole-codebase mode answers what no per-diff gate can. A rule added after a
22
+ file was written has never been applied to that file, and never will be by a
23
+ gate that only ever sees changes. Mechanically it is a diff against the empty
24
+ tree, so every line reads as added and `forbid_pattern` applies repository
25
+ wide; `require_pattern` already reads a snapshot and needs no help. Such a diff
26
+ is large by construction, which is exactly what the separate CI-sized budget
27
+ from TASK-73 exists for, so this mode passes it rather than failing closed on
28
+ size.
29
+
30
+ **Exit codes separate the two failures**, because "your ADRs are not good
31
+ enough" and "your code violates an ADR" have different owners and different
32
+ fixes. One conflated non-zero tells the caller nothing about what to go and do:
33
+
34
+ 0 both clean
35
+ 1 the code violates an Accepted ADR (fix the code, or supersede the ADR)
36
+ 3 the ADR set fails its own gates (fix the records)
37
+ 4 both
38
+ 2 the audit could not run at all (tooling or configuration)
39
+
40
+ 3 and 4 sit above 1 rather than below it so that a caller who only checks
41
+ `!= 0` still blocks, while a caller who cares can tell the cases apart. Exit 2
42
+ keeps its usual meaning across this toolkit: the tool could not answer, which
43
+ is never the same as answering "no".
44
+
45
+ A note on the name. `bin/adr-audit` used to be the init discovery scanner; it
46
+ is now `bin/adr-discover`, which is what it does. Two things called audit that
47
+ audit different things is precisely the ambiguity ADRs exist to prevent.
48
+ """
49
+
50
+ from __future__ import annotations
51
+
52
+ import argparse
53
+ import json
54
+ import os
55
+ import subprocess
56
+ import sys
57
+ from pathlib import Path
58
+ from typing import Dict, List, Optional, Tuple
59
+
60
+ _BIN_DIR = Path(__file__).resolve().parent
61
+
62
+ # The branch- and repository-sized budget from TASK-73. Deliberately separate
63
+ # from judge.max_diff_bytes so raising it here never weakens the commit gate.
64
+ WHOLE_CODEBASE_DIFF_BUDGET = 33_554_432
65
+
66
+ # The empty tree object, which every Git repository has without creating it.
67
+ # Diffing against it turns "the codebase" into "one enormous addition".
68
+ EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
69
+
70
+ EXIT_OK = 0
71
+ EXIT_CODE_VIOLATION = 1
72
+ EXIT_TOOLING = 2
73
+ EXIT_ADR_QUALITY = 3
74
+ EXIT_BOTH = 4
75
+
76
+
77
+ class AuditError(Exception):
78
+ """The audit could not run. Distinct from the audit finding something."""
79
+
80
+
81
+ def _run(argv: List[str], cwd: Path, stdin_text: Optional[str] = None,
82
+ timeout: int = 600) -> subprocess.CompletedProcess:
83
+ return subprocess.run(
84
+ argv,
85
+ cwd=str(cwd),
86
+ input=stdin_text,
87
+ capture_output=True,
88
+ text=True,
89
+ encoding="utf-8",
90
+ errors="replace",
91
+ timeout=timeout,
92
+ check=False,
93
+ )
94
+
95
+
96
+ # ---------------------------------------------------------------------------
97
+ # Half one: are the decisions any good?
98
+ # ---------------------------------------------------------------------------
99
+
100
+ def run_lint(
101
+ adr_dir: Path, repo_root: Path, strict: bool, gates: Optional[str] = None
102
+ ) -> Dict:
103
+ """Lint the ADRs, at the gate set the caller asked for.
104
+
105
+ The gate selector matters more than it looks. This command's own rationale
106
+ is that "a clean judge over a set of vague ADRs proves nothing, because
107
+ vague rules cannot be violated" -- and vagueness is what the `evidence` and
108
+ `clarity` gates measure. Neither was reachable from here: the argv was
109
+ fixed, `--gates` was never passed, and `--strict` does not help because it
110
+ adds `schema` only. Measured on this repository, the default set reported
111
+ zero failures over a set that `--gates all` reports four failures on.
112
+ """
113
+ script = _BIN_DIR / "adr-lint"
114
+ if not script.is_file():
115
+ raise AuditError(f"adr-lint not found at {script}")
116
+ argv = [sys.executable, str(script), "--format", "json",
117
+ "--repo-root", str(repo_root), str(adr_dir)]
118
+ if gates:
119
+ argv[4:4] = ["--gates", gates]
120
+ if strict:
121
+ argv.insert(3, "--strict")
122
+ try:
123
+ result = _run(argv, repo_root)
124
+ except (OSError, subprocess.SubprocessError) as exc:
125
+ raise AuditError(f"adr-lint did not run ({exc})") from exc
126
+ if result.returncode == 2:
127
+ raise AuditError(
128
+ f"adr-lint could not run: {(result.stderr or result.stdout).strip()[:400]}"
129
+ )
130
+ try:
131
+ payload = json.loads(result.stdout or "{}")
132
+ except (json.JSONDecodeError, ValueError) as exc:
133
+ raise AuditError(f"adr-lint returned unreadable JSON ({exc})") from exc
134
+
135
+ summary = payload.get("summary") or {}
136
+ failures = [
137
+ {
138
+ "adr": item.get("file"),
139
+ "gate": finding.get("gate"),
140
+ "code": finding.get("code"),
141
+ "summary": finding.get("summary"),
142
+ }
143
+ for item in payload.get("files", [])
144
+ for finding in item.get("findings", [])
145
+ if finding.get("level") == "FAIL"
146
+ ]
147
+ return {
148
+ "clean": not failures,
149
+ "total": summary.get("total", 0),
150
+ "fail": summary.get("fail", 0),
151
+ "advisory": summary.get("advisory", 0),
152
+ "failures": failures,
153
+ }
154
+
155
+
156
+ # ---------------------------------------------------------------------------
157
+ # Half two: does the code obey them?
158
+ # ---------------------------------------------------------------------------
159
+
160
+ def whole_codebase_diff(repo_root: Path) -> str:
161
+ """Every tracked file as one addition, via a diff against the empty tree.
162
+
163
+ The right-hand side is the working tree, not HEAD, so a local run answers
164
+ the question the person actually asked -- is the code in front of me on
165
+ course? -- and matches the `worktree` snapshot the require rules read. In a
166
+ CI checkout the two are the same bytes, so nothing changes there. Untracked
167
+ files are outside this by construction: git cannot diff what it does not
168
+ track, and an audit that silently skipped them would be worse than one that
169
+ says so.
170
+ """
171
+ try:
172
+ result = _run(
173
+ ["git", "diff", "--unified=0", "--no-color", EMPTY_TREE],
174
+ repo_root,
175
+ )
176
+ except (OSError, subprocess.SubprocessError) as exc:
177
+ raise AuditError(f"git diff against the empty tree failed ({exc})") from exc
178
+ if result.returncode != 0:
179
+ raise AuditError(
180
+ "git diff against the empty tree failed: "
181
+ f"{(result.stderr or '').strip()[:300]}"
182
+ )
183
+ return result.stdout
184
+
185
+
186
+ def read_diff(source: str) -> str:
187
+ if source == "-":
188
+ return sys.stdin.read()
189
+ try:
190
+ return Path(source).read_text(encoding="utf-8", errors="replace")
191
+ except OSError as exc:
192
+ raise AuditError(f"cannot read diff {source}: {exc}") from exc
193
+
194
+
195
+ def run_judge(
196
+ diff_text: str,
197
+ adr_dir: Path,
198
+ repo_root: Path,
199
+ snapshot: str,
200
+ max_diff_bytes: int,
201
+ llm: bool,
202
+ ) -> Dict:
203
+ script = _BIN_DIR / "adr-judge"
204
+ if not script.is_file():
205
+ raise AuditError(f"adr-judge not found at {script}")
206
+ if not diff_text.strip():
207
+ return {"clean": True, "violations": [], "empty": True}
208
+
209
+ argv = [
210
+ sys.executable, str(script),
211
+ "--diff", "-",
212
+ "--adr-dir", str(adr_dir),
213
+ "--repo-root", str(repo_root),
214
+ "--snapshot", snapshot,
215
+ "--max-diff-bytes", str(max_diff_bytes),
216
+ "--json",
217
+ ]
218
+ if llm:
219
+ argv.append("--llm")
220
+ try:
221
+ result = _run(argv, repo_root, stdin_text=diff_text)
222
+ except (OSError, subprocess.SubprocessError) as exc:
223
+ raise AuditError(f"adr-judge did not run ({exc})") from exc
224
+ if result.returncode == 2:
225
+ raise AuditError(
226
+ f"adr-judge could not run: {(result.stderr or result.stdout).strip()[:400]}"
227
+ )
228
+ try:
229
+ payload = json.loads(result.stdout or "{}")
230
+ except (json.JSONDecodeError, ValueError) as exc:
231
+ raise AuditError(f"adr-judge returned unreadable JSON ({exc})") from exc
232
+
233
+ findings = payload.get("findings")
234
+ violations = [
235
+ finding
236
+ for finding in (findings if isinstance(findings, list) else [])
237
+ if isinstance(finding, dict) and finding.get("severity") == "violation"
238
+ ]
239
+ return {"clean": not violations, "violations": violations, "empty": False}
240
+
241
+
242
+ # ---------------------------------------------------------------------------
243
+ # Reporting
244
+ # ---------------------------------------------------------------------------
245
+
246
+ def exit_code(lint: Dict, judge: Dict) -> int:
247
+ bad_adrs = not lint["clean"]
248
+ bad_code = not judge["clean"]
249
+ if bad_adrs and bad_code:
250
+ return EXIT_BOTH
251
+ if bad_adrs:
252
+ return EXIT_ADR_QUALITY
253
+ if bad_code:
254
+ return EXIT_CODE_VIOLATION
255
+ return EXIT_OK
256
+
257
+
258
+ def render_text(lint: Dict, judge: Dict, mode: str, code: int) -> str:
259
+ lines = [f"[adr-audit] {mode}"]
260
+
261
+ if lint["clean"]:
262
+ lines.append(
263
+ f" decisions: OK {lint['total']} ADR(s), "
264
+ f"{lint['advisory']} advisory"
265
+ )
266
+ else:
267
+ lines.append(f" decisions: FAIL {lint['fail']} of {lint['total']} ADR(s)")
268
+ for failure in lint["failures"][:10]:
269
+ lines.append(
270
+ f" {failure['adr']} {failure['gate']} {failure['summary']}"
271
+ )
272
+ if len(lint["failures"]) > 10:
273
+ lines.append(f" ... and {len(lint['failures']) - 10} more")
274
+
275
+ if judge.get("empty"):
276
+ lines.append(" code: OK nothing to judge (empty diff)")
277
+ elif judge["clean"]:
278
+ lines.append(" code: OK no violations of an Accepted ADR")
279
+ else:
280
+ lines.append(f" code: FAIL {len(judge['violations'])} violation(s)")
281
+ for violation in judge["violations"][:10]:
282
+ where = violation.get("path") or "?"
283
+ line = violation.get("line")
284
+ location = f"{where}:{line}" if line else where
285
+ lines.append(
286
+ f" {violation.get('adr', '?')} {location} "
287
+ f"{violation.get('message', '')}".rstrip()
288
+ )
289
+ if len(judge["violations"]) > 10:
290
+ lines.append(f" ... and {len(judge['violations']) - 10} more")
291
+
292
+ lines.append(f" verdict: exit {code} ({_VERDICTS[code]})")
293
+ return "\n".join(lines)
294
+
295
+
296
+ _VERDICTS = {
297
+ EXIT_OK: "on course",
298
+ EXIT_CODE_VIOLATION: "the code violates an Accepted ADR",
299
+ EXIT_ADR_QUALITY: "the ADR set fails its own gates",
300
+ EXIT_BOTH: "both the ADRs and the code need work",
301
+ }
302
+
303
+
304
+ # The health family behind this entry point. `adr-audit status` and friends
305
+ # dispatch to the sibling implementations, so a user needs two commands --
306
+ # adr-audit for anything on demand, adr-guardian for the unprompted cadence --
307
+ # instead of six. The siblings stay on disk as support modules because the
308
+ # guardian, the lifecycle gates and the skills spawn them directly; what
309
+ # shrinks is the surface a person has to know, not the capability.
310
+ HEALTH_SUBCOMMANDS = {
311
+ "status": "adr-status",
312
+ "quality": "adr-quality",
313
+ "readiness": "adr-readiness",
314
+ "doctor": "adr-doctor",
315
+ }
316
+
317
+
318
+ def _dispatch_health_subcommand(argv: List[str]) -> Optional[int]:
319
+ """Run `adr-audit <status|quality|readiness|doctor> ...`, or None.
320
+
321
+ A subprocess rather than an import: each sibling owns its argument
322
+ surface and exit-code contract, and re-parsing them here would be a
323
+ second copy that drifts.
324
+ """
325
+ if not argv or argv[0] not in HEALTH_SUBCOMMANDS:
326
+ return None
327
+ sibling = Path(__file__).resolve().with_name(HEALTH_SUBCOMMANDS[argv[0]])
328
+ result = subprocess.run([sys.executable, str(sibling), *argv[1:]])
329
+ return result.returncode
330
+
331
+
332
+ def main(argv: Optional[List[str]] = None) -> int:
333
+ dispatched = _dispatch_health_subcommand(
334
+ list(sys.argv[1:] if argv is None else argv)
335
+ )
336
+ if dispatched is not None:
337
+ return dispatched
338
+ parser = argparse.ArgumentParser(
339
+ prog="adr-audit",
340
+ description="Lint the decisions and judge the code in one command.",
341
+ epilog=(
342
+ "Exit codes: 0 clean, 1 code violation, 3 ADR-quality failure, "
343
+ "4 both, 2 the audit could not run. Subcommands: "
344
+ "`adr-audit status|quality|readiness|doctor` dispatch to the "
345
+ "health family with each tool's own arguments and exit codes."
346
+ ),
347
+ )
348
+ parser.add_argument("--adr-dir", default="docs/adr")
349
+ parser.add_argument("--repo-root", default=".")
350
+ parser.add_argument("--format", choices=["text", "json"], default="text")
351
+ parser.add_argument(
352
+ "--strict", action="store_true",
353
+ help="Treat every advisory ADR finding as a failure.",
354
+ )
355
+ parser.add_argument(
356
+ "--llm", action="store_true",
357
+ help="Also run the judge's LLM pass for llm_judge ADRs.",
358
+ )
359
+ parser.add_argument(
360
+ "--gates", default=None, metavar="LIST",
361
+ help=(
362
+ "Comma-separated lint gates, or 'all'. Passed through to adr-lint. "
363
+ "The default set answers whether the records are structurally "
364
+ "sound; 'evidence' and 'clarity' answer whether they are sharp "
365
+ "enough to be violated, which is the question this command's own "
366
+ "rationale rests on."
367
+ ),
368
+ )
369
+ scope = parser.add_mutually_exclusive_group()
370
+ scope.add_argument(
371
+ "--diff", default=None, metavar="PATH",
372
+ help="Judge this unified diff ('-' for stdin). The hook and PR case.",
373
+ )
374
+ scope.add_argument(
375
+ "--whole-codebase", action="store_true",
376
+ help=(
377
+ "Judge every tracked file as newly added, so forbid rules reach "
378
+ "code no recent diff touched. Uses the CI-sized diff budget."
379
+ ),
380
+ )
381
+ parser.add_argument(
382
+ "--max-diff-bytes", type=int, default=None,
383
+ help=f"Diff budget. Default {WHOLE_CODEBASE_DIFF_BUDGET} whole-codebase.",
384
+ )
385
+ parser.add_argument(
386
+ "--snapshot", choices=["staged", "worktree", "diff"], default=None,
387
+ help="Post-image source for require_pattern. Default worktree.",
388
+ )
389
+ args = parser.parse_args(argv)
390
+
391
+ repo_root = Path(args.repo_root).resolve()
392
+ adr_dir = Path(args.adr_dir)
393
+ if not adr_dir.is_absolute():
394
+ adr_dir = repo_root / adr_dir
395
+
396
+ # A scope must be named. Defaulting to stdin looks convenient and is the one
397
+ # shape that can answer wrongly in silence: with stdin closed -- a CI step, a
398
+ # cron job, a script that used to call the old `bin/adr-audit` discovery
399
+ # scanner and was never renamed -- the diff reads empty, nothing is judged,
400
+ # and the command prints "on course" and exits 0. A tool that cannot check
401
+ # must not pretend it did, so it refuses instead and says which flag to add.
402
+ if not args.whole_codebase and args.diff is None:
403
+ print(
404
+ "adr-audit: name a scope. Use --whole-codebase to audit every tracked "
405
+ "file, or --diff PATH ('-' for stdin) to audit one diff.\n"
406
+ " (Looking for the init discovery scanner? It is now bin/adr-discover.)",
407
+ file=sys.stderr,
408
+ )
409
+ return EXIT_TOOLING
410
+
411
+ try:
412
+ if args.whole_codebase:
413
+ mode = "whole codebase"
414
+ diff_text = whole_codebase_diff(repo_root)
415
+ budget = args.max_diff_bytes or WHOLE_CODEBASE_DIFF_BUDGET
416
+ else:
417
+ mode = "diff"
418
+ diff_text = read_diff(args.diff)
419
+ budget = args.max_diff_bytes or WHOLE_CODEBASE_DIFF_BUDGET
420
+
421
+ lint = run_lint(adr_dir, repo_root, args.strict, args.gates)
422
+ judge = run_judge(
423
+ diff_text, adr_dir, repo_root,
424
+ args.snapshot or "worktree", budget, args.llm,
425
+ )
426
+ except AuditError as exc:
427
+ print(f"adr-audit: {exc}", file=sys.stderr)
428
+ return EXIT_TOOLING
429
+
430
+ code = exit_code(lint, judge)
431
+ if args.format == "json":
432
+ print(json.dumps(
433
+ {
434
+ "mode": mode,
435
+ "decisions": lint,
436
+ "code": judge,
437
+ "exit_code": code,
438
+ "verdict": _VERDICTS[code],
439
+ },
440
+ indent=2, ensure_ascii=False,
441
+ ))
442
+ else:
443
+ print(render_text(lint, judge, mode, code))
444
+ return code
445
+
446
+
447
+ if __name__ == "__main__":
448
+ if hasattr(sys.stdout, "reconfigure"):
449
+ try:
450
+ sys.stdout.reconfigure(encoding="utf-8")
451
+ sys.stderr.reconfigure(encoding="utf-8")
452
+ except (AttributeError, ValueError, OSError):
453
+ pass
454
+ raise SystemExit(main())