@mmerterden/multi-agent-pipeline 21.0.0 → 21.1.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +8 -6
  3. package/README.tr.md +8 -6
  4. package/docs/architecture.md +3 -3
  5. package/docs/ecosystem.md +12 -12
  6. package/docs/facts.json +10 -9
  7. package/docs/features.md +1 -1
  8. package/install/claude.mjs +8 -1
  9. package/install/templates/claude-hooks.json +12 -1
  10. package/manifest.json +57 -41
  11. package/package.json +1 -1
  12. package/pipeline/agents/plan-critic.md +1 -1
  13. package/pipeline/commands/multi-agent/address-review/SKILL.md +183 -0
  14. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  15. package/pipeline/commands/multi-agent/update/SKILL.md +3 -2
  16. package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
  17. package/pipeline/multi-agent-refs/features/approach-choice.md +61 -0
  18. package/pipeline/multi-agent-refs/features/root-cause.md +98 -0
  19. package/pipeline/multi-agent-refs/features/usage-reporting.md +1 -1
  20. package/pipeline/multi-agent-refs/features/visual-evidence.md +14 -0
  21. package/pipeline/multi-agent-refs/help/en.md +3 -2
  22. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  23. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +6 -4
  24. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +2 -0
  25. package/pipeline/office/toolkit.json +1 -1
  26. package/pipeline/rules/debugging.md +10 -7
  27. package/pipeline/rules/outside-the-pipeline.md +1 -1
  28. package/pipeline/rules/tdd.md +4 -7
  29. package/pipeline/schemas/agent-state.schema.json +91 -0
  30. package/pipeline/schemas/prefs.schema.json +13 -1
  31. package/pipeline/schemas/toolkit-path-params.json +79 -1
  32. package/pipeline/scripts/_stack-routing.mjs +2 -0
  33. package/pipeline/scripts/approach-choice.mjs +232 -0
  34. package/pipeline/scripts/gate-ledger.mjs +30 -1
  35. package/pipeline/scripts/pr-threads.mjs +537 -0
  36. package/pipeline/scripts/pr-write-guard.mjs +139 -0
  37. package/pipeline/scripts/pr-write-guard.sh +34 -0
  38. package/pipeline/scripts/root-cause-gate.mjs +354 -0
  39. package/pipeline/skills/.skill-manifest.json +17 -5
  40. package/pipeline/skills/.skills-index.json +35 -2
  41. package/pipeline/skills/shared/README.md +8 -5
  42. package/pipeline/skills/shared/core/multi-agent-address-review/SKILL.md +44 -0
  43. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  44. package/pipeline/skills/shared/core/multi-agent-update/SKILL.md +1 -1
  45. package/pipeline/skills/shared/external/humanizer/SKILL.md +48 -6
  46. package/pipeline/skills/shared/external/humanizer/evals/evals.json +13 -0
  47. package/pipeline/skills/shared/external/humanizer/references/turkish.md +88 -0
  48. package/pipeline/skills/shared/external/store-screenshots/SKILL.md +252 -0
  49. package/pipeline/skills/shared/external/store-screenshots/evals/evals.json +47 -0
  50. package/pipeline/skills/shared/external/thesis-writing/SKILL.md +140 -0
  51. package/pipeline/skills/shared/external/thesis-writing/evals/evals.json +40 -0
  52. package/pipeline/skills/shared/external/thesis-writing/references/review-checklist.md +33 -0
  53. package/pipeline/skills/shared/external/thesis-writing/references/turkish-thesis-conventions.md +65 -0
  54. package/pipeline/skills/skills-index.md +4 -1
@@ -1,7 +1,7 @@
1
1
  # Cross-CLI Contract (Claude Code · Copilot CLI · Codex CLI)
2
2
 
3
3
  <!-- toc -->
4
- - [1. Command Inventory (71 commands)](#1-command-inventory-71-commands)
4
+ - [1. Command Inventory (72 commands)](#1-command-inventory-72-commands)
5
5
  - [2. Canonical Placeholder Vocabulary](#2-canonical-placeholder-vocabulary)
6
6
  - [2.6 Intentional structural divergence - two entry files over one set of refs](#26-intentional-structural-divergence---two-entry-files-over-one-set-of-refs)
7
7
  - [2.7 One command, three different meanings: `/multi-agent:model`](#27-one-command-three-different-meanings-multi-agentmodel)
@@ -20,10 +20,10 @@
20
20
 
21
21
  ---
22
22
 
23
- ## 1. Command Inventory (71 commands)
23
+ ## 1. Command Inventory (72 commands)
24
24
 
25
25
  ```
26
- analysis, analysis-jira, analysis-resolve, autopilot-off,
26
+ address-review, analysis, analysis-jira, analysis-resolve, autopilot-off,
27
27
  autopilot-on, autopilot-status, bug-bash, build-optimize, channels, clean-disk, complaint-analysis,
28
28
  create-jira, design-check, diff-explain, doctor, estimate, feedback, forget,
29
29
  garbage-collect, graph, health, help, ios-coding-standard, issue, jira, kill,
@@ -43,7 +43,7 @@ Categories:
43
43
  - **Issue generator** (one-shot, no worktree, asks type Task/Bug/Story, hard approval gate before create): `create-jira`
44
44
  - **Pipeline entries**: the bare `/multi-agent` in the dispatcher. Autopilot is its modifier (`/multi-agent "task" autopilot`, with `--loop N` for a bounded loop), not a command of its own. The phase set is a property of the command, and every mode runs its whole set.
45
45
  - **Tail path** (the pipeline tail over work already on a branch, no run behind it): `resume`
46
- - **Ops commands** (one-shot, no worktree): `status`, `log`, `kill`, `steer`, `purge`, `uninstall`, `resume`, `review`, `review-jira`, `review-issue`, `review-priority`, `analysis`, `analysis-resolve`, `research`, `scaffold`, `complaint-analysis`, `bug-bash`, `test-gen`, `build-optimize`, `channels`, `scan`, `search`, `diff-explain`, `garbage-collect`, `graph`, `health`, `postmortem`, `prune-logs`, `prune-prompts`, `clean-disk`, `serve`, `office-on`, `office-off`, `office-status`
46
+ - **Ops commands** (one-shot, no worktree): `status`, `log`, `kill`, `steer`, `purge`, `uninstall`, `resume`, `review`, `review-jira`, `review-issue`, `review-priority`, `address-review`, `analysis`, `analysis-resolve`, `research`, `scaffold`, `complaint-analysis`, `bug-bash`, `test-gen`, `build-optimize`, `channels`, `scan`, `search`, `diff-explain`, `garbage-collect`, `graph`, `health`, `postmortem`, `prune-logs`, `prune-prompts`, `clean-disk`, `serve`, `office-on`, `office-off`, `office-status`
47
47
  - **Local audits** (worktree only to build; no commit, push, PR or channels): `design-check`, `testflight-validation`, `ios-coding-standard`. `testflight-validation` additionally never invokes `altool --upload-app` - a validation run must not be able to ship a build by accident.
48
48
  - **Meta-ops**: `setup`, `sync`, `update`, `help`, `refactor`, `test`, `stack`, `manual-test`, `language`
49
49
  - **Routines** (user-defined routine registry; the routines they create are local-only and never synced): `save`, `routines`, `forget`
@@ -0,0 +1,61 @@
1
+ # Feature: Choosing the approach (free-text tasks without an analysis document)
2
+
3
+ **When**: Phase 1, after codebase exploration (Step 3) and before the
4
+ analysis document (Step 4), when all of these hold:
5
+
6
+ - `state.inputType === "free-text"`;
7
+ - no analysis document is behind the run: no `/multi-agent:analysis` output
8
+ linked in `state.contextLinks[]`, and Step 4 would not reuse a cached one;
9
+ - `prefs.global.approachChoice.enabled` is not `false` (default on).
10
+
11
+ A Jira or GitHub item carries a stated intent and an analysis document is a
12
+ decided design; both skip this step.
13
+
14
+ ## 1. Write the alternatives
15
+
16
+ From what Step 3 found, write `<worktree>/.pipeline/approaches.json`: two or
17
+ three approaches that would each satisfy the task, each with a `title`, a
18
+ one-sentence `summary`, `pros[]`, `cons[]`, the `modules[]` it touches and an
19
+ `estFiles` count, plus the `recommended` id. Real alternatives differ in
20
+ where the change lives or what it costs later (a new module against an
21
+ extension, a migration against an adapter), not in naming.
22
+
23
+ When exploration found one sensible way only (a config value, a one-line
24
+ guard), write `{"skip": {"reason": "..."}}` instead and say why. Never invent
25
+ a weaker option to reach two.
26
+
27
+ ```bash
28
+ node $HOME/.claude/scripts/approach-choice.mjs check --file "$WORKTREE/.pipeline/approaches.json"
29
+ ```
30
+
31
+ Exit 1 lists what is missing; fix and run again. Exit 2 is the skip: log
32
+ `Phase 1: approach choice - skipped (<reason>)` and go on to Step 4.
33
+
34
+ ## 2. Choose
35
+
36
+ **Attended**: `approach-choice.mjs options --file ...` prints the options,
37
+ recommended first. Ask one `AskUserQuestion` per `$HOME/.claude/multi-agent-refs/picker-contract.md` (`header` "Approach"; question,
38
+ labels and descriptions in `outputLanguage`), then record the pick:
39
+
40
+ ```bash
41
+ node $HOME/.claude/scripts/approach-choice.mjs choose \
42
+ --file "$WORKTREE/.pipeline/approaches.json" --pick <id> --state "$STATE_FILE"
43
+ ```
44
+
45
+ **Autopilot**: no question. The run takes the recommended approach and
46
+ writes why, from the evidence of Step 3 (files, callers, existing patterns):
47
+
48
+ ```bash
49
+ node $HOME/.claude/scripts/approach-choice.mjs choose --file ... \
50
+ --pick <recommended id> --why "<evidence for it>" --state "$STATE_FILE"
51
+ ```
52
+
53
+ The script refuses any other pick unattended, requires `--why`, and adds the
54
+ choice to `decisions[]`, so the PR body and the Phase 5 report show it.
55
+
56
+ ## 3. Downstream
57
+
58
+ `state.approachChoice` is the design input of Step 4 and Step 6: the analysis
59
+ document and the task graph build the chosen approach only. The plan critic's
60
+ cheaper-alternative lens starts from `rejected[]` and their cons rather than
61
+ inventing new ones.
@@ -0,0 +1,98 @@
1
+ # Feature: Root cause before the fix (bugfix tasks)
2
+
3
+ **Applies to** every Phase 2 task of a run whose `taskType` is `bugfix`, and to
4
+ every rework of one. A symptom patch passes its test and leaves the cause in
5
+ place; the record below makes the cause a thing written down and checked
6
+ before any production line changes.
7
+
8
+ ## 1. The record
9
+
10
+ `<worktree>/.pipeline/root-cause.json`, written with the Write tool before the
11
+ first fix:
12
+
13
+ ```json
14
+ {
15
+ "symptom": "what fails, as the user or the test sees it",
16
+ "hypothesis": "the cause, as one falsifiable sentence",
17
+ "origin": "src/money.js:2",
18
+ "evidence": [
19
+ { "kind": "test", "ref": ".pipeline/red.log:2", "quote": "NaN !== 0" },
20
+ { "kind": "read", "ref": "src/money.js:2", "quote": "Number.parseFloat" }
21
+ ],
22
+ "rejected": ["hypotheses ruled out, each with what ruled it out"],
23
+ "attempts": []
24
+ }
25
+ ```
26
+
27
+ - `origin` is where the cause is, not where the symptom shows. Trace back
28
+ from the failing line through each caller until the value or state first
29
+ goes wrong; the frames in between go in the hypothesis.
30
+ - `evidence` holds at least one observation: a failing test's output, a log,
31
+ a stack trace (`kind` `test` | `log` | `trace`), saved under `.pipeline/`
32
+ and cited by `path:line` with the text on that line. A `read` of the code
33
+ backs the claim but is not enough alone.
34
+ - Instrument before guessing: a log line or an assertion at the suspected
35
+ boundary, run once, beats a second hypothesis.
36
+
37
+ ```bash
38
+ node $HOME/.claude/scripts/root-cause-gate.mjs check \
39
+ --record "$WORKTREE/.pipeline/root-cause.json" --repo "$WORKTREE" --state "$STATE_FILE"
40
+ ```
41
+
42
+ Exit 1 lists what does not resolve. No production edit before it exits 0.
43
+ The RED test of the TDD cycle is the test that reproduces the symptom; when
44
+ it exists before the record, its output is the `test` evidence.
45
+
46
+ ## 2. Attempts and the stop
47
+
48
+ After each fix attempt, with the outcome of the reproducing test:
49
+
50
+ ```bash
51
+ node $HOME/.claude/scripts/root-cause-gate.mjs attempt \
52
+ --record "$WORKTREE/.pipeline/root-cause.json" --repo "$WORKTREE" \
53
+ --outcome red|green --hypothesis "<what this attempt assumed>" --state "$STATE_FILE"
54
+ ```
55
+
56
+ An attempt is the diff against HEAD; recording the same diff twice counts
57
+ once. A red attempt is a hypothesis that failed: before the next one, move it
58
+ to `rejected` with what the run showed, and write the new hypothesis.
59
+
60
+ **The third red attempt in a row (since the last green one) exits 4, and a fourth is refused.** Three
61
+ fixes that each failed are a sign the cause is in the structure (a shared
62
+ mutable state, a wrong ownership boundary, a contract two callers read
63
+ differently), not in the line being patched. Do not try again:
64
+
65
+ - **Attended**: stop and ask one `AskUserQuestion` per `$HOME/.claude/multi-agent-refs/picker-contract.md`, `header` "Root cause",
66
+ the question in `outputLanguage`: the three hypotheses that failed, what
67
+ each showed, and the design question they point at (which boundary, which
68
+ owner, which contract). Options: **Rethink** (the person names the design
69
+ change; their answer is the `--decision`) and **Stop** (leave the task
70
+ parked, work kept on the branch).
71
+ - **Unattended**: the gate parks the run itself on `pendingQuestion`
72
+ `root-cause-escalation` (stepId `phase-2/root-cause`, options `rethink` and
73
+ `stop`). Resume carries the answer back to this step.
74
+
75
+ On **Rethink**:
76
+
77
+ ```bash
78
+ node $HOME/.claude/scripts/root-cause-gate.mjs reset \
79
+ --record "$WORKTREE/.pipeline/root-cause.json" --decision "<the design change agreed>"
80
+ ```
81
+
82
+ The round is archived with the decision, the hypothesis is cleared, and
83
+ `check` must pass again on a new one before the next attempt.
84
+
85
+ ## 3. At commit
86
+
87
+ `state.rootCause` is written on every `check`, `attempt` and `reset`. For a
88
+ `bugfix` run the gate ledger refuses the commit while it is missing, its
89
+ check has not passed, or it is escalated: the unattended commit check
90
+ (`gate-ledger.mjs check`) lists it as failing `root-cause`, and the attended
91
+ pre-commit check names it beside the build and test evidence.
92
+
93
+ ## 4. What the gate cannot know
94
+
95
+ It proves that the origin and every cited line exist and that the evidence
96
+ includes an observation. Whether the hypothesis explains the evidence is
97
+ judgement, and so is whether the fix reaches `origin`: a diff whose changed
98
+ lines never touch the origin file says why in the record's `hypothesis`.
@@ -454,7 +454,7 @@ comment before Phase 0; `resume` on both hosts, since a resumed run skips
454
454
  Phase 0; Phase 0 itself (Step −2); the autopilot runner (before each item it
455
455
  would take); the autopilot loop (before each iteration); the office (before it
456
456
  starts a job); and, first, every standalone command that writes outside the
457
- machine: `analysis`, `analysis-jira`, `channels`, `complaint-analysis`,
457
+ machine: `address-review`, `analysis`, `analysis-jira`, `channels`, `complaint-analysis`,
458
458
  `create-jira`, `design-check`, `kill`, `purge`, `refactor`,
459
459
  `review`, `review-analysis`, `review-issue`, `review-jira`, `review-priority`,
460
460
  `routines`, `scaffold` and `sync`, on both hosts. `feedback` stays open so a
@@ -6,6 +6,7 @@
6
6
  - [3. After - Phase 2, not the Phase 3 user test](#3-after---phase-2-not-the-phase-3-user-test)
7
7
  - [4. Video - the recording rides on a test run](#4-video---the-recording-rides-on-a-test-run)
8
8
  - [5. Size, and what happens when it does not fit](#5-size-and-what-happens-when-it-does-not-fit)
9
+ - [5a. Personal data, before anything leaves the machine](#5a-personal-data-before-anything-leaves-the-machine)
9
10
  - [5b. Where the artefacts live - the host](#5b-where-the-artefacts-live---the-host)
10
11
  - [6. Rendering](#6-rendering)
11
12
  - [7. Blocker](#7-blocker)
@@ -294,6 +295,19 @@ Order of attempts, each one recorded:
294
295
 
295
296
  Never silently attach nothing.
296
297
 
298
+ ## 5a. Personal data, before anything leaves the machine
299
+
300
+ A still or a recording can show what must not reach a ticket or a PR: a test
301
+ account's name, email or phone, a passport or card field, a token on screen.
302
+ Before step 1 above, look at each artefact; where such a field is visible, cover
303
+ it with `mcp__multi-agent__media_redact` (`input`, `output` beside it, one
304
+ `box` region per field, a `start`/`end` window on video) and upload the output
305
+ instead. `box` is the only method that counts as redaction; `blur` and
306
+ `pixelate` are cosmetic. The tool decodes its output again and fails rather
307
+ than write a region it could not cover, so a failure means the artefact is not
308
+ uploaded and the gap line says why. It never overwrites the original, and under
309
+ `MULTI_AGENT_UNATTENDED=1` an existing output is not replaced either.
310
+
297
311
  ## 5b. Where the artefacts live - the host
298
312
 
299
313
  Resolved in Phase 4 Step 2.9, recorded as `state.visualEvidence.host`:
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- facts: commandCount="commands" toolCount="tools, most for a RUNNING app" -->
4
4
  ```
5
- Multi-Agent Pipeline - 71 commands, grouped by what you want to do
5
+ Multi-Agent Pipeline - 72 commands, grouped by what you want to do
6
6
 
7
7
  Start here:
8
8
 
@@ -58,6 +58,7 @@ Jira and GitHub
58
58
  Review and analysis
59
59
 
60
60
  /multi-agent:review [PR|branch] Parallel review of a PR or branch diff
61
+ /multi-agent:address-review [PR] Answer review on our own PR; each write approved alone
61
62
  /multi-agent:diff-explain Map a review finding back to its diff lines
62
63
  /multi-agent:analysis ["name"] Feature analysis from Figma, Swagger, Confluence, repos
63
64
  /multi-agent:analysis-resolve [doc] Answer an analysis doc's open questions one by one
@@ -148,7 +149,7 @@ Access and usage reporting
148
149
  Plugins and tools (call them directly)
149
150
 
150
151
  Stack plugins ai-<stack>-toolkit:<skill>; catalog: ai-<stack>-toolkit:help
151
- Toolkit MCP multi-agent: 238 tools, most for a RUNNING app:
152
+ Toolkit MCP multi-agent: 250 tools, most for a RUNNING app:
152
153
  ios_*, android_*, web_*, design_*, store_*, the audits.
153
154
  Not registered means a silent no-op.
154
155
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- facts: commandCount="komut" toolCount="araç, çoğu" -->
4
4
  ```
5
- Multi-Agent Pipeline - 71 komut, ne yapmak istediğine göre gruplu
5
+ Multi-Agent Pipeline - 72 komut, ne yapmak istediğine göre gruplu
6
6
 
7
7
  Buradan başla:
8
8
 
@@ -58,6 +58,7 @@ Jira ve GitHub
58
58
  Review ve analiz
59
59
 
60
60
  /multi-agent:review [PR|branch] PR ya da branch diff'ine paralel review
61
+ /multi-agent:address-review [PR] Kendi PR'ımızdaki review'u yanıtla; her yazma ayrı onaylı
61
62
  /multi-agent:diff-explain Review bulgusunu diff satırlarına bağla
62
63
  /multi-agent:analysis ["ad"] Figma, Swagger, Confluence ve repolardan analiz
63
64
  /multi-agent:analysis-resolve [doc] Analizin açık sorularını tek tek yanıtla
@@ -148,7 +149,7 @@ Erişim ve kullanım raporu
148
149
  Plugin'ler ve araçlar (doğrudan çağır)
149
150
 
150
151
  Stack plugin ai-<stack>-toolkit:<skill>; katalog: ai-<stack>-toolkit:help
151
- Toolkit MCP multi-agent: 238 araç, çoğu ÇALIŞAN uygulama için:
152
+ Toolkit MCP multi-agent: 250 araç, çoğu ÇALIŞAN uygulama için:
152
153
  ios_*, android_*, web_*, design_*, store_*, denetimler.
153
154
  Kayıtlı değilse sessizce hiçbir şey yapmaz.
154
155
 
@@ -186,17 +186,19 @@ Launch parallel Explore agents to scan codebase:
186
186
  - Existing patterns and conventions
187
187
  - Potential impact areas
188
188
 
189
- Use `subagent_type: "Explore"` with thoroughness scaled to task size AND knowledge availability (first match wins):
189
+ `subagent_type: "Explore"`, thoroughness by task size and knowledge (first match wins):
190
190
 
191
- - A fresh code graph answered the task's query with a ranked file set (Step 2.6) → "light" (the starting set is already narrowed; explore outward from it, do not re-scan)
191
+ - A fresh code graph answered the task's query with a ranked file set (Step 2.6) → "light" (explore outward from it, do not re-scan)
192
192
  - `taskType` is `bugfix`/`chore` AND scope is small (single named file, or a referenced crash/stack frame that pinpoints the site) → "light" (cheapest - scan only the named area + its direct callers)
193
193
  - Knowledge exists → "medium" (targeted, cheaper)
194
194
  - No knowledge, or `taskType` is `feature`/`refactor`/`component` → "very thorough" (full scan, first-time investment)
195
195
 
196
- The light tier keeps a one-line bug fix from triggering a full-repo scan; pairing it with the deterministic `taskType` (Phase 0 Step 7) prevents the cheap path from firing on feature work.
197
-
198
196
  **Dispatch resilience (required).** The synthesis waits on every Explore agent, so bound each Explore dispatch by a wall-clock budget (`EXPLORE_TIMEOUT_SECONDS`, default 180). If an agent has not returned by the budget: log `explore.timeout agent=<id>`, drop that agent's slice, and synthesize from the agents that did return. Proceed as long as at least one Explore agent returned; if zero returned, retry the cheapest single Explore once, then HALT with `ERR: no Explore agent returned within ${EXPLORE_TIMEOUT_SECONDS}s; resume with /multi-agent:resume #N.`.
199
197
 
198
+ #### Step 3.5 - Approach choice (free-text, no analysis doc)
199
+
200
+ 2-3 approaches with tradeoffs; the person picks, autopilot records why: [`features/approach-choice.md`]($HOME/.claude/multi-agent-refs/features/approach-choice.md).
201
+
200
202
  #### Step 4 - Analysis document (the design contract Phase 1 and Phase 2 demand)
201
203
 
202
204
  Phase 1 and Phase 2 pre-flights BLOCK on `analysis/<feature-slug>-<platform>.md`. **This step produces it.**
@@ -111,6 +111,8 @@ For each task (respecting dependency order), on start and on end: `bash $HOME/.c
111
111
  2. **Multi-submodule awareness**: a task may span the submodules Phase 0 Step 7 detected (e.g. tokens in **common**, the component in **uicomponents**); that is expected.
112
112
  3. **TDD cycle** (Launch Agent with `model: "sonnet"`) - gated by `state.testPolicy`: `tdd` = the loop below; `tests-after` = skip RED, author the same tests once green; `none` = author no tests (existing ones never weakened), report "tests not written - project policy" rather than a gap.
113
113
 
114
+ **Bugfix (`taskType === bugfix`, rework included): root cause before any fix.** `root-cause-gate.mjs check` passes on an evidenced record first; each fix attempt is recorded, and the third red one stops the loop with a design question, never a fourth patch: [`features/root-cause.md`]($HOME/.claude/multi-agent-refs/features/root-cause.md).
115
+
114
116
  **RED - Write ONE failing test first:**
115
117
  - **Rework re-entry**: if `state.reviewIterations[-1].verifyByTest.redTests[]` exists (Phase 3 Step 3.7 ran), those failing repro tests ARE the RED step for their findings - make them green, do not write a duplicate failing test and do not delete or weaken them. See `$HOME/.claude/multi-agent-refs/features/verify-by-test.md`.
116
118
  - Test framework: use whatever the project already uses. Detect from existing test files:
@@ -1,3 +1,3 @@
1
1
  {
2
- "toolkitVersion": "4.0.0"
2
+ "toolkitVersion": "4.1.0"
3
3
  }
@@ -10,15 +10,18 @@
10
10
 
11
11
  ### Common Root Cause Categories
12
12
 
13
- | Category | Signs | Approach |
14
- | ---------------- | ------------------------------ | -------------------------------------- |
15
- | Race Condition | Intermittent, timing-dependent | Instrumentation, concurrent tests |
16
- | State Corruption | Works initially, fails later | Trace state changes, invariant checks |
17
- | Resource Leak | Degrades over time | Monitor memory, check cleanup |
18
- | Off-by-One | Edge cases fail | Test boundaries: 0, 1, N-1, N, N+1 |
19
- | Nil/Crash | Crashes in production | Guard external data, trace from source |
13
+ | Category | Signs | Approach |
14
+ |---|---|---|
15
+ | Race Condition | Intermittent, timing-dependent | Instrumentation, concurrent tests |
16
+ | State Corruption | Works initially, fails later | Trace state changes, invariant checks |
17
+ | Resource Leak | Degrades over time | Monitor memory, check cleanup |
18
+ | Off-by-One | Edge cases fail | Test boundaries: 0, 1, N-1, N, N+1 |
19
+ | Nil/Crash | Crashes in production | Guard external data, trace from source |
20
20
 
21
21
  ### Rules
22
22
 
23
23
  - Never fix a bug without a test that reproduces it first
24
+ - Root cause first: symptom, hypothesis, origin `file:line`, an observed failure (test, log, trace); fix at the origin
25
+ - Trace back through callers to where the value first goes wrong
26
+ - 3 failed fixes: stop and question the design; no 4th patch
24
27
  - Stack traces: read bottom-up for chain, top for crash location
@@ -26,7 +26,7 @@ the file first; never inline it). The repo's own `.claude/skills` come first.
26
26
  `ai-common-toolkit` and `ai-analyst-toolkit` are on everywhere. Nothing enabled
27
27
  is a normal state.
28
28
 
29
- **multi-agent MCP.** <!-- fact:toolCount -->238<!-- /fact --> tools, most for a running app: `ios_get_ui_tree` /
29
+ **multi-agent MCP.** <!-- fact:toolCount -->250<!-- /fact --> tools, most for a running app: `ios_get_ui_tree` /
30
30
  `android_get_ui_tree`, `ios_list_crashes` / `android_list_crashes`, `design_*`,
31
31
  `ios_app_store_audit`, `ios_testflight_validate`. Use them instead of guessing
32
32
  about on-screen state. Not registered is a silent no-op.
@@ -11,15 +11,12 @@ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
11
11
  3. **GREEN**: Simplest code to pass - nothing more
12
12
  4. **Verify GREEN**: Confirm pass AND other tests still pass
13
13
  5. **REFACTOR**: Remove duplication, improve names
14
-
15
- ### Bug Fix Protocol
16
-
17
- Bug found -> Write failing test -> TDD cycle -> Test proves fix & prevents regression.
14
+ 6. **Claim only what ran**: "passes" needs this session's command and its output
18
15
 
19
16
  ### iOS Testing Pyramid
20
17
 
21
18
  ```
22
- [UI Tests / XCUITest] (minimize)
23
- [Integration / Snapshot Tests]
24
- [Unit Tests / ViewInspector / XCTest] (maximize)
19
+ [UI Tests / XCUITest] (minimize)
20
+ [Integration / Snapshot Tests]
21
+ [Unit Tests / ViewInspector / XCTest] (maximize)
25
22
  ```
@@ -975,6 +975,38 @@
975
975
  }
976
976
  }
977
977
  },
978
+ "rootCause": {
979
+ "type": ["object", "null"],
980
+ "additionalProperties": false,
981
+ "required": ["path", "failedAttempts", "at"],
982
+ "description": "Summary of a bugfix's root-cause record (refs/features/root-cause.md), written by root-cause-gate.mjs whenever the run's state resolves. The record itself stays at path. gate-ledger.mjs holds a bugfix commit to it: verdict pass and not escalated. escalated: the third failed fix attempt in a row stopped the loop and parked the run on the phase-2/root-cause question.",
983
+ "properties": {
984
+ "path": {
985
+ "type": "string"
986
+ },
987
+ "origin": {
988
+ "type": ["string", "null"]
989
+ },
990
+ "verdict": {
991
+ "enum": ["pass", "fail"]
992
+ },
993
+ "failedAttempts": {
994
+ "type": "integer",
995
+ "minimum": 0
996
+ },
997
+ "rounds": {
998
+ "type": "integer",
999
+ "minimum": 0
1000
+ },
1001
+ "escalated": {
1002
+ "type": "boolean"
1003
+ },
1004
+ "at": {
1005
+ "type": "string",
1006
+ "format": "date-time"
1007
+ }
1008
+ }
1009
+ },
978
1010
  "run": {
979
1011
  "type": ["object", "null"],
980
1012
  "additionalProperties": true,
@@ -1967,6 +1999,65 @@
1967
1999
  "format": "date-time",
1968
2000
  "description": "Set when Phase 4 removed the worktree after opening the PR. Its presence is what tells :resume, :status and :log that a worktree-less task is finished-and-tidied rather than broken - without it a missing worktree is indistinguishable from a killed run."
1969
2001
  },
2002
+ "approachChoice": {
2003
+ "type": ["object", "null"],
2004
+ "additionalProperties": false,
2005
+ "required": ["chosen", "rejected", "recommended", "by", "at"],
2006
+ "description": "The approach a free-text task without an analysis document was built on (refs/features/approach-choice.md), written by approach-choice.mjs. by user: picked by the person; derived: an unattended run took the recommended approach, why says on what evidence, and the same choice is in decisions[]. plan-critic reads rejected[].",
2007
+ "properties": {
2008
+ "chosen": {
2009
+ "type": "object",
2010
+ "additionalProperties": false,
2011
+ "required": ["id", "title"],
2012
+ "properties": {
2013
+ "id": {
2014
+ "type": "string"
2015
+ },
2016
+ "title": {
2017
+ "type": "string"
2018
+ }
2019
+ }
2020
+ },
2021
+ "rejected": {
2022
+ "type": "array",
2023
+ "items": {
2024
+ "type": "object",
2025
+ "additionalProperties": false,
2026
+ "required": ["id", "title"],
2027
+ "properties": {
2028
+ "id": {
2029
+ "type": "string"
2030
+ },
2031
+ "title": {
2032
+ "type": "string"
2033
+ },
2034
+ "cons": {
2035
+ "type": "array",
2036
+ "items": {
2037
+ "type": "string"
2038
+ }
2039
+ }
2040
+ }
2041
+ }
2042
+ },
2043
+ "recommended": {
2044
+ "type": "string"
2045
+ },
2046
+ "by": {
2047
+ "enum": ["user", "derived"]
2048
+ },
2049
+ "why": {
2050
+ "type": ["string", "null"]
2051
+ },
2052
+ "path": {
2053
+ "type": "string"
2054
+ },
2055
+ "at": {
2056
+ "type": "string",
2057
+ "format": "date-time"
2058
+ }
2059
+ }
2060
+ },
1970
2061
  "artifactsPath": {
1971
2062
  "type": ["string", "null"],
1972
2063
  "description": "Directory the worktree's artefacts were salvaged into before removal (agent-state, phase-tracker, triage-output, .pipeline/, build+test logs, review diff). Phase 5 and :resume read from here when worktreePath is gone."
@@ -994,7 +994,7 @@
994
994
  "testBaseline": {
995
995
  "type": "object",
996
996
  "additionalProperties": false,
997
- "description": "Phase 0 test baseline. When enabled, Phase 0 runs the SAME test command the Phase 2 exit gate's Gate 3 uses and records which tests were already failing before this run touched anything, so the gate stops attributing an inherited red suite to the current work. Three outcomes are stored, never two: green, red (with the failing set when it can be parsed, otherwise the log path alone), or unknown when the command is absent or the time cap was hit. Off by default because on iOS the run costs a full xcodebuild test before any work starts. Pattern source: obra/superpowers using-git-worktrees Step 3 'Verify Clean Baseline', extended from ask-the-user to a stored set Phase 3 can subtract.",
997
+ "description": "Phase 0 test baseline. When enabled, Phase 0 runs the SAME test command the Phase 2 exit gate's Gate 3 uses and records which tests were already failing before this run touched anything, so the gate stops attributing an inherited red suite to the current work. Three outcomes are stored, never two: green, red (with the failing set when it can be parsed, otherwise the log path alone), or unknown when the command is absent or the time cap was hit. Off by default because on iOS the run costs a full xcodebuild test before any work starts. The outcome is stored rather than asked about, so Phase 3 can subtract it.",
998
998
  "properties": {
999
999
  "enabled": {
1000
1000
  "type": "boolean",
@@ -1291,6 +1291,18 @@
1291
1291
  }
1292
1292
  }
1293
1293
  },
1294
+ "approachChoice": {
1295
+ "type": "object",
1296
+ "additionalProperties": false,
1297
+ "description": "Phase 1 approach choice for free-text tasks with no analysis document behind them (refs/features/approach-choice.md): two or three written approaches with their tradeoffs, picked by the person, or by an autopilot run that takes the recommended one and records why in decisions[].",
1298
+ "properties": {
1299
+ "enabled": {
1300
+ "type": "boolean",
1301
+ "default": true,
1302
+ "description": "false skips the step; the plan is then built on the approach the planner takes without showing alternatives."
1303
+ }
1304
+ }
1305
+ },
1294
1306
  "planComplexity": {
1295
1307
  "type": "object",
1296
1308
  "additionalProperties": false,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-toolkit-path-params.mjs from multi-agent-mcp tool-manifest.json; do not edit. Per toolkit tool: the parameters it writes to and the filesystem paths it reads, both confined by scripts/unattended_policy.py.",
3
- "toolkitVersion": "4.0.0",
3
+ "toolkitVersion": "4.1.0",
4
4
  "tools": {
5
5
  "agent_query_output": {
6
6
  "writes": [],
@@ -611,6 +611,20 @@
611
611
  "path"
612
612
  ]
613
613
  },
614
+ "media_redact": {
615
+ "writes": [
616
+ "output"
617
+ ],
618
+ "reads": [
619
+ "path"
620
+ ]
621
+ },
622
+ "media_thumbnail_check": {
623
+ "writes": [],
624
+ "reads": [
625
+ "path"
626
+ ]
627
+ },
614
628
  "media_transcript": {
615
629
  "writes": [],
616
630
  "reads": []
@@ -868,6 +882,25 @@
868
882
  "writes": [],
869
883
  "reads": []
870
884
  },
885
+ "store_screenshot_check": {
886
+ "writes": [],
887
+ "reads": [
888
+ "dir"
889
+ ]
890
+ },
891
+ "store_screenshot_render": {
892
+ "writes": [
893
+ "out_dir"
894
+ ],
895
+ "reads": [
896
+ "html",
897
+ "assets"
898
+ ]
899
+ },
900
+ "store_screenshot_sizes": {
901
+ "writes": [],
902
+ "reads": []
903
+ },
871
904
  "store_search": {
872
905
  "writes": [],
873
906
  "reads": []
@@ -890,6 +923,51 @@
890
923
  "confirm"
891
924
  ]
892
925
  },
926
+ "thesis_bib_check": {
927
+ "writes": [],
928
+ "reads": [
929
+ "paths"
930
+ ]
931
+ },
932
+ "thesis_citation_check": {
933
+ "writes": [],
934
+ "reads": [
935
+ "manuscripts",
936
+ "bibliography"
937
+ ]
938
+ },
939
+ "thesis_overlap": {
940
+ "writes": [],
941
+ "reads": [
942
+ "paths",
943
+ "reference_paths"
944
+ ]
945
+ },
946
+ "thesis_reference_format": {
947
+ "writes": [],
948
+ "reads": [
949
+ "bibliography"
950
+ ]
951
+ },
952
+ "thesis_reference_verify": {
953
+ "writes": [],
954
+ "reads": [
955
+ "bibliography"
956
+ ]
957
+ },
958
+ "thesis_structure_lint": {
959
+ "writes": [],
960
+ "reads": [
961
+ "paths"
962
+ ]
963
+ },
964
+ "thesis_style_lint": {
965
+ "writes": [],
966
+ "reads": [
967
+ "paths",
968
+ "original_path"
969
+ ]
970
+ },
893
971
  "ui_hit_test": {
894
972
  "writes": [],
895
973
  "reads": []
@@ -41,6 +41,8 @@ export const COMMON_SKILLS = [
41
41
  "release-video",
42
42
  "short-video-craft",
43
43
  "reverse-engineer-own-app",
44
+ "thesis-writing",
45
+ "store-screenshots",
44
46
  ];
45
47
 
46
48
  // The analyst plugin is the second always-enabled toolkit. It carries outside