@sabaiway/agent-workflow-kit 19.1.0 → 19.2.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 +28 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/contracts.md +7 -2
- package/references/modes/procedures.md +1 -1
- package/references/modes/upgrade.md +6 -6
- package/references/shared/composition-handoff.md +14 -12
- package/tools/inject-methodology.mjs +84 -149
- package/tools/project-rules/index.mjs +1 -1
- package/tools/project-rules/memory-map-row.mjs +24 -7
- package/tools/upgrade-runlist.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,34 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 19.2.0 — the entry file's kit pointers and Memory Map rows are written current with no question; a differing one is named with its route (AD-212)
|
|
8
|
+
|
|
9
|
+
**Your upgrade now writes the kit's three pointers in `AGENTS.md` current, with no question and no copy kept.**
|
|
10
|
+
Before, the reconcile filled an empty pointer and refreshed one that matched text the kit had shipped; any other text
|
|
11
|
+
between a pointer's two `<!-- workflow: -->` comment lines was kept as found, with an advisory note, so an edited
|
|
12
|
+
pointer stayed on old wording for good. Now a current pointer is left, a known earlier one refreshed, and any other
|
|
13
|
+
text is written with the installed engine's fragment, every byte outside the two comment lines unchanged and a CRLF
|
|
14
|
+
file staying CRLF. Its clause in the reconcile line reads `wrote the current <name> pointer over a different one`, and
|
|
15
|
+
one note line names where your own text goes:
|
|
16
|
+
|
|
17
|
+
`[inject-methodology] note: text of your own goes outside the two <!-- workflow: --> comment lines around each pointer.`
|
|
18
|
+
|
|
19
|
+
- **The Memory Map rows of the rules themes follow the same rule.** A theme's row with other text is written with the
|
|
20
|
+
current row (`the <theme> Memory Map row written with the current text`), and its note reads `a row of your own goes
|
|
21
|
+
on a line of its own, its first cell a path of your own`. A theme with more than one row, or a row that does not
|
|
22
|
+
close its cells on one line, is left as it stands with its reason.
|
|
23
|
+
- **The engine is read for every pointer the run judges.** A filled pointer cannot be judged without its fragment, so
|
|
24
|
+
a file whose three pointers are all filled now stops with the install command when the engine is absent, where it
|
|
25
|
+
was a zero-diff exit 0. The kit's own route always installs the engine; the No-Node walk reports that no pointer was
|
|
26
|
+
brought current and continues the upgrade.
|
|
27
|
+
- **The line cap still guards every write**: a differing pointer whose write would pass the 100-line cap takes the
|
|
28
|
+
same lane as a fill, and the chained soft skips are unchanged.
|
|
29
|
+
- **The advisory notes retire**: the procedures hint and the per-pointer upgrade advice no longer print.
|
|
30
|
+
- **The texts say the same.** `upgrade.md` (the pointers row and block, the No-Node walk, the step-4 and step-8
|
|
31
|
+
relays), the run-list's pointers outcomes (`written over a different one`), `composition-handoff.md`, the procedures
|
|
32
|
+
guide's cap-soft-skip paragraph and the guide's *Reserved names and channels*, which names the pointers and the
|
|
33
|
+
rules-theme rows as the kit's and gains the ninth channel.
|
|
34
|
+
|
|
7
35
|
## 19.1.0 — the kit sections of the agent rules file are written current with no question; a differing body is named with its route (AD-211)
|
|
8
36
|
|
|
9
37
|
**Your upgrade now writes the kit's three sections of `docs/ai/agent_rules.md` current, with no question and no copy
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: agent-workflow-kit
|
|
|
3
3
|
description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '19.
|
|
6
|
+
version: '19.2.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": "19.
|
|
3
|
+
"version": "19.2.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
|
@@ -106,9 +106,11 @@ Also the kit's: the vendor skill copy the kit installs into the three agent skil
|
|
|
106
106
|
when it matches a pin the kit shipped, written with no question beside a copy at a kit pin;
|
|
107
107
|
a copy matching none is the user's, left and named. Also the kit's: the three kit sections of
|
|
108
108
|
`docs/ai/agent_rules.md` (Communication, Story sessions and the planning/review lens), each
|
|
109
|
-
written current on every upgrade with no question and no copy kept.
|
|
109
|
+
written current on every upgrade with no question and no copy kept. Also the kit's: the three pointers of `AGENTS.md`
|
|
110
|
+
and its Memory Map rows of the rules themes, each written current on every upgrade with no question and no copy kept.
|
|
111
|
+
A declaration seeded once from a template and never
|
|
110
112
|
replaced by the upgrade's ensures (a migration rewrites one only on the user's explicit yes) is the
|
|
111
|
-
user's own file. A customization goes into one of
|
|
113
|
+
user's own file. A customization goes into one of nine channels instead:
|
|
112
114
|
|
|
113
115
|
- **Your own commit checks** go in the local hook file `scripts/pre-commit.local`: the managed
|
|
114
116
|
pre-commit hook runs it first, once the installer has run.
|
|
@@ -121,6 +123,9 @@ user's own file. A customization goes into one of eight channels instead:
|
|
|
121
123
|
- **A hook of your own** goes in `.claude/hooks/<name>.local.mjs`, which you wire.
|
|
122
124
|
- **Your own text in the agent rules file**: text of your own goes under a ### heading of its own,
|
|
123
125
|
titled unlike the kit's sections.
|
|
126
|
+
- **Your own text in the entry file `AGENTS.md`**: text of your own goes outside the two
|
|
127
|
+
`<!-- workflow: -->` comment lines around each pointer; a row of your own goes on a line of its
|
|
128
|
+
own, its first cell a path of your own.
|
|
124
129
|
|
|
125
130
|
No path segment of a file the kit bundles and places as its own has a dot-separated part exactly
|
|
126
131
|
`local`; a path of that form is the user's, and no kit tool writes one on its own. Outside that rule:
|
|
@@ -43,6 +43,6 @@ Run **`node ${CLAUDE_SKILL_DIR}/tools/procedures.mjs <activity> [--override <slo
|
|
|
43
43
|
|
|
44
44
|
**Record-bound review block (`feedback-triage` only).** In place of the driving contracts and the grounding pre-step the advisor renders the check-with-excerpts line, then one line per review member — a ready bridge's plan-mode command, a ready lens's brief (the record plus the excerpts), a skipped line for a not-ready member — and the round-table line while the slot carries a bridge obligation (a roster naming no bridge: the no-receipt fact in its place; a fully degraded reviewed or council slot keeps the line). The round-table line is followed by the standing fact that the table judges the obligation `review-rounds-cli` resolves from `docs/ai/orchestration.json`, never this run's `--override`. `--json` carries the identical lines under **`feedbackTriage`** (an empty array for the other activities).
|
|
45
45
|
|
|
46
|
-
**Cap-soft-skip degradation (the feature's only AUTO route).** The activity procedures are auto-discoverable only through the one-line **`workflow:methodology`** pointer (this kit + the engine carry `disable-model-invocation:true`, so NL like "write a plan" does **not** auto-load this skill). On a deployment whose methodology pointer
|
|
46
|
+
**Cap-soft-skip degradation (the feature's only AUTO route).** The activity procedures are auto-discoverable only through the one-line **`workflow:methodology`** pointer (this kit + the engine carry `disable-model-invocation:true`, so NL like "write a plan" does **not** auto-load this skill). On a deployment whose methodology pointer could not fit the line cap, the procedures are still reachable by **explicitly** invoking `/agent-workflow-kit procedures`; surface that plainly rather than treating it as a gap.
|
|
47
47
|
|
|
48
48
|
**Invariants:** read-only · never writes · never commits · never runs a subscription CLI · the deterministic resolution is the kit's, the recipe execution is the orchestrator's.
|
|
@@ -10,7 +10,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
10
10
|
2. **Never-downgrade gate — FIRST, before any write.** Compare the stamp to the **deployment-lineage head** (`4.0.0` — NOT this kit's package version). If the stamp is **greater than the head** or unparseable → **STOP and report**; do not touch a newer / unknown deployment at all (not even the methodology slot). This STOP is one of the few places the number is actionable (*Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`): show the user **the `docs/ai` structure version** their deployment carries versus the one this kit expects, plus the plain one-line two-axes note — naming it the structure version, **never** "lineage head".
|
|
11
11
|
3. **The step-3 run-list — stamp-independent reconciles, BEFORE the equal-head short-circuit.** Reached only when the stamp **≤ head**. Run the **eight operations below in order, on every upgrade** (equal-head too) — no lineage-head bump, no migration file. Each backticked id anchors its rationale block below the checklist; a consent marker is a CONDITIONAL gate — an explicit yes is required exactly where the row's clause states one:
|
|
12
12
|
|
|
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).
|
|
13
|
+
1. `pointers` — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` → per pointer: added · already present · written over a different one · skipped (reported) · a hard STOP; per Memory Map row of a rules theme: added · already present · refreshed · skipped (reported) · written.
|
|
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
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`.
|
|
@@ -19,17 +19,17 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
19
19
|
7. `tier` — `node ${CLAUDE_SKILL_DIR}/tools/tier-preview.mjs --cwd <project>` → per gap: present · offered · declined · undecidable · applied · recorded · refused — consent: one ask, only when offered.
|
|
20
20
|
8. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
|
|
21
21
|
|
|
22
|
-
**`pointers` — the bounded pointers.** ONE call reconciles **three** pointers — the **workflow-methodology** pointer, the **orchestration-recipes** pointer (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) right below it, and the **autonomy-policy** pointer (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) below that — and is filled on **every** upgrade, idempotently (zero-diff when all are already present + filled and the Memory Map rows present), so even a legacy or current equal-head deployment gains them **without a lineage-head bump or a migration** (the `agent-workflow-memory` **package** template did get docs-only headroom trims for the chained pointers, but no deployed-`docs/ai` structure changed). Per slot it inserts an empty pair at its anchor if absent,
|
|
22
|
+
**`pointers` — the bounded pointers.** ONE call reconciles **three** pointers — the **workflow-methodology** pointer, the **orchestration-recipes** pointer (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) right below it, and the **autonomy-policy** pointer (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) below that — and is filled on **every** upgrade, idempotently (zero-diff when all are already present + filled and the Memory Map rows present, each with the current text), so even a legacy or current equal-head deployment gains them **without a lineage-head bump or a migration** (the `agent-workflow-memory` **package** template did get docs-only headroom trims for the chained pointers, but no deployed-`docs/ai` structure changed). Per slot it inserts an empty pair at its anchor if absent, writes a pair holding other text with the current pointer, no question and no copy kept, its line naming the route — text of your own goes outside the two `<!-- workflow: -->` comment lines around each pointer — and STOPs (never edits) on a malformed pair or a missing / duplicate anchor. The installed `agent-workflow-engine` is read for every pointer the run judges (the fragments live there — see the distinct outcomes below), and an absent/invalid one STOPs also when every pointer is filled. The same call keeps one Memory Map row per project-rules theme, after the `docs/ai/agent_rules.md` row: a row with other text is written current, its line naming the route — a row of your own goes on a line of its own, its first cell a path of your own; one it cannot place is skipped and reported, never a STOP.
|
|
23
23
|
|
|
24
24
|
**Classify the exit — there are THREE non-zero exits + soft in-band skips; handle each differently:**
|
|
25
25
|
|
|
26
|
-
(a) **Soft, reported skip of a CHAINED pointer — orchestration and/or autonomy (CONTINUE the upgrade).** The chained pointers are the less-critical ones; when one can't be
|
|
26
|
+
(a) **Soft, reported skip of a CHAINED pointer — orchestration and/or autonomy (CONTINUE the upgrade).** The chained pointers are the less-critical ones; when one can't be brought current right now `reconcile` exits **zero**, writes the earlier pointers' results, and **reports each skip on stdout** (the `… skipped …` line) — never silent (Hard Constraint). Three reasons: **(i)** the prior pointers fit but adding or writing this one would push the file past the `AGENTS.md` 100-line cap; **(ii)** the installed `agent-workflow-engine` is **present but too old** to ship that fragment (`<1.2.0` lacks the recipes one; every engine before the autonomy release lacks the autonomy one) — it can still supply the earlier pointers, so only that pointer is not current; or **(iii)** — autonomy only — its **anchor is absent** because the orchestration pair is itself absent or was skipped, so the autonomy pointer has nowhere to chain (add the orchestration pointer first, then re-run). Report it in the successful-exit report (**step 4** equal-head, else **step 8**) in plain language, e.g. *"The orchestration-recipes / autonomy pointer wasn't added — the entry point is at its 100-line limit / your methodology engine is older than that feature. The recipes stay available via `/agent-workflow-kit recipes` and the autonomy policy via `/agent-workflow-kit set-autonomy`; to add the pointer, trim the entry point and/or refresh the engine with `npx @sabaiway/agent-workflow-engine@latest init`, then re-run upgrade."* (The separate case where the **methodology** pointer ITSELF can't fit the cap is a non-zero exit that changes nothing — continue without the pointers, same plain-language framing.) A skipped Memory Map row is its own clause, never a pointer skip: report it as step 4 words the rows.
|
|
27
27
|
|
|
28
28
|
(b) **Malformed pair / missing-or-duplicate anchor (any pointer) — a hard STOP (do NOT continue).** A non-zero exit whose message names a marker/anchor problem; never soft-skip it. (The one deliberate exception is (a)(iii): the autonomy pointer's ABSENT anchor is the chained soft skip, exit zero — a reported skip, not this STOP.)
|
|
29
29
|
|
|
30
|
-
(c) **`methodology engine not found/invalid …` — a hard STOP (do NOT continue).**
|
|
30
|
+
(c) **`methodology engine not found/invalid …` — a hard STOP (do NOT continue).** The engine is read for every pointer the run judges, so a **fully absent/invalid** installed `agent-workflow-engine` STOPs also when every pointer is filled — it can supply **no** fragment (distinct from (a)(ii), where the engine is valid but merely too old for a chained one). Report it in plain language with the one-line install command `npx @sabaiway/agent-workflow-engine@latest init` (or note that `npx @sabaiway/agent-workflow-kit@latest init` installs the engine for you), then re-run upgrade once it is present. **Never** treat (c) as a soft-skip (a) — mis-handling it would silently drop a pointer (a no-silent-failures violation). (b) and (c) STOP the upgrade; only (a) continues.
|
|
31
31
|
|
|
32
|
-
**No-Node project:** the fragments live only in the **installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md` + `references/autonomy-slot.md`, under `~/.claude/skills/agent-workflow-engine` or `$AGENT_WORKFLOW_ENGINE_DIR`) — there is no bundled copy, and a No-Node host cannot run the `npx` engine install. Open `AGENTS.md` and classify **each** pointer by hand: a **
|
|
32
|
+
**No-Node project:** the fragments live only in the **installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md` + `references/autonomy-slot.md`, under `~/.claude/skills/agent-workflow-engine` or `$AGENT_WORKFLOW_ENGINE_DIR`) — there is no bundled copy, and a No-Node host cannot run the `npx` engine install. Open `AGENTS.md` and classify **each** pointer by hand: a **malformed** pair (not exactly one ordered `start → end`) → STOP, do not edit. If the engine is **not installed**, no pointer is brought current this run — report it plainly (the methodology is already in `docs/ai/agent_rules.md`; the recipes are available via `/agent-workflow-kit recipes`; the autonomy policy via `/agent-workflow-kit set-autonomy`; install the engine to bring the pointers current), and the upgrade continues. If the engine **is** present, judge each pair against its engine fragment (`methodology-slot.md` / `orchestration-slot.md` / `autonomy-slot.md`): the same text → nothing to do; absent markers, an empty pair or other text → the fragment goes between the markers. **Count the lines first** — if a write would take the file over 100 lines, **skip that pointer and report the skip** (methodology first, then orchestration, then autonomy; each chained pair sits right under the previous pair's end marker). Never inline a copy (that would re-create the retired mirror).
|
|
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
|
|
|
@@ -114,7 +114,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
114
114
|
**The LATE navigator finalizer — the AUTHORITATIVE run, after the last `docs/ai` mutation.** `lens` above rewrites `docs/ai/agent_rules.md`, so the step-3 index ensure is already behind by the time the run-list ends. Re-run that ONE op here, before the step-4 report: `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>`. Relay **this** line in the report (it supersedes the early one; an untouched tree changes nothing, a failure STOPs the upgrade like any other ensure). On the migrated path the same rung runs again at the END of step 7 — after the migrations, before the step-8 re-stamp.
|
|
115
115
|
4. **Equal-head exit — a real successful-exit report, not a bare stop.** If the stamp **equals** the head, the lineage is up to date — but step 3 (the stamp-independent reconciles) ran first and may have changed things, so this is a proper exit report, not a no-op:
|
|
116
116
|
- **A skip line that contradicts the observed tree is a FINDING, never pasted as neutral.** Every ensure skip names the fact it proved (the probes that answered absent); if the tree you can see disproves that reason — a "no Node" skip beside deployed Node scripts, a "not deployed" skip beside a stamped `docs/ai` — do not relay the line as an outcome: raise it in the report as a defect of the tool, with the contradicting fact named, and stop short of any step that would build on the skip.
|
|
117
|
-
- **Report step 3's outcome in plain language** — for **each** `pointers` slot (workflow-methodology, orchestration-recipes and autonomy-policy) whether it was *added*, was *already present* (nothing changed), or was *skipped* (the soft-skip from step 3, with its reason — over the line limit / engine too old / the autonomy pointer's anchor absent), and each Memory Map row the same way (or *refreshed*); the **nine project-configuration ensure** (`configs`) lines exactly as the one ensure run composed them (the ensures and their outcome tokens are enumerated in step 3), each rendered in plain language: what was created, what was left exactly as the user wrote it, and — for a `failed` line — what stopped it; for the navigator, relay the **late** `--only index` line, not the early one; the **`gates-migration`** result — *nothing to migrate*, the shown plan *applied* on your explicit yes, or the plan *left unapplied* (consent not given), with any INERT checker or CUSTOMIZED entries named; the **placed-bridge refresh** (`bridges`) outcome — paste the tool's per-bridge lines verbatim (they are already plain: *refreshed* / *already current* / *skipped — not placed* / `skipped-readonly` with its re-scan verdict / *could not refresh* + recovery); the **agent-rules lens** (`lens`) outcome (*refreshed* / *already current* / *differing body written*, its line naming the route: text of your own goes under a ### heading of its own, titled unlike the kit's sections / *file absent* / *engine too old* / *over the line cap*; a doubled heading has nothing written) and the **Communication-section** and **story-sessions section** outcomes (each its own set: refreshed / already current / differing body written / section absent — noted / over the file's line cap — refused); the **full-flow offer** (`tier`) lines; the **bridge-settings reconcile** (`bridge-settings`) outcome (paste the tool's line(s) verbatim); and, for a hidden deployment, whether the hidden-mode footprint (`footprint`) was *moved to project-local*, was *already project-local* (nothing changed), or needed a question (ambiguous visibility). Plain wording only — never the reconcile/slot/anchor/marker terms (the never-leak-kit-internals Gotcha — `${CLAUDE_SKILL_DIR}/references/shared/deploy-tail.md`).
|
|
117
|
+
- **Report step 3's outcome in plain language** — for **each** `pointers` slot (workflow-methodology, orchestration-recipes and autonomy-policy) whether it was *added*, was *already present* (nothing changed), was *written over a different one* (its route: text of your own goes outside the two `<!-- workflow: -->` comment lines around each pointer), or was *skipped* (the soft-skip from step 3, with its reason — over the line limit / engine too old / the autonomy pointer's anchor absent), and each Memory Map row the same way (or *refreshed*), a *written* row with its route: a row of your own goes on a line of its own, its first cell a path of your own; the **nine project-configuration ensure** (`configs`) lines exactly as the one ensure run composed them (the ensures and their outcome tokens are enumerated in step 3), each rendered in plain language: what was created, what was left exactly as the user wrote it, and — for a `failed` line — what stopped it; for the navigator, relay the **late** `--only index` line, not the early one; the **`gates-migration`** result — *nothing to migrate*, the shown plan *applied* on your explicit yes, or the plan *left unapplied* (consent not given), with any INERT checker or CUSTOMIZED entries named; the **placed-bridge refresh** (`bridges`) outcome — paste the tool's per-bridge lines verbatim (they are already plain: *refreshed* / *already current* / *skipped — not placed* / `skipped-readonly` with its re-scan verdict / *could not refresh* + recovery); the **agent-rules lens** (`lens`) outcome (*refreshed* / *already current* / *differing body written*, its line naming the route: text of your own goes under a ### heading of its own, titled unlike the kit's sections / *file absent* / *engine too old* / *over the line cap*; a doubled heading has nothing written) and the **Communication-section** and **story-sessions section** outcomes (each its own set: refreshed / already current / differing body written / section absent — noted / over the file's line cap — refused); the **full-flow offer** (`tier`) lines; the **bridge-settings reconcile** (`bridge-settings`) outcome (paste the tool's line(s) verbatim); and, for a hidden deployment, whether the hidden-mode footprint (`footprint`) was *moved to project-local*, was *already project-local* (nothing changed), or needed a question (ambiguous visibility). Plain wording only — never the reconcile/slot/anchor/marker terms (the never-leak-kit-internals Gotcha — `${CLAUDE_SKILL_DIR}/references/shared/deploy-tail.md`).
|
|
118
118
|
- **Never surface the structure number on this exit.** Whatever step 3 did, do **not** recite the `docs/ai` structure version, the internal versioning vocabulary, or the two-axes note here — the number is inert on an equal-head exit; it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md` (shown at the never-downgrade STOP, the explicit status view, or on an explicit ask). Frame the success itself per the final bullet: if step 3 changed anything, say **what changed** in plain human terms; only a pure zero-diff no-op is *settings already current — no update needed*.
|
|
119
119
|
- **Render the mandatory Recommendations section — on this exit too, BEFORE the footer.** Run `node ${CLAUDE_SKILL_DIR}/tools/recommendations.mjs --cwd <project-root>` and PRESENT its output — from the `## Recommendations (agent-workflow)` header — in the user's conversational language: every fact, count and item from the tool, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; show the raw tool block on request. The section is present-even-when-empty (with everything optimal the body is exactly `no recommendations — flow optimal.`) and VERDICT-FIRST — the composed verdict line renders from the frozen templates `{K} item(s) need attention` / `nothing is broken` / `{N} optional recommendation(s), apply any you want` / `optimality NOT attested — {M} probe check(s) skipped`. Then apply each kit item by the kit route, with no question: its check line in the sandbox, then at once its apply line once outside it. Then OFFER the consent route: the user picks items in plain language; surface each picked item's posture note and get the explicit confirm; run its lane's rendered lines — chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — per the full consent route in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. Pinned order on this exit: Recommendations block → optional applies → report footer → the commit ask (the advisor/apply lane never lands after the commit ask).
|
|
120
120
|
- **Recommendations lanes — both exits.** The four lanes (`chat`, `harness`, `kit`, `user`), the consent route and the kit route live in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`; `init` stays a route the user may take.
|
|
@@ -23,25 +23,27 @@ exists, run ONE command — `node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.m
|
|
|
23
23
|
`/agent-workflow-kit recipes`) right below it, and the **autonomy-policy** pointer (the
|
|
24
24
|
`docs/ai/autonomy.json` read contract) below that. Each is **one atomic operation per slot**:
|
|
25
25
|
**ensure the slot exists**
|
|
26
|
-
(insert an empty marker pair at its anchor when a legacy entry point lacks one) → **
|
|
27
|
-
|
|
26
|
+
(insert an empty marker pair at its anchor when a legacy entry point lacks one) → **judge it against
|
|
27
|
+
the bounded fragment**: the same text needs no write; an empty slot is filled; any other text is
|
|
28
|
+
written with the fragment, no question and no copy kept, its line naming the route — text of your
|
|
29
|
+
own goes outside the two `<!-- workflow: -->` comment lines around each pointer →
|
|
28
30
|
**cap-check** (each chained pointer's check runs on the file *after* the previous one, so it guards the
|
|
29
|
-
**combined** ≤100-line budget). The
|
|
31
|
+
**combined** ≤100-line budget). The same call writes a Memory Map row with other text current, its
|
|
32
|
+
line naming the route — a row of your own goes on a line of its own, its first cell a path of your
|
|
33
|
+
own. The fragments are short summary + pointer, read **live from the
|
|
30
34
|
installed `agent-workflow-engine`** (`references/methodology-slot.md` + `references/orchestration-slot.md`
|
|
31
35
|
+ `references/autonomy-slot.md`,
|
|
32
36
|
the family's one source of truth) — **not** a bundled mirror, and **not** the full references. The
|
|
33
|
-
live read is **
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
**is** needed and the engine is **absent/invalid**, reconcile
|
|
37
|
-
**STOPs** — report it in plain language with the one-line install command
|
|
37
|
+
live read is **fail-loud**: the engine is read for every pointer the run judges, so an
|
|
38
|
+
**absent/invalid** engine **STOPs** the reconcile also when every pointer is filled — report it in
|
|
39
|
+
plain language with the one-line install command
|
|
38
40
|
`npx @sabaiway/agent-workflow-engine@latest init` (`npx @sabaiway/agent-workflow-kit@latest init`
|
|
39
41
|
installs the engine for you; translate, never leak tool internals). Contract per slot: exactly one
|
|
40
42
|
ordered `start → end` pair; a malformed slot (single, reversed, nested, duplicate) or a missing /
|
|
41
|
-
duplicate anchor → **STOP with an error**, never edit (
|
|
42
|
-
**chained pointer is soft-skipped** (reported, never silent) when — and only when — adding it
|
|
43
|
-
exceed the 100-line cap, the engine is too old to ship its fragment, or (autonomy only)
|
|
44
|
-
|
|
43
|
+
duplicate anchor → **STOP with an error**, never edit (nothing is written). A
|
|
44
|
+
**chained pointer is soft-skipped** (reported, never silent) when — and only when — adding or writing it
|
|
45
|
+
would exceed the 100-line cap, the engine is too old to ship its fragment, or (autonomy only) the
|
|
46
|
+
orchestration pointer was itself skipped this run: every prior pointer still lands and the upgrade continues.
|
|
45
47
|
|
|
46
48
|
**Agent-rules lens + Communication refresh (runs in BOTH paths).** Its precondition is its own target file — run it
|
|
47
49
|
only after `<project>/docs/ai/agent_rules.md` exists: after the substrate deploy in the
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
// exactly one ordered start→end pair → replace only the bytes between them;
|
|
15
15
|
// markers absent → ensure-insert an empty pair at the slot's anchor (or NO-OP in legacy inject);
|
|
16
16
|
// any malformed state (single, reversed, nested, duplicate) → NO-OP WITH AN ERROR, never edit.
|
|
17
|
-
// The live read is
|
|
18
|
-
//
|
|
17
|
+
// The live read is fail-loud: the engine is read for every slot the ensure can place (a filled slot
|
|
18
|
+
// cannot be judged without its fragment), and a needed-but-absent/invalid engine is a loud STOP.
|
|
19
19
|
// Pure string functions (testable with byte-preservation fixtures); dependency-free, Node >= 22.
|
|
20
20
|
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
21
|
+
// The policy per slot (entry-pointers revision 1): content equal to the fragment is left, a KNOWN PRIOR
|
|
22
|
+
// canonical fragment (drift-guarded, append-only per descriptor) is refreshed, and any other content is
|
|
23
|
+
// written current with no question and no copy kept. Contract: docs/ai/specs/kit/install/entry-pointers.md.
|
|
24
24
|
|
|
25
25
|
import { isDirectRun } from './direct-run.mjs';
|
|
26
26
|
import { normalizeCanonical } from './orchestration-config.mjs';
|
|
27
|
-
import { reconcileMemoryMapRows } from './project-rules/index.mjs';
|
|
27
|
+
import { reconcileMemoryMapRows, ROW_ROUTE } from './project-rules/index.mjs';
|
|
28
28
|
|
|
29
29
|
export const START_MARKER = '<!-- workflow:methodology:start -->';
|
|
30
30
|
export const END_MARKER = '<!-- workflow:methodology:end -->';
|
|
@@ -73,9 +73,8 @@ export const AUTONOMY_EMPTY_SLOT = `${AUTONOMY_START_MARKER}\n${AUTONOMY_END_MAR
|
|
|
73
73
|
|
|
74
74
|
// ── known-prior canonical fragments (drift-guarded, APPEND-ONLY per slot) ───────
|
|
75
75
|
// The EXACT content a PREVIOUS release's engine fragment shipped (what a filled slot would carry today).
|
|
76
|
-
// reconcileMarkerSlot
|
|
77
|
-
//
|
|
78
|
-
// customization (which never matches). Any release that CHANGES an engine fragment must FIRST append the
|
|
76
|
+
// reconcileMarkerSlot words a filled slot's write as a refresh IFF its content normalize-matches one of
|
|
77
|
+
// these. Any release that CHANGES an engine fragment must FIRST append the
|
|
79
78
|
// OUTGOING content here, so the immediately-previous deployments still match (a drift-guard test pins
|
|
80
79
|
// current-minus-one → new). NEVER edit an existing entry — only append.
|
|
81
80
|
export const KNOWN_PRIOR_METHODOLOGY_SLOT = [
|
|
@@ -100,9 +99,8 @@ export const KNOWN_PRIOR_ORCH_SLOT = [
|
|
|
100
99
|
// A slot descriptor bundles everything the generic engine needs to operate on ONE marker pair.
|
|
101
100
|
// `leadingBlank` controls whether the inserted empty pair gets a blank separator line above it — the
|
|
102
101
|
// methodology insert keeps it (readability), the orchestration insert omits it to save a cap line
|
|
103
|
-
// (the pair already sits right under the methodology block). `knownPriorCanonicals`
|
|
104
|
-
// `
|
|
105
|
-
// that predates the current clause.
|
|
102
|
+
// (the pair already sits right under the methodology block). `knownPriorCanonicals` words the refresh;
|
|
103
|
+
// `label` names the pointer in the reconcile line and the over-cap error.
|
|
106
104
|
export const METHODOLOGY_DESCRIPTOR = {
|
|
107
105
|
startMarker: START_MARKER,
|
|
108
106
|
endMarker: END_MARKER,
|
|
@@ -110,11 +108,9 @@ export const METHODOLOGY_DESCRIPTOR = {
|
|
|
110
108
|
emptySlot: EMPTY_SLOT,
|
|
111
109
|
leadingBlank: true,
|
|
112
110
|
markerName: 'methodology',
|
|
111
|
+
label: 'workflow-methodology',
|
|
113
112
|
anchorLabel: 'methodology anchor (the "Read it before any code change." Session-Protocols line)',
|
|
114
113
|
knownPriorCanonicals: KNOWN_PRIOR_METHODOLOGY_SLOT,
|
|
115
|
-
upgradeSignature: 'feedback-triage, epic, task',
|
|
116
|
-
upgradeAdvice:
|
|
117
|
-
'the workflow-methodology pointer predates the current canon — six named activities (plan-authoring, plan-execution, routine, feedback-triage, epic, task) with the communication-contract clause (deliver the artifact inline, lead with the result) — refresh it to the current canon, or add what it lacks by hand; the contract still applies.',
|
|
118
114
|
};
|
|
119
115
|
export const ORCHESTRATION_DESCRIPTOR = {
|
|
120
116
|
startMarker: ORCH_START_MARKER,
|
|
@@ -123,11 +119,9 @@ export const ORCHESTRATION_DESCRIPTOR = {
|
|
|
123
119
|
emptySlot: ORCH_EMPTY_SLOT,
|
|
124
120
|
leadingBlank: false,
|
|
125
121
|
markerName: 'orchestration',
|
|
122
|
+
label: 'orchestration-recipes',
|
|
126
123
|
anchorLabel: 'orchestration anchor (the methodology end-marker line)',
|
|
127
124
|
knownPriorCanonicals: KNOWN_PRIOR_ORCH_SLOT,
|
|
128
|
-
upgradeSignature: '/agent-workflow-kit set-recipe',
|
|
129
|
-
upgradeAdvice:
|
|
130
|
-
'the orchestration-recipes pointer predates the read-at-start clause — add "read `docs/ai/orchestration.json` at session start; set it with /agent-workflow-kit set-recipe", or set your preference now with /agent-workflow-kit set-recipe.',
|
|
131
125
|
};
|
|
132
126
|
// The autonomy-policy slot (AD-044 Plan 3) — first canon, so no known priors yet: any future
|
|
133
127
|
// fragment change must append the outgoing content to a KNOWN_PRIOR_AUTONOMY_SLOT store first.
|
|
@@ -138,11 +132,9 @@ export const AUTONOMY_DESCRIPTOR = {
|
|
|
138
132
|
emptySlot: AUTONOMY_EMPTY_SLOT,
|
|
139
133
|
leadingBlank: false,
|
|
140
134
|
markerName: 'autonomy',
|
|
135
|
+
label: 'autonomy',
|
|
141
136
|
anchorLabel: 'autonomy anchor (the orchestration end-marker line)',
|
|
142
137
|
knownPriorCanonicals: [],
|
|
143
|
-
upgradeSignature: 'docs/ai/autonomy.json',
|
|
144
|
-
upgradeAdvice:
|
|
145
|
-
'the autonomy pointer does not name the per-project policy file — add "read `docs/ai/autonomy.json` at session start; set it with /agent-workflow-kit set-autonomy", or refresh the slot to the current canon.',
|
|
146
138
|
};
|
|
147
139
|
|
|
148
140
|
// ── generic marker-slot engine (descriptor-parameterized) ──────────────────────
|
|
@@ -222,55 +214,40 @@ export const ensureMarkerSlot = (text, descriptor) => {
|
|
|
222
214
|
return { status: 'inserted', text: out };
|
|
223
215
|
};
|
|
224
216
|
|
|
225
|
-
// Bootstrap/upgrade reconciliation policy (pure): ensure the slot exists, then
|
|
226
|
-
//
|
|
227
|
-
//
|
|
217
|
+
// Bootstrap/upgrade reconciliation policy (pure): ensure the slot exists, then judge the bytes between
|
|
218
|
+
// its markers against `fragment`, enforcing the line cap — all as one step the CLI commits with a single
|
|
219
|
+
// atomic write. On ANY error the INPUT bytes are returned unchanged.
|
|
228
220
|
// reconciled-inserted — slot was absent, inserted at the anchor, then filled.
|
|
229
221
|
// reconciled-filled — slot existed but was empty, now filled.
|
|
230
222
|
// reconciled-refreshed — slot was filled with a KNOWN PRIOR canonical → replaced with `fragment`.
|
|
231
|
-
//
|
|
232
|
-
//
|
|
223
|
+
// reconciled-written — slot held any other content → replaced with `fragment`.
|
|
224
|
+
// present-filled — slot already carries `fragment` → left, bytes unchanged.
|
|
225
|
+
// error — malformed slot, 0/>1 anchors, a blank fragment, or cap exceeded → input unchanged.
|
|
233
226
|
export const reconcileMarkerSlot = (text, descriptor, fragment, { maxLines } = {}) => {
|
|
234
227
|
const ensured = ensureMarkerSlot(text, descriptor);
|
|
235
228
|
if (ensured.status === 'error') return { status: 'error', text, error: ensured.error };
|
|
229
|
+
if (fragment.trim() === '') return { status: 'error', text, error: `the ${descriptor.label} fragment is blank — refusing to write an empty pointer` };
|
|
236
230
|
const current = extractMarkerSlot(ensured.text, descriptor);
|
|
237
|
-
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (matchesPrior) {
|
|
245
|
-
const injected = injectIntoSlot(ensured.text, descriptor, fragment, { maxLines });
|
|
246
|
-
if (injected.status !== 'injected') return { status: 'error', text, error: injected.error };
|
|
247
|
-
return { status: 'reconciled-refreshed', text: injected.text };
|
|
248
|
-
}
|
|
249
|
-
if (maxLines != null && lineCount(ensured.text) > maxLines) {
|
|
250
|
-
return { status: 'error', text, error: `AGENTS.md is ${lineCount(ensured.text)} lines (cap ${maxLines}) — trim the file (a customized ${descriptor.markerName} slot must still fit the cap)` };
|
|
231
|
+
let status = ensured.status === 'inserted' ? 'reconciled-inserted' : 'reconciled-filled';
|
|
232
|
+
if (current.trim() !== '') {
|
|
233
|
+
if (normalizeCanonical(current) === normalizeCanonical(fragment)) {
|
|
234
|
+
if (maxLines != null && lineCount(ensured.text) > maxLines) {
|
|
235
|
+
return { status: 'error', text, error: `AGENTS.md is ${lineCount(ensured.text)} lines (cap ${maxLines}) — trim the file (the current ${descriptor.label} pointer must still fit the cap)` };
|
|
236
|
+
}
|
|
237
|
+
return { status: 'present-filled', text: ensured.text };
|
|
251
238
|
}
|
|
252
|
-
|
|
239
|
+
const priors = descriptor.knownPriorCanonicals ?? [];
|
|
240
|
+
status = priors.some((p) => normalizeCanonical(p) === normalizeCanonical(current)) ? 'reconciled-refreshed' : 'reconciled-written';
|
|
253
241
|
}
|
|
254
242
|
const injected = injectIntoSlot(ensured.text, descriptor, fragment, { maxLines });
|
|
255
243
|
if (injected.status !== 'injected') return { status: 'error', text, error: injected.error };
|
|
256
|
-
const status = ensured.status === 'inserted' ? 'reconciled-inserted' : 'reconciled-filled';
|
|
257
244
|
return { status, text: injected.text };
|
|
258
245
|
};
|
|
259
246
|
|
|
260
|
-
// Pure predicate (no fs):
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
export const markerSlotNeedsFill = (text, descriptor) => {
|
|
265
|
-
const ensured = ensureMarkerSlot(text, descriptor);
|
|
266
|
-
if (ensured.status === 'error') return false;
|
|
267
|
-
const current = extractMarkerSlot(ensured.text, descriptor);
|
|
268
|
-
if (current == null || current.trim() === '') return true; // empty → fill
|
|
269
|
-
// filled-but-STALE (content matches a known prior canonical) → needs a refresh, so main() must
|
|
270
|
-
// re-source the fragment. A customized slot doesn't match → no source needed (preserved verbatim).
|
|
271
|
-
const priors = descriptor.knownPriorCanonicals ?? [];
|
|
272
|
-
return priors.some((p) => normalizeCanonical(p) === normalizeCanonical(current));
|
|
273
|
-
};
|
|
247
|
+
// Pure predicate (no fs): can the ensure place this slot (present or insertable)? Every such slot is
|
|
248
|
+
// judged against its fragment, so main() reads the engine exactly when this is true. Reuses the SAME
|
|
249
|
+
// ensure as reconcileMarkerSlot, so the engine-read guard cannot diverge from the policy.
|
|
250
|
+
export const markerSlotEnsurable = (text, descriptor) => ensureMarkerSlot(text, descriptor).status !== 'error';
|
|
274
251
|
|
|
275
252
|
// ── methodology-slot exports (delegate to the generic engine, byte-for-byte) ────
|
|
276
253
|
|
|
@@ -279,36 +256,9 @@ export const injectMethodology = (text, fragment, opts) => injectIntoSlot(text,
|
|
|
279
256
|
export const extractSlot = (text) => extractMarkerSlot(text, METHODOLOGY_DESCRIPTOR);
|
|
280
257
|
export const ensureSlot = (text) => ensureMarkerSlot(text, METHODOLOGY_DESCRIPTOR);
|
|
281
258
|
export const reconcileSlot = (text, fragment, opts) => reconcileMarkerSlot(text, METHODOLOGY_DESCRIPTOR, fragment, opts);
|
|
282
|
-
export const slotNeedsFill = (text) => markerSlotNeedsFill(text, METHODOLOGY_DESCRIPTOR);
|
|
283
|
-
|
|
284
|
-
// The routing token the methodology pointer should carry so NL like "write a plan" auto-discovers the
|
|
285
|
-
// activity procedures. A deployment whose methodology slot was filled (legacy / customized) BEFORE this
|
|
286
|
-
// clause existed will NOT auto-receive it — reconcile preserves a filled slot verbatim (AD-019 §3.1a).
|
|
287
|
-
export const PROCEDURES_POINTER = '/agent-workflow-kit procedures';
|
|
288
|
-
|
|
289
|
-
// Read-only upgrade advisory (NO mutation): when the methodology slot is present + FILLED but lacks the
|
|
290
|
-
// procedures route, return a one-line note the upgrade flow surfaces — add it for auto-discovery; the
|
|
291
|
-
// feature is reachable now via the explicit command. Returns null for an absent / empty / malformed slot
|
|
292
|
-
// or one that already routes to procedures. Pure; never edits the file.
|
|
293
|
-
export const methodologyProceduresHint = (text) => {
|
|
294
|
-
const content = extractSlot(text);
|
|
295
|
-
if (content == null || content.trim() === '') return null; // only a FILLED methodology slot
|
|
296
|
-
if (content.includes(PROCEDURES_POINTER)) return null; // already routes to the procedures advisor
|
|
297
|
-
return `the methodology pointer has no procedures route — add "${PROCEDURES_POINTER} <activity>" for auto-discovery; the activity procedures are reachable now via ${PROCEDURES_POINTER}.`;
|
|
298
|
-
};
|
|
299
259
|
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
// be canonical-refreshed — its content is customized) gets a one-line note the upgrade flow surfaces.
|
|
303
|
-
// Returns null for an absent / empty / malformed slot, or one that already carries the signature. Pure;
|
|
304
|
-
// never edits the file (a customization is never rewritten — only the user decides).
|
|
305
|
-
export const markerSlotUpgradeHint = (text, descriptor) => {
|
|
306
|
-
if (!descriptor.upgradeSignature) return null;
|
|
307
|
-
const content = extractMarkerSlot(text, descriptor);
|
|
308
|
-
if (content == null || content.trim() === '') return null; // only a FILLED slot
|
|
309
|
-
if (content.includes(descriptor.upgradeSignature)) return null; // already carries the current clause
|
|
310
|
-
return descriptor.upgradeAdvice;
|
|
311
|
-
};
|
|
260
|
+
// The route the reconcile's pointer note names when it wrote a pointer over a different one.
|
|
261
|
+
export const POINTER_ROUTE = 'text of your own goes outside the two <!-- workflow: --> comment lines around each pointer';
|
|
312
262
|
|
|
313
263
|
// A cap-refusal is a SOFT, reported skip (distinct from a malformed/anchor STOP) — keyed off the
|
|
314
264
|
// stable "(cap N)" substring both cap messages carry, so the dual-slot reconcile can skip the
|
|
@@ -316,14 +266,26 @@ export const markerSlotUpgradeHint = (text, descriptor) => {
|
|
|
316
266
|
const isCapRefusal = (errorMessage) => typeof errorMessage === 'string' && errorMessage.includes('(cap ');
|
|
317
267
|
// The autonomy lane distinguishes the TWO cap messages "(cap " conflates (D4 cap-lane honesty):
|
|
318
268
|
// only a FILL-overflow from an in-cap input (injectIntoSlot's "injection would push …") is the soft
|
|
319
|
-
// skip — the pointer was genuinely withheld. An ALREADY-over-cap
|
|
269
|
+
// skip — the pointer was genuinely withheld. An ALREADY-over-cap file (reconcileMarkerSlot's
|
|
320
270
|
// "AGENTS.md is N lines … trim the file") keeps its distinct over-cap report as a hard refusal,
|
|
321
271
|
// never a mislabeled "skipped". Exported so the split is pinned against the real messages.
|
|
322
272
|
export const isFillCapRefusal = (errorMessage) =>
|
|
323
273
|
isCapRefusal(errorMessage) && errorMessage.includes('injection would push');
|
|
324
274
|
|
|
325
275
|
const EXIT = Symbol('inject-methodology.exit');
|
|
326
|
-
const ROW_WORDS = { inserted: 'added', kept: 'already present', refreshed: 'refreshed to the current text' };
|
|
276
|
+
const ROW_WORDS = { inserted: 'added', kept: 'already present', refreshed: 'refreshed to the current text', written: 'written with the current text' };
|
|
277
|
+
// The reconcile line's clause for a judged slot, by its status.
|
|
278
|
+
const describeSlot = (descriptor, status) => {
|
|
279
|
+
const pointer = `${descriptor.label} pointer`;
|
|
280
|
+
const where = descriptor === METHODOLOGY_DESCRIPTOR ? 'at the Session-Protocols anchor' : 'below it';
|
|
281
|
+
return {
|
|
282
|
+
'reconciled-inserted': `inserted the ${pointer} ${where} and filled it`,
|
|
283
|
+
'reconciled-filled': `filled the empty ${pointer}`,
|
|
284
|
+
'reconciled-refreshed': `refreshed the ${pointer} to the current canon`,
|
|
285
|
+
'reconciled-written': `wrote the current ${pointer} over a different one`,
|
|
286
|
+
'present-filled': `${pointer} already present`,
|
|
287
|
+
}[status];
|
|
288
|
+
};
|
|
327
289
|
|
|
328
290
|
// The return-code entry point (5.1): argv[] + injected env/home → { code, stdout, stderr }, no
|
|
329
291
|
// process.argv / process.exit / console inside — an in-process caller is as hermetic as a spawned
|
|
@@ -362,11 +324,11 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
362
324
|
try {
|
|
363
325
|
const text = await readFile(resolve(agentsPath), 'utf8');
|
|
364
326
|
|
|
365
|
-
// Source a bounded fragment
|
|
366
|
-
//
|
|
367
|
-
//
|
|
368
|
-
//
|
|
369
|
-
//
|
|
327
|
+
// Source a bounded fragment per slot. An explicit [fragment.md] arg (tests + manual) wins and skips
|
|
328
|
+
// engine resolution entirely; it binds the METHODOLOGY slot only. Otherwise read it LIVE from the
|
|
329
|
+
// installed engine (no bundled mirror) — readEngineFragment THROWS (never falls back) when the engine
|
|
330
|
+
// is needed but absent/invalid; sourceFragmentOrStop turns that into a hard, loud STOP carrying the
|
|
331
|
+
// install command. The caller invokes this for every slot the ensure can place.
|
|
370
332
|
const sourceFragment = async (rel) => {
|
|
371
333
|
if (explicitFragmentArg) return readFile(resolve(explicitFragmentArg), 'utf8');
|
|
372
334
|
const { dir, source } = resolveEngineDir({ env, home });
|
|
@@ -383,10 +345,10 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
383
345
|
}
|
|
384
346
|
};
|
|
385
347
|
|
|
386
|
-
// The orchestration + autonomy fragments are the CHAINED (less-critical) pointers. Source each
|
|
387
|
-
//
|
|
388
|
-
//
|
|
389
|
-
//
|
|
348
|
+
// The orchestration + autonomy fragments are the CHAINED (less-critical) pointers. Source each, but
|
|
349
|
+
// DISTINGUISH two failures keyed off the engine's own detection (not message text): an engine that
|
|
350
|
+
// is VALID but simply TOO OLD to ship the requested fragment is a SOFT skip — the earlier slots'
|
|
351
|
+
// results are written and the pointer is reported as withheld (parallel to the cap-skip); only a FULLY
|
|
390
352
|
// absent/invalid engine (it cannot supply ANY pointer) is a hard STOP. A read error on a PRESENT
|
|
391
353
|
// fragment is a real corruption STOP, NEVER a "too old" skip (don't mislabel a current engine with
|
|
392
354
|
// an unreadable fragment). Returns { fragment } on success, { skip } for the soft case, or
|
|
@@ -426,8 +388,8 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
426
388
|
};
|
|
427
389
|
|
|
428
390
|
if (mode === 'reconcile') {
|
|
429
|
-
// ── Slot 1: methodology (
|
|
430
|
-
const methFragment =
|
|
391
|
+
// ── Slot 1: methodology (the engine read for a slot the ensure can place, then reconcile) ──
|
|
392
|
+
const methFragment = markerSlotEnsurable(text, METHODOLOGY_DESCRIPTOR) ? await sourceFragmentOrStop('reconcile STOP', ENGINE_FRAGMENT_REL) : '';
|
|
431
393
|
const methResult = reconcileSlot(text, methFragment, { maxLines: AGENTS_MD_CAP });
|
|
432
394
|
if (methResult.status === 'error') {
|
|
433
395
|
// cap-refusal OR malformed/anchor STOP — preserve the single-slot classification (SKILL.md
|
|
@@ -435,23 +397,13 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
435
397
|
logError(`[inject-methodology] reconcile refused — ${methResult.error}`);
|
|
436
398
|
return result(1);
|
|
437
399
|
}
|
|
438
|
-
const afterMeth = methResult.text; // === text when the methodology slot was already
|
|
439
|
-
const describeMeth =
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
// Read-only upgrade advisories for a CUSTOMIZED methodology pointer that reconcile preserved verbatim
|
|
446
|
-
// (a refreshed/filled/inserted slot already carries the current canon, so it gets none): the AD-019 procedures route
|
|
447
|
-
// AND the current-canon hint, keyed on the six-activity token (it names the §1.9 clause too). No mutation — notes only.
|
|
448
|
-
const notes = [];
|
|
449
|
-
if (methResult.status === 'present-filled') {
|
|
450
|
-
const p = methodologyProceduresHint(afterMeth); if (p) notes.push(p);
|
|
451
|
-
const u = markerSlotUpgradeHint(afterMeth, METHODOLOGY_DESCRIPTOR); if (u) notes.push(u);
|
|
452
|
-
}
|
|
453
|
-
const reportNotes = () => {
|
|
454
|
-
for (const n of notes) log(`[inject-methodology] note: ${n}`);
|
|
400
|
+
const afterMeth = methResult.text; // === text when the methodology slot was already current
|
|
401
|
+
const describeMeth = describeSlot(METHODOLOGY_DESCRIPTOR, methResult.status);
|
|
402
|
+
// One pointer note when a pointer was written over a different one; the row note follows it.
|
|
403
|
+
let pointerWritten = methResult.status === 'reconciled-written';
|
|
404
|
+
const reportNotes = (rowWritten = false) => {
|
|
405
|
+
if (pointerWritten) log(`[inject-methodology] note: ${POINTER_ROUTE}.`);
|
|
406
|
+
if (rowWritten) log(`[inject-methodology] note: ${ROW_ROUTE}.`);
|
|
455
407
|
};
|
|
456
408
|
|
|
457
409
|
// ── Explicit [fragment.md] binds methodology ONLY → skip the orchestration + autonomy reconciles ──
|
|
@@ -462,21 +414,22 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
462
414
|
}
|
|
463
415
|
await writeAtomic(afterMeth);
|
|
464
416
|
log(`[inject-methodology] reconcile: ${describeMeth}.`);
|
|
417
|
+
reportNotes();
|
|
465
418
|
return result(0);
|
|
466
419
|
}
|
|
467
420
|
|
|
468
421
|
// ── Slot 2: orchestration, reconciled on the methodology-reconciled text (the cap-check then guards
|
|
469
|
-
// the COMBINED ≤100).
|
|
422
|
+
// the COMBINED ≤100). The engine is read whenever the ensure can place the slot. ──
|
|
470
423
|
let finalText = afterMeth;
|
|
471
424
|
let describeOrch;
|
|
472
425
|
let orchSkipped = false;
|
|
473
426
|
|
|
474
|
-
const orchSource =
|
|
427
|
+
const orchSource = markerSlotEnsurable(afterMeth, ORCHESTRATION_DESCRIPTOR)
|
|
475
428
|
? await sourceChainedFragment(ORCHESTRATION_FRAGMENT_REL)
|
|
476
429
|
: { fragment: '' };
|
|
477
430
|
if (orchSource.skip) {
|
|
478
431
|
// Engine too old to supply the recipes pointer → SOFT skip, parallel to the cap-skip: the
|
|
479
|
-
// methodology
|
|
432
|
+
// methodology result is written; the recipes pointer is reported as withheld.
|
|
480
433
|
orchSkipped = true;
|
|
481
434
|
describeOrch = `orchestration-recipes pointer skipped — ${orchSource.skip}`;
|
|
482
435
|
} else {
|
|
@@ -484,7 +437,7 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
484
437
|
if (orchResult.status === 'error') {
|
|
485
438
|
if (isCapRefusal(orchResult.error)) {
|
|
486
439
|
// SOFT skip — keep the methodology result, report the orchestration cap-skip loudly (not
|
|
487
|
-
// silent)
|
|
440
|
+
// silent); the orchestration slot is unchanged.
|
|
488
441
|
orchSkipped = true;
|
|
489
442
|
describeOrch = `orchestration-recipes pointer skipped — ${orchResult.error}`;
|
|
490
443
|
} else {
|
|
@@ -494,27 +447,17 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
494
447
|
}
|
|
495
448
|
} else {
|
|
496
449
|
finalText = orchResult.text;
|
|
497
|
-
describeOrch =
|
|
498
|
-
|
|
499
|
-
'reconciled-filled': 'filled the empty orchestration-recipes pointer',
|
|
500
|
-
'reconciled-refreshed': 'refreshed the orchestration-recipes pointer to the current canon',
|
|
501
|
-
'present-filled': 'orchestration-recipes pointer already present',
|
|
502
|
-
}[orchResult.status];
|
|
503
|
-
// §1.6a advisory: a CUSTOMIZED orchestration pointer preserved verbatim, lacking the read-at-start
|
|
504
|
-
// clause, gets a read-only nudge (a refreshed/filled slot already carries it).
|
|
505
|
-
if (orchResult.status === 'present-filled') {
|
|
506
|
-
const u = markerSlotUpgradeHint(finalText, ORCHESTRATION_DESCRIPTOR);
|
|
507
|
-
if (u) notes.push(u);
|
|
508
|
-
}
|
|
450
|
+
describeOrch = describeSlot(ORCHESTRATION_DESCRIPTOR, orchResult.status);
|
|
451
|
+
pointerWritten ||= orchResult.status === 'reconciled-written';
|
|
509
452
|
}
|
|
510
453
|
}
|
|
511
454
|
|
|
512
455
|
// ── Slot 3: autonomy, chained on the orchestration-reconciled text (same combined ≤100 guard).
|
|
513
|
-
// D4 invariant: every failure lane SPECIFIC to this slot is a LOUD soft skip that
|
|
514
|
-
//
|
|
456
|
+
// D4 invariant: every failure lane SPECIFIC to this slot is a LOUD soft skip that writes the
|
|
457
|
+
// earlier slots' results and exits 0 — (i) a too-old engine (no autonomy fragment), (ii) a
|
|
515
458
|
// fill-overflow cap refusal, (iii) an ABSENT anchor (the orchestration pair is absent or was
|
|
516
|
-
// itself skipped above — a 0-anchors ensure error must not discard the methodology
|
|
517
|
-
// Malformed autonomy markers, an already-over-cap
|
|
459
|
+
// itself skipped above — a 0-anchors ensure error must not discard the methodology result).
|
|
460
|
+
// Malformed autonomy markers, an already-over-cap file, a present-but-unreadable
|
|
518
461
|
// fragment, and a fully absent/invalid engine stay hard STOPs. ──
|
|
519
462
|
let describeAut;
|
|
520
463
|
let autSkipped = false;
|
|
@@ -538,7 +481,7 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
538
481
|
describeAut =
|
|
539
482
|
'autonomy pointer skipped — chained below the orchestration pointer, which was itself skipped this run; re-run once it lands';
|
|
540
483
|
} else {
|
|
541
|
-
const autSource =
|
|
484
|
+
const autSource = markerSlotEnsurable(finalText, AUTONOMY_DESCRIPTOR)
|
|
542
485
|
? await sourceChainedFragment(AUTONOMY_FRAGMENT_REL)
|
|
543
486
|
: { fragment: '' };
|
|
544
487
|
if (autSource.skip) {
|
|
@@ -549,7 +492,7 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
549
492
|
if (autResult.status === 'error') {
|
|
550
493
|
if (isFillCapRefusal(autResult.error)) {
|
|
551
494
|
// SOFT skip — only the genuine fill-overflow withholds the pointer; an already-over-cap
|
|
552
|
-
//
|
|
495
|
+
// file keeps its distinct over-cap report via the hard-STOP branch below.
|
|
553
496
|
autSkipped = true;
|
|
554
497
|
describeAut = `autonomy pointer skipped — ${autResult.error}`;
|
|
555
498
|
} else {
|
|
@@ -558,16 +501,8 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
558
501
|
}
|
|
559
502
|
} else {
|
|
560
503
|
finalText = autResult.text;
|
|
561
|
-
describeAut =
|
|
562
|
-
|
|
563
|
-
'reconciled-filled': 'filled the empty autonomy pointer',
|
|
564
|
-
'reconciled-refreshed': 'refreshed the autonomy pointer to the current canon',
|
|
565
|
-
'present-filled': 'autonomy pointer already present',
|
|
566
|
-
}[autResult.status];
|
|
567
|
-
if (autResult.status === 'present-filled') {
|
|
568
|
-
const u = markerSlotUpgradeHint(finalText, AUTONOMY_DESCRIPTOR);
|
|
569
|
-
if (u) notes.push(u);
|
|
570
|
-
}
|
|
504
|
+
describeAut = describeSlot(AUTONOMY_DESCRIPTOR, autResult.status);
|
|
505
|
+
pointerWritten ||= autResult.status === 'reconciled-written';
|
|
571
506
|
}
|
|
572
507
|
}
|
|
573
508
|
}
|
|
@@ -575,16 +510,16 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
575
510
|
// ── The Memory Map rows on the three-slot text, then one atomic write ──
|
|
576
511
|
const rows = reconcileMemoryMapRows(finalText, { maxLines: AGENTS_MD_CAP });
|
|
577
512
|
const describeRows = rows.outcomes.map((o) => `the ${o.theme} Memory Map row ${ROW_WORDS[o.status] ?? `skipped — ${o.note}`}`).join('; ');
|
|
513
|
+
const rowWritten = rows.outcomes.some((o) => o.status === 'written');
|
|
578
514
|
if (rows.text === text) {
|
|
579
515
|
// Byte-unchanged. Still report a skip (it is not "nothing to do" — a pointer was withheld).
|
|
580
516
|
if (orchSkipped || autSkipped) log(`[inject-methodology] reconcile: ${describeMeth}; ${describeOrch}; ${describeAut}; ${describeRows}.`);
|
|
581
517
|
else log(`[inject-methodology] reconcile: all three pointers already present and filled; ${describeRows} — nothing to do (zero-diff).`);
|
|
582
|
-
reportNotes();
|
|
583
518
|
return result(0);
|
|
584
519
|
}
|
|
585
520
|
await writeAtomic(rows.text);
|
|
586
521
|
log(`[inject-methodology] reconcile: ${describeMeth}; ${describeOrch}; ${describeAut}; ${describeRows}.`);
|
|
587
|
-
reportNotes();
|
|
522
|
+
reportNotes(rowWritten);
|
|
588
523
|
return result(0);
|
|
589
524
|
}
|
|
590
525
|
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export { THEMES } from './themes.mjs';
|
|
3
3
|
export { checkRules } from './rules-check.mjs';
|
|
4
4
|
export { ensureRules } from './rules-ensure.mjs';
|
|
5
|
-
export { reconcileMemoryMapRows } from './memory-map-row.mjs';
|
|
5
|
+
export { reconcileMemoryMapRows, ROW_ROUTE } from './memory-map-row.mjs';
|
|
@@ -8,6 +8,9 @@ import { THEMES, themePaths } from './themes.mjs';
|
|
|
8
8
|
// the outgoing one here.
|
|
9
9
|
export const MEMORY_MAP_PRIOR_ROWS = Object.freeze([]);
|
|
10
10
|
|
|
11
|
+
// The route the reconcile's row note names when it wrote a row with other text.
|
|
12
|
+
export const ROW_ROUTE = 'a row of your own goes on a line of its own, its first cell a path of your own';
|
|
13
|
+
|
|
11
14
|
const ANCHOR_PATH = 'docs/ai/agent_rules.md';
|
|
12
15
|
const opening = (path) => `| [\`${path}\`](./${path}) |`;
|
|
13
16
|
const rowOf = (theme) => {
|
|
@@ -21,6 +24,11 @@ const bodyOf = (line) => line.replace(/\r?\n$/, '');
|
|
|
21
24
|
const endingOf = (line) => line.slice(bodyOf(line).length);
|
|
22
25
|
// A table line that does not close its last cell goes on over the next line.
|
|
23
26
|
const isWhole = (line) => bodyOf(line).trimEnd().endsWith('|');
|
|
27
|
+
// One whole row: at least four | that no backslash escapes, the last of them closing the line.
|
|
28
|
+
const isOneRow = (line) => {
|
|
29
|
+
const body = bodyOf(line).trimEnd();
|
|
30
|
+
return (body.match(/(?<!\\)\|/g) ?? []).length >= 4 && /(?<!\\)\|$/.test(body);
|
|
31
|
+
};
|
|
24
32
|
|
|
25
33
|
// placeAfter(lines, i, row) → the lines with row on the line after i, taking line i's ending.
|
|
26
34
|
const placeAfter = (lines, i, row) => {
|
|
@@ -30,21 +38,30 @@ const placeAfter = (lines, i, row) => {
|
|
|
30
38
|
};
|
|
31
39
|
|
|
32
40
|
// reconcileMemoryMapRows(text, { maxLines, priors }) → { text, outcomes }: one outcome
|
|
33
|
-
// { theme, status, note } per registry theme in registry order, status inserted, kept, refreshed
|
|
34
|
-
// skipped; a skipped theme changes no byte and its note names the reason.
|
|
41
|
+
// { theme, status, note } per registry theme in registry order, status inserted, kept, refreshed,
|
|
42
|
+
// written or skipped; a skipped theme changes no byte and its note names the reason.
|
|
35
43
|
export const reconcileMemoryMapRows = (text, { maxLines, priors = MEMORY_MAP_PRIOR_ROWS } = {}) => {
|
|
36
44
|
let lines = splitLines(text);
|
|
37
45
|
let last = -1;
|
|
38
46
|
const outcomes = [];
|
|
39
47
|
for (const theme of THEMES) {
|
|
40
48
|
const row = rowOf(theme);
|
|
49
|
+
const path = themePaths(theme.name).effective;
|
|
41
50
|
const answer = (status, note = '') => outcomes.push({ theme: theme.name, status, note });
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
|
|
51
|
+
const found = lines.flatMap((line, i) => (line.startsWith(opening(path)) ? [i] : []));
|
|
52
|
+
if (found.length > 1) {
|
|
53
|
+
answer('skipped', `the Memory Map has more than one ${path} row — none of them was changed`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (found.length === 1) {
|
|
57
|
+
const at = found[0];
|
|
58
|
+
const body = bodyOf(lines[at]);
|
|
59
|
+
if (!isOneRow(lines[at])) answer('skipped', `the ${path} row does not close its cells on one line — left as it stands`);
|
|
60
|
+
else if (body === row) answer('kept');
|
|
61
|
+
else {
|
|
45
62
|
lines = lines.with(at, `${row}${endingOf(lines[at])}`);
|
|
46
|
-
answer('refreshed');
|
|
47
|
-
}
|
|
63
|
+
answer(priors.includes(body) ? 'refreshed' : 'written');
|
|
64
|
+
}
|
|
48
65
|
continue;
|
|
49
66
|
}
|
|
50
67
|
const anchor = last !== -1 ? last : lines.findIndex((line) => line.startsWith(opening(ANCHOR_PATH)));
|
|
@@ -23,7 +23,7 @@ export const UPGRADE_RUNLIST = Object.freeze([
|
|
|
23
23
|
'pointers',
|
|
24
24
|
'node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md',
|
|
25
25
|
null,
|
|
26
|
-
['added', 'already present', 'skipped', 'STOP'],
|
|
26
|
+
['added', 'already present', 'written over a different one', 'skipped', 'STOP'],
|
|
27
27
|
),
|
|
28
28
|
entry(
|
|
29
29
|
'footprint',
|