@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,273 +1,273 @@
1
- ---
2
- name: upgrade
3
- description: "Upgrade ADR Kit project artifacts and legacy layouts. Use after a plugin update, for stale wrappers, guide refresh, or migration."
4
- argument-hint: "[no arguments]"
5
- disable-model-invocation: true
6
- allowed-tools: [Read, Write, Edit, Bash, Task]
7
- ---
8
-
9
- # adr-kit upgrade
10
-
11
- This is the **upgrade** mode of `/adr-kit:setup` (spec R19: one entry point,
12
- four modes). Invoked directly or via `/adr-kit:setup upgrade`, the procedure
13
- is identical -- this file owns it.
14
-
15
- `$ARGUMENTS` should be empty. Stop for confirmation before any breaking
16
- migration or backup-backed rewrite.
17
-
18
- You bring a project's **installed adr-kit artifacts** in line with the **installed plugin version**. Two jobs, run in order:
19
-
20
- 1. **Artifact refresh (any version, the common case).** Plugin-level hooks refresh automatically when the plugin updates, but artifacts copied into the project freeze at install time: the git pre-commit wrapper, the project-scoped guardian entry in `.claude/settings.json`, and `.claude/adr-kit-guide.md`. Step 0 detects and refreshes them.
21
- 2. **Legacy footprint migration (v0.11 to v0.12, one-time).** Steps 1-4 below. Skip them when the project is already on the v0.12 footprint.
22
-
23
- If the project has no ADRs yet, point the user to `/adr-kit:init` instead.
24
-
25
- After resolving `ADR_KIT` in Step 0 and before refreshing artifacts, run
26
- format discovery:
27
-
28
- ```bash
29
- python3 "$ADR_KIT/bin/adr-migrate" --plan docs/adr/
30
- ```
31
-
32
- Report every migration notice. Do not apply any migration during upgrade.
33
- Supported legacy records receive a deterministic dry-run command; external,
34
- hybrid, or ambiguous formats receive `/adr-kit:migrate <path>` guidance.
35
- Continue the artifact upgrade regardless of whether notices exist.
36
-
37
- ## Step 0 — Artifact freshness check and refresh
38
-
39
- Resolve the plugin path and run the detector:
40
-
41
- ```bash
42
- ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ | sort -V | tail -1)
43
- python3 "$ADR_KIT/bin/adr-guardian" artifacts --format json
44
- ```
45
-
46
- The report lists each copied artifact with its embedded version stamp and a `stale` flag (the guardian SessionStart nudge uses the same detection, so this is the same signal that brought most users here). For each stale artifact:
47
-
48
- - **`git-pre-commit-wrapper`** (`.githooks/pre-commit` or `.git/hooks/pre-commit`): overwrite it with the current `$ADR_KIT/templates/githooks/pre-commit` (same target path it already occupies). Show a unified diff first when the installed wrapper differs from any shipped template version (the user may have local edits); ask `replace | keep | merge by hand` only in that case, otherwise replace silently. Preserve the executable bit.
49
- - **`settings-guardian-entry`** (`.claude/settings.json`): replace the guardian hook entry with the current `$ADR_KIT/templates/cc-settings/guardian-hook-entry.json` content using JSON-structural editing (never clobber sibling hooks; same posture as `/adr-kit:install-hooks`).
50
- - **`.claude/adr-kit-guide.md`**: if its version line (first line, `<!-- adr-kit-guide vX.Y.Z -->`) lags the plugin, refresh it from `$ADR_KIT/templates/adr-kit-guide.md` (diff-and-ask when the project copy has local edits, like Step 2 below).
51
-
52
- When the report shows no stale artifacts AND the project is already on the v0.12 footprint, exit with `everything up to date; nothing to do`.
53
-
54
- Artifacts the plugin cannot refresh from here (report them, do not edit): GitHub Action pins (`uses: ...adr-judge@vX` in workflows; suggest a Dependabot/Renovate rule or a manual bump) and a `pre-commit` framework `rev:` (suggest `pre-commit autoupdate`).
55
-
56
- ## Step 1 — Detect the installed footprint
57
-
58
- Inspect the current state:
59
-
60
- - `CLAUDE.md` exists? Read it. Look for a v0.11-style `## ADR Kit Rules` section (free-form heading, no markers) OR a v0.12 `<!-- ADR-KIT STUB START -->` block (markers).
61
- - `docs/adr/` exists? Count `ADR-*.md` files. Scan for any existing `## Enforcement` blocks and tally them.
62
- - `.githooks/pre-commit` exists?
63
- - `.claude/adr-kit-guide.md` exists? If yes, check the version line (first line of the plugin template is `<!-- adr-kit-guide vX.Y.Z -->`).
64
-
65
- Report the detected state to the user in a 4–6 line summary before changing anything.
66
-
67
- If all of the following are true, the project is already on v0.12:
68
- - CLAUDE.md has the marker-bracketed stub
69
- - `.claude/adr-kit-guide.md` matches the plugin's current version
70
- - `.githooks/pre-commit` is the adr-kit hook
71
- - All Accepted ADRs either have `## Enforcement` blocks or have been explicitly skipped
72
-
73
- If so, exit with `already on v0.12; nothing to do`.
74
-
75
- ## Step 2 — Refresh CLAUDE.md stub + guide file
76
-
77
- Resolve the plugin path:
78
-
79
- ```bash
80
- ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ | sort -V | tail -1)
81
- ```
82
-
83
- Three migration paths for `CLAUDE.md`:
84
-
85
- - **v0.11 inline `## ADR Kit Rules` section present.** Replace the entire section (heading through the next `## ` heading, or EOF) with the v0.12 stub:
86
- ```markdown
87
- <!-- ADR-KIT STUB START -->
88
- <!-- DO NOT regenerate manually. Updated by `/adr-kit:init`, `/adr-kit:upgrade`, `/adr-kit:setup`. -->
89
- ## ADR Kit
90
-
91
- This project uses [adr-kit](https://github.com/rvdbreemen/adr-kit). All architectural decisions live as ADRs in `docs/adr/`. Full guide: @.claude/adr-kit-guide.md
92
-
93
- Authoring: `/adr-kit:adr` (or the `adr-generator` subagent).
94
- Pre-commit verification: `bin/adr-judge` runs declarative `Enforcement` rules at commit time. ADRs with `llm_judge: true` are reviewed in-session via `/adr-kit:judge`.
95
- <!-- ADR-KIT STUB END -->
96
- ```
97
- Surrounding content (everything outside the section) stays byte-exact. Verify by diff after the edit.
98
-
99
- - **v0.12 stub already present.** Replace just the contents between the markers with the current stub text. Idempotent.
100
-
101
- - **No ADR-kit footprint.** Append the v0.12 stub at the end of `CLAUDE.md`, with one blank line of separation.
102
-
103
- For `.claude/adr-kit-guide.md`:
104
-
105
- - If absent: create it from `$ADR_KIT/templates/adr-kit-guide.md`.
106
- - If present and byte-identical to the plugin template: no-op.
107
- - If present and differs: read both, show a unified diff (3 context lines), ask the user `keep project version | replace with plugin version | merge by hand`. Apply.
108
-
109
- ## Step 3 — Install the pre-commit hook (default-on)
110
-
111
- Delegate to `/adr-kit:install-hooks` (or do its work inline if delegation is awkward). Same logic as that skill — detect existing hook, prepend / replace / abort, set `core.hooksPath`. **Do not prompt for installation itself; the hook is default-on as of v0.12.** If the user wants to opt out, they can disable per-commit with `ADR_KIT_HOOK_DISABLE=1` or remove via `/adr-kit:install-hooks --uninstall`.
112
-
113
- ## Step 4 — Enforcement-block backfill (the only slow step)
114
-
115
- For every `Status: Accepted` ADR in `docs/adr/` that does NOT already have a `## Enforcement` section, propose one. Walk them one at a time (not batched) — each proposal needs the ADR's full Decision/Context to make a judgement, and the user's input is per-ADR.
116
-
117
- For each ADR:
118
-
119
- 1. Read the ADR. Summarise its Decision in one line.
120
- 2. Decide which of three categories it falls into:
121
- - **Declarative.** The rule is mechanically expressible. Examples: "no String class in hot paths" → `forbid_pattern: \\bString\\b ... in src/**`; "use addOTWGcmdtoqueue() for OTGW commands" → `require_pattern: addOTWGcmdtoqueue\\(`.
122
- - **LLM-judgeable.** The rule is too nuanced for regex but a model can read the diff and decide. Set `llm_judge: true`.
123
- - **Manual review only.** No code surface (e.g., a process or governance ADR). Suggest the user add `<!-- adr-kit-judge: skip -->` near the heading, or simply omit the Enforcement block (the judge skips ADRs without one).
124
- 3. Print: `[ADR-NNN] <one-line title> → proposed category: <declarative | llm-judge | manual>; proposed block:` and show the JSON.
125
- 4. Ask the user: `accept | edit | skip this ADR | skip rest`.
126
- - `accept`: Edit the ADR file, append the `## Enforcement` section.
127
- - `edit`: Show the user the proposal, let them edit it inline; apply when satisfied.
128
- - `skip this ADR`: leave it alone.
129
- - `skip rest`: stop the backfill loop entirely.
130
-
131
- Do NOT modify any other section of the ADR. Only append the new `## Enforcement` section. Accepted ADRs are otherwise immutable.
132
-
133
- ## Step 4b — LLM judge: opt-out migration (ask before writing)
134
-
135
- `llm_judge` defaults to **true** as of TASK-74. ADRs written before that carry an explicit `"llm_judge": false` that is indistinguishable from a deliberate refusal, so the upgrade proposes turning them on — and the user gets the chance to decline.
136
-
137
- Run the deterministic scan first. It writes nothing:
138
-
139
- ```bash
140
- python3 "$ADR_KIT/bin/adr-migrate" docs/adr/ --enable-llm-judge --dry-run --format json
141
- ```
142
-
143
- The result has three lists — `enabled` (what would be turned on), `opted_out` (rule-less blocks the scan proposes to mark as having no code surface), and `unchanged` — plus a `summary` carrying the two numbers that decide this step: `judged_after` (how many ADRs the LLM pass evaluates once the migration lands) and `unbounded_after` (how many of those declare no `path_glob`).
144
-
145
- **Then ask the user, once, with the whole picture in front of them.** Show:
146
-
147
- - **the `summary` totals first.** The `enabled` list is only this run's delta; on an upgraded repository the dominant cost sits in ADRs that are already on. A dry-run reading "6 enabled, 0 unbounded" has been accepted on a set that ended at 64 unscoped of 68 judged, which at the measured 20–28 s per isolated call is ~25 minutes of blocking per commit;
148
- - how many ADRs would be enabled, and for each one its id, its one-line Decision and its rule count;
149
- - which ADRs carry `unbounded_scope: true` — those have no `path_glob` to narrow with, so enabling them costs a model call on **every** commit, not only on commits that touch their area;
150
- - which ADRs the scan proposes to mark as no-code-surface, and why.
151
-
152
- Offer these answers:
153
-
154
- - **accept all** (the default) — apply as proposed.
155
- - **opt out of specific ADRs** — name them; each needs a reason, which is written into the ADR as `llm_judge_reason` so no later upgrade re-proposes it.
156
- - **enable a rule-less ADR anyway** — name it under `--force-enable`; say plainly that this means one call per commit until the ADR declares a scope.
157
- - **skip entirely** — change nothing; the next upgrade will ask again.
158
-
159
- Apply the answer:
160
-
161
- ```bash
162
- python3 "$ADR_KIT/bin/adr-migrate" docs/adr/ --enable-llm-judge \
163
- --except ADR-006,ADR-011 --reason "reviewed manually in the release checklist" \
164
- --force-enable ADR-014
165
- ```
166
-
167
- Report exactly which ADRs were enabled and which were left off. State the cost shape in the same breath, and state it for the whole set: a commit makes one isolated call per scoped ADR whose `path_glob` the diff touches, **plus one call for every unscoped ADR regardless of the diff**. "A commit outside every scope makes none" holds only when `unbounded_after` is zero.
168
-
169
- Re-running the command after this is a no-op and says so.
170
-
171
- ## Step 4b² — Make the pass runnable, and decide where it runs
172
-
173
- Enabling `llm_judge` on ADRs configures what SHOULD be judged; it does not make the judge able to run, and it does not decide where the cost lands. An upgrade that stops here can leave a project whose pass degrades silently on every commit, or one whose commits block for half an hour. Finish both halves:
174
-
175
- **1. The host client.** Read the effective configuration:
176
-
177
- ```bash
178
- python3 "$ADR_KIT/bin/adr-judge" --show-config
179
- ```
180
-
181
- - Retired keys present (`judge.llm_cmd`, `judge.llm_model`, `judge.openrouter_model`, `judge.ollama_model`, `judge.openai_model`) → config validation refuses each by name and says what replaced it (ADR-036). Have the user delete the keys from `.adr-kit.json`; no command edits a file that carries them.
182
- - No recorded client → record it now rather than leaving it to the first degraded commit:
183
-
184
- ```bash
185
- python3 "$ADR_KIT/bin/adr-judge" --set-backend host --host-client claude-code-cli
186
- ```
187
-
188
- The host model is the only backend (ADR-036); operators can override one run with `ADR_KIT_LLM_CMD` / `--llm-cmd`.
189
-
190
- **2. The cadence.** Take `unbounded_after` from Step 4b's summary and put the multiplication in front of the user: `unbounded_after × ~20 s` is what every commit will block, sequentially, because the pass makes one isolated call per ADR. Two honest configurations exist:
191
-
192
- - `unbounded_after` is small (a handful): per-commit judging is affordable; leave `judge.llm_enabled` on.
193
- - `unbounded_after` is large: per-commit judging is not viable, and no faster model fixes a per-ADR multiplier. Offer `judge.llm_enabled: false` (the declarative pass keeps blocking, at milliseconds) with the **guardian llm tier** as the semantic cadence — `guardian.llm_stale_days` in `docs/adr/.adr-kit.json` (default 14; 7 for a weekly pass) makes the SessionStart nudge raise it when due, cost-gated by `guardian.llm_autorun: false`.
194
-
195
- Record the choice in the wrap-up so the next reader of `.adr-kit.json` sees a decision, not an accident.
196
-
197
- ## Step 4c — The signer: propose, never assume
198
-
199
- Every lifecycle command writes a Status History entry naming who decided, and it
200
- refuses to sign on the user's behalf. That refusal is right, and it should not be
201
- the user's first experience of the tool.
202
-
203
- ```bash
204
- python3 "$ADR_KIT/bin/adr" signer --suggest --adr-dir docs/adr
205
- ```
206
-
207
- Read-only: it finds candidates and writes nothing. It looks at the signed-in
208
- GitHub account (`gh api user`, when the CLI is available) and at
209
- `git config user.name`, ranks them, and shows each with its source — a proposal
210
- the user cannot trace is one they cannot judge, and this value lands in an
211
- immutable history.
212
-
213
- - **Candidates found** — show them and ask which to adopt, or let the user type a
214
- different name. Then write it:
215
- `python3 "$ADR_KIT/bin/adr" signer --set "User: <chosen>"`.
216
- - **Already configured** — say so and move on. Do not overwrite it.
217
- - **Nothing found** — the GitHub CLI is absent or signed out and git names nobody
218
- usable. Ask for the name outright rather than guessing.
219
-
220
- **Bot and CI identities are deliberately not offered.** `github-actions[bot]`,
221
- `runner`, a bare `user`: those are configured values that name a machine, and
222
- R8 asks for evidence of which *human* accepted a decision.
223
-
224
- The value is machine-local by design (`docs/adr/.adr-kit.local.json`, gitignored)
225
- because writing one person's name into the tracked config would sign every
226
- teammate's acceptances. Each machine, container and CI runner needs its own.
227
-
228
- ## Step 5 — Final lint
229
-
230
- ```bash
231
- "$ADR_KIT/bin/adr-lint" docs/adr/
232
- ```
233
-
234
- Report the result. Then optionally run a no-op judge to confirm hook plumbing:
235
-
236
- ```bash
237
- echo "" | "$ADR_KIT/bin/adr-judge" --diff - --adr-dir docs/adr/
238
- ```
239
-
240
- Should exit 0 with `OK — 0 violations, 0 advisory`.
241
-
242
- ## Wrap-up
243
-
244
- Print the final summary:
245
-
246
- ```
247
- adr-kit upgrade complete:
248
- - CLAUDE.md: <unchanged | refreshed | migrated from v0.11>
249
- - guide: .claude/adr-kit-guide.md (created | refreshed | unchanged)
250
- - hook: <installed | already present>
251
- - backfill: <N> ADRs got declarative rules, <M> got llm_judge:true, <K> skipped, <Q> already had Enforcement
252
- - lint: <P> PASS, <A> ADVISORY, <F> FAIL
253
- - formats: <N> deterministic migration notices, <M> guided notices; 0 auto-migrated
254
- - judge: backend <name | none>, <judged_after> ADRs judged, <unbounded_after> unscoped;
255
- cadence <per-commit | guardian llm tier every <D>d | declarative-only>
256
- ```
257
-
258
- Suggest a commit:
259
-
260
- ```bash
261
- git add CLAUDE.md .claude/adr-kit-guide.md .githooks/pre-commit docs/adr/
262
- git commit -m "chore(adr-kit): upgrade to v0.12"
263
- ```
264
-
265
- Do not run the commit yourself.
266
-
267
- ## Constraints
268
-
269
- - **Per-ADR backfill is opt-in.** Never silently rewrite ADR contents. Each proposal is shown, the user accepts/edits/skips.
270
- - **Surrounding CLAUDE.md content stays byte-exact.** Only the marked stub block (or v0.11 `## ADR Kit Rules` section being replaced) may change.
271
- - **Re-runnable.** A second invocation should detect "already on v0.12" and exit cleanly.
272
- - **No new ADRs.** This skill never invokes `adr-generator`. New ADRs come from `/adr-kit:init` (first-time bootstrap) or `/adr-kit:adr` (on-demand authoring).
273
- - **Default-on hook.** Don't prompt for hook installation as if it were optional. The opt-out path is `--uninstall`, not pre-install consent.
1
+ ---
2
+ name: upgrade
3
+ description: "Upgrade ADR Kit project artifacts and legacy layouts. Use after a plugin update, for stale wrappers, guide refresh, or migration."
4
+ argument-hint: "[no arguments]"
5
+ disable-model-invocation: true
6
+ allowed-tools: [Read, Write, Edit, Bash, Task]
7
+ ---
8
+
9
+ # adr-kit upgrade
10
+
11
+ This is the **upgrade** mode of `/adr-kit:setup` (spec R19: one entry point,
12
+ four modes). Invoked directly or via `/adr-kit:setup upgrade`, the procedure
13
+ is identical -- this file owns it.
14
+
15
+ `$ARGUMENTS` should be empty. Stop for confirmation before any breaking
16
+ migration or backup-backed rewrite.
17
+
18
+ You bring a project's **installed adr-kit artifacts** in line with the **installed plugin version**. Two jobs, run in order:
19
+
20
+ 1. **Artifact refresh (any version, the common case).** Plugin-level hooks refresh automatically when the plugin updates, but artifacts copied into the project freeze at install time: the git pre-commit wrapper, the project-scoped guardian entry in `.claude/settings.json`, and `.claude/adr-kit-guide.md`. Step 0 detects and refreshes them.
21
+ 2. **Legacy footprint migration (v0.11 to v0.12, one-time).** Steps 1-4 below. Skip them when the project is already on the v0.12 footprint.
22
+
23
+ If the project has no ADRs yet, point the user to `/adr-kit:init` instead.
24
+
25
+ After resolving `ADR_KIT` in Step 0 and before refreshing artifacts, run
26
+ format discovery:
27
+
28
+ ```bash
29
+ python3 "$ADR_KIT/bin/adr-migrate" --plan docs/adr/
30
+ ```
31
+
32
+ Report every migration notice. Do not apply any migration during upgrade.
33
+ Supported legacy records receive a deterministic dry-run command; external,
34
+ hybrid, or ambiguous formats receive `/adr-kit:migrate <path>` guidance.
35
+ Continue the artifact upgrade regardless of whether notices exist.
36
+
37
+ ## Step 0 — Artifact freshness check and refresh
38
+
39
+ Resolve the plugin path and run the detector:
40
+
41
+ ```bash
42
+ ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ | sort -V | tail -1)
43
+ python3 "$ADR_KIT/bin/adr-guardian" artifacts --format json
44
+ ```
45
+
46
+ The report lists each copied artifact with its embedded version stamp and a `stale` flag (the guardian SessionStart nudge uses the same detection, so this is the same signal that brought most users here). For each stale artifact:
47
+
48
+ - **`git-pre-commit-wrapper`** (`.githooks/pre-commit` or `.git/hooks/pre-commit`): overwrite it with the current `$ADR_KIT/templates/githooks/pre-commit` (same target path it already occupies). Show a unified diff first when the installed wrapper differs from any shipped template version (the user may have local edits); ask `replace | keep | merge by hand` only in that case, otherwise replace silently. Preserve the executable bit.
49
+ - **`settings-guardian-entry`** (`.claude/settings.json`): replace the guardian hook entry with the current `$ADR_KIT/templates/cc-settings/guardian-hook-entry.json` content using JSON-structural editing (never clobber sibling hooks; same posture as `/adr-kit:install-hooks`).
50
+ - **`.claude/adr-kit-guide.md`**: if its version line (first line, `<!-- adr-kit-guide vX.Y.Z -->`) lags the plugin, refresh it from `$ADR_KIT/templates/adr-kit-guide.md` (diff-and-ask when the project copy has local edits, like Step 2 below).
51
+
52
+ When the report shows no stale artifacts AND the project is already on the v0.12 footprint, exit with `everything up to date; nothing to do`.
53
+
54
+ Artifacts the plugin cannot refresh from here (report them, do not edit): GitHub Action pins (`uses: ...adr-judge@vX` in workflows; suggest a Dependabot/Renovate rule or a manual bump) and a `pre-commit` framework `rev:` (suggest `pre-commit autoupdate`).
55
+
56
+ ## Step 1 — Detect the installed footprint
57
+
58
+ Inspect the current state:
59
+
60
+ - `CLAUDE.md` exists? Read it. Look for a v0.11-style `## ADR Kit Rules` section (free-form heading, no markers) OR a v0.12 `<!-- ADR-KIT STUB START -->` block (markers).
61
+ - `docs/adr/` exists? Count `ADR-*.md` files. Scan for any existing `## Enforcement` blocks and tally them.
62
+ - `.githooks/pre-commit` exists?
63
+ - `.claude/adr-kit-guide.md` exists? If yes, check the version line (first line of the plugin template is `<!-- adr-kit-guide vX.Y.Z -->`).
64
+
65
+ Report the detected state to the user in a 4–6 line summary before changing anything.
66
+
67
+ If all of the following are true, the project is already on v0.12:
68
+ - CLAUDE.md has the marker-bracketed stub
69
+ - `.claude/adr-kit-guide.md` matches the plugin's current version
70
+ - `.githooks/pre-commit` is the adr-kit hook
71
+ - All Accepted ADRs either have `## Enforcement` blocks or have been explicitly skipped
72
+
73
+ If so, exit with `already on v0.12; nothing to do`.
74
+
75
+ ## Step 2 — Refresh CLAUDE.md stub + guide file
76
+
77
+ Resolve the plugin path:
78
+
79
+ ```bash
80
+ ADR_KIT=$(ls -d ~/.claude/plugins/cache/rvdbreemen-adr-kit/adr-kit/*/ | sort -V | tail -1)
81
+ ```
82
+
83
+ Three migration paths for `CLAUDE.md`:
84
+
85
+ - **v0.11 inline `## ADR Kit Rules` section present.** Replace the entire section (heading through the next `## ` heading, or EOF) with the v0.12 stub:
86
+ ```markdown
87
+ <!-- ADR-KIT STUB START -->
88
+ <!-- DO NOT regenerate manually. Updated by `/adr-kit:init`, `/adr-kit:upgrade`, `/adr-kit:setup`. -->
89
+ ## ADR Kit
90
+
91
+ This project uses [adr-kit](https://github.com/rvdbreemen/adr-kit). All architectural decisions live as ADRs in `docs/adr/`. Full guide: @.claude/adr-kit-guide.md
92
+
93
+ Authoring: `/adr-kit:adr` (or the `adr-generator` subagent).
94
+ Pre-commit verification: `bin/adr-judge` runs declarative `Enforcement` rules at commit time. ADRs with `llm_judge: true` are reviewed in-session via `/adr-kit:judge`.
95
+ <!-- ADR-KIT STUB END -->
96
+ ```
97
+ Surrounding content (everything outside the section) stays byte-exact. Verify by diff after the edit.
98
+
99
+ - **v0.12 stub already present.** Replace just the contents between the markers with the current stub text. Idempotent.
100
+
101
+ - **No ADR-kit footprint.** Append the v0.12 stub at the end of `CLAUDE.md`, with one blank line of separation.
102
+
103
+ For `.claude/adr-kit-guide.md`:
104
+
105
+ - If absent: create it from `$ADR_KIT/templates/adr-kit-guide.md`.
106
+ - If present and byte-identical to the plugin template: no-op.
107
+ - If present and differs: read both, show a unified diff (3 context lines), ask the user `keep project version | replace with plugin version | merge by hand`. Apply.
108
+
109
+ ## Step 3 — Install the pre-commit hook (default-on)
110
+
111
+ Delegate to `/adr-kit:install-hooks` (or do its work inline if delegation is awkward). Same logic as that skill — detect existing hook, prepend / replace / abort, set `core.hooksPath`. **Do not prompt for installation itself; the hook is default-on as of v0.12.** If the user wants to opt out, they can disable per-commit with `ADR_KIT_HOOK_DISABLE=1` or remove via `/adr-kit:install-hooks --uninstall`.
112
+
113
+ ## Step 4 — Enforcement-block backfill (the only slow step)
114
+
115
+ For every `Status: Accepted` ADR in `docs/adr/` that does NOT already have a `## Enforcement` section, propose one. Walk them one at a time (not batched) — each proposal needs the ADR's full Decision/Context to make a judgement, and the user's input is per-ADR.
116
+
117
+ For each ADR:
118
+
119
+ 1. Read the ADR. Summarise its Decision in one line.
120
+ 2. Decide which of three categories it falls into:
121
+ - **Declarative.** The rule is mechanically expressible. Examples: "no String class in hot paths" → `forbid_pattern: \\bString\\b ... in src/**`; "use addOTWGcmdtoqueue() for OTGW commands" → `require_pattern: addOTWGcmdtoqueue\\(`.
122
+ - **LLM-judgeable.** The rule is too nuanced for regex but a model can read the diff and decide. Set `llm_judge: true`.
123
+ - **Manual review only.** No code surface (e.g., a process or governance ADR). Suggest the user add `<!-- adr-kit-judge: skip -->` near the heading, or simply omit the Enforcement block (the judge skips ADRs without one).
124
+ 3. Print: `[ADR-NNN] <one-line title> → proposed category: <declarative | llm-judge | manual>; proposed block:` and show the JSON.
125
+ 4. Ask the user: `accept | edit | skip this ADR | skip rest`.
126
+ - `accept`: Edit the ADR file, append the `## Enforcement` section.
127
+ - `edit`: Show the user the proposal, let them edit it inline; apply when satisfied.
128
+ - `skip this ADR`: leave it alone.
129
+ - `skip rest`: stop the backfill loop entirely.
130
+
131
+ Do NOT modify any other section of the ADR. Only append the new `## Enforcement` section. Accepted ADRs are otherwise immutable.
132
+
133
+ ## Step 4b — LLM judge: opt-out migration (ask before writing)
134
+
135
+ `llm_judge` defaults to **true** as of TASK-74. ADRs written before that carry an explicit `"llm_judge": false` that is indistinguishable from a deliberate refusal, so the upgrade proposes turning them on — and the user gets the chance to decline.
136
+
137
+ Run the deterministic scan first. It writes nothing:
138
+
139
+ ```bash
140
+ python3 "$ADR_KIT/bin/adr-migrate" docs/adr/ --enable-llm-judge --dry-run --format json
141
+ ```
142
+
143
+ The result has three lists — `enabled` (what would be turned on), `opted_out` (rule-less blocks the scan proposes to mark as having no code surface), and `unchanged` — plus a `summary` carrying the two numbers that decide this step: `judged_after` (how many ADRs the LLM pass evaluates once the migration lands) and `unbounded_after` (how many of those declare no `path_glob`).
144
+
145
+ **Then ask the user, once, with the whole picture in front of them.** Show:
146
+
147
+ - **the `summary` totals first.** The `enabled` list is only this run's delta; on an upgraded repository the dominant cost sits in ADRs that are already on. A dry-run reading "6 enabled, 0 unbounded" has been accepted on a set that ended at 64 unscoped of 68 judged, which at the measured 20–28 s per isolated call is ~25 minutes of blocking per commit;
148
+ - how many ADRs would be enabled, and for each one its id, its one-line Decision and its rule count;
149
+ - which ADRs carry `unbounded_scope: true` — those have no `path_glob` to narrow with, so enabling them costs a model call on **every** commit, not only on commits that touch their area;
150
+ - which ADRs the scan proposes to mark as no-code-surface, and why.
151
+
152
+ Offer these answers:
153
+
154
+ - **accept all** (the default) — apply as proposed.
155
+ - **opt out of specific ADRs** — name them; each needs a reason, which is written into the ADR as `llm_judge_reason` so no later upgrade re-proposes it.
156
+ - **enable a rule-less ADR anyway** — name it under `--force-enable`; say plainly that this means one call per commit until the ADR declares a scope.
157
+ - **skip entirely** — change nothing; the next upgrade will ask again.
158
+
159
+ Apply the answer:
160
+
161
+ ```bash
162
+ python3 "$ADR_KIT/bin/adr-migrate" docs/adr/ --enable-llm-judge \
163
+ --except ADR-006,ADR-011 --reason "reviewed manually in the release checklist" \
164
+ --force-enable ADR-014
165
+ ```
166
+
167
+ Report exactly which ADRs were enabled and which were left off. State the cost shape in the same breath, and state it for the whole set: a commit makes one isolated call per scoped ADR whose `path_glob` the diff touches, **plus one call for every unscoped ADR regardless of the diff**. "A commit outside every scope makes none" holds only when `unbounded_after` is zero.
168
+
169
+ Re-running the command after this is a no-op and says so.
170
+
171
+ ## Step 4b² — Make the pass runnable, and decide where it runs
172
+
173
+ Enabling `llm_judge` on ADRs configures what SHOULD be judged; it does not make the judge able to run, and it does not decide where the cost lands. An upgrade that stops here can leave a project whose pass degrades silently on every commit, or one whose commits block for half an hour. Finish both halves:
174
+
175
+ **1. The host client.** Read the effective configuration:
176
+
177
+ ```bash
178
+ python3 "$ADR_KIT/bin/adr-judge" --show-config
179
+ ```
180
+
181
+ - Retired keys present (`judge.llm_cmd`, `judge.llm_model`, `judge.openrouter_model`, `judge.ollama_model`, `judge.openai_model`) → config validation refuses each by name and says what replaced it (ADR-036). Have the user delete the keys from `.adr-kit.json`; no command edits a file that carries them.
182
+ - No recorded client → record it now rather than leaving it to the first degraded commit:
183
+
184
+ ```bash
185
+ python3 "$ADR_KIT/bin/adr-judge" --set-backend host --host-client claude-code-cli
186
+ ```
187
+
188
+ The host model is the only backend (ADR-036); operators can override one run with `ADR_KIT_LLM_CMD` / `--llm-cmd`.
189
+
190
+ **2. The cadence.** Take `unbounded_after` from Step 4b's summary and put the multiplication in front of the user: `unbounded_after × ~20 s` is what every commit will block, sequentially, because the pass makes one isolated call per ADR. Two honest configurations exist:
191
+
192
+ - `unbounded_after` is small (a handful): per-commit judging is affordable; leave `judge.llm_enabled` on.
193
+ - `unbounded_after` is large: per-commit judging is not viable, and no faster model fixes a per-ADR multiplier. Offer `judge.llm_enabled: false` (the declarative pass keeps blocking, at milliseconds) with the **guardian llm tier** as the semantic cadence — `guardian.llm_stale_days` in `docs/adr/.adr-kit.json` (default 14; 7 for a weekly pass) makes the SessionStart nudge raise it when due, cost-gated by `guardian.llm_autorun: false`.
194
+
195
+ Record the choice in the wrap-up so the next reader of `.adr-kit.json` sees a decision, not an accident.
196
+
197
+ ## Step 4c — The signer: propose, never assume
198
+
199
+ Every lifecycle command writes a Status History entry naming who decided, and it
200
+ refuses to sign on the user's behalf. That refusal is right, and it should not be
201
+ the user's first experience of the tool.
202
+
203
+ ```bash
204
+ python3 "$ADR_KIT/bin/adr" signer --suggest --adr-dir docs/adr
205
+ ```
206
+
207
+ Read-only: it finds candidates and writes nothing. It looks at the signed-in
208
+ GitHub account (`gh api user`, when the CLI is available) and at
209
+ `git config user.name`, ranks them, and shows each with its source — a proposal
210
+ the user cannot trace is one they cannot judge, and this value lands in an
211
+ immutable history.
212
+
213
+ - **Candidates found** — show them and ask which to adopt, or let the user type a
214
+ different name. Then write it:
215
+ `python3 "$ADR_KIT/bin/adr" signer --set "User: <chosen>"`.
216
+ - **Already configured** — say so and move on. Do not overwrite it.
217
+ - **Nothing found** — the GitHub CLI is absent or signed out and git names nobody
218
+ usable. Ask for the name outright rather than guessing.
219
+
220
+ **Bot and CI identities are deliberately not offered.** `github-actions[bot]`,
221
+ `runner`, a bare `user`: those are configured values that name a machine, and
222
+ R8 asks for evidence of which *human* accepted a decision.
223
+
224
+ The value is machine-local by design (`docs/adr/.adr-kit.local.json`, gitignored)
225
+ because writing one person's name into the tracked config would sign every
226
+ teammate's acceptances. Each machine, container and CI runner needs its own.
227
+
228
+ ## Step 5 — Final lint
229
+
230
+ ```bash
231
+ "$ADR_KIT/bin/adr-lint" docs/adr/
232
+ ```
233
+
234
+ Report the result. Then optionally run a no-op judge to confirm hook plumbing:
235
+
236
+ ```bash
237
+ echo "" | "$ADR_KIT/bin/adr-judge" --diff - --adr-dir docs/adr/
238
+ ```
239
+
240
+ Should exit 0 with `OK — 0 violations, 0 advisory`.
241
+
242
+ ## Wrap-up
243
+
244
+ Print the final summary:
245
+
246
+ ```
247
+ adr-kit upgrade complete:
248
+ - CLAUDE.md: <unchanged | refreshed | migrated from v0.11>
249
+ - guide: .claude/adr-kit-guide.md (created | refreshed | unchanged)
250
+ - hook: <installed | already present>
251
+ - backfill: <N> ADRs got declarative rules, <M> got llm_judge:true, <K> skipped, <Q> already had Enforcement
252
+ - lint: <P> PASS, <A> ADVISORY, <F> FAIL
253
+ - formats: <N> deterministic migration notices, <M> guided notices; 0 auto-migrated
254
+ - judge: backend <name | none>, <judged_after> ADRs judged, <unbounded_after> unscoped;
255
+ cadence <per-commit | guardian llm tier every <D>d | declarative-only>
256
+ ```
257
+
258
+ Suggest a commit:
259
+
260
+ ```bash
261
+ git add CLAUDE.md .claude/adr-kit-guide.md .githooks/pre-commit docs/adr/
262
+ git commit -m "chore(adr-kit): upgrade to v0.12"
263
+ ```
264
+
265
+ Do not run the commit yourself.
266
+
267
+ ## Constraints
268
+
269
+ - **Per-ADR backfill is opt-in.** Never silently rewrite ADR contents. Each proposal is shown, the user accepts/edits/skips.
270
+ - **Surrounding CLAUDE.md content stays byte-exact.** Only the marked stub block (or v0.11 `## ADR Kit Rules` section being replaced) may change.
271
+ - **Re-runnable.** A second invocation should detect "already on v0.12" and exit cleanly.
272
+ - **No new ADRs.** This skill never invokes `adr-generator`. New ADRs come from `/adr-kit:init` (first-time bootstrap) or `/adr-kit:adr` (on-demand authoring).
273
+ - **Default-on hook.** Don't prompt for hook installation as if it were optional. The opt-out path is `--uninstall`, not pre-install consent.