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.
- package/README.md +135 -414
- package/dist/artifact-linter.js +10 -6
- package/dist/config.d.ts +1 -1
- package/dist/config.js +28 -3
- package/dist/content/core-agents.d.ts +110 -0
- package/dist/content/core-agents.js +255 -3
- package/dist/content/examples.js +8 -5
- package/dist/content/harness-doc.d.ts +1 -0
- package/dist/content/harness-doc.js +3 -0
- package/dist/content/hooks.d.ts +1 -0
- package/dist/content/hooks.js +189 -0
- package/dist/content/next-command.js +10 -6
- package/dist/content/reference-patterns.d.ts +18 -0
- package/dist/content/reference-patterns.js +391 -0
- package/dist/content/skills.js +42 -36
- package/dist/content/stage-common-guidance.js +19 -3
- package/dist/content/stage-schema.d.ts +12 -0
- package/dist/content/stage-schema.js +184 -28
- package/dist/content/stages/_lint-metadata/index.js +3 -2
- package/dist/content/stages/brainstorm.js +7 -3
- package/dist/content/stages/design.js +12 -3
- package/dist/content/stages/review.js +7 -5
- package/dist/content/stages/schema-types.d.ts +9 -2
- package/dist/content/stages/scope.js +8 -2
- package/dist/content/stages/ship.js +3 -2
- package/dist/content/stages/tdd.js +18 -13
- package/dist/content/start-command.js +3 -2
- package/dist/content/status-command.js +17 -6
- package/dist/content/subagents.js +286 -40
- package/dist/content/templates.js +64 -3
- package/dist/content/tree-command.js +7 -1
- package/dist/delegation.d.ts +34 -1
- package/dist/delegation.js +168 -8
- package/dist/doctor-registry.js +9 -0
- package/dist/doctor.js +121 -6
- package/dist/gate-evidence.js +25 -2
- package/dist/harness-adapters.d.ts +6 -0
- package/dist/harness-adapters.js +28 -4
- package/dist/install.js +5 -10
- package/dist/internal/advance-stage.js +179 -26
- package/dist/run-persistence.js +21 -3
- package/dist/tdd-verification-evidence.d.ts +17 -0
- package/dist/tdd-verification-evidence.js +43 -0
- package/dist/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
export const REFERENCE_PATTERNS = [
|
|
2
|
+
{
|
|
3
|
+
id: "socraticode_context_readiness",
|
|
4
|
+
title: "Context Readiness",
|
|
5
|
+
intent: "Do not draft from memory. Start once the agent can name upstream artifacts, discovered code patterns, template shape, and open blockers.",
|
|
6
|
+
useWhen: "Every stage before writing or validating an artifact.",
|
|
7
|
+
policyNeedles: ["Context Readiness", "upstream freshness", "template shape"],
|
|
8
|
+
contracts: [
|
|
9
|
+
{
|
|
10
|
+
stage: "brainstorm",
|
|
11
|
+
guidance: [
|
|
12
|
+
"Capture discovered project context before asking approval questions.",
|
|
13
|
+
"Separate observed facts from assumptions and open blockers."
|
|
14
|
+
],
|
|
15
|
+
artifactSections: ["Context", "Discovered context"]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
stage: "scope",
|
|
19
|
+
guidance: [
|
|
20
|
+
"Name which brainstorm decisions are fresh enough to carry forward.",
|
|
21
|
+
"If upstream decisions are stale or missing, stop for re-scope instead of inventing boundaries."
|
|
22
|
+
],
|
|
23
|
+
artifactSections: ["Upstream Handoff", "Scope Contract"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
stage: "design",
|
|
27
|
+
guidance: [
|
|
28
|
+
"Read blast-radius code before locking architecture.",
|
|
29
|
+
"Use reference patterns as examples to adapt, not authority to copy."
|
|
30
|
+
],
|
|
31
|
+
artifactSections: ["Codebase Investigation", "Reference-Grade Contracts"]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
stage: "tdd",
|
|
35
|
+
guidance: [
|
|
36
|
+
"Discover tests and affected contracts before opening a RED vertical slice.",
|
|
37
|
+
"Map the slice to the active source item before editing production code."
|
|
38
|
+
],
|
|
39
|
+
artifactSections: ["Test Discovery", "System-Wide Impact Check", "Acceptance Mapping"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
stage: "review",
|
|
43
|
+
guidance: [
|
|
44
|
+
"Review only after current diff, test evidence, and source-item coverage are known.",
|
|
45
|
+
"A no-finding verdict still needs inspected-surface evidence."
|
|
46
|
+
],
|
|
47
|
+
artifactSections: ["Review Evidence Scope", "Completeness Snapshot"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
stage: "ship",
|
|
51
|
+
guidance: [
|
|
52
|
+
"Ship only after fresh preflight, rollback trigger, and finalization mode are explicit.",
|
|
53
|
+
"Treat stale review or missing rollback evidence as a blocker, not a concern."
|
|
54
|
+
],
|
|
55
|
+
artifactSections: ["Preflight Results", "Rollback Plan", "Finalization"]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "addy_reference_grade_contracts",
|
|
61
|
+
title: "Reference-Grade Contracts",
|
|
62
|
+
intent: "Promote good examples into explicit contracts: source, invariant, adaptation, rejection boundary, and verification signal.",
|
|
63
|
+
useWhen: "Brainstorm, scope, and design need reusable patterns without copying unrelated behavior.",
|
|
64
|
+
policyNeedles: ["Reference Pattern Registry", "Reference-Grade Contracts", "accepted/rejected reference ideas"],
|
|
65
|
+
contracts: [
|
|
66
|
+
{
|
|
67
|
+
stage: "brainstorm",
|
|
68
|
+
guidance: [
|
|
69
|
+
"Record which reference patterns informed each option and which were rejected.",
|
|
70
|
+
"A challenger must name the reference idea that makes it meaningfully higher-upside."
|
|
71
|
+
],
|
|
72
|
+
artifactSections: ["Reference Pattern Candidates", "Approaches"]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
stage: "scope",
|
|
76
|
+
guidance: [
|
|
77
|
+
"Lock accepted, rejected, and deferred reference ideas as scope boundaries.",
|
|
78
|
+
"Do not let a reference expand scope unless the user explicitly opts in."
|
|
79
|
+
],
|
|
80
|
+
artifactSections: ["Reference Pattern Registry", "Scope Contract"]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
stage: "design",
|
|
84
|
+
guidance: [
|
|
85
|
+
"For every mirrored pattern, name source, invariant, adaptation, and verification evidence.",
|
|
86
|
+
"If a reference conflicts with local architecture, reject it and document the revival signal."
|
|
87
|
+
],
|
|
88
|
+
artifactSections: ["Reference-Grade Contracts", "Patterns to Mirror", "Rejected Alternatives"]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "evanflow_coder_overseer",
|
|
94
|
+
title: "Coder / Overseer Split",
|
|
95
|
+
intent: "Keep implementation and validation context isolated: coders edit bounded slices, overseers read only, and integration overseers validate shared touchpoints.",
|
|
96
|
+
useWhen: "TDD, review, and parallel worker orchestration need safe independent implementation with fresh verification.",
|
|
97
|
+
policyNeedles: ["coder/overseer", "integration overseer", "non-overlap checks"],
|
|
98
|
+
contracts: [
|
|
99
|
+
{
|
|
100
|
+
stage: "plan",
|
|
101
|
+
guidance: [
|
|
102
|
+
"Executable packets name file ownership, shared interfaces, expected failing test, passing command, and stop conditions.",
|
|
103
|
+
"Parallel writers are allowed only after non-overlap checks for files, shared interfaces, migrations/config, and baseline cleanliness."
|
|
104
|
+
],
|
|
105
|
+
artifactSections: ["Task List", "Dependency Batches", "Execution Posture"]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
stage: "tdd",
|
|
109
|
+
guidance: [
|
|
110
|
+
"Coder edits only the assigned slice after RED evidence; read-only overseer validates spec fit and assertion quality.",
|
|
111
|
+
"When 3+ independent packets run, use an integration overseer for named touchpoints and integration tests."
|
|
112
|
+
],
|
|
113
|
+
artifactSections: ["Execution Posture", "Per-Slice Review", "Verification Ladder"]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
stage: "review",
|
|
117
|
+
guidance: [
|
|
118
|
+
"Layered reviewers reconcile findings by source tag, confidence, owner, and verification requirement.",
|
|
119
|
+
"Do not accept implementer self-review as overseer evidence."
|
|
120
|
+
],
|
|
121
|
+
artifactSections: ["Review Evidence Scope", "Review Findings Contract"]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "superpowers_executable_packet",
|
|
127
|
+
title: "Executable Packet",
|
|
128
|
+
intent: "Plan tasks as self-contained packets with acceptance mapping, expected RED failure, GREEN command, allowed files, and stop conditions.",
|
|
129
|
+
useWhen: "Plan and TDD need work items a fresh agent can execute without hidden parent context.",
|
|
130
|
+
policyNeedles: ["executable packet", "expected failing test", "stop condition"],
|
|
131
|
+
contracts: [
|
|
132
|
+
{
|
|
133
|
+
stage: "plan",
|
|
134
|
+
guidance: [
|
|
135
|
+
"Each task is copy-paste ready for a worker and includes acceptance criteria, file boundaries, expected failing test, passing command, and stop conditions.",
|
|
136
|
+
"Tasks that depend on shared interfaces or migration/config files are serialized unless an integration contract exists."
|
|
137
|
+
],
|
|
138
|
+
artifactSections: ["Task List", "Dependency Batches", "Execution Posture"]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
stage: "tdd",
|
|
142
|
+
guidance: [
|
|
143
|
+
"Open one packet as one vertical slice; do not mix unrelated packet evidence.",
|
|
144
|
+
"Close packet only when RED, GREEN, REFACTOR, and verification evidence align."
|
|
145
|
+
],
|
|
146
|
+
artifactSections: ["Acceptance Mapping", "RED Evidence", "GREEN Evidence", "REFACTOR Notes"]
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: "gstack_question_tuning",
|
|
152
|
+
title: "Question Tuning",
|
|
153
|
+
intent: "Ask only decision-changing questions, auto-assume low-risk two-way doors, and stop on one-way-door decisions.",
|
|
154
|
+
useWhen: "Brainstorm/scope/spec interactions could drift into broad interrogation instead of useful approval gates.",
|
|
155
|
+
policyNeedles: ["one decision-changing question", "two-way door", "one-way door"],
|
|
156
|
+
contracts: [
|
|
157
|
+
{
|
|
158
|
+
stage: "brainstorm",
|
|
159
|
+
guidance: [
|
|
160
|
+
"Ask one decision-changing question at a time and record impact only when it changes direction or blocks progress.",
|
|
161
|
+
"Continue on low-risk defaults; stop on scope, architecture, security, data loss, public API, migration, auth/pricing, or approval uncertainty."
|
|
162
|
+
],
|
|
163
|
+
artifactSections: ["Sharpening Questions", "Selected Direction"]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
stage: "scope",
|
|
167
|
+
guidance: [
|
|
168
|
+
"Present labeled scope moves with one recommendation; wait for user opt-in before treating a mode as selected.",
|
|
169
|
+
"Record what signal would change the recommendation."
|
|
170
|
+
],
|
|
171
|
+
artifactSections: ["Scope Mode", "Scope Contract"]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
stage: "spec",
|
|
175
|
+
guidance: [
|
|
176
|
+
"Chunk acceptance criteria for approval and stop on assumptions with irreversible impact.",
|
|
177
|
+
"Rewrite vague criteria before asking the user to approve."
|
|
178
|
+
],
|
|
179
|
+
artifactSections: ["Acceptance Criteria", "Assumptions Before Finalization", "Approval"]
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: "evanflow_vertical_slice_tdd",
|
|
185
|
+
title: "Vertical-Slice TDD",
|
|
186
|
+
intent: "Execute behavior end-to-end in one reviewable slice instead of collecting unrelated test or implementation fragments.",
|
|
187
|
+
useWhen: "TDD and review need to prove a source item moved from RED to GREEN with traceable behavior evidence.",
|
|
188
|
+
policyNeedles: ["vertical slice", "RED vertical slice", "slice victory detector"],
|
|
189
|
+
contracts: [
|
|
190
|
+
{
|
|
191
|
+
stage: "tdd",
|
|
192
|
+
guidance: [
|
|
193
|
+
"One vertical slice is one source item plus one or more ACs, tests, implementation, refactor notes, and verification evidence.",
|
|
194
|
+
"Do not open a second vertical slice while RED evidence or regression repair remains open for the current slice."
|
|
195
|
+
],
|
|
196
|
+
artifactSections: ["Execution Posture", "RED Evidence", "GREEN Evidence", "Verification Ladder"]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
stage: "review",
|
|
200
|
+
guidance: [
|
|
201
|
+
"Review source-item coverage by vertical slice, not by file count alone.",
|
|
202
|
+
"A slice is review-ready only when RED, GREEN, REFACTOR, and verification evidence all line up."
|
|
203
|
+
],
|
|
204
|
+
artifactSections: ["Completeness Snapshot", "Trace Matrix Check"]
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: "superclaude_confidence_gates",
|
|
210
|
+
title: "Confidence Gates",
|
|
211
|
+
intent: "Require source verification before execution and a fresh self-check before completion claims.",
|
|
212
|
+
useWhen: "Stage work could proceed from memory, duplicate an existing implementation, or close with stale evidence.",
|
|
213
|
+
policyNeedles: ["pre-execution confidence", "post-implementation self-check", "source verification"],
|
|
214
|
+
contracts: [
|
|
215
|
+
{
|
|
216
|
+
stage: "design",
|
|
217
|
+
guidance: [
|
|
218
|
+
"Before locking architecture, verify duplicate implementation risk, architecture fit, docs/source truth, and root-cause confidence.",
|
|
219
|
+
"If confidence is low, stop for investigation instead of adding fallback layers."
|
|
220
|
+
],
|
|
221
|
+
artifactSections: ["Codebase Investigation", "Architecture Confidence"]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
stage: "review",
|
|
225
|
+
guidance: [
|
|
226
|
+
"Review requirements met, assumptions verified, tests passing, and evidence freshness before any PASS verdict.",
|
|
227
|
+
"Separate verified facts from implementer claims."
|
|
228
|
+
],
|
|
229
|
+
artifactSections: ["Review Readiness Snapshot", "Final Verdict"]
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "oh_my_worker_lifecycle",
|
|
235
|
+
title: "Worker Lifecycle Evidence",
|
|
236
|
+
intent: "Make asynchronous or delegated work inspectable through state, dispatch, evidence refs, and stale-worker handling.",
|
|
237
|
+
useWhen: "Stages schedule subagents, role-switch work, or generic dispatch and need auditable completion evidence.",
|
|
238
|
+
policyNeedles: ["dispatch lifecycle", "stale worker", "strict worker JSON schema"],
|
|
239
|
+
contracts: [
|
|
240
|
+
{
|
|
241
|
+
stage: "plan",
|
|
242
|
+
guidance: [
|
|
243
|
+
"Plan only bounded worker packets with clear file ownership, stop conditions, and evidence expectations.",
|
|
244
|
+
"Name any dispatch or concurrency governor before workers start."
|
|
245
|
+
],
|
|
246
|
+
artifactSections: ["Task List", "Dependency Batches", "Execution Posture"]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
stage: "tdd",
|
|
250
|
+
guidance: [
|
|
251
|
+
"Every scheduled worker needs a terminal return with evidence refs or an explicit blocker route.",
|
|
252
|
+
"A stale worker blocks completion until resolved, failed, or structurally waived."
|
|
253
|
+
],
|
|
254
|
+
artifactSections: ["Execution Posture", "Verification Ladder", "Per-Slice Review"]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
stage: "review",
|
|
258
|
+
guidance: [
|
|
259
|
+
"Synthesize reviewer returns by status, source tag, evidence refs, and unresolved blockers.",
|
|
260
|
+
"Do not treat missing worker output as a clean review."
|
|
261
|
+
],
|
|
262
|
+
artifactSections: ["Review Evidence Scope", "Review Findings Contract"]
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: "gsd_hard_stop_routing",
|
|
268
|
+
title: "Hard-Stop Routing",
|
|
269
|
+
intent: "Advance only when unresolved checkpoints, stale handoffs, and verification debt are cleared or routed explicitly.",
|
|
270
|
+
useWhen: "A stage wants to continue despite missing gates, stale rewind markers, or uncertain next command state.",
|
|
271
|
+
policyNeedles: ["hard-stop next routing", "goal-backward verification", "operator line"],
|
|
272
|
+
contracts: [
|
|
273
|
+
{
|
|
274
|
+
stage: "tdd",
|
|
275
|
+
guidance: [
|
|
276
|
+
"Start from the outcome that must be true, then verify source, tests, artifact wiring, and gate evidence from that goal backward.",
|
|
277
|
+
"If source/test preflight blocks execution, route to the managed blocker taxonomy instead of fabricating RED evidence."
|
|
278
|
+
],
|
|
279
|
+
artifactSections: ["TDD Blocker Taxonomy", "Verification Ladder"]
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
stage: "ship",
|
|
283
|
+
guidance: [
|
|
284
|
+
"Block ship on unresolved checkpoints, stale handoffs, or verification debt.",
|
|
285
|
+
"Report the compact operator line: stage, scope, validation issues, recovery state, and next action."
|
|
286
|
+
],
|
|
287
|
+
artifactSections: ["Preflight Results", "Completion Status", "Handoff"]
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: "everyinc_delegation_preflight",
|
|
293
|
+
title: "Delegation Preflight",
|
|
294
|
+
intent: "Use delegation only when support, consent, baseline, non-overlap, batch size, and fallback mode are known.",
|
|
295
|
+
useWhen: "A controller is about to fan out implementation or review work across multiple specialists.",
|
|
296
|
+
policyNeedles: ["delegation preflight", "non-overlapping files", "layered review synthesis"],
|
|
297
|
+
contracts: [
|
|
298
|
+
{
|
|
299
|
+
stage: "plan",
|
|
300
|
+
guidance: [
|
|
301
|
+
"Before parallel writers, verify support, user consent when needed, baseline cleanliness, non-overlapping files, batch size, and fallback mode.",
|
|
302
|
+
"Shared interfaces, migrations, config, and generated surfaces need an integration contract or serial execution."
|
|
303
|
+
],
|
|
304
|
+
artifactSections: ["Dependency Batches", "Execution Posture"]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
stage: "review",
|
|
308
|
+
guidance: [
|
|
309
|
+
"Dedupe layered reviewer findings with confidence, owner, and verification requirement.",
|
|
310
|
+
"Keep user-facing synthesis separate from raw worker returns."
|
|
311
|
+
],
|
|
312
|
+
artifactSections: ["Layered Review Synthesis", "Review Findings Contract"]
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "ecc_worktree_control_plane",
|
|
318
|
+
title: "Worktree Control Plane",
|
|
319
|
+
intent: "Treat isolated worker state, handoff files, and orchestration snapshots as recoverable control-plane data rather than chat memory.",
|
|
320
|
+
useWhen: "Parallel or resumable work needs clear seed paths, state files, handoffs, and cleanup visibility.",
|
|
321
|
+
policyNeedles: ["worktree control plane", "handoff files", "orchestration snapshot"],
|
|
322
|
+
contracts: [
|
|
323
|
+
{
|
|
324
|
+
stage: "plan",
|
|
325
|
+
guidance: [
|
|
326
|
+
"Name seed paths, worker handoff expectations, and integration touchpoints before isolated work begins.",
|
|
327
|
+
"Cap ad-hoc teams and require agreement/conflict synthesis for any multi-agent result."
|
|
328
|
+
],
|
|
329
|
+
artifactSections: ["Task List", "Dependency Batches", "Execution Posture"]
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
stage: "ship",
|
|
333
|
+
guidance: [
|
|
334
|
+
"Confirm handoffs, cleanup, and orchestration state are captured before archive or closeout.",
|
|
335
|
+
"Do not rely on chat transcript alone for recoverability."
|
|
336
|
+
],
|
|
337
|
+
artifactSections: ["Handoff", "Completion Status"]
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
id: "walkinglabs_victory_detector",
|
|
343
|
+
title: "Iterate / Victory Detector",
|
|
344
|
+
intent: "Iterate while evidence is missing; stop only when the stage-specific victory detector is satisfied or a real blocker is named.",
|
|
345
|
+
useWhen: "Content-only closeout wording for review and ship readiness.",
|
|
346
|
+
policyNeedles: ["Victory Detector", "iterate until evidence", "fresh evidence"],
|
|
347
|
+
contracts: [
|
|
348
|
+
{
|
|
349
|
+
stage: "review",
|
|
350
|
+
guidance: [
|
|
351
|
+
"Victory Detector: Layer 1, Layer 2, security sweep, structured findings, and trace evidence are complete with no unresolved criticals unless verdict is BLOCKED.",
|
|
352
|
+
"If the detector fails, iterate findings or route back to TDD; do not say LGTM."
|
|
353
|
+
],
|
|
354
|
+
artifactSections: ["Review Readiness Snapshot", "Final Verdict"]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
stage: "ship",
|
|
358
|
+
guidance: [
|
|
359
|
+
"Victory Detector: valid review verdict, fresh preflight, rollback trigger/steps, selected finalization enum, and execution result are present.",
|
|
360
|
+
"If any detector field is stale or missing, keep status BLOCKED."
|
|
361
|
+
],
|
|
362
|
+
artifactSections: ["Preflight Results", "Rollback Plan", "Finalization", "Completion Status"]
|
|
363
|
+
}
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
export function referencePatternsForStage(stage) {
|
|
368
|
+
return REFERENCE_PATTERNS.filter((pattern) => pattern.contracts.some((contract) => contract.stage === stage));
|
|
369
|
+
}
|
|
370
|
+
export function referencePatternContractsForStage(stage) {
|
|
371
|
+
return REFERENCE_PATTERNS.flatMap((pattern) => pattern.contracts
|
|
372
|
+
.filter((contract) => contract.stage === stage)
|
|
373
|
+
.map((contract) => ({
|
|
374
|
+
...contract,
|
|
375
|
+
guidance: [...contract.guidance],
|
|
376
|
+
artifactSections: [...contract.artifactSections]
|
|
377
|
+
})));
|
|
378
|
+
}
|
|
379
|
+
export function referencePatternPolicyNeedles(stage) {
|
|
380
|
+
const needles = [];
|
|
381
|
+
const seen = new Set();
|
|
382
|
+
for (const pattern of referencePatternsForStage(stage)) {
|
|
383
|
+
for (const needle of pattern.policyNeedles) {
|
|
384
|
+
if (seen.has(needle))
|
|
385
|
+
continue;
|
|
386
|
+
seen.add(needle);
|
|
387
|
+
needles.push(needle);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return needles;
|
|
391
|
+
}
|
package/dist/content/skills.js
CHANGED
|
@@ -4,6 +4,7 @@ import { FLOW_STAGES } from "../types.js";
|
|
|
4
4
|
import { stageExamples } from "./examples.js";
|
|
5
5
|
import { reviewStackAwareRoutes, reviewStackAwareRoutingSummary, stageAutoSubagentDispatch, stageSchema, stageTrackRenderContext } from "./stage-schema.js";
|
|
6
6
|
import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
|
|
7
|
+
import { referencePatternsForStage } from "./reference-patterns.js";
|
|
7
8
|
const VERIFICATION_STAGES = ["tdd", "review", "ship"];
|
|
8
9
|
function whenNotToUseBlock(items) {
|
|
9
10
|
if (items.length === 0) {
|
|
@@ -37,24 +38,17 @@ Before execution:
|
|
|
37
38
|
2. Load active artifacts from \`.cclaw/artifacts/\`.
|
|
38
39
|
3. Load upstream artifacts required by this stage:
|
|
39
40
|
${readLines}
|
|
40
|
-
4. Read the state contract
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
6. Extract upstream decisions, constraints, and open questions into the current
|
|
48
|
-
artifact's \`Upstream Handoff\` section when that section exists.
|
|
49
|
-
7. Before doing stage work, give a compact user-facing drift preamble: "Carrying forward: <1-3 bullets>. Drift since upstream: None / <specific drift>. Recommendation: continue / re-scope."
|
|
50
|
-
8. If you change an upstream decision, record an explicit drift reason in the
|
|
51
|
-
current artifact before continuing.
|
|
52
|
-
9. Confirm stage inputs:
|
|
41
|
+
4. Read the state contract from \`.cclaw/templates/state-contracts/<stage>.json\` for required fields, taxonomies, and derived markdown path.
|
|
42
|
+
5. Read the canonical artifact template at \`${artifactTemplatePath}\` and reuse its exact section layout — per-row tables with stable column order, calibrated review block; do not invent layouts.
|
|
43
|
+
6. Extract upstream decisions, constraints, and open questions into the current artifact's \`Upstream Handoff\` section when present.
|
|
44
|
+
7. Confirm context readiness: upstream artifact freshness, required context, canonical template shape, relevant in-repo/reference patterns, and unresolved blockers are known. If any item is missing, load it or stop before drafting.
|
|
45
|
+
8. Before doing stage work, give a compact user-facing drift preamble: "Carrying forward: <1-3 bullets>. Drift since upstream: None / <specific drift>. Recommendation: continue / re-scope."
|
|
46
|
+
9. If you change an upstream decision, record an explicit drift reason in the current artifact before continuing.
|
|
47
|
+
10. Confirm stage inputs:
|
|
53
48
|
${inputs}
|
|
54
|
-
|
|
49
|
+
11. Confirm required context:
|
|
55
50
|
${requiredContext}
|
|
56
|
-
|
|
57
|
-
\`.cclaw/knowledge.jsonl\` when the digest is insufficient.
|
|
51
|
+
12. Use the injected knowledge digest; only fall back to full \`.cclaw/knowledge.jsonl\` when insufficient.
|
|
58
52
|
`;
|
|
59
53
|
}
|
|
60
54
|
function autoSubagentDispatchBlock(stage, track) {
|
|
@@ -65,35 +59,47 @@ function autoSubagentDispatchBlock(stage, track) {
|
|
|
65
59
|
const rows = rules
|
|
66
60
|
.map((rule) => {
|
|
67
61
|
const userGate = rule.requiresUserGate ? "required" : "not required";
|
|
68
|
-
|
|
62
|
+
const dispatchClass = rule.dispatchClass ?? "stage-specialist";
|
|
63
|
+
const returnSchema = rule.returnSchema ?? "agent-default";
|
|
64
|
+
return `| ${rule.agent} | ${rule.mode} | ${dispatchClass} | ${returnSchema} | ${userGate} | ${rule.when} | ${rule.purpose} |`;
|
|
69
65
|
})
|
|
70
66
|
.join("\n");
|
|
71
67
|
const mandatory = schema.mandatoryDelegations;
|
|
72
68
|
const mandatoryList = mandatory.length > 0 ? mandatory.map((a) => `\`${a}\``).join(", ") : "none";
|
|
73
69
|
const delegationLogRel = `${RUNTIME_ROOT}/state/delegation-log.json`;
|
|
70
|
+
const delegationEventsRel = `${RUNTIME_ROOT}/state/delegation-events.jsonl`;
|
|
74
71
|
const artifactRef = `${RUNTIME_ROOT}/artifacts/${schema.artifactRules.artifactFile}`;
|
|
75
72
|
return `## Automatic Subagent Dispatch
|
|
76
|
-
| Agent | Mode | User Gate | Trigger | Purpose |
|
|
77
|
-
|
|
73
|
+
| Agent | Mode | Class | Return Schema | User Gate | Trigger | Purpose |
|
|
74
|
+
|---|---|---|---|---|---|---|
|
|
78
75
|
${rows}
|
|
79
|
-
Mandatory: ${mandatoryList}. Record
|
|
80
|
-
### Harness Dispatch Contract
|
|
81
|
-
Use true harness dispatch: Claude native Task, Cursor generic dispatch, OpenCode \`.opencode/agents/<agent>.md\`, Codex \`.codex/agents/<agent>.toml\`. Run independent read-only/review agents in parallel where safe, write evidence into \`${artifactRef}\`, then append \`${delegationLogRel}\` rows with matching \`fulfillmentMode: "isolated"\` or \`"generic-dispatch"\`. Do not collapse OpenCode or Codex to role-switch by default; role-switch is degraded fallback and must carry non-empty \`evidenceRefs\`. Missing evidence blocks completion.
|
|
76
|
+
Mandatory: ${mandatoryList}. Record lifecycle rows in \`${delegationLogRel}\` and append-only \`${delegationEventsRel}\` before completion.
|
|
77
|
+
### Harness Dispatch Contract — use true harness dispatch: Claude Task, Cursor generic dispatch, OpenCode \`.opencode/agents/<agent>.md\` via Task/@agent, Codex \`.codex/agents/<agent>.toml\`. Do not collapse OpenCode or Codex to role-switch by default. Worker ACK Contract: ACK must include \`spanId\`, \`dispatchId\`, \`dispatchSurface\`, \`agentDefinitionPath\`, and \`ackTs\`; never claim \`fulfillmentMode: "isolated"\` without matching lifecycle proof. Helper: \`.cclaw/hooks/delegation-record.mjs --status=<status> --span-id=<spanId> --dispatch-id=<dispatchId> --dispatch-surface=<surface> --agent-definition-path=<path> --json\`. Exact recipe: scheduled -> launched -> acknowledged -> completed with the same span; completed isolated/generic rows require a prior ACK event for that span or \`--ack-ts=<iso>\`.
|
|
82
78
|
`;
|
|
83
79
|
}
|
|
84
80
|
function researchPlaybooksBlock(playbooks) {
|
|
85
81
|
if (playbooks.length === 0)
|
|
86
82
|
return "";
|
|
87
83
|
const rows = playbooks
|
|
88
|
-
.map((playbook) =>
|
|
89
|
-
.join("
|
|
84
|
+
.map((playbook) => `\`${RUNTIME_ROOT}/skills/${playbook}\``)
|
|
85
|
+
.join("; ");
|
|
90
86
|
return `## Research Playbooks
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
Execute in primary agent context before locking the stage; record outcomes in the artifact when relevant: ${rows}.
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
function referencePatternsBlock(stage) {
|
|
91
|
+
const patterns = referencePatternsForStage(stage);
|
|
92
|
+
if (patterns.length === 0)
|
|
93
|
+
return "";
|
|
94
|
+
const summaries = patterns
|
|
95
|
+
.map((pattern) => {
|
|
96
|
+
const contract = pattern.contracts.find((item) => item.stage === stage);
|
|
97
|
+
const sections = contract ? contract.artifactSections.join(", ") : "n/a";
|
|
98
|
+
return `${pattern.title} (sections: ${sections})`;
|
|
99
|
+
})
|
|
100
|
+
.join("; ");
|
|
101
|
+
return `## Reference Patterns
|
|
102
|
+
Prompt-only; no runtime/delegation changes. These compact pattern titles come from the internal registry; use the behavior and artifact sections, not the source project history. Use: ${summaries}.
|
|
97
103
|
`;
|
|
98
104
|
}
|
|
99
105
|
function reviewSectionsBlock(sectionsInput) {
|
|
@@ -242,8 +248,9 @@ function completionParametersBlock(schema, track) {
|
|
|
242
248
|
- \`completion helper\`: \`node .cclaw/hooks/stage-complete.mjs ${schema.stage}\`
|
|
243
249
|
- \`completion helper with evidence\`: \`node .cclaw/hooks/stage-complete.mjs ${schema.stage} --evidence-json '{"<gate_id>":"<evidence note>"}' --passed=<gate_id>[,<gate_id>]\`
|
|
244
250
|
- \`completion helper JSON diagnostics\`: append \`--json\` to receive a machine-readable validation failure summary.
|
|
251
|
+
- \`delegation record helper\`: \`node .cclaw/hooks/delegation-record.mjs --stage=${schema.stage} --agent=<agent> --mode=<mandatory|proactive> --status=<scheduled|launched|acknowledged|completed|failed|waived|stale> --span-id=<spanId> --dispatch-id=<dispatchId> --dispatch-surface=<surface> --agent-definition-path=<path> --json\`. \`delegation helper recipe\`: call \`--status=scheduled\`, then \`--status=launched\`, then \`--status=acknowledged\`, then \`--status=completed\` with the same \`--span-id\`, \`--dispatch-id\`, \`--dispatch-surface\`, and \`--agent-definition-path\`; completed isolated/generic rows fail unless that same span already has an acknowledged event or the completed call includes \`--ack-ts=<iso>\`. For role-switch fallback, use \`--dispatch-surface=role-switch --evidence-ref=<artifact#anchor>\` instead of pretending isolated completion.
|
|
245
252
|
- Fill \`## Learnings\` before closeout: either \`- None this stage.\` or JSON bullets with required keys \`type\`, \`trigger\`, \`action\`, \`confidence\` (knowledge-schema compatible).
|
|
246
|
-
- Record mandatory delegation
|
|
253
|
+
- Record mandatory delegation lifecycle in \`${RUNTIME_ROOT}/state/delegation-log.json\` and append proof events to \`${RUNTIME_ROOT}/state/delegation-events.jsonl\`; the ledger is current state, the event log is audit proof.${mandatoryAgents.length > 0 ? ` If a mandatory delegation cannot run in this harness, use \`--waive-delegation=${mandatoryAgents.join(",")} --waiver-reason="<why safe>"\` on the completion helper.` : ""}
|
|
247
254
|
- Never edit raw \`flow-state.json\` to complete a stage, even in advisory mode; that bypasses validation, gate evidence, and Learnings harvest. If the helper fails, stop and report the exact command/output instead of applying a manual state workaround.
|
|
248
255
|
- Completion protocol: verify required gates, update the artifact, then use the completion helper with \`--evidence-json\` and \`--passed\` for every satisfied gate.
|
|
249
256
|
`;
|
|
@@ -389,9 +396,8 @@ ${conversationLanguagePolicyMarkdown()}
|
|
|
389
396
|
${philosophy.purpose}
|
|
390
397
|
|
|
391
398
|
## Complexity Tier
|
|
392
|
-
- Active tier: \`${schema.complexityTier}
|
|
393
|
-
- Scale-to-complexity
|
|
394
|
-
- Mandatory delegations at this tier: ${mandatoryDelegationSummary}
|
|
399
|
+
- Active tier: \`${schema.complexityTier}\`; mandatory delegations: ${mandatoryDelegationSummary}
|
|
400
|
+
- Scale-to-complexity: execute required gates/sections; keep optional/deep sections compact unless risk, novelty, or config triggers them.
|
|
395
401
|
- Track render context: \`${trackContext.track}\` (${trackContext.usesPlanTerminology ? "plan-first wording" : "acceptance-first wording"})
|
|
396
402
|
|
|
397
403
|
## When to Use
|
|
@@ -406,14 +412,14 @@ ${mergedAntiPatterns(philosophy, executionModel)}
|
|
|
406
412
|
|
|
407
413
|
## Process
|
|
408
414
|
|
|
409
|
-
|
|
410
|
-
|
|
415
|
+
Stage state machine (map only; Checklist is authoritative):
|
|
411
416
|
${processFlowMermaid.length > 0 ? processFlowMermaid : "```mermaid\nflowchart TD\n S1[\"Execute Checklist\"] --> S2[\"Satisfy required gates\"] --> S3[\"Verify before closeout\"]\n```"}
|
|
412
417
|
|
|
413
418
|
${platformNotesBlock}${contextLoadingBlock(stage, artifactRules.crossStageTrace, executionModel)}
|
|
414
419
|
${autoSubagentDispatchBlock(stage, track)}
|
|
415
420
|
${stackAwareReviewRoutingBlock(stage)}
|
|
416
421
|
${researchPlaybooksBlock(executionModel.researchPlaybooks ?? [])}
|
|
422
|
+
${referencePatternsBlock(stage)}
|
|
417
423
|
|
|
418
424
|
## Checklist
|
|
419
425
|
|
|
@@ -14,6 +14,11 @@ ${conversationLanguagePolicyMarkdown()}
|
|
|
14
14
|
harvest learnings, then use \`/cc-next\` for progression.
|
|
15
15
|
- Do not create separate protocol files.
|
|
16
16
|
|
|
17
|
+
## Context readiness
|
|
18
|
+
|
|
19
|
+
- Before drafting, know the upstream artifact freshness, required template shape, relevant code/reference patterns, and unresolved blockers.
|
|
20
|
+
- If any item is missing, load it or stop with a blocker instead of inventing content.
|
|
21
|
+
|
|
17
22
|
## Shared decision protocol
|
|
18
23
|
|
|
19
24
|
- Ask only decision-changing questions.
|
|
@@ -28,7 +33,7 @@ Use this same closeout menu for every stage:
|
|
|
28
33
|
- **A) Advance** — run \`/cc-next\` and continue the critical path; after \`ship\`, the same command drives \`retro -> compound -> archive\`.
|
|
29
34
|
- **B) Revise this stage** — stay on current stage and apply feedback.
|
|
30
35
|
- **C) Pause / park** — run \`/cc-view status\`, then stop and resume later.
|
|
31
|
-
- **D) Rewind** — run \`npx cclaw-cli internal rewind <target-stage> "<reason>"\` as
|
|
36
|
+
- **D) Rewind** — run \`npx cclaw-cli internal rewind <target-stage> "<reason>"\` as the managed support/runtime repair action; after redoing the target stage, run \`npx cclaw-cli internal rewind --ack <target-stage>\` to clear the stale marker.
|
|
32
37
|
- **E) Abandon** — only when the user explicitly wants to end a non-ship active run early, archive with \`npx cclaw-cli archive --skip-retro --retro-reason="<reason>"\`. Once in post-ship closeout, continue \`/cc-next\` through retro/compound/archive instead.
|
|
33
38
|
|
|
34
39
|
Recommendation defaults:
|
|
@@ -37,6 +42,12 @@ Recommendation defaults:
|
|
|
37
42
|
- Completion status \`DONE_WITH_CONCERNS\` -> recommend **B**.
|
|
38
43
|
- Completion status \`BLOCKED\` -> recommend **B** or **C**.
|
|
39
44
|
|
|
45
|
+
## Iterate / Victory Detector
|
|
46
|
+
|
|
47
|
+
- Iterate while a required gate, artifact section, or fresh evidence item is missing.
|
|
48
|
+
- Stop only when the stage-specific Victory Detector passes or a named blocker is recorded.
|
|
49
|
+
- Do not use vague closeout wording such as \`looks good\`, \`done enough\`, or \`all set\` without the detector evidence.
|
|
50
|
+
|
|
40
51
|
## Completion status vocabulary
|
|
41
52
|
|
|
42
53
|
- \`DONE\` — all required gates and checks satisfied.
|
|
@@ -63,9 +74,12 @@ Rollback / fallback: <if decision proves wrong>
|
|
|
63
74
|
|
|
64
75
|
Before closeout, fill the artifact \`## Learnings\` section (do not write
|
|
65
76
|
\`.cclaw/knowledge.jsonl\` by hand):
|
|
66
|
-
- \`- None this stage.\` when nothing reusable emerged.
|
|
77
|
+
- \`- None this stage.\` only when nothing reusable emerged.
|
|
67
78
|
- Or 1-3 JSON bullets with required keys \`type\`, \`trigger\`, \`action\`,
|
|
68
79
|
\`confidence\` (optional fields may mirror knowledge.jsonl schema keys).
|
|
80
|
+
- For meaningful \`design\`, \`tdd\`, or \`review\` work, prefer a small JSON
|
|
81
|
+
learning over \`None\` when you made a reusable decision, found a testing
|
|
82
|
+
pattern, or caught a review/security issue.
|
|
69
83
|
During \`node .cclaw/hooks/stage-complete.mjs <stage>\`, cclaw validates those
|
|
70
84
|
bullets, appends unique entries to \`.cclaw/knowledge.jsonl\`, and stamps a
|
|
71
85
|
harvest marker in the artifact.
|
|
@@ -78,7 +92,9 @@ Track policy:
|
|
|
78
92
|
- \`quick\`: recommended only.
|
|
79
93
|
|
|
80
94
|
\`- None this stage.\` is acceptable only when the stage produced no reusable
|
|
81
|
-
insight (for example, purely mechanical edits with no new decisions).
|
|
95
|
+
insight (for example, purely mechanical edits with no new decisions). If unsure,
|
|
96
|
+
record a concise \`lesson\` with \`confidence":"medium"\` instead of dropping
|
|
97
|
+
operator knowledge.
|
|
82
98
|
|
|
83
99
|
## Progressive disclosure baseline
|
|
84
100
|
|
|
@@ -23,11 +23,23 @@ export interface StageStackAwareReviewRoute {
|
|
|
23
23
|
signals: string[];
|
|
24
24
|
focus: string;
|
|
25
25
|
}
|
|
26
|
+
export interface StageDelegationDispatchRule {
|
|
27
|
+
agent: string;
|
|
28
|
+
mode: "mandatory" | "proactive";
|
|
29
|
+
when: string;
|
|
30
|
+
purpose: string;
|
|
31
|
+
requiresUserGate: boolean;
|
|
32
|
+
requiredAtTier?: StageComplexityTier;
|
|
33
|
+
dispatchClass: NonNullable<StageAutoSubagentDispatch["dispatchClass"]>;
|
|
34
|
+
returnSchema: NonNullable<StageAutoSubagentDispatch["returnSchema"]>;
|
|
35
|
+
skill?: string;
|
|
36
|
+
}
|
|
26
37
|
export interface StageDelegationSummary {
|
|
27
38
|
stage: FlowStage;
|
|
28
39
|
mandatoryAgents: string[];
|
|
29
40
|
proactiveAgents: string[];
|
|
30
41
|
primaryAgents: string[];
|
|
42
|
+
dispatchRules: StageDelegationDispatchRule[];
|
|
31
43
|
stackAwareRoutes: StageStackAwareReviewRoute[];
|
|
32
44
|
}
|
|
33
45
|
export declare function reviewStackAwareRoutes(): StageStackAwareReviewRoute[];
|