@rvdbreemen/adr-kit-opencode 0.52.0 → 0.52.2
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.
- package/.claude-plugin/plugin.json +29 -29
- package/README.md +861 -850
- package/bin/adr +0 -0
- package/bin/adr-audit +0 -0
- package/bin/adr-context +0 -0
- package/bin/adr-discover +0 -0
- package/bin/adr-doctor +0 -0
- package/bin/adr-generate-scripts +0 -0
- package/bin/adr-grill-signal +0 -0
- package/bin/adr-guardian +0 -0
- package/bin/adr-index +0 -0
- package/bin/adr-judge +0 -0
- package/bin/adr-judge-precommit +0 -0
- package/bin/adr-lint +0 -0
- package/bin/adr-mcp +0 -0
- package/bin/adr-migrate +0 -0
- package/bin/adr-quality +0 -0
- package/bin/adr-readiness +0 -0
- package/bin/adr-readiness-ci +0 -0
- package/bin/adr-related +0 -0
- package/bin/adr-renumber +254 -254
- package/bin/adr-retire +0 -0
- package/bin/adr-settings +0 -0
- package/bin/adr-status +0 -0
- package/bin/adr-suggest +0 -0
- package/bin/adr-watch +0 -0
- package/bin/bump-version +0 -0
- package/clients/workflows.json +229 -229
- package/hooks/__init__.py +1 -1
- package/hooks/adapters/__init__.py +13 -13
- package/hooks/adapters/claude.py +27 -27
- package/hooks/adapters/codex.py +26 -26
- package/hooks/adapters/copilot.py +11 -11
- package/hooks/adr-hook.py +128 -128
- package/hooks/adr_hook_core.py +843 -843
- package/hooks/adr_pr_guard.py +367 -367
- package/instructions/ADR-guide.md +48 -48
- package/instructions/adr.coding.md +82 -82
- package/instructions/adr.review.md +182 -182
- package/opencode/plugin.ts +1 -4
- package/package.json +5 -2
- package/schemas/adr-context-probes.schema.json +56 -56
- package/schemas/adr-enforcement.schema.json +57 -57
- package/schemas/adr-frontmatter.schema.json +144 -144
- package/schemas/adr-index.schema.json +276 -276
- package/schemas/adr-kit-config.schema.json +371 -371
- package/schemas/adr-readiness.schema.json +41 -41
- package/schemas/client-capabilities.schema.json +503 -503
- package/schemas/client-certification.schema.json +101 -101
- package/schemas/doctor-output.schema.json +92 -92
- package/skills/adr/SKILL.md +780 -780
- package/skills/audit/SKILL.md +103 -103
- package/skills/context/SKILL.md +77 -77
- package/skills/grill/SKILL.md +84 -84
- package/skills/grill/agents/openai.yaml +4 -4
- package/skills/guardian/SKILL.md +316 -316
- package/skills/init/SKILL.md +499 -499
- package/skills/install-hooks/SKILL.md +154 -154
- package/skills/judge/SKILL.md +168 -168
- package/skills/lint/SKILL.md +321 -321
- package/skills/migrate/SKILL.md +313 -313
- package/skills/related/SKILL.md +62 -62
- package/skills/retire/SKILL.md +41 -41
- package/skills/review/SKILL.md +167 -167
- package/skills/settings/SKILL.md +73 -73
- package/skills/setup/SKILL.md +128 -128
- package/skills/supersede/SKILL.md +136 -136
- package/skills/upgrade/SKILL.md +273 -273
- package/templates/adr-kit-guide.md +354 -354
- package/templates/adr-template.canonical.md +115 -115
- package/templates/adr-template.madr.md +131 -131
- package/templates/adr-template.md +131 -131
- package/templates/adr-template.nygard.md +111 -111
- package/templates/cc-settings/guardian-hook-entry.json +9 -9
- package/templates/githooks/pre-commit +1 -1
- package/templates/github-workflows/adr-audit.yml +58 -58
- package/templates/github-workflows/adr-guardian-audit.yml +133 -133
- package/templates/github-workflows/adr-index-check.yml +30 -30
- package/templates/github-workflows/adr-judge.yml +31 -31
- package/templates/github-workflows/adr-readiness.yml +18 -18
- package/templates/validate_adr_template.py +38 -38
- 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())
|