cclaw-cli 0.5.0 → 0.5.2

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.
@@ -173,10 +173,18 @@ When all required gates are satisfied and the artifact is written:
173
173
 
174
174
  1. **Update \`${RUNTIME_ROOT}/state/flow-state.json\`:**
175
175
  ${stateUpdate}
176
+ - For each passed gate, add an entry to \`guardEvidence\`: \`"<gate_id>": "<artifact path or excerpt proving the gate>"\`. Do NOT leave \`guardEvidence\` empty.
176
177
  2. **Sync artifact** to \`${RUNTIME_ROOT}/runs/<activeRunId>/artifacts/${schema.artifactFile}\`
177
178
  ${nextAction}
178
179
 
179
180
  **STOP.** Do not load the next stage skill yourself. The user will run \`/cc-next\` when ready (same session or new session).
181
+
182
+ ## Resume Protocol
183
+
184
+ When resuming a stage in a NEW session (artifact exists but gates are not all passed in flow-state):
185
+ 1. Read the existing artifact and check which gates can be verified from artifact evidence.
186
+ 2. For each unverified gate, ask the user to confirm ONE gate at a time. Do NOT batch multiple gate confirmations in a single message.
187
+ 3. Update \`guardEvidence\` for each confirmed gate before proceeding.
180
188
  `;
181
189
  }
182
190
  function stageTransitionAutoAdvanceBlock(schema) {
@@ -36,38 +36,44 @@ const BRAINSTORM = {
36
36
  "The task is purely retrospective after ship with no new design decisions needed"
37
37
  ],
38
38
  checklist: [
39
- "Explore project context — check files, docs, recent commits, existing behavior.",
39
+ "Explore project context — check files, docs, recent commits, existing behavior. Summarize what you found (even for seemingly simple projects).",
40
40
  "Assess scope — if the request describes multiple independent subsystems, flag for decomposition before detailed questions.",
41
- "Ask clarifying questionsone at a time, understand purpose, constraints, success criteria. For straightforward requests, ask no more than 1-2 clarifying questions before presenting options.",
42
- "Propose 2-3 approaches — with trade-offs and your explicit recommendation with reasoning.",
43
- "Present designin sections scaled to their complexity (few sentences if simple, up to 300 words if nuanced). Get approval after each section.",
41
+ "Restate the problemin a SEPARATE message (no questions in this message), summarize what you understood the user wants and why. **STOP and wait** for user to confirm or correct before asking any clarifying questions.",
42
+ "Ask clarifying questions — one at a time, one per message. You MUST cover these categories before proposing approaches: (a) PURPOSE why this project exists, who it serves; (b) SCOPE — what it must do, what it must NOT do; (c) BOUNDARIES — error handling, edge cases, failure modes; (d) ENVIRONMENT — how it runs, deploys, installs; (e) CONSTRAINTS — performance, compatibility, dependencies. Skip a category only if the user already provided that info. Do NOT rush — 3 generic questions are never enough for a non-trivial project.",
43
+ "Propose 2-3 approaches with real trade-offs (not cosmetic differences) and your explicit recommendation with reasoning. Explain WHY you recommend this option over others.",
44
+ "Present design — in sections. After each section, explicitly state what you are asking the user to approve: 'Do you approve [specific thing]?' Never ask a bare 'одобряете?/approve?' without context.",
44
45
  "Write design doc — save to `.cclaw/artifacts/01-brainstorm.md`.",
45
46
  "Self-review — scan for placeholders, TBDs, contradictions, ambiguity, scope creep. Fix inline.",
46
- "User reviews written artifact — ask user to review before proceeding. **STOP.** Do NOT proceed until user responds.",
47
+ "User reviews written artifact — ask user to review the written artifact (not the chat summary). **STOP.** Do NOT proceed until user responds.",
47
48
  "Stage complete — update `flow-state.json` per the Stage Completion Protocol. Tell user to run `/cc-next` to continue to scope."
48
49
  ],
49
50
  interactionProtocol: [
50
- "Explore context first (files, docs, existing behavior).",
51
- "Ask one clarifying question per message. Do NOT combine questions.",
52
- "For approach selection: use the Decision Protocol present labeled options (A/B/C) with trade-offs and mark one as (recommended). If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
51
+ "Explore context first (files, docs, existing behavior). Share a brief summary of what you found.",
52
+ "Restate the problem in your own words in a SEPARATE message. Do NOT add any questions to this message. Wait for user to confirm or correct.",
53
+ "Ask clarifying questions — one per message. Cover mandatory categories: PURPOSE, SCOPE, BOUNDARIES, ENVIRONMENT, CONSTRAINTS. Do NOT combine questions. Do NOT propose approaches until all categories are addressed.",
54
+ "For approach selection: use the Decision Protocol — present labeled options (A/B/C) with REAL trade-offs (not cosmetic) and mark one as (recommended) with clear reasoning. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
55
+ "Every approval question MUST state what exactly is being approved: 'Do you approve [the architecture / the API shape / the dependency choice]?' Never ask a bare 'approve?' or 'looks good?'.",
53
56
  "Get section-by-section approval before finalizing the design direction.",
54
57
  "Run a self-review pass (ambiguity, placeholders, contradictions) before handoff.",
55
58
  "**STOP.** Wait for explicit user approval after writing the artifact. Do NOT auto-advance to the next stage."
56
59
  ],
57
60
  process: [
58
- "Capture problem statement, users, constraints, and success criteria.",
61
+ "Explore project context — files, docs, behavior, recent changes. Share findings.",
62
+ "Restate the problem — summarize what the user wants and why in a SEPARATE message. Wait for confirmation before questions.",
63
+ "Clarify iteratively — ask questions one at a time covering mandatory categories: PURPOSE, SCOPE, BOUNDARIES, ENVIRONMENT, CONSTRAINTS. Do not skip to approaches early.",
59
64
  "Identify whether request should be decomposed into smaller sub-problems.",
60
- "Offer alternatives and recommendation with rationale.",
61
- "Present design in sections, ask after each section whether it looks right.",
62
- "Write artifact with validated design.",
65
+ "Offer 2-3 alternatives with real trade-offs and recommendation with rationale.",
66
+ "Present design in sections. After each section explicitly name what you ask the user to approve.",
67
+ "Write artifact to `.cclaw/artifacts/01-brainstorm.md`.",
63
68
  "Run self-review: placeholder scan, internal consistency, scope check, ambiguity check.",
64
- "Ask user to review the written spec. Wait for changes or approval.",
69
+ "Ask user to review the written artifact. Wait for changes or approval.",
65
70
  "Handoff to scope stage only after approval is explicit."
66
71
  ],
67
72
  requiredGates: [
68
- { id: "brainstorm_context_explored", description: "Project context and constraints have been reviewed." },
69
- { id: "brainstorm_options_compared", description: "At least two alternatives were compared with trade-offs." },
70
- { id: "brainstorm_design_approved", description: "User approved a concrete design direction." },
73
+ { id: "brainstorm_context_explored", description: "Project context and constraints have been reviewed and summarized." },
74
+ { id: "brainstorm_problem_restated", description: "Problem was restated in agent's words and user confirmed the understanding." },
75
+ { id: "brainstorm_options_compared", description: "At least two alternatives were compared with real trade-offs." },
76
+ { id: "brainstorm_design_approved", description: "User approved a concrete design direction (with explicit statement of what was approved)." },
71
77
  { id: "brainstorm_self_review_passed", description: "Design doc passed placeholder/ambiguity/consistency checks." },
72
78
  { id: "brainstorm_user_reviewed_artifact", description: "User reviewed the written artifact and confirmed readiness." }
73
79
  ],
@@ -104,24 +110,33 @@ const BRAINSTORM = {
104
110
  "Asking many questions in one message",
105
111
  "Jumping directly into implementation",
106
112
  "Combining visual companion offer with a clarifying question",
107
- "Invoking implementation skills before writing plans"
113
+ "Invoking implementation skills before writing plans",
114
+ "Asking bare 'approve?' or 'одобряете?' without stating WHAT is being approved",
115
+ "Presenting a single summary and asking for blanket approval instead of section-by-section review",
116
+ "Rushing through clarification — asking 1-2 generic questions then jumping to design",
117
+ "Batching multiple gate confirmations in one message when resuming a session"
108
118
  ],
109
119
  rationalizations: [
110
120
  { claim: "This is too simple for design.", reality: "Simple tasks fail fast when assumptions are wrong; a short design pass prevents rework." },
111
121
  { claim: "We can figure it out while coding.", reality: "Coding before alignment creates churn and hidden scope growth." },
112
122
  { claim: "There is only one obvious approach.", reality: "Without alternatives, trade-offs stay implicit and risk goes unexamined." },
113
- { claim: "The user already knows what they want.", reality: "Unstated assumptions diverge during implementation; explicit design surfaces them early." }
123
+ { claim: "The user already knows what they want.", reality: "Unstated assumptions diverge during implementation; explicit design surfaces them early." },
124
+ { 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." }
114
125
  ],
115
126
  redFlags: [
116
127
  "No alternatives documented",
117
128
  "No explicit approval checkpoint",
118
129
  "Implementation-related actions before approval",
119
130
  "Self-review skipped or glossed over",
120
- "Artifact has TBD or placeholder sections"
131
+ "Artifact has TBD or placeholder sections",
132
+ "Fewer than 3 clarifying questions asked for any non-trivial project",
133
+ "Approval requested without stating what exactly is being approved"
121
134
  ],
122
135
  policyNeedles: [
136
+ "Restate problem before questions",
123
137
  "One clarifying question per message",
124
- "2-3 approaches with trade-offs",
138
+ "2-3 approaches with real trade-offs",
139
+ "State what is being approved",
125
140
  "Do NOT implement, scaffold, or modify behavior"
126
141
  ],
127
142
  artifactFile: "01-brainstorm.md",
@@ -140,9 +155,11 @@ const BRAINSTORM = {
140
155
  traceabilityRule: "Every approved direction must be traceable forward through scope and design. Downstream stages must reference brainstorm decisions."
141
156
  },
142
157
  artifactValidation: [
143
- { section: "Problem Statement", required: true, validationRule: "Must describe the user problem, not the solution." },
144
- { section: "Alternatives Table", required: true, validationRule: "At least 2 approaches with trade-offs and recommendation." },
145
- { section: "Approved Direction", required: true, validationRule: "Must contain explicit approval marker from user." },
158
+ { section: "Problem Statement", required: true, validationRule: "Must describe the user problem, not the solution. Include WHO and WHY." },
159
+ { section: "Known Context", required: true, validationRule: "Files, patterns, constraints discovered during exploration. Evidence that context was actually explored." },
160
+ { section: "Alternatives Table", required: true, validationRule: "At least 2 approaches with real trade-offs (not cosmetic) and recommendation with reasoning." },
161
+ { section: "Approved Direction", required: true, validationRule: "Must contain explicit approval marker from user. State what was approved." },
162
+ { section: "Assumptions & Risks", required: true, validationRule: "Explicit assumptions made during design. Known risks. If none, state 'None'." },
146
163
  { section: "Open Questions", required: true, validationRule: "If empty, state 'None' explicitly. Do not omit." }
147
164
  ],
148
165
  namedAntiPattern: {
@@ -4,9 +4,16 @@ export const ARTIFACT_TEMPLATES = {
4
4
  "01-brainstorm.md": `# Brainstorm Artifact
5
5
 
6
6
  ## Problem Statement
7
- - User problem:
8
- - Success signal:
9
- - Constraints:
7
+ - **User problem:**
8
+ - **Who benefits:**
9
+ - **Why now:**
10
+ - **Success signal:**
11
+ - **Constraints:**
12
+
13
+ ## Known Context
14
+ - **Explored files/patterns:**
15
+ - **Existing behavior:**
16
+ - **Relevant dependencies:**
10
17
 
11
18
  ## Alternatives Table
12
19
  | Option | Summary | Trade-offs | Recommendation |
@@ -16,9 +23,13 @@ export const ARTIFACT_TEMPLATES = {
16
23
  | C | | | |
17
24
 
18
25
  ## Approved Direction
19
- - Selected option:
20
- - Why selected:
21
- - Approval marker:
26
+ - **Selected option:**
27
+ - **Why selected:**
28
+ - **What was approved:** (state the specific decision)
29
+ - **Approval marker:**
30
+
31
+ ## Assumptions & Risks
32
+ -
22
33
 
23
34
  ## Open Questions
24
35
  - None
package/dist/install.js CHANGED
@@ -179,10 +179,6 @@ async function writeCommandContracts(projectRoot) {
179
179
  async function writeArtifactTemplates(projectRoot) {
180
180
  for (const [fileName, content] of Object.entries(ARTIFACT_TEMPLATES)) {
181
181
  await writeFileSafe(runtimePath(projectRoot, "templates", fileName), content);
182
- const artifactPath = runtimePath(projectRoot, "artifacts", fileName);
183
- if (!(await exists(artifactPath))) {
184
- await writeFileSafe(artifactPath, content);
185
- }
186
182
  }
187
183
  }
188
184
  async function writeSkills(projectRoot) {
package/dist/runs.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { COMMAND_FILE_ORDER, RUNTIME_ROOT } from "./constants.js";
4
- import { ARTIFACT_TEMPLATES } from "./content/templates.js";
5
4
  import { createInitialFlowState } from "./flow-state.js";
6
5
  import { ensureDir, exists, withDirectoryLock, writeFileSafe } from "./fs-utils.js";
7
6
  const FLOW_STATE_REL_PATH = `${RUNTIME_ROOT}/state/flow-state.json`;
@@ -287,12 +286,6 @@ async function persistRunStateSnapshot(projectRoot, runId, state) {
287
286
  stateSnapshot: snapshotState(safeState)
288
287
  });
289
288
  }
290
- async function seedArtifactsFromTemplates(targetDir) {
291
- await ensureDir(targetDir);
292
- for (const [fileName, content] of Object.entries(ARTIFACT_TEMPLATES)) {
293
- await writeFileSafe(path.join(targetDir, fileName), content);
294
- }
295
- }
296
289
  async function syncActiveArtifactsToRun(projectRoot, runId) {
297
290
  const fromDir = activeArtifactsPath(projectRoot);
298
291
  const toDir = runArtifactsPath(projectRoot, runId);
@@ -317,13 +310,10 @@ async function createRun(projectRoot, options) {
317
310
  await ensureDir(runRoot(projectRoot, runId));
318
311
  await ensureRunMetadata(projectRoot, meta);
319
312
  const runArtifactsDir = runArtifactsPath(projectRoot, runId);
313
+ await ensureDir(runArtifactsDir);
320
314
  if (options?.seedFromActiveArtifacts && (await exists(activeArtifactsPath(projectRoot)))) {
321
- await ensureDir(runArtifactsDir);
322
315
  await copyImmediateFiles(activeArtifactsPath(projectRoot), runArtifactsDir);
323
316
  }
324
- else {
325
- await seedArtifactsFromTemplates(runArtifactsDir);
326
- }
327
317
  return meta;
328
318
  }
329
319
  async function ensureRunHandoff(projectRoot, runId) {
@@ -350,9 +340,7 @@ export async function ensureRunSystem(projectRoot) {
350
340
  await writeFlowState(projectRoot, state);
351
341
  }
352
342
  const runArtifactsDir = runArtifactsPath(projectRoot, activeRunId);
353
- if ((await listImmediateFiles(runArtifactsDir)).length === 0) {
354
- await seedArtifactsFromTemplates(runArtifactsDir);
355
- }
343
+ await ensureDir(runArtifactsDir);
356
344
  if ((await listImmediateFiles(activeArtifactsPath(projectRoot))).length === 0) {
357
345
  await loadRunArtifactsToActive(projectRoot, activeRunId);
358
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {