cclaw-cli 0.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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/dist/cli.d.ts +10 -0
  4. package/dist/cli.js +101 -0
  5. package/dist/config.d.ts +5 -0
  6. package/dist/config.js +70 -0
  7. package/dist/constants.d.ts +12 -0
  8. package/dist/constants.js +50 -0
  9. package/dist/content/agents.d.ts +39 -0
  10. package/dist/content/agents.js +244 -0
  11. package/dist/content/autoplan.d.ts +7 -0
  12. package/dist/content/autoplan.js +297 -0
  13. package/dist/content/contracts.d.ts +2 -0
  14. package/dist/content/contracts.js +50 -0
  15. package/dist/content/examples.d.ts +2 -0
  16. package/dist/content/examples.js +327 -0
  17. package/dist/content/hooks.d.ts +16 -0
  18. package/dist/content/hooks.js +753 -0
  19. package/dist/content/learnings.d.ts +5 -0
  20. package/dist/content/learnings.js +265 -0
  21. package/dist/content/meta-skill.d.ts +10 -0
  22. package/dist/content/meta-skill.js +137 -0
  23. package/dist/content/observe.d.ts +21 -0
  24. package/dist/content/observe.js +1110 -0
  25. package/dist/content/session-hooks.d.ts +7 -0
  26. package/dist/content/session-hooks.js +137 -0
  27. package/dist/content/skills.d.ts +3 -0
  28. package/dist/content/skills.js +257 -0
  29. package/dist/content/stage-schema.d.ts +78 -0
  30. package/dist/content/stage-schema.js +1453 -0
  31. package/dist/content/subagents.d.ts +13 -0
  32. package/dist/content/subagents.js +616 -0
  33. package/dist/content/templates.d.ts +3 -0
  34. package/dist/content/templates.js +272 -0
  35. package/dist/content/utility-skills.d.ts +12 -0
  36. package/dist/content/utility-skills.js +467 -0
  37. package/dist/doctor.d.ts +7 -0
  38. package/dist/doctor.js +610 -0
  39. package/dist/flow-state.d.ts +19 -0
  40. package/dist/flow-state.js +41 -0
  41. package/dist/fs-utils.d.ts +5 -0
  42. package/dist/fs-utils.js +28 -0
  43. package/dist/gitignore.d.ts +3 -0
  44. package/dist/gitignore.js +43 -0
  45. package/dist/harness-adapters.d.ts +12 -0
  46. package/dist/harness-adapters.js +175 -0
  47. package/dist/install.d.ts +9 -0
  48. package/dist/install.js +562 -0
  49. package/dist/learnings-summarizer.d.ts +25 -0
  50. package/dist/learnings-summarizer.js +201 -0
  51. package/dist/logger.d.ts +3 -0
  52. package/dist/logger.js +6 -0
  53. package/dist/policy.d.ts +6 -0
  54. package/dist/policy.js +179 -0
  55. package/dist/runs.d.ts +18 -0
  56. package/dist/runs.js +446 -0
  57. package/dist/types.d.ts +19 -0
  58. package/dist/types.js +12 -0
  59. package/package.json +47 -0
@@ -0,0 +1,297 @@
1
+ /**
2
+ * Autoplan orchestrator content for cclaw.
3
+ * Generates markdown instructions that AI agents follow; cclaw does not execute the pipeline.
4
+ */
5
+ export function autoplanSkillMarkdown() {
6
+ return `---
7
+ name: autoplan
8
+ description: "One command, rough idea in, fully reviewed plan out. Runs brainstorm through plan stages in sequence with auto-decisions."
9
+ ---
10
+
11
+ # Cclaw Autoplan — Auto-Orchestration
12
+
13
+ ## Overview
14
+
15
+ Autoplan is a **one-shot planning pipeline** that accepts a rough idea (plus whatever context already exists in the repo) and produces a **fully reviewed plan** as markdown artifacts under \`.cclaw/artifacts/\`.
16
+
17
+ It runs the **first five cclaw flow stages in strict order**:
18
+
19
+ \`brainstorm → scope → design → spec → plan\`
20
+
21
+ Mechanical questions are **auto-answered** using the Six Decision Principles and logged to a running **Decision Audit Trail**. **Taste** decisions are also auto-answered but must be **surfaced with rationale** at the single **Final Approval Gate**. **User challenges** (cases where the agent believes the user’s stated direction should change) are **never** auto-decided.
22
+
23
+ Autoplan ends with **one structured HARD STOP** for human approval before any downstream work (test/build/review/ship) should proceed.
24
+
25
+ This skill describes **what the agent must do when invoked as \`/cc-autoplan\`**. Cclaw installs the markdown; **the agent performs the protocol**.
26
+
27
+ ## HARD-GATE
28
+
29
+ - **Do NOT write implementation code** (no feature code, refactors, migrations, or "quick fixes" in application sources). Autoplan output is **planning artifacts only**.
30
+ - **Do NOT skip any phase** (Phases 0–6). If something seems redundant, still execute it and record "no material change" with evidence.
31
+ - **Do NOT auto-answer user challenges.** Present them explicitly and wait.
32
+ - **Do NOT "shortcut"** to individual stage commands mid-pipeline unless the user explicitly aborts autoplan and chooses a different path.
33
+
34
+ ## Phase Sequence
35
+
36
+ ### Phase 0 — Intake (always runs)
37
+
38
+ 1. **Create restore point (mandatory, first filesystem write of autoplan):**
39
+ - Path: \`.cclaw/state/autoplan-restore-{ISO-8601-timestamp}.md\`
40
+ - Ensure parent directories exist.
41
+ - File must include:
42
+ - **Timestamp** (same as filename)
43
+ - **Current git branch** (or explicit note if not a git repo)
44
+ - **Original idea/plan text** (verbatim capture of what the user provided for this autoplan run)
45
+ - **Re-run instructions** (how to resume; see **Restore Points**)
46
+ 2. **Load context:**
47
+ - Read existing \`.cclaw/artifacts/\` (if present) to avoid contradicting prior locked decisions without calling it out.
48
+ - Read **recent git log** (bounded, e.g., last ~30 commits) and **current branch**.
49
+ - Read \`AGENTS.md\` and/or \`CLAUDE.md\` if present (repo agent guidance).
50
+ 3. **Scope detection flags (heuristic, non-blocking):**
51
+ - **UI scope active** if the request matches **2+** UI/UX terms (examples: "layout", "responsive", "animation", "accessibility", "Figma", "design system", "component", "CSS", "dark mode", "modal", "form validation UX", "empty state", "loading skeleton", "pixel", "spacing", "typography", "contrast", "WCAG", "screen reader", "keyboard navigation").
52
+ - **DX scope active** if the request matches **2+** dev-tooling terms (examples: "CLI", "flag", "subcommand", "SDK", "API client", "OpenAPI", "schema", "codegen", "plugin", "hook", "watcher", "dev server", "logging format", "telemetry", "error codes", "CI", "lint rule", "formatter", "LSP", "extension", "REPL").
53
+ - If both activate, **record both** and prefer **explicit user priority** if stated; otherwise treat as **multi-surface** and keep UX + DX constraints visible in later phases.
54
+ 4. **Load stage skills (read fully, treat as authoritative for stage depth):**
55
+ - \`.cclaw/skills/brainstorming/SKILL.md\`
56
+ - \`.cclaw/skills/scope-shaping/SKILL.md\`
57
+ - \`.cclaw/skills/engineering-design-lock/SKILL.md\`
58
+ - \`.cclaw/skills/specification-authoring/SKILL.md\`
59
+ - \`.cclaw/skills/planning-and-task-breakdown/SKILL.md\`
60
+
61
+ ### Phase 1 — Brainstorm (always runs)
62
+
63
+ - Follow \`.cclaw/skills/brainstorming/SKILL.md\` at **full depth** (all sections, all required evaluations).
64
+ - **Auto-answer mechanical questions** using the Six Decision Principles + phase tie-breakers.
65
+ - **Premise / USER CHALLENGE rule:** If the agent believes a core user premise is wrong, risky, or incompatible with repo reality, classify it as **User Challenge** and **stop auto-progression** on that item until the user confirms or revises.
66
+ - **Artifact:** write/update \`.cclaw/artifacts/01-brainstorm.md\` (single source of truth for brainstorm outputs).
67
+
68
+ ### Phase 2 — Scope (always runs)
69
+
70
+ - Follow \`.cclaw/skills/scope-shaping/SKILL.md\` at **full depth**.
71
+ - **Default mode selection:**
72
+ - **SELECTIVE_EXPANSION** for **greenfield** work (new capability, new subsystem, new user-facing flow with meaningful net-new behavior).
73
+ - **HOLD** for **enhancement/bugfix** work (tight blast radius, correctness/perf/regression risk dominates).
74
+ - **Auto-answer** scope boundary questions when they are **mechanical** or **taste** (never user challenges).
75
+ - **Artifact:** \`.cclaw/artifacts/02-scope.md\`
76
+
77
+ ### Phase 3 — Design (always runs)
78
+
79
+ - Follow \`.cclaw/skills/engineering-design-lock/SKILL.md\` at **full depth**.
80
+ - **All review sections** must be evaluated; **none skipped**. If a section has no findings, write **"No issues found"** with a brief evidence note (what you checked).
81
+ - **Artifact:** \`.cclaw/artifacts/03-design.md\`
82
+
83
+ ### Phase 4 — Spec (always runs)
84
+
85
+ - Follow \`.cclaw/skills/specification-authoring/SKILL.md\` at **full depth**.
86
+ - **Artifact:** \`.cclaw/artifacts/04-spec.md\`
87
+
88
+ ### Phase 5 — Plan (always runs)
89
+
90
+ - Follow \`.cclaw/skills/planning-and-task-breakdown/SKILL.md\` at **full depth**.
91
+ - Maintain the **Decision Audit Trail** as a running markdown table inside \`05-plan.md\` (append rows after each auto-decision).
92
+ - **Artifact:** \`.cclaw/artifacts/05-plan.md\`
93
+
94
+ ### Phase 6 — Final Approval Gate (HARD STOP)
95
+
96
+ Present a **structured summary** to the user and **do not proceed** to implementation stages until the user selects an option.
97
+
98
+ **Must include:**
99
+
100
+ - **Plan summary** (goal, scope cut-line, key design decisions, spec highlights, plan outline).
101
+ - **Total auto-decisions count** (mechanical + taste).
102
+ - **Taste decisions** with **one-line impact of the rejected alternative** each.
103
+ - **User challenges** (if any) — explicitly list: what user said, agent recommendation, why, cost if agent is wrong.
104
+ - **Decision audit trail pointer** (where the full table lives — typically \`.cclaw/artifacts/05-plan.md\`).
105
+ - **Cross-phase themes** (recurring constraints, risks, or invariants spanning brainstorm→plan).
106
+
107
+ **Options:**
108
+
109
+ - **(A) Approve as-is** — treat artifacts as locked enough to start downstream cclaw stages.
110
+ - **(B) Approve with overrides** — user states explicit overrides; update artifacts to reflect overrides **without** inventing new scope; re-present diff summary.
111
+ - **(C) Interrogate a specific decision** — answer questions; only mutate artifacts if corrections are agreed.
112
+ - **(D) Revise plan** — re-run **affected phases only**, preserving intact artifacts where unchanged; **max 3 revision cycles** total (count across the whole autoplan session).
113
+ - **(E) Reject / start over** — stop; optionally create a fresh restore point on the next run.
114
+
115
+ ## Six Decision Principles (for auto-answering)
116
+
117
+ 1. **Completeness (P1):** Ship the whole thing. Prefer covering edge cases and failure modes over leaving silent gaps.
118
+ 2. **Boil Lakes (P2):** Fix everything in the blast radius (touched files + direct importers). Auto-approve lake-boiling when **< 5 files** and **no new infra** (no new services, queues, clusters, deployables).
119
+ 3. **Pragmatic (P3):** If two options solve the same problem, pick the cleaner/faster-to-validate one. **5 seconds, not 5 minutes** — but do not disguise uncertainty as speed.
120
+ 4. **DRY (P4):** Reject duplicating existing functionality; prefer extension points and shared modules already present in-repo.
121
+ 5. **Explicit over Clever (P5):** Prefer obvious, short solutions with clear boundaries over clever abstractions.
122
+ 6. **Bias toward Action (P6):** Prefer merging decisions and moving forward; **flag** residual risks rather than **blocking** unless a true stop condition exists (security, correctness, ethics, user challenge).
123
+
124
+ ### Phase tie-breakers
125
+
126
+ - **Brainstorm + Scope:** **P1 + P2 dominate** (completeness + blast-radius integrity).
127
+ - **Design + Spec:** **P5 + P1 dominate** (explicitness + completeness of specification).
128
+ - **Plan:** **P3 + P5 dominate** (pragmatic sequencing + explicit tasks).
129
+
130
+ ## Decision Taxonomy
131
+
132
+ ### Mechanical
133
+
134
+ - **Definition:** Exactly one clearly correct answer given repo conventions and constraints.
135
+ - **Behavior:** Auto-decide **silently** (no chat clutter), but **still log** to the audit trail.
136
+ - **Examples:** use the repo's existing test framework; follow established lint/format patterns; reuse established error handling utilities.
137
+
138
+ ### Taste
139
+
140
+ - **Definition:** Reasonable engineers could disagree; tradeoffs are real but not safety-critical.
141
+ - **Behavior:** Auto-decide with a **stated recommendation** + rationale; **must surface** at Final Approval Gate with **one-line impact of rejected alternative**.
142
+ - **Examples:** borderline scope inclusion; close architectural approaches; naming that affects ergonomics but not correctness.
143
+
144
+ ### User Challenge
145
+
146
+ - **Definition:** The agent believes the user's direction should change (premise risk, wrong problem framing, incompatible constraints, ethical/safety concern).
147
+ - **Behavior:** **NEVER auto-decided.** Present:
148
+ - what the user said (quoted, concise)
149
+ - what the agent recommends instead
150
+ - why (repo evidence + reasoning)
151
+ - cost if the agent is wrong
152
+ - **Gate:** Wait for explicit user resolution before treating that thread as decided.
153
+
154
+ ## Decision Audit Trail (running table)
155
+
156
+ After **each** auto-decision (mechanical or taste), append a row to the running table stored in \`.cclaw/artifacts/05-plan.md\` (create the table if missing):
157
+
158
+ | # | Phase | Decision | Classification | Principle | Rationale | Rejected Alternative |
159
+ |---:|---|---|---|---|---|---|
160
+ | 1 | brainstorm | … | Mechanical | P4 | … | … |
161
+
162
+ **Rules:**
163
+
164
+ - **Monotonic numbering** across the entire autoplan run (do not reset per phase).
165
+ - **No blank classifications.** If unsure between mechanical vs taste, default to **taste** (safer) and surface at the gate.
166
+ - The table is part of the **evidence bundle** for the Final Approval Gate.
167
+
168
+ ## Restore Points
169
+
170
+ - **When:** Phase 0, **before any substantive work** begins (before mutating artifacts beyond creating dirs).
171
+ - **Path:** \`.cclaw/state/autoplan-restore-{ISO-timestamp}.md\`
172
+ - **Contents must include:**
173
+ - timestamp
174
+ - branch
175
+ - original idea/plan text
176
+ - re-run instructions
177
+ - **Resume procedure:** copy the captured **original idea/plan text** back into the working plan input the user provides, then run \`/cc-autoplan\` again (optionally after reverting artifact edits manually if needed).
178
+
179
+ ## Completion Status
180
+
181
+ Report exactly one terminal status for the autoplan session:
182
+
183
+ - **APPROVED** — user chose (A) or accepted post-(B) state without further revision cycles.
184
+ - **APPROVED_WITH_OVERRIDES** — user chose (B) and artifacts reflect explicit overrides.
185
+ - **REJECTED** — user chose (E) or explicitly abandoned the plan.
186
+ - **BLOCKED** — cannot proceed due to unresolved **User Challenge(s)** or hard external dependency; list what unblocks.
187
+
188
+ ## Anti-Patterns
189
+
190
+ - **Skipping a phase** because "it's obvious."
191
+ - **Auto-deciding user challenges** "to save time."
192
+ - **Failing to log** auto-decisions in the audit trail.
193
+ - **Aborting mid-pipeline** and redirecting to individual stage commands without an explicit user abort decision.
194
+ - **Exceeding 3 revision cycles** for option (D); if still unresolved, stop with **BLOCKED** and a crisp list of remaining forks.
195
+ - **Silent artifact drift** (changing earlier artifacts without marking what changed and why).
196
+
197
+ ## Common Rationalizations (reject these)
198
+
199
+ | Rationalization | Reality |
200
+ |---|---|
201
+ | "We can skip scope because brainstorm was thorough." | Thorough brainstorm does not replace scope shaping; different obligations, different failure modes. |
202
+ | "Design lock is redundant if the spec is going to rewrite it anyway." | Spec authorizes details; design lock prevents architectural drift and hidden coupling before authorization. |
203
+ | "I'll batch auto-decisions mentally and log them at the end." | End-only logging guarantees omissions; the audit trail is a **running** compliance artifact. |
204
+ | "The user's premise is probably wrong, but I'll implement around it." | That is a **User Challenge**; autoplan must surface it, not sneak around it. |
205
+
206
+ ## Red Flags (stop and reassess)
207
+
208
+ - **Missing restore file** after claiming Phase 0 complete.
209
+ - **05-plan.md** has fewer audit rows than claimed auto-decisions.
210
+ - **Any implementation patch** appears during autoplan (source edits outside \`.cclaw/\` planning artifacts).
211
+ - **Contradictions across artifacts** without an explicit "revision delta" section explaining the change.
212
+ - **Skipped review sections** in design (missing "No issues found" where applicable).
213
+ - **Revision cycle count** is unclear or exceeds three.
214
+
215
+ ## Agent Execution Notes (non-normative but helpful)
216
+
217
+ - Prefer **small, explicit commits** of artifacts only if the repo workflow expects it; otherwise keep changes grouped logically — but never hide planning edits.
218
+ - Treat **UI scope** / **DX scope** flags as persistent headers in artifacts **02–05** so downstream agents inherit the context quickly.
219
+ `;
220
+ }
221
+ export function autoplanCommandContract() {
222
+ return `# /cc-autoplan
223
+
224
+ ## Purpose
225
+
226
+ Run **brainstorm → scope → design → spec → plan** as a single orchestrated pass: load repo context, create a restore point, execute each stage skill at full depth, auto-answer mechanical questions, auto-resolve taste questions with explicit rationale, never auto-resolve user challenges, and finish with **one Final Approval Gate** before any implementation work.
227
+
228
+ ## HARD-GATE
229
+
230
+ - **No implementation code** during autoplan (planning artifacts only).
231
+ - **No skipped phases** (Phases 0–6).
232
+ - **No auto-answers for user challenges** (explicit user resolution required).
233
+
234
+ ## Phase Sequence (numbered, one-line each)
235
+
236
+ 1. **Phase 0 — Intake:** restore point + context scan + UI/DX scope flags + read all five stage skills.
237
+ 2. **Phase 1 — Brainstorm:** full \`brainstorming\` skill depth → \`.cclaw/artifacts/01-brainstorm.md\`.
238
+ 3. **Phase 2 — Scope:** full \`scope-shaping\` skill depth (greenfield default **SELECTIVE_EXPANSION**, enhancement/bug default **HOLD**) → \`02-scope.md\`.
239
+ 4. **Phase 3 — Design:** full \`engineering-design-lock\` skill depth; all review sections evaluated → \`03-design.md\`.
240
+ 5. **Phase 4 — Spec:** full \`specification-authoring\` skill depth → \`04-spec.md\`.
241
+ 6. **Phase 5 — Plan:** full \`planning-and-task-breakdown\` skill depth; maintain audit trail table → \`05-plan.md\`.
242
+ 7. **Phase 6 — Final Approval Gate:** HARD STOP summary + options **A–E** (max **3** revision cycles for **D**).
243
+
244
+ ## Decision Principles (numbered list)
245
+
246
+ 1. **Completeness (P1):** ship the whole thing; favor edge-case and failure-mode coverage.
247
+ 2. **Boil Lakes (P2):** clean the full blast radius; auto-approve when **< 5 files** and **no new infra**.
248
+ 3. **Pragmatic (P3):** pick the cleaner equal fix quickly (**5 seconds not 5 minutes**).
249
+ 4. **DRY (P4):** do not duplicate existing functionality; extend what exists.
250
+ 5. **Explicit over Clever (P5):** obvious, short solutions win.
251
+ 6. **Bias toward Action (P6):** merge over endless review; flag residual risks instead of stalling.
252
+
253
+ **Phase tie-breakers:** brainstorm/scope → **P1+P2**; design/spec → **P5+P1**; plan → **P3+P5**.
254
+
255
+ ## Decision Taxonomy (Mechanical / Taste / User Challenge)
256
+
257
+ - **Mechanical:** one clearly right answer → auto-decide silently + **audit log row**.
258
+ - **Taste:** reasonable disagreement → auto-decide with recommendation + **audit log row** + **surface at gate** with **one-line rejected-alternative impact**.
259
+ - **User Challenge:** agent recommends changing user direction → **never** auto-decide; present evidence + costs; await user.
260
+
261
+ ## Final Approval Gate (options A-E)
262
+
263
+ - **(A) Approve as-is**
264
+ - **(B) Approve with overrides** (explicit user deltas reflected in artifacts)
265
+ - **(C) Interrogate a specific decision** (Q/A; only change artifacts if corrections are agreed)
266
+ - **(D) Revise plan** (re-run affected phases only; **≤ 3** cycles)
267
+ - **(E) Reject / start over**
268
+
269
+ ## Restore Points
270
+
271
+ Created in **Phase 0** at \`.cclaw/state/autoplan-restore-{ISO-timestamp}.md\` containing timestamp, branch, original idea text, and resume instructions (**copy original idea/plan text → rerun \`/cc-autoplan\`**).
272
+
273
+ ## Completion Status
274
+
275
+ **APPROVED**, **APPROVED_WITH_OVERRIDES**, **REJECTED**, **BLOCKED**.
276
+
277
+ ## Anti-Patterns
278
+
279
+ Skipping phases; auto-deciding user challenges; missing audit trail rows; mid-run redirects to other cclaw commands without explicit user abort; >3 revision cycles; silent cross-artifact contradictions.
280
+
281
+ ## Primary Skill (.cclaw/skills/autoplan/SKILL.md)
282
+
283
+ The executable protocol and tables live in the installed autoplan skill markdown at \`.cclaw/skills/autoplan/SKILL.md\` (generated from cclaw's orchestrator content module).
284
+ `;
285
+ }
286
+ export function autoplanAgentsMdBlock() {
287
+ return `### Autoplan Orchestrator
288
+
289
+ Use \`/cc-autoplan\` to run brainstorm→scope→design→spec→plan in one shot with auto-decisions.
290
+ - Mechanical questions are auto-answered using 6 principles
291
+ - Taste decisions are auto-answered but surfaced at a single final approval gate
292
+ - User challenges are NEVER auto-answered
293
+ - Restore point is created before any work begins
294
+
295
+ Use this when you want a complete planning pass without interactive per-stage approval.
296
+ `;
297
+ }
@@ -0,0 +1,2 @@
1
+ import type { FlowStage } from "../types.js";
2
+ export declare function commandContract(stage: FlowStage): string;
@@ -0,0 +1,50 @@
1
+ import { nextCclawCommand, stageSchema } from "./stage-schema.js";
2
+ import { stageSkillFolder } from "./skills.js";
3
+ export function commandContract(stage) {
4
+ const schema = stageSchema(stage);
5
+ const nextCommand = nextCclawCommand(stage);
6
+ const skillPath = `.cclaw/skills/${stageSkillFolder(stage)}/SKILL.md`;
7
+ const reads = schema.crossStageTrace.readsFrom;
8
+ const readsLine = reads.length > 0 ? reads.join(", ") : "(first stage)";
9
+ const hydrationLines = reads.length > 0
10
+ ? reads
11
+ .map((readPath) => {
12
+ const parts = readPath.split("/");
13
+ const fileName = parts[parts.length - 1] ?? readPath;
14
+ return `- Canonical: \`.cclaw/runs/<activeRunId>/artifacts/${fileName}\` (fallback: \`${readPath}\`)`;
15
+ })
16
+ .join("\n")
17
+ : "- (first stage — no upstream artifacts)";
18
+ const gateIds = schema.requiredGates
19
+ .map((g) => `\`${g.id}\``)
20
+ .join(", ");
21
+ return `# /cc-${stage}
22
+
23
+ Load and follow **${skillPath}** — it contains the full checklist, examples, interaction protocol, and verification discipline.
24
+
25
+ ## HARD-GATE
26
+ ${schema.hardGate}
27
+
28
+ ## In / Out
29
+ - **Reads:** ${readsLine}
30
+ - **Writes:** \`.cclaw/artifacts/${schema.artifactFile}\` (canonical run copy: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`)
31
+ - **Next:** ${nextCommand}
32
+
33
+ ## Context Hydration (mandatory before stage work)
34
+ 1. Read \`.cclaw/state/flow-state.json\` and capture \`activeRunId\`.
35
+ 2. Resolve canonical artifact root: \`.cclaw/runs/<activeRunId>/artifacts/\`.
36
+ 3. Load required upstream artifacts for this stage:
37
+ ${hydrationLines}
38
+ 4. If a canonical run artifact is missing, fallback to the matching file under \`.cclaw/artifacts/\` and record that fallback in the stage artifact.
39
+ 5. Write stage output to \`.cclaw/artifacts/${schema.artifactFile}\` and keep canonical run copy aligned at \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`.
40
+
41
+ ## Gates
42
+ ${gateIds}
43
+
44
+ ## Exit
45
+ ${schema.exitCriteria.map((v) => `- ${v}`).join("\n")}
46
+
47
+ ## Anchors
48
+ ${schema.policyNeedles.map((v) => `- ${v}`).join("\n")}
49
+ `;
50
+ }
@@ -0,0 +1,2 @@
1
+ import type { FlowStage } from "../types.js";
2
+ export declare function stageExamples(stage: FlowStage): string;