cclaw-cli 0.51.24 → 0.51.25

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 (37) hide show
  1. package/README.md +135 -414
  2. package/dist/artifact-linter.js +10 -6
  3. package/dist/config.d.ts +1 -1
  4. package/dist/config.js +28 -3
  5. package/dist/content/core-agents.d.ts +110 -0
  6. package/dist/content/core-agents.js +235 -3
  7. package/dist/content/examples.js +8 -5
  8. package/dist/content/next-command.js +10 -6
  9. package/dist/content/reference-patterns.d.ts +18 -0
  10. package/dist/content/reference-patterns.js +391 -0
  11. package/dist/content/skills.js +39 -34
  12. package/dist/content/stage-common-guidance.js +19 -3
  13. package/dist/content/stage-schema.d.ts +12 -0
  14. package/dist/content/stage-schema.js +184 -28
  15. package/dist/content/stages/_lint-metadata/index.js +3 -2
  16. package/dist/content/stages/brainstorm.js +7 -3
  17. package/dist/content/stages/design.js +12 -3
  18. package/dist/content/stages/review.js +7 -5
  19. package/dist/content/stages/schema-types.d.ts +9 -2
  20. package/dist/content/stages/scope.js +8 -2
  21. package/dist/content/stages/ship.js +3 -2
  22. package/dist/content/stages/tdd.js +18 -13
  23. package/dist/content/start-command.js +3 -2
  24. package/dist/content/status-command.js +9 -4
  25. package/dist/content/subagents.js +281 -39
  26. package/dist/content/templates.js +64 -3
  27. package/dist/delegation.d.ts +2 -0
  28. package/dist/delegation.js +27 -6
  29. package/dist/doctor.js +47 -5
  30. package/dist/gate-evidence.js +25 -2
  31. package/dist/install.js +2 -9
  32. package/dist/internal/advance-stage.js +179 -26
  33. package/dist/run-persistence.js +21 -3
  34. package/dist/tdd-verification-evidence.d.ts +17 -0
  35. package/dist/tdd-verification-evidence.js +43 -0
  36. package/dist/types.d.ts +10 -0
  37. package/package.json +1 -1
package/dist/config.d.ts CHANGED
@@ -49,7 +49,7 @@ export declare function readConfig(projectRoot: string, options?: ReadConfigOpti
49
49
  * the user set them explicitly. Keeps the default template small and honest:
50
50
  * only knobs a new user would meaningfully flip show up.
51
51
  */
52
- type AdvancedConfigKey = "tddTestGlobs" | "tdd" | "compound" | "defaultTrack" | "languageRulePacks" | "trackHeuristics" | "sliceReview" | "ironLaws" | "optInAudits" | "reviewLoop";
52
+ type AdvancedConfigKey = "vcs" | "tddTestGlobs" | "tdd" | "compound" | "defaultTrack" | "languageRulePacks" | "trackHeuristics" | "sliceReview" | "ironLaws" | "optInAudits" | "reviewLoop";
53
53
  /**
54
54
  * Options controlling the serialisation shape of `config.yaml`.
55
55
  *
package/dist/config.js CHANGED
@@ -16,6 +16,7 @@ const ALLOWED_CONFIG_KEYS = new Set([
16
16
  "version",
17
17
  "flowVersion",
18
18
  "harnesses",
19
+ "vcs",
19
20
  "strictness",
20
21
  "tddTestGlobs",
21
22
  "tdd",
@@ -51,6 +52,7 @@ const MINIMAL_CONFIG_KEYS = [
51
52
  "version",
52
53
  "flowVersion",
53
54
  "harnesses",
55
+ "vcs",
54
56
  "strictness",
55
57
  "gitHookGuards"
56
58
  ];
@@ -142,11 +144,13 @@ export function createDefaultConfig(harnesses = DEFAULT_HARNESSES, defaultTrack
142
144
  version: CCLAW_VERSION,
143
145
  flowVersion: FLOW_VERSION,
144
146
  harnesses,
147
+ vcs: "git-local-only",
145
148
  strictness: "advisory",
146
149
  tddTestGlobs: [...tddTestPathPatterns],
147
150
  tdd: {
148
151
  testPathPatterns: tddTestPathPatterns,
149
- productionPathPatterns: tddProductionPathPatterns
152
+ productionPathPatterns: tddProductionPathPatterns,
153
+ verificationRef: "auto"
150
154
  },
151
155
  compound: {
152
156
  recurrenceThreshold: DEFAULT_COMPOUND_RECURRENCE_THRESHOLD
@@ -244,6 +248,16 @@ export async function readConfig(projectRoot, options = {}) {
244
248
  const harnesses = hasHarnessesField
245
249
  ? [...new Set(validatedHarnesses)]
246
250
  : DEFAULT_HARNESSES;
251
+ const vcsRaw = parsed.vcs;
252
+ if (Object.prototype.hasOwnProperty.call(parsed, "vcs") &&
253
+ vcsRaw !== "git-with-remote" &&
254
+ vcsRaw !== "git-local-only" &&
255
+ vcsRaw !== "none") {
256
+ throw configValidationError(fullPath, `"vcs" must be one of: git-with-remote, git-local-only, none`);
257
+ }
258
+ const vcs = vcsRaw === "git-with-remote" || vcsRaw === "git-local-only" || vcsRaw === "none"
259
+ ? vcsRaw
260
+ : "git-local-only";
247
261
  const strictnessRaw = parsed.strictness;
248
262
  if (Object.prototype.hasOwnProperty.call(parsed, "strictness") &&
249
263
  strictnessRaw !== "advisory" &&
@@ -258,16 +272,24 @@ export async function readConfig(projectRoot, options = {}) {
258
272
  const tddRaw = parsed.tdd;
259
273
  let explicitTddTestPathPatterns;
260
274
  let explicitTddProductionPathPatterns;
275
+ let explicitTddVerificationRef;
261
276
  if (hasTddField) {
262
277
  if (!isRecord(tddRaw)) {
263
278
  throw configValidationError(fullPath, `"tdd" must be an object`);
264
279
  }
265
- const unknownTddKeys = Object.keys(tddRaw).filter((key) => key !== "testPathPatterns" && key !== "productionPathPatterns");
280
+ const unknownTddKeys = Object.keys(tddRaw).filter((key) => key !== "testPathPatterns" && key !== "productionPathPatterns" && key !== "verificationRef");
266
281
  if (unknownTddKeys.length > 0) {
267
282
  throw configValidationError(fullPath, `"tdd" has unknown key(s): ${unknownTddKeys.join(", ")}`);
268
283
  }
269
284
  explicitTddTestPathPatterns = validateStringArray(tddRaw.testPathPatterns, "tdd.testPathPatterns", fullPath);
270
285
  explicitTddProductionPathPatterns = validateStringArray(tddRaw.productionPathPatterns, "tdd.productionPathPatterns", fullPath);
286
+ if (tddRaw.verificationRef !== undefined &&
287
+ tddRaw.verificationRef !== "auto" &&
288
+ tddRaw.verificationRef !== "required" &&
289
+ tddRaw.verificationRef !== "disabled") {
290
+ throw configValidationError(fullPath, '"tdd.verificationRef" must be one of: auto, required, disabled');
291
+ }
292
+ explicitTddVerificationRef = tddRaw.verificationRef;
271
293
  }
272
294
  if (tddTestGlobsRaw !== undefined &&
273
295
  explicitTddTestPathPatterns !== undefined &&
@@ -508,11 +530,13 @@ export async function readConfig(projectRoot, options = {}) {
508
530
  version: parsed.version ?? CCLAW_VERSION,
509
531
  flowVersion: parsed.flowVersion ?? FLOW_VERSION,
510
532
  harnesses,
533
+ vcs,
511
534
  strictness,
512
535
  tddTestGlobs,
513
536
  tdd: {
514
537
  testPathPatterns: resolvedTddTestPathPatterns,
515
- productionPathPatterns: resolvedTddProductionPathPatterns
538
+ productionPathPatterns: resolvedTddProductionPathPatterns,
539
+ verificationRef: explicitTddVerificationRef ?? "auto"
516
540
  },
517
541
  compound: {
518
542
  recurrenceThreshold: compoundRecurrenceThreshold
@@ -538,6 +562,7 @@ function buildSerializableConfig(config, options = {}) {
538
562
  "version",
539
563
  "flowVersion",
540
564
  "harnesses",
565
+ "vcs",
541
566
  "strictness",
542
567
  "tddTestGlobs",
543
568
  "tdd",
@@ -6,6 +6,16 @@
6
6
  * need isolated subagent context lives in `.cclaw/skills/research/*.md`
7
7
  * playbooks and is executed in-thread by the primary agent.
8
8
  */
9
+ export interface AgentReturnSchema {
10
+ /** Field carrying the terminal verdict/status token. */
11
+ statusField: string;
12
+ /** Exact allowed terminal values for this agent's first structured return. */
13
+ allowedStatuses: string[];
14
+ /** Fields the controller should expect in every completed response. */
15
+ requiredFields: string[];
16
+ /** Fields that must cite artifact anchors, commands, or code locations when applicable. */
17
+ evidenceFields: string[];
18
+ }
9
19
  export interface AgentDefinition {
10
20
  /** Kebab-case identifier, e.g. `"reviewer"`. */
11
21
  name: string;
@@ -19,6 +29,8 @@ export interface AgentDefinition {
19
29
  activation: "proactive" | "on-demand" | "mandatory";
20
30
  /** cclaw flow stages this agent is designed to support. */
21
31
  relatedStages: string[];
32
+ /** Strict terminal return contract rendered into materialized agent files. */
33
+ returnSchema: AgentReturnSchema;
22
34
  /** Markdown body rendered below the YAML frontmatter. */
23
35
  body: string;
24
36
  }
@@ -32,12 +44,22 @@ export interface AgentDefinition {
32
44
  * to `string` and break the compile-time drift guard.
33
45
  */
34
46
  export declare const CCLAW_AGENTS: readonly [{
47
+ readonly name: "researcher";
48
+ readonly description: "PROACTIVE when context readiness, repo search, reference patterns, or external docs could change a stage decision. MUST summarize search-before-read evidence before large reads.";
49
+ readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
50
+ readonly model: "fast";
51
+ readonly activation: "proactive";
52
+ readonly relatedStages: ["brainstorm", "scope", "design", "plan"];
53
+ readonly returnSchema: AgentReturnSchema;
54
+ readonly body: string;
55
+ }, {
35
56
  readonly name: "planner";
36
57
  readonly description: "MANDATORY for scope/design/plan and PROACTIVE for high-ambiguity work. MUST BE USED when sequencing, dependency mapping, or risk trade-offs are required before coding.";
37
58
  readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
38
59
  readonly model: "deep";
39
60
  readonly activation: "mandatory";
40
61
  readonly relatedStages: ["brainstorm", "scope", "design", "spec", "plan"];
62
+ readonly returnSchema: AgentReturnSchema;
41
63
  readonly body: string;
42
64
  }, {
43
65
  readonly name: "product-manager";
@@ -46,6 +68,7 @@ export declare const CCLAW_AGENTS: readonly [{
46
68
  readonly model: "balanced";
47
69
  readonly activation: "proactive";
48
70
  readonly relatedStages: ["brainstorm", "scope"];
71
+ readonly returnSchema: AgentReturnSchema;
49
72
  readonly body: string;
50
73
  }, {
51
74
  readonly name: "critic";
@@ -54,6 +77,25 @@ export declare const CCLAW_AGENTS: readonly [{
54
77
  readonly model: "balanced";
55
78
  readonly activation: "proactive";
56
79
  readonly relatedStages: ["brainstorm", "scope", "design"];
80
+ readonly returnSchema: AgentReturnSchema;
81
+ readonly body: string;
82
+ }, {
83
+ 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.";
85
+ readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
86
+ readonly model: "deep";
87
+ readonly activation: "mandatory";
88
+ readonly relatedStages: ["design"];
89
+ readonly returnSchema: AgentReturnSchema;
90
+ readonly body: string;
91
+ }, {
92
+ readonly name: "spec-validator";
93
+ readonly description: "MANDATORY during standard/deep spec. MUST BE USED to validate measurable acceptance criteria, assumptions, edge cases, and testability mapping.";
94
+ readonly tools: ["Read", "Grep", "Glob"];
95
+ readonly model: "balanced";
96
+ readonly activation: "mandatory";
97
+ readonly relatedStages: ["spec"];
98
+ readonly returnSchema: AgentReturnSchema;
57
99
  readonly body: string;
58
100
  }, {
59
101
  readonly name: "reviewer";
@@ -62,6 +104,34 @@ export declare const CCLAW_AGENTS: readonly [{
62
104
  readonly model: "balanced";
63
105
  readonly activation: "mandatory";
64
106
  readonly relatedStages: ["spec", "review", "ship"];
107
+ readonly returnSchema: AgentReturnSchema;
108
+ readonly body: string;
109
+ }, {
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.";
112
+ readonly tools: ["Read", "Grep", "Glob"];
113
+ readonly model: "balanced";
114
+ readonly activation: "proactive";
115
+ readonly relatedStages: ["review"];
116
+ readonly returnSchema: AgentReturnSchema;
117
+ readonly body: string;
118
+ }, {
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.";
121
+ readonly tools: ["Read", "Grep", "Glob"];
122
+ readonly model: "balanced";
123
+ readonly activation: "proactive";
124
+ readonly relatedStages: ["design", "review"];
125
+ readonly returnSchema: AgentReturnSchema;
126
+ readonly body: string;
127
+ }, {
128
+ readonly name: "observability-reviewer";
129
+ readonly description: "PROACTIVE during design/review when diagnosis, telemetry, rollout visibility, or supportability could affect safe operation.";
130
+ readonly tools: ["Read", "Grep", "Glob"];
131
+ readonly model: "balanced";
132
+ readonly activation: "proactive";
133
+ readonly relatedStages: ["design", "review"];
134
+ readonly returnSchema: AgentReturnSchema;
65
135
  readonly body: string;
66
136
  }, {
67
137
  readonly name: "security-reviewer";
@@ -70,6 +140,7 @@ export declare const CCLAW_AGENTS: readonly [{
70
140
  readonly model: "balanced";
71
141
  readonly activation: "mandatory";
72
142
  readonly relatedStages: ["design", "review", "ship"];
143
+ readonly returnSchema: AgentReturnSchema;
73
144
  readonly body: string;
74
145
  }, {
75
146
  readonly name: "test-author";
@@ -78,6 +149,16 @@ export declare const CCLAW_AGENTS: readonly [{
78
149
  readonly model: "balanced";
79
150
  readonly activation: "mandatory";
80
151
  readonly relatedStages: ["tdd"];
152
+ readonly returnSchema: AgentReturnSchema;
153
+ readonly body: string;
154
+ }, {
155
+ readonly name: "release-reviewer";
156
+ readonly description: "MANDATORY during ship. MUST BE USED for release readiness, rollback, finalization mode, evidence freshness, and victory detector checks.";
157
+ readonly tools: ["Read", "Grep", "Glob", "Bash"];
158
+ readonly model: "balanced";
159
+ readonly activation: "mandatory";
160
+ readonly relatedStages: ["ship"];
161
+ readonly returnSchema: AgentReturnSchema;
81
162
  readonly body: string;
82
163
  }, {
83
164
  readonly name: "doc-updater";
@@ -86,6 +167,34 @@ export declare const CCLAW_AGENTS: readonly [{
86
167
  readonly model: "fast";
87
168
  readonly activation: "mandatory";
88
169
  readonly relatedStages: ["tdd", "ship"];
170
+ readonly returnSchema: AgentReturnSchema;
171
+ readonly body: string;
172
+ }, {
173
+ readonly name: "slice-implementer";
174
+ readonly description: "ON-DEMAND or PROACTIVE during TDD GREEN/REFACTOR for one bounded vertical slice after RED evidence exists and file ownership is non-overlapping.";
175
+ readonly tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"];
176
+ readonly model: "balanced";
177
+ readonly activation: "on-demand";
178
+ readonly relatedStages: ["tdd"];
179
+ readonly returnSchema: AgentReturnSchema;
180
+ 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
+ }, {
191
+ readonly name: "fixer";
192
+ readonly description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.";
193
+ readonly tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"];
194
+ readonly model: "balanced";
195
+ readonly activation: "on-demand";
196
+ readonly relatedStages: ["review", "tdd"];
197
+ readonly returnSchema: AgentReturnSchema;
89
198
  readonly body: string;
90
199
  }];
91
200
  /**
@@ -106,6 +215,7 @@ export declare function agentRoutingTable(): string;
106
215
  * Cost tier routing for the specialist agent roster.
107
216
  */
108
217
  export declare function agentCostTierTable(): string;
218
+ export declare function agentRegistryMatrix(): string;
109
219
  /**
110
220
  * AGENTS.md-ready section describing cclaw’s specialist delegation model.
111
221
  */
@@ -6,6 +6,38 @@ function yamlScalarString(value) {
6
6
  function yamlFlowSequence(values) {
7
7
  return JSON.stringify(values);
8
8
  }
9
+ const WORKER_RETURN_SCHEMA = {
10
+ statusField: "status",
11
+ allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
12
+ requiredFields: ["status", "filesChanged", "testsRun", "evidenceRefs", "concerns", "needsContext", "blockers"],
13
+ evidenceFields: ["testsRun", "evidenceRefs"]
14
+ };
15
+ const REVIEW_RETURN_SCHEMA = {
16
+ statusField: "status",
17
+ allowedStatuses: ["PASS", "PASS_WITH_GAPS", "FAIL", "BLOCKED"],
18
+ requiredFields: ["status", "findings", "criteria", "evidenceRefs", "blockers"],
19
+ evidenceFields: ["findings.location", "criteria.evidence", "evidenceRefs"]
20
+ };
21
+ const ADVISORY_RETURN_SCHEMA = {
22
+ statusField: "status",
23
+ allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
24
+ requiredFields: ["status", "summary", "recommendations", "evidenceRefs", "unknowns"],
25
+ evidenceFields: ["evidenceRefs", "recommendations"]
26
+ };
27
+ const DOC_RETURN_SCHEMA = {
28
+ statusField: "status",
29
+ allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
30
+ requiredFields: ["status", "filesUpdated", "summary", "evidenceRefs", "openQuestions"],
31
+ evidenceFields: ["filesUpdated", "evidenceRefs"]
32
+ };
33
+ function formatReturnSchema(schema) {
34
+ return [
35
+ `- Status field: \`${schema.statusField}\``,
36
+ `- Allowed statuses: ${schema.allowedStatuses.map((status) => `\`${status}\``).join(", ")}`,
37
+ `- Required fields: ${schema.requiredFields.map((field) => `\`${field}\``).join(", ")}`,
38
+ `- Evidence fields: ${schema.evidenceFields.map((field) => `\`${field}\``).join(", ")}`
39
+ ].join("\n");
40
+ }
9
41
  function formattedAgentsForStages(stages) {
10
42
  const summary = stageDelegationSummary("standard");
11
43
  const merged = [];
@@ -48,6 +80,26 @@ function activationModeSummary() {
48
80
  * to `string` and break the compile-time drift guard.
49
81
  */
50
82
  export const CCLAW_AGENTS = [
83
+ {
84
+ name: "researcher",
85
+ description: "PROACTIVE when context readiness, repo search, reference patterns, or external docs could change a stage decision. MUST summarize search-before-read evidence before large reads.",
86
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
87
+ model: "fast",
88
+ activation: "proactive",
89
+ relatedStages: ["brainstorm", "scope", "design", "plan"],
90
+ returnSchema: ADVISORY_RETURN_SCHEMA,
91
+ body: [
92
+ "You are a **context readiness and research specialist**.",
93
+ "",
94
+ "When invoked:",
95
+ "1. Start with search/query summaries before reading large files.",
96
+ "2. Name provider status when known: graph/search/docs/MCP/semantic index freshness.",
97
+ "3. Separate observed facts from assumptions and stale or missing context.",
98
+ "4. Return concise evidence refs the controller can paste into stage artifacts.",
99
+ "",
100
+ "**Role boundary:** research and context synthesis only. Do NOT edit files."
101
+ ].join("\n")
102
+ },
51
103
  {
52
104
  name: "planner",
53
105
  description: "MANDATORY for scope/design/plan and PROACTIVE for high-ambiguity work. MUST BE USED when sequencing, dependency mapping, or risk trade-offs are required before coding.",
@@ -55,6 +107,7 @@ export const CCLAW_AGENTS = [
55
107
  model: "deep",
56
108
  activation: "mandatory",
57
109
  relatedStages: ["brainstorm", "scope", "design", "spec", "plan"],
110
+ returnSchema: ADVISORY_RETURN_SCHEMA,
58
111
  body: [
59
112
  "You are an **implementation planning specialist** (staff engineer mindset).",
60
113
  "",
@@ -75,6 +128,7 @@ export const CCLAW_AGENTS = [
75
128
  model: "balanced",
76
129
  activation: "proactive",
77
130
  relatedStages: ["brainstorm", "scope"],
131
+ returnSchema: ADVISORY_RETURN_SCHEMA,
78
132
  body: [
79
133
  "You are a **product discovery specialist**.",
80
134
  "",
@@ -97,6 +151,7 @@ export const CCLAW_AGENTS = [
97
151
  model: "balanced",
98
152
  activation: "proactive",
99
153
  relatedStages: ["brainstorm", "scope", "design"],
154
+ returnSchema: ADVISORY_RETURN_SCHEMA,
100
155
  body: [
101
156
  "You are an **adversarial critic** for product and engineering decisions.",
102
157
  "",
@@ -109,6 +164,40 @@ export const CCLAW_AGENTS = [
109
164
  "Return confirmed risks, disproven concerns, and the smallest decision-changing recommendation."
110
165
  ].join("\n")
111
166
  },
167
+ {
168
+ name: "architect",
169
+ description: "MANDATORY during design. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and spec handoff before implementation.",
170
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
171
+ model: "deep",
172
+ activation: "mandatory",
173
+ relatedStages: ["design"],
174
+ returnSchema: ADVISORY_RETURN_SCHEMA,
175
+ body: [
176
+ "You are an **architecture validation specialist**.",
177
+ "",
178
+ "Check architecture boundaries, existing-system fit, critical paths, data/state flow, alternatives, rescue paths, and verification hooks.",
179
+ "Return chosen path risks, rejected alternatives, switch triggers, and required evidence before spec handoff.",
180
+ "",
181
+ "**Role boundary:** design validation only. Do NOT write implementation code."
182
+ ].join("\n")
183
+ },
184
+ {
185
+ name: "spec-validator",
186
+ description: "MANDATORY during standard/deep spec. MUST BE USED to validate measurable acceptance criteria, assumptions, edge cases, and testability mapping.",
187
+ tools: ["Read", "Grep", "Glob"],
188
+ model: "balanced",
189
+ activation: "mandatory",
190
+ relatedStages: ["spec"],
191
+ returnSchema: REVIEW_RETURN_SCHEMA,
192
+ body: [
193
+ "You are a **specification validation specialist**.",
194
+ "",
195
+ "For every acceptance criterion, verify it is observable, measurable, falsifiable, mapped to upstream decisions, and paired with concrete verification evidence.",
196
+ "Flag vague language, missing edge cases, hidden assumptions, and RED tests that cannot be expressed.",
197
+ "",
198
+ "**Role boundary:** validate the spec; do NOT write plan tasks or implementation."
199
+ ].join("\n")
200
+ },
112
201
  {
113
202
  name: "reviewer",
114
203
  description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.",
@@ -116,6 +205,7 @@ export const CCLAW_AGENTS = [
116
205
  model: "balanced",
117
206
  activation: "mandatory",
118
207
  relatedStages: ["spec", "review", "ship"],
208
+ returnSchema: REVIEW_RETURN_SCHEMA,
119
209
  body: [
120
210
  "You are a **combined spec + code reviewer**.",
121
211
  "",
@@ -141,6 +231,51 @@ export const CCLAW_AGENTS = [
141
231
  "**Trust model:** never rely on implementer claims; verify by reading code."
142
232
  ].join("\n")
143
233
  },
234
+ {
235
+ name: "performance-reviewer",
236
+ description: "PROACTIVE during review for hot paths, IO, data volume, caching, rendering, or algorithmic cost changes. Produces no-impact rationale when clean.",
237
+ tools: ["Read", "Grep", "Glob"],
238
+ model: "balanced",
239
+ activation: "proactive",
240
+ relatedStages: ["review"],
241
+ returnSchema: REVIEW_RETURN_SCHEMA,
242
+ body: [
243
+ "You are a **performance review specialist**.",
244
+ "",
245
+ "Check hot paths, algorithmic complexity, IO/network calls, caching behavior, bundle/runtime costs, and accidental N+1 or repeated work.",
246
+ "Every finding needs a concrete code citation and a measurement or measurement plan."
247
+ ].join("\n")
248
+ },
249
+ {
250
+ name: "compatibility-reviewer",
251
+ description: "PROACTIVE during design/review when public APIs, config, persisted data, CLI behavior, generated clients, or dependency versions may change.",
252
+ tools: ["Read", "Grep", "Glob"],
253
+ model: "balanced",
254
+ activation: "proactive",
255
+ relatedStages: ["design", "review"],
256
+ returnSchema: REVIEW_RETURN_SCHEMA,
257
+ body: [
258
+ "You are a **compatibility review specialist**.",
259
+ "",
260
+ "Check API compatibility, config/schema stability, persisted data migrations, CLI/user-facing behavior, generated clients, and rollout fallback paths.",
261
+ "Distinguish shipped compatibility obligations from in-branch implementation churn."
262
+ ].join("\n")
263
+ },
264
+ {
265
+ name: "observability-reviewer",
266
+ description: "PROACTIVE during design/review when diagnosis, telemetry, rollout visibility, or supportability could affect safe operation.",
267
+ tools: ["Read", "Grep", "Glob"],
268
+ model: "balanced",
269
+ activation: "proactive",
270
+ relatedStages: ["design", "review"],
271
+ returnSchema: REVIEW_RETURN_SCHEMA,
272
+ body: [
273
+ "You are an **observability review specialist**.",
274
+ "",
275
+ "Check logs, metrics, traces, alerts, debug handles, failure detection, and support handoff evidence for the changed paths.",
276
+ "Report missing visibility as a ship risk only when it affects diagnosis or rollback."
277
+ ].join("\n")
278
+ },
144
279
  {
145
280
  name: "security-reviewer",
146
281
  description: "MANDATORY during review; PROACTIVE during design/ship for trust-boundary changes. Always produce an explicit no-change attestation when no security-relevant surface moved.",
@@ -148,6 +283,7 @@ export const CCLAW_AGENTS = [
148
283
  model: "balanced",
149
284
  activation: "mandatory",
150
285
  relatedStages: ["design", "review", "ship"],
286
+ returnSchema: REVIEW_RETURN_SCHEMA,
151
287
  body: [
152
288
  "You are a **security vulnerability specialist** focused on exploitability.",
153
289
  "",
@@ -173,6 +309,7 @@ export const CCLAW_AGENTS = [
173
309
  model: "balanced",
174
310
  activation: "mandatory",
175
311
  relatedStages: ["tdd"],
312
+ returnSchema: WORKER_RETURN_SCHEMA,
176
313
  body: [
177
314
  "You are a **test-driven development** specialist.",
178
315
  "",
@@ -186,6 +323,21 @@ export const CCLAW_AGENTS = [
186
323
  "5. REFACTOR with behavior preserved."
187
324
  ].join("\n")
188
325
  },
326
+ {
327
+ name: "release-reviewer",
328
+ description: "MANDATORY during ship. MUST BE USED for release readiness, rollback, finalization mode, evidence freshness, and victory detector checks.",
329
+ tools: ["Read", "Grep", "Glob", "Bash"],
330
+ model: "balanced",
331
+ activation: "mandatory",
332
+ relatedStages: ["ship"],
333
+ returnSchema: REVIEW_RETURN_SCHEMA,
334
+ body: [
335
+ "You are a **release readiness reviewer**.",
336
+ "",
337
+ "Verify preflight evidence, review verdict freshness, rollback trigger and steps, finalization enum, no-VCS handoff when applicable, learnings capture, and handoff completeness.",
338
+ "Block ship on stale evidence, unresolved criticals, missing rollback, or ambiguous finalization."
339
+ ].join("\n")
340
+ },
189
341
  {
190
342
  name: "doc-updater",
191
343
  description: "MANDATORY only at ship; PROACTIVE during tdd/review whenever behavior, config, or public API changes. Keep docs and runbooks in lockstep with shipped behavior.",
@@ -193,6 +345,7 @@ export const CCLAW_AGENTS = [
193
345
  model: "fast",
194
346
  activation: "mandatory",
195
347
  relatedStages: ["tdd", "ship"],
348
+ returnSchema: DOC_RETURN_SCHEMA,
196
349
  body: [
197
350
  "You are a **documentation maintenance specialist**.",
198
351
  "",
@@ -204,6 +357,66 @@ export const CCLAW_AGENTS = [
204
357
  "",
205
358
  "Preserve existing tone and structure; avoid rewrites for style alone."
206
359
  ].join("\n")
360
+ },
361
+ {
362
+ name: "slice-implementer",
363
+ description: "ON-DEMAND or PROACTIVE during TDD GREEN/REFACTOR for one bounded vertical slice after RED evidence exists and file ownership is non-overlapping.",
364
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
365
+ model: "balanced",
366
+ activation: "on-demand",
367
+ relatedStages: ["tdd"],
368
+ returnSchema: WORKER_RETURN_SCHEMA,
369
+ body: [
370
+ "You are a **vertical-slice implementation worker**.",
371
+ "",
372
+ "Rules:",
373
+ "1. Start only from the assigned RED failure and acceptance mapping.",
374
+ "2. Edit only the allowed files for the slice.",
375
+ "3. Implement the minimal GREEN change, then preserve behavior during REFACTOR.",
376
+ "4. Return files changed, tests run, evidence refs, concerns, and blockers.",
377
+ "",
378
+ "**Role boundary:** do not broaden scope, do not review your own work as final approval, and do not spawn subagents."
379
+ ].join("\n")
380
+ },
381
+ {
382
+ name: "implementer",
383
+ description: "ON-DEMAND worker for one scoped implementation slice. Use only with self-contained task text, explicit file boundaries, and verification expectations.",
384
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
385
+ model: "balanced",
386
+ activation: "on-demand",
387
+ relatedStages: ["tdd"],
388
+ returnSchema: WORKER_RETURN_SCHEMA,
389
+ body: [
390
+ "You are an **implementation worker** for one bounded cclaw task.",
391
+ "",
392
+ "Rules:",
393
+ "1. Treat the parent prompt as the full task boundary; do not infer hidden scope from plan files.",
394
+ "2. Make the smallest coherent code change that satisfies the pasted acceptance criteria.",
395
+ "3. Run the requested verification commands when feasible and report representative evidence.",
396
+ "4. Return the strict worker JSON schema before prose.",
397
+ "",
398
+ "**Role boundary:** do not review your own work as final approval and do not spawn subagents."
399
+ ].join("\n")
400
+ },
401
+ {
402
+ name: "fixer",
403
+ description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.",
404
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
405
+ model: "balanced",
406
+ activation: "on-demand",
407
+ relatedStages: ["review", "tdd"],
408
+ returnSchema: WORKER_RETURN_SCHEMA,
409
+ body: [
410
+ "You are a **fresh fixer worker** dispatched after a review found a concrete gap.",
411
+ "",
412
+ "Rules:",
413
+ "1. Start from the failing criterion and reviewer evidence, not from implementer claims.",
414
+ "2. Stay inside the allowed files and forbidden-change constraints.",
415
+ "3. Apply the smallest fix and rerun the relevant verification.",
416
+ "4. Return the strict fixer JSON schema before prose.",
417
+ "",
418
+ "**Role boundary:** fix only the cited gap; do not redesign the slice."
419
+ ].join("\n")
207
420
  }
208
421
  ];
209
422
  import { stageDelegationSummary } from "./stage-schema.js";
@@ -233,6 +446,12 @@ ${agent.body}
233
446
  - Mode: ${agent.activation}
234
447
  - Related stages: ${relatedStages}
235
448
 
449
+ ## Required Return Schema
450
+
451
+ STRICT_RETURN_SCHEMA: return a structured object matching this contract before any narrative when delegated.
452
+
453
+ ${formatReturnSchema(agent.returnSchema)}
454
+
236
455
  ## Rules
237
456
 
238
457
  ## Conversation Language Policy
@@ -273,20 +492,33 @@ export function agentCostTierTable() {
273
492
  return `| Tier | Use for | Example agents |
274
493
  |---|---|---|
275
494
  | \`deep\` | one heavy planning pass per stage | planner |
276
- | \`balanced\` | discovery, criticism, review, and TDD specialists with stronger reasoning depth | product-manager, critic, reviewer, security-reviewer, test-author |
495
+ | \`balanced\` | discovery, criticism, review, TDD, and bounded worker execution | product-manager, critic, reviewer, security-reviewer, test-author, implementer, fixer |
277
496
  | \`fast\` | bounded maintenance updates with limited blast radius | doc-updater |
278
497
  `;
279
498
  }
499
+ export function agentRegistryMatrix() {
500
+ const rows = CCLAW_AGENTS.map((agent) => {
501
+ const stages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "none";
502
+ return `| ${agent.name} | ${agent.activation} | ${agent.model} | ${stages} | ${agent.returnSchema.allowedStatuses.join(" / ")} |`;
503
+ }).join("\n");
504
+ return `| Agent | Activation | Model | Related stages | Terminal statuses |
505
+ |---|---|---|---|---|
506
+ ${rows}`;
507
+ }
280
508
  /**
281
509
  * AGENTS.md-ready section describing cclaw’s specialist delegation model.
282
510
  */
283
511
  export function agentsAgentsMdBlock() {
284
512
  return `### Agent Specialists
285
513
 
286
- cclaw materializes specialist agents under \`.cclaw/agents/\`, including planner, product-manager, critic, reviewer, security-reviewer, test-author, and doc-updater.
514
+ cclaw materializes specialist agents under \`.cclaw/agents/\`: ${CCLAW_AGENTS.map((agent) => agent.name).join(", ")}.
287
515
 
288
516
  ${agentRoutingTable()}
289
517
 
518
+ ### Agent Registry Matrix
519
+
520
+ ${agentRegistryMatrix()}
521
+
290
522
  ### Research Playbooks (in-thread)
291
523
 
292
524
  Research work is no longer modeled as standalone personas. Use in-thread playbooks under \`.cclaw/skills/research/\`:
@@ -303,7 +535,7 @@ ${(() => {
303
535
  const mode = activationModeSummary();
304
536
  return `- **Mandatory:** ${mode.mandatory}.
305
537
  - **Proactive:** ${mode.proactive}.
306
- - **On-demand:** none in the specialist roster; research playbooks are in-thread procedures.`;
538
+ - **On-demand:** slice-implementer, implementer, fixer. Research playbooks are in-thread procedures.`;
307
539
  })()}
308
540
 
309
541
  ### Cost-aware routing