@sabaiway/agent-workflow-kit 23.1.0 → 23.2.1
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 +34 -0
- package/README.md +1 -1
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/hooks/gate-approve.mjs +61 -61
- package/references/modes/recommendations.md +2 -2
- package/references/modes/setup.md +2 -0
- package/references/modes/upgrade.md +3 -3
- package/references/modes/velocity.md +1 -1
- package/tools/apply-danger-check.mjs +1 -1
- package/tools/bridge-sandbox-recipe.mjs +7 -3
- package/tools/bridge-settings-read.mjs +2 -0
- package/tools/family-registry.mjs +1 -2
- package/tools/fs-safe.mjs +2 -2
- package/tools/manifest/schema.md +2 -2
- package/tools/refresh-parity.mjs +3 -3
- package/tools/services/antigravity.json +3 -0
- package/tools/services/codex.json +5 -0
- package/tools/services/index.mjs +44 -4
- package/tools/services/jev.json +1 -0
- package/tools/setup-backends.mjs +37 -48
- package/tools/velocity-profile.mjs +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,40 @@ 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
|
+
## 23.2.1 — the gate hook's read-only list is written from the kit's own list (AD-227)
|
|
8
|
+
|
|
9
|
+
**The gate hook's list of read-only commands and its list of residual shell forms are now written from the kit's own
|
|
10
|
+
lists, so the two can no longer drift apart.** The hook decides every gate run exactly as before. The hook file in
|
|
11
|
+
the kit changes, so where you wired the gate hook your next `/agent-workflow-kit upgrade` refreshes
|
|
12
|
+
`.claude/hooks/agent-workflow-gates.mjs` through its usual item, with no question, and `init` refreshes it on its one
|
|
13
|
+
y.
|
|
14
|
+
|
|
15
|
+
## 23.2.0 — a service the kit does not ship goes into your own services list (AD-226)
|
|
16
|
+
|
|
17
|
+
**A bridge run can now reach a service the kit does not ship: you list it once in your own
|
|
18
|
+
`~/.config/agent-workflow/services.json`, and the kit adds it to every placed bridge and to the project's sandbox
|
|
19
|
+
settings.** The kit only reads that file, never writes it. Each entry maps a new service id to the same six keys as a
|
|
20
|
+
kit service file (`hosts`, `writableDirs`, `excludedCommands`, `passedVariables`, `billingVariables`,
|
|
21
|
+
`runReachesHosts`); Mode: setup describes it. With no such file every output is what it was, but for the two lines
|
|
22
|
+
below.
|
|
23
|
+
|
|
24
|
+
- **Placement and every refresh write your services into each bridge's facts file.** `/agent-workflow-kit setup`,
|
|
25
|
+
`init` and `/agent-workflow-kit upgrade` write each placed bridge's `service-facts.txt` from the bridge's own
|
|
26
|
+
services, then yours, so the bridge wrappers reach your hosts and pass your variables.
|
|
27
|
+
- **The bridge tier adds your hosts, state folders and excluded commands** to `.claude/settings.json` for every bridge
|
|
28
|
+
the project uses: the dry-run, the apply, the Recommendations item, the danger check and the autonomy preview read
|
|
29
|
+
the same list.
|
|
30
|
+
- **A broken list stops the step before it writes anything**, naming the file: fix or remove it, then run the same
|
|
31
|
+
step again (`/agent-workflow-kit setup` after a stopped place, `/agent-workflow-kit upgrade` after a refresh that
|
|
32
|
+
could not run).
|
|
33
|
+
- **No list can hand a billing key to a run.** Every service now names its billing variables (codex `OPENAI_API_KEY`,
|
|
34
|
+
`CODEX_API_KEY`, `OPENAI_BASE_URL`; antigravity `GEMINI_API_KEY`), and a passed variable equal to one is refused.
|
|
35
|
+
- **A service you remove leaves the facts files at the next refresh**; the sandbox entries the tier already added stay,
|
|
36
|
+
and you remove them from `.claude/settings.json` yourself.
|
|
37
|
+
- **Two changed lines:** an equal-version refresh no longer reports the placed `service-facts.txt` as a local edit,
|
|
38
|
+
since every refresh writes it anew; and a read-only refresh that cannot repair a file now says it still differs
|
|
39
|
+
"from what the refresh writes", where it said "from the bundled copy".
|
|
40
|
+
|
|
7
41
|
## 23.1.0 — every bridge wrapper reads its hosts and passed keys from the file in its own folder (AD-225)
|
|
8
42
|
|
|
9
43
|
**The bridge wrappers no longer carry their own copy of the Jev hosts and key: each reads them from the
|
package/README.md
CHANGED
|
@@ -259,7 +259,7 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
|
|
|
259
259
|
| `/agent-workflow-kit core-evidence` | any time | **the ONE loop-evidence writer** (strip-the-kit) — every core evidence record lands in a single append-only JSONL store inside the git dir (never committable; versioned schema, latest-per-key supersession, byte-identical duplicates refused, malformed lines fail every reader closed). `red-proof "<file>#<pattern>"` declares an observed-red **BEFORE a bugfix** (N/N red runs + content custody + base + the pre-fix fingerprint; green/mixed/timeout are DISTINGUISHED refusals — nothing written); `degrade --backend --reason` is the ONLY escape for an unavailable review backend (per-tree, never all backends); `summary` renders the whole loop state statelessly (gate result · per-backend verdicts · red-proofs · degrades) — no ledger, no rounds, nothing remembered. Honest residual: records are forgeable — self-discipline, not a security boundary. Never commits, never runs a subscription CLI. |
|
|
260
260
|
| `/agent-workflow-kit coverage-check` | any time | **the final-run checker** (D3(c)+(d)) — **certifies coverage ONLY inside the `--final` run that owns the lcov** (ownership is exclusive by CONVENTION over the fixed path, not enforced — a concurrent writer to it is a stated residual, queued as LCOV-EXCLUSIVE-OWNERSHIP): an artifact on disk proves nothing about the tree it came from, so a standalone run prints its findings and states `attested=no` / `NO VERDICT` rather than a PASS (an lcov that predates an edit would otherwise certify a line the suite never executed). `attested=` claims a verdict was ISSUED, pass or fail — a run over uncovered lines still reads `attested=yes` and still exits 1, and a run whose coverage arm never executed (no lcov) reads `attested=no` even inside `--final`, because nothing was read and nothing is certified. The runner passes a nonce whose one-way commitment over `{nonce, fingerprint, base}` is the `final-start.attempt` it recorded; a context describing another tree, or matching no recorded attempt, is a REFUSAL, never a verdict. Findings are unchanged — reads the lcov the declared `unit-tests` gate produced at the FIXED git-dir path and fails on any uncovered CHANGED executable Node line (listed `file:line`; a changed file absent from the map is a file-level red; out-of-domain/unsupported files are LISTED — the claim narrowed honestly); VERIFIES every current-base red-proof declaration (bound test exists · custody hash unchanged · green N/N now · pre-fix fingerprint differs); prints `lcov-sha256=<hex|none>` of the exact bytes it consumed — the sha the `--final` receipt binds and re-hashes. An absent lcov is a LOUD `skipped-no-lcov`; a symlinked path is a refusal. `--check` is the gate exit code — declare it as the LAST gate (`run-gates --final` refuses otherwise). Read-only. |
|
|
261
261
|
| `/agent-workflow-kit commit-guard` | any time | **the read-only pre-commit guard** (D10) — makes the commit capture the whole current working tree, so «verified» and «about to be committed» are the same bytes (the receipt itself has a stated residual — see the mode doc). FIRST it refuses an **INDEX that lags the verified working tree** (the gates and the fingerprint describe the WORKING tree while `git commit` takes the INDEX alone, and the fingerprint cannot tell them apart — so a lagging index used to ship a strict subset of what was verified): unstaged tracked paths or reviewable untracked-not-ignored paths, named up to a bounded cap with the remainder stated, a dirty tracked **submodule** named separately with its own recovery, and fail-closed on an undecidable probe. This deliberately blocks a partial commit. Then it binds the LATEST completed `run-gates --final` receipt to the EXACT current tree: refuses on a missing/red/stale receipt, fingerprint drift under the run, a dangling later attempt, declaration content drift, evidence-hash or lcov drift, or unsatisfied review obligations (the same review-state decision, recomputed over a sanitized env — forged out-of-repo stores never satisfy). Re-runs NO gate or test. Wire it into `.git/hooks/pre-commit` (the installer writes the RESOLVED invocation). `git commit --no-verify` stays the stated residual. |
|
|
262
|
-
| `/agent-workflow-kit recommendations` | any time (every `upgrade` ends with it) | **read-only deployment advisor** (AD-044) — computes what in THIS deployment is configured sub-optimally (allowlist not seeded, autonomy render drifted, OS sandbox unavailable, gates undeclared, bridge friction, sandbox-mask clutter, a feature-spec layer never adopted) and renders **verdict-first**: one composed verdict line (does anything need attention?), then each item as **{severity · what · one-line benefit · an optional `recipe:` line (the bridge-tier item's missing-entries line — each missing entry by kind: allow rules, exclusions, hosts, state dirs, then what the execution wrapper codex-exec needs, then the host condition; the worktrees-dir ack fallback for a host that ignores the settings key, the agents hidden-mode reconcile follow-up, a user item's own facts, the spec-adoption decline preview, or another offer's decline preview) · the exact consent-gated apply one-liner}**; `references/advisor-writers.md` names each variant's writer or user step. The agent PRESENTS the section in the user's conversational language — every fact and count, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request — and runs EXACTLY the rendered one-liners and the follow-up commands required by the mode doc, only on the answer authorizing that step — your yes to apply or your explicit decline to record it — with a second yes where the mode doc requires it, surfacing each item's posture note first; a kit item it applies with no question, its check line first, the harness's own dialog the only ask, or the one plain step where auto mode refuses its check or apply. Renders **present-even-when-empty** (`no recommendations — flow optimal.`); a failed probe degrades to a stated skip line. Registry strings are fact-true frozen one-line data (posture/risk notes live in the mode doc at the consent moment); `velocity --bridge-tier` seeds the used bridges' review allow rules, `<wrapper> *` exclusions (`codex-exec *` where an execute slot delegates, keeping its permission prompt), declared hosts into `sandbox.network.allowedDomains`, and home-relative state dirs into `sandbox.filesystem.allowWrite`; hosts and dirs come from the kit service fragments (`agent-workflow-kit/tools/services/`) each bridge's `capability.json` names in `services`, and the advisor's `bridge-tier` item counts and names each missing one. `--cwd` is required (the target project is explicit); writes nothing, never commits, never runs a subscription CLI. |
|
|
262
|
+
| `/agent-workflow-kit recommendations` | any time (every `upgrade` ends with it) | **read-only deployment advisor** (AD-044) — computes what in THIS deployment is configured sub-optimally (allowlist not seeded, autonomy render drifted, OS sandbox unavailable, gates undeclared, bridge friction, sandbox-mask clutter, a feature-spec layer never adopted) and renders **verdict-first**: one composed verdict line (does anything need attention?), then each item as **{severity · what · one-line benefit · an optional `recipe:` line (the bridge-tier item's missing-entries line — each missing entry by kind: allow rules, exclusions, hosts, state dirs, then what the execution wrapper codex-exec needs, then the host condition; the worktrees-dir ack fallback for a host that ignores the settings key, the agents hidden-mode reconcile follow-up, a user item's own facts, the spec-adoption decline preview, or another offer's decline preview) · the exact consent-gated apply one-liner}**; `references/advisor-writers.md` names each variant's writer or user step. The agent PRESENTS the section in the user's conversational language — every fact and count, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request — and runs EXACTLY the rendered one-liners and the follow-up commands required by the mode doc, only on the answer authorizing that step — your yes to apply or your explicit decline to record it — with a second yes where the mode doc requires it, surfacing each item's posture note first; a kit item it applies with no question, its check line first, the harness's own dialog the only ask, or the one plain step where auto mode refuses its check or apply. Renders **present-even-when-empty** (`no recommendations — flow optimal.`); a failed probe degrades to a stated skip line. Registry strings are fact-true frozen one-line data (posture/risk notes live in the mode doc at the consent moment); `velocity --bridge-tier` seeds the used bridges' review allow rules, `<wrapper> *` exclusions (`codex-exec *` where an execute slot delegates, keeping its permission prompt), declared hosts into `sandbox.network.allowedDomains`, and home-relative state dirs into `sandbox.filesystem.allowWrite`; hosts and dirs come from the kit service fragments (`agent-workflow-kit/tools/services/`) each bridge's `capability.json` names in `services`, then from your own services list (`services.json` beside the bridge settings file, Mode: setup), and the advisor's `bridge-tier` item counts and names each missing one. `--cwd` is required (the target project is explicit); writes nothing, never commits, never runs a subscription CLI. |
|
|
263
263
|
| `/agent-workflow-kit doc-parity` | any time | **read-only doc-parity lint** (AD-049) — kills the doc-drift class where a mode-contract doc silently lags a code constant (a `--check` doc still reading `300` after the diff cap moved to `400`): a **closed, exported registry** binds each live constant (review caps, schema versions, the ledger's own class/scope vocabulary, and the autonomy-doctor EXIT/status/trusted-dir contract) to the exact token its `references/modes/*.md` contract must carry, and asserts the CURRENT value renders into every bound file — a drifted doc, an unreadable file, or an absent token **fails closed**. The values are sourced from the live imports (never re-typed), so the lint can't itself go stale; adding a binding is adding a checked entry (closed-world, edit-safe). `--check` is the gate exit code a kit maintainer runs: the lint checks the kit's own package. Never writes, never commits, never runs a subscription CLI. |
|
|
264
264
|
| `/agent-workflow-kit dispatch` | any time | **the delegation engine** — makes "how much does delegating a sub-task actually buy?" a measured number instead of a feeling. `check <file>` validates a sub-task brief's contract block and exits 0/1 naming the first violated field — **form only**: whether the task is genuinely bounded, its design decided and its acceptance adequate stays your judgment, and a well-formed absurdity passes here by construction. `advise --step-class <c>` answers the question that comes BEFORE that one — which vehicle should carry this kind of sub-task, whether it is even present on this machine, and what the ledger has already recorded for threads of that class (finished, failed, closed without a fold, and still open — counted separately) — and it decides nothing: it refuses no dispatch, gates no verb, and a choice that diverges from the advice is noted rather than blocked. It reads the filesystem only: nothing is launched to find out what is installed, an absent ledger prints "no recorded history", an unreadable one prints the store's own words, and either way the advice still prints. The same block appears as a footer under a form-valid `check` — never under a refusal, so it can never hide one. `register` pre-registers an acceptance wave (step classes, pairing key, minimum observations per class, the mean and first-pass thresholds) so the bar can never be chosen after the results it judges — immutable per wave. `observe` records ONE hand-written observation (`solo-construction`, the baseline whose ratio is 1 by construction — except over a scope measuring zero bytes, which has no ratio at all and is recorded ineligible by name — or `self-reported`) — delegated numbers are never hand-written, they are derived. The writer verbs are where that derivation happens: `open` puts a delegated thread on the record with every mint-time field copied from the brief's own header, refusing a deadline the wrapper's cap plus its kill grace would not fit inside, and recording whether the tree it started from was clean against the thread's base — HEAD by default, or the tree `--checkpoint <oid>` names, so the second task of a story is measured over the first one's uncommitted work instead of opening dirty (a dirty one makes the result honestly unmeasurable rather than quietly counted), while `--task <brief>` also records which task brief the thread carries out and the files that brief lists, refusing, since the last commit, a task thread whose files overlap by path prefix those of an open task thread or of a folded thread of another brief (`files-overlap`), and a mix of the two kinds — an untasked open beside an open task thread or, for a `code` open of backend `codex`, after a task fold, and a task open beside an open untasked thread (`mixed-open`), refusing at open a Files path the snapshot scope can never hold (`task-files-scope`), and measuring a task thread over its files alone, so `return` and `fold` refuse a changed path that no open or folded task thread on the same base claims (`out-of-files`); `await` waits for that one dispatch to answer and writes nothing — only the finished receipt satisfies it, a run still holding the nonce means keep waiting, and a wait that runs out says so with its own exit code, names whether the deadline or your own timeout ended it, and authorizes nothing: a wait that ended without an answer is a question for you, never permission to dispatch again; `return` absorbs the receipt the wrapper minted — only a finished one, checked against the contract it actually ran, its deadline and its own report, and refused outright when the tree hides changes from git or moves while the return is being computed — and derives the bytes from git rather than from anyone's claim; `fold` is the acceptance, and it refuses if the tree moved since the return — precisely, it re-confirms **equality of the visible canonical payload**, which is a change detector rather than a cryptographic identity of the tree: under the default head base that payload's untracked section is unframed and carries no file mode, so a content or symlink target that imitates the marker opening the next entry can alias two trees, and making an untracked file executable moves nothing (both named as residuals in the mode doc, with the fix queued); under a checkpoint base it is one indexed diff that carries modes. A change set carrying a binary, a non-regular path, a submodule, or a symlink whose target is not valid UTF-8 is **refused** at `return` and `fold` — CONSERVATIVELY, rather than promise what the default head payload may not be able to follow — and the same refusals hold for a checkpoint thread. `degrade` closes a thread that never earned a fold, on the record and with its reason. `aggregate` prints one wave: the registered thresholds, every observation as context, and per step class the finished threads — a folded success with git-provable bytes contributes its ratio, one whose bytes are unprovable is excluded from the mean but still counts in the first-pass rate, and a failed thread, a degrade-closed one, or one folded after failing acceptance each count as a real zero. Below the registered minimum nothing is computed (insufficient); at or above it is computed and labeled PILOT evidence. It REFUSES rather than guessing: no pre-registration, an unfinished thread in scope, a recorded refusal-to-delegate that never opened a thread, or an ambiguous wave each stop the computation by name. `handoff-return --slug <s>` closes the worktree loop after `land --prepare`: it re-attests that main still holds exactly the prepared tree under the same HEAD (both recorded in the handoff at prepare time), prints the satellite handoff's user-owned content byte for byte with its boundaries, byte lengths and the main-owned destinations each part folds into, prints the handoff digest and both OIDs as its proof, states the after-the-fold order (a fold landed after the gates leaves them stale), and records ONE self-reported worktree-stream observation only when the whole prepared change set is measurable — a deletion, a rename, a symlink, a submodule or a mode-only change ends with a named NOT RECORDED instead, never a partial number. Appends only to its own ledger inside the git dir (never committable); it also writes `handoff-return`'s `write-tree` tree object and, for a checkpoint measurement, the leaf's OWN temporary index file and the blobs its forced adds store — never a ref, never the real index; never commits, never runs a subscription CLI. |
|
|
265
265
|
| `/agent-workflow-kit worktrees` | any time | **parallel feature worktrees** — run several features in DIFFERENT agent sessions on one repo, zero interference on working-tree files (the ONE exception is the dependency cache, below): `provision <slug> --plan <file>` creates a sibling git worktree on branch `aw/<slug>` and populates it (registry-derived footprint copy-if-missing — a tracked file is never overwritten; EXACTLY ONE seeded feature plan; the `handoff-<slug>.md` record from minute zero; `node_modules` symlinked where the link stays ignored — a shared MUTABLE dependency cache: writes through it hit MAIN's node_modules; for isolation run the printed isolated-install command (`--install` only PRINTS it; on `--resume` run the printed unlink-first recovery first — printed only for a link whose RAW TARGET is MAIN's `node_modules`, since a foreign or unreadable link is reported as such with no removal advised); absolute root-pinned gate commands rebased on untracked copies only, and only while their bytes equal the MAIN source or its rebased form — user-modified copies stay untouched); `list` is read-only (slug, branch, base, dirty, handoff); `prompt <slug>` is read-only too and re-prints the satellite's cold-start prompt — the same text `provision` ends its report with: where the worktree is, its ONE seeded plan, the handoff as the one channel back, MAIN's orientation (shared series index, landing) and, under its own heading because it is probed on the satellite, that checkout's install posture — every value derived LIVE rather than replayed from the frozen provision record, a recorded value that no longer matches NAMED as a divergence (with the cause its source makes likely) instead of printed as the runnable one, every offered command marked with WHO runs it (`MAIN $ …` for the landing, `HERE $ …` for this checkout's own install, a posture with nothing to run staying prose), and a control character in any rendered value a typed STOP rather than a forged prompt line; `land <slug> --prepare` locks the common git dir, fail-closes on divergence or incomplete satellite state, transfers the complete accepted satellite diff onto a CLEAN main, runs sync plus the declared gates, and reports HEAD/TRANSFER/PREPARED OIDs — the commit ALWAYS stays a dialogue ask; `cleanup <slug>` takes the same lock and removes a LANDED worktree only after live landed-verification against main HEAD, while `--abandon` is the ONE destructive arm (destroys unlanded work; **no preview step** on any writer). The parent dir is the `docs/ai/worktrees.json` `parentDir` setting (default: the repo's sibling parent); an unwritable parent prints the `worktrees-dir` check line: the agent applies the grant on your chat yes after the check, one entry in this copy's `.claude/settings.local.json`, never the committed project settings (`init` is the route you may take instead, and the ack is the fallback for a host that ignores the key), else the printed terminal command runs it. Never commits, never pushes, never runs a subscription CLI. |
|
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: '23.1
|
|
6
|
+
version: '23.2.1'
|
|
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": "23.1
|
|
3
|
+
"version": "23.2.1",
|
|
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",
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
// .claude/settings.json.
|
|
6
6
|
//
|
|
7
7
|
// SELF-CONTAINED by contract: the placed copy must run on machines without the kit — no kit
|
|
8
|
-
// imports, dependency-free, Node >= 22, no side effects on import.
|
|
9
|
-
//
|
|
10
|
-
// SEEDED_READONLY_CORE ≡ UNIVERSAL_READONLY_ALLOWLIST and RESIDUAL_FORMS ≡
|
|
11
|
-
// RUNTIME_RESIDUAL_FORMS — drift-guarded by the kit's test/gate-hook-core-parity.test.mjs.
|
|
8
|
+
// imports, dependency-free, Node >= 22, no side effects on import.
|
|
9
|
+
// SEEDED_READONLY_CORE and RESIDUAL_FORMS are the generated region scripts/sync-mirrors.mjs writes from velocity-profile.mjs.
|
|
12
10
|
//
|
|
13
11
|
// It reads <project root>/docs/ai/gates.json LIVE on every invocation (AD-035: one declaration,
|
|
14
12
|
// two consumers — editing gates.json never requires re-wiring) and, for the opt-in read-lane
|
|
@@ -101,67 +99,69 @@ export const DECISION_ASK = 'ask';
|
|
|
101
99
|
// fenced closed by default. The residual guard (b) is NOT mode-fenced: an `ask` never loosens.
|
|
102
100
|
export const ALLOW_PERMISSION_MODES = Object.freeze(['default', 'acceptEdits']);
|
|
103
101
|
|
|
104
|
-
//
|
|
105
|
-
// core velocity seeds as settings allow rules). Drift-guarded — never edit here alone.
|
|
102
|
+
// generated from agent-workflow-kit/tools/velocity-profile.mjs by scripts/sync-mirrors.mjs; do not edit
|
|
106
103
|
export const SEEDED_READONLY_CORE = Object.freeze([
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
104
|
+
"Bash(git status:*)",
|
|
105
|
+
"Bash(git diff:*)",
|
|
106
|
+
"Bash(git log:*)",
|
|
107
|
+
"Bash(git show:*)",
|
|
108
|
+
"Bash(git ls-files:*)",
|
|
109
|
+
"Bash(git check-ignore:*)",
|
|
110
|
+
"Bash(git branch --list:*)",
|
|
111
|
+
"Bash(git rev-parse:*)",
|
|
112
|
+
"Bash(git blame:*)",
|
|
113
|
+
"Bash(git shortlog:*)",
|
|
114
|
+
"Bash(git describe:*)",
|
|
115
|
+
"Bash(git tag --list:*)",
|
|
116
|
+
"Bash(git stash list:*)",
|
|
117
|
+
"Bash(git worktree list:*)",
|
|
118
|
+
"Bash(npm view:*)",
|
|
119
|
+
"Bash(npm ls:*)",
|
|
120
|
+
"Bash(npm outdated:*)",
|
|
121
|
+
"Bash(ls:*)",
|
|
122
|
+
"Bash(cat:*)",
|
|
123
|
+
"Bash(head:*)",
|
|
124
|
+
"Bash(tail:*)",
|
|
125
|
+
"Bash(wc:*)",
|
|
126
|
+
"Bash(readlink:*)",
|
|
127
|
+
"Bash(which:*)",
|
|
128
|
+
"Bash(grep:*)",
|
|
129
|
+
"Bash(diff:*)",
|
|
130
|
+
"Bash(stat:*)",
|
|
131
|
+
"Bash(du:*)",
|
|
132
|
+
"Bash(basename:*)",
|
|
133
|
+
"Bash(dirname:*)",
|
|
134
|
+
"Bash(realpath:*)",
|
|
138
135
|
]);
|
|
139
|
-
|
|
140
|
-
// Baked frozen copy of velocity-profile.mjs RUNTIME_RESIDUAL_FORMS (the documented residual a
|
|
141
|
-
// settings-level allow rule cannot see). Drift-guarded — never edit here alone.
|
|
142
136
|
export const RESIDUAL_FORMS = Object.freeze({
|
|
143
|
-
writeRedirections: Object.freeze([
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
137
|
+
"writeRedirections": Object.freeze([
|
|
138
|
+
">",
|
|
139
|
+
">>",
|
|
140
|
+
"1>",
|
|
141
|
+
"2>",
|
|
142
|
+
"&>",
|
|
143
|
+
">|",
|
|
144
|
+
]),
|
|
145
|
+
"commandSubstitutions": Object.freeze([
|
|
146
|
+
"$(",
|
|
147
|
+
"`",
|
|
148
|
+
"<(",
|
|
149
|
+
">(",
|
|
150
|
+
"${ ",
|
|
151
|
+
"${\t",
|
|
152
|
+
"${\n",
|
|
153
|
+
"${\r",
|
|
154
|
+
"${|",
|
|
155
|
+
]),
|
|
156
|
+
"lineContinuations": Object.freeze([
|
|
157
|
+
"\\\n",
|
|
158
|
+
"\\\r",
|
|
159
|
+
]),
|
|
160
|
+
"boundedWriteFlags": Object.freeze([
|
|
161
|
+
"--output",
|
|
162
|
+
]),
|
|
164
163
|
});
|
|
164
|
+
// end of the generated lists
|
|
165
165
|
|
|
166
166
|
export const RESIDUAL_CLASS_REDIRECTION = 'output redirection';
|
|
167
167
|
export const RESIDUAL_CLASS_SUBSTITUTION = 'command substitution';
|
|
@@ -30,7 +30,7 @@ The **consent route** for a harness item: run its `check:` line in the sandbox a
|
|
|
30
30
|
|
|
31
31
|
A variant's posture note, where its key has one, is printed by `init` from this installed mode doc (the one source); a variant without a note shows its preview, and a harness variant also the check's lines.
|
|
32
32
|
|
|
33
|
-
- `bridge-tier` — the lane is harness and env-dependent: the agent applies the item on the chat yes after the check, writing the project `.claude/settings.json`; `init` previews `velocity-profile --bridge-tier` and applies it on the terminal y as the route the user may take instead. It wires the USED bridges from the project's effective recipes and host readiness: each used review wrapper's `code`-mode allow rule (a wrapper then runs UNATTENDED: it reads any repo file it is pointed at and sends the assembled payload to its subscription backend), the quoted grounding pre-step rule when `agy-review` is used, `codex-review *` / `agy-review *` in `sandbox.excludedCommands`, and `codex-exec *` where an execute slot delegates (no execution allow rule: it keeps its prompt). It also seeds the used bridges' hosts in `sandbox.network.allowedDomains` and resolved state dirs, home-relative where under home, in `sandbox.filesystem.allowWrite`; both come from the kit service fragments (`agent-workflow-kit/tools/services/`) their manifests name in `services`. Where the host honours the settings sandbox keys, an excluded wrapper runs outside the sandbox, every sandboxed command of the project can reach the seeded hosts, and every sandboxed command can write the seeded state dirs. The item fires while an allow rule, a `*` exclusion, a host or a state dir of a used bridge is missing. Its `recipe:` line names each missing entry by kind (allow rules, exclusions, hosts, state dirs), then what the execution wrapper `codex-exec` needs where an execute slot delegates, then, when the project settings enable the sandbox, "once added, wired where the host honors the settings sandbox keys", or "host condition unchecked" with the reason.
|
|
33
|
+
- `bridge-tier` — the lane is harness and env-dependent: the agent applies the item on the chat yes after the check, writing the project `.claude/settings.json`; `init` previews `velocity-profile --bridge-tier` and applies it on the terminal y as the route the user may take instead. It wires the USED bridges from the project's effective recipes and host readiness: each used review wrapper's `code`-mode allow rule (a wrapper then runs UNATTENDED: it reads any repo file it is pointed at and sends the assembled payload to its subscription backend), the quoted grounding pre-step rule when `agy-review` is used, `codex-review *` / `agy-review *` in `sandbox.excludedCommands`, and `codex-exec *` where an execute slot delegates (no execution allow rule: it keeps its prompt). It also seeds the used bridges' hosts in `sandbox.network.allowedDomains` and resolved state dirs, home-relative where under home, in `sandbox.filesystem.allowWrite`; both come from the kit service fragments (`agent-workflow-kit/tools/services/`) their manifests name in `services`, then from your own services list (`services.json` beside the bridge settings file, Mode: setup); it also seeds your list's excluded commands into `sandbox.excludedCommands`. Where the host honours the settings sandbox keys, an excluded wrapper, and each excluded command of your list, runs outside the sandbox, every sandboxed command of the project can reach the seeded hosts, and every sandboxed command can write the seeded state dirs. The item fires while an allow rule, a `*` exclusion, a host or a state dir of a used bridge is missing. Its `recipe:` line names each missing entry by kind (allow rules, exclusions, hosts, state dirs), then what the execution wrapper `codex-exec` needs where an execute slot delegates, then, when the project settings enable the sandbox, "once added, wired where the host honors the settings sandbox keys", or "host condition unchecked" with the reason.
|
|
34
34
|
|
|
35
35
|
- `read-lane` — enabling the opt-in read-only compound lane auto-approves *compounds* (and singles) of the seeded read-only core that carry ZERO shell metaprogramming: an UNATTENDED trust extension, bounded by the audited read-only core (never a command outside it; prompt-bypass only, never a sandbox bypass) and applied regardless of which of those core commands you seeded as individual settings rules. It is a PROJECT-PERSISTENT declaration in `docs/ai/lanes.json` — every future session, subagents' Bash too where the host fires hooks on subagent Bash, and (committed) every checkout. The item renders while the hook is wired and the lane is off, whatever the placed hook's bytes; its apply is the `gate-hook --read-lane` preview, whose own currency check refuses a stale hook (a pre-1.48 hook never reads `lanes.json`). A stale or absent hook under it is a planned file of the kit item `gate-hook.not-current`, applied before the offers. The agent applies the enable offer on the chat yes, and the kit item with no question after the check; `init` applies that kit item on its one y as the route the user may take instead. Risk profile: a bounded read-only trust-posture extension — no write/exec exposure beyond the audited core.
|
|
36
36
|
- `worktrees-dir` — the agent applies the item on the chat yes after the check: one `sandbox.filesystem.allowWrite` entry naming the worktrees parent itself, written to this copy's `.claude/settings.local.json` only, never the committed project settings, the parent created when missing. `init` applies it on the batch terminal yes as the route the user may take instead. Where the host honors the key, the entry widens the OS-sandbox WRITE surface to the whole parent dir: every sibling path under it (other repositories included) becomes agent-writable, for every later session and every worktree provisioned afterwards. Narrow it BEFORE the first apply: point `docs/ai/worktrees.json` `parentDir` at a dedicated dir — no apply removes an entry, so an earlier one stays until the user deletes it. A parent that is the home or holds it renders `worktrees-dir.home` instead, the user's own step. **Convergence** is two-path: a declared `sandbox.filesystem.allowWrite` entry covering the probed dir (either settings scope — `~` and `~/…` resolve against home, and coverage is path-segment-aware, so a grant on a sibling or on a child never counts), or the dir-bound acknowledgement `worktreesDirAck` in the family-owned `docs/ai/acks.json`, recorded by the `ack-write --lane worktrees-dir` line the `recipe:` line carries — the ack fallback for a host that ignores the key, run only on the user's word, instead of the grant; against a trusted host NO no ack renders. Neither is proof of write CAPABILITY: the provision preflight's real create+delete probe stays the runtime truth, and the ack is bound to the **resolved probe dir**, so the item re-fires only when that resolved dir changes. Risk profile: a real write-surface widening where honored — scope it deliberately.
|
|
@@ -57,7 +57,7 @@ Only Claude Code on Linux/WSL2 is measured; Codex, Devin and agy as hosts and ma
|
|
|
57
57
|
A first session may meet ordinary prompts until the autonomy render lands; a chat apply is promptless only where the host auto-allows sandboxed commands.
|
|
58
58
|
|
|
59
59
|
- **Settings-native sandbox** (the harness reads the `.claude/settings.json` sandbox keys): where the harness honours the `--bridge-tier` wiring's `excludedCommands` entries (`codex-review *` / `agy-review *`, and `codex-exec *` where an execute slot delegates, keeping its prompt), the used bridges' wrappers run OUTSIDE the sandbox and never consult `allowedDomains`/`allowWrite` — nothing beyond the tier. A bare name matches only the argument-free command: observed 2026-10-06, Claude Code 2.1.291 ran an agent's plain `codex-review` inside its sandbox beside the bare entry; a harness may keep a `*`-excluded wrapper sandboxed too (unmeasured). There a recipe host outside `allowedDomains` is refused by the harness proxy or held for a network prompt (a refusal reads `Tunnel connection failed: 403` or `CONNECT tunnel failed, response 403` in the run). The lane for the hosts AND the state dirs is the `--bridge-tier` re-run: it seeds the used bridges' declared hosts into `sandbox.network.allowedDomains` and resolved state dirs into `sandbox.filesystem.allowWrite`, and the `bridge-tier` item offers it while any used-bridge surface is missing. Where the host honours the settings sandbox keys, every sandboxed command of the project can reach those hosts and every sandboxed command can write those state dirs.
|
|
60
|
-
- **Harness-managed sandbox** (an IDE/session-imposed sandbox that ignores the settings keys) — a NARROWEST-SCOPE ladder: (1) prefer wrapper/command-SCOPED sandbox rules where the harness offers them (only the review wrappers gain the egress + state-dir writes); (2) a SESSION-scoped allowance (the hosts of the services the manifests name + the resolved state dirs for the whole session) is an INFORMED WIDENING — it carries the same blast-radius class the `--bridge-tier` keys carry where a host honours them (every sandboxed command in the session gains that egress and write access to those state dirs), acceptable only as the maintainer's deliberate choice for a review-heavy session. (3) Else the per-run consented bypass. The kit writes no shape for this sandbox — the harness's own controls (its scoped rules, a session allowance, its consent at the point of action) govern there; an IDE-managed session sandbox was live-observed (2026-07-11/12) ignoring the settings security keys in BOTH scopes, and whether a session's sandbox honours them is not knowable from the advisor.
|
|
60
|
+
- **Harness-managed sandbox** (an IDE/session-imposed sandbox that ignores the settings keys) — a NARROWEST-SCOPE ladder: (1) prefer wrapper/command-SCOPED sandbox rules where the harness offers them (only the review wrappers gain the egress + state-dir writes); (2) a SESSION-scoped allowance (the hosts of the services the manifests name and of your own services list + the resolved state dirs for the whole session) is an INFORMED WIDENING — it carries the same blast-radius class the `--bridge-tier` keys carry where a host honours them (every sandboxed command in the session gains that egress and write access to those state dirs), acceptable only as the maintainer's deliberate choice for a review-heavy session. (3) Else the per-run consented bypass. The kit writes no shape for this sandbox — the harness's own controls (its scoped rules, a session allowance, its consent at the point of action) govern there; an IDE-managed session sandbox was live-observed (2026-07-11/12) ignoring the settings security keys in BOTH scopes, and whether a session's sandbox honours them is not knowable from the advisor.
|
|
61
61
|
- Either way the recipe is **observed-minimal, honestly incomplete** — a blocked host names itself at run time; the service fragments (`agent-workflow-kit/tools/services/`) record what was observed.
|
|
62
62
|
|
|
63
63
|
**Invariants:** read-only (never writes, never commits, never runs a subscription CLI) · `--cwd` required · present-even-when-empty · verdict-first from frozen templates · probe failures degrade to stated skip lines · chat apply one-liners are cwd-independent (absolute tool paths + a pinned `--cwd`; the ONE exception is the `set-autonomy` item, a conversational skill invocation explicitly labeled *run IN the target project*) · the bare `sandbox-provision` item is the user's own step, pinned via a `cd <root> &&` prefix — the doctor reads its cwd · harness items carry a check and an apply bound to its digest; user items, including `family-freshness`, carry the user's own step · the used bridges' `sandbox.filesystem.allowWrite` and `sandbox.network.allowedDomains` are seeded only by the consented `velocity-profile --bridge-tier`; the worktrees grant is seeded into the local settings by the consented `velocity-profile --worktrees` · the `worktrees-dir` item converges on a declared `allowWrite` entry covering its probed dir in either scope, or on its `worktreesDirAck` in `docs/ai/acks.json`, recorded by the `ack-write` line its `recipe:` line carries, not by its apply line.
|
|
@@ -43,6 +43,8 @@ For each backend it:
|
|
|
43
43
|
2. **Links its wrappers** (`codex-exec` / `codex-review`; `agy-review` / `agy-run`) onto `--bindir` via **managed symlinks** — replacing only a symlink that already points at our source. A non-symlink or a foreign symlink → **STOP**; it **preflights every target first**, so a conflict on one wrapper makes **zero** changes. If `--bindir` is not on `PATH`, it prints the one-line `export PATH=…` to add — it never edits a shell rc.
|
|
44
44
|
3. **Guides the manual, secret-bearing steps it will NOT automate** — the binary install (each bridge's `setup/README.md` §1) and the one-time interactive subscription login (`codex login` / `agy`) — printing the exact command for whichever axis is still missing (axis-aware: it can ask for both the CLI and the login at once).
|
|
45
45
|
|
|
46
|
+
**Your own services list.** A service a bridge run must reach that the kit does not ship goes into one strict JSON file of your own, `services.json` beside the bridge settings file (`$XDG_CONFIG_HOME/agent-workflow/services.json`, default `~/.config/agent-workflow/services.json`); the kit only reads it. Its root maps a service id (lowercase letters, digits and `-`, starting with a letter, never a kit service id) to an object with exactly the six keys of a kit service fragment (`agent-workflow-kit/tools/services/`, schema in `${CLAUDE_SKILL_DIR}/tools/manifest/schema.md`): `hosts`, `writableDirs`, `excludedCommands`, `passedVariables`, `billingVariables`, `runReachesHosts`. A passed variable equal to any billing variable is refused. Every service in it joins every placed bridge, in two phases: (1) this step's place and every refresh (`init`, `/agent-workflow-kit upgrade`) write each placed bridge's `service-facts.txt` from the bridge's own services then yours; (2) the `velocity --bridge-tier` item adds your hosts, state dirs and excluded commands to the project `.claude/settings.json` for every used bridge. A list the loader refuses stops the place (`stop`) or the refresh (`could not refresh`) with zero writes in that bridge's folder, and stops the tier with zero writes: the line names the file — fix or remove it, then run the same step again. **Removal:** a service you delete from the list leaves each placed facts file at the next refresh; the sandbox entries the tier already added stay (the tier only adds) — remove them from `.claude/settings.json` yourself.
|
|
47
|
+
|
|
46
48
|
**Close-the-loop output (surface both, localized).** The tool prints, after the per-backend report:
|
|
47
49
|
- a **bridge version** on each skill line — `(vX)` for a fresh place / equal refresh, `(vOld → vNew)` when a refresh bumps the bridge (never `vnull → …`);
|
|
48
50
|
- a **status pointer** — the full family + deployment version view lives in `/agent-workflow-kit status`;
|
|
@@ -58,7 +58,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
58
58
|
current* / *skipped — not placed* / `skipped-readonly` / *could not refresh* + its recovery). It
|
|
59
59
|
is **refresh-only**: it refreshes a bridge **`setup` already placed** from this kit's bundled copies
|
|
60
60
|
and re-links its wrappers; an **absent** bridge is a stated skip, **never a first placement**
|
|
61
|
-
(placement stays the opt-in `${CLAUDE_SKILL_DIR}/references/modes/setup.md`
|
|
61
|
+
(placement stays the opt-in `${CLAUDE_SKILL_DIR}/references/modes/setup.md`), a placed bridge
|
|
62
62
|
**newer** than the bundle is a stated skip naming the kit update (**never a downgrade**), and
|
|
63
63
|
`skipped-readonly` is an equal-version re-sync a **read-only** skills dir blocked this session (a
|
|
64
64
|
stated skip, exit 0 — not a failure). That line never guesses at the tree: it carries one **proven**
|
|
@@ -69,8 +69,8 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
69
69
|
write, an incompatible node kind, a foreign wrapper target; those are named apart as
|
|
70
70
|
resolve-by-hand-then-rerun), or `unverifiable` (every uncomparable item **named**, the remaining
|
|
71
71
|
need for repair unknown). The line carries the exact cause per item — relay it as worded, never
|
|
72
|
-
soften `unverifiable` into "already fine", never relay a resolve-by-hand item as rerun-fixable
|
|
73
|
-
Runs on **every** upgrade
|
|
72
|
+
soften `unverifiable` into "already fine", never relay a resolve-by-hand item as rerun-fixable;
|
|
73
|
+
on `drifted`/`unverifiable` rerun it outside the sandbox. Runs on **every** upgrade
|
|
74
74
|
(equal-head too), no lineage-head bump; a *could not refresh* line is non-fatal — relay it plainly
|
|
75
75
|
with its recovery.
|
|
76
76
|
|
|
@@ -49,7 +49,7 @@ Honesty notes: tier entries get **NO PreToolUse-hook residual coverage — with
|
|
|
49
49
|
|
|
50
50
|
**The boundary of that qualifier, stated so it is not guessed.** It covers claims about `sandbox.*` keys — the block whose honouring was observed to vary by host. It deliberately does NOT cover `permissions.*` semantics (an allow rule auto-approving a command, `local > project` precedence for a non-sandbox key): that is the harness's own documented permission model, the layer this whole mode rests on, and hedging it would say nothing true. **Stated residual:** which sentences count as settings-derived runtime claims is decided by review, not by a checker — deciding whether a sentence asserts a runtime effect is a question about prose meaning, and this family deliberately has no mechanism that judges that (the same limit that retired the byte-scanning deny rung). A new claim-bearing line therefore has to carry the qualifier by authorship; the acceptance criterion is that every line stating what a `sandbox.*` key DOES carries it, and the tests pin the surfaces that exist today. What does NOT change is the CLASSIFICATION: which red-line a key would weaken, and that a proven bridge-tier exclusion is a note rather than a weakening, are properties of the declaration and stay flat statements.
|
|
51
51
|
|
|
52
|
-
**The `--bridge-tier` (own opt-in, AD-044).** Seeds the USED bridges from every recipe's review and execute slots in `docs/ai/orchestration.json`, resolved over host readiness to the effective recipe: a degraded recipe uses its resolved providers; an absent config takes the computed default. A bridge no slot uses gets nothing. Per used review role it seeds `Bash(<wrapper> code:*)` into `permissions.allow` and, with agy-review used, the quoted grounding pre-step rule. Per used role it seeds `<wrapper> *` and the excluded commands of the services its manifest names into `sandbox.excludedCommands`, those services' hosts into `sandbox.network.allowedDomains`, and their resolved state dirs into `sandbox.filesystem.allowWrite`, home-relative under the home and absolute outside it, with env overrides honoured. All entries land in the **project** `.claude/settings.json`, preserving existing entries and sibling keys. **Where the host honors the settings sandbox keys**, an exclusion means the wrapper runs outside the sandbox; a host means every sandboxed command of the project can reach it; a dir means every sandboxed command can write it — each widening is part of this consent. A session-imposed sandbox may ignore those keys; its lane is in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. An exclusion placed only in `settings.local.json` was live-observed NOT to route the command outside the sandbox (2026-07-11: the wrapper then starts sandboxed and dies on a read-only HOME), so hand-wiring the local file is no substitute for this tier. Under a harness-managed session sandbox (live-observed 2026-07-11/12) an IDE-managed sandbox ignores `sandbox.network.allowedDomains` and `sandbox.filesystem.allowWrite` in BOTH settings scopes — its own per-host consents govern egress, and the durable lanes there are the session sandbox config (the hosts plus the CLI state-dir writes) or the per-run consented bypass. Each bridge's observed egress hosts come from the kit service fragments (`agent-workflow-kit/tools/services/`) its `capability.json` names in `services` — the single documentation source (this doc retypes no host list); an apex domain is NOT covered by its `*.`-wildcard form, so the fragments carry both forms where observed. The upgrade Recommendations advisor's `bridge-tier` item offers this tier while any used-bridge surface is missing, its `recipe:` line naming each missing entry; an acknowledgement the retired session-sandbox-recipe item recorded in `docs/ai/acks.json` is never read, relabelled or removed — it keeps the meaning "seen". **Bare-entry reading (measured 2026-10-06):** an exclusion uses Bash rule syntax; a bare name matches only the argument-free command, so the tier writes the form with ` *`; an earlier bare entry stays and does not satisfy that surface. Where an execute slot delegates, codex-exec gets its exclusion, hosts and state dirs, but no allow rule, so a delegated run keeps its prompt. Only the code review mode is auto-allowed; plan/diff keep their prompt. The grounding rule uses the double-quoted absolute kit path the procedures advisor renders; an unseedable path is a stated skip. Its writer guard accepts only system-temp scratch or a fresh gitignored in-repo destination, refusing tracked, non-ignored, existing in-repo, outside-repo non-temp and symlink/non-regular destinations. The seeded byte-forms (this list IS the documented-invocation source for the bridge tier):
|
|
52
|
+
**The `--bridge-tier` (own opt-in, AD-044).** Seeds the USED bridges from every recipe's review and execute slots in `docs/ai/orchestration.json`, resolved over host readiness to the effective recipe: a degraded recipe uses its resolved providers; an absent config takes the computed default. A bridge no slot uses gets nothing. Per used review role it seeds `Bash(<wrapper> code:*)` into `permissions.allow` and, with agy-review used, the quoted grounding pre-step rule. Per used role it seeds `<wrapper> *` and the excluded commands of the services its manifest names into `sandbox.excludedCommands`, those services' hosts into `sandbox.network.allowedDomains`, and their resolved state dirs into `sandbox.filesystem.allowWrite`, home-relative under the home and absolute outside it, with env overrides honoured. All entries land in the **project** `.claude/settings.json`, preserving existing entries and sibling keys. **Where the host honors the settings sandbox keys**, an exclusion means the wrapper runs outside the sandbox; a host means every sandboxed command of the project can reach it; a dir means every sandboxed command can write it — each widening is part of this consent. A session-imposed sandbox may ignore those keys; its lane is in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. An exclusion placed only in `settings.local.json` was live-observed NOT to route the command outside the sandbox (2026-07-11: the wrapper then starts sandboxed and dies on a read-only HOME), so hand-wiring the local file is no substitute for this tier. Under a harness-managed session sandbox (live-observed 2026-07-11/12) an IDE-managed sandbox ignores `sandbox.network.allowedDomains` and `sandbox.filesystem.allowWrite` in BOTH settings scopes — its own per-host consents govern egress, and the durable lanes there are the session sandbox config (the hosts plus the CLI state-dir writes) or the per-run consented bypass. Each bridge's observed egress hosts come from the kit service fragments (`agent-workflow-kit/tools/services/`) its `capability.json` names in `services`, then from your own services list (`services.json` beside the bridge settings file, Mode: setup), whose services every used bridge also gets — the single documentation source (this doc retypes no host list); a list its loader refuses stops the tier with zero writes, naming the file; an apex domain is NOT covered by its `*.`-wildcard form, so the fragments carry both forms where observed. The upgrade Recommendations advisor's `bridge-tier` item offers this tier while any used-bridge surface is missing, its `recipe:` line naming each missing entry; an acknowledgement the retired session-sandbox-recipe item recorded in `docs/ai/acks.json` is never read, relabelled or removed — it keeps the meaning "seen". **Bare-entry reading (measured 2026-10-06):** an exclusion uses Bash rule syntax; a bare name matches only the argument-free command, so the tier writes the form with ` *`; an earlier bare entry stays and does not satisfy that surface. Where an execute slot delegates, codex-exec gets its exclusion, hosts and state dirs, but no allow rule, so a delegated run keeps its prompt. Only the code review mode is auto-allowed; plan/diff keep their prompt. The grounding rule uses the double-quoted absolute kit path the procedures advisor renders; an unseedable path is a stated skip. Its writer guard accepts only system-temp scratch or a fresh gitignored in-repo destination, refusing tracked, non-ignored, existing in-repo, outside-repo non-temp and symlink/non-regular destinations. The seeded byte-forms (this list IS the documented-invocation source for the bridge tier):
|
|
53
53
|
|
|
54
54
|
- `Bash(codex-review code:*)` — the review code-mode allow rule; `codex-review *` — its sandbox.excludedCommands entry.
|
|
55
55
|
- `Bash(agy-review code:*)` — the review code-mode allow rule; `agy-review *` — its sandbox.excludedCommands entry; `Bash(node "${CLAUDE_SKILL_DIR}/tools/grounding.mjs":*)` — its quoted grounding pre-step rule.
|
|
@@ -185,7 +185,7 @@ export const scopeOf = (variant, facts, deps = {}) => {
|
|
|
185
185
|
if (variant === 'bridge-tier') {
|
|
186
186
|
const detect = deps.detect ?? facts.detect ?? (() => detectAtRoot(facts.root, { env: facts.env, home: facts.home }));
|
|
187
187
|
const used = usedBridges(loadConfig(facts.root).config, detect());
|
|
188
|
-
const recipe = bundledSandboxRecipe(used, { groundingAbsPath: join(facts.toolsDir, '..', KIT_GROUNDING_TOOL) });
|
|
188
|
+
const recipe = bundledSandboxRecipe(used, { env: facts.env, home: facts.home, groundingAbsPath: join(facts.toolsDir, '..', KIT_GROUNDING_TOOL) });
|
|
189
189
|
allow.push(...recipe.allow);
|
|
190
190
|
set('sandbox.excludedCommands', recipe.excludedCommands);
|
|
191
191
|
set('sandbox.network.allowedDomains', recipe.hosts);
|
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
// Dependency-free, Node >= 22. No side effects on import.
|
|
8
8
|
|
|
9
9
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
10
11
|
import { dirname, join, resolve } from 'node:path';
|
|
11
12
|
import { fileURLToPath } from 'node:url';
|
|
12
|
-
import { DEFAULT_BUNDLE_ROOT } from './bridge-settings-read.mjs';
|
|
13
|
+
import { DEFAULT_BUNDLE_ROOT, userServicesFile } from './bridge-settings-read.mjs';
|
|
13
14
|
import { ACTIVITIES, BACKEND_PRIORITY, REVIEW_CMD_ALIASES } from './carriers.mjs';
|
|
14
15
|
import { planRecipe, resolveActivityRecipe } from './recipes.mjs';
|
|
15
16
|
import { isReadyMember } from './review-roster-resolve.mjs';
|
|
16
17
|
import { isSeedablePathToken } from './repo-lex.mjs';
|
|
17
|
-
import { loadServiceFragments, mergeServices } from './services/index.mjs';
|
|
18
|
+
import { loadServiceFragments, loadUserServices, mergeServices } from './services/index.mjs';
|
|
18
19
|
|
|
19
20
|
// The review wrappers, spelled bare as invoked. Only their `code` mode is auto-allowed: a bare
|
|
20
21
|
// `Bash(<wrapper>:*)` prefix would also cover the plan/diff file-argument modes, whose targets can
|
|
@@ -83,6 +84,9 @@ export const bundledSandboxRecipe = (used, deps = {}) => {
|
|
|
83
84
|
const readDir = deps.readdir ?? readdirSync;
|
|
84
85
|
const bundleRoot = deps.bundleRoot ?? DEFAULT_BUNDLE_ROOT;
|
|
85
86
|
const fragments = loadServiceFragments({ servicesDir: deps.servicesDir });
|
|
87
|
+
const userFragments = deps.userServices === false ? {} : loadUserServices(fragments, {
|
|
88
|
+
file: deps.userServicesFile ?? userServicesFile({ env: deps.env ?? process.env, home: deps.home ?? homedir() }),
|
|
89
|
+
});
|
|
86
90
|
const allow = [];
|
|
87
91
|
const excludedCommands = [];
|
|
88
92
|
const hosts = [];
|
|
@@ -119,7 +123,7 @@ export const bundledSandboxRecipe = (used, deps = {}) => {
|
|
|
119
123
|
});
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
|
-
const services = mergeServices(manifest.services ?? [], fragments);
|
|
126
|
+
const services = mergeServices(manifest.services ?? [], fragments, userFragments);
|
|
123
127
|
for (const command of services.excludedCommands) pushOnce(excludedCommands, command);
|
|
124
128
|
for (const host of services.hosts) pushOnce(hosts, host);
|
|
125
129
|
for (const entry of services.dirEntries) {
|
|
@@ -84,6 +84,8 @@ export const allowedLabel = (entry) => {
|
|
|
84
84
|
|
|
85
85
|
export const settingsDir = (ctx) => join(resolveDir(SETTINGS_XDG, ctx.getenv ?? process.env, ctx.home ?? homedir()), SETTINGS_SUBDIR);
|
|
86
86
|
export const settingsPath = (ctx) => join(settingsDir(ctx), SETTINGS_FILENAME);
|
|
87
|
+
export const userServicesFile = ({ env = process.env, home = homedir() } = {}) =>
|
|
88
|
+
join(resolveDir(SETTINGS_XDG, env, home), SETTINGS_SUBDIR, 'services.json');
|
|
87
89
|
|
|
88
90
|
// Lines with a single trailing newline normalized away, so edits operate on an exact line array and
|
|
89
91
|
// re-serialize with one trailing newline (comments/blank lines in the middle survive verbatim).
|
|
@@ -349,8 +349,7 @@ const hasHiddenFence = (projectDir, deps = {}) => {
|
|
|
349
349
|
// probe never imports the rotator).
|
|
350
350
|
// The ADR-layout probe's paths. LOCAL literals, not an import: this module backs the read-only
|
|
351
351
|
// `status` view and importing the rotator would drag child_process + crypto into a status read. A
|
|
352
|
-
// drift guard in family-registry.test.mjs pins each literal to the rotator's exported constant
|
|
353
|
-
// the same baked-frozen-copy shape the gate hook uses for its velocity constants.
|
|
352
|
+
// drift guard in family-registry.test.mjs pins each literal to the rotator's exported constant.
|
|
354
353
|
export const ADR_LAYOUT_PATHS = Object.freeze({
|
|
355
354
|
hot: 'docs/ai/decisions.md',
|
|
356
355
|
monoliths: Object.freeze(['docs/ai/history/decisions-archive.md', 'docs/ai/history/decisions-archive-early.md']),
|
package/tools/fs-safe.mjs
CHANGED
|
@@ -71,14 +71,14 @@ export const assertContainedRealPath = (root, dest, deps = {}) => {
|
|
|
71
71
|
// Read-only write-boundary tagging (REFRESH-EROFS-HONESTY / AD-056). A DESTINATION-side write failure
|
|
72
72
|
// of the read-only class is TAGGED (err.readonlyWriteBoundary) so the refresh-only driver can classify
|
|
73
73
|
// an equal-version repair-on-rerun that cannot write as a STATED skip — never a false red. The tag is
|
|
74
|
-
// applied ONLY around
|
|
74
|
+
// applied ONLY around a write primitive, so a READ-side failure (bundle read / dir listing)
|
|
75
75
|
// is never absorbed: the degrade classifies at the write boundary, not by a broad err.code sniff over
|
|
76
76
|
// the whole copy. EROFS is destination-side by nature; mkdir/symlink write only the dest; an
|
|
77
77
|
// EACCES/EPERM at copyFile (which also READS the source) is destination-provable ONLY when the source
|
|
78
78
|
// is readable — else it is a source-side read failure that must stay loud.
|
|
79
79
|
const READONLY_WRITE_ERRNOS = new Set(['EROFS', 'EACCES', 'EPERM']);
|
|
80
80
|
export const isReadonlyWriteBoundary = (err) => Boolean(err && err.readonlyWriteBoundary);
|
|
81
|
-
const throwTaggedReadonly = (err, primitive, src, readFile) => {
|
|
81
|
+
export const throwTaggedReadonly = (err, primitive, src, readFile) => {
|
|
82
82
|
if (err && READONLY_WRITE_ERRNOS.has(err.code)) {
|
|
83
83
|
let destinationSide = err.code === 'EROFS' || primitive !== 'copyFile';
|
|
84
84
|
if (!destinationSide) {
|
package/tools/manifest/schema.md
CHANGED
|
@@ -98,8 +98,8 @@ drift-guarded set-equal to this block by the bridge `bin/*.test.mjs` suites (hel
|
|
|
98
98
|
|
|
99
99
|
`services` names the kit service fragments under `agent-workflow-kit/tools/services/` that the
|
|
100
100
|
bridge uses. The module's `mergeServices` supplies their hosts, state dirs and excluded commands.
|
|
101
|
-
A fragment is a closed object of
|
|
102
|
-
`passedVariables`, `runReachesHosts`), enforced by the module's loader in
|
|
101
|
+
A fragment is a closed object of six required keys (`hosts`, `writableDirs`, `excludedCommands`,
|
|
102
|
+
`passedVariables`, `billingVariables`, `runReachesHosts`), enforced by the module's loader in
|
|
103
103
|
[`../services/index.mjs`](../services/index.mjs); the host and state-dir rules are the ones these
|
|
104
104
|
retired manifest fields carried.
|
|
105
105
|
|
package/tools/refresh-parity.mjs
CHANGED
|
@@ -75,7 +75,7 @@ const probe = (path, fs) => {
|
|
|
75
75
|
// Plus `modes`: the placed mode of every node the walk actually reached as a regular file. It exists
|
|
76
76
|
// so the wrapper axis can judge a source's mode WITHOUT a second lstat of its own — a separate stat
|
|
77
77
|
// could traverse a symlinked ancestor this walk already refused, and produce a contradicting verdict.
|
|
78
|
-
export const scanBundleOwnedDrift = (bundleDir, skillDir, fs) => {
|
|
78
|
+
export const scanBundleOwnedDrift = (bundleDir, skillDir, fs, expectedBytes = {}) => {
|
|
79
79
|
const drifted = [];
|
|
80
80
|
const unreadable = [];
|
|
81
81
|
const absent = [];
|
|
@@ -126,7 +126,7 @@ export const scanBundleOwnedDrift = (bundleDir, skillDir, fs) => {
|
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
if (typeof placed.mode === 'number') modes.set(rel, placed.mode);
|
|
129
|
-
const srcBytes = fs.readFile(src);
|
|
129
|
+
const srcBytes = Object.hasOwn(expectedBytes, rel) ? expectedBytes[rel] : fs.readFile(src);
|
|
130
130
|
const destBytes = (() => {
|
|
131
131
|
try {
|
|
132
132
|
return fs.readFile(dest);
|
|
@@ -243,7 +243,7 @@ export const readonlySkipLine = (name, version, verdict) => {
|
|
|
243
243
|
// repair" over both would promise a repair that never happens.
|
|
244
244
|
const said = [];
|
|
245
245
|
if (verdict.drifted.length > 0) {
|
|
246
|
-
said.push(`A read-only re-scan found ${count(verdict.drifted)} still differing from the
|
|
246
|
+
said.push(`A read-only re-scan found ${count(verdict.drifted)} still differing from what the refresh writes: ` +
|
|
247
247
|
`${verdict.drifted.join(', ')} — ${READONLY_RERUN_HINT} to repair.`);
|
|
248
248
|
}
|
|
249
249
|
if (verdict.conflicts.length > 0) {
|
package/tools/services/index.mjs
CHANGED
|
@@ -5,7 +5,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
export const SERVICE_FACTS_FILE = 'service-facts.txt';
|
|
6
6
|
const SERVICES_DIRECTORY = fileURLToPath(new URL('.', import.meta.url));
|
|
7
7
|
const FRAGMENT_EXTENSION = '.json';
|
|
8
|
-
const FRAGMENT_KEYS = ['hosts', 'writableDirs', 'excludedCommands', 'passedVariables', 'runReachesHosts'];
|
|
8
|
+
const FRAGMENT_KEYS = ['hosts', 'writableDirs', 'excludedCommands', 'passedVariables', 'billingVariables', 'runReachesHosts'];
|
|
9
|
+
const SERVICE_ID_RE = /^[a-z][a-z0-9-]*$/;
|
|
9
10
|
const NETWORK_HOST_RE = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;
|
|
10
11
|
const VARIABLE_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
11
12
|
const EXCLUDED_COMMAND_RE = /^[A-Za-z0-9][A-Za-z0-9._-]* \*$/;
|
|
@@ -59,6 +60,7 @@ const validateFragment = (fragment, path) => {
|
|
|
59
60
|
(command) => typeof command === 'string' && EXCLUDED_COMMAND_RE.test(command));
|
|
60
61
|
validateList(fragment.passedVariables, path, 'passedVariables',
|
|
61
62
|
(value) => isVariable(value) && value !== 'OPENAI_BASE_URL');
|
|
63
|
+
validateList(fragment.billingVariables, path, 'billingVariables', isVariable);
|
|
62
64
|
if (typeof fragment.runReachesHosts !== 'boolean') refuseSchema(path, 'runReachesHosts', 'must be a boolean');
|
|
63
65
|
if (fragment.runReachesHosts && fragment.hosts.some((host) => host.startsWith('*.'))) {
|
|
64
66
|
refuseSchema(path, 'hosts', 'must not contain a wildcard when runReachesHosts is true');
|
|
@@ -77,6 +79,18 @@ const readFragment = (path, readFile) => {
|
|
|
77
79
|
return validateFragment(fragment, path);
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
const validateBillingVariables = (fragments, locate) => {
|
|
83
|
+
const billing = new Map(Object.entries(fragments).flatMap(([id, fragment]) =>
|
|
84
|
+
fragment.billingVariables.map((variable) => [variable, id])));
|
|
85
|
+
for (const [id, fragment] of Object.entries(fragments)) {
|
|
86
|
+
for (const variable of fragment.passedVariables) {
|
|
87
|
+
if (!billing.has(variable)) continue;
|
|
88
|
+
const [path, key] = locate(id, billing.get(variable));
|
|
89
|
+
refuseSchema(path, key, `conflicts with billing variable ${variable}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
80
94
|
export const loadServiceFragments = (deps = {}) => {
|
|
81
95
|
const servicesDir = deps.servicesDir ?? SERVICES_DIRECTORY;
|
|
82
96
|
const readdir = deps.readdir ?? readdirSync;
|
|
@@ -88,9 +102,32 @@ export const loadServiceFragments = (deps = {}) => {
|
|
|
88
102
|
throw new Error(`${servicesDir}: cannot read services directory: ${error.message}`, { cause: error });
|
|
89
103
|
}
|
|
90
104
|
})();
|
|
91
|
-
|
|
105
|
+
const fragments = Object.fromEntries(entries.filter((name) => name.endsWith(FRAGMENT_EXTENSION)).sort().map((name) => [
|
|
92
106
|
name.slice(0, -FRAGMENT_EXTENSION.length), readFragment(join(servicesDir, name), readFile),
|
|
93
107
|
]));
|
|
108
|
+
validateBillingVariables(fragments, (id) => [join(servicesDir, `${id}${FRAGMENT_EXTENSION}`), 'passedVariables']);
|
|
109
|
+
return fragments;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const loadUserServices = (fragments, { file, readFile = readFileSync }) => {
|
|
113
|
+
const userFragments = (() => {
|
|
114
|
+
try {
|
|
115
|
+
return JSON.parse(readFile(file, 'utf8'));
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error.code === 'ENOENT') return {};
|
|
118
|
+
throw new Error(`${file}: cannot read or parse user services: ${error.message}`, { cause: error });
|
|
119
|
+
}
|
|
120
|
+
})();
|
|
121
|
+
if (!isObject(userFragments)) refuseSchema(file, 'root', 'must be an object');
|
|
122
|
+
for (const [id, fragment] of Object.entries(userFragments)) {
|
|
123
|
+
if (!SERVICE_ID_RE.test(id) || Object.hasOwn(fragments, id)) refuseSchema(file, id, 'is not an available service id');
|
|
124
|
+
validateFragment(fragment, `${file}: ${id}`);
|
|
125
|
+
}
|
|
126
|
+
validateBillingVariables({ ...fragments, ...userFragments }, (passing, billed) =>
|
|
127
|
+
Object.hasOwn(userFragments, passing)
|
|
128
|
+
? [`${file}: ${passing}`, 'passedVariables']
|
|
129
|
+
: [`${file}: ${billed}`, 'billingVariables']);
|
|
130
|
+
return userFragments;
|
|
94
131
|
};
|
|
95
132
|
|
|
96
133
|
const takeUnique = (entries, identify = (entry) => entry) => {
|
|
@@ -103,11 +140,11 @@ const takeUnique = (entries, identify = (entry) => entry) => {
|
|
|
103
140
|
});
|
|
104
141
|
};
|
|
105
142
|
|
|
106
|
-
export const mergeServices = (ids, fragments) => {
|
|
143
|
+
export const mergeServices = (ids, fragments, userFragments = {}) => {
|
|
107
144
|
const selected = ids.map((id) => {
|
|
108
145
|
if (!Object.hasOwn(fragments, id)) throw new Error(`Unknown service id: ${id}`);
|
|
109
146
|
return fragments[id];
|
|
110
|
-
});
|
|
147
|
+
}).concat(Object.values(userFragments));
|
|
111
148
|
return {
|
|
112
149
|
hosts: takeUnique(selected.flatMap((fragment) => fragment.hosts)),
|
|
113
150
|
dirEntries: takeUnique(selected.flatMap((fragment) => fragment.writableDirs),
|
|
@@ -125,3 +162,6 @@ export const renderServiceFacts = (merged) => [
|
|
|
125
162
|
`${key}=${field === 'dirEntries' ? `${entry.env ?? ''}:${entry.default}` : entry}`)),
|
|
126
163
|
'',
|
|
127
164
|
].join('\n');
|
|
165
|
+
|
|
166
|
+
export const placedServiceFacts = (services, fragments, userFragments) =>
|
|
167
|
+
renderServiceFacts(mergeServices(services, fragments, userFragments));
|
package/tools/services/jev.json
CHANGED
package/tools/setup-backends.mjs
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// setup-backends.mjs — link-only auto-setup for the execution-backend bridges (Plan B / AD-011).
|
|
3
|
-
// The kit owns ONLY the two deterministic, secret-free steps: (1) PLACE/REFRESH the bundled bridge
|
|
4
|
-
// skill into its canonical dir, and (2) LINK its POSIX wrappers onto PATH (~/.local/bin) via managed
|
|
5
|
-
// symlinks. Binary install + the interactive subscription login stay GUIDED (printed, never run) —
|
|
6
|
-
// guideFor() supplies the exact commands. The read-only detector is the reader; this is the writer.
|
|
7
|
-
//
|
|
8
|
-
// Two write modes: plain setup (opt-in, in-agent — the ONLY path that ever PLACES a bridge) and the
|
|
9
|
-
// refresh-only driver (`--refresh-placed` / refreshPlacedBridges, run by `init` and Mode: upgrade) —
|
|
10
|
-
// it refreshes what setup already placed and re-links wrappers, states an absent bridge as a skip
|
|
11
|
-
// (never a first placement), and never downgrades: a placed bridge newer than the kit-bundled mirror
|
|
12
|
-
// is a stated skip naming the kit update (guarded again at the write boundary in placeSkill).
|
|
13
|
-
//
|
|
14
|
-
// Safety posture (AD-011): drive off the decoupled axes (a per-bindir wrapper check + an independent
|
|
15
|
-
// skill-dir inspection), never the detector's collapsed readiness. REFRESH only a dir we provably own
|
|
16
|
-
// (valid manifest, name+kind match) or one that is absent/empty; STOP on anything else (a marker fs
|
|
17
|
-
// error, a stub/foreign/invalid/unsupported manifest, a non-empty unknown dir, or a symlinked dir).
|
|
18
|
-
// Clobber-risk lives only on the wrapper symlinks — replace only a symlink already pointing at our
|
|
19
|
-
// source; STOP on a foreign symlink or a non-symlink. PREFLIGHT every dst, THEN mutate (a conflict on
|
|
20
|
-
// the 2nd wrapper ⇒ zero mutations; no rollback — symlinks/chmod converge on re-run). Windows: the
|
|
21
|
-
// wrappers are POSIX .sh — report unsupported / use WSL and mutate nothing. Every fs primitive is
|
|
22
|
-
// injectable (deps.*) so the whole module is unit-testable without touching the real filesystem.
|
|
23
|
-
//
|
|
24
|
-
// Dependency-free, Node >= 22.
|
|
25
2
|
|
|
26
3
|
import {
|
|
27
4
|
existsSync, lstatSync, statSync, readdirSync, readlinkSync, symlinkSync, mkdirSync, copyFileSync,
|
|
28
|
-
chmodSync, readFileSync, realpathSync,
|
|
5
|
+
chmodSync, readFileSync, realpathSync, writeFileSync,
|
|
29
6
|
} from 'node:fs';
|
|
30
7
|
import { join, resolve, relative, dirname, isAbsolute } from 'node:path';
|
|
31
8
|
import { fileURLToPath } from 'node:url';
|
|
32
9
|
import os from 'node:os';
|
|
33
10
|
import { KNOWN_BACKENDS, detectBackend, detectBackends, resolveDir, guideFor, READY } from './detect-backends.mjs';
|
|
34
11
|
import { isDirectRun } from './direct-run.mjs';
|
|
35
|
-
import { copyTreeRefresh, linkManaged, isReadonlyWriteBoundary } from './fs-safe.mjs';
|
|
12
|
+
import { assertContainedRealPath, copyTreeRefresh, linkManaged, isReadonlyWriteBoundary, throwTaggedReadonly } from './fs-safe.mjs';
|
|
13
|
+
import { userServicesFile } from './bridge-settings-read.mjs';
|
|
14
|
+
import { loadServiceFragments, loadUserServices, placedServiceFacts, SERVICE_FACTS_FILE } from './services/index.mjs';
|
|
36
15
|
import {
|
|
37
16
|
READONLY_RERUN_HINT, WRAPPER_MODE, scanBundleOwnedDrift, scanWrapperParity, parityVerdict,
|
|
38
17
|
unverifiableParity, readonlySkipLine,
|
|
@@ -79,6 +58,7 @@ const fsDeps = (deps = {}) => ({
|
|
|
79
58
|
chmod: deps.chmod ?? chmodSync,
|
|
80
59
|
readFile: deps.readFile ?? readFileSync,
|
|
81
60
|
realpath: deps.realpath ?? realpathSync,
|
|
61
|
+
writeFile: deps.writeFile ?? writeFileSync,
|
|
82
62
|
});
|
|
83
63
|
|
|
84
64
|
// lstat without following symlinks; null when absent. A non-ENOENT error propagates (never fail open).
|
|
@@ -302,14 +282,33 @@ const assertNoDowngrade = (plan, deps = {}) => {
|
|
|
302
282
|
if (compareSemver(placed, bundled) === 1) throw stop(downgradeReason(placed, bundled), { skillDir: plan.skillDir, wouldDowngrade: true });
|
|
303
283
|
};
|
|
304
284
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
285
|
+
const userServicesRemedy = (step) => `fix or remove that file, then run /agent-workflow-kit ${step} again`;
|
|
286
|
+
const loadBridgeServices = (deps) => {
|
|
287
|
+
const fragments = loadServiceFragments();
|
|
288
|
+
try {
|
|
289
|
+
const userFragments = loadUserServices(fragments, {
|
|
290
|
+
file: userServicesFile({ env: deps.getenv ?? process.env, home: deps.home ?? os.homedir() }),
|
|
291
|
+
});
|
|
292
|
+
return { fragments, userFragments };
|
|
293
|
+
} catch (error) {
|
|
294
|
+
throw stop(`${error.message}; ${userServicesRemedy('setup')}`, { userServicesMessage: error.message });
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
309
298
|
const copyBridgeWithHonesty = (action, bundleDir, skillDir, deps) => {
|
|
299
|
+
const { fragments, userFragments } = loadBridgeServices(deps);
|
|
300
|
+
const facts = Object.keys(userFragments).length
|
|
301
|
+
? placedServiceFacts(readBundledManifest(bundleDir, deps).services ?? [], fragments, userFragments) : null;
|
|
310
302
|
const fs = fsDeps(deps);
|
|
311
|
-
const drift = action === 'refresh' ? scanBundleOwnedDrift(bundleDir, skillDir,
|
|
303
|
+
const drift = action === 'refresh' ? scanBundleOwnedDrift(bundleDir, skillDir, {
|
|
304
|
+
...fs, readdir: (path) => fs.readdir(path).filter((name) => path !== bundleDir || name !== SERVICE_FACTS_FILE),
|
|
305
|
+
}) : null;
|
|
312
306
|
copyTreeRefresh(bundleDir, skillDir, skillDir, fs);
|
|
307
|
+
if (facts !== null) {
|
|
308
|
+
const file = join(skillDir, SERVICE_FACTS_FILE);
|
|
309
|
+
assertContainedRealPath(skillDir, file, fs);
|
|
310
|
+
try { fs.writeFile(file, facts, 'utf8'); } catch (error) { throwTaggedReadonly(error, 'writeFile', file, fs.readFile); }
|
|
311
|
+
}
|
|
313
312
|
return drift;
|
|
314
313
|
};
|
|
315
314
|
|
|
@@ -557,12 +556,6 @@ const refreshSkillOnly = (entry, deps = {}) => {
|
|
|
557
556
|
const NOT_PLACED_LINE = 'skipped — not placed (placement is opt-in: /agent-workflow-kit setup)';
|
|
558
557
|
const stripPrefix = (message) => message.replace('[agent-workflow-kit] ', '');
|
|
559
558
|
|
|
560
|
-
// The read-only degrade wording (D1, honesty-split per D4). The STATED-skip line is composed in
|
|
561
|
-
// refresh-parity.mjs from a POST-FAILURE re-scan: the old line asserted "PARTIALLY updated" and "any
|
|
562
|
-
// remaining drift persists" unconditionally — two claims about post-state that nothing had checked.
|
|
563
|
-
// It still never claims a re-sync RAN (that is already-current's line). The FAILED line (a
|
|
564
|
-
// version-behind upgrade blocked by the same read-only dir) stays loud, but its recovery points at a
|
|
565
|
-
// writable rerun — the in-session `setup` would hit the same read-only dir.
|
|
566
559
|
const readonlyRefreshFailedLine = (name, message) =>
|
|
567
560
|
` ${name}: could not refresh — ${stripPrefix(message)}; the skills directory is read-only this session — ${READONLY_RERUN_HINT}`;
|
|
568
561
|
|
|
@@ -573,7 +566,7 @@ export const REFRESH_LINES = Object.freeze({
|
|
|
573
566
|
unsupported: (name, reason) => ` ${name}: skipped — ${reason}`,
|
|
574
567
|
'kept-newer': (name, reason) => ` ${name}: skipped — ${reason}`,
|
|
575
568
|
'not-placed': (name) => ` ${name}: ${NOT_PLACED_LINE}`,
|
|
576
|
-
failed: (name, reason) => ` ${name}: could not refresh — ${reason};
|
|
569
|
+
failed: (name, reason, remedy = 'recover with /agent-workflow-kit setup') => ` ${name}: could not refresh — ${reason}; ${remedy}`,
|
|
577
570
|
'failed-readonly': readonlyRefreshFailedLine,
|
|
578
571
|
[SKIPPED_READONLY]: readonlySkipLine,
|
|
579
572
|
'already-current': (name, label, summary) => {
|
|
@@ -583,19 +576,14 @@ export const REFRESH_LINES = Object.freeze({
|
|
|
583
576
|
refreshed: (name, label) => ` ${name}: refreshed${label}`,
|
|
584
577
|
});
|
|
585
578
|
|
|
586
|
-
// The post-failure parity verdict behind that line (D3): a read-only re-scan of the bundle-owned
|
|
587
|
-
// files AND the wrapper links, run AFTER the write refusal, so every clause binds to state proven
|
|
588
|
-
// THIS run. The degrade returns before linkWrappers, so the wrapper axis is genuinely unreconciled —
|
|
589
|
-
// a calm claim that skipped it would be unproven. Any failure raised out of the walk itself (the
|
|
590
|
-
// bundle read is deliberately uncaught in there) collapses to could-not-verify: the calm claim is
|
|
591
|
-
// withheld, never inverted into a false clean, and a re-scan problem never turns the stated skip
|
|
592
|
-
// into a reported failure.
|
|
593
579
|
const readonlyParity = (plan, deps) => {
|
|
594
580
|
const fs = fsDeps(deps);
|
|
595
581
|
try {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const scan = scanBundleOwnedDrift(plan.place.bundleDir, plan.skillDir, fs
|
|
582
|
+
const { fragments, userFragments } = loadBridgeServices(deps);
|
|
583
|
+
const manifest = readBundledManifest(plan.place.bundleDir, deps);
|
|
584
|
+
const scan = scanBundleOwnedDrift(plan.place.bundleDir, plan.skillDir, fs, {
|
|
585
|
+
[SERVICE_FACTS_FILE]: placedServiceFacts(manifest.services ?? [], fragments, userFragments),
|
|
586
|
+
});
|
|
599
587
|
return parityVerdict({
|
|
600
588
|
scan,
|
|
601
589
|
wrappers: scanWrapperParity(plan.links, fs, { skillDir: plan.skillDir, modes: scan.modes }),
|
|
@@ -672,7 +660,8 @@ export const refreshPlacedBridges = (deps = {}, names = KNOWN_BACKENDS.map((b) =
|
|
|
672
660
|
if (isReadonlyWriteBoundary(err)) {
|
|
673
661
|
return { name: canonical, outcome: 'failed', line: REFRESH_LINES['failed-readonly'](canonical, err.message) };
|
|
674
662
|
}
|
|
675
|
-
return { name: canonical, outcome: 'failed', line: REFRESH_LINES.failed(canonical,
|
|
663
|
+
return { name: canonical, outcome: 'failed', line: REFRESH_LINES.failed(canonical,
|
|
664
|
+
err.userServicesMessage ?? stripPrefix(err.message), err.userServicesMessage ? userServicesRemedy('upgrade') : undefined) };
|
|
676
665
|
}
|
|
677
666
|
});
|
|
678
667
|
|
|
@@ -233,9 +233,9 @@ export { SHELL_METACHARACTERS };
|
|
|
233
233
|
|
|
234
234
|
// The RUNTIME residual documented above, as data: the exact write-redirection / command-
|
|
235
235
|
// substitution / bounded write-flag forms a settings-level allow rule cannot see. Consumed by
|
|
236
|
-
// the PreToolUse gate hook's residual guard —
|
|
237
|
-
//
|
|
238
|
-
//
|
|
236
|
+
// the PreToolUse gate hook's residual guard — scripts/sync-mirrors.mjs writes the generated region
|
|
237
|
+
// in the bundled hook (references/hooks/gate-approve.mjs; a placed file cannot import the kit),
|
|
238
|
+
// alongside UNIVERSAL_READONLY_ALLOWLIST.
|
|
239
239
|
export const RUNTIME_RESIDUAL_FORMS = Object.freeze({
|
|
240
240
|
writeRedirections: Object.freeze(['>', '>>', '1>', '2>', '&>', '>|']),
|
|
241
241
|
// `$(…)` + backtick + BOTH process substitutions `<(…)` / `>(…)` RUN a nested command. `>(…)` is
|
|
@@ -936,7 +936,7 @@ export const preflightVelocityProfile = ({ cwd }, deps = {}) => {
|
|
|
936
936
|
const derivedBridge = (() => {
|
|
937
937
|
try {
|
|
938
938
|
const probe = deps.findWrapper ?? ((cmd) => findOnPath(cmd).state === WRAPPER_PLACED);
|
|
939
|
-
return bundledSandboxRecipe(BRIDGE_REVIEW_WRAPPERS.filter(probe), deps).allow;
|
|
939
|
+
return bundledSandboxRecipe(BRIDGE_REVIEW_WRAPPERS.filter(probe), { ...deps, userServices: false }).allow;
|
|
940
940
|
} catch {
|
|
941
941
|
return [];
|
|
942
942
|
}
|