@sabaiway/agent-workflow-kit 20.1.0 → 21.0.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 (94) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +7 -5
  3. package/SKILL.md +1 -1
  4. package/bin/install.mjs +10 -11
  5. package/capability.json +1 -1
  6. package/launchers/windsurf-workflow.md +3 -1
  7. package/package.json +5 -2
  8. package/references/contracts.md +9 -9
  9. package/references/modes/bootstrap.md +3 -3
  10. package/references/modes/commit-guard.md +1 -1
  11. package/references/modes/gates.md +1 -1
  12. package/references/modes/recommendations.md +2 -2
  13. package/references/modes/upgrade.md +4 -4
  14. package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
  15. package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
  16. package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
  17. package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
  18. package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
  19. package/references/scripts/docs-size/index.mjs +2 -0
  20. package/references/scripts/family.json +43 -0
  21. package/references/scripts/family.mjs +90 -0
  22. package/references/scripts/gates/kit-command-gates.mjs +117 -0
  23. package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +30 -13
  24. package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
  25. package/references/scripts/run.mjs +74 -0
  26. package/references/scripts/shared/index.mjs +3 -0
  27. package/references/scripts/shared/project-root.mjs +11 -0
  28. package/references/scripts/spec-schema/index.mjs +2 -0
  29. package/references/shared/composition-handoff.md +1 -1
  30. package/references/shared/deploy-tail.md +2 -2
  31. package/references/templates/SPEC_TEMPLATE.md +1 -1
  32. package/references/templates/adr-record.md +3 -3
  33. package/tools/apply-danger-check.mjs +9 -5
  34. package/tools/atomic-write.mjs +3 -1
  35. package/tools/checker-gates-read.mjs +4 -1
  36. package/tools/direct-run.mjs +2 -0
  37. package/tools/distribution-files/retired.mjs +99 -0
  38. package/tools/distribution-files/scripts.mjs +67 -52
  39. package/tools/ensure-configs.mjs +21 -21
  40. package/tools/ensure-ops.mjs +60 -18
  41. package/tools/ensure-specs.mjs +82 -47
  42. package/tools/ensure-vocabulary.mjs +4 -4
  43. package/tools/epic-shape-cli.mjs +1 -1
  44. package/tools/epic-shape-ledger.mjs +1 -1
  45. package/tools/epic-shape.mjs +1 -1
  46. package/tools/family-registry.mjs +3 -1
  47. package/tools/feedback-record-cli.mjs +1 -1
  48. package/tools/fold-scope.mjs +2 -2
  49. package/tools/gates-declaration.mjs +8 -4
  50. package/tools/git-hooks.mjs +90 -65
  51. package/tools/jev-connect.mjs +1 -1
  52. package/tools/jev-guide.mjs +1 -1
  53. package/tools/jev-skill.mjs +1 -1
  54. package/tools/known-footprint.mjs +7 -29
  55. package/tools/node-evidence.mjs +29 -15
  56. package/tools/now-cli.mjs +1 -1
  57. package/tools/payload-prune.mjs +53 -58
  58. package/tools/plan-shape-cli.mjs +1 -1
  59. package/tools/plan-shape.mjs +1 -1
  60. package/tools/project-rules/rules-record.mjs +1 -1
  61. package/tools/queue-audit-cli.mjs +1 -1
  62. package/tools/queue-audit.mjs +2 -2
  63. package/tools/queue-purge-archive.mjs +1 -1
  64. package/tools/queue-purge-cli.mjs +1 -1
  65. package/tools/queue-purge.mjs +1 -1
  66. package/tools/recommendations.mjs +22 -19
  67. package/tools/script-priors.mjs +31 -3
  68. package/tools/source-size/piles.mjs +1 -1
  69. package/tools/spec-adoption.mjs +1 -1
  70. package/tools/spec-check-ops.mjs +2 -2
  71. package/tools/spec-check.mjs +2 -2
  72. package/tools/spec-coverage.mjs +1 -1
  73. package/tools/tier-guide.mjs +1 -1
  74. package/tools/transition/index.mjs +1 -1
  75. package/tools/upgrade-runlist.mjs +1 -1
  76. package/tools/write-lanes.mjs +2 -2
  77. package/references/scripts/_expect-shim.mjs +0 -41
  78. package/references/scripts/archive-caps.test.mjs +0 -321
  79. package/references/scripts/archive-changelog.test.mjs +0 -560
  80. package/references/scripts/archive-conservation.test.mjs +0 -466
  81. package/references/scripts/archive-decisions.test.mjs +0 -1503
  82. package/references/scripts/archive-issues.test.mjs +0 -825
  83. package/references/scripts/archiver-structure.test.mjs +0 -84
  84. package/references/scripts/check-docs-size-cli.test.mjs +0 -325
  85. package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
  86. package/references/scripts/check-docs-size.test.mjs +0 -395
  87. package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
  88. package/references/scripts/install-git-hooks.test.mjs +0 -241
  89. package/references/scripts/markdown-blocks.test.mjs +0 -310
  90. package/references/scripts/migrate-gates-branches.test.mjs +0 -302
  91. package/references/scripts/migrate-gates.test.mjs +0 -517
  92. package/references/scripts/spec-schema.test.mjs +0 -352
  93. /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
  94. /package/references/scripts/{spec-schema.mjs → spec-schema/spec-schema.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,68 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
4
4
  is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
5
5
  every `migrations/<version>-<slug>.md` newer than it, in semver order.
6
6
 
7
+ ## 21.0.0 — the kit's scripts live in one folder, `scripts/agent-workflow/`, run through one stable command (AD-220)
8
+
9
+ **Your project's `scripts/` stops being a pile of kit files.** Every kit script now lives in one folder the kit alone
10
+ writes, `scripts/agent-workflow/`, and your hook, gates and docs name one command that will not move again:
11
+ `node scripts/agent-workflow/run.mjs <name>`. One plain `/agent-workflow-kit upgrade` with your chat yes moves a
12
+ project that holds the 25 flat kit files.
13
+
14
+ - **The kit folder.** It holds runtime files only, laid out by meaning: `run.mjs`, `docs-size/`, `spec-schema/`,
15
+ `archives/` and `git-hooks/`, plus `shared/`. No kit test suite is deployed, and no published package carries one;
16
+ your commit hook no longer runs the kit's tests. Your size check already leaves the folder alone (20.1.0).
17
+ - **The stable command.** `node scripts/agent-workflow/run.mjs <name> [arguments...]` runs `docs-size`,
18
+ `archive-changelog`, `archive-issues`, `archive-decisions` or `install-git-hooks` with every argument unchanged; any
19
+ other name exits 2 with the list of known names. The names are a public contract every later release answers.
20
+ - **The move, in one upgrade run.** The `configs` step places the kit folder and, once
21
+ `scripts/agent-workflow/run.mjs` stands, removes each flat kit file whose replacement stands or that has none, printing `scripts/<name>: removed — the kit's scripts live in
22
+ scripts/agent-workflow/`; a file whose bytes are not the kit's, a link, a directory or an unreadable file is named
23
+ and left; a file whose replacement is not placed yet is kept and waits for the next run.
24
+ - **Your consumers switch in the same upgrade.** The `gates-migration` step switches each flat gate to the command on
25
+ your yes; the `hook-checks` item rewrites a managed commit hook to the command (an unmanaged hook stays yours); the
26
+ agent edits the documented `package.json` scripts. After the removal the upgrade names each `scripts/*.test.mjs` of
27
+ your own with the line that keeps it on every commit (`scripts/pre-commit.local`), prints one `git grep` line that
28
+ finds every other file naming an old path, and, in a visible deployment, one line to commit the change together and
29
+ merge it into every branch you still commit on.
30
+ - **After a no.** On a project with a `package.json`, an upgrade places the caps and index check and the ADR rotator
31
+ even after a no to the enforcement offer; the changelog and issue rotators and the hook still wait for a yes. The kit's
32
+ texts and the ADR rotator's own printed lines run a script of the kit folder only through the command.
33
+ - **Stated limits, each with its fix.** A no on the hook item stops every commit at Node's error naming a removed file
34
+ until you apply the item or run `node scripts/agent-workflow/run.mjs install-git-hooks`. A no on the gates apply
35
+ leaves those gates failing until you apply it. A checkout that does not carry the move yet (a branch forked earlier)
36
+ commits with the kit's checks skipped, under one line naming the fix, and its old installer refuses the new hook,
37
+ until you merge the move into it. In a project named `agent-workflow` the new hook carries the old installer's
38
+ marker, so that installer rewrites the hook to the old paths instead, and every commit in a moved checkout stops at
39
+ Node's error naming a removed file until `node scripts/agent-workflow/run.mjs install-git-hooks`, run in a moved
40
+ checkout, writes it back.
41
+
42
+ MAJOR: every deployed kit script changes path, the upgrade removes the flat files, and the package no longer carries
43
+ the suites. Contracts: script-family revision 7, kit-command revision 6, distribution-files revision 23, init-project
44
+ revision 30.
45
+
46
+ ## 20.2.0 — the project rules check is offered as a gate of every project (AD-219)
47
+
48
+ **Your project's rules can now stop a red gate run, not only a commit.** The check that each rules theme's effective
49
+ file still matches the record it was built from, `project-rules/rules-cli.mjs --check`, joins the kit checkers that
50
+ `checker-gates.mjs` and the upgrade's `tier` step offer as gates of your project:
51
+
52
+ - `node <kit>/tools/checker-gates.mjs --cwd <project>` previews a fifth line, `project-rules`, after `spec-coverage`,
53
+ offered on every deployment, one with no rules theme laid yet included; an offered line is followed by its entry,
54
+ `node "<kit>/tools/project-rules/rules-cli.mjs" --check`, and `--apply` (or the `tier` yes) writes it add-only, as
55
+ for the other four.
56
+ - The gate passes over a theme the check answers `current` or `absent` and stops on one it answers `drift` or `record`,
57
+ naming the remedy `/agent-workflow-kit upgrade`; unlike the commit hook's rules line, it waits for no theme to be
58
+ `current` first.
59
+ - A decline of `checker-gates-declared` you recorded earlier stays current and covers the new candidate; the preview
60
+ above and `--apply --only project-rules` still reach it.
61
+ - If your `docs/ai/gates.json` already declares a `project-rules` gate with `--cwd .` (the form `/agent-workflow-kit
62
+ rules` runs), the preview prints `project-rules: id-taken` and, once no other candidate is offered, every upgrade reads its
63
+ `checker-gates-declared` item as undecidable. Drop `--cwd`
64
+ and its value from that gate's cmd: the gate runner already runs every cmd from the project root, and the preview
65
+ then prints `project-rules: declared`.
66
+
67
+ Contracts: checker-gates revision 2, project-rules revision 11.
68
+
7
69
  ## 20.1.0 — the size check leaves the kit's own folder `scripts/agent-workflow` alone (AD-218)
8
70
 
9
71
  **A coming kit release can move its scripts into one folder of your project without stopping a single commit.** The
package/README.md CHANGED
@@ -117,12 +117,14 @@ your-repo/
117
117
  ├── tech_reference.md ← configs & patterns
118
118
  ├── pages/ ← one spec per page/route
119
119
  └── history/ ← changelog archive (HOT→WARM→COLD)
120
- + scripts/ ← caps · index · archive (installed on a yes)
120
+ + scripts/agent-workflow/ ← caps · index · archive (the kit folder)
121
121
  + pre-commit hook ← keeps it all honest (installed on a yes)
122
122
  ```
123
123
 
124
- The Markdown memory is **stack-agnostic**; the `scripts/` + pre-commit hook are the **Node path**
125
- (dependency-free, `node --test`). They are offered on every project because the agent host runs them; a committer without Node on PATH gets a loud hook failure.
124
+ The Markdown memory is **stack-agnostic**; the kit folder `scripts/agent-workflow/` + pre-commit hook are the
125
+ **Node path** (dependency-free). They are offered on every project because the agent host runs them; a committer without Node on PATH gets a loud hook failure.
126
+ On a project with a `package.json`, an upgrade places the caps and index check and the ADR rotator even after a no;
127
+ the changelog and issue rotators and the hook still wait for a yes.
126
128
 
127
129
  Two **visibility** modes, chosen at deploy time: **visible** (committed with the repo) or **hidden**
128
130
  (same files in-tree but git-ignored via the project-local `.git/info/exclude`, so the repo "looks
@@ -288,7 +290,7 @@ block aside, which is written current on every run).
288
290
  - **Plan lifecycle** — a capped plan (goal and boundary, module ledger, verification), ephemeral plan files, and a mandatory Cleanup phase.
289
291
  - **No silent failures** — every guard that rejects an action logs structured context.
290
292
 
291
- The dependency-free **Node** enforcement scripts (`node --test`, no package manager assumed) and their hook are offered on every project because the agent host runs them; a committer without Node on PATH gets a loud hook failure.
293
+ The dependency-free **Node** enforcement scripts (no package manager assumed) and their hook are offered on every project because the agent host runs them; a committer without Node on PATH gets a loud hook failure.
292
294
 
293
295
  ---
294
296
 
@@ -363,7 +365,7 @@ agent-workflow-kit/
363
365
  │ ├── modes/ ← one file per mode (deploy/upgrade/… procedures)
364
366
  │ ├── shared/ ← shared contracts (footer · hand-off · tail)
365
367
  │ ├── templates/ ← AGENTS.md + every docs/ai file
366
- │ ├── scripts/ ← caps / archive / index + tests
368
+ │ ├── scripts/ ← the script family: manifest, stable command, modules
367
369
  │ └── contracts.md ← visibility / language / attribution rules
368
370
  ├── tools/ ← family tooling:
369
371
  │ ├── manifest/ ← capability-manifest schema + validator
package/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: agent-workflow-kit
3
3
  description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
4
4
  disable-model-invocation: true
5
5
  metadata:
6
- version: '20.1.0'
6
+ version: '21.0.0'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
package/bin/install.mjs CHANGED
@@ -36,8 +36,8 @@ import { dirname, resolve, sep } from 'node:path';
36
36
  import { fileURLToPath } from 'node:url';
37
37
  import { homedir } from 'node:os';
38
38
  import { spawnSync } from 'node:child_process';
39
- import { copyTreeRefresh } from '../tools/fs-safe.mjs';
40
- import { assertInstallableHome, prunePayload } from '../tools/payload-prune.mjs';
39
+ import { assertContainedRealPath, copyTreeRefresh } from '../tools/fs-safe.mjs';
40
+ import { assertInstallableHome, prunePayload, rerunCommand } from '../tools/payload-prune.mjs';
41
41
  // Dependency-free semver, shared with the family registry's bridge freshness probe (one leaf, no
42
42
  // second drifting copy). The null-on-unparseable contract is load-bearing here: legacy installs
43
43
  // predate any version stamp, so an unparseable side means "no gate", never a false ordering.
@@ -129,10 +129,9 @@ const lstatNoFollow = (path) => {
129
129
  }
130
130
  };
131
131
 
132
- // The symlink-traversal guard + the recursive refresh copy now live in tools/fs-safe.mjs (shared,
133
- // dependency-injectable, unit-tested in isolation). install.mjs consumes copyTreeRefresh, which guards
134
- // every dest via assertContainedRealPath internally. The local lstatNoFollow above stays for the
135
- // pre-flight check on the target root itself (a nicer error than letting the copy throw).
132
+ // The symlink-traversal guard + the recursive refresh copy live in tools/fs-safe.mjs (shared, unit-tested
133
+ // in isolation); copyTreeRefresh guards every dest via assertContainedRealPath. The local lstatNoFollow
134
+ // above serves the pre-flight check on the target root and is the prune's no-follow probe.
136
135
 
137
136
  const parseArgs = (argv) => {
138
137
  const dirFlag = argv.indexOf('--dir');
@@ -361,15 +360,15 @@ const main = async () => {
361
360
  process.exit(1);
362
361
  }
363
362
 
364
- assertInstallableHome(target);
363
+ const owner = { name: 'agent-workflow-kit', prefix: '[agent-workflow-kit]', noun: 'kit home',
364
+ rerun: rerunCommand('npx @sabaiway/agent-workflow-kit@latest init', target, !args.dir && !process.env.AGENT_WORKFLOW_KIT_DIR) };
365
+ assertInstallableHome(target, owner);
365
366
  await mkdir(target, { recursive: true });
366
367
  for (const entry of PAYLOAD.filter((e) => existsSync(resolve(PKG_ROOT, e)))) {
367
368
  copyTreeRefresh(resolve(PKG_ROOT, entry), resolve(target, entry), target);
368
369
  }
369
- const prune = prunePayload({ packageRoot: PKG_ROOT, home: target, payload: PAYLOAD });
370
- for (const line of prune.lines) {
371
- console.log(line);
372
- }
370
+ const prune = prunePayload({ packageRoot: PKG_ROOT, home: target, payload: PAYLOAD, owner }, { assertContainedRealPath, lstatNoFollow });
371
+ prune.lines.forEach((line) => console.log(line));
373
372
  // Verb keyed on the OBSERVED version relation (cmp), never on mere presence: null (fresh install,
374
373
  // or a legacy/unstamped one whose prior version is unknowable) → "installed"; -1 → a real update;
375
374
  // 0 → already current (the copy still ran — see the note below); 1 is reachable only under
package/capability.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "agent-workflow-kit",
5
5
  "kind": "composition-root",
6
- "version": "20.1.0",
6
+ "version": "21.0.0",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
@@ -26,7 +26,9 @@ reinvent any of it here; the kit's `SKILL.md` is the single source of truth.
26
26
  attribution) as ONE structured multi-question prompt; record each answer individually,
27
27
  write nothing until ALL are answered** →
28
28
  create `AGENTS.md` (+ `CLAUDE.md` symlink) from `<KIT_DIR>/references/templates/` →
29
- deploy `docs/ai/` → offer the enforcement scripts + pre-commit hook (on a yes: copy `<KIT_DIR>/references/scripts/*.mjs`, install the hook) →
29
+ deploy `docs/ai/` → offer the enforcement scripts + pre-commit hook (on a yes: copy
30
+ `<KIT_DIR>/references/scripts/<path>` of each deployed entry to `scripts/agent-workflow/<path>`, install the hook
31
+ with `node scripts/agent-workflow/run.mjs install-git-hooks`) →
30
32
  wire/hide per visibility → stamp `docs/ai/.workflow-version`.
31
33
  4. Report what was filled with real data vs left as TODO, then **ask before committing** —
32
34
  never auto-commit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "20.1.0",
3
+ "version": "21.0.0",
4
4
  "description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -54,7 +54,10 @@
54
54
  "!bin/*.test.mjs",
55
55
  "!tools/**/*.test.mjs",
56
56
  "!tools/manifest/fixtures/**",
57
- "!tools/project-rules/fixtures/**"
57
+ "!tools/project-rules/fixtures/**",
58
+ "!references/scripts/**/*.test.mjs",
59
+ "!references/scripts/archives/index.mjs",
60
+ "!references/scripts/test-support/**"
58
61
  ],
59
62
  "engines": {
60
63
  "node": ">=22"
@@ -18,10 +18,10 @@ The user chooses at bootstrap whether the AI artifacts are visible in the repo o
18
18
  **explicit up-front question** (bootstrap step 2), never an assumed default. The two modes then
19
19
  diverge:
20
20
 
21
- - **visible** — artifacts are committed. When a `package.json` exists and the enforcement scripts are in place, wire the project's `package.json` scripts (`docs:check` / `docs:index` / `docs:index:check` / `docs:archive` / `docs:archive:check` / `docs:archive:issues` / `docs:archive:issues:check` / `prepare: node scripts/install-git-hooks.mjs`); add a minimal `.gitignore` (`docs/plans/`, `.claude/settings.local.json`) either way. This is the canonical model.
22
- - **hidden** (in-tree) — same files on disk, but the repo "looks normal": the AI/agent footprint is git-ignored via **one managed block in the project-local `.git/info/exclude`** (resolved with `git rev-parse --git-path info/exclude` — never the machine-global `core.excludesFile`, which would affect every repo on the host; **AD-014** amends **AD-006**). The kit's `tools/hide-footprint.mjs` is the single writer: it covers `KIT_OWN_PATHS ∪ the present subset of KNOWN_FOOTPRINT` (the full footprint table below — the kit's own artifacts **and** every other AI/agent tool's files). Per path: a **tracked** file → **ASK** (an exclude does nothing for it; only `git rm --cached` un-tracks it — the tool prints that command and never runs it); an untracked path already covered by a **tracked `.gitignore`** → dropped (redundant); a **present** file whose name is generic enough to be ambiguous (`falsePositiveRisk`) → **ASK**; everything else → **hidden**. `asks` are excluded from the block unless explicitly opted in. **Verify** treats a path as hidden only when it is **untracked AND ignored by our project-local block** (or a tracked `.gitignore`) — being ignored by the global excludes does **not** count. Re-running re-derives the block wholesale (sorted/deduped) → a clean re-run is a **zero-diff** no-op. On an existing global-excludes deployment the tool **detects + reports the residual legacy machine-global block and keeps it** (a harmless double-ignore; the local block wins precedence); removal is the advisor's `footprint-global` item, which the agent applies on the user's yes after its check — its `--remove-global` mode prints the removed lines as a restorable backup — since another of the user's hidden repos on the same host may rely on the same root-anchored global lines. **Do not edit `package.json`** — that is a tracked change and would leak; the pre-commit hook (always untracked in `.git/hooks/`) calls the scripts via `node scripts/<x>.mjs` directly. Windows is supported (text edit, no symlinks; CRLF preserved).
21
+ - **visible** — artifacts are committed. When a `package.json` exists and the enforcement scripts are in place, wire the project's `package.json` scripts (`docs:check: node scripts/agent-workflow/run.mjs docs-size` / `docs:index: node scripts/agent-workflow/run.mjs docs-size --write-index` / `docs:index:check: node scripts/agent-workflow/run.mjs docs-size --check-index` / `docs:archive: node scripts/agent-workflow/run.mjs archive-changelog` / `docs:archive:check: node scripts/agent-workflow/run.mjs archive-changelog --check` / `docs:archive:issues: node scripts/agent-workflow/run.mjs archive-issues` / `docs:archive:issues:check: node scripts/agent-workflow/run.mjs archive-issues --check` / `prepare: node scripts/agent-workflow/run.mjs install-git-hooks`); add a minimal `.gitignore` (`docs/plans/`, `.claude/settings.local.json`) either way. This is the canonical model.
22
+ - **hidden** (in-tree) — same files on disk, but the repo "looks normal": the AI/agent footprint is git-ignored via **one managed block in the project-local `.git/info/exclude`** (resolved with `git rev-parse --git-path info/exclude` — never the machine-global `core.excludesFile`, which would affect every repo on the host; **AD-014** amends **AD-006**). The kit's `tools/hide-footprint.mjs` is the single writer: it covers `KIT_OWN_PATHS ∪ the present subset of KNOWN_FOOTPRINT` (the full footprint table below — the kit's own artifacts **and** every other AI/agent tool's files). Per path: a **tracked** file → **ASK** (an exclude does nothing for it; only `git rm --cached` un-tracks it — the tool prints that command and never runs it); an untracked path already covered by a **tracked `.gitignore`** → dropped (redundant); a **present** file whose name is generic enough to be ambiguous (`falsePositiveRisk`) → **ASK**; everything else → **hidden**. `asks` are excluded from the block unless explicitly opted in. **Verify** treats a path as hidden only when it is **untracked AND ignored by our project-local block** (or a tracked `.gitignore`) — being ignored by the global excludes does **not** count. Re-running re-derives the block wholesale (sorted/deduped) → a clean re-run is a **zero-diff** no-op. On an existing global-excludes deployment the tool **detects + reports the residual legacy machine-global block and keeps it** (a harmless double-ignore; the local block wins precedence); removal is the advisor's `footprint-global` item, which the agent applies on the user's yes after its check — its `--remove-global` mode prints the removed lines as a restorable backup — since another of the user's hidden repos on the same host may rely on the same root-anchored global lines. **Do not edit `package.json`** — that is a tracked change and would leak; the pre-commit hook (always untracked in `.git/hooks/`) calls the scripts through `node scripts/agent-workflow/run.mjs <name>` directly. Windows is supported (text edit, no symlinks; CRLF preserved).
23
23
 
24
- **Visibility changes what git sees — never how the agent works (the load-bearing invariant).** Both modes carry the **same** working memory and run the **same** session protocol: `docs/ai` and the deployed workflow artifacts (`AGENTS.md`, the added `scripts/`) are read at session start and maintained on task completion **identically** whether visible or hidden. (Hidden mode git-ignores a *wider* footprint — other AI/agent tools' files too — but that is only a **visibility** surface; the working memory the agent actually reads and maintains is `docs/ai` plus those artifacts.) Hidden mode only makes the repo *look* normal to git; it is **never** a license to skip, defer, or down-prioritise a doc/state update. The single difference is the destination: in hidden mode those updates live on disk and never enter a commit (the footprint is excluded), so a commit there carries only the project's own tracked files while `docs/ai` is still kept current locally — **git-ignored ≠ optional-to-maintain**. An agent that reads "git-ignored / `git status` clean" and infers the working memory is optional has the model backwards. (This is why bootstrap/upgrade never wire hidden-mode docs into a commit, yet the session protocol still mandates maintaining them.)
24
+ **Visibility changes what git sees — never how the agent works (the load-bearing invariant).** Both modes carry the **same** working memory and run the **same** session protocol: `docs/ai` and the deployed workflow artifacts (`AGENTS.md`, the kit folder `scripts/agent-workflow/`) are read at session start and maintained on task completion **identically** whether visible or hidden. (Hidden mode git-ignores a *wider* footprint — other AI/agent tools' files too — but that is only a **visibility** surface; the working memory the agent actually reads and maintains is `docs/ai` plus those artifacts.) Hidden mode only makes the repo *look* normal to git; it is **never** a license to skip, defer, or down-prioritise a doc/state update. The single difference is the destination: in hidden mode those updates live on disk and never enter a commit (the footprint is excluded), so a commit there carries only the project's own tracked files while `docs/ai` is still kept current locally — **git-ignored ≠ optional-to-maintain**. An agent that reads "git-ignored / `git status` clean" and infers the working memory is optional has the model backwards. (This is why bootstrap/upgrade never wire hidden-mode docs into a commit, yet the session protocol still mandates maintaining them.)
25
25
 
26
26
  **Known AI/agent footprint** (the `KNOWN_FOOTPRINT` registry in `tools/known-footprint.mjs`; this table is its human mirror, kept in sync by review — D11):
27
27
 
@@ -43,9 +43,9 @@ diverge:
43
43
  | `/.aider.input.history` | Aider | file | no | input history |
44
44
  | `/.continue/` | Continue | dir | no | project config dir |
45
45
 
46
- The kit's OWN footprint (`KIT_OWN_PATHS`) — `AGENTS.md`, `CLAUDE.md`, `docs/ai/` (subsumes the stamp), the added `scripts/*.mjs`, `docs/plans/`, `.claude/settings.local.json`, `.claude/settings.json` (hidden-only — visible mode commits it), and `.mcp.json` (the `mcp` mode's registration; hidden-only for the same reason, and it carries an absolute machine path) — is always a candidate in hidden mode.
46
+ The kit's OWN footprint (`KIT_OWN_PATHS`) — `AGENTS.md`, `CLAUDE.md`, `docs/ai/` (subsumes the stamp), the kit folder `scripts/agent-workflow/`, `docs/plans/`, `.claude/settings.local.json`, `.claude/settings.json` (hidden-only — visible mode commits it), and `.mcp.json` (the `mcp` mode's registration; hidden-only for the same reason, and it carries an absolute machine path) — is always a candidate in hidden mode.
47
47
 
48
- `.agent-workflow/` is the family's reserved folder. No kit tool writes there: every kit script, the spec layer's four pair files included, is written over with no copy kept. The copies an earlier release kept there are the user's, outside the kit's own paths: no kit tool overwrites, deletes or hides them, and the folder's own `.gitignore` (`*`) an earlier release wrote keeps git from seeing them in either visibility mode. The kit's literal search never walks into the reserved `.agent-workflow` folder, at any depth, unless that folder or a path inside it is named as a target, and the plan-shape checks never walk into it, so an unnamed copy there never stands beside the live file in their results.
48
+ `.agent-workflow/` is the family's reserved folder. No kit tool writes there: every kit script, the kit folder `scripts/agent-workflow/` whole, is written over with no copy kept. The copies an earlier release kept there are the user's, outside the kit's own paths: no kit tool overwrites, deletes or hides them, and the folder's own `.gitignore` (`*`) an earlier release wrote keeps git from seeing them in either visibility mode. The kit's literal search never walks into the reserved `.agent-workflow` folder, at any depth, unless that folder or a path inside it is named as a target, and the plan-shape checks never walk into it, so an unnamed copy there never stands beside the live file in their results.
49
49
 
50
50
  Not in this version: a fully-external hidden mode (artifacts relocated outside the repo tree).
51
51
  Deferred to a later release + migration.
@@ -94,10 +94,10 @@ On `upgrade`, a pre-1.2.0 deployment with no block gets one (the agent asks, def
94
94
  ## Reserved names and channels
95
95
 
96
96
  Every name the kit bundles and writes over on an upgrade is the kit's, and an edit there is never a
97
- customization: every kit script, the spec layer's four pair files (`scripts/spec-schema.mjs`,
98
- `scripts/spec-schema.test.mjs`, `scripts/check-docs-size.mjs`, `scripts/check-docs-size.test.mjs`)
99
- included, the hook installer set, the kit rules files `docs/ai/rules/<theme>.md` and the kit agent
100
- files (the five the kit bundles for `.claude/agents/` — `changelog-skeleton.md`, `executor.md`,
97
+ customization: every kit script, the kit folder `scripts/agent-workflow/` whole, the spec layer's
98
+ files and the command `scripts/agent-workflow/run.mjs` in it, the hook installer set, the kit rules
99
+ files `docs/ai/rules/<theme>.md` and the kit agent files (the five the kit bundles for
100
+ `.claude/agents/` — `changelog-skeleton.md`, `executor.md`,
101
101
  `gate-triage.md`, `mechanical-sweep.md`, `review-lens.md` — and each configured
102
102
  `review-lens-<model>-<effort>.md`) and, within a hook you wired, the kit hook files
103
103
  `.claude/hooks/agent-workflow-gates.mjs` and `.claude/hooks/state-block-guard.mjs` are written over
@@ -25,8 +25,8 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
25
25
  4. **Choose agent attribution — answered in the step-2 batch.** May the agent attribute work to itself / to AI — `Co-Authored-By` trailers, "Generated with …" footers, "AI"/agent/model mentions in code, comments, commit messages, PR titles/bodies, or docs? **Default to `off`** (no agent/AI mention anywhere) unless they opt in — people are routinely surprised to find an AI listed as a repo contributor. Carry the answer into the `{{AGENT_ATTRIBUTION}}` slot of the *Attribution* block when `AGENTS.md` is created (step 5). **If `off`**, the advisor's `attribution` item of step 11 sets the harness setting in the project's `.claude/settings.json`, applied on the user's yes after its check — the trailer is added by the harness, so a doc directive alone won't stop it. See [Attribution contract](${CLAUDE_SKILL_DIR}/references/contracts.md#attribution-contract).
26
26
  5. **Entry-point doc.** If `AGENTS.md` / `CLAUDE.md` already exist (step-1 recon), do **not** overwrite — show the user and ask whether to merge or replace. Otherwise create `AGENTS.md` (the cross-agent standard — Codex / Cursor / Devin Desktop / Copilot read it natively) from `${CLAUDE_SKILL_DIR}/references/templates/AGENTS.md`, and symlink `CLAUDE.md -> AGENTS.md` (`ln -s AGENTS.md CLAUDE.md`) for Claude Code — single source, no duplication. For nested context, add a subdir `AGENTS.md` (+ a `CLAUDE.md` symlink beside it for Claude Code).
27
27
  6. **Deploy `docs/ai/`.** Create every `docs/ai/` file + `pages/` + the seed `adr/` store + the seed `specs/` store from `${CLAUDE_SKILL_DIR}/references/templates/` (the template loop deploys every template except `AGENTS.md`, `adr-record.md` and `SPEC_TEMPLATE.md` — the latter two are skill-home authoring references, never deployed). This deploys the HOT ADR window **`docs/ai/decisions.md`** and the seed navigator **`docs/ai/adr/log.md`** (its `adr/` subdir copies in wholesale), the spec store root **`docs/ai/specs/index.md`** (its `specs/` subdir copies in wholesale), the `.md` docs, **and** the four seeded, user-editable strict-JSON configs: **`docs/ai/orchestration.json`** (the per-project recipe defaults the `procedures` advisor reads), **`docs/ai/gates.json`** (the project's gate declaration — seeded as the no-consent EMPTY list; FILLING it is the consented `gates-init` preview, `${CLAUDE_SKILL_DIR}/references/modes/gates.md`), **`docs/ai/autonomy.json`** (the per-project autonomy policy — seeded SPARSE with the onboarding note only, so it is exactly the computed defaults until the user declares levels via `/agent-workflow-kit set-autonomy` or by hand), and **`docs/ai/vehicles.json`** (the executor vehicle's model, effort and fallback as a setting the kit's readers resolve into one posture; the placed executor's body follows it, and the bundled review lens's model and effort, `opus` / `high` by default, follow its optional `review-lens` section — seeded once, hand-edited, never clobbered). Keep each `.md` file's frontmatter (`type / lastUpdated / scope / staleAfter / owner / maxLines`); the `.json` seeds carry no frontmatter (the docs cap-validator globs `*.md` only, so they are inherently skipped).
28
- 7. **Fill templates** per the table below. **Then materialize the navigator, as the last `docs/ai` step:** the entry point declares `docs/ai/index.md` always-loaded and it is a GENERATED artifact with no template, so run `node ${CLAUDE_SKILL_DIR}/references/scripts/check-docs-size.mjs --ensure-index --root=<project>` and relay its one outcome line (`ensure-index: regenerated` / `already-current`, or a `write-refused` / `probe-failed` line naming the offending path — either is a STOP: resolve it before reporting the deploy, since the navigator the entry point declares does not exist yet). The generator runs from **this skill's own directory**, so a project with **no Node runtime** is covered too: the agent host runs it, and step 8's copy is not a precondition.
29
- 8. **Offer enforcement on every project, preview-first.** Explain in one line that the dependency-free Node scripts are available because the agent host already runs their step-7 navigator; the only skip condition is that the agent host cannot run them. Run the `enforcement` item's check line, `node ${CLAUDE_SKILL_DIR}/tools/apply-danger-check.mjs --variant enforcement --cwd <project>`: its result is the preview — each script the kit places into the project's `scripts/` with its bytes and the installer it runs with its bytes. Ask once on that result; on a yes copy them by its apply line with that digest, run by the consent route of `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`: the copy is create-only and the project's installer installs the pre-commit hook. On a no, skip the hook and say so; a check that refuses (exit 1 or 3) or an apply that exits 6 leaves no script the kit placed — say so with its output and fill the command slots as on a no. On a no the docs command slots name no project-local command — fill `env_commands.md` and the `Docs caps + index freshness` row of `AGENTS.md` with the same note: the caps + index gate run from the agent's own skill copy (the step-7 `--root=<project>` form) and the archive rotations need the scripts deployed. Never write the skill's absolute path into a deployed doc. They self-configure (project name from `package.json` or, without one, the directory basename; hierarchical/on-demand sections auto-discovered). The hook calls `node scripts/<x>.mjs` directly, so a committer without `node` on PATH gets the hook's own loud failure.
28
+ 7. **Fill templates** per the table below. **Then materialize the navigator, as the last `docs/ai` step:** the entry point declares `docs/ai/index.md` always-loaded and it is a GENERATED artifact with no template, so run `node ${CLAUDE_SKILL_DIR}/references/scripts/docs-size/check-docs-size.mjs --ensure-index --root=<project>` and relay its one outcome line (`ensure-index: regenerated` / `already-current`, or a `write-refused` / `probe-failed` line naming the offending path — either is a STOP: resolve it before reporting the deploy, since the navigator the entry point declares does not exist yet). The generator runs from **this skill's own directory**, so a project with **no Node runtime** is covered too: the agent host runs it, and step 8's copy is not a precondition.
29
+ 8. **Offer enforcement on every project, preview-first.** Explain in one line that the dependency-free Node scripts are available because the agent host already runs their step-7 navigator; the only skip condition is that the agent host cannot run them. Run the `enforcement` item's check line, `node ${CLAUDE_SKILL_DIR}/tools/apply-danger-check.mjs --variant enforcement --cwd <project>`: its result is the preview — each script the kit places into the kit folder `scripts/agent-workflow/` with its bytes and the installer it runs with its bytes. Ask once on that result; on a yes copy them by its apply line with that digest, run by the consent route of `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`: the copy is create-only and the project's installer installs the pre-commit hook. On a no, skip the hook and say so; a check that refuses (exit 1 or 3) or an apply that exits 6 leaves no script the kit placed — say so with its output and fill the command slots as on a no. On a no the docs command slots name no project-local command — fill `env_commands.md` and the `Docs caps + index freshness` row of `AGENTS.md` with the same note: the caps + index gate run from the agent's own skill copy (the step-7 `--root=<project>` form) and the archive rotations need the scripts deployed. Never write the skill's absolute path into a deployed doc. They self-configure (project name from `package.json` or, without one, the directory basename; hierarchical/on-demand sections auto-discovered). The hook calls `node scripts/agent-workflow/run.mjs <name>` directly, so a committer without `node` on PATH gets the hook's own loud failure.
30
30
  9. **Wire / hide** per visibility (see [Visibility contract](${CLAUDE_SKILL_DIR}/references/contracts.md#visibility-contract)). The pre-commit hook is the installer's decision at step 8's apply; over a pre-commit hook the installer did not write, that apply exits 6 with the installer's output naming the hook, and moving it aside is the user's own step. Once the gate declaration is final-run-capable, the advisor's `commit-guard` item binds commits to the green `run-gates --final` receipt; it is applied the same way, its check line first.
31
31
  - **visible** — when a `package.json` exists and step 8's apply exited 0, wire its scripts (never create one for this); add the minimal `.gitignore` either way. **Do not run the hide tool.**
32
32
  - **hidden** — run the kit's hide writer (one managed block in the **project-local** `.git/info/exclude`, covering the kit's own artifacts **and** every known AI/agent tool's footprint — never the machine-global excludes): `node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --dry-run` **first** (changes nothing, prints the plan), then the same without `--dry-run`. Handle what it surfaces, in plain language (never the tool's internal terms):
@@ -64,5 +64,5 @@ Fill strategy:
64
64
  | `tech_reference.md` | Carry over real configs/patterns found in deps. |
65
65
  | `active_plan.md`, `handover.md` | TODO seed (e.g. "Bootstrap session — fill domain sections after first real work"). |
66
66
  | `decisions.md` | The HOT ADR window — seed `AD-001` (adopting this memory system), newest at the bottom. |
67
- | `adr/log.md` | The seed navigator — deployed as-is (the generator over the seeded HOT); regenerated by `archive-decisions.mjs` where the enforcement scripts are deployed (installed on a yes), otherwise it stays the seed — never hand-edited either way. |
67
+ | `adr/log.md` | The seed navigator — deployed as-is (the generator over the seeded HOT); regenerated by `node scripts/agent-workflow/run.mjs archive-decisions` wherever the kit folder holds the rotator, otherwise it stays the seed — never hand-edited either way. |
68
68
  | `known_issues.md`, `changelog.md`, `pages/shared-patterns.md` | Empty template / first bootstrap entry. |
@@ -18,7 +18,7 @@ Run `node ${CLAUDE_SKILL_DIR}/tools/commit-guard.mjs --check [--cwd <dir>]` —
18
18
 
19
19
  **The empty-commit lane is a PASS that attests NOTHING — and it consults no receipt.** A content-free fingerprint over a CLEAN index means the index contributes no tree-content delta, so the commit changes no tree content: `git commit --allow-empty`, a message- or signature-only `--amend`, an empty merge. (What such a commit DOES change — its message, its parents, its signature — was never in the guard's domain.) The guard passes and says exactly that, because its whole claim is about the bytes a commit carries and here there are none. The receipt arms are SKIPPED rather than satisfied: the content-free fingerprint is the one value every clean moment shares, so a receipt found there cannot be correlated to THIS moment or base — letting it decide would make the outcome depend on which stray moment the store recorded last, the same reason `flow-check`'s `#65` rung steps over a content-free RED. The flow arm still runs (the commit still moves HEAD, and the chain bookkeeping is about that), with its own fingerprint-keyed correlations dropped through the explicit `treeCarriesBytes: false` the guard declares — the checker never derives that fact, because a routine clean-tree check still wants those rungs.
20
20
 
21
- **Wiring:** this repo's dogfood rides `scripts/install-git-hooks.mjs`; a consumer install is a consented surface (init/recommendations) — the hook INSTALLER resolves the installed kit location at install time and writes the RESOLVED invocation into the hook it places (no runtime guessing). The final-run ordering that keeps the guard green is D13: stage everything FIRST → run the reviews on the staged tree → `run-gates --final` → commit immediately (any index/worktree mutation after the final run re-stales the receipt).
21
+ **Wiring:** this repo's dogfood rides the hook `node scripts/agent-workflow/run.mjs install-git-hooks` installs; a consumer install is a consented surface (init/recommendations) — the hook INSTALLER resolves the installed kit location at install time and writes the RESOLVED invocation into the hook it places (no runtime guessing). The final-run ordering that keeps the guard green is D13: stage everything FIRST → run the reviews on the staged tree → `run-gates --final` → commit immediately (any index/worktree mutation after the final run re-stales the receipt).
22
22
 
23
23
  **The deliberate partial commit is BLOCKED — stated, accepted.** Refusal 1 means staging a subset on purpose no longer commits: a pathspec commit (`git commit --only <path>`, `git commit <path>`) hands the hook a temporary index carrying less than the verified tree, and that is exactly the capture blindness this arm closes. No opt-out flag exists, deliberately — the guard's whole claim is that the committed bytes ARE the verified bytes, and a flag that suspends it would suspend the claim. An intentional partial commit stays `--no-verify` territory.
24
24
 
@@ -23,7 +23,7 @@ Declared gates can also be **auto-approved** (no permission prompt on a byte-exa
23
23
 
24
24
  **Candidate line — the source-size gate (opt-in, never auto-seeded).** A project declaring the source-size practice (`docs/ai/source-size.json`) can declare its checker as one more gate, offered **only over a MINTED schema-2 practice** — an absent config has nothing to offer, an authored-but-unminted one is withheld by name rather than declaring a gate that would refuse, and a minted schema-1 one is withheld naming its `--write-baseline` move. Adoption is ONE consented verb, `node ${CLAUDE_SKILL_DIR}/tools/source-size-check.mjs --adopt --reason "<text>" [--cwd <project>]`: it mints the record and declares this gate and NOTHING else, is idempotent once adopted, and with no config refuses with the exact file to author. The advisor surfaces it as the `source-size` item, reading a declared cmd as one of THREE claims rather than a yes/no — **canonical** (this copy — answered), **tool-elsewhere** (the same shape resolving to a DIFFERENT real copy — a vendored deployment, converging on a `source-size-copy` acknowledgement, never on `--adopt`, which would collide on the declared id), **not-the-tool** (a gate merely CARRYING the id is a squatter: rename it, or repoint its cmd at this `--check` form) — in that precedence. An unminted record stays the same attention outcome for either copy, and no acknowledgement silences it.
25
25
 
26
- **Candidate lines — the kit's own checkers (opt-in, one consented verb).** `control-bytes`, `plan-shape`, `spec-check` and `spec-coverage` can each be declared as a gate of your project: `node ${CLAUDE_SKILL_DIR}/tools/checker-gates.mjs --cwd <project>` previews them and writes nothing. Each is offered only over a state where its checker runs by design: `control-bytes` over a `.git` directory or gitfile at the project root, `plan-shape` on any deployment, `spec-check` over a regular `docs/ai/specs/index.md`, `spec-coverage` over a regular `docs/ai/spec-coverage.json` beside that store root. An offered checker prints its paste-ready entry line; the upgrade's `tier` ask writes the offered entries on your explicit yes — add-only, placed by the rule below, not stamp-gated, after the preview printed the disclosure below. An entry it wrote is removed by hand from `docs/ai/gates.json`: the verb never un-declares. `epic-shape` and `queue-audit` take a project operand and `doc-parity` checks only the kit's own package, so none of them is offered.
26
+ **Candidate lines — the kit's own checkers (opt-in, one consented verb).** `control-bytes`, `plan-shape`, `spec-check`, `spec-coverage` and `project-rules` can each be declared as a gate of your project: `node ${CLAUDE_SKILL_DIR}/tools/checker-gates.mjs --cwd <project>` previews them and writes nothing. Each is offered only over a state where its checker runs by design: `control-bytes` over a `.git` directory or gitfile at the project root, `plan-shape` and `project-rules` on any deployment, `spec-check` over a regular `docs/ai/specs/index.md`, `spec-coverage` over a regular `docs/ai/spec-coverage.json` beside that store root. An offered checker prints its paste-ready entry line; the upgrade's `tier` ask writes the offered entries on your explicit yes — add-only, placed by the rule below, not stamp-gated, after the preview printed the disclosure below. An entry it wrote is removed by hand from `docs/ai/gates.json`: the verb never un-declares. `epic-shape` and `queue-audit` take a project operand and `doc-parity` checks only the kit's own package, so none of them is offered.
27
27
 
28
28
  **Consent-gated filling — the init preview, not part of the runner (D9).** The template `gates.json` is seeded EMPTY; FILLING it is a consented preview at init (`node ${CLAUDE_SKILL_DIR}/tools/gates-init.mjs --cwd <project>`, dry-run by default — prints the derived entries and **writes NOTHING**; `--apply [--only <id>]…` writes exactly the consented entries on your explicit yes; add-only, id collisions refused). **Placement, not blind appending:** a consented entry lands at the END, except that a non-checker entry goes **BEFORE** a trailing canonical coverage checker — that checker must stay last, so appending after it would write a declaration the validator refuses, leaving a hand edit as the only lane on any final-capable declaration. Existing entries are never modified, removed or reordered. The offer derivation is **closed-world** (AD-052): only a terminating-class script NAME (test / lint / type-check / build — never dev/watch/serve, never a write-mode or release/publish/deploy variant) whose BODY is a member of the literal runner allowlist is offered — membership, never blocklist screening: the worst case is a legit command not offered, never a dangerous one offered. The offered cmd is the uniform hook-free **`COREPACK_ENABLE_NETWORK=0 <pm> exec -- <allowlisted-body>`** — `exec` runs a command, not a named script, so no pre/post hook can fire (npm/pnpm/yarn alike; never `<pm> run <name>`, which re-exposes hooks), and the Corepack env prefix blocks a hostile `packageManager` pin from fetching the PM binary before exec. npm is pinned `--offline --script-shell /bin/sh`; pnpm/yarn refuse an absent runner without network (a user-installed cache/global/PATH runner executing is user machine state — part of the disclosed residual); a family without a verified fail-closed exec contract is WITHHELD loudly. A screened-out body is always named — and when nothing but kit checkers remains, the preview says so in plain words: the offer carries **no project-verification gate at all**. **Disclose before the yes** (the preview prints it): gates.json is a PRIVILEGED file — the wired hook auto-approves byte-exact declared commands — and a script gate runs project-controlled tooling the preview does not sandbox (safe-by-construction = the OFFER DERIVATION). At upgrade, step 3's run-list changes an existing gates.json only through the consented legacy migration and, under the `tier` ask, `tools/checker-gates.mjs` (`${CLAUDE_SKILL_DIR}/references/modes/upgrade.md`).
29
29
 
@@ -39,8 +39,8 @@ A variant's posture note, where its key has one, is printed by `init` from this
39
39
 
40
40
  - `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading: it claims the practice while nothing measures module size, so it is the user's own step (rename the id, or repoint the cmd at this `--check`). **`unminted`**, for both copies: a gate refusing every run over an authored or incomplete record (over an absent one the check judges layout alone), attention, and NO acknowledgement silences it; only the verb differs (with the gate declared elsewhere, `--write-baseline`). **`schema-1`** — the check stops on a minted schema-1 config, so this arm comes first: its `--write-baseline` line carries NO reason (a pinned one would launder a raise; a raise riding the move refuses and you relay it), every run until the move. **`layout`** — on a config with no layout record, the record of the piles already there comes first, as its own item: a no writes nothing and the item returns every run; its `recipe:` line names the branch states, and `source-size.layout` is applied before the `hook-checks` check line runs, whose layout line follows that record. **`piles`** — each recorded pile with no queue row gets one, at the end of the queue's Later bucket; a write the queue's own declared check would refuse is not made and the stated skip says why. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file, so every arm here either records an acknowledgement or hands you an edit — the kit declares nothing on its own.
41
41
  - `gate-hook` — the offer wires the hook on the harness lane: the agent applies it on the chat yes after the check; `init` previews and applies it on the terminal yes as the route the user may take instead. Over a wired hook the key renders the kit item `gate-hook.not-current` instead: the placed hook file is absent or differs from the body the kit writes for it. An older body validates your declaration through its OWN baked copy and goes dark on a key it does not know, such as `lcovProducer` (present, whatever its value), so every gate prompts again with no error anywhere. The agent applies the kit item with no question after the check, whose result names the file with its new digest, and the old one too over a differing file; it writes only the hook file. Risk profile: the offer places a hook file and wires one settings entry; the kit item writes one hook file with the kit's body; the declaration is never touched.
42
- - `enforcement` — copies the bundled `references/scripts/*.mjs` runnable scripts and their tests, then runs the project's own hook installer, which installs the pre-commit hook. The lane is harness: the agent applies the item on the chat yes after the check, whose result shows each script the kit places with its bytes and the installer it runs with its bytes; `init` applies it on the batch terminal yes as the route the user may take instead. The copy is create-only: an existing file stands and nothing is written through a link, and the offer renders only when `scripts/` is absent or a plain directory contains no bundled basename. The hook invokes `node` directly, so a committer without it on PATH gets a loud failure. The installer refuses to overwrite a pre-commit hook it did not write: an install it refuses removes the scripts this apply copied, and the item is offered again with the installer's output shown; over a pre-commit hook the installer did not write the item is not offered — its skip names the user's own step. Risk profile: local tooling and a Git hook are added on the chat yes after the check, or on init's y.
43
- - `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines, aggregate and layout; over a clone with no pre-commit hook the installer writes its whole hook, so commits also stop on its docs, archive and `scripts/` test lines.
42
+ - `enforcement` — copies the bundled runtime files of `references/scripts/` into the kit folder `scripts/agent-workflow/`, then runs the project's own hook installer, which installs the pre-commit hook. The lane is harness: the agent applies the item on the chat yes after the check, whose result shows each script the kit places with its bytes and the installer it runs with its bytes; `init` applies it on the batch terminal yes as the route the user may take instead. The copy is create-only: an existing file stands and nothing is written through a link, and the offer renders only on no Node evidence. The hook invokes `node` directly, so a committer without it on PATH gets a loud failure. The installer refuses to overwrite a pre-commit hook it did not write: an install it refuses removes the scripts this apply copied, and the item is offered again with the installer's output shown; over a pre-commit hook the installer did not write the item is not offered — its skip names the user's own step. Risk profile: local tooling and a Git hook are added on the chat yes after the check, or on init's y.
43
+ - `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines, aggregate and layout; over a clone with no pre-commit hook the installer writes its whole hook, so commits also stop on its docs and archive lines.
44
44
  - `attribution` — the agent applies the item on the chat yes after the check, setting one key in the project `.claude/settings.json`; `init` applies it on the terminal y as the route the user may take instead. An existing "includeCoAuthoredBy": false already converges the item unless an "attribution" key sets a commit or PR text; a local-scope override is the user's own edit. Risk profile: one settings key, nothing widened.
45
45
  - `footprint-global` — the agent applies the item on the chat yes after the check, which prints each line it removes; `init` applies it on the terminal y as the route the user may take instead. Another of the user's repositories may rely on the same lines: a no keeps the block, and the item returns at the next run. The apply prints the removed lines as a backup. Risk profile: lines removed from the machine-global excludes file.
46
46
  - `mcp-channel` — the offer is to REGISTER the kit's read-only stdio MCP server in this project on the harness lane: a registration is a command your MCP client will RUN. The agent applies it on the chat yes after the check; `init` previews the exact entry and applies it on the terminal y as the route the user may take instead. What the registration buys: path questions and literal searches become typed tool calls whose arguments are named JSON fields instead of a string handed to a shell, so a pipe, a redirect or a quote inside a pattern or a path stays DATA and is never interpreted. Posture: the server is a **read-only child of your client** (path/type/size/line facts and literal search over this project root; no write and no exec API), and like the client itself it runs **outside the Bash sandbox** — the sandbox is not what bounds it, the server's own root containment is. The two allow rules it adds make those two tools promptless and nothing else. The **`.differing`** arm is also a harness item: an `agent-workflow` entry already stands in `.mcp.json` and **structurally differs** from what this kit copy would write (another kit copy, a hand-edited path, an added `env`; the comparison ignores key order, so re-serialized identical bytes are the same registration). The check shows the entry standing in `.mcp.json` and the entry it would write; the chat yes confirms the replacement. `init` previews `mcp --replace` and replaces only on the terminal y. Stated limit: this item does **not** detect a `disabledMcpjsonServers` veto, so a converged `mcp-channel` means *what the mode writes is in place*, not *the client will load it* — see `${CLAUDE_SKILL_DIR}/references/modes/mcp.md`. Risk profile: a new read-only channel your client will launch; no write or exec exposure; a differing registration is replaced only on the checked chat yes or the terminal y and every other declaration is kept.
@@ -13,7 +13,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
13
13
  1. `entry-block` — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` → the kit block between its two workflow:kit comment lines, its table one row per theme, written current with no question and no copy kept, its line naming the route (text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/): added · already current · written · refused · a hard STOP.
14
14
  2. `footprint` — `node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --reconcile --dry-run` → visibility: visible · ambiguous · hidden — consent (conditional): ambiguous → ask which it is BEFORE anything; hidden → the conditional re-run without `--dry-run` (its surfaced paths ask per bootstrap step 9).
15
15
  3. `configs` — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --cwd <project>` → one line per ensure: `seeded` / `note-refreshed` / `refreshed` / `regenerated` / `pending` / `already-current` / `customized-preserved` / `malformed-preserved` / `already-present` / `not-placed` / `skipped-no-node-evidence` / `failed`.
16
- 4. `gates-migration` — `node ${CLAUDE_SKILL_DIR}/references/scripts/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>` → the preview plan · INERT checker · CUSTOMIZED entries, each named — consent: apply only on an explicit yes, re-run with `--apply`.
16
+ 4. `gates-migration` — `node ${CLAUDE_SKILL_DIR}/references/scripts/gates/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>` → the preview plan · INERT checker · CUSTOMIZED entries, each named — consent: apply only on an explicit yes, re-run with `--apply`.
17
17
  5. `bridges` — `node ${CLAUDE_SKILL_DIR}/tools/setup-backends.mjs --refresh-placed` → per-bridge lines: refreshed · already current · skipped — with its stated reason (not placed / newer than the bundle / unsupported host) · `skipped-readonly` · could not refresh.
18
18
  6. `tier` — `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --cwd <project>` → per gap: present · offered · declined · undecidable · applied · recorded · refused — consent: one ask, only when offered.
19
19
  7. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
@@ -32,7 +32,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
32
32
 
33
33
  **`footprint` — hidden-mode footprint reconcile (D9 / AD-014).** A deployment does not record whether it chose `hidden`, so first **infer visibility** — the dry-run writes **zero bytes** and reports one of — **visible** (the entry point is tracked) → nothing to do; **ambiguous** (untracked but not ignored — could be a fresh uncommitted repo, or a hide that broke) → **ASK** the user which it is, never guess; **hidden** → re-run without `--dry-run` to migrate any older **machine-global** hide to the **project-local** `.git/info/exclude` (one managed block; folds in the legacy `.claude/skills/` line), idempotently (a clean re-run is zero-diff). Handle its surfaced paths exactly as bootstrap step 9 (`${CLAUDE_SKILL_DIR}/references/modes/bootstrap.md`) (already-committed → show `git rm --cached`, ask before `--include`; generic-name present file → ask; **a leftover machine-wide ignore block is kept + reported — the advisor's `footprint-global` item removes it**). This runs on **every** hidden upgrade, like the kit block — no lineage-head bump, no migration file.
34
34
 
35
- **`configs` — the project-configuration ensures, ONE run.** The ONE command performs **all nine** ensures — orchestration config · gate declaration · autonomy declaration · vehicles declaration · executor check · enforcement scripts · spec layer · project rules · navigator index — in a fixed order, and prints **one outcome line per ensure**: paste those lines into the step 4 / step 8 success report. Every SEED is **create-only** (an existing file is preserved byte-for-byte); a refresh-class op rewrites only what it owns, and the scripts op's store run moves ADR entries, rewrites their inbound links in `docs/ai` pages and regenerates the index, as the rotator does — the outcome tokens by ensure, below, name each arm. One ensure failing **never** skips the others: each reports its own outcome and the run exits non-zero when any of them `failed`. The outcome tokens, by ensure: orchestration → `seeded` / `note-refreshed` / `already-current` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `not-placed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `already-current`; index → `regenerated` / `already-current` / `customized-preserved`; and any ensure may report `failed`, whose line OPENS with the cause (relay it with that cause — never soften it into a skip; an op that copies file by file also states when it stopped partway). The cause vocabulary is CLOSED — one of `race-unresolved`, `template-unreadable`, `bundle-unreadable`, `adr-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade** — before the equal-head exit, the migrations and the re-stamp. Add `--dry-run` to preview without writing a byte. Like the kit block + the footprint reconcile, all nine reach an equal-head deployment **without a lineage-head bump or a migration file**.
35
+ **`configs` — the project-configuration ensures, ONE run.** The ONE command performs **all nine** ensures — orchestration config · gate declaration · autonomy declaration · vehicles declaration · executor check · spec layer · enforcement scripts · project rules · navigator index — in a fixed order, and prints **one outcome line per ensure**: paste those lines into the step 4 / step 8 success report. Every SEED is **create-only** (an existing file is preserved byte-for-byte); a refresh-class op rewrites only what it owns, and the scripts op's store run moves ADR entries, rewrites their inbound links in `docs/ai` pages and regenerates the index, as the rotator does — the outcome tokens by ensure, below, name each arm. One ensure failing **never** skips the others: each reports its own outcome and the run exits non-zero when any of them `failed`. The outcome tokens, by ensure: orchestration → `seeded` / `note-refreshed` / `already-current` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; specs → `seeded` / `refreshed` / `already-present` / `skipped-no-node-evidence`; scripts → `seeded` / `refreshed` / `already-present` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `already-current`; index → `regenerated` / `already-current` / `customized-preserved`; and any ensure may report `failed`, whose line OPENS with the cause (relay it with that cause — never soften it into a skip; an op that copies file by file also states when it stopped partway). The cause vocabulary is CLOSED — one of `race-unresolved`, `template-unreadable`, `bundle-unreadable`, `adr-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade** — before the equal-head exit, the migrations and the re-stamp. Add `--dry-run` to preview without writing a byte. Like the kit block + the footprint reconcile, all nine reach an equal-head deployment **without a lineage-head bump or a migration file**.
36
36
 
37
37
  **What the orchestration-config ensure does.** `docs/ai/orchestration.json` must exist **and its onboarding note must be current**: created from the canonical seed if missing; if it already exists, the current note is left and an absent, prior or any other note is written current with no question and no copy kept, **every activity and slot the user set kept** (CRLF/whitespace normalized first) → `note-refreshed`; a differing note's line names the route — a note of your own goes in AGENTS.md, outside the kit block's two workflow:kit comment lines; a *malformed* existing config is **preserved untouched + LOUD** → `malformed-preserved`, never clobbered and never silently skipped. The current note points at `/agent-workflow-kit set-recipe`. **Kit-owned:** in the **delegated** path memory only seeds or keeps the file (memory upgrade step 2) and this ensure writes the note; in the **fallback** path it does both. (Memory stays standalone.)
38
38
 
@@ -42,11 +42,11 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
42
42
 
43
43
  **What the executor ensure does.** It never writes: a placed `.claude/agents/executor.md` whose bytes differ from the body derived from `docs/ai/vehicles.json` is `pending` and an absent one is `not-placed` — the advisor's `agents` item writes the derived body.
44
44
 
45
- **What the enforcement-script ensure does.** It judges every kit script — each `*.mjs` of `${CLAUDE_SKILL_DIR}/references/scripts/` but the spec-layer pairs — once the component is accepted: a kit script outside the seed names (memory's own copies) stands in `scripts/` as a regular file. Each file by proof, with no question and no copy kept: a shipped prior is refreshed, an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. The hook installer and its two suites go first; a closing line says the commit hook runs the files written. A declined enforcement offer keeps the standing seed files current with the modules they import, places no other kit script (one line says so) and words that hook-run line as a condition. With no kit script there: `not-placed`, nothing written. **The ADR store, after the writes:** where the run judged the rotator, it runs `scripts/archive-decisions.mjs --ensure-current`, with no question, which brings the store current (an older layout moved) or writes nothing; its lines are relayed under `ADR store: `. A rotator that does not bring the store current is `failed` / `adr-store-not-current`, the scripts written above staying as written: its refusal stops the upgrade. Where the size practice measures `scripts/`, a write may grow a root past its record: the size check names its own reasoned `--write-baseline`. **Whether Node runs here is PROVEN, never proxied:** the ensure runs on a regular `package.json` at the root OR on any kit-seeded `scripts/*.mjs` already deployed; only when every probe answers absent does it report `skipped-no-node-evidence`, a line naming every probe it checked, while the config ensures still run; a probe that cannot be read is `failed` with the cause `node-evidence-unverifiable`, nothing written. **A `skipped-*` outcome whose stated reason this tool could itself disprove may not exist**. A deployed pre-commit hook takes a new installer body only when the installer next runs: the `enforcement` check line and apply, by the consent route, re-run it (it refuses a non-marker hook as always); until then `scripts/pre-commit.local` does not run.
45
+ **What the enforcement-script ensure does.** It judges every kit script of the kit folder `scripts/agent-workflow/` — each deployed `*.mjs` of `${CLAUDE_SKILL_DIR}/references/scripts/` but the spec layer's pairs and `run.mjs`, which the spec-layer ensure places first — once the component is accepted: a kit script outside the seed names (memory's own copies) stands in the kit folder as a regular file, or a regular file stands in `scripts/` under the old flat name of the hook installer. Each file by proof, with no question and no copy kept: a shipped prior is refreshed, an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. The hook installer goes first; a closing line says the commit hook runs the files written. On a declined enforcement offer, a project with Node evidence gets every seed file, the decisions rotator and the modules it imports, kept current (an absent one placed); the run places no other kit script (one line says so) and words that hook-run line as a condition. **The ADR store, after the writes:** where the run judged the rotator, it runs the kit folder's rotator with `--ensure-current`, with no question, which brings the store current (an older layout moved) or writes nothing; its lines are relayed under `ADR store: `. A rotator that does not bring the store current is `failed` / `adr-store-not-current`, the scripts written above staying as written: its refusal stops the upgrade. **The move from the flat layout, the run's last act.** A deployment of an earlier release holds the kit's old files flat in `scripts/` (the names of `PRIOR_FILES` in `${CLAUDE_SKILL_DIR}/tools/script-priors.mjs`). After every write landed and the store run passed, and only while `scripts/agent-workflow/run.mjs` stands, each `scripts/<name>` of those names whose bytes are a body this kit shipped is removed, `scripts/<name>: removed — the kit's scripts live in scripts/agent-workflow/`, when its replacement `scripts/agent-workflow/<path>` stands or it has none (a suite, the test-support file, the gate migration); one whose replacement is not placed yet is kept with its line and waits for the next run, and so is every old file while `run.mjs` does not stand (under `--only scripts` the spec-layer ensure does not place it). A file whose bytes differ from every body this kit shipped is the user's, named and left, never written or removed; a link, a directory, an unreadable file or a failed unlink is named and left. A removal counts as `refreshed`; `--dry-run` removes nothing and prints what would be removed. After a removal the run prints one line per regular `scripts/*.test.mjs` left that is not the kit's (a suite of the user's own, which the kit's hook does not run: wire it with `node --test scripts/<file>` in `scripts/pre-commit.local`); inside a git work tree one `git grep` line over the old names, the kit folder excluded, and its boundary line (the hooks dir and ignored files are the user's to check), outside one a line saying so; and, in a visible deployment, one line to commit `scripts/agent-workflow/`, the removed files and, as the upgrade changed them, `docs/ai/gates.json` and `package.json` as one change, merged into every branch still committed or installed on. **Edit each grep hit in this upgrade:** a `node scripts/<file>` of a kit check becomes `node scripts/agent-workflow/run.mjs <name>` with its arguments; a path of a deployed file becomes `scripts/agent-workflow/<path>`; a suite and the test-support file have no deployed path (a suite of the user's own is the suite line's, and a file of the user's importing the support file keeps a copy under a name of its own); a hit of the gate migration is row 4's registry `gates-migration` command, never a path under the kit folder; a record in `docs/ai/source-size.json` is regenerated by the size check's `--write-baseline`. Edit `package.json`'s scripts in this upgrade too (the documented wiring of `contracts.md`): a `prepare` script fails at Node's cannot-find-module until then. Row 4's migration switches the old gates and the `hook-checks` item switches the managed commit hook. **What stays open:** a no on the hook item leaves every commit stopped at Node's error naming a removed file until the item is applied or `node scripts/agent-workflow/run.mjs install-git-hooks` is run; a no on the gates apply leaves those gates failing; the hooks dir (another hook of the user's) and ignored files are outside the printed line; a checkout without the kit folder commits under the hook's checkout line and installs through its own old installer, which refuses the clone's name-free hook (exit 1, so a `prepare` there fails) until it takes the move; in a project named `agent-workflow` the new hook carries the old installer's marker, so that installer rewrites the hook to the old paths instead, and every commit of a moved checkout stops at Node's error naming a removed file until `node scripts/agent-workflow/run.mjs install-git-hooks`, run in a moved checkout, writes it back. The suite and grep lines print once, on the run that removed: an upgrade stopped after that run and before these edits finishes them from this paragraph — wire each regular `scripts/*.test.mjs` outside the names of `PRIOR_FILES` as a suite, and search with `git grep -n -F --untracked -e <name> … -- . ':!scripts/agent-workflow'`, one `-e` per name of `PRIOR_FILES`. Where the size practice measures `scripts/`, a write may grow a root past its record: the size check names its own reasoned `--write-baseline`. **Whether Node runs here is PROVEN, never proxied:** Node evidence is a regular root `package.json`, or a regular file, every folder above it a plain directory, at one of the kit's flat script names in `scripts/` or at a deployed path in `scripts/agent-workflow/`; `skipped-no-node-evidence` only when the probe finds none, a line naming every probe it checked, while the config ensures still run; a probe that cannot be read is `failed` with the cause `node-evidence-unverifiable`, nothing written. **A `skipped-*` outcome whose stated reason this tool could itself disprove may not exist**. A deployed pre-commit hook takes a new installer body only when the installer next runs: the `enforcement` check line and apply, by the consent route, re-run it (it refuses a non-marker hook as always); until then `scripts/pre-commit.local` does not run.
46
46
 
47
47
  **What the navigator ensure does.** `docs/ai/index.md` is the always-loaded navigator the entry point declares, and it is GENERATED — no template ships it, so a deployment that never ran the generator boots from a broken entry point (and a Node project's hook fails its index check). The ensure runs the bundled generator's finalizer and reports `regenerated` (it was missing or stale — it was written) or `already-current` (nothing written); under a hook module that is not the bundled one, a write the project's own checker rejects is put back → `customized-preserved`. It never skips a No-Node project: the generator runs from `${CLAUDE_SKILL_DIR}/references/scripts/` on the agent host, not from the project's `scripts/`. **Its position in the run-list is EARLY and therefore NOT authoritative** — the `tier` offer (and, on the migrated path, steps 6–7) may still change `docs/ai` afterwards — so the authoritative run is the LATE `--only index` rung documented at both exits; the early one is idempotent: an untouched tree changes nothing.
48
48
 
49
- **What the spec-layer ensure does.** A deployment older than the feature-spec layer lacks `scripts/spec-schema.mjs` and `docs/ai/specs/index.md`, and its deployed `check-docs-size.mjs` predates the store collapse. The four pair files follow the enforcement-script rule, with no question and no copy kept: a shipped prior is refreshed (an append-only digest catalog), an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. In ONE order: the reader pair, then the checker pair, then the store root, seeded create-only from the bundled template, date rendered — an older checker renders the store row by row and reds the hook's `--check-index`, so the checker is written first, and a write that fails stops every later one. A closing line says a commit hook that runs the files written may stop the next commit. One token by precedence: `seeded` > `refreshed` > `already-present`; `skipped-no-node-evidence` only when neither a root `package.json` nor any kit-seeded `scripts/*.mjs` is present (the same Node-evidence probe the enforcement-script ensure uses; an unreadable probe is `failed` / `node-evidence-unverifiable`). **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline the agent records), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
49
+ **What the spec-layer ensure does.** A deployment older than the feature-spec layer lacks the kit folder's spec reader and `docs/ai/specs/index.md`, and its deployed `check-docs-size.mjs` predates the store collapse. The spec layer's files in `scripts/agent-workflow/` — the three it deploys, `spec-schema/spec-schema.mjs`, `spec-schema/index.mjs` and `docs-size/check-docs-size.mjs`, no suite among them — the files they import and the stable kit command `scripts/agent-workflow/run.mjs` follow the enforcement-script rule, with no question and no copy kept: a shipped prior is refreshed (an append-only digest catalog), an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. This ensure runs before the enforcement-script ensure, so those files and `run.mjs` stand before that ensure judges the kit folder and removes the old flat files. In ONE order: the reader, then the checker, then `run.mjs`, then the store root, seeded create-only from the bundled template, date rendered — an older checker renders the store row by row and reds the hook's `--check-index`, so the checker is written first, and a write that fails stops every later one. A closing line says a commit hook that runs the files written may stop the next commit. One token by precedence: `seeded` > `refreshed` > `already-present`; Node evidence is a regular root `package.json`, or a regular file, every folder above it a plain directory, at one of the kit's flat script names in `scripts/` or at a deployed path in `scripts/agent-workflow/`; `skipped-no-node-evidence` only when the probe finds none (the same Node-evidence probe the enforcement-script ensure uses; an unreadable probe is `failed` / `node-evidence-unverifiable`). **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline the agent records), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
50
50
 
51
51
  **What the project-rules ensure does.** Each theme's kit file `docs/ai/rules/<theme>.md` is seeded, refreshed from a body a release shipped, and any other body replaced by the template with no question and no copy kept, its line naming the local rules file `docs/ai/rules/local/<theme>.md` for a rule meant to last; with no local file its effective copy and record are rebuilt. With a local file it writes neither: `pending` prints the merge to do and its record command — do the merge, show the user what changed, then run that command.
52
52
 
@@ -19,7 +19,7 @@
19
19
  // Dependency-free (one sibling import for the shared failure shape), Node >= 22. No side effects on
20
20
  // import.
21
21
 
22
- import { fail } from './markdown-blocks.mjs';
22
+ import { fail } from '../shared/index.mjs';
23
23
 
24
24
  // Each tier carries its OWN remedy, because the three run out of room for different reasons and one
25
25
  // piece of advice is wrong for two of them: COLD is already sharded per month, and WARM is a window
@@ -39,25 +39,23 @@
39
39
  // --today=YYYY-MM-DD (default today UTC) — useful for tests / reproducible runs
40
40
 
41
41
  import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync, realpathSync } from 'node:fs';
42
- import { dirname, resolve, basename } from 'node:path';
42
+ import { resolve, basename } from 'node:path';
43
43
  import { fileURLToPath } from 'node:url';
44
- import { tokenizeMarkdown, findParagraphBreak, fail } from './markdown-blocks.mjs';
44
+ import { tokenizeMarkdown, findParagraphBreak, fail, findProjectRoot } from '../shared/index.mjs';
45
45
  import { capFor, countLines, shardingWarning } from './archive-caps.mjs';
46
46
 
47
- const __filename = fileURLToPath(import.meta.url);
48
- const __dirname = dirname(__filename);
49
- const ROOT = resolve(__dirname, '..');
47
+ const ROOT = findProjectRoot(import.meta.url);
50
48
 
51
- const readProjectName = () => {
49
+ export const readProjectName = (root) => {
52
50
  try {
53
- const pkg = JSON.parse(readFileSync(resolve(ROOT, 'package.json'), 'utf8'));
51
+ const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8'));
54
52
  if (pkg.name) return pkg.name;
55
53
  } catch {
56
54
  /* no package.json — fall back to repo dir basename */
57
55
  }
58
- return basename(ROOT);
56
+ return basename(root);
59
57
  };
60
- const PROJECT_NAME = readProjectName();
58
+ const PROJECT_NAME = readProjectName(ROOT);
61
59
 
62
60
  const CHANGELOG_REL = 'docs/ai/changelog.md';
63
61
  const HISTORY_REL = 'docs/ai/history';
@@ -83,7 +83,7 @@
83
83
  // destructive --migrate --apply writes a durable snapshot to the git dir (uncommittable, the
84
84
  // review-receipts precedent) BEFORE any delete, with a stated out-of-tree fallback off git.
85
85
  //
86
- // Dependency-free, Node >= 22. Deployed into a consumer's scripts/ like its siblings.
86
+ // Dependency-free, Node >= 22. Deployed at a consumer's scripts/agent-workflow/archives/ like its siblings.
87
87
 
88
88
  import { readFileSync, writeFileSync, renameSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, realpathSync, openSync, fsyncSync, closeSync } from 'node:fs';
89
89
  import { dirname, resolve, join, posix, relative, isAbsolute } from 'node:path';
@@ -91,10 +91,12 @@ import { fileURLToPath } from 'node:url';
91
91
  import { spawnSync } from 'node:child_process';
92
92
  import { createHash, randomBytes } from 'node:crypto';
93
93
  import { tmpdir } from 'node:os';
94
- import { tokenizeMarkdown } from './markdown-blocks.mjs';
94
+ import { tokenizeMarkdown, findProjectRoot } from '../shared/index.mjs';
95
95
 
96
96
  const __dirname = dirname(fileURLToPath(import.meta.url));
97
- const DEFAULT_ROOT = resolve(__dirname, '..');
97
+ const DEFAULT_ROOT = findProjectRoot(import.meta.url);
98
+ // The command this rotator prints for itself is the stable kit command (spec kit-command).
99
+ const SELF = 'node scripts/agent-workflow/run.mjs archive-decisions';
98
100
 
99
101
  export const HOT_REL = 'docs/ai/decisions.md';
100
102
  // The retired monolith tiers — still READ during migration (their entries explode into records) and
@@ -888,16 +890,17 @@ export const writeSnapshot = (root, files, deps = {}) => {
888
890
  };
889
891
 
890
892
  // ── index regeneration (item (h) — reuse the ONE generator in check-docs-size.mjs) ──────
893
+ // A declared spawn edge to the docs-size module's CLI, resolved from this file's own directory — never an import.
891
894
 
892
- const CHECK_DOCS_SIBLING = resolve(__dirname, 'check-docs-size.mjs');
893
- const INDEX_INSTRUCT = 'run `node scripts/check-docs-size.mjs --write-index` to refresh docs/ai/index.md';
895
+ const CHECK_DOCS_SIBLING = resolve(__dirname, '..', 'docs-size', 'check-docs-size.mjs');
896
+ const INDEX_INSTRUCT = 'run `node scripts/agent-workflow/run.mjs docs-size --write-index` to refresh docs/ai/index.md';
894
897
 
895
898
  export const defaultRegenerateIndex = (root, today, deps = {}) => {
896
899
  const exists = deps.existsSync ?? existsSync;
897
900
  const spawn = deps.spawnSync ?? spawnSync;
898
901
  const sibling = deps.sibling ?? CHECK_DOCS_SIBLING;
899
902
  if (!exists(sibling)) {
900
- return { ok: false, detail: `the index generator is not beside this script — ${INDEX_INSTRUCT}` };
903
+ return { ok: false, detail: `the index generator is not beside this script — an upgrade places the docs checker; then ${INDEX_INSTRUCT}` };
901
904
  }
902
905
  const r = spawn(process.execPath, [sibling, '--write-index', '--report', `--root=${root}`, `--today=${today}`], { encoding: 'utf8' });
903
906
  if (r.error || r.status !== 0) {
@@ -1187,7 +1190,7 @@ const runCheck = (root, today, log, logError) => {
1187
1190
  // absent) is a half-migrated / half-deleted tree, never a clean "no substrate" skip.
1188
1191
  const present = monolithsPresent(root);
1189
1192
  if (present.length > 0) {
1190
- logError(`[archive-decisions] FAIL: legacy monolith present (${present.join(', ')}) — the ADR store is half-migrated; run \`node scripts/archive-decisions.mjs --migrate --apply\` first.`);
1193
+ logError(`[archive-decisions] FAIL: legacy monolith present (${present.join(', ')}) — the ADR store is half-migrated; run \`${SELF} --migrate --apply\` first.`);
1191
1194
  return 1;
1192
1195
  }
1193
1196
  if (!hasHot && !hasStore) {
@@ -1211,7 +1214,7 @@ const runCheck = (root, today, log, logError) => {
1211
1214
  // Arm B: the verdict names the parsed unit count, not just raw lines — with the loud parse
1212
1215
  // path, zero can only mean genuinely empty, never a populated file read as nothing.
1213
1216
  log(`[archive-decisions] ${HOT_REL}: ${hot.rawLines}/${hot.cap} lines, ${hot.entries.length} ADR(s) in the HOT window`);
1214
- if (hot.cap !== null && hot.rawLines > hot.cap) problems.push(`${HOT_REL} is over its cap (${hot.rawLines}/${hot.cap}) — run \`node scripts/archive-decisions.mjs\` to explode the oldest entries`);
1217
+ if (hot.cap !== null && hot.rawLines > hot.cap) problems.push(`${HOT_REL} is over its cap (${hot.rawLines}/${hot.cap}) — run \`${SELF}\` to explode the oldest entries`);
1215
1218
  }
1216
1219
  log(`[archive-decisions] ${ADR_DIR_REL}: ${adrEntries.length} record(s)`);
1217
1220
 
@@ -1222,7 +1225,7 @@ const runCheck = (root, today, log, logError) => {
1222
1225
  const expected = buildNavigator(corpus, existsSync(navPath) ? navLastUpdated(readFileSync(navPath, 'utf8')) : today);
1223
1226
  const onDisk = existsSync(navPath) ? readFileSync(navPath, 'utf8') : null;
1224
1227
  if (onDisk !== expected) {
1225
- problems.push(`${NAV_REL} is stale (out of sync with the ADR corpus) — run \`node scripts/archive-decisions.mjs --write-navigator\` and commit it`);
1228
+ problems.push(`${NAV_REL} is stale (out of sync with the ADR corpus) — run \`${SELF} --write-navigator\` and commit it`);
1226
1229
  }
1227
1230
 
1228
1231
  problems.push(...collectReferenceViolations(root, new Set(hotEntries.map((e) => e.id)), new Set(adrEntries.map((e) => e.id))));
@@ -1238,7 +1241,7 @@ const runCheck = (root, today, log, logError) => {
1238
1241
  const runRotate = (root, flags, today, deps, log, logError) => {
1239
1242
  const present = monolithsPresent(root);
1240
1243
  if (present.length > 0) {
1241
- logError(`[archive-decisions] FAIL: legacy monolith present (${present.join(', ')}) — the ADR store is half-migrated; run \`node scripts/archive-decisions.mjs --migrate --apply\` first (a default rotate never half-explodes).`);
1244
+ logError(`[archive-decisions] FAIL: legacy monolith present (${present.join(', ')}) — the ADR store is half-migrated; run \`${SELF} --migrate --apply\` first (a default rotate never half-explodes).`);
1242
1245
  return 1;
1243
1246
  }
1244
1247
  const plan = planRotation(root, today);