@sabaiway/agent-workflow-kit 22.0.0 → 22.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 +43 -0
- package/README.md +10 -8
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/upgrade.md +4 -4
- package/references/rules/communication.md +2 -1
- package/references/shared/composition-handoff.md +13 -8
- package/tools/inject-methodology.mjs +73 -14
- package/tools/project-rules/rules-priors.mjs +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,49 @@ 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
|
+
## 22.2.0 — a question is answered, not acted on: one new bullet in your communication rules (AD-223)
|
|
8
|
+
|
|
9
|
+
**Your communication rules now say that a message which only asks changes nothing.** A message asking for information
|
|
10
|
+
or an opinion is answered, with a change proposed if one is needed; a request phrased as a question ("can you fix
|
|
11
|
+
it?") and work you already approved run as before. A change nobody asked for is a miss: the agent undoes it in the
|
|
12
|
+
same turn when it is its own and safely reversible, and otherwise says plainly what was changed, never handing it
|
|
13
|
+
back to you as a decision or a cleanup. Once `npx @sabaiway/agent-workflow-kit@latest init` has installed this kit,
|
|
14
|
+
your next `/agent-workflow-kit upgrade` brings the bullet with no question; `init` alone leaves your project's rules
|
|
15
|
+
files as they are.
|
|
16
|
+
|
|
17
|
+
- **Where it sits.** `references/rules/communication.md` gains the bullet right after `Lead with the result`; every
|
|
18
|
+
other bullet is unchanged and `Two blocks for the user` stays last.
|
|
19
|
+
- **A quiet refresh.** The body releases 20.0.0 to 22.1.0 shipped is now a known earlier body
|
|
20
|
+
(`tools/project-rules/rules-priors.mjs`), so the upgrade reports a `docs/ai/rules/communication.md` holding it as
|
|
21
|
+
refreshed from an earlier release, never as differing from every body the kit shipped. A file holding any other body is replaced by the template as before, with the line
|
|
22
|
+
naming `docs/ai/rules/local/communication.md` as the place for a rule of your own.
|
|
23
|
+
- Nothing is removed and no export changes (MINOR).
|
|
24
|
+
|
|
25
|
+
## 22.1.0 — the kit block loads your session-start files into Claude Code before its first word (AD-222)
|
|
26
|
+
|
|
27
|
+
**A Claude Code session started at your project root now holds your handover, your agent rules and every rules theme
|
|
28
|
+
in context from the start.** The kit block of `AGENTS.md` gains one `@` import line per session-start file
|
|
29
|
+
(`docs/ai/handover.md`, `docs/ai/agent_rules.md` and each `docs/ai/rules/effective/<theme>.md` the rules table lists)
|
|
30
|
+
and, under them, a fallback sentence telling an agent to read those files from disk when their content is not in its
|
|
31
|
+
context. Your next `/agent-workflow-kit upgrade` (or `init`) writes them with no question; a second run writes nothing.
|
|
32
|
+
|
|
33
|
+
- **Where they load.** A start at the project root loads every listed file with no dialog, whatever an earlier dialog
|
|
34
|
+
answered, and again after `/clear` and after compaction, read fresh from disk; a subagent that loads project
|
|
35
|
+
instructions holds them too. A start in a subfolder loads them once Claude Code's own one-time external-imports
|
|
36
|
+
approval for that repository was answered Yes in an interactive session; before that answer (every `-p` start
|
|
37
|
+
included) or after No, it holds `AGENTS.md` with its pointer lines and the fallback sentence, as before. A listed
|
|
38
|
+
file you deleted is skipped with no error.
|
|
39
|
+
- **One list.** The import lines and the rules table come from one list in the kit, in the same order; a rules theme
|
|
40
|
+
your engine does not supply has neither its row nor its import line. The pointer lines stay for agents without
|
|
41
|
+
imports.
|
|
42
|
+
- **The CLAUDE.md check.** Claude Code reads `AGENTS.md` by itself only where the folder has no `CLAUDE.md`, so the
|
|
43
|
+
writer prints one line, writing nothing, when the root `CLAUDE.md` is not a symlink resolving to `AGENTS.md`:
|
|
44
|
+
absent → make it the link; a file of its own or a link elsewhere → move its text into `AGENTS.md` outside the kit
|
|
45
|
+
block, then make it the link.
|
|
46
|
+
- **The open-fence note.** A code fence opened above the import lines and never closed makes Claude Code read them as
|
|
47
|
+
code; the writer names that fence's line.
|
|
48
|
+
- `tools/inject-methodology.mjs` exports `MEMORY_IMPORTS` and `FALLBACK_LINE`; nothing is removed (MINOR).
|
|
49
|
+
|
|
7
50
|
## 22.0.0 — a red unit-test gate prints only its failures, through one gate form the upgrade moves you to (AD-221)
|
|
8
51
|
|
|
9
52
|
**A failing unit-test gate now prints a few lines per failing test instead of the whole test log.** The kit's
|
package/README.md
CHANGED
|
@@ -316,14 +316,16 @@ agent-workflow-kit — the composition root (installed via npx … init)
|
|
|
316
316
|
`<!-- workflow:kit:start -->` and `<!-- workflow:kit:end -->` comment lines, current on every run
|
|
317
317
|
with no question and no copy kept — the read order, the workflow **methodology**, the
|
|
318
318
|
**orchestration recipes** (Solo / Reviewed / Council / Delegated / Subagent), the **autonomy
|
|
319
|
-
policy** (the `docs/ai/autonomy.json` read contract),
|
|
320
|
-
(`docs/ai/rules/effective/<theme>.md`)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
319
|
+
policy** (the `docs/ai/autonomy.json` read contract), a table of the rules themes
|
|
320
|
+
(`docs/ai/rules/effective/<theme>.md`), then one `@` import line per session-start file (the
|
|
321
|
+
handover, the agent rules and each rules theme) and a fallback sentence telling an agent to read
|
|
322
|
+
those files from disk when their content is not in its context; the engine texts are read **live**
|
|
323
|
+
from the installed **`agent-workflow-engine`** (the canonical narrative; a published member, never
|
|
324
|
+
one of the shipped backends). Text of your own goes outside the two `workflow:kit` comment lines;
|
|
325
|
+
a change to a kit rule goes in its theme's file under `docs/ai/rules/local/`.
|
|
326
|
+
`docs/ai/agent_rules.md` is yours: the kit lays it only where it is absent, and apart from the
|
|
327
|
+
one-time `5.0.0` step, which removes the kit's old sections from it, never reads or writes it.
|
|
328
|
+
`/agent-workflow-kit recipes` surfaces + plans a recipe for your environment, read-only.
|
|
327
329
|
- **Detects & (opt-in) sets up** the optional `codex` / `agy` **bridges** — agent skills (not npm;
|
|
328
330
|
never first placed by `init` — `setup` places them, and once placed `init`/`upgrade` refresh
|
|
329
331
|
them). They plug into the workflow's **execute** and **review** phases — for *what
|
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: '22.
|
|
6
|
+
version: '22.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": "22.
|
|
3
|
+
"version": "22.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",
|
|
@@ -18,7 +18,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
18
18
|
6. `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.
|
|
19
19
|
7. `bridge-settings` — `node ${CLAUDE_SKILL_DIR}/tools/bridge-settings.mjs --reconcile` → outcome line(s), pasted verbatim: ok · absent · flagged · duplicates · unusable.
|
|
20
20
|
|
|
21
|
-
**`entry-block` — the kit block.** ONE call writes the kit block of `AGENTS.md` between its two `workflow:kit` comment lines — the precedence line, the read line, the **workflow-methodology**, **orchestration-recipes** (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) and **autonomy-policy** (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) texts,
|
|
21
|
+
**`entry-block` — the kit block.** ONE call writes the kit block of `AGENTS.md` between its two `workflow:kit` comment lines — the precedence line, the read line, the **workflow-methodology**, **orchestration-recipes** (Solo / Reviewed / Council / Delegated / Subagent, routing to `/agent-workflow-kit recipes`) and **autonomy-policy** (the `docs/ai/autonomy.json` read contract, routing to `/agent-workflow-kit set-autonomy`) texts, the rules-themes table, one row per theme, then one `@` import line per session-start file (handover, agent rules, each theme) and the fallback sentence (read them from disk when not loaded) — on **every** upgrade, idempotently (zero-diff when the block is already current), so an equal-head deployment gains it **without a lineage-head bump or a migration**. The block is written current with no question and no copy kept, its line naming the route — text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/; a file with no block gains it at its start. The installed `agent-workflow-engine` is read on every run (the texts live there), and no length of the file is judged.
|
|
22
22
|
|
|
23
23
|
**Classify the exit — two non-zero exits, each a hard STOP (do NOT continue):**
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
28
28
|
|
|
29
29
|
An engine that is valid but lacks the orchestration or the autonomy text, or the lens rules theme, is no STOP: the block holds one line in its place and the run prints a `note:` line naming `npx @sabaiway/agent-workflow-engine@latest init` — relay it in the report (**step 4** equal-head, else **step 8**).
|
|
30
30
|
|
|
31
|
-
**No-Node project:** the texts 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 judge the block by hand: a `workflow:kit` comment-line pair that is not exactly one start line before one end line → STOP, do not edit. If the engine is **not installed**, the block is not written this run — report it plainly (the recipes are available via `/agent-workflow-kit recipes`; the autonomy policy via `/agent-workflow-kit set-autonomy`; install the engine to write the block), and the upgrade continues. If the engine **is** present, compose the block in the order above, its table from the rules themes, and put it between the two comment lines, at the start of the file when there are none. Never inline a copy elsewhere in the file.
|
|
31
|
+
**No-Node project:** the texts 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 judge the block by hand: a `workflow:kit` comment-line pair that is not exactly one start line before one end line → STOP, do not edit. If the engine is **not installed**, the block is not written this run — report it plainly (the recipes are available via `/agent-workflow-kit recipes`; the autonomy policy via `/agent-workflow-kit set-autonomy`; install the engine to write the block), and the upgrade continues. If the engine **is** present, compose the block in the order above, its table and import lines from the rules themes, the fallback sentence from `${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs`, and put it between the two comment lines, at the start of the file when there are none. Never inline a copy elsewhere in the file.
|
|
32
32
|
|
|
33
33
|
**`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 kit block — no lineage-head bump, no migration file.
|
|
34
34
|
|
|
@@ -88,7 +88,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
88
88
|
**The LATE navigator finalizer — the AUTHORITATIVE run, after the last `docs/ai` mutation.** The `tier` offer above may write `docs/ai`, so the step-3 index ensure may be 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.
|
|
89
89
|
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:
|
|
90
90
|
- **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.
|
|
91
|
-
- **Report step 3's outcome in plain language** — the kit block (`entry-block`): whether it was *added* at the start of the file, was *already current* (nothing changed) or was *written* with the current kit text (its route: text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/), with each `note:` line
|
|
91
|
+
- **Report step 3's outcome in plain language** — the kit block (`entry-block`): whether it was *added* at the start of the file, was *already current* (nothing changed) or was *written* with the current kit text (its route: text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/), with each `note:` line (an engine text not supplied, the fallback, an unclosed code fence above the block) and the `CLAUDE.md` line when printed; 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*, or the moves *written*, each with its `was:`, with any KEPT gate, CUSTOMIZED entry, checker fact or the OFFER of the coverage check 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 **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`).
|
|
92
92
|
- **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*.
|
|
93
93
|
- **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).
|
|
94
94
|
- **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.
|
|
@@ -98,4 +98,4 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
98
98
|
5. Show the relevant `${CLAUDE_SKILL_DIR}/CHANGELOG.md` diff (entries newer than the project's stamp).
|
|
99
99
|
6. **Collect the migration answers FIRST, then apply.** Run `node ${CLAUDE_SKILL_DIR}/tools/migration-notes.mjs --cwd <project>` and relay its stdout lines verbatim, in order; a non-zero exit relays its one named line and STOPs, except `stamp-absent`, which routes back to step 1. Then run the preview `node ${CLAUDE_SKILL_DIR}/tools/migration-blocks.mjs --cwd <project>`. If its lines say both blocks are missing (pre-1.1.0), ask the two questions as ONE structured multi-question prompt; record each answer individually, write nothing until ALL are answered, and carry the answers into the migrations below: a migration whose answer was already collected never re-asks; a single missing block keeps its single ask (step 7). Then apply exactly the notes the tool listed, in its order ("only those newer than the project's stamp" is why, never a second selection). Migrations are **idempotent** — safe to re-run. When a note names an exit of its command a refusal and gives it no retry of its own, relay that refusal's line with the recovery it names and STOP before the finalizer and the stamp, so the next upgrade applies that note again.
|
|
100
100
|
7. Reconcile drift: add any kernel files/scripts the project is missing; never clobber project-authored content (their `decisions.md`, `known_issues.md`, page specs stay). Any user question a migration raises follows the same rule as bootstrap — **structured multiple-choice where supported** (`AskUserQuestion` in Claude Code), otherwise prose. For a block the preview names as needing its answer, **ask the user their conversational language** (`--language`) or **whether the agent may attribute work to itself / AI** (`--attribution`, defaulting to `off`), never re-asking a step-6 answer; then re-run the preview with `--apply` and the answers, relaying its lines. Exit 1 `answer-missing`: ask exactly what its lines name and re-run `--apply` once; a second one STOPs. Any other exit 1 is a named refusal: relay it with its recovery and STOP before the finalizer and the stamp. **Then, before the stamp, re-run the LATE navigator finalizer:** the migrations of steps 6–7 may have changed `docs/ai` files, so run the one op again — `node ${CLAUDE_SKILL_DIR}/tools/ensure-configs.mjs --reconcile --only index --cwd <project>` — and relay THAT line in the step-8 report (idempotent: an untouched tree changes nothing; a failure STOPs this upgrade like any other ensure).
|
|
101
|
-
8. Re-stamp `docs/ai/.workflow-version` to the **deployment-lineage head** (`5.0.0`, not the package version — mechanics unchanged: the atomic write to the stamp file). In the report, **describe what the upgrade changed in plain human terms** — which parts of their `docs/ai` are now different (the migrations that ran), plus the step-3 run-list outcomes, each as step 4 words it: the kit block (`entry-block`), the `footprint` visibility verdict (and what a consented re-run migrated), the **nine project-configuration ensure** (`configs`) lines (enumerated in step 3) — the navigator one being the late `--only index` run at the end of step 7, the **`gates-migration`** result, the **placed-bridge refresh** (`bridges`) lines (pasted verbatim), the **full-flow offer** (`tier`) outcome, and the **bridge-settings reconcile** (`bridge-settings`) outcome (line(s) pasted verbatim) — rather than reciting a version number; **omit the raw structure number**, and do **not** print the two-axes note here (it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`, on demand only). Then **render the mandatory Recommendations section**: 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, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request; present-even-when-empty: `no recommendations — flow optimal.`), then apply each kit item by the kit route (no question: its check line, then at once its apply line), then OFFER the consent route (per picked item: posture note → explicit confirm → chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`). **Every current host/session claim in this report is tool-composed only** — prompts fired, sandbox scope, whether a bypass was needed, network reachability and approval counts must trace to **live tool output** from **this session**, a memory/handover snapshot is **context, never report facts**, and an unbacked claim is **omitted or explicitly marked unverified** (full clause: *Live host/session facts* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`). Then **print the report footer** in the canonical order (version block → one-line backend-status line → welcome mat — the shared contracts in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`; rendered from the helpers, same host-can't-run skip-with-reason; the welcome mat closes on one caveat-aware next step). Then **ask before committing** — the pinned order on this exit is: Recommendations block → optional applies → report footer → the commit ask.
|
|
101
|
+
8. Re-stamp `docs/ai/.workflow-version` to the **deployment-lineage head** (`5.0.0`, not the package version — mechanics unchanged: the atomic write to the stamp file). In the report, **describe what the upgrade changed in plain human terms** — which parts of their `docs/ai` are now different (the migrations that ran), plus the step-3 run-list outcomes, each as step 4 words it: the kit block (`entry-block`) with its notes and its `CLAUDE.md` line, the `footprint` visibility verdict (and what a consented re-run migrated), the **nine project-configuration ensure** (`configs`) lines (enumerated in step 3) — the navigator one being the late `--only index` run at the end of step 7, the **`gates-migration`** result, the **placed-bridge refresh** (`bridges`) lines (pasted verbatim), the **full-flow offer** (`tier`) outcome, and the **bridge-settings reconcile** (`bridge-settings`) outcome (line(s) pasted verbatim) — rather than reciting a version number; **omit the raw structure number**, and do **not** print the two-axes note here (it belongs to *Version disclosure* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`, on demand only). Then **render the mandatory Recommendations section**: 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, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request; present-even-when-empty: `no recommendations — flow optimal.`), then apply each kit item by the kit route (no question: its check line, then at once its apply line), then OFFER the consent route (per picked item: posture note → explicit confirm → chat: the one-liner; harness: the check line, then on the yes to its result the apply line; user: the user's own step — `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`). **Every current host/session claim in this report is tool-composed only** — prompts fired, sandbox scope, whether a bypass was needed, network reachability and approval counts must trace to **live tool output** from **this session**, a memory/handover snapshot is **context, never report facts**, and an unbacked claim is **omitted or explicitly marked unverified** (full clause: *Live host/session facts* in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`). Then **print the report footer** in the canonical order (version block → one-line backend-status line → welcome mat — the shared contracts in `${CLAUDE_SKILL_DIR}/references/shared/report-footer.md`; rendered from the helpers, same host-can't-run skip-with-reason; the welcome mat closes on one caveat-aware next step). Then **ask before committing** — the pinned order on this exit is: Recommendations block → optional applies → report footer → the commit ask.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
type: rules
|
|
3
|
-
lastUpdated: 2026-
|
|
3
|
+
lastUpdated: 2026-11-02
|
|
4
4
|
scope: permanent
|
|
5
5
|
staleAfter: never
|
|
6
6
|
owner: kit
|
|
@@ -14,6 +14,7 @@ The kit block of AGENTS.md is the kit's and is rewritten on every upgrade; it an
|
|
|
14
14
|
- **Plain language.** User-facing narration is short, clear, plain words of the dialogue language; when the dialogue language is not English, transliterated English jargon is banned — an English term survives only as the NAME of a thing (a flag / command / file / test), glossed in plain words when helpful; plain English stays plain for English-dialogue users.
|
|
15
15
|
- **Deliver the artifact IN the message** — paste the prompt / diff / version / command inline; never "see §X / open the file / run it and you'll see" as a *substitute* for showing what was asked.
|
|
16
16
|
- **Lead with the result**, then the details; show exactly what was asked — no deflection, no "almost done" when the ask was the finished thing.
|
|
17
|
+
- **A question is answered, not acted on.** A message that only asks for information or an opinion changes nothing: answer it, and propose a change if one is needed. A request phrased as a question ("can you fix it?") and work the user already approved run as before. A change nobody asked for is a miss: undo it yourself in the same turn when it is your own and safely reversible — nothing else has touched it since — and otherwise say plainly what was changed; never hand it back as a decision or a cleanup for the user.
|
|
17
18
|
- **No condescension, no filler.** Own a miss plainly and fix it in the same message.
|
|
18
19
|
- **Large artifact (≈>100 lines):** deliver a real summary or the key excerpt inline **and** link the file — never flood the reader with a 2000-line paste, never hide the answer behind a bare pointer.
|
|
19
20
|
- **Live host/session facts are tool-composed only.** Any claim about the current host or session state (prompts fired, sandbox scope, whether a bypass was needed, network reachability, approval counts) must trace to **live tool output** from **this session**; a memory/handover snapshot is **context, never report facts**, and a claim with no live signal is **omitted or explicitly marked unverified** — never asserted from recollection.
|
|
@@ -17,19 +17,24 @@
|
|
|
17
17
|
`node ${CLAUDE_SKILL_DIR}/tools/inject-methodology.mjs reconcile <project>/AGENTS.md` — which writes
|
|
18
18
|
the kit block between its two `workflow:kit` comment lines in a single atomic write: the precedence
|
|
19
19
|
line, the read line, the **workflow-methodology**, **orchestration-recipes** and **autonomy-policy**
|
|
20
|
-
texts,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
with no
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
texts, the rules-themes table, one row per theme, then one `@` import line per session-start file
|
|
21
|
+
(the handover, the agent rules and each rules theme) and the fallback sentence telling an agent to
|
|
22
|
+
read those files from disk when their content is not in its context. The block is written current
|
|
23
|
+
with no question and no copy kept, its line naming the route — text of your own goes outside the two
|
|
24
|
+
workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/.
|
|
25
|
+
A file with no block gains it at its start; with a valid installed engine supplying every text, a
|
|
26
|
+
deployment whose kit block is current reconciles to a zero-diff no-op. The texts are read **live
|
|
27
|
+
from the installed `agent-workflow-engine`** (`references/methodology-slot.md` +
|
|
28
|
+
`references/orchestration-slot.md` + `references/autonomy-slot.md`, the family's one source of truth) — **not** a bundled mirror. The
|
|
27
29
|
read is **fail-loud**: an **absent/invalid** engine **STOPs** the run, nothing written — report it
|
|
28
30
|
in plain language with the one-line install command `npx @sabaiway/agent-workflow-engine@latest init`
|
|
29
31
|
(`npx @sabaiway/agent-workflow-kit@latest init` installs the engine for you; translate, never leak
|
|
30
32
|
tool internals). An engine that lacks a later text writes one line in its place and a note naming
|
|
31
33
|
the refresh command. Comment lines that are not exactly one start line before one end line are
|
|
32
|
-
refused with their line numbers, nothing written: the upgrade STOPs.
|
|
34
|
+
refused with their line numbers, nothing written: the upgrade STOPs. The install report relays each
|
|
35
|
+
`note:` line in plain words — a text the engine does not supply, the fallback note, an unclosed code
|
|
36
|
+
fence above the import lines — and the `CLAUDE.md` line, when printed, with its one step: make
|
|
37
|
+
`CLAUDE.md` the link to `AGENTS.md`, its text moved into `AGENTS.md` first when it holds any.
|
|
33
38
|
|
|
34
39
|
**Navigator finalizer (runs in BOTH paths, AFTER the block write above).** `docs/ai/index.md` is
|
|
35
40
|
a GENERATED artifact the entry point declares always-loaded, and the deploy may have just
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The kit block — the composition root's only mutation of a deployed AGENTS.md. ONE block between two
|
|
3
3
|
// marker lines holds the precedence line, the read line, the installed engine's three fragments (read
|
|
4
|
-
// LIVE, no bundled copy)
|
|
5
|
-
// question and no copy kept; outside it nothing is written or
|
|
6
|
-
// STOP; malformed marker lines are refused with their line
|
|
7
|
-
// return-code entry point; dependency-free, Node >= 22.
|
|
4
|
+
// LIVE, no bundled copy), the rules-themes table, import lines and fallback sentence. The block is
|
|
5
|
+
// written current on every run with no question and no copy kept; outside it nothing is written or
|
|
6
|
+
// found. An absent or invalid engine is a STOP; malformed marker lines are refused with their line
|
|
7
|
+
// numbers. Pure string functions plus one return-code entry point; dependency-free, Node >= 22.
|
|
8
|
+
// Contract: docs/ai/specs/kit/install/entry-pointers.md.
|
|
8
9
|
|
|
10
|
+
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
9
11
|
import { isDirectRun } from './direct-run.mjs';
|
|
10
12
|
import { normalizeCanonical } from './orchestration-config.mjs';
|
|
11
13
|
import { PRECEDENCE_LINE, THEMES, themePaths } from './project-rules/index.mjs';
|
|
@@ -16,6 +18,8 @@ import {
|
|
|
16
18
|
export const BLOCK_START = '<!-- workflow:kit:start -->';
|
|
17
19
|
export const BLOCK_END = '<!-- workflow:kit:end -->';
|
|
18
20
|
export const READ_LINE = 'Read `docs/ai/index.md` after this file; read `docs/ai/agent_rules.md` before any code change.';
|
|
21
|
+
export const MEMORY_IMPORTS = Object.freeze(['docs/ai/handover.md', 'docs/ai/agent_rules.md']);
|
|
22
|
+
export const FALLBACK_LINE = 'Claude Code loads the content of the `@` files above at a start in the project root with no dialog, and at a start in a subfolder once its one-time per-repository approval was answered Yes in an interactive session; if their content is not in your context, read each `@` path above from disk before anything else.';
|
|
19
23
|
export const SKIP_PREFIX = 'Kit text not supplied by the installed engine:';
|
|
20
24
|
export const BLOCK_ROUTE = "text of your own goes outside the two workflow:kit comment lines; a change to a kit rule goes in its theme's file under docs/ai/rules/local/";
|
|
21
25
|
|
|
@@ -24,6 +28,10 @@ const CRLF = '\r\n';
|
|
|
24
28
|
const BOM = '\uFEFF';
|
|
25
29
|
const INSTALL = 'npx @sabaiway/agent-workflow-engine@latest init';
|
|
26
30
|
const TAG = '[inject-methodology]';
|
|
31
|
+
const CLAUDE_PREFIX = `${TAG} CLAUDE.md is not a symlink to AGENTS.md: automatic loading of the kit block in Claude Code is not guaranteed; `;
|
|
32
|
+
const CLAUDE_ABSENT = 'make CLAUDE.md the link to AGENTS.md.';
|
|
33
|
+
const CLAUDE_MOVE = 'move its text into AGENTS.md outside the kit block, then make CLAUDE.md the link to AGENTS.md.';
|
|
34
|
+
const MAX_LINKS = 40;
|
|
27
35
|
|
|
28
36
|
// The three engine fragments in block order; a valid engine lacking one but methodology leaves a skip line.
|
|
29
37
|
const FRAGMENTS = Object.freeze([
|
|
@@ -81,17 +89,34 @@ export const findKitBlock = (text) => {
|
|
|
81
89
|
const skipLine = (name) => `${SKIP_PREFIX} ${name} — refresh it with ${INSTALL}`;
|
|
82
90
|
const effectiveOf = (theme) => themePaths(theme.name).effective;
|
|
83
91
|
|
|
84
|
-
//
|
|
85
|
-
// string, and a theme named in lacking, each leave a skip line.
|
|
86
|
-
|
|
92
|
+
// composeKitParts({ fragments, themes, lacking? }) → the block's parts in order; a fragment that is not a
|
|
93
|
+
// string, and a theme named in lacking, each leave a skip line, and a lacking theme has no row and no import line.
|
|
94
|
+
const composeKitParts = ({ fragments, themes, lacking = [] }) => {
|
|
87
95
|
const texts = FRAGMENTS.map(({ id, name }) => (typeof fragments[id] === 'string'
|
|
88
96
|
? fragments[id].replace(/\r\n/gu, LF).trim()
|
|
89
97
|
: skipLine(name)));
|
|
90
|
-
const
|
|
91
|
-
|
|
98
|
+
const shipped = themes.filter((theme) => !lacking.includes(theme.name));
|
|
99
|
+
const rows = shipped.map((theme) => `| [\`${effectiveOf(theme)}\`](./${effectiveOf(theme)}) | ${theme.readWhen} |`);
|
|
92
100
|
const table = ['| Rules theme | Read when |', '|---|---|', ...rows].join(LF);
|
|
93
101
|
const skips = themes.filter((theme) => lacking.includes(theme.name)).map((theme) => skipLine(themeName(theme.name)));
|
|
94
|
-
|
|
102
|
+
const imports = [...MEMORY_IMPORTS, ...shipped.map(effectiveOf)].map((path) => `@${path}`).join(LF);
|
|
103
|
+
return [BLOCK_START, PRECEDENCE_LINE, READ_LINE, ...texts, table, ...skips, imports, FALLBACK_LINE, BLOCK_END];
|
|
104
|
+
};
|
|
105
|
+
// composeKitBlock({ fragments, themes, lacking? }) → the block in LF form, one blank line between parts.
|
|
106
|
+
export const composeKitBlock = (input) => composeKitParts(input).join(LF + LF);
|
|
107
|
+
|
|
108
|
+
// findOpenFence(text, importLine) → the 1-based line of the first opener above importLine no later line closes, or null.
|
|
109
|
+
const findOpenFence = (text, importLine) => {
|
|
110
|
+
const lines = text.split(LF);
|
|
111
|
+
const cursor = { index: 0 };
|
|
112
|
+
for (; cursor.index < importLine - 1; cursor.index += 1) {
|
|
113
|
+
const open = opensFence(lines[cursor.index]);
|
|
114
|
+
if (!open) continue;
|
|
115
|
+
const close = lines.findIndex((line, at) => at > cursor.index && closesFence(line, open));
|
|
116
|
+
if (close === -1) return cursor.index + 1;
|
|
117
|
+
cursor.index = close;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
95
120
|
};
|
|
96
121
|
|
|
97
122
|
// The byte offset where 1-based line n starts, and where its content ends (before its CR and LF).
|
|
@@ -154,10 +179,14 @@ const readEngineParts = ({ env, home, logError }) => {
|
|
|
154
179
|
return { fragments, lacking };
|
|
155
180
|
};
|
|
156
181
|
|
|
157
|
-
// runCli(argv, { env, home }) → { code, stdout, stderr }; never exits.
|
|
182
|
+
// runCli(argv, { env, home, lstat, readlink, realpath }) → { code, stdout, stderr }; never exits.
|
|
183
|
+
// `reconcile <AGENTS.md>` checks CLAUDE.md before writing; reports fallback, open fence and link last.
|
|
158
184
|
export const runCli = async (argv, deps = {}) => {
|
|
159
|
-
const
|
|
160
|
-
const {
|
|
185
|
+
const fs = await import('node:fs/promises');
|
|
186
|
+
const { readFile, writeFile, rename, rm } = fs;
|
|
187
|
+
const lstat = deps.lstat ?? fs.lstat;
|
|
188
|
+
const readlink = deps.readlink ?? fs.readlink;
|
|
189
|
+
const realpath = deps.realpath ?? fs.realpath;
|
|
161
190
|
const { homedir } = await import('node:os');
|
|
162
191
|
const env = deps.env ?? process.env;
|
|
163
192
|
const home = deps.home ?? homedir();
|
|
@@ -175,6 +204,27 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
175
204
|
return result(2);
|
|
176
205
|
}
|
|
177
206
|
const target = resolve(argv[1]);
|
|
207
|
+
const checkClaudeLink = async (own) => {
|
|
208
|
+
const state = { hop: join(dirname(own), 'CLAUDE.md'), links: 0, checkingEntry: true };
|
|
209
|
+
while (state.hop !== own) {
|
|
210
|
+
state.checkingEntry = true;
|
|
211
|
+
try {
|
|
212
|
+
const stat = await lstat(state.hop);
|
|
213
|
+
if (!stat.isSymbolicLink()) return CLAUDE_MOVE;
|
|
214
|
+
state.checkingEntry = false;
|
|
215
|
+
// Joined without resolve(): a `..` after a directory link is the native realpath's to follow, as the kernel does.
|
|
216
|
+
const link = await readlink(state.hop);
|
|
217
|
+
const next = isAbsolute(link) ? link : `${dirname(state.hop)}/${link}`;
|
|
218
|
+
state.hop = join(await realpath(dirname(next)), basename(next));
|
|
219
|
+
state.links += 1;
|
|
220
|
+
if (state.links > MAX_LINKS) return CLAUDE_MOVE;
|
|
221
|
+
} catch (err) {
|
|
222
|
+
if (!['ENOENT', 'ENOTDIR', 'ELOOP'].includes(err.code)) throw err;
|
|
223
|
+
return err.code === 'ENOENT' && state.checkingEntry && state.links === 0 ? CLAUDE_ABSENT : CLAUDE_MOVE;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
};
|
|
178
228
|
const writeAtomic = async (out) => {
|
|
179
229
|
const tmp = join(dirname(target), `.${basename(target)}.tmp-${process.pid}-${Date.now()}`);
|
|
180
230
|
try {
|
|
@@ -188,16 +238,25 @@ export const runCli = async (argv, deps = {}) => {
|
|
|
188
238
|
try {
|
|
189
239
|
const text = await readFile(target, 'utf8');
|
|
190
240
|
const { fragments, lacking } = readEngineParts({ env, home, logError });
|
|
191
|
-
const
|
|
241
|
+
const parts = composeKitParts({ fragments, themes: THEMES, lacking });
|
|
242
|
+
const block = parts.join(LF + LF);
|
|
192
243
|
const judged = reconcileKitBlock(text, block);
|
|
193
244
|
if (judged.status === 'refused') {
|
|
194
245
|
logError(refusalLine(judged.lines));
|
|
195
246
|
return result(1);
|
|
196
247
|
}
|
|
248
|
+
const own = join(await realpath(dirname(target)), basename(target));
|
|
249
|
+
const claude = await checkClaudeLink(own);
|
|
197
250
|
if (judged.status !== 'current') await writeAtomic(judged.text);
|
|
198
251
|
log(OUTCOME[judged.status]);
|
|
199
252
|
const skipped = [...FRAGMENTS.filter(({ id }) => typeof fragments[id] !== 'string').map(({ name }) => name), ...lacking.map(themeName)];
|
|
200
253
|
skipped.forEach((name) => log(noteLine(name)));
|
|
254
|
+
if (judged.status !== 'current') log(`${TAG} note: ${FALLBACK_LINE}`);
|
|
255
|
+
// The import part is the third part from the end: its first line follows the earlier parts and one blank line.
|
|
256
|
+
const importOffset = parts.slice(0, -3).join(LF + LF).split(LF).length + 1;
|
|
257
|
+
const opener = findOpenFence(judged.text, findKitBlock(judged.text).start + importOffset);
|
|
258
|
+
if (opener !== null) log(`${TAG} note: an unclosed code fence on line ${opener} runs over the kit block's import lines, so Claude Code reads them as code; close it.`);
|
|
259
|
+
if (claude !== null) log(CLAUDE_PREFIX + claude);
|
|
201
260
|
return result(0);
|
|
202
261
|
} catch (err) {
|
|
203
262
|
if (err[EXIT] !== undefined) return result(err[EXIT]);
|
|
@@ -6,6 +6,7 @@ import { digestOf } from './rules-check.mjs';
|
|
|
6
6
|
export const RULES_PRIORS = Object.freeze([
|
|
7
7
|
Object.freeze({ theme: 'project-layout', release: '14.37.0', sha256: 'b79f19a9e0583f1e0619ee6aca06feb2c359b9655f1d260e87d8d5647bd1de19' }),
|
|
8
8
|
Object.freeze({ theme: 'project-layout', release: '19.4.0', sha256: 'ec4ef10c05ba365e73df96d175042314ea120f3fe1c946fdd94d3d1237de8be9' }),
|
|
9
|
+
Object.freeze({ theme: 'communication', release: '20.0.0', sha256: 'ce0ebcab194b21fedd96c389daefb92be3cf2b5fe15f3c40b0485c32a2575e1f' }),
|
|
9
10
|
]);
|
|
10
11
|
|
|
11
12
|
// isKnownPrior(theme, bytes, catalog?) → true exactly when the bytes hash to an entry of that theme.
|