@sabaiway/agent-workflow-kit 19.5.0 → 20.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +18 -10
  3. package/SKILL.md +6 -6
  4. package/bin/install.mjs +1 -1
  5. package/capability.json +1 -1
  6. package/migrations/1.1.0-communication-language.md +2 -4
  7. package/migrations/1.2.0-agent-attribution.md +1 -3
  8. package/migrations/5.0.0-kit-text-in-kit-files.md +30 -0
  9. package/migrations/README.md +2 -2
  10. package/package.json +1 -1
  11. package/references/advisor-writers.md +1 -1
  12. package/references/contracts.md +9 -11
  13. package/references/modes/bootstrap.md +2 -4
  14. package/references/modes/hook.md +1 -1
  15. package/references/modes/procedures.md +1 -1
  16. package/references/modes/recommendations.md +1 -1
  17. package/references/modes/rules.md +4 -3
  18. package/references/modes/upgrade.md +23 -49
  19. package/references/modes/velocity.md +1 -1
  20. package/references/reference-profile.json +0 -6
  21. package/references/rules/communication.md +22 -0
  22. package/references/rules/project-layout.md +2 -0
  23. package/references/rules/story-sessions.md +14 -0
  24. package/references/shared/composition-handoff.md +24 -59
  25. package/references/shared/deploy-tail.md +2 -2
  26. package/references/templates/AGENTS.md +0 -10
  27. package/references/templates/agent_rules.md +0 -33
  28. package/tools/cheap-agents-read.mjs +1 -1
  29. package/tools/delegation.mjs +5 -8
  30. package/tools/engine-source.mjs +13 -11
  31. package/tools/family-registry.mjs +4 -5
  32. package/tools/inject-methodology.mjs +153 -493
  33. package/tools/migration-blocks.mjs +0 -6
  34. package/tools/orchestration-readme.mjs +1 -1
  35. package/tools/payload-prune.mjs +48 -8
  36. package/tools/profile-gap-screen.mjs +2 -6
  37. package/tools/profile-gaps.mjs +19 -100
  38. package/tools/project-rules/index.mjs +1 -2
  39. package/tools/project-rules/rules-ensure.mjs +37 -6
  40. package/tools/project-rules/rules-priors.mjs +1 -0
  41. package/tools/project-rules/themes.mjs +13 -5
  42. package/tools/transition/index.mjs +214 -0
  43. package/tools/upgrade-runlist.mjs +2 -17
  44. package/tools/velocity-profile.mjs +1 -1
  45. package/tools/lens-region.mjs +0 -281
  46. package/tools/project-rules/memory-map-row.mjs +0 -81
  47. package/tools/rules-insert.mjs +0 -203
  48. package/tools/rules-regions.mjs +0 -190
@@ -7,35 +7,34 @@
7
7
  Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKILL_DIR}/references/shared/composition-handoff.md · ${CLAUDE_SKILL_DIR}/references/shared/deploy-tail.md · ${CLAUDE_SKILL_DIR}/references/shared/command-shapes.md
8
8
 
9
9
  1. Read `docs/ai/.workflow-version` (the project's stamped lineage). If missing, treat as a pre-versioned deployment and offer to re-bootstrap conservatively.
10
- 2. **Never-downgrade gate — FIRST, before any write.** Compare the stamp to the **deployment-lineage head** (`4.0.0` — NOT this kit's package version). If the stamp is **greater than the head** or unparseable → **STOP and report**; do not touch a newer / unknown deployment at all (not even the methodology slot). This STOP is one of the few places the number is actionable (*Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`): show the user **the `docs/ai` structure version** their deployment carries versus the one this kit expects, plus the plain one-line two-axes note — naming it the structure version, **never** "lineage head".
11
- 3. **The step-3 run-list — stamp-independent reconciles, BEFORE the equal-head short-circuit.** Reached only when the stamp **≤ head**. Run the **eight operations below in order, on every upgrade** (equal-head too) — no lineage-head bump, no migration file. Each backticked id anchors its rationale block below the checklist; a consent marker is a CONDITIONAL gate — an explicit yes is required exactly where the row's clause states one:
10
+ 2. **Never-downgrade gate — FIRST, before any write.** Compare the stamp to the **deployment-lineage head** (`5.0.0` — NOT this kit's package version). If the stamp is **greater than the head** or unparseable → **STOP and report**; do not touch a newer / unknown deployment at all (not even the kit block). This STOP is one of the few places the number is actionable (*Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`): show the user **the `docs/ai` structure version** their deployment carries versus the one this kit expects, plus the plain one-line two-axes note — naming it the structure version, **never** "lineage head".
11
+ 3. **The step-3 run-list — stamp-independent reconciles, BEFORE the equal-head short-circuit.** Reached only when the stamp **≤ head**. Run the **seven operations below in order, on every upgrade** (equal-head too) — no lineage-head bump, no migration file. Each backticked id anchors its rationale block below the checklist; a consent marker is a CONDITIONAL gate — an explicit yes is required exactly where the row's clause states one:
12
12
 
13
- 1. `pointers` — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` → per pointer: added · already present · written over a different one · skipped (reported) · a hard STOP; per Memory Map row of a rules theme: added · already present · refreshed · skipped (reported) · written.
13
+ 1. `entry-block` — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` → the kit block between its two workflow:kit comment lines, its table one row per theme, written current with no question and no copy kept, its line naming the route (text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/): added · already current · written · refused · a hard STOP.
14
14
  2. `footprint` — `node ${CLAUDE_SKILL_DIR}/tools/hide-footprint.mjs --dir <project> --reconcile --dry-run` → visibility: visible · ambiguous · hidden — consent (conditional): ambiguous → ask which it is BEFORE anything; hidden → the conditional re-run without `--dry-run` (its surfaced paths ask per bootstrap step 9).
15
15
  3. `configs` — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --cwd <project>` → one line per ensure: `seeded` / `note-refreshed` / `refreshed` / `regenerated` / `pending` / `already-current` / `customized-preserved` / `malformed-preserved` / `already-present` / `not-placed` / `skipped-no-node-evidence` / `failed`.
16
16
  4. `gates-migration` — `node ${CLAUDE_SKILL_DIR}/references/scripts/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>` → the preview plan · INERT checker · CUSTOMIZED entries, each named — consent: apply only on an explicit yes, re-run with `--apply`.
17
17
  5. `bridges` — `node ${CLAUDE_SKILL_DIR}/tools/setup-backends.mjs --refresh-placed` → per-bridge lines: refreshed · already current · skipped — with its stated reason (not placed / newer than the bundle / unsupported host) · `skipped-readonly` · could not refresh.
18
- 6. `lens` — `node ${CLAUDE_SKILL_DIR}/tools/lens-region.mjs reconcile <project>/docs/ai/agent_rules.md` → per section: refreshed · already current · differing body written · file absent / engine too old — skipped · over the line cap — refused · section absent — noted · a fully absent/invalid engine → hard STOP.
19
- 7. `tier` — `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --cwd <project>` → per gap: present · offered · declined · undecidable · applied · recorded · refused — consent: one ask, only when offered.
20
- 8. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
18
+ 6. `tier` — `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --cwd <project>` → per gap: present · offered · declined · undecidable · applied · recorded · refused — consent: one ask, only when offered.
19
+ 7. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
21
20
 
22
- **`pointers` — the bounded pointers.** ONE call reconciles **three** pointers — the **workflow-methodology** pointer, the **orchestration-recipes** pointer (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) right below it, and the **autonomy-policy** pointer (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) below that — and is filled on **every** upgrade, idempotently (zero-diff when all are already present + filled and the Memory Map rows present, each with the current text), so even a legacy or current equal-head deployment gains them **without a lineage-head bump or a migration** (the `agent-workflow-memory` **package** template did get docs-only headroom trims for the chained pointers, but no deployed-`docs/ai` structure changed). Per slot it inserts an empty pair at its anchor if absent, writes a pair holding other text with the current pointer, no question and no copy kept, its line naming the route — text of your own goes outside the two `<!-- workflow: -->` comment lines around each pointer — and STOPs (never edits) on a malformed pair or a missing / duplicate anchor. The installed `agent-workflow-engine` is read for every pointer the run judges (the fragments live there — see the distinct outcomes below), and an absent/invalid one STOPs also when every pointer is filled. The same call keeps one Memory Map row per project-rules theme, after the `docs/ai/agent_rules.md` row: a row with other text is written current, its line naming the route — a row of your own goes on a line of its own, its first cell a path of your own; one it cannot place is skipped and reported, never a STOP.
21
+ **`entry-block` — the kit block.** ONE call writes the kit block of `AGENTS.md` between its two `workflow:kit` comment lines — the precedence line, the read line, the **workflow-methodology**, **orchestration-recipes** (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) and **autonomy-policy** (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) texts, and the rules-themes table, one row per theme — on **every** upgrade, idempotently (zero-diff when the block is already current), so an equal-head deployment gains it **without a lineage-head bump or a migration**. The block is written current with no question and no copy kept, its line naming the route — text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/; a file with no block gains it at its start. The installed `agent-workflow-engine` is read on every run (the texts live there), and no length of the file is judged.
23
22
 
24
- **Classify the exit — there are THREE non-zero exits + soft in-band skips; handle each differently:**
23
+ **Classify the exit — two non-zero exits, each a hard STOP (do NOT continue):**
25
24
 
26
- (a) **Soft, reported skip of a CHAINED pointer — orchestration and/or autonomy (CONTINUE the upgrade).** The chained pointers are the less-critical ones; when one can't be brought current right now `reconcile` exits **zero**, writes the earlier pointers' results, and **reports each skip on stdout** (the `… skipped …` line) — never silent (Hard Constraint). Three reasons: **(i)** the prior pointers fit but adding or writing this one would push the file past the `AGENTS.md` 100-line cap; **(ii)** the installed `agent-workflow-engine` is **present but too old** to ship that fragment (`<1.2.0` lacks the recipes one; every engine before the autonomy release lacks the autonomy one) — it can still supply the earlier pointers, so only that pointer is not current; or **(iii)** — autonomy only — its **anchor is absent** because the orchestration pair is itself absent or was skipped, so the autonomy pointer has nowhere to chain (add the orchestration pointer first, then re-run). Report it in the successful-exit report (**step 4** equal-head, else **step 8**) in plain language, e.g. *"The orchestration-recipes / autonomy pointer wasn't added — the entry point is at its 100-line limit / your methodology engine is older than that feature. The recipes stay available via `/agent-workflow-kit recipes` and the autonomy policy via `/agent-workflow-kit set-autonomy`; to add the pointer, trim the entry point and/or refresh the engine with `npx @sabaiway/agent-workflow-engine@latest init`, then re-run upgrade."* (The separate case where the **methodology** pointer ITSELF can't fit the cap is a non-zero exit that changes nothing — continue without the pointers, same plain-language framing.) A skipped Memory Map row is its own clause, never a pointer skip: report it as step 4 words the rows.
25
+ (a) **`methodology engine not found/invalid …`.** An absent or invalid installed `agent-workflow-engine`, or an engine text that cannot be read or is blank, STOPs the run with nothing written. Report it in plain language with the one-line install command `npx @sabaiway/agent-workflow-engine@latest init` (or note that `npx @sabaiway/agent-workflow-kit@latest init` installs the engine for you), then re-run upgrade once it is present.
27
26
 
28
- (b) **Malformed pair / missing-or-duplicate anchor (any pointer) — a hard STOP (do NOT continue).** A non-zero exit whose message names a marker/anchor problem; never soft-skip it. (The one deliberate exception is (a)(iii): the autonomy pointer's ABSENT anchor is the chained soft skip, exit zero — a reported skip, not this STOP.)
27
+ (b) **`kit block refused — …`.** The `workflow:kit` comment lines are not exactly one start line before one end line: the line names each of them by its line number and nothing is written. Relay it plainly; once those lines are fixed, re-run upgrade.
29
28
 
30
- (c) **`methodology engine not found/invalid …` — a hard STOP (do NOT continue).** The engine is read for every pointer the run judges, so a **fully absent/invalid** installed `agent-workflow-engine` STOPs also when every pointer is filled — it can supply **no** fragment (distinct from (a)(ii), where the engine is valid but merely too old for a chained one). Report it in plain language with the one-line install command `npx @sabaiway/agent-workflow-engine@latest init` (or note that `npx @sabaiway/agent-workflow-kit@latest init` installs the engine for you), then re-run upgrade once it is present. **Never** treat (c) as a soft-skip (a) — mis-handling it would silently drop a pointer (a no-silent-failures violation). (b) and (c) STOP the upgrade; only (a) continues.
29
+ An engine that is valid but lacks the orchestration or the autonomy text, or the lens rules theme, is no STOP: the block holds one line in its place and the run prints a `note:` line naming `npx @sabaiway/agent-workflow-engine@latest init` — relay it in the report (**step 4** equal-head, else **step 8**).
31
30
 
32
- **No-Node project:** the fragments live only in the **installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md` + `references/autonomy-slot.md`, under `~/.claude/skills/agent-workflow-engine` or `$AGENT_WORKFLOW_ENGINE_DIR`) — there is no bundled copy, and a No-Node host cannot run the `npx` engine install. Open `AGENTS.md` and classify **each** pointer by hand: a **malformed** pair (not exactly one ordered `start → end`) → STOP, do not edit. If the engine is **not installed**, no pointer is brought current this run — report it plainly (the methodology is already in `docs/ai/agent_rules.md`; the recipes are available via `/agent-workflow-kit recipes`; the autonomy policy via `/agent-workflow-kit set-autonomy`; install the engine to bring the pointers current), and the upgrade continues. If the engine **is** present, judge each pair against its engine fragment (`methodology-slot.md` / `orchestration-slot.md` / `autonomy-slot.md`): the same text → nothing to do; absent markers, an empty pair or other text → the fragment goes between the markers. **Count the lines first** — if a write would take the file over 100 lines, **skip that pointer and report the skip** (methodology first, then orchestration, then autonomy; each chained pair sits right under the previous pair's end marker). Never inline a copy (that would re-create the retired mirror).
31
+ **No-Node project:** the texts live only in the **installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md` + `references/autonomy-slot.md`, under `~/.claude/skills/agent-workflow-engine` or `$AGENT_WORKFLOW_ENGINE_DIR`) — there is no bundled copy, and a No-Node host cannot run the `npx` engine install. Open `AGENTS.md` and judge the block by hand: a `workflow:kit` comment-line pair that is not exactly one start line before one end line → STOP, do not edit. If the engine is **not installed**, the block is not written this run — report it plainly (the recipes are available via `/agent-workflow-kit recipes`; the autonomy policy via `/agent-workflow-kit set-autonomy`; install the engine to write the block), and the upgrade continues. If the engine **is** present, compose the block in the order above, its table from the rules themes, and put it between the two comment lines, at the start of the file when there are none. Never inline a copy elsewhere in the file.
33
32
 
34
- **`footprint` — hidden-mode footprint reconcile (D9 / AD-014).** A deployment does not record whether it chose `hidden`, so first **infer visibility** — the dry-run writes **zero bytes** and reports one of — **visible** (the entry point is tracked) → nothing to do; **ambiguous** (untracked but not ignored — could be a fresh uncommitted repo, or a hide that broke) → **ASK** the user which it is, never guess; **hidden** → re-run without `--dry-run` to migrate any older **machine-global** hide to the **project-local** `.git/info/exclude` (one managed block; folds in the legacy `.claude/skills/` line), idempotently (a clean re-run is zero-diff). Handle its surfaced paths exactly as bootstrap step 9 (`${CLAUDE_SKILL_DIR}/references/modes/bootstrap.md`) (already-committed → show `git rm --cached`, ask before `--include`; generic-name present file → ask; **a leftover machine-wide ignore block is kept + reported — the advisor's `footprint-global` item removes it**). This runs on **every** hidden upgrade, like the methodology slot — no lineage-head bump, no migration file.
33
+ **`footprint` — hidden-mode footprint reconcile (D9 / AD-014).** A deployment does not record whether it chose `hidden`, so first **infer visibility** — the dry-run writes **zero bytes** and reports one of — **visible** (the entry point is tracked) → nothing to do; **ambiguous** (untracked but not ignored — could be a fresh uncommitted repo, or a hide that broke) → **ASK** the user which it is, never guess; **hidden** → re-run without `--dry-run` to migrate any older **machine-global** hide to the **project-local** `.git/info/exclude` (one managed block; folds in the legacy `.claude/skills/` line), idempotently (a clean re-run is zero-diff). Handle its surfaced paths exactly as bootstrap step 9 (`${CLAUDE_SKILL_DIR}/references/modes/bootstrap.md`) (already-committed → show `git rm --cached`, ask before `--include`; generic-name present file → ask; **a leftover machine-wide ignore block is kept + reported — the advisor's `footprint-global` item removes it**). This runs on **every** hidden upgrade, like the kit block — no lineage-head bump, no migration file.
35
34
 
36
- **`configs` — the project-configuration ensures, ONE run.** The ONE command performs **all nine** ensures — orchestration config · gate declaration · autonomy declaration · vehicles declaration · executor check · enforcement scripts · spec layer · project rules · navigator index — in a fixed order, and prints **one outcome line per ensure**: paste those lines into the step 4 / step 8 success report. Every SEED is **create-only** (an existing file is preserved byte-for-byte); a refresh-class op rewrites only what it owns, and the scripts op's store run moves ADR entries, rewrites their inbound links in `docs/ai` pages and regenerates the index, as the rotator does — the outcome tokens by ensure, below, name each arm. One ensure failing **never** skips the others: each reports its own outcome and the run exits non-zero when any of them `failed`. The outcome tokens, by ensure: orchestration → `seeded` / `note-refreshed` / `already-current` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `not-placed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `already-current`; index → `regenerated` / `already-current` / `customized-preserved`; and any ensure may report `failed`, whose line OPENS with the cause (relay it with that cause — never soften it into a skip; an op that copies file by file also states when it stopped partway). The cause vocabulary is CLOSED — one of `race-unresolved`, `template-unreadable`, `bundle-unreadable`, `adr-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade** — before the equal-head exit, the migrations and the re-stamp. Add `--dry-run` to preview without writing a byte. Like the pointer slots + the footprint reconcile, all nine reach an equal-head deployment **without a lineage-head bump or a migration file**.
35
+ **`configs` — the project-configuration ensures, ONE run.** The ONE command performs **all nine** ensures — orchestration config · gate declaration · autonomy declaration · vehicles declaration · executor check · enforcement scripts · spec layer · project rules · navigator index — in a fixed order, and prints **one outcome line per ensure**: paste those lines into the step 4 / step 8 success report. Every SEED is **create-only** (an existing file is preserved byte-for-byte); a refresh-class op rewrites only what it owns, and the scripts op's store run moves ADR entries, rewrites their inbound links in `docs/ai` pages and regenerates the index, as the rotator does — the outcome tokens by ensure, below, name each arm. One ensure failing **never** skips the others: each reports its own outcome and the run exits non-zero when any of them `failed`. The outcome tokens, by ensure: orchestration → `seeded` / `note-refreshed` / `already-current` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `not-placed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `already-current`; index → `regenerated` / `already-current` / `customized-preserved`; and any ensure may report `failed`, whose line OPENS with the cause (relay it with that cause — never soften it into a skip; an op that copies file by file also states when it stopped partway). The cause vocabulary is CLOSED — one of `race-unresolved`, `template-unreadable`, `bundle-unreadable`, `adr-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade** — before the equal-head exit, the migrations and the re-stamp. Add `--dry-run` to preview without writing a byte. Like the kit block + the footprint reconcile, all nine reach an equal-head deployment **without a lineage-head bump or a migration file**.
37
36
 
38
- **What the orchestration-config ensure does.** `docs/ai/orchestration.json` must exist **and its onboarding note must be current**: created from the canonical seed if missing; if it already exists, the current note is left and an absent, prior or any other note is written current with no question and no copy kept, **every activity and slot the user set kept** (CRLF/whitespace normalized first) → `note-refreshed`; a differing note's line names the route — a note of your own goes in AGENTS.md, outside the two `<!-- workflow: -->` comment lines around the orchestration pointer; a *malformed* existing config is **preserved untouched + LOUD** → `malformed-preserved`, never clobbered and never silently skipped. The current note points at `/agent-workflow-kit set-recipe`. **Kit-owned:** in the **delegated** path memory only seeds or keeps the file (memory upgrade step 2) and this ensure writes the note; in the **fallback** path it does both. (Memory stays standalone.)
37
+ **What the orchestration-config ensure does.** `docs/ai/orchestration.json` must exist **and its onboarding note must be current**: created from the canonical seed if missing; if it already exists, the current note is left and an absent, prior or any other note is written current with no question and no copy kept, **every activity and slot the user set kept** (CRLF/whitespace normalized first) → `note-refreshed`; a differing note's line names the route — a note of your own goes in AGENTS.md, outside the kit block's two workflow:kit comment lines; a *malformed* existing config is **preserved untouched + LOUD** → `malformed-preserved`, never clobbered and never silently skipped. The current note points at `/agent-workflow-kit set-recipe`. **Kit-owned:** in the **delegated** path memory only seeds or keeps the file (memory upgrade step 2) and this ensure writes the note; in the **fallback** path it does both. (Memory stays standalone.)
39
38
 
40
39
  **What the gate-declaration ensure does.** `docs/ai/gates.json` must exist: created from `${CLAUDE_SKILL_DIR}/references/templates/gates.json` if missing — the kit's OWN template twin, so a memory substrate predating the gates feature never silently loses it; **an existing file is preserved byte-for-byte** (a declared gate matrix is authored content; no note-refresh here).
41
40
 
@@ -45,7 +44,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
45
44
 
46
45
  **What the enforcement-script ensure does.** It judges every kit script — each `*.mjs` of `${CLAUDE_SKILL_DIR}/references/scripts/` but the spec-layer pairs — once the component is accepted: a kit script outside the seed names (memory's own copies) stands in `scripts/` as a regular file. Each file by proof, with no question and no copy kept: a shipped prior is refreshed, an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. The hook installer and its two suites go first; a closing line says the commit hook runs the files written. A declined enforcement offer keeps the standing seed files current with the modules they import, places no other kit script (one line says so) and words that hook-run line as a condition. With no kit script there: `not-placed`, nothing written. **The ADR store, after the writes:** where the run judged the rotator, it runs `scripts/archive-decisions.mjs --ensure-current`, with no question, which brings the store current (an older layout moved) or writes nothing; its lines are relayed under `ADR store: `. A rotator that does not bring the store current is `failed` / `adr-store-not-current`, the scripts written above staying as written: its refusal stops the upgrade. Where the size practice measures `scripts/`, a write may grow a root past its record: the size check names its own reasoned `--write-baseline`. **Whether Node runs here is PROVEN, never proxied:** the ensure runs on a regular `package.json` at the root OR on any kit-seeded `scripts/*.mjs` already deployed; only when every probe answers absent does it report `skipped-no-node-evidence`, a line naming every probe it checked, while the config ensures still run; a probe that cannot be read is `failed` with the cause `node-evidence-unverifiable`, nothing written. **A `skipped-*` outcome whose stated reason this tool could itself disprove may not exist**. A deployed pre-commit hook takes a new installer body only when the installer next runs: the `enforcement` check line and apply, by the consent route, re-run it (it refuses a non-marker hook as always); until then `scripts/pre-commit.local` does not run.
47
46
 
48
- **What the navigator ensure does.** `docs/ai/index.md` is the always-loaded navigator the entry point declares, and it is GENERATED — no template ships it, so a deployment that never ran the generator boots from a broken entry point (and a Node project's hook fails its index check). The ensure runs the bundled generator's finalizer and reports `regenerated` (it was missing or stale — it was written) or `already-current` (nothing written); under a hook module that is not the bundled one, a write the project's own checker rejects is put back → `customized-preserved`. It never skips a No-Node project: the generator runs from `${CLAUDE_SKILL_DIR}/references/scripts/` on the agent host, not from the project's `scripts/`. **Its position in the run-list is EARLY and therefore NOT authoritative** — `lens` (and, on the migrated path, steps 6–7) still change `docs/ai` afterwards — so the authoritative run is the LATE `--only index` rung documented at both exits; the early one is idempotent: an untouched tree changes nothing.
47
+ **What the navigator ensure does.** `docs/ai/index.md` is the always-loaded navigator the entry point declares, and it is GENERATED — no template ships it, so a deployment that never ran the generator boots from a broken entry point (and a Node project's hook fails its index check). The ensure runs the bundled generator's finalizer and reports `regenerated` (it was missing or stale — it was written) or `already-current` (nothing written); under a hook module that is not the bundled one, a write the project's own checker rejects is put back → `customized-preserved`. It never skips a No-Node project: the generator runs from `${CLAUDE_SKILL_DIR}/references/scripts/` on the agent host, not from the project's `scripts/`. **Its position in the run-list is EARLY and therefore NOT authoritative** — the `tier` offer (and, on the migrated path, steps 6–7) may still change `docs/ai` afterwards — so the authoritative run is the LATE `--only index` rung documented at both exits; the early one is idempotent: an untouched tree changes nothing.
49
48
 
50
49
  **What the spec-layer ensure does.** A deployment older than the feature-spec layer lacks `scripts/spec-schema.mjs` and `docs/ai/specs/index.md`, and its deployed `check-docs-size.mjs` predates the store collapse. The four pair files follow the enforcement-script rule, with no question and no copy kept: a shipped prior is refreshed (an append-only digest catalog), an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. In ONE order: the reader pair, then the checker pair, then the store root, seeded create-only from the bundled template, date rendered — an older checker renders the store row by row and reds the hook's `--check-index`, so the checker is written first, and a write that fails stops every later one. A closing line says a commit hook that runs the files written may stop the next commit. One token by precedence: `seeded` > `refreshed` > `already-present`; `skipped-no-node-evidence` only when neither a root `package.json` nor any kit-seeded `scripts/*.mjs` is present (the same Node-evidence probe the enforcement-script ensure uses; an unreadable probe is `failed` / `node-evidence-unverifiable`). **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline the agent records), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
51
50
 
@@ -75,35 +74,10 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
75
74
  (equal-head too), no lineage-head bump; a *could not refresh* line is non-fatal — relay it plainly
76
75
  with its recovery.
77
76
 
78
- **`lens` — agent-rules lens refresh.** Relay the outcome in plain
79
- language: the planning/review lens section was **refreshed** to
80
- the current canon · had a **differing body — written** with the canon, its line naming the
81
- route: text of your own goes under a ### heading of its own, titled unlike the kit's sections ·
82
- the **file is absent — skipped** · the **engine is too old — skipped**
83
- (refresh it with `npx @sabaiway/agent-workflow-engine@latest init`, then re-run) · **over the
84
- file's line cap — refused** (trim the file, re-run). The section is found by its heading — no
85
- markers; a renamed heading, no longer opening with the title words, is noted. A fully absent/invalid engine is the same hard
86
- STOP as (c). Exit 0 covers every soft outcome; only the STOP is non-zero. The same invocation
87
- also reconciles the **Communication (user-facing messages)** and **story-sessions** sections
88
- from the kit's own bundled template canon (no engine involved) — relay each section's line:
89
- *refreshed* / *already current* / *differing body written* / *section absent — noted* /
90
- *over the file's line cap — refused*; an unreadable bundled template canon is its own loud STOP
91
- naming the kit reinstall command.
92
- A doubled heading in any of the three sections has nothing written.
93
- The **Communication and story-sessions** absent-section notes already carry the preview
94
- command: relay the printed note verbatim as the offer.
95
- Run the insert with `--apply` only on the user's explicit yes (the `tier` ask while `tier`
96
- offers `story-sessions-section`).
97
-
98
77
  **`tier` — the full-flow offer.** Relay every preview line. Ask ONCE, only when an entry is
99
78
  `offered`: yes re-runs it and every other offered `apply:` line with `--apply`; no re-runs it
100
- with `--decline`. `story-sessions-section` `offered`: run its preview line and relay its lines
101
- (Communication `planned` too) before the ask; `declined`: relay the lens story-sessions absent note
102
- as the recorded decline, without its preview command, and put no ask for it. `checker-gates-declared`
103
- `offered`: run its preview line and relay its lines, the disclosure and each `entry:` line included,
104
- before the ask. A Communication absent
105
- note beside a `present` or `declined` one keeps its own ask, after the insert's full preview
106
- (the insert is indivisible). In an upgrade this governs the composition handoff's lens ask. A
79
+ with `--decline`. `checker-gates-declared` `offered`: run its preview line and relay its lines,
80
+ the disclosure and each `entry:` line included, before the ask. A `declined` entry gets no ask. A
107
81
  `refused` item, or a non-zero exit of any command the ask runs, STOPs the upgrade before the
108
82
  re-stamp.
109
83
 
@@ -111,17 +85,17 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
111
85
  verbatim**: it validates the deployed host settings file's keys against the bundled manifests and
112
86
  **NEVER writes** it (the file lives outside every kit tree — D2), so an unknown/retired key is
113
87
  flagged + preserved, never edited. Runs on **every** upgrade; exit 0 covers every outcome.
114
- **The LATE navigator finalizer — the AUTHORITATIVE run, after the last `docs/ai` mutation.** `lens` above rewrites `docs/ai/agent_rules.md`, so the step-3 index ensure is already behind by the time the run-list ends. Re-run that ONE op here, before the step-4 report: `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>`. Relay **this** line in the report (it supersedes the early one; an untouched tree changes nothing, a failure STOPs the upgrade like any other ensure). On the migrated path the same rung runs again at the END of step 7 — after the migrations, before the step-8 re-stamp.
88
+ **The LATE navigator finalizer — the AUTHORITATIVE run, after the last `docs/ai` mutation.** The `tier` offer above may write `docs/ai`, so the step-3 index ensure may be behind by the time the run-list ends. Re-run that ONE op here, before the step-4 report: `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>`. Relay **this** line in the report (it supersedes the early one; an untouched tree changes nothing, a failure STOPs the upgrade like any other ensure). On the migrated path the same rung runs again at the END of step 7 — after the migrations, before the step-8 re-stamp.
115
89
  4. **Equal-head exit — a real successful-exit report, not a bare stop.** If the stamp **equals** the head, the lineage is up to date — but step 3 (the stamp-independent reconciles) ran first and may have changed things, so this is a proper exit report, not a no-op:
116
90
  - **A skip line that contradicts the observed tree is a FINDING, never pasted as neutral.** Every ensure skip names the fact it proved (the probes that answered absent); if the tree you can see disproves that reason — a "no Node" skip beside deployed Node scripts, a "not deployed" skip beside a stamped `docs/ai` — do not relay the line as an outcome: raise it in the report as a defect of the tool, with the contradicting fact named, and stop short of any step that would build on the skip.
117
- - **Report step 3's outcome in plain language** — for **each** `pointers` slot (workflow-methodology, orchestration-recipes and autonomy-policy) whether it was *added*, was *already present* (nothing changed), was *written over a different one* (its route: text of your own goes outside the two `<!-- workflow: -->` comment lines around each pointer), or was *skipped* (the soft-skip from step 3, with its reason — over the line limit / engine too old / the autonomy pointer's anchor absent), and each Memory Map row the same way (or *refreshed*), a *written* row with its route: a row of your own goes on a line of its own, its first cell a path of your own; the **nine project-configuration ensure** (`configs`) lines exactly as the one ensure run composed them (the ensures and their outcome tokens are enumerated in step 3), each rendered in plain language: what was created, what was left exactly as the user wrote it, and — for a `failed` line — what stopped it; for the navigator, relay the **late** `--only index` line, not the early one; the **`gates-migration`** result — *nothing to migrate*, the shown plan *applied* on your explicit yes, or the plan *left unapplied* (consent not given), with any INERT checker or CUSTOMIZED entries named; the **placed-bridge refresh** (`bridges`) outcome — paste the tool's per-bridge lines verbatim (they are already plain: *refreshed* / *already current* / *skipped — not placed* / `skipped-readonly` with its re-scan verdict / *could not refresh* + recovery); the **agent-rules lens** (`lens`) outcome (*refreshed* / *already current* / *differing body written*, its line naming the route: text of your own goes under a ### heading of its own, titled unlike the kit's sections / *file absent* / *engine too old* / *over the line cap*; a doubled heading has nothing written) and the **Communication-section** and **story-sessions section** outcomes (each its own set: refreshed / already current / differing body written / section absent — noted / over the file's line cap — refused); the **full-flow offer** (`tier`) lines; the **bridge-settings reconcile** (`bridge-settings`) outcome (paste the tool's line(s) verbatim); and, for a hidden deployment, whether the hidden-mode footprint (`footprint`) was *moved to project-local*, was *already project-local* (nothing changed), or needed a question (ambiguous visibility). Plain wording only — never the reconcile/slot/anchor/marker terms (the never-leak-kit-internals Gotcha — `${CLAUDE_SKILL_DIR}/references/shared/deploy-tail.md`).
91
+ - **Report step 3's outcome in plain language** — the kit block (`entry-block`): whether it was *added* at the start of the file, was *already current* (nothing changed) or was *written* with the current kit text (its route: text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/), with each `note:` line about a text the engine does not supply; the **nine project-configuration ensure** (`configs`) lines exactly as the one ensure run composed them (the ensures and their outcome tokens are enumerated in step 3), each rendered in plain language: what was created, what was left exactly as the user wrote it, and — for a `failed` line — what stopped it; for the navigator, relay the **late** `--only index` line, not the early one; the **`gates-migration`** result — *nothing to migrate*, the shown plan *applied* on your explicit yes, or the plan *left unapplied* (consent not given), with any INERT checker or CUSTOMIZED entries named; the **placed-bridge refresh** (`bridges`) outcome — paste the tool's per-bridge lines verbatim (they are already plain: *refreshed* / *already current* / *skipped — not placed* / `skipped-readonly` with its re-scan verdict / *could not refresh* + recovery); the **full-flow offer** (`tier`) lines; the **bridge-settings reconcile** (`bridge-settings`) outcome (paste the tool's line(s) verbatim); and, for a hidden deployment, whether the hidden-mode footprint (`footprint`) was *moved to project-local*, was *already project-local* (nothing changed), or needed a question (ambiguous visibility). Plain wording only — never the reconcile/slot/anchor/marker terms (the never-leak-kit-internals Gotcha — `${CLAUDE_SKILL_DIR}/references/shared/deploy-tail.md`).
118
92
  - **Never surface the structure number on this exit.** Whatever step 3 did, do **not** recite the `docs/ai` structure version, the internal versioning vocabulary, or the two-axes note here — the number is inert on an equal-head exit; it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md` (shown at the never-downgrade STOP, the explicit status view, or on an explicit ask). Frame the success itself per the final bullet: if step 3 changed anything, say **what changed** in plain human terms; only a pure zero-diff no-op is *settings already current — no update needed*.
119
93
  - **Render the mandatory Recommendations section — on this exit too, BEFORE the footer.** Run `node ${CLAUDE_SKILL_DIR}/tools/recommendations.mjs --cwd <project-root>` and PRESENT its output — from the `## Recommendations (agent-workflow)` header — in the user's conversational language: every fact, count and item from the tool, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; show the raw tool block on request. The section is present-even-when-empty (with everything optimal the body is exactly `no recommendations — flow optimal.`) and VERDICT-FIRST — the composed verdict line renders from the frozen templates `{K} item(s) need attention` / `nothing is broken` / `{N} optional recommendation(s), apply any you want` / `optimality NOT attested — {M} probe check(s) skipped`. Then apply each kit item by the kit route, with no question: its check line in the sandbox, then at once its apply line once outside it. Then OFFER the consent route: the user picks items in plain language; surface each picked item's posture note and get the explicit confirm; run its lane's rendered lines — chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — per the full consent route in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. Pinned order on this exit: Recommendations block → optional applies → report footer → the commit ask (the advisor/apply lane never lands after the commit ask).
120
94
  - **Recommendations lanes — both exits.** The four lanes (`chat`, `harness`, `kit`, `user`), the consent route and the kit route live in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`; `init` stays a route the user may take.
121
95
  - **Live host/session facts are tool-composed only.** Any claim this report makes about the current host or session state — prompts fired, sandbox scope, whether a bypass was needed, network reachability, approval counts — must trace to **live tool output** from **this session** (the lines you just composed, or a probe you ran this run); a memory/handover snapshot is **context, never report facts**, and a claim with no live signal is **omitted or explicitly marked unverified** — never asserted from recollection. Full clause: *Live host/session facts* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`.
122
96
  - **Print the report footer** in the canonical order (version block → one-line backend-status line → welcome mat — the shared contracts in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`; rendered from the helpers, same host-can't-run skip-with-reason). The welcome mat closes on **one** caveat-aware next step (a behind member first, else `setup` / `recipes` / `velocity` / `agents` / `hook`).
123
- - **Then ask before committing — never auto-commit.** If step 3 added the slot (or anything else changed), report it and ask. If step 3 was a pure zero-diff no-op and nothing else changed, give the plain **settings already current — no update needed** message (the *Success state* contract in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`) and still print the read-only version block (installed package versions) + backend line — but **no `docs/ai` structure version and no two-axes note** (nothing changed, so the number is inert here).
97
+ - **Then ask before committing — never auto-commit.** If step 3 added the kit block (or anything else changed), report it and ask. If step 3 was a pure zero-diff no-op and nothing else changed, give the plain **settings already current — no update needed** message (the *Success state* contract in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`) and still print the read-only version block (installed package versions) + backend line — but **no `docs/ai` structure version and no two-axes note** (nothing changed, so the number is inert here).
124
98
  5. Show the relevant `${CLAUDE_SKILL_DIR}/CHANGELOG.md` diff (entries newer than the project's stamp).
125
- 6. **Collect the migration answers FIRST, then apply.** Run `node ${CLAUDE_SKILL_DIR}/tools/migration-notes.mjs --cwd <project>` and relay its stdout lines verbatim, in order; a non-zero exit relays its one named line and STOPs, except `stamp-absent`, which routes back to step 1. Then run the preview `node ${CLAUDE_SKILL_DIR}/tools/migration-blocks.mjs --cwd <project>`. If its lines say both blocks are missing (pre-1.1.0), ask the two questions as ONE structured multi-question prompt; record each answer individually, write nothing until ALL are answered, and carry the answers into the migrations below: a migration whose answer was already collected never re-asks; a single missing block keeps its single ask (step 7). Then apply exactly the notes the tool listed, in its order ("only those newer than the project's stamp" is why, never a second selection). Migrations are **idempotent** — safe to re-run.
126
- 7. Reconcile drift: add any kernel files/scripts the project is missing; never clobber project-authored content (their `decisions.md`, `known_issues.md`, page specs stay). Any user question a migration raises follows the same rule as bootstrap — **structured multiple-choice where supported** (`AskUserQuestion` in Claude Code), otherwise prose. For a block the preview names as needing its answer, **ask the user their conversational language** (`--language`) or **whether the agent may attribute work to itself / AI** (`--attribution`, defaulting to `off`), never re-asking a step-6 answer; then re-run the preview with `--apply` and the answers, relaying its lines. Exit 1 `answer-missing`: ask exactly what its lines name and re-run `--apply` once; a second one STOPs. Any other exit 1 is a named refusal: relay it with its recovery (`cap`: trim `AGENTS.md`, re-run) and STOP before the finalizer and the stamp. **Then, before the stamp, re-run the LATE navigator finalizer:** the migrations of steps 6–7 may have changed `docs/ai` files, so run the one op again — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>` — and relay THAT line in the step-8 report (idempotent: an untouched tree changes nothing; a failure STOPs this upgrade like any other ensure).
127
- 8. Re-stamp `docs/ai/.workflow-version` to the **deployment-lineage head** (`4.0.0`, not the package version — mechanics unchanged: the atomic write to the stamp file). In the report, **describe what the upgrade changed in plain human terms** — which parts of their `docs/ai` are now different (the migrations that ran), plus the step-3 run-list outcomes, each as step 4 words it: the `pointers` slots and Memory Map rows, the `footprint` visibility verdict (and what a consented re-run migrated), the **nine project-configuration ensure** (`configs`) lines (enumerated in step 3) — the navigator one being the late `--only index` run at the end of step 7, the **`gates-migration`** result, the **placed-bridge refresh** (`bridges`) lines (pasted verbatim), the **agent-rules lens** (`lens`) + **Communication-section** + **story-sessions section** outcomes (same outcome sets as step 4), the **full-flow offer** (`tier`) outcome, and the **bridge-settings reconcile** (`bridge-settings`) outcome (line(s) pasted verbatim) — rather than reciting a version number; **omit the raw structure number**, and do **not** print the two-axes note here (it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`, on demand only). Then **render the mandatory Recommendations section**: run `node ${CLAUDE_SKILL_DIR}/tools/recommendations.mjs --cwd <project-root>` and PRESENT its output — from the `## Recommendations (agent-workflow)` header — in the user's conversational language (every fact, count and item, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request; present-even-when-empty: `no recommendations — flow optimal.`), then apply each kit item by the kit route (no question: its check line, then at once its apply line), then OFFER the consent route (per picked item: posture note → explicit confirm → chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`). **Every current host/session claim in this report is tool-composed only** — prompts fired, sandbox scope, whether a bypass was needed, network reachability and approval counts must trace to **live tool output** from **this session**, a memory/handover snapshot is **context, never report facts**, and an unbacked claim is **omitted or explicitly marked unverified** (full clause: *Live host/session facts* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`). Then **print the report footer** in the canonical order (version block → one-line backend-status line → welcome mat — the shared contracts in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`; rendered from the helpers, same host-can't-run skip-with-reason; the welcome mat closes on one caveat-aware next step). Then **ask before committing** — the pinned order on this exit is: Recommendations block → optional applies → report footer → the commit ask.
99
+ 6. **Collect the migration answers FIRST, then apply.** Run `node ${CLAUDE_SKILL_DIR}/tools/migration-notes.mjs --cwd <project>` and relay its stdout lines verbatim, in order; a non-zero exit relays its one named line and STOPs, except `stamp-absent`, which routes back to step 1. Then run the preview `node ${CLAUDE_SKILL_DIR}/tools/migration-blocks.mjs --cwd <project>`. If its lines say both blocks are missing (pre-1.1.0), ask the two questions as ONE structured multi-question prompt; record each answer individually, write nothing until ALL are answered, and carry the answers into the migrations below: a migration whose answer was already collected never re-asks; a single missing block keeps its single ask (step 7). Then apply exactly the notes the tool listed, in its order ("only those newer than the project's stamp" is why, never a second selection). Migrations are **idempotent** — safe to re-run. When a note names an exit of its command a refusal and gives it no retry of its own, relay that refusal's line with the recovery it names and STOP before the finalizer and the stamp, so the next upgrade applies that note again.
100
+ 7. Reconcile drift: add any kernel files/scripts the project is missing; never clobber project-authored content (their `decisions.md`, `known_issues.md`, page specs stay). Any user question a migration raises follows the same rule as bootstrap — **structured multiple-choice where supported** (`AskUserQuestion` in Claude Code), otherwise prose. For a block the preview names as needing its answer, **ask the user their conversational language** (`--language`) or **whether the agent may attribute work to itself / AI** (`--attribution`, defaulting to `off`), never re-asking a step-6 answer; then re-run the preview with `--apply` and the answers, relaying its lines. Exit 1 `answer-missing`: ask exactly what its lines name and re-run `--apply` once; a second one STOPs. Any other exit 1 is a named refusal: relay it with its recovery and STOP before the finalizer and the stamp. **Then, before the stamp, re-run the LATE navigator finalizer:** the migrations of steps 6–7 may have changed `docs/ai` files, so run the one op again — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>` — and relay THAT line in the step-8 report (idempotent: an untouched tree changes nothing; a failure STOPs this upgrade like any other ensure).
101
+ 8. Re-stamp `docs/ai/.workflow-version` to the **deployment-lineage head** (`5.0.0`, not the package version — mechanics unchanged: the atomic write to the stamp file). In the report, **describe what the upgrade changed in plain human terms** — which parts of their `docs/ai` are now different (the migrations that ran), plus the step-3 run-list outcomes, each as step 4 words it: the kit block (`entry-block`), the `footprint` visibility verdict (and what a consented re-run migrated), the **nine project-configuration ensure** (`configs`) lines (enumerated in step 3) — the navigator one being the late `--only index` run at the end of step 7, the **`gates-migration`** result, the **placed-bridge refresh** (`bridges`) lines (pasted verbatim), the **full-flow offer** (`tier`) outcome, and the **bridge-settings reconcile** (`bridge-settings`) outcome (line(s) pasted verbatim) — rather than reciting a version number; **omit the raw structure number**, and do **not** print the two-axes note here (it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`, on demand only). Then **render the mandatory Recommendations section**: run `node ${CLAUDE_SKILL_DIR}/tools/recommendations.mjs --cwd <project-root>` and PRESENT its output — from the `## Recommendations (agent-workflow)` header — in the user's conversational language (every fact, count and item, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request; present-even-when-empty: `no recommendations — flow optimal.`), then apply each kit item by the kit route (no question: its check line, then at once its apply line), then OFFER the consent route (per picked item: posture note → explicit confirm → chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`). **Every current host/session claim in this report is tool-composed only** — prompts fired, sandbox scope, whether a bypass was needed, network reachability and approval counts must trace to **live tool output** from **this session**, a memory/handover snapshot is **context, never report facts**, and an unbacked claim is **omitted or explicitly marked unverified** (full clause: *Live host/session facts* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`). Then **print the report footer** in the canonical order (version block → one-line backend-status line → welcome mat — the shared contracts in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`; rendered from the helpers, same host-can't-run skip-with-reason; the welcome mat closes on one caveat-aware next step). Then **ask before committing** — the pinned order on this exit is: Recommendations block → optional applies → report footer → the commit ask.
@@ -10,7 +10,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/command-shapes.md
10
10
 
11
11
  The opt-in onboarding **velocity profile** — it seeds a fixed, audited **read-only** Claude Code allowlist into `.claude/settings.json` so an agent stops idling on approval prompts for routine read-only commands while the maintainer is away. It is the family's **first programmatic `.claude/settings.json` writer** (attribution stayed an agent-driven prose merge). **In-agent, opt-in, writes `.claude/settings.json`** — its `--worktrees` mode alone writes `.claude/settings.local.json` plus the created parent — on one hard rule: **it never allowlists `commit`/`push`/`publish`** — so a direct commit/push/publish still ASKs; the only caveat is the trust-posture residual (below) — its closure is **shipped, opt-in: `${CLAUDE_SKILL_DIR}/references/modes/hook.md`**.
12
12
 
13
- **Version-status routing (like the other writer modes):** read `docs/ai/.workflow-version` first — not-deployed → bootstrap; stamp < `4.0.0` → `upgrade`; stamp > head / unparseable → STOP. The tool enforces this in code too (`--apply` STOPs unless the stamp is the lineage head).
13
+ **Version-status routing (like the other writer modes):** read `docs/ai/.workflow-version` first — not-deployed → bootstrap; stamp < `5.0.0` → `upgrade`; stamp > head / unparseable → STOP. The tool enforces this in code too (`--apply` STOPs unless the stamp is the lineage head).
14
14
 
15
15
  Run `node ${CLAUDE_SKILL_DIR}/tools/velocity-profile.mjs [--dry-run | --apply] [--kit-tools] [--bridge-tier] [--accept-edits] [--cwd <dir>]`:
16
16
 
@@ -12,9 +12,6 @@
12
12
  { "id": "payload-converged",
13
13
  "story": "S1",
14
14
  "has": "The installed kit holds no file the package stopped shipping." },
15
- { "id": "story-sessions-section",
16
- "story": "S2",
17
- "has": "The project's rules carry the story-sessions section." },
18
15
  { "id": "epic-task-slots",
19
16
  "story": "S3",
20
17
  "has": "The orchestration settings carry the epic and task slots, each resolved to your environment or to solo with the reason." },
@@ -24,9 +21,6 @@
24
21
  { "id": "checker-gates-declared",
25
22
  "story": "S4",
26
23
  "has": "The kit-owned checker gates are declared." },
27
- { "id": "session-close-rules",
28
- "story": "S5",
29
- "has": "The rules your project reads state the session-close value section and the four-session story flow." },
30
24
  { "id": "named-queue-row-seed",
31
25
  "story": "S5",
32
26
  "has": "A new work queue is seeded with the named row." },
@@ -0,0 +1,22 @@
1
+ ---
2
+ type: rules
3
+ lastUpdated: 2026-10-28
4
+ scope: permanent
5
+ staleAfter: never
6
+ owner: kit
7
+ maxLines: 40
8
+ ---
9
+
10
+ # Communication
11
+
12
+ The kit block of AGENTS.md is the kit's and is rewritten on every upgrade; it and docs/ai/rules/effective/ govern over any copy of kit text elsewhere in this project's files; text of your own goes outside the block, and a change to a kit rule goes in its theme's file under docs/ai/rules/local/.
13
+
14
+ - **Plain language.** User-facing narration is short, clear, plain words of the dialogue language; when the dialogue language is not English, transliterated English jargon is banned — an English term survives only as the NAME of a thing (a flag / command / file / test), glossed in plain words when helpful; plain English stays plain for English-dialogue users.
15
+ - **Deliver the artifact IN the message** — paste the prompt / diff / version / command inline; never "see §X / open the file / run it and you'll see" as a *substitute* for showing what was asked.
16
+ - **Lead with the result**, then the details; show exactly what was asked — no deflection, no "almost done" when the ask was the finished thing.
17
+ - **No condescension, no filler.** Own a miss plainly and fix it in the same message.
18
+ - **Large artifact (≈>100 lines):** deliver a real summary or the key excerpt inline **and** link the file — never flood the reader with a 2000-line paste, never hide the answer behind a bare pointer.
19
+ - **Live host/session facts are tool-composed only.** Any claim about the current host or session state (prompts fired, sandbox scope, whether a bypass was needed, network reachability, approval counts) must trace to **live tool output** from **this session**; a memory/handover snapshot is **context, never report facts**, and a claim with no live signal is **omitted or explicitly marked unverified** — never asserted from recollection.
20
+ - **The closing state block answers three DIFFERENT questions.** Close a user-facing message with three labelled slots — *now* · *what I need from you* · *what's next*. The slot LABELS stay ENGLISH — an English label is what lets a state-block checker FIND the block and its slots at all; everything written INTO a slot is in the project's dialogue language; when that language is not English, the checker's English phrase sets do not judge those values. **Now** = the state at this instant: what is RUNNING, or what the work is stopped on. It is **never a report of finished work** — what you completed goes in the message BODY, above the block. **From you** = the real unblocker, named; a turn that is ENDING always has one. **Next** = what follows. A *now* slot that opens with what was completed buries the one fact the reader opened the message for, and the three slots collapse into one restatement.
21
+ - **A skip that contradicts the tree is a finding.** A tool-composed `skipped-*` line whose stated reason the observed tree disproves (a "no Node" skip beside deployed Node scripts) is raised as a FINDING in the report, never pasted as a neutral outcome — and a tool may not emit a skip whose reason it could itself disprove.
22
+ - **Two blocks for the user.** At a plan's approval, at a release and at every session close, the message BODY — above the closing state block — carries two short blocks in the dialogue language. *What was done, and for what*: per item the user-facing problem, then what now exists; a command name is allowed, an internal id is not. *What is next, and why*: each proposal names its benefit, plus the one hand step if any. No internal ids, no review-round tallies. The same two blocks are the handover's `## For the user` section, which the kit's `session-close-check` checker judges at the close, where the kit is installed.
@@ -9,6 +9,8 @@ maxLines: 80
9
9
 
10
10
  # Project layout
11
11
 
12
+ The kit block of AGENTS.md is the kit's and is rewritten on every upgrade; it and docs/ai/rules/effective/ govern over any copy of kit text elsewhere in this project's files; text of your own goes outside the block, and a change to a kit rule goes in its theme's file under docs/ai/rules/local/.
13
+
12
14
  Where a file goes is decided by what it means, never by where there is room.
13
15
 
14
16
  ## A module is a directory
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: rules
3
+ lastUpdated: 2026-10-28
4
+ scope: permanent
5
+ staleAfter: never
6
+ owner: kit
7
+ maxLines: 30
8
+ ---
9
+
10
+ # Story sessions
11
+
12
+ The kit block of AGENTS.md is the kit's and is rewritten on every upgrade; it and docs/ai/rules/effective/ govern over any copy of kit text elsewhere in this project's files; text of your own goes outside the block, and a change to a kit rule goes in its theme's file under docs/ai/rules/local/.
13
+
14
+ A story — one row of an epic's ledger, carried by one plan — runs as four sessions, each step in them giving one checked result: **spec and plan** (every contract the story creates or revises and the plan's ledger beside them, checked by the spec gate, the plan-shape gate and one review of at most two rounds that reads both, then the plan's approval), **tests** (only tests, each new one failing for the reason its scenario or acceptance bullet states, or on the absence of a name the plan adds, imported inside the test; no code and no prototype), **code** (code until the tests and the pre-review gates pass; a wrong test is changed only back to what its scenario states), and **diff review, release and record** (every committable output, tracked records included, staged first, the review of the staged diff in at most two rounds, the final gates and the release where the story ships one, then the plan's Phase: Cleanup). Tests and code never share a session. A storyless plan runs the same four. **Exception — a split:** moving code and its existing cases into modules, with no new logic and no new case, is one session: a short spec (the Module list), the split, the diff review, the release, Cleanup. A bridge executor gets a task only when it writes new tests or code, from one prompt of the orchestrator; a file the orchestrator already wrote is laid down by the orchestrator, never relayed through a bridge.
@@ -1,74 +1,39 @@
1
- ## Hand-off contract & bounded pointer reconciliation (composition root)
1
+ ## Hand-off contract & the kit block (composition root)
2
2
 
3
3
  **Hand-off contract (explicit; tested independent of agent interpretation).**
4
4
  - **Delegated** (memory valid): the kit passes the **target project dir** + the **three setup
5
5
  answers** (visibility / language / attribution — memory is told to skip its step-4 settings write; the `attribution` item of step 11 sets it) to `agent-workflow-memory`, which writes
6
- `docs/ai/` + `AGENTS.md` (carrying the **three empty pointer pairs** — `workflow:methodology`,
7
- `workflow:orchestration` and `workflow:autonomy`) + **`.memory-version`**. The kit then **reconciles
8
- the bounded pointers** (below) and writes the kit-fallback **`.workflow-version`**. → **both stamps** present. In **hidden** mode the kit is the **single
6
+ `docs/ai/` + `AGENTS.md` + **`.memory-version`**. The kit then **writes the kit block** (below)
7
+ and writes the kit-fallback **`.workflow-version`**. → **both stamps** present. In **hidden** mode the kit is the **single
9
8
  hide authority**: after the hand-off it runs `tools/hide-footprint.mjs` (bootstrap step 9 — `${CLAUDE_SKILL_DIR}/references/modes/bootstrap.md`), which **absorbs
10
9
  memory's project-local footprint lines** into the one canonical `.git/info/exclude` block and adds
11
10
  the external footprint — so the hide makes **no machine-global write** (a stale memory's
12
11
  residual global block is the advisor's footprint-global item).
13
12
  - **Fallback** (memory absent/invalid): the kit runs the bootstrap procedure (`${CLAUDE_SKILL_DIR}/references/modes/bootstrap.md`) from its own
14
- bundled assets — whose entry-point template now ships **three empty pointer pairs** (`workflow:methodology`
15
- + `workflow:orchestration` + `workflow:autonomy`) the kit reconciles + fills — and writes **`.workflow-version`** only.
13
+ bundled assets — whose entry-point template the kit block is then written into — and writes **`.workflow-version`** only.
16
14
  Softly suggest installing `agent-workflow-memory` — never a prerequisite.
17
15
 
18
- **Bounded pointer reconciliation (the kit is the ONLY writer of these slots).** After `AGENTS.md`
19
- exists, run ONE command — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile
20
- <project>/AGENTS.md` — which reconciles **three** bounded pointers in a single atomic write: the
21
- **workflow-methodology** pointer (the plan → execute → review summary), the
22
- **orchestration-recipes** pointer (the Solo / Reviewed / Council / Delegated / Subagent vocabulary, routing to
23
- `/agent-workflow-kit recipes`) right below it, and the **autonomy-policy** pointer (the
24
- `docs/ai/autonomy.json` read contract) below that. Each is **one atomic operation per slot**:
25
- **ensure the slot exists**
26
- (insert an empty marker pair at its anchor when a legacy entry point lacks one) → **judge it against
27
- the bounded fragment**: the same text needs no write; an empty slot is filled; any other text is
28
- written with the fragment, no question and no copy kept, its line naming the route — text of your
29
- own goes outside the two `<!-- workflow: -->` comment lines around each pointer →
30
- **cap-check** (each chained pointer's check runs on the file *after* the previous one, so it guards the
31
- **combined** ≤100-line budget). The same call writes a Memory Map row with other text current, its
32
- line naming the route — a row of your own goes on a line of its own, its first cell a path of your
33
- own. The fragments are short summary + pointer, read **live from the
34
- installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md`
35
- + `references/autonomy-slot.md`,
36
- the family's one source of truth) — **not** a bundled mirror, and **not** the full references. The
37
- live read is **fail-loud**: the engine is read for every pointer the run judges, so an
38
- **absent/invalid** engine **STOPs** the reconcile also when every pointer is filled — report it in
39
- plain language with the one-line install command
40
- `npx @sabaiway/agent-workflow-engine@latest init` (`npx @sabaiway/agent-workflow-kit@latest init`
41
- installs the engine for you; translate, never leak tool internals). Contract per slot: exactly one
42
- ordered `start → end` pair; a malformed slot (single, reversed, nested, duplicate) or a missing /
43
- duplicate anchor → **STOP with an error**, never edit (nothing is written). A
44
- **chained pointer is soft-skipped** (reported, never silent) when — and only when — adding or writing it
45
- would exceed the 100-line cap, the engine is too old to ship its fragment, or (autonomy only) the
46
- orchestration pointer was itself skipped this run: every prior pointer still lands and the upgrade continues.
16
+ **The kit block (the kit is the ONLY writer of it).** After `AGENTS.md` exists, run ONE command —
17
+ `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` — which writes
18
+ the kit block between its two `workflow:kit` comment lines in a single atomic write: the precedence
19
+ line, the read line, the **workflow-methodology**, **orchestration-recipes** and **autonomy-policy**
20
+ texts, and the rules-themes table, one row per theme. The block is written current with no question
21
+ and no copy kept, its line naming the route — text of your own goes outside the two workflow:kit
22
+ comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/. A file
23
+ with no block gains it at its start; with a valid installed engine supplying every text, a
24
+ deployment whose kit block is current reconciles to a zero-diff no-op. The texts are read **live from the installed
25
+ `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md` +
26
+ `references/autonomy-slot.md`, the family's one source of truth) — **not** a bundled mirror. The
27
+ read is **fail-loud**: an **absent/invalid** engine **STOPs** the run, nothing written — report it
28
+ in plain language with the one-line install command `npx @sabaiway/agent-workflow-engine@latest init`
29
+ (`npx @sabaiway/agent-workflow-kit@latest init` installs the engine for you; translate, never leak
30
+ tool internals). An engine that lacks a later text writes one line in its place and a note naming
31
+ the refresh command. Comment lines that are not exactly one start line before one end line are
32
+ refused with their line numbers, nothing written: the upgrade STOPs.
47
33
 
48
- **Agent-rules lens + Communication refresh (runs in BOTH paths).** Its precondition is its own target file — run it
49
- only after `<project>/docs/ai/agent_rules.md` exists: after the substrate deploy in the
50
- **delegated** path, after the fallback-template copy in the **kit** path (never anchored to the
51
- `AGENTS.md` step above). ONE command:
52
- `node ${CLAUDE_SKILL_DIR}/tools/lens-region.mjs reconcile <project>/docs/ai/agent_rules.md`.
53
- This is what converges a substrate seeded by an older memory — a lens section matching a known
54
- prior canonical body is refreshed from the installed engine; a current seed reports *already
55
- current* (zero-diff). Relay its outcome in plain language (*refreshed* / *already current* /
56
- *differing body written* / *file absent — skipped* / *engine too old — skipped* / *over the
57
- line cap — refused*); a fully absent/invalid engine is the same loud STOP + one-line install
58
- command as the pointer reconcile. The same invocation also reconciles the **Communication
59
- (user-facing messages)** and **story-sessions** sections from the kit's own bundled template canon (no engine involved):
60
- a body matching the current canon is reported *already current*; a body matching a known prior
61
- is refreshed; any other differing body is written with the canon, its line naming the route: text
62
- of your own goes under a ### heading of its own, titled unlike the kit's sections; a doubled
63
- heading has nothing written; an absent section is a stated note;
64
- an over-cap write is refused; and an unreadable bundled template canon is its own
65
- loud STOP naming the kit reinstall command. Relay both sections' outcome lines.
66
- The printed absent-section note already carries the preview command: relaying it is the offer.
67
- Run the insert with `--apply` only on the user's explicit yes.
68
-
69
- **Navigator finalizer (runs in BOTH paths, AFTER the lens reconcile above).** `docs/ai/index.md` is
70
- a GENERATED artifact the entry point declares always-loaded, and the reconcile above may have just
71
- rewritten a `docs/ai` file — so the finalizer runs at the LAST `docs/ai` mutation of the deploy,
34
+ **Navigator finalizer (runs in BOTH paths, AFTER the block write above).** `docs/ai/index.md` is
35
+ a GENERATED artifact the entry point declares always-loaded, and the deploy may have just
36
+ written a `docs/ai` file — so the finalizer runs at the LAST `docs/ai` mutation of the deploy,
72
37
  before the stamp and the report. ONE command:
73
38
  `node ${CLAUDE_SKILL_DIR}/references/scripts/check-docs-size.mjs --ensure-index --root=<project>`.
74
39
  Relay its one outcome line (*regenerated* / *already current*); a `write-refused` (the write) or
@@ -12,7 +12,7 @@ The non-obvious traps — scan these before bootstrapping or upgrading. Each is
12
12
  - **Enforcement is offered on every project.** The dependency-free scripts are available because the agent host already runs the navigator; for the offer, the only skip condition is that the agent host cannot run them. The hook calls `node scripts/<x>.mjs`, so a committer without `node` on PATH gets the hook's own loud failure. **A skip names a PROVEN fact, never a proxy:** upgrade ensures judge Node by EVIDENCE — a root `package.json` OR any kit-seeded `scripts/*.mjs` already deployed — and the `skipped-no-node-evidence` line lists every probe that answered absent; a reason the tool could disprove is a tool defect. **A skip line that contradicts the observed tree is raised as a finding in the report, never pasted as neutral** — report the contradiction with the proven fact and do not build on the skip.
13
13
  - **Conversational language never translates artifacts.** It governs *dialogue only*. Code, identifiers, paths, commands, log output, abbreviations, and every deployed `docs/ai/` / `AGENTS.md` file stay in their source language. See [Communication contract](${CLAUDE_SKILL_DIR}/references/contracts.md#communication-contract).
14
14
  - **Never auto-commit.** Report quality-gate results and wait for explicit approval — in both modes.
15
- - **Never leak kit internals to the user — and a tool-COMPOSED user-facing line holds the same bar at the source.** No ADR ids, tool / function / operation names (`reconcile`, `inject`, `ensureSlot`), marker / slot / fragment / anchor terminology, or verbatim tool stderr **inside the human sentence** of anything the user reads. Translate every tool outcome into plain language a third-party user — who has never read this `SKILL.md` — can understand and act on (e.g. the cap-refusal report in `${CLAUDE_SKILL_DIR}/references/modes/upgrade.md` step 3). The composed lines themselves are **user-grade** language: machine tokens and tool self-labels belong to the **machine-line channel** — the `[run-gates] status=…` grammar (`${CLAUDE_SKILL_DIR}/references/modes/gates.md`), a line's leading self-label/prefix, or a runnable command/path the user can act on — never mid-sentence; alarm words (`PARTIALLY`, `incomplete`, `failed`, `broken`, `persists`) render only in outcomes gated on a **detected abnormal condition**. ONE designed exception, stated not implied: the configuration ensures' LEADING outcome token — one closed-vocabulary token, a failure's closed cause word opening its detail line — is that contract's own machine slot, not a leak. The **verbatim**-paste contract stays: the agent pastes tool-composed outcome lines as written and never re-composes their facts — the lines are user-grade at the source, so pasting them verbatim IS the plain language.
15
+ - **Never leak kit internals to the user — and a tool-COMPOSED user-facing line holds the same bar at the source.** No ADR ids, tool / function / operation names (`reconcile`, `inject`, `ensureSlot`), marker / slot / fragment / anchor terminology, or verbatim tool stderr **inside the human sentence** of anything the user reads. Translate every tool outcome into plain language a third-party user — who has never read this `SKILL.md` — can understand and act on (e.g. the kit-block refusal report in `${CLAUDE_SKILL_DIR}/references/modes/upgrade.md` step 3). The composed lines themselves are **user-grade** language: machine tokens and tool self-labels belong to the **machine-line channel** — the `[run-gates] status=…` grammar (`${CLAUDE_SKILL_DIR}/references/modes/gates.md`), a line's leading self-label/prefix, or a runnable command/path the user can act on — never mid-sentence; alarm words (`PARTIALLY`, `incomplete`, `failed`, `broken`, `persists`) render only in outcomes gated on a **detected abnormal condition**. ONE designed exception, stated not implied: the configuration ensures' LEADING outcome token — one closed-vocabulary token, a failure's closed cause word opening its detail line — is that contract's own machine slot, not a leak. The **verbatim**-paste contract stays: the agent pastes tool-composed outcome lines as written and never re-composes their facts — the lines are user-grade at the source, so pasting them verbatim IS the plain language.
16
16
  - **Uninstall never deletes user-authored content, and dry-runs first.** `/agent-workflow-kit uninstall` removes only what is **provably ours** (a managed skill dir / wrapper symlink / fenced block / marker hook) and **prints — never runs** the `rm` / `git rm --cached` for `docs/ai` and the entry-point docs, and an **edit** instruction (not an `rm`) for `.claude/settings.json`. Always run `--dry-run` first, show the plan, get consent, then `--yes`. A skill dir or symlink that is not provably ours is a STOP, never a clobber (the `setup` posture, inverted). Removing a shared global (memory/engine/a bridge) may affect another project — say so.
17
17
 
18
18
  ---
@@ -37,7 +37,7 @@ The three setup choices — **visibility** (step 2), **conversational language**
37
37
  10. **Honest `known_issues.md`.** Every bug with a workaround gets Impact + Plan so it isn't re-discovered later.
38
38
  11. **One conversational language.** Talk to the user in the language chosen at bootstrap; keep code, paths, commands, and abbreviations in their source language. See *Communication contract*.
39
39
  12. **Attribution is opt-in.** Honour the *Attribution* block: by default no agent/AI/model mention anywhere (commits, PRs, code, comments, docs), and no `Co-Authored-By` trailer. See *Attribution contract*.
40
- 13. **Orchestrate via a named recipe.** Compose execution through a named recipe (Solo / Reviewed / Council / Delegated / Subagent) and **always commit yourself** — every other carrier is advisory or delegated, never autonomous. Encoded via the reconciled `workflow:orchestration` pointer (it routes to `/agent-workflow-kit recipes` + the engine canon), not by bloating the entry point.
40
+ 13. **Orchestrate via a named recipe.** Compose execution through a named recipe (Solo / Reviewed / Council / Delegated / Subagent) and **always commit yourself** — every other carrier is advisory or delegated, never autonomous. Encoded via the engine's orchestration text in the kit block (it routes to `/agent-workflow-kit recipes` + the engine canon), not by bloating the entry point.
41
41
 
42
42
  ---
43
43
 
@@ -53,13 +53,6 @@ All project knowledge lives in `docs/ai/`. Layered, lazy-loaded context:
53
53
 
54
54
  Start-of-session, during-work, and task-completion procedures live in [`docs/ai/agent_rules.md`](./docs/ai/agent_rules.md) §1. **Read it before any code change.**
55
55
 
56
- <!-- workflow:methodology:start -->
57
- <!-- workflow:methodology:end -->
58
- <!-- workflow:orchestration:start -->
59
- <!-- workflow:orchestration:end -->
60
- <!-- workflow:autonomy:start -->
61
- <!-- workflow:autonomy:end -->
62
-
63
56
  ---
64
57
 
65
58
  ## 🚫 Hard Constraints
@@ -91,6 +84,3 @@ Start-of-session, during-work, and task-completion procedures live in [`docs/ai/
91
84
 
92
85
  Full reference → [`docs/ai/env_commands.md`](./docs/ai/env_commands.md).
93
86
 
94
- ---
95
-
96
- **Rule:** This file stays CONCISE (≤100 lines). Details go to `docs/ai/`. Never bloat this file.
@@ -63,39 +63,6 @@ Before proposing changes or committing, review against:
63
63
  ### 2.4. Quality Gates
64
64
  - Always run type-checker, linter, and all tests before committing.
65
65
 
66
- ### 2.5. Communication (user-facing messages)
67
- Apply this as part of §2 before any user-facing summary:
68
- - **Plain language.** User-facing narration is short, clear, plain words of the dialogue language; when the dialogue language is not English, transliterated English jargon is banned — an English term survives only as the NAME of a thing (a flag / command / file / test), glossed in plain words when helpful; plain English stays plain for English-dialogue users.
69
- - **Deliver the artifact IN the message** — paste the prompt / diff / version / command inline; never "see §X / open the file / run it and you'll see" as a *substitute* for showing what was asked.
70
- - **Lead with the result**, then the details; show exactly what was asked — no deflection, no "almost done" when the ask was the finished thing.
71
- - **No condescension, no filler.** Own a miss plainly and fix it in the same message.
72
- - **Large artifact (≈>100 lines):** deliver a real summary or the key excerpt inline **and** link the file — never flood the reader with a 2000-line paste, never hide the answer behind a bare pointer.
73
- - **Live host/session facts are tool-composed only.** Any claim about the current host or session state (prompts fired, sandbox scope, whether a bypass was needed, network reachability, approval counts) must trace to **live tool output** from **this session**; a memory/handover snapshot is **context, never report facts**, and a claim with no live signal is **omitted or explicitly marked unverified** — never asserted from recollection.
74
- - **The closing state block answers three DIFFERENT questions.** Close a user-facing message with three labelled slots — *now* · *what I need from you* · *what's next*. The slot LABELS stay ENGLISH — an English label is what lets a state-block checker FIND the block and its slots at all; everything written INTO a slot is in the project's dialogue language; when that language is not English, the checker's English phrase sets do not judge those values. **Now** = the state at this instant: what is RUNNING, or what the work is stopped on. It is **never a report of finished work** — what you completed goes in the message BODY, above the block. **From you** = the real unblocker, named; a turn that is ENDING always has one. **Next** = what follows. A *now* slot that opens with what was completed buries the one fact the reader opened the message for, and the three slots collapse into one restatement.
75
- - **A skip that contradicts the tree is a finding.** A tool-composed `skipped-*` line whose stated reason the observed tree disproves (a "no Node" skip beside deployed Node scripts) is raised as a FINDING in the report, never pasted as a neutral outcome — and a tool may not emit a skip whose reason it could itself disprove.
76
- - **Two blocks for the user.** At a plan's approval, at a release and at every session close, the message BODY — above the closing state block — carries two short blocks in the dialogue language. *What was done, and for what*: per item the user-facing problem, then what now exists; a command name is allowed, an internal id is not. *What is next, and why*: each proposal names its benefit, plus the one hand step if any. No internal ids, no review-round tallies. The same two blocks are the handover's `## For the user` section, which the kit's `session-close-check` checker judges at the close, where the kit is installed.
77
-
78
- ### 2.6. Planning, review & process-fidelity invariants
79
- Apply these when authoring a plan, reviewing, folding a finding, or editing code — the layer read **before any code change**. (Full canon: the project's planning / workflow-methodology + orchestration canon. This section is rendered from that canon and written current on every upgrade; text of your own goes under a ### heading of its own, titled unlike the kit's sections.)
80
- - **Fold by code, not prose.** Before folding a code-touching finding into a plan or change, read the cited `file:line` and cite it — a prose fold drifts from the code and seeds the next bug.
81
- - **Finding scope (plan-execution) — name the invariant BEFORE the edit.** During EXECUTION only — a spec and its plan under authoring have no shipped behaviour to call a live defect in, so the spec review carries none of this. Every finding names the invariant its fix would enforce, and where that invariant already lives decides the disposition: already an acceptance criterion of the phase → **fold here**; it would have to be ADDED → ship the **narrow fix** for the found site (red first, then green) and queue ONLY the generalization — a deferral row carries the invariant, the origin `file:line`, the narrow fix, its proof and a residual exposure declared NOT live; no correct narrow fix → **blocking**: the phase does not close, and it is **never queued**. Two bars declared before each round: a finding counts only if it changes a **WRITE/REMOVE decision** or is a false statement in shipped text; a repeat finding in one subarea **routes to SUBTRACTION**, not a fourth patch.
82
- - **Right altitude.** Pin intent + invariants + acceptance criteria (named tests); leave fine code-mechanics to Execute, where prose cannot diverge from reality.
83
- - **Spec-first.** A plan names its GOVERNING spec(s) — zero, one or many, one per touched spec-covered slice (the feature spec under `docs/ai/specs/`; page-only coverage governs as an ADOPTION SHIM, with Out of scope + Revision stated inline in the plan). A ZERO names the adoption state it relies on — `not adopted` (no store) or `adopting` (a store with no live contract), either with a recorded decline, or `nothing spec-covered touched` (a store with live contracts) — a bare zero is never a licence; the store's own state is what `status` and the upgrade advisor report. Each cited spec's Out of scope bounds that slice's work and the plan's non-goals restate it per slice — no global union; a cross-spec conflict is resolved by a spec revision BEFORE approval, never by silent precedence. A NEW feature's draft spec exists AT the spec review (a `create` row); a change to a governed contract rides the plan as its proposed revision (a `modify` row); approval confirms plan and contract atomically, and the revision lands with the code. Scenario bindings are per scenario: a new scenario is `unbound` until its test lands in the same plan, and a status never regresses for an extension.
84
- - **No code-mechanics in the plan.** A ledger row carries its path and anchor, and Verification carries the exact commands (the plan-shape canon) — checked syntax: the plan's own Verification runs them against an explicit expected outcome or gate; the only other syntax a plan may carry is a literal fixture/schema fragment a named test copies or validates. Un-run, logic-bearing syntax — control-flow, a regex, a glob, a grammar, an algorithm body, a mini-DSL — never lives in plan prose, however plausible or shell-verified it looks: a fold or draft that wants one is the trigger to write the test instead.
85
- - **Test-as-spec.** Fold a code-touching finding into a red→green TEST, not a prose paragraph — the gate is the only deterministic checker; a paragraph cannot self-check.
86
- - **Characterize-first.** Before editing UNCOVERED code, pin its current behavior in a green test, then edit — any unintended change goes red. Never edit what has no checker; first give it one. Keep edits atomic/reversible; prefer SUBTRACTIVE folds.
87
- - **State table BEFORE the guard — enumerate by PROOF, never by exclusion.** The subtraction rule above fires on a repeat finding, which is a LATE signal: by then the review has paid for each miss. The EARLY signal is structural — a decision whose input has **several independent state dimensions** (is it tracked? do the bytes still match the source? does the neighbouring file exist?). Write the table first, admit the write with **ONE conjunction of proven facts**, and funnel every other cell into a single refusal; the table is then the table-driven test. An exclusion list (`if (bad1) return; if (bad2) return;`) fails **OPEN** on the first state nobody enumerated — and "unreadable" is a state, distinct from "absent". A reviewer cannot save you here: it judges the patch in front of it and can only name the NEXT missing state, one round at a time.
88
- - **Fold minimally — prose has no checker.** A spec under the spec review, like the ephemeral plan beside it, is prose with no executable checker; fold **minimally, in ONE place** and run a **self-consistency** read across the spec before every re-review — a fold that drifts several prose spots is what turns a 2-round review into churn.
89
- - **Heavy review at the diff.** The spec review settles the contract and reads the plan's ledger in the same rounds (≤2 rounds, stop at the pre-existing→fold-induced crossover); the plan has no rounds of its own and is checked by its shape gate, that reading and the approval; the exhaustive review runs against the staged diff of real compiling code + the full suite, where a regression fails a gate immediately. **Backend divergence** (one backend grounded-ships while another keeps revising mechanics) IS that crossover — resolve at altitude, don't exhaust the strictest backend; route an all-mechanics/CI or prose-only artifact to a **thin plan + diff-review**.
90
- - **Convergence bar.** A review loop is CLEAN only when one round returns **0 blockers + 0 majors** from EVERY backend the recipe names (nits + a ship verdict is the stop). Folding ≠ convergence — re-review after folding.
91
- - **Per-round emission.** Every review round emits **{round N · finding-origin tally · per-backend verdict}** so the crossover is a computed, visible signal, not a remembered rule.
92
- - **Recipe fidelity.** Council runs every backend the recipe names, **every round**; silently dropping a ready backend for quota/convenience is a forbidden downgrade — an unavailable backend is a LOUD, stated degrade, never a quiet drop.
93
- - **ExitPlanMode ≠ execute.** A harness "approved — start coding" prompt authorizes the PLAN only; this methodology overrides it. Continue into execution only as a DELIBERATE transition after the plan + cold-start prompt exist, never an implicit slide.
94
- - **Cost lanes.** Route every step to the **cheapest adequate executor** — L0 deterministic script (the batched gate matrix over `gates.json`, the rotation `--check`s) · L1 cheap subagent (extraction/drafting only; the orchestrator verifies) · L2 subscription bridge · L3 frontier judgment. A step with **no named guardrail does not move down** a lane, and the **red lines never move down** (council review models · real code · ADR/handover/changelog-entry wording · persuasive copy · go/no-go · the approval asks). Own-error repair: salvage recorded state first (L0/L1, batched), never frontier re-derivation. **Prompt economy:** read-only fan-out (research/sweeps/extraction) runs ONLY on restricted-tool vehicles — a full-tool subagent for read-only work is a forbidden lane downgrade (invisible prompt-flood + blast radius), and a subagent is never told to shell out for facts obtainable read-only; the orchestrator's own shell form is ONE plain pipeline per call (a `;`/`&&` chain or env-prefixed invocation never matches a prefix allow rule); a fan-out launcher that gates per call yields to the agent-spawn lane — capability-gated: without restricted-tool vehicles (generic full-tool spawning does not count), read-only research stays in the orchestrator's own context, never a vehicle mandate a host cannot satisfy. Judgment, code, synthesis stay at the frontier lane (a task that genuinely runs/writes keeps a full-tool subagent); honest limit: no deterministic gate classifies a dispatch — canon at the point of use + placed vehicles + the retro loop. **Writer economy:** a stage's repeated WRITER commands batch — evidence declarations ride consecutive plain invocations of ONE allow-listed tool, other stage writers combine via one launcher per stage; never an unbatched writer scatter (each gated write is its own prompt).
95
-
96
- ### 2.7. Story sessions
97
- A story — one row of an epic's ledger, carried by one plan — runs as four sessions, each step in them giving one checked result: **spec and plan** (every contract the story creates or revises and the plan's ledger beside them, checked by the spec gate, the plan-shape gate and one review of at most two rounds that reads both, then the plan's approval), **tests** (only tests, each new one failing for the reason its scenario or acceptance bullet states, or on the absence of a name the plan adds, imported inside the test; no code and no prototype), **code** (code until the tests and the pre-review gates pass; a wrong test is changed only back to what its scenario states), and **diff review, release and record** (every committable output, tracked records included, staged first, the review of the staged diff in at most two rounds, the final gates and the release where the story ships one, then the plan's Phase: Cleanup). Tests and code never share a session. A storyless plan runs the same four. **Exception — a split:** moving code and its existing cases into modules, with no new logic and no new case, is one session: a short spec (the Module list), the split, the diff review, the release, Cleanup. A bridge executor gets a task only when it writes new tests or code, from one prompt of the orchestrator; a file the orchestrator already wrote is laid down by the orchestrator, never relayed through a bridge.
98
-
99
66
  ---
100
67
 
101
68
  ## 3. Token & Session Optimization
@@ -15,7 +15,7 @@ const HERE = dirname(fileURLToPath(import.meta.url));
15
15
  export const AGENTS_DIR = '.claude/agents';
16
16
  export const CLAUDE_DIR = '.claude';
17
17
  export const WORKFLOW_STAMP = 'docs/ai/.workflow-version';
18
- export const EXPECTED_WORKFLOW_VERSION = '4.0.0';
18
+ export const EXPECTED_WORKFLOW_VERSION = '5.0.0';
19
19
  export const BUNDLED_AGENTS_DIR = resolve(HERE, '..', 'references', 'agents');
20
20
 
21
21
  export const UTF8 = 'utf8';