cclaw-cli 8.1.2 → 8.3.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/README.md +50 -23
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/content/antipatterns.d.ts +1 -1
- package/dist/content/antipatterns.js +24 -0
- package/dist/content/artifact-templates.d.ts +1 -1
- package/dist/content/artifact-templates.js +83 -2
- package/dist/content/node-hooks.js +80 -27
- package/dist/content/skills.js +397 -13
- package/dist/content/specialist-prompts/architect.d.ts +1 -1
- package/dist/content/specialist-prompts/architect.js +30 -6
- package/dist/content/specialist-prompts/brainstormer.d.ts +1 -1
- package/dist/content/specialist-prompts/brainstormer.js +31 -8
- package/dist/content/specialist-prompts/planner.d.ts +1 -1
- package/dist/content/specialist-prompts/planner.js +81 -12
- package/dist/content/specialist-prompts/reviewer.d.ts +1 -1
- package/dist/content/specialist-prompts/reviewer.js +43 -6
- package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -1
- package/dist/content/specialist-prompts/security-reviewer.js +31 -6
- package/dist/content/specialist-prompts/slice-builder.d.ts +1 -1
- package/dist/content/specialist-prompts/slice-builder.js +79 -10
- package/dist/content/start-command.js +310 -153
- package/dist/flow-state.d.ts +46 -6
- package/dist/flow-state.js +141 -6
- package/dist/run-persistence.d.ts +11 -4
- package/dist/run-persistence.js +18 -7
- package/dist/types.d.ts +55 -1
- package/dist/types.js +28 -0
- package/package.json +1 -1
|
@@ -1,245 +1,402 @@
|
|
|
1
1
|
import { CORE_AGENTS } from "./core-agents.js";
|
|
2
2
|
import { ironLawsMarkdown } from "./iron-laws.js";
|
|
3
|
-
import { failureModesChecklist } from "./review-loop.js";
|
|
4
3
|
const SPECIALIST_LIST = CORE_AGENTS.map((agent) => `- **${agent.id}** (${agent.modes.join(" / ")}) — ${agent.description}`).join("\n");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
const TRIAGE_ASK_EXAMPLE = `\`\`\`
|
|
5
|
+
askUserQuestion(
|
|
6
|
+
prompt: "Triage — Complexity: small/medium (high). Recommended: plan → build → review → ship. Why: 3 modules, ~150 LOC, no auth touch. AC mode: soft. Pick a path.",
|
|
7
|
+
options: [
|
|
8
|
+
"Proceed as recommended",
|
|
9
|
+
"Switch to trivial (inline edit + commit, skip plan/review)",
|
|
10
|
+
"Escalate to large-risky (add brainstormer/architect, strict AC, parallel slices)",
|
|
11
|
+
"Custom (let me edit complexity / acMode / path)"
|
|
12
|
+
],
|
|
13
|
+
multiSelect: false
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# After the user picks, ask the second question:
|
|
17
|
+
|
|
18
|
+
askUserQuestion(
|
|
19
|
+
prompt: "Run mode for this flow?",
|
|
20
|
+
options: [
|
|
21
|
+
"Step (default) — pause after every stage; I type \\"continue\\" to advance",
|
|
22
|
+
"Auto — chain plan → build → review → ship; stop only on block findings or security flag"
|
|
23
|
+
],
|
|
24
|
+
multiSelect: false
|
|
25
|
+
)
|
|
24
26
|
\`\`\``;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
const TRIAGE_FALLBACK_EXAMPLE = `\`\`\`
|
|
28
|
+
Triage
|
|
29
|
+
─ Complexity: small/medium (confidence: high)
|
|
30
|
+
─ Recommended path: plan → build → review → ship
|
|
31
|
+
─ Why: 3 modules touched, ~150 LOC, no auth/payment/data-layer surface.
|
|
32
|
+
─ AC mode: soft
|
|
33
|
+
|
|
34
|
+
[1] Proceed as recommended
|
|
35
|
+
[2] Switch to trivial (inline edit + commit, skip plan/review)
|
|
36
|
+
[3] Escalate to large-risky (add brainstormer/architect, strict AC, parallel slices)
|
|
37
|
+
[4] Custom (let me edit complexity / acMode / path)
|
|
38
|
+
\`\`\`
|
|
39
|
+
|
|
40
|
+
\`\`\`
|
|
41
|
+
Run mode
|
|
42
|
+
[s] Step — pause after every stage (default)
|
|
43
|
+
[a] Auto — chain stages; stop only on block findings or security flag
|
|
44
|
+
\`\`\``;
|
|
45
|
+
const TRIAGE_PERSIST_EXAMPLE = `\`\`\`json
|
|
46
|
+
{
|
|
47
|
+
"triage": {
|
|
48
|
+
"complexity": "small-medium",
|
|
49
|
+
"acMode": "soft",
|
|
50
|
+
"path": ["plan", "build", "review", "ship"],
|
|
51
|
+
"rationale": "3 modules, ~150 LOC, no auth touch.",
|
|
52
|
+
"decidedAt": "2026-05-08T12:34:56Z",
|
|
53
|
+
"userOverrode": false,
|
|
54
|
+
"runMode": "step"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
39
57
|
\`\`\``;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const RESUME_SUMMARY_EXAMPLE = `\`\`\`
|
|
59
|
+
Active flow: approval-page
|
|
60
|
+
─ Stage: build (last touched 2 hours ago)
|
|
61
|
+
─ Triage: small/medium / acMode=soft
|
|
62
|
+
─ Progress: 2 of 3 conditions verified
|
|
63
|
+
─ Last specialist: slice-builder
|
|
64
|
+
─ Open findings: 0
|
|
65
|
+
─ Next step: continue with the third condition (tooltip on hover)
|
|
66
|
+
|
|
67
|
+
[r] Resume — continue from build
|
|
68
|
+
[s] Show — open flows/approval-page/build.md and pause
|
|
69
|
+
[c] Cancel — /cc-cancel and free the slot
|
|
70
|
+
\`\`\``;
|
|
71
|
+
const SUB_AGENT_DISPATCH_EXAMPLE = `\`\`\`
|
|
72
|
+
Dispatch <specialist>
|
|
73
|
+
─ Stage: <plan | build | review | ship>
|
|
74
|
+
─ Slug: <slug>
|
|
75
|
+
─ AC mode: <inline | soft | strict>
|
|
76
|
+
─ Inputs the sub-agent reads:
|
|
77
|
+
- .cclaw/state/flow-state.json
|
|
78
|
+
- .cclaw/flows/<slug>/<stage>.md (if it exists)
|
|
79
|
+
- .cclaw/lib/templates/<stage>.md
|
|
80
|
+
- other artifacts the stage needs (decisions, build, review)
|
|
81
|
+
─ Output contract:
|
|
82
|
+
- write/update .cclaw/flows/<slug>/<stage>.md
|
|
83
|
+
- update flow-state.json (currentStage, lastSpecialist, AC progress)
|
|
84
|
+
- return a slim summary block (≤6 lines) — see below
|
|
85
|
+
─ Forbidden:
|
|
86
|
+
- dispatch other specialists
|
|
87
|
+
- run git commands besides commit-helper.mjs (and only when ac_mode=strict)
|
|
88
|
+
- read or modify files outside the slug's touch surface
|
|
89
|
+
\`\`\``;
|
|
90
|
+
const SUMMARY_RETURN_EXAMPLE = `\`\`\`
|
|
91
|
+
Stage: <stage> ✅ complete | ⏸ paused | ❌ blocked
|
|
92
|
+
Artifact: .cclaw/flows/<slug>/<stage>.md
|
|
93
|
+
What changed: <one sentence; e.g. "5 testable conditions written" or "AC-1 RED+GREEN+REFACTOR committed">
|
|
94
|
+
Open findings: <0 outside review; integer in review>
|
|
95
|
+
Recommended next: <continue | review-pause | fix-only | cancel>
|
|
56
96
|
\`\`\``;
|
|
57
97
|
export const START_COMMAND_BODY = `# /cc — cclaw orchestrator
|
|
58
98
|
|
|
59
|
-
You are the cclaw orchestrator. The
|
|
99
|
+
You are the **cclaw orchestrator**. Your job is to *coordinate*: detect what flow the user wants, classify it, dispatch a sub-agent for each stage, summarise. The actual work — writing the plan, the build, the review, the ship notes — happens in the sub-agent's context, not yours.
|
|
60
100
|
|
|
61
|
-
|
|
101
|
+
User input: ${"`{{TASK}}`"}.
|
|
62
102
|
|
|
63
|
-
|
|
103
|
+
The flow has five hops, in order:
|
|
64
104
|
|
|
65
|
-
1.
|
|
66
|
-
2.
|
|
67
|
-
3.
|
|
105
|
+
1. **Detect** — fresh \`/cc\` or resume?
|
|
106
|
+
2. **Triage** — only on fresh starts; classify and confirm with the user.
|
|
107
|
+
3. **Dispatch** — for each stage on the chosen path, hand off to a sub-agent.
|
|
108
|
+
4. **Pause** — after each stage, summarise and wait for "continue" / "show" / "cancel".
|
|
109
|
+
5. **Ship** — last hop on \`small/medium\` and \`large-risky\` paths; \`trivial\` skips this.
|
|
68
110
|
|
|
69
|
-
|
|
111
|
+
Skipping any hop is a bug; the gates downstream will fail. Read \`triage-gate.md\`, \`flow-resume.md\`, \`tdd-cycle.md\` (active during build), and \`ac-traceability.md\` (active in strict mode) before starting.
|
|
70
112
|
|
|
71
|
-
|
|
113
|
+
## Hop 1 — Detect
|
|
72
114
|
|
|
73
|
-
|
|
115
|
+
Read \`.cclaw/state/flow-state.json\`.
|
|
74
116
|
|
|
75
|
-
|
|
117
|
+
| State | What it means | Action |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| missing or unparseable | first run in this project | initialise empty state, treat as fresh |
|
|
120
|
+
| \`schemaVersion\` < 3 | v8.0/v8.1 state | auto-migrated on read; continue |
|
|
121
|
+
| \`schemaVersion\` < 2 | pre-v8 state | hard stop; surface migration message |
|
|
122
|
+
| \`currentSlug == null\` | no active flow | fresh start |
|
|
123
|
+
| \`currentSlug != null\` and no \`/cc\` arg | resume | run \`flow-resume.md\` summary, ask r/s/c |
|
|
124
|
+
| \`currentSlug != null\` and \`/cc <task>\` arg | collision | run resume summary AND ask r/s/c/n |
|
|
76
125
|
|
|
77
|
-
-
|
|
78
|
-
- Read the YAML frontmatter (use the \`artifact-frontmatter\` skill).
|
|
79
|
-
- Surface to the user: slug, status (\`active\` | \`shipped\` | \`cancelled\`), \`last_specialist\`, AC progress (committed/pending counts), and \`security_flag\`.
|
|
126
|
+
Hard-stop message for pre-v8 state:
|
|
80
127
|
|
|
81
|
-
|
|
128
|
+
> "This project's flow-state.json predates cclaw v8 and cannot be auto-migrated. Choose: (a) finish or abandon the run with the older cclaw; (b) delete \`.cclaw/state/flow-state.json\` and start a new flow; (c) leave it alone and ask me again later."
|
|
82
129
|
|
|
83
|
-
|
|
84
|
-
- **shipped match** → \`refine shipped <slug>\` (creates new plan with \`refines: <old-slug>\`) / \`new unrelated\`.
|
|
85
|
-
- **cancelled match** → \`resume from cancelled\` (move artifacts back to active) / \`new\`.
|
|
86
|
-
- **no match** → continue to Phase 0.
|
|
130
|
+
Do not auto-delete state. Do not hand-edit the JSON.
|
|
87
131
|
|
|
88
|
-
|
|
132
|
+
## Hop 2 — Triage (fresh starts only)
|
|
89
133
|
|
|
90
|
-
|
|
134
|
+
Run the \`triage-gate.md\` skill. **Use the harness's structured question tool** (\`AskUserQuestion\` in Claude Code, \`AskQuestion\` in Cursor, the "ask" content block in OpenCode, \`prompt\` in Codex). Two questions, in order:
|
|
91
135
|
|
|
92
|
-
|
|
136
|
+
${TRIAGE_ASK_EXAMPLE}
|
|
93
137
|
|
|
94
|
-
|
|
138
|
+
The first question's prompt MUST embed the four heuristic facts (complexity + confidence, recommended path, why, AC mode) so the user can decide without reading another block. Keep it under 280 characters; truncate the rationale before truncating the facts.
|
|
95
139
|
|
|
96
|
-
|
|
140
|
+
The second question is skipped on the trivial / inline path (no stages to chain). Default \`runMode\` is \`step\` if the user dismisses the question.
|
|
97
141
|
|
|
98
|
-
|
|
99
|
-
| --- | --- | --- |
|
|
100
|
-
| trivial | typo / format / rename / docs-only edit, ≤1 file, ≤30 lines | edit + commit per AC, no \`plan.md\` |
|
|
101
|
-
| small / medium | new functionality in 1-3 modules, 1-5 AC, no architectural questions | inline plan/build/review/ship |
|
|
102
|
-
| large / abstract / risky | >5 AC, ambiguous prompt, architectural decision, security-sensitive, multi-component | propose specialists |
|
|
142
|
+
If the harness lacks a structured ask facility, fall back to the legacy form:
|
|
103
143
|
|
|
104
|
-
|
|
144
|
+
${TRIAGE_FALLBACK_EXAMPLE}
|
|
105
145
|
|
|
106
|
-
|
|
146
|
+
Once both answers are in, patch \`flow-state.json\`:
|
|
107
147
|
|
|
108
|
-
|
|
148
|
+
${TRIAGE_PERSIST_EXAMPLE}
|
|
109
149
|
|
|
110
|
-
|
|
150
|
+
The triage decision is **immutable** for the lifetime of the flow. If the user wants a different acMode or runMode mid-flight, the path is \`/cc-cancel\` and a fresh \`/cc\` invocation.
|
|
111
151
|
|
|
112
|
-
After the
|
|
152
|
+
After triage, the rest of the orchestrator runs the stages listed in \`triage.path\`, in order. Pause behaviour between stages is controlled by \`triage.runMode\` — see Hop 4.
|
|
113
153
|
|
|
114
|
-
|
|
115
|
-
2. \`architect\` writes \`decisions/<slug>.md\` and adds Architecture subsection to \`plans/<slug>.md\` → user reads → continue with planner?
|
|
116
|
-
3. \`planner\` writes Plan / Phases / Acceptance Criteria / Topology into \`plans/<slug>.md\` → user reads → enter build.
|
|
154
|
+
### Trivial path (acMode: inline)
|
|
117
155
|
|
|
118
|
-
|
|
156
|
+
\`triage.path\` is \`["build"]\`. Skip plan/review/ship. Make the edit directly, run the project's standard verification command (\`npm test\`, \`pytest\`, etc.) once if there is one, commit with plain \`git commit\`. Single message back to the user with the commit SHA. Done.
|
|
119
157
|
|
|
120
|
-
|
|
158
|
+
This is the only path where the orchestrator writes code itself; everything else dispatches a sub-agent.
|
|
121
159
|
|
|
122
|
-
|
|
160
|
+
### Resume — show summary, await user
|
|
161
|
+
|
|
162
|
+
Run the \`flow-resume.md\` skill. Render the resume summary:
|
|
163
|
+
|
|
164
|
+
${RESUME_SUMMARY_EXAMPLE}
|
|
123
165
|
|
|
124
|
-
|
|
166
|
+
Wait for r/s/c (and n on collision). On \`r\`, jump to Hop 3 with the saved \`currentStage\`. On \`s\`, open the artifact and stop. On \`c\`, run \`/cc-cancel\` semantics (move artifacts to \`cancelled/<slug>/\`, reset state).
|
|
125
167
|
|
|
126
|
-
##
|
|
168
|
+
## Hop 3 — Dispatch
|
|
127
169
|
|
|
128
|
-
|
|
170
|
+
For each stage in \`triage.path\` (after \`detect\` and starting from \`currentStage\`):
|
|
129
171
|
|
|
130
|
-
|
|
172
|
+
1. Pick the specialist for the stage (mapping below).
|
|
173
|
+
2. Build the dispatch envelope. Sub-agent gets a small filebag and a tight contract; nothing else.
|
|
174
|
+
3. **Hand off** in a sub-agent. Do not run the specialist's work in your own context.
|
|
175
|
+
4. When the sub-agent returns, read its summary, do not re-read its artifact.
|
|
176
|
+
5. Patch \`flow-state.json\` — set \`currentStage\` to the next stage, update \`lastSpecialist\`, AC progress, etc.
|
|
177
|
+
6. Render the pause summary and wait (Hop 4).
|
|
131
178
|
|
|
132
|
-
|
|
179
|
+
### Stage → specialist mapping
|
|
133
180
|
|
|
134
|
-
|
|
181
|
+
| Stage | Specialist | Mode | Inline allowed? |
|
|
182
|
+
| --- | --- | --- | --- |
|
|
183
|
+
| \`plan\` | \`planner\` | — | yes for trivial; no for any path that includes plan |
|
|
184
|
+
| \`build\` | \`slice-builder\` | \`build\` (or \`fix-only\` after a review with block findings) | yes for trivial only |
|
|
185
|
+
| \`review\` | \`reviewer\` | \`code\` (default) or \`integration\` (after parallel-build) | no, always sub-agent |
|
|
186
|
+
| \`ship\` | \`reviewer\` (mode=release) + \`security-reviewer\` if \`security_flag\` | parallel fan-out, then merge | no, always sub-agent |
|
|
187
|
+
| \`discovery\` (only on large-risky path) | \`brainstormer\` then \`architect\` then \`planner\` | sequential, checkpoint between each | no, always sub-agent |
|
|
135
188
|
|
|
136
|
-
|
|
189
|
+
### Dispatch envelope (mandatory)
|
|
137
190
|
|
|
138
|
-
|
|
191
|
+
When you announce a dispatch in your message to the user, use exactly this shape so the harness picks it up consistently:
|
|
139
192
|
|
|
140
|
-
|
|
193
|
+
${SUB_AGENT_DISPATCH_EXAMPLE}
|
|
141
194
|
|
|
142
|
-
|
|
143
|
-
2. **RED** — write a failing test that encodes the AC's verification line. The test must fail for the **right reason** (the assertion that encodes the AC, not a syntax/import error). **Test file is named after the unit under test, never after the AC id** (\`tests/unit/permissions.test.ts\`, not \`AC-1.test.ts\`). Stage **test files only**, then commit:
|
|
195
|
+
The sub-agent reads the listed inputs, writes the listed output, and returns the slim summary block. It does **not**:
|
|
144
196
|
|
|
145
|
-
|
|
197
|
+
- dispatch other specialists (composition is your job, not theirs);
|
|
198
|
+
- run \`git commit\` directly (only \`commit-helper.mjs\` in strict mode; plain \`git commit\` in inline / soft mode for a feature-level cycle);
|
|
199
|
+
- modify files outside the slug's touch surface.
|
|
146
200
|
|
|
147
|
-
|
|
148
|
-
4. **REFACTOR** (mandatory) — either apply a real refactor and commit with \`--phase=refactor\`, or explicitly skip with \`--phase=refactor --skipped --message="refactor(AC-N) skipped: <reason>"\`. Silence fails the gate.
|
|
149
|
-
5. Append the row to \`builds/<slug>.md\` with all six columns (Discovery, RED proof, GREEN evidence, REFACTOR notes, commits) filled.
|
|
201
|
+
If the harness does not support sub-agent dispatch, run the specialist inline in a fresh context (clear the prior conversation if you can). Record the fallback in the artifact's frontmatter (\`subAgentDispatch: inline-fallback\`). This is not an error.
|
|
150
202
|
|
|
151
|
-
|
|
203
|
+
### Slim summary (sub-agent → orchestrator)
|
|
152
204
|
|
|
153
|
-
|
|
205
|
+
Every sub-agent returns at most six lines:
|
|
154
206
|
|
|
155
|
-
|
|
207
|
+
${SUMMARY_RETURN_EXAMPLE}
|
|
156
208
|
|
|
157
|
-
|
|
209
|
+
The orchestrator reads only this. The full artifact stays in \`.cclaw/flows/<slug>/<stage>.md\` and is the source of truth for the next stage's sub-agent (which re-reads it from disk, not from your context).
|
|
158
210
|
|
|
159
|
-
|
|
211
|
+
### Stage details
|
|
160
212
|
|
|
161
|
-
|
|
213
|
+
#### plan
|
|
162
214
|
|
|
163
|
-
|
|
215
|
+
- Specialist: \`planner\`.
|
|
216
|
+
- Inputs: triage decision, the user's original prompt, \`.cclaw/lib/templates/plan.md\`, and any matching shipped slug if refining.
|
|
217
|
+
- Output: \`.cclaw/flows/<slug>/plan.md\` with \`status: active\`.
|
|
218
|
+
- Soft-mode plan body: bullet list of testable conditions, no AC IDs, no commit-trace block.
|
|
219
|
+
- Strict-mode plan body: AC table with IDs, verification lines, touch surfaces, parallel-build topology if it applies.
|
|
220
|
+
- Slim summary: condition / AC count, max touch surface, parallel-build flag, recommended-next.
|
|
164
221
|
|
|
165
|
-
|
|
166
|
-
2. Dispatch a \`slice-builder\` sub-agent rooted at the worktree path. Pass the slice id, the AC ids it owns, the touchSurface, and the worktree cwd.
|
|
167
|
-
3. Each slice-builder runs the full RED → GREEN → REFACTOR cycle for every AC it owns, sequentially inside its slice.
|
|
222
|
+
#### build
|
|
168
223
|
|
|
169
|
-
|
|
224
|
+
- Specialist: \`slice-builder\`.
|
|
225
|
+
- Inputs: \`.cclaw/flows/<slug>/plan.md\`, \`.cclaw/lib/templates/build.md\`, \`.cclaw/lib/skills/tdd-cycle.md\`.
|
|
226
|
+
- Output: \`.cclaw/flows/<slug>/build.md\` with TDD evidence at the granularity dictated by \`acMode\`.
|
|
227
|
+
- Soft mode: one TDD cycle for the whole feature; tests under \`tests/\` mirroring the production module path; plain \`git commit\`. Sequential, single dispatch, no worktrees.
|
|
228
|
+
- Strict mode, sequential: full RED → GREEN → REFACTOR per AC, every commit through \`commit-helper.mjs\`. Single \`slice-builder\` dispatch in the main working tree.
|
|
229
|
+
- Strict mode, parallel: see "Parallel-build fan-out" below — only when planner declared \`topology: parallel-build\` AND ≥4 AC AND ≥2 disjoint touchSurface clusters.
|
|
230
|
+
- Inline mode: not dispatched here — handled in the trivial path of Hop 2.
|
|
231
|
+
- Slim summary: AC committed (strict) or conditions verified (soft), suite-status (passed / failed), open follow-ups.
|
|
170
232
|
|
|
171
|
-
|
|
233
|
+
##### Parallel-build fan-out (strict mode + planner topology=parallel-build only)
|
|
172
234
|
|
|
173
|
-
|
|
235
|
+
When the planner artifact declares \`topology: parallel-build\` with ≥2 slices and \`acMode == strict\`, the orchestrator fans out one \`slice-builder\` sub-agent per slice, **capped at 5**, each in its own \`git worktree\`. This is the only fan-out cclaw uses outside of \`ship\`.
|
|
236
|
+
|
|
237
|
+
\`\`\`text
|
|
238
|
+
flows/<slug>/plan.md
|
|
239
|
+
topology: parallel-build
|
|
240
|
+
slices: [s-1, s-2, s-3] (max 5)
|
|
241
|
+
│
|
|
242
|
+
▼
|
|
243
|
+
git worktree add .cclaw/worktrees/<slug>-s-1 -b cclaw/<slug>/s-1
|
|
244
|
+
git worktree add .cclaw/worktrees/<slug>-s-2 -b cclaw/<slug>/s-2
|
|
245
|
+
git worktree add .cclaw/worktrees/<slug>-s-3 -b cclaw/<slug>/s-3
|
|
246
|
+
│
|
|
247
|
+
┌───────────────────┼───────────────────┐
|
|
248
|
+
▼ ▼ ▼
|
|
249
|
+
slice-builder slice-builder slice-builder
|
|
250
|
+
(s-1; AC-1, AC-2) (s-2; AC-3) (s-3; AC-4, AC-5)
|
|
251
|
+
cwd: …/<slug>-s-1 cwd: …/<slug>-s-2 cwd: …/<slug>-s-3
|
|
252
|
+
RED→GREEN→REFACTOR RED→GREEN→REFACTOR RED→GREEN→REFACTOR
|
|
253
|
+
per AC, in slice per AC, in slice per AC, in slice
|
|
254
|
+
│ │ │
|
|
255
|
+
└───────────────────┼───────────────────┘
|
|
256
|
+
▼
|
|
257
|
+
reviewer (mode=integration)
|
|
258
|
+
reads each branch, checks
|
|
259
|
+
cross-slice conflicts, AC↔commit
|
|
260
|
+
chain across the wave
|
|
261
|
+
│
|
|
262
|
+
▼
|
|
263
|
+
merge cclaw/<slug>/s-1 → main, then s-2, then s-3
|
|
264
|
+
(fast-forward when wave was clean; otherwise stop and ask)
|
|
265
|
+
│
|
|
266
|
+
▼
|
|
267
|
+
git worktree remove .cclaw/worktrees/<slug>-s-N (per slice)
|
|
268
|
+
\`\`\`
|
|
269
|
+
|
|
270
|
+
Dispatch envelope per slice:
|
|
271
|
+
|
|
272
|
+
\`\`\`
|
|
273
|
+
Dispatch slice-builder
|
|
274
|
+
─ Stage: build
|
|
275
|
+
─ Slug: <slug>
|
|
276
|
+
─ Slice: s-N (acIds: [AC-N, AC-N+1])
|
|
277
|
+
─ Working tree: .cclaw/worktrees/<slug>-s-N
|
|
278
|
+
─ Branch: cclaw/<slug>/s-N
|
|
279
|
+
─ AC mode: strict
|
|
280
|
+
─ Touch surface (only paths this slice may modify): [<paths from plan>]
|
|
281
|
+
─ Output: .cclaw/flows/<slug>/build.md (append, marked with slice id)
|
|
282
|
+
─ Forbidden: read or modify any path outside touch surface; read another slice's worktree mid-flight; merge or rebase
|
|
283
|
+
\`\`\`
|
|
174
284
|
|
|
175
|
-
|
|
285
|
+
After every slice-builder returns:
|
|
176
286
|
|
|
177
|
-
|
|
178
|
-
|
|
287
|
+
1. Patch \`flow-state.json\` with the per-slice progress.
|
|
288
|
+
2. When **every** slice has reported, dispatch \`reviewer\` mode=\`integration\` (one sub-agent, reads from each branch).
|
|
289
|
+
3. On clear integration review, merge slices into main one at a time. On block, dispatch \`slice-builder\` mode=\`fix-only\` against the cited file:line refs, then re-run the integration reviewer.
|
|
290
|
+
4. Worktree cleanup happens after merge; the cclaw branches stay until ship.
|
|
179
291
|
|
|
180
|
-
|
|
292
|
+
Hard rules:
|
|
181
293
|
|
|
182
|
-
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
294
|
+
- **More than 5 parallel slices is forbidden.** If planner produced >5, the planner must merge thinner slices into fatter ones before build; do not generate "wave 2".
|
|
295
|
+
- Slice-builders never read each other's worktrees mid-flight. A slice that detects a conflict with another stops and raises an integration finding.
|
|
296
|
+
- If the harness lacks sub-agent dispatch or worktree creation fails (non-git repo, permissions), parallel-build degrades silently to inline-sequential. Record the fallback in \`flows/<slug>/build.md\` frontmatter (\`subAgentDispatch: inline-fallback\`) — not an error.
|
|
297
|
+
- \`auto\` runMode does **not** affect the integration-reviewer ask: a parallel wave that produces a block finding always asks the user before fix-only.
|
|
185
298
|
|
|
186
|
-
|
|
299
|
+
#### review
|
|
187
300
|
|
|
188
|
-
|
|
301
|
+
- Specialist: \`reviewer\` (mode = \`code\` for sequential build, \`integration\` for parallel-build).
|
|
302
|
+
- Inputs: \`.cclaw/flows/<slug>/plan.md\`, \`.cclaw/flows/<slug>/build.md\`, the diff since plan.
|
|
303
|
+
- Output: \`.cclaw/flows/<slug>/review.md\` with the **Concern Ledger** (always; same shape regardless of acMode).
|
|
304
|
+
- The five Failure Modes checklist runs every iteration.
|
|
305
|
+
- Hard cap: 5 review/fix iterations. After the 5th iteration without convergence, write \`status: cap-reached\` and surface to user.
|
|
306
|
+
- Slim summary: decision (clear / warn / block / cap-reached), open findings count, recommended next (continue / fix-only / cancel).
|
|
189
307
|
|
|
190
|
-
|
|
308
|
+
#### ship
|
|
191
309
|
|
|
192
|
-
|
|
310
|
+
- Specialist: \`reviewer\` mode=\`release\` AND \`security-reviewer\` mode=\`threat-model\` if \`security_flag\` is true.
|
|
311
|
+
- Pattern: **parallel fan-out + merge** (the only fan-out cclaw uses). Dispatch both specialists in the same message; merge their summaries in your context.
|
|
312
|
+
- Inputs: \`.cclaw/flows/<slug>/plan.md\`, build.md, review.md.
|
|
313
|
+
- Output: \`.cclaw/flows/<slug>/ship.md\` with the go/no-go decision, AC↔commit map (strict) or condition checklist (soft), release notes, and rollback plan.
|
|
314
|
+
- After ship, run the compound learning gate (Hop 5).
|
|
193
315
|
|
|
194
|
-
|
|
316
|
+
### Discovery (large-risky only)
|
|
195
317
|
|
|
196
|
-
|
|
318
|
+
If \`triage.path\` starts with \`discovery\`, the orchestrator dispatches three sub-agents sequentially with a checkpoint after each:
|
|
197
319
|
|
|
198
|
-
|
|
320
|
+
1. \`brainstormer\` writes Frame + (optional) Approaches + Selected direction into \`flows/<slug>/plan.md\` (in the "Frame" section). User reads, says continue.
|
|
321
|
+
2. \`architect\` writes \`flows/<slug>/decisions.md\` with the decision records. User reads, says continue.
|
|
322
|
+
3. \`planner\` writes the rest of the plan. User reads, says continue. The orchestrator then proceeds to the build dispatch.
|
|
199
323
|
|
|
200
|
-
|
|
324
|
+
Each step is a separate dispatch + pause + slim summary. The user can stop after any checkpoint and ship what is in the plan.
|
|
201
325
|
|
|
202
|
-
|
|
326
|
+
## Hop 4 — Pause and resume
|
|
203
327
|
|
|
204
|
-
|
|
328
|
+
Pause behaviour depends on \`triage.runMode\` (default \`step\`).
|
|
205
329
|
|
|
206
|
-
|
|
330
|
+
### \`step\` mode (default; safer; recommended for \`strict\` work)
|
|
331
|
+
|
|
332
|
+
After every dispatch returns:
|
|
333
|
+
|
|
334
|
+
1. Render the slim summary back to the user.
|
|
335
|
+
2. State the next stage in plain language: "Plan is ready (5 testable conditions). Continue to build?"
|
|
336
|
+
3. Wait. Do **not** auto-advance. The user types \`continue\`, \`show\`, \`fix-only\`, or \`cancel\`.
|
|
337
|
+
4. On \`continue\` → next stage in \`triage.path\`. On \`show\` → open the artifact and stop. On \`fix-only\` → re-dispatch slice-builder with mode=fix-only and the cited findings. On \`cancel\` → \`/cc-cancel\`.
|
|
338
|
+
|
|
339
|
+
### \`auto\` mode (autopilot; faster; recommended for \`inline\` / \`soft\` work)
|
|
340
|
+
|
|
341
|
+
After every dispatch returns:
|
|
342
|
+
|
|
343
|
+
1. Render the slim summary back to the user (one block, no prompt).
|
|
344
|
+
2. **Immediately** dispatch the next stage in \`triage.path\` — no waiting, no question.
|
|
345
|
+
3. Stop unconditionally only on these hard gates (autopilot **always** asks here):
|
|
346
|
+
- \`reviewer\` returned \`block\` decision (open findings) → render the findings, ask \`continue with fix-only\` / \`cancel\`.
|
|
347
|
+
- \`security-reviewer\` raised any finding → ask before proceeding.
|
|
348
|
+
- \`reviewer\` returned \`cap-reached\` (5 iterations without convergence) → ask.
|
|
349
|
+
- About to run \`ship\` (last stage in \`triage.path\`) → ask \`ship now?\` once, then proceed on confirmation. Ship is the only stage that always confirms in autopilot.
|
|
350
|
+
|
|
351
|
+
Auto mode never silently skips a hard gate; it just removes the cosmetic pause between green stages. The user typed \`auto\` once during triage and meant it.
|
|
352
|
+
|
|
353
|
+
### Common rules for both modes
|
|
354
|
+
|
|
355
|
+
Resume from a fresh session works because everything is on disk: \`flow-state.json\` has \`currentStage\`, \`triage\` (with \`runMode\`), \`flows/<slug>/*.md\` carries the artifacts. The next \`/cc\` invocation enters Hop 1 → detect → resume summary → continue from \`currentStage\` with the saved runMode.
|
|
356
|
+
|
|
357
|
+
Resuming a paused \`auto\` flow re-enters auto mode silently. Resuming a paused \`step\` flow renders the slim summary again and waits for \`continue\`.
|
|
358
|
+
|
|
359
|
+
## Hop 5 — Compound (automatic)
|
|
360
|
+
|
|
361
|
+
After ship, check the compound quality gate:
|
|
207
362
|
|
|
208
363
|
- a non-trivial decision was recorded by \`architect\` or \`planner\`;
|
|
209
364
|
- review needed three or more iterations;
|
|
210
365
|
- a security review ran or \`security_flag\` is true;
|
|
211
366
|
- the user explicitly asked to capture (\`/cc <task> --capture-learnings\`).
|
|
212
367
|
|
|
213
|
-
If
|
|
368
|
+
If any signal fires, dispatch the learnings sub-agent (small one-shot): write \`flows/<slug>/learnings.md\` from \`.cclaw/lib/templates/learnings.md\`, append a line to \`.cclaw/knowledge.jsonl\`. Otherwise skip silently.
|
|
214
369
|
|
|
215
|
-
|
|
216
|
-
2. Append one line to \`.cclaw/knowledge.jsonl\`:
|
|
370
|
+
After ship + compound, move every \`<stage>.md\` from \`flows/<slug>/\` into \`.cclaw/flows/shipped/<slug>/\`. Write \`shipped/<slug>/manifest.md\`. Reset \`flow-state.json\` to fresh-state defaults.
|
|
217
371
|
|
|
218
|
-
|
|
219
|
-
{"slug":"approval-page","ship_commit":"abc1234","shipped_at":"2026-05-07T18:30:00Z","signals":{"hasArchitectDecision":true,"reviewIterations":2,"securityFlag":false,"userRequestedCapture":false}}
|
|
220
|
-
\`\`\`
|
|
372
|
+
## Always-ask rules
|
|
221
373
|
|
|
222
|
-
|
|
374
|
+
- Always run the triage gate on a fresh \`/cc\`. Never silently pick a path. Use the harness's structured question tool, not a printed code block.
|
|
375
|
+
- In \`step\` mode, always pause after every stage. Never auto-advance.
|
|
376
|
+
- In \`auto\` mode, never auto-advance past a hard gate (block / cap-reached / security finding / ship). The user opted into chaining green stages, not chaining decisions.
|
|
377
|
+
- Always ask before \`git push\` or PR creation. Commit-helper auto-commits in strict mode; everything past commit is opt-in.
|
|
378
|
+
- Always ask before deleting active artifacts (\`/cc-cancel\` is the supported way; do not \`rm\` artifacts directly).
|
|
379
|
+
- Always show the slim summary back to the user; do not summarise from your own memory of the dispatch.
|
|
223
380
|
|
|
224
|
-
|
|
381
|
+
## Available specialists
|
|
225
382
|
|
|
226
|
-
|
|
383
|
+
${SPECIALIST_LIST}
|
|
227
384
|
|
|
228
|
-
-
|
|
229
|
-
- Always ask before \`git push\` or PR creation.
|
|
230
|
-
- Always ask before deleting active artifacts (\`/cc-cancel\` is the supported way; do not \`rm\` artifacts directly).
|
|
231
|
-
- Always ask before resuming a refinement that crosses the trivial / medium / large boundary.
|
|
385
|
+
\`reviewer\` is multi-mode (\`code\` / \`text-review\` / \`integration\` / \`release\` / \`adversarial\`). \`security-reviewer\` is separate; invoke it when the diff or task touches authn / authz / secrets / supply chain / data exposure.
|
|
232
386
|
|
|
233
387
|
## Skills attached
|
|
234
388
|
|
|
235
|
-
|
|
389
|
+
These skills auto-trigger during \`/cc\`. Do not re-explain them; obey them.
|
|
236
390
|
|
|
237
|
-
- **conversation-language** — always-on; reply in the user's language but never translate \`AC-N\`, \`D-N\`, \`F-N\`, slugs, paths, frontmatter keys, or hook output.
|
|
391
|
+
- **conversation-language** — always-on; reply in the user's language but never translate \`AC-N\`, \`D-N\`, \`F-N\`, slugs, paths, frontmatter keys, mode names, or hook output.
|
|
392
|
+
- **anti-slop** — always-on for any code-modifying step; bans redundant verification and environment shims.
|
|
393
|
+
- **triage-gate** — Hop 2 of every fresh \`/cc\`.
|
|
394
|
+
- **flow-resume** — when \`/cc\` is invoked with no task or with an active flow.
|
|
238
395
|
- **plan-authoring** — on every edit to \`.cclaw/flows/<slug>/plan.md\`.
|
|
239
|
-
- **ac-traceability** — before every commit
|
|
240
|
-
- **tdd-cycle** — always-on while stage=build;
|
|
396
|
+
- **ac-traceability** — strict mode only; before every commit.
|
|
397
|
+
- **tdd-cycle** — always-on while stage=build; granularity scales with acMode.
|
|
241
398
|
- **refinement** — when an existing plan match is detected.
|
|
242
|
-
- **parallel-build** —
|
|
399
|
+
- **parallel-build** — strict mode + planner topology=parallel-build; enforces 5-slice cap and worktree dispatch.
|
|
243
400
|
- **security-review** — when the diff touches sensitive surfaces.
|
|
244
401
|
- **review-loop** — wraps every reviewer / security-reviewer invocation; runs the Concern Ledger + convergence detector.
|
|
245
402
|
|