@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
@@ -0,0 +1,216 @@
1
+ """Bounded native and MCP-extension doctor probes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import subprocess
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ from adr_doctor_models import benchmark_extension, check
11
+ from clients.installer.detection import detect_clients
12
+ from clients.installer.bounded import run_bounded
13
+ from hooks.hook_benchmark import measure as measure_hooks
14
+
15
+
16
+ def _command(values: list[str], *, cwd: Path, timeout: float) -> subprocess.CompletedProcess[str]:
17
+ # DEVNULL rather than the console, because `timeout=` is not a bound here.
18
+ # On Windows `copilot` resolves to a .CMD shim, so the child is cmd.exe with
19
+ # a node grandchild; subprocess.run's own TimeoutExpired handler then
20
+ # re-enters communicate() with no bound, and kill() is TerminateProcess on
21
+ # the shim alone. Measured: a 2s timeout returned after 8.18s behind a shim
22
+ # against 2.03s without one. Closing stdin does not restore the bound, but
23
+ # it removes the one thing that would make the wait permanent instead of
24
+ # merely long.
25
+ return run_bounded(
26
+ values, cwd=str(cwd), capture_output=True, text=True,
27
+ stdin=subprocess.DEVNULL,
28
+ encoding="utf-8", errors="replace", timeout=timeout,
29
+ )
30
+
31
+
32
+ def _native_deep(root: Path, name: str, executable: str) -> dict:
33
+ command = (
34
+ [executable, "plugin", "list", "--json"]
35
+ if name in {"claude", "codex"}
36
+ else [executable, "plugin", "list"]
37
+ )
38
+ try:
39
+ result = _command(command, cwd=root, timeout=10)
40
+ except (OSError, subprocess.SubprocessError) as exc:
41
+ return check(
42
+ "native-registration", client=name, status="failed",
43
+ summary=f"native list probe failed: {exc}",
44
+ )
45
+ output = (result.stdout + result.stderr).lower()
46
+ if "trust" in output or "review" in output:
47
+ status = "trust-pending"
48
+ elif result.returncode:
49
+ status = "failed"
50
+ elif "adr-kit" not in output:
51
+ status = "stale"
52
+ else:
53
+ status = "healthy"
54
+ return check(
55
+ "native-registration", client=name, status=status,
56
+ summary=f"bounded native plugin-list probe returned {status}",
57
+ evidence=[{"command": command, "returncode": result.returncode}],
58
+ actions=[{"detail": f"Review or reinstall ADR Kit in {name}."}]
59
+ if status != "healthy" else [],
60
+ )
61
+
62
+
63
+ def _mcp_deep(root: Path, plugin_root: Path) -> dict:
64
+ messages = [
65
+ {
66
+ "jsonrpc": "2.0",
67
+ "id": 1,
68
+ "method": "initialize",
69
+ "params": {
70
+ "protocolVersion": "2025-06-18",
71
+ "capabilities": {},
72
+ "clientInfo": {"name": "adr-doctor", "version": "1"},
73
+ },
74
+ },
75
+ {"jsonrpc": "2.0", "method": "notifications/initialized"},
76
+ {"jsonrpc": "2.0", "id": 2, "method": "tools/list"},
77
+ {
78
+ "jsonrpc": "2.0",
79
+ "id": 3,
80
+ "method": "tools/call",
81
+ "params": {
82
+ "name": "adr_status",
83
+ "arguments": {"project_root": str(root)},
84
+ },
85
+ },
86
+ ]
87
+ try:
88
+ result = subprocess.run(
89
+ [sys.executable, str(plugin_root / "bin" / "adr-mcp")],
90
+ input="\n".join(json.dumps(item) for item in messages) + "\n",
91
+ cwd=str(root),
92
+ capture_output=True,
93
+ text=True,
94
+ encoding="utf-8",
95
+ errors="replace",
96
+ timeout=15,
97
+ )
98
+ responses = {
99
+ item["id"]: item
100
+ for line in result.stdout.splitlines()
101
+ if (item := json.loads(line)).get("id") is not None
102
+ }
103
+ tools = {item["name"] for item in responses[2]["result"]["tools"]}
104
+ called = responses[3]["result"].get("isError") is not True
105
+ healthy = (
106
+ result.returncode == 0
107
+ and {
108
+ "adr_context",
109
+ "adr_judge",
110
+ "adr_status",
111
+ "adr_quality",
112
+ "adr_readiness",
113
+ } == tools
114
+ and called
115
+ )
116
+ except (
117
+ OSError,
118
+ subprocess.SubprocessError,
119
+ json.JSONDecodeError,
120
+ KeyError,
121
+ TypeError,
122
+ ) as exc:
123
+ return check(
124
+ "mcp-live", status="failed",
125
+ summary=f"MCP initialize/list/call probe failed: {exc}",
126
+ actions=[{"detail": "Run adr-doctor --deep after reinstalling ADR Kit."}],
127
+ )
128
+ return check(
129
+ "mcp-live", status="healthy" if healthy else "failed",
130
+ summary=(
131
+ "MCP initialize, tools/list, and adr_status call passed"
132
+ if healthy else "MCP handshake returned an incomplete result"
133
+ ),
134
+ evidence=[{
135
+ "returncode": result.returncode,
136
+ "tools": sorted(tools),
137
+ "call_ok": called,
138
+ }],
139
+ )
140
+
141
+
142
+ def run_deep_extensions(
143
+ root: Path,
144
+ plugin_root: Path,
145
+ *,
146
+ checks: list[dict],
147
+ global_settings: Path | None,
148
+ check_only: bool,
149
+ ) -> list[dict]:
150
+ extensions = [
151
+ _native_deep(root, name, client.executable)
152
+ for name, client in detect_clients().items()
153
+ ]
154
+ extensions.append(_mcp_deep(root, plugin_root))
155
+ # The harness reads plugin_root/tests/fixtures/hooks/reference-corpus.json,
156
+ # and `tests` is a forbidden segment in the public payload -- so the fixture
157
+ # is absent from EVERY installed payload, not only from a generated client
158
+ # tree. Without this branch that lands in the except below as "failed",
159
+ # which reads like a broken harness rather than a fixture that was never
160
+ # shipped. Pre-existing behaviour; only the wording changes.
161
+ corpus = plugin_root / "tests" / "fixtures" / "hooks" / "reference-corpus.json"
162
+ if not corpus.is_file():
163
+ extensions.append(check(
164
+ "hook-latency-extension", status="unsupported", required=False,
165
+ summary=(
166
+ "hook latency corpus is not part of an installed payload; "
167
+ "run the harness from a checkout"
168
+ ),
169
+ ))
170
+ return extensions
171
+ try:
172
+ hook_result = measure_hooks(plugin_root, root, samples=5)
173
+ aggregate = {
174
+ "p50_ms": max(
175
+ item["p50_ms"] for item in hook_result["results"].values()
176
+ ),
177
+ "p95_ms": max(
178
+ item["p95_ms"] for item in hook_result["results"].values()
179
+ ),
180
+ "max_ms": max(
181
+ item["max_ms"] for item in hook_result["results"].values()
182
+ ),
183
+ }
184
+ extension = benchmark_extension(
185
+ method_id=hook_result["method_id"],
186
+ state=hook_result["cache_state"],
187
+ sample_count=5,
188
+ reference_fixture=hook_result["reference_fixture"],
189
+ budget={"event_specific": True},
190
+ measurements=aggregate,
191
+ )
192
+ extension["process_startup_included"] = hook_result[
193
+ "process_startup_included"
194
+ ]
195
+ extension["results"] = hook_result["results"]
196
+ extensions.append(check(
197
+ "hook-latency-extension",
198
+ status="healthy" if hook_result["all_targets_met"] else "degraded",
199
+ required=False,
200
+ summary=(
201
+ "hook latency targets passed"
202
+ if hook_result["all_targets_met"]
203
+ else "one or more hook latency targets missed"
204
+ ),
205
+ evidence=[{
206
+ "machine": hook_result["machine"],
207
+ "ci_variance_percent": hook_result["ci_variance_percent"],
208
+ }],
209
+ extension=extension,
210
+ ))
211
+ except (OSError, ValueError, subprocess.SubprocessError) as exc:
212
+ extensions.append(check(
213
+ "hook-latency-extension", status="failed", required=False,
214
+ summary=f"bounded hook latency harness failed: {exc}",
215
+ ))
216
+ return extensions