@rvdbreemen/adr-kit-opencode 0.52.0 → 0.53.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 (83) hide show
  1. package/.claude-plugin/plugin.json +29 -29
  2. package/README.md +865 -850
  3. package/bin/adr +0 -0
  4. package/bin/adr-audit +0 -0
  5. package/bin/adr-context +0 -0
  6. package/bin/adr-discover +0 -0
  7. package/bin/adr-doctor +0 -0
  8. package/bin/adr-generate-scripts +0 -0
  9. package/bin/adr-grill-signal +0 -0
  10. package/bin/adr-guardian +0 -0
  11. package/bin/adr-index +0 -0
  12. package/bin/adr-judge +0 -0
  13. package/bin/adr-judge-precommit +0 -0
  14. package/bin/adr-lint +0 -0
  15. package/bin/adr-mcp +96 -4
  16. package/bin/adr-migrate +0 -0
  17. package/bin/adr-quality +0 -0
  18. package/bin/adr-readiness +0 -0
  19. package/bin/adr-readiness-ci +0 -0
  20. package/bin/adr-related +0 -0
  21. package/bin/adr-renumber +254 -254
  22. package/bin/adr-retire +0 -0
  23. package/bin/adr-settings +0 -0
  24. package/bin/adr-status +0 -0
  25. package/bin/adr-suggest +0 -0
  26. package/bin/adr-watch +0 -0
  27. package/bin/adr_doctor_probes.py +2 -0
  28. package/bin/bump-version +0 -0
  29. package/clients/workflows.json +229 -229
  30. package/hooks/__init__.py +1 -1
  31. package/hooks/adapters/__init__.py +13 -13
  32. package/hooks/adapters/claude.py +27 -27
  33. package/hooks/adapters/codex.py +26 -26
  34. package/hooks/adapters/copilot.py +11 -11
  35. package/hooks/adr-hook.py +128 -128
  36. package/hooks/adr_hook_core.py +843 -843
  37. package/hooks/adr_pr_guard.py +367 -367
  38. package/instructions/ADR-guide.md +101 -48
  39. package/instructions/adr.coding.md +82 -82
  40. package/instructions/adr.review.md +182 -182
  41. package/opencode/plugin.ts +1 -4
  42. package/package.json +5 -2
  43. package/schemas/adr-context-probes.schema.json +56 -56
  44. package/schemas/adr-enforcement.schema.json +57 -57
  45. package/schemas/adr-frontmatter.schema.json +144 -144
  46. package/schemas/adr-index.schema.json +276 -276
  47. package/schemas/adr-kit-config.schema.json +371 -371
  48. package/schemas/adr-readiness.schema.json +41 -41
  49. package/schemas/client-capabilities.schema.json +503 -503
  50. package/schemas/client-certification.schema.json +101 -101
  51. package/schemas/doctor-output.schema.json +92 -92
  52. package/skills/adr/SKILL.md +780 -780
  53. package/skills/audit/SKILL.md +103 -103
  54. package/skills/context/SKILL.md +77 -77
  55. package/skills/grill/SKILL.md +84 -84
  56. package/skills/grill/agents/openai.yaml +4 -4
  57. package/skills/guardian/SKILL.md +316 -316
  58. package/skills/init/SKILL.md +499 -499
  59. package/skills/install-hooks/SKILL.md +154 -154
  60. package/skills/judge/SKILL.md +168 -168
  61. package/skills/lint/SKILL.md +321 -321
  62. package/skills/migrate/SKILL.md +313 -313
  63. package/skills/related/SKILL.md +62 -62
  64. package/skills/retire/SKILL.md +41 -41
  65. package/skills/review/SKILL.md +167 -167
  66. package/skills/settings/SKILL.md +73 -73
  67. package/skills/setup/SKILL.md +128 -128
  68. package/skills/supersede/SKILL.md +136 -136
  69. package/skills/upgrade/SKILL.md +273 -273
  70. package/templates/adr-kit-guide.md +354 -354
  71. package/templates/adr-template.canonical.md +115 -115
  72. package/templates/adr-template.madr.md +131 -131
  73. package/templates/adr-template.md +131 -131
  74. package/templates/adr-template.nygard.md +111 -111
  75. package/templates/cc-settings/guardian-hook-entry.json +9 -9
  76. package/templates/githooks/pre-commit +1 -1
  77. package/templates/github-workflows/adr-audit.yml +58 -58
  78. package/templates/github-workflows/adr-guardian-audit.yml +133 -133
  79. package/templates/github-workflows/adr-index-check.yml +30 -30
  80. package/templates/github-workflows/adr-judge.yml +31 -31
  81. package/templates/github-workflows/adr-readiness.yml +18 -18
  82. package/templates/validate_adr_template.py +38 -38
  83. package/templates/validate_adr_template.sh +74 -74
@@ -1,11 +1,11 @@
1
- """Copilot CLI hook output with an honest post-edit backstop."""
2
-
3
- from __future__ import annotations
4
-
5
-
6
- def render(event: str, context: str, kind: str) -> dict:
7
- if not context:
8
- return {}
9
- if kind == "pre-edit":
10
- return {}
11
- return {"additionalContext": context}
1
+ """Copilot CLI hook output with an honest post-edit backstop."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ def render(event: str, context: str, kind: str) -> dict:
7
+ if not context:
8
+ return {}
9
+ if kind == "pre-edit":
10
+ return {}
11
+ return {"additionalContext": context}
package/hooks/adr-hook.py CHANGED
@@ -1,128 +1,128 @@
1
- #!/usr/bin/env python3
2
- """Fail-open command entrypoint for ADR Kit lifecycle hooks."""
3
-
4
- from __future__ import annotations
5
-
6
- import argparse
7
- import json
8
- import sys
9
- from pathlib import Path
10
-
11
- HOOKS = Path(__file__).resolve().parent
12
- if str(HOOKS) not in sys.path:
13
- sys.path.insert(0, str(HOOKS))
14
-
15
- from adapters import ADAPTERS
16
- from adr_hook_core import duplicate_event, evaluate, parse_payload
17
- from adr_pr_guard import judge_branch, looks_like_pr_create
18
-
19
-
20
- def _pr_guard(envelope) -> tuple[str, str] | None:
21
- """Judge the branch when the agent is about to open a pull request.
22
-
23
- Returns None when this is not that moment, so the normal injection path
24
- runs untouched. Kept in the entrypoint rather than in adr_hook_core because
25
- it spawns adr-judge, and the retrieval core is asserted to import nothing
26
- that can reach a model or the network.
27
- """
28
- if envelope.event != "PreToolUse":
29
- return None
30
- tool = (envelope.tool_name or "").lower().replace("_", "")
31
- if tool not in {"bash", "shell", "run", "terminal"}:
32
- return None
33
- command = envelope.tool_input.get("command")
34
- if not isinstance(command, str) or not looks_like_pr_create(command):
35
- return None
36
- bin_dir = Path(__file__).resolve().parent.parent / "bin"
37
- verdict = judge_branch(
38
- envelope.workspace,
39
- envelope.workspace / "docs" / "adr",
40
- bin_dir / "adr-judge",
41
- # R2 asks two questions at this moment: does this violate an accepted
42
- # decision, and does it contain one nobody recorded. Only the first was
43
- # ever answered here (ADR-024). The second joins it rather than getting
44
- # its own moment, because this one is already intercepted and the user
45
- # is already waiting.
46
- suggest=bin_dir / "adr-suggest",
47
- )
48
- nudge = verdict.get("nudge") or ""
49
- if verdict.get("decision") == "deny":
50
- # A violation denies. The nudge rides along because the branch that
51
- # broke a rule is also the one most likely to be making a decision, but
52
- # it never contributes to the denial.
53
- reason = verdict["reason"]
54
- joined = "\n\n".join(part for part in (reason, nudge) if part)
55
- return joined, "pr-guard-deny"
56
- if verdict.get("checked") is False:
57
- # The guard could not do its job, and silence here is the whole defect:
58
- # a branch nobody managed to check looks exactly like a clean one. Say
59
- # so and let the command through -- an unchecked branch is not a
60
- # violation, and blocking on our own failure would punish the wrong
61
- # thing.
62
- return (
63
- "ADR check skipped before this pull request: "
64
- f"{verdict.get('reason', 'unknown reason')}. "
65
- "The commit hook and CI remain the enforcing gates.",
66
- "pr-guard-unchecked",
67
- )
68
- # A clean branch says nothing. An "all clear" on every pull request is noise
69
- # that teaches people to skim past the one that matters. A branch carrying an
70
- # unrecorded decision is not clean in the sense that matters, so the nudge
71
- # speaks -- advisory, and on its own it can never block the tool call.
72
- if nudge:
73
- return nudge, "pr-guard-suggest"
74
- return None
75
-
76
-
77
- def _emit(response) -> None:
78
- """Write the response as UTF-8 bytes, past the platform's text layer.
79
-
80
- `print()` encodes through `sys.stdout`, which is cp1252 on a default Windows
81
- console. An ADR title carrying an em dash came out as byte 0x97 — not valid
82
- UTF-8, so a client decoding the frame as UTF-8 gets nothing usable; a title
83
- carrying anything cp1252 cannot represent raised `UnicodeEncodeError`, which
84
- the fail-open `except BaseException` swallowed into zero bytes and exit 0.
85
- Silent, total loss of the injection, on the platform `clients/capabilities.json`
86
- marks release-required.
87
-
88
- Writing bytes removes the failure rather than handling it: there is no text
89
- layer left to encode wrongly, so no encoding error can reach the fail-open
90
- catch and hide there. `bin/adr-mcp` reconfigures its stdout for the same
91
- reason (TASK-69); this is the same defect one process over.
92
- """
93
- frame = json.dumps(response, ensure_ascii=False, separators=(",", ":"))
94
- out = getattr(sys.stdout, "buffer", None)
95
- if out is not None:
96
- out.write(frame.encode("utf-8") + b"\n")
97
- out.flush()
98
- else:
99
- # Fallback for environments without a binary stdout buffer (e.g. redirected stdout)
100
- sys.stdout.write(frame + "\n")
101
- sys.stdout.flush()
102
-
103
-
104
- def main(argv: list[str] | None = None) -> int:
105
- parser = argparse.ArgumentParser(add_help=False)
106
- parser.add_argument("--client", required=True, choices=tuple(ADAPTERS))
107
- parser.add_argument("--event")
108
- args, _unknown = parser.parse_known_args(argv)
109
- try:
110
- envelope = parse_payload(
111
- sys.stdin.buffer.read(64 * 1024 + 1), args.client, args.event
112
- )
113
- if envelope is None:
114
- return 0
115
- if duplicate_event(envelope):
116
- return 0
117
- context, kind = _pr_guard(envelope) or evaluate(envelope)
118
- response = ADAPTERS[args.client](envelope.event, context, kind)
119
- if response:
120
- _emit(response)
121
- except BaseException:
122
- # Optional hooks can never replace deterministic pre-commit enforcement.
123
- return 0
124
- return 0
125
-
126
-
127
- if __name__ == "__main__":
128
- raise SystemExit(main())
1
+ #!/usr/bin/env python3
2
+ """Fail-open command entrypoint for ADR Kit lifecycle hooks."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ HOOKS = Path(__file__).resolve().parent
12
+ if str(HOOKS) not in sys.path:
13
+ sys.path.insert(0, str(HOOKS))
14
+
15
+ from adapters import ADAPTERS
16
+ from adr_hook_core import duplicate_event, evaluate, parse_payload
17
+ from adr_pr_guard import judge_branch, looks_like_pr_create
18
+
19
+
20
+ def _pr_guard(envelope) -> tuple[str, str] | None:
21
+ """Judge the branch when the agent is about to open a pull request.
22
+
23
+ Returns None when this is not that moment, so the normal injection path
24
+ runs untouched. Kept in the entrypoint rather than in adr_hook_core because
25
+ it spawns adr-judge, and the retrieval core is asserted to import nothing
26
+ that can reach a model or the network.
27
+ """
28
+ if envelope.event != "PreToolUse":
29
+ return None
30
+ tool = (envelope.tool_name or "").lower().replace("_", "")
31
+ if tool not in {"bash", "shell", "run", "terminal"}:
32
+ return None
33
+ command = envelope.tool_input.get("command")
34
+ if not isinstance(command, str) or not looks_like_pr_create(command):
35
+ return None
36
+ bin_dir = Path(__file__).resolve().parent.parent / "bin"
37
+ verdict = judge_branch(
38
+ envelope.workspace,
39
+ envelope.workspace / "docs" / "adr",
40
+ bin_dir / "adr-judge",
41
+ # R2 asks two questions at this moment: does this violate an accepted
42
+ # decision, and does it contain one nobody recorded. Only the first was
43
+ # ever answered here (ADR-024). The second joins it rather than getting
44
+ # its own moment, because this one is already intercepted and the user
45
+ # is already waiting.
46
+ suggest=bin_dir / "adr-suggest",
47
+ )
48
+ nudge = verdict.get("nudge") or ""
49
+ if verdict.get("decision") == "deny":
50
+ # A violation denies. The nudge rides along because the branch that
51
+ # broke a rule is also the one most likely to be making a decision, but
52
+ # it never contributes to the denial.
53
+ reason = verdict["reason"]
54
+ joined = "\n\n".join(part for part in (reason, nudge) if part)
55
+ return joined, "pr-guard-deny"
56
+ if verdict.get("checked") is False:
57
+ # The guard could not do its job, and silence here is the whole defect:
58
+ # a branch nobody managed to check looks exactly like a clean one. Say
59
+ # so and let the command through -- an unchecked branch is not a
60
+ # violation, and blocking on our own failure would punish the wrong
61
+ # thing.
62
+ return (
63
+ "ADR check skipped before this pull request: "
64
+ f"{verdict.get('reason', 'unknown reason')}. "
65
+ "The commit hook and CI remain the enforcing gates.",
66
+ "pr-guard-unchecked",
67
+ )
68
+ # A clean branch says nothing. An "all clear" on every pull request is noise
69
+ # that teaches people to skim past the one that matters. A branch carrying an
70
+ # unrecorded decision is not clean in the sense that matters, so the nudge
71
+ # speaks -- advisory, and on its own it can never block the tool call.
72
+ if nudge:
73
+ return nudge, "pr-guard-suggest"
74
+ return None
75
+
76
+
77
+ def _emit(response) -> None:
78
+ """Write the response as UTF-8 bytes, past the platform's text layer.
79
+
80
+ `print()` encodes through `sys.stdout`, which is cp1252 on a default Windows
81
+ console. An ADR title carrying an em dash came out as byte 0x97 — not valid
82
+ UTF-8, so a client decoding the frame as UTF-8 gets nothing usable; a title
83
+ carrying anything cp1252 cannot represent raised `UnicodeEncodeError`, which
84
+ the fail-open `except BaseException` swallowed into zero bytes and exit 0.
85
+ Silent, total loss of the injection, on the platform `clients/capabilities.json`
86
+ marks release-required.
87
+
88
+ Writing bytes removes the failure rather than handling it: there is no text
89
+ layer left to encode wrongly, so no encoding error can reach the fail-open
90
+ catch and hide there. `bin/adr-mcp` reconfigures its stdout for the same
91
+ reason (TASK-69); this is the same defect one process over.
92
+ """
93
+ frame = json.dumps(response, ensure_ascii=False, separators=(",", ":"))
94
+ out = getattr(sys.stdout, "buffer", None)
95
+ if out is not None:
96
+ out.write(frame.encode("utf-8") + b"\n")
97
+ out.flush()
98
+ else:
99
+ # Fallback for environments without a binary stdout buffer (e.g. redirected stdout)
100
+ sys.stdout.write(frame + "\n")
101
+ sys.stdout.flush()
102
+
103
+
104
+ def main(argv: list[str] | None = None) -> int:
105
+ parser = argparse.ArgumentParser(add_help=False)
106
+ parser.add_argument("--client", required=True, choices=tuple(ADAPTERS))
107
+ parser.add_argument("--event")
108
+ args, _unknown = parser.parse_known_args(argv)
109
+ try:
110
+ envelope = parse_payload(
111
+ sys.stdin.buffer.read(64 * 1024 + 1), args.client, args.event
112
+ )
113
+ if envelope is None:
114
+ return 0
115
+ if duplicate_event(envelope):
116
+ return 0
117
+ context, kind = _pr_guard(envelope) or evaluate(envelope)
118
+ response = ADAPTERS[args.client](envelope.event, context, kind)
119
+ if response:
120
+ _emit(response)
121
+ except BaseException:
122
+ # Optional hooks can never replace deterministic pre-commit enforcement.
123
+ return 0
124
+ return 0
125
+
126
+
127
+ if __name__ == "__main__":
128
+ raise SystemExit(main())