@mmerterden/multi-agent-pipeline 20.41.0 → 20.42.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 +44 -0
- package/README.md +1 -1
- package/README.tr.md +1 -1
- package/docs/ecosystem.md +45 -8
- package/docs/facts.json +7 -7
- package/docs/features.md +9 -4
- package/install/claude.mjs +34 -1
- package/install/templates/claude-hooks.json +12 -1
- package/manifest.json +106 -86
- package/package.json +3 -2
- package/pipeline/commands/multi-agent/autopilot/SKILL.md +11 -0
- package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
- package/pipeline/lib/args.mjs +131 -4
- package/pipeline/lib/bg-launch.mjs +5 -2
- package/pipeline/lib/credential-store.sh +11 -1
- package/pipeline/lib/hook-once.mjs +134 -0
- package/pipeline/lib/isotonic.mjs +73 -0
- package/pipeline/lib/low-disk.mjs +153 -0
- package/pipeline/lib/mcp-schema-load.mjs +90 -0
- package/pipeline/lib/md2confluence-v3.py +8 -7
- package/pipeline/lib/model-dispatch.sh +26 -2
- package/pipeline/lib/normalize-text.mjs +135 -0
- package/pipeline/lib/outbound-gate.mjs +21 -3
- package/pipeline/lib/plan-todos.sh +17 -4
- package/pipeline/lib/redact.mjs +12 -3
- package/pipeline/lib/risky-settings.mjs +198 -0
- package/pipeline/lib/route-state.sh +1 -0
- package/pipeline/lib/secret-patterns.generated.mjs +6 -2
- package/pipeline/lib/session-usage.mjs +232 -0
- package/pipeline/lib/source-digest.mjs +211 -0
- package/pipeline/lib/tdd-evidence.mjs +250 -17
- package/pipeline/lib/untrusted-fence.mjs +132 -1
- package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
- package/pipeline/multi-agent-refs/features/cost-analysis.md +37 -2
- package/pipeline/multi-agent-refs/features/doctor.md +51 -4
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -0
- package/pipeline/multi-agent-refs/features/plan-todos.md +4 -0
- package/pipeline/multi-agent-refs/features/unattended-gates.md +5 -3
- package/pipeline/multi-agent-refs/features/usage-reporting.md +4 -2
- package/pipeline/multi-agent-refs/help/en.md +1 -1
- package/pipeline/multi-agent-refs/help/tr.md +1 -1
- package/pipeline/multi-agent-refs/outside-the-pipeline.md +6 -0
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +1 -1
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -2
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +2 -0
- package/pipeline/multi-agent-refs/progress-contract.md +3 -1
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/doctor-report.schema.json +47 -0
- package/pipeline/schemas/plan-todos.schema.json +29 -1
- package/pipeline/schemas/prefs.schema.json +63 -0
- package/pipeline/schemas/route-config.schema.json +51 -0
- package/pipeline/schemas/secret-patterns.json +17 -1
- package/pipeline/schemas/toolkit-path-params.json +15 -1
- package/pipeline/scripts/_cost-advise.mjs +357 -0
- package/pipeline/scripts/_cost-budget.mjs +78 -0
- package/pipeline/scripts/_cost.mjs +29 -0
- package/pipeline/scripts/_decode_text.py +107 -0
- package/pipeline/scripts/_guard-probe.mjs +406 -0
- package/pipeline/scripts/_guard_rules.py +206 -0
- package/pipeline/scripts/_memory-policy.mjs +1 -25
- package/pipeline/scripts/_retrieval.mjs +148 -2
- package/pipeline/scripts/_secret-scan.mjs +6 -1
- package/pipeline/scripts/_stack-routing.mjs +1 -0
- package/pipeline/scripts/_test-gaming.mjs +346 -0
- package/pipeline/scripts/agent-guard.py +8 -1
- package/pipeline/scripts/argv-secret-scan.mjs +2 -1
- package/pipeline/scripts/autopilot-loop.mjs +407 -0
- package/pipeline/scripts/autopilot-runner.mjs +38 -25
- package/pipeline/scripts/capture-resume.sh +9 -1
- package/pipeline/scripts/cost-analyze.mjs +66 -4
- package/pipeline/scripts/cost-budget-check.mjs +5 -13
- package/pipeline/scripts/disk-cleaner.mjs +1418 -0
- package/pipeline/scripts/doctor.mjs +169 -44
- package/pipeline/scripts/evidence-gate.mjs +90 -0
- package/pipeline/scripts/gate-ledger.mjs +76 -21
- package/pipeline/scripts/gc-tmp.sh +5 -0
- package/pipeline/scripts/guard-probe-known-holes.json +3 -0
- package/pipeline/scripts/learnings-ledger.mjs +16 -12
- package/pipeline/scripts/note-agent-event.mjs +2 -0
- package/pipeline/scripts/note-mcp-failure.mjs +9 -2
- package/pipeline/scripts/note-skill-use.mjs +4 -1
- package/pipeline/scripts/pre-commit-check.sh +2 -2
- package/pipeline/scripts/pre-push-check.sh +8 -1
- package/pipeline/scripts/publish-staged.mjs +324 -0
- package/pipeline/scripts/route-learn.mjs +628 -0
- package/pipeline/scripts/run-scope-guard.mjs +55 -1
- package/pipeline/scripts/scan-agent-config.sh +1 -1
- package/pipeline/scripts/statusline.mjs +309 -0
- package/pipeline/scripts/test-integrity-gate.mjs +97 -2
- package/pipeline/scripts/triage-memory.mjs +12 -4
- package/pipeline/scripts/uninstall.mjs +1 -0
- package/pipeline/skills/.skill-manifest.json +8 -4
- package/pipeline/skills/.skills-index.json +14 -3
- package/pipeline/skills/shared/README.md +5 -4
- package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
- package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +105 -0
- package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +62 -0
- package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +1418 -0
- package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
- package/pipeline/skills/skill-copies.json +4 -0
- package/pipeline/skills/skills-index.md +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,50 @@ Internal file-layout changes that don't affect the slash-command surface are sti
|
|
|
16
16
|
|
|
17
17
|
## [Unreleased]
|
|
18
18
|
|
|
19
|
+
## [20.42.0] - 2026-11-04
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Build and test evidence is tied to a digest of the working tree (`lib/source-digest.mjs`). The gate ledger records it, an edit after the build makes the entry `stale` at commit, and `evidence-gate --ran-on` refuses a run whose source changed under it.
|
|
24
|
+
- `evidence-gate --command` / `--command-file` refuses a narrowed test run (`-only-testing`, `--filter`, `--tests`, `-t`, `-k`, `--grep`, `-run`, a single test file, `--passWithNoTests`) across fourteen runners and package scripts. `test-integrity-gate --test-command-file` reports one as blocking.
|
|
25
|
+
- `tdd-red` keeps the test files changed since the run's base commit, committed or not. `tdd-green` refuses a weakened or deleted one unless `--test-edit-reason` is given (blocking regardless when unattended), `plan-todos.sh tdd-restore` puts them back without creating anything outside the work tree, and `test-integrity-gate --state` reports the edits. An unreadable `--state` or `--test-command-file` is a blocking finding.
|
|
26
|
+
- `eval-guard-robustness` probes every PreToolUse hook in the install template, and the library matchers, with ReDoS, 1 MB and 5000-deep inputs under a timeout, against a dated known-holes list. `npm test` runs `--fast`; `npm run eval:guards` runs the whole probe.
|
|
27
|
+
- The guard asks before a recursive delete of `/`, the home directory (`$HOME`, `${HOME:?}` and the other parameter forms, `~`, `~user`) or a directory above it, and before a fork bomb, and refuses these unattended.
|
|
28
|
+
- The outbound gate, the command-line credential scan and the memory secret scan also match credentials hidden in base64, hex or rot13, with a Python twin used by the guard.
|
|
29
|
+
- Fenced untrusted text that reads like instructions is marked `suspicious` with the toolkit's classes: instruction-override, role-tag, tool-invocation, exfiltration and fence-escape.
|
|
30
|
+
- The installer reports risky `settings.json` combinations before it merges hooks, and setup asks about each HIGH finding.
|
|
31
|
+
- `run-scope-guard` on `Agent|Task` asks before a subagent starts on a run over its cost budget, and refuses with `onExceed: halt`.
|
|
32
|
+
- `lib/hook-once.mjs` makes the note-skill-use, note-mcp-failure and note-agent-event hooks write once per tool event.
|
|
33
|
+
- `cost-analyze advise` reports cache-read ratio, 1-hour cache TTL payback, sub-agent rung downshift with the pinned personas, context bloat and unpriced models, each finding with its numbers, its source and a what-if saving or null.
|
|
34
|
+
- `session-usage.mjs --host codex` reads the Codex CLI token ledger (running-total deltas, resets, forked replays); an unknown format reports UNMEASURED.
|
|
35
|
+
- Memory recall re-picks its head with MMR and ranks each clause of a multi-part task as its own query (`memoryRecall.mmrLambda`, `memoryRecall.multiQuery`); eval-recall gains two diversity cases.
|
|
36
|
+
- `doctor --json` carries `schemaVersion: 1` and `selection` under `schemas/doctor-report.schema.json`, with a golden test; `--only <id,...>`; the new check `mcp-schema-load` reports the toolkit's tool-list load per family as an estimate (`mcpSurface.schemaInfoAboveTokens`).
|
|
37
|
+
- An unknown flag or subcommand names the nearest one, in the output language.
|
|
38
|
+
- Opt-in `statusline.mjs` shows the run a session drives. Its cache lives in a private per-user directory, install never replaces an existing `statusLine`, and a symlinked settings file is written through with its mode kept.
|
|
39
|
+
- `publish-staged.mjs` publishes under a candidate dist-tag, matches the integrity, runs an install test, then promotes to latest; `--tag latest` is refused. It is the documented release step.
|
|
40
|
+
- Learned model-rung order (`modelRouting.learned`, off by default): `route-learn.mjs` learns from gate and review outcomes, promotes a policy only after a holdout Brier comparison with isotonic calibration, and chooses with seeded Thompson sampling.
|
|
41
|
+
- `/multi-agent:autopilot --loop N` (`autopilot-loop.mjs`): a bounded loop in which every iteration is a fully gated unattended run, launched with the autopilot runner's own argv, environment, unattended settings profile and preconditions, so the loop refuses to start where the runner would. Completion is checked and marked by the loop itself, and iterations, time and cost are hard caps.
|
|
42
|
+
- `disk-cleaner.mjs` frees disk space on a macOS developer machine by deleting regenerable data from a fixed allowlist of 24 categories: Xcode DerivedData, SwiftPM `.build` and DerivedData folders inside dev roots that look like build output and sat untouched for 12 hours, stale XCTest device clones, SwiftUI preview, Interface Builder and documentation caches, archives past an age, DeviceSupport for OS versions no paired device runs, unavailable simulators, simulator, SwiftPM, CocoaPods, Gradle, npm, yarn and pnpm caches, Homebrew, `dd-*` build folders in /tmp and $TMPDIR, pipeline scratch through `gc-tmp.sh`, scratchpads of ended Claude Code sessions, merged and clean agent worktrees under `.claude/worktrees`, developer-tool folders in ~/Library/Caches, old simulator logs and crash reports, finished pipeline task logs through `prune-logs.sh`, `.DS_Store` in dev roots, and orphaned children of ended sessions. The default run measures and deletes nothing; `--apply` deletes, every category can be skipped, and every path is checked again right before it goes: no symlink is followed, the real path must sit inside the category's roots, the user's folders, iCloud, keychains, credential folders and memory folders are refused, and nothing an open file or running command points into is touched. Transcripts and the Trash are opt-in; processes are stopped only with `--apply --processes`; unattended runs keep to a safe subset. It prints free space before and after and writes a JSON report.
|
|
43
|
+
- New `disk-cleaner` skill in ai-common-toolkit, which ships the script.
|
|
44
|
+
- Low-disk suggestion: `lib/low-disk.mjs` checks free space with one statfs call against `diskCleaner.lowDiskGb` (default 10) and `diskCleaner.lowDiskPercent` (default 5), and prints one line naming the disk-cleaner skill from doctor's `disk-space` check, the SessionStart banner, and the pre-push gate when a failed step said ENOSPC. `diskCleaner.suggest: false` silences it. Nothing is deleted from any of these places.
|
|
45
|
+
- `note-mcp-failure.mjs` classifies `ENOSPC` and no-space errors as `disk-full`, and doctor's `mcp-failures` check names the disk-cleaner skill after one such failure.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- `credential-store.sh set <key>` without a value reads the secret from stdin, or asks for it with hidden input on a terminal, and refuses an empty secret with usage.
|
|
50
|
+
- `usage-reporting.md`, the hooks template and the classifier's header give the MCP failure classes in the order the code reads them: the interrupt flag, a user or permission refusal, then a JSON-RPC code.
|
|
51
|
+
- `md2confluence-v3.py --image-width` help says images in a table cell stay at 240 px, and decision 18 in `locked.md` names that width for the frame gallery.
|
|
52
|
+
- `outside-the-pipeline.md` lists `media_video_plan` and `media_video_render`.
|
|
53
|
+
- Phase 2 stops retrying a build that failed for lack of disk space and prints the low-disk line instead.
|
|
54
|
+
- The `backlog` and `localization-reuse-map` skill descriptions are shorter, to stay under the description ceiling.
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- The URL-credential secret pattern, the command-line DSN pattern and the outbound email rule scan a long URL-shaped line in linear time, and a URL password of any length is still caught.
|
|
59
|
+
- `redact` skips the fold for printable ASCII text.
|
|
60
|
+
- `phase-1-plan.md` counts the 37 locked analysis decisions.
|
|
61
|
+
- progress-contract.md names the cost check's real default rate.
|
|
62
|
+
|
|
19
63
|
## [20.41.0] - 2026-11-03
|
|
20
64
|
|
|
21
65
|
### Added
|
package/README.md
CHANGED
|
@@ -538,7 +538,7 @@ Installing the pipeline is not only useful when you run it. Open an ordinary ses
|
|
|
538
538
|
|
|
539
539
|
- **Services you already onboarded.** The token `setup` mapped is readable now - resolve the logical name through `credential-store.sh` and fetch the issue, the page, the log. **Reads are ordinary work; writes are not.** Posting a Jira comment, editing an issue or opening a PR goes through the pipeline commands, because the rules that make those safe (never auto-close, `Ref:` not `Closes:`, humanizer on outward prose) live there.
|
|
540
540
|
- **The stack skills `/multi-agent:stack` enabled for the repo.** Each toolkit's own `index` skill routes; the pipeline keeps no copy of that table.
|
|
541
|
-
- **The `multi-agent-toolkit` MCP.** <!-- fact:toolCount -->
|
|
541
|
+
- **The `multi-agent-toolkit` MCP.** <!-- fact:toolCount -->230<!-- /fact --> tools, most of them for a running app - screen state, crash logs, design comparison, store pre-submission, web scraping and browser test states. Several measure instead of judging by eye: WCAG contrast (`design_contrast_check`), layout shift across themes or a mirrored locale (`ios_visual_diff` with `mode: "layout"`), store listing limits (`store_listing_lint`), review themes with verbatim quotes (`store_review_themes`) and whether security findings cite real lines (`security_evidence_check`, with `security_sarif_export` for code-scanning views). The learnings ledger and the code graph are readable through it too (`learnings_*`, `graph_*`).
|
|
542
542
|
|
|
543
543
|
Uninstall preserves this layer: the tokens, the reader that opens them, the mapping that names them, and the MCP registration. Removing the pipeline should not cost you the credentials you onboarded through it.
|
|
544
544
|
|
package/README.tr.md
CHANGED
|
@@ -537,7 +537,7 @@ Pipeline'ı kurmak yalnız onu çalıştırdığında işe yaramıyor. Sıradan
|
|
|
537
537
|
|
|
538
538
|
- **Zaten onboard ettiğin servisler.** `setup`'ın eşlediği token okunabilir durumda - mantıksal adı `credential-store.sh` ile çöz, issue'yu, sayfayı, logu getir. **Okuma sıradan iş, yazma değil.** Jira yorumu, issue düzenleme ve PR açma pipeline komutlarından geçer, çünkü onları güvenli kılan kurallar (issue asla otomatik kapanmaz, `Closes:` değil `Ref:`, dışa dönük metinde humanizer) orada yaşıyor.
|
|
539
539
|
- **`/multi-agent:stack`'in bu repo için açtığı stack skilleri.** Yönlendirmeyi her toolkit'in kendi `index` skill'i yapar; pipeline o tablonun kopyasını tutmaz.
|
|
540
|
-
- **`multi-agent-toolkit` MCP.** <!-- fact:toolCount -->
|
|
540
|
+
- **`multi-agent-toolkit` MCP.** <!-- fact:toolCount -->230<!-- /fact --> araç, çoğu çalışan uygulama için - ekran durumu, crash logu, tasarım karşılaştırma, store ön-kontrolü, web kazıma ve tarayıcı test durumları. Bazı kontrolleri gözle değil ölçümle yapar. WCAG kontrastı `design_contrast_check` ile, tema ya da RTL değişince kayan yerleşim `ios_visual_diff` (`mode: "layout"`) ile ölçülür. Mağaza metni sınırlarını `store_listing_lint` denetler. `store_review_themes` yorumları temalara ayırır ve alıntıyı birebir bırakır. Güvenlik bulgularının gerçek satırlara dayandığını `security_evidence_check` doğrular; `security_sarif_export` kod tarama ekranları için SARIF yazar. Öğrenim kaydı (`learnings_*`) ve kod grafiği (`graph_*`) de buradan okunur.
|
|
541
541
|
|
|
542
542
|
Uninstall bu katmanı korur: token'lar, onları açan okuyucu, adlarını tutan eşleme ve MCP kaydı. Pipeline'ı kaldırmak, onun üzerinden onboard ettiğin credential'ları kaybetmek anlamına gelmemeli.
|
|
543
543
|
|
package/docs/ecosystem.md
CHANGED
|
@@ -7,7 +7,7 @@ separately, wired together at install time and at run time:
|
|
|
7
7
|
|---|---|---|
|
|
8
8
|
| **`multi-agent-pipeline`** (this repo) | Orchestration: the <!-- fact:phaseCount -->6<!-- /fact -->-phase flow, the <!-- fact:commandCount -->71<!-- /fact --> slash commands, quality gates, review/triage, cross-CLI parity | npm package (`@mmerterden/multi-agent-pipeline`), installs itself onto Claude Code / Copilot CLI / Codex CLI |
|
|
9
9
|
| **`multi-agent-plugins`** | Stack knowledge: per-platform component/lifecycle skills (iOS, Android, Frontend, Backend) + shared knowledge | Claude Code marketplace, 6 independently-versioned plugins |
|
|
10
|
-
| **`multi-agent-toolkit-mcp`** | The pipeline's hands on devices and browsers: <!-- fact:toolCount -->
|
|
10
|
+
| **`multi-agent-toolkit-mcp`** | The pipeline's hands on devices and browsers: <!-- fact:toolCount -->230<!-- /fact --> MCP tools across <!-- fact:toolFamilyCount -->23<!-- /fact --> families (simulator/emulator control, end-to-end locators and assertions, memory, crash diagnostics, accessibility audit, store compliance and listing lint, web automation and scraping, Figma-vs-mock design audit with contrast checks, code intelligence, a code graph, a learnings ledger, wallet passes, an agent-DSL batch runner, a full-text context index with text-to-image rendering, provider-backed and community research, opt-in social reading, verified hand-off of simple text tasks to free models, video key frames and transcripts, offline security scoring with evidence checks, SARIF export and MCP config launch-selector audits, read-only access to related repositories at their latest branch, travel document fixtures, a voice channel, App Store Connect and Play Console APIs, virtual iPhones) | npm package, registered as a standard stdio MCP server on every host |
|
|
11
11
|
|
|
12
12
|
None of the three depends on the others at the code level. They compose through two
|
|
13
13
|
narrow contracts: the **Skill tool** (pipeline → plugin, at Phase 2) and the **MCP
|
|
@@ -95,7 +95,7 @@ graph TD
|
|
|
95
95
|
from the Claude Code source - sync writes their content. `multi-agent-toolkit-mcp` is not:
|
|
96
96
|
it's a separate codebase developed on its own schedule. Sync's Step 3d only
|
|
97
97
|
*detects* whether it moved (dirty tree, unpushed commits, untagged version), runs
|
|
98
|
-
**its own** gate suite, and ships it - commit, tag,
|
|
98
|
+
**its own** gate suite, and ships it - commit, tag, staged publish (section 6). If the pipeline
|
|
99
99
|
needs a tool that toolkit doesn't have yet, that's a two-repo change: add the tool
|
|
100
100
|
in `multi-agent-toolkit-mcp`, ship it, then bump the minimum version pin back in
|
|
101
101
|
`cross-cli-contract.md` (see section 4).
|
|
@@ -113,7 +113,7 @@ hand-authored *inside* `multi-agent-plugins` and are never touched by sync.
|
|
|
113
113
|
<!-- facts: skillCount="skills - single authoring source" -->
|
|
114
114
|
```mermaid
|
|
115
115
|
graph TD
|
|
116
|
-
EXT["pipeline/skills/shared/external/<br/>
|
|
116
|
+
EXT["pipeline/skills/shared/external/<br/>168 skills - single authoring source<br/>(the pipeline's own phases read these too)"]
|
|
117
117
|
|
|
118
118
|
EXT -->|"cross-stack skills"| COMMONP["ai-common-toolkit"]
|
|
119
119
|
EXT -->|"outside facts for analysis"| ANAP["ai-analyst-toolkit"]
|
|
@@ -136,7 +136,7 @@ graph TD
|
|
|
136
136
|
style EXT fill:#ffd,stroke:#333
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
Together the plugins carry more skills than the <!-- fact:skillCount -->
|
|
139
|
+
Together the plugins carry more skills than the <!-- fact:skillCount -->168<!-- /fact -->-skill source because each
|
|
140
140
|
plugin also carries its own authored `reference/`, `workflow/` and `tools/`
|
|
141
141
|
skills and an `index` router. A vendored knowledge skill ships in exactly one
|
|
142
142
|
plugin: cross-stack skills go to `ai-common-toolkit` rather than into every
|
|
@@ -239,8 +239,8 @@ Detail: [`unattended-security.md`](../pipeline/multi-agent-refs/features/unatten
|
|
|
239
239
|
|
|
240
240
|
### multi-agent-toolkit-mcp's tools, by category
|
|
241
241
|
|
|
242
|
-
<!-- fact:toolCount -->
|
|
243
|
-
at toolkit <!-- fact:toolkitVersion -->3.
|
|
242
|
+
<!-- fact:toolCount -->230<!-- /fact --> tools in <!-- fact:toolFamilyCount -->23<!-- /fact --> families, counted from the server's own `tools/list` response
|
|
243
|
+
at toolkit <!-- fact:toolkitVersion -->3.32.0<!-- /fact --> rather than from a README. Three families are defined in
|
|
244
244
|
modules the main file only spreads in, so a count taken from the source reads
|
|
245
245
|
low; the response is the only place the whole surface appears at once. A
|
|
246
246
|
family is the prefix every tool name carries.
|
|
@@ -253,8 +253,8 @@ skill body and leaves frontmatter `allowed-tools` alone. Both qualified forms
|
|
|
253
253
|
let `lint-mcp-refs.mjs` check that the tool exists.
|
|
254
254
|
|
|
255
255
|
The families can be narrowed per host: `MCP_TOOLKIT_CAPS` serves only the named
|
|
256
|
-
ones, and unset serves all <!-- fact:toolCount -->
|
|
257
|
-
sees 50 tools instead of <!-- fact:toolCount -->
|
|
256
|
+
ones, and unset serves all <!-- fact:toolCount -->230<!-- /fact -->. A frontend repo that sets `web,code,context`
|
|
257
|
+
sees 50 tools instead of <!-- fact:toolCount -->230<!-- /fact -->, which matters because every registered server's
|
|
258
258
|
tool list is charged against the context window on every turn.
|
|
259
259
|
|
|
260
260
|
| Family | Tools | Primary pipeline consumers |
|
|
@@ -304,3 +304,40 @@ tool list is charged against the context window on every turn.
|
|
|
304
304
|
present *for specific task types* (component work, UI testing) but functions
|
|
305
305
|
without either - a non-component bugfix task never touches the plugin marketplace,
|
|
306
306
|
and a task with no UI-testing step never opens the MCP connection.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 6. Release step: staged npm publish
|
|
311
|
+
|
|
312
|
+
Both npm packages, the pipeline and `multi-agent-toolkit-mcp`, are published
|
|
313
|
+
with `pipeline/scripts/publish-staged.mjs` from a clean checkout of the
|
|
314
|
+
release tag, never with a bare `npm publish`. `latest` then only ever names a
|
|
315
|
+
version the registry was seen to serve and that installed:
|
|
316
|
+
|
|
317
|
+
1. `npm pack`, and the tarball's sha512 computed locally; npm's reported
|
|
318
|
+
integrity must agree.
|
|
319
|
+
2. `npm publish <tarball> --tag candidate`. A version the registry already
|
|
320
|
+
holds with the same bytes is a resumed release and is not published again;
|
|
321
|
+
with other bytes it is refused.
|
|
322
|
+
3. Poll the packument over HTTP (not `npm view`, whose cache answers before
|
|
323
|
+
the registry does) until the version carries the local integrity and the
|
|
324
|
+
`candidate` tag names it. A different integrity fails at once.
|
|
325
|
+
4. Download the tarball the registry serves and compare its sha512.
|
|
326
|
+
5. Install that tarball into an empty temp project with scripts off, and check
|
|
327
|
+
the installed version and its bins.
|
|
328
|
+
6. Run `--smoke "<cmd>"` in that project, when given.
|
|
329
|
+
7. `npm dist-tag add <name>@<version> latest`, then poll until `latest` names it.
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
node pipeline/scripts/publish-staged.mjs --dir . --userconfig "$TMP_NPMRC" \
|
|
333
|
+
--smoke "node node_modules/@mmerterden/multi-agent-pipeline/index.js --version"
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
`--userconfig` points every npm call at a temporary npmrc built from the
|
|
337
|
+
credential store, so the token never reaches argv. Exit 0 means promoted; 1
|
|
338
|
+
means nothing was published; 3 means the version is on `candidate` and
|
|
339
|
+
`latest` did not move, and running the same command again resumes from the
|
|
340
|
+
registry check. `--dry-run` stops after the pack. `test/publish-staged.test.mjs`
|
|
341
|
+
drives the whole flow against a fake npm and a fake registry, including a
|
|
342
|
+
corrupted upload, a slow registry, a failed install, a failed smoke and a
|
|
343
|
+
resumed release.
|
package/docs/facts.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Generated by pipeline/scripts/gen-facts.mjs. Do not hand-edit: the site reads this, and a number edited here instead of at its source is the drift this file removes.",
|
|
3
3
|
"generatedAt": "2026-11-03",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.42.0",
|
|
5
5
|
"phaseSchema": 2,
|
|
6
6
|
"phases": [
|
|
7
7
|
{
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"analysis": [0, 1, 2, 3, 4, 5]
|
|
37
37
|
},
|
|
38
38
|
"commandCount": 71,
|
|
39
|
-
"skillCount":
|
|
40
|
-
"skillCountAll":
|
|
39
|
+
"skillCount": 168,
|
|
40
|
+
"skillCountAll": 242,
|
|
41
41
|
"agentCount": 11,
|
|
42
42
|
"hosts": ["Claude Code", "Codex CLI", "Copilot CLI"],
|
|
43
|
-
"toolCount":
|
|
43
|
+
"toolCount": 230,
|
|
44
44
|
"toolCategories": {
|
|
45
45
|
"ios": 42,
|
|
46
46
|
"web": 38,
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"security": 5,
|
|
56
56
|
"ui": 5,
|
|
57
57
|
"context": 4,
|
|
58
|
+
"media": 4,
|
|
58
59
|
"pass": 4,
|
|
59
60
|
"document": 3,
|
|
60
61
|
"learnings": 3,
|
|
61
62
|
"research": 3,
|
|
62
63
|
"agent": 2,
|
|
63
64
|
"llm": 2,
|
|
64
|
-
"media": 2,
|
|
65
65
|
"coverage": 1,
|
|
66
66
|
"social": 1,
|
|
67
67
|
"test": 1
|
|
68
68
|
},
|
|
69
|
-
"pluginSkillCount":
|
|
70
|
-
"toolkitVersion": "3.
|
|
69
|
+
"pluginSkillCount": 264,
|
|
70
|
+
"toolkitVersion": "3.32.0"
|
|
71
71
|
}
|
package/docs/features.md
CHANGED
|
@@ -54,7 +54,7 @@ The install is not only useful while `/multi-agent` is running. `rules/outside-t
|
|
|
54
54
|
|
|
55
55
|
- **Onboarded service credentials.** Resolve the logical name through `credential-store.sh` and read the issue, page or log. Writes route through the pipeline commands, which carry the rules that make them safe - issues are never auto-closed, PR bodies use `Ref:`, outward prose goes through the humanizer.
|
|
56
56
|
- **The stack skills enabled for this repo.** Each toolkit's own `index` skill routes. The pipeline reads the effective `enabledPlugins` rather than keeping a stack table, so a seventh toolkit needs no code change.
|
|
57
|
-
- **The `multi-agent-toolkit` MCP.** <!-- fact:toolCount -->
|
|
57
|
+
- **The `multi-agent-toolkit` MCP.** <!-- fact:toolCount -->230<!-- /fact --> tools, most of them for a running app.
|
|
58
58
|
|
|
59
59
|
Uninstall preserves the whole layer - tokens, the reader that opens them, the mapping that names them, the MCP registration. It is 1.5 kB of always-loaded text; the detail lives in a ref that loads on demand, and a gate keeps both under a ceiling because every byte there is paid by every session.
|
|
60
60
|
|
|
@@ -256,7 +256,7 @@ A triage verdict is a judgment call; a failing repro test is proof. When `prefs.
|
|
|
256
256
|
|
|
257
257
|
### Immutable-Test Rule + `test_lines_removed` Signal
|
|
258
258
|
|
|
259
|
-
Existing tests are immutable during a task: deleting, renaming, or weakening an assertion to reach green is a violation (`refs/rules.md`, Phase 2 GREEN step). A test changes only when the task changes the spec it encodes, named in the commit body. Deterministic backstop: `diff-risk-score.mjs` emits `test_lines_removed` (w=3.0) for any test-classified file whose diff removes more lines than it adds.
|
|
259
|
+
Existing tests are immutable during a task: deleting, renaming, or weakening an assertion to reach green is a violation (`refs/rules.md`, Phase 2 GREEN step). A test changes only when the task changes the spec it encodes, named in the commit body. Deterministic backstop: `diff-risk-score.mjs` emits `test_lines_removed` (w=3.0) for any test-classified file whose diff removes more lines than it adds. In Phase 2 the tests a todo wrote in RED are kept (`tdd-red` stores their bytes): `tdd-green` refuses a run in which one was weakened or deleted unless `--test-edit-reason` says why, `tdd-restore` puts them back, and `test-integrity-gate.mjs --state` reports a recorded edit as important and an unrecorded one as blocking.
|
|
260
260
|
|
|
261
261
|
### Update Check at Run Start
|
|
262
262
|
|
|
@@ -314,9 +314,13 @@ Detail: [`autopilot-operations.md`](../pipeline/multi-agent-refs/features/autopi
|
|
|
314
314
|
### Security Base
|
|
315
315
|
|
|
316
316
|
- **Fail-closed guard.** `agent-guard.sh` is the PreToolUse hook on `Bash`, `Edit|Write|NotebookEdit` and `WebFetch|mcp__multi-agent-toolkit__.*`. Under the variable a Bash command is judged only when it reduces to simple commands joined by `;`, `&&`, `||` and plain pipes between non-interpreter commands; a subshell, group, nested substitution, unquoted heredoc, background job, shell keyword, interpreter reading stdin, shell `-c`, inline interpreter program (`node -e`, `perl -e`, `php -r`, ...), program file the run wrote or modified, or runtime-built command name is refused unparsed. On what it parses: no push, PR, issue or tracker write, no Keychain read, no package install or manifest edit, no write into a protected path. The guard arms its own 5-second deadline and answers "block" on expiry when unattended.
|
|
317
|
+
- **Destructive floor, every mode.** A recursive `rm` of the filesystem root, of `$HOME` or of a directory above it (`~`, `$HOME`, `${HOME}/*`, `../..` resolved against the working directory, `--no-preserve-root`), and a fork bomb (`:(){ :|:& };:` under any name, perl's `fork while fork`) ask the user in an attended session and are refused unattended. A delete inside home or the project, a quoted mention and an ordinary shell function do not ask.
|
|
318
|
+
- **Encoded secrets.** The outbound gate, the command-line credential scan and the memory secret scan also match the certain credential shapes on a bounded decode of the text: base64 (standard and URL-safe), hex and rot13, two layers deep, a decoded run kept only when nine tenths of it is printable, at most 32 copies and 256 KB decoded per scan. A finding names the decode path (`encoding: "base64>hex"`). The guard reads a stored-secret read hidden the same way. Hashes, paths, images and encoded configuration are held to no finding by a negative set.
|
|
319
|
+
- **Guard probe.** `eval-guard-robustness.mjs` throws ReDoS-shaped input, a 1 MB string and 5000-deep nesting at every PreToolUse hook in the install template and at the library matchers, each in its own process group with a timeout. A probe fails on a timeout, an exit outside 0 and 2, a throw, or a median over the hook's own timeout (1 s for a library call); a dated known-holes list holds an accepted failure until its expiry. `npm test` runs the `--fast` subset; `npm run eval:guards` runs the whole probe.
|
|
317
320
|
- **Network allowlist.** `curl`, `wget`, `WebFetch` and the toolkit's `web_*` tools reach only hosts in the allowlist (`network.staticHosts` plus the configured service hosts); a URL built at run time, a proxy flag or a request body is refused, and `web_eval` is refused outright. The runner starts the toolkit with `MCP_TOOLKIT_URL_POLICY=strict` and `MCP_TOOLKIT_INDEX_DENY`.
|
|
318
321
|
- **No package installs.** A restore from the committed lockfile is allowed; adding a package is not.
|
|
319
|
-
- **Untrusted data.** Fetched bodies, ticket text, comments and PR text enter prompts inside `<untrusted-data>` delimiters that defuse a forged closing tag.
|
|
322
|
+
- **Untrusted data.** Fetched bodies, ticket text, comments and PR text enter prompts inside `<untrusted-data>` delimiters that defuse a forged closing tag. Text that reads like instructions to the model gets `suspicious="instruction-override,tool-invocation,..."` on its block, naming in a fixed order the classes the toolkit uses for the same mark: instruction-override (override phrases, new-directive headers, role reassignment, prompt probes, requests to keep something from the user), role-tag (chat template tokens and forged conversation turns), tool-invocation, exfiltration and fence-escape. The patterns are matched on the text and on a folded copy, over the head and tail of a long text; hidden or look-alike characters hide text rather than instruct, so they are not marked. The mark is a signal and never blocks; the toolkit vendors the same file, and a block it already labels with `injection-flags` gets no second mark.
|
|
323
|
+
- **Risky settings at install.** Before the installer merges its hooks it reads `~/.claude/settings.json` for what lets anything run unasked: `bypassPermissions` with a blanket Bash allow or every project MCP server enabled (HIGH), a hook that pipes fetched or decoded code into a shell (HIGH), a literal credential (HIGH), and each risky setting alone or a floating MCP launch (MEDIUM). It prints the rule and the place, never a value, changes nothing, and leaves `multi-agent-risky-settings.json` for `/multi-agent:setup`, which asks about each HIGH finding.
|
|
320
324
|
- **Permission profile.** `install --unattended` writes a `dontAsk` profile with a narrow allow list and deny rules into `~/.claude/multi-agent-unattended.settings.json`, printed in full before anything is written; the runner passes it with `claude --settings`, so `~/.claude/settings.json` and attended sessions are unchanged. A default install writes no permissions.
|
|
321
325
|
- **Machine setup, applied by the operator.** A separate non-admin macOS user for the runner, per-repo GitHub credentials limited to contents and pull requests, a Jira token that can only read and comment, and GitHub rulesets on every default and release branch (no force-push, no deletion, PR and code-owner review required, the bot in no bypass list).
|
|
322
326
|
|
|
@@ -333,7 +337,7 @@ While the quality gates are active (`MULTI_AGENT_UNATTENDED=1`, or `state.autopi
|
|
|
333
337
|
| `verify-citations` | a triage citation quotes the line it cites (at least 8 non-space characters, or the whole line) |
|
|
334
338
|
| pre-existing claims | a "pre-existing" finding cites a line the diff from the base does not add or change |
|
|
335
339
|
| `plan-coverage` | every plan step is accounted for; a planned run with no todos is a gap |
|
|
336
|
-
| `evidence-gate`, `test-summary` | build and test claims read with the stack's own markers and a positive executed test count |
|
|
340
|
+
| `evidence-gate`, `test-summary` | build and test claims read with the stack's own markers and a positive executed test count; the run must cover the whole suite (a narrowed command such as `-only-testing`, `-k`, `-t` or one test file fails) and be on the source as it is now: the entry carries a digest of the working tree, so an edit after the build makes it stale at commit |
|
|
337
341
|
| `test-strength` | a new test goes red without the change it claims to cover |
|
|
338
342
|
| `review-decision` | a `blocking` finding carries two independent reviewers or a failing test |
|
|
339
343
|
| `spec-consistency`, `plan-critique` | recorded, not required at commit (see below) |
|
|
@@ -410,6 +414,7 @@ Per-phase token budgets prevent runaway sessions. If a phase exceeds its budget,
|
|
|
410
414
|
- **Cost Telemetry**: Per-phase token cost tracking (`tokens_in`, `tokens_out`, `model`, `duration_ms`). Omitted fields handled gracefully.
|
|
411
415
|
- **Phase Tracker**: Cross-CLI visual progress (current phase, elapsed time, iteration count).
|
|
412
416
|
- **Phase Banner**: Terminal UI for phase transitions with Unicode box-drawing characters.
|
|
417
|
+
- **Status Line (opt-in)**: `node ~/.claude/scripts/statusline.mjs install` adds a Claude Code `statusLine` showing the run this session drives: phase, cost against `costBudget`, gates passed and the first failing one, and whether it waits for an answer. Local files only, no network. Install never replaces a `statusLine` that is already set; `uninstall` removes only its own.
|
|
413
418
|
- **Per-task Cost Breakdown in agent-log.md**: Phase 5 appends a 4-column block (Phase · Model · Tokens in/out · Est. USD) to every run's `agent-log.md`. Sourced from `phase-tracker.sh tokens` accumulators × `cost-table.json` prices. Independent of the channels-side `reportContent.costSummary` toggle. The `LOG_METRIC_FORWARD_TO_TRACKER=1` env flag mirrors `tokens_in`/`tokens_out`/`model` from `log-metric.sh` into the tracker so JSONL metrics and the cost block stay in sync from one call site.
|
|
414
419
|
|
|
415
420
|
### Run Post-Mortem (`/multi-agent:postmortem`)
|
package/install/claude.mjs
CHANGED
|
@@ -44,6 +44,7 @@ import { registerMcpServer } from "./_mcp-register.mjs";
|
|
|
44
44
|
import { linkClaudeXcodePlugin } from "./_xcode-skills.mjs";
|
|
45
45
|
import { applyFableRung, fableEnabled } from "../pipeline/lib/agent-model-sync.mjs";
|
|
46
46
|
import { PREFS_FILE, prefsFileIn } from "../pipeline/lib/prefs-value.mjs";
|
|
47
|
+
import { RISKY_REPORT, riskyReport, scanRiskySettings } from "../pipeline/lib/risky-settings.mjs";
|
|
47
48
|
|
|
48
49
|
export const AGENT_GUARD_FILE_MATCHER = "Edit|Write|NotebookEdit";
|
|
49
50
|
// WebFetch and the toolkit's tools reach hosts with no Bash hook to see them:
|
|
@@ -755,7 +756,7 @@ export function quotePipelineHookCommands(hooks) {
|
|
|
755
756
|
* The run-scoped hooks the installer registers beside the two gates above:
|
|
756
757
|
* run-stop-guard.sh (Stop), task-mirror.sh (TaskCreate / TaskUpdate),
|
|
757
758
|
* answer-check.sh (AskUserQuestion, in every session: it only adds context),
|
|
758
|
-
* file-context.sh (after a Read, and before a Read, Grep or Glob), run-scope-guard.sh (Figma MCP tools, file edits, Figma over HTTP
|
|
759
|
+
* file-context.sh (after a Read, and before a Read, Grep or Glob), run-scope-guard.sh (Figma MCP tools, file edits, Figma over HTTP, direct run-state writes in Bash or WebFetch, and subagent spawns against the cost budget), note-skill-use.sh (after a Skill call, ok or failed) and note-mcp-failure.sh (after a failed MCP tool call). The run hooks are silent outside a pipeline run (file-context also runs everywhere when prefs.global.fileContext.enabled is true) and fail open, so
|
|
759
760
|
* registering them by default changes nothing until a run is active. note-skill-use.sh runs in every
|
|
760
761
|
* session, records only the skill name, outcome, time, host and repo folder name into the local
|
|
761
762
|
* skill-usage log, and is off with prefs.global.skillUsage.enabled false. note-mcp-failure.sh
|
|
@@ -812,6 +813,13 @@ export const RUN_HOOKS = [
|
|
|
812
813
|
timeout: 10,
|
|
813
814
|
statusMessage: "Checking the edit is inside the run's worktree...",
|
|
814
815
|
},
|
|
816
|
+
{
|
|
817
|
+
event: "PreToolUse",
|
|
818
|
+
matcher: "Agent|Task",
|
|
819
|
+
script: "run-scope-guard.sh",
|
|
820
|
+
timeout: 10,
|
|
821
|
+
statusMessage: "Checking the run's cost budget before a new subagent...",
|
|
822
|
+
},
|
|
815
823
|
{
|
|
816
824
|
event: "PreToolUse",
|
|
817
825
|
matcher: "Bash|WebFetch|AskUserQuestion",
|
|
@@ -899,6 +907,29 @@ export function ensureHook(hooks, r) {
|
|
|
899
907
|
return true;
|
|
900
908
|
}
|
|
901
909
|
|
|
910
|
+
/**
|
|
911
|
+
* The risky-settings gate, before the hooks are merged: findings are printed
|
|
912
|
+
* (rule and place, never a value) and left in RISKY_REPORT for
|
|
913
|
+
* /multi-agent:setup to ask about. Nothing in settings.json is changed here;
|
|
914
|
+
* a clean scan removes an old report.
|
|
915
|
+
*/
|
|
916
|
+
function reportRiskySettings(home, settings, settingsPath) {
|
|
917
|
+
const reportPath = join(home, ".claude", RISKY_REPORT);
|
|
918
|
+
const findings = scanRiskySettings(settings);
|
|
919
|
+
if (!findings.length) {
|
|
920
|
+
if (existsSync(reportPath) && !isDryRun()) unlinkSync(reportPath);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
const high = findings.filter((f) => f.level === "HIGH").length;
|
|
924
|
+
console.log(
|
|
925
|
+
` -> Risky settings in ${settingsPath}: ${high} high, ${findings.length - high} medium (left as they are; /multi-agent:setup asks about them)`,
|
|
926
|
+
);
|
|
927
|
+
for (const f of findings) console.log(` [${f.level}] ${f.rule} (${f.where}): ${f.message}`);
|
|
928
|
+
if (!isDryRun()) {
|
|
929
|
+
writeFile(reportPath, `${JSON.stringify(riskyReport(findings, settingsPath), null, 2)}\n`);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
902
933
|
export function configureSettings(home) {
|
|
903
934
|
console.log(" [Claude Code] Configuring hooks + context management...");
|
|
904
935
|
const SETTINGS_PATH = join(home, ".claude", "settings.json");
|
|
@@ -907,6 +938,8 @@ export function configureSettings(home) {
|
|
|
907
938
|
? JSON.parse(readFileSync(SETTINGS_PATH, "utf-8"))
|
|
908
939
|
: {};
|
|
909
940
|
|
|
941
|
+
reportRiskySettings(home, settings, SETTINGS_PATH);
|
|
942
|
+
|
|
910
943
|
let settingsChanged = false;
|
|
911
944
|
|
|
912
945
|
if (!settings.env) settings.env = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_readme": "Recommended Claude Code hooks for multi-agent-pipeline. `install` registers the pre-commit and agent-guard gates, the run-scoped run-stop-guard / run-scope-guard hooks, the task-mirror hook, the file-context hook, the skill-usage hook and the MCP failure hook itself (install/claude.mjs configureSettings, RUN_HOOKS); /multi-agent:setup offers to merge the rest of this block. Merge the `hooks` object into your ~/.claude/settings.json to make these deterministic PreToolUse gates real (exit 2 blocks the tool call). A PreToolUse matcher is a regex over the TOOL NAME, so each gate registers on a tool name and reads the command from its stdin payload. Three PreToolUse gates ship here: (1) pre-commit-check.sh on Bash, which acts only on a `git commit` and blocks a secret in the staged diff; (2) agent-guard.sh on Bash, on Edit|Write|NotebookEdit, and on WebFetch plus every multi-agent-toolkit tool (WebFetch|mcp__multi-agent-toolkit__.*). Always, it blocks AI/assistant attribution in a commit message and a force-push, delete or mirror push to a protected branch (main/master/develop), including one inside a subshell or a `bash -c` / `eval` line. With MULTI_AGENT_UNATTENDED=1 in the hook's environment it also applies the unattended policy: no push, PR or tracker write, no Keychain read, no fetch outside the host allowlist (curl, WebFetch, the toolkit's web tools, agent_run_steps and open_url), no package install, and no write into a protected path (features/unattended-security.md); (3) check-read-size.sh on Read|Bash, which inspects Read plus the shell commands that read a file whole (cat/head/tail/sed), returns immediately for everything else, and routes an oversized read to a cheap worker instead of the caller's own rung; it is inert until `prefs.global.bulkRead.mode` is set to observe or enforce. Failure behaviour: pre-commit-check.sh and check-read-size.sh fail open on an internal error. agent-guard.sh fails open when attended, so a guard bug cannot break a legitimate tool call, and fails closed under MULTI_AGENT_UNATTENDED=1, where nobody is there to notice a gap. None of the three executes the inspected command, and none needs run-specific arguments. The other deterministic gates (evidence, consensus, intent, learnings) take run-specific arguments and are phase-enforced by the pipeline instead. Three capture hooks ship alongside them and block nothing: (4) SessionEnd runs capture-flush.sh --if-stale, which writes a run's triage findings and durable learnings into the per-repo stores when the run ended before Phase 5, where those writes otherwise happen; the same hook runs note-session.sh, which records the mechanical shape of a session outside the pipeline (tools used, commands that failed, calls the user refused). (4b) SubagentStop and PostToolUseFailure run note-agent-event.sh, which appends one row to the same session notes as the event happens: a subagent's type, id, the bound run's task id and its last message cut to 200 characters (secret-scanned; a hit stores the row without the message), or a failed tool's name and its command's first program word, never an argument or error text. (5) PreCompact runs capture-flush.sh without --if-stale: a compaction summarizes the conversation mid-phase, so it is the moment unflushed findings are at risk, and both writes are idempotent, so a finished run costs two no-op writes. The staleness test exists only so a session exit does not re-flush a run that already finished. (6) SessionStart runs capture-resume.sh, which prints at most two lines: an unfinished run and how to resume it, and a stale pipeline-observation queue. No capture hook calls a model or reads a payload - note-session.sh keeps a command's first word and an exit code, never an argument or any output - and all exit 0 on every path, because a hook that fails a session over bookkeeping costs more than the bookkeeping. A run-scoped PreToolUse gate ships too: (2b) run-scope-guard.sh on every Figma MCP tool (mcp__.*[Ff]igma.*) denies a Figma call above phases.json thresholds.mcpAllowedThroughPhase for the run bound to the session, unless the run is in analysis mode, and records each allowed call into telemetry.mcpCalls[]; on Edit|Write|NotebookEdit the same script warns, attended only, when the target is outside the bound run's worktree (additionalContext for the model, systemMessage for the user; the call proceeds). On Bash|WebFetch|AskUserQuestion it denies a question from a bound autopilot run, a Figma read over HTTP (figma.com or api.figma.com) under the same phase rule, and, in any session, a direct write to agent-state.json or tracker-state.json (Edit/Write, a shell redirect or tee), since write-state.mjs is their only writer; the shell wrapper starts node only when the payload mentions Figma or a state file. Outside a run it is silent, and it fails open. One PostToolUse hook ships as well and blocks nothing: (7) edit-syntax-gate.sh on Edit|Write|MultiEdit parses the file the edit just wrote (swiftc -parse, node --check, py_compile into a temp dir, JSON.parse, bash -n; Kotlin skipped) under a 2 s deadline and, when it no longer parses, hands the model the error as PostToolUse additionalContext; it exits 0 on every path, stays silent when a parser is missing or slow, and is inert until `prefs.global.editSyntaxGate.enabled` is true. A second PostToolUse hook blocks nothing either: (7b) task-mirror.sh on TaskCreate|TaskUpdate mirrors the native task list into the tracker of the run bound to the session (phase-tracker.sh task, tracker-contract.md, \"Mirroring the host's task list\"), skipping phase tiles, so the office panel shows the same list; silent outside a run, exit 0 on every path. A third blocks nothing: (7c) file-context.sh on Read (PostToolUse, and PreToolUse on Read|Grep|Glob) hands the model, once per file per session, what the repo's memory says about the file it reads or searches (ledger facts whose scope covers it, its latest review findings, its open known limits from debt-ledger.mjs) as additionalContext inside an <untrusted-data> block, after the secret scan and fitted to the host's 10,000-character hook output limit; a Grep with a path, or a Glob whose literal directory is inside the repo, is mapped to at most five files the stores know, and a whole-repo search gets nothing; inside a run bound to the session by default, everywhere with prefs.global.fileContext.enabled true, never with it false; exit 0 on every path. A fourth blocks nothing: (7d) answer-check.sh on AskUserQuestion names, as PostToolUse additionalContext, every question the user submitted without a choice, so an empty answer is asked again instead of resolved to the Recommended option; it runs in every session, since it only adds context, and exits 0 on every path. A fifth blocks nothing: (7e) graph-hint.sh on Grep|Glob (PreToolUse) adds, once per session, one line pointing at `/multi-agent:graph ask` and mcp__multi-agent-toolkit__graph_query when the call searches the whole repo for a bare identifier and a current code graph (graphFreshness: build commit is HEAD, no indexed file changed) exists for the repo; silent with prefs.global.codeGraph.enabled false; exit 0 on every path. A sixth blocks nothing: (7f) note-skill-use.sh on Skill (PostToolUse and PostToolUseFailure) appends one row to the local <log root>/skill-usage.jsonl: the skill name (kept only when it matches a strict charset and length and carries no credential pattern, else the call is dropped), ok or error, the time, the host and the repo folder name (null outside a git repository and for a repository in prefs.global.memory.excludeProjects), never the arguments, the prompt or any output; past 1 MiB the log moves to skill-usage.jsonl.1; off with prefs.global.skillUsage.enabled false or prefs.global.usageLog.optOut true; it reads stdin for at most 1.5 s and exits 0 on every path. skill-usage.mjs summary and prune-candidates read it. A seventh blocks nothing: (7g) note-mcp-failure.sh on mcp__.* (PostToolUseFailure) appends one row to the local <log root>/mcp-failures.jsonl: the server and tool from the tool name (dropped unless both match a strict charset and length and carry no credential pattern), the time and a closed error class chosen from the error text (a JSON-RPC code first, then a message opening with invalid or validation, then an HTTP status, then fixed patterns), never the arguments, the output or the error text itself; it probes nothing, is written by the same code as the skill-usage log, so it has the same 1 MiB cap and .1 generation, rotates under its own mcp-failures.jsonl.lock, never follows a symlink at the log path, is off with prefs.global.mcpFailures.enabled false or prefs.global.usageLog.optOut true, and exits 0 on every path; doctor's mcp-failures check reads it. One Stop hook ships as well: (8) run-stop-guard.sh answers {\"decision\":\"block\"} when the session driving an active pipeline run (bound through agent-state.json sessionId or hostSessionId, never by a worktree match) tries to stop while the run is in_progress below its mode's last phase with no haltReason or waitingFor; the reason says to finish the current phase, record the wait, or record a halt. A turn that ends on a question to the user, a session with background tasks or crons, and prefs.global.stopGuard.enabled false are never held, and run-stop-guard.sh is not registered on SubagentStop: a subagent's stop is the dispatching session's business. After three consecutive blocks it records the halt itself (status paused, haltReason <phase>:stop-guard), which write-state clears when the run advances a phase. It never blocks outside a run and fails open, with a line in <log root>/hook-failures.log, on any error. These registrations are Claude Code's; README \"Hooks per host\" lists which have no equivalent elsewhere. On Codex only the syntax gate is offered, from codex-hooks.json through host-hooks.mjs; Copilot CLI gets none, since as of 1.0.45 it discards postToolUse output; the other gates are Claude Code only. multi-agent:setup offers to merge this block.",
|
|
2
|
+
"_readme": "Recommended Claude Code hooks for multi-agent-pipeline. `install` registers the pre-commit and agent-guard gates, the run-scoped run-stop-guard / run-scope-guard hooks, the task-mirror hook, the file-context hook, the skill-usage hook and the MCP failure hook itself (install/claude.mjs configureSettings, RUN_HOOKS); /multi-agent:setup offers to merge the rest of this block. Merge the `hooks` object into your ~/.claude/settings.json to make these deterministic PreToolUse gates real (exit 2 blocks the tool call). A PreToolUse matcher is a regex over the TOOL NAME, so each gate registers on a tool name and reads the command from its stdin payload. Three PreToolUse gates ship here: (1) pre-commit-check.sh on Bash, which acts only on a `git commit` and blocks a secret in the staged diff; (2) agent-guard.sh on Bash, on Edit|Write|NotebookEdit, and on WebFetch plus every multi-agent-toolkit tool (WebFetch|mcp__multi-agent-toolkit__.*). Always, it blocks AI/assistant attribution in a commit message and a force-push, delete or mirror push to a protected branch (main/master/develop), including one inside a subshell or a `bash -c` / `eval` line. With MULTI_AGENT_UNATTENDED=1 in the hook's environment it also applies the unattended policy: no push, PR or tracker write, no Keychain read, no fetch outside the host allowlist (curl, WebFetch, the toolkit's web tools, agent_run_steps and open_url), no package install, and no write into a protected path (features/unattended-security.md); (3) check-read-size.sh on Read|Bash, which inspects Read plus the shell commands that read a file whole (cat/head/tail/sed), returns immediately for everything else, and routes an oversized read to a cheap worker instead of the caller's own rung; it is inert until `prefs.global.bulkRead.mode` is set to observe or enforce. Failure behaviour: pre-commit-check.sh and check-read-size.sh fail open on an internal error. agent-guard.sh fails open when attended, so a guard bug cannot break a legitimate tool call, and fails closed under MULTI_AGENT_UNATTENDED=1, where nobody is there to notice a gap. None of the three executes the inspected command, and none needs run-specific arguments. The other deterministic gates (evidence, consensus, intent, learnings) take run-specific arguments and are phase-enforced by the pipeline instead. Three capture hooks ship alongside them and block nothing: (4) SessionEnd runs capture-flush.sh --if-stale, which writes a run's triage findings and durable learnings into the per-repo stores when the run ended before Phase 5, where those writes otherwise happen; the same hook runs note-session.sh, which records the mechanical shape of a session outside the pipeline (tools used, commands that failed, calls the user refused). (4b) SubagentStop and PostToolUseFailure run note-agent-event.sh, which appends one row to the same session notes as the event happens: a subagent's type, id, the bound run's task id and its last message cut to 200 characters (secret-scanned; a hit stores the row without the message), or a failed tool's name and its command's first program word, never an argument or error text. (5) PreCompact runs capture-flush.sh without --if-stale: a compaction summarizes the conversation mid-phase, so it is the moment unflushed findings are at risk, and both writes are idempotent, so a finished run costs two no-op writes. The staleness test exists only so a session exit does not re-flush a run that already finished. (6) SessionStart runs capture-resume.sh, which prints at most two lines: an unfinished run and how to resume it, and a stale pipeline-observation queue. No capture hook calls a model or reads a payload - note-session.sh keeps a command's first word and an exit code, never an argument or any output - and all exit 0 on every path, because a hook that fails a session over bookkeeping costs more than the bookkeeping. A run-scoped PreToolUse gate ships too: (2b) run-scope-guard.sh on every Figma MCP tool (mcp__.*[Ff]igma.*) denies a Figma call above phases.json thresholds.mcpAllowedThroughPhase for the run bound to the session, unless the run is in analysis mode, and records each allowed call into telemetry.mcpCalls[]; on Edit|Write|NotebookEdit the same script warns, attended only, when the target is outside the bound run's worktree (additionalContext for the model, systemMessage for the user; the call proceeds). On Agent|Task, with prefs.global.costBudget.enabled true, it asks before a subagent starts while the bound run's estimated spend is over the ceiling (denies with onExceed halt) and adds a note for the model from the warn threshold. On Bash|WebFetch|AskUserQuestion it denies a question from a bound autopilot run, a Figma read over HTTP (figma.com or api.figma.com) under the same phase rule, and, in any session, a direct write to agent-state.json or tracker-state.json (Edit/Write, a shell redirect or tee), since write-state.mjs is their only writer; the shell wrapper starts node only when the payload mentions Figma or a state file. Outside a run it is silent, and it fails open. One PostToolUse hook ships as well and blocks nothing: (7) edit-syntax-gate.sh on Edit|Write|MultiEdit parses the file the edit just wrote (swiftc -parse, node --check, py_compile into a temp dir, JSON.parse, bash -n; Kotlin skipped) under a 2 s deadline and, when it no longer parses, hands the model the error as PostToolUse additionalContext; it exits 0 on every path, stays silent when a parser is missing or slow, and is inert until `prefs.global.editSyntaxGate.enabled` is true. A second PostToolUse hook blocks nothing either: (7b) task-mirror.sh on TaskCreate|TaskUpdate mirrors the native task list into the tracker of the run bound to the session (phase-tracker.sh task, tracker-contract.md, \"Mirroring the host's task list\"), skipping phase tiles, so the office panel shows the same list; silent outside a run, exit 0 on every path. A third blocks nothing: (7c) file-context.sh on Read (PostToolUse, and PreToolUse on Read|Grep|Glob) hands the model, once per file per session, what the repo's memory says about the file it reads or searches (ledger facts whose scope covers it, its latest review findings, its open known limits from debt-ledger.mjs) as additionalContext inside an <untrusted-data> block, after the secret scan and fitted to the host's 10,000-character hook output limit; a Grep with a path, or a Glob whose literal directory is inside the repo, is mapped to at most five files the stores know, and a whole-repo search gets nothing; inside a run bound to the session by default, everywhere with prefs.global.fileContext.enabled true, never with it false; exit 0 on every path. A fourth blocks nothing: (7d) answer-check.sh on AskUserQuestion names, as PostToolUse additionalContext, every question the user submitted without a choice, so an empty answer is asked again instead of resolved to the Recommended option; it runs in every session, since it only adds context, and exits 0 on every path. A fifth blocks nothing: (7e) graph-hint.sh on Grep|Glob (PreToolUse) adds, once per session, one line pointing at `/multi-agent:graph ask` and mcp__multi-agent-toolkit__graph_query when the call searches the whole repo for a bare identifier and a current code graph (graphFreshness: build commit is HEAD, no indexed file changed) exists for the repo; silent with prefs.global.codeGraph.enabled false; exit 0 on every path. A sixth blocks nothing: (7f) note-skill-use.sh on Skill (PostToolUse and PostToolUseFailure) appends one row to the local <log root>/skill-usage.jsonl: the skill name (kept only when it matches a strict charset and length and carries no credential pattern, else the call is dropped), ok or error, the time, the host and the repo folder name (null outside a git repository and for a repository in prefs.global.memory.excludeProjects), never the arguments, the prompt or any output; past 1 MiB the log moves to skill-usage.jsonl.1; off with prefs.global.skillUsage.enabled false or prefs.global.usageLog.optOut true; it reads stdin for at most 1.5 s and exits 0 on every path. skill-usage.mjs summary and prune-candidates read it. A seventh blocks nothing: (7g) note-mcp-failure.sh on mcp__.* (PostToolUseFailure) appends one row to the local <log root>/mcp-failures.jsonl: the server and tool from the tool name (dropped unless both match a strict charset and length and carry no credential pattern), the time and a closed error class (the host's interrupt flag first, then a refusal by the user or the permission layer, then a JSON-RPC code in the error text, then a message opening with invalid or validation, then an HTTP status, then fixed patterns), never the arguments, the output or the error text itself; it probes nothing, is written by the same code as the skill-usage log, so it has the same 1 MiB cap and .1 generation, rotates under its own mcp-failures.jsonl.lock, never follows a symlink at the log path, is off with prefs.global.mcpFailures.enabled false or prefs.global.usageLog.optOut true, and exits 0 on every path; doctor's mcp-failures check reads it. One Stop hook ships as well: (8) run-stop-guard.sh answers {\"decision\":\"block\"} when the session driving an active pipeline run (bound through agent-state.json sessionId or hostSessionId, never by a worktree match) tries to stop while the run is in_progress below its mode's last phase with no haltReason or waitingFor; the reason says to finish the current phase, record the wait, or record a halt. A turn that ends on a question to the user, a session with background tasks or crons, and prefs.global.stopGuard.enabled false are never held, and run-stop-guard.sh is not registered on SubagentStop: a subagent's stop is the dispatching session's business. After three consecutive blocks it records the halt itself (status paused, haltReason <phase>:stop-guard), which write-state clears when the run advances a phase. It never blocks outside a run and fails open, with a line in <log root>/hook-failures.log, on any error. These registrations are Claude Code's; README \"Hooks per host\" lists which have no equivalent elsewhere. On Codex only the syntax gate is offered, from codex-hooks.json through host-hooks.mjs; Copilot CLI gets none, since as of 1.0.45 it discards postToolUse output; the other gates are Claude Code only. multi-agent:setup offers to merge this block.",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"PreToolUse": [
|
|
5
5
|
{
|
|
@@ -80,6 +80,17 @@
|
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"matcher": "Agent|Task",
|
|
85
|
+
"hooks": [
|
|
86
|
+
{
|
|
87
|
+
"type": "command",
|
|
88
|
+
"command": "bash \"$HOME/.claude/scripts/run-scope-guard.sh\"",
|
|
89
|
+
"timeout": 10,
|
|
90
|
+
"statusMessage": "Checking the run's cost budget before a new subagent..."
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
83
94
|
{
|
|
84
95
|
"matcher": "Read|Grep|Glob",
|
|
85
96
|
"hooks": [
|