@sabaiway/agent-workflow-kit 15.0.0 → 16.0.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 +49 -0
- package/README.md +1 -1
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/contracts.md +5 -4
- package/references/modes/recommendations.md +2 -2
- package/references/modes/rules.md +3 -4
- package/references/modes/upgrade.md +4 -4
- package/tools/distribution-files/index.mjs +1 -2
- package/tools/distribution-files/scripts.mjs +5 -4
- package/tools/ensure-configs.mjs +24 -59
- package/tools/ensure-ops.mjs +4 -5
- package/tools/ensure-specs.mjs +69 -165
- package/tools/ensure-vocabulary.mjs +5 -5
- package/tools/project-rules/rules-ensure.mjs +10 -13
- package/tools/script-priors.mjs +2 -2
- package/tools/upgrade-runlist.mjs +1 -1
- package/tools/distribution-files/kept-aside.mjs +0 -83
- package/tools/distribution-files/replace-set.mjs +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,55 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 16.0.0 — the upgrade writes the spec layer current with no question; `--replace-custom` and the kept-aside copy retire (AD-206)
|
|
8
|
+
|
|
9
|
+
**MAJOR: the `--replace-custom` flag is removed, and the upgrade no longer asks a yes before it writes a spec-layer
|
|
10
|
+
file.** Before, an edited `scripts/spec-schema.mjs`, `scripts/check-docs-size.mjs` or one of their suites was left as
|
|
11
|
+
it stood, the writes that depended on it waited, and the upgrade asked one yes before it kept the edit under
|
|
12
|
+
`.agent-workflow/kept-aside/` and replaced it. Now the four files follow the rule every other kit script follows: on
|
|
13
|
+
every plain run a body an earlier release shipped is refreshed, any other body is replaced in place and an absent file
|
|
14
|
+
is placed, with no question and no copy kept. An edited file's line reads `differs from every body this kit knows it
|
|
15
|
+
shipped — replaced by the bundled body; an edit meant to last goes in a script or suite of your own under its own name
|
|
16
|
+
in scripts/, or a config the script reads`.
|
|
17
|
+
|
|
18
|
+
- **The order stays.** The reader pair, then the checker pair, then the spec store root `docs/ai/specs/index.md`,
|
|
19
|
+
seeded create-only. A write that fails stops every later one, and the step names the files already written.
|
|
20
|
+
- **Nothing waits behind an edit.** The checker pair and the store root no longer wait for a current reader pair or
|
|
21
|
+
checker. The step never reports `customized-preserved`.
|
|
22
|
+
- **One closing line** after a run that wrote a file: `if a commit hook runs the files written above, they may stop
|
|
23
|
+
the next commit`.
|
|
24
|
+
- **`--replace-custom` is gone, with no alias.** `ensure-configs.mjs --reconcile --replace-custom …` now stops with
|
|
25
|
+
`unknown argument`, exit 2, nothing run. The replace block, its command and the upgrade's row 3 yes are gone with it.
|
|
26
|
+
No migration note is owed: the flag only ever ran as the line the kit printed.
|
|
27
|
+
- **`.agent-workflow/` stays reserved.** No kit tool writes there any more; copies an earlier release kept there are
|
|
28
|
+
yours, and nothing deletes them.
|
|
29
|
+
- **The texts say the same.** The upgrade mode's spec-layer paragraph and `specs` token list, the `spec-adoption` notes
|
|
30
|
+
in `references/modes/recommendations.md`, the guide's *Reserved names and channels* (the four spec-layer files now
|
|
31
|
+
among the files written over), and the header and `--help` of `tools/ensure-configs.mjs`. When the navigator ensure
|
|
32
|
+
puts back a navigator the project's own checker rejected, its route now reads `the spec layer's write of the bundled
|
|
33
|
+
modules the project's hook loads, then this step again`.
|
|
34
|
+
|
|
35
|
+
## 15.1.0 — the upgrade writes the kit rules file current with no question; the rules mode no longer moves an edit (AD-205)
|
|
36
|
+
|
|
37
|
+
**`/agent-workflow-kit upgrade` now puts the kit's rules file back to the kit's template, whatever it holds.** Before,
|
|
38
|
+
a `docs/ai/rules/<theme>.md` that differed from every body a release shipped was kept byte for byte and the kit's
|
|
39
|
+
updates to that file waited; a file with no frontmatter was kept and nothing else was written for its theme. Now any
|
|
40
|
+
such body (an edit, a body this kit does not know, a file with no frontmatter) is replaced by the bundled template
|
|
41
|
+
with no question and no copy kept, and the step reports `refreshed`.
|
|
42
|
+
Its line reads `differs from every body this kit knows it shipped — replaced by the bundled template; a rule meant to
|
|
43
|
+
last goes in docs/ai/rules/local/<theme>.md, where it wins`.
|
|
44
|
+
|
|
45
|
+
- **Your own rules live in the local file.** `docs/ai/rules/local/<theme>.md` is never written by the upgrade, and its
|
|
46
|
+
rules win over the kit's. If you edited the kit file, move the edit there before you upgrade.
|
|
47
|
+
- **With a local file, the record is judged against the template.** When the record already holds the merge built
|
|
48
|
+
from the template, replacing an edited kit file writes only that file; otherwise the step reports `pending`, and the
|
|
49
|
+
record command it prints carries the template's digest.
|
|
50
|
+
- **`/agent-workflow-kit rules` offers three routes:** change a rule, drop your local rules, or change a number. The
|
|
51
|
+
route that moved an edit of the kit file into the local file is gone, with the README row's clause about it.
|
|
52
|
+
- **The texts say the same.** The upgrade mode's project-rules paragraph and its `rules` token list (no
|
|
53
|
+
`customized-preserved`), the header and `--help` of `tools/ensure-configs.mjs`, and the guide's *Reserved names and
|
|
54
|
+
channels*, which now names the kit rules files among the files the next upgrade writes over.
|
|
55
|
+
|
|
7
56
|
## 15.0.0 — the opt-in ADR migration mode retires; status names the upgrade for an older ADR layout (AD-204)
|
|
8
57
|
|
|
9
58
|
**MAJOR: `/agent-workflow-kit migrate-adr-store` is gone, with no alias.** Since 14.50.0 the upgrade moves an older
|
package/README.md
CHANGED
|
@@ -252,7 +252,7 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
|
|
|
252
252
|
| `/agent-workflow-kit review-state` | any time | **read-only review-receipt checker** — makes "reviewed ≠ shipped" detectable: the bridge review wrappers append a receipt per successful review (into a file inside the git dir — never committable); this checks that every backend your configured `plan-execution.review` recipe names holds a **fresh, grounded receipt for the current uncommitted tree** (any later edit the payload can see moves the fingerprint and stales the receipt; a review continuation never re-attests a folded tree). `--check` gives a gate exit code to declare in `docs/ai/gates.json` **by hand or via the consent-gated seeder** (preview → your explicit yes; never without consent). `--await [--timeout <s>]` (AD-049) BLOCKS until every recipe-named backend has receipted the current tree — the durable completion signal is the receipt, never a process event — so you wait for the bridges instead of hand-polling. Never writes, never commits, never runs a subscription CLI; it spawns read-only `git` queries to fingerprint the tree — and `git commit --no-verify` stays possible (discipline, not a sandbox). |
|
|
253
253
|
| `/agent-workflow-kit sandbox-masks` | any time | **exclude lane for sandbox masks** — an OS sandbox (Claude Code) masks work-tree paths with a device or, on Linux, a foreign bind mount, as untracked `git status` noise; the review domain already ignores a **device mask** **by construction** (never-committable untracked classes — char/block devices, FIFOs, sockets — are excluded from the fingerprint, the assembled review payload, and the clean checks), while a **mount-only mask** rides the fingerprint and `git add -A` while git does not ignore it (load-bearing there). This mode hides them from `git status` too: flagless = read-only probe (derives the CURRENT mask set from the unfiltered walk + lstat + `/proc/self/mountinfo` — never a frozen list; off Linux the mount signal is not read and it says so, an unreadable or malformed table refuses — and revalidates fenced entries, loudly flagging one that became a real path); `--apply` = consent-gated FULL-BLOCK replace of its own fenced block in `git rev-parse --git-path info/exclude` (stale masks drop by construction; `--clear` always means REMOVE the block — it takes precedence over the derivation). Writes ONLY its fence — never `.gitignore`, never global config; symlinked/non-regular exclude paths and malformed fences fail closed. Watch note: a real file at an excluded path is silently skipped by bulk staging (`git add -A`/`git add .`) — delete the stale line first; the probe flags exactly this case. |
|
|
254
254
|
| `/agent-workflow-kit mcp` | Claude Code · opt-in | **typed-channel registration** — the kit ships a read-only stdio **MCP server** exposing its two promptless readers as TYPED tools (`path_inventory`: exists / type / size / line count / listing / a small file's text, many paths in ONE call; `repo_search`: literal search, the pattern a JSON string). Their arguments are named JSON fields rather than a string handed to a shell, so a pipe, a redirect or a quote inside a pattern or a path stays DATA and is never interpreted — legal bytes to search for, with no shell to read them as operators. Shipping the server does nothing on its own — a client sees it only once the project declares it, and this mode is that declaration: the `agent-workflow` entry in **`.mcp.json`** (command `node`, args = the absolute path of the RUNNING kit's server) plus `enabledMcpjsonServers` and the two derived tool allow rules in **`.claude/settings.json`**. Preview by default and the **exact entry is printed before consent** (registering a server means your client will run that command); `--apply` writes `.mcp.json` FIRST, then settings, merge-don't-clobber with each file's EOL kept, and a re-apply adds nothing twice. An existing `agent-workflow` entry that **structurally differs** from what this kit copy would write is refused unwritten unless `--replace` is given (the comparison ignores key order, so re-serialized identical bytes are the same registration) — silently changing what an MCP server launches is what consent must not slide past. `--replace` prints the entry standing in `.mcp.json` and the entry it would write, and replaces it only with `--apply`. An existing `.mcp.json` or `.claude/settings.json` is written in place: it keeps its inode, never removed or renamed over; an absent file is created. Where an OS sandbox masks `.mcp.json` with a device node, it writes nothing, exits 0 and names the advisor's `mcp-channel` item, which applies the registration by the consent route. The server is a read-only child of your client (no write, no exec API) running outside the Bash sandbox as the client does. Never writes `settings.local.json`; never commits. |
|
|
255
|
-
| `/agent-workflow-kit rules` | any time | **your project rules** — the kit lays down default rules per theme (the first is project layout: where code, tests and specs live) in `docs/ai/rules/<theme>.md`; your own rules go into `docs/ai/rules/local/<theme>.md` and win where they differ. Tell the agent in plain words what to change: it shows the exact text first and writes your local file only on your yes, then rebuilds the effective file `docs/ai/rules/effective/<theme>.md` that agents read (merging your rules over the kit’s by meaning) and checks it is current. It also
|
|
255
|
+
| `/agent-workflow-kit rules` | any time | **your project rules** — the kit lays down default rules per theme (the first is project layout: where code, tests and specs live) in `docs/ai/rules/<theme>.md`; your own rules go into `docs/ai/rules/local/<theme>.md` and win where they differ. Tell the agent in plain words what to change: it shows the exact text first and writes your local file only on your yes, then rebuilds the effective file `docs/ai/rules/effective/<theme>.md` that agents read (merging your rules over the kit’s by meaning) and checks it is current. It also drops your local rules on request. Never commits. |
|
|
256
256
|
| `/agent-workflow-kit grounding` | any time | **grounded-review facts assembler** — mechanizes populating `agy-review --facts @f`: slices your entry-point's **Hard Constraints** section verbatim (exactly one match, else a loud stop) and/or a plan's three canon sections (`## Goal and boundary` + `## Module ledger` + `## Verification`, each required; duplicates stop), under the same byte budget the agy wrapper enforces (minus `--reserve-bytes` for the artifact share), with a loud tail-trim on overflow. `--autonomy` (AD-044) appends the COMPUTED effective autonomy policy from the git-top `docs/ai/autonomy.json` (every red-line + per-activity level, stated source line; absent file → the computed defaults ARE the policy, exit 0; a malformed policy fails CLOSED, exit 1). `--extra <text|@file>` (repeatable) appends your own facts **byte-verbatim** after the mechanical sections, so the merge is a tool input rather than a shell append — an `@file` must sit inside the proven git work tree (never the git dir) or the system temp surface, and is read through a no-follow descriptor (a FIFO cannot block it, a symlink leaf cannot substitute its target). Prints to stdout; `--out` writes **one scratch file only** — system-temp outside the repo ($TMPDIR / /tmp, rewritable) or a **fresh** gitignored in-repo path (create-only, exclusive write; an existing in-repo file, even gitignored, is refused — the `.env` clobber class); tracked, not-ignored-in-repo, other outside-repo, and symlink/non-regular destinations are all refused. Never commits, never runs a subscription CLI. |
|
|
257
257
|
| `/agent-workflow-kit core-evidence` | any time | **the ONE loop-evidence writer** (strip-the-kit) — every core evidence record lands in a single append-only JSONL store inside the git dir (never committable; versioned schema, latest-per-key supersession, byte-identical duplicates refused, malformed lines fail every reader closed). `red-proof "<file>#<pattern>"` declares an observed-red **BEFORE a bugfix** (N/N red runs + content custody + base + the pre-fix fingerprint; green/mixed/timeout are DISTINGUISHED refusals — nothing written); `degrade --backend --reason` is the ONLY escape for an unavailable review backend (per-tree, never all backends); `summary` renders the whole loop state statelessly (gate result · per-backend verdicts · red-proofs · degrades) — no ledger, no rounds, nothing remembered. Honest residual: records are forgeable — self-discipline, not a security boundary. Never commits, never runs a subscription CLI. |
|
|
258
258
|
| `/agent-workflow-kit coverage-check` | any time | **the final-run checker** (D3(c)+(d)) — **certifies coverage ONLY inside the `--final` run that owns the lcov** (ownership is exclusive by CONVENTION over the fixed path, not enforced — a concurrent writer to it is a stated residual, queued as LCOV-EXCLUSIVE-OWNERSHIP): an artifact on disk proves nothing about the tree it came from, so a standalone run prints its findings and states `attested=no` / `NO VERDICT` rather than a PASS (an lcov that predates an edit would otherwise certify a line the suite never executed). `attested=` claims a verdict was ISSUED, pass or fail — a run over uncovered lines still reads `attested=yes` and still exits 1, and a run whose coverage arm never executed (no lcov) reads `attested=no` even inside `--final`, because nothing was read and nothing is certified. The runner passes a nonce whose one-way commitment over `{nonce, fingerprint, base}` is the `final-start.attempt` it recorded; a context describing another tree, or matching no recorded attempt, is a REFUSAL, never a verdict. Findings are unchanged — reads the lcov the declared `unit-tests` gate produced at the FIXED git-dir path and fails on any uncovered CHANGED executable Node line (listed `file:line`; a changed file absent from the map is a file-level red; out-of-domain/unsupported files are LISTED — the claim narrowed honestly); VERIFIES every current-base red-proof declaration (bound test exists · custody hash unchanged · green N/N now · pre-fix fingerprint differs); prints `lcov-sha256=<hex|none>` of the exact bytes it consumed — the sha the `--final` receipt binds and re-hashes. An absent lcov is a LOUD `skipped-no-lcov`; a symlinked path is a refusal. `--check` is the gate exit code — declare it as the LAST gate (`run-gates --final` refuses otherwise). Read-only. |
|
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: '
|
|
6
|
+
version: '16.0.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
package/capability.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.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
|
@@ -45,7 +45,7 @@ diverge:
|
|
|
45
45
|
|
|
46
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.
|
|
47
47
|
|
|
48
|
-
`.agent-workflow/` is the family's reserved folder.
|
|
48
|
+
`.agent-workflow/` is the family's reserved folder. No kit tool writes there: every kit script, the spec layer's four pair files included, is written over with no copy kept. The copies an earlier release kept there are the user's, outside the kit's own paths: no kit tool overwrites, deletes or hides them, and the folder's own `.gitignore` (`*`) an earlier release wrote keeps git from seeing them in either visibility mode. 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 copy there never stands beside the live file in their results.
|
|
49
49
|
|
|
50
50
|
Not in this version: a fully-external hidden mode (artifacts relocated outside the repo tree).
|
|
51
51
|
Deferred to a later release + migration.
|
|
@@ -94,9 +94,10 @@ On `upgrade`, a pre-1.2.0 deployment with no block gets one (the agent asks, def
|
|
|
94
94
|
## Reserved names and channels
|
|
95
95
|
|
|
96
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:
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
customization: every kit script, the spec layer's four pair files (`scripts/spec-schema.mjs`,
|
|
98
|
+
`scripts/spec-schema.test.mjs`, `scripts/check-docs-size.mjs`, `scripts/check-docs-size.test.mjs`)
|
|
99
|
+
included, the hook installer set and the kit rules files `docs/ai/rules/<theme>.md` are written
|
|
100
|
+
over by the next upgrade with no question and no copy kept. A declaration seeded once from a template and never
|
|
100
101
|
replaced by the upgrade's ensures (a migration rewrites one only on the user's explicit yes) is the
|
|
101
102
|
user's own file. A customization goes into one of five channels instead:
|
|
102
103
|
|
|
@@ -17,7 +17,7 @@ Run `node ${CLAUDE_SKILL_DIR}/tools/recommendations.mjs --cwd <project-root> [--
|
|
|
17
17
|
|
|
18
18
|
1. **`--cwd` is REQUIRED** — the target project is explicit, never inferred from the shell's current directory (a subdirectory invocation still advises on the named root).
|
|
19
19
|
2. **Verdict first (present-even-when-empty, opening at the `## Recommendations (agent-workflow)` header).** With everything optimal the body is exactly `no recommendations — flow optimal.` — the empty-state line ALONE is the verdict, zero added lines. Every other state opens the body with ONE verdict line composed from the frozen templates: `{K} item(s) need attention` leads when any item's severity is `attention` (a CONFIGURED declaration that is broken, drifted, degrading or invalid — the deployment needs review); `{N} optional recommendation(s), apply any you want` covers the `optional` class (offers to enable an unconfigured capability), led by `nothing is broken` ONLY when no item needs attention AND no probe check was skipped (a skipped probe could hide an attention-class problem — the claim never overreaches); `optimality NOT attested — {M} probe check(s) skipped` is appended last whenever probe checks were skipped. (The `(s)` invariant form IS the pinned pluralization — no singular/plural branching.) Items render attention-first, each tagged `needs attention:` / `optional:`. A failed probe renders as a stated `⚠ skipped item …` line — never a crash, never a fabricated item.
|
|
20
|
-
3. **The apply-through-agent lane — an explicit informed-consent checkpoint:** the agent applies chat and harness items on the chat yes, harness items by the consent route below. A chat item is never retried outside the sandbox and every failure of a chat step is a STOP. A user item is the user's own step, handed over as worded with its posture note (e.g. `source-size.id-squatter`). After presenting, OFFER to apply; the user selects items in plain language; for each selected item you **surface its posture note inline** where one exists (the per-item notes below cover exactly the risk-marked keys). For a chat item: the user **explicitly confirms**, and **only then** — **no command runs before confirmation** — do you run the rendered command. Do NOT infer safety from the presence or absence of an `--apply` flag: most chat items' rendered command IS the mutation and completes on that one run, **including a no-`--apply` mutation** such as `spec-adoption`'s `ensure-configs --reconcile --only specs` (
|
|
20
|
+
3. **The apply-through-agent lane — an explicit informed-consent checkpoint:** the agent applies chat and harness items on the chat yes, harness items by the consent route below. A chat item is never retried outside the sandbox and every failure of a chat step is a STOP. A user item is the user's own step, handed over as worded with its posture note (e.g. `source-size.id-squatter`). After presenting, OFFER to apply; the user selects items in plain language; for each selected item you **surface its posture note inline** where one exists (the per-item notes below cover exactly the risk-marked keys). For a chat item: the user **explicitly confirms**, and **only then** — **no command runs before confirmation** — do you run the rendered command. Do NOT infer safety from the presence or absence of an `--apply` flag: most chat items' rendered command IS the mutation and completes on that one run, **including a no-`--apply` mutation** such as `spec-adoption`'s `ensure-configs --reconcile --only specs` (it writes an edited spec-layer file with the bundled body with no question, its line naming where an edit meant to last goes). Some items instead render a **dry-run preview** that changes nothing and prints an explicit follow-up `--apply`/mutating command to run NEXT (e.g. the `gates-declaration` seeder): after the SAME confirmation you run that printed follow-up command — no second ask, no improvisation (each writer keeps its own consent semantics: previews, `--apply` flags, refusals) — except profile-gap, whose apply line runs with --apply appended only on a second yes over the relayed preview. For `worktrees-dir` you apply the grant on the chat yes after its check, like every harness item, with no hand step to wait for; its `recipe:` line's `ack-write` preview is the ack fallback, run only on the user's word that the host ignores the settings key, instead of the grant, and against a trusted host NO no ack renders.
|
|
21
21
|
4. Registry strings (benefits + item texts) are frozen tool data, fact-true, ONE line under the pinned shape cap — posture/risk detail lives in the notes below at the consent moment, never inline in the overview. The dual velocity+security wording (`safer — blast radius bounded by the OS sandbox, not human attention`) rides ONLY the items with a real security delta (the autonomy render, the sandbox provisioning); the bridge-wrappers item claims **velocity only**.
|
|
22
22
|
|
|
23
23
|
The **consent route** for a harness item: run its `check:` line in the sandbox and show its result. On the check's `masked:` line, say so and run that same check line once more outside the sandbox, so it re-judges in the apply's own environment; the yes is taken on the outside result. Take the user's yes on that result and run its `apply:` line with that result's digest once, outside the sandbox at once, so the harness asks at the point of action (with the apply ask rule seeded, its own dialog); never another line, never unseen. When velocity-core, kit-tools-tier or bridge-tier is among the user's picks (velocity-core preferred), check, confirm and apply it, or leave it pending, before any other pick's check runs, so its apply seeds the ask rule before the other harness applies. When the harness's auto mode refuses the check or the apply, say so and give the one plain step: leave auto mode for this one action (Shift+Tab in the terminal, the mode indicator in an editor) and say yes, or run `npx @sabaiway/agent-workflow-kit@latest init` in a terminal of your own. On the user's word, run the same line once more when they left auto mode, never another, never unseen; when they ran `init` instead, run the advisor again and offer only what is still pending, each through this route from its check (after a restart `init` asked for, the next session's upgrade does it). When that refusal hits the velocity-core, kit-tools-tier or bridge-tier pick taken first, run no other pick's check until the user answers the plain step. A check that refuses (exit 1) leaves the item unapplied and pending, its result shown; a changed digest (exit 5) applies nothing, shows the new result and asks a new yes. A no, a harness refusal and any other failure of a harness apply leave the item pending with its output shown, and the agent continues. `init`, run in a console from the project's folder, is the route the user may take instead.
|
|
@@ -43,7 +43,7 @@ A variant's posture note, where its key has one, is printed by `init` from this
|
|
|
43
43
|
- `footprint-global` — the agent applies the item on the chat yes after the check, which prints each line it removes; `init` applies it on the terminal y as the route the user may take instead. Another of the user's repositories may rely on the same lines: a no keeps the block, and the item returns at the next run. The apply prints the removed lines as a backup. Risk profile: lines removed from the machine-global excludes file.
|
|
44
44
|
- `mcp-channel` — the offer is to REGISTER the kit's read-only stdio MCP server in this project on the harness lane: a registration is a command your MCP client will RUN. The agent applies it on the chat yes after the check; `init` previews the exact entry and applies it on the terminal y as the route the user may take instead. What the registration buys: path questions and literal searches become typed tool calls whose arguments are named JSON fields instead of a string handed to a shell, so a pipe, a redirect or a quote inside a pattern or a path stays DATA and is never interpreted. Posture: the server is a **read-only child of your client** (path/type/size/line facts and literal search over this project root; no write and no exec API), and like the client itself it runs **outside the Bash sandbox** — the sandbox is not what bounds it, the server's own root containment is. The two allow rules it adds make those two tools promptless and nothing else. The **`.differing`** arm is also a harness item: an `agent-workflow` entry already stands in `.mcp.json` and **structurally differs** from what this kit copy would write (another kit copy, a hand-edited path, an added `env`; the comparison ignores key order, so re-serialized identical bytes are the same registration). The check shows the entry standing in `.mcp.json` and the entry it would write; the chat yes confirms the replacement. `init` previews `mcp --replace` and replaces only on the terminal y. Stated limit: this item does **not** detect a `disabledMcpjsonServers` veto, so a converged `mcp-channel` means *what the mode writes is in place*, not *the client will load it* — see `${CLAUDE_SKILL_DIR}/references/modes/mcp.md`. Risk profile: a new read-only channel your client will launch; no write or exec exposure; a differing registration is replaced only on the checked chat yes or the terminal y and every other declaration is kept.
|
|
45
45
|
- ADDITIONAL `gates-inert` arms (the third outcomes) — two further arms, and they differ in whether anything is BROKEN. **`producer-unrecognized`** — a checker with no producer anywhere in the declaration, on a tracked tree the changed-line coverage domain cannot reach (`.ts`/`.tsx`/`.jsx`/`.mts`/`.cts` strictly outnumber `.mjs`/`.cjs`/`.js`): the dead pair is real, so this arm is a user item, the user's own step, and the two remedies are marking the real producer with `"lcovProducer": true` or dropping the checker. Never a `node --test` prescription, the fill preview or an acknowledgement — a dead pair is broken, not narrow. **`coverage-domain-narrow`** — the producer/checker pair IS live and the tree is still dominated by what the domain excludes: nothing is broken, and the honest sentence is that certification covers the assessable minority. Its apply is the consent-gated **ack writer** preview (a NEUTRAL fingerprint into `docs/ai/acks.json` as `coverageDomainAck`, never a security key); after the SAME confirmation you run the `--apply` it prints. The fingerprint binds the FACT — the verdict plus the unsupported extensions present, never the file counts — so an acknowledged project stays quiet as it grows and re-fires when a new unsupported language arrives or the verdict flips. The census reads the TRACKED tree with a read-only `git ls-files`; a tree it cannot read (a non-git deployment) becomes a stated skip. Risk profile: no enforcement change of any kind — one acknowledgement recorded in a family-owned file, and one edit that is the user's own step.
|
|
46
|
-
- `spec-adoption` — the feature-spec layer's ADOPTION STATE, judged from `docs/ai/specs/` alone through the same census `spec-check --all` runs, so a store the checker would refuse to observe is never counted here either. Both arms are OFFERS (`optional`) — the layer is opt-in, and `attention` stays reserved for a configured declaration that is broken. **`not-adopted`** (no store): every plan then cites zero governing specs by default and nothing says adoption never started; its apply is the spec-layer ensure one-liner (`ensure-configs --reconcile --only specs`, the same seed `upgrade` runs — it seeds the reader/checker pairs and the store root, and skips with a stated reason where no Node evidence exists), and its `recipe:` line carries the decline alternative — the DECLINE preview (`ack-write --lane spec-adoption`, a dry-run that prints the exact `--apply`), which records `specAdoptionAck` in the family-owned `docs/ai/acks.json`. **The two are exclusive, and the order is part of the contract:** ask which the user wants, apart, BEFORE the confirmation; on "seed" run the apply; on "decline" the agent records it — the preview line, then on that same answer its printed `--apply`; never run the seed after a decline, nor the decline after the seed. **`adopting`** (a store with no live contract): an optional item naming the draft count; its apply is that same decline preview (a dry-run; after the SAME confirmation you run the `--apply` it prints), and the honest remedy is authoring a contract from the skill's `SPEC_TEMPLATE.md`. A recorded decline silences BOTH arms and shows on `status` as ` — declined`; one live contract makes the decline moot. An unreadable store is a stated skip, never `flow optimal`. Risk profile: the seed writes create-only files under `scripts/` and `docs/ai/specs/` and refreshes a script body a release shipped;
|
|
46
|
+
- `spec-adoption` — the feature-spec layer's ADOPTION STATE, judged from `docs/ai/specs/` alone through the same census `spec-check --all` runs, so a store the checker would refuse to observe is never counted here either. Both arms are OFFERS (`optional`) — the layer is opt-in, and `attention` stays reserved for a configured declaration that is broken. **`not-adopted`** (no store): every plan then cites zero governing specs by default and nothing says adoption never started; its apply is the spec-layer ensure one-liner (`ensure-configs --reconcile --only specs`, the same seed `upgrade` runs — it seeds the reader/checker pairs and the store root, and skips with a stated reason where no Node evidence exists), and its `recipe:` line carries the decline alternative — the DECLINE preview (`ack-write --lane spec-adoption`, a dry-run that prints the exact `--apply`), which records `specAdoptionAck` in the family-owned `docs/ai/acks.json`. **The two are exclusive, and the order is part of the contract:** ask which the user wants, apart, BEFORE the confirmation; on "seed" run the apply; on "decline" the agent records it — the preview line, then on that same answer its printed `--apply`; never run the seed after a decline, nor the decline after the seed. **`adopting`** (a store with no live contract): an optional item naming the draft count; its apply is that same decline preview (a dry-run; after the SAME confirmation you run the `--apply` it prints), and the honest remedy is authoring a contract from the skill's `SPEC_TEMPLATE.md`. A recorded decline silences BOTH arms and shows on `status` as ` — declined`; one live contract makes the decline moot. An unreadable store is a stated skip, never `flow optimal`. Risk profile: the seed writes create-only files under `scripts/` and `docs/ai/specs/` and refreshes a script body a release shipped; it writes an edited spec-layer file with the bundled body with no question, its line naming where an edit meant to last goes; the decline writes one key into the ack store; nothing here authors a spec or blocks a plan.
|
|
47
47
|
- `profile-gap` — each item's apply is a PREVIEW that writes nothing, and consent takes two steps: the confirmed pick runs the preview and you relay every line it prints (the environment-resolved slot values, each checker `entry:` line with its trust-chain disclosure, a Communication region the insert plans in the same run); the same line with ` --apply` appended runs only on a SECOND yes over those lines, never carried by the first. Items whose apply lines are byte-equal are one writer and take one answer: the tier preview's `--apply` writes the absent slots, the store seed and the queue seed together; the checker verb writes only its own entries; the insert writes every region it plans, all or nothing, so a `communication-absent` skip beside a declined `story-sessions-section` gets its own ask after the insert's full preview. A no records nothing and the item stays on the screen. A DECLINE is asked apart from later, before anything runs, and runs `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --decline --cwd <project-root>` only when the user refuses EVERY item the tier preview then reports offered: it records each of them at the shipped lineage, and a declined item leaves the screen until a lineage step changes the profile. An undecidable entry is a stated skip naming its reason, the remedy by reason: a prior → the upgrade's `lens` reconcile; an absent region → the insert; a customized region → a hand edit only (the lens preserves it), so that skip stands and withholds `flow optimal`. Risk profile: the tier preview's `--apply` rewrites `docs/ai/orchestration.json` in canonical form with the `_README` note and creates `docs/ai/epics/.gitkeep` and `docs/plans/queue.md` create-only; the insert adds regions to `docs/ai/agent_rules.md`; the checker verb adds entries to the PRIVILEGED `docs/ai/gates.json`; the decline writes `docs/ai/profile-declines.json`; nothing here commits.
|
|
48
48
|
- `jev-connect` — the lane is user and env-dependent: the connect command is the user's own step in a terminal of their own, where it asks for the key; the key never reaches the agent or the chat (the command refuses without a terminal, and a terminal is not consent). When the recipe line opens with `run the apply in <place>`, that place is the terminal to run it in; `init`, run there, offers the command on its own consent line. The command reads the key with no echo, makes one network call to api.typesafe.ai with the vendor's sample text only on the user's own run, and writes the key in plain text — as managed export lines in the shell's startup files (bash: ~/.bashrc and the login file, created as ~/.bash_profile when none exists; zsh: ~/.zshrc), as the kit's own file ~/.config/fish/conf.d/typesafe-api-key.fish for fish, or on Windows as the user environment variable TYPESAFE_API_KEY, stored in the Windows user environment; a process already running at the save can keep its old environment and hand it to what it starts — the guide's key mark confirms the agent sees it (a file is readable by any process running as that user, and by other local accounts when one is world-readable in a traversable home); the vendor keeps data under its processing agreement and offers zero retention only to enterprise accounts. The item reads the environment the agent's commands run in: a host setting that filters it shows the item while the key is set in the user's shell. The decline alternative rides the recipe line, asked apart BEFORE the confirmation (the `spec-adoption` order): on "connect" hand over the apply line; on "decline" the agent records it — the recipe line's preview, then its printed `--apply` — per project as `jevConnectAck` in `docs/ai/acks.json`. Risk profile: a plain-text key in the user's startup files or the Windows user environment, written by a command the user runs; one network call from that run.
|
|
49
49
|
- `jev-skill` — the lane is harness; both `jev-skill` and `jev-skill.earlier` are env-dependent: the agent applies the item on the chat yes after the check, showing the files it would write; it changes no harness setting. `init` applies it on the batch terminal yes as the route the user may take instead. When the recipe line opens with `run the apply in <place>`, that place is where a user who prefers their own terminal runs it. The skill is third-party text — the vendor's, MIT — that the kit ships pinned and installs as a verified copy into three agent skill roots: `~/.agents/skills`, the Claude Code skills dir (`CLAUDE_CONFIG_DIR` or `~/.claude`) and `~/.gemini/config/skills`. It is never updated silently: a copy at an earlier pin is replaced only by that command, and a foreign copy is left untouched and named on the recipe line. A copy the vendor's `skills` CLI wrote with the same bytes reads current, and a later pin move replaces it like a kit copy; a vendor plugin install is invisible to the file check, so the Claude Code root may read absent while the plugin serves it. Only when the user asks to see the plan does the agent run the command without `--apply` (a read-only dry run). The decline alternative rides the recipe line, asked apart BEFORE the confirmation: on "install" run the check line and, on the yes given on its result, the apply line by the consent route; on "decline" the agent records it — the recipe line's preview, then its printed `--apply` — per project as `jevSkillAck` in `docs/ai/acks.json`. Risk profile: third-party text written into the user's agent skill roots by the kit's skill command; no network.
|
|
@@ -8,17 +8,16 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/command-shapes.md
|
|
|
8
8
|
|
|
9
9
|
**1. Start with the ensure.** Run `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only rules --cwd <project>` and relay its line in plain words. The effective file is built, never written by hand: this mode moves no edit out of it, and the ensure's rebuild or the next merge replaces one.
|
|
10
10
|
|
|
11
|
-
**2. Do what the user asks — one of
|
|
11
|
+
**2. Do what the user asks — one of three.**
|
|
12
12
|
|
|
13
13
|
- **Change a rule.** The user says in plain words what to change. Show the exact text you will write to `docs/ai/rules/local/<theme>.md`, its frontmatter included, holding only the user's own rules and never a copy of the kit's, and write it on the user's yes. That request and that yes are the consent for the write of the local file.
|
|
14
|
-
- **Move an edit of the kit file.** When an ensure line for the kit file says it `carries your edit`, whatever token the run printed (`pending` and `regenerated` included), offer the move: compare `docs/ai/rules/<theme>.md` with the bundled `${CLAUDE_SKILL_DIR}/references/rules/<theme>.md`, write the user's changes, by meaning, into the local file (shown first, written on the yes), then delete the kit file. The next ensure seeds it again from the template, so the kit file keeps its one writer.
|
|
15
14
|
- **Drop the local rules.** On the user's request, delete the local file; the next ensure rebuilds the effective file from the kit file and records it.
|
|
16
15
|
- **Change a number.** A request to change a number, a limit's value or its tolerance, is never written into a rules file: the rules are prose and carry no numbers; the kit keeps its numbers in its code, and a project's own number is a reasoned override in the size check's config. Show the exact `node ${CLAUDE_SKILL_DIR}/tools/source-size-check.mjs --override <id> [--value <n>] [--tolerance <p>] --reason "<text>" --cwd <project>` command, passing only the numbers the user named (an option left out keeps the limit's current value or tolerance; `files-per-root` takes `--tolerance` only), with `--kit-default` in their place to return to the kit's numbers; run it on the user's yes and relay its lines. This route ends there: it runs no ensure, merge, record or closing check.
|
|
17
16
|
|
|
18
|
-
**3. After each of the
|
|
17
|
+
**3. After each of the two rules routes, run the ensure again.** On `pending`, do the merge its line states, show the user what changed in the final rules, then run the record command the line prints with the sha256 of the merged file (one plain command for the digest, per the shared command-shapes contract).
|
|
19
18
|
|
|
20
19
|
**It stops on a refusal.** When an ensure run answers `failed`, the record command exits non-zero, or the `--override` command exits non-zero, relay the line and stop: write, delete and record nothing further, and run no closing check as if the change held.
|
|
21
20
|
|
|
22
21
|
**4. End with the checks.** Run `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>`, then `node ${CLAUDE_SKILL_DIR}/tools/project-rules/rules-cli.mjs --check --cwd <project>`, which answers `current` for every theme; relay both in plain words.
|
|
23
22
|
|
|
24
|
-
**What it never does.** It never writes the effective file except with the merge a `pending` line states, never changes the kit file's text
|
|
23
|
+
**What it never does.** It never writes the effective file except with the merge a `pending` line states, never changes the kit file's text, and never writes a local file without the user's 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` / `failed
|
|
15
|
+
3. `configs` — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --cwd <project>` → one line per ensure: `seeded` / `note-refreshed` / `refreshed` / `regenerated` / `pending` / `already-current` / `customized-preserved` / `malformed-preserved` / `already-present` / `not-placed` / `skipped-no-node-evidence` / `failed`.
|
|
16
16
|
4. `gates-migration` — `node ${CLAUDE_SKILL_DIR}/references/scripts/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>` → the preview plan · INERT checker · CUSTOMIZED entries, each named — consent: apply only on an explicit yes, re-run with `--apply`.
|
|
17
17
|
5. `bridges` — `node ${CLAUDE_SKILL_DIR}/tools/setup-backends.mjs --refresh-placed` → per-bridge lines: refreshed · already current · skipped — with its stated reason (not placed / newer than the bundle / unsupported host) · `skipped-readonly` · could not refresh.
|
|
18
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, 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` / `
|
|
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` / `skipped-no-node-evidence`; rules → `seeded` / `refreshed` / `regenerated` / `pending` / `already-current`; index → `regenerated` / `already-current` / `customized-preserved`; and any ensure may report `failed`, whose line OPENS with the cause (relay it with that cause — never soften it into a skip; an op that copies file by file also states when it stopped partway). The cause vocabulary is CLOSED — one of `race-unresolved`, `template-unreadable`, `bundle-unreadable`, `adr-store-not-current`, `node-evidence-unverifiable`, `wrong-node-kind`, `vehicle-settings-unreadable`, `write-refused`, `unexpected-error`, `generator-unlaunchable`, `generator-failed`, `index-probe-failed`, `index-stale-after-write` — and every cause that can only arise AFTER the generator ran (`generator-failed`, and `index-probe-failed` / `index-stale-after-write` when they follow a reported regeneration) DISCLOSES in its own line that a write may already have landed. **A non-zero exit STOPs this upgrade** — before the equal-head exit, the migrations and the re-stamp. Add `--dry-run` to preview without writing a byte. Like the pointer slots + the footprint reconcile, all nine reach an equal-head deployment **without a lineage-head bump or a migration file**.
|
|
37
37
|
|
|
38
38
|
**What the orchestration-config ensure does.** `docs/ai/orchestration.json` must exist **and its onboarding note must be current**: created from the canonical seed if missing; if it already exists, **every activity/slot the user set is preserved** and ONLY the `_README` note is refreshed, and only when the existing one still matches a known prior canonical — `refreshIfCanonical` / `refreshReadme` in `tools/orchestration-config.mjs` decide it (CRLF/whitespace normalized first; a *customized* `_README` is preserved verbatim → `customized-preserved`; a *malformed* existing config is **preserved untouched + LOUD** → `malformed-preserved`, never clobbered and never silently skipped). The current note points at `/agent-workflow-kit set-recipe`. **Kit-owned:** in the **delegated** path memory only seeds/preserves the file (memory upgrade step 2) and this ensure applies the `_README` refresh; in the **fallback** path it does both. (Memory stays standalone.)
|
|
39
39
|
|
|
@@ -47,9 +47,9 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
47
47
|
|
|
48
48
|
**What the navigator ensure does.** `docs/ai/index.md` is the always-loaded navigator the entry point declares, and it is GENERATED — no template ships it, so a deployment that never ran the generator boots from a broken entry point (and a Node project's hook fails its index check). The ensure runs the bundled generator's finalizer and reports `regenerated` (it was missing or stale — it was written) or `already-current` (nothing written); under a hook module that is not the bundled one, a write the project's own checker rejects is put back → `customized-preserved`. It never skips a No-Node project: the generator runs from `${CLAUDE_SKILL_DIR}/references/scripts/` on the agent host, not from the project's `scripts/`. **Its position in the run-list is EARLY and therefore NOT authoritative** — `lens` (and, on the migrated path, steps 6–7) still change `docs/ai` afterwards — so the authoritative run is the LATE `--only index` rung documented at both exits; the early one is idempotent: an untouched tree changes nothing.
|
|
49
49
|
|
|
50
|
-
**What the spec-layer ensure does.** A deployment older than the feature-spec layer lacks `scripts/spec-schema.mjs` and `docs/ai/specs/index.md`, and its deployed `check-docs-size.mjs` predates the store collapse.
|
|
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. The four pair files follow the enforcement-script rule, with no question and no copy kept: a shipped prior is refreshed (an append-only digest catalog), an edited body replaced (its line names where a lasting edit goes), an absent file placed, the current body left. In ONE order: the reader pair, then the checker pair, then the store root, seeded create-only from the bundled template, date rendered — an older checker renders the store row by row and reds the hook's `--check-index`, so the checker is written first, and a write that fails stops every later one. A closing line says a commit hook that runs the files written may stop the next commit. One token by precedence: `seeded` > `refreshed` > `already-present`; `skipped-no-node-evidence` only when neither a root `package.json` nor any kit-seeded `scripts/*.mjs` is present (the same Node-evidence probe the enforcement-script ensure uses; an unreadable probe is `failed` / `node-evidence-unverifiable`). **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline the agent records), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
|
|
51
51
|
|
|
52
|
-
**What the project-rules ensure does.** Each theme's kit file `docs/ai/rules/<theme>.md` is seeded, refreshed
|
|
52
|
+
**What the project-rules ensure does.** Each theme's kit file `docs/ai/rules/<theme>.md` is seeded, refreshed from a body a release shipped, and any other body replaced by the template with no question and no copy kept, its line naming the local rules file `docs/ai/rules/local/<theme>.md` for a rule meant to last; 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.
|
|
53
53
|
|
|
54
54
|
**`gates-migration` — legacy gates.json migration (consented preview — D8).** An EXISTING declaration may still carry the retired review-ledger / fold-completeness checks. Run the preview (dry-run — writes NOTHING), show the user the exact plan, and only on an explicit yes re-run it with `--apply`: canonical legacy entries (matched by their documented single-invocation cmd forms) are REMOVED, the canonical `unit-tests` cmd gains the built-in lcov reporters, and the coverage-check gate is ADDED last — atomic and COMPLETE, so the migrated declaration satisfies `run-gates --final`. **The checker rides a PRODUCER or is not declared at all** (`${CLAUDE_SKILL_DIR}/references/modes/gates.md`): with no gate producing the lcov it reads, the migration does NOT add it, an already-declared one is reported INERT, the result is not called final-run-capable, and the preview prints the paste-ready suite cmd to declare by hand — nothing is ever removed for you. CUSTOMIZED entries are NEVER auto-touched: the preview names each with a paste-ready recovery, and the commit guard must NOT be installed until they are resolved. Of step 3's run-list, only this migration and `tools/checker-gates.mjs` under the `tier` ask change an existing gates.json (the FILL preview runs at init).
|
|
55
55
|
|
|
@@ -2,5 +2,4 @@
|
|
|
2
2
|
// import, each the very export of the leaf that owns it. No kit module outside this directory
|
|
3
3
|
// imports a leaf directly.
|
|
4
4
|
|
|
5
|
-
export {
|
|
6
|
-
export { SCRIPT_CHANNEL, ensureScripts } from './scripts.mjs';
|
|
5
|
+
export { SCRIPT_CHANNEL, ensureScripts, fileLine, hookLine } from './scripts.mjs';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// question and no copy kept; a current one is left. The installer set is written first; after the last
|
|
6
6
|
// write the project's own rotator brings the ADR store current (`--ensure-current`). It never imports
|
|
7
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.
|
|
8
|
+
// ensure-specs.mjs takes its channel and its lines from there.
|
|
9
9
|
//
|
|
10
10
|
// Dependency-free, Node >= 22. Every fs primitive and the spawn are injectable (deps.*). No side effects on import.
|
|
11
11
|
|
|
@@ -76,10 +76,11 @@ const survey = ({ cwd, kitRoot, deps, read, lstat }) => {
|
|
|
76
76
|
// ── the lines (composed from what HAPPENED: each file's state and the fate of its write) ─────────
|
|
77
77
|
|
|
78
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.
|
|
79
|
+
// write failed), or none: the run stopped before it, or, dry, would write it. The spec layer's pair
|
|
80
|
+
// lines are these too, through the module's index.
|
|
80
81
|
const VERBS = { prior: ['refreshed', 'refreshed to the bundled one'], custom: ['replaced', 'replaced by the bundled body'], absent: ['placed', 'placed from the bundled scripts'] };
|
|
81
82
|
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
|
+
export const fileLine = (f, fate, dryRun) => {
|
|
83
84
|
if (fate === 'stood') return `${f.rel}: appeared while this run was placing it — the bundled body stands, nothing written`;
|
|
84
85
|
const [verb, done] = VERBS[f.state];
|
|
85
86
|
const tail = fate === 'written' ? done : dryRun ? `would be ${done}` : `not ${verb}; ${fate === 'refused' ? 'its write was refused (above)' : 'the run stopped before it'}`;
|
|
@@ -87,7 +88,7 @@ const fileLine = (f, fate, dryRun) => {
|
|
|
87
88
|
};
|
|
88
89
|
const NOT_ACCEPTED = `${SCRIPTS_DIR}/: the enforcement scripts were not accepted in this project, so no other kit script is placed`;
|
|
89
90
|
// 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
|
+
export const hookLine = (accepted, dryRun) => (accepted
|
|
91
92
|
? (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
93
|
: (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'));
|
|
93
94
|
const partialNote = (count) => (count > 0 ? [`the writes stopped PARTWAY — the ${count} file(s) named above were already written and are NOT rolled back`] : []);
|
package/tools/ensure-configs.mjs
CHANGED
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
// + the installer set written with no question and no copy kept; installer set first; on a
|
|
11
11
|
// declined offer only the standing seed files and the modules they import;
|
|
12
12
|
// then the project's rotator brings the ADR store current (--ensure-current)
|
|
13
|
-
// specs scripts/<spec layer> reader + checker pairs
|
|
14
|
-
// + docs/ai/specs/index.md a shipped prior
|
|
15
|
-
//
|
|
16
|
-
// rules docs/ai/rules/<theme>.md the kit file seeded,
|
|
17
|
-
// + effective/ + sources.json
|
|
18
|
-
//
|
|
13
|
+
// specs scripts/<spec layer> reader + checker pairs, with no question and no copy kept:
|
|
14
|
+
// + docs/ai/specs/index.md a shipped prior refreshed, an edited one replaced, an absent
|
|
15
|
+
// one placed; then the store root seeded create-only
|
|
16
|
+
// rules docs/ai/rules/<theme>.md the kit file seeded, refreshed on a shipped prior body, or any
|
|
17
|
+
// + effective/ + sources.json other body replaced, with no question and no copy kept; with no
|
|
18
|
+
// local file the effective copy and its record rebuilt; with one
|
|
19
|
+
// the merge an agent does is named, never done
|
|
19
20
|
// index docs/ai/index.md regenerate-if-missing-or-stale (a GENERATED artifact); under
|
|
20
21
|
// a project hook module that is not the bundled one, a write
|
|
21
22
|
// the project's own checker rejects is put back
|
|
@@ -28,12 +29,7 @@
|
|
|
28
29
|
// • --reconcile is REQUIRED. A bare run is a usage error, so nothing writes by accident.
|
|
29
30
|
// • --dry-run reports `would-*` tokens and writes nothing — never a write token.
|
|
30
31
|
// • The ops run in a FIXED order and one op's failure NEVER skips the rest: every op reports its own
|
|
31
|
-
// token, and the exit is non-zero when any of them failed.
|
|
32
|
-
// (--replace-custom <digest>), which distribution-files/ runs: each edit kept aside, then the
|
|
33
|
-
// owning op (specs), then index only when none failed.
|
|
34
|
-
// • ONE replace block, after every op's lines and before the failure footer, over the union the
|
|
35
|
-
// replace run recomputes: the spec-layer files whose write waits for the user's yes, and the one
|
|
36
|
-
// command for it.
|
|
32
|
+
// token, and the exit is non-zero when any of them failed.
|
|
37
33
|
// • The deployment gate runs ONCE, before any op: an absent/symlinked docs/ai stops the whole run
|
|
38
34
|
// with the gate's own message rather than one copy of it per op.
|
|
39
35
|
//
|
|
@@ -51,15 +47,13 @@ import { ensureExecutor } from './ensure-executor.mjs';
|
|
|
51
47
|
import { ENSURE_OPS, OWN_IMPLEMENTATIONS, failedOutcome } from './ensure-ops.mjs';
|
|
52
48
|
import { ensureSpecs } from './ensure-specs.mjs';
|
|
53
49
|
import { ensureRules } from './project-rules/index.mjs';
|
|
54
|
-
import { ensureScripts
|
|
50
|
+
import { ensureScripts } from './distribution-files/index.mjs';
|
|
55
51
|
|
|
56
52
|
const KIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
57
53
|
|
|
58
54
|
// The op table this CLI walks — name → implementation, in ENSURE_OPS order. Composed HERE (the one
|
|
59
55
|
// consumer) because the executor, scripts, spec-layer and rules ensures import ensure-ops.mjs for their outcome door and probes.
|
|
60
56
|
export const ENSURE_IMPLEMENTATIONS = Object.freeze({ ...OWN_IMPLEMENTATIONS, executor: ensureExecutor, scripts: ensureScripts, specs: ensureSpecs, rules: ensureRules });
|
|
61
|
-
// The ops whose writes wait for the user's yes and so own the replace run, in ENSURE_OPS order.
|
|
62
|
-
const OWNING_OPS = ['specs'];
|
|
63
57
|
|
|
64
58
|
const EXIT_OK = 0;
|
|
65
59
|
const EXIT_FAILED = 1;
|
|
@@ -71,36 +65,27 @@ const EMPTY_CWD = '--cwd needs a path argument (an empty value would silently me
|
|
|
71
65
|
const EMPTY_ONLY = `--only needs one operation name (${ENSURE_OPS.join(' | ')}) — an empty value would silently widen the run`;
|
|
72
66
|
const REPEATED_ONLY = '--only was passed more than once — this selector names exactly ONE operation';
|
|
73
67
|
const unknownOp = (value) => `--only ${value}: no such operation (${ENSURE_OPS.join(' | ')}) — nothing was run`;
|
|
74
|
-
const EMPTY_REPLACE = '--replace-custom needs the digest its replace line printed — an empty value names no file to replace';
|
|
75
|
-
const REPEATED_REPLACE = '--replace-custom was passed more than once — a replace run carries exactly ONE digest';
|
|
76
|
-
const REPLACE_WITH_ONLY = '--replace-custom runs the spec layer, then the navigator, so it cannot be combined with --only — nothing was run';
|
|
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";
|
|
78
68
|
|
|
79
69
|
const HELP = `ensure-configs — the nine stamp-independent upgrade ensures, as ONE command.
|
|
80
70
|
|
|
81
71
|
Usage:
|
|
82
72
|
node ensure-configs.mjs --reconcile [--dry-run] [--only <op>] [--cwd <project>]
|
|
83
|
-
node ensure-configs.mjs --reconcile --replace-custom <digest> [--cwd <project>]
|
|
84
73
|
|
|
85
74
|
--reconcile required — run the nine ensures (${ENSURE_OPS.join(', ')})
|
|
86
75
|
--dry-run report what each ensure WOULD do; write nothing
|
|
87
76
|
--only <op> run EXACTLY ONE of them (an unknown, missing or repeated value is a usage error)
|
|
88
|
-
--replace-custom <digest>
|
|
89
|
-
the replace run the replace block prints, run only on the user's yes: every edit its
|
|
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)
|
|
93
77
|
--cwd <dir> the target project (default: the current directory)
|
|
94
78
|
--help, -h this help
|
|
95
79
|
|
|
96
80
|
Every SEED is CREATE-ONLY: an existing file is preserved byte-for-byte, never clobbered and never
|
|
97
81
|
refreshed in place. Four ops refresh instead: the orchestration onboarding note, only while it still
|
|
98
82
|
matches a canonical the kit shipped (your own wording is preserved verbatim); the spec-layer reader
|
|
99
|
-
and checker pairs,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
kit file,
|
|
103
|
-
file rebuilt as its copy and recorded where no local file
|
|
83
|
+
and checker pairs, with no question and no copy kept: a body a release shipped is refreshed, an
|
|
84
|
+
edited one replaced (its line names where an edit meant to last goes) and an absent one placed,
|
|
85
|
+
the reader pair, then the checker pair, then the spec store root seeded create-only; the project rules
|
|
86
|
+
kit file, refreshed while its bytes are a body a release shipped and any other body replaced by the template,
|
|
87
|
+
with no question and no copy kept, the effective file rebuilt as its copy and recorded where no local file
|
|
88
|
+
exists; and the navigator index — a GENERATED artifact, regenerated
|
|
104
89
|
whenever it is missing or stale; where a module the project's hook loads is not the bundled one,
|
|
105
90
|
the project's own checker judges the navigator and a write it rejects is put back byte for byte.
|
|
106
91
|
The executor ensure writes nothing: a placed .claude/agents/executor.md whose bytes differ from the
|
|
@@ -119,7 +104,7 @@ Exit codes: 0 every op fine; 1 an op failed (its line says so) or there is no de
|
|
|
119
104
|
// argv → { reconcile, dryRun, cwd, help }. Order-independent; an unknown flag or a missing --cwd
|
|
120
105
|
// value is a usage error, never a silently-ignored argument.
|
|
121
106
|
export const parseArgs = (argv) => {
|
|
122
|
-
const out = { reconcile: false, dryRun: false, cwd: undefined, only: undefined,
|
|
107
|
+
const out = { reconcile: false, dryRun: false, cwd: undefined, only: undefined, help: false };
|
|
123
108
|
for (let i = 0; i < argv.length; i += 1) {
|
|
124
109
|
const a = argv[i];
|
|
125
110
|
if (a === '--help' || a === '-h') out.help = true;
|
|
@@ -136,13 +121,6 @@ export const parseArgs = (argv) => {
|
|
|
136
121
|
if (!ENSURE_OPS.includes(value)) throw fail(EXIT_USAGE, unknownOp(value));
|
|
137
122
|
out.only = value;
|
|
138
123
|
if (!inline) i += 1;
|
|
139
|
-
} else if (a === '--replace-custom' || a.startsWith('--replace-custom=')) {
|
|
140
|
-
if (out.replaceCustom !== undefined) throw fail(EXIT_USAGE, REPEATED_REPLACE);
|
|
141
|
-
const inline = a.startsWith('--replace-custom=');
|
|
142
|
-
const value = inline ? a.slice('--replace-custom='.length) : argv[i + 1];
|
|
143
|
-
if (value === undefined || value === '' || (!inline && value.startsWith('-'))) throw fail(EXIT_USAGE, EMPTY_REPLACE);
|
|
144
|
-
out.replaceCustom = value;
|
|
145
|
-
if (!inline) i += 1;
|
|
146
124
|
} else if (a === '--cwd') {
|
|
147
125
|
// An EMPTY value resolves to the ambient cwd — a writing CLI would then act on a different
|
|
148
126
|
// project than the caller named, silently. Both spellings refuse it.
|
|
@@ -159,8 +137,6 @@ export const parseArgs = (argv) => {
|
|
|
159
137
|
if (!out.help && !out.reconcile) {
|
|
160
138
|
throw fail(EXIT_USAGE, 'nothing to do — pass --reconcile (see --help). This tool never writes without it.');
|
|
161
139
|
}
|
|
162
|
-
if (out.replaceCustom !== undefined && out.only !== undefined) throw fail(EXIT_USAGE, REPLACE_WITH_ONLY);
|
|
163
|
-
if (out.replaceCustom !== undefined && out.dryRun) throw fail(EXIT_USAGE, REPLACE_WITH_DRY_RUN);
|
|
164
140
|
return out;
|
|
165
141
|
};
|
|
166
142
|
|
|
@@ -174,30 +150,19 @@ const runOne = (op, args) => {
|
|
|
174
150
|
|
|
175
151
|
// Run every op in ENSURE_OPS order. A throw from one op becomes THAT op's failed outcome — the
|
|
176
152
|
// remaining ops still run, because a project missing its gate declaration should not also be left
|
|
177
|
-
// without its autonomy seed just because the first ensure hit an unreadable file. →
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// only when it did not fail, and its block is non-empty only when the digest no longer matches.
|
|
181
|
-
export const runEnsures = ({ cwd, kitRoot, dryRun, deps, only, replaceCustom }) => {
|
|
182
|
-
if (replaceCustom !== undefined) {
|
|
183
|
-
const owning = OWNING_OPS.map((op) => ({ op, run: (args) => runOne(op, args) }));
|
|
184
|
-
return runReplace({ cwd, kitRoot, digest: replaceCustom, owning, index: (args) => runOne('index', args), deps });
|
|
185
|
-
}
|
|
186
|
-
const outcomes = (only ? [only] : ENSURE_OPS).map((op) => runOne(op, { cwd, kitRoot, dryRun, deps }));
|
|
187
|
-
return { outcomes, block: outcomes.flatMap((o) => o.entries ?? []) };
|
|
188
|
-
};
|
|
153
|
+
// without its autonomy seed just because the first ensure hit an unreadable file. → the outcomes.
|
|
154
|
+
export const runEnsures = ({ cwd, kitRoot, dryRun, deps, only }) =>
|
|
155
|
+
(only ? [only] : ENSURE_OPS).map((op) => runOne(op, { cwd, kitRoot, dryRun, deps }));
|
|
189
156
|
|
|
190
|
-
const render = (
|
|
157
|
+
const render = (outcomes, { dryRun, only }) => {
|
|
191
158
|
// The banner names the tool + the flag it ran under (both machine tokens the L2 rule exempts);
|
|
192
159
|
// the failure footer is a user-grade sentence — the composed-lines guard scans both.
|
|
193
|
-
const scope = only ? `, --only ${only}` :
|
|
160
|
+
const scope = only ? `, --only ${only}` : '';
|
|
194
161
|
const lines = [dryRun ? `ensure-configs (--reconcile${scope}, dry run — nothing written)` : `ensure-configs (--reconcile${scope})`];
|
|
195
162
|
for (const o of outcomes) {
|
|
196
163
|
lines.push(` ${o.op}: ${o.token}`);
|
|
197
164
|
for (const detail of o.lines) lines.push(` ${detail}`);
|
|
198
165
|
}
|
|
199
|
-
const blockLines = replaceBlock(block, { kitRoot, cwd });
|
|
200
|
-
if (blockLines.length > 0) lines.push('', ...blockLines.map((line) => ` ${line}`));
|
|
201
166
|
if (outcomes.some((o) => o.failed)) {
|
|
202
167
|
// No blanket claim about what was written: an op that copies file by file can stop PARTWAY, and
|
|
203
168
|
// its own lines are the only accurate account of what landed.
|
|
@@ -216,10 +181,10 @@ export const main = (argv = [], ctx = {}) => {
|
|
|
216
181
|
// reconcile, and one identical STOP per op would read as that many separate problems.
|
|
217
182
|
assertDocsAiDeployment(cwd, deps, { noun: 'the project configuration', rel: 'under docs/ai' });
|
|
218
183
|
const kitRoot = ctx.kitRoot ?? KIT_ROOT;
|
|
219
|
-
const
|
|
184
|
+
const outcomes = runEnsures({ cwd, kitRoot, dryRun: args.dryRun, deps, only: args.only });
|
|
220
185
|
return {
|
|
221
|
-
code:
|
|
222
|
-
stdout: render(
|
|
186
|
+
code: outcomes.some((o) => o.failed) ? EXIT_FAILED : EXIT_OK,
|
|
187
|
+
stdout: render(outcomes, { dryRun: args.dryRun, only: args.only }),
|
|
223
188
|
stderr: '',
|
|
224
189
|
};
|
|
225
190
|
} catch (err) {
|
package/tools/ensure-ops.mjs
CHANGED
|
@@ -253,6 +253,7 @@ const describeExitWithOutput = (result, subject = 'it') => `${subject} exited ${
|
|
|
253
253
|
const HOOK_MODULES = ['check-docs-size.mjs', 'spec-schema.mjs'];
|
|
254
254
|
const KEPT_JUDGE = `the project's own checker (${SCRIPTS_DIR}/check-docs-size.mjs --check-index)`;
|
|
255
255
|
const KEPT_FITS = `in sync under ${KEPT_JUDGE} and within the maxLines it stamps`;
|
|
256
|
+
const KEPT_ROUTE = "the spec layer's write of the bundled modules the project's hook loads, then this step again";
|
|
256
257
|
const KEPT_PROBE_TIMEOUT_MS = 30_000;
|
|
257
258
|
const countLines = (text) => text.split('\n').length - (text.endsWith('\n') ? 1 : 0);
|
|
258
259
|
const readStampedCap = (text) => { const value = parseFrontmatter(text)?.maxLines; const cap = value ? Number(value) : NaN; return Number.isNaN(cap) ? undefined : cap; };
|
|
@@ -298,14 +299,12 @@ const putBackIndex = (cwd, found, deps) => {
|
|
|
298
299
|
return null;
|
|
299
300
|
};
|
|
300
301
|
|
|
301
|
-
const ensureKeptIndex = ({ cwd,
|
|
302
|
+
const ensureKeptIndex = ({ cwd, drive, spawn, read, lstat, deps }) => {
|
|
302
303
|
const judge = () => judgeKept({ cwd, spawn, read, lstat, deps });
|
|
303
304
|
const reportUnanswered = (verdict, after) => loud('index', 'index-probe-failed', `${INDEX_REL}: ${KEPT_JUDGE} could not be launched or did not answer in time (${verdict.error}) — ${after}`);
|
|
304
305
|
const first = judge();
|
|
305
306
|
if (first.error) return reportUnanswered(first, 'nothing was written');
|
|
306
307
|
if (first.accepted) return ok('index', 'already-current', `${INDEX_REL}: ${KEPT_FITS} — nothing written`);
|
|
307
|
-
const custom = [...hook, ...['check-docs-size.test.mjs', 'spec-schema.test.mjs'].map((name) => surveyHookModule(cwd, kitRoot, name, read, lstat))].filter((entry) => entry.state === 'custom').map((entry) => entry.rel).sort();
|
|
308
|
-
const route = custom.length > 0 ? `the replace line printed for the spec layer (${custom.join(', ')}), run on the user's yes` : "the spec layer's refresh of the modules the project's hook loads, then this step again";
|
|
309
308
|
const found = lstatNoFollow(join(cwd, INDEX_REL), lstat) === null ? null : read(join(cwd, INDEX_REL));
|
|
310
309
|
const restored = found === null ? 'the navigator was put back: found absent, it was removed again' : 'the navigator was put back byte for byte';
|
|
311
310
|
const restoreThen = (failure, compose) => {
|
|
@@ -323,7 +322,7 @@ const ensureKeptIndex = ({ cwd, kitRoot, drive, spawn, read, lstat, deps, hook }
|
|
|
323
322
|
try { second = judge(); } catch (err) { return restoreThen(`the navigator could not be read back (${causeOf(err)})`, () => loud('index', 'unexpected-error', `${INDEX_REL}: the navigator could not be read back after the bundled write (${causeOf(err)}) — ${restored}`)); }
|
|
324
323
|
if (second.error) return restoreThen(`${KEPT_JUDGE} could not answer (${second.error})`, () => reportUnanswered(second, restored));
|
|
325
324
|
if (second.accepted) return ok('index', 'regenerated', `${INDEX_REL}: written by the bundled generator — ${KEPT_FITS}`);
|
|
326
|
-
return restoreThen(null, () => ok('index', 'customized-preserved', `${INDEX_REL}: ${KEPT_JUDGE} rejected the bundled render on ${second.half} (${second.said}), and the navigator as found did not pass it either (${first.half}) — ${restored}. The route: ${
|
|
325
|
+
return restoreThen(null, () => ok('index', 'customized-preserved', `${INDEX_REL}: ${KEPT_JUDGE} rejected the bundled render on ${second.half} (${second.said}), and the navigator as found did not pass it either (${first.half}) — ${restored}. The route: ${KEPT_ROUTE}`));
|
|
327
326
|
};
|
|
328
327
|
|
|
329
328
|
const buildKeptDryRunNote = (hook) =>
|
|
@@ -348,7 +347,7 @@ export const ensureIndex = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
348
347
|
const kept = hook[0].state !== 'absent' && !hook.every((entry) => entry.state === 'current');
|
|
349
348
|
const unreadable = kept && hook.find((entry) => entry.state === 'bundle-unreadable');
|
|
350
349
|
if (unreadable) return loud('index', 'bundle-unreadable', `${unreadable.rel}: the bundled module could not be read, so nothing was written — reinstall the kit. ${unreadable.error}`);
|
|
351
|
-
if (kept && !dryRun) return ensureKeptIndex({ cwd,
|
|
350
|
+
if (kept && !dryRun) return ensureKeptIndex({ cwd, drive, spawn, read, lstat, deps });
|
|
352
351
|
const dryNote = kept ? [buildKeptDryRunNote(hook)] : [];
|
|
353
352
|
if (dryRun) {
|
|
354
353
|
const check = drive('--check-index');
|
package/tools/ensure-specs.mjs
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
// ensure-specs.mjs — the SIXTH upgrade ensure: the spec layer (memory 4.6.0, AD-112)
|
|
2
|
-
// EXISTING deployment
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// only behind a reader pair this run leaves byte-current;
|
|
11
|
-
// 3. the store root docs/ai/specs/index.md — seeded (placeholders rendered)
|
|
12
|
-
// only once both pairs are current.
|
|
1
|
+
// ensure-specs.mjs — the SIXTH upgrade ensure: the spec layer (memory 4.6.0, AD-112) kept current on an
|
|
2
|
+
// EXISTING deployment. Four deployed scripts (the pairs script-priors.mjs names; every other kit script
|
|
3
|
+
// is the scripts ensure's) and one store root, by the scripts op's rule (distribution-files/): every
|
|
4
|
+
// file is surveyed by proof first, then on every plain run a prior body is refreshed and an edited one
|
|
5
|
+
// replaced in place, an absent one placed create-only and an absent store root seeded create-only, with
|
|
6
|
+
// no question and no copy kept; a current file is left. The writes run in a FIXED order:
|
|
7
|
+
// 1. the reader pair scripts/spec-schema.mjs + .test.mjs
|
|
8
|
+
// 2. the checker pair scripts/check-docs-size.mjs + .test.mjs
|
|
9
|
+
// 3. the store root docs/ai/specs/index.md (placeholders rendered)
|
|
13
10
|
// Why the order: the kit's bundled navigator generator collapses `specs/` into one row, while the
|
|
14
11
|
// project's pre-commit hook runs ITS deployed checker — an older one renders the store row by row and
|
|
15
|
-
// reds `--check-index`.
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// The state table (enumerate by PROOF, never by exclusion): every file is classified into exactly one
|
|
19
|
-
// of current | prior | custom | absent | wrong-kind before anything is written, each write admits
|
|
20
|
-
// through ONE conjunction of those facts (decideWrites), and every other cell is a stated refusal —
|
|
21
|
-
// a custom file of either pair preserves itself AND withholds every write that depends on it. Under
|
|
22
|
-
// the replace the driver hands back (`replace: { digest, entries }`), the bound custom files are
|
|
23
|
-
// rewritten. Writes run in order and each is idempotent, so a stopped run converges on the next.
|
|
12
|
+
// reds `--check-index`. So the checker is written before the spec store, and a write that fails stops
|
|
13
|
+
// every later one. The pair lines and the hook-run line are the scripts op's own, from the module's
|
|
14
|
+
// index. Each write is idempotent, so a stopped run converges on the next.
|
|
24
15
|
//
|
|
25
16
|
// Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
|
|
26
17
|
|
|
27
18
|
import { readFileSync, lstatSync } from 'node:fs';
|
|
28
19
|
import { join } from 'node:path';
|
|
29
20
|
import { writeContainedFileAtomic, writeProjectFileCreateOnly } from './atomic-write.mjs';
|
|
30
|
-
import { CHECKER_PAIR, READER_PAIR, classifyDeployedScript
|
|
21
|
+
import { CHECKER_PAIR, READER_PAIR, classifyDeployedScript } from './script-priors.mjs';
|
|
31
22
|
import { composeFailure, composeOutcome, nodeEvidenceRefusal, probeSeedTarget, tmpNote } from './ensure-ops.mjs';
|
|
32
|
-
import {
|
|
23
|
+
import { fileLine, hookLine } from './distribution-files/index.mjs';
|
|
33
24
|
|
|
34
25
|
const OP = 'specs';
|
|
35
26
|
const SCRIPTS_DIR = 'scripts';
|
|
@@ -56,8 +47,7 @@ const surveyScript = ({ cwd, kitRoot, name, read, lstat }) => {
|
|
|
56
47
|
const probe = probeSeedTarget(join(cwd, SCRIPTS_DIR, name), lstat);
|
|
57
48
|
if (probe.wrongKind) return { rel, name, state: 'wrong-kind', wrongKind: probe.wrongKind, bundle };
|
|
58
49
|
if (!probe.present) return { rel, name, state: 'absent', bundle };
|
|
59
|
-
|
|
60
|
-
return { rel, name, state: classifyDeployedScript(bytes, name, bundle), bundle, bytes };
|
|
50
|
+
return { rel, name, state: classifyDeployedScript(read(join(cwd, SCRIPTS_DIR, name)), name, bundle), bundle };
|
|
61
51
|
};
|
|
62
52
|
|
|
63
53
|
const surveyStoreRoot = (cwd, lstat) => {
|
|
@@ -66,94 +56,23 @@ const surveyStoreRoot = (cwd, lstat) => {
|
|
|
66
56
|
return { rel: STORE_ROOT_REL, state: probe.present ? 'present' : 'absent' };
|
|
67
57
|
};
|
|
68
58
|
|
|
69
|
-
// ── the
|
|
70
|
-
|
|
71
|
-
// Reader seeds are create-only and always admitted. A REFRESH overwrites bytes, so it runs only
|
|
72
|
-
// inside a pair whose every file is proven refreshable (current | prior | absent) — one custom file
|
|
73
|
-
// withholds its whole pair; the checker lane (its seeds included) and the store additionally wait
|
|
74
|
-
// for a reader pair this run leaves byte-current (seeded + refreshed = current). Under the user's
|
|
75
|
-
// replace yes a custom file is refreshable too: it is rewritten to the bundled body.
|
|
76
|
-
const PAIR_ELIGIBLE = new Set(['current', 'prior', 'absent']);
|
|
77
|
-
const REPLACE_ELIGIBLE = new Set([...PAIR_ELIGIBLE, 'custom']);
|
|
59
|
+
// ── the lines (composed from what HAPPENED: each file's state and the fate of its write) ─────────
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const checkerEligible = readerEligible && checker.every((f) => eligible.has(f.state));
|
|
84
|
-
const writes = [];
|
|
85
|
-
for (const f of reader) {
|
|
86
|
-
if (f.state === 'absent') writes.push({ kind: 'seed', file: f });
|
|
87
|
-
if (readerEligible && refreshable.includes(f.state)) writes.push({ kind: 'refresh', file: f });
|
|
88
|
-
}
|
|
89
|
-
if (checkerEligible) {
|
|
90
|
-
for (const f of checker) {
|
|
91
|
-
if (f.state === 'absent') writes.push({ kind: 'seed', file: f });
|
|
92
|
-
if (refreshable.includes(f.state)) writes.push({ kind: 'refresh', file: f });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (checkerEligible && store.state === 'absent') writes.push({ kind: 'store' });
|
|
96
|
-
return { writes, withheld: !checkerEligible };
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// ── the lines (composed from what HAPPENED, never from what was planned) ──────────────────────────
|
|
100
|
-
|
|
101
|
-
// Every file's line is a function of its surveyed state and the FATE of its write this run:
|
|
102
|
-
// `written` · `stood` (lost the create-only race to the bundled body) · `would` (dry run) ·
|
|
103
|
-
// `withheld` (a custom file in the pair) · `stopped` (the run failed before reaching it) · `none`
|
|
104
|
-
// (no write was admitted or needed). A line never claims a write that did not happen. Under the
|
|
105
|
-
// replace a custom line names its kept-aside copy and never points at a block below.
|
|
106
|
-
const LEFT_FOR = { withheld: 'it waits on the pair named above', stopped: 'the run stopped before it' };
|
|
107
|
-
const SCRIPT_LINES = {
|
|
108
|
-
current: () => 'already the bundled body — nothing written',
|
|
109
|
-
custom: (fate, kept) => (fate === 'written' ? `carried an edit — kept aside at ${kept}, then replaced by the bundled body on the user's yes`
|
|
110
|
-
: kept !== undefined ? `carries an edit — not replaced${kept ? `; its copy kept aside at ${kept} stays` : ''}`
|
|
111
|
-
: "carries an edit — left as it stands until the user's yes keeps it aside and replaces it (the block below); the writes that depend on it wait"),
|
|
112
|
-
absent: (fate) => ({
|
|
113
|
-
written: 'copied from the bundled scripts',
|
|
114
|
-
stood: 'appeared while this run was seeding it — the bundled body stands',
|
|
115
|
-
would: 'absent — would be copied from the bundled scripts',
|
|
116
|
-
})[fate] ?? `absent — not copied${fate === 'withheld' ? ' this run' : ''}; ${LEFT_FOR[fate]}`,
|
|
117
|
-
prior: (fate) => `matches a body an earlier release shipped — ${({
|
|
118
|
-
written: 'refreshed to the bundled one',
|
|
119
|
-
would: 'would be refreshed to the bundled one',
|
|
120
|
-
})[fate] ?? `left as is; ${LEFT_FOR[fate]}`}`,
|
|
121
|
-
};
|
|
122
|
-
const scriptLine = (f, fate, keptOf) => `${f.rel}: ${SCRIPT_LINES[f.state](fate, keptOf?.(f.rel))}`;
|
|
61
|
+
// A fate is `written`, `stood` (a create-only write that found the path taken: a pair file with the
|
|
62
|
+
// bundled body, or a store root as found), `refused` (its write failed), or none: the run stopped
|
|
63
|
+
// before it, or, dry, would write it. A pair file that is not current takes the scripts op's line.
|
|
64
|
+
const CURRENT = 'already the bundled body — nothing written';
|
|
123
65
|
const STORE_LINES = {
|
|
124
66
|
present: 'already present — preserved byte-for-byte, nothing written',
|
|
125
67
|
written: "created from the bundled template (today's date rendered)",
|
|
126
68
|
stood: 'appeared while this run was seeding it — the existing file stands',
|
|
127
69
|
would: 'absent — would be created from the bundled template',
|
|
128
|
-
|
|
129
|
-
stopped: 'absent — not created; the run stopped before it',
|
|
130
|
-
};
|
|
131
|
-
const storeLine = (store, fate, custom) => {
|
|
132
|
-
const line = STORE_LINES[store.state === 'present' ? 'present' : fate];
|
|
133
|
-
return `${STORE_ROOT_REL}: ${typeof line === 'function' ? line(custom) : line}`;
|
|
134
|
-
};
|
|
135
|
-
const relOf = (write) => (write.kind === 'store' ? STORE_ROOT_REL : write.file.rel);
|
|
136
|
-
|
|
137
|
-
// The fate of every path for the lines: a write that ran carries its result, an admitted write the
|
|
138
|
-
// run never reached is `stopped`, and a path with no admitted write is `withheld` behind a custom
|
|
139
|
-
// file or `none` when nothing was needed.
|
|
140
|
-
const fateOf = (rel, { writes, fates, withheld, stopped }) => {
|
|
141
|
-
if (fates.has(rel)) return fates.get(rel);
|
|
142
|
-
if (writes.some((w) => relOf(w) === rel)) return stopped ? 'stopped' : 'would';
|
|
143
|
-
return withheld ? 'withheld' : 'none';
|
|
144
|
-
};
|
|
145
|
-
const composeLines = ({ reader, checker, store, writes, fates, withheld, stopped, keptOf }) => {
|
|
146
|
-
const fate = (rel) => fateOf(rel, { writes, fates, withheld, stopped });
|
|
147
|
-
const lines = [...reader, ...checker].map((f) => scriptLine(f, fate(f.rel), keptOf));
|
|
148
|
-
const storeFate = fate(STORE_ROOT_REL);
|
|
149
|
-
const custom = [...reader, ...checker].filter((f) => f.state === 'custom').map((f) => f.rel);
|
|
150
|
-
if (store.state === 'present' || storeFate !== 'none') lines.push(storeLine(store, storeFate, custom));
|
|
151
|
-
return lines;
|
|
70
|
+
stopped: 'absent — not created',
|
|
152
71
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
72
|
+
const composeLines = ({ files, store, fates, dryRun }) => [
|
|
73
|
+
...files.map((f) => (f.state === 'current' ? `${f.rel}: ${CURRENT}` : fileLine(f, fates.get(f.rel), dryRun))),
|
|
74
|
+
`${STORE_ROOT_REL}: ${STORE_LINES[store.state === 'present' ? 'present' : fates.get(STORE_ROOT_REL) ?? (dryRun ? 'would' : 'stopped')]}`,
|
|
75
|
+
];
|
|
157
76
|
|
|
158
77
|
// A per-file loop can stop partway; the run says which files already landed — never "nothing happened".
|
|
159
78
|
const partialNote = (count) =>
|
|
@@ -169,82 +88,67 @@ const renderStoreRoot = (kitRoot, read, today) => {
|
|
|
169
88
|
return body;
|
|
170
89
|
};
|
|
171
90
|
|
|
172
|
-
|
|
91
|
+
// One write per due path in write order: a prior refreshed and an edit replaced by the atomic write,
|
|
92
|
+
// an absent pair file and the store root written create-only. → { fates, notes, failure? }
|
|
93
|
+
const writeAll = ({ cwd, due, storeBody, deps, read }) => {
|
|
94
|
+
const fates = new Map();
|
|
95
|
+
const notes = [];
|
|
96
|
+
for (const f of due) {
|
|
97
|
+
const isStore = f.rel === STORE_ROOT_REL;
|
|
98
|
+
let result;
|
|
99
|
+
try {
|
|
100
|
+
result = isStore ? writeProjectFileCreateOnly(cwd, f.rel, storeBody, deps, { noun: 'the spec store root' })
|
|
101
|
+
: f.state === 'absent' ? writeProjectFileCreateOnly(cwd, f.rel, String(f.bundle), deps, { noun: 'a seeded spec-layer script' })
|
|
102
|
+
: writeContainedFileAtomic(cwd, join(cwd, f.rel), String(f.bundle), deps, { label: f.rel });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if (!isStore) fates.set(f.rel, 'refused');
|
|
105
|
+
return { fates, notes, failure: ['write-refused', `${f.rel}: ${causeOf(err)}`] };
|
|
106
|
+
}
|
|
107
|
+
notes.push(...tmpNote(f.rel, result.tmpLeftBehind));
|
|
108
|
+
const stood = f.state === 'absent' && !result.created;
|
|
109
|
+
if (stood && !isStore && classifyDeployedScript(read(join(cwd, f.rel)), f.name, f.bundle) !== 'current') {
|
|
110
|
+
fates.set(f.rel, 'refused');
|
|
111
|
+
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`] };
|
|
112
|
+
}
|
|
113
|
+
fates.set(f.rel, stood ? 'stood' : 'written');
|
|
114
|
+
}
|
|
115
|
+
return { fates, notes };
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
173
119
|
const lstat = deps.lstat ?? lstatSync;
|
|
174
120
|
const read = deps.readFile ?? readFileSync;
|
|
175
121
|
const refusal = nodeEvidenceRefusal(OP, cwd, lstat);
|
|
176
122
|
if (refusal) return refusal;
|
|
177
123
|
const survey = (name) => surveyScript({ cwd, kitRoot, name, read, lstat });
|
|
178
|
-
const
|
|
179
|
-
const checker = CHECKER_PAIR.map(survey);
|
|
124
|
+
const files = [...READER_PAIR.map(survey), ...CHECKER_PAIR.map(survey)];
|
|
180
125
|
const store = surveyStoreRoot(cwd, lstat);
|
|
181
|
-
for (const f of
|
|
126
|
+
for (const f of files) {
|
|
182
127
|
if (f.state === 'bundle-unreadable') return composeFailure(OP, 'bundle-unreadable', `${f.rel}: the bundled script could not be read, so nothing was written — reinstall the kit. ${f.error}`);
|
|
183
128
|
}
|
|
184
|
-
for (const f of [...
|
|
129
|
+
for (const f of [...files, store]) {
|
|
185
130
|
if (f.state === 'wrong-kind') return composeFailure(OP, 'wrong-node-kind', `${f.rel}: exists but is ${f.wrongKind} — nothing was read or written; resolve it by hand, then re-run`);
|
|
186
131
|
}
|
|
187
132
|
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const keptOf = bound && ((rel) => (bound.has(rel) ? keptAsidePath(replace.digest, rel) : ''));
|
|
195
|
-
if (bound && !sameEntries(entries, replace.entries)) {
|
|
196
|
-
const asFound = decideWrites({ reader, checker, store });
|
|
197
|
-
return loud('race-unresolved', 'the edited spec-layer files are not the set the yes was given for (another set or other bytes), so nothing was written', ...composeLines({ reader, checker, store, ...asFound, fates: new Map(), stopped: true, keptOf }));
|
|
133
|
+
const due = [...files.filter((f) => f.state !== 'current'), ...(store.state === 'absent' ? [store] : [])];
|
|
134
|
+
const seeds = (fs) => fs.some((f) => f.state === 'absent');
|
|
135
|
+
const refreshes = (fs) => fs.some((f) => f.state === 'prior' || f.state === 'custom');
|
|
136
|
+
if (dryRun) {
|
|
137
|
+
const token = seeds(due) ? 'would-seed' : refreshes(due) ? 'would-refresh' : 'already-present';
|
|
138
|
+
return composeOutcome(OP, token, [...composeLines({ files, store, fates: new Map(), dryRun }), ...(due.length > 0 ? [hookLine(false, true)] : [])], false);
|
|
198
139
|
}
|
|
199
|
-
const { writes, withheld } = decideWrites({ reader, checker, store }, Boolean(bound));
|
|
200
|
-
const kinds = new Set(writes.map((w) => w.kind));
|
|
201
|
-
// ONE token by precedence — a write that happened (or, dry, would happen) always outranks the
|
|
202
|
-
// preserved-custom report, which names a run that wrote nothing behind an edited pair.
|
|
203
|
-
const tokenFor = (seeded, refreshed) => {
|
|
204
|
-
if (seeded) return dryRun ? 'would-seed' : 'seeded';
|
|
205
|
-
if (refreshed) return dryRun ? 'would-refresh' : 'refreshed';
|
|
206
|
-
return withheld ? 'customized-preserved' : 'already-present';
|
|
207
|
-
};
|
|
208
|
-
const fates = new Map();
|
|
209
|
-
const linesNow = (stopped) => composeLines({ reader, checker, store, writes, fates, withheld, stopped, keptOf });
|
|
210
|
-
const writtenCount = () => [...fates.values()].filter((fate) => fate === 'written').length;
|
|
211
|
-
if (dryRun) return ok(tokenFor(kinds.has('seed') || kinds.has('store'), kinds.has('refresh')), linesNow(false));
|
|
212
140
|
|
|
213
141
|
let storeBody = null;
|
|
214
|
-
if (
|
|
142
|
+
if (store.state === 'absent') {
|
|
215
143
|
try {
|
|
216
144
|
storeBody = renderStoreRoot(kitRoot, read, deps.today ?? todayIso());
|
|
217
145
|
} catch (err) {
|
|
218
|
-
return
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const writeOne = ({ kind, file }) => {
|
|
222
|
-
if (kind === 'store') return writeProjectFileCreateOnly(cwd, STORE_ROOT_REL, storeBody, deps, { noun: 'the spec store root' });
|
|
223
|
-
if (kind === 'seed') return writeProjectFileCreateOnly(cwd, file.rel, String(file.bundle), deps, { noun: 'a seeded spec-layer script' });
|
|
224
|
-
return writeContainedFileAtomic(cwd, join(cwd, file.rel), String(file.bundle), deps, { label: file.rel });
|
|
225
|
-
};
|
|
226
|
-
// A seed that lost the create-only race is re-PROVEN before anything that depends on it runs: the
|
|
227
|
-
// file that appeared must carry the bundled body, or the tree is changing underneath this run.
|
|
228
|
-
const stoodCurrent = ({ kind, file }) => kind === 'store' || classifyDeployedScript(read(join(cwd, file.rel)), file.name, file.bundle) === 'current';
|
|
229
|
-
const movedSinceBind = ({ kind, file }) => { if (kind !== 'refresh' || !bound?.has(file.rel)) return false; try { return digestOf(read(join(cwd, file.rel))) !== bound.get(file.rel); } catch { return true; } };
|
|
230
|
-
const notes = [];
|
|
231
|
-
for (const write of writes) {
|
|
232
|
-
const rel = relOf(write);
|
|
233
|
-
if (movedSinceBind(write)) {
|
|
234
|
-
return loud('race-unresolved', `${rel}: changed after this run read it — left as it stands and nothing further written`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
|
|
235
|
-
}
|
|
236
|
-
let result;
|
|
237
|
-
try {
|
|
238
|
-
result = writeOne(write);
|
|
239
|
-
} catch (err) {
|
|
240
|
-
return loud('write-refused', `${rel}: ${causeOf(err)}`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
|
|
241
|
-
}
|
|
242
|
-
if (write.kind !== 'refresh' && !result.created && !stoodCurrent(write)) {
|
|
243
|
-
return loud('race-unresolved', `${rel}: appeared while this run was seeding it and does not carry the bundled body — something is writing there underneath this run; nothing further written, re-run when the tree is settled`, ...linesNow(true), ...notes, ...partialNote(writtenCount()));
|
|
146
|
+
return composeFailure(OP, 'template-unreadable', `${STORE_ROOT_REL}: ${causeOf(err)}`, ...composeLines({ files, store, fates: new Map(), dryRun }));
|
|
244
147
|
}
|
|
245
|
-
fates.set(rel, write.kind !== 'refresh' && !result.created ? 'stood' : 'written');
|
|
246
|
-
notes.push(...tmpNote(rel, result.tmpLeftBehind));
|
|
247
148
|
}
|
|
248
|
-
const
|
|
249
|
-
|
|
149
|
+
const { fates, notes, failure } = writeAll({ cwd, due, storeBody, deps, read });
|
|
150
|
+
const written = due.filter((f) => fates.get(f.rel) === 'written');
|
|
151
|
+
const lines = [...composeLines({ files, store, fates, dryRun }), ...(written.length > 0 ? [hookLine(false, false)] : []), ...notes];
|
|
152
|
+
if (failure) return composeFailure(OP, failure[0], failure[1], ...lines, ...partialNote(written.length));
|
|
153
|
+
return composeOutcome(OP, seeds(written) ? 'seeded' : refreshes(written) ? 'refreshed' : 'already-present', lines, false);
|
|
250
154
|
};
|
|
@@ -9,9 +9,9 @@
|
|
|
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. `specs`
|
|
13
|
-
//
|
|
14
|
-
//
|
|
12
|
+
// root it seeds is a docs/ai file the navigator must count. `specs` writes its pairs and `scripts`
|
|
13
|
+
// every kit script with no question and no copy kept, and `scripts` then
|
|
14
|
+
// 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']);
|
|
@@ -20,8 +20,8 @@ export const ENSURE_OPS = Object.freeze(['orchestration', 'gates', 'autonomy', '
|
|
|
20
20
|
// walks this set), and each has exactly one `would-` counterpart below. `refreshed` is the spec-layer
|
|
21
21
|
// ensure's pair refresh (reader or checker) or the scripts ensure's write of a kit script — a deployed
|
|
22
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
|
|
24
|
-
//
|
|
23
|
+
// absent kit script placed (`seeded`), or the ADR store the rotator brought current; an edited
|
|
24
|
+
// spec-layer file is replaced on the same plain run.
|
|
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
|
|
|
@@ -7,7 +7,6 @@ import { join } from 'node:path';
|
|
|
7
7
|
import { writeDocsAiFileAtomic, writeProjectFileCreateOnly } from '../atomic-write.mjs';
|
|
8
8
|
import { composeFailure, composeOutcome, tmpNote } from '../ensure-ops.mjs';
|
|
9
9
|
import { shellQuoteArg } from '../repo-lex.mjs';
|
|
10
|
-
import { parseFrontmatter } from '../../references/scripts/check-docs-size.mjs';
|
|
11
10
|
import { digestOf, readRecord, readUnder } from './rules-check.mjs';
|
|
12
11
|
import { writeRecord } from './rules-record.mjs';
|
|
13
12
|
import { RULES_PRIORS, isKnownPrior } from './rules-priors.mjs';
|
|
@@ -58,24 +57,22 @@ const survey = ({ themes, cwd, kitRoot, readFile, deps }) => {
|
|
|
58
57
|
const classifyKit = (name, kit, template, priors) => {
|
|
59
58
|
if (kit.outcome === 'absent') return 'absent';
|
|
60
59
|
if (kit.bytes.equals(template)) return 'current';
|
|
61
|
-
return isKnownPrior(name, kit.bytes, priors) ? 'prior' : '
|
|
60
|
+
return isKnownPrior(name, kit.bytes, priors) ? 'prior' : 'other';
|
|
62
61
|
};
|
|
63
62
|
|
|
64
63
|
const planTheme = ({ theme, paths, template, reads }, record, priors) => {
|
|
65
64
|
const { kit, local, effective } = reads;
|
|
66
65
|
const kitState = classifyKit(theme.name, kit, template, priors);
|
|
67
|
-
const
|
|
68
|
-
const kitWrite = { absent: 'seed', prior: 'refresh' }[kitState] ?? null;
|
|
66
|
+
const kitWrite = { absent: 'seed', prior: 'refresh', other: 'refresh' }[kitState] ?? null;
|
|
69
67
|
const entry = record.ok ? record.themes[theme.name] : undefined;
|
|
70
|
-
const base = { name: theme.name, paths, kitState, kitBytes, kitWrite, effectiveWrite: null, recordWrite: false };
|
|
68
|
+
const base = { name: theme.name, paths, kitState, kitBytes: template, kitWrite, effectiveWrite: null, recordWrite: false };
|
|
71
69
|
if (local.outcome === 'ok') {
|
|
72
|
-
const merged = entry !== undefined && effective.outcome === 'ok' && entry.kit === digestOf(
|
|
70
|
+
const merged = entry !== undefined && effective.outcome === 'ok' && entry.kit === digestOf(template)
|
|
73
71
|
&& entry.local === digestOf(local.bytes) && entry.effective === digestOf(effective.bytes);
|
|
74
72
|
return { ...base, mode: merged ? 'merged' : 'pending', localDigest: digestOf(local.bytes) };
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const passed = { kit: digestOf(kitBytes), local: 'absent', effective: digestOf(kitBytes) };
|
|
74
|
+
const effectiveWrite = effective.outcome === 'absent' ? 'seed' : effective.bytes.equals(template) ? null : 'rebuild';
|
|
75
|
+
const passed = { kit: digestOf(template), local: 'absent', effective: digestOf(template) };
|
|
79
76
|
const recorded = entry !== undefined && entry.kit === passed.kit && entry.local === 'absent' && entry.effective === passed.effective;
|
|
80
77
|
const droppedEdit = effectiveWrite === 'rebuild' && entry !== undefined && entry.effective !== digestOf(effective.bytes);
|
|
81
78
|
return { ...base, mode: 'copy', effectiveWrite, recordWrite: effectiveWrite !== null || !recorded, passed, droppedEdit };
|
|
@@ -86,13 +83,13 @@ const planTheme = ({ theme, paths, template, reads }, record, priors) => {
|
|
|
86
83
|
const KIT_LINES = {
|
|
87
84
|
absent: { written: 'created from the bundled template', stood: 'appeared while this run was creating it and holds the bundled template — it stands', would: 'absent — would be created from the bundled template' },
|
|
88
85
|
prior: { written: 'held the body an earlier release shipped — refreshed to the bundled template', would: 'holds the body an earlier release shipped — would be refreshed to the bundled template' },
|
|
86
|
+
other: { written: 'differs from every body this kit knows it shipped — replaced by the bundled template', would: 'differs from every body this kit knows it shipped — would be replaced by the bundled template' },
|
|
89
87
|
};
|
|
90
88
|
const kitLine = (plan, fate) => {
|
|
91
89
|
const { kit, local } = plan.paths;
|
|
92
90
|
if (plan.kitState === 'current') return `${kit}: already the bundled template — nothing written`;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return `${kit}: ${KIT_LINES[plan.kitState][fate]}`;
|
|
91
|
+
const lasting = plan.kitState === 'other' ? `; a rule meant to last goes in ${local}, where it wins` : '';
|
|
92
|
+
return `${kit}: ${KIT_LINES[plan.kitState][fate]}${lasting}`;
|
|
96
93
|
};
|
|
97
94
|
|
|
98
95
|
const effectiveLine = (plan, fate) => {
|
|
@@ -141,7 +138,7 @@ const tokenOf = (plans, wrote, dryRun) => {
|
|
|
141
138
|
if (plans.some((plan) => plan.kitWrite === 'seed' && wrote(plan, 'kit'))) return token('seeded');
|
|
142
139
|
if (plans.some((plan) => plan.kitWrite === 'refresh' && wrote(plan, 'kit'))) return token('refreshed');
|
|
143
140
|
if (plans.some((plan) => wrote(plan, 'effective') || wrote(plan, 'record'))) return token('regenerated');
|
|
144
|
-
return
|
|
141
|
+
return 'already-current';
|
|
145
142
|
};
|
|
146
143
|
|
|
147
144
|
// ── the writes, in order; the first that fails stops the run ─────────────────────────────────────
|
package/tools/script-priors.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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 — replaced on the plain run
|
|
6
|
-
//
|
|
5
|
+
// shipped, never edited since) · `custom` (anything else — replaced on the plain run, the spec-layer
|
|
6
|
+
// pairs included, with no question). The lens-region idiom (AD-041) over whole
|
|
7
7
|
// script bodies.
|
|
8
8
|
//
|
|
9
9
|
// Append discipline: when a release changes one of PRIOR_FILES, append the OUTGOING body's row here
|
|
@@ -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
|
-
|
|
37
|
+
null,
|
|
38
38
|
[
|
|
39
39
|
'seeded',
|
|
40
40
|
'note-refreshed',
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// kept-aside.mjs — where an upgrade keeps a user's edit before the bundled body replaces it:
|
|
2
|
-
// `.agent-workflow/kept-aside/<the first 16 hex of the replace set's digest>/<rel>` at the project
|
|
3
|
-
// root. Every copy is written create-only from the bytes the survey read (never a re-read of the
|
|
4
|
-
// source), read back and proven against the sha256 the digest bound, before anything is replaced.
|
|
5
|
-
// `.agent-workflow/.gitignore` holding exactly `*` and a line feed is proven before the first copy,
|
|
6
|
-
// so no stop leaves a copy git can see, with no edit of the user's own ignore files. The kit never
|
|
7
|
-
// overwrites or deletes a kept-aside copy: a copy with other bytes is the user's to move.
|
|
8
|
-
//
|
|
9
|
-
// Dependency-free, Node >= 22. Every fs primitive is injectable (deps.*). No side effects on import.
|
|
10
|
-
|
|
11
|
-
import { lstatSync, readFileSync } from 'node:fs';
|
|
12
|
-
import { createHash } from 'node:crypto';
|
|
13
|
-
import { join } from 'node:path';
|
|
14
|
-
import { lstatNoFollow, writeProjectFileCreateOnly } from '../atomic-write.mjs';
|
|
15
|
-
import { RESERVED_DIR } from '../repo-lex.mjs';
|
|
16
|
-
|
|
17
|
-
export const KEPT_ASIDE_DIR = `${RESERVED_DIR}/kept-aside`;
|
|
18
|
-
const IGNORE_REL = `${RESERVED_DIR}/.gitignore`;
|
|
19
|
-
const IGNORE_BODY = '*\n';
|
|
20
|
-
|
|
21
|
-
export const keptAsidePath = (digest, rel) => `${KEPT_ASIDE_DIR}/${digest.slice(0, 16)}/${rel}`;
|
|
22
|
-
|
|
23
|
-
const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
24
|
-
const causeOf = (err) => String((err && err.message) || err);
|
|
25
|
-
const kindOf = (st) => (st.isSymbolicLink() ? 'a symlink' : st.isDirectory() ? 'a directory' : st.isFile() ? 'a regular file' : 'not a regular file');
|
|
26
|
-
const NOTHING_DONE = 'nothing was kept aside or replaced';
|
|
27
|
-
|
|
28
|
-
// The node-kind preflight, before anything is created: every directory from the project root down
|
|
29
|
-
// to each copy's parent must be a real directory, and each copy path and the ignore file a regular
|
|
30
|
-
// file when present. Returns the refusal line, or null.
|
|
31
|
-
const chainRefusal = (cwd, rels, lstat) => {
|
|
32
|
-
for (const rel of rels) {
|
|
33
|
-
const parts = rel.split('/');
|
|
34
|
-
for (let i = 1; i <= parts.length; i += 1) {
|
|
35
|
-
const sub = parts.slice(0, i).join('/');
|
|
36
|
-
const st = lstatNoFollow(join(cwd, sub), lstat);
|
|
37
|
-
const leaf = i === parts.length;
|
|
38
|
-
if (st && (leaf ? !st.isFile() : !st.isDirectory())) return `${sub}: exists but is ${kindOf(st)} — ${NOTHING_DONE}; resolve it by hand, then re-run`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const fail = (cause, line, kept) => {
|
|
45
|
-
const written = kept.filter((copy) => copy.created).map((copy) => copy.path);
|
|
46
|
-
const note = written.length > 0 ? [`the edits already kept aside stay where they are: ${written.join(', ')}`] : [];
|
|
47
|
-
return { failed: true, cause, lines: [line, ...note], kept };
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// keepAside({ cwd, digest, entries, deps }) → { failed: false, kept } with every edited entry's copy
|
|
51
|
-
// proven, or { failed: true, cause, lines, kept } naming why and which copies were already written.
|
|
52
|
-
// An absent entry gets no copy. `kept` lists { rel, path, created } per proven copy.
|
|
53
|
-
export const keepAside = ({ cwd, digest, entries, deps = {} }) => {
|
|
54
|
-
const lstat = deps.lstat ?? lstatSync;
|
|
55
|
-
const read = deps.readFile ?? readFileSync;
|
|
56
|
-
const edited = entries.filter((entry) => !entry.absent).sort((a, b) => (a.rel < b.rel ? -1 : 1));
|
|
57
|
-
const kept = [];
|
|
58
|
-
if (edited.length === 0) return { failed: false, kept };
|
|
59
|
-
const refusal = chainRefusal(cwd, [IGNORE_REL, ...edited.map((entry) => keptAsidePath(digest, entry.rel))], lstat);
|
|
60
|
-
if (refusal) return fail('wrong-node-kind', refusal, kept);
|
|
61
|
-
let at = IGNORE_REL;
|
|
62
|
-
try {
|
|
63
|
-
if (lstatNoFollow(join(cwd, IGNORE_REL), lstat) === null) {
|
|
64
|
-
writeProjectFileCreateOnly(cwd, IGNORE_REL, IGNORE_BODY, deps, { noun: 'the kept-aside ignore file' });
|
|
65
|
-
}
|
|
66
|
-
if (String(read(join(cwd, IGNORE_REL))) !== IGNORE_BODY) {
|
|
67
|
-
return fail('write-refused', `${IGNORE_REL}: holds other bytes — it must hold exactly "*" and a line feed, so git sees no kept-aside copy; ${NOTHING_DONE}`, kept);
|
|
68
|
-
}
|
|
69
|
-
for (const entry of edited) {
|
|
70
|
-
const path = keptAsidePath(digest, entry.rel);
|
|
71
|
-
const abs = join(cwd, path);
|
|
72
|
-
at = path;
|
|
73
|
-
const created = lstatNoFollow(abs, lstat) === null && writeProjectFileCreateOnly(cwd, path, entry.bytes, deps, { noun: 'a kept-aside copy' }).created;
|
|
74
|
-
if (sha256(read(abs)) !== entry.sha256) {
|
|
75
|
-
return fail('race-unresolved', `${path}: a copy with other bytes is there — it is the user's to move or delete before the yes is asked again; nothing was replaced`, kept);
|
|
76
|
-
}
|
|
77
|
-
kept.push({ rel: entry.rel, path, created });
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
return fail('write-refused', `${at}: ${causeOf(err)} — nothing was replaced`, kept);
|
|
81
|
-
}
|
|
82
|
-
return { failed: false, kept };
|
|
83
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// replace-set.mjs — the ONE replace block an upgrade prints over every file whose write waits for the
|
|
2
|
-
// user's yes, and the replace run that yes starts. An owning op reports entries on its outcome: { rel,
|
|
3
|
-
// sha256, bytes, channel } for an edited file, { rel, absent: true, channel } for an absent one, either
|
|
4
|
-
// marked `hookRun: true` when the commit hook runs it. One digest binds their union, one block prints
|
|
5
|
-
// over it, and the yes keeps every edit aside (kept-aside.mjs) before any op replaces a byte. It never
|
|
6
|
-
// imports ensure-configs.mjs: the CLI hands it the ops it runs.
|
|
7
|
-
//
|
|
8
|
-
// Dependency-free, Node >= 22. No side effects on import.
|
|
9
|
-
|
|
10
|
-
import { createHash } from 'node:crypto';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
import { composeFailure } from '../ensure-ops.mjs';
|
|
13
|
-
import { shellQuoteArg } from '../repo-lex.mjs';
|
|
14
|
-
import { keepAside, keptAsidePath } from './kept-aside.mjs';
|
|
15
|
-
|
|
16
|
-
export { keptAsidePath };
|
|
17
|
-
|
|
18
|
-
const INDEX_NOT_RUN = 'the navigator step did not run: a replace run runs it only after every step it re-runs succeeds';
|
|
19
|
-
const RACE_LINE = 'the files to replace changed since the replace line was printed (another set or other bytes), so nothing was written — ask the user again over the fresh block below';
|
|
20
|
-
const HOOK_RUN = '; the commit hook runs it, so it may stop the next commit';
|
|
21
|
-
|
|
22
|
-
// The digest binds the set AND the bytes: `<rel> <sha256>` or `<rel> absent`, sorted by rel in
|
|
23
|
-
// code-unit order, LF-joined. Over an all-edited set it is the digest the specs op printed before.
|
|
24
|
-
const byRel = (a, b) => (a.rel < b.rel ? -1 : 1);
|
|
25
|
-
const digestLine = (entry) => `${entry.rel} ${entry.absent ? 'absent' : entry.sha256}`;
|
|
26
|
-
export const replaceSetDigest = (entries) => createHash('sha256').update([...entries].sort(byRel).map(digestLine).join('\n')).digest('hex');
|
|
27
|
-
|
|
28
|
-
const entryLine = (entry, digest) => `${entry.absent
|
|
29
|
-
? `${entry.rel}: absent — the user's yes places the bundled body`
|
|
30
|
-
: `${entry.rel}: carries an edit — on the user's yes it is kept aside at ${keptAsidePath(digest, entry.rel)}, then the bundled body replaces it; an edit meant to last goes in ${entry.channel}`}${entry.hookRun ? HOOK_RUN : ''}`;
|
|
31
|
-
|
|
32
|
-
// One line per entry in rel order, then the ONE command line, its condition first and both paths
|
|
33
|
-
// shell-quoted; no line at all for an empty set.
|
|
34
|
-
export const replaceBlock = (entries, { kitRoot, cwd }) => {
|
|
35
|
-
if (entries.length === 0) return [];
|
|
36
|
-
const digest = replaceSetDigest(entries);
|
|
37
|
-
return [
|
|
38
|
-
...[...entries].sort(byRel).map((entry) => entryLine(entry, digest)),
|
|
39
|
-
`only on the user's yes, keep aside and replace the files named above: node ${shellQuoteArg(join(kitRoot, 'tools', 'ensure-configs.mjs'))} --reconcile --replace-custom ${digest} --cwd ${shellQuoteArg(cwd)}`,
|
|
40
|
-
];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// A refused survey is a failed outcome that carries no entries field: that op takes no part.
|
|
44
|
-
const refused = (outcome) => outcome.failed && outcome.entries === undefined;
|
|
45
|
-
|
|
46
|
-
// runReplace({ cwd, kitRoot, digest, owning, index, deps }) → { outcomes, block }. `owning` is
|
|
47
|
-
// [{ op, run }] in ENSURE_OPS order and `index` the navigator's run; each run(args) returns an
|
|
48
|
-
// outcome and never throws (the CLI wraps it). `block` carries the recomputed union only when the
|
|
49
|
-
// digest differs — every other outcome of a replace run prints no block.
|
|
50
|
-
export const runReplace = ({ cwd, kitRoot, digest, owning, index, deps = {} }) => {
|
|
51
|
-
const surveys = owning.map(({ op, run }) => ({ op, run, survey: run({ cwd, kitRoot, dryRun: true, deps }) })).map((s) => ({ ...s, entries: s.survey.entries ?? [] }));
|
|
52
|
-
// Outcomes in owning order; index only when none failed, else the last failed one ends with the navigator line.
|
|
53
|
-
const finish = (results, block = []) => {
|
|
54
|
-
const outcomes = results.filter(Boolean);
|
|
55
|
-
const last = outcomes.findLastIndex((o) => o.failed);
|
|
56
|
-
if (last === -1) return { outcomes: [...outcomes, index({ cwd, kitRoot, dryRun: false, deps })], block };
|
|
57
|
-
return { outcomes: outcomes.map((o, i) => (i === last ? { ...o, lines: [...o.lines, INDEX_NOT_RUN] } : o)), block };
|
|
58
|
-
};
|
|
59
|
-
const results = surveys.map((s) => (refused(s.survey) ? s.survey : null));
|
|
60
|
-
const stopped = surveys.findIndex((s) => s.survey.failed && !refused(s.survey));
|
|
61
|
-
if (stopped !== -1) return finish(results.map((o, i) => (i === stopped ? surveys[i].survey : o)));
|
|
62
|
-
const taking = surveys.filter((s) => !refused(s.survey));
|
|
63
|
-
if (taking.length === 0) return finish(results);
|
|
64
|
-
const union = taking.flatMap((s) => s.entries);
|
|
65
|
-
const atFirst = (outcome) => results.map((o, i) => (surveys[i] === taking[0] ? outcome : o));
|
|
66
|
-
if (union.length > 0 && replaceSetDigest(union) !== digest) return finish(atFirst(composeFailure(taking[0].op, 'race-unresolved', RACE_LINE)), union);
|
|
67
|
-
const kept = keepAside({ cwd, digest, entries: union, deps });
|
|
68
|
-
if (kept.failed) return finish(atFirst(composeFailure(taking[0].op, kept.cause, ...kept.lines)));
|
|
69
|
-
for (const [i, s] of surveys.entries()) {
|
|
70
|
-
if (refused(s.survey)) continue;
|
|
71
|
-
results[i] = s.run({ cwd, kitRoot, dryRun: false, deps, replace: { digest, entries: s.entries } });
|
|
72
|
-
if (results[i].failed) break;
|
|
73
|
-
}
|
|
74
|
-
return finish(results);
|
|
75
|
-
};
|