@rvdbreemen/adr-kit-opencode 0.61.0 → 0.61.1

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.61.0",
4
+ "version": "0.61.1",
5
5
  "author": {
6
6
  "name": "Robert van den Breemen",
7
7
  "url": "https://github.com/rvdbreemen"
package/README.md CHANGED
@@ -333,7 +333,7 @@ For another project, use the published package:
333
333
  ```json
334
334
  {
335
335
  "$schema": "https://opencode.ai/config.json",
336
- "plugin": ["@rvdbreemen/adr-kit-opencode@0.61.0"]
336
+ "plugin": ["@rvdbreemen/adr-kit-opencode@0.61.1"]
337
337
  }
338
338
  ```
339
339
 
@@ -721,7 +721,7 @@ directly after a full-history checkout:
721
721
  - uses: actions/checkout@v4
722
722
  with:
723
723
  fetch-depth: 0
724
- - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.61.0
724
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.61.1
725
725
  with:
726
726
  adr-dir: docs/adr
727
727
  ```
@@ -749,7 +749,7 @@ jobs:
749
749
  - uses: actions/checkout@v4
750
750
  with:
751
751
  fetch-depth: 0 # both sides of the diff must be available
752
- - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.61.0
752
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.61.1
753
753
  with:
754
754
  adr-dir: docs/adr/
755
755
  ```
@@ -763,7 +763,7 @@ The action also takes `max-diff-bytes` (default 32 MiB, available from the relea
763
763
  ```yaml
764
764
  repos:
765
765
  - repo: https://github.com/rvdbreemen/adr-kit
766
- rev: v0.61.0
766
+ rev: v0.61.1
767
767
  hooks:
768
768
  - id: adr-judge
769
769
  ```
package/bin/adr CHANGED
@@ -1110,24 +1110,16 @@ def command_relate(args) -> List[str]:
1110
1110
  verb = "not related" if args.remove else "already related"
1111
1111
  return [f"{left_id} and {right_id} are {verb}; nothing to do"]
1112
1112
 
1113
- # The signer is resolved once, before any write, so a machine with no
1114
- # configured signer refuses the whole operation instead of half of it.
1115
- changed_by = resolve_signer(adr_dir, args.changed_by)
1116
- action = "Unrelated" if args.remove else "Related"
1113
+ # Only the frontmatter changes. A cross-reference is not a status transition,
1114
+ # so nothing goes into status_history: an entry here was signed with the
1115
+ # machine signer for an edit that person did not make, and on a record with no
1116
+ # Status History it first invented one, with a "recovered" entry (TASK-243).
1117
+ # With no history entry there is no actor to sign, so no signer is resolved.
1117
1118
  changes: List[Tuple[Path, str]] = []
1118
- for path, data, body, other_id in (
1119
- (left_path, left_data, left_body, right_id),
1120
- (right_path, right_data, right_body, left_id),
1119
+ for path, data, body in (
1120
+ (left_path, left_data, left_body),
1121
+ (right_path, right_data, right_body),
1121
1122
  ):
1122
- body = ensure_status_history(path, data, body, (str(data.get("status")), args.date))
1123
- body = append_status_history(
1124
- body,
1125
- str(data.get("status")),
1126
- changed_by,
1127
- args.reason or f"{action} to {other_id}",
1128
- "adr-kit lifecycle",
1129
- args.date,
1130
- )
1131
1123
  changes.append((path, render_frontmatter(data) + body))
1132
1124
  _commit_lifecycle_changes(adr_dir, changes)
1133
1125
  joiner = "no longer related to" if args.remove else "related to"
@@ -1603,7 +1595,11 @@ def build_parser() -> argparse.ArgumentParser:
1603
1595
 
1604
1596
  relate = sub.add_parser(
1605
1597
  "relate",
1606
- help="record a cross-reference between two ADRs on both sides at once",
1598
+ help=(
1599
+ "record a cross-reference between two ADRs on both sides at once; it "
1600
+ "changes only the related frontmatter, so --changed-by, --reason and "
1601
+ "--date are accepted and ignored"
1602
+ ),
1607
1603
  )
1608
1604
  relate.add_argument("adr")
1609
1605
  relate.add_argument("--to", required=True, help="the other ADR id")
package/bin/adr-lint CHANGED
@@ -305,7 +305,7 @@ def load_config(path: Optional[Path]) -> Dict:
305
305
  )
306
306
 
307
307
  sf = cfg.get("strict_from")
308
- if sf is not None and not re.match(r"^ADR-\d{3}$", sf):
308
+ if sf is not None and (not isinstance(sf, str) or not re.fullmatch(r"ADR-\d{3}", sf)):
309
309
  raise PolicyError(
310
310
  f"{path}: strict_from={sf!r} does not match pattern ADR-NNN"
311
311
  )
@@ -370,9 +370,10 @@ def severity_of(
370
370
  ) -> str:
371
371
  """Return 'FAIL' or 'ADVISORY' for a gate failure, given the policy."""
372
372
  sf_id = strict_from_override or cfg.get("strict_from")
373
- sf_num = (
374
- int(re.match(r"ADR-(\d+)", sf_id).group(1)) if sf_id else None
375
- )
373
+ match = re.fullmatch(r"ADR-(\d+)", sf_id) if isinstance(sf_id, str) else None
374
+ if sf_id is not None and match is None:
375
+ raise PolicyError(f"strict_from={sf_id!r} does not match pattern ADR-NNN")
376
+ sf_num = int(match.group(1)) if match else None
376
377
  sev = cfg.get("severity", {})
377
378
  default = "advisory_before_strict_from" if sf_id and gate != "consistency" else "always_strict"
378
379
  s = sev.get(gate, default)
@@ -2083,6 +2084,8 @@ def main(argv: Optional[List[str]] = None) -> int:
2083
2084
  "--version", action="version", version="adr-lint 0.15.0",
2084
2085
  )
2085
2086
  args = parser.parse_args(argv)
2087
+ if args.strict_from is not None and not re.fullmatch(r"ADR-\d+", args.strict_from):
2088
+ parser.error("--strict-from must be an ADR id (for example, ADR-100)")
2086
2089
 
2087
2090
  target = Path(args.path)
2088
2091
  if not target.exists():
@@ -317,6 +317,26 @@ def _guidance_check(root: Path) -> dict:
317
317
  )
318
318
 
319
319
 
320
+ def _vendored_lint_check(root: Path, plugin_root: Path) -> dict[str, Any] | None:
321
+ local = root / "bin" / "adr-lint"
322
+ bundled = plugin_root / "bin" / "adr-lint"
323
+ if not local.is_file() or not bundled.is_file() or local == bundled:
324
+ return None
325
+ try:
326
+ local_source = local.read_bytes().replace(b"\r\n", b"\n")
327
+ bundled_source = bundled.read_bytes().replace(b"\r\n", b"\n")
328
+ except OSError:
329
+ return None
330
+ if local_source == bundled_source:
331
+ return None
332
+ return check(
333
+ "vendored-adr-lint", status="degraded", required=False,
334
+ summary="project bin/adr-lint differs from the bundled ADR Kit copy",
335
+ evidence=[{"project": str(local), "bundled": str(bundled)}],
336
+ actions=[{"detail": f"Use the bundled linter at {bundled} or review and update the project copy."}],
337
+ )
338
+
339
+
320
340
  def run_client_checks(
321
341
  root: Path,
322
342
  plugin_root: Path,
@@ -329,6 +349,9 @@ def run_client_checks(
329
349
  generated, generated_repairs = _generated_check(plugin_root, check_only)
330
350
  checks.append(generated)
331
351
  repairs.extend(generated_repairs)
352
+ vendored_lint = _vendored_lint_check(root, plugin_root)
353
+ if vendored_lint:
354
+ checks.append(vendored_lint)
332
355
  try:
333
356
  settings = resolve_settings(root, global_path=global_settings)["values"]
334
357
  checks.append(check(
@@ -19,6 +19,7 @@ import hashlib
19
19
  import json
20
20
  import os
21
21
  import re
22
+ import shlex
22
23
  import tempfile
23
24
  import sys
24
25
  from dataclasses import dataclass
@@ -230,12 +231,13 @@ def duplicate_event(envelope: Envelope) -> bool:
230
231
  return False
231
232
 
232
233
 
234
+ def _adr_dirs(workspace: Path) -> tuple[Path, Path]:
235
+ return workspace / "docs" / "adr", workspace / "adr"
236
+
237
+
233
238
  def _index_path(workspace: Path) -> Path | None:
234
- candidates = (
235
- workspace / "docs" / "adr" / "ADR-INDEX.json",
236
- workspace / "adr" / "ADR-INDEX.json",
237
- )
238
- for path in candidates:
239
+ for adr_dir in _adr_dirs(workspace):
240
+ path = adr_dir / "ADR-INDEX.json"
239
241
  if path.is_file():
240
242
  return path
241
243
  return None
@@ -515,11 +517,21 @@ REFRESHING_EVENTS = {"SessionStart", "UserPromptSubmit"}
515
517
 
516
518
  STALE_INDEX_MESSAGE = (
517
519
  "The generated ADR index is stale, so ADR context is unavailable for this "
518
- "step. Run `bin/adr-index docs/adr` to regenerate it."
520
+ "step."
519
521
  )
520
522
 
521
523
 
522
- def index_is_stale(workspace: Path) -> bool:
524
+ def stale_index_message(adr_dir: Path) -> str:
525
+ args = (Path(sys.executable), _BIN_DIR / "adr-index", adr_dir)
526
+ if os.name == "nt":
527
+ quoted = ("'" + path.as_posix().replace("'", "''") + "'" for path in args)
528
+ command = "& " + " ".join(quoted)
529
+ return f"{STALE_INDEX_MESSAGE} Run in PowerShell to regenerate it: `{command}`."
530
+ command = shlex.join(str(path) for path in args)
531
+ return f"{STALE_INDEX_MESSAGE} Run to regenerate it: `{command}`."
532
+
533
+
534
+ def _stale_index_dir(workspace: Path) -> Path | None:
523
535
  """Cheap precondition, ~2.8 ms measured, not a certification.
524
536
 
525
537
  `index_probably_fresh` is an mtime comparison and says so in its own
@@ -527,15 +539,14 @@ def index_is_stale(workspace: Path) -> bool:
527
539
  treats a false negative as "read what is there", which is what it would have
528
540
  done anyway.
529
541
  """
530
- index = _index_path(workspace)
531
- if index is None:
532
- return False
533
542
  try:
534
543
  from adr_index_core import index_probably_fresh
535
544
 
536
- return not index_probably_fresh(index.parent)
545
+ index = _index_path(workspace)
546
+ candidates = (index.parent,) if index is not None else _adr_dirs(workspace)
547
+ return next((path for path in candidates if not index_probably_fresh(path)), None)
537
548
  except (ImportError, OSError, ValueError):
538
- return False
549
+ return None
539
550
 
540
551
 
541
552
  def refresh_index(workspace: Path, event: str) -> str:
@@ -550,22 +561,19 @@ def refresh_index(workspace: Path, event: str) -> str:
550
561
  inside a fail-open hook, and a governance tool that breaks a session is
551
562
  worse than one that asks for a command to be run.
552
563
  """
553
- if not index_is_stale(workspace):
564
+ adr_dir = _stale_index_dir(workspace)
565
+ if adr_dir is None:
554
566
  return ""
567
+ notice = stale_index_message(adr_dir)
555
568
  if event not in REFRESHING_EVENTS:
556
569
  # The edit tier reads only. Rendering there would put a write on the
557
570
  # path taken before every single edit.
558
- return STALE_INDEX_MESSAGE
559
-
560
- index = _index_path(workspace)
561
- if index is None:
562
- return STALE_INDEX_MESSAGE
563
- adr_dir = index.parent
571
+ return notice
564
572
 
565
573
  try:
566
574
  from adr_index_core import projected_render_ms, regenerate_index
567
575
  except ImportError:
568
- return STALE_INDEX_MESSAGE
576
+ return notice
569
577
 
570
578
  budget_ms = _event_budget_ms(event)
571
579
  projected = projected_render_ms(adr_dir)
@@ -573,7 +581,7 @@ def refresh_index(workspace: Path, event: str) -> str:
573
581
  # A large ADR set degrades to a nudge rather than to a timeout. The
574
582
  # client kills the hook at its own bound, and a process killed mid-write
575
583
  # is worse than one that never started.
576
- return STALE_INDEX_MESSAGE
584
+ return notice
577
585
 
578
586
  lock = adr_dir / ".adr-index.lock"
579
587
  try:
@@ -583,16 +591,16 @@ def refresh_index(workspace: Path, event: str) -> str:
583
591
  # Another session is rendering. Read what is there and continue -- ADR-021
584
592
  # forbids waiting, because the loser would spend a budget it cannot
585
593
  # recover on work someone else is already doing.
586
- return STALE_INDEX_MESSAGE
594
+ return notice
587
595
  except OSError:
588
- return STALE_INDEX_MESSAGE
596
+ return notice
589
597
 
590
598
  try:
591
599
  os.close(handle)
592
600
  regenerate_index(adr_dir)
593
601
  return ""
594
602
  except (OSError, ValueError, KeyError, TypeError):
595
- return STALE_INDEX_MESSAGE
603
+ return notice
596
604
  finally:
597
605
  try:
598
606
  lock.unlink()
@@ -1,4 +1,4 @@
1
- <!-- adr-kit-guide v0.61.0 -->
1
+ <!-- adr-kit-guide v0.61.1 -->
2
2
  <!-- Generated ADR Kit guidance. Local additions belong in .adr-kit/ADR-guide.local.md. -->
3
3
 
4
4
  # ADR Kit agent guide
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rvdbreemen/adr-kit-opencode",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
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",
@@ -144,12 +144,21 @@ def _runner_timeout(event: dict) -> int:
144
144
 
145
145
 
146
146
  def _codex_windows_command(event: dict) -> str:
147
- """Run Codex hooks fail-open when its plugin-root env is unavailable."""
147
+ """Launch through either Codex's PowerShell pipeline or its cmd fallback."""
148
+ root = "[Environment]::GetEnvironmentVariable('PLUGIN_ROOT')"
149
+ wrapper = f"(Join-Path ({root}) 'hooks/run-hook.cmd')"
150
+ # Keep control operators inside the quoted -Command argument. Avoid dollar
151
+ # variables so an outer PowerShell passes the command through unchanged.
152
+ # Read and forward the JSON line explicitly: native children do not always
153
+ # inherit redirected stdin on Windows. Windows PowerShell can prefix the
154
+ # line with a BOM, which the Python hook's UTF-8 decoder expects to be absent.
148
155
  return (
149
- "cmd.exe /d /c if defined PLUGIN_ROOT if exist "
150
- '"%PLUGIN_ROOT%\\hooks\\run-hook.cmd" '
151
- 'call "%PLUGIN_ROOT%\\hooks\\run-hook.cmd" '
152
- f'{event["command"]} codex-cli & exit /b 0'
156
+ 'powershell.exe -NoProfile -NonInteractive -Command "'
157
+ f"if (({root}) -and (Test-Path -LiteralPath {wrapper} -PathType Leaf)) "
158
+ "{ [Console]::InputEncoding = [Text.UTF8Encoding]::new(); "
159
+ "Set-Variable -Name OutputEncoding -Value ([Text.UTF8Encoding]::new()); "
160
+ "([string][Console]::In.ReadLine()).TrimStart([char]0xFEFF) | "
161
+ f'& {wrapper} {event["command"]} codex-cli }}; exit 0"'
153
162
  )
154
163
 
155
164
 
@@ -1,4 +1,4 @@
1
- <!-- adr-kit-guide v0.61.0 -->
1
+ <!-- adr-kit-guide v0.61.1 -->
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.61.0",
5
+ "_wrapper_version": "0.61.1",
6
6
  "type": "command",
7
7
  "command": "_PY=$(command -v python3 || command -v python || command -v py) && [ -n \"$_PY\" ] && ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ 2>/dev/null | \"$_PY\" -c 'import re, sys; d = [l.strip() for l in sys.stdin if l.strip()]; k = lambda p: [int(x) for x in re.findall(r\"\\d+\", p.rstrip(\"/\").rsplit(\"/\", 1)[-1])]; sys.stdout.write(max(d, key=k) if d else \"\")' 2>/dev/null) && [ -n \"$ADR_KIT\" ] && \"$_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.61.0"
55
+ ADR_KIT_WRAPPER_VERSION="0.61.1"
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
@@ -25,6 +25,6 @@ jobs:
25
25
  runs-on: ubuntu-latest
26
26
  steps:
27
27
  - uses: actions/checkout@v4
28
- - uses: rvdbreemen/adr-kit/.github/actions/adr-index-check@v0.61.0
28
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-index-check@v0.61.1
29
29
  with:
30
30
  adr-dir: docs/adr
@@ -22,7 +22,7 @@ jobs:
22
22
  - uses: actions/checkout@v4
23
23
  with:
24
24
  fetch-depth: 0
25
- - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.61.0
25
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-judge@v0.61.1
26
26
  with:
27
27
  adr-dir: docs/adr/
28
28
  # A release-sized branch diff needs more room than a single commit.
@@ -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.61.0
16
+ - uses: rvdbreemen/adr-kit/.github/actions/adr-readiness@v0.61.1
17
17
  with:
18
18
  adr-dir: docs/adr