@sabaiway/agent-workflow-kit 16.1.0 → 18.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,81 @@ 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
+ ## 18.0.0 — the kit's two hook files are written current within a hook you wired; `gate-hook --reseed` and three advisor items retire (AD-209)
8
+
9
+ **MAJOR: `gate-hook.mjs --reseed` is removed, and the advisor's `gate-hook.marker-stale`, `read-lane.stale` and
10
+ `read-lane.missing` items are gone.** Before, a placed gate hook that differed from the kit's was preserved by
11
+ `gate-hook --apply`; the advisor offered the reseed route, on your yes, in two states only: a declaration carrying
12
+ `lcovProducer`, and an enabled read-lane. A wired gate hook whose file was missing got `read-lane.missing`, whose apply
13
+ was `gate-hook --apply`; a wired state-block hook whose file was missing was never offered at all. Now one rule covers
14
+ both kit hook files, `.claude/hooks/agent-workflow-gates.mjs` and `.claude/hooks/state-block-guard.mjs`: within a hook
15
+ you wired (for the gate hook, a `PreToolUse` `Bash` entry running its command; for the state-block hook, a `Stop` entry
16
+ whose command names `state-block-guard.mjs`, whichever copy it runs — in `.claude/settings.json` or
17
+ `.claude/settings.local.json`), an absent file is placed and one whose bytes
18
+ differ is written with the body the kit writes for it, in place, with no question and no copy kept. Wiring stays
19
+ yours: an unwired hook keeps its `gate-hook` or `state-block` offer and your yes.
20
+
21
+ - **Two new kit items, `gate-hook.not-current` and `state-block.not-current`.** Over a wired hook whose file is absent
22
+ or differs, the advisor renders this `lane: kit` item, which the agent applies with no question by the kit route. Its
23
+ text reads `<the hook file> is absent or differs from the body the kit writes for it — written with that body, with
24
+ no question`, and its detail names the one file its apply writes. A stale stamp beside it is the upgrade-first skip.
25
+ - **`gate-hook --apply` writes a differing file.** It places an absent hook file, writes a differing one with the
26
+ bundled body in place, leaves a current one, and wires the entry only while it is wired in neither settings file —
27
+ so over a wired hook it writes the file alone. A differing file under an unwired hook is no longer refused: your yes
28
+ to the offer writes and wires it.
29
+ - **The line.** A differing kit hook file reads `differs from the body the kit writes for it — written with that body;
30
+ a hook of your own goes in .claude/hooks/<name>.local.mjs` (on a dry run, `would be written with that body`), from
31
+ both hook writers. No line says preserved or reseed.
32
+ - **The danger check** for a kit hook item admits only that hook file and its folders, and only while it judges the
33
+ hook wired; over an unwired hook it admits nothing (`refused:`, exit 1), so the no-question apply never wires a hook.
34
+ - **`read-lane` is the enable offer alone.** It renders while the hook is wired and the lane is off; a stale or absent
35
+ hook under it is written by `gate-hook.not-current` first. The `--read-lane` currency refusal now names
36
+ `gate-hook --apply`.
37
+ - **`--reseed` is gone, with no alias.** `gate-hook.mjs --reseed` now stops with `unknown argument: --reseed`, exit 2.
38
+ No migration note is owed: every line that printed it — the retired items `gate-hook.marker-stale` and
39
+ `read-lane.stale`, the writer's refusals, its diverged line and `--help` — is gone or now names `gate-hook --apply`,
40
+ and a script that ran `--apply --reseed` runs `gate-hook.mjs --apply`.
41
+ - **The texts say the same.** The writer's header and `--help`; the hook, gates, state-block-guard and recommendations
42
+ modes; `references/advisor-writers.md`; the README's hook and state-block-guard rows; the guide's *Reserved names and
43
+ channels*, which names the two hook files and gains a seventh channel, `.claude/hooks/<name>.local.mjs`, for a hook
44
+ of your own, which you wire.
45
+
46
+ ## 17.0.0 — every kit agent file is written current with no question; `--executor` and `executor-vehicle.differing` retire (AD-208)
47
+
48
+ **MAJOR: `cheap-agents.mjs --executor` is removed, and the advisor's `executor-vehicle.differing` item is gone.** Before,
49
+ a placed cheap vehicle or roster-derived lens whose bytes differed from the kit's was `customized — preserved` forever,
50
+ a differing bundled `review-lens.md` was re-derived only on your yes to the `agents` item, and only the executor had a
51
+ no-question route. Now one rule covers every kit agent file — the five names the
52
+ kit bundles for `.claude/agents/` (`changelog-skeleton.md`, `executor.md`, `gate-triage.md`, `mechanical-sweep.md`,
53
+ `review-lens.md`) and each configured `review-lens-<model>-<effort>.md`: an absent one is placed, one whose bytes
54
+ differ is written with the body the kit writes for it, a current one is left, with no question and no copy kept.
55
+ Every other file under `.claude/agents/` is yours, and no kit tool writes it.
56
+
57
+ - **A new kit item, `agents.not-current`.** Over a placed component (a kit agent path holds a regular file) the
58
+ advisor's `agents` key renders this `lane: kit` item, which the agent applies with no question by the kit route. Its
59
+ text reads `{n} kit agent file(s) in .claude/agents/ not current — each is written with the body the kit writes for
60
+ it, with no question`, and its `recipe:` line names every file the apply writes. Over a component not placed the
61
+ `agents` offer is unchanged, and your yes to it is what places the component.
62
+ - **The lines.** A differing executor keeps, and a differing bundled `review-lens.md` now takes, `differs from the body
63
+ derived from the vehicle settings — written with that body; its model and effort are set in docs/ai/vehicles.json`. Every other kit agent file
64
+ reads `differs from the body the kit writes for it — written with that body; a vehicle of your own goes in
65
+ .claude/agents/<name>.local.md with a name: of its own`. No line says customized or preserved.
66
+ - **A link stops the run.** A link, another non-regular node or an unreadable file at a kit agent path stops the writer
67
+ naming it, in a dry run too, with nothing written; the advisor states that refusal as a skip. Every write is contained
68
+ and atomic.
69
+ - **The danger check** for `agents.not-current` admits only the kit agent paths, and over a tree with no placed kit
70
+ agent file it admits none (`refused:`, exit 1), so the no-question apply never places a component you never accepted.
71
+ - **The base `executor-vehicle` item yields** to `agents.not-current`, whose apply writes the executor: the two never
72
+ render for one tree.
73
+ - **`--executor` is gone, with no alias.** `cheap-agents.mjs --executor` now stops with `unknown argument: --executor`,
74
+ exit 2. No migration note is owed: its printed caller, the advisor's `executor-vehicle.differing` item, retires with
75
+ it, and the `agents` item now writes the executor; a script that ran `--executor --apply` runs `cheap-agents.mjs
76
+ --apply`, which writes every kit agent file that is not current.
77
+ - **The texts say the same.** The executor ensure's `pending` and `not-placed` lines and the `ensure-configs.mjs` help
78
+ name the advisor's `agents` item; the writer's header and `--help`; the agents, upgrade and recommendations modes;
79
+ `references/advisor-writers.md`; the README's agents row; the guide's *Reserved names and channels*, which names the
80
+ kit agent files and gains a sixth channel, `.claude/agents/<name>.local.md`, for a vehicle of your own.
81
+
7
82
  ## 16.1.0 — the agent writes a differing executor vehicle with no question: a new advisor lane `kit` (AD-207)
8
83
 
9
84
  **A placed `.claude/agents/executor.md` that differs from the body derived from `docs/ai/vehicles.json` is now
package/README.md CHANGED
@@ -263,9 +263,9 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
263
263
  | `/agent-workflow-kit worktrees` | any time | **parallel feature worktrees** — run several features in DIFFERENT agent sessions on one repo, zero interference on working-tree files (the ONE exception is the dependency cache, below): `provision <slug> --plan <file>` creates a sibling git worktree on branch `aw/<slug>` and populates it (registry-derived footprint copy-if-missing — a tracked file is never overwritten; EXACTLY ONE seeded feature plan; the `handoff-<slug>.md` record from minute zero; `node_modules` symlinked where the link stays ignored — a shared MUTABLE dependency cache: writes through it hit MAIN's node_modules; for isolation run the printed isolated-install command (`--install` only PRINTS it; on `--resume` run the printed unlink-first recovery first — printed only for a link whose RAW TARGET is MAIN's `node_modules`, since a foreign or unreadable link is reported as such with no removal advised); absolute root-pinned gate commands rebased on untracked copies only, and only while their bytes equal the MAIN source or its rebased form — user-modified copies stay untouched); `list` is read-only (slug, branch, base, dirty, handoff); `prompt <slug>` is read-only too and re-prints the satellite's cold-start prompt — the same text `provision` ends its report with: where the worktree is, its ONE seeded plan, the handoff as the one channel back, MAIN's orientation (shared series index, landing) and, under its own heading because it is probed on the satellite, that checkout's install posture — every value derived LIVE rather than replayed from the frozen provision record, a recorded value that no longer matches NAMED as a divergence (with the cause its source makes likely) instead of printed as the runnable one, every offered command marked with WHO runs it (`MAIN $ …` for the landing, `HERE $ …` for this checkout's own install, a posture with nothing to run staying prose), and a control character in any rendered value a typed STOP rather than a forged prompt line; `land <slug> --prepare` locks the common git dir, fail-closes on divergence or incomplete satellite state, transfers the complete accepted satellite diff onto a CLEAN main, runs sync plus the declared gates, and reports HEAD/TRANSFER/PREPARED OIDs — the commit ALWAYS stays a dialogue ask; `cleanup <slug>` takes the same lock and removes a LANDED worktree only after live landed-verification against main HEAD, while `--abandon` is the ONE destructive arm (destroys unlanded work; **no preview step** on any writer). The parent dir is the `docs/ai/worktrees.json` `parentDir` setting (default: the repo's sibling parent); an unwritable parent prints the `worktrees-dir` check line: the agent applies the grant on your chat yes after the check, one entry in this copy's `.claude/settings.local.json`, never the committed project settings (`init` is the route you may take instead, and the ack is the fallback for a host that ignores the key), else the printed terminal command runs it. Never commits, never pushes, never runs a subscription CLI. |
264
264
  | `/agent-workflow-kit uninstall` | opt-in, any time | **guarded teardown** — the inverse of `init` / `setup`. Removes only what's **provably ours** (managed skill dirs + bridge wrappers; in a project, the hidden-mode git-ignore block it added + the pre-commit hook it installed); **never deletes** your `docs/ai` / `AGENTS.md` (prints the exact `rm` to run by hand) or your `.claude/settings.json` (prints an **edit** — remove the attribution key, review any velocity `permissions.*` — never an `rm`). Always `--dry-run` first; preflight-then-mutate; never commits. |
265
265
  | `/agent-workflow-kit velocity` | Claude Code · opt-in | **onboarding velocity profile** — seeds a fixed, audited **read-only** allowlist into `.claude/settings.json` so routine read-only commands stop idling on approval prompts while you're away; every allowlist apply (flagless, `--kit-tools`, `--bridge-tier`) also seeds one `permissions.ask` rule, so all work can stay in auto mode: without it auto mode refuses a harness or kit apply (the `apply:` line of each harness or kit item the upgrade advisor renders) and you must leave auto mode for it; with it the harness shows its usual dialog — the rule allows nothing; opt-in `acceptEdits`; plus a **read-only advisory** of likely project gate commands to add by hand. Writes `.claude/settings.json`; a fourth opt-in, `--worktrees`, writes the worktrees grant into the local settings, `.claude/settings.local.json`, alone — **never** allowlists commit/push/publish, never commits. A seeded entry is a **trust posture, not a sandbox** (a runtime residual remains at the settings level — its guard ships as the opt-in `hook` command); a direct commit/push/publish still asks. `--dry-run` first. |
266
- | `/agent-workflow-kit agents` | Claude Code · opt-in | **subagent vehicles** — places the five bundled subagent definitions into `.claude/agents/`: **four read-only vehicles + one full-tool `executor`**. **No read-only vehicle gets `Bash`**, and that is the load-bearing property: a read-only fan-out on a full-tool subagent shells out for facts it could have read, and every shelled command is an approval prompt you never needed to see. Three of the four ride a **cheap model** (haiku, low effort) for mechanical work — extraction sweeps, changelog fact-skeletons, gate-failure triage; the fourth, **`review-lens`**, is an ADDITIONAL independent read-only review opinion on code your configured backends have already seen (never a replacement for your plan or diff review recipe, advisory like every review; an epic is reviewed by the lens alone, whatever `epic.review` resolves to). The fifth, **`executor`** (all tools; model and effort from `docs/ai/vehicles.json`), is the ONE vehicle with a shell and the instrument behind the **Subagent** recipe: dispatched only for a bounded, file-disjoint execution / authoring / routine slice you verify afterwards — never for read-only work, never as a review backend, and it never commits. Its state (`placed` / `customized` / `unusable` / `missing`) is what a `subagent` slot's readiness resolves from. Writing code and running gates stay off the four read-only vehicles; the executor carries a bounded slice you re-verify on your main lane, and every vehicle's output is verified. Preview by default (`--apply` writes); an existing customized read-only vehicle or roster-derived lens is **preserved, never overwritten**; the executor's body and the bundled `review-lens`'s (opus / high by default, set in the file's optional `review-lens` section) are re-derived from `docs/ai/vehicles.json` (the earlier body is replaced); never touches `settings*.json`, never commits. |
267
- | `/agent-workflow-kit hook` | Claude Code · opt-in | **gate-approval hook** — places a self-contained PreToolUse hook (`.claude/hooks/`) and wires it into `.claude/settings.json`: a Bash command **byte-identical** to a gate you declared in `docs/ai/gates.json` (run from the project root) is auto-approved — no prompt, no idle; a seeded read-only command carrying a runtime residual (output redirection, command substitution, `--output` writes) now **asks** even where an allow rule would have silently passed it (proven live — hook `ask` overrides an allow rule). Detection is a conservative string scan, so it over-asks on a byte that is ordinary text — searching for `=>`, or a read wearing `2>/dev/null`, prompts. That is a documented open limit: 4.1.0 built three mechanisms to narrow it and removed all three in review, each counterexample kept as a test (see Mode: hook). Exact matches only, never patterns; never `deny`; a broken `gates.json` only disables auto-approval, never the guard. An opt-in **read-lane** (`--read-lane` → `docs/ai/lanes.json`, a **separate** file from `gates.json`) additionally auto-approves *compounds* of seeded read-only commands carrying no shell metaprogramming; `--apply --read-lane` verifies the placed hook is current first; a stale or diverged placed hook is replaced by the reseed route (`--apply --reseed`, the bundled bytes in place). Preview by default; never writes `settings.local.json`; never commits. |
268
- | `/agent-workflow-kit state-block-guard` | Claude Code · opt-in | **closing-block detector** — a `Stop` hook that reads the turn's final assistant message and warns when the closing state block is defective: the «what I need from you» slot answering *nothing* (a turn that ENDS always needs a resume, so the answer is false, not merely unhelpful), or a first-person promise of imminent work in a turn that is over. Judged on the slot's first clause, so a real ask followed by a clause break and "nothing else" passes, and a promise gated on something named passes; matching is word-bounded and Unicode-aware, quoted and fenced examples are stripped, and the last STARTED block decides — an incomplete tail counts as no block rather than falling back to an earlier one. A message carrying no block at all is silent unless you pass `--require-block` — this kit does not mandate the block, and a hook that runs every turn must not warn every turn. The judgement is lexical and the mode doc names every residual it leaves. **Detection, never prevention** — a `Stop` hook cannot un-send the message it judges; what it buys is that a silent recurrence becomes a visible one. Warns via `systemMessage` and **exits 0 on every path**: never `deny`, never blocks the stop, never re-enters the model. Reads nothing but the message, makes no network call, approves nothing. Its writer is `tools/state-block-hook.mjs`: it places the self-contained hook and merges its `Stop` entry into `.claude/settings.json` by the three merge cases, keeping every foreign hook — the agent applies it on the chat yes after the danger check. |
266
+ | `/agent-workflow-kit agents` | Claude Code · opt-in | **subagent vehicles** — places the five bundled subagent definitions into `.claude/agents/`: **four read-only vehicles + one full-tool `executor`**. **No read-only vehicle gets `Bash`**, and that is the load-bearing property: a read-only fan-out on a full-tool subagent shells out for facts it could have read, and every shelled command is an approval prompt you never needed to see. Three of the four ride a **cheap model** (haiku, low effort) for mechanical work — extraction sweeps, changelog fact-skeletons, gate-failure triage; the fourth, **`review-lens`**, is an ADDITIONAL independent read-only review opinion on code your configured backends have already seen (never a replacement for your plan or diff review recipe, advisory like every review; an epic is reviewed by the lens alone, whatever `epic.review` resolves to). The fifth, **`executor`** (all tools; model and effort from `docs/ai/vehicles.json`), is the ONE vehicle with a shell and the instrument behind the **Subagent** recipe: dispatched only for a bounded, file-disjoint execution / authoring / routine slice you verify afterwards — never for read-only work, never as a review backend, and it never commits. Its state (`placed` / `customized` / `unusable` / `missing`) is what a `subagent` slot's readiness resolves from. Writing code and running gates stay off the four read-only vehicles; the executor carries a bounded slice you re-verify on your main lane, and every vehicle's output is verified. Preview by default (`--apply` writes); every kit agent file (the five bundled names and each configured roster-derived lens) is **written current with no question** — an absent one placed, a differing one written with the body the kit writes for it, the executor's and the bundled `review-lens`'s (opus / high by default, set in the file's optional `review-lens` section) derived from `docs/ai/vehicles.json`, no copy kept; a link at a kit agent path stops the run naming it, nothing written; a vehicle of your own goes in `.claude/agents/<name>.local.md` with a `name:` of its own; never touches `settings*.json`, never commits. |
267
+ | `/agent-workflow-kit hook` | Claude Code · opt-in | **gate-approval hook** — places a self-contained PreToolUse hook (`.claude/hooks/`) and wires it into `.claude/settings.json`: a Bash command **byte-identical** to a gate you declared in `docs/ai/gates.json` (run from the project root) is auto-approved — no prompt, no idle; a seeded read-only command carrying a runtime residual (output redirection, command substitution, `--output` writes) now **asks** even where an allow rule would have silently passed it (proven live — hook `ask` overrides an allow rule). Detection is a conservative string scan, so it over-asks on a byte that is ordinary text — searching for `=>`, or a read wearing `2>/dev/null`, prompts. That is a documented open limit: 4.1.0 built three mechanisms to narrow it and removed all three in review, each counterexample kept as a test (see Mode: hook). Exact matches only, never patterns; never `deny`; a broken `gates.json` only disables auto-approval, never the guard. An opt-in **read-lane** (`--read-lane` → `docs/ai/lanes.json`, a **separate** file from `gates.json`) additionally auto-approves *compounds* of seeded read-only commands carrying no shell metaprogramming; `--apply --read-lane` verifies the placed hook is current first. Within a hook you wired, its file is placed when absent and written with the kit's body when it differs, with no question and no copy kept (the upgrade's `gate-hook.not-current`); a hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire. Preview by default; never writes `settings.local.json`; never commits. |
268
+ | `/agent-workflow-kit state-block-guard` | Claude Code · opt-in | **closing-block detector** — a `Stop` hook that reads the turn's final assistant message and warns when the closing state block is defective: the «what I need from you» slot answering *nothing* (a turn that ENDS always needs a resume, so the answer is false, not merely unhelpful), or a first-person promise of imminent work in a turn that is over. Judged on the slot's first clause, so a real ask followed by a clause break and "nothing else" passes, and a promise gated on something named passes; matching is word-bounded and Unicode-aware, quoted and fenced examples are stripped, and the last STARTED block decides — an incomplete tail counts as no block rather than falling back to an earlier one. A message carrying no block at all is silent unless you pass `--require-block` — this kit does not mandate the block, and a hook that runs every turn must not warn every turn. The judgement is lexical and the mode doc names every residual it leaves. **Detection, never prevention** — a `Stop` hook cannot un-send the message it judges; what it buys is that a silent recurrence becomes a visible one. Warns via `systemMessage` and **exits 0 on every path**: never `deny`, never blocks the stop, never re-enters the model. Reads nothing but the message, makes no network call, approves nothing. Its writer is `tools/state-block-hook.mjs`: it places the self-contained hook and merges its `Stop` entry into `.claude/settings.json` by the three merge cases, keeping every foreign hook — the agent applies it on the chat yes after the danger check. Within the wired hook its runtime file is written with the kit's body when absent or differing, with no question (the upgrade's `state-block.not-current`); a hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire. |
269
269
  | `/agent-workflow-kit bridge-settings` | opt-in, any time | **host-level bridge settings** — read or change the bridges' `KEY=VALUE` config file (`${XDG_CONFIG_HOME:-~/.config}/agent-workflow/bridge-settings.conf`), the **one place a knob survives kit upgrades** (it lives outside every kit tree; a refresh never touches it, and now states loudly if it ever overwrote a local edit). The **model each bridge runs**: `CODEX_MODEL` + `CODEX_EFFORT` (default `gpt-6.1-sol` at `high`) and `AGY_MODEL` (default `Gemini 3.8 Flash (High)`) — the read-out shows the models each installed CLI offers, and a set one is checked against that list before anything is written. Other knobs: the **codex Fast tier** (`CODEX_SERVICE_TIER=priority` — "2x speed, **increased usage**" in the catalog's own words, quality-neutral, default off — a consented spend), the codex/agy hard timeouts, the codex review byte cap, and `AGY_REVIEW_MAX_TOTAL_BYTES` (the ceiling on what an oversized agy code review may feed before it refuses pre-spend). `AGY_REVIEW_ALLOW_ADDDIR` is a **retired** compatibility key: still recognized so an existing line never warns as unknown, but it arms nothing — the writer refuses to set it and `--unset` clears it. Allowed keys + value rules come from the bundled bridge manifests. **Previews by default**; refuses an unknown key, an out-of-range value, a model or effort the catalog does not offer, or a duplicate-carrying file; writes atomically (symlink/TOCTOU-safe). Never commits, never runs a model (only the read-only catalog commands). |
270
270
  | `/agent-workflow-kit autonomy-doctor` | opt-in, any time | **guarded sandbox provisioner "doctor"** — can this machine run the Claude sandbox, and (only with your consent) fix it: macOS Seatbelt built-in / Linux+WSL2 needs `bwrap`+`socat` / native Windows → WSL2. Flagless = **FS-only preview** (the diagnosis, the exact absolute-path command it WOULD run, the exact `--apply <pm>:<pkgs>` consent tuple — runs nothing, never claims ready); `--verify` runs the unprivileged proof (a `bwrap` user-namespace smoke + `socat -V`) — the **only** source of a Linux "ready (verified)" claim; `--apply <pm>:<pkgs>` is the consent-gated privileged install (the tuple must equal the previewed plan; everything executed resolves to absolute paths inside `/usr/bin:/bin:/usr/sbin:/sbin`; the exact command is re-printed immediately before execution), then verifies. Honest loud degrades (unknown PM, untrusted location, nested-sandbox INDETERMINATE, root-unproven) and a stated restart step. Sits **outside every velocity auto-approve tier**; never auto-runs, never writes repo files, never commits. |
271
271
 
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: '16.1.0'
6
+ version: '18.0.0'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
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": "16.1.0",
6
+ "version": "18.0.0",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "16.1.0",
3
+ "version": "18.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",
@@ -25,19 +25,18 @@
25
25
  | source-size.schema-1 | chat | source-size-check.mjs |
26
26
  | source-size.layout | chat | source-size-check.mjs |
27
27
  | gate-hook | harness | gate-hook.mjs |
28
- | gate-hook.marker-stale | harness | gate-hook.mjs |
28
+ | gate-hook.not-current | kit | gate-hook.mjs |
29
29
  | commit-guard | harness | git-hooks.mjs |
30
30
  | hook-checks | harness | git-hooks.mjs |
31
31
  | enforcement | harness | git-hooks.mjs |
32
32
  | read-lane | chat | gate-hook.mjs |
33
- | read-lane.stale | harness | gate-hook.mjs |
34
- | read-lane.missing | harness | gate-hook.mjs |
35
33
  | state-block | harness | state-block-hook.mjs |
34
+ | state-block.not-current | kit | state-block-hook.mjs |
36
35
  | mcp-channel | harness | mcp.mjs |
37
36
  | mcp-channel.differing | harness | mcp.mjs |
38
37
  | agents | harness | cheap-agents.mjs |
38
+ | agents.not-current | kit | cheap-agents.mjs |
39
39
  | executor-vehicle | harness | cheap-agents.mjs |
40
- | executor-vehicle.differing | kit | cheap-agents.mjs |
41
40
  | attribution | harness | attribution.mjs |
42
41
  | footprint-global | harness | hide-footprint.mjs |
43
42
  | family-freshness | user | user step |
@@ -96,10 +96,14 @@ On `upgrade`, a pre-1.2.0 deployment with no block gets one (the agent asks, def
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
97
  customization: every kit script, the spec layer's four pair files (`scripts/spec-schema.mjs`,
98
98
  `scripts/spec-schema.test.mjs`, `scripts/check-docs-size.mjs`, `scripts/check-docs-size.test.mjs`)
99
- included, the hook installer set and the kit rules files `docs/ai/rules/<theme>.md` are written
100
- over by the next upgrade with no question and no copy kept. A declaration seeded once from a template and never
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`,
101
+ `gate-triage.md`, `mechanical-sweep.md`, `review-lens.md` — and each configured
102
+ `review-lens-<model>-<effort>.md`) and, within a hook you wired, the kit hook files
103
+ `.claude/hooks/agent-workflow-gates.mjs` and `.claude/hooks/state-block-guard.mjs` are written over
104
+ by the next upgrade with no question and no copy kept. A declaration seeded once from a template and never
101
105
  replaced by the upgrade's ensures (a migration rewrites one only on the user's explicit yes) is the
102
- user's own file. A customization goes into one of five channels instead:
106
+ user's own file. A customization goes into one of seven channels instead:
103
107
 
104
108
  - **Your own commit checks** go in the local hook file `scripts/pre-commit.local`: the managed
105
109
  pre-commit hook runs it first, once the installer has run.
@@ -107,6 +111,9 @@ user's own file. A customization goes into one of five channels instead:
107
111
  - **A setting** goes in a config a script reads.
108
112
  - **Your own rules** go in the local rules file `docs/ai/rules/local/<theme>.md`.
109
113
  - **An agent's model** goes in the vehicle settings `docs/ai/vehicles.json`.
114
+ - **A vehicle of your own** goes in `.claude/agents/<name>.local.md` with a `name:` of its own, which
115
+ no review roster names; a lens of your own in a review slot keeps a stem of its own.
116
+ - **A hook of your own** goes in `.claude/hooks/<name>.local.mjs`, which you wire.
110
117
 
111
118
  No path segment of a file the kit bundles and places as its own has a dot-separated part exactly
112
119
  `local`; a path of that form is the user's, and no kit tool writes one on its own. Outside that rule:
@@ -14,12 +14,14 @@ Writing code, running gates, and user-facing copy never move to these four vehic
14
14
 
15
15
  **The fifth vehicle, `executor`, is the ONE full-tool one** (model and effort from `docs/ai/vehicles.json` — `opus` / `high` by default — and every tool, a shell included). It is the instrument behind the **Subagent** recipe, dispatched ONLY for a **bounded, file-disjoint slice** the orchestrator verifies afterwards by running its suites: a slice of execution (`plan-execution.execute`), a plan/contract authoring brief (`plan-authoring.author`), an authoring-round fold (`plan-authoring.fold`), a bounded chore (`routine.carrier`), an epic brief (`epic.author`), or one prompt the orchestrator wrote from one ledger row, run inside its Files (`task.execute`); `task.author` dispatches no slice, since the orchestrator writes each row's prompt itself. It **never commits** (no git write at all), is **never a review backend**, is **never a bridge substitute**, and is **never dispatched for read-only work** — a sweep, an inventory or a review rides a read-only vehicle instead.
16
16
 
17
- **Its readiness is the vehicle FILE.** `surveyExecutorVehicle` answers exactly one of four states: **`placed`** (bytes equal to the body derived from `docs/ai/vehicles.json` at `.claude/agents/executor.md`), **`customized`** (a readable regular file whose frontmatter names `executor` and whose tools are not read-only), **`unusable`** (a symlink, a non-regular or unreadable file, one failing that check, or an unreadable `docs/ai/vehicles.json` — with the reason), **`missing`**. `placed` and `customized` are dispatchable; on `unusable` or `missing` a `subagent` slot **degrades to Solo** with a reason naming this mode's apply command (and `docs/ai/vehicles.json` when that file is unreadable). `/agent-workflow-kit status` shows the state in its `agents` block and the deployment advisor raises it when a configured slot names `subagent` and the vehicle is `unusable` or `missing` — that item is **`executor-vehicle`** (attention-class: a configured declaration that is broken), a DIFFERENT capability from this mode's placement offer (`agents`), which converges the moment nothing is left to place and the bundled review lens matches its derived body, and therefore can never observe a present-but-unusable vehicle. It is a claim about the FILE, never about the host: a Claude Code lane, like this mode itself.
17
+ **Its readiness is the vehicle FILE.** `surveyExecutorVehicle` answers exactly one of four states: **`placed`** (bytes equal to the body derived from `docs/ai/vehicles.json` at `.claude/agents/executor.md`), **`customized`** (a readable regular file whose frontmatter names `executor` and whose tools are not read-only), **`unusable`** (a symlink, a non-regular or unreadable file, one failing that check, or an unreadable `docs/ai/vehicles.json` — with the reason), **`missing`**. `placed` and `customized` are dispatchable; on `unusable` or `missing` a `subagent` slot **degrades to Solo** with a reason naming this mode's apply command (and `docs/ai/vehicles.json` when that file is unreadable). `/agent-workflow-kit status` shows the state in its `agents` block and the deployment advisor raises it when a configured slot names `subagent` and the vehicle is `unusable` or `missing` — that item is **`executor-vehicle`** (attention-class: a configured declaration that is broken). It yields to the `agents` key's `agents.not-current`, which writes the executor in a placed component — a regular executor whose bytes differ, the check failing or not — so the two never render for one tree; over a component not placed the `agents` offer places the executor and `executor-vehicle` names the solo degrade beside it. It is a claim about the FILE, never about the host: a Claude Code lane, like this mode itself.
18
18
 
19
- Run `node ${CLAUDE_SKILL_DIR}/tools/cheap-agents.mjs [--dry-run | --apply] [--executor] [--cwd <dir>]`:
19
+ **Every kit agent file is written current with no question.** The kit agent files are the five bundled names and every configured roster-derived lens `review-lens-<model>-<effort>.md`; an absent one is placed, one whose bytes differ is written with the body the kit writes for it, no copy kept, and a current one is left. Every other file under `.claude/agents/` is yours and no kit tool writes it: a vehicle of your own goes in `.claude/agents/<name>.local.md` with a `name:` of its own (Claude Code knows a subagent by its `name:` alone).
20
20
 
21
- 1. **`--dry-run` first, always** (the default — changes nothing). It previews, per bundled vehicle, whether it **would place** the file, finds it **already current**, or finds a **customized** file (different content) that will be **preserved, never overwritten** (delete the file to reseed it from the bundle) — except the executor and the bundled `review-lens`, whose differing bytes are rewritten on `--apply` with the body derived from `docs/ai/vehicles.json` (the earlier body is replaced, never preserved). The executor's line reads `.claude/agents/executor.md: differs from the body derived from the vehicle settings — would be written with that body; its model and effort are set in docs/ai/vehicles.json` (on `--apply`, `written with that body`). The lens takes its model and effort from that file's optional `review-lens` section — `opus` / `high` by default — and the report prints its posture line beside the executor's.
22
- 2. **Only on an explicit yes**, re-run with `--apply`. It writes **only** under `.claude/agents/` — never `settings.json` / `settings.local.json`, never a commit. `--apply` is deployment-gated (the stamp must be at the lineage head) and symlink-safe (a symlinked project root / `.claude` / `.claude/agents` / target file is a STOP, in a `--dry-run` too). **`--executor`** is the form of the advisor's `executor-vehicle.differing` kit item, which the agent applies with no question: it plans the executor alone and reads no orchestration config, so its `--apply` writes `.claude/agents/executor.md` and no other file.
23
- 3. **Hidden-mode deployments:** after an apply without `--executor`, run the hide-footprint reconcile (`node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --reconcile`) so the placed files stay invisible to `git status` — `/.claude/agents/` is in the known-footprint registry; the apply report reminds you.
21
+ Run `node ${CLAUDE_SKILL_DIR}/tools/cheap-agents.mjs [--dry-run | --apply] [--cwd <dir>]`:
24
22
 
25
- **Invariants:** writer (writes only `.claude/agents/`) · preview by default · a diverged existing file is reported and preserved, never clobbered — except the executor and the review lens, re-derived from `docs/ai/vehicles.json` on apply · never touches settings · never commits · **no READ-ONLY vehicle grants `Bash`, and exactly one bundled vehicle, `executor`, grants a shell** · the cheap-lane vehicles are pinned to `model: haiku` + `effort: low`, and the bundled review lens file is pinned OFF the cheap model (`opus` / `high`), its placed copy taking the posture `docs/ai/vehicles.json` sets — `opus` / `high` when unset (all content-tested).
23
+ 1. **`--dry-run` first, always** (the default — changes nothing). It previews, per kit agent file, whether it **would place** the file, finds it **already current**, or finds its bytes differ. The executor's and the bundled `review-lens`'s line reads `<rel>: differs from the body derived from the vehicle settings — would be written with that body; its model and effort are set in docs/ai/vehicles.json`; every other kit file's reads `<rel>: differs from the body the kit writes for it — would be written with that body; a vehicle of your own goes in .claude/agents/<name>.local.md with a name: of its own` (on `--apply`, `written with that body`). The lens takes its model and effort from that file's optional `review-lens` section — `opus` / `high` by default — and the report prints its posture line beside the executor's.
24
+ 2. **`--apply`** writes what the preview named. Over a placed component the advisor's `agents.not-current` item applies this `--apply` through the kit route with no question; the first placement is the yes to the advisor's `agents` offer. It writes **only** under `.claude/agents/`, each write contained and atomic — never `settings.json` / `settings.local.json`, never a commit. `--apply` is deployment-gated (the stamp must be at the lineage head). A symlinked project root / `.claude` / `.claude/agents`, or a link, another non-regular node or an unreadable file at any kit agent path, stops the run naming it with nothing written, in a `--dry-run` too.
25
+ 3. **Hidden-mode deployments:** after the apply that places the component, run the hide-footprint reconcile (`node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --reconcile`) so the placed files stay invisible to `git status` — `/.claude/agents/` is in the known-footprint registry; that apply's report reminds you.
26
+
27
+ **Invariants:** writer (writes only `.claude/agents/`) · preview by default · every kit agent file written current with no question, a link or an unreadable file at a kit agent path a STOP naming it · never touches settings · never commits · **no READ-ONLY vehicle grants `Bash`, and exactly one bundled vehicle, `executor`, grants a shell** · the cheap-lane vehicles are pinned to `model: haiku` + `effort: low`, and the bundled review lens file is pinned OFF the cheap model (`opus` / `high`), its placed copy taking the posture `docs/ai/vehicles.json` sets — `opus` / `high` when unset (all content-tested).
@@ -40,7 +40,7 @@ Declared gates can also be **auto-approved** (no permission prompt on a byte-exa
40
40
 
41
41
  **A declared checker is read in THREE outcomes, not two.** `gates-inert.producer-unrecognized` — no producer anywhere in the declaration, over a tracked tree the changed-line domain cannot reach: the remedies are the marker above or dropping the checker, never a `node --test` prescription and never an acknowledgement (a dead pair is broken, not narrow). `gates-inert.coverage-domain-narrow` — the pair IS live and the tree is still dominated by what the domain excludes: certification covers the assessable minority, a FACT that converges on a `coverage-domain` acknowledgement. The census is the TRACKED tree (`git ls-files`) in this same closed vocabulary; dominance is STRICT (a tie, or a lone `.d.ts` beside real JS, never fires), and a tree it cannot read is a stated skip — no census, no optimality claim. A producer declared AFTER the checker is neither outcome: it keeps the ORDERING remedy above. Each outcome's convergence and posture note live in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`.
42
42
 
43
- **A marker-carrying declaration needs a CURRENT placed hook.** The gate-approval hook restates this schema in its own baked copy and goes dark on any key it does not know (`${CLAUDE_SKILL_DIR}/references/modes/hook.md`), so a declaration carrying the key under a hook that predates it silently switches auto-approval off — every gate prompting again, no error anywhere. The condition is the key's PRESENCE: an older hook rejects a key it does not know whatever the value, so `"lcovProducer": false` darkens it exactly as `true` does. The recovery is the reseed route: `node ${CLAUDE_SKILL_DIR}/tools/gate-hook.mjs --apply --reseed --cwd <project>` replaces the placed hook with the bundled bytes in place — the advisor's `gate-hook.marker-stale` item, which the agent applies on the chat yes after the danger check.
43
+ **A marker-carrying declaration needs a CURRENT placed hook.** The gate-approval hook restates this schema in its own baked copy and goes dark on any key it does not know (`${CLAUDE_SKILL_DIR}/references/modes/hook.md`), so a declaration carrying the key under a hook that predates it silently switches auto-approval off — every gate prompting again, no error anywhere. The condition is the key's PRESENCE: an older hook rejects a key it does not know whatever the value, so `"lcovProducer": false` darkens it exactly as `true` does. The recovery is the advisor's `gate-hook.not-current` item: within the wired hook it writes the placed hook with the kit's body in place, and the agent applies it with no question after the danger check.
44
44
 
45
45
  **`coverage=` states what the run can honestly say about coverage.** A CLOSED four-value set, always present, DETAIL only — exit code, `status=`, the receipt status, `--final` acceptance and the commit-guard disposition are untouched. `coverage=certified` — the checker consumed an lcov and ISSUED a verdict, pass **or** fail (one listing uncovered lines still reads certified and still exits 1). `coverage=not-run` — the checker ran and issued NO verdict (no lcov bytes were read, or the run holds no attestation context). `coverage=none` — no canonical checker ran here (an `--only` subset, the `--pre-review` subset). `coverage=unknown` — the run ended before the gates produced a signal (missing / empty / malformed declaration, no bash, a pre-spend refusal), or that signal is unreadable: the checker could not spawn, or its two anchored lines are missing, duplicated, or CONTRADICTORY (`attested=yes` over `lcov-sha256=none` certifies nothing) — fail closed. The value is DERIVED by cross-reading both anchored machine lines, the bytes the `--final` receipt binds, so it can never disagree with what the checker printed; the checker's table row names a withheld verdict in the same words, and a `--final` receipt RECORDS the token (`none` never rides one — a final run always selects the checker).
46
46
 
@@ -22,23 +22,23 @@ The opt-in **gate-approval PreToolUse hook** — the family's third `.claude/` w
22
22
 
23
23
  **Trust posture (state it plainly when asking consent):** the hook removes the PROMPT only for commands the human already declared in `docs/ai/gates.json` — the same trust boundary as the `gates` runner, which executes them with the caller's privileges. **gates.json thereby becomes a privileged file**: whoever can edit it can get its commands auto-approved. An invalid declaration approves NOTHING (strict parse, exact validation parity with the runner).
24
24
 
25
- **The read-lane (opt-in, AD-055 Part II).** The toggle lives in `docs/ai/lanes.json` — a **SEPARATE kit-owned strict-JSON file** (`{ "readLane": true }`); `docs/ai/gates.json`, both its validators and the byte-mirrored template are **untouched** (the gates schema has no lane/model/routing fields — that claim stays true). The hook reads `lanes.json` LIVE per call, **fail-closed**: an absent / malformed / non-object file, or a `readLane` that is not the boolean `true`, leaves the lane dark (gate auto-approval and the residual ask are unaffected). `lanes.json` becomes a **privileged file** exactly like `gates.json` — an auto-approved read chain runs **unattended** and can read any file you can (the same trust boundary as the audited read-only core velocity seeds, extended to compounds (and singles) of that core; **prompt-bypass only, never a sandbox bypass**). Enable it with `--read-lane` (below), which runs a **currency check** first: it refuses unless the PLACED hook is byte-identical to the current bundle — a **pre-1.48 hook never reads `lanes.json`**, so enabling the lane against a stale placed copy would be a silent no-op the user paid consent for. The stale-hook silent-blackout class is dead **by construction** (an old hook merely lacks the rung; nothing existing changes behavior); the currency refusal names the **reseed** route (`gate-hook --apply --reseed --cwd <root>`, which replaces the placed hook with the bundled bytes in place).
25
+ **The read-lane (opt-in, AD-055 Part II).** The toggle lives in `docs/ai/lanes.json` — a **SEPARATE kit-owned strict-JSON file** (`{ "readLane": true }`); `docs/ai/gates.json`, both its validators and the byte-mirrored template are **untouched** (the gates schema has no lane/model/routing fields — that claim stays true). The hook reads `lanes.json` LIVE per call, **fail-closed**: an absent / malformed / non-object file, or a `readLane` that is not the boolean `true`, leaves the lane dark (gate auto-approval and the residual ask are unaffected). `lanes.json` becomes a **privileged file** exactly like `gates.json` — an auto-approved read chain runs **unattended** and can read any file you can (the same trust boundary as the audited read-only core velocity seeds, extended to compounds (and singles) of that core; **prompt-bypass only, never a sandbox bypass**). Enable it with `--read-lane` (below), which runs a **currency check** first: it refuses unless the PLACED hook is byte-identical to the current bundle — a **pre-1.48 hook never reads `lanes.json`**, so enabling the lane against a stale placed copy would be a silent no-op the user paid consent for. The stale-hook silent-blackout class is dead **by construction** (an old hook merely lacks the rung; nothing existing changes behavior); the currency refusal names `gate-hook --apply --cwd <root>`, which writes the placed hook with the kit's body in place.
26
26
 
27
27
  **Version-status routing** like the other writer modes (stamp head `4.0.0`; `--apply` enforces it in code).
28
28
 
29
29
  Run `node ${CLAUDE_SKILL_DIR}/tools/gate-hook.mjs [--dry-run | --apply] [--cwd <dir>]`:
30
30
 
31
- 1. **`--dry-run` first, always** (the default — changes nothing): previews the placement and the exact settings entry it would merge. It STOPs (zero writes) on: a symlinked `.claude` / `.claude/hooks` / target file / non-regular `settings.json`; malformed settings JSON; a **malformed existing `hooks` shape** (never a merge-through-clobber); an unsafe `permissions.defaultMode` in **either** settings file; or a target hook file with **different** content while our entry is not wired (**it refuses to wire an unknown script as a PreToolUse hook** — the recovery is named: the reseed route, below).
31
+ 1. **`--dry-run` first, always** (the default — changes nothing): previews the placement and the exact settings entry it would merge. It STOPs (zero writes) on: a symlinked `.claude` / `.claude/hooks` / target file / non-regular `settings.json`; malformed settings JSON; a **malformed existing `hooks` shape** (never a merge-through-clobber); or an unsafe `permissions.defaultMode` in **either** settings file.
32
32
  2. **Ask consent** via **`AskUserQuestion` where supported**, the no-change option first: keep prompting for gate commands, or place + wire the hook — presenting the trust posture above in plain language.
33
- 3. **Only on an explicit yes**, re-run with `--apply`. It places the file FIRST, then wires settings (a wired-but-missing entry would error on every Bash call); merge-don't-clobber (foreign hooks/matchers/keys and existing permissions preserved; re-apply never duplicates); **settings hot-reload — the hook is active for new Bash calls, no session restart needed**. An identical existing file is *already current*; a diverged-but-already-wired file is reported, never clobbered or unwired by `--apply`.
33
+ 3. **Only on an explicit yes**, re-run with `--apply`. It places the file FIRST, then wires settings (a wired-but-missing entry would error on every Bash call); merge-don't-clobber (foreign hooks/matchers/keys and existing permissions preserved; re-apply never duplicates); **settings hot-reload — the hook is active for new Bash calls, no session restart needed**. An identical existing file is *already current*; a differing one is written with the kit's body in place; the entry is wired only while it is wired in neither settings file.
34
34
 
35
- **The reseed route — `--reseed`, the one consented replacement.** `gate-hook --reseed` previews and `--apply --reseed --cwd <root>` replaces a PLACED hook whose bytes differ from the bundle with the bundled bytes, in place, and wires the entry only while it is wired in neither settings file; a current hook wired in either file is `nothing to change: the placed hook is current`, and a current unwired one is only wired. It refuses an absent hook (`--apply` places it), a symlinked or non-regular target, a hook file swapped for a symlink before the write (nothing is written through it), and `--read-lane` beside it; where Node exposes no no-follow open flag (native Windows) it refuses the replace instead of risking a write through a link. It is what the advisor's `gate-hook.marker-stale` and `read-lane.stale` items apply: the agent runs it on the chat yes after the danger check, whose result names the replaced file with the old and the new digest; `init` applies it as the route the user may take instead.
35
+ **The hook file is the kit's.** Within a wired hook, `.claude/hooks/agent-workflow-gates.mjs` is placed when absent and written with the kit's body when it differs, in place, with no question and no copy kept; a current one is left; a link or another non-regular node there is named and nothing is written, and where Node exposes no no-follow open flag (native Windows) a replace stops instead of risking a write through a link. The advisor renders that state as `gate-hook.not-current`, lane kit: the agent applies it with no question after the danger check, and over a wired hook `gate-hook --apply` writes only the file. A hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire; no kit tool writes it.
36
36
  4. **Hidden-mode deployments:** after apply, run the hide-footprint reconcile (`node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --reconcile`) — `/.claude/hooks/` is in the known-footprint registry; the apply report reminds you.
37
37
 
38
- **Enabling the read-lane:** `node ${CLAUDE_SKILL_DIR}/tools/gate-hook.mjs --read-lane [--dry-run | --apply] [--cwd <dir>]`. `--dry-run` (the default) previews the `lanes.json` edit, the hook-currency status, and the trust posture; `--apply --read-lane` runs the **currency check** (above), then writes `{ "readLane": true }` into `docs/ai/lanes.json` — create-if-absent, merge-preserve every key, symlink / non-regular refusal, malformed-JSON fail-closed, atomic. It **never touches** `.claude/settings.json` or `docs/ai/gates.json`. The upgrade Recommendations advisor surfaces this as the `read-lane` offer once the hook is placed **and** wired.
38
+ **Enabling the read-lane:** `node ${CLAUDE_SKILL_DIR}/tools/gate-hook.mjs --read-lane [--dry-run | --apply] [--cwd <dir>]`. `--dry-run` (the default) previews the `lanes.json` edit, the hook-currency status, and the trust posture; `--apply --read-lane` runs the **currency check** (above), then writes `{ "readLane": true }` into `docs/ai/lanes.json` — create-if-absent, merge-preserve every key, symlink / non-regular refusal, malformed-JSON fail-closed, atomic. It **never touches** `.claude/settings.json` or `docs/ai/gates.json`. The upgrade Recommendations advisor surfaces this as the `read-lane` offer once the hook is wired.
39
39
 
40
- **Invariants:** the base flow writes ONLY `.claude/hooks/agent-workflow-gates.mjs` + `.claude/settings.json`; `--read-lane` writes ONLY `docs/ai/lanes.json` (never settings, never `gates.json`) · never `settings.local.json` · never commits · exact-match approval only (no patterns) · never `deny` · never auto-wired by `init`/`upgrade` (placement stays opt-in — the AD-011/AD-034 boundary: init/upgrade may refresh placed things, never place new ones).
40
+ **Invariants:** the base flow writes ONLY `.claude/hooks/agent-workflow-gates.mjs` + `.claude/settings.json`; `--read-lane` writes ONLY `docs/ai/lanes.json` (never settings, never `gates.json`) · never `settings.local.json` · never commits · exact-match approval only (no patterns) · never `deny` · never auto-wired by `init`/`upgrade` (wiring stays opt-in — the AD-011/AD-034 boundary: the upgrade with no question, and init on its one y, place or refresh the hook file of a hook the user wired, and a hook is wired only on the user's yes to its offer).
41
41
 
42
- **Exit codes:** `0` done / dry-run (incl. the reported diverged-but-wired state); `1` a precondition STOP; `2` bad arguments.
42
+ **Exit codes:** `0` done / dry-run; `1` a precondition STOP; `2` bad arguments.
43
43
 
44
44
  **The kit's other hook.** `state-block-guard` (see `${CLAUDE_SKILL_DIR}/references/modes/state-block-guard.md`) is a separate, unrelated `Stop` hook that judges the closing state block of a turn. Its writer is `tools/state-block-hook.mjs` (the advisor's `state-block` item), it never approves or denies anything, and this mode neither places nor wires it — the two hooks share only the `.claude/` directory they live in and the hardened placement discipline the state-block writer imports from `gate-hook.mjs`.
@@ -24,7 +24,7 @@ The **consent route** for a harness item: run its `check:` line in the sandbox a
24
24
 
25
25
  **The kit route** for a `lane: kit` item, which writes a kit file of a component the project already has: ask no question and wait for no pick. Before offering the other items, run each kit item's `check:` line in the sandbox and show its result, then at once run its `apply:` line with that result's digest once, outside the sandbox; the harness's own dialog there is its consent, which the kit cannot remove. A changed digest (exit 5) re-runs the check once and applies with its new digest, still with no question; every other outcome leaves the item pending with its output shown, and the agent goes on; an auto-mode refusal gets the one plain step above. `init` checks and applies it on its one y, as a harness item.
26
26
 
27
- **The `executor-vehicle` item (the carrier the project already CONFIGURED — beside the `agents` offer, never the same item).** It fires on ONE pair of facts: a slot in `docs/ai/orchestration.json` names `subagent` while the executor vehicle (`.claude/agents/executor.md`) is `missing` or `unusable` — so every such slot silently degrades to solo. That is a configured declaration that is broken, hence **`attention`**, not an offer; its text names the state, its reason and how many configured slots are affected across the six activities (`plan-authoring`, `plan-execution`, `routine`, `feedback-triage`, `epic`, `task`), covering the subagent-capable slots `plan-authoring.author`, `plan-authoring.fold`, `plan-execution.execute`, `routine.carrier`, `epic.author`, `task.author` and `task.execute`. **`placed` renders NOTHING** (a working vehicle is not a recommendation); a differing executor body is the optional `executor-vehicle.differing` arm, a kit item the agent applies with no question, a config naming no `subagent` slot renders no base item, and a config the validated reader refuses is a stated **skip**, never an item computed over a shape nothing accepted. It is deliberately DISTINCT from the `agents` offer and the review-recipe probe, neither of which can observe this state. The agent applies it on the chat yes after the check; `init` previews the agents writer's own `cheap-agents.mjs` and applies it with `--apply` on the terminal yes as a route the user may take instead. Its `recipe:` line carries each precondition the advisor observes beside the apply slot, followed by the hidden-mode reconcile follow-up (`hide-footprint --reconcile`), for a hidden deployment only. Honest limit on convergence: the apply places an ABSENT vehicle, so it clears `missing`; it STOPs on a symlink, so on `unusable` the `recipe:` line names each refusal as a precondition; an executor whose frontmatter is invalid is re-derived by the apply itself. Risk profile: writes under `.claude/agents/` only — the executor's and the review lens's bodies re-derived from `docs/ai/vehicles.json` (the lens opus/high by default), every other vehicle create-only — never `settings.json`, never a commit.
27
+ **The `executor-vehicle` item (the carrier the project already CONFIGURED — beside the `agents` offer, never the same item).** It fires on ONE pair of facts: a slot in `docs/ai/orchestration.json` names `subagent` while the executor vehicle (`.claude/agents/executor.md`) is `missing` or `unusable` — so every such slot silently degrades to solo. That is a configured declaration that is broken, hence **`attention`**, not an offer; its text names the state, its reason and how many configured slots are affected across the six activities (`plan-authoring`, `plan-execution`, `routine`, `feedback-triage`, `epic`, `task`), covering the subagent-capable slots `plan-authoring.author`, `plan-authoring.fold`, `plan-execution.execute`, `routine.carrier`, `epic.author`, `task.author` and `task.execute`. **`placed` renders NOTHING** (a working vehicle is not a recommendation); it yields to `agents.not-current`, the kit item the agent applies with no question, which writes a regular executor whose bytes differ, the check failing or not, in a placed component; a config naming no `subagent` slot renders no base item, and a config the validated reader refuses is a stated **skip**, never an item computed over a shape nothing accepted. It is deliberately DISTINCT from the `agents` offer and the review-recipe probe, neither of which can observe this state. The agent applies it on the chat yes after the check; `init` previews the agents writer's own `cheap-agents.mjs` and applies it with `--apply` on the terminal yes as a route the user may take instead. Its `recipe:` line carries each precondition the advisor observes beside the apply slot, followed by the hidden-mode reconcile follow-up (`hide-footprint --reconcile`), for a hidden deployment only. Honest limit on convergence: the apply places an ABSENT vehicle, so it clears `missing`; it STOPs on a symlink, so on `unusable` the `recipe:` line names each refusal as a precondition; an executor whose frontmatter is invalid is written by the apply itself. Risk profile: writes under `.claude/agents/` only — every kit agent file written current with no question, the executor's and the review lens's bodies derived from `docs/ai/vehicles.json` — never `settings.json`, never a commit.
28
28
 
29
29
  **Per-item posture notes (the consent moment — surface BEFORE running or handing over the apply):**
30
30
 
@@ -32,13 +32,13 @@ A variant's posture note, where its key has one, is printed by `init` from this
32
32
 
33
33
  - `bridge-tier` — the lane is harness and env-dependent: the agent applies the item on the chat yes after the check, writing the project `.claude/settings.json`; `init` previews `velocity-profile --bridge-tier` and applies it on the terminal y as the route the user may take instead. It wires the USED bridges from the project's effective recipes and host readiness: each used review wrapper's `code`-mode allow rule (a wrapper then runs UNATTENDED: it reads any repo file it is pointed at and sends the assembled payload to its subscription backend), the quoted grounding pre-step rule when `agy-review` is used, `codex-review *` / `agy-review *` in `sandbox.excludedCommands`, and `codex-exec *` where an execute slot delegates (no execution allow rule: it keeps its prompt). It also seeds the used bridges' declared hosts (`networkHosts`) in `sandbox.network.allowedDomains` and resolved state dirs (`writableDirs`), home-relative where under home, in `sandbox.filesystem.allowWrite`. Where the host honours the settings sandbox keys, an excluded wrapper runs outside the sandbox, every sandboxed command of the project can reach the seeded hosts, and every sandboxed command can write the seeded state dirs. The item fires while an allow rule, a `*` exclusion, a host or a state dir of a used bridge is missing. Its `recipe:` line names each missing entry by kind (allow rules, exclusions, hosts, state dirs), then what the execution wrapper `codex-exec` needs where an execute slot delegates, then, when the project settings enable the sandbox, "once added, wired where the host honors the settings sandbox keys", or "host condition unchecked" with the reason.
34
34
 
35
- - `read-lane` — enabling the opt-in read-only compound lane auto-approves *compounds* (and singles) of the seeded read-only core that carry ZERO shell metaprogramming: an UNATTENDED trust extension, bounded by the audited read-only core (never a command outside it; prompt-bypass only, never a sandbox bypass) and applied regardless of which of those core commands you seeded as individual settings rules. It is a PROJECT-PERSISTENT declaration in `docs/ai/lanes.json` — every future session, subagents' Bash too where the host fires hooks on subagent Bash, and (committed) every checkout. The apply depends on state: when the lane is OFF, it is the `gate-hook --read-lane` preview (whose own currency check refuses a stale hook — a pre-1.48 hook never reads `lanes.json`); when the placed hook is MISSING, the item instead surfaces the re-place offer; when it is STALE (an enabled lane over an old hook), the **stale** arm is an attention item on the harness lane: its writer is `gate-hook --apply --reseed`, which replaces the placed hook with the bundled bytes in place, and the agent applies it on the chat yes after the check, whose result names the replaced file with both digests; `init` applies it on the terminal y as the route the user may take instead. Risk profile: a bounded read-only trust-posture extension — no write/exec exposure beyond the audited core.
35
+ - `read-lane` — enabling the opt-in read-only compound lane auto-approves *compounds* (and singles) of the seeded read-only core that carry ZERO shell metaprogramming: an UNATTENDED trust extension, bounded by the audited read-only core (never a command outside it; prompt-bypass only, never a sandbox bypass) and applied regardless of which of those core commands you seeded as individual settings rules. It is a PROJECT-PERSISTENT declaration in `docs/ai/lanes.json` — every future session, subagents' Bash too where the host fires hooks on subagent Bash, and (committed) every checkout. The item renders while the hook is wired and the lane is off, whatever the placed hook's bytes; its apply is the `gate-hook --read-lane` preview, whose own currency check refuses a stale hook (a pre-1.48 hook never reads `lanes.json`). A stale or absent hook under it is a planned file of the kit item `gate-hook.not-current`, applied before the offers. The agent applies the enable offer on the chat yes, and the kit item with no question after the check; `init` applies that kit item on its one y as the route the user may take instead. Risk profile: a bounded read-only trust-posture extension — no write/exec exposure beyond the audited core.
36
36
  - `worktrees-dir` — the agent applies the item on the chat yes after the check: one `sandbox.filesystem.allowWrite` entry naming the worktrees parent itself, written to this copy's `.claude/settings.local.json` only, never the committed project settings, the parent created when missing. `init` applies it on the batch terminal yes as the route the user may take instead. Where the host honors the key, the entry widens the OS-sandbox WRITE surface to the whole parent dir: every sibling path under it (other repositories included) becomes agent-writable, for every later session and every worktree provisioned afterwards. Narrow it BEFORE the first apply: point `docs/ai/worktrees.json` `parentDir` at a dedicated dir — no apply removes an entry, so an earlier one stays until the user deletes it. A parent that is the home or holds it renders `worktrees-dir.home` instead, the user's own step. **Convergence** is two-path: a declared `sandbox.filesystem.allowWrite` entry covering the probed dir (either settings scope — `~` and `~/…` resolve against home, and coverage is path-segment-aware, so a grant on a sibling or on a child never counts), or the dir-bound acknowledgement `worktreesDirAck` in the family-owned `docs/ai/acks.json`, recorded by the `ack-write --lane worktrees-dir` line the `recipe:` line carries — the ack fallback for a host that ignores the key, run only on the user's word, instead of the grant; against a trusted host NO no ack renders. Neither is proof of write CAPABILITY: the provision preflight's real create+delete probe stays the runtime truth, and the ack is bound to the **resolved probe dir**, so the item re-fires only when that resolved dir changes. Risk profile: a real write-surface widening where honored — scope it deliberately.
37
37
 
38
38
  - `gates-inert` — the gate matrix is DECLARED but verifies nothing, and the two causes have different remedies, so the item renders a different apply for each. **Cause A** — a canonical `coverage-check` gate with no producer gate declared BEFORE it (none at all, or one declared after it, which writes the lcov too late): the run certifies no coverage of its own — `coverage=not-run` when nothing wrote an lcov, or a verdict over STALE bytes an earlier run left in the git dir, which is worse because it reads as `coverage=certified`. The remedy needs the producer to run BEFORE the checker — declared or MOVED there. When the checker is the LAST declared gate and the project's own scripts yield an offerable producer, the fill PLACES that producer before it, so the apply is the ordinary `gates-init` dry-run preview. Otherwise — no offerable producer, or a checker that is not last — it is the user item `gates-inert.unfillable`: the user's own step is to edit `docs/ai/gates.json` (the exact producer form lives in `${CLAUDE_SKILL_DIR}/references/modes/gates.md`), because the fill never reorders entries it did not write. **Cause B** — every declared gate is one of the kit's own canonical checkers, so the matrix runs no project-verification command at all: the apply is the `gates-init` dry-run preview, the same consent-gated seeder the `gates-declaration` item renders, and after the SAME confirmation you run the `--apply` line it prints. Neither cause changes any gate result, exit code or receipt — the item adds no enforcement, only the offer. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file (a declared gate is auto-approvable by the wired hook), so both causes land in the same place — where the fill can help, it declares a project-controlled command on your explicit yes; where it cannot, the edit is the user's own step.
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. 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
- - `gate-hook` — the base arm is the ordinary opt-in wiring offer 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. The **`marker-stale`** arm is not: the placed hook validates your declaration through its OWN baked copy and goes dark on any key it does not know, so a declaration carrying the `lcovProducer` key under a hook that predates it silently turns auto-approval OFF, and every gate prompts again with no error anywhere. The condition is the key's PRESENCE, not its value: `"lcovProducer": false` darkens it exactly as `true` does. The arm is deliberately marker-scoped — a stale hook is otherwise harmless — and it is a harness item: its writer is `gate-hook --apply --reseed`, which replaces the placed hook with the bundled bytes in place (and wires the entry only while it is unwired), so the agent applies it on the chat yes after the check, whose result names the replaced file with the old and the new digest; `init` applies it on the terminal y as the route the user may take instead. When the read-lane is also enabled, this arm and `read-lane.stale` would report the same file with the same recovery, so exactly one renders — **this one**: a hook that postdates the read-lane and merely predates the marker key reads `lanes.json` perfectly well. Risk profile: one placed hook file replaced by the bundled runtime; the declaration is never touched.
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
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
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.
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.
@@ -100,6 +100,10 @@ stamp refusals use that writer's error codes:
100
100
  present and not an array is a refusal with nothing written;
101
101
  - the entry is merged only while no `Stop` entry of either settings file runs the runtime, so a
102
102
  wiring you made yourself (another path, `--require-block`) counts and is never duplicated;
103
+ - within a wired hook the advisor renders a runtime that is absent or differs as
104
+ `state-block.not-current`, lane kit: the agent applies it with no question after the danger check,
105
+ and the writer then writes only the file. A hook of your own goes in `.claude/hooks/<name>.local.mjs`,
106
+ which you wire;
103
107
  - a symlinked `.claude`, `.claude/hooks`, target or settings file, malformed settings and an unsafe
104
108
  permission mode each refuse with nothing written; a deployment stamp behind the kit refuses
105
109
  `--apply` (the preview still answers and notes it); the runtime is written through gate-hook's
@@ -41,7 +41,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
41
41
 
42
42
  **What the autonomy-declaration ensure does.** `docs/ai/autonomy.json` must exist: created from `${CLAUDE_SKILL_DIR}/references/templates/autonomy.json` if missing (the kit's own template twin — a stale memory never silently loses the seed); **an existing file is preserved byte-for-byte** (a declared policy is authored content). The seed is SPARSE (the onboarding note only) and **defaults-equivalent** — deploying it never changes behavior (the computed defaults stay the policy until the user declares levels with `/agent-workflow-kit set-autonomy` or by hand).
43
43
 
44
- **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` — the advisor's `executor-vehicle.differing` item, which the agent applies with no question, writes the derived body — and an absent one is `not-placed` (the agents mode places it on consent).
44
+ **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.
45
45
 
46
46
  **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.
47
47
 
@@ -9,17 +9,17 @@ import {
9
9
  APPLY_ASK_RULE, CLAUDE_DIR, RENDER_OWNED_REDLINE_RULES,
10
10
  SAFE_DEFAULT_MODES, SETTINGS_FILE, SETTINGS_LOCAL_FILE, UNIVERSAL_READONLY_ALLOWLIST,
11
11
  deriveKitToolsAllowlist, detectAtRoot, mergeAutonomySettings,
12
- writeAutonomyProfile, writeVelocityProfile,
12
+ readSettingsFile, writeAutonomyProfile, writeVelocityProfile,
13
13
  } from './velocity-profile.mjs';
14
14
  import { KIT_GROUNDING_TOOL, bundledSandboxRecipe, usedBridges } from './bridge-sandbox-recipe.mjs';
15
15
  import { homeRelative, mergeAllowWrite, stateDirsOf } from './bridge-state-dirs.mjs';
16
16
  import { nearestExistingDir, worktreesGrantDir, worktreesGrantHoldsHome } from './worktrees.mjs';
17
17
  import { loadConfig } from './orchestration-config.mjs';
18
- import { HOOK_FILE_REL, HOOKS_DIR, buildHookSettingsEntry, mergeHookEntry, writeGateHook } from './gate-hook.mjs';
19
- import { STATE_BLOCK_HOOK_FILE_REL, buildStopHookEntry, mergeStopEntry, writeStateBlockHook } from './state-block-hook.mjs';
18
+ import { HOOK_FILE_REL, HOOKS_DIR, buildHookSettingsEntry, isHookWired, mergeHookEntry, writeGateHook } from './gate-hook.mjs';
19
+ import { STATE_BLOCK_HOOK_FILE_REL, buildStopHookEntry, isStopHookWired, mergeStopEntry, writeStateBlockHook } from './state-block-hook.mjs';
20
20
  import { writeMcp } from './mcp.mjs';
21
21
  import { ENABLED_KEY, MCP_JSON_REL, SERVERS_KEY, SERVER_NAME, allowRulesFor, buildServerEntry } from './mcp-registration.mjs';
22
- import { AGENTS_DIR, EXECUTOR_VEHICLE_REL, writeCheapAgents } from './cheap-agents.mjs';
22
+ import { AGENTS_DIR, agentsAccepted, kitAgentNames, writeCheapAgents } from './cheap-agents.mjs';
23
23
  import { planFor } from './jev-skill.mjs';
24
24
  import { SKILL_FILES, claudeDirOf, skillTargets } from './jev-facts.mjs';
25
25
  import { findOnPath } from './detect-backends.mjs';
@@ -33,17 +33,16 @@ import { dirCovers as covers } from './declared-paths.mjs';
33
33
  const TOOLS = dirname(fileURLToPath(import.meta.url));
34
34
  const SKILL_VARIANTS = ['jev-skill', 'jev-skill.earlier'];
35
35
  const VELOCITY_VARIANTS = ['velocity-core', 'kit-tools-tier', 'bridge-tier'];
36
- const RESEED_VARIANTS = ['gate-hook.marker-stale', 'read-lane.stale'];
37
- const HOOK_VARIANTS = ['gate-hook', 'read-lane.missing', ...RESEED_VARIANTS];
38
- const STOP = 'state-block';
36
+ const [GATE_KIT, STOP, STOP_KIT] = ['gate-hook.not-current', 'state-block', 'state-block.not-current'];
37
+ const [HOOK_VARIANTS, STOP_VARIANTS, KIT_HOOKS] = [['gate-hook', GATE_KIT], [STOP, STOP_KIT], [GATE_KIT, STOP_KIT]];
39
38
  const MCP_VARIANTS = ['mcp-channel', 'mcp-channel.differing'];
40
- const EXECUTOR_KIT = 'executor-vehicle.differing';
41
- const AGENT_VARIANTS = ['agents', 'executor-vehicle', EXECUTOR_KIT];
39
+ const AGENTS_KIT = 'agents.not-current';
40
+ const AGENT_VARIANTS = ['agents', 'executor-vehicle', AGENTS_KIT];
42
41
  const GIT_VARIANTS = ['enforcement', 'commit-guard', 'hook-checks'];
43
42
  const WORKTREES = 'worktrees-dir';
44
43
  const ATTRIBUTION = 'attribution';
45
44
  const FOOTPRINT = 'footprint-global';
46
- const VARIANTS = [...VELOCITY_VARIANTS, 'autonomy-render', ...HOOK_VARIANTS, STOP, ...MCP_VARIANTS, ...AGENT_VARIANTS, ...SKILL_VARIANTS, ...GIT_VARIANTS, WORKTREES, ATTRIBUTION, FOOTPRINT];
45
+ const VARIANTS = [...VELOCITY_VARIANTS, 'autonomy-render', ...HOOK_VARIANTS, ...STOP_VARIANTS, ...MCP_VARIANTS, ...AGENT_VARIANTS, ...SKILL_VARIANTS, ...GIT_VARIANTS, WORKTREES, ATTRIBUTION, FOOTPRINT];
47
46
  const HOOK_KEYS = ['hooks.PreToolUse', 'hooks.Stop'];
48
47
  const CREDENTIALS = 'sandbox.credentials.envVars';
49
48
  const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -163,6 +162,15 @@ const writerFacts = (facts, deps) => ({
163
162
  findWrapper: (name) => findOnPath(name, { getenv: facts.env }).state === 'present',
164
163
  findOnPath: (name) => findOnPath(name, { getenv: facts.env }),
165
164
  });
165
+ // A kit hook variant writes neither settings file, so a device there (a sandbox mask over an absent file) reads
166
+ // as absent; its acceptance is judged by the check from the two settings files with the writer's own predicate.
167
+ const SETTINGS_FILES = [SETTINGS_FILE, SETTINGS_LOCAL_FILE];
168
+ const unmaskedLstat = (facts) => (path, ...args) => {
169
+ const stat = lstatSync(path, ...args);
170
+ if (stat?.isCharacterDevice() && SETTINGS_FILES.some((rel) => path === join(facts.root, rel))) throw Object.assign(new Error(`ENOENT: ${path}`), { code: 'ENOENT' });
171
+ return stat;
172
+ };
173
+ const kitHookWired = (variant, facts) => SETTINGS_FILES.some((rel) => (variant === GATE_KIT ? isHookWired : isStopHookWired)(readSettingsFile(join(facts.root, rel), { lstat: unmaskedLstat(facts), cwd: facts.root }).data));
166
174
 
167
175
  export const scopeOf = (variant, facts, deps = {}) => {
168
176
  const allowed = {};
@@ -195,7 +203,7 @@ export const scopeOf = (variant, facts, deps = {}) => {
195
203
  if (grantDir !== null && !worktreesGrantHoldsHome(grantDir, facts.home, facts)) {
196
204
  set('sandbox.filesystem.allowWrite', [homeRelative(grantDir, facts.home)]);
197
205
  }
198
- if (HOOK_VARIANTS.includes(variant)) set('hooks.PreToolUse', [buildHookSettingsEntry()]);
206
+ if (variant === 'gate-hook') set('hooks.PreToolUse', [buildHookSettingsEntry()]);
199
207
  else if (variant === STOP) set('hooks.Stop', [buildStopHookEntry()]);
200
208
  else if (MCP_VARIANTS.includes(variant)) {
201
209
  set(`${SERVERS_KEY}.${SERVER_NAME}`, [buildServerEntry(join(facts.toolsDir, 'mcp-server.mjs'))]);
@@ -204,13 +212,16 @@ export const scopeOf = (variant, facts, deps = {}) => {
204
212
  }
205
213
  const targets = SKILL_VARIANTS.includes(variant) ? skillTargets({ home: facts.home,
206
214
  claudeDir: facts.claudeDir ?? claudeDirOf(facts.env, facts.home, facts.platform).dir }) : [];
207
- const filePaths = HOOK_VARIANTS.includes(variant) ? [join(facts.root, HOOK_FILE_REL)]
208
- : variant === STOP ? [join(facts.root, STATE_BLOCK_HOOK_FILE_REL)] : [];
209
- const directories = SKILL_VARIANTS.includes(variant) || variant === FOOTPRINT ? [] : [join(facts.root, CLAUDE_DIR)];
215
+ const accepted = !KIT_HOOKS.includes(variant) || kitHookWired(variant, facts);
216
+ const filePaths = !accepted ? [] : HOOK_VARIANTS.includes(variant) ? [join(facts.root, HOOK_FILE_REL)] : STOP_VARIANTS.includes(variant) ? [join(facts.root, STATE_BLOCK_HOOK_FILE_REL)] : [];
217
+ const directories = !accepted || SKILL_VARIANTS.includes(variant) || variant === FOOTPRINT ? [] : [join(facts.root, CLAUDE_DIR)];
210
218
  const globalFile = variant === FOOTPRINT ? footprintPlan(facts, deps)?.source : undefined;
211
219
  if (globalFile) filePaths.push(globalFile);
212
- if (HOOK_VARIANTS.includes(variant) || variant === STOP) directories.push(join(facts.root, HOOKS_DIR));
220
+ if (accepted && (HOOK_VARIANTS.includes(variant) || STOP_VARIANTS.includes(variant))) directories.push(join(facts.root, HOOKS_DIR));
213
221
  if (AGENT_VARIANTS.includes(variant)) directories.push(join(facts.root, AGENTS_DIR));
222
+ const kitNames = variant === AGENTS_KIT ? kitAgentNames(facts.root) : [];
223
+ if (kitNames.length && agentsAccepted(facts.root, kitNames)) filePaths.push(...kitNames.map((name) => join(facts.root, AGENTS_DIR, name)));
224
+ else if (kitNames.length) directories.splice(0);
214
225
  const existingAncestor = grantDir === null ? null : nearestExistingDir(grantDir, facts);
215
226
  for (let at = grantDir; at !== existingAncestor; at = dirname(at)) directories.push(at);
216
227
  for (const target of targets) {
@@ -237,7 +248,7 @@ export const scopeOf = (variant, facts, deps = {}) => {
237
248
  return correctFile && (!gains || change === 'added') && !(key === ATTRIBUTION_KEY && change === 'removed') && Boolean(allowed[key]?.(value));
238
249
  },
239
250
  admitsPath: (path, directory = false) => directory ? directories.includes(path) : filePaths.includes(path)
240
- || (variant === EXECUTOR_KIT ? path === join(facts.root, EXECUTOR_VEHICLE_REL) : AGENT_VARIANTS.includes(variant) && covers(join(facts.root, AGENTS_DIR), path)),
251
+ || (variant !== AGENTS_KIT && AGENT_VARIANTS.includes(variant) && covers(join(facts.root, AGENTS_DIR), path)),
241
252
  };
242
253
  };
243
254
 
@@ -245,7 +256,7 @@ const jsonAt = (path) => existsSync(path) ? JSON.parse(readFileSync(path, 'utf8'
245
256
  const regularBytes = (path) => lstatSync(path, { throwIfNoEntry: false })?.isFile() ? readFileSync(path) : undefined;
246
257
  const halted = (lines) => Object.assign(new Error(lines.join('\n')), { code: 'CHECK_HALTED', lines });
247
258
  const maskedFiles = (variant, facts) => {
248
- const paths = VELOCITY_VARIANTS.includes(variant) || variant === 'autonomy-render' || HOOK_VARIANTS.includes(variant)
259
+ const paths = VELOCITY_VARIANTS.includes(variant) || variant === 'autonomy-render' || variant === 'gate-hook'
249
260
  || variant === STOP || variant === WORKTREES || variant === ATTRIBUTION ? [SETTINGS_FILE, SETTINGS_LOCAL_FILE] : MCP_VARIANTS.includes(variant) ? [MCP_JSON_REL, SETTINGS_FILE] : [];
250
261
  return paths.flatMap((path) => lstatSync(join(facts.root, path), { throwIfNoEntry: false })?.isCharacterDevice()
251
262
  ? [`masked: ${path}`] : []);
@@ -256,7 +267,7 @@ export const plannedChange = (variant, facts, deps = {}) => {
256
267
  const temporaries = [];
257
268
  const created = [];
258
269
  let runs = null;
259
- const writerDeps = writerFacts(facts, deps);
270
+ const writerDeps = { ...writerFacts(facts, deps), ...(KIT_HOOKS.includes(variant) ? { lstat: unmaskedLstat(facts) } : {}) };
260
271
  const addFile = (path, before, after) => {
261
272
  files.push({ path, before: before ?? null, after });
262
273
  };
@@ -284,23 +295,20 @@ export const plannedChange = (variant, facts, deps = {}) => {
284
295
  const before = jsonAt(join(facts.root, SETTINGS_FILE));
285
296
  addFile(SETTINGS_FILE, before, mergeAutonomySettings(before, render));
286
297
  } else if (HOOK_VARIANTS.includes(variant)) {
287
- const plan = writeGateHook({ cwd: facts.root, dryRun: true, reseed: RESEED_VARIANTS.includes(variant) }, writerDeps);
298
+ const plan = (deps.writeGateHook ?? writeGateHook)({ cwd: facts.root, dryRun: true }, writerDeps);
288
299
  if (plan.wirePlanned) addFile(SETTINGS_FILE, plan.projectSettings.data, mergeHookEntry(plan.projectSettings.data));
289
- const path = join(facts.root, HOOK_FILE_REL);
290
- if (plan.placePlanned) writes.push({ path, bytes: plan.bundleContent });
291
- if (plan.reseedPlanned) writes.push({ path, bytes: plan.bundleContent });
292
- } else if (variant === STOP) {
293
- const plan = writeStateBlockHook({ cwd: facts.root, dryRun: true }, writerDeps);
300
+ if (plan.placePlanned || plan.replacePlanned) writes.push({ path: join(facts.root, HOOK_FILE_REL), bytes: plan.bundleContent });
301
+ } else if (STOP_VARIANTS.includes(variant)) {
302
+ const plan = (deps.writeStateBlockHook ?? writeStateBlockHook)({ cwd: facts.root, dryRun: true }, writerDeps);
294
303
  if (plan.mergePlanned) addFile(SETTINGS_FILE, plan.projectSettings.data, mergeStopEntry(plan.projectSettings.data));
295
- const path = join(facts.root, STATE_BLOCK_HOOK_FILE_REL);
296
- if (['create', 'replace'].includes(plan.placement)) writes.push({ path, bytes: plan.bundleContent });
304
+ if (['create', 'replace'].includes(plan.placement)) writes.push({ path: join(facts.root, STATE_BLOCK_HOOK_FILE_REL), bytes: plan.bundleContent });
297
305
  } else if (MCP_VARIANTS.includes(variant)) {
298
306
  const result = writeMcp({ cwd: facts.root, dryRun: true, replace: variant === 'mcp-channel.differing' }, writerDeps);
299
307
  const { plan, registration } = result;
300
308
  if (plan.writeMcpJson) addFile(MCP_JSON_REL, registration.mcpJson.data, JSON.parse(plan.mcpBody));
301
309
  if (plan.writeSettings) addFile(SETTINGS_FILE, registration.settings.data, JSON.parse(plan.settingsBody));
302
310
  } else if (AGENT_VARIANTS.includes(variant)) {
303
- const plan = writeCheapAgents({ cwd: facts.root, dryRun: true, executorOnly: variant === EXECUTOR_KIT }, writerDeps);
311
+ const plan = writeCheapAgents({ cwd: facts.root, dryRun: true }, writerDeps);
304
312
  for (const item of plan.plan.filter(({ action }) => ['place', 're-derive'].includes(action))) {
305
313
  writes.push({ path: item.abs, bytes: item.content });
306
314
  }