@rvdbreemen/adr-kit-opencode 0.56.0 → 0.57.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/bin/adr +32 -2
- package/bin/adr-lint +40 -2
- package/bin/adr-migrate +28 -0
- package/bin/adr_format.py +73 -0
- package/bin/adr_guardian_queue.py +15 -1
- package/bin/adr_quality_core.py +19 -2
- package/bin/adr_readiness.py +59 -1
- package/package.json +1 -1
- package/scripts/check-changelog-sections.py +198 -0
- package/scripts/release.py +171 -0
- package/scripts/release_npm.py +117 -0
- package/scripts/release_phases.py +331 -0
- package/scripts/release_shell.py +124 -0
- package/templates/adr-kit-guide.md +7 -2
- package/templates/cc-settings/guardian-hook-entry.json +1 -1
- package/templates/githooks/pre-commit +1 -1
- package/templates/github-workflows/adr-readiness.yml +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""How the release driver talks to the outside world.
|
|
3
|
+
|
|
4
|
+
Split from release_phases.py along the seam ADR-010 asks for: this module is
|
|
5
|
+
process invocation and repository interrogation, that one is the sequence of
|
|
6
|
+
steps. Keeping them apart means a phase reads as the runbook step it mirrors,
|
|
7
|
+
with the Windows and PATH details out of the way.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import re
|
|
13
|
+
import shutil
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import time
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Callable, NamedTuple, Optional, Sequence, Tuple
|
|
19
|
+
|
|
20
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
21
|
+
PACKAGE = "@rvdbreemen/adr-kit-opencode"
|
|
22
|
+
CLIENTS = ("claude", "codex", "copilot")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ReleaseError(RuntimeError):
|
|
26
|
+
"""A phase refused to continue. The message says what to do next."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Context(NamedTuple):
|
|
30
|
+
version: str
|
|
31
|
+
skip_tests: bool
|
|
32
|
+
timeout_min: int
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def tag(self) -> str:
|
|
36
|
+
return f"v{self.version}"
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def branch(self) -> str:
|
|
40
|
+
return f"release/v{self.version}"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def run(
|
|
44
|
+
cmd: Sequence[str],
|
|
45
|
+
*,
|
|
46
|
+
check: bool = False,
|
|
47
|
+
cwd: Optional[Path] = None,
|
|
48
|
+
) -> Tuple[int, str, str]:
|
|
49
|
+
"""Run a command and return (code, stdout, stderr), never raising on exit code.
|
|
50
|
+
|
|
51
|
+
Returning the code rather than raising is deliberate: most callers here are
|
|
52
|
+
asking a question ("is this already done?") where a non-zero answer is
|
|
53
|
+
information, not a failure.
|
|
54
|
+
"""
|
|
55
|
+
argv = list(cmd)
|
|
56
|
+
# shutil.which applies PATHEXT, so `npm` finds npm.cmd on Windows. Without
|
|
57
|
+
# it subprocess raises FileNotFoundError for every shim on PATH.
|
|
58
|
+
resolved = shutil.which(argv[0])
|
|
59
|
+
if resolved is None:
|
|
60
|
+
return 127, "", f"{argv[0]}: not found on PATH"
|
|
61
|
+
proc = subprocess.run(
|
|
62
|
+
[resolved, *argv[1:]],
|
|
63
|
+
cwd=str(cwd or ROOT),
|
|
64
|
+
capture_output=True,
|
|
65
|
+
text=True,
|
|
66
|
+
encoding="utf-8",
|
|
67
|
+
errors="replace",
|
|
68
|
+
)
|
|
69
|
+
if check and proc.returncode != 0:
|
|
70
|
+
raise ReleaseError(
|
|
71
|
+
f"{' '.join(cmd)} failed ({proc.returncode})\n{proc.stdout}{proc.stderr}"
|
|
72
|
+
)
|
|
73
|
+
return proc.returncode, proc.stdout or "", proc.stderr or ""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def git(*args: str, check: bool = False) -> Tuple[int, str, str]:
|
|
77
|
+
return run(["git", *args], check=check)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def script(name: str, *args: str, check: bool = False) -> Tuple[int, str, str]:
|
|
81
|
+
return run([sys.executable, str(ROOT / "scripts" / name), *args], check=check)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _clean_tree() -> bool:
|
|
85
|
+
return not git("status", "--porcelain")[1].strip()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _version_everywhere(ctx: Context) -> bool:
|
|
89
|
+
return script("check-release-version.py", "--expect", ctx.tag)[0] == 0
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _main_sha() -> str:
|
|
93
|
+
git("fetch", "origin", "--tags")
|
|
94
|
+
return git("rev-parse", "origin/main")[1].strip()
|
|
95
|
+
|
|
96
|
+
def _wait_until(predicate: Callable[[], bool], ctx: Context, what: str) -> None:
|
|
97
|
+
deadline = time.monotonic() + ctx.timeout_min * 60
|
|
98
|
+
while time.monotonic() < deadline:
|
|
99
|
+
if predicate():
|
|
100
|
+
return
|
|
101
|
+
time.sleep(30)
|
|
102
|
+
raise ReleaseError(
|
|
103
|
+
f"gave up waiting for {what} after {ctx.timeout_min} minutes. Nothing is "
|
|
104
|
+
"broken: re-run this command once it has happened and the finished "
|
|
105
|
+
"phases will be skipped."
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _client_version(client: str) -> Optional[str]:
|
|
110
|
+
"""Read the version a client reports, rather than trusting an exit code."""
|
|
111
|
+
listings = {
|
|
112
|
+
"claude": ["claude", "plugin", "list"],
|
|
113
|
+
"copilot": ["copilot", "plugin", "list"],
|
|
114
|
+
"codex": ["codex", "plugin", "list"],
|
|
115
|
+
}
|
|
116
|
+
code, out, _ = run(listings[client])
|
|
117
|
+
if code != 0:
|
|
118
|
+
return None
|
|
119
|
+
for line in out.splitlines():
|
|
120
|
+
if "adr-kit" in line.lower() or "version" in line.lower():
|
|
121
|
+
found = re.search(r"(\d+\.\d+\.\d+)", line)
|
|
122
|
+
if found:
|
|
123
|
+
return found.group(1)
|
|
124
|
+
return None
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- adr-kit-guide v0.
|
|
1
|
+
<!-- adr-kit-guide v0.57.0 -->
|
|
2
2
|
<!-- Canonical project-side ADR guide. Copied from the plugin's templates/adr-kit-guide.md to .claude/adr-kit-guide.md by /adr-kit:init, /adr-kit:upgrade, and /adr-kit:setup. -->
|
|
3
3
|
<!-- This file is plain markdown — readable by Claude Code, headless `claude -p`, shell scripts in pre-commit hooks, evaluator scripts, and any agent that doesn't process @-imports. Do not embed Claude-Code-specific syntax inside this file. -->
|
|
4
4
|
|
|
@@ -210,7 +210,12 @@ Steps 3 and 4 may run in either order. Accepting first is the safer habit, becau
|
|
|
210
210
|
|
|
211
211
|
Never edit Decision, Context, Consequences, or Alternatives of an Accepted/Deprecated ADR. Only the Status line and an appended Status History transition may change.
|
|
212
212
|
|
|
213
|
-
**One thing the commands cannot recover.** An ADR authored before the `## Status History` convention has its acceptance date in the Status line and nowhere else. The lifecycle commands seed a recovered entry from that line before replacing it, recording `changed_by: unknown` and `changed_via: unrecorded` rather than inventing a signer.
|
|
213
|
+
**One thing the commands cannot recover.** An ADR authored before the `## Status History` convention has its acceptance date in the Status line and nowhere else. The lifecycle commands seed a recovered entry from that line before replacing it, recording `changed_by: unknown` and `changed_via: unrecorded` rather than inventing a signer. The recovered entry also carries the Status line verbatim in its `reason`, so anything the parser cannot turn into structure — a `Decision Maker:` attribution, a note about which release line the decision applied to — survives in the record rather than being discarded for not fitting a field.
|
|
214
|
+
|
|
215
|
+
There are two ways the command refuses rather than rewriting, and both exist so it never writes a history that silently omits an earlier transition:
|
|
216
|
+
|
|
217
|
+
- The Status line does not yield both a status and a date. Fix the line, then re-run.
|
|
218
|
+
- The Status line carries a **second** transition the recovered one does not account for, for example `Superseded by ADR-088, 2026-08-07. Originally Accepted, 2026-05-08.` Only the leading status and the first date are read, so the command can see that it is about to discard something without knowing what. Write the `## Status History` block first, recording each transition the line names, then re-run.
|
|
214
219
|
|
|
215
220
|
## Code review checks
|
|
216
221
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_comment": "ADR Guardian SessionStart hook entry for .claude/settings.json",
|
|
3
3
|
"_note": "Add this entry under hooks.SessionStart[0].hooks[] in the project's .claude/settings.json.",
|
|
4
4
|
"_remove_marker": "adr-guardian-session-start",
|
|
5
|
-
"_wrapper_version": "0.
|
|
5
|
+
"_wrapper_version": "0.57.0",
|
|
6
6
|
"type": "command",
|
|
7
7
|
"command": "ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ 2>/dev/null | sort -V | tail -1) && [ -n \"$ADR_KIT\" ] && _PY=$(command -v python3 || command -v python || command -v py) && [ -n \"$_PY\" ] && \"$_PY\" \"$ADR_KIT/bin/adr-guardian\" check 2>/dev/null || true",
|
|
8
8
|
"timeout": 10
|
|
@@ -52,7 +52,7 @@ set -e
|
|
|
52
52
|
# freezes at install time. adr-guardian compares this stamp against the
|
|
53
53
|
# installed plugin version and nudges /adr-kit:upgrade when the wrapper lags.
|
|
54
54
|
# Maintained by scripts/bump-version.py; do not edit by hand.
|
|
55
|
-
ADR_KIT_WRAPPER_VERSION="0.
|
|
55
|
+
ADR_KIT_WRAPPER_VERSION="0.57.0"
|
|
56
56
|
|
|
57
57
|
if [ "${ADR_KIT_HOOK_DISABLE:-0}" = "1" ]; then
|
|
58
58
|
echo "[adr-kit] hook disabled for this commit (ADR_KIT_HOOK_DISABLE=1)" >&2
|