cclaw-cli 0.5.4 → 0.5.6
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 +8 -11
- package/dist/artifact-linter.js +3 -13
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +12 -1
- package/dist/config.js +0 -19
- package/dist/content/contracts.js +7 -12
- package/dist/content/examples.js +31 -49
- package/dist/content/hooks.d.ts +4 -6
- package/dist/content/hooks.js +104 -523
- package/dist/content/learnings.js +55 -203
- package/dist/content/meta-skill.js +8 -11
- package/dist/content/next-command.js +3 -3
- package/dist/content/observe.d.ts +4 -7
- package/dist/content/observe.js +10 -48
- package/dist/content/session-hooks.js +8 -8
- package/dist/content/skills.js +9 -16
- package/dist/content/stage-schema.js +76 -120
- package/dist/content/templates.d.ts +1 -1
- package/dist/content/templates.js +25 -57
- package/dist/delegation.js +7 -7
- package/dist/doctor.js +16 -47
- package/dist/flow-state.js +1 -1
- package/dist/harness-adapters.js +1 -1
- package/dist/install.js +22 -48
- package/dist/policy.js +1 -4
- package/dist/runs.d.ts +9 -9
- package/dist/runs.js +107 -320
- package/dist/trace-matrix.js +8 -18
- package/dist/types.d.ts +0 -4
- package/package.json +1 -1
- package/dist/learnings-summarizer.d.ts +0 -25
- package/dist/learnings-summarizer.js +0 -201
package/dist/content/skills.js
CHANGED
|
@@ -2,10 +2,6 @@ import { RUNTIME_ROOT } from "../constants.js";
|
|
|
2
2
|
import { stageExamples } from "./examples.js";
|
|
3
3
|
import { selfImprovementBlock } from "./learnings.js";
|
|
4
4
|
import { QUESTION_FORMAT_SPEC, ERROR_BUDGET_SPEC, stageAutoSubagentDispatch, stageSchema } from "./stage-schema.js";
|
|
5
|
-
function artifactFileName(artifactPath) {
|
|
6
|
-
const parts = artifactPath.split("/");
|
|
7
|
-
return parts[parts.length - 1] ?? artifactPath;
|
|
8
|
-
}
|
|
9
5
|
function rationalizationTable(stage) {
|
|
10
6
|
const schema = stageSchema(stage);
|
|
11
7
|
return `| Rationalization | Reality |
|
|
@@ -75,20 +71,17 @@ function contextLoadingBlock(stage) {
|
|
|
75
71
|
const trace = stageSchema(stage).crossStageTrace;
|
|
76
72
|
const readLines = trace.readsFrom.length > 0
|
|
77
73
|
? trace.readsFrom
|
|
78
|
-
.map((value) => {
|
|
79
|
-
const fileName = artifactFileName(value);
|
|
80
|
-
return `- Canonical: \`.cclaw/runs/<activeRunId>/artifacts/${fileName}\` (fallback: \`${value}\`)`;
|
|
81
|
-
})
|
|
74
|
+
.map((value) => `- \`${value}\``)
|
|
82
75
|
.join("\n")
|
|
83
76
|
: "- (first stage — no upstream artifacts)";
|
|
84
77
|
return `## Context Loading
|
|
85
78
|
|
|
86
79
|
Before starting stage execution:
|
|
87
|
-
1. Read \`.cclaw/state/flow-state.json
|
|
88
|
-
2. Resolve
|
|
80
|
+
1. Read \`.cclaw/state/flow-state.json\`.
|
|
81
|
+
2. Resolve active artifact root: \`.cclaw/artifacts/\`.
|
|
89
82
|
3. Load upstream artifacts required by this stage:
|
|
90
83
|
${readLines}
|
|
91
|
-
4.
|
|
84
|
+
4. Read \`.cclaw/knowledge.md\` and apply relevant entries before making decisions.
|
|
92
85
|
`;
|
|
93
86
|
}
|
|
94
87
|
function whenNotToUseBlock(stage) {
|
|
@@ -113,7 +106,7 @@ function autoSubagentDispatchBlock(stage) {
|
|
|
113
106
|
.join("\n");
|
|
114
107
|
const mandatory = stageSchema(stage).mandatoryDelegations;
|
|
115
108
|
const mandatoryList = mandatory.length > 0 ? mandatory.map((a) => `\`${a}\``).join(", ") : "(none — only proactive dispatch applies)";
|
|
116
|
-
const delegationLogRel = `${RUNTIME_ROOT}/
|
|
109
|
+
const delegationLogRel = `${RUNTIME_ROOT}/state/delegation-log.json`;
|
|
117
110
|
return `## Automatic Subagent Dispatch
|
|
118
111
|
|
|
119
112
|
Machine-only work should be delegated to specialist agents automatically according to the matrix below.
|
|
@@ -174,7 +167,7 @@ When all required gates are satisfied and the artifact is written:
|
|
|
174
167
|
1. **Update \`${RUNTIME_ROOT}/state/flow-state.json\`:**
|
|
175
168
|
${stateUpdate}
|
|
176
169
|
- For each passed gate, add an entry to \`guardEvidence\`: \`"<gate_id>": "<artifact path or excerpt proving the gate>"\`. Do NOT leave \`guardEvidence\` empty.
|
|
177
|
-
2. **Persist artifact** at \`${RUNTIME_ROOT}/artifacts/${schema.artifactFile}\`. Do NOT manually copy into
|
|
170
|
+
2. **Persist artifact** at \`${RUNTIME_ROOT}/artifacts/${schema.artifactFile}\`. Do NOT manually copy into \`${RUNTIME_ROOT}/runs/\`; archival is handled by \`cclaw archive\`.
|
|
178
171
|
${nextAction}
|
|
179
172
|
|
|
180
173
|
**STOP.** Do not load the next stage skill yourself. The user will run \`/cc-next\` when ready (same session or new session).
|
|
@@ -231,7 +224,7 @@ function progressiveDisclosureBlock(stage) {
|
|
|
231
224
|
- Primary stage procedure (this file): \`.cclaw/skills/${schema.skillFolder}/SKILL.md\`
|
|
232
225
|
- Orchestrator contract (gate language and handoff): \`.cclaw/commands/${stage}.md\`
|
|
233
226
|
- Artifact structure baseline: \`.cclaw/templates/${schema.artifactFile}\`
|
|
234
|
-
- Runtime state truth source: \`.cclaw/state/flow-state.json\` + \`.cclaw/
|
|
227
|
+
- Runtime state truth source: \`.cclaw/state/flow-state.json\` + \`.cclaw/artifacts/\` + \`.cclaw/knowledge.md\`
|
|
235
228
|
|
|
236
229
|
### See also
|
|
237
230
|
- Meta routing and activation rules: \`.cclaw/skills/using-cclaw/SKILL.md\`
|
|
@@ -287,7 +280,7 @@ function quickStartBlock(stage) {
|
|
|
287
280
|
|
|
288
281
|
> **Even if you read nothing else, do these 3 things:**
|
|
289
282
|
> 1. Obey the HARD-GATE below — violating it invalidates the entire stage.
|
|
290
|
-
> 2. Complete every checklist step in order and write the artifact to \`.cclaw/artifacts/${schema.artifactFile}\`.
|
|
283
|
+
> 2. Complete every checklist step in order and write the artifact to \`.cclaw/artifacts/${schema.artifactFile}\`.
|
|
291
284
|
> 3. Do not claim completion without satisfying gates: ${topGates}${schema.requiredGates.length > 3 ? ` (+${schema.requiredGates.length - 3} more)` : ""}.
|
|
292
285
|
>
|
|
293
286
|
> **After this stage:** update \`flow-state.json\` and tell the user to run \`/cc-next\`.
|
|
@@ -385,7 +378,7 @@ ${progressiveDisclosureBlock(stage)}
|
|
|
385
378
|
${selfImprovementBlock(stage)}
|
|
386
379
|
## Handoff
|
|
387
380
|
- Next command: \`/cc-next\` (loads whatever stage is current in flow-state)
|
|
388
|
-
- Required artifact: \`.cclaw/artifacts/${schema.artifactFile}\`
|
|
381
|
+
- Required artifact: \`.cclaw/artifacts/${schema.artifactFile}\`
|
|
389
382
|
- Stage stays blocked if any required gate is unsatisfied
|
|
390
383
|
`;
|
|
391
384
|
}
|
|
@@ -22,185 +22,141 @@ const BRAINSTORM = {
|
|
|
22
22
|
stage: "brainstorm",
|
|
23
23
|
skillFolder: "brainstorming",
|
|
24
24
|
skillName: "brainstorming",
|
|
25
|
-
skillDescription: "Design-first stage.
|
|
26
|
-
hardGate: "Do NOT invoke
|
|
27
|
-
purpose: "Turn
|
|
25
|
+
skillDescription: "Design-first stage. Explore context, understand intent through collaborative dialogue, propose distinct approaches, and lock an approved direction before scope/design work.",
|
|
26
|
+
hardGate: "Do NOT invoke implementation skills, write code, scaffold projects, or mutate product behavior until a concrete direction is approved by the user.",
|
|
27
|
+
purpose: "Turn an initial idea into an approved design direction through natural collaborative dialogue — understanding the problem before proposing solutions.",
|
|
28
28
|
whenToUse: [
|
|
29
29
|
"Starting a new feature or behavior change",
|
|
30
|
-
"Requirements are ambiguous or
|
|
31
|
-
"Before any implementation-stage command"
|
|
30
|
+
"Requirements are ambiguous or trade-offs are unclear",
|
|
31
|
+
"Before any implementation-stage command or architecture commitment"
|
|
32
32
|
],
|
|
33
33
|
whenNotToUse: [
|
|
34
|
-
"
|
|
35
|
-
"The request is
|
|
36
|
-
"The task is
|
|
34
|
+
"A valid approved direction already exists and only execution remains",
|
|
35
|
+
"The request is a pure release/finalization action with no new product decisions",
|
|
36
|
+
"The task is retrospective only (post-ship audit with no new solution choices)"
|
|
37
37
|
],
|
|
38
38
|
checklist: [
|
|
39
|
-
"Explore project context — check files, docs, recent commits
|
|
40
|
-
"Assess scope — if the request
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"User reviews written artifact — ask user to review the written artifact (not the chat summary). **STOP.** Do NOT proceed until user responds.",
|
|
49
|
-
"Stage complete — update `flow-state.json` per the Stage Completion Protocol. Tell user to run `/cc-next` to continue to scope."
|
|
39
|
+
"**Explore project context** — check files, docs, recent commits to understand what already exists.",
|
|
40
|
+
"**Assess scope** — if the request covers multiple independent subsystems, flag it and help decompose before deep-diving. Each sub-project gets its own brainstorm cycle.",
|
|
41
|
+
"**Ask clarifying questions** — one at a time, understand purpose, constraints, and success criteria. Prefer multiple choice when possible. Each question should change what we build, not just gather trivia.",
|
|
42
|
+
"**Propose 2-3 architecturally distinct approaches** — with real trade-offs and your recommendation. Lead with the recommended option and explain why.",
|
|
43
|
+
"**Present design by sections** — scale each section to its complexity. Ask after each section whether it looks right so far. Cover: architecture, key components, data flow.",
|
|
44
|
+
"**Write artifact** to `.cclaw/artifacts/01-brainstorm.md`.",
|
|
45
|
+
"**Self-review** — scan for placeholders/TODOs, check internal consistency, verify scope is focused, resolve any ambiguity.",
|
|
46
|
+
"**User reviews artifact** — ask the user to review the written artifact and explicitly approve or request changes.",
|
|
47
|
+
"**Handoff** — only then complete stage and point to `/cc-next`."
|
|
50
48
|
],
|
|
51
49
|
interactionProtocol: [
|
|
52
|
-
"Explore
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"When
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"Get section-by-section approval before finalizing the design direction.",
|
|
61
|
-
"Run a self-review pass (ambiguity, placeholders, contradictions) before handoff.",
|
|
62
|
-
"**STOP.** Wait for explicit user approval after writing the artifact. Do NOT auto-advance to the next stage."
|
|
50
|
+
"Explore what exists before asking what to build — check project files first.",
|
|
51
|
+
"Ask exactly one question per turn. Prefer multiple choice. No bundled questions.",
|
|
52
|
+
"Each question should change a concrete design decision. If a question only gathers trivia, skip it.",
|
|
53
|
+
"Present design in sections scaled to their complexity — a few sentences for simple aspects, detailed for nuanced ones. Get approval after each section.",
|
|
54
|
+
"When proposing approaches, lead with your recommendation and explain why.",
|
|
55
|
+
"State explicitly what is being approved when requesting approval.",
|
|
56
|
+
"Run a brief self-review (placeholders, contradictions, scope, ambiguity) before presenting the artifact.",
|
|
57
|
+
"**STOP.** Wait for explicit user approval after writing the artifact. Do NOT auto-advance."
|
|
63
58
|
],
|
|
64
59
|
process: [
|
|
65
|
-
"Explore project context
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"Ask user to review the written artifact. Wait for changes or approval.",
|
|
75
|
-
"Handoff to scope stage only after approval is explicit."
|
|
60
|
+
"Explore project context: check files, docs, recent activity.",
|
|
61
|
+
"Assess scope: flag if request is too broad, help decompose first.",
|
|
62
|
+
"Ask clarifying questions one at a time — focus on purpose, constraints, success criteria.",
|
|
63
|
+
"Propose 2-3 architecturally distinct approaches with trade-offs and a recommendation.",
|
|
64
|
+
"Present design sections incrementally, get approval after each.",
|
|
65
|
+
"Write approved direction to `.cclaw/artifacts/01-brainstorm.md`.",
|
|
66
|
+
"Self-review: placeholder scan, internal consistency, scope check, ambiguity check.",
|
|
67
|
+
"Request explicit user approval of the artifact.",
|
|
68
|
+
"Handoff to scope only after approval is explicit."
|
|
76
69
|
],
|
|
77
70
|
requiredGates: [
|
|
78
|
-
{ id: "
|
|
79
|
-
{ id: "
|
|
80
|
-
{ id: "
|
|
81
|
-
{ id: "
|
|
82
|
-
{ id: "
|
|
83
|
-
{
|
|
84
|
-
id: "brainstorm_problem_restated",
|
|
85
|
-
description: "Problem was restated in agent's words in a standalone non-question message, and user confirmed the understanding."
|
|
86
|
-
},
|
|
87
|
-
{ id: "brainstorm_options_compared", description: "At least two alternatives were compared with real trade-offs." },
|
|
88
|
-
{ id: "brainstorm_design_approved", description: "User approved a concrete design direction (with explicit statement of what was approved)." },
|
|
89
|
-
{ id: "brainstorm_self_review_passed", description: "Design doc passed placeholder/ambiguity/consistency checks." },
|
|
90
|
-
{ id: "brainstorm_user_reviewed_artifact", description: "User reviewed the written artifact and confirmed readiness." }
|
|
71
|
+
{ id: "brainstorm_context_explored", description: "Project context (files, docs, existing patterns) was checked before asking questions." },
|
|
72
|
+
{ id: "brainstorm_idea_understood", description: "Agent and user share the same understanding of the problem, constraints, and success criteria." },
|
|
73
|
+
{ id: "brainstorm_approaches_compared", description: "2-3 architecturally distinct approaches were compared with real trade-offs and a recommendation." },
|
|
74
|
+
{ id: "brainstorm_direction_approved", description: "User approved a concrete direction and what exactly was approved is stated." },
|
|
75
|
+
{ id: "brainstorm_artifact_reviewed", description: "User reviewed the written brainstorm artifact and confirmed readiness." }
|
|
91
76
|
],
|
|
92
77
|
requiredEvidence: [
|
|
93
78
|
"Artifact written to `.cclaw/artifacts/01-brainstorm.md`.",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"Approved direction captured in artifact.",
|
|
100
|
-
"Restatement evidence shows a standalone non-question restatement message before clarification Q&A.",
|
|
101
|
-
"Open questions explicitly listed (if any).",
|
|
102
|
-
"Self-review pass completed with no unresolved issues."
|
|
79
|
+
"Project context was explored (files, docs, or recent activity referenced).",
|
|
80
|
+
"Clarifying questions and their answers are captured.",
|
|
81
|
+
"2-3 approaches with trade-offs and recommendation are recorded.",
|
|
82
|
+
"Approved direction and approval marker are present.",
|
|
83
|
+
"Assumptions and open questions are captured (or explicitly marked as none)."
|
|
103
84
|
],
|
|
104
85
|
inputs: ["problem statement", "constraints", "success criteria"],
|
|
105
86
|
requiredContext: [
|
|
106
|
-
"existing project
|
|
87
|
+
"existing project context and patterns",
|
|
107
88
|
"current behavior of affected area",
|
|
108
89
|
"business and delivery constraints"
|
|
109
90
|
],
|
|
110
91
|
outputs: [
|
|
111
92
|
"approved design direction",
|
|
112
|
-
"alternatives
|
|
93
|
+
"alternatives with trade-offs",
|
|
113
94
|
"brainstorm artifact"
|
|
114
95
|
],
|
|
115
96
|
blockers: [
|
|
116
97
|
"no explicit approval",
|
|
117
98
|
"critical ambiguity unresolved",
|
|
118
|
-
"
|
|
99
|
+
"project context not explored"
|
|
119
100
|
],
|
|
120
101
|
exitCriteria: [
|
|
121
102
|
"approved design direction documented",
|
|
122
103
|
"required gates marked satisfied",
|
|
123
104
|
"no implementation action taken",
|
|
124
|
-
"
|
|
105
|
+
"artifact reviewed by user"
|
|
125
106
|
],
|
|
126
107
|
antiPatterns: [
|
|
127
|
-
"
|
|
128
|
-
"Asking
|
|
108
|
+
"Asking questions without exploring existing project context first",
|
|
109
|
+
"Asking bundled or purely informational questions that don't change decisions",
|
|
110
|
+
"Proposing cosmetic option variants instead of architecturally distinct approaches",
|
|
129
111
|
"Jumping directly into implementation",
|
|
130
|
-
"
|
|
131
|
-
"Invoking implementation skills before writing plans",
|
|
132
|
-
"Appending clarifying questions to the restatement message instead of waiting for confirmation",
|
|
133
|
-
"Packing multiple clarifying questions into one message (including bullet-list question bundles)",
|
|
134
|
-
"Silently filling defaults after 'не знаю'/'I don't know' without explicit assumption confirmation",
|
|
135
|
-
"Accepting 'simple/test/demo' framing without premise challenge or failure stress testing",
|
|
136
|
-
"Asking bare 'approve?' or 'одобряете?' without stating WHAT is being approved",
|
|
137
|
-
"Presenting a single summary and asking for blanket approval instead of section-by-section review",
|
|
138
|
-
"Rushing through clarification — asking 1-2 generic questions then jumping to design",
|
|
139
|
-
"Batching multiple gate confirmations in one message when resuming a session"
|
|
112
|
+
"Requesting approval without stating what decision is being approved"
|
|
140
113
|
],
|
|
141
114
|
rationalizations: [
|
|
142
|
-
{ claim: "
|
|
143
|
-
{ claim: "
|
|
144
|
-
{ claim: "
|
|
145
|
-
{ claim: "The user already knows what they want.", reality: "Unstated assumptions diverge during implementation; explicit design surfaces them early." },
|
|
146
|
-
{ claim: "This is straightforward, 1-2 questions are enough.", reality: "Even simple projects have hidden constraints (error handling, edge cases, deployment). A few extra questions now prevent rework later." }
|
|
115
|
+
{ claim: "I already know what to build, so exploration is unnecessary.", reality: "Checking files and context catches wrong assumptions that waste hours later." },
|
|
116
|
+
{ claim: "Any question is useful context.", reality: "Only questions whose answers change what we build improve the design." },
|
|
117
|
+
{ claim: "Two options that differ only in tooling count as distinct approaches.", reality: "Distinct means different architecture, not different libraries for the same approach." }
|
|
147
118
|
],
|
|
148
119
|
redFlags: [
|
|
149
|
-
"No
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"Artifact has TBD or placeholder sections",
|
|
154
|
-
"Restatement step includes clarifying questions or option prompts",
|
|
155
|
-
"Clarification turns repeatedly include multi-question bundles instead of single asks",
|
|
156
|
-
"Unknown user answers are treated as settled requirements without explicit assumption confirmation",
|
|
157
|
-
"No evidence of premise challenge or failure stress-test questions before options",
|
|
158
|
-
"Fewer than 3 clarifying questions asked for any non-trivial project",
|
|
159
|
-
"Approval requested without stating what exactly is being approved"
|
|
120
|
+
"No project context exploration before questions",
|
|
121
|
+
"Questions that only gather preferences without design impact",
|
|
122
|
+
"Options that are variants of one approach, not distinct alternatives",
|
|
123
|
+
"Approval requested without explicit decision context"
|
|
160
124
|
],
|
|
161
125
|
policyNeedles: [
|
|
162
|
-
"
|
|
163
|
-
"One
|
|
164
|
-
"2-3
|
|
126
|
+
"Explore project context",
|
|
127
|
+
"One question at a time",
|
|
128
|
+
"2-3 architecturally distinct approaches",
|
|
165
129
|
"State what is being approved",
|
|
130
|
+
"Self-review before handoff",
|
|
166
131
|
"Do NOT implement, scaffold, or modify behavior"
|
|
167
132
|
],
|
|
168
133
|
artifactFile: "01-brainstorm.md",
|
|
169
134
|
next: "scope",
|
|
170
135
|
cognitivePatterns: [
|
|
171
|
-
{ name: "
|
|
172
|
-
{ name: "
|
|
173
|
-
{ name: "
|
|
174
|
-
{ name: "
|
|
136
|
+
{ name: "Context Before Questions", description: "Understand what exists before asking what to build." },
|
|
137
|
+
{ name: "Depth Matches Complexity", description: "Brief design for simple tasks, thorough exploration for complex ones." },
|
|
138
|
+
{ name: "Diverge Then Commit", description: "Explore multiple architecturally distinct options first, commit only after explicit approval." },
|
|
139
|
+
{ name: "Question Quality Over Quantity", description: "Each question should change what we build, not just gather trivia." }
|
|
175
140
|
],
|
|
176
141
|
reviewSections: [],
|
|
177
142
|
completionStatus: ["DONE", "DONE_WITH_CONCERNS", "BLOCKED"],
|
|
178
143
|
crossStageTrace: {
|
|
179
144
|
readsFrom: [],
|
|
180
145
|
writesTo: [".cclaw/artifacts/01-brainstorm.md"],
|
|
181
|
-
traceabilityRule: "
|
|
146
|
+
traceabilityRule: "Scope and design decisions must trace back to explored context and approved brainstorm direction."
|
|
182
147
|
},
|
|
183
148
|
artifactValidation: [
|
|
184
|
-
{ section: "
|
|
185
|
-
{ section: "
|
|
186
|
-
{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
{ section: "Purpose & Beneficiaries", required: true, validationRule: "At least 3 meaningful lines describing why this exists and who benefits." },
|
|
192
|
-
{ section: "Scope Boundaries", required: true, validationRule: "At least 2 scope items including explicit out-of-scope boundaries." },
|
|
193
|
-
{ section: "Failure Boundaries", required: true, validationRule: "At least 2 failure/edge-case expectations and error visibility behavior." },
|
|
194
|
-
{ section: "Runtime Environment", required: true, validationRule: "At least 2 lines describing runtime, install/distribution, and execution environment." },
|
|
195
|
-
{ section: "Constraints", required: true, validationRule: "At least 2 concrete constraints (performance, compatibility, dependency, or policy)." },
|
|
196
|
-
{ section: "Alternatives Table", required: true, validationRule: "At least 2 approaches with real trade-offs (not cosmetic) and recommendation with reasoning." },
|
|
197
|
-
{ section: "Approved Direction", required: true, validationRule: "Must contain explicit approval marker from user. State what was approved." },
|
|
198
|
-
{ section: "Assumptions & Risks", required: true, validationRule: "Explicit assumptions made during design. Known risks. If none, state 'None'." },
|
|
199
|
-
{ section: "Open Questions", required: true, validationRule: "If empty, state 'None' explicitly. Do not omit." }
|
|
149
|
+
{ section: "Context", required: true, validationRule: "Must reference project state and relevant existing code or patterns." },
|
|
150
|
+
{ section: "Problem", required: true, validationRule: "Must define what we're solving, success criteria, and constraints." },
|
|
151
|
+
{ section: "Clarifying Questions", required: true, validationRule: "Must capture question, answer, and decision impact for each clarifying question." },
|
|
152
|
+
{ section: "Approaches", required: true, validationRule: "Must compare 2-3 architecturally distinct options with real trade-offs and recommendation." },
|
|
153
|
+
{ section: "Selected Direction", required: true, validationRule: "Must include the selected approach, rationale, and explicit approval marker." },
|
|
154
|
+
{ section: "Design", required: true, validationRule: "Must cover architecture, key components, and data flow scaled to complexity." },
|
|
155
|
+
{ section: "Assumptions and Open Questions", required: true, validationRule: "Must capture unresolved assumptions/open questions, or explicitly state none." }
|
|
200
156
|
],
|
|
201
157
|
namedAntiPattern: {
|
|
202
158
|
title: "This Is Too Simple To Need A Design",
|
|
203
|
-
description: "Every project goes through this process.
|
|
159
|
+
description: "Every project goes through this process. Simple projects are where unexamined assumptions cause the most wasted work. The design can be short, but you MUST present it and get approval."
|
|
204
160
|
}
|
|
205
161
|
};
|
|
206
162
|
// ---------------------------------------------------------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const ARTIFACT_TEMPLATES: Record<string, string>;
|
|
2
2
|
export declare const RULEBOOK_MARKDOWN = "# Cclaw Rulebook\n\n## MUST_ALWAYS\n- Follow flow order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\n- Require explicit user confirmation after plan before TDD\n- Keep evidence artifacts in `.cclaw/artifacts/`\n- Enforce RED before GREEN in TDD\n- Run two-layer review (spec_compliance and code_quality) before ship\n- Validate all inputs before processing \u2014 never trust external data without sanitization\n- Prefer immutable data patterns and pure functions where the language supports them\n- Follow existing repo conventions, patterns, and directory structure \u2014 match the codebase\n- Verify claims with fresh evidence: \"tests pass\" requires running tests in this message\n- Use conventional commits: `type(scope): description` (feat, fix, refactor, test, docs, chore)\n\n## MUST_NEVER\n- Skip RED phase and jump directly to GREEN in TDD\n- Ship with critical review findings\n- Start implementation during /brainstorm\n- Modify generated cclaw files manually when CLI can regenerate them\n- Commit `.cclaw/` or generated shim files\n- Expose secrets, tokens, API keys, or absolute system paths in agent output\n- Duplicate existing functionality without explicit justification \u2014 search before building\n- Bypass security checks, linting hooks, or type checking to \"move faster\"\n- Claim success (\"Done,\" \"All good,\" \"Tests pass\") without running verification in this message\n- Make changes outside the blast radius of the current task without user consent\n\n## DELEGATION\nWhen a task requires specialist knowledge (security audit, performance profiling, database review),\ndelegate to a specialized agent or skill if the harness supports it. The primary agent should:\n1. Identify the specialist domain\n2. Provide focused context (relevant files, the specific concern)\n3. Evaluate the specialist output before acting on it \u2014 do not blindly apply recommendations\n";
|
|
3
|
-
export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n- Follow stage order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship.\n- Read `.cclaw/state/flow-state.json` before acting; continue from current stage when active.\n- Use `/cc-next` only after required gates pass; never bypass explicit pause/approval rules.\n- Keep evidence in `.cclaw/artifacts/`;
|
|
3
|
+
export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n- Follow stage order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship.\n- Read `.cclaw/state/flow-state.json` before acting; continue from current stage when active.\n- Use `/cc-next` only after required gates pass; never bypass explicit pause/approval rules.\n- Keep evidence in `.cclaw/artifacts/`; archive completed feature artifacts only via `cclaw archive`.\n- For machine-only checks in design/plan/tdd/review/ship, dispatch required specialists automatically when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, user challenge resolution, ship finalization).\n- Treat `.cclaw/skills/using-cclaw/SKILL.md` as routing source of truth; load contextual utility skills only when their triggers apply.\n";
|
|
4
4
|
export declare function buildRulesJson(): Record<string, unknown>;
|
|
@@ -3,71 +3,39 @@ import { orderedStageSchemas } from "./stage-schema.js";
|
|
|
3
3
|
export const ARTIFACT_TEMPLATES = {
|
|
4
4
|
"01-brainstorm.md": `# Brainstorm Artifact
|
|
5
5
|
|
|
6
|
-
##
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **Why now:**
|
|
10
|
-
- **Success signal:**
|
|
11
|
-
|
|
12
|
-
## Known Context
|
|
13
|
-
- **Explored files/patterns:**
|
|
14
|
-
- **Existing behavior:**
|
|
15
|
-
- **Relevant dependencies:**
|
|
16
|
-
|
|
17
|
-
## Clarification Log
|
|
18
|
-
| Category | Question asked | User answer | Evidence note |
|
|
19
|
-
|---|---|---|---|
|
|
20
|
-
| PURPOSE | | | |
|
|
21
|
-
| SCOPE | | | |
|
|
22
|
-
| BOUNDARIES | | | |
|
|
23
|
-
| ENVIRONMENT | | | |
|
|
24
|
-
| CONSTRAINTS | | | |
|
|
25
|
-
|
|
26
|
-
## Purpose & Beneficiaries
|
|
27
|
-
- **Project purpose:**
|
|
28
|
-
- **Primary users:**
|
|
29
|
-
- **Value outcome:**
|
|
30
|
-
|
|
31
|
-
## Scope Boundaries
|
|
32
|
-
### In Scope
|
|
33
|
-
-
|
|
6
|
+
## Context
|
|
7
|
+
- **Project state:**
|
|
8
|
+
- **Relevant existing code/patterns:**
|
|
34
9
|
|
|
35
|
-
|
|
36
|
-
-
|
|
10
|
+
## Problem
|
|
11
|
+
- **What we're solving:**
|
|
12
|
+
- **Success criteria:**
|
|
13
|
+
- **Constraints:**
|
|
37
14
|
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Runtime Environment
|
|
44
|
-
- **Runtime/platform:**
|
|
45
|
-
- **Install/distribution model:**
|
|
46
|
-
- **Execution context (local/CI/deploy):**
|
|
47
|
-
|
|
48
|
-
## Constraints
|
|
49
|
-
- **Performance constraints:**
|
|
50
|
-
- **Compatibility constraints:**
|
|
51
|
-
- **Dependency constraints:**
|
|
15
|
+
## Clarifying Questions
|
|
16
|
+
| # | Question | Answer | Decision impact |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| 1 | | | |
|
|
52
19
|
|
|
53
|
-
##
|
|
54
|
-
|
|
|
20
|
+
## Approaches
|
|
21
|
+
| Approach | Architecture | Trade-offs | Recommendation |
|
|
55
22
|
|---|---|---|---|
|
|
56
23
|
| A | | | |
|
|
57
24
|
| B | | | |
|
|
58
|
-
| C | | | |
|
|
59
25
|
|
|
60
|
-
##
|
|
61
|
-
- **
|
|
62
|
-
- **
|
|
63
|
-
- **
|
|
64
|
-
- **Approval marker:**
|
|
26
|
+
## Selected Direction
|
|
27
|
+
- **Approach:**
|
|
28
|
+
- **Rationale:**
|
|
29
|
+
- **Approval:** pending
|
|
65
30
|
|
|
66
|
-
##
|
|
67
|
-
-
|
|
31
|
+
## Design
|
|
32
|
+
- **Architecture:**
|
|
33
|
+
- **Key components:**
|
|
34
|
+
- **Data flow:**
|
|
68
35
|
|
|
69
|
-
## Open Questions
|
|
70
|
-
-
|
|
36
|
+
## Assumptions and Open Questions
|
|
37
|
+
- **Assumptions:**
|
|
38
|
+
- **Open questions (or "None"):**
|
|
71
39
|
`,
|
|
72
40
|
"02-scope.md": `# Scope Artifact
|
|
73
41
|
|
|
@@ -382,7 +350,7 @@ alwaysApply: true
|
|
|
382
350
|
- Follow stage order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship.
|
|
383
351
|
- Read \`.cclaw/state/flow-state.json\` before acting; continue from current stage when active.
|
|
384
352
|
- Use \`/cc-next\` only after required gates pass; never bypass explicit pause/approval rules.
|
|
385
|
-
- Keep evidence in \`.cclaw/artifacts/\`;
|
|
353
|
+
- Keep evidence in \`.cclaw/artifacts/\`; archive completed feature artifacts only via \`cclaw archive\`.
|
|
386
354
|
- For machine-only checks in design/plan/tdd/review/ship, dispatch required specialists automatically when tooling supports it.
|
|
387
355
|
- Ask for user input only at explicit approval gates (scope mode, plan approval, user challenge resolution, ship finalization).
|
|
388
356
|
- Treat \`.cclaw/skills/using-cclaw/SKILL.md\` as routing source of truth; load contextual utility skills only when their triggers apply.
|
package/dist/delegation.js
CHANGED
|
@@ -4,11 +4,11 @@ import { RUNTIME_ROOT } from "./constants.js";
|
|
|
4
4
|
import { exists, withDirectoryLock, writeFileSafe } from "./fs-utils.js";
|
|
5
5
|
import { readFlowState } from "./runs.js";
|
|
6
6
|
import { stageSchema } from "./content/stage-schema.js";
|
|
7
|
-
function delegationLogPath(projectRoot
|
|
8
|
-
return path.join(projectRoot, RUNTIME_ROOT, "
|
|
7
|
+
function delegationLogPath(projectRoot) {
|
|
8
|
+
return path.join(projectRoot, RUNTIME_ROOT, "state", "delegation-log.json");
|
|
9
9
|
}
|
|
10
|
-
function delegationLockPath(projectRoot
|
|
11
|
-
return path.join(projectRoot, RUNTIME_ROOT, "
|
|
10
|
+
function delegationLockPath(projectRoot) {
|
|
11
|
+
return path.join(projectRoot, RUNTIME_ROOT, "state", ".delegation.lock");
|
|
12
12
|
}
|
|
13
13
|
function isDelegationEntry(value) {
|
|
14
14
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -45,7 +45,7 @@ function parseLedger(raw, runId) {
|
|
|
45
45
|
}
|
|
46
46
|
export async function readDelegationLedger(projectRoot) {
|
|
47
47
|
const { activeRunId } = await readFlowState(projectRoot);
|
|
48
|
-
const filePath = delegationLogPath(projectRoot
|
|
48
|
+
const filePath = delegationLogPath(projectRoot);
|
|
49
49
|
if (!(await exists(filePath))) {
|
|
50
50
|
return { runId: activeRunId, entries: [] };
|
|
51
51
|
}
|
|
@@ -60,8 +60,8 @@ export async function readDelegationLedger(projectRoot) {
|
|
|
60
60
|
}
|
|
61
61
|
export async function appendDelegation(projectRoot, entry) {
|
|
62
62
|
const { activeRunId } = await readFlowState(projectRoot);
|
|
63
|
-
await withDirectoryLock(delegationLockPath(projectRoot
|
|
64
|
-
const filePath = delegationLogPath(projectRoot
|
|
63
|
+
await withDirectoryLock(delegationLockPath(projectRoot), async () => {
|
|
64
|
+
const filePath = delegationLogPath(projectRoot);
|
|
65
65
|
const prior = await readDelegationLedger(projectRoot);
|
|
66
66
|
const ledger = {
|
|
67
67
|
runId: activeRunId,
|