@sabaiway/agent-workflow-kit 14.48.0 → 14.50.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 +62 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/migrations/3.0.0-hardened-core-loop.md +2 -3
- package/package.json +1 -1
- package/references/contracts.md +27 -2
- package/references/modes/migrate-adr-store.md +2 -2
- package/references/modes/upgrade.md +5 -5
- package/tools/distribution-files/scripts.mjs +89 -100
- package/tools/ensure-configs.mjs +24 -23
- package/tools/ensure-ops.mjs +2 -2
- package/tools/ensure-vocabulary.mjs +9 -10
- package/tools/git-hooks.mjs +1 -1
- package/tools/migrate-adr-store.mjs +3 -3
- package/tools/script-priors.mjs +3 -2
- package/tools/upgrade-runlist.mjs +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,68 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 14.50.0 — the upgrade moves an older ADR layout itself, with no question (AD-203)
|
|
8
|
+
|
|
9
|
+
**`/agent-workflow-kit upgrade` now brings your ADR store current in the same run.** Before, on a project still on the
|
|
10
|
+
retired three-tier ADR layout (a `docs/ai/history/decisions-archive*.md` monolith, or a decisions script older than the
|
|
11
|
+
one-file-per-ADR store), the upgrade held back `archive-decisions.mjs`, its suite and `archiver-structure.test.mjs`,
|
|
12
|
+
reported `old-adr-layout-migration-instructed` and named the opt-in `/agent-workflow-kit migrate-adr-store`. Now:
|
|
13
|
+
|
|
14
|
+
- **Every kit script follows the one rule, whatever the layout.** The decisions script and its two suites are
|
|
15
|
+
refreshed, replaced or placed like every other kit script; the `scripts` step reads no ADR layout.
|
|
16
|
+
- **Then the store run.** After the last write, the step runs your project's `scripts/archive-decisions.mjs
|
|
17
|
+
--ensure-current` with no question. It moves a retired monolith into `docs/ai/adr/` records, rotates a HOT window over
|
|
18
|
+
its cap and writes the navigator, as needed, or writes nothing when the store is already current. When it brought
|
|
19
|
+
the store current, its lines follow the step's other lines, each under `ADR store: ` (for example `ADR store:
|
|
20
|
+
brought-current: migrated, navigator written`), and the step reports `refreshed`, or `seeded` when it also placed a
|
|
21
|
+
kit script. It runs wherever the step judged
|
|
22
|
+
the decisions script: always where you took the kit's scripts, and on a project that declined the enforcement offer
|
|
23
|
+
when that script or its suite stands in `scripts/`. It never runs after a write that failed.
|
|
24
|
+
- **A refusal stops the upgrade.** When the decisions script ends with an error, a signal or a non-zero exit, the step
|
|
25
|
+
reports `failed` with the cause `adr-store-not-current`, relays the script's own lines under `ADR store: `, and the
|
|
26
|
+
upgrade stops; the kit scripts written before it stay as written.
|
|
27
|
+
- **A dry run** spawns nothing and, where it judged the decisions script, ends with one line saying the store run
|
|
28
|
+
would follow the writes.
|
|
29
|
+
- **Retired:** the token `old-adr-layout-migration-instructed` and the cause `adr-layout-unverifiable`. The step's
|
|
30
|
+
tokens are `seeded`, `refreshed`, `already-present`, `not-placed` and `skipped-no-node-evidence`.
|
|
31
|
+
- **The opt-in `migrate-adr-store` mode** has nothing left to do after an upgrade where `scripts/` holds the decisions
|
|
32
|
+
script; it stays for a project whose `scripts/` holds no kit script.
|
|
33
|
+
|
|
34
|
+
MINOR: the upgrade gains the store run and one failure cause.
|
|
35
|
+
|
|
36
|
+
## 14.49.0 — the upgrade writes the kit's current scripts and hook installer with no question and no kept-aside copy (AD-202)
|
|
37
|
+
|
|
38
|
+
**`/agent-workflow-kit upgrade` no longer asks about its own scripts.** Before, an edited or absent kit script in
|
|
39
|
+
`scripts/` waited for the upgrade's one yes, and an edit was kept aside under `.agent-workflow/kept-aside/` first. Now
|
|
40
|
+
the upgrade's `scripts` step writes every kit script that is not the bundled body, the hook installer and its two
|
|
41
|
+
suites first, with no question and no copy kept:
|
|
42
|
+
|
|
43
|
+
- **Each file by proof.** A body an earlier release shipped is refreshed, an edited body replaced in place, an absent
|
|
44
|
+
file placed; the current body is left. The line of an edited file names where an edit meant to last goes:
|
|
45
|
+
`scripts/pre-commit.local` for the installer, a script or suite of your own under its own name in `scripts/`, or a
|
|
46
|
+
config the script reads, for the rest. One closing line says the commit hook runs the files written, so they may
|
|
47
|
+
stop the next commit.
|
|
48
|
+
- **Only where you took the kit's scripts.** The step works once a kit script other than the four that memory also
|
|
49
|
+
places on its own (`archive-decisions.mjs`, its suite, and the `markdown-blocks.mjs` and `_expect-shim.mjs` that
|
|
50
|
+
memory's copied files import) stands in `scripts/`. A
|
|
51
|
+
project that declined the enforcement offer keeps those standing copies current, with an absent one they import
|
|
52
|
+
placed, gets no other kit script, and one line says so.
|
|
53
|
+
- **The one yes is the spec layer's alone.** The replace block and its yes now name only the four spec-layer files,
|
|
54
|
+
whose edit is still kept aside first. The `--only scripts` run no longer surveys the spec layer, and the step's
|
|
55
|
+
tokens are `seeded`, `refreshed`, `already-present`, `not-placed`, `old-adr-layout-migration-instructed` and
|
|
56
|
+
`skipped-no-node-evidence` (a dry run: `would-seed`, `would-refresh`); it never prints `pending`.
|
|
57
|
+
- **The hook line names the plain upgrade.** When the `commit-guard` or `hook-checks` apply finds a hook line the
|
|
58
|
+
installer left out, its line says the upgrade writes the kit's current installer over any other body with no
|
|
59
|
+
question; migration note 3.0.0 step 4 says the same.
|
|
60
|
+
- **The guide names the reserved names.** `references/contracts.md` gains *Reserved names and channels*: the names
|
|
61
|
+
the kit writes over are its own, a declaration seeded once is yours, five places hold your own checks, scripts,
|
|
62
|
+
settings, rules and an agent's model, and no path the kit bundles and places as its own has a dot-separated part
|
|
63
|
+
exactly `local`, so a name like `scripts/pre-commit.local` is yours (the section names its two exceptions).
|
|
64
|
+
- **Unchanged:** the hold-back of the decisions files on an older ADR layout, the unreadable layout keeping the
|
|
65
|
+
installer set current, and the upgrade never running the installer.
|
|
66
|
+
|
|
67
|
+
MINOR: no question for the kit's scripts, and a new guide section.
|
|
68
|
+
|
|
7
69
|
## 14.48.0 — the kit's decisions script brings an ADR store current in one command; a copy of its previous body is now a known earlier body (AD-200)
|
|
8
70
|
|
|
9
71
|
**`references/scripts/archive-decisions.mjs` is memory 8.5.0's script, byte for byte.** Its new `--ensure-current`
|
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.
|
|
6
|
+
version: '14.50.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
package/capability.json
CHANGED
|
@@ -29,9 +29,8 @@ loudly, never silently.
|
|
|
29
29
|
back to verify the arm took. A 2.x deployment's project-local `scripts/install-git-hooks.mjs`
|
|
30
30
|
predates the arm: an unarmed hook after the installer's exit 0 makes the apply exit 6 with
|
|
31
31
|
one line naming the hook and the guard line the installer left out, ending with the upgrade
|
|
32
|
-
route — `/agent-workflow-kit upgrade`
|
|
33
|
-
|
|
34
|
-
the item returns at the next run.
|
|
32
|
+
route — `/agent-workflow-kit upgrade` writes the kit's current installer over it with no
|
|
33
|
+
question — and the item returns at the next run.
|
|
35
34
|
5. **Re-stamp:** init/upgrade re-stamps `docs/ai/.workflow-version` to 3.0.0.
|
|
36
35
|
|
|
37
36
|
## Verification
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.50.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",
|
package/references/contracts.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Setup contracts
|
|
2
2
|
|
|
3
3
|
The three choices the bootstrap makes with the user — **visibility**, **conversational
|
|
4
|
-
language**, and **agent attribution** — each have a contract below
|
|
4
|
+
language**, and **agent attribution** — each have a contract below, and the names the kit bundles
|
|
5
|
+
and writes have theirs beside them, under *Reserved names and channels*. `SKILL.md` links here so the
|
|
5
6
|
main procedure stays lean; load this file when you need the full rule for a contract (e.g. while
|
|
6
7
|
filling the matching `AGENTS.md` block, or when an `upgrade` migration touches it).
|
|
7
8
|
|
|
@@ -44,7 +45,7 @@ diverge:
|
|
|
44
45
|
|
|
45
46
|
The kit's OWN footprint (`KIT_OWN_PATHS`) — `AGENTS.md`, `CLAUDE.md`, `docs/ai/` (subsumes the stamp), the added `scripts/*.mjs`, `docs/plans/`, `.claude/settings.local.json`, `.claude/settings.json` (hidden-only — visible mode commits it), and `.mcp.json` (the `mcp` mode's registration; hidden-only for the same reason, and it carries an absolute machine path) — is always a candidate in hidden mode.
|
|
46
47
|
|
|
47
|
-
`.agent-workflow/` is the family's reserved folder. Before an upgrade replaces a
|
|
48
|
+
`.agent-workflow/` is the family's reserved folder. Before an upgrade replaces a spec-layer file the user edited (`scripts/spec-schema.mjs`, `scripts/spec-schema.test.mjs`, `scripts/check-docs-size.mjs`, `scripts/check-docs-size.test.mjs`), it keeps the edit there, unchanged, at `.agent-workflow/kept-aside/<16 hex>/<path>`; every other kit script is written over with no copy kept. 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. The kit's literal search never walks into the reserved `.agent-workflow` folder, at any depth, unless that folder or a path inside it is named as a target, and the plan-shape checks never walk into it, so an unnamed kept-aside copy never stands beside the live file in their results.
|
|
48
49
|
|
|
49
50
|
Not in this version: a fully-external hidden mode (artifacts relocated outside the repo tree).
|
|
50
51
|
Deferred to a later release + migration.
|
|
@@ -87,3 +88,27 @@ block is about *attribution*, not authorship of the actual changes — quality,
|
|
|
87
88
|
before commit" rule are unchanged either way.
|
|
88
89
|
|
|
89
90
|
On `upgrade`, a pre-1.2.0 deployment with no block gets one (the agent asks, defaulting to `off`).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Reserved names and channels
|
|
95
|
+
|
|
96
|
+
Every name the kit bundles and writes over on an upgrade is the kit's, and an edit there is never a
|
|
97
|
+
customization: the kit's scripts outside the spec layer and the hook installer set are written over
|
|
98
|
+
by the next upgrade with no question and no copy kept. The spec layer's pair files are replaced on
|
|
99
|
+
the upgrade's one yes, the edit kept aside first. A declaration seeded once from a template and never
|
|
100
|
+
replaced by the upgrade's ensures (a migration rewrites one only on the user's explicit yes) is the
|
|
101
|
+
user's own file. A customization goes into one of five channels instead:
|
|
102
|
+
|
|
103
|
+
- **Your own commit checks** go in the local hook file `scripts/pre-commit.local`: the managed
|
|
104
|
+
pre-commit hook runs it first, once the installer has run.
|
|
105
|
+
- **Your own scripts and suites** go in `scripts/` under names of your own.
|
|
106
|
+
- **A setting** goes in a config a script reads.
|
|
107
|
+
- **Your own rules** go in the local rules file `docs/ai/rules/local/<theme>.md`.
|
|
108
|
+
- **An agent's model** goes in the vehicle settings `docs/ai/vehicles.json`.
|
|
109
|
+
|
|
110
|
+
No path segment of a file the kit bundles and places as its own has a dot-separated part exactly
|
|
111
|
+
`local`; a path of that form is the user's, and no kit tool writes one on its own. Outside that rule:
|
|
112
|
+
`.claude/settings.local.json`, the host's local settings file, into which the kit only merges keys on
|
|
113
|
+
a consented item (the `--worktrees` grant), and `docs/ai/rules/local/<theme>.md`, which the agent
|
|
114
|
+
writes only on the user's own request.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- opt-in-capability: adr-store-migration -->
|
|
4
4
|
|
|
5
|
-
The **guarded ADR-store migration** — a one-time, opt-in move of an existing project's `docs/ai` from the retired 3-tier ADR cascade (HOT `decisions.md` → the WARM/COLD `decisions-archive*.md` monoliths) to the durable **one-file-per-ADR store** (HOT `decisions.md` + `docs/ai/adr/AD-NNN-slug.md` records + the `docs/ai/adr/log.md` navigator). **In-agent, opt-in
|
|
5
|
+
The **guarded ADR-store migration** — a one-time, opt-in move of an existing project's `docs/ai` from the retired 3-tier ADR cascade (HOT `decisions.md` → the WARM/COLD `decisions-archive*.md` monoliths) to the durable **one-file-per-ADR store** (HOT `decisions.md` + `docs/ai/adr/AD-NNN-slug.md` records + the `docs/ai/adr/log.md` navigator). **In-agent, opt-in**: the upgrade moves an older layout itself wherever `scripts/` holds the kit's rotator, so after a full upgrade this mode does nothing; it stays for a project whose `scripts/` holds no kit script. Run **`--dry-run` first, always**, show the user the plan in plain language, get explicit consent, then re-run with `--apply`. It **never commits**.
|
|
6
6
|
|
|
7
|
-
When to run it: `status`
|
|
7
|
+
When to run it: `status` reports an *old ADR layout*. That covers **two** shapes, and the remedy is the same for both — (1) a `decisions-archive*.md` monolith is still on disk, and (2) **no monolith was ever produced**: the project's deployed `scripts/archive-decisions.mjs` simply predates the store, so its own gate reports the retired three-tier world as healthy and would never mention the store. The second shape is detected by that deployed script's own provenance — never by "has `decisions.md`, lacks `adr/`", which would falsely accuse a project whose NEW rotator already reds its gate with an actionable fix, and every project that runs no Node. A project already on the one-file-per-ADR store with a fresh navigator — or a fresh deployment seeded with it — needs nothing here (the mode is a stated no-op).
|
|
8
8
|
|
|
9
9
|
On the no-monolith shape `--apply` does the same work minus the explosion: snapshot → refresh the deployed enforcement scripts → **seed** the store (`docs/ai/adr/` + the navigator + a regenerated `docs/ai/index.md`) → verify. It is **re-runnable to completion from any interruption**: a store directory alone never counts as finished (the navigator must exist and the project's own `--check` must pass), the whole script refresh is re-planned on every run with the rotation script written last, and a failed index regeneration fails the run **closed** rather than reporting success.
|
|
10
10
|
|
|
@@ -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` / `
|
|
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` — consent (conditional): a replace line → ONE yes naming every spec-layer 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 → `
|
|
36
|
+
**`configs` — the project-configuration ensures, ONE run.** The ONE command performs **all nine** ensures — orchestration config · gate declaration · autonomy declaration · vehicles declaration · executor check · enforcement scripts · spec layer · project rules · navigator index — in a fixed order, and prints **one outcome line per ensure**: paste those lines into the step 4 / step 8 success report. Every SEED is **create-only** (an existing file is preserved byte-for-byte); a refresh-class op rewrites only what it owns, and the scripts op's store run moves ADR entries, rewrites their inbound links in `docs/ai` pages and regenerates the index, as the rotator does — the outcome tokens by ensure, below, name each arm. One ensure failing **never** skips the others: each reports its own outcome and the run exits non-zero when any of them `failed`. The outcome tokens, by ensure: orchestration → `seeded` / `note-refreshed` / `already-current` / `customized-preserved` / `malformed-preserved`; gates, autonomy and vehicles → `seeded` / `already-present`; executor → `not-placed` / `already-current` / `pending`; scripts → `seeded` / `refreshed` / `already-present` / `not-placed` / `skipped-no-node-evidence`; specs → `seeded` / `refreshed` / `already-present` / `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-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade — 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
|
|
|
@@ -43,11 +43,11 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
43
43
|
|
|
44
44
|
**What the executor ensure does.** It never writes: a placed `.claude/agents/executor.md` whose bytes differ from the body derived from `docs/ai/vehicles.json` is `pending` — the advisor's `executor-vehicle.differing` item re-derives it on the user's yes — and an absent one is `not-placed` (the agents mode places it on consent).
|
|
45
45
|
|
|
46
|
-
**What the enforcement-script ensure does.** It judges every kit script — each `*.mjs` of `${CLAUDE_SKILL_DIR}/references/scripts/` but the spec-layer pairs — once the component is accepted:
|
|
46
|
+
**What the enforcement-script ensure does.** It judges every kit script — each `*.mjs` of `${CLAUDE_SKILL_DIR}/references/scripts/` but the spec-layer pairs — once the component is accepted: a kit script outside the seed names (memory's own copies) stands in `scripts/` as a regular file. Each file by proof, with no question and no copy kept: a shipped prior is refreshed, an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. The hook installer and its two suites go first; a closing line says the commit hook runs the files written. A declined enforcement offer keeps the standing seed files current with the modules they import, places no other kit script (one line says so) and words that hook-run line as a condition. With no kit script there: `not-placed`, nothing written. **The ADR store, after the writes:** where the run judged the rotator, it runs `scripts/archive-decisions.mjs --ensure-current`, with no question, which brings the store current (an older layout moved) or writes nothing; its lines are relayed under `ADR store: `. A rotator that does not bring the store current is `failed` / `adr-store-not-current`, the scripts written above staying as written: its refusal stops the upgrade. Where the size practice measures `scripts/`, a write may grow a root past its record: the size check names its own reasoned `--write-baseline`. **Whether Node runs here is PROVEN, never proxied:** the ensure runs on a regular `package.json` at the root OR on any kit-seeded `scripts/*.mjs` already deployed; only when every probe answers absent does it report `skipped-no-node-evidence`, a line naming every probe it checked, while the config ensures still run; a probe that cannot be read is `failed` with the cause `node-evidence-unverifiable`, nothing written. **A `skipped-*` outcome whose stated reason this tool could itself disprove may not exist**. A deployed pre-commit hook takes a new installer body only when the installer next runs: the `enforcement` check line and apply, by the consent route, re-run it (it refuses a non-marker hook as always); until then `scripts/pre-commit.local` does not run.
|
|
47
47
|
|
|
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 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`).
|
|
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 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
|
|
|
@@ -112,7 +112,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
112
112
|
flagged + preserved, never edited. Runs on **every** upgrade; exit 0 covers every outcome.
|
|
113
113
|
**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
114
|
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
|
-
- **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
|
|
115
|
+
- **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
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
117
|
- **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
118
|
- **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 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).
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
// scripts.mjs — the upgrade's `scripts` op: every kit script of a deployment, the hook installer set
|
|
2
2
|
// included, kept current by the one rule. Each family file is surveyed by proof before any write:
|
|
3
|
-
// absent, current, prior (a body SCRIPT_PRIORS catalogs for its name) or edited.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
3
|
+
// absent, current, prior (a body SCRIPT_PRIORS catalogs for its name) or edited. On every plain run a
|
|
4
|
+
// prior is refreshed, an edited one replaced in place and an absent one placed create-only, with no
|
|
5
|
+
// question and no copy kept; a current one is left. The installer set is written first; after the last
|
|
6
|
+
// write the project's own rotator brings the ADR store current (`--ensure-current`). It never imports
|
|
7
|
+
// ensure-specs.mjs or ensure-configs.mjs: the CLI composes this op from the module's index, and
|
|
8
|
+
// ensure-specs.mjs takes its channel from there.
|
|
9
9
|
//
|
|
10
|
-
// Dependency-free, Node >= 22. Every fs primitive
|
|
10
|
+
// Dependency-free, Node >= 22. Every fs primitive and the spawn are injectable (deps.*). No side effects on import.
|
|
11
11
|
|
|
12
|
+
import { spawnSync } from 'node:child_process';
|
|
12
13
|
import { lstatSync, readFileSync } from 'node:fs';
|
|
13
14
|
import { join } from 'node:path';
|
|
14
15
|
import { lstatNoFollow, writeContainedFileAtomic, writeProjectFileCreateOnly } from '../atomic-write.mjs';
|
|
15
16
|
import { composeFailure, composeOutcome, nodeEvidenceRefusal, probeSeedTarget, tmpNote } from '../ensure-ops.mjs';
|
|
16
|
-
import { surveyAdrLayoutStrict } from '../family-registry.mjs';
|
|
17
17
|
import { BUNDLED_SCRIPT_NAMES } from '../node-evidence.mjs';
|
|
18
|
-
import { CHECKER_PAIR, INSTALLER_SET, READER_PAIR, SCRIPT_PRIORS, classifyDeployedScript
|
|
19
|
-
import { keptAsidePath } from './kept-aside.mjs';
|
|
18
|
+
import { CHECKER_PAIR, INSTALLER_SET, READER_PAIR, SCRIPT_PRIORS, classifyDeployedScript } from '../script-priors.mjs';
|
|
20
19
|
|
|
21
20
|
const OP = 'scripts';
|
|
22
21
|
const SCRIPTS_DIR = 'scripts';
|
|
@@ -24,12 +23,13 @@ const BUNDLED = ['references', 'scripts'];
|
|
|
24
23
|
// Where an edit meant to last goes: the installer's in the local hook file, every other file's beside it.
|
|
25
24
|
export const SCRIPT_CHANNEL = 'a script or suite of your own under its own name in scripts/, or a config the script reads';
|
|
26
25
|
export const LOCAL_HOOK_CHANNEL = 'the local hook file scripts/pre-commit.local, which the commit hook runs first';
|
|
27
|
-
// The family files
|
|
28
|
-
export const
|
|
29
|
-
const
|
|
26
|
+
// The family files memory copies on Node evidence alone, accepted or not (the suite derives them).
|
|
27
|
+
export const SEED_NAMES = Object.freeze(['_expect-shim.mjs', 'archive-decisions.mjs', 'archive-decisions.test.mjs', 'markdown-blocks.mjs']);
|
|
28
|
+
const ROTATOR = 'archive-decisions.mjs';
|
|
30
29
|
const PAIRS = new Set([...READER_PAIR, ...CHECKER_PAIR]);
|
|
31
30
|
// The family in write order: the installer set, then every other bundled name in code-unit order.
|
|
32
31
|
const FAMILY = Object.freeze([...INSTALLER_SET, ...BUNDLED_SCRIPT_NAMES.filter((name) => !PAIRS.has(name) && !INSTALLER_SET.includes(name)).sort()]);
|
|
32
|
+
const LOCAL_IMPORT = /(?:from|import)\s*\(?\s*'\.\/([^']+)'/g;
|
|
33
33
|
|
|
34
34
|
const causeOf = (err) => String((err && err.message) || err);
|
|
35
35
|
const relOf = (name) => `${SCRIPTS_DIR}/${name}`;
|
|
@@ -38,8 +38,16 @@ const wrongKind = (rel, kind) => composeFailure(OP, 'wrong-node-kind', `${rel}:
|
|
|
38
38
|
|
|
39
39
|
// ── the survey: the component first, then every family file by proof, nothing written ────────────
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
//
|
|
41
|
+
// The seed files a run of a component that is not accepted judges: each standing one, and every seed
|
|
42
|
+
// file reached from one through its bundled `./` imports, so every seed file the run leaves loads.
|
|
43
|
+
const seedClosure = (standing, bundleOf) => {
|
|
44
|
+
const reached = new Set(standing);
|
|
45
|
+
for (const name of reached) for (const [, dep] of bundleOf(name).toString('utf8').matchAll(LOCAL_IMPORT)) if (SEED_NAMES.includes(dep)) reached.add(dep);
|
|
46
|
+
return reached;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// → { refusal } | { notPlaced } | { files, accepted }. A family path of another node kind is judged
|
|
50
|
+
// before the component, so a linked family file never reads as not-placed.
|
|
43
51
|
const survey = ({ cwd, kitRoot, deps, read, lstat }) => {
|
|
44
52
|
const dir = lstatNoFollow(join(cwd, SCRIPTS_DIR), lstat);
|
|
45
53
|
if (dir === null) return { notPlaced: true };
|
|
@@ -48,60 +56,50 @@ const survey = ({ cwd, kitRoot, deps, read, lstat }) => {
|
|
|
48
56
|
const wrong = probes.find((f) => f.probe.wrongKind);
|
|
49
57
|
if (wrong) return { refusal: wrongKind(wrong.rel, wrong.probe.wrongKind) };
|
|
50
58
|
if (!probes.some((f) => f.probe.present)) return { notPlaced: true };
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
const accepted = probes.some((f) => f.probe.present && !SEED_NAMES.includes(f.name));
|
|
60
|
+
const bundles = new Map();
|
|
61
|
+
for (const { name, rel } of probes) {
|
|
54
62
|
try {
|
|
55
|
-
|
|
63
|
+
bundles.set(name, read(join(kitRoot, ...BUNDLED, name)));
|
|
56
64
|
} catch (err) {
|
|
57
65
|
return { refusal: composeFailure(OP, 'bundle-unreadable', `${rel}: the bundled script could not be read, so nothing was written — reinstall the kit. ${causeOf(err)}`) };
|
|
58
66
|
}
|
|
59
|
-
const bytes = probe.present ? read(join(cwd, rel)) : undefined;
|
|
60
|
-
files.push({ name, rel, bundle, bytes, state: probe.present ? classifyDeployedScript(bytes, name, bundle, deps.priors ?? SCRIPT_PRIORS) : 'absent' });
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
return { files, layout: surveyAdrLayoutStrict(cwd, deps) };
|
|
64
|
-
} catch (err) {
|
|
65
|
-
return { files, layoutError: causeOf(err) };
|
|
66
67
|
}
|
|
68
|
+
const judged = accepted ? new Set(FAMILY) : seedClosure(probes.filter((f) => f.probe.present).map((f) => f.name), (name) => bundles.get(name));
|
|
69
|
+
const files = probes.filter((f) => judged.has(f.name)).map(({ name, rel, probe }) => {
|
|
70
|
+
const bytes = probe.present ? read(join(cwd, rel)) : undefined;
|
|
71
|
+
return { name, rel, bundle: bundles.get(name), state: probe.present ? classifyDeployedScript(bytes, name, bundles.get(name), deps.priors ?? SCRIPT_PRIORS) : 'absent' };
|
|
72
|
+
});
|
|
73
|
+
return { files, accepted };
|
|
67
74
|
};
|
|
68
75
|
|
|
69
|
-
const entryOf = (f) => ({
|
|
70
|
-
rel: f.rel,
|
|
71
|
-
...(f.state === 'absent' ? { absent: true } : { sha256: digestOf(f.bytes), bytes: f.bytes }),
|
|
72
|
-
channel: f.name === INSTALLER_SET[0] ? LOCAL_HOOK_CHANNEL : SCRIPT_CHANNEL,
|
|
73
|
-
hookRun: true,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
76
|
// ── the lines (composed from what HAPPENED: each file's state and the fate of its write) ─────────
|
|
77
77
|
|
|
78
|
-
// A fate is `written`, `stood` (
|
|
79
|
-
//
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (f.state === 'absent') return `${f.rel}: ${{ written: "placed from the bundled scripts on the user's yes", stood: 'appeared while this run was placing it — the bundled body stands, nothing written' }[fate] ?? 'absent — not placed'}`;
|
|
88
|
-
const kept = keptOf(f.rel);
|
|
89
|
-
return `${f.rel}: ${fate === 'written' ? `carried an edit — kept aside at ${kept}, then replaced by the bundled body on the user's yes` : `carries an edit — not replaced${kept ? `; its copy kept aside at ${kept} stays` : ''}`}`;
|
|
78
|
+
// A fate is `written`, `stood` (an absent file that appeared with the bundled body), `refused` (its
|
|
79
|
+
// write failed), or none: the run stopped before it, or, dry, would write it.
|
|
80
|
+
const VERBS = { prior: ['refreshed', 'refreshed to the bundled one'], custom: ['replaced', 'replaced by the bundled body'], absent: ['placed', 'placed from the bundled scripts'] };
|
|
81
|
+
const HEADS = { prior: 'matches a body an earlier release shipped', custom: 'differs from every body this kit knows it shipped', absent: 'absent' };
|
|
82
|
+
const fileLine = (f, fate, dryRun) => {
|
|
83
|
+
if (fate === 'stood') return `${f.rel}: appeared while this run was placing it — the bundled body stands, nothing written`;
|
|
84
|
+
const [verb, done] = VERBS[f.state];
|
|
85
|
+
const tail = fate === 'written' ? done : dryRun ? `would be ${done}` : `not ${verb}; ${fate === 'refused' ? 'its write was refused (above)' : 'the run stopped before it'}`;
|
|
86
|
+
return `${f.rel}: ${HEADS[f.state]} — ${tail}${f.state === 'custom' ? `; an edit meant to last goes in ${f.name === INSTALLER_SET[0] ? LOCAL_HOOK_CHANNEL : SCRIPT_CHANNEL}` : ''}`;
|
|
90
87
|
};
|
|
91
|
-
const
|
|
88
|
+
const NOT_ACCEPTED = `${SCRIPTS_DIR}/: the enforcement scripts were not accepted in this project, so no other kit script is placed`;
|
|
89
|
+
// The hook-run line, once after the file lines of a run that wrote (or, dry, would write) a file.
|
|
90
|
+
const hookLine = (accepted, dryRun) => (accepted
|
|
91
|
+
? (dryRun ? 'the commit hook runs the files named above, so writing them may stop the next commit' : 'the commit hook runs the files written above, so they may stop the next commit')
|
|
92
|
+
: (dryRun ? 'if a commit hook runs the files named above, writing them may stop the next commit' : 'if a commit hook runs the files written above, they may stop the next commit'));
|
|
92
93
|
const partialNote = (count) => (count > 0 ? [`the writes stopped PARTWAY — the ${count} file(s) named above were already written and are NOT rolled back`] : []);
|
|
93
94
|
|
|
94
95
|
// ── the writes ────────────────────────────────────────────────────────────────────────────────────
|
|
95
96
|
|
|
96
|
-
// One write per file in write order: a prior refreshed
|
|
97
|
-
//
|
|
98
|
-
const writeAll = ({ cwd, files, deps, read
|
|
97
|
+
// One write per file in write order: a prior refreshed and an edit replaced by the atomic write, an
|
|
98
|
+
// absent file written create-only. → { fates, notes, failure? }
|
|
99
|
+
const writeAll = ({ cwd, files, deps, read }) => {
|
|
99
100
|
const fates = new Map();
|
|
100
101
|
const notes = [];
|
|
101
102
|
for (const f of files) {
|
|
102
|
-
if (f.state === 'custom' && digestOf(read(join(cwd, f.rel))) !== bound.get(f.rel)) {
|
|
103
|
-
return { fates, notes, failure: ['race-unresolved', `${f.rel}: changed after this run read it — left as it stands and nothing further written`] };
|
|
104
|
-
}
|
|
105
103
|
let result;
|
|
106
104
|
try {
|
|
107
105
|
result = f.state === 'absent'
|
|
@@ -114,6 +112,7 @@ const writeAll = ({ cwd, files, deps, read, bound }) => {
|
|
|
114
112
|
notes.push(...tmpNote(f.rel, result.tmpLeftBehind));
|
|
115
113
|
if (f.state === 'absent' && !result.created) {
|
|
116
114
|
if (classifyDeployedScript(read(join(cwd, f.rel)), f.name, f.bundle) !== 'current') {
|
|
115
|
+
fates.set(f.rel, 'refused');
|
|
117
116
|
return { fates, notes, failure: ['race-unresolved', `${f.rel}: appeared while this run was placing it and does not carry the bundled body — nothing further written, re-run when the tree is settled`] };
|
|
118
117
|
}
|
|
119
118
|
fates.set(f.rel, 'stood');
|
|
@@ -122,25 +121,37 @@ const writeAll = ({ cwd, files, deps, read, bound }) => {
|
|
|
122
121
|
return { fates, notes };
|
|
123
122
|
};
|
|
124
123
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
// One run over the files it is handed: every one that is not current written in order, its lines,
|
|
125
|
+
// then the hook-run line once when a file was (or, dry, would be) written.
|
|
126
|
+
const writeRun = ({ cwd, files, accepted, dryRun, deps, read }) => {
|
|
127
|
+
const due = files.filter((f) => f.state !== 'current');
|
|
128
|
+
const { fates, notes, failure } = dryRun ? { fates: new Map(), notes: [] } : writeAll({ cwd, files: due, deps, read });
|
|
129
|
+
const written = due.filter((f) => fates.get(f.rel) === 'written');
|
|
130
|
+
const hook = (dryRun ? due.length > 0 : written.length > 0) ? [hookLine(accepted, dryRun)] : [];
|
|
131
|
+
return { due, fates, failure, written, lines: due.map((f) => fileLine(f, fates.get(f.rel), dryRun)), tail: [...hook, ...notes, ...(failure ? partialNote(written.length) : [])] };
|
|
132
|
+
};
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
// ── the ADR store, after the writes ───────────────────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
// The rotator the run just left on the bundled body brings the store current; its output is relayed
|
|
137
|
+
// keyed on its contracted summary, the last standard output line.
|
|
138
|
+
const STORE = 'ADR store: ';
|
|
139
|
+
const ENSURE = `${SCRIPTS_DIR}/${ROTATOR} --ensure-current`;
|
|
140
|
+
const WOULD_STORE = `${STORE}${ENSURE} would run after the writes, bringing the store current or writing nothing when it already is`;
|
|
141
|
+
const outputLines = (text) => String(text ?? '').split(/\r?\n/).filter((line) => line !== '');
|
|
142
|
+
// → { brought, lines, failure? }
|
|
143
|
+
const runStore = (cwd, deps) => {
|
|
144
|
+
const r = (deps.spawnSync ?? spawnSync)(process.execPath, [join(cwd, SCRIPTS_DIR, ROTATOR), '--ensure-current'], { cwd, encoding: 'utf8' });
|
|
145
|
+
const [out, err] = [outputLines(r.stdout), outputLines(r.stderr)];
|
|
146
|
+
const ended = r.error ? `ended with an error (${causeOf(r.error)})` : r.signal ? `was killed by signal ${r.signal}` : r.status !== 0 ? `exited with code ${r.status}` : null;
|
|
147
|
+
if (ended) return { failure: `${ENSURE} ${ended} — the ADR store is not current`, lines: [...err, ...out].map((line) => STORE + line) };
|
|
148
|
+
const brought = (out.at(-1) ?? '').startsWith('brought-current:');
|
|
149
|
+
return { brought, lines: [...(brought ? out : []), ...err].map((line) => STORE + line) };
|
|
139
150
|
};
|
|
140
151
|
|
|
141
152
|
// ── the op ────────────────────────────────────────────────────────────────────────────────────────
|
|
142
153
|
|
|
143
|
-
export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {}
|
|
154
|
+
export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
144
155
|
const lstat = deps.lstat ?? lstatSync;
|
|
145
156
|
const read = deps.readFile ?? readFileSync;
|
|
146
157
|
const refusal = nodeEvidenceRefusal(OP, cwd, lstat);
|
|
@@ -148,38 +159,16 @@ export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {}, replace
|
|
|
148
159
|
const found = survey({ cwd, kitRoot, deps, read, lstat });
|
|
149
160
|
if (found.refusal) return found.refusal;
|
|
150
161
|
if (found.notPlaced) return composeOutcome(OP, 'not-placed', [`${SCRIPTS_DIR}/: no kit script stands in it, so none is placed`], false);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
];
|
|
164
|
-
const ok = (token, lines) => ({ ...composeOutcome(OP, token, lines, false), entries });
|
|
165
|
-
const loud = (cause, ...lines) => ({ ...composeFailure(OP, cause, ...lines), entries });
|
|
166
|
-
if (bound && !sameEntries(entries, replace.entries)) {
|
|
167
|
-
return loud('race-unresolved', 'the kit scripts to place or replace are not the set the yes was given for (another set or other bytes), so nothing was written', ...linesOf(new Map()));
|
|
168
|
-
}
|
|
169
|
-
const due = live.filter((f) => f.state === 'prior' || (bound && (f.state === 'custom' || f.state === 'absent')));
|
|
170
|
-
const tokenOf = (fates) => {
|
|
171
|
-
const landed = (state) => due.some((f) => f.state === state && fates.get(f.rel) === 'written');
|
|
172
|
-
if (held) return 'old-adr-layout-migration-instructed';
|
|
173
|
-
if (!bound && entries.length > 0) return 'pending';
|
|
174
|
-
if (landed('absent')) return 'seeded';
|
|
175
|
-
if (dryRun ? due.length > 0 : landed('prior') || landed('custom')) return dryRun ? 'would-refresh' : 'refreshed';
|
|
176
|
-
return 'already-present';
|
|
177
|
-
};
|
|
178
|
-
if (dryRun) return ok(tokenOf(new Map()), linesOf(new Map()));
|
|
179
|
-
const { fates, notes, failure } = writeAll({ cwd, files: due, deps, read, bound });
|
|
180
|
-
if (failure) {
|
|
181
|
-
const written = [...fates.values()].filter((fate) => fate === 'written').length;
|
|
182
|
-
return loud(failure[0], failure[1], ...linesOf(fates), ...notes, ...partialNote(written));
|
|
183
|
-
}
|
|
184
|
-
return ok(tokenOf(fates), [...linesOf(fates), ...notes]);
|
|
162
|
+
const { files, accepted } = found;
|
|
163
|
+
const current = files.filter((f) => f.state === 'current').length;
|
|
164
|
+
const r = writeRun({ cwd, files, accepted, dryRun, deps, read });
|
|
165
|
+
const body = [...r.lines, ...(current > 0 ? [`${SCRIPTS_DIR}/: ${current} other kit scripts are already the bundled body — nothing written`] : []), ...(accepted ? [] : [NOT_ACCEPTED])];
|
|
166
|
+
if (r.failure) return composeFailure(OP, r.failure[0], r.failure[1], ...body, ...r.tail);
|
|
167
|
+
const rotator = files.some((f) => f.name === ROTATOR);
|
|
168
|
+
const store = !rotator ? { lines: [] } : dryRun ? { lines: [WOULD_STORE] } : runStore(cwd, deps);
|
|
169
|
+
if (store.failure) return composeFailure(OP, 'adr-store-not-current', store.failure, ...body, ...r.tail, ...store.lines);
|
|
170
|
+
const landed = (state) => (dryRun ? r.due : r.written).some((f) => f.state === state);
|
|
171
|
+
const token = landed('absent') ? (dryRun ? 'would-seed' : 'seeded')
|
|
172
|
+
: landed('prior') || landed('custom') || store.brought ? (dryRun ? 'would-refresh' : 'refreshed') : 'already-present';
|
|
173
|
+
return composeOutcome(OP, token, [...body, ...r.tail, ...store.lines], false);
|
|
185
174
|
};
|
package/tools/ensure-configs.mjs
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
// autonomy docs/ai/autonomy.json seed-if-missing (same)
|
|
7
7
|
// vehicles docs/ai/vehicles.json seed-if-missing (same)
|
|
8
8
|
// executor .claude/agents/executor.md judged against docs/ai/vehicles.json, never written: a differing body is pending
|
|
9
|
-
// scripts scripts/<every kit script>
|
|
10
|
-
// + the installer set
|
|
9
|
+
// scripts scripts/<every kit script> once a kit script outside the seed names stands there, every file not current
|
|
10
|
+
// + the installer set written with no question and no copy kept; installer set first; on a
|
|
11
|
+
// declined offer only the standing seed files and the modules they import;
|
|
12
|
+
// then the project's rotator brings the ADR store current (--ensure-current)
|
|
11
13
|
// specs scripts/<spec layer> reader + checker pairs seeded when absent, refreshed only on
|
|
12
14
|
// + docs/ai/specs/index.md a shipped prior body, an edited one replaced only on the
|
|
13
15
|
// user's yes; store root seeded behind a current checker
|
|
@@ -28,10 +30,10 @@
|
|
|
28
30
|
// • The ops run in a FIXED order and one op's failure NEVER skips the rest: every op reports its own
|
|
29
31
|
// token, and the exit is non-zero when any of them failed. The one exception is the replace run
|
|
30
32
|
// (--replace-custom <digest>), which distribution-files/ runs: each edit kept aside, then the
|
|
31
|
-
// owning
|
|
33
|
+
// owning op (specs), then index only when none failed.
|
|
32
34
|
// • ONE replace block, after every op's lines and before the failure footer, over the union the
|
|
33
|
-
// replace run recomputes: the files whose write waits for the user's yes, and the one
|
|
34
|
-
//
|
|
35
|
+
// replace run recomputes: the spec-layer files whose write waits for the user's yes, and the one
|
|
36
|
+
// command for it.
|
|
35
37
|
// • The deployment gate runs ONCE, before any op: an absent/symlinked docs/ai stops the whole run
|
|
36
38
|
// with the gate's own message rather than one copy of it per op.
|
|
37
39
|
//
|
|
@@ -57,7 +59,7 @@ const KIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
57
59
|
// consumer) because the executor, scripts, spec-layer and rules ensures import ensure-ops.mjs for their outcome door and probes.
|
|
58
60
|
export const ENSURE_IMPLEMENTATIONS = Object.freeze({ ...OWN_IMPLEMENTATIONS, executor: ensureExecutor, scripts: ensureScripts, specs: ensureSpecs, rules: ensureRules });
|
|
59
61
|
// The ops whose writes wait for the user's yes and so own the replace run, in ENSURE_OPS order.
|
|
60
|
-
const OWNING_OPS = ['
|
|
62
|
+
const OWNING_OPS = ['specs'];
|
|
61
63
|
|
|
62
64
|
const EXIT_OK = 0;
|
|
63
65
|
const EXIT_FAILED = 1;
|
|
@@ -71,7 +73,7 @@ const REPEATED_ONLY = '--only was passed more than once — this selector names
|
|
|
71
73
|
const unknownOp = (value) => `--only ${value}: no such operation (${ENSURE_OPS.join(' | ')}) — nothing was run`;
|
|
72
74
|
const EMPTY_REPLACE = '--replace-custom needs the digest its replace line printed — an empty value names no file to replace';
|
|
73
75
|
const REPEATED_REPLACE = '--replace-custom was passed more than once — a replace run carries exactly ONE digest';
|
|
74
|
-
const REPLACE_WITH_ONLY = '--replace-custom runs the
|
|
76
|
+
const REPLACE_WITH_ONLY = '--replace-custom runs the spec layer, then the navigator, so it cannot be combined with --only — nothing was run';
|
|
75
77
|
const REPLACE_WITH_DRY_RUN = "--replace-custom writes on the user's yes, so it cannot be combined with --dry-run — nothing was run";
|
|
76
78
|
|
|
77
79
|
const HELP = `ensure-configs — the nine stamp-independent upgrade ensures, as ONE command.
|
|
@@ -82,13 +84,12 @@ Usage:
|
|
|
82
84
|
|
|
83
85
|
--reconcile required — run the nine ensures (${ENSURE_OPS.join(', ')})
|
|
84
86
|
--dry-run report what each ensure WOULD do; write nothing
|
|
85
|
-
--only <op> run EXACTLY ONE of them (an unknown, missing or repeated value is a usage error)
|
|
86
|
-
scripts or specs, a write-free survey of the other owning op feeds the replace block
|
|
87
|
+
--only <op> run EXACTLY ONE of them (an unknown, missing or repeated value is a usage error)
|
|
87
88
|
--replace-custom <digest>
|
|
88
89
|
the replace run the replace block prints, run only on the user's yes: every edit its
|
|
89
|
-
digest names is kept aside under .agent-workflow/kept-aside/, then the
|
|
90
|
-
|
|
91
|
-
--
|
|
90
|
+
digest names is kept aside under .agent-workflow/kept-aside/, then the spec layer
|
|
91
|
+
replaces and places its files, then index runs when nothing failed (not with --only or
|
|
92
|
+
--dry-run; an empty value is a usage error)
|
|
92
93
|
--cwd <dir> the target project (default: the current directory)
|
|
93
94
|
--help, -h this help
|
|
94
95
|
|
|
@@ -105,10 +106,13 @@ the project's own checker judges the navigator and a write it rejects is put bac
|
|
|
105
106
|
The executor ensure writes nothing: a placed .claude/agents/executor.md whose bytes differ from the
|
|
106
107
|
body derived from docs/ai/vehicles.json is pending — the advisor's executor-vehicle.differing item
|
|
107
108
|
changes it on your yes; an absent file is never placed here.
|
|
108
|
-
A fifth
|
|
109
|
-
kit script, the hook installer and its two suites
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
A fifth writes too: once a kit script outside the seed names stands in scripts/, the enforcement-script
|
|
110
|
+
ensure writes every kit script that is not the bundled body, the hook installer and its two suites
|
|
111
|
+
first, with no question and no copy kept: a body a release shipped is refreshed, an edited one replaced
|
|
112
|
+
(its line names where an edit meant to last goes) and an absent one placed; on a project that
|
|
113
|
+
declined the enforcement offer, its standing seed files are kept current the same way, with an
|
|
114
|
+
absent module they import placed, and no other kit script is placed; after the writes the project's
|
|
115
|
+
scripts/archive-decisions.mjs --ensure-current brings the ADR store current, an older layout moved.
|
|
112
116
|
|
|
113
117
|
Exit codes: 0 every op fine; 1 an op failed (its line says so) or there is no deployment here; 2 usage.`;
|
|
114
118
|
|
|
@@ -171,19 +175,16 @@ const runOne = (op, args) => {
|
|
|
171
175
|
// Run every op in ENSURE_OPS order. A throw from one op becomes THAT op's failed outcome — the
|
|
172
176
|
// remaining ops still run, because a project missing its gate declaration should not also be left
|
|
173
177
|
// without its autonomy seed just because the first ensure hit an unreadable file. → { outcomes, block }:
|
|
174
|
-
// the block is the union the replace run recomputes
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
// index only when none failed, and its block is non-empty only when the digest no longer matches.
|
|
178
|
+
// the block is the union the replace run recomputes, the entries of the owning op. The replace run is
|
|
179
|
+
// the one exception, handed to runReplace: it keeps every edit aside, runs the owning op, then index
|
|
180
|
+
// only when it did not fail, and its block is non-empty only when the digest no longer matches.
|
|
178
181
|
export const runEnsures = ({ cwd, kitRoot, dryRun, deps, only, replaceCustom }) => {
|
|
179
182
|
if (replaceCustom !== undefined) {
|
|
180
183
|
const owning = OWNING_OPS.map((op) => ({ op, run: (args) => runOne(op, args) }));
|
|
181
184
|
return runReplace({ cwd, kitRoot, digest: replaceCustom, owning, index: (args) => runOne('index', args), deps });
|
|
182
185
|
}
|
|
183
186
|
const outcomes = (only ? [only] : ENSURE_OPS).map((op) => runOne(op, { cwd, kitRoot, dryRun, deps }));
|
|
184
|
-
|
|
185
|
-
const shown = [...outcomes, ...surveys.filter((o) => o.failed)].sort((a, b) => ENSURE_OPS.indexOf(a.op) - ENSURE_OPS.indexOf(b.op));
|
|
186
|
-
return { outcomes: shown, block: [...outcomes, ...surveys].flatMap((o) => o.entries ?? []) };
|
|
187
|
+
return { outcomes, block: outcomes.flatMap((o) => o.entries ?? []) };
|
|
187
188
|
};
|
|
188
189
|
|
|
189
190
|
const render = ({ outcomes, block }, { dryRun, only, replace, kitRoot, cwd }) => {
|
package/tools/ensure-ops.mjs
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
// orchestration-write.mjs — the file's one writer. Nothing here re-derives either.
|
|
19
19
|
// • Every token names a state this run PROVED. `already-present` follows a probe; `skipped-no-node-evidence`
|
|
20
20
|
// names every Node probe that answered absent (the refusal the kit-script and spec-layer ensures
|
|
21
|
-
// share, below; the kit scripts' rule —
|
|
22
|
-
//
|
|
21
|
+
// share, below; the kit scripts' rule — every kit script written with no question and no copy
|
|
22
|
+
// kept — lives in distribution-files/scripts.mjs).
|
|
23
23
|
// • A failed op is a non-zero signal, never a line that reads like success.
|
|
24
24
|
//
|
|
25
25
|
// Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
|
|
10
10
|
// The FIXED order the CLI runs them in — the order references/modes/upgrade.md already prescribed.
|
|
11
11
|
// `specs` sits after `scripts` (its reader pair is a scripts/ seed too) and BEFORE `index`: the store
|
|
12
|
-
// root it seeds is a docs/ai file the navigator must count. `
|
|
13
|
-
//
|
|
14
|
-
//
|
|
12
|
+
// root it seeds is a docs/ai file the navigator must count. `specs` alone owns the replace run: its
|
|
13
|
+
// edited files are written only on the user's yes, while `scripts` writes every kit script with no
|
|
14
|
+
// question and then runs the project's rotator (`--ensure-current`), which brings the ADR store current.
|
|
15
15
|
// `executor` follows `vehicles`: its body is derived from the settings file that op seeds.
|
|
16
16
|
// `rules` follows `specs` and precedes `index`: the rules files it lays are docs/ai files the navigator counts.
|
|
17
17
|
export const ENSURE_OPS = Object.freeze(['orchestration', 'gates', 'autonomy', 'vehicles', 'executor', 'scripts', 'specs', 'rules', 'index']);
|
|
18
18
|
|
|
19
19
|
// Tokens that assert a WRITE happened. --dry-run may never emit one of these (the CLI's contract test
|
|
20
20
|
// walks this set), and each has exactly one `would-` counterpart below. `refreshed` is the spec-layer
|
|
21
|
-
// ensure's pair refresh (reader or checker) or the scripts ensure's
|
|
22
|
-
// script on a body a release shipped, rewritten to the bundled one
|
|
23
|
-
// absent kit script placed,
|
|
24
|
-
//
|
|
21
|
+
// ensure's pair refresh (reader or checker) or the scripts ensure's write of a kit script — a deployed
|
|
22
|
+
// script on a body a release shipped, or an edited one, rewritten to the bundled one on a plain run, an
|
|
23
|
+
// absent kit script placed (`seeded`), or the ADR store the rotator brought current; an edited spec-layer file is replaced only by the replace run the
|
|
24
|
+
// user's yes starts (--replace-custom, over the spec layer).
|
|
25
25
|
export const WRITE_TOKENS = Object.freeze(['seeded', 'note-refreshed', 'refreshed', 'regenerated']);
|
|
26
26
|
export const DRY_RUN_TOKENS = Object.freeze(['would-seed', 'would-refresh-note', 'would-refresh', 'would-regenerate']);
|
|
27
27
|
|
|
@@ -40,7 +40,6 @@ export const ENSURE_TOKENS = Object.freeze([
|
|
|
40
40
|
'customized-preserved',
|
|
41
41
|
'malformed-preserved',
|
|
42
42
|
'skipped-no-node-evidence',
|
|
43
|
-
'old-adr-layout-migration-instructed',
|
|
44
43
|
'failed',
|
|
45
44
|
]);
|
|
46
45
|
|
|
@@ -51,7 +50,8 @@ export const FAILURE_CAUSES = Object.freeze([
|
|
|
51
50
|
'race-unresolved',
|
|
52
51
|
'template-unreadable',
|
|
53
52
|
'bundle-unreadable',
|
|
54
|
-
'
|
|
53
|
+
// The scripts op's store run: the rotator ended with an error, a signal or a non-zero exit.
|
|
54
|
+
'adr-store-not-current',
|
|
55
55
|
// A Node probe (package.json, a kit-seeded script) failed with anything but ENOENT: whether Node runs
|
|
56
56
|
// here is unproven, so the ensures that place Node scripts write nothing (contract: kit/node-evidence).
|
|
57
57
|
'node-evidence-unverifiable',
|
|
@@ -91,6 +91,5 @@ export const RELAYED_ENSURE_TOKENS = Object.freeze([
|
|
|
91
91
|
'already-present',
|
|
92
92
|
'not-placed',
|
|
93
93
|
'skipped-no-node-evidence',
|
|
94
|
-
'old-adr-layout-migration-instructed',
|
|
95
94
|
'failed',
|
|
96
95
|
]);
|
package/tools/git-hooks.mjs
CHANGED
|
@@ -34,7 +34,7 @@ const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
|
34
34
|
const usageError = (message) => Object.assign(new Error(message), { exitCode: EXIT_USAGE });
|
|
35
35
|
const refusal = (message) => Object.assign(new Error(message), { exitCode: EXIT_REFUSED });
|
|
36
36
|
// The one route the two re-read lines end with: an installer that left a passed line out is not the kit's current body.
|
|
37
|
-
export const UPGRADE_ROUTE = "/agent-workflow-kit upgrade
|
|
37
|
+
export const UPGRADE_ROUTE = "/agent-workflow-kit upgrade writes the kit's current installer over any other installer body, with no question; if it stops on another cause, resolve the cause it names and run it again; then apply this item again";
|
|
38
38
|
|
|
39
39
|
const nodeAt = (path, lstat) => {
|
|
40
40
|
try {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// migrate-adr-store.mjs — the consent-gated, opt-in migration of an EXISTING consumer's docs/ai from
|
|
3
3
|
// the retired 3-tier ADR cascade (HOT decisions.md → WARM/COLD monoliths) to the one-file-per-ADR
|
|
4
4
|
// store (HOT decisions.md + docs/ai/adr/AD-NNN-slug.md records + the docs/ai/adr/log.md navigator).
|
|
5
|
-
// Reached
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// Reached through the opt-in `migrate-adr-store` mode (SKILL.md): the upgrade moves an older layout
|
|
6
|
+
// itself wherever scripts/ holds the kit's rotator, so after a full upgrade this mode does nothing; it
|
|
7
|
+
// stays for a project whose scripts/ holds no kit script.
|
|
8
8
|
//
|
|
9
9
|
// What it does (in order, on --apply):
|
|
10
10
|
// 1. GATE — docs/ai must be deployed, and the tree must be on the OLD layout. That is TWO shapes:
|
package/tools/script-priors.mjs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// into a project's `scripts/`, as sha256 digests, and the ONE classifier a refresh asks before it
|
|
3
3
|
// replaces a deployed script — the spec-layer ensure for its pairs and the upgrade's `scripts` ensure
|
|
4
4
|
// for every other kit script: `current` (byte-equal to the bundled copy) · `prior` (a body a release
|
|
5
|
-
// shipped, never edited since) · `custom` (anything else —
|
|
6
|
-
//
|
|
5
|
+
// shipped, never edited since) · `custom` (anything else — replaced on the plain run by the scripts op,
|
|
6
|
+
// and by the user's yes for the spec-layer pairs alone). The lens-region idiom (AD-041) over whole
|
|
7
|
+
// script bodies.
|
|
7
8
|
//
|
|
8
9
|
// Append discipline: when a release changes one of PRIOR_FILES, append the OUTGOING body's row here
|
|
9
10
|
// in the same release and copy its bytes to test/fixtures/script-priors/<firstShipped>/<file>.txt —
|
|
@@ -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 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>",
|
|
37
|
+
"a replace line → ONE yes naming every spec-layer 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',
|
|
@@ -47,7 +47,6 @@ export const UPGRADE_RUNLIST = Object.freeze([
|
|
|
47
47
|
'already-present',
|
|
48
48
|
'not-placed',
|
|
49
49
|
'skipped-no-node-evidence',
|
|
50
|
-
'old-adr-layout-migration-instructed',
|
|
51
50
|
'failed',
|
|
52
51
|
],
|
|
53
52
|
),
|