@sabaiway/agent-workflow-kit 19.0.0 → 19.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
4
4
  is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
5
5
  every `migrations/<version>-<slug>.md` newer than it, in semver order.
6
6
 
7
+ ## 19.1.0 — the kit sections of the agent rules file are written current with no question; a differing body is named with its route (AD-211)
8
+
9
+ **Your upgrade now writes the kit's three sections of `docs/ai/agent_rules.md` current, with no question and no copy
10
+ kept.** Before, the `lens` step refreshed Communication (user-facing messages), Story sessions and the planning/review
11
+ lens only when a section matched a body the kit had shipped; any other body was preserved verbatim with a note, so an
12
+ edited section stayed on old wording for good. Now a current section is left, a known earlier one refreshed, and any
13
+ other body is written with the canon at the file's own heading number, in the file's own newline form, its trailing
14
+ blank lines kept and every byte outside the section unchanged. Its line names where your own text goes:
15
+
16
+ `[lens-region] the planning/review lens section differed from the current canon — written with it; text of your own goes under a ### heading of its own, titled unlike the kit's sections.`
17
+
18
+ From engine 5.12.2 on, the lens section's own intro says it is written current; with an earlier engine that ships the
19
+ lens canon, the step writes that engine's canon, whose intro still says a custom edit is preserved.
20
+
21
+ - **A `### 2.<N>.` heading that opens with a section's title words is that section.** Alone, `### 2.6. Planning,
22
+ review & process-fidelity invariants: my additions` is written over too; beside the kit's own heading the two are
23
+ doubled and neither is changed. A section of your own needs a title of its own.
24
+ - **A section with doubled headings is left.** With more than one heading for a section, the step prints `none of them
25
+ was changed` for it, still reconciles the other sections, and asks you to retitle every heading but one, then re-run.
26
+ - **A target the step cannot rewrite safely is left alone.** A link or any other node that is not a regular file at
27
+ the target, or a file that is not valid UTF-8, prints one line and nothing is written.
28
+ - **The line cap still guards every write where the file declares `maxLines`**: a section whose write would pass it
29
+ is refused and left as it stands, exit 0; a file with no `maxLines` skips the guard with a note.
30
+ - **The texts say the same.** `upgrade.md` (the `lens` row, its relay and the report), `composition-handoff.md`, the
31
+ run-list's `lens` outcome `differing body written` in place of `custom edit preserved`, the Recommendations remedy
32
+ (a prior or any other body → the upgrade's `lens` reconcile), the rules template, and the guide's *Reserved names and
33
+ channels*, which names the three sections as the kit's and gains the eighth channel: text of your own under a `###`
34
+ heading of its own, titled unlike the kit's sections.
35
+
7
36
  ## 19.0.0 — the Jev copy is written current with no question beside a copy at a kit pin; `jev-skill.earlier` retires (AD-210)
8
37
 
9
38
  **MAJOR: the advisor's `jev-skill.earlier` item is gone, and `apply-danger-check --variant jev-skill.earlier` is a
package/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: agent-workflow-kit
3
3
  description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
4
4
  disable-model-invocation: true
5
5
  metadata:
6
- version: '19.0.0'
6
+ version: '19.1.0'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
package/capability.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "agent-workflow-kit",
5
5
  "kind": "composition-root",
6
- "version": "19.0.0",
6
+ "version": "19.1.0",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "19.0.0",
3
+ "version": "19.1.0",
4
4
  "description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -104,9 +104,11 @@ files (the five the kit bundles for `.claude/agents/` — `changelog-skeleton.md
104
104
  by the next upgrade with no question and no copy kept.
105
105
  Also the kit's: the vendor skill copy the kit installs into the three agent skill roots
106
106
  when it matches a pin the kit shipped, written with no question beside a copy at a kit pin;
107
- a copy matching none is the user's, left and named. A declaration seeded once from a template and never
107
+ a copy matching none is the user's, left and named. Also the kit's: the three kit sections of
108
+ `docs/ai/agent_rules.md` (Communication, Story sessions and the planning/review lens), each
109
+ written current on every upgrade with no question and no copy kept. A declaration seeded once from a template and never
108
110
  replaced by the upgrade's ensures (a migration rewrites one only on the user's explicit yes) is the
109
- user's own file. A customization goes into one of seven channels instead:
111
+ user's own file. A customization goes into one of eight channels instead:
110
112
 
111
113
  - **Your own commit checks** go in the local hook file `scripts/pre-commit.local`: the managed
112
114
  pre-commit hook runs it first, once the installer has run.
@@ -117,6 +119,8 @@ user's own file. A customization goes into one of seven channels instead:
117
119
  - **A vehicle of your own** goes in `.claude/agents/<name>.local.md` with a `name:` of its own, which
118
120
  no review roster names; a lens of your own in a review slot keeps a stem of its own.
119
121
  - **A hook of your own** goes in `.claude/hooks/<name>.local.mjs`, which you wire.
122
+ - **Your own text in the agent rules file**: text of your own goes under a ### heading of its own,
123
+ titled unlike the kit's sections.
120
124
 
121
125
  No path segment of a file the kit bundles and places as its own has a dot-separated part exactly
122
126
  `local`; a path of that form is the user's, and no kit tool writes one on its own. Outside that rule:
@@ -46,7 +46,7 @@ A variant's posture note, where its key has one, is printed by `init` from this
46
46
  - `mcp-channel` — the offer is to REGISTER the kit's read-only stdio MCP server in this project on the harness lane: a registration is a command your MCP client will RUN. The agent applies it on the chat yes after the check; `init` previews the exact entry and applies it on the terminal y as the route the user may take instead. What the registration buys: path questions and literal searches become typed tool calls whose arguments are named JSON fields instead of a string handed to a shell, so a pipe, a redirect or a quote inside a pattern or a path stays DATA and is never interpreted. Posture: the server is a **read-only child of your client** (path/type/size/line facts and literal search over this project root; no write and no exec API), and like the client itself it runs **outside the Bash sandbox** — the sandbox is not what bounds it, the server's own root containment is. The two allow rules it adds make those two tools promptless and nothing else. The **`.differing`** arm is also a harness item: an `agent-workflow` entry already stands in `.mcp.json` and **structurally differs** from what this kit copy would write (another kit copy, a hand-edited path, an added `env`; the comparison ignores key order, so re-serialized identical bytes are the same registration). The check shows the entry standing in `.mcp.json` and the entry it would write; the chat yes confirms the replacement. `init` previews `mcp --replace` and replaces only on the terminal y. Stated limit: this item does **not** detect a `disabledMcpjsonServers` veto, so a converged `mcp-channel` means *what the mode writes is in place*, not *the client will load it* — see `${CLAUDE_SKILL_DIR}/references/modes/mcp.md`. Risk profile: a new read-only channel your client will launch; no write or exec exposure; a differing registration is replaced only on the checked chat yes or the terminal y and every other declaration is kept.
47
47
  - ADDITIONAL `gates-inert` arms (the third outcomes) — two further arms, and they differ in whether anything is BROKEN. **`producer-unrecognized`** — a checker with no producer anywhere in the declaration, on a tracked tree the changed-line coverage domain cannot reach (`.ts`/`.tsx`/`.jsx`/`.mts`/`.cts` strictly outnumber `.mjs`/`.cjs`/`.js`): the dead pair is real, so this arm is a user item, the user's own step, and the two remedies are marking the real producer with `"lcovProducer": true` or dropping the checker. Never a `node --test` prescription, the fill preview or an acknowledgement — a dead pair is broken, not narrow. **`coverage-domain-narrow`** — the producer/checker pair IS live and the tree is still dominated by what the domain excludes: nothing is broken, and the honest sentence is that certification covers the assessable minority. Its apply is the consent-gated **ack writer** preview (a NEUTRAL fingerprint into `docs/ai/acks.json` as `coverageDomainAck`, never a security key); after the SAME confirmation you run the `--apply` it prints. The fingerprint binds the FACT — the verdict plus the unsupported extensions present, never the file counts — so an acknowledged project stays quiet as it grows and re-fires when a new unsupported language arrives or the verdict flips. The census reads the TRACKED tree with a read-only `git ls-files`; a tree it cannot read (a non-git deployment) becomes a stated skip. Risk profile: no enforcement change of any kind — one acknowledgement recorded in a family-owned file, and one edit that is the user's own step.
48
48
  - `spec-adoption` — the feature-spec layer's ADOPTION STATE, judged from `docs/ai/specs/` alone through the same census `spec-check --all` runs, so a store the checker would refuse to observe is never counted here either. Both arms are OFFERS (`optional`) — the layer is opt-in, and `attention` stays reserved for a configured declaration that is broken. **`not-adopted`** (no store): every plan then cites zero governing specs by default and nothing says adoption never started; its apply is the spec-layer ensure one-liner (`ensure-configs --reconcile --only specs`, the same seed `upgrade` runs — it seeds the reader/checker pairs and the store root, and skips with a stated reason where no Node evidence exists), and its `recipe:` line carries the decline alternative — the DECLINE preview (`ack-write --lane spec-adoption`, a dry-run that prints the exact `--apply`), which records `specAdoptionAck` in the family-owned `docs/ai/acks.json`. **The two are exclusive, and the order is part of the contract:** ask which the user wants, apart, BEFORE the confirmation; on "seed" run the apply; on "decline" the agent records it — the preview line, then on that same answer its printed `--apply`; never run the seed after a decline, nor the decline after the seed. **`adopting`** (a store with no live contract): an optional item naming the draft count; its apply is that same decline preview (a dry-run; after the SAME confirmation you run the `--apply` it prints), and the honest remedy is authoring a contract from the skill's `SPEC_TEMPLATE.md`. A recorded decline silences BOTH arms and shows on `status` as ` — declined`; one live contract makes the decline moot. An unreadable store is a stated skip, never `flow optimal`. Risk profile: the seed writes create-only files under `scripts/` and `docs/ai/specs/` and refreshes a script body a release shipped; it writes an edited spec-layer file with the bundled body with no question, its line naming where an edit meant to last goes; the decline writes one key into the ack store; nothing here authors a spec or blocks a plan.
49
- - `profile-gap` — each item's apply is a PREVIEW that writes nothing, and consent takes two steps: the confirmed pick runs the preview and you relay every line it prints (the environment-resolved slot values, each checker `entry:` line with its trust-chain disclosure, a Communication region the insert plans in the same run); the same line with ` --apply` appended runs only on a SECOND yes over those lines, never carried by the first. Items whose apply lines are byte-equal are one writer and take one answer: the tier preview's `--apply` writes the absent slots, the store seed and the queue seed together; the checker verb writes only its own entries; the insert writes every region it plans, all or nothing, so a `communication-absent` skip beside a declined `story-sessions-section` gets its own ask after the insert's full preview. A no records nothing and the item stays on the screen. A DECLINE is asked apart from later, before anything runs, and runs `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --decline --cwd <project-root>` only when the user refuses EVERY item the tier preview then reports offered: it records each of them at the shipped lineage, and a declined item leaves the screen until a lineage step changes the profile. An undecidable entry is a stated skip naming its reason, the remedy by reason: a prior → the upgrade's `lens` reconcile; an absent region → the insert; a customized region → a hand edit only (the lens preserves it), so that skip stands and withholds `flow optimal`. Risk profile: the tier preview's `--apply` rewrites `docs/ai/orchestration.json` in canonical form with the `_README` note and creates `docs/ai/epics/.gitkeep` and `docs/plans/queue.md` create-only; the insert adds regions to `docs/ai/agent_rules.md`; the checker verb adds entries to the PRIVILEGED `docs/ai/gates.json`; the decline writes `docs/ai/profile-declines.json`; nothing here commits.
49
+ - `profile-gap` — each item's apply is a PREVIEW that writes nothing, and consent takes two steps: the confirmed pick runs the preview and you relay every line it prints (the environment-resolved slot values, each checker `entry:` line with its trust-chain disclosure, a Communication region the insert plans in the same run); the same line with ` --apply` appended runs only on a SECOND yes over those lines, never carried by the first. Items whose apply lines are byte-equal are one writer and take one answer: the tier preview's `--apply` writes the absent slots, the store seed and the queue seed together; the checker verb writes only its own entries; the insert writes every region it plans, all or nothing, so a `communication-absent` skip beside a declined `story-sessions-section` gets its own ask after the insert's full preview. A no records nothing and the item stays on the screen. A DECLINE is asked apart from later, before anything runs, and runs `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --decline --cwd <project-root>` only when the user refuses EVERY item the tier preview then reports offered: it records each of them at the shipped lineage, and a declined item leaves the screen until a lineage step changes the profile. An undecidable entry is a stated skip naming its reason, the remedy by reason: a prior or any other body → the upgrade's `lens` reconcile, which writes the region current or names the line cap that refused the write; an absent region → the insert. Risk profile: the tier preview's `--apply` rewrites `docs/ai/orchestration.json` in canonical form with the `_README` note and creates `docs/ai/epics/.gitkeep` and `docs/plans/queue.md` create-only; the insert adds regions to `docs/ai/agent_rules.md`; the checker verb adds entries to the PRIVILEGED `docs/ai/gates.json`; the decline writes `docs/ai/profile-declines.json`; nothing here commits.
50
50
  - `jev-connect` — the lane is user and env-dependent: the connect command is the user's own step in a terminal of their own, where it asks for the key; the key never reaches the agent or the chat (the command refuses without a terminal, and a terminal is not consent). When the recipe line opens with `run the apply in <place>`, that place is the terminal to run it in; `init`, run there, offers the command on its own consent line. The command reads the key with no echo, makes one network call to api.typesafe.ai with the vendor's sample text only on the user's own run, and writes the key in plain text — as managed export lines in the shell's startup files (bash: ~/.bashrc and the login file, created as ~/.bash_profile when none exists; zsh: ~/.zshrc), as the kit's own file ~/.config/fish/conf.d/typesafe-api-key.fish for fish, or on Windows as the user environment variable TYPESAFE_API_KEY, stored in the Windows user environment; a process already running at the save can keep its old environment and hand it to what it starts — the guide's key mark confirms the agent sees it (a file is readable by any process running as that user, and by other local accounts when one is world-readable in a traversable home); the vendor keeps data under its processing agreement and offers zero retention only to enterprise accounts. The item reads the environment the agent's commands run in: a host setting that filters it shows the item while the key is set in the user's shell. The decline alternative rides the recipe line, asked apart BEFORE the confirmation (the `spec-adoption` order): on "connect" hand over the apply line; on "decline" the agent records it — the recipe line's preview, then its printed `--apply` — per project as `jevConnectAck` in `docs/ai/acks.json`. Risk profile: a plain-text key in the user's startup files or the Windows user environment, written by a command the user runs; one network call from that run.
51
51
  - `jev-skill` — two arms, both env-dependent. The offer `jev-skill`, lane harness, shows once `TYPESAFE_API_KEY` is set and no decline is recorded, while no skill root holds a copy at a kit pin and a root the kit fills is absent: the agent applies it on the chat yes after the check, showing the files it would write; it changes no harness setting. `init` applies it on the batch terminal yes as the route the user may take instead. When the recipe line opens with `run the apply in <place>`, that place is where a user who prefers their own terminal runs it. The kit item `jev-skill.not-current`, lane kit, shows beside a copy at a kit pin in any root: the kit route applies it with no question, writing every root absent or behind the kit's pin. The skill is third-party text — the vendor's, MIT — that the kit ships pinned and installs as a verified copy into three agent skill roots: `~/.agents/skills`, the Claude Code skills dir (`CLAUDE_CONFIG_DIR` or `~/.claude`) and `~/.gemini/config/skills`. The copy is written current with no question beside a copy at a kit pin; a foreign copy is left untouched and named on the recipe line. A copy the vendor's `skills` CLI wrote with the same bytes reads current, accepts the component and is written at a later pin like a kit copy; a vendor plugin install is invisible to the file check, so the Claude Code root may read absent while the plugin serves it. Only when the user asks to see the plan does the agent run the command without `--apply` (a read-only dry run). The decline alternative rides the offer's recipe line, asked apart BEFORE the confirmation: on "install" run the check line and, on the yes given on its result, the apply line by the consent route; on "decline" the agent records it — the recipe line's preview, then its printed `--apply` — per project as `jevSkillAck` in `docs/ai/acks.json`. Risk profile: third-party text written into the user's agent skill roots by the kit's skill command; no network.
52
52
 
@@ -15,7 +15,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
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 · custom edit preserved · file absent / engine too old — skipped · over the line cap — refused · section absent — noted · a fully absent/invalid engine → hard STOP.
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
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
20
  8. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
21
21
 
@@ -77,18 +77,19 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
77
77
 
78
78
  **`lens` — agent-rules lens refresh.** Relay the outcome in plain
79
79
  language: the planning/review lens section was **refreshed** to
80
- the current canon · was **already current** · carries a **custom edit — preserved verbatim** (+
81
- its one-line note) · the **file is absent — skipped** · the **engine is too old — skipped**
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**
82
83
  (refresh it with `npx @sabaiway/agent-workflow-engine@latest init`, then re-run) · **over the
83
84
  file's line cap — refused** (trim the file, re-run). The section is found by its heading — no
84
- markers; a renamed heading is preserved + noted. A fully absent/invalid engine is the same hard
85
+ markers; a renamed heading, no longer opening with the title words, is noted. A fully absent/invalid engine is the same hard
85
86
  STOP as (c). Exit 0 covers every soft outcome; only the STOP is non-zero. The same invocation
86
87
  also reconciles the **Communication (user-facing messages)** and **story-sessions** sections
87
88
  from the kit's own bundled template canon (no engine involved) — relay each section's line:
88
- *refreshed* / *already current* / *custom edit preserved + note* / *section absent — noted* /
89
+ *refreshed* / *already current* / *differing body written* / *section absent — noted* /
89
90
  *over the file's line cap — refused*; an unreadable bundled template canon is its own loud STOP
90
91
  naming the kit reinstall command.
91
- A doubled heading in any of the three sections is preserved with a note and no write.
92
+ A doubled heading in any of the three sections has nothing written.
92
93
  The **Communication and story-sessions** absent-section notes already carry the preview
93
94
  command: relay the printed note verbatim as the offer.
94
95
  Run the insert with `--apply` only on the user's explicit yes (the `tier` ask while `tier`
@@ -113,7 +114,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
113
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.
114
115
  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:
115
116
  - **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.
116
- - **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), 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*); 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* / *custom edit preserved + note* / *file absent* / *engine too old* / *over the line cap*) and the **Communication-section** outcome (its own set: refreshed / already current / custom preserved + note / section absent — noted / over the cap — refused) and the **story-sessions section** outcome (its own set: refreshed / already current / custom edit preserved + note / 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`).
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), 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*); 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`).
117
118
  - **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*.
118
119
  - **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).
119
120
  - **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.
@@ -51,13 +51,15 @@ only after `<project>/docs/ai/agent_rules.md` exists: after the substrate deploy
51
51
  This is what converges a substrate seeded by an older memory — a lens section matching a known
52
52
  prior canonical body is refreshed from the installed engine; a current seed reports *already
53
53
  current* (zero-diff). Relay its outcome in plain language (*refreshed* / *already current* /
54
- *custom edit preserved + note* / *file absent — skipped* / *engine too old — skipped* / *over the
54
+ *differing body written* / *file absent — skipped* / *engine too old — skipped* / *over the
55
55
  line cap — refused*); a fully absent/invalid engine is the same loud STOP + one-line install
56
56
  command as the pointer reconcile. The same invocation also reconciles the **Communication
57
57
  (user-facing messages)** and **story-sessions** sections from the kit's own bundled template canon (no engine involved):
58
58
  a body matching the current canon is reported *already current*; a body matching a known prior
59
- is refreshed; a custom body is preserved + noted; an absent section is a stated note;
60
- an over-cap refresh is refused; and an unreadable bundled template canon is its own
59
+ is refreshed; any other differing body is written with the canon, its line naming the route: text
60
+ of your own goes under a ### heading of its own, titled unlike the kit's sections; a doubled
61
+ heading has nothing written; an absent section is a stated note;
62
+ an over-cap write is refused; and an unreadable bundled template canon is its own
61
63
  loud STOP naming the kit reinstall command. Relay both sections' outcome lines.
62
64
  The printed absent-section note already carries the preview command: relaying it is the offer.
63
65
  Run the insert with `--apply` only on the user's explicit yes.
@@ -76,7 +76,7 @@ Apply this as part of §2 before any user-facing summary:
76
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
77
 
78
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 refreshed on upgrade; a custom edit is preserved verbatim, but flagged.)
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
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
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
82
  - **Right altitude.** Pin intent + invariants + acceptance criteria (named tests); leave fine code-mechanics to Execute, where prose cannot diverge from reality.
@@ -2,9 +2,10 @@
2
2
  // The only mutation of a deployed rules file the composition root runs WITHOUT a consent ask.
3
3
  import { isDirectRun } from './direct-run.mjs';
4
4
  import { normalizeCanonical } from './orchestration-config.mjs';
5
- import { RULES_REGIONS, extractRegionBy, readTemplateSpan, frontmatterMaxLines, exceedsCap, buildInsertPreview } from './rules-regions.mjs';
5
+ import { RULES_REGIONS, extractRegionBy, readTemplateSpan, frontmatterMaxLines, exceedsCap, buildInsertPreview, decodeUtf8Strict } from './rules-regions.mjs';
6
6
 
7
7
  export { frontmatterMaxLines } from './rules-regions.mjs';
8
+ export const REGION_ROUTE = "text of your own goes under a ### heading of its own, titled unlike the kit's sections";
8
9
  const [COMMUNICATION, STORY, LENS] = RULES_REGIONS;
9
10
  export const LENS_HEADING_RE = LENS.headingRe;
10
11
  export const COMMS_HEADING_RE = COMMUNICATION.headingRe;
@@ -88,13 +89,13 @@ export const replaceLensRegion = (text, region, renderedBody) => {
88
89
  const reconcileRegionText = (text, fragment, priors, { extract, normalize, render }) => {
89
90
  const region = extract(text);
90
91
  if (!region.found) return { status: 'no-region', text };
91
- if (region.count > SINGLE_HEADING) return { status: 'custom', text };
92
+ if (region.count > SINGLE_HEADING) return { status: 'doubled', text };
92
93
  const current = normalize(region.body);
93
94
  const canon = normalize(fragment);
94
95
  if (current === canon) return { status: 'current', text };
95
96
  const known = priors.map((prior) => normalize(prior));
96
- if (!known.includes(current)) return { status: 'custom', text };
97
- return { status: 'refreshed', text: replaceLensRegion(text, region, render(fragment, region.number)) };
97
+ const status = known.includes(current) ? 'refreshed' : 'custom';
98
+ return { status, text: replaceLensRegion(text, region, render(fragment, region.number)) };
98
99
  };
99
100
  export const reconcileLensText = (text, fragment, priors) =>
100
101
  reconcileRegionText(text, fragment, priors, { extract: extractLensRegion, normalize: normalizeLensBody, render: renderLens });
@@ -104,20 +105,22 @@ export const reconcileStoryText = (text, fragment, priors) =>
104
105
  reconcileRegionText(text, fragment, priors, { extract: extractStoryRegion, normalize: normalizeStoryBody, render: renderStory });
105
106
  const RECONCILERS = Object.freeze({ communication: reconcileCommsText, 'story-sessions': reconcileStoryText, lens: reconcileLensText });
106
107
 
108
+ const writtenLine = (section) => `[lens-region] the ${section} differed from the current canon ${EM_DASH} written with it; ${REGION_ROUTE}.`;
109
+ const capRefusedLine = (section, target, count, cap, capWord = 'cap') => `[lens-region] refused ${EM_DASH} writing the current ${section} would push ${oneLine(target)} to ${count} lines (${capWord} ${cap}); trim the file and re-run. The ${section} was not changed.`;
110
+
107
111
  export const OUTCOME_LINES = Object.freeze({
108
112
  errorDetail,
109
113
  targetAbsent: (target) => `[lens-region] ${oneLine(target)} is absent ${EM_DASH} skipped (nothing to update; the file is seeded at bootstrap).`,
114
+ targetNotRegular: (target) => `[lens-region] ${oneLine(target)} is a link or not a regular file ${EM_DASH} left as it stands; nothing written.`,
115
+ targetUndecodable: (target) => `[lens-region] ${oneLine(target)} is not valid UTF-8 ${EM_DASH} nothing written; fix its encoding and re-run.`,
110
116
  commsNoRegion: (target, command) => [
111
117
  `[lens-region] no "${COMMUNICATION.label}" section in ${spanFree(target)} ${EM_DASH} left untouched.`,
112
118
  ...insertNote(command),
113
119
  ],
114
120
  commsCurrent: () => `[lens-region] Communication section already current ${EM_DASH} nothing to do (zero-diff).`,
115
- commsCustom: () => [
116
- `[lens-region] Communication section carries a custom edit ${EM_DASH} preserved verbatim.`,
117
- `[lens-region] note: the canonical Communication section has changed since this section was edited ${EM_DASH} compare it with the current template when convenient; your wording is never overwritten.`,
118
- ],
121
+ commsWritten: () => writtenLine('Communication section'),
119
122
  capSkipNote: () => '[lens-region] note: no `maxLines` frontmatter on the target ' + EM_DASH + ' the line-cap guard is skipped.',
120
- commsCapRefused: (target, count, cap) => `[lens-region] refused ${EM_DASH} refreshing the Communication section would push ${oneLine(target)} to ${count} lines (cap ${cap}); trim the file and re-run. The Communication section was not changed.`,
123
+ commsCapRefused: (target, count, cap) => capRefusedLine('Communication section', target, count, cap),
121
124
  commsRefreshed: () => '[lens-region] refreshed the Communication section to the current canon.',
122
125
  templateCanonStop: () => `[lens-region] STOP ${EM_DASH} the kit's bundled agent_rules.md template canon is unreadable; reinstall the kit: npx @sabaiway/agent-workflow-kit@latest init`,
123
126
  storyNoRegion: (target, command) => [
@@ -125,15 +128,12 @@ export const OUTCOME_LINES = Object.freeze({
125
128
  ...insertNote(command),
126
129
  ],
127
130
  storyCurrent: () => `[lens-region] Story sessions section already current ${EM_DASH} nothing to do (zero-diff).`,
128
- storyCustom: () => [
129
- `[lens-region] Story sessions section carries a custom edit ${EM_DASH} preserved verbatim.`,
130
- `[lens-region] note: this body differs from the bundled template's Story sessions section ${EM_DASH} compare the two when convenient; your wording is never overwritten.`,
131
- ],
132
- storyCapRefused: (target, count, cap) => `[lens-region] refused ${EM_DASH} refreshing the Story sessions section would push ${oneLine(target)} to ${count} lines (maxLines ${cap}); trim the file and re-run. The Story sessions section was not changed.`,
131
+ storyWritten: () => writtenLine('Story sessions section'),
132
+ storyCapRefused: (target, count, cap) => capRefusedLine('Story sessions section', target, count, cap, 'maxLines'),
133
133
  storyRefreshed: () => '[lens-region] refreshed the Story sessions section to the current canon.',
134
134
  regionHeadingTwice: (label, target) => [
135
- `[lens-region] more than one "${oneLine(label)}" section in ${oneLine(target)} ${EM_DASH} preserved verbatim.`,
136
- '[lens-region] note: give the sections distinct headings before retrying; their wording was not changed.',
135
+ `[lens-region] more than one "${oneLine(label)}" section in ${oneLine(target)} ${EM_DASH} none of them was changed.`,
136
+ "[lens-region] note: retitle every one of these headings but one so it no longer opens with the section's title words, then re-run.",
137
137
  ],
138
138
  lensNoRegion: (target) => [
139
139
  `[lens-region] no "${LENS.label}" section in ${oneLine(target)} ${EM_DASH} left untouched.`,
@@ -145,11 +145,8 @@ export const OUTCOME_LINES = Object.freeze({
145
145
  return err?.reason ? [human, errorDetail(err.reason)] : [human];
146
146
  },
147
147
  lensCurrent: () => `[lens-region] lens section already current ${EM_DASH} nothing to do (zero-diff).`,
148
- lensCustom: () => [
149
- `[lens-region] lens section carries a custom edit ${EM_DASH} preserved verbatim.`,
150
- `[lens-region] note: the canonical planning/review lens has changed since this section was edited ${EM_DASH} compare it with the project methodology canon when convenient; your wording is never overwritten.`,
151
- ],
152
- lensCapRefused: (target, count, cap) => `[lens-region] refused ${EM_DASH} refreshing would push ${oneLine(target)} to ${count} lines (cap ${cap}); trim the file and re-run. The planning/review lens section was not changed.`,
148
+ lensWritten: () => writtenLine('planning/review lens section'),
149
+ lensCapRefused: (target, count, cap) => capRefusedLine('planning/review lens section', target, count, cap),
153
150
  lensRefreshed: () => '[lens-region] refreshed the planning/review lens section to the current canon.',
154
151
  });
155
152
 
@@ -195,16 +192,28 @@ export const runCli = async (argv, deps = {}) => {
195
192
  const targetPath = resolve(argv[1]);
196
193
  const served = targetPath.endsWith(sep + SERVED_TARGET.join(sep));
197
194
  const command = served ? buildInsertPreview(resolve(targetPath, '..', '..', '..')) : '';
198
- const text = await (async () => {
195
+ const stat = await fs.lstat(targetPath).catch((err) => {
196
+ if (err.code === 'ENOENT') return null;
197
+ throw err;
198
+ });
199
+ if (stat === null) {
200
+ log(OUTCOME_LINES.targetAbsent(argv[1]));
201
+ return EXIT_OK;
202
+ }
203
+ if (stat.isSymbolicLink() || !stat.isFile()) {
204
+ log(OUTCOME_LINES.targetNotRegular(argv[1]));
205
+ return EXIT_OK;
206
+ }
207
+ const bytes = await fs.readFile(targetPath);
208
+ const text = (() => {
199
209
  try {
200
- return await fs.readFile(targetPath, UTF8);
201
- } catch (err) {
202
- if (err.code === 'ENOENT') return null;
203
- throw err;
210
+ return decodeUtf8Strict(bytes);
211
+ } catch {
212
+ return null;
204
213
  }
205
214
  })();
206
215
  if (text === null) {
207
- log(OUTCOME_LINES.targetAbsent(argv[1]));
216
+ log(OUTCOME_LINES.targetUndecodable(argv[1]));
208
217
  return EXIT_OK;
209
218
  }
210
219
  const templatePath = join(dirname(fileURLToPath(import.meta.url)), '..', 'references', 'templates', 'agent_rules.md');
@@ -255,10 +264,6 @@ export const runCli = async (argv, deps = {}) => {
255
264
  log(OUTCOME_LINES[`${prefix}Current`]());
256
265
  return state;
257
266
  }
258
- if (result.status === 'custom') {
259
- for (const line of OUTCOME_LINES[`${prefix}Custom`]()) log(line);
260
- return state;
261
- }
262
267
  const cap = frontmatterMaxLines(state.text);
263
268
  const decision = exceedsCap(result.text, cap);
264
269
  if (decision.skipped) log(OUTCOME_LINES.capSkipNote());
@@ -267,7 +272,7 @@ export const runCli = async (argv, deps = {}) => {
267
272
  return state;
268
273
  }
269
274
  await atomicWrite(result.text);
270
- log(OUTCOME_LINES[`${prefix}Refreshed`]());
275
+ log(OUTCOME_LINES[`${prefix}${result.status === 'custom' ? 'Written' : 'Refreshed'}`]());
271
276
  return { text: result.text, code: EXIT_OK };
272
277
  }, Promise.resolve({ text, code: EXIT_OK }));
273
278
  return outcome.code;
@@ -78,7 +78,7 @@ export const UPGRADE_RUNLIST = Object.freeze([
78
78
  [
79
79
  'refreshed',
80
80
  'already current',
81
- 'custom edit preserved',
81
+ 'differing body written',
82
82
  'file absent',
83
83
  'engine too old',
84
84
  'over the line cap — refused',