cclaw-cli 0.51.30 → 1.0.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 (160) hide show
  1. package/README.md +24 -18
  2. package/dist/artifact-linter/brainstorm.d.ts +2 -0
  3. package/dist/artifact-linter/brainstorm.js +289 -0
  4. package/dist/artifact-linter/design.d.ts +2 -0
  5. package/dist/artifact-linter/design.js +354 -0
  6. package/dist/artifact-linter/plan.d.ts +2 -0
  7. package/dist/artifact-linter/plan.js +183 -0
  8. package/dist/artifact-linter/review-army.d.ts +24 -0
  9. package/dist/artifact-linter/review-army.js +365 -0
  10. package/dist/artifact-linter/review.d.ts +2 -0
  11. package/dist/artifact-linter/review.js +99 -0
  12. package/dist/artifact-linter/scope.d.ts +2 -0
  13. package/dist/artifact-linter/scope.js +125 -0
  14. package/dist/artifact-linter/shared.d.ts +247 -0
  15. package/dist/artifact-linter/shared.js +1517 -0
  16. package/dist/artifact-linter/ship.d.ts +2 -0
  17. package/dist/artifact-linter/ship.js +82 -0
  18. package/dist/artifact-linter/spec.d.ts +2 -0
  19. package/dist/artifact-linter/spec.js +130 -0
  20. package/dist/artifact-linter/tdd.d.ts +2 -0
  21. package/dist/artifact-linter/tdd.js +198 -0
  22. package/dist/artifact-linter.d.ts +4 -76
  23. package/dist/artifact-linter.js +56 -2949
  24. package/dist/cli.d.ts +1 -6
  25. package/dist/cli.js +4 -159
  26. package/dist/codex-feature-flag.d.ts +1 -1
  27. package/dist/codex-feature-flag.js +1 -1
  28. package/dist/config.d.ts +3 -2
  29. package/dist/config.js +67 -3
  30. package/dist/constants.d.ts +1 -7
  31. package/dist/constants.js +10 -15
  32. package/dist/content/cancel-command.js +2 -2
  33. package/dist/content/closeout-guidance.d.ts +1 -1
  34. package/dist/content/closeout-guidance.js +15 -13
  35. package/dist/content/core-agents.d.ts +46 -29
  36. package/dist/content/core-agents.js +216 -82
  37. package/dist/content/decision-protocol.d.ts +1 -1
  38. package/dist/content/decision-protocol.js +1 -1
  39. package/dist/content/diff-command.js +1 -1
  40. package/dist/content/examples.d.ts +0 -3
  41. package/dist/content/examples.js +197 -752
  42. package/dist/content/harness-doc.js +20 -2
  43. package/dist/content/hook-manifest.d.ts +2 -2
  44. package/dist/content/hook-manifest.js +2 -2
  45. package/dist/content/hooks.d.ts +1 -0
  46. package/dist/content/hooks.js +32 -137
  47. package/dist/content/idea.d.ts +60 -0
  48. package/dist/content/idea.js +404 -0
  49. package/dist/content/iron-laws.d.ts +0 -1
  50. package/dist/content/iron-laws.js +31 -16
  51. package/dist/content/learnings.d.ts +2 -4
  52. package/dist/content/learnings.js +11 -27
  53. package/dist/content/meta-skill.js +7 -7
  54. package/dist/content/node-hooks.d.ts +10 -0
  55. package/dist/content/node-hooks.js +163 -95
  56. package/dist/content/opencode-plugin.js +15 -29
  57. package/dist/content/reference-patterns.js +2 -2
  58. package/dist/content/runtime-shared-snippets.d.ts +8 -0
  59. package/dist/content/runtime-shared-snippets.js +80 -0
  60. package/dist/content/session-hooks.js +1 -1
  61. package/dist/content/skills.d.ts +1 -0
  62. package/dist/content/skills.js +69 -7
  63. package/dist/content/stage-schema.js +147 -61
  64. package/dist/content/stages/_lint-metadata/index.js +26 -2
  65. package/dist/content/stages/brainstorm.js +13 -7
  66. package/dist/content/stages/design.js +16 -11
  67. package/dist/content/stages/plan.js +7 -4
  68. package/dist/content/stages/review.js +12 -12
  69. package/dist/content/stages/schema-types.d.ts +2 -2
  70. package/dist/content/stages/scope.js +15 -12
  71. package/dist/content/stages/ship.js +3 -3
  72. package/dist/content/stages/spec.js +9 -3
  73. package/dist/content/stages/tdd.js +14 -4
  74. package/dist/content/start-command.js +11 -10
  75. package/dist/content/status-command.js +5 -5
  76. package/dist/content/subagent-context-skills.js +156 -1
  77. package/dist/content/subagents.d.ts +0 -5
  78. package/dist/content/subagents.js +65 -81
  79. package/dist/content/templates.d.ts +1 -1
  80. package/dist/content/templates.js +187 -154
  81. package/dist/content/tree-command.js +2 -2
  82. package/dist/content/utility-skills.d.ts +2 -2
  83. package/dist/content/utility-skills.js +28 -99
  84. package/dist/content/view-command.js +4 -2
  85. package/dist/delegation.d.ts +2 -0
  86. package/dist/delegation.js +2 -1
  87. package/dist/early-loop.d.ts +66 -0
  88. package/dist/early-loop.js +275 -0
  89. package/dist/flow-state.d.ts +5 -6
  90. package/dist/flow-state.js +4 -6
  91. package/dist/gate-evidence.d.ts +0 -23
  92. package/dist/gate-evidence.js +111 -153
  93. package/dist/harness-adapters.d.ts +2 -2
  94. package/dist/harness-adapters.js +48 -19
  95. package/dist/install.js +190 -32
  96. package/dist/internal/advance-stage/advance.d.ts +50 -0
  97. package/dist/internal/advance-stage/advance.js +479 -0
  98. package/dist/internal/advance-stage/cancel-run.d.ts +8 -0
  99. package/dist/internal/advance-stage/cancel-run.js +19 -0
  100. package/dist/internal/advance-stage/flow-state-coercion.d.ts +3 -0
  101. package/dist/internal/advance-stage/flow-state-coercion.js +81 -0
  102. package/dist/internal/advance-stage/helpers.d.ts +14 -0
  103. package/dist/internal/advance-stage/helpers.js +145 -0
  104. package/dist/internal/advance-stage/hook.d.ts +8 -0
  105. package/dist/internal/advance-stage/hook.js +40 -0
  106. package/dist/internal/advance-stage/parsers.d.ts +54 -0
  107. package/dist/internal/advance-stage/parsers.js +307 -0
  108. package/dist/internal/advance-stage/review-loop.d.ts +7 -0
  109. package/dist/internal/advance-stage/review-loop.js +161 -0
  110. package/dist/internal/advance-stage/rewind.d.ts +14 -0
  111. package/dist/internal/advance-stage/rewind.js +108 -0
  112. package/dist/internal/advance-stage/start-flow.d.ts +11 -0
  113. package/dist/internal/advance-stage/start-flow.js +136 -0
  114. package/dist/internal/advance-stage/verify.d.ts +29 -0
  115. package/dist/internal/advance-stage/verify.js +225 -0
  116. package/dist/internal/advance-stage.js +21 -1470
  117. package/dist/internal/compound-readiness.d.ts +1 -1
  118. package/dist/internal/compound-readiness.js +2 -2
  119. package/dist/internal/early-loop-status.d.ts +7 -0
  120. package/dist/internal/early-loop-status.js +90 -0
  121. package/dist/internal/runtime-integrity.d.ts +7 -0
  122. package/dist/internal/runtime-integrity.js +288 -0
  123. package/dist/internal/tdd-red-evidence.js +1 -1
  124. package/dist/knowledge-store.d.ts +5 -28
  125. package/dist/knowledge-store.js +57 -84
  126. package/dist/managed-resources.js +24 -2
  127. package/dist/policy.js +7 -9
  128. package/dist/retro-gate.js +8 -90
  129. package/dist/run-archive.d.ts +1 -1
  130. package/dist/run-archive.js +13 -16
  131. package/dist/run-persistence.js +20 -15
  132. package/dist/runtime/run-hook.entry.d.ts +3 -0
  133. package/dist/runtime/run-hook.entry.js +5 -0
  134. package/dist/runtime/run-hook.mjs +9477 -0
  135. package/dist/tdd-cycle.d.ts +3 -3
  136. package/dist/tdd-cycle.js +1 -1
  137. package/dist/types.d.ts +18 -10
  138. package/package.json +4 -2
  139. package/dist/content/hook-inline-snippets.d.ts +0 -83
  140. package/dist/content/hook-inline-snippets.js +0 -302
  141. package/dist/content/ideate-command.d.ts +0 -8
  142. package/dist/content/ideate-command.js +0 -315
  143. package/dist/content/ideate-frames.d.ts +0 -31
  144. package/dist/content/ideate-frames.js +0 -140
  145. package/dist/content/ideate-ranking.d.ts +0 -25
  146. package/dist/content/ideate-ranking.js +0 -65
  147. package/dist/content/next-command.d.ts +0 -20
  148. package/dist/content/next-command.js +0 -298
  149. package/dist/content/seed-shelf.d.ts +0 -36
  150. package/dist/content/seed-shelf.js +0 -301
  151. package/dist/content/stage-common-guidance.d.ts +0 -1
  152. package/dist/content/stage-common-guidance.js +0 -106
  153. package/dist/doctor-registry.d.ts +0 -10
  154. package/dist/doctor-registry.js +0 -186
  155. package/dist/doctor.d.ts +0 -17
  156. package/dist/doctor.js +0 -2201
  157. package/dist/internal/hook-manifest.d.ts +0 -16
  158. package/dist/internal/hook-manifest.js +0 -77
  159. package/dist/trace-matrix.d.ts +0 -27
  160. package/dist/trace-matrix.js +0 -226
@@ -15,6 +15,8 @@ export interface AgentReturnSchema {
15
15
  requiredFields: string[];
16
16
  /** Fields that must cite artifact anchors, commands, or code locations when applicable. */
17
17
  evidenceFields: string[];
18
+ /** Additional optional fields allowed for specific agent contracts. */
19
+ optionalFields?: string[];
18
20
  }
19
21
  export interface AgentDefinition {
20
22
  /** Kebab-case identifier, e.g. `"reviewer"`. */
@@ -62,8 +64,17 @@ export declare const CCLAW_AGENTS: readonly [{
62
64
  readonly returnSchema: AgentReturnSchema;
63
65
  readonly body: string;
64
66
  }, {
65
- readonly name: "product-manager";
66
- readonly description: "PROACTIVE during brainstorm/scope when product value, persona/JTBD, success metric, or why-now framing is unclear. Use for product discovery, not implementation.";
67
+ readonly name: "product-discovery";
68
+ readonly description: "MANDATORY during brainstorm and PROACTIVE during scope when value framing or expansion strategy needs product-level discovery pressure.";
69
+ readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
70
+ readonly model: "deep";
71
+ readonly activation: "mandatory";
72
+ readonly relatedStages: ["brainstorm", "scope"];
73
+ readonly returnSchema: AgentReturnSchema;
74
+ readonly body: string;
75
+ }, {
76
+ readonly name: "divergent-thinker";
77
+ readonly description: "PROACTIVE before planner/critic convergence when brainstorm or scope needs option-space expansion and alternative framings.";
67
78
  readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
68
79
  readonly model: "balanced";
69
80
  readonly activation: "proactive";
@@ -81,11 +92,11 @@ export declare const CCLAW_AGENTS: readonly [{
81
92
  readonly body: string;
82
93
  }, {
83
94
  readonly name: "architect";
84
- readonly description: "MANDATORY during design. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and spec handoff before implementation.";
95
+ readonly description: "MANDATORY during design and final ship verification. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and cross-stage cohesion before release.";
85
96
  readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
86
97
  readonly model: "deep";
87
98
  readonly activation: "mandatory";
88
- readonly relatedStages: ["design"];
99
+ readonly relatedStages: ["design", "ship"];
89
100
  readonly returnSchema: AgentReturnSchema;
90
101
  readonly body: string;
91
102
  }, {
@@ -98,39 +109,48 @@ export declare const CCLAW_AGENTS: readonly [{
98
109
  readonly returnSchema: AgentReturnSchema;
99
110
  readonly body: string;
100
111
  }, {
101
- readonly name: "reviewer";
102
- readonly description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.";
112
+ readonly name: "spec-document-reviewer";
113
+ readonly description: "PROACTIVE during spec when self-review surfaces issues, subsystem boundaries feel broad, or the artifact needs a final plan-readiness pass.";
103
114
  readonly tools: ["Read", "Grep", "Glob"];
104
115
  readonly model: "balanced";
105
- readonly activation: "mandatory";
106
- readonly relatedStages: ["spec", "review", "ship"];
116
+ readonly activation: "proactive";
117
+ readonly relatedStages: ["spec"];
107
118
  readonly returnSchema: AgentReturnSchema;
108
119
  readonly body: string;
109
120
  }, {
110
- readonly name: "performance-reviewer";
111
- readonly description: "PROACTIVE during review for hot paths, IO, data volume, caching, rendering, or algorithmic cost changes. Produces no-impact rationale when clean.";
121
+ readonly name: "coherence-reviewer";
122
+ readonly description: "PROACTIVE during spec/plan/design when internal consistency must be validated across sections, terminology, references, and dependency narratives.";
112
123
  readonly tools: ["Read", "Grep", "Glob"];
113
124
  readonly model: "balanced";
114
125
  readonly activation: "proactive";
115
- readonly relatedStages: ["review"];
126
+ readonly relatedStages: ["spec", "plan", "design"];
116
127
  readonly returnSchema: AgentReturnSchema;
117
128
  readonly body: string;
118
129
  }, {
119
- readonly name: "compatibility-reviewer";
120
- readonly description: "PROACTIVE during design/review when public APIs, config, persisted data, CLI behavior, generated clients, or dependency versions may change.";
130
+ readonly name: "scope-guardian-reviewer";
131
+ readonly description: "PROACTIVE during scope/plan/design when complexity growth, scope drift, or unnecessary abstraction risk needs a dedicated challenge pass.";
121
132
  readonly tools: ["Read", "Grep", "Glob"];
122
133
  readonly model: "balanced";
123
134
  readonly activation: "proactive";
124
- readonly relatedStages: ["design", "review"];
135
+ readonly relatedStages: ["scope", "plan", "design"];
125
136
  readonly returnSchema: AgentReturnSchema;
126
137
  readonly body: string;
127
138
  }, {
128
- readonly name: "observability-reviewer";
129
- readonly description: "PROACTIVE during design/review when diagnosis, telemetry, rollout visibility, or supportability could affect safe operation.";
139
+ readonly name: "feasibility-reviewer";
140
+ readonly description: "PROACTIVE during plan/design when resource, runtime, environment, dependency, or rollout assumptions can make the solution non-viable.";
130
141
  readonly tools: ["Read", "Grep", "Glob"];
131
142
  readonly model: "balanced";
132
143
  readonly activation: "proactive";
133
- readonly relatedStages: ["design", "review"];
144
+ readonly relatedStages: ["plan", "design"];
145
+ readonly returnSchema: AgentReturnSchema;
146
+ readonly body: string;
147
+ }, {
148
+ readonly name: "reviewer";
149
+ readonly description: "MANDATORY during review. MUST BE USED to run a two-pass audit with explicit inline lens coverage for performance, compatibility, and observability.";
150
+ readonly tools: ["Read", "Grep", "Glob"];
151
+ readonly model: "balanced";
152
+ readonly activation: "mandatory";
153
+ readonly relatedStages: ["spec", "review", "ship"];
134
154
  readonly returnSchema: AgentReturnSchema;
135
155
  readonly body: string;
136
156
  }, {
@@ -142,6 +162,15 @@ export declare const CCLAW_AGENTS: readonly [{
142
162
  readonly relatedStages: ["design", "review", "ship"];
143
163
  readonly returnSchema: AgentReturnSchema;
144
164
  readonly body: string;
165
+ }, {
166
+ readonly name: "integration-overseer";
167
+ readonly description: "ON-DEMAND after TDD fan-out to verify cross-slice cohesion contract integrity, integration surfaces, and shared invariants before review handoff.";
168
+ readonly tools: ["Read", "Grep", "Glob"];
169
+ readonly model: "balanced";
170
+ readonly activation: "on-demand";
171
+ readonly relatedStages: ["tdd", "review"];
172
+ readonly returnSchema: AgentReturnSchema;
173
+ readonly body: string;
145
174
  }, {
146
175
  readonly name: "test-author";
147
176
  readonly description: "MANDATORY in TDD stage. MUST BE USED for RED -> GREEN -> REFACTOR with evidence-first discipline.";
@@ -178,15 +207,6 @@ export declare const CCLAW_AGENTS: readonly [{
178
207
  readonly relatedStages: ["tdd"];
179
208
  readonly returnSchema: AgentReturnSchema;
180
209
  readonly body: string;
181
- }, {
182
- readonly name: "implementer";
183
- readonly description: "ON-DEMAND worker for one scoped implementation slice. Use only with self-contained task text, explicit file boundaries, and verification expectations.";
184
- readonly tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"];
185
- readonly model: "balanced";
186
- readonly activation: "on-demand";
187
- readonly relatedStages: ["tdd"];
188
- readonly returnSchema: AgentReturnSchema;
189
- readonly body: string;
190
210
  }, {
191
211
  readonly name: "fixer";
192
212
  readonly description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.";
@@ -203,9 +223,6 @@ export declare const CCLAW_AGENTS: readonly [{
203
223
  * and typos instead of letting them slip into generated artifacts.
204
224
  */
205
225
  export type AgentName = (typeof CCLAW_AGENTS)[number]["name"];
206
- /**
207
- * Render a complete cclaw agent markdown file (YAML frontmatter + body).
208
- */
209
226
  export declare function agentMarkdown(agent: AgentDefinition): string;
210
227
  /**
211
228
  * Markdown table mapping cclaw stage entry points to specialist agents.
@@ -24,6 +24,10 @@ const ADVISORY_RETURN_SCHEMA = {
24
24
  requiredFields: ["status", "summary", "recommendations", "evidenceRefs", "unknowns"],
25
25
  evidenceFields: ["evidenceRefs", "recommendations"]
26
26
  };
27
+ const CRITIC_ADVISORY_RETURN_SCHEMA = {
28
+ ...ADVISORY_RETURN_SCHEMA,
29
+ optionalFields: ["predictions", "predictionsValidated", "openQuestions", "realistCheckResults"]
30
+ };
27
31
  const DOC_RETURN_SCHEMA = {
28
32
  statusField: "status",
29
33
  allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
@@ -49,12 +53,16 @@ Before doing substantive work, return an ACK object that the parent can record:
49
53
  Finish with the required return schema plus the same \`spanId\` and \`dispatchId\`. The parent must not claim isolated completion unless ACK/result proof matches the ledger/event span.`;
50
54
  }
51
55
  function formatReturnSchema(schema) {
52
- return [
56
+ const lines = [
53
57
  `- Status field: \`${schema.statusField}\``,
54
58
  `- Allowed statuses: ${schema.allowedStatuses.map((status) => `\`${status}\``).join(", ")}`,
55
59
  `- Required fields: ${schema.requiredFields.map((field) => `\`${field}\``).join(", ")}`,
56
60
  `- Evidence fields: ${schema.evidenceFields.map((field) => `\`${field}\``).join(", ")}`
57
- ].join("\n");
61
+ ];
62
+ if (schema.optionalFields && schema.optionalFields.length > 0) {
63
+ lines.push(`- Optional fields: ${schema.optionalFields.map((field) => `\`${field}\``).join(", ")}`);
64
+ }
65
+ return lines.join("\n");
58
66
  }
59
67
  function formattedAgentsForStages(stages) {
60
68
  const summary = stageDelegationSummary("standard");
@@ -140,26 +148,58 @@ export const CCLAW_AGENTS = [
140
148
  ].join("\n")
141
149
  },
142
150
  {
143
- name: "product-manager",
144
- description: "PROACTIVE during brainstorm/scope when product value, persona/JTBD, success metric, or why-now framing is unclear. Use for product discovery, not implementation.",
151
+ name: "product-discovery",
152
+ description: "MANDATORY during brainstorm and PROACTIVE during scope when value framing or expansion strategy needs product-level discovery pressure.",
145
153
  tools: ["Read", "Grep", "Glob", "WebSearch"],
146
- model: "balanced",
147
- activation: "proactive",
154
+ model: "deep",
155
+ activation: "mandatory",
148
156
  relatedStages: ["brainstorm", "scope"],
149
157
  returnSchema: ADVISORY_RETURN_SCHEMA,
150
158
  body: [
151
159
  "You are a **product discovery specialist**.",
152
160
  "",
153
- "Produce concise evidence for:",
161
+ "**Mode: discovery** (default)",
154
162
  "- persona / user and job to be done",
155
163
  "- pain or trigger",
156
164
  "- value hypothesis and success metric",
157
165
  "- evidence or signal strength",
158
166
  "- why now, do-nothing consequence, and non-goals",
159
167
  "",
160
- "For technical-maintenance work, translate this to operator/developer, failure mode, operational improvement, verification signal, do-nothing cost, and non-goals.",
168
+ "**Mode: strategist** (trigger when scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION)",
169
+ "- 10x vision and ideal outcome versus baseline scope",
170
+ "- concrete expansion proposals (not cosmetic variants)",
171
+ "- expected upside, reversibility, and trajectory impact",
172
+ "- explicit add/defer/skip recommendation per proposal",
173
+ "",
174
+ "For technical-maintenance work, translate these modes to operator/developer outcomes, failure-mode reduction, verification signal quality, and trajectory impact.",
175
+ "",
176
+ "**Role boundary:** frame value and trajectory fit. Do NOT choose implementation architecture."
177
+ ].join("\n")
178
+ },
179
+ {
180
+ name: "divergent-thinker",
181
+ description: "PROACTIVE before planner/critic convergence when brainstorm or scope needs option-space expansion and alternative framings.",
182
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
183
+ model: "balanced",
184
+ activation: "proactive",
185
+ relatedStages: ["brainstorm", "scope"],
186
+ returnSchema: ADVISORY_RETURN_SCHEMA,
187
+ body: [
188
+ "You are a **creative divergent-thinker** dispatched BEFORE planner/critic converge on a single path.",
161
189
  "",
162
- "**Role boundary:** frame value and problem fit. Do NOT choose implementation architecture."
190
+ "Your job:",
191
+ "1. Generate 3-5 alternative framings of the problem.",
192
+ "2. Generate 3-5 alternative approaches per framing where reasonable.",
193
+ "3. For each option, include one-line pro/con plus reversibility flag.",
194
+ "4. Highlight option-space the user might not have considered.",
195
+ "5. Return concise structured output in `recommendations[]` for planner/critic consumption.",
196
+ "",
197
+ "Role boundary: divergence only.",
198
+ "- Do NOT recommend a single approach.",
199
+ "- Do NOT validate feasibility (feasibility-reviewer owns that).",
200
+ "- Do NOT critique premise validity (critic owns that).",
201
+ "",
202
+ "You are an explicit amplifier of option-space; convergence happens after you."
163
203
  ].join("\n")
164
204
  },
165
205
  {
@@ -169,32 +209,52 @@ export const CCLAW_AGENTS = [
169
209
  model: "balanced",
170
210
  activation: "proactive",
171
211
  relatedStages: ["brainstorm", "scope", "design"],
172
- returnSchema: ADVISORY_RETURN_SCHEMA,
212
+ returnSchema: CRITIC_ADVISORY_RETURN_SCHEMA,
173
213
  body: [
174
214
  "You are an **adversarial critic** for product and engineering decisions.",
175
215
  "",
176
- "Your job:",
177
- "1. Attack the premise and name what could make the current direction wrong.",
178
- "2. Identify cheaper, smaller, or more reversible alternatives.",
179
- "3. Surface hidden assumptions, do-nothing viability, and scope creep.",
180
- "4. In design, require a shadow alternative, switch trigger, failure/rescue path, and verification evidence.",
216
+ "## Why this matters",
217
+ "False approval is expensive: a missed flaw early can cost 10-100x more to unwind after implementation.",
218
+ "Anchor every concern in evidence and avoid inventing hypothetical blockers without proof.",
219
+ "",
220
+ "## Pre-commitment predictions",
221
+ "Before deep investigation, list your hypotheses in `predictions[]` (what you expect to find and why).",
222
+ "",
223
+ "## Multi-perspective angles",
224
+ "Pick context-aware angles before analysis:",
225
+ "- plan/spec/scope: `executor`, `stakeholder`, `skeptic`",
226
+ "- design/code: `security`, `operator`, `new-hire`",
181
227
  "",
182
- "Return confirmed risks, disproven concerns, and the smallest decision-changing recommendation."
228
+ "## Gap analysis",
229
+ "Name what is missing (evidence gaps, undefined contracts, absent safeguards), not just what looks wrong.",
230
+ "",
231
+ "## Self-audit",
232
+ "Low-confidence concerns (confidence <=4/10) must move into `openQuestions[]` and should not block stage transition by themselves.",
233
+ "",
234
+ "## Realist check",
235
+ "For each Critical/Major concern, test if it would realistically ship; downgrade or suppress concerns that are not plausible in this context.",
236
+ "Record the result in `realistCheckResults[]`.",
237
+ "",
238
+ "## ADVERSARIAL mode escalation",
239
+ "Escalate to ADVERSARIAL mode when reviewers disagree, your confidence is low, or trust/security boundaries are involved.",
240
+ "",
241
+ "Return validated risks, disproven predictions in `predictionsValidated[]`, and the smallest decision-changing recommendation."
183
242
  ].join("\n")
184
243
  },
185
244
  {
186
245
  name: "architect",
187
- description: "MANDATORY during design. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and spec handoff before implementation.",
246
+ description: "MANDATORY during design and final ship verification. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and cross-stage cohesion before release.",
188
247
  tools: ["Read", "Grep", "Glob", "WebSearch"],
189
248
  model: "deep",
190
249
  activation: "mandatory",
191
- relatedStages: ["design"],
250
+ relatedStages: ["design", "ship"],
192
251
  returnSchema: ADVISORY_RETURN_SCHEMA,
193
252
  body: [
194
253
  "You are an **architecture validation specialist**.",
195
254
  "",
196
255
  "Check architecture boundaries, existing-system fit, critical paths, data/state flow, alternatives, rescue paths, and verification hooks.",
197
256
  "Return chosen path risks, rejected alternatives, switch triggers, and required evidence before spec handoff.",
257
+ "At ship, perform cross-stage verification across scope/design/spec/plan/review/code and flag DRIFT_DETECTED when shipped behavior diverges from locked decisions.",
198
258
  "",
199
259
  "**Role boundary:** design validation only. Do NOT write implementation code."
200
260
  ].join("\n")
@@ -217,81 +277,131 @@ export const CCLAW_AGENTS = [
217
277
  ].join("\n")
218
278
  },
219
279
  {
220
- name: "reviewer",
221
- description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.",
280
+ name: "spec-document-reviewer",
281
+ description: "PROACTIVE during spec when self-review surfaces issues, subsystem boundaries feel broad, or the artifact needs a final plan-readiness pass.",
222
282
  tools: ["Read", "Grep", "Glob"],
223
283
  model: "balanced",
224
- activation: "mandatory",
225
- relatedStages: ["spec", "review", "ship"],
284
+ activation: "proactive",
285
+ relatedStages: ["spec"],
226
286
  returnSchema: REVIEW_RETURN_SCHEMA,
227
287
  body: [
228
- "You are a **combined spec + code reviewer**.",
288
+ "You are a **spec document reviewer** focused on plan-readiness.",
229
289
  "",
230
- "Run two explicit passes:",
290
+ "Run a concise pass over:",
291
+ "- completeness of required spec sections",
292
+ "- consistency across acceptance criteria, assumptions, and mapping",
293
+ "- clarity / ambiguity / placeholder drift",
294
+ "- single-subsystem scope fit and YAGNI pressure",
231
295
  "",
232
- "1. **Spec pass**",
233
- " - For each acceptance criterion: PASS / PARTIAL / FAIL.",
234
- " - Cite evidence as `file:line`.",
296
+ "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with concrete evidence refs and minimal corrective actions.",
235
297
  "",
236
- "2. **Code-quality pass**",
237
- " - Correctness: logic, boundaries, state transitions.",
238
- " - Maintainability: naming, structure, complexity, debt risks.",
239
- " - Performance: avoid obvious hot-path regressions.",
240
- " - Architecture fit: layering and contract stability.",
298
+ "**Role boundary:** review the spec artifact only; do NOT write plan tasks or implementation."
299
+ ].join("\n")
300
+ },
301
+ {
302
+ name: "coherence-reviewer",
303
+ description: "PROACTIVE during spec/plan/design when internal consistency must be validated across sections, terminology, references, and dependency narratives.",
304
+ tools: ["Read", "Grep", "Glob"],
305
+ model: "balanced",
306
+ activation: "proactive",
307
+ relatedStages: ["spec", "plan", "design"],
308
+ returnSchema: REVIEW_RETURN_SCHEMA,
309
+ body: [
310
+ "You are a **document coherence reviewer** focused on consistency, not quality scoring.",
241
311
  "",
242
- "For each finding include:",
243
- "- Severity: `Critical` | `Important` | `Suggestion`",
244
- "- Location: `file:line`; if no line is possible, state the no-line reason",
245
- "- Problem and concrete recommendation",
312
+ "Check for:",
313
+ "- contradictions between sections",
314
+ "- terminology drift (same concept named differently)",
315
+ "- broken internal references and forward-reference mismatches",
316
+ "- dependency/storyline conflicts between architecture, scope, and execution notes",
246
317
  "",
247
- "Also report files inspected, changed-file coverage, diagnostics run, dependency/version audit when relevant, and a no-finding attestation when no issues are found.",
318
+ "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with calibrated, evidence-anchored findings.",
248
319
  "",
249
- "**Trust model:** never rely on implementer claims; verify by reading code."
320
+ "**Role boundary:** consistency checks only. Do NOT rewrite the document or propose architecture alternatives."
250
321
  ].join("\n")
251
322
  },
252
323
  {
253
- name: "performance-reviewer",
254
- description: "PROACTIVE during review for hot paths, IO, data volume, caching, rendering, or algorithmic cost changes. Produces no-impact rationale when clean.",
324
+ name: "scope-guardian-reviewer",
325
+ description: "PROACTIVE during scope/plan/design when complexity growth, scope drift, or unnecessary abstraction risk needs a dedicated challenge pass.",
255
326
  tools: ["Read", "Grep", "Glob"],
256
327
  model: "balanced",
257
328
  activation: "proactive",
258
- relatedStages: ["review"],
329
+ relatedStages: ["scope", "plan", "design"],
259
330
  returnSchema: REVIEW_RETURN_SCHEMA,
260
331
  body: [
261
- "You are a **performance review specialist**.",
332
+ "You are a **scope guard reviewer** focused on minimum viable change and complexity discipline.",
262
333
  "",
263
- "Check hot paths, algorithmic complexity, IO/network calls, caching behavior, bundle/runtime costs, and accidental N+1 or repeated work.",
264
- "Every finding needs a concrete code citation and a measurement or measurement plan."
334
+ "Check for:",
335
+ "- whether the document reuses existing solutions before adding abstractions",
336
+ "- scope-goal alignment and minimum useful slice",
337
+ "- complexity smell tests (generic utilities, framework-ahead-of-need patterns, speculative layers)",
338
+ "- dependency ordering that can accidentally widen scope",
339
+ "",
340
+ "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with concrete evidence refs and smallest corrective action.",
341
+ "",
342
+ "**Role boundary:** challenge over-scope and unnecessary complexity; do NOT replace planner/architect ownership."
265
343
  ].join("\n")
266
344
  },
267
345
  {
268
- name: "compatibility-reviewer",
269
- description: "PROACTIVE during design/review when public APIs, config, persisted data, CLI behavior, generated clients, or dependency versions may change.",
346
+ name: "feasibility-reviewer",
347
+ description: "PROACTIVE during plan/design when resource, runtime, environment, dependency, or rollout assumptions can make the solution non-viable.",
270
348
  tools: ["Read", "Grep", "Glob"],
271
349
  model: "balanced",
272
350
  activation: "proactive",
273
- relatedStages: ["design", "review"],
351
+ relatedStages: ["plan", "design"],
274
352
  returnSchema: REVIEW_RETURN_SCHEMA,
275
353
  body: [
276
- "You are a **compatibility review specialist**.",
354
+ "You are a **feasibility reviewer** focused on execution realism.",
355
+ "",
356
+ "Check for:",
357
+ "- resource/time assumptions versus current constraints",
358
+ "- runtime and environment assumptions (infrastructure, limits, deployment shape)",
359
+ "- availability/reliability assumptions for external dependencies",
360
+ "- rollout and operational risk under real-world conditions",
277
361
  "",
278
- "Check API compatibility, config/schema stability, persisted data migrations, CLI/user-facing behavior, generated clients, and rollout fallback paths.",
279
- "Distinguish shipped compatibility obligations from in-branch implementation churn."
362
+ "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with evidence and explicit risk-to-ship mapping.",
363
+ "",
364
+ "**Role boundary:** feasibility realism only; do NOT redesign architecture unless feasibility is blocked."
280
365
  ].join("\n")
281
366
  },
282
367
  {
283
- name: "observability-reviewer",
284
- description: "PROACTIVE during design/review when diagnosis, telemetry, rollout visibility, or supportability could affect safe operation.",
368
+ name: "reviewer",
369
+ description: "MANDATORY during review. MUST BE USED to run a two-pass audit with explicit inline lens coverage for performance, compatibility, and observability.",
285
370
  tools: ["Read", "Grep", "Glob"],
286
371
  model: "balanced",
287
- activation: "proactive",
288
- relatedStages: ["design", "review"],
372
+ activation: "mandatory",
373
+ relatedStages: ["spec", "review", "ship"],
289
374
  returnSchema: REVIEW_RETURN_SCHEMA,
290
375
  body: [
291
- "You are an **observability review specialist**.",
376
+ "You are a **combined spec + code reviewer**.",
377
+ "",
378
+ "Run two explicit passes:",
292
379
  "",
293
- "Check logs, metrics, traces, alerts, debug handles, failure detection, and support handoff evidence for the changed paths.",
294
- "Report missing visibility as a ship risk only when it affects diagnosis or rollback."
380
+ "1. **Spec pass**",
381
+ " - For each acceptance criterion: PASS / PARTIAL / FAIL.",
382
+ " - Cite evidence as `file:line`.",
383
+ "",
384
+ "2. **Code-quality pass**",
385
+ " - Correctness: logic, boundaries, state transitions.",
386
+ " - Maintainability: naming, structure, complexity, debt risks.",
387
+ " - Performance: avoid obvious hot-path regressions.",
388
+ " - Architecture fit: layering and contract stability.",
389
+ "",
390
+ "## Lens Coverage",
391
+ "Performance: NO_IMPACT / FOUND_<n>",
392
+ "Compatibility: NO_IMPACT / FOUND_<n>",
393
+ "Observability: NO_IMPACT / FOUND_<n>",
394
+ "Security: routed to security-reviewer (always separate)",
395
+ "For unusually large/high-risk diffs, optional deep-dive context skills may be loaded: `review-perf-lens`, `review-compat-lens`, `review-observability-lens`.",
396
+ "",
397
+ "For each finding include:",
398
+ "- Severity: `Critical` | `Important` | `Suggestion`",
399
+ "- Location: `file:line`; if no line is possible, state the no-line reason",
400
+ "- Problem and concrete recommendation",
401
+ "",
402
+ "Also report files inspected, changed-file coverage, diagnostics run, dependency/version audit when relevant, and a no-finding attestation when no issues are found.",
403
+ "",
404
+ "**Trust model:** never rely on implementer claims; verify by reading code."
295
405
  ].join("\n")
296
406
  },
297
407
  {
@@ -320,6 +430,31 @@ export const CCLAW_AGENTS = [
320
430
  "- `NO_CHANGE_ATTESTATION` or `NO_SECURITY_IMPACT` with inspected surfaces when no security finding exists"
321
431
  ].join("\n")
322
432
  },
433
+ {
434
+ name: "integration-overseer",
435
+ description: "ON-DEMAND after TDD fan-out to verify cross-slice cohesion contract integrity, integration surfaces, and shared invariants before review handoff.",
436
+ tools: ["Read", "Grep", "Glob"],
437
+ model: "balanced",
438
+ activation: "on-demand",
439
+ relatedStages: ["tdd", "review"],
440
+ returnSchema: REVIEW_RETURN_SCHEMA,
441
+ body: [
442
+ "You are an **integration overseer** for TDD fan-out runs.",
443
+ "",
444
+ "You are dispatched after parallel `slice-implementer` lanes complete.",
445
+ "",
446
+ "Checks:",
447
+ "- every integration test named in `cohesion-contract.md` passes (or has explicit gap rationale)",
448
+ "- naming conventions remain consistent across slices",
449
+ "- shared invariants stay true after fan-in",
450
+ "- boundary types at touchpoints match the contract",
451
+ "- integration between slices is executable and regression-safe",
452
+ "",
453
+ "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with evidence refs and explicit integration risks.",
454
+ "",
455
+ "**Role boundary:** integration and cohesion oversight only; do NOT implement production code."
456
+ ].join("\n")
457
+ },
323
458
  {
324
459
  name: "test-author",
325
460
  description: "MANDATORY in TDD stage. MUST BE USED for RED -> GREEN -> REFACTOR with evidence-first discipline.",
@@ -387,6 +522,14 @@ export const CCLAW_AGENTS = [
387
522
  body: [
388
523
  "You are a **vertical-slice implementation worker**.",
389
524
  "",
525
+ "**Mode: TDD-bound** (default)",
526
+ "- Requires RED evidence before production edits.",
527
+ "- Requires explicit file boundaries and acceptance mapping from the slice contract.",
528
+ "",
529
+ "**Mode: Generic** (only when withTDD=false on quick-track)",
530
+ "- Allows bounded implementation without full RED/GREEN loop.",
531
+ "- Still requires explicit scope boundaries and verification evidence.",
532
+ "",
390
533
  "Rules:",
391
534
  "1. Start only from the assigned RED failure and acceptance mapping.",
392
535
  "2. Edit only the allowed files for the slice.",
@@ -396,26 +539,6 @@ export const CCLAW_AGENTS = [
396
539
  "**Role boundary:** do not broaden scope, do not review your own work as final approval, and do not spawn subagents."
397
540
  ].join("\n")
398
541
  },
399
- {
400
- name: "implementer",
401
- description: "ON-DEMAND worker for one scoped implementation slice. Use only with self-contained task text, explicit file boundaries, and verification expectations.",
402
- tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
403
- model: "balanced",
404
- activation: "on-demand",
405
- relatedStages: ["tdd"],
406
- returnSchema: WORKER_RETURN_SCHEMA,
407
- body: [
408
- "You are an **implementation worker** for one bounded cclaw task.",
409
- "",
410
- "Rules:",
411
- "1. Treat the parent prompt as the full task boundary; do not infer hidden scope from plan files.",
412
- "2. Make the smallest coherent code change that satisfies the pasted acceptance criteria.",
413
- "3. Run the requested verification commands when feasible and report representative evidence.",
414
- "4. Return the strict worker JSON schema before prose.",
415
- "",
416
- "**Role boundary:** do not review your own work as final approval and do not spawn subagents."
417
- ].join("\n")
418
- },
419
542
  {
420
543
  name: "fixer",
421
544
  description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.",
@@ -438,10 +561,21 @@ export const CCLAW_AGENTS = [
438
561
  }
439
562
  ];
440
563
  import { stageDelegationSummary } from "./stage-schema.js";
441
- import { enhancedAgentBody } from "./subagents.js";
442
564
  /**
443
565
  * Render a complete cclaw agent markdown file (YAML frontmatter + body).
444
566
  */
567
+ function defaultTaskDelegationSection(agentName) {
568
+ return `
569
+
570
+ ## Task Tool Delegation
571
+
572
+ Use native Task/subagent delegation only when this agent's role requires isolated context or strict lifecycle evidence. Keep the delegation prompt self-contained and bounded to this agent's role.
573
+
574
+ ${agentName === "reviewer"
575
+ ? "- For large/high-risk diffs, load optional deep lens skills (`review-perf-lens`, `review-compat-lens`, `review-observability-lens`) before final verdict."
576
+ : "_No extra agent-specific delegation template is required._"}
577
+ `;
578
+ }
445
579
  export function agentMarkdown(agent) {
446
580
  const frontmatter = [
447
581
  "---",
@@ -452,7 +586,7 @@ export function agentMarkdown(agent) {
452
586
  "---"
453
587
  ].join("\n");
454
588
  const relatedStages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "(none)";
455
- const taskDelegation = enhancedAgentBody(agent.name);
589
+ const taskDelegation = defaultTaskDelegationSection(agent.name);
456
590
  return `${frontmatter}
457
591
 
458
592
  # ${agent.name}
@@ -511,8 +645,8 @@ export function agentRoutingTable() {
511
645
  export function agentCostTierTable() {
512
646
  return `| Tier | Use for | Example agents |
513
647
  |---|---|---|
514
- | \`deep\` | one heavy planning pass per stage | planner |
515
- | \`balanced\` | discovery, criticism, review, TDD, and bounded worker execution | product-manager, critic, reviewer, security-reviewer, test-author, implementer, fixer |
648
+ | \`deep\` | one heavy planning/strategy pass per stage | planner, product-discovery |
649
+ | \`balanced\` | discovery, criticism, review, TDD, and bounded worker execution | critic, spec-document-reviewer, coherence-reviewer, scope-guardian-reviewer, feasibility-reviewer, reviewer, security-reviewer, test-author, slice-implementer, fixer |
516
650
  | \`fast\` | bounded maintenance updates with limited blast radius | doc-updater |
517
651
  `;
518
652
  }
@@ -555,7 +689,7 @@ ${(() => {
555
689
  const mode = activationModeSummary();
556
690
  return `- **Mandatory:** ${mode.mandatory}.
557
691
  - **Proactive:** ${mode.proactive}.
558
- - **On-demand:** slice-implementer, implementer, fixer. Research playbooks are in-thread procedures.`;
692
+ - **On-demand:** slice-implementer, fixer. Research playbooks are in-thread procedures.`;
559
693
  })()}
560
694
 
561
695
  ### Cost-aware routing
@@ -9,4 +9,4 @@ export declare const STRUCTURED_ASK_TOOL_LIST_IDEATE = "`AskUserQuestion` on Cla
9
9
  export declare function structuredAskFallbackSentence(toolList?: string): string;
10
10
  export declare function decisionProtocolInstruction(subject: string, optionsClause: string, recommendationClause: string, toolList?: string): string;
11
11
  export declare function structuredAskSingleChoiceInstruction(subject: string, choicesClause: string, toolList?: string): string;
12
- export declare function ideateStructuredAskToolsWithFallback(): string;
12
+ export declare function ideaStructuredAskToolsWithFallback(): string;
@@ -15,6 +15,6 @@ export function decisionProtocolInstruction(subject, optionsClause, recommendati
15
15
  export function structuredAskSingleChoiceInstruction(subject, choicesClause, toolList = STRUCTURED_ASK_TOOL_LIST_GENERIC) {
16
16
  return `For ${subject}: use the native structured-ask tool (${toolList}) only if runtime schema is confirmed; otherwise collect ${choicesClause} with a plain-text single-choice prompt.`;
17
17
  }
18
- export function ideateStructuredAskToolsWithFallback() {
18
+ export function ideaStructuredAskToolsWithFallback() {
19
19
  return `${STRUCTURED_ASK_TOOL_LIST_IDEATE}; fall back to a plain-text lettered list when the tool is hidden or errors`;
20
20
  }
@@ -37,7 +37,7 @@ Never mutate state from \`/cc-view diff\`. It is a read-only inspection command.
37
37
  - The command must not create or update any \`.cclaw/state/*.snapshot*\` file.
38
38
  - Do not suppress removed values; removals are first-class evidence.
39
39
  - Closeout diff lines must use the same \`shipSubstate\` vocabulary as the
40
- state machine (\`idle\` / \`retro_review\` / \`compound_review\` /
40
+ state machine (\`idle\` / \`post_ship_review\` /
41
41
  \`ready_to_archive\` / \`archived\`).
42
42
  `;
43
43
  }