cclaw-cli 0.51.24 → 0.51.26

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 (45) 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 +255 -3
  7. package/dist/content/examples.js +8 -5
  8. package/dist/content/harness-doc.d.ts +1 -0
  9. package/dist/content/harness-doc.js +3 -0
  10. package/dist/content/hooks.d.ts +1 -0
  11. package/dist/content/hooks.js +189 -0
  12. package/dist/content/next-command.js +10 -6
  13. package/dist/content/reference-patterns.d.ts +18 -0
  14. package/dist/content/reference-patterns.js +391 -0
  15. package/dist/content/skills.js +42 -36
  16. package/dist/content/stage-common-guidance.js +19 -3
  17. package/dist/content/stage-schema.d.ts +12 -0
  18. package/dist/content/stage-schema.js +184 -28
  19. package/dist/content/stages/_lint-metadata/index.js +3 -2
  20. package/dist/content/stages/brainstorm.js +7 -3
  21. package/dist/content/stages/design.js +12 -3
  22. package/dist/content/stages/review.js +7 -5
  23. package/dist/content/stages/schema-types.d.ts +9 -2
  24. package/dist/content/stages/scope.js +8 -2
  25. package/dist/content/stages/ship.js +3 -2
  26. package/dist/content/stages/tdd.js +18 -13
  27. package/dist/content/start-command.js +3 -2
  28. package/dist/content/status-command.js +17 -6
  29. package/dist/content/subagents.js +286 -40
  30. package/dist/content/templates.js +64 -3
  31. package/dist/content/tree-command.js +7 -1
  32. package/dist/delegation.d.ts +34 -1
  33. package/dist/delegation.js +168 -8
  34. package/dist/doctor-registry.js +9 -0
  35. package/dist/doctor.js +121 -6
  36. package/dist/gate-evidence.js +25 -2
  37. package/dist/harness-adapters.d.ts +6 -0
  38. package/dist/harness-adapters.js +28 -4
  39. package/dist/install.js +5 -10
  40. package/dist/internal/advance-stage.js +179 -26
  41. package/dist/run-persistence.js +21 -3
  42. package/dist/tdd-verification-evidence.d.ts +17 -0
  43. package/dist/tdd-verification-evidence.js +43 -0
  44. package/dist/types.d.ts +10 -0
  45. 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,56 @@ 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 workerAckContract() {
34
+ return `## Worker ACK Contract
35
+
36
+ Before doing substantive work, return an ACK object that the parent can record:
37
+
38
+ \`\`\`json
39
+ {
40
+ "status": "ACK",
41
+ "spanId": "<parent spanId>",
42
+ "dispatchId": "<parent dispatchId or workerRunId>",
43
+ "dispatchSurface": "claude-task|cursor-task|opencode-agent|codex-agent|generic-task|role-switch",
44
+ "agentDefinitionPath": ".cclaw/agents/<agent>.md or harness generated path",
45
+ "ackTs": "<ISO timestamp>"
46
+ }
47
+ \`\`\`
48
+
49
+ 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
+ }
51
+ function formatReturnSchema(schema) {
52
+ return [
53
+ `- Status field: \`${schema.statusField}\``,
54
+ `- Allowed statuses: ${schema.allowedStatuses.map((status) => `\`${status}\``).join(", ")}`,
55
+ `- Required fields: ${schema.requiredFields.map((field) => `\`${field}\``).join(", ")}`,
56
+ `- Evidence fields: ${schema.evidenceFields.map((field) => `\`${field}\``).join(", ")}`
57
+ ].join("\n");
58
+ }
9
59
  function formattedAgentsForStages(stages) {
10
60
  const summary = stageDelegationSummary("standard");
11
61
  const merged = [];
@@ -48,6 +98,26 @@ function activationModeSummary() {
48
98
  * to `string` and break the compile-time drift guard.
49
99
  */
50
100
  export const CCLAW_AGENTS = [
101
+ {
102
+ name: "researcher",
103
+ 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.",
104
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
105
+ model: "fast",
106
+ activation: "proactive",
107
+ relatedStages: ["brainstorm", "scope", "design", "plan"],
108
+ returnSchema: ADVISORY_RETURN_SCHEMA,
109
+ body: [
110
+ "You are a **context readiness and research specialist**.",
111
+ "",
112
+ "When invoked:",
113
+ "1. Start with search/query summaries before reading large files.",
114
+ "2. Name provider status when known: graph/search/docs/MCP/semantic index freshness.",
115
+ "3. Separate observed facts from assumptions and stale or missing context.",
116
+ "4. Return concise evidence refs the controller can paste into stage artifacts.",
117
+ "",
118
+ "**Role boundary:** research and context synthesis only. Do NOT edit files."
119
+ ].join("\n")
120
+ },
51
121
  {
52
122
  name: "planner",
53
123
  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 +125,7 @@ export const CCLAW_AGENTS = [
55
125
  model: "deep",
56
126
  activation: "mandatory",
57
127
  relatedStages: ["brainstorm", "scope", "design", "spec", "plan"],
128
+ returnSchema: ADVISORY_RETURN_SCHEMA,
58
129
  body: [
59
130
  "You are an **implementation planning specialist** (staff engineer mindset).",
60
131
  "",
@@ -75,6 +146,7 @@ export const CCLAW_AGENTS = [
75
146
  model: "balanced",
76
147
  activation: "proactive",
77
148
  relatedStages: ["brainstorm", "scope"],
149
+ returnSchema: ADVISORY_RETURN_SCHEMA,
78
150
  body: [
79
151
  "You are a **product discovery specialist**.",
80
152
  "",
@@ -97,6 +169,7 @@ export const CCLAW_AGENTS = [
97
169
  model: "balanced",
98
170
  activation: "proactive",
99
171
  relatedStages: ["brainstorm", "scope", "design"],
172
+ returnSchema: ADVISORY_RETURN_SCHEMA,
100
173
  body: [
101
174
  "You are an **adversarial critic** for product and engineering decisions.",
102
175
  "",
@@ -109,6 +182,40 @@ export const CCLAW_AGENTS = [
109
182
  "Return confirmed risks, disproven concerns, and the smallest decision-changing recommendation."
110
183
  ].join("\n")
111
184
  },
185
+ {
186
+ name: "architect",
187
+ description: "MANDATORY during design. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and spec handoff before implementation.",
188
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
189
+ model: "deep",
190
+ activation: "mandatory",
191
+ relatedStages: ["design"],
192
+ returnSchema: ADVISORY_RETURN_SCHEMA,
193
+ body: [
194
+ "You are an **architecture validation specialist**.",
195
+ "",
196
+ "Check architecture boundaries, existing-system fit, critical paths, data/state flow, alternatives, rescue paths, and verification hooks.",
197
+ "Return chosen path risks, rejected alternatives, switch triggers, and required evidence before spec handoff.",
198
+ "",
199
+ "**Role boundary:** design validation only. Do NOT write implementation code."
200
+ ].join("\n")
201
+ },
202
+ {
203
+ name: "spec-validator",
204
+ description: "MANDATORY during standard/deep spec. MUST BE USED to validate measurable acceptance criteria, assumptions, edge cases, and testability mapping.",
205
+ tools: ["Read", "Grep", "Glob"],
206
+ model: "balanced",
207
+ activation: "mandatory",
208
+ relatedStages: ["spec"],
209
+ returnSchema: REVIEW_RETURN_SCHEMA,
210
+ body: [
211
+ "You are a **specification validation specialist**.",
212
+ "",
213
+ "For every acceptance criterion, verify it is observable, measurable, falsifiable, mapped to upstream decisions, and paired with concrete verification evidence.",
214
+ "Flag vague language, missing edge cases, hidden assumptions, and RED tests that cannot be expressed.",
215
+ "",
216
+ "**Role boundary:** validate the spec; do NOT write plan tasks or implementation."
217
+ ].join("\n")
218
+ },
112
219
  {
113
220
  name: "reviewer",
114
221
  description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.",
@@ -116,6 +223,7 @@ export const CCLAW_AGENTS = [
116
223
  model: "balanced",
117
224
  activation: "mandatory",
118
225
  relatedStages: ["spec", "review", "ship"],
226
+ returnSchema: REVIEW_RETURN_SCHEMA,
119
227
  body: [
120
228
  "You are a **combined spec + code reviewer**.",
121
229
  "",
@@ -141,6 +249,51 @@ export const CCLAW_AGENTS = [
141
249
  "**Trust model:** never rely on implementer claims; verify by reading code."
142
250
  ].join("\n")
143
251
  },
252
+ {
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.",
255
+ tools: ["Read", "Grep", "Glob"],
256
+ model: "balanced",
257
+ activation: "proactive",
258
+ relatedStages: ["review"],
259
+ returnSchema: REVIEW_RETURN_SCHEMA,
260
+ body: [
261
+ "You are a **performance review specialist**.",
262
+ "",
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."
265
+ ].join("\n")
266
+ },
267
+ {
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.",
270
+ tools: ["Read", "Grep", "Glob"],
271
+ model: "balanced",
272
+ activation: "proactive",
273
+ relatedStages: ["design", "review"],
274
+ returnSchema: REVIEW_RETURN_SCHEMA,
275
+ body: [
276
+ "You are a **compatibility review specialist**.",
277
+ "",
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."
280
+ ].join("\n")
281
+ },
282
+ {
283
+ name: "observability-reviewer",
284
+ description: "PROACTIVE during design/review when diagnosis, telemetry, rollout visibility, or supportability could affect safe operation.",
285
+ tools: ["Read", "Grep", "Glob"],
286
+ model: "balanced",
287
+ activation: "proactive",
288
+ relatedStages: ["design", "review"],
289
+ returnSchema: REVIEW_RETURN_SCHEMA,
290
+ body: [
291
+ "You are an **observability review specialist**.",
292
+ "",
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."
295
+ ].join("\n")
296
+ },
144
297
  {
145
298
  name: "security-reviewer",
146
299
  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 +301,7 @@ export const CCLAW_AGENTS = [
148
301
  model: "balanced",
149
302
  activation: "mandatory",
150
303
  relatedStages: ["design", "review", "ship"],
304
+ returnSchema: REVIEW_RETURN_SCHEMA,
151
305
  body: [
152
306
  "You are a **security vulnerability specialist** focused on exploitability.",
153
307
  "",
@@ -173,6 +327,7 @@ export const CCLAW_AGENTS = [
173
327
  model: "balanced",
174
328
  activation: "mandatory",
175
329
  relatedStages: ["tdd"],
330
+ returnSchema: WORKER_RETURN_SCHEMA,
176
331
  body: [
177
332
  "You are a **test-driven development** specialist.",
178
333
  "",
@@ -186,6 +341,21 @@ export const CCLAW_AGENTS = [
186
341
  "5. REFACTOR with behavior preserved."
187
342
  ].join("\n")
188
343
  },
344
+ {
345
+ name: "release-reviewer",
346
+ description: "MANDATORY during ship. MUST BE USED for release readiness, rollback, finalization mode, evidence freshness, and victory detector checks.",
347
+ tools: ["Read", "Grep", "Glob", "Bash"],
348
+ model: "balanced",
349
+ activation: "mandatory",
350
+ relatedStages: ["ship"],
351
+ returnSchema: REVIEW_RETURN_SCHEMA,
352
+ body: [
353
+ "You are a **release readiness reviewer**.",
354
+ "",
355
+ "Verify preflight evidence, review verdict freshness, rollback trigger and steps, finalization enum, no-VCS handoff when applicable, learnings capture, and handoff completeness.",
356
+ "Block ship on stale evidence, unresolved criticals, missing rollback, or ambiguous finalization."
357
+ ].join("\n")
358
+ },
189
359
  {
190
360
  name: "doc-updater",
191
361
  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 +363,7 @@ export const CCLAW_AGENTS = [
193
363
  model: "fast",
194
364
  activation: "mandatory",
195
365
  relatedStages: ["tdd", "ship"],
366
+ returnSchema: DOC_RETURN_SCHEMA,
196
367
  body: [
197
368
  "You are a **documentation maintenance specialist**.",
198
369
  "",
@@ -204,6 +375,66 @@ export const CCLAW_AGENTS = [
204
375
  "",
205
376
  "Preserve existing tone and structure; avoid rewrites for style alone."
206
377
  ].join("\n")
378
+ },
379
+ {
380
+ name: "slice-implementer",
381
+ description: "ON-DEMAND or PROACTIVE during TDD GREEN/REFACTOR for one bounded vertical slice after RED evidence exists and file ownership is non-overlapping.",
382
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
383
+ model: "balanced",
384
+ activation: "on-demand",
385
+ relatedStages: ["tdd"],
386
+ returnSchema: WORKER_RETURN_SCHEMA,
387
+ body: [
388
+ "You are a **vertical-slice implementation worker**.",
389
+ "",
390
+ "Rules:",
391
+ "1. Start only from the assigned RED failure and acceptance mapping.",
392
+ "2. Edit only the allowed files for the slice.",
393
+ "3. Implement the minimal GREEN change, then preserve behavior during REFACTOR.",
394
+ "4. Return files changed, tests run, evidence refs, concerns, and blockers.",
395
+ "",
396
+ "**Role boundary:** do not broaden scope, do not review your own work as final approval, and do not spawn subagents."
397
+ ].join("\n")
398
+ },
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
+ {
420
+ name: "fixer",
421
+ description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.",
422
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
423
+ model: "balanced",
424
+ activation: "on-demand",
425
+ relatedStages: ["review", "tdd"],
426
+ returnSchema: WORKER_RETURN_SCHEMA,
427
+ body: [
428
+ "You are a **fresh fixer worker** dispatched after a review found a concrete gap.",
429
+ "",
430
+ "Rules:",
431
+ "1. Start from the failing criterion and reviewer evidence, not from implementer claims.",
432
+ "2. Stay inside the allowed files and forbidden-change constraints.",
433
+ "3. Apply the smallest fix and rerun the relevant verification.",
434
+ "4. Return the strict fixer JSON schema before prose.",
435
+ "",
436
+ "**Role boundary:** fix only the cited gap; do not redesign the slice."
437
+ ].join("\n")
207
438
  }
208
439
  ];
209
440
  import { stageDelegationSummary } from "./stage-schema.js";
@@ -233,6 +464,14 @@ ${agent.body}
233
464
  - Mode: ${agent.activation}
234
465
  - Related stages: ${relatedStages}
235
466
 
467
+ ${workerAckContract()}
468
+
469
+ ## Required Return Schema
470
+
471
+ STRICT_RETURN_SCHEMA: return a structured object matching this contract before any narrative when delegated. Include \`spanId\`, \`dispatchId\` or \`workerRunId\`, \`dispatchSurface\`, \`agentDefinitionPath\`, and lifecycle timestamps when provided by the parent.
472
+
473
+ ${formatReturnSchema(agent.returnSchema)}
474
+
236
475
  ## Rules
237
476
 
238
477
  ## Conversation Language Policy
@@ -273,20 +512,33 @@ export function agentCostTierTable() {
273
512
  return `| Tier | Use for | Example agents |
274
513
  |---|---|---|
275
514
  | \`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 |
515
+ | \`balanced\` | discovery, criticism, review, TDD, and bounded worker execution | product-manager, critic, reviewer, security-reviewer, test-author, implementer, fixer |
277
516
  | \`fast\` | bounded maintenance updates with limited blast radius | doc-updater |
278
517
  `;
279
518
  }
519
+ export function agentRegistryMatrix() {
520
+ const rows = CCLAW_AGENTS.map((agent) => {
521
+ const stages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "none";
522
+ return `| ${agent.name} | ${agent.activation} | ${agent.model} | ${stages} | ${agent.returnSchema.allowedStatuses.join(" / ")} |`;
523
+ }).join("\n");
524
+ return `| Agent | Activation | Model | Related stages | Terminal statuses |
525
+ |---|---|---|---|---|
526
+ ${rows}`;
527
+ }
280
528
  /**
281
529
  * AGENTS.md-ready section describing cclaw’s specialist delegation model.
282
530
  */
283
531
  export function agentsAgentsMdBlock() {
284
532
  return `### Agent Specialists
285
533
 
286
- cclaw materializes specialist agents under \`.cclaw/agents/\`, including planner, product-manager, critic, reviewer, security-reviewer, test-author, and doc-updater.
534
+ cclaw materializes specialist agents under \`.cclaw/agents/\`: ${CCLAW_AGENTS.map((agent) => agent.name).join(", ")}.
287
535
 
288
536
  ${agentRoutingTable()}
289
537
 
538
+ ### Agent Registry Matrix
539
+
540
+ ${agentRegistryMatrix()}
541
+
290
542
  ### Research Playbooks (in-thread)
291
543
 
292
544
  Research work is no longer modeled as standalone personas. Use in-thread playbooks under \`.cclaw/skills/research/\`:
@@ -303,7 +555,7 @@ ${(() => {
303
555
  const mode = activationModeSummary();
304
556
  return `- **Mandatory:** ${mode.mandatory}.
305
557
  - **Proactive:** ${mode.proactive}.
306
- - **On-demand:** none in the specialist roster; research playbooks are in-thread procedures.`;
558
+ - **On-demand:** slice-implementer, implementer, fixer. Research playbooks are in-thread procedures.`;
307
559
  })()}
308
560
 
309
561
  ### Cost-aware routing