cclaw-cli 0.51.23 → 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.
- 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 +128 -2
- package/dist/content/core-agents.js +291 -13
- package/dist/content/examples.js +21 -10
- 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/seed-shelf.js +73 -8
- package/dist/content/skills.js +39 -34
- package/dist/content/stage-common-guidance.js +19 -3
- package/dist/content/stage-schema.d.ts +12 -0
- package/dist/content/stage-schema.js +224 -24
- package/dist/content/stages/_lint-metadata/index.js +3 -2
- package/dist/content/stages/brainstorm.js +27 -18
- package/dist/content/stages/design.js +27 -18
- package/dist/content/stages/review.js +20 -9
- package/dist/content/stages/schema-types.d.ts +9 -2
- package/dist/content/stages/scope.js +21 -10
- 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 +9 -4
- package/dist/content/subagents.js +336 -38
- package/dist/content/templates.js +182 -25
- package/dist/delegation.d.ts +2 -0
- package/dist/delegation.js +27 -6
- package/dist/doctor.js +167 -25
- package/dist/flow-state.d.ts +1 -0
- package/dist/flow-state.js +1 -0
- package/dist/gate-evidence.js +25 -2
- package/dist/install.js +72 -8
- package/dist/internal/advance-stage.js +179 -26
- package/dist/knowledge-store.js +30 -6
- package/dist/run-archive.js +11 -0
- package/dist/run-persistence.js +35 -10
- 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
|
+
}
|
|
@@ -4,6 +4,8 @@ import { parse } from "yaml";
|
|
|
4
4
|
import { RUNTIME_ROOT } from "../constants.js";
|
|
5
5
|
const SEED_FILE_NAME_PATTERN = /^SEED-(\d{4}-\d{2}-\d{2})-([a-z0-9]+(?:-[a-z0-9]+)*)(?:-(\d+))?\.md$/u;
|
|
6
6
|
const DEFAULT_MAX_MATCHES = 3;
|
|
7
|
+
const MAX_SEED_MATCHES = 10;
|
|
8
|
+
const MIN_TOKEN_OVERLAP = 2;
|
|
7
9
|
function isRecord(value) {
|
|
8
10
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
11
|
}
|
|
@@ -189,18 +191,81 @@ export async function readSeedShelf(projectRoot) {
|
|
|
189
191
|
entries.sort((a, b) => b.fileName.localeCompare(a.fileName));
|
|
190
192
|
return entries;
|
|
191
193
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (
|
|
194
|
+
function normalizeMatchText(value) {
|
|
195
|
+
return value.toLowerCase().trim().replace(/\s+/gu, " ");
|
|
196
|
+
}
|
|
197
|
+
function tokenizeSeedText(value) {
|
|
198
|
+
if (!value)
|
|
199
|
+
return [];
|
|
200
|
+
return value
|
|
201
|
+
.toLowerCase()
|
|
202
|
+
.split(/[^a-z0-9]+/u)
|
|
203
|
+
.map((token) => token.trim())
|
|
204
|
+
.filter((token) => token.length >= 3);
|
|
205
|
+
}
|
|
206
|
+
function uniqueTokens(values) {
|
|
207
|
+
return new Set(values);
|
|
208
|
+
}
|
|
209
|
+
function exactTriggerMatch(seed, normalizedPrompt) {
|
|
210
|
+
if (normalizedPrompt.length === 0 || seed.triggerWhen.length === 0)
|
|
197
211
|
return false;
|
|
198
|
-
return seed.triggerWhen.some((trigger) =>
|
|
212
|
+
return seed.triggerWhen.some((trigger) => {
|
|
213
|
+
const normalizedTrigger = normalizeMatchText(trigger);
|
|
214
|
+
return normalizedTrigger.length > 0 && normalizedPrompt.includes(normalizedTrigger);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function seedContentTokens(seed) {
|
|
218
|
+
return uniqueTokens([
|
|
219
|
+
...tokenizeSeedText(seed.title),
|
|
220
|
+
...tokenizeSeedText(seed.summary),
|
|
221
|
+
...tokenizeSeedText(seed.hypothesis),
|
|
222
|
+
...tokenizeSeedText(seed.action)
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
function tokenOverlap(seed, promptTokens) {
|
|
226
|
+
if (promptTokens.size === 0)
|
|
227
|
+
return 0;
|
|
228
|
+
const contentTokens = seedContentTokens(seed);
|
|
229
|
+
let overlap = 0;
|
|
230
|
+
for (const token of promptTokens) {
|
|
231
|
+
if (contentTokens.has(token))
|
|
232
|
+
overlap += 1;
|
|
233
|
+
}
|
|
234
|
+
return overlap;
|
|
235
|
+
}
|
|
236
|
+
export function seedMatchesPrompt(seed, prompt) {
|
|
237
|
+
const normalizedPrompt = normalizeMatchText(prompt);
|
|
238
|
+
if (exactTriggerMatch(seed, normalizedPrompt))
|
|
239
|
+
return true;
|
|
240
|
+
return tokenOverlap(seed, uniqueTokens(tokenizeSeedText(prompt))) >= MIN_TOKEN_OVERLAP;
|
|
199
241
|
}
|
|
200
242
|
export async function findMatchingSeeds(projectRoot, prompt, maxMatches = DEFAULT_MAX_MATCHES) {
|
|
201
243
|
const seeds = await readSeedShelf(projectRoot);
|
|
202
|
-
const
|
|
203
|
-
|
|
244
|
+
const normalizedPrompt = normalizeMatchText(prompt);
|
|
245
|
+
if (normalizedPrompt.length === 0)
|
|
246
|
+
return [];
|
|
247
|
+
const promptTokens = uniqueTokens(tokenizeSeedText(prompt));
|
|
248
|
+
const cappedMax = typeof maxMatches === "number" && Number.isFinite(maxMatches) && maxMatches > 0
|
|
249
|
+
? Math.min(MAX_SEED_MATCHES, Math.max(1, Math.floor(maxMatches)))
|
|
250
|
+
: DEFAULT_MAX_MATCHES;
|
|
251
|
+
const ranked = seeds
|
|
252
|
+
.map((seed, index) => {
|
|
253
|
+
const exact = exactTriggerMatch(seed, normalizedPrompt);
|
|
254
|
+
const overlap = tokenOverlap(seed, promptTokens);
|
|
255
|
+
return { seed, index, exact, overlap };
|
|
256
|
+
})
|
|
257
|
+
.filter((row) => row.exact || row.overlap >= MIN_TOKEN_OVERLAP);
|
|
258
|
+
ranked.sort((a, b) => {
|
|
259
|
+
if (a.exact !== b.exact)
|
|
260
|
+
return a.exact ? -1 : 1;
|
|
261
|
+
if (b.overlap !== a.overlap)
|
|
262
|
+
return b.overlap - a.overlap;
|
|
263
|
+
const recency = b.seed.createdOn.localeCompare(a.seed.createdOn);
|
|
264
|
+
if (recency !== 0)
|
|
265
|
+
return recency;
|
|
266
|
+
return a.index - b.index;
|
|
267
|
+
});
|
|
268
|
+
return ranked.slice(0, cappedMax).map((row) => row.seed);
|
|
204
269
|
}
|
|
205
270
|
export function renderSeedTemplate(input) {
|
|
206
271
|
const triggerWhen = [...input.triggerWhen].map((item) => item.trim()).filter((item) => item.length > 0);
|
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,7 +59,9 @@ 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;
|
|
@@ -73,27 +69,37 @@ function autoSubagentDispatchBlock(stage, track) {
|
|
|
73
69
|
const delegationLogRel = `${RUNTIME_ROOT}/state/delegation-log.json`;
|
|
74
70
|
const artifactRef = `${RUNTIME_ROOT}/artifacts/${schema.artifactRules.artifactFile}`;
|
|
75
71
|
return `## Automatic Subagent Dispatch
|
|
76
|
-
| Agent | Mode | User Gate | Trigger | Purpose |
|
|
77
|
-
|
|
72
|
+
| Agent | Mode | Class | Return Schema | User Gate | Trigger | Purpose |
|
|
73
|
+
|---|---|---|---|---|---|---|
|
|
78
74
|
${rows}
|
|
79
|
-
Mandatory: ${mandatoryList}. Record
|
|
75
|
+
Mandatory: ${mandatoryList}. Record scheduled/completed/waived lifecycle rows in \`${delegationLogRel}\` before completion.
|
|
80
76
|
### 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.
|
|
77
|
+
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"\`. Each dispatched worker should have a scheduled row and a terminal row sharing \`spanId\`; stale scheduled spans block completion. 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.
|
|
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) {
|
|
@@ -389,9 +395,8 @@ ${conversationLanguagePolicyMarkdown()}
|
|
|
389
395
|
${philosophy.purpose}
|
|
390
396
|
|
|
391
397
|
## Complexity Tier
|
|
392
|
-
- Active tier: \`${schema.complexityTier}
|
|
393
|
-
- Scale-to-complexity
|
|
394
|
-
- Mandatory delegations at this tier: ${mandatoryDelegationSummary}
|
|
398
|
+
- Active tier: \`${schema.complexityTier}\`; mandatory delegations: ${mandatoryDelegationSummary}
|
|
399
|
+
- Scale-to-complexity: execute required gates/sections; keep optional/deep sections compact unless risk, novelty, or config triggers them.
|
|
395
400
|
- Track render context: \`${trackContext.track}\` (${trackContext.usesPlanTerminology ? "plan-first wording" : "acceptance-first wording"})
|
|
396
401
|
|
|
397
402
|
## When to Use
|
|
@@ -406,14 +411,14 @@ ${mergedAntiPatterns(philosophy, executionModel)}
|
|
|
406
411
|
|
|
407
412
|
## Process
|
|
408
413
|
|
|
409
|
-
|
|
410
|
-
|
|
414
|
+
Stage state machine (map only; Checklist is authoritative):
|
|
411
415
|
${processFlowMermaid.length > 0 ? processFlowMermaid : "```mermaid\nflowchart TD\n S1[\"Execute Checklist\"] --> S2[\"Satisfy required gates\"] --> S3[\"Verify before closeout\"]\n```"}
|
|
412
416
|
|
|
413
417
|
${platformNotesBlock}${contextLoadingBlock(stage, artifactRules.crossStageTrace, executionModel)}
|
|
414
418
|
${autoSubagentDispatchBlock(stage, track)}
|
|
415
419
|
${stackAwareReviewRoutingBlock(stage)}
|
|
416
420
|
${researchPlaybooksBlock(executionModel.researchPlaybooks ?? [])}
|
|
421
|
+
${referencePatternsBlock(stage)}
|
|
417
422
|
|
|
418
423
|
## Checklist
|
|
419
424
|
|