cclaw-cli 0.3.0 → 0.4.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.
@@ -1,8 +1,7 @@
1
- import { nextCclawCommand, stageSchema } from "./stage-schema.js";
1
+ import { stageSchema } from "./stage-schema.js";
2
2
  import { stageSkillFolder } from "./skills.js";
3
3
  export function commandContract(stage) {
4
4
  const schema = stageSchema(stage);
5
- const nextCommand = nextCclawCommand(stage);
6
5
  const skillPath = `.cclaw/skills/${stageSkillFolder(stage)}/SKILL.md`;
7
6
  const reads = schema.crossStageTrace.readsFrom;
8
7
  const readsLine = reads.length > 0 ? reads.join(", ") : "(first stage)";
@@ -28,7 +27,7 @@ ${schema.hardGate}
28
27
  ## In / Out
29
28
  - **Reads:** ${readsLine}
30
29
  - **Writes:** \`.cclaw/artifacts/${schema.artifactFile}\` (canonical run copy: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`)
31
- - **Next:** ${nextCommand}
30
+ - **Next:** \`/cc-next\` (updates flow-state and loads the next stage)
32
31
 
33
32
  ## Context Hydration (mandatory before stage work)
34
33
  1. Read \`.cclaw/state/flow-state.json\` and capture \`activeRunId\`.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Command contract for /cc-next - agent reads flow state, evaluates gates, advances or reports blockers.
3
- * Wire into install (write to `.cclaw/commands/next.md` + harness shim `cc-next.md`) in a follow-up; not invoked by CLI.
2
+ * Command contract for /cc-next the primary progression command.
3
+ * Reads flow-state, starts the current stage if unfinished, or advances if all gates pass.
4
4
  */
5
5
  export declare function nextCommandContract(): string;
6
6
  /**
7
- * Skill body for /cc-next - flow logic and continue semantics.
7
+ * Skill body for /cc-next the primary flow progression command.
8
8
  */
9
9
  export declare function nextCommandSkillMarkdown(): string;
@@ -6,15 +6,12 @@ const NEXT_SKILL_NAME = "flow-next-step";
6
6
  function flowStatePath() {
7
7
  return `${RUNTIME_ROOT}/state/flow-state.json`;
8
8
  }
9
- function configPathLine() {
10
- return `${RUNTIME_ROOT}/config.yaml`;
11
- }
12
9
  function delegationLogPathLine() {
13
10
  return `${RUNTIME_ROOT}/runs/<activeRunId>/delegation-log.json`;
14
11
  }
15
12
  /**
16
- * Command contract for /cc-next - agent reads flow state, evaluates gates, advances or reports blockers.
17
- * Wire into install (write to `.cclaw/commands/next.md` + harness shim `cc-next.md`) in a follow-up; not invoked by CLI.
13
+ * Command contract for /cc-next the primary progression command.
14
+ * Reads flow-state, starts the current stage if unfinished, or advances if all gates pass.
18
15
  */
19
16
  export function nextCommandContract() {
20
17
  const flowPath = flowStatePath();
@@ -24,115 +21,133 @@ export function nextCommandContract() {
24
21
 
25
22
  ## Purpose
26
23
 
27
- Single **continue** command: read flow state, verify **current stage** gate satisfaction, verify any **mandatory delegations**, then either **hand off to the next stage** (load its skill and proceed) or **list blocking gates / pauses** so the user knows what to finish first.
24
+ **The primary progression command.** Read flow state, determine what to do:
25
+
26
+ - **Current stage not started / in progress** → load its skill and execute it.
27
+ - **Current stage complete (all gates passed)** → advance \`currentStage\` and load the next skill.
28
+ - **Flow complete** → report done.
29
+
30
+ This is the only command the user needs to drive the entire flow. Individual \`/cc-<stage>\` commands are shortcuts for jumping to a specific stage.
28
31
 
29
32
  ## HARD-GATE
30
33
 
31
34
  - **Do not** invent gate completion: use only \`${flowPath}\` plus observable evidence in repo artifacts.
32
- - **Do not** skip stages: the only valid advance is from \`currentStage\` to that stage's configured successor in the flow schema (same order as \`/cc-brainstorm\` -> \`/cc-ship\`).
33
- - **Do not** treat \`/cc-next\`, \`autoAdvance\`, or user impatience as permission to bypass \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, explicit approval pauses, or mandatory delegation requirements from the current stage skill.
34
- - If the flow is already at the terminal stage with all ship gates satisfied, **report completion** instead of advancing.
35
+ - **Do not** skip stages: advance only from \`currentStage\` to its configured successor.
36
+ - If the flow is at the terminal stage with all ship gates satisfied, **report completion**.
35
37
 
36
38
  ## Algorithm (mandatory)
37
39
 
38
- 1. Read **\`${flowPath}\`** (create parent dirs only if you are also initializing a broken install - otherwise treat missing file as **BLOCKED**: state missing).
39
- 2. Parse JSON. Capture \`currentStage\`, \`activeRunId\` (must be present), and the current run-scoped context.
40
- 3. Load **\`${skillRel}\`** - canonical semantics for gate evaluation and continuation live there.
41
- 4. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema (authoritative list of gate ids).
42
- 5. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state (if missing, treat all gates as unmet).
43
- 6. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
44
- 7. **Unmet** = gates in \`G\` that are not satisfied **or** appear in \`catalog.blocked\`.
45
- 8. Let \`M\` = \`mandatoryDelegations\` for **\`currentStage\`** from the stage schema.
46
- 9. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. A mandatory delegation counts only if that agent is recorded as **completed** or explicitly **waived** by the user. Missing or in-progress entries are blocking.
47
- 10. Respect explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval"). \`/cc-next\` is a convenience command, not authorization to bypass confirmation gates.
48
- 11. If **any** unmet gates, blocking pause rules, or missing mandatory delegations remain: print a short **Blocking gates** list (id + human description from schema \`requiredGates\`, plus any missing delegation or approval requirement). Do **not** invoke the next stage skill yet.
49
- 12. If **all** required gates and mandatory delegations are satisfied:
50
- - If current stage's \`next\` is **\`done\`**: report **flow complete**; stop.
51
- - Otherwise let \`nextStage\` be the schema successor of \`currentStage\`. Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** using the real \`skillFolder\` and stage id from the schema for \`nextStage\`, then run that stage's protocol in-agent (equivalent to invoking \`/cc-\` + \`nextStage\`) without asking the user to re-type the slash-command. While doing so, obey the current and next stage skills' explicit pause rules; if either skill says to pause, stop and report readiness instead of auto-continuing through that gate.
40
+ 1. Read **\`${flowPath}\`**. If missing **BLOCKED** (state missing).
41
+ 2. Parse JSON. Capture \`currentStage\`, \`activeRunId\`, and \`stageGateCatalog[currentStage]\`.
42
+ 3. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema.
43
+ 4. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state.
44
+ 5. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
45
+ 6. Let \`M\` = \`mandatoryDelegations\` for \`currentStage\`.
46
+ 7. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. Treat as satisfied only if the agent is **completed** or **waived**.
47
+
48
+ ### Path A: Current stage is NOT complete (any gate unmet or delegation missing)
49
+
50
+ Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<currentStage>.md\`** for the current stage.
51
+ → Execute that stage's protocol. The stage skill handles the full interaction including STOP points and gate tracking.
52
+ When the stage completes, the Stage Completion Protocol in the skill updates \`flow-state.json\` automatically.
53
+
54
+ ### Path B: Current stage IS complete (all gates passed, all delegations satisfied)
55
+
56
+ → If current stage's \`next\` is **\`done\`**: report **"Flow complete. All stages finished."** and stop.
57
+ → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** for the successor stage. Execute that stage's protocol.
58
+
59
+ ## Resume Semantics
60
+
61
+ \`/cc-next\` in a **new session** = resume from where you left off:
62
+ - Flow-state records \`currentStage\` and which gates have passed.
63
+ - The stage skill reads upstream artifacts and picks up context.
64
+ - No special resume command needed — \`/cc-next\` IS the resume command.
52
65
 
53
66
  ## Primary skill
54
67
 
55
- **${skillRel}** - full protocol, gate/flow tie-in, and interaction with \`autoAdvance\` in **\`${configPathLine()}\`**.
68
+ **${skillRel}** full protocol and stage table.
56
69
  `;
57
70
  }
58
71
  /**
59
- * Skill body for /cc-next - flow logic and continue semantics.
72
+ * Skill body for /cc-next the primary flow progression command.
60
73
  */
61
74
  export function nextCommandSkillMarkdown() {
62
75
  const flowPath = flowStatePath();
63
- const cfgPath = configPathLine();
64
76
  const delegationPath = delegationLogPathLine();
65
77
  const stageRows = ["brainstorm", "scope", "design", "spec", "plan", "test", "build", "review", "ship"]
66
78
  .map((stage) => {
67
79
  const schema = stageSchema(stage);
68
- const next = schema.next === "done" ? "(terminal)" : `/cc-${schema.next}`;
80
+ const next = schema.next === "done" ? "(terminal)" : schema.next;
69
81
  const skillMd = `${RUNTIME_ROOT}/skills/${stageSkillFolder(stage)}/SKILL.md`;
70
- return `| \`${stage}\` | ${next} | \`${skillMd}\` |`;
82
+ return `| \`${stage}\` | \`${next}\` | \`${skillMd}\` |`;
71
83
  })
72
84
  .join("\n");
73
85
  return `---
74
86
  name: ${NEXT_SKILL_NAME}
75
- description: "Evaluate current stage gates from flow state; advance to the next /cc-* stage or list blockers."
87
+ description: "The primary progression command. Reads flow state, starts/resumes the current stage or advances to the next one."
76
88
  ---
77
89
 
78
- # Flow: /cc-next (gate-aware continuation)
90
+ # /cc-next Flow Progression
91
+
92
+ ## Overview
79
93
 
80
- ## When to use
94
+ \`/cc-next\` is **the only command you need** to drive the entire cclaw flow.
81
95
 
82
- - You want **one command** instead of manually typing the next \`/cc-*\` after a stage.
83
- - You are unsure whether **current stage gates** are satisfied.
84
- - The user said **continue**, **next**, or **pick up where we left off**.
96
+ **How it works:**
97
+ 1. Reads \`flow-state.json\` to find \`currentStage\`
98
+ 2. Checks if all gates for that stage are satisfied
99
+ 3. If **not** → loads the stage skill and starts/resumes execution
100
+ 4. If **yes** → advances to the next stage and loads its skill
101
+
102
+ **Resume:** \`/cc-next\` in a new session picks up from where \`flow-state.json\` says you are.
85
103
 
86
104
  ## HARD-GATE
87
105
 
88
- Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (paths, excerpts) consistent with \`requiredGates\` for \`currentStage\`. If evidence is missing, list the gate as **unmet**. Also treat missing mandatory delegations or unresolved confirmation pauses as blockers even if someone claims the stage is "basically done."
106
+ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (paths, excerpts). If evidence is missing, list the gate as **unmet**. Do **not** skip stages.
107
+
108
+ ## Algorithm
89
109
 
90
- ## Read flow state
110
+ ### Step 1: Read state
91
111
 
92
112
  1. Open **\`${flowPath}\`**.
93
- 2. Record \`currentStage\`, \`activeRunId\`, and \`stageGateCatalog[currentStage]\` (\`required\`, \`passed\`, \`blocked\` arrays).
94
- 3. If the file is missing or invalid JSON -> **BLOCKED** (report; do not advance).
95
- 4. Resolve the current delegation ledger at **\`${delegationPath}\`** using the recorded \`activeRunId\`.
113
+ 2. Record \`currentStage\`, \`activeRunId\`, \`stageGateCatalog[currentStage]\`.
114
+ 3. If the file is missing or invalid JSON **BLOCKED** (report and stop).
96
115
 
97
- ## Evaluate gates for \`currentStage\`
116
+ ### Step 2: Evaluate gates
98
117
 
99
- For each gate id in the stage schema's \`requiredGates\` for \`currentStage\`:
118
+ For each gate id in \`requiredGates\` for \`currentStage\`:
119
+ - **Met** if in \`catalog.passed\` and not in \`catalog.blocked\`.
120
+ - **Unmet** otherwise.
100
121
 
101
- - **Met** if the id is in \`catalog.passed\` and **not** in \`catalog.blocked\`.
102
- - **Blocked** if the id is in \`catalog.blocked\` (always list these first).
103
- - **Unmet** if not met (explain what evidence or artifact action is still needed, using the gate's description from the schema).
122
+ Check \`mandatoryDelegations\` via **\`${delegationPath}\`** satisfied only if **completed** or **waived**.
104
123
 
105
- Also evaluate stage-level transition blockers:
124
+ ### Step 3: Act
106
125
 
107
- - Read \`mandatoryDelegations\` from the current stage schema.
108
- - If any mandatory agent is required, inspect **\`${delegationPath}\`**. Treat that agent as satisfied only if the ledger records it as **completed** or explicitly **waived** by the user.
109
- - Treat explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval") as authoritative. **/cc-next** does not override them.
126
+ **Path A stage NOT complete (any gate unmet):**
110
127
 
111
- If **any** gate is unmet or blocked, or any mandatory delegation / confirmation pause remains unresolved -> output **Blocking gates** (bulleted: \`id\` or agent name - reason). **Stop** without loading the next stage skill.
128
+ Load the current stage's skill and command contract:
129
+ - \`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`
130
+ - \`${RUNTIME_ROOT}/commands/<currentStage>.md\`
112
131
 
113
- ## Advance (all gates satisfied)
132
+ Execute the stage protocol. The stage skill handles interaction, STOP points, gate tracking, and the Stage Completion Protocol (updates \`flow-state.json\` when done).
114
133
 
115
- 1. Look up \`currentStage\` in the transition table below. If next is **terminal**, print **Flow complete** and stop.
116
- 2. Let \`nextStage\` be the \`To\` stage. Read **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** and **\`${RUNTIME_ROOT}/skills/<folder>/SKILL.md\`** for that row.
117
- 3. **Continue semantics:** execute that stage's protocol **in the same session** as a natural handoff (you are now "in" \`nextStage\` until it completes or blocks).
118
- 4. Honor **\`${cfgPath}\`**: \`autoAdvance\` only applies where the stage skill allows it. Explicit pause / confirmation rules in either the current or next stage always win.
119
- 5. If the next stage reaches a confirmation gate or a "do not auto-advance" boundary, stop there and report readiness instead of claiming automatic advancement through that gate.
134
+ **Path B stage IS complete (all gates met, all delegations done):**
120
135
 
121
- ## Stage order (reference)
136
+ If \`next\` is \`done\` → report **"Flow complete. All stages finished."** and stop.
122
137
 
123
- | Stage | Next command | Skill path |
124
- |---|---|---|
125
- ${stageRows}
138
+ Otherwise load the next stage's skill and command contract, begin execution.
126
139
 
127
- ## Relation to per-stage skills
140
+ ## Stage order
128
141
 
129
- Wave auto-execute (\`waveExecutionAllowed\`) applies only to **test** and **build** skills after plan approval - see those SKILL.md files. **/cc-next** does not replace RED/GREEN/REFACTOR discipline; it only removes friction **between** stages.
142
+ | Stage | Next | Skill path |
143
+ |---|---|---|
144
+ ${stageRows}
130
145
 
131
146
  ## Anti-patterns
132
147
 
133
148
  - Advancing when \`blocked\` is non-empty for the current stage.
134
149
  - Treating \`passed\` as trusted when artifact evidence contradicts it.
135
- - Using **/cc-next** to bypass \`WAIT_FOR_CONFIRM\`, explicit approval pauses, or missing mandatory delegations.
136
150
  - Skipping **review** or **ship** because "the code looks fine".
151
+ - Loading a stage skill directly instead of using \`/cc-next\` for progression.
137
152
  `;
138
153
  }
@@ -1,7 +1,7 @@
1
1
  import { RUNTIME_ROOT } from "../constants.js";
2
2
  import { stageExamples } from "./examples.js";
3
3
  import { selfImprovementBlock } from "./learnings.js";
4
- import { nextCclawCommand, QUESTION_FORMAT_SPEC, ERROR_BUDGET_SPEC, stageAutoSubagentDispatch, stageSchema } from "./stage-schema.js";
4
+ import { QUESTION_FORMAT_SPEC, ERROR_BUDGET_SPEC, stageAutoSubagentDispatch, stageSchema } from "./stage-schema.js";
5
5
  function artifactFileName(artifactPath) {
6
6
  const parts = artifactPath.split("/");
7
7
  return parts[parts.length - 1] ?? artifactPath;
@@ -145,55 +145,44 @@ After plan approval (**WAIT_FOR_CONFIRM** / \`plan_wait_for_confirm\` satisfied)
145
145
 
146
146
  `;
147
147
  }
148
- function stageRequiresExplicitPause(schema) {
149
- const pauseRules = [
150
- /\bWAIT_FOR_CONFIRM\b/,
151
- /\*\*STOP\.\*\*/,
152
- /Do NOT auto-advance/i,
153
- /Do NOT proceed until user/i,
154
- /wait for explicit user approval/i,
155
- /wait for explicit approval/i,
156
- /explicitly pause/i
157
- ];
158
- const stageText = [
159
- schema.hardGate,
160
- ...schema.checklist,
161
- ...schema.interactionProtocol,
162
- ...schema.process,
163
- ...schema.exitCriteria
164
- ];
165
- return stageText.some((line) => pauseRules.some((rule) => rule.test(line)));
166
- }
167
- function stageTransitionAutoAdvanceBlock(schema, nextCommand) {
168
- if (schema.next === "done") {
169
- return "";
170
- }
171
- if (stageRequiresExplicitPause(schema)) {
172
- return `## Stage transition (gate chain)
173
-
174
- **STOP.** This stage requires explicit user confirmation before advancing.
175
- Even if project config has \`autoAdvance: true\`, this stage's pause rule takes precedence.
176
- Do NOT auto-advance after gates pass. Present a summary of completed gates and suggest \`${nextCommand}\`, then wait for explicit user approval.
177
-
178
- `;
179
- }
180
- return `## Stage transition (gate chain)
181
-
182
- After all gates pass, suggest the next command (\`${nextCommand}\`).
183
- If project config at \`${RUNTIME_ROOT}/config.yaml\` has \`autoAdvance: true\`, proceed automatically.
184
- Otherwise, **STOP** and wait for user confirmation before advancing.
185
-
148
+ function stageCompletionProtocol(schema) {
149
+ const stage = schema.stage;
150
+ const gateIds = schema.requiredGates.map((g) => g.id);
151
+ const gateList = gateIds.map((id) => `\`${id}\``).join(", ");
152
+ const nextStage = schema.next === "done" ? null : schema.next;
153
+ const stateUpdate = nextStage
154
+ ? ` - Set \`currentStage\` to \`"${nextStage}"\`
155
+ - Add \`"${stage}"\` to \`completedStages\` array
156
+ - Move all gate IDs for this stage (${gateList}) into \`stageGateCatalog.${stage}.passed\`
157
+ - Clear \`stageGateCatalog.${stage}.blocked\``
158
+ : ` - Add \`"${stage}"\` to \`completedStages\` array
159
+ - Move all gate IDs for this stage (${gateList}) into \`stageGateCatalog.${stage}.passed\`
160
+ - Clear \`stageGateCatalog.${stage}.blocked\``;
161
+ const nextAction = nextStage
162
+ ? `3. Tell the user: **"Stage \`${stage}\` complete. Next stage: \`${nextStage}\`. Run \`/cc-next\` to continue."**`
163
+ : `3. Tell the user: **"Flow complete. All stages finished."**`;
164
+ return `## Stage Completion Protocol
165
+
166
+ When all required gates are satisfied and the artifact is written:
167
+
168
+ 1. **Update \`${RUNTIME_ROOT}/state/flow-state.json\`:**
169
+ ${stateUpdate}
170
+ 2. **Sync artifact** to \`${RUNTIME_ROOT}/runs/<activeRunId>/artifacts/${schema.artifactFile}\`
171
+ ${nextAction}
172
+
173
+ **STOP.** Do not load the next stage skill yourself. The user will run \`/cc-next\` when ready (same session or new session).
186
174
  `;
187
175
  }
188
- function progressiveDisclosureBlock(stage, nextCommand) {
176
+ function stageTransitionAutoAdvanceBlock(schema) {
177
+ return stageCompletionProtocol(schema);
178
+ }
179
+ function progressiveDisclosureBlock(stage) {
189
180
  const schema = stageSchema(stage);
190
181
  const stageSpecificRefs = {
191
182
  brainstorm: [
192
- "- `.cclaw/skills/autoplan/SKILL.md` — when the user wants brainstorm→plan orchestration in one flow",
193
183
  "- `.cclaw/skills/learnings/SKILL.md` — to capture durable framing insights early"
194
184
  ],
195
185
  scope: [
196
- "- `.cclaw/skills/autoplan/SKILL.md` — for coordinated premise challenge across early stages",
197
186
  "- `.cclaw/skills/learnings/SKILL.md` — to persist rejected assumptions and constraints"
198
187
  ],
199
188
  design: [
@@ -237,7 +226,7 @@ function progressiveDisclosureBlock(stage, nextCommand) {
237
226
  - Meta routing and activation rules: \`.cclaw/skills/using-cclaw/SKILL.md\`
238
227
  - Session continuity and checkpoint behavior: \`.cclaw/skills/session/SKILL.md\`
239
228
  ${stageSpecificRefs[stage].join("\n")}
240
- - Next-stage handoff command: \`${nextCommand}\`
229
+ - Progression command: \`/cc-next\` (reads flow-state, loads the next stage)
241
230
  `;
242
231
  }
243
232
  function verificationBlock(stage) {
@@ -282,7 +271,6 @@ export function stageSkillFolder(stage) {
282
271
  }
283
272
  function quickStartBlock(stage) {
284
273
  const schema = stageSchema(stage);
285
- const nextCommand = nextCclawCommand(stage);
286
274
  const topGates = schema.requiredGates.slice(0, 3).map((g) => `\`${g.id}\``).join(", ");
287
275
  return `## Quick Start (minimum compliance)
288
276
 
@@ -291,12 +279,11 @@ function quickStartBlock(stage) {
291
279
  > 2. Complete every checklist step in order and write the artifact to \`.cclaw/artifacts/${schema.artifactFile}\` (canonical run copy: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`).
292
280
  > 3. Do not claim completion without satisfying gates: ${topGates}${schema.requiredGates.length > 3 ? ` (+${schema.requiredGates.length - 3} more)` : ""}.
293
281
  >
294
- > **Next command after this stage:** ${nextCommand}
282
+ > **After this stage:** update \`flow-state.json\` and tell the user to run \`/cc-next\`.
295
283
  `;
296
284
  }
297
285
  export function stageSkillMarkdown(stage) {
298
286
  const schema = stageSchema(stage);
299
- const nextCommand = nextCclawCommand(stage);
300
287
  const gateList = schema.requiredGates
301
288
  .map((g) => `- \`${g.id}\` — ${g.description}`)
302
289
  .join("\n");
@@ -382,11 +369,11 @@ ${completionStatusBlock(stage)}
382
369
  ## Verification
383
370
  ${schema.exitCriteria.map((item) => `- [ ] ${item}`).join("\n")}
384
371
 
385
- ${stageTransitionAutoAdvanceBlock(schema, nextCommand)}
386
- ${progressiveDisclosureBlock(stage, nextCommand)}
372
+ ${stageTransitionAutoAdvanceBlock(schema)}
373
+ ${progressiveDisclosureBlock(stage)}
387
374
  ${selfImprovementBlock(stage)}
388
375
  ## Handoff
389
- - Next command: ${nextCommand}
376
+ - Next command: \`/cc-next\` (loads whatever stage is current in flow-state)
390
377
  - Required artifact: \`.cclaw/artifacts/${schema.artifactFile}\` (canonical: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`)
391
378
  - Stage stays blocked if any required gate is unsatisfied
392
379
  `;
@@ -44,7 +44,7 @@ const BRAINSTORM = {
44
44
  "Write design doc — save to `.cclaw/artifacts/01-brainstorm.md`.",
45
45
  "Self-review — scan for placeholders, TBDs, contradictions, ambiguity, scope creep. Fix inline.",
46
46
  "User reviews written artifact — ask user to review before proceeding. **STOP.** Do NOT proceed until user responds.",
47
- "Transitioninvoke /cc-scope only after explicit user approval. **STOP.** Do NOT auto-advance to scope."
47
+ "Stage complete update `flow-state.json` per the Stage Completion Protocol. Tell user to run `/cc-next` to continue to scope."
48
48
  ],
49
49
  interactionProtocol: [
50
50
  "Explore context first (files, docs, existing behavior).",
@@ -689,15 +689,15 @@ const PLAN = {
689
689
  "Slice into vertical tasks — each task targets 2-5 minutes, produces one testable outcome, and touches one coherent area.",
690
690
  "Attach verification — every task has an acceptance criterion mapping and a concrete verification command.",
691
691
  "Define checkpoints — mark points where progress should be validated before continuing.",
692
- "WAIT_FOR_CONFIRM — write plan artifact and explicitly pause. **STOP.** Do NOT proceed to /cc-test until user confirms."
692
+ "WAIT_FOR_CONFIRM — write plan artifact and explicitly pause. **STOP.** Do NOT proceed until user confirms. Then update `flow-state.json` and tell user to run `/cc-next`."
693
693
  ],
694
694
  interactionProtocol: [
695
695
  "Plan in read-only mode relative to implementation.",
696
696
  "Split work into small vertical slices (target 2-5 minute tasks).",
697
697
  "Publish explicit dependency waves with entry and exit checks for each wave.",
698
698
  "Attach verification step to every task.",
699
- "Enforce WAIT_FOR_CONFIRM before moving to /cc-test. Use AskQuestion/AskUserQuestion tool: present the plan summary with options (A) Approve / (B) Revise / (C) Reject.",
700
- "**STOP.** Do NOT proceed to /cc-test until user explicitly approves. Do not auto-advance."
699
+ "Enforce WAIT_FOR_CONFIRM: present the plan summary with options (A) Approve / (B) Revise / (C) Reject.",
700
+ "**STOP.** Do NOT proceed until user explicitly approves. Then update `flow-state.json` and tell user to run `/cc-next`."
701
701
  ],
702
702
  process: [
703
703
  "Build dependency graph and ordered slices.",
@@ -793,7 +793,7 @@ const TEST = {
793
793
  purpose: "Create RED evidence tied to acceptance criteria before any implementation.",
794
794
  whenToUse: [
795
795
  "After plan confirmation",
796
- "Before /cc-build",
796
+ "After RED evidence from test stage (user runs /cc-next)",
797
797
  "For every behavior change in scope"
798
798
  ],
799
799
  whenNotToUse: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {