@sabaiway/agent-workflow-kit 14.42.0 → 14.44.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,55 @@ 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
+ ## 14.44.0 — before the upgrade replaces a spec-layer file you edited, it keeps your edit aside and names it, under one replace block (AD-196)
8
+
9
+ **An edited spec-layer script is no longer lost on the upgrade's yes.** Before the bundled body replaces it, the
10
+ upgrade copies the edit, unchanged, to `.agent-workflow/kept-aside/<16 hex>/<path>`, reads the copy back and proves its
11
+ sha256; the replace block names that path before the ask, so the yes is given over the exact copy.
12
+
13
+ - **One replace block per run.** `ensure-configs.mjs --reconcile` prints ONE block, when any file's write waits for
14
+ the yes, after every op's lines and before the failure footer, on a plain run, a `--dry-run` and an `--only` run alike: one line per file whose write waits for
15
+ the yes, naming its kept-aside path and where an edit meant to last belongs (for the spec layer: a script or suite of
16
+ your own under its own name in `scripts/`, or a config the script reads), then one command line. The specs op no
17
+ longer prints a replace line of its own. Over the files the specs op names the digest is the one it printed before,
18
+ so a digest an earlier release printed stays valid.
19
+ - **The yes run** (`--replace-custom <digest>`) surveys first and writes nothing when files are still edited but
20
+ the set or its bytes changed since the block printed (`race-unresolved`, with a fresh block); otherwise it keeps every edit aside, proven, before
21
+ the first replace, then replaces, then regenerates the navigator only when nothing failed. Each bound file is
22
+ checked against its bound bytes again right before its own write. No token or cause is added.
23
+ - **`.agent-workflow/` is the family's reserved folder** (`references/contracts.md`). Its own `.gitignore`, holding
24
+ exactly `*` and a line feed, keeps git from seeing a copy in either visibility mode, with no edit of your `.gitignore` or git's
25
+ exclude: it is written when absent and proven before the first copy, and one holding other bytes stops the run with
26
+ nothing copied or replaced. A link or a non-directory on the way, or a copy already there with other bytes, stops
27
+ the run too. The kit never overwrites or deletes a kept-aside copy.
28
+ - The upgrade's row 3 and the `configs` run-list entry ask one yes naming every file the block names, each edit's
29
+ kept-aside copy and that the bundled body replaces it.
30
+ - Recorded debt (`docs/debt.md`): REPLACE-RUN-EMPTY-UNION-MISSES-A-NEW-EDIT — when a replace run's survey finds no
31
+ edited spec-layer file, a file that turns edited before the op's own survey is reported `customized-preserved` with
32
+ no ask; the next plain run asks.
33
+
34
+ Contracts: distribution-files revision 1 (new, under kit/install), docs-navigator revision 2.
35
+
36
+ ## 14.43.0 — the commit hook runs your own scripts/pre-commit.local first, and the upgrade delivers that installer (AD-195)
37
+
38
+ **A deployment's own commit checks now go in `scripts/pre-commit.local`, with no edit of a kit file.** The bundled hook
39
+ installer (memory 8.4.0) writes, right after `set -e`, a comment line naming that file and
40
+ `if [ -f scripts/pre-commit.local ]; then bash scripts/pre-commit.local; fi`; the file runs with bash before the
41
+ kit's lines, and a non-zero exit stops the commit. The kit never writes, reads or ships it.
42
+
43
+ - **Delivered by the upgrade.** `script-priors.mjs` appends one 8.3.0 row per member of `INSTALLER_SET`, so the
44
+ enforcement-script ensure (op `scripts`) replaces an unedited 8.3.0 installer and its two suites with this kit's
45
+ copies, as it already did for 4.0.0-8.2.1. No ensure op, token or cause changes.
46
+ - **The hook itself gains the line only when the new installer next runs**: a visible deployment's `prepare`, or the
47
+ apply of the `enforcement`, `commit-guard` or `hook-checks` item (`hook-checks` refreshes a known-prior installer
48
+ first; the other two run the installer in place). The upgrade replaces the installer file, not the hook.
49
+ - Stated limit: where the 8.3.0 `install-git-hooks.test.mjs` stays beside the new installer — `hook-checks`
50
+ refreshing the installer alone (before the next upgrade, or while an edited member withholds the set), or a set
51
+ refresh stopped after the installer — that suite fails inside the hook and every commit stops: an unedited set or a
52
+ stopped refresh until the next upgrade refreshes the set, a withheld set until its edit is replaced.
53
+
54
+ Contracts: init-project revision 16 (part git-hooks revision 13).
55
+
7
56
  ## 14.42.0 — the upgrade refreshes the hook installer with its two suites, so a commit through the hook passes them again (AD-194)
8
57
 
9
58
  **Where the hook installer and its two suites carry a body a release shipped (memory 4.0.0 to 8.2.1), the upgrade now
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: '14.42.0'
6
+ version: '14.44.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": "14.42.0",
6
+ "version": "14.44.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": "14.42.0",
3
+ "version": "14.44.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",
@@ -44,6 +44,8 @@ diverge:
44
44
 
45
45
  The kit's OWN footprint (`KIT_OWN_PATHS`) — `AGENTS.md`, `CLAUDE.md`, `docs/ai/` (subsumes the stamp), the added `scripts/*.mjs`, `docs/plans/`, `.claude/settings.local.json`, `.claude/settings.json` (hidden-only — visible mode commits it), and `.mcp.json` (the `mcp` mode's registration; hidden-only for the same reason, and it carries an absolute machine path) — is always a candidate in hidden mode.
46
46
 
47
+ `.agent-workflow/` is the family's reserved folder. Before an upgrade replaces a kit file the user edited, it keeps the edit there, unchanged, at `.agent-workflow/kept-aside/<16 hex>/<path>`; the folder's own `.gitignore` (`*`) keeps git from seeing the copies in either visibility mode. The copies are the user's, outside the kit's own paths: no kit tool overwrites, deletes or hides them.
48
+
47
49
  Not in this version: a fully-external hidden mode (artifacts relocated outside the repo tree).
48
50
  Deferred to a later release + migration.
49
51
 
@@ -12,7 +12,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
12
12
 
13
13
  1. `pointers` — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` → per pointer: added · already present · skipped (reported) · a hard STOP; per Memory Map row of a rules theme: added · already present · refreshed · skipped (reported).
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
- 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` / `old-adr-layout-migration-instructed` / `failed` — consent (conditional): a specs replace line → ONE yes naming every file the custom lines name and saying their edits are overwritten, asked even on a non-zero exit; on the yes run the printed line, then STOP if that run fails or an op it does not re-run failed; on a no STOP on any failed op.
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` / `old-adr-layout-migration-instructed` / `failed` — consent (conditional): a replace line → ONE yes naming every file its block names, each edit's kept-aside copy and that the bundled body replaces it, asked even on a non-zero exit; on the yes run the printed line, then STOP if that run fails or an op it does not re-run failed; on a no STOP on any failed op.
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
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.
@@ -33,7 +33,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
33
33
 
34
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.
35
35
 
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 — 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` / `customized-preserved` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `customized-preserved` / `old-adr-layout-migration-instructed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `customized-preserved` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `customized-preserved` / `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-layout-unverifiable`, `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 — once row 3's replace ask is answered when a specs replace line printed, then as that ask says** — 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**.
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 — 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` / `customized-preserved` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `customized-preserved` / `old-adr-layout-migration-instructed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `customized-preserved` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `customized-preserved` / `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-layout-unverifiable`, `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 — once row 3's replace ask is answered when a replace line printed, then as that ask says** — 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**.
37
37
 
38
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, **every activity/slot the user set is preserved** and ONLY the `_README` note is refreshed, and only when the existing one still matches a known prior canonical — `refreshIfCanonical` / `refreshReadme` in `tools/orchestration-config.mjs` decide it (CRLF/whitespace normalized first; a *customized* `_README` is preserved verbatim → `customized-preserved`; 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/preserves the file (memory upgrade step 2) and this ensure applies the `_README` refresh; in the **fallback** path it does both. (Memory stays standalone.)
39
39
 
@@ -47,7 +47,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
47
47
 
48
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.
49
49
 
50
- **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. In ONE order: the reader pair, then the checker pair — each seeded when absent and REFRESHED only while a file's bytes are a body a release shipped (an append-only digest catalog → `refreshed`; an edited body is preserved verbatim and withholds the writes that depend on it, the checker lane waiting on a byte-current reader pair); the store root is seeded from the bundled template, date rendered, ONLY behind a checker pair current after the run — an older or edited checker renders the store row by row and reds the hook's `--check-index`; edited files are replaced only on row 3's yes. One token by precedence: `seeded` > `refreshed` > `customized-preserved` (an edited pair, and this run wrote nothing) > `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 legacy-ADR instruct never withholds it. **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline the agent records), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
50
+ **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. In ONE order: the reader pair, then the checker pair — each seeded when absent and REFRESHED only while a file's bytes are a body a release shipped (an append-only digest catalog → `refreshed`; an edited body is preserved verbatim and withholds the writes that depend on it, the checker lane waiting on a byte-current reader pair); the store root is seeded from the bundled template, date rendered, ONLY behind a checker pair current after the run — an older or edited checker renders the store row by row and reds the hook's `--check-index`; edited files are kept aside and replaced on row 3's yes. One token by precedence: `seeded` > `refreshed` > `customized-preserved` (an edited pair, and this run wrote nothing) > `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 legacy-ADR instruct never withholds it. **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
51
 
52
52
  **What the project-rules ensure does.** Each theme's kit file `docs/ai/rules/<theme>.md` is seeded, refreshed only from a body a release shipped (an edit is kept, its line saying it carries your edit), and with no local file its effective copy and record are rebuilt. With a local file it writes neither: `pending` prints the merge to do and its record command — do the merge, show the user what changed, then run that command. A kit-file line saying it carries your edit, whatever the run's token, is offered `/agent-workflow-kit rules` to move the edit into the local file.
53
53
 
@@ -4,12 +4,13 @@
4
4
  // deploy-copy suite (install-git-hooks.test.mjs) keeps the consumer-shaped behavior pins. Every
5
5
  // branch of the installer runs from here: fresh install, the guard arm/carry/disable/conflict
6
6
  // lanes, the rules-check and layout-check arm/carry/duplicate/refusal lanes (win32 included), the
7
- // unmanaged refusal, the up-to-date short-circuit, and the not-a-git-checkout skip. Every child
7
+ // unmanaged refusal, the up-to-date short-circuit, the not-a-git-checkout skip, and the S71
8
+ // real-commit lane (real `git commit` through the written hook over stand-in scripts). Every child
8
9
  // runs with each inherited GIT_* variable stripped, so a hook's environment never leaks in.
9
10
 
10
11
  import { describe, it } from 'node:test';
11
12
  import assert from 'node:assert/strict';
12
- import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, existsSync, realpathSync } from 'node:fs';
13
+ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, existsSync, realpathSync, chmodSync, statSync } from 'node:fs';
13
14
  import { tmpdir } from 'node:os';
14
15
  import { join, dirname } from 'node:path';
15
16
  import { fileURLToPath } from 'node:url';
@@ -130,3 +131,55 @@ describe('install-git-hooks — the in-place installer under a GIT_DIR-pinned fi
130
131
  rmSync(nowhere, { recursive: true, force: true });
131
132
  });
132
133
  });
134
+
135
+ // The commit lane also drops NODE_TEST_CONTEXT: an inherited one makes the hook's nested `node --test` skip every file.
136
+ const IDENTITY = { GIT_AUTHOR_NAME: 'p', GIT_AUTHOR_EMAIL: 'p@e', GIT_COMMITTER_NAME: 'p', GIT_COMMITTER_EMAIL: 'p@e' };
137
+ const bareAt = (home, extra = {}) => { const { NODE_TEST_CONTEXT: _, ...env } = envAt(home, { ...IDENTITY, ...extra }); return env; };
138
+ const passes = (r) => (assert.equal(r.status, 0, r.stderr), r);
139
+
140
+ // Passing stand-ins for every script the hook runs; check-docs-size.mjs, run right after the local line, records
141
+ // whether the marker existed. The marker and the record live in a sibling dir, outside the work tree.
142
+ const commitRepo = (root, side) => {
143
+ const [marker, record, local] = [join(side, 'marker'), join(side, 'record'), join(root, 'scripts', 'pre-commit.local')];
144
+ const git = (...args) => spawnChecked('git', args, { cwd: root, env: bareAt(root) });
145
+ mkdirSync(join(root, 'scripts'));
146
+ writeFileSync(join(root, 'scripts', 'check-docs-size.mjs'), `import { existsSync, writeFileSync } from 'node:fs';
147
+ if (!process.argv.includes('--check-index')) writeFileSync(${JSON.stringify(record)}, String(existsSync(${JSON.stringify(marker)})));\n`);
148
+ for (const name of ['archive-changelog', 'archive-issues', 'archive-decisions']) writeFileSync(join(root, 'scripts', `${name}.mjs`), 'process.exit(0);\n');
149
+ writeFileSync(join(root, 'scripts', 'stand-in.test.mjs'), "import { test } from 'node:test';\ntest('a passing stand-in', () => {});\n");
150
+ for (const args of [['init', '-q'], ['add', '-A'], ['commit', '-qm', 'base']]) passes(git(...args));
151
+ passes(spawnChecked(process.execPath, [INSTALLER], { env: bareAt(root, { GIT_DIR: join(root, '.git') }) }));
152
+ const head = () => git('rev-parse', 'HEAD').stdout.trim();
153
+ const commit = (body) => {
154
+ if (body !== undefined) { writeFileSync(local, body); chmodSync(local, 0o644); assert.equal(statSync(local).mode & 0o111, 0, 'the local file is not executable'); }
155
+ writeFileSync(join(root, 'change.txt'), 'change\n');
156
+ passes(git('add', 'change.txt'));
157
+ return git('commit', '-qm', 'change');
158
+ };
159
+ return { marker, record, head, commit };
160
+ };
161
+ const inCommitRepo = (cell) => () => {
162
+ const dirs = ['hooks-commit-', 'hooks-commit-side-'].map((prefix) => realpathSync(mkdtempSync(join(tmpdir(), prefix))));
163
+ try { cell(commitRepo(...dirs)); } finally { for (const dir of dirs) rmSync(dir, { recursive: true, force: true }); }
164
+ };
165
+
166
+ describe('spec:init-project/S71 the local hook file through real commits over stand-ins', () => {
167
+ it('a local file that writes a marker runs before the docs check, and the commit exits 0', { timeout: 120_000 }, inCommitRepo((fx) => {
168
+ passes(fx.commit(`printf made > "${fx.marker}"\n`));
169
+ assert.ok(existsSync(fx.marker), 'the local file ran: its marker appeared');
170
+ assert.equal(readFileSync(fx.record, 'utf8'), 'true', 'the marker existed when check-docs-size.mjs ran');
171
+ }));
172
+
173
+ it('a local file that exits 1 stops the commit: non-zero, no new commit', { timeout: 120_000 }, inCommitRepo((fx) => {
174
+ const before = fx.head();
175
+ assert.notEqual(fx.commit('exit 1\n').status, 0, 'a local file exiting 1 stops the commit');
176
+ assert.equal(fx.head(), before, 'no new commit');
177
+ }));
178
+
179
+ it('with no local file the commit exits 0', { timeout: 120_000 }, inCommitRepo((fx) => {
180
+ const before = fx.head();
181
+ passes(fx.commit());
182
+ assert.notEqual(fx.head(), before, 'the commit landed');
183
+ assert.equal(readFileSync(fx.record, 'utf8'), 'false', 'the hook ran its stand-ins, with no marker');
184
+ }));
185
+ });
@@ -6,6 +6,7 @@
6
6
  // suite, so docs files cannot drift over their declared `maxLines`, the auto-generated
7
7
  // `index.md` navigator cannot silently fall out of sync, stale archive entries never
8
8
  // reach a commit, and regressions to the scripts themselves are caught at commit time.
9
+ // First after `set -e` it runs the project's own `scripts/pre-commit.local` with bash when present.
9
10
  //
10
11
  // The hooks location comes from git's OWN answer (`git rev-parse --git-path hooks`) — a linked
11
12
  // worktree resolves ITS OWN hooks path (its `.git` is a FILE; a hardcoded `.git/hooks` would
@@ -161,6 +162,8 @@ ${MAGIC_MARKER}
161
162
  # declared maxLines, the auto-generated index.md cannot silently go stale, stale
162
163
  # archive entries never reach a commit, and regressions to the scripts are caught.
163
164
  set -e
165
+ # Your own commit checks go in scripts/pre-commit.local; it runs first, with bash, when present.
166
+ if [ -f scripts/pre-commit.local ]; then bash scripts/pre-commit.local; fi
164
167
  node scripts/check-docs-size.mjs
165
168
  node scripts/check-docs-size.mjs --check-index
166
169
  node scripts/archive-changelog.mjs --check
@@ -59,7 +59,7 @@ const markerFor = (name) => `# ${name}:install-git-hooks.mjs`;
59
59
  const readHook = (root) => readFileSync(join(hooksPathOf(root), 'pre-commit'), 'utf8');
60
60
  const stub = (root, rel) => (mkdirSync(dirname(join(root, rel)), { recursive: true }), writeFileSync(join(root, rel), '// a stand-in tool\n'), join(root, rel));
61
61
 
62
- // The hook the 4.0.0-8.2.1 installer body writes with no guard: the six docs and scripts lines.
62
+ // The hook the 8.3.0 installer body writes with no guard: the six docs and scripts lines.
63
63
  const plainHook = (root) => `#!/usr/bin/env bash
64
64
  ${markerFor(basename(root))}
65
65
  # Auto-installed by scripts/install-git-hooks.mjs (run it from "prepare" or by hand).
@@ -75,6 +75,16 @@ node scripts/archive-issues.mjs --check
75
75
  node scripts/archive-decisions.mjs --check
76
76
  node --test scripts/*.test.mjs
77
77
  `;
78
+ const LOCAL_LINE = 'if [ -f scripts/pre-commit.local ]; then bash scripts/pre-commit.local; fi';
79
+ // The plain hook every write carries: the 8.3.0 hook with, right after set -e, one `# ` comment naming
80
+ // scripts/pre-commit.local (its wording is free, so it is read from the written hook) and the exact local line.
81
+ const localHook = (root) => {
82
+ const lines = readHook(root).split('\n');
83
+ const comment = lines[lines.indexOf('set -e') + 1];
84
+ assert.ok(comment?.startsWith('# ') && comment.includes('scripts/pre-commit.local'), `right after set -e a # comment names scripts/pre-commit.local, got ${JSON.stringify(comment)}`);
85
+ assert.deepEqual(lines.filter((l) => l.includes('scripts/pre-commit.local')), [comment, LOCAL_LINE], 'the comment and the local line are the only lines naming scripts/pre-commit.local');
86
+ return plainHook(root).replace('set -e\n', `set -e\n${comment}\n${LOCAL_LINE}\n`);
87
+ };
78
88
  const line = (path, role) => `node "${role ? shown(path) : path}" --check${role ? ` # ${role}` : ''}\n`;
79
89
 
80
90
  describe('install-git-hooks — beside no package.json, or a malformed one, the marker names the directory basename', () => {
@@ -148,8 +158,9 @@ describe('spec:init-project/S58 install-git-hooks — the rules-check and layout
148
158
  const [rules, layout, guard, guard2] = ['tools/rules-cli.mjs', 'tools/source-size-check.mjs', 'guard.mjs', 'g2/guard.mjs'].map((rel) => stub(root, rel));
149
159
  installs(root, ['--commit-guard', 'guard.mjs']);
150
160
  installs(root, ['--layout-check', 'tools/source-size-check.mjs']);
161
+ assert.equal(readHook(root), localHook(root) + line(layout, 'layout-check') + line(guard), 'the --layout-check run carried the guard line');
151
162
  installs(root, ['--rules-check', rules]);
152
- const armed = plainHook(root) + line(rules, 'rules-check') + line(layout, 'layout-check');
163
+ const armed = localHook(root) + line(rules, 'rules-check') + line(layout, 'layout-check');
153
164
  assert.equal(readHook(root), armed + line(guard), 'each arming run carried the other armed lines');
154
165
  assert.match(installs(root).stdout, /already up to date/, 'a flagless re-run keeps all three');
155
166
  assert.equal(readHook(root), armed + line(guard));
@@ -163,7 +174,7 @@ describe('spec:init-project/S58 install-git-hooks — the rules-check and layout
163
174
  const [legacy, rules] = ['legacy/rules-cli.mjs', 'tools/rules-cli.mjs'].map((rel) => stub(root, rel));
164
175
  installs(root, ['--commit-guard', legacy]);
165
176
  installs(root, ['--rules-check', rules]);
166
- const expected = plainHook(root) + line(rules, 'rules-check') + line(legacy);
177
+ const expected = localHook(root) + line(rules, 'rules-check') + line(legacy);
167
178
  assert.equal(readHook(root), expected);
168
179
  installs(root);
169
180
  assert.equal(readHook(root), expected, 'the flagless re-run keeps the legacy line as the guard');
@@ -183,11 +194,11 @@ describe('spec:init-project/S58 install-git-hooks — the rules-check and layout
183
194
  }
184
195
  }));
185
196
 
186
- it('over a hook with no rules or layout line, a flagless and a --commit-guard run write the 4.0.0-8.2.1 bytes', inProject(({ root }) => {
197
+ it('over a hook with no rules or layout line, a flagless and a --commit-guard run write the plain hook with the comment line and the local line right after set -e', inProject(({ root }) => {
187
198
  installs(root);
188
- assert.equal(readHook(root), plainHook(root));
199
+ assert.equal(readHook(root), localHook(root));
189
200
  installs(root, ['--commit-guard', 'guard.mjs']);
190
- assert.equal(readHook(root), plainHook(root) + line(join(root, 'guard.mjs')));
201
+ assert.equal(readHook(root), localHook(root) + line(join(root, 'guard.mjs')));
191
202
  }));
192
203
 
193
204
  it('a wrong file name, a shell-active path or a missing value exits 2, a missing file exits 1, each writing nothing', inProject(({ root }) => {
@@ -220,11 +231,11 @@ describe('spec:init-project/S58 install-git-hooks — the rules-check and layout
220
231
  const armedAt = stub(root, 'a/b/rules-cli.mjs');
221
232
  if (process.platform !== 'win32') { // there the backslash is refused, writing nothing
222
233
  const posix = runInstaller(root, ['--rules-check', given]);
223
- assert.deepEqual([posix.status, /a backslash, CR or LF/.test(posix.stderr), readHook(root)], [2, true, plainHook(root)], posix.stderr);
234
+ assert.deepEqual([posix.status, /a backslash, CR or LF/.test(posix.stderr), readHook(root)], [2, true, localHook(root)], posix.stderr);
224
235
  }
225
236
  installs(root, ['--rules-check', given], WIN32);
226
- assert.equal(readHook(root), plainHook(root) + line(armedAt, 'rules-check'));
237
+ assert.equal(readHook(root), localHook(root) + line(armedAt, 'rules-check'));
227
238
  assert.match(installs(root).stdout, /already up to date/, 'the flagless re-run recognises the win32-armed line');
228
- assert.equal(readHook(root), plainHook(root) + line(armedAt, 'rules-check'));
239
+ assert.equal(readHook(root), localHook(root) + line(armedAt, 'rules-check'));
229
240
  }));
230
241
  });
@@ -0,0 +1,5 @@
1
+ // index.mjs — the one door into distribution-files/: what ensure-configs.mjs and ensure-specs.mjs
2
+ // import, each the very export of the leaf that owns it. No kit module outside this directory
3
+ // imports a leaf directly.
4
+
5
+ export { keptAsidePath, replaceBlock, runReplace } from './replace-set.mjs';
@@ -0,0 +1,83 @@
1
+ // kept-aside.mjs — where an upgrade keeps a user's edit before the bundled body replaces it:
2
+ // `.agent-workflow/kept-aside/<the first 16 hex of the replace set's digest>/<rel>` at the project
3
+ // root. Every copy is written create-only from the bytes the survey read (never a re-read of the
4
+ // source), read back and proven against the sha256 the digest bound, before anything is replaced.
5
+ // `.agent-workflow/.gitignore` holding exactly `*` and a line feed is proven before the first copy,
6
+ // so no stop leaves a copy git can see, with no edit of the user's own ignore files. The kit never
7
+ // overwrites or deletes a kept-aside copy: a copy with other bytes is the user's to move.
8
+ //
9
+ // Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
10
+
11
+ import { lstatSync, readFileSync } from 'node:fs';
12
+ import { createHash } from 'node:crypto';
13
+ import { join } from 'node:path';
14
+ import { lstatNoFollow, writeProjectFileCreateOnly } from '../atomic-write.mjs';
15
+
16
+ const RESERVED_DIR = '.agent-workflow';
17
+ export const KEPT_ASIDE_DIR = `${RESERVED_DIR}/kept-aside`;
18
+ const IGNORE_REL = `${RESERVED_DIR}/.gitignore`;
19
+ const IGNORE_BODY = '*\n';
20
+
21
+ export const keptAsidePath = (digest, rel) => `${KEPT_ASIDE_DIR}/${digest.slice(0, 16)}/${rel}`;
22
+
23
+ const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
24
+ const causeOf = (err) => String((err && err.message) || err);
25
+ const kindOf = (st) => (st.isSymbolicLink() ? 'a symlink' : st.isDirectory() ? 'a directory' : st.isFile() ? 'a regular file' : 'not a regular file');
26
+ const NOTHING_DONE = 'nothing was kept aside or replaced';
27
+
28
+ // The node-kind preflight, before anything is created: every directory from the project root down
29
+ // to each copy's parent must be a real directory, and each copy path and the ignore file a regular
30
+ // file when present. Returns the refusal line, or null.
31
+ const chainRefusal = (cwd, rels, lstat) => {
32
+ for (const rel of rels) {
33
+ const parts = rel.split('/');
34
+ for (let i = 1; i <= parts.length; i += 1) {
35
+ const sub = parts.slice(0, i).join('/');
36
+ const st = lstatNoFollow(join(cwd, sub), lstat);
37
+ const leaf = i === parts.length;
38
+ if (st && (leaf ? !st.isFile() : !st.isDirectory())) return `${sub}: exists but is ${kindOf(st)} — ${NOTHING_DONE}; resolve it by hand, then re-run`;
39
+ }
40
+ }
41
+ return null;
42
+ };
43
+
44
+ const fail = (cause, line, kept) => {
45
+ const written = kept.filter((copy) => copy.created).map((copy) => copy.path);
46
+ const note = written.length > 0 ? [`the edits already kept aside stay where they are: ${written.join(', ')}`] : [];
47
+ return { failed: true, cause, lines: [line, ...note], kept };
48
+ };
49
+
50
+ // keepAside({ cwd, digest, entries, deps }) → { failed: false, kept } with every edited entry's copy
51
+ // proven, or { failed: true, cause, lines, kept } naming why and which copies were already written.
52
+ // An absent entry gets no copy. `kept` lists { rel, path, created } per proven copy.
53
+ export const keepAside = ({ cwd, digest, entries, deps = {} }) => {
54
+ const lstat = deps.lstat ?? lstatSync;
55
+ const read = deps.readFile ?? readFileSync;
56
+ const edited = entries.filter((entry) => !entry.absent).sort((a, b) => (a.rel < b.rel ? -1 : 1));
57
+ const kept = [];
58
+ if (edited.length === 0) return { failed: false, kept };
59
+ const refusal = chainRefusal(cwd, [IGNORE_REL, ...edited.map((entry) => keptAsidePath(digest, entry.rel))], lstat);
60
+ if (refusal) return fail('wrong-node-kind', refusal, kept);
61
+ let at = IGNORE_REL;
62
+ try {
63
+ if (lstatNoFollow(join(cwd, IGNORE_REL), lstat) === null) {
64
+ writeProjectFileCreateOnly(cwd, IGNORE_REL, IGNORE_BODY, deps, { noun: 'the kept-aside ignore file' });
65
+ }
66
+ if (String(read(join(cwd, IGNORE_REL))) !== IGNORE_BODY) {
67
+ return fail('write-refused', `${IGNORE_REL}: holds other bytes — it must hold exactly "*" and a line feed, so git sees no kept-aside copy; ${NOTHING_DONE}`, kept);
68
+ }
69
+ for (const entry of edited) {
70
+ const path = keptAsidePath(digest, entry.rel);
71
+ const abs = join(cwd, path);
72
+ at = path;
73
+ const created = lstatNoFollow(abs, lstat) === null && writeProjectFileCreateOnly(cwd, path, entry.bytes, deps, { noun: 'a kept-aside copy' }).created;
74
+ if (sha256(read(abs)) !== entry.sha256) {
75
+ return fail('race-unresolved', `${path}: a copy with other bytes is there — it is the user's to move or delete before the yes is asked again; nothing was replaced`, kept);
76
+ }
77
+ kept.push({ rel: entry.rel, path, created });
78
+ }
79
+ } catch (err) {
80
+ return fail('write-refused', `${at}: ${causeOf(err)} — nothing was replaced`, kept);
81
+ }
82
+ return { failed: false, kept };
83
+ };
@@ -0,0 +1,69 @@
1
+ // replace-set.mjs — the ONE replace block an upgrade prints over every file whose write waits for the
2
+ // user's yes, and the replace run that yes starts. An op that owns such writes reports entries on its
3
+ // outcome: { rel, sha256, bytes, channel } for an edited file, { rel, absent: true, channel } for an
4
+ // absent one. This module binds their union into one digest, prints one block over it, and on the yes
5
+ // keeps every edit aside (kept-aside.mjs) before any owning op replaces a byte. It never imports
6
+ // ensure-configs.mjs: the CLI hands it the ops it runs.
7
+ //
8
+ // Dependency-free, Node >= 22. No side effects on import.
9
+
10
+ import { createHash } from 'node:crypto';
11
+ import { join } from 'node:path';
12
+ import { composeFailure } from '../ensure-ops.mjs';
13
+ import { shellQuoteArg } from '../repo-lex.mjs';
14
+ import { keepAside, keptAsidePath } from './kept-aside.mjs';
15
+
16
+ export { keptAsidePath };
17
+
18
+ const INDEX_NOT_RUN = 'the navigator step did not run: a replace run runs it only after the spec layer succeeds';
19
+ const RACE_LINE = 'the files to replace changed since the replace line was printed (another set or other bytes), so nothing was written — ask the user again over the fresh block below';
20
+
21
+ // The digest binds the set AND the bytes: `<rel> <sha256>` or `<rel> absent`, sorted by rel in
22
+ // code-unit order, LF-joined. Over an all-edited set it is the digest the specs op printed before.
23
+ const byRel = (a, b) => (a.rel < b.rel ? -1 : 1);
24
+ const digestLine = (entry) => `${entry.rel} ${entry.absent ? 'absent' : entry.sha256}`;
25
+ export const replaceSetDigest = (entries) => createHash('sha256').update([...entries].sort(byRel).map(digestLine).join('\n')).digest('hex');
26
+
27
+ const entryLine = (entry, digest) => (entry.absent
28
+ ? `${entry.rel}: absent — the user's yes places the bundled body`
29
+ : `${entry.rel}: carries an edit — on the user's yes it is kept aside at ${keptAsidePath(digest, entry.rel)}, then the bundled body replaces it; an edit meant to last goes in ${entry.channel}`);
30
+
31
+ // One line per entry in rel order, then the ONE command line, its condition first and both paths
32
+ // shell-quoted; no line at all for an empty set.
33
+ export const replaceBlock = (entries, { kitRoot, cwd }) => {
34
+ if (entries.length === 0) return [];
35
+ const digest = replaceSetDigest(entries);
36
+ return [
37
+ ...[...entries].sort(byRel).map((entry) => entryLine(entry, digest)),
38
+ `only on the user's yes, keep aside and replace the files named above: node ${shellQuoteArg(join(kitRoot, 'tools', 'ensure-configs.mjs'))} --reconcile --replace-custom ${digest} --cwd ${shellQuoteArg(cwd)}`,
39
+ ];
40
+ };
41
+
42
+ // runReplace({ cwd, kitRoot, digest, owning, index, deps }) → { outcomes, block }. `owning` is
43
+ // [{ op, run }] in ENSURE_OPS order and `index` the navigator's run; each run(args) returns an
44
+ // outcome and never throws (the CLI wraps it). `block` carries the recomputed union only when the
45
+ // digest differs — every other outcome of a replace run prints no block.
46
+ export const runReplace = ({ cwd, kitRoot, digest, owning, index, deps = {} }) => {
47
+ const notRun = (outcome) => ({ ...outcome, lines: [...outcome.lines, INDEX_NOT_RUN] });
48
+ const surveys = [];
49
+ for (const { op, run } of owning) {
50
+ const survey = run({ cwd, kitRoot, dryRun: true, deps });
51
+ if (survey.failed) return { outcomes: [notRun(survey)], block: [] };
52
+ surveys.push({ run, entries: survey.entries ?? [] });
53
+ }
54
+ const union = surveys.flatMap((survey) => survey.entries);
55
+ const first = owning[0].op;
56
+ if (union.length > 0 && replaceSetDigest(union) !== digest) {
57
+ return { outcomes: [notRun(composeFailure(first, 'race-unresolved', RACE_LINE))], block: union };
58
+ }
59
+ const kept = keepAside({ cwd, digest, entries: union, deps });
60
+ if (kept.failed) return { outcomes: [notRun(composeFailure(first, kept.cause, ...kept.lines))], block: [] };
61
+ const outcomes = [];
62
+ for (const survey of surveys) {
63
+ const replace = union.length > 0 ? { digest, entries: survey.entries } : undefined;
64
+ const outcome = survey.run({ cwd, kitRoot, dryRun: false, deps, replace });
65
+ if (outcome.failed) return { outcomes: [...outcomes, notRun(outcome)], block: [] };
66
+ outcomes.push(outcome);
67
+ }
68
+ return { outcomes: [...outcomes, index({ cwd, kitRoot, dryRun: false, deps })], block: [] };
69
+ };
@@ -27,7 +27,10 @@
27
27
  // • --dry-run reports `would-*` tokens and writes nothing — never a write token.
28
28
  // • The ops run in a FIXED order and one op's failure NEVER skips the rest: every op reports its own
29
29
  // token, and the exit is non-zero when any of them failed. The one exception is the replace run
30
- // (--replace-custom <digest>): specs, then index only when specs did not fail.
30
+ // (--replace-custom <digest>), which distribution-files/ runs: each edit kept aside, then the
31
+ // owning ops (specs), then index only when none failed.
32
+ // • ONE replace block, after every op's lines and before the failure footer, over the entries of
33
+ // every op that ran: the files whose write waits for the user's yes, and the one command for it.
31
34
  // • The deployment gate runs ONCE, before any op: an absent/symlinked docs/ai stops the whole run
32
35
  // with the gate's own message rather than one copy of it per op.
33
36
  //
@@ -45,12 +48,15 @@ import { ensureExecutor } from './ensure-executor.mjs';
45
48
  import { ENSURE_OPS, OWN_IMPLEMENTATIONS, failedOutcome } from './ensure-ops.mjs';
46
49
  import { ensureSpecs } from './ensure-specs.mjs';
47
50
  import { ensureRules } from './project-rules/index.mjs';
51
+ import { replaceBlock, runReplace } from './distribution-files/index.mjs';
48
52
 
49
53
  const KIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
50
54
 
51
55
  // The op table this CLI walks — name → implementation, in ENSURE_OPS order. Composed HERE (the one
52
56
  // consumer) because the executor, spec-layer and rules ensures import ensure-ops.mjs for their outcome door and probes.
53
57
  export const ENSURE_IMPLEMENTATIONS = Object.freeze({ ...OWN_IMPLEMENTATIONS, executor: ensureExecutor, specs: ensureSpecs, rules: ensureRules });
58
+ // The ops whose writes wait for the user's yes and so own the replace run, in ENSURE_OPS order.
59
+ const OWNING_OPS = ['specs'];
54
60
 
55
61
  const EXIT_OK = 0;
56
62
  const EXIT_FAILED = 1;
@@ -66,7 +72,6 @@ const EMPTY_REPLACE = '--replace-custom needs the digest its replace line printe
66
72
  const REPEATED_REPLACE = '--replace-custom was passed more than once — a replace run carries exactly ONE digest';
67
73
  const REPLACE_WITH_ONLY = '--replace-custom runs the spec layer and then the navigator, so it cannot be combined with --only — nothing was run';
68
74
  const REPLACE_WITH_DRY_RUN = "--replace-custom writes on the user's yes, so it cannot be combined with --dry-run — nothing was run";
69
- const INDEX_NOT_RUN = 'the navigator step did not run: a replace run runs it only after the spec layer succeeds';
70
75
 
71
76
  const HELP = `ensure-configs — the nine stamp-independent upgrade ensures, as ONE command.
72
77
 
@@ -78,9 +83,9 @@ Usage:
78
83
  --dry-run report what each ensure WOULD do; write nothing
79
84
  --only <op> run EXACTLY ONE of them (an unknown, missing or repeated value is a usage error)
80
85
  --replace-custom <digest>
81
- the replace run the specs ensure prints behind an edited spec-layer file, run only on
82
- the user's yes: specs replaces every file its digest names, then index runs when
83
- specs did not fail (not with --only or --dry-run; an empty value is a usage error)
86
+ the replace run the replace block prints, run only on the user's yes: every edit its
87
+ digest names is kept aside under .agent-workflow/kept-aside/, then replaced, then index
88
+ runs when nothing failed (not with --only or --dry-run; an empty value is a usage error)
84
89
  --cwd <dir> the target project (default: the current directory)
85
90
  --help, -h this help
86
91
 
@@ -89,7 +94,7 @@ refreshed in place. Four ops refresh instead: the orchestration onboarding note,
89
94
  matches a canonical the kit shipped (your own wording is preserved verbatim); the spec-layer reader
90
95
  and checker pairs, only while a file's bytes are a body a release shipped (an edited file is
91
96
  preserved, the writes that depend on it — the spec store root included — are withheld behind it,
92
- and ONE printed replace line replaces every edited file only on the user's yes); the project rules
97
+ and ONE printed replace block keeps every edit aside and replaces it only on the user's yes); the project rules
93
98
  kit file, only while its bytes are a body a release shipped (an edited one is kept), with the effective
94
99
  file rebuilt as its copy and recorded where no local file exists; and the navigator index — a GENERATED artifact, regenerated
95
100
  whenever it is missing or stale; where a module the project's hook loads is not the bundled one,
@@ -162,16 +167,20 @@ const runOne = (op, args) => {
162
167
 
163
168
  // Run every op in ENSURE_OPS order. A throw from one op becomes THAT op's failed outcome — the
164
169
  // remaining ops still run, because a project missing its gate declaration should not also be left
165
- // without its autonomy seed just because the first ensure hit an unreadable file. The replace run is
166
- // the one exception: index runs only after a specs op that did not fail, and otherwise says so.
170
+ // without its autonomy seed just because the first ensure hit an unreadable file. → { outcomes, block }:
171
+ // the block is the union of the entries of the ops that ran. The replace run is the one exception,
172
+ // handed to runReplace: it keeps every edit aside, runs the owning ops, then index only when none
173
+ // failed, and its block is non-empty only when the digest no longer matches.
167
174
  export const runEnsures = ({ cwd, kitRoot, dryRun, deps, only, replaceCustom }) => {
168
- if (replaceCustom === undefined) return (only ? [only] : ENSURE_OPS).map((op) => runOne(op, { cwd, kitRoot, dryRun, deps }));
169
- const specs = runOne('specs', { cwd, kitRoot, dryRun: false, deps, replaceCustom });
170
- if (specs.failed) return [{ ...specs, lines: [...specs.lines, INDEX_NOT_RUN] }];
171
- return [specs, runOne('index', { cwd, kitRoot, dryRun: false, deps })];
175
+ if (replaceCustom !== undefined) {
176
+ const owning = OWNING_OPS.map((op) => ({ op, run: (args) => runOne(op, args) }));
177
+ return runReplace({ cwd, kitRoot, digest: replaceCustom, owning, index: (args) => runOne('index', args), deps });
178
+ }
179
+ const outcomes = (only ? [only] : ENSURE_OPS).map((op) => runOne(op, { cwd, kitRoot, dryRun, deps }));
180
+ return { outcomes, block: outcomes.flatMap((o) => o.entries ?? []) };
172
181
  };
173
182
 
174
- const render = (outcomes, dryRun, only, replace) => {
183
+ const render = ({ outcomes, block }, { dryRun, only, replace, kitRoot, cwd }) => {
175
184
  // The banner names the tool + the flag it ran under (both machine tokens the L2 rule exempts);
176
185
  // the failure footer is a user-grade sentence — the composed-lines guard scans both.
177
186
  const scope = only ? `, --only ${only}` : replace ? ', --replace-custom' : '';
@@ -180,6 +189,8 @@ const render = (outcomes, dryRun, only, replace) => {
180
189
  lines.push(` ${o.op}: ${o.token}`);
181
190
  for (const detail of o.lines) lines.push(` ${detail}`);
182
191
  }
192
+ const blockLines = replaceBlock(block, { kitRoot, cwd });
193
+ if (blockLines.length > 0) lines.push('', ...blockLines.map((line) => ` ${line}`));
183
194
  if (outcomes.some((o) => o.failed)) {
184
195
  // No blanket claim about what was written: an op that copies file by file can stop PARTWAY, and
185
196
  // its own lines are the only accurate account of what landed.
@@ -197,10 +208,11 @@ export const main = (argv = [], ctx = {}) => {
197
208
  // ONE deployment gate for the whole run (see the header): with no docs/ai there is nothing to
198
209
  // reconcile, and one identical STOP per op would read as that many separate problems.
199
210
  assertDocsAiDeployment(cwd, deps, { noun: 'the project configuration', rel: 'under docs/ai' });
200
- const outcomes = runEnsures({ cwd, kitRoot: ctx.kitRoot ?? KIT_ROOT, dryRun: args.dryRun, deps, only: args.only, replaceCustom: args.replaceCustom });
211
+ const kitRoot = ctx.kitRoot ?? KIT_ROOT;
212
+ const run = runEnsures({ cwd, kitRoot, dryRun: args.dryRun, deps, only: args.only, replaceCustom: args.replaceCustom });
201
213
  return {
202
- code: outcomes.some((o) => o.failed) ? EXIT_FAILED : EXIT_OK,
203
- stdout: render(outcomes, args.dryRun, args.only, args.replaceCustom !== undefined),
214
+ code: run.outcomes.some((o) => o.failed) ? EXIT_FAILED : EXIT_OK,
215
+ stdout: render(run, { dryRun: args.dryRun, only: args.only, replace: args.replaceCustom !== undefined, kitRoot, cwd }),
204
216
  stderr: '',
205
217
  };
206
218
  } catch (err) {
@@ -3,8 +3,8 @@
3
3
  // a FIXED order the measured coupling dictates:
4
4
  // 1. the reader pair scripts/spec-schema.mjs + .test.mjs — created when absent; since 2a
5
5
  // also REFRESHED when the deployed bytes are a body a release shipped (script-priors.mjs), a
6
- // custom body preserved verbatim until the user's yes runs the printed replace line
7
- // (--replace-custom <digest>, spec docs-navigator);
6
+ // custom body preserved verbatim and reported as a replace entry (distribution-files/): the
7
+ // ONE replace block keeps it aside and replaces it only on the user's yes;
8
8
  // 2. the checker pair scripts/check-docs-size.mjs + .test.mjs — the same prior-refresh lane, and
9
9
  // only behind a reader pair this run leaves byte-current;
10
10
  // 3. the store root docs/ai/specs/index.md — seeded (placeholders rendered)
@@ -17,9 +17,9 @@
17
17
  // The state table (enumerate by PROOF, never by exclusion): every file is classified into exactly one
18
18
  // of current | prior | custom | absent | wrong-kind before anything is written, each write admits
19
19
  // through ONE conjunction of those facts (decideWrites), and every other cell is a stated refusal —
20
- // a custom file of either pair preserves itself AND withholds every write that depends on it, and the
21
- // ONE replace line names every custom file; on the yes, a replace run whose digest still matches
22
- // rewrites them. Writes run in order and each is idempotent, so a stopped run converges on the next.
20
+ // a custom file of either pair preserves itself AND withholds every write that depends on it. Under
21
+ // the replace the driver hands back (`replace: { digest, entries }`), the bound custom files are
22
+ // rewritten. Writes run in order and each is idempotent, so a stopped run converges on the next.
23
23
  //
24
24
  // Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
25
25
 
@@ -28,7 +28,7 @@ import { join } from 'node:path';
28
28
  import { writeContainedFileAtomic, writeProjectFileCreateOnly } from './atomic-write.mjs';
29
29
  import { classifyDeployedScript, digestOf } from './script-priors.mjs';
30
30
  import { composeFailure, composeOutcome, nodeEvidenceRefusal, probeSeedTarget, tmpNote } from './ensure-ops.mjs';
31
- import { shellQuoteArg } from './repo-lex.mjs';
31
+ import { keptAsidePath } from './distribution-files/index.mjs';
32
32
 
33
33
  const OP = 'specs';
34
34
  const SCRIPTS_DIR = 'scripts';
@@ -36,13 +36,12 @@ const BUNDLED_SCRIPTS = ['references', 'scripts'];
36
36
  const STORE_ROOT_REL = 'docs/ai/specs/index.md';
37
37
  const STORE_ROOT_TEMPLATE = ['references', 'templates', 'specs', 'index.md'];
38
38
  const DATE_PLACEHOLDER = '{{DATE}}';
39
+ const CHANNEL = 'a script or suite of your own under its own name in scripts/, or a config the script reads';
39
40
  // Explicit pairs, deliberately NOT aliased to the catalog's PRIOR_FILES (which spans both): each
40
41
  // file is surveyed exactly once. Exported so the suite pins pairs-union === catalog domain.
41
42
  export const READER_PAIR = Object.freeze(['spec-schema.mjs', 'spec-schema.test.mjs']);
42
43
  export const CHECKER_PAIR = Object.freeze(['check-docs-size.mjs', 'check-docs-size.test.mjs']);
43
44
 
44
- const ok = (token, lines) => composeOutcome(OP, token, lines, false);
45
- const loud = (cause, ...lines) => composeFailure(OP, cause, ...lines);
46
45
  const causeOf = (err) => String((err && err.message) || err);
47
46
  const todayIso = () => new Date().toISOString().slice(0, 10);
48
47
 
@@ -65,10 +64,6 @@ const surveyScript = ({ cwd, kitRoot, name, read, lstat }) => {
65
64
  return { rel, name, state: classifyDeployedScript(bytes, name, bundle), bundle, bytes };
66
65
  };
67
66
 
68
- // The custom set's digest binds the set AND the bytes: the rel-sorted `<rel> <sha256>` lines, LF-joined.
69
- export const customSetDigest = (files) =>
70
- digestOf([...files].sort((a, b) => (a.rel < b.rel ? -1 : 1)).map((f) => `${f.rel} ${digestOf(f.bytes)}`).join('\n'));
71
-
72
67
  const surveyStoreRoot = (cwd, lstat) => {
73
68
  const probe = probeSeedTarget(join(cwd, STORE_ROOT_REL), lstat);
74
69
  if (probe.wrongKind) return { rel: STORE_ROOT_REL, state: 'wrong-kind', wrongKind: probe.wrongKind };
@@ -110,14 +105,14 @@ export const decideWrites = ({ reader, checker, store }, replace = false) => {
110
105
  // Every file's line is a function of its surveyed state and the FATE of its write this run:
111
106
  // `written` · `stood` (lost the create-only race to the bundled body) · `would` (dry run) ·
112
107
  // `withheld` (a custom file in the pair) · `stopped` (the run failed before reaching it) · `none`
113
- // (no write was admitted or needed). A line never claims a write that did not happen.
108
+ // (no write was admitted or needed). A line never claims a write that did not happen. Under the
109
+ // replace a custom line names its kept-aside copy and never points at a block below.
114
110
  const LEFT_FOR = { withheld: 'it waits on the pair named above', stopped: 'the run stopped before it' };
115
111
  const SCRIPT_LINES = {
116
112
  current: () => 'already the bundled body — nothing written',
117
- custom: (fate) => ({
118
- written: "carried an edited body — replaced by the bundled one on the user's yes",
119
- stopped: 'carries an edited body — not replaced; the run stopped before it',
120
- })[fate] ?? "carries a body this kit did not ship as current — preserved verbatim; the writes that depend on it wait until it is replaced on the user's yes (the replace line below)",
113
+ custom: (fate, kept) => (fate === 'written' ? `carried an edit — kept aside at ${kept}, then replaced by the bundled body on the user's yes`
114
+ : kept !== undefined ? `carries an edit — not replaced${kept ? `; its copy kept aside at ${kept} stays` : ''}`
115
+ : "carries an edit — left as it stands until the user's yes keeps it aside and replaces it (the block below); the writes that depend on it wait"),
121
116
  absent: (fate) => ({
122
117
  written: 'copied from the bundled scripts',
123
118
  stood: 'appeared while this run was seeding it — the bundled body stands',
@@ -128,7 +123,7 @@ const SCRIPT_LINES = {
128
123
  would: 'would be refreshed to the bundled one',
129
124
  })[fate] ?? `left as is; ${LEFT_FOR[fate]}`}`,
130
125
  };
131
- const scriptLine = (f, fate) => `${f.rel}: ${SCRIPT_LINES[f.state](fate)}`;
126
+ const scriptLine = (f, fate, keptOf) => `${f.rel}: ${SCRIPT_LINES[f.state](fate, keptOf?.(f.rel))}`;
132
127
  const STORE_LINES = {
133
128
  present: 'already present — preserved byte-for-byte, nothing written',
134
129
  written: "created from the bundled template (today's date rendered)",
@@ -151,20 +146,18 @@ const fateOf = (rel, { writes, fates, withheld, stopped }) => {
151
146
  if (writes.some((w) => relOf(w) === rel)) return stopped ? 'stopped' : 'would';
152
147
  return withheld ? 'withheld' : 'none';
153
148
  };
154
- const composeLines = ({ reader, checker, store, writes, fates, withheld, stopped }) => {
149
+ const composeLines = ({ reader, checker, store, writes, fates, withheld, stopped, keptOf }) => {
155
150
  const fate = (rel) => fateOf(rel, { writes, fates, withheld, stopped });
156
- const lines = [...reader, ...checker].map((f) => scriptLine(f, fate(f.rel)));
151
+ const lines = [...reader, ...checker].map((f) => scriptLine(f, fate(f.rel), keptOf));
157
152
  const storeFate = fate(STORE_ROOT_REL);
158
153
  const custom = [...reader, ...checker].filter((f) => f.state === 'custom').map((f) => f.rel);
159
154
  if (store.state === 'present' || storeFate !== 'none') lines.push(storeLine(store, storeFate, custom));
160
155
  return lines;
161
156
  };
162
157
 
163
- // The ONE replace line: the exact command, its condition first, both paths shell-quoted.
164
- const replaceLineFor = (custom, kitRoot, cwd) => (custom.length === 0 ? [] : [
165
- `to replace the edited files named above, run this only on the user's yes — the bundled bodies overwrite their edits: node ${shellQuoteArg(join(kitRoot, 'tools', 'ensure-configs.mjs'))} --reconcile --replace-custom ${customSetDigest(custom)} --cwd ${shellQuoteArg(cwd)}`,
166
- ]);
167
- const RACE_LINE = 'the edited files changed since the replace line was printed (another set or other bytes), so nothing was written — ask the user again with the fresh replace line below';
158
+ // Under the replace the op's own survey must yield exactly the entries the yes bound.
159
+ const sameEntries = (own, bound) =>
160
+ own.length === bound.length && own.every((e) => bound.some((b) => b.rel === e.rel && !b.absent && b.sha256 === e.sha256));
168
161
 
169
162
  // A per-file loop can stop partway; the run says which files already landed — never "nothing happened".
170
163
  const partialNote = (count) =>
@@ -180,7 +173,7 @@ const renderStoreRoot = (kitRoot, read, today) => {
180
173
  return body;
181
174
  };
182
175
 
183
- export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {}, replaceCustom }) => {
176
+ export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {}, replace }) => {
184
177
  const lstat = deps.lstat ?? lstatSync;
185
178
  const read = deps.readFile ?? readFileSync;
186
179
  const refusal = nodeEvidenceRefusal(OP, cwd, lstat);
@@ -190,21 +183,24 @@ export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {}, replaceCu
190
183
  const checker = CHECKER_PAIR.map(survey);
191
184
  const store = surveyStoreRoot(cwd, lstat);
192
185
  for (const f of [...reader, ...checker]) {
193
- if (f.state === 'bundle-unreadable') return loud('bundle-unreadable', `${f.rel}: the bundled script could not be read, so nothing was written — reinstall the kit. ${f.error}`);
186
+ if (f.state === 'bundle-unreadable') return composeFailure(OP, 'bundle-unreadable', `${f.rel}: the bundled script could not be read, so nothing was written — reinstall the kit. ${f.error}`);
194
187
  }
195
188
  for (const f of [...reader, ...checker, store]) {
196
- if (f.state === 'wrong-kind') return loud('wrong-node-kind', `${f.rel}: exists but is ${f.wrongKind} — nothing was read or written; resolve it by hand, then re-run`);
189
+ if (f.state === 'wrong-kind') return composeFailure(OP, 'wrong-node-kind', `${f.rel}: exists but is ${f.wrongKind} — nothing was read or written; resolve it by hand, then re-run`);
197
190
  }
198
191
 
192
+ // The survey completed: its entries ride every outcome from here on, a failed one included.
199
193
  const custom = [...reader, ...checker].filter((f) => f.state === 'custom');
200
- const replace = replaceCustom !== undefined && custom.length > 0;
201
- const replaceLine = replaceLineFor(custom, kitRoot, cwd);
202
- if (replace && replaceCustom !== customSetDigest(custom)) {
194
+ const entries = custom.map((f) => ({ rel: f.rel, sha256: digestOf(f.bytes), bytes: f.bytes, channel: CHANNEL }));
195
+ const ok = (token, lines) => ({ ...composeOutcome(OP, token, lines, false), entries });
196
+ const loud = (cause, ...lines) => ({ ...composeFailure(OP, cause, ...lines), entries });
197
+ const bound = replace ? new Map(replace.entries.map((e) => [e.rel, e.sha256])) : null;
198
+ const keptOf = bound && ((rel) => (bound.has(rel) ? keptAsidePath(replace.digest, rel) : ''));
199
+ if (bound && !sameEntries(entries, replace.entries)) {
203
200
  const asFound = decideWrites({ reader, checker, store });
204
- return loud('race-unresolved', RACE_LINE, ...composeLines({ reader, checker, store, ...asFound, fates: new Map(), stopped: true }), ...replaceLine);
201
+ return loud('race-unresolved', 'the edited spec-layer files are not the set the yes was given for (another set or other bytes), so nothing was written', ...composeLines({ reader, checker, store, ...asFound, fates: new Map(), stopped: true, keptOf }));
205
202
  }
206
- const { writes, withheld } = decideWrites({ reader, checker, store }, replace);
207
- const tail = replace ? [] : replaceLine;
203
+ const { writes, withheld } = decideWrites({ reader, checker, store }, Boolean(bound));
208
204
  const kinds = new Set(writes.map((w) => w.kind));
209
205
  // ONE token by precedence — a write that happened (or, dry, would happen) always outranks the
210
206
  // preserved-custom report, which names a run that wrote nothing behind an edited pair.
@@ -214,16 +210,16 @@ export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {}, replaceCu
214
210
  return withheld ? 'customized-preserved' : 'already-present';
215
211
  };
216
212
  const fates = new Map();
217
- const linesNow = (stopped) => composeLines({ reader, checker, store, writes, fates, withheld, stopped });
213
+ const linesNow = (stopped) => composeLines({ reader, checker, store, writes, fates, withheld, stopped, keptOf });
218
214
  const writtenCount = () => [...fates.values()].filter((fate) => fate === 'written').length;
219
- if (dryRun) return ok(tokenFor(kinds.has('seed') || kinds.has('store'), kinds.has('refresh')), [...linesNow(false), ...tail]);
215
+ if (dryRun) return ok(tokenFor(kinds.has('seed') || kinds.has('store'), kinds.has('refresh')), linesNow(false));
220
216
 
221
217
  let storeBody = null;
222
218
  if (kinds.has('store')) {
223
219
  try {
224
220
  storeBody = renderStoreRoot(kitRoot, read, deps.today ?? todayIso());
225
221
  } catch (err) {
226
- return loud('template-unreadable', `${STORE_ROOT_REL}: ${causeOf(err)}`, ...linesNow(true), ...tail);
222
+ return loud('template-unreadable', `${STORE_ROOT_REL}: ${causeOf(err)}`, ...linesNow(true));
227
223
  }
228
224
  }
229
225
  const writeOne = ({ kind, file }) => {
@@ -234,21 +230,25 @@ export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {}, replaceCu
234
230
  // A seed that lost the create-only race is re-PROVEN before anything that depends on it runs: the
235
231
  // file that appeared must carry the bundled body, or the tree is changing underneath this run.
236
232
  const stoodCurrent = ({ kind, file }) => kind === 'store' || classifyDeployedScript(read(join(cwd, file.rel)), file.name, file.bundle) === 'current';
233
+ const movedSinceBind = ({ kind, file }) => { if (kind !== 'refresh' || !bound?.has(file.rel)) return false; try { return digestOf(read(join(cwd, file.rel))) !== bound.get(file.rel); } catch { return true; } };
237
234
  const notes = [];
238
235
  for (const write of writes) {
239
236
  const rel = relOf(write);
237
+ if (movedSinceBind(write)) {
238
+ return loud('race-unresolved', `${rel}: changed after this run read it — left as it stands and nothing further written`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
239
+ }
240
240
  let result;
241
241
  try {
242
242
  result = writeOne(write);
243
243
  } catch (err) {
244
- return loud('write-refused', `${rel}: ${causeOf(err)}`, ...linesNow(true), ...notes, ...partialNote(writtenCount()), ...tail);
244
+ return loud('write-refused', `${rel}: ${causeOf(err)}`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
245
245
  }
246
246
  if (write.kind !== 'refresh' && !result.created && !stoodCurrent(write)) {
247
- return loud('race-unresolved', `${rel}: appeared while this run was seeding it and does not carry the bundled body — something is writing there underneath this run; nothing further written, re-run when the tree is settled`, ...linesNow(true), ...notes, ...partialNote(writtenCount()), ...tail);
247
+ return loud('race-unresolved', `${rel}: appeared while this run was seeding it and does not carry the bundled body — something is writing there underneath this run; nothing further written, re-run when the tree is settled`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
248
248
  }
249
249
  fates.set(rel, write.kind !== 'refresh' && !result.created ? 'stood' : 'written');
250
250
  notes.push(...tmpNote(rel, result.tmpLeftBehind));
251
251
  }
252
252
  const landed = (kind) => writes.some((w) => w.kind === kind && fates.get(relOf(w)) === 'written');
253
- return ok(tokenFor(landed('seed') || landed('store'), landed('refresh')), [...linesNow(false), ...notes, ...tail]);
253
+ return ok(tokenFor(landed('seed') || landed('store'), landed('refresh')), [...linesNow(false), ...notes]);
254
254
  };
@@ -48,6 +48,9 @@ export const SCRIPT_PRIORS = Object.freeze([
48
48
  prior('install-git-hooks.test.mjs', '4.0.0', '7.1.2', '9603c4dec823d4de8b7b603563d98acb836c0f430565ef8b56c31db4aea4829b'),
49
49
  prior('install-git-hooks.test.mjs', '7.2.0', '8.2.1', 'b57d6b2004ef1967034d9ad8d1f1db0a3b4972c6284bb8c79dea6900dcec0b69'),
50
50
  prior('install-git-hooks-repo-exec.test.mjs', '4.0.0', '8.2.1', 'f12584b062cfa337f09f21b8d4d096549eaecc08242ee264e6f0b98226605464'),
51
+ prior('install-git-hooks.mjs', '8.3.0', '8.3.0', 'aa21b3dcbfc48ea1db7a33ed5a5c8cf30d911b266386b67159288cd12d28bc38'),
52
+ prior('install-git-hooks.test.mjs', '8.3.0', '8.3.0', '058ac6de4dd5f83c4f09c8afd72ef2bfda365a9aea55bddd0089ce89a4e941e2'),
53
+ prior('install-git-hooks-repo-exec.test.mjs', '8.3.0', '8.3.0', 'd5a3253fa0cd088733b927f2a7187c6484298f11dec48f6f63953e380b071c9a'),
51
54
  ]);
52
55
 
53
56
  export const digestOf = (bytes) => createHash('sha256').update(bytes).digest('hex');
@@ -34,7 +34,7 @@ export const UPGRADE_RUNLIST = Object.freeze([
34
34
  entry(
35
35
  'configs',
36
36
  'node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --cwd <project>',
37
- 'a specs replace line → ONE yes naming every file the custom lines name and saying their edits are overwritten, asked even on a non-zero exit; on the yes run the printed line, then STOP if that run fails or an op it does not re-run failed; on a no STOP on any failed op. The printed line: node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --replace-custom <digest> --cwd <project>',
37
+ "a replace line → ONE yes naming every file its block names, each edit's kept-aside copy and that the bundled body replaces it, asked even on a non-zero exit; on the yes run the printed line, then STOP if that run fails or an op it does not re-run failed; on a no STOP on any failed op. The printed line: node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --replace-custom <digest> --cwd <project>",
38
38
  [
39
39
  'seeded',
40
40
  'note-refreshed',