@rvdbreemen/adr-kit-opencode 0.54.0 → 0.56.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adr-kit",
3
3
  "description": "Architecture Decision Record toolkit for AI coding agents: bootstrap, multi-format authoring, bounded deterministic enforcement, lifecycle workflows, context injection, generated graph indexes, and local health checks.",
4
- "version": "0.54.0",
4
+ "version": "0.56.0",
5
5
  "author": {
6
6
  "name": "Robert van den Breemen",
7
7
  "url": "https://github.com/rvdbreemen"
package/README.md CHANGED
@@ -100,6 +100,7 @@ patch releases, is in [CHANGELOG.md](CHANGELOG.md).
100
100
 
101
101
  | Version | What landed | Why it matters |
102
102
  | --- | --- | --- |
103
+ | **0.55.1** | [ADR-029](docs/adr/ADR-029-retire-the-native-hook-binary-rather-than-maintain-a-second-retrieval-engine.md) is carried out: the committed `adr-hook.exe`, its Rust sources, the dispatcher branch that preferred it and the `ADR_KIT_NATIVE_HOOK` opt-in are gone from all three client trees, so Python is the only hook host on every platform. `adr-mcp` now rejects malformed JSON-RPC frames instead of answering them. | The binary was measurably wrong, not merely untested: against the Python oracle it returned one of four governing ADRs on an edit event, and the parity test that should have caught it read a constant out of the Rust source instead of running the build. One retrieval engine means the hook answers what the CLI answers. On the MCP side, a server that answers a malformed frame hides a client defect the client cannot see in its own logs. |
103
104
  | **0.54.0** | Automatic interactive ADR grilling ([ADR-041](docs/adr/ADR-041-automatically-hand-off-unfinished-proposed-adrs-to-interactive-grilling.md)) hands one unfinished Proposed decision to the native grill workflow at the next user-visible prompt. `/adr-kit:upgrade` materializes `grill.auto_start: true` while preserving explicit opt-outs. | Incomplete decisions reach the human while their implementation context is still available, without starting interviews in CI, pre-commit, background, or unattended lifecycle paths. |
104
105
  | **0.52.0** | Native [OpenCode](docs/clients/opencode.md) support through a separate TypeScript plugin, backed by the shared deterministic engines and MCP server ([ADR-039](docs/adr/ADR-039-add-a-native-opencode-plugin-without-expanding-the-certified-cli-gate.md)). The certified Claude Code, Codex, and Copilot CLI registry and release gate remain unchanged. | OpenCode gets its documented native configuration, skills, commands, context, compaction, edit, shell, and MCP integration without weakening the existing certification boundary. |
105
106
  | **0.48.0** | Retrieval is lexical scoring over the generated index plus one-hop graph neighbours, and the LLM judge runs on the CLI you are already signed in to ([ADR-036](docs/adr/ADR-036-retire-the-vector-layer-and-run-the-judge-on-the-host-model-only.md)): the vector subsystem, `bin/adr-embed` and the openrouter/ollama/openai backends are gone, and eight retired config keys now fail validation by name. The guardian records a verdict per ADR and prints it as the sweep lands ([ADR-037](docs/adr/ADR-037-keep-per-adr-judge-verdicts-in-the-advisory-per-machine-guardian-state.md)). | Two subsystems were carrying their own credentials, install paths and failure modes to answer questions the index already answers. A sweep is also long enough to be interrupted, so a per-sweep timestamp discarded everything it had established; per-ADR verdicts keep it. |
@@ -134,8 +135,8 @@ And because decisions age, a periodic guardian flags drift between code and deci
134
135
  ### One engine, three certified CLIs plus OpenCode
135
136
 
136
137
  ADR Kit ships separate integration payloads for Claude Code CLI, OpenAI Codex
137
- CLI, and the standalone GitHub Copilot CLI. All three carry the same 15
138
- workflows, the same deterministic engines, the same key-free five-tool MCP
138
+ CLI, and the standalone GitHub Copilot CLI. All three carry the same 17
139
+ workflows, the same deterministic engines, the same key-free seven-tool MCP
139
140
  server, and English skill metadata; only the native event surface differs. A
140
141
  separate native OpenCode plugin uses the same engines and adds OpenCode-native
141
142
  config, skills, commands, hooks, compaction context, and MCP registration. The
@@ -240,7 +241,7 @@ required.
240
241
 
241
242
  The Claude integration keeps only its manifest under `.claude-plugin/`.
242
243
  Plugin-root `skills/`, `hooks/hooks.json`, `.mcp.json`, agents, and bundled
243
- executables provide 15 workflows, six bounded hooks, and the five-tool MCP
244
+ executables provide 17 workflows, eight bounded hooks, and the seven-tool MCP
244
245
  server.
245
246
 
246
247
  ### OpenAI Codex
@@ -254,8 +255,8 @@ codex mcp list
254
255
  Codex does not use Claude's `/adr-kit:...` slash-command syntax. ADR Kit
255
256
  workflows appear as namespaced skills: open `/skills`, or invoke
256
257
  `$adr-kit:context`, `$adr-kit:judge`, `$adr-kit:lint`, and the other skills.
257
- The separate `codex/` distribution contains all 15 workflows and the key-free
258
- five-tool MCP server. See the official [Codex skills](https://learn.chatgpt.com/docs/build-skills)
258
+ The separate `codex/` distribution contains all 17 workflows and the key-free
259
+ seven-tool MCP server. See the official [Codex skills](https://learn.chatgpt.com/docs/build-skills)
259
260
  and [plugin](https://learn.chatgpt.com/docs/build-plugins) contracts.
260
261
 
261
262
  ### Standalone GitHub Copilot CLI
@@ -294,7 +295,7 @@ Agents should use these native update commands instead of editing the installed
294
295
  ### OpenCode
295
296
 
296
297
  OpenCode is supported through a separate native plugin package. It uses the
297
- same deterministic Python engines and five-tool MCP server as the certified
298
+ same deterministic Python engines and seven-tool MCP server as the certified
298
299
  clients, while adding OpenCode-native configuration, skills, commands, context,
299
300
  compaction, edit, shell, and session hooks.
300
301
 
@@ -308,12 +309,12 @@ configured:
308
309
  }
309
310
  ```
310
311
 
311
- For another project, use the published package for v0.52.0:
312
+ For another project, use the published package:
312
313
 
313
314
  ```json
314
315
  {
315
316
  "$schema": "https://opencode.ai/config.json",
316
- "plugin": ["@rvdbreemen/adr-kit-opencode@0.52.0"]
317
+ "plugin": ["@rvdbreemen/adr-kit-opencode@0.56.0"]
317
318
  }
318
319
  ```
319
320
 
@@ -670,7 +671,7 @@ jobs:
670
671
  - uses: actions/checkout@v4
671
672
  with:
672
673
  fetch-depth: 0 # both sides of the diff must be available
673
- - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.54.0
674
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.56.0
674
675
  with:
675
676
  adr-dir: docs/adr/
676
677
  ```
@@ -684,7 +685,7 @@ The action also takes `max-diff-bytes` (default 32 MiB, available from the relea
684
685
  ```yaml
685
686
  repos:
686
687
  - repo: https://github.com/rvdbreemen/adr-kit
687
- rev: v0.54.0
688
+ rev: v0.56.0
688
689
  hooks:
689
690
  - id: adr-judge
690
691
  ```
@@ -795,7 +796,7 @@ A plain ADR template gives you a markdown file with sections to fill in. What `a
795
796
  | Enforcement | absent | declarative rules vs every commit and PR, key-free; opt-in LLM judge |
796
797
  | Aging | absent | guardian (drift, missing, stale), retirement audit, trend history, coverage KPI |
797
798
  | Team workflows | absent | CI sweeps with tracking issue, collision-safe numbering, audited overrides, guided supersession |
798
- | Tool integration | none | Claude Code, OpenAI Codex, GitHub Copilot CLI, and OpenCode integrations plus a 5-tool MCP server |
799
+ | Tool integration | none | Claude Code, OpenAI Codex, GitHub Copilot CLI, and OpenCode integrations plus a 7-tool MCP server |
799
800
 
800
801
  If your team is happy with a plain template and the discipline lives in your culture, you do not need this. If you want the discipline to survive contact with an AI agent at 2 a.m., this is what `adr-kit` is for.
801
802
 
package/bin/adr CHANGED
@@ -54,6 +54,7 @@ from adr_format import (
54
54
  normalize_profile,
55
55
  profile_catalog,
56
56
  profile_template_path,
57
+ section_span,
57
58
  unresolved_open_questions,
58
59
  )
59
60
  from adr_schema import (
@@ -102,6 +103,24 @@ def find_adr_file(adr_dir: Path, adr_id: str) -> Path:
102
103
  return matches[0]
103
104
 
104
105
 
106
+ _ADR_RECORD_RE = re.compile(r"(?i)^ADR-\d{1,4}-")
107
+
108
+
109
+ def iter_adr_records(adr_dir: Path):
110
+ """Yield ADR record paths, skipping the generated ADR-INDEX.* artefacts.
111
+
112
+ ``glob("ADR-*.md")`` also matches ``ADR-INDEX.md``, which every lifecycle
113
+ command writes in the same transaction as the record it mutates. Feeding
114
+ that generated file to ``load_adr`` was only ever harmless because the
115
+ frontmatter inference invented ``status: Proposed`` for it. Once inference
116
+ started failing closed instead of guessing (issue #118), the generated
117
+ index became a hard error in the middle of an otherwise valid supersede.
118
+ """
119
+ for path in sorted(adr_dir.glob("ADR-*.md")):
120
+ if _ADR_RECORD_RE.match(path.name):
121
+ yield path
122
+
123
+
105
124
  def load_adr(path: Path) -> Tuple[Dict, str]:
106
125
  text = path.read_text(encoding="utf-8")
107
126
  migrated, _changed, issues = migrate_text(text, path)
@@ -236,6 +255,30 @@ def history_entry(status: str, changed_by: str, reason: str, changed_via: str, w
236
255
  )
237
256
 
238
257
 
258
+ def _splice_after_yaml_block(body: str, pos: int, limit: int, entry: str) -> str:
259
+ """Insert `entry` after the last line of an unfenced ``status_history`` block.
260
+
261
+ A line belongs to the block while it is blank or indented; the first
262
+ unindented non-blank line inside the section ends it. Bounded by `limit`
263
+ so a malformed document cannot walk out of the section.
264
+ """
265
+ newline = body.find("\n", pos)
266
+ insert_at = newline + 1 if newline != -1 and newline < limit else limit
267
+ cursor = insert_at
268
+ while cursor < limit:
269
+ newline = body.find("\n", cursor)
270
+ if newline == -1 or newline >= limit:
271
+ line, end = body[cursor:limit], limit
272
+ else:
273
+ line, end = body[cursor:newline], newline + 1
274
+ if line.strip():
275
+ if not line[:1].isspace():
276
+ break
277
+ insert_at = end
278
+ cursor = end
279
+ return body[:insert_at] + entry + body[insert_at:]
280
+
281
+
239
282
  def append_status_history(
240
283
  body: str,
241
284
  status: str,
@@ -245,11 +288,25 @@ def append_status_history(
245
288
  when: str,
246
289
  ) -> str:
247
290
  entry = history_entry(status, changed_by, reason, changed_via, when)
248
- start = HISTORY_START_RE.search(body)
249
- if start:
250
- closing = body.find("```", start.end())
251
- if closing != -1:
252
- return body[:closing] + entry + body[closing:]
291
+
292
+ # Bound every search to the section the reader parses. This used to search
293
+ # the whole remaining document for the next triple backtick, so an unfenced
294
+ # status_history block sent the entry into the next fenced block instead -
295
+ # the ## Enforcement JSON, on every ADR in this project. The command still
296
+ # exited 0, and the index went on reporting the pre-transition status
297
+ # because the reader only looks inside ## Status History (issue #119).
298
+ span = section_span(body, "history")
299
+ if span is not None:
300
+ section_start, section_end = span
301
+ start = HISTORY_START_RE.search(body, section_start, section_end)
302
+ if start:
303
+ closing = body.find("```", start.end(), section_end)
304
+ if closing != -1:
305
+ return body[:closing] + entry + body[closing:]
306
+ # No fence: append after the last line that belongs to the YAML
307
+ # block. Falling through to the section builder below would append
308
+ # a second ## Status History and invert chronology.
309
+ return _splice_after_yaml_block(body, start.end(), section_end, entry)
253
310
 
254
311
  section = (
255
312
  "\n## Status History\n\n"
@@ -1037,7 +1094,7 @@ def command_supersede(args) -> List[str]:
1037
1094
  # decision can legitimately retire more than one record. What stays
1038
1095
  # exclusive is the other direction, enforced below: each predecessor gets
1039
1096
  # exactly one successor.
1040
- for candidate in sorted(adr_dir.glob("ADR-*.md")):
1097
+ for candidate in iter_adr_records(adr_dir):
1041
1098
  if candidate in {old_path, new_path}:
1042
1099
  continue
1043
1100
  candidate_data, _candidate_body = load_adr(candidate)
@@ -1318,7 +1375,7 @@ def command_signer(args) -> List[str]:
1318
1375
 
1319
1376
  if args.audit:
1320
1377
  offenders = []
1321
- for path in sorted(adr_dir.glob("ADR-*.md")):
1378
+ for path in iter_adr_records(adr_dir):
1322
1379
  try:
1323
1380
  body = path.read_text(encoding="utf-8")
1324
1381
  except OSError:
package/bin/adr-mcp CHANGED
@@ -783,6 +783,8 @@ TOOL_HANDLERS = {
783
783
  # JSON-RPC 2.0 plumbing (newline-delimited over stdio)
784
784
  # ---------------------------------------------------------------------------
785
785
 
786
+ JSONRPC_VERSION = "2.0"
787
+
786
788
  PARSE_ERROR = -32700
787
789
  INVALID_REQUEST = -32600
788
790
  METHOD_NOT_FOUND = -32601
@@ -837,8 +839,27 @@ def _write_message(payload: Dict[str, Any]) -> None:
837
839
  sys.stdout.flush()
838
840
 
839
841
 
842
+ def request_id_is_valid(value: Any) -> bool:
843
+ """True when this server may echo `value` as a JSON-RPC id.
844
+
845
+ `RequestId` is `string | number` in schema.ts and `string | integer` in the
846
+ generated schema.json. Floats are refused even when integral: Python cannot
847
+ echo 1.0 without serialising it as `1.0`, which is not an integer in JSON,
848
+ and the echo lands in the server's OWN outgoing frame - the one place a
849
+ non-conformant peer cannot correct for us. Normalising 1.0 to 1 would keep
850
+ the value but silently change the representation the client chose, against
851
+ "It MUST be the same as the value of the id member in the Request Object".
852
+ JSON-RPC 2.0 itself says numbers SHOULD NOT contain fractional parts.
853
+
854
+ `bool` is excluded explicitly, because isinstance(True, int) is True.
855
+ """
856
+ if isinstance(value, bool):
857
+ return False
858
+ return isinstance(value, (str, int))
859
+
860
+
840
861
  def _reply_result(req_id: Any, result: Dict[str, Any]) -> None:
841
- _write_message({"jsonrpc": "2.0", "id": req_id, "result": result})
862
+ _write_message({"jsonrpc": JSONRPC_VERSION, "id": req_id, "result": result})
842
863
 
843
864
 
844
865
  def _reply_error(
@@ -847,7 +868,7 @@ def _reply_error(
847
868
  error: Dict[str, Any] = {"code": code, "message": message}
848
869
  if data is not None:
849
870
  error["data"] = data
850
- _write_message({"jsonrpc": "2.0", "id": req_id, "error": error})
871
+ _write_message({"jsonrpc": JSONRPC_VERSION, "id": req_id, "error": error})
851
872
 
852
873
 
853
874
  # ---------------------------------------------------------------------------
@@ -922,6 +943,15 @@ def modern_envelope_error(
922
943
  f"Invalid params: '{PROTOCOL_VERSION_META_KEY}' must be a string",
923
944
  None,
924
945
  )
946
+ if not isinstance(meta[CLIENT_CAPABILITIES_META_KEY], dict):
947
+ # Also a shape defect, and deliberately decided before negotiation:
948
+ # RequestMetaObject types this key as ClientCapabilities, so a scalar
949
+ # there is a malformed envelope rather than a version disagreement.
950
+ return (
951
+ INVALID_PARAMS,
952
+ f"Invalid params: '{CLIENT_CAPABILITIES_META_KEY}' must be an object",
953
+ None,
954
+ )
925
955
  if requested not in MODERN_PROTOCOL_VERSIONS:
926
956
  # Era-scoped: a modern answer lists modern versions only, because a
927
957
  # handshake revision cannot be reached through a modern envelope.
@@ -938,7 +968,7 @@ def _modern_result(
938
968
  ) -> Dict[str, Any]:
939
969
  """Stamp a modern-era result: resultType, cache hints, _meta.serverInfo.
940
970
 
941
- `resultType` is always "complete": the five tools are fully parameterised
971
+ `resultType` is always "complete": the seven tools are fully parameterised
942
972
  by their arguments, so the server never emits "input_required" and never
943
973
  invents a value of its own. Cache hints are stamped on `server/discover`
944
974
  and `tools/list` only - `CallToolResult` extends `Result`, not
@@ -1027,6 +1057,24 @@ def dispatch(message: Dict[str, Any], root: Path, adr_dir: Path) -> None:
1027
1057
  if not isinstance(params, dict):
1028
1058
  params = {}
1029
1059
 
1060
+ # Base protocol first, before anything era-specific. `jsonrpc` and the id
1061
+ # shape are JSON-RPC 2.0 rather than MCP, so both eras answer them alike,
1062
+ # and clearing them here means every echo further down is a shape this
1063
+ # server is allowed to emit.
1064
+ if message.get("jsonrpc") != JSONRPC_VERSION:
1065
+ if not is_notification:
1066
+ _reply_error(None, INVALID_REQUEST,
1067
+ f"Invalid request: 'jsonrpc' must be {JSONRPC_VERSION!r}")
1068
+ return
1069
+
1070
+ if not is_notification and not request_id_is_valid(req_id):
1071
+ # The id cannot be echoed without repeating the defect it carries, so
1072
+ # the reply takes the null id JSON-RPC 2.0 reserves for exactly this
1073
+ # case - the same convention serve() already uses for a parse error.
1074
+ _reply_error(None, INVALID_REQUEST,
1075
+ "Invalid request: 'id' must be a string or an integer")
1076
+ return
1077
+
1030
1078
  if not isinstance(method, str):
1031
1079
  if not is_notification:
1032
1080
  _reply_error(req_id, INVALID_REQUEST, "Invalid request: missing method")
@@ -1035,7 +1083,7 @@ def dispatch(message: Dict[str, Any], root: Path, adr_dir: Path) -> None:
1035
1083
  if method.startswith("notifications/"):
1036
1084
  # notifications/initialized, notifications/cancelled,
1037
1085
  # notifications/progress, ...: accepted and ignored in both eras.
1038
- # The notification rules forbid a response, and the five tool
1086
+ # The notification rules forbid a response, and the seven tool
1039
1087
  # handlers are synchronous subprocess calls that cannot be
1040
1088
  # interrupted mid-flight, so nothing further is emitted either.
1041
1089
  return
@@ -13,7 +13,11 @@ from pathlib import Path
13
13
  from typing import Dict, Iterable, List, Optional
14
14
 
15
15
  from adr_format import (
16
+ STATUS_BODY_LINE_RE,
17
+ STATUS_BOLD_INLINE_RE,
18
+ STATUS_HEADING_RE,
16
19
  SUPPORTED_PROFILES,
20
+ adr_status,
17
21
  detect_profile,
18
22
  section_text,
19
23
  unresolved_open_questions,
@@ -42,44 +46,18 @@ ENFORCEMENT_BLOCK_RE = re.compile(
42
46
  re.IGNORECASE | re.MULTILINE | re.DOTALL,
43
47
  )
44
48
 
45
- STATUS_HEADING_RE = re.compile(
46
- r"^##\s+Status\s*$\n+([^\n]+)", re.IGNORECASE | re.MULTILINE
47
- )
48
- STATUS_BOLD_INLINE_RE = re.compile(
49
- r"^\s*\*\*\s*Status\s*:?\s*\*\*\s*:?\s*([A-Za-z]+)"
50
- r"|^\s*\*\*\s*Status\s*:?\s*([A-Za-z]+)\s*\*\*",
51
- re.IGNORECASE | re.MULTILINE,
52
- )
49
+ # The status reader and its shapes moved to adr_format so adr_schema can use
50
+ # the same one when it INFERS frontmatter; adr_catalog imports adr_schema, so
51
+ # the dependency could not run the other way (issue #118). Re-exported here
52
+ # under their original names because bin/adr-lint imports them from this
53
+ # module. STATUS_LINE_RE is the body-line form; adr_format keeps a private
54
+ # _STATUS_LINE_RE for frontmatter detection, which is a different question.
55
+ #
53
56
  # Superset of the two historical single-line variants so every tool agrees on
54
57
  # whether an ADR is Accepted: colon optional, leading indentation tolerated,
55
58
  # same line only. Recognizes "Status: Accepted", " Status: Accepted", and
56
59
  # "Status Accepted"; it never captures the "## Status History" heading.
57
- STATUS_LINE_RE = re.compile(
58
- r"^[ \t]*Status[ \t]*:?[ \t]*([A-Za-z]+)", re.IGNORECASE | re.MULTILINE
59
- )
60
- _STATUS_LEADING_WORD_RE = re.compile(r"\s*([A-Za-z]+)")
61
-
62
-
63
- def adr_status(text: str) -> Optional[str]:
64
- """Return the leading ADR status word, or None.
65
-
66
- The single cross-tool status reader used by adr-index, adr-judge, adr-lint,
67
- adr-retire, and adr-watch. A ``## Status`` heading body wins, then a
68
- bold-inline ``**Status:** X`` form, then a plain ``Status: X`` line. The
69
- line form is a deliberate superset of the older per-tool regexes so those
70
- tools can never disagree on an ADR's status. Authoritative lifecycle status
71
- still comes from the status_history chain in ``load_adr_record``; this is
72
- the lightweight reader used by gates and listings.
73
- """
74
- match = STATUS_HEADING_RE.search(text)
75
- if match:
76
- word = _STATUS_LEADING_WORD_RE.match(match.group(1))
77
- return word.group(1) if word else None
78
- match = STATUS_BOLD_INLINE_RE.search(text)
79
- if match:
80
- return match.group(1) or match.group(2)
81
- match = STATUS_LINE_RE.search(text)
82
- return match.group(1) if match else None
60
+ STATUS_LINE_RE = STATUS_BODY_LINE_RE
83
61
 
84
62
 
85
63
  def normalize_adr_id(raw: object) -> Optional[str]:
@@ -192,9 +192,11 @@ def check_hook_package(plugin_root: Path, client: str) -> dict[str, Any]:
192
192
  actions=[{"detail": f"Reinstall ADR Kit for {client}."}],
193
193
  )
194
194
  runtime = root / "hooks" / "adr-hook.py"
195
- native = root / "hooks" / "bin" / "windows-x64" / "adr-hook.exe"
196
195
  wrapper = root / "hooks" / "run-hook.cmd"
197
- required_files = [runtime, native]
196
+ # The Rust host used to be required here too. ADR-029 retired it, so
197
+ # demanding the artefact would now fail every healthy install: Python is
198
+ # the runtime on every platform.
199
+ required_files = [runtime]
198
200
  if client != "copilot":
199
201
  required_files.append(wrapper)
200
202
  missing = [str(path) for path in required_files if not path.is_file()]
package/bin/adr_format.py CHANGED
@@ -125,6 +125,86 @@ _FORMAT_LINE_RE = re.compile(
125
125
  r"^\s*format\s*:\s*[\"']?([a-z-]+)[\"']?\s*$", re.IGNORECASE | re.MULTILINE
126
126
  )
127
127
  _STATUS_LINE_RE = re.compile(r"^\s*status\s*:", re.IGNORECASE | re.MULTILINE)
128
+
129
+ # The body-status reader, and the shapes it accepts. These live here rather
130
+ # than in adr_catalog because adr_schema needs them too and adr_catalog imports
131
+ # adr_schema, not the other way round. adr_catalog re-exports them, so the
132
+ # tools that already import them from there are unaffected.
133
+ STATUS_HEADING_RE = re.compile(
134
+ r"^##\s+Status\s*$\n+([^\n]+)", re.IGNORECASE | re.MULTILINE
135
+ )
136
+ STATUS_BOLD_INLINE_RE = re.compile(
137
+ r"^\s*\*\*\s*Status\s*:?\s*\*\*\s*:?\s*([A-Za-z]+)"
138
+ r"|^\s*\*\*\s*Status\s*:?\s*([A-Za-z]+)\s*\*\*",
139
+ re.IGNORECASE | re.MULTILINE,
140
+ )
141
+ STATUS_BODY_LINE_RE = re.compile(
142
+ r"^[ \t]*Status[ \t]*:?[ \t]*([A-Za-z]+)", re.IGNORECASE | re.MULTILINE
143
+ )
144
+ _STATUS_LEADING_WORD_RE = re.compile(r"\s*([A-Za-z]+)")
145
+
146
+
147
+ def adr_status(text: str) -> Optional[str]:
148
+ """Return the leading ADR status word, or None.
149
+
150
+ The single cross-tool status reader used by adr-index, adr-judge, adr-lint,
151
+ adr-retire, adr-watch and, since issue #118, the frontmatter inference that
152
+ ``adr-migrate`` writes with. A ``## Status`` heading body wins, then a
153
+ bold-inline ``**Status:** X`` form, then a plain ``Status: X`` line. The
154
+ line form is a deliberate superset of the older per-tool regexes so those
155
+ tools can never disagree on an ADR's status.
156
+
157
+ It returns None rather than guessing. That is the whole point: the writer
158
+ used to default to ``"Proposed"`` on a shape it could not read, which
159
+ silently downgraded Accepted records and stopped them being injected.
160
+ Authoritative lifecycle status still comes from the status_history chain in
161
+ ``load_adr_record``; this is the lightweight reader used by gates and
162
+ listings.
163
+ """
164
+ match = STATUS_HEADING_RE.search(text)
165
+ if match:
166
+ word = _STATUS_LEADING_WORD_RE.match(match.group(1))
167
+ return word.group(1) if word else None
168
+ match = STATUS_BOLD_INLINE_RE.search(text)
169
+ if match:
170
+ return match.group(1) or match.group(2)
171
+ match = STATUS_BODY_LINE_RE.search(text)
172
+ return match.group(1) if match else None
173
+
174
+
175
+ def status_statement(text: str) -> str:
176
+ """Return the whole line the status was read from, or an empty string.
177
+
178
+ The status word and the facts printed beside it - the date, the successor -
179
+ sit on the same line, so they must be recovered from the same region.
180
+ Reading the word from one shape and the successor from another is why
181
+ ``superseded_by`` came back None on records whose status reads
182
+ ``**Status:** Superseded by ADR-046``: the word was found, and the
183
+ successor was looked for in a ``## Status`` section those records do not
184
+ have (issue #118).
185
+ """
186
+ match = STATUS_HEADING_RE.search(text)
187
+ if match:
188
+ return match.group(1).strip()
189
+ for pattern in (STATUS_BOLD_INLINE_RE, STATUS_BODY_LINE_RE):
190
+ match = pattern.search(text)
191
+ if match:
192
+ # Anchor on the captured status word, not on match.start(): these
193
+ # patterns begin with `^\s*`, and `\s` eats the preceding newline,
194
+ # so match.start() can sit on the line ABOVE the status and slice
195
+ # out an empty string.
196
+ pos = next(
197
+ (
198
+ match.start(group)
199
+ for group in range(1, (match.lastindex or 0) + 1)
200
+ if match.group(group) is not None
201
+ ),
202
+ match.end(),
203
+ )
204
+ line_start = text.rfind("\n", 0, pos) + 1
205
+ line_end = text.find("\n", pos)
206
+ return text[line_start : line_end if line_end != -1 else len(text)].strip()
207
+ return ""
128
208
  _CANONICAL_FILENAME_RE = re.compile(
129
209
  r"^ADR-\d{3,4}-[a-z0-9]+(?:-[a-z0-9]+)*\.md$",
130
210
  re.IGNORECASE,
@@ -668,13 +748,28 @@ def profile_for_text(text: str, *, fallback: Optional[str] = None) -> str:
668
748
  )
669
749
 
670
750
 
671
- def section_text(
751
+ def section_span(
672
752
  text: str,
673
753
  role: str,
674
754
  *,
675
755
  profile: Optional[str] = None,
676
756
  tolerant: bool = True,
677
- ) -> str:
757
+ ) -> Optional[Tuple[int, int]]:
758
+ """Return the (start, end) offsets of a section's body, or None.
759
+
760
+ ``section_text`` answers *what* a section says; this answers *where* it
761
+ says it, which is what a writer needs in order to place something inside
762
+ the bounds the reader will later parse. Both go through this one matcher,
763
+ so a writer cannot put content where the reader does not look.
764
+
765
+ That failure was real: ``append_status_history`` used to find its insertion
766
+ point with ``body.find("```")`` over the whole remaining document, so on an
767
+ ADR whose ``status_history`` block carries no fence the entry landed in the
768
+ next fenced block - in this project, the ``## Enforcement`` JSON. The
769
+ lifecycle command reported success, the frontmatter said ``Accepted``, and
770
+ ``ADR-INDEX.json`` went on reporting ``Proposed`` because the reader only
771
+ ever looks inside ``## Status History`` (issue #119).
772
+ """
678
773
  profiles: List[str] = []
679
774
  if profile is not None:
680
775
  profiles.append(normalize_profile(profile))
@@ -697,8 +792,21 @@ def section_text(
697
792
  re.IGNORECASE | re.MULTILINE | re.DOTALL,
698
793
  )
699
794
  if match:
700
- return match.group(1).strip()
701
- return ""
795
+ return match.start(1), match.end(1)
796
+ return None
797
+
798
+
799
+ def section_text(
800
+ text: str,
801
+ role: str,
802
+ *,
803
+ profile: Optional[str] = None,
804
+ tolerant: bool = True,
805
+ ) -> str:
806
+ span = section_span(text, role, profile=profile, tolerant=tolerant)
807
+ if span is None:
808
+ return ""
809
+ return text[span[0] : span[1]].strip()
702
810
 
703
811
 
704
812
  def replace_role_heading(text: str, role: str, source: str, target: str) -> str:
package/bin/adr_schema.py CHANGED
@@ -43,7 +43,7 @@ def _load_sibling(name: str):
43
43
 
44
44
  _load_sibling("adr_format")
45
45
 
46
- from adr_format import SUPPORTED_PROFILES
46
+ from adr_format import SUPPORTED_PROFILES, adr_status, status_statement
47
47
 
48
48
  FRONTMATTER_FIELD_ORDER = (
49
49
  "id",
@@ -92,8 +92,13 @@ STATUS_SECTION_RE = re.compile(
92
92
  re.IGNORECASE | re.MULTILINE,
93
93
  )
94
94
  DATE_RE = re.compile(r"\b(\d{4}-\d{2}-\d{2})\b")
95
- SUPERSEDES_RE = re.compile(r"\bSupersedes\s+ADR-(\d{1,4})\b", re.IGNORECASE)
96
- SUPERSEDED_BY_RE = re.compile(r"\bSuperseded\s+by\s+ADR-(\d{1,4})\b", re.IGNORECASE)
95
+ # The optional `[` accepts the link-wrapped form real bodies use:
96
+ # "Superseded by [ADR-124](ADR-124-title.md)". Requiring a bare ADR-NNN meant
97
+ # superseded_by came back None on those records while the status was guessed
98
+ # separately, producing frontmatter that contradicted the prose it was inferred
99
+ # from (issue #118).
100
+ SUPERSEDES_RE = re.compile(r"\bSupersedes\s+\[?ADR-(\d{1,4})\b", re.IGNORECASE)
101
+ SUPERSEDED_BY_RE = re.compile(r"\bSuperseded\s+by\s+\[?ADR-(\d{1,4})\b", re.IGNORECASE)
97
102
 
98
103
 
99
104
  class FrontmatterError(Exception):
@@ -207,14 +212,27 @@ def infer_frontmatter(body: str, path: Optional[Path] = None) -> Dict:
207
212
  title_match = generic_title
208
213
  title = title_match.group(1).strip() if title_match else ""
209
214
 
210
- status_line = ""
211
- status_match = STATUS_SECTION_RE.search(body)
212
- if status_match:
213
- status_line = status_match.group(1).strip()
214
- status_word_match = re.match(r"([A-Za-z]+)", status_line)
215
- status = status_word_match.group(1).capitalize() if status_word_match else "Proposed"
215
+ # The same region the status word was read from, so the date and the
216
+ # successor beside it are recovered from that line rather than from a
217
+ # `## Status` section the record may not have (issue #118).
218
+ status_line = status_statement(body)
219
+ # One reader for the status word, shared with adr-index, adr-judge,
220
+ # adr-lint, adr-retire and adr-watch. It handles the `## Status` heading,
221
+ # the bold-inline `**Status:** X` form and a plain `Status: X` line, and it
222
+ # returns None on anything else.
223
+ #
224
+ # None must stay None. This used to default to "Proposed" whenever the one
225
+ # recognised shape did not match - and `re.match` also returns None for any
226
+ # line starting with `**`, `[` or `-`, so bold and link-wrapped statuses
227
+ # fell through too. `status` is the field that decides whether a decision is
228
+ # binding and injected, so guessing it downgraded Accepted records in
229
+ # silence, with exit 0. Both callers already handle an undetermined status
230
+ # honestly: adr_catalog reports STATUS_UNKNOWN, and migrate_text returns it
231
+ # as an issue and writes nothing (issue #118).
232
+ status_word = adr_status(body)
233
+ status = status_word.capitalize() if status_word else None
216
234
  if status not in VALID_STATUSES:
217
- status = "Proposed"
235
+ status = None
218
236
 
219
237
  date_match = DATE_RE.search(status_line)
220
238
  status_date = date_match.group(1) if date_match else None
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rvdbreemen/adr-kit-opencode",
3
- "version": "0.54.0",
3
+ "version": "0.56.0",
4
4
  "description": "Native OpenCode plugin for ADR Kit, backed by the shared deterministic Python engines.",
5
5
  "type": "module",
6
6
  "main": "./opencode/plugin.ts",
@@ -293,7 +293,14 @@ def main(argv: list[str] | None = None) -> int:
293
293
  print("Then verify the changes and:")
294
294
  print(" git add " + " ".join(staged))
295
295
  print(f' git commit -m "chore(release): v{version}"')
296
- print(f" git tag v{version}")
296
+ # Deliberately not "git tag": since ADR-042 the tag is created by
297
+ # release-publish.yml from the merged main commit. Tagging by hand is
298
+ # how v0.55.0 was burned - the tag went on the dev tip, where every
299
+ # version site still read the previous release, and the gate refused to
300
+ # publish a tag that was already public.
301
+ print()
302
+ print(f"Do NOT tag by hand. Open a pull request into main; once it merges,")
303
+ print(f"release-publish.yml creates v{version} on the merge commit and publishes.")
297
304
  return 0
298
305
  except VersionSiteError as exc:
299
306
  print(f"bump-version: {exc}", file=sys.stderr)
@@ -14,6 +14,13 @@ once. Every mismatch is reported in one pass.
14
14
  Usage:
15
15
  python scripts/check-release-version.py --expect 0.39.0
16
16
  python scripts/check-release-version.py --expect v0.39.0 # leading v is stripped
17
+ python scripts/check-release-version.py --print-canonical # the CHANGELOG version, nothing else
18
+
19
+ `--print-canonical` exists so the release workflow can derive the tag from the
20
+ commit it is standing on (ADR-042) without a second implementation of "what
21
+ version is this". It reads the same registry entry the gate above compares
22
+ against, so the tag and the gate can never disagree about where the version
23
+ lives.
17
24
  """
18
25
  from __future__ import annotations
19
26
 
@@ -40,13 +47,16 @@ def main(argv: list[str] | None = None) -> int:
40
47
  parser = argparse.ArgumentParser(description=__doc__)
41
48
  parser.add_argument(
42
49
  "--expect",
43
- required=True,
44
50
  help="Expected release version (git tag). A leading 'v' is stripped.",
45
51
  )
52
+ parser.add_argument(
53
+ "--print-canonical",
54
+ action="store_true",
55
+ help="Print the canonical CHANGELOG version and exit, comparing nothing.",
56
+ )
46
57
  args = parser.parse_args(argv)
47
- expected = args.expect.lstrip("vV").strip()
48
- if not SEMVER.match(expected):
49
- parser.error(f"not a MAJOR.MINOR.PATCH version: {args.expect!r}")
58
+ if not args.print_canonical and not args.expect:
59
+ parser.error("one of --expect or --print-canonical is required")
50
60
 
51
61
  try:
52
62
  registry = load_registry(ROOT)
@@ -54,6 +64,21 @@ def main(argv: list[str] | None = None) -> int:
54
64
  print(f"check-release-version: {exc}", file=sys.stderr)
55
65
  return 1
56
66
 
67
+ if args.print_canonical:
68
+ canonical = read_canonical(ROOT, registry)
69
+ if not canonical:
70
+ print(
71
+ "check-release-version: the CHANGELOG names no release version",
72
+ file=sys.stderr,
73
+ )
74
+ return 1
75
+ print(canonical)
76
+ return 0
77
+
78
+ expected = args.expect.lstrip("vV").strip()
79
+ if not SEMVER.match(expected):
80
+ parser.error(f"not a MAJOR.MINOR.PATCH version: {args.expect!r}")
81
+
57
82
  print(f"Expected release version: {expected}")
58
83
  canonical = read_canonical(ROOT, registry)
59
84
  mark = "ok" if canonical == expected else "MISMATCH"
@@ -263,7 +263,7 @@ def generate(
263
263
  if not path.is_file() or "__pycache__" in path.parts:
264
264
  continue
265
265
  relative = path.relative_to(output_root).as_posix()
266
- if "/hooks/bin/" in f"/{relative}" or relative in expected_set:
266
+ if relative in expected_set:
267
267
  continue
268
268
  drift.append(relative)
269
269
  if not check:
@@ -204,16 +204,13 @@ def _copilot_hook_config(manifest: dict) -> dict:
204
204
  f"--client github-copilot-cli --event {command} || true"
205
205
  ),
206
206
  "powershell": (
207
- # The native exe is opt-in via ADR_KIT_NATIVE_HOOK=1, exactly as
208
- # hooks/run-hook.cmd gates it: preferring it by default silently
209
- # narrowed governance on Windows (the host is not
210
- # parity-certified), and Copilot was the one client that did.
211
- '$native = "${PLUGIN_ROOT}/hooks/bin/windows-x64/adr-hook.exe"; '
212
- f'if ($env:ADR_KIT_NATIVE_HOOK -eq "1" -and (Test-Path $native)) '
213
- f'{{ & $native --client github-copilot-cli --event {command} }} '
214
- "else { $python = Get-Command python -ErrorAction SilentlyContinue; "
207
+ # Python is the only host (ADR-029). This branch used to prefer
208
+ # a committed Rust exe, gated behind ADR_KIT_NATIVE_HOOK=1; the
209
+ # binary was retired rather than maintained as a second
210
+ # retrieval engine, so there is nothing left to select.
211
+ "$python = Get-Command python -ErrorAction SilentlyContinue; "
215
212
  f'if ($python) {{ & $python.Source "${{PLUGIN_ROOT}}/hooks/adr-hook.py" '
216
- f"--client github-copilot-cli --event {command} }} }}; exit 0"
213
+ f"--client github-copilot-cli --event {command} }}; exit 0"
217
214
  ),
218
215
  "cwd": "${PLUGIN_ROOT}",
219
216
  "timeoutSec": runner_timeout,
@@ -47,7 +47,6 @@ HOOK_RUNTIME_FILES = (
47
47
  "hooks/adapters/claude.py",
48
48
  "hooks/adapters/codex.py",
49
49
  "hooks/adapters/copilot.py",
50
- "hooks/bin/windows-x64/adr-hook.exe",
51
50
  )
52
51
  # The modules bin/ entrypoints import from OUTSIDE bin/. Mirrored at their own
53
52
  # relative paths, because bin/adr-doctor resolves them by appending ROOT and
@@ -1,4 +1,4 @@
1
- <!-- adr-kit-guide v0.54.0 -->
1
+ <!-- adr-kit-guide v0.56.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
 
@@ -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.54.0",
5
+ "_wrapper_version": "0.56.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.54.0"
55
+ ADR_KIT_WRAPPER_VERSION="0.56.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
@@ -13,6 +13,6 @@ jobs:
13
13
  - uses: actions/checkout@v4
14
14
  with:
15
15
  fetch-depth: 0
16
- - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.37.0
16
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.56.0
17
17
  with:
18
18
  adr-dir: docs/adr