@sabaiway/agent-workflow-kit 14.48.0 → 14.49.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 +33 -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/upgrade.md +3 -3
- package/tools/distribution-files/scripts.mjs +79 -90
- package/tools/ensure-configs.mjs +23 -23
- package/tools/ensure-ops.mjs +2 -2
- package/tools/ensure-vocabulary.mjs +7 -7
- package/tools/git-hooks.mjs +1 -1
- package/tools/script-priors.mjs +3 -2
- package/tools/upgrade-runlist.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,39 @@ 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.49.0 — the upgrade writes the kit's current scripts and hook installer with no question and no kept-aside copy (AD-202)
|
|
8
|
+
|
|
9
|
+
**`/agent-workflow-kit upgrade` no longer asks about its own scripts.** Before, an edited or absent kit script in
|
|
10
|
+
`scripts/` waited for the upgrade's one yes, and an edit was kept aside under `.agent-workflow/kept-aside/` first. Now
|
|
11
|
+
the upgrade's `scripts` step writes every kit script that is not the bundled body, the hook installer and its two
|
|
12
|
+
suites first, with no question and no copy kept:
|
|
13
|
+
|
|
14
|
+
- **Each file by proof.** A body an earlier release shipped is refreshed, an edited body replaced in place, an absent
|
|
15
|
+
file placed; the current body is left. The line of an edited file names where an edit meant to last goes:
|
|
16
|
+
`scripts/pre-commit.local` for the installer, a script or suite of your own under its own name in `scripts/`, or a
|
|
17
|
+
config the script reads, for the rest. One closing line says the commit hook runs the files written, so they may
|
|
18
|
+
stop the next commit.
|
|
19
|
+
- **Only where you took the kit's scripts.** The step works once a kit script other than the four that memory also
|
|
20
|
+
places on its own (`archive-decisions.mjs`, its suite, and the `markdown-blocks.mjs` and `_expect-shim.mjs` that
|
|
21
|
+
memory's copied files import) stands in `scripts/`. A
|
|
22
|
+
project that declined the enforcement offer keeps those standing copies current, with an absent one they import
|
|
23
|
+
placed, gets no other kit script, and one line says so.
|
|
24
|
+
- **The one yes is the spec layer's alone.** The replace block and its yes now name only the four spec-layer files,
|
|
25
|
+
whose edit is still kept aside first. The `--only scripts` run no longer surveys the spec layer, and the step's
|
|
26
|
+
tokens are `seeded`, `refreshed`, `already-present`, `not-placed`, `old-adr-layout-migration-instructed` and
|
|
27
|
+
`skipped-no-node-evidence` (a dry run: `would-seed`, `would-refresh`); it never prints `pending`.
|
|
28
|
+
- **The hook line names the plain upgrade.** When the `commit-guard` or `hook-checks` apply finds a hook line the
|
|
29
|
+
installer left out, its line says the upgrade writes the kit's current installer over any other body with no
|
|
30
|
+
question; migration note 3.0.0 step 4 says the same.
|
|
31
|
+
- **The guide names the reserved names.** `references/contracts.md` gains *Reserved names and channels*: the names
|
|
32
|
+
the kit writes over are its own, a declaration seeded once is yours, five places hold your own checks, scripts,
|
|
33
|
+
settings, rules and an agent's model, and no path the kit bundles and places as its own has a dot-separated part
|
|
34
|
+
exactly `local`, so a name like `scripts/pre-commit.local` is yours (the section names its two exceptions).
|
|
35
|
+
- **Unchanged:** the hold-back of the decisions files on an older ADR layout, the unreadable layout keeping the
|
|
36
|
+
installer set current, and the upgrade never running the installer.
|
|
37
|
+
|
|
38
|
+
MINOR: no question for the kit's scripts, and a new guide section.
|
|
39
|
+
|
|
7
40
|
## 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
41
|
|
|
9
42
|
**`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.49.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.49.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.
|
|
@@ -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 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.
|
|
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 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 — 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` / `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
|
|
|
@@ -43,7 +43,7 @@ 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. **OLD ADR-store layout — DETECTED, never auto-migrated (AD-051, Decision 13):** on a `docs/ai/history/decisions-archive*.md` monolith (`old`), or no monolith but a deployed rotator predating the store (`old-unrotated`), the decisions group (`archive-decisions.mjs`, `archive-decisions.test.mjs`, `archiver-structure.test.mjs`) is held back and the ensure reports `old-adr-layout-migration-instructed`. Relay it LOUD: the fix is the opt-in **`/agent-workflow-kit migrate-adr-store`** (previews first, never commits); the next upgrade judges the group. A layout the ensure cannot READ is `failed`: the installer set alone is kept current, every other kit script waits. 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
|
|
|
@@ -1,11 +1,11 @@
|
|
|
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; on an older
|
|
6
|
+
// ADR layout the decisions group is held back, the migration named. It never imports ensure-specs.mjs
|
|
7
|
+
// or ensure-configs.mjs: the CLI composes this op from the module's index, and ensure-specs.mjs takes
|
|
8
|
+
// its channel from there.
|
|
9
9
|
//
|
|
10
10
|
// Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
|
|
11
11
|
|
|
@@ -15,8 +15,7 @@ import { lstatNoFollow, writeContainedFileAtomic, writeProjectFileCreateOnly } f
|
|
|
15
15
|
import { composeFailure, composeOutcome, nodeEvidenceRefusal, probeSeedTarget, tmpNote } from '../ensure-ops.mjs';
|
|
16
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';
|
|
@@ -26,10 +25,13 @@ export const SCRIPT_CHANNEL = 'a script or suite of your own under its own name
|
|
|
26
25
|
export const LOCAL_HOOK_CHANNEL = 'the local hook file scripts/pre-commit.local, which the commit hook runs first';
|
|
27
26
|
// The family files whose bytes import or read archive-decisions.mjs, plus that file (the suite derives it).
|
|
28
27
|
export const DECISIONS_GROUP = Object.freeze(['archive-decisions.mjs', 'archive-decisions.test.mjs', 'archiver-structure.test.mjs']);
|
|
28
|
+
// The family files memory copies on Node evidence alone, accepted or not (the suite derives them).
|
|
29
|
+
export const SEED_NAMES = Object.freeze(['_expect-shim.mjs', 'archive-decisions.mjs', 'archive-decisions.test.mjs', 'markdown-blocks.mjs']);
|
|
29
30
|
const OLD_ADR_LAYOUTS = new Set(['old', 'old-unrotated']);
|
|
30
31
|
const PAIRS = new Set([...READER_PAIR, ...CHECKER_PAIR]);
|
|
31
32
|
// The family in write order: the installer set, then every other bundled name in code-unit order.
|
|
32
33
|
const FAMILY = Object.freeze([...INSTALLER_SET, ...BUNDLED_SCRIPT_NAMES.filter((name) => !PAIRS.has(name) && !INSTALLER_SET.includes(name)).sort()]);
|
|
34
|
+
const LOCAL_IMPORT = /(?:from|import)\s*\(?\s*'\.\/([^']+)'/g;
|
|
33
35
|
|
|
34
36
|
const causeOf = (err) => String((err && err.message) || err);
|
|
35
37
|
const relOf = (name) => `${SCRIPTS_DIR}/${name}`;
|
|
@@ -38,8 +40,16 @@ const wrongKind = (rel, kind) => composeFailure(OP, 'wrong-node-kind', `${rel}:
|
|
|
38
40
|
|
|
39
41
|
// ── the survey: the component first, then every family file by proof, nothing written ────────────
|
|
40
42
|
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
+
// The seed files a run of a component that is not accepted judges: each standing one, and every seed
|
|
44
|
+
// file reached from one through its bundled `./` imports, so every seed file the run leaves loads.
|
|
45
|
+
const seedClosure = (standing, bundleOf) => {
|
|
46
|
+
const reached = new Set(standing);
|
|
47
|
+
for (const name of reached) for (const [, dep] of bundleOf(name).toString('utf8').matchAll(LOCAL_IMPORT)) if (SEED_NAMES.includes(dep)) reached.add(dep);
|
|
48
|
+
return reached;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// → { refusal } | { notPlaced } | { files, accepted, layout, layoutError }. A family path of another node
|
|
52
|
+
// kind is judged before the component, so a linked family file never reads as not-placed.
|
|
43
53
|
const survey = ({ cwd, kitRoot, deps, read, lstat }) => {
|
|
44
54
|
const dir = lstatNoFollow(join(cwd, SCRIPTS_DIR), lstat);
|
|
45
55
|
if (dir === null) return { notPlaced: true };
|
|
@@ -48,60 +58,55 @@ const survey = ({ cwd, kitRoot, deps, read, lstat }) => {
|
|
|
48
58
|
const wrong = probes.find((f) => f.probe.wrongKind);
|
|
49
59
|
if (wrong) return { refusal: wrongKind(wrong.rel, wrong.probe.wrongKind) };
|
|
50
60
|
if (!probes.some((f) => f.probe.present)) return { notPlaced: true };
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
const accepted = probes.some((f) => f.probe.present && !SEED_NAMES.includes(f.name));
|
|
62
|
+
const bundles = new Map();
|
|
63
|
+
for (const { name, rel } of probes) {
|
|
54
64
|
try {
|
|
55
|
-
|
|
65
|
+
bundles.set(name, read(join(kitRoot, ...BUNDLED, name)));
|
|
56
66
|
} catch (err) {
|
|
57
67
|
return { refusal: composeFailure(OP, 'bundle-unreadable', `${rel}: the bundled script could not be read, so nothing was written — reinstall the kit. ${causeOf(err)}`) };
|
|
58
68
|
}
|
|
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
69
|
}
|
|
70
|
+
const judged = accepted ? new Set(FAMILY) : seedClosure(probes.filter((f) => f.probe.present).map((f) => f.name), (name) => bundles.get(name));
|
|
71
|
+
const files = probes.filter((f) => judged.has(f.name)).map(({ name, rel, probe }) => {
|
|
72
|
+
const bytes = probe.present ? read(join(cwd, rel)) : undefined;
|
|
73
|
+
return { name, rel, bundle: bundles.get(name), state: probe.present ? classifyDeployedScript(bytes, name, bundles.get(name), deps.priors ?? SCRIPT_PRIORS) : 'absent' };
|
|
74
|
+
});
|
|
62
75
|
try {
|
|
63
|
-
return { files, layout: surveyAdrLayoutStrict(cwd, deps) };
|
|
76
|
+
return { files, accepted, layout: surveyAdrLayoutStrict(cwd, deps) };
|
|
64
77
|
} catch (err) {
|
|
65
|
-
return { files, layoutError: causeOf(err) };
|
|
78
|
+
return { files, accepted, layoutError: causeOf(err) };
|
|
66
79
|
}
|
|
67
80
|
};
|
|
68
81
|
|
|
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
82
|
// ── the lines (composed from what HAPPENED: each file's state and the fate of its write) ─────────
|
|
77
83
|
|
|
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` : ''}`}`;
|
|
84
|
+
// A fate is `written`, `stood` (an absent file that appeared with the bundled body), `refused` (its
|
|
85
|
+
// write failed), or none: the run stopped before it, or, dry, would write it.
|
|
86
|
+
const VERBS = { prior: ['refreshed', 'refreshed to the bundled one'], custom: ['replaced', 'replaced by the bundled body'], absent: ['placed', 'placed from the bundled scripts'] };
|
|
87
|
+
const HEADS = { prior: 'matches a body an earlier release shipped', custom: 'differs from every body this kit knows it shipped', absent: 'absent' };
|
|
88
|
+
const fileLine = (f, fate, dryRun) => {
|
|
89
|
+
if (fate === 'stood') return `${f.rel}: appeared while this run was placing it — the bundled body stands, nothing written`;
|
|
90
|
+
const [verb, done] = VERBS[f.state];
|
|
91
|
+
const tail = fate === 'written' ? done : dryRun ? `would be ${done}` : `not ${verb}; ${fate === 'refused' ? 'its write was refused (above)' : 'the run stopped before it'}`;
|
|
92
|
+
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
93
|
};
|
|
91
94
|
const heldLine = (layout) => `${SCRIPTS_DIR}/: ${DECISIONS_GROUP.slice(0, -1).join(', ')} and ${DECISIONS_GROUP.at(-1)} are held back while this project is on the older ADR layout (${layout}) — run the opt-in /agent-workflow-kit migrate-adr-store (it previews, and never commits); the next upgrade judges them`;
|
|
95
|
+
const NOT_ACCEPTED = `${SCRIPTS_DIR}/: the enforcement scripts were not accepted in this project, so no other kit script is placed`;
|
|
96
|
+
// The hook-run line, once after the file lines of a run that wrote (or, dry, would write) a file.
|
|
97
|
+
const hookLine = (accepted, dryRun) => (accepted
|
|
98
|
+
? (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')
|
|
99
|
+
: (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
100
|
const partialNote = (count) => (count > 0 ? [`the writes stopped PARTWAY — the ${count} file(s) named above were already written and are NOT rolled back`] : []);
|
|
93
101
|
|
|
94
102
|
// ── the writes ────────────────────────────────────────────────────────────────────────────────────
|
|
95
103
|
|
|
96
|
-
// One write per file in write order: a prior refreshed
|
|
97
|
-
//
|
|
98
|
-
const writeAll = ({ cwd, files, deps, read
|
|
104
|
+
// One write per file in write order: a prior refreshed and an edit replaced by the atomic write, an
|
|
105
|
+
// absent file written create-only. → { fates, notes, failure? }
|
|
106
|
+
const writeAll = ({ cwd, files, deps, read }) => {
|
|
99
107
|
const fates = new Map();
|
|
100
108
|
const notes = [];
|
|
101
109
|
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
110
|
let result;
|
|
106
111
|
try {
|
|
107
112
|
result = f.state === 'absent'
|
|
@@ -114,6 +119,7 @@ const writeAll = ({ cwd, files, deps, read, bound }) => {
|
|
|
114
119
|
notes.push(...tmpNote(f.rel, result.tmpLeftBehind));
|
|
115
120
|
if (f.state === 'absent' && !result.created) {
|
|
116
121
|
if (classifyDeployedScript(read(join(cwd, f.rel)), f.name, f.bundle) !== 'current') {
|
|
122
|
+
fates.set(f.rel, 'refused');
|
|
117
123
|
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
124
|
}
|
|
119
125
|
fates.set(f.rel, 'stood');
|
|
@@ -122,25 +128,19 @@ const writeAll = ({ cwd, files, deps, read, bound }) => {
|
|
|
122
128
|
return { fates, notes };
|
|
123
129
|
};
|
|
124
130
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const priors = set.filter((f) => f.state === 'prior');
|
|
134
|
-
const { fates, notes, failure } = dryRun ? { fates: new Map(), notes: [] } : writeAll({ cwd, files: priors, deps, read });
|
|
135
|
-
const lines = set.map((f) => (f.state === 'prior' ? fileLine(f, fates.get(f.rel), { dryRun }) : `${f.rel}: ${WAITS}`));
|
|
136
|
-
const written = [...fates.values()].filter((fate) => fate === 'written').length;
|
|
137
|
-
if (failure) return composeFailure(OP, failure[0], failure[1], ...lines, ...notes, ...partialNote(written));
|
|
138
|
-
return composeFailure(OP, 'adr-layout-unverifiable', `${SCRIPTS_DIR}/: the ADR-store layout could not be read (${layoutError}), so the other kit scripts wait for the layout`, ...lines, ...notes);
|
|
131
|
+
// One run over the files it is handed: every one that is not current written in order, its lines,
|
|
132
|
+
// then the hook-run line once when a file was (or, dry, would be) written.
|
|
133
|
+
const writeRun = ({ cwd, files, accepted, dryRun, deps, read }) => {
|
|
134
|
+
const due = files.filter((f) => f.state !== 'current');
|
|
135
|
+
const { fates, notes, failure } = dryRun ? { fates: new Map(), notes: [] } : writeAll({ cwd, files: due, deps, read });
|
|
136
|
+
const written = due.filter((f) => fates.get(f.rel) === 'written');
|
|
137
|
+
const hook = (dryRun ? due.length > 0 : written.length > 0) ? [hookLine(accepted, dryRun)] : [];
|
|
138
|
+
return { due, fates, failure, written, lines: due.map((f) => fileLine(f, fates.get(f.rel), dryRun)), tail: [...hook, ...notes, ...(failure ? partialNote(written.length) : [])] };
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
// ── the op ────────────────────────────────────────────────────────────────────────────────────────
|
|
142
142
|
|
|
143
|
-
export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {}
|
|
143
|
+
export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
144
144
|
const lstat = deps.lstat ?? lstatSync;
|
|
145
145
|
const read = deps.readFile ?? readFileSync;
|
|
146
146
|
const refusal = nodeEvidenceRefusal(OP, cwd, lstat);
|
|
@@ -148,38 +148,27 @@ export const ensureScripts = ({ cwd, kitRoot, dryRun = false, deps = {}, replace
|
|
|
148
148
|
const found = survey({ cwd, kitRoot, deps, read, lstat });
|
|
149
149
|
if (found.refusal) return found.refusal;
|
|
150
150
|
if (found.notPlaced) return composeOutcome(OP, 'not-placed', [`${SCRIPTS_DIR}/: no kit script stands in it, so none is placed`], false);
|
|
151
|
-
|
|
151
|
+
const { files, accepted } = found;
|
|
152
|
+
const declined = accepted ? [] : [NOT_ACCEPTED];
|
|
153
|
+
|
|
154
|
+
// An unreadable layout: on an accepted component the installer set alone is kept current.
|
|
155
|
+
if (found.layoutError !== undefined) {
|
|
156
|
+
const layoutLine = `${SCRIPTS_DIR}/: the ADR-store layout could not be read (${found.layoutError}), so the other kit scripts wait for the layout`;
|
|
157
|
+
const set = accepted ? files.filter((f) => INSTALLER_SET.includes(f.name)) : [];
|
|
158
|
+
const r = writeRun({ cwd, files: set, accepted, dryRun, deps, read });
|
|
159
|
+
if (r.failure) return composeFailure(OP, r.failure[0], r.failure[1], ...r.lines, layoutLine, ...r.tail);
|
|
160
|
+
return composeFailure(OP, 'adr-layout-unverifiable', layoutLine, ...r.lines, ...r.tail);
|
|
161
|
+
}
|
|
152
162
|
|
|
153
|
-
// The survey completed: its entries ride every outcome from here on, a failed one included.
|
|
154
163
|
const held = OLD_ADR_LAYOUTS.has(found.layout);
|
|
155
|
-
const live =
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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]);
|
|
164
|
+
const live = files.filter((f) => !(held && DECISIONS_GROUP.includes(f.name)));
|
|
165
|
+
const current = live.filter((f) => f.state === 'current').length;
|
|
166
|
+
const r = writeRun({ cwd, files: live, accepted, dryRun, deps, read });
|
|
167
|
+
const body = [...r.lines, ...(current > 0 ? [`${SCRIPTS_DIR}/: ${current} other kit scripts are already the bundled body — nothing written`] : []), ...(held ? [heldLine(found.layout)] : []), ...declined];
|
|
168
|
+
if (r.failure) return composeFailure(OP, r.failure[0], r.failure[1], ...body, ...r.tail);
|
|
169
|
+
const landed = (state) => (dryRun ? r.due : r.written).some((f) => f.state === state);
|
|
170
|
+
const token = held ? 'old-adr-layout-migration-instructed'
|
|
171
|
+
: landed('absent') ? (dryRun ? 'would-seed' : 'seeded')
|
|
172
|
+
: landed('prior') || landed('custom') ? (dryRun ? 'would-refresh' : 'refreshed') : 'already-present';
|
|
173
|
+
return composeOutcome(OP, token, [...body, ...r.tail], false);
|
|
185
174
|
};
|
package/tools/ensure-configs.mjs
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
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
|
|
11
12
|
// specs scripts/<spec layer> reader + checker pairs seeded when absent, refreshed only on
|
|
12
13
|
// + docs/ai/specs/index.md a shipped prior body, an edited one replaced only on the
|
|
13
14
|
// user's yes; store root seeded behind a current checker
|
|
@@ -28,10 +29,10 @@
|
|
|
28
29
|
// • The ops run in a FIXED order and one op's failure NEVER skips the rest: every op reports its own
|
|
29
30
|
// token, and the exit is non-zero when any of them failed. The one exception is the replace run
|
|
30
31
|
// (--replace-custom <digest>), which distribution-files/ runs: each edit kept aside, then the
|
|
31
|
-
// owning
|
|
32
|
+
// owning op (specs), then index only when none failed.
|
|
32
33
|
// • 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
|
-
//
|
|
34
|
+
// replace run recomputes: the spec-layer files whose write waits for the user's yes, and the one
|
|
35
|
+
// command for it.
|
|
35
36
|
// • The deployment gate runs ONCE, before any op: an absent/symlinked docs/ai stops the whole run
|
|
36
37
|
// with the gate's own message rather than one copy of it per op.
|
|
37
38
|
//
|
|
@@ -57,7 +58,7 @@ const KIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
57
58
|
// consumer) because the executor, scripts, spec-layer and rules ensures import ensure-ops.mjs for their outcome door and probes.
|
|
58
59
|
export const ENSURE_IMPLEMENTATIONS = Object.freeze({ ...OWN_IMPLEMENTATIONS, executor: ensureExecutor, scripts: ensureScripts, specs: ensureSpecs, rules: ensureRules });
|
|
59
60
|
// The ops whose writes wait for the user's yes and so own the replace run, in ENSURE_OPS order.
|
|
60
|
-
const OWNING_OPS = ['
|
|
61
|
+
const OWNING_OPS = ['specs'];
|
|
61
62
|
|
|
62
63
|
const EXIT_OK = 0;
|
|
63
64
|
const EXIT_FAILED = 1;
|
|
@@ -71,7 +72,7 @@ const REPEATED_ONLY = '--only was passed more than once — this selector names
|
|
|
71
72
|
const unknownOp = (value) => `--only ${value}: no such operation (${ENSURE_OPS.join(' | ')}) — nothing was run`;
|
|
72
73
|
const EMPTY_REPLACE = '--replace-custom needs the digest its replace line printed — an empty value names no file to replace';
|
|
73
74
|
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
|
|
75
|
+
const REPLACE_WITH_ONLY = '--replace-custom runs the spec layer, then the navigator, so it cannot be combined with --only — nothing was run';
|
|
75
76
|
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
77
|
|
|
77
78
|
const HELP = `ensure-configs — the nine stamp-independent upgrade ensures, as ONE command.
|
|
@@ -82,13 +83,12 @@ Usage:
|
|
|
82
83
|
|
|
83
84
|
--reconcile required — run the nine ensures (${ENSURE_OPS.join(', ')})
|
|
84
85
|
--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
|
|
86
|
+
--only <op> run EXACTLY ONE of them (an unknown, missing or repeated value is a usage error)
|
|
87
87
|
--replace-custom <digest>
|
|
88
88
|
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
|
-
--
|
|
89
|
+
digest names is kept aside under .agent-workflow/kept-aside/, then the spec layer
|
|
90
|
+
replaces and places its files, then index runs when nothing failed (not with --only or
|
|
91
|
+
--dry-run; an empty value is a usage error)
|
|
92
92
|
--cwd <dir> the target project (default: the current directory)
|
|
93
93
|
--help, -h this help
|
|
94
94
|
|
|
@@ -105,10 +105,13 @@ the project's own checker judges the navigator and a write it rejects is put bac
|
|
|
105
105
|
The executor ensure writes nothing: a placed .claude/agents/executor.md whose bytes differ from the
|
|
106
106
|
body derived from docs/ai/vehicles.json is pending — the advisor's executor-vehicle.differing item
|
|
107
107
|
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
|
-
|
|
108
|
+
A fifth writes too: once a kit script outside the seed names stands in scripts/, the enforcement-script
|
|
109
|
+
ensure writes every kit script that is not the bundled body, the hook installer and its two suites
|
|
110
|
+
first, with no question and no copy kept: a body a release shipped is refreshed, an edited one replaced
|
|
111
|
+
(its line names where an edit meant to last goes) and an absent one placed; on a project that
|
|
112
|
+
declined the enforcement offer, its standing seed files are kept current the same way, with an
|
|
113
|
+
absent module they import placed, and no other kit script is placed; on an older ADR-store layout
|
|
114
|
+
the decisions files are held back and the opt-in migration is named.
|
|
112
115
|
|
|
113
116
|
Exit codes: 0 every op fine; 1 an op failed (its line says so) or there is no deployment here; 2 usage.`;
|
|
114
117
|
|
|
@@ -171,19 +174,16 @@ const runOne = (op, args) => {
|
|
|
171
174
|
// Run every op in ENSURE_OPS order. A throw from one op becomes THAT op's failed outcome — the
|
|
172
175
|
// remaining ops still run, because a project missing its gate declaration should not also be left
|
|
173
176
|
// 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.
|
|
177
|
+
// the block is the union the replace run recomputes, the entries of the owning op. The replace run is
|
|
178
|
+
// the one exception, handed to runReplace: it keeps every edit aside, runs the owning op, then index
|
|
179
|
+
// only when it did not fail, and its block is non-empty only when the digest no longer matches.
|
|
178
180
|
export const runEnsures = ({ cwd, kitRoot, dryRun, deps, only, replaceCustom }) => {
|
|
179
181
|
if (replaceCustom !== undefined) {
|
|
180
182
|
const owning = OWNING_OPS.map((op) => ({ op, run: (args) => runOne(op, args) }));
|
|
181
183
|
return runReplace({ cwd, kitRoot, digest: replaceCustom, owning, index: (args) => runOne('index', args), deps });
|
|
182
184
|
}
|
|
183
185
|
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 ?? []) };
|
|
186
|
+
return { outcomes, block: outcomes.flatMap((o) => o.entries ?? []) };
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
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.
|
|
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`); 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
|
|
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 {
|
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',
|