cclaw-cli 3.0.0 → 4.0.0

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.
@@ -18,18 +18,38 @@ export function adaptiveElicitationSkillMarkdown() {
18
18
  const budgetTable = renderQuestionBudgetHintTable();
19
19
  return `---
20
20
  name: adaptive-elicitation
21
- description: "Harness-native one-question-at-a-time dialogue for brainstorm/scope/design with stop signals, smart-skip, and append-only Q&A logging."
21
+ description: "Harness-native one-question-at-a-time dialogue for brainstorm/scope/design with stop signals, smart-skip, and append-only Q&A logging. Walking forcing questions in order is mandatory; the linter blocks stage-complete when Q&A Log is below floor."
22
22
  ---
23
23
 
24
24
  # Adaptive Elicitation
25
25
 
26
26
  Pinned anchor: "Don't tell it what to do, give it success criteria and watch it go."
27
27
 
28
- ## HARD-GATE
28
+ ## Anti-pattern (BAD examples — never do these)
29
+
30
+ These behaviors are the exact reason this skill exists. The linter will block your stage-complete if you do them.
31
+
32
+ - **Bad**: User asks for a "simple web app" -> agent asks 1 question about stack -> 1 question about auth -> drafts the brainstorm artifact and asks for approval.
33
+ - **Good**: User asks for a "simple web app" -> agent asks Q1 (what pain) -> Q2 (direct path) -> Q3 (do-nothing cost) -> Q4 (first operator/user) -> Q5 (no-go boundaries) -> self-eval: clear -> drafts the brainstorm artifact.
34
+
35
+ - **Bad**: Agent immediately dispatches a subagent (\`product-discovery\`, \`critic\`, \`planner\`) at the start of brainstorm/scope/design to "gather context" before any user dialogue.
36
+ - **Good**: Agent walks the Q&A loop with the user first; subagent dispatch happens only after the user approves the elicitation outcome.
37
+
38
+ - **Bad**: Agent batches 3-5 grill questions into one large message and asks the user to answer them all at once.
39
+ - **Good**: Agent asks one grill question, waits, logs the answer, asks the next.
40
+
41
+ - **Bad**: Agent skips forcing questions because it "already has a good idea" of the answer.
42
+ - **Good**: Agent asks the forcing question; if the user's reply confirms the assumption, log it as \`asked (confirmed assumption)\` and move on. Do not silently skip.
43
+
44
+ ## HARD-GATE (machine-enforced)
45
+
29
46
  - User does not run cclaw manually. Do not tell the user to run CLI commands for answers.
30
47
  - Ask exactly one question per turn and wait for the answer before asking the next one.
31
48
  - Use harness-native question tools first; prose fallback is allowed only when the tool is unavailable.
32
49
  - Keep a running Q&A trace in the active artifact under \`## Q&A Log\` in \`${RUNTIME_ROOT}/artifacts/\` as append-only rows.
50
+ - **Hard floor**: do NOT advance the stage (do NOT call \`stage-complete.mjs\`) until \`## Q&A Log\` contains at least \`min(track, stage)\` substantive entries OR an explicit user stop-signal is recorded as a row. The linter rule \`qa_log_below_min\` enforces this; \`stage-complete\` will fail otherwise.
51
+ - **NEVER run shell hash commands** (\`shasum\`, \`sha256sum\`, \`md5sum\`, \`Get-FileHash\`, \`certutil\`, etc.) to compute artifact hashes. If a linter ever asks you for a hash, that is a linter bug — report failure and stop, do not auto-fix in bash.
52
+ - **NEVER paste cclaw command lines into chat** (e.g. \`node .cclaw/hooks/stage-complete.mjs ... --evidence-json '{...}'\`). Run them via the tool layer; report only the resulting summary. The user does not run cclaw manually and seeing the command line is noise.
33
53
 
34
54
  ## Harness Question Surface
35
55
 
@@ -43,67 +63,81 @@ If unavailable, ask one concise prose question and explicitly wait for chat answ
43
63
 
44
64
  ## Core Protocol
45
65
 
46
- 1. Ask one decision-changing question.
66
+ 1. Ask one decision-changing question via the harness-native question tool.
47
67
  2. Wait for the answer.
48
68
  3. Append one row to \`## Q&A Log\`: \`Turn | Question | User answer (1-line) | Decision impact\`.
49
69
  4. Self-evaluate:
50
70
  - What did I learn?
51
71
  - Is context enough to draft now? (yes/no + reason)
52
- - If no, what is the next most decision-changing question?
53
- 5. Repeat until context is clear OR user asks to proceed.
72
+ - Have I covered all stage forcing questions in order? (yes/no + which remain)
73
+ - If forcing questions remain or context is incomplete, what is the next decision-changing question?
74
+ 5. Repeat until **all forcing questions are answered/skipped/waived AND self-evaluation says context is sufficient**, OR user records an explicit stop-signal row.
54
75
 
55
76
  ## Question Shape Rules
56
77
 
57
78
  - Prefer single-select multiple choice when one direction/priority/next step must be chosen.
58
79
  - Use multi-select only for compatible sets (goals, constraints, non-goals).
59
- - Smart-skip questions already answered earlier (directly or implicitly) and log "skipped (already covered)" when relevant.
80
+ - Smart-skip: if a question is already answered earlier (directly or implicitly), log \`skipped (already covered: turn N)\` instead of skipping silently. The smart-skip row counts as a substantive Q&A Log entry for floor purposes.
60
81
 
61
82
  ## Stop Signals (Natural Language)
62
83
 
63
84
  Treat these as stop-and-draft signals:
64
- - RU: "достаточно", "хватит", "давай драфт"
65
- - EN: "enough", "skip", "just draft it", "stop asking", "move on"
85
+ - RU: "достаточно", "хватит", "давай драфт", "хватит вопросов"
86
+ - EN: "enough", "skip", "just draft it", "stop asking", "move on", "no more questions"
66
87
  - UA: "досить", "вистачить", "давай драфт", "рухаємось далі"
67
88
 
68
89
  When detected:
90
+ - Append a Q&A Log row exactly like: \`Turn N | (stop-signal) | <user quote> | stop-and-draft\` — this row satisfies the linter floor escape hatch.
69
91
  - Do not ask another question in this stage loop.
70
92
  - Move to drafting with available context.
71
- - For internal agent calls only, pass \`--skip-questions\` on the next advance helper call.
93
+ - For the next internal agent-only call to advance-stage, pass \`--skip-questions\`. **The user never sees or types this flag.**
72
94
 
73
95
  ## Conditional Grilling (Only On Risk Triggers)
74
96
 
75
- Ask an extra 3-5 sharp questions only when one of these triggers appears:
97
+ When one of these triggers appears, continue the elicitation loop with sharper questions **one at a time** (do NOT batch them):
76
98
  - Irreversibility (data deletion, schema migration, breaking API/contract)
77
99
  - Security/auth boundary changes
78
100
  - Domain-model ambiguity with multiple plausible invariants
79
101
 
102
+ Each grill question follows the same Core Protocol: ask one, wait, log, self-eval, ask next.
103
+
80
104
  Do not ask extra questions "for theater" on simple low-risk work.
81
105
 
82
- ## Question Budget Hint (Soft Guidance)
106
+ ## Question Budget Hint (linter-enforced floor)
83
107
 
84
- Use as orientation, never as a hard stop. Source of truth is \`questionBudgetHint(track, stage)\`:
108
+ Source of truth: \`questionBudgetHint(track, stage)\`. The \`Min\` column is enforced by \`qa_log_below_min\` linter rule — \`stage-complete\` fails when below.
85
109
 
86
110
  ${budgetTable}
87
111
 
88
112
  Track mapping note: \`quick\` ~= lightweight, \`medium\` ~= standard, \`standard\` ~= deep.
89
- Stop based on clarity/user signal, not raw count.
90
113
 
91
- ## Stage Forcing Questions
114
+ How to use the columns:
115
+ - \`Min\` — hard floor. Below this, \`stage-complete\` is blocked unless escape hatch is recorded.
116
+ - \`Recommended\` — target for normal flows.
117
+ - \`Hard cap warning\` — point at which to stop or compress remaining forcing questions into one final batched ask. Not skip.
118
+
119
+ ## Stage Forcing Questions (walk in order, one per turn)
92
120
 
93
- Always keep at least one unresolved forcing question in play until answered or explicitly waived:
121
+ **Walk the forcing questions list one-by-one in order, asking each as a separate turn.** Do NOT batch. Do NOT pick favorites — go in order. For each question record one of:
122
+ - \`asked\` — question was asked and answered.
123
+ - \`asked (confirmed assumption)\` — question was asked, user confirmed your prior reading.
124
+ - \`skipped (already covered: turn N)\` — answered implicitly by an earlier reply; cite the turn.
125
+ - \`waived (user override)\` — user explicitly waived this question.
94
126
 
95
- - Brainstorm:
127
+ Stage forcing question lists:
128
+
129
+ - **Brainstorm**:
96
130
  - What pain are we solving?
97
131
  - What is the most direct path?
98
132
  - What happens if we do nothing?
99
133
  - Who is the operator/user impacted first?
100
134
  - What are non-negotiable no-go boundaries?
101
- - Scope:
135
+ - **Scope**:
102
136
  - What is definitely in and definitely out?
103
137
  - Which decisions are already locked upstream?
104
138
  - What is the rollback path if this fails?
105
139
  - What are the top failure modes we must design for?
106
- - Design:
140
+ - **Design**:
107
141
  - What is the data flow end-to-end?
108
142
  - Where are the seams/interfaces and ownership boundaries?
109
143
  - Which invariants must always hold?
@@ -118,6 +152,10 @@ For irreversible moves (deletion, schema migration, breaking API):
118
152
 
119
153
  ## Completion Rule
120
154
 
121
- "Continue until clear OR user wants to proceed."
122
- Never force a fixed N-question script.`;
155
+ Continue asking forcing questions in order until one of:
156
+ - (a) all forcing questions for the stage are answered/skipped/waived AND self-evaluation says context is sufficient, OR
157
+ - (b) user records an explicit stop-signal row in \`## Q&A Log\`, OR
158
+ - (c) the \`hard cap warning\` count is reached and you compressed the remaining forcing questions into one final batched ask (not skip).
159
+
160
+ Do NOT exit the loop after the first 1-2 questions just because you can draft something. The point of the loop is to surface the user's actual constraints, not to confirm your initial reading.`;
123
161
  }
@@ -175,18 +175,23 @@ function autoSubagentDispatchBlock(stage, track) {
175
175
  const userGate = rule.requiresUserGate ? "required" : "not required";
176
176
  const dispatchClass = rule.dispatchClass ?? "stage-specialist";
177
177
  const returnSchema = rule.returnSchema ?? "agent-default";
178
- return `| ${rule.agent} | ${rule.mode} | ${dispatchClass} | ${returnSchema} | ${userGate} | ${rule.when} | ${rule.purpose} |`;
178
+ const runPhase = rule.runPhase ?? "any";
179
+ return `| ${rule.agent} | ${rule.mode} | ${runPhase} | ${dispatchClass} | ${returnSchema} | ${userGate} | ${rule.when} | ${rule.purpose} |`;
179
180
  })
180
181
  .join("\n");
181
182
  const mandatory = schema.mandatoryDelegations;
182
183
  const mandatoryList = mandatory.length > 0 ? mandatory.map((a) => `\`${a}\``).join(", ") : "none";
183
184
  const delegationLogRel = `${RUNTIME_ROOT}/state/delegation-log.json`;
184
185
  const delegationEventsRel = `${RUNTIME_ROOT}/state/delegation-events.jsonl`;
186
+ const hasPostElicitation = rules.some((rule) => rule.runPhase === "post-elicitation");
187
+ const runPhaseLegend = hasPostElicitation
188
+ ? `\nRun Phase legend: \`post-elicitation\` = run only AFTER the adaptive elicitation Q&A loop converges (forcing questions answered/skipped/waived OR user stop-signal recorded). \`pre-elicitation\` = run before any user dialogue (rare). \`any\` = no ordering constraint.`
189
+ : "";
185
190
  return `## Automatic Subagent Dispatch
186
- | Agent | Mode | Class | Return Schema | User Gate | Trigger | Purpose |
187
- |---|---|---|---|---|---|---|
191
+ | Agent | Mode | Run Phase | Class | Return Schema | User Gate | Trigger | Purpose |
192
+ |---|---|---|---|---|---|---|---|
188
193
  ${rows}
189
- Mandatory: ${mandatoryList}. Record lifecycle rows in \`${delegationLogRel}\` and append-only \`${delegationEventsRel}\` before completion.
194
+ Mandatory: ${mandatoryList}. Record lifecycle rows in \`${delegationLogRel}\` and append-only \`${delegationEventsRel}\` before completion.${runPhaseLegend}
190
195
  ### 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>\`.
191
196
 
192
197
  ${perHarnessLifecycleRecipeBlock()}`;
@@ -392,6 +397,14 @@ function delegationAndCompletionBlock(schema, track) {
392
397
  ${normalizedDispatch}
393
398
 
394
399
  ${completionBlock}
400
+
401
+ ### Stage Closure (harness-only UX)
402
+
403
+ - **NEVER paste the \`stage-complete.mjs\` command line into chat.** The user does not run cclaw manually; seeing \`node .cclaw/hooks/stage-complete.mjs ... --evidence-json '{...}' --waive-delegation=...\` is noise. Run the helper via the tool layer; report only the resulting summary.
404
+ - **NEVER paste the \`--evidence-json\` payload into chat.** It is structured data for the helper, not for the user. The same evidence already lives in the artifact section.
405
+ - On failure, report a compact human-readable summary based on the helper's JSON \`findings\` array — list failing section names only (one line each), include the full helper JSON in a single fenced \`json\` block. Do not echo the invoking command.
406
+ - **NEVER run shell hash commands** (\`shasum\`, \`sha256sum\`, \`md5sum\`, \`Get-FileHash\`, \`certutil\`, etc.) for hash compute. If the linter ever asks for a hash, that is a linter bug — report failure and stop, do not auto-fix in bash.
407
+ - The helper defaults to quiet success (\`CCLAW_STAGE_COMPLETE_QUIET=1\`); rely on the resulting JSON, not stdout chatter.
395
408
  `;
396
409
  }
397
410
  function quickStartBlock(stage, track) {
@@ -638,10 +651,10 @@ CLI commands, using existing \`cclaw run resume\` and \`internal verify-current-
638
651
 
639
652
  1. **Wave Start**: author wave plan as \`.cclaw/wave-plans/<wave-n>.md\` referencing previous wave's ship artifact.
640
653
  2. **Carry-forward Audit**: at brainstorm of the next wave, re-read previous wave ship artifact and explicitly record in the existing \`## Wave Carry-forward\` section:
641
- - Carrying forward: <scope LD# hash references still valid>
654
+ - Carrying forward: <scope D-XX decision references still valid>
642
655
  - Drift detected: <decisions no longer valid + reason>
643
656
  - Re-scope needed: <yes/no>
644
- - Never create a second \`## Locked Decisions\` heading in brainstorm; reference prior LD# hashes inline.
657
+ - Never create a second \`## Locked Decisions\` heading in brainstorm; reference prior D-XX IDs inline.
645
658
  3. **Resume Path**: if a wave was interrupted mid-stage, \`cclaw run resume\` restores state. Run \`internal verify-current-state\` before continuing.
646
659
  4. **Wave End**: at ship, architect cross-stage verification runs from dispatch matrix. If \`DRIFT_DETECTED\`, fix before ship.
647
660
  5. **Next Wave Trigger**: launch new \`/cc <topic>\` for next wave and reference previous wave ship artifact in upstream handoff.
@@ -445,14 +445,16 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
445
445
  agent: "product-discovery",
446
446
  mode: "mandatory",
447
447
  requiredAtTier: "standard",
448
- when: "Always for standard/deep brainstorm to validate value, persona/JTBD, success metric, and why-now framing.",
448
+ runPhase: "post-elicitation",
449
+ when: "Always for standard/deep brainstorm to validate value, persona/JTBD, success metric, and why-now framing. Runs only after the adaptive elicitation Q&A loop converges.",
449
450
  purpose: "Run product-discovery mode to pressure-test problem/value fit and produce product evidence for the Problem Decision Record.",
450
451
  requiresUserGate: false
451
452
  },
452
453
  {
453
454
  agent: "divergent-thinker",
454
455
  mode: "proactive",
455
- when: "When brainstorm has >1 candidate direction or user signals openness to alternatives.",
456
+ runPhase: "post-elicitation",
457
+ when: "When brainstorm has >1 candidate direction or user signals openness to alternatives. Runs only after the adaptive elicitation Q&A loop converges.",
456
458
  purpose: "Expand option-space with alternative framings and approaches before planner/critic convergence.",
457
459
  requiresUserGate: false
458
460
  },
@@ -460,7 +462,8 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
460
462
  agent: "critic",
461
463
  mode: "mandatory",
462
464
  requiredAtTier: "standard",
463
- when: "Always for standard/deep brainstorm to challenge the premise, do-nothing path, and higher-upside alternatives.",
465
+ runPhase: "post-elicitation",
466
+ when: "Always for standard/deep brainstorm to challenge the premise, do-nothing path, and higher-upside alternatives. Runs only after the adaptive elicitation Q&A loop converges.",
464
467
  purpose: "Attack assumptions and surface non-goals before direction approval, with pre-commitment predictions validated against evidence.",
465
468
  requiresUserGate: false,
466
469
  skill: "critic-multi-perspective"
@@ -468,7 +471,8 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
468
471
  {
469
472
  agent: "researcher",
470
473
  mode: "proactive",
471
- when: "When repository, market, docs, or prior-art context changes the approach set.",
474
+ runPhase: "post-elicitation",
475
+ when: "When repository, market, docs, or prior-art context changes the approach set. Runs only after the adaptive elicitation Q&A loop converges.",
472
476
  purpose: "Provide search-before-read summaries and context-readiness evidence before large reads or decisions.",
473
477
  requiresUserGate: false
474
478
  }
@@ -478,14 +482,16 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
478
482
  agent: "planner",
479
483
  mode: "mandatory",
480
484
  requiredAtTier: "standard",
481
- when: "Always during scope shaping.",
485
+ runPhase: "post-elicitation",
486
+ when: "Always during scope shaping. Runs only after the adaptive elicitation Q&A loop converges and the user has approved the scope contract draft.",
482
487
  purpose: "Challenge premise, map alternatives, and produce explicit in/out contract.",
483
488
  requiresUserGate: false
484
489
  },
485
490
  {
486
491
  agent: "divergent-thinker",
487
492
  mode: "proactive",
488
- when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has fewer than 3 alternatives considered.",
493
+ runPhase: "post-elicitation",
494
+ when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has fewer than 3 alternatives considered. Runs only after the adaptive elicitation Q&A loop converges.",
489
495
  purpose: "Generate additional framings and approach variants before scope convergence hardens.",
490
496
  requiresUserGate: false
491
497
  },
@@ -493,7 +499,8 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
493
499
  agent: "critic",
494
500
  mode: "mandatory",
495
501
  requiredAtTier: "standard",
496
- when: "Always during scope shaping for standard/deep work.",
502
+ runPhase: "post-elicitation",
503
+ when: "Always during scope shaping for standard/deep work. Runs only after the adaptive elicitation Q&A loop converges.",
497
504
  purpose: "Test whether the selected scope mode is too timid, too broad, or hiding a smaller useful slice, using pre-commitment predictions and validation.",
498
505
  requiresUserGate: false,
499
506
  skill: "critic-multi-perspective"
@@ -501,14 +508,16 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
501
508
  {
502
509
  agent: "researcher",
503
510
  mode: "proactive",
504
- when: "When churn, prior attempts, reference patterns, or external constraints may change scope boundaries.",
511
+ runPhase: "post-elicitation",
512
+ when: "When churn, prior attempts, reference patterns, or external constraints may change scope boundaries. Runs only after the adaptive elicitation Q&A loop converges.",
505
513
  purpose: "Summarize search/context findings before the scope contract locks accepted/rejected/deferred ideas.",
506
514
  requiresUserGate: false
507
515
  },
508
516
  {
509
517
  agent: "product-discovery",
510
518
  mode: "proactive",
511
- when: "When scope choices change user value, success metrics, or product positioning (Mode: discovery).",
519
+ runPhase: "post-elicitation",
520
+ when: "When scope choices change user value, success metrics, or product positioning (Mode: discovery). Runs only after the adaptive elicitation Q&A loop converges.",
512
521
  purpose: "Keep accepted/deferred reference ideas tied to user value and measurable success under product-discovery mode.",
513
522
  requiresUserGate: false
514
523
  },
@@ -516,14 +525,16 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
516
525
  agent: "product-discovery",
517
526
  mode: "proactive",
518
527
  requiredAtTier: "standard",
519
- when: "When scope mode resolves to SCOPE EXPANSION or SELECTIVE EXPANSION (Mode: strategist).",
528
+ runPhase: "post-elicitation",
529
+ when: "When scope mode resolves to SCOPE EXPANSION or SELECTIVE EXPANSION (Mode: strategist). Runs only after the adaptive elicitation Q&A loop converges.",
520
530
  purpose: "Drive 10x vision and concrete expansion proposals before locking the scope contract via product-discovery strategist mode.",
521
531
  requiresUserGate: false
522
532
  },
523
533
  {
524
534
  agent: "scope-guardian-reviewer",
525
535
  mode: "proactive",
526
- when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has many accepted ideas.",
536
+ runPhase: "post-elicitation",
537
+ when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has many accepted ideas. Runs only after the adaptive elicitation Q&A loop converges.",
527
538
  purpose: "Challenge complexity growth and enforce minimum-change scope discipline before scope lock.",
528
539
  requiresUserGate: false,
529
540
  skill: "document-scope-guard"
@@ -534,7 +545,8 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
534
545
  agent: "architect",
535
546
  mode: "mandatory",
536
547
  requiredAtTier: "standard",
537
- when: "Always during design lock.",
548
+ runPhase: "post-elicitation",
549
+ when: "Always during design lock. Runs only after the adaptive elicitation Q&A loop converges.",
538
550
  purpose: "Stress architecture boundaries, dependency graph, critical path, and spec handoff.",
539
551
  requiresUserGate: false
540
552
  },
@@ -542,14 +554,16 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
542
554
  agent: "test-author",
543
555
  mode: "mandatory",
544
556
  requiredAtTier: "standard",
545
- when: "Always during design lock.",
557
+ runPhase: "post-elicitation",
558
+ when: "Always during design lock. Runs only after the adaptive elicitation Q&A loop converges.",
546
559
  purpose: "Check test diagram mapping, RED expressibility, assertion quality, and verification routes before implementation.",
547
560
  requiresUserGate: false
548
561
  },
549
562
  {
550
563
  agent: "critic",
551
564
  mode: "proactive",
552
- when: "When architecture alternatives, coupling, cost, or rollback risk remain debatable, or when security/auth/authz trust boundaries are involved.",
565
+ runPhase: "post-elicitation",
566
+ when: "When architecture alternatives, coupling, cost, or rollback risk remain debatable, or when security/auth/authz trust boundaries are involved. Runs only after the adaptive elicitation Q&A loop converges.",
553
567
  purpose: "Produce a shadow alternative, switch trigger, and cheaper-path challenge for the engineering lock with pre-commitment predictions and validation.",
554
568
  requiresUserGate: false,
555
569
  skill: "critic-multi-perspective"
@@ -557,21 +571,24 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
557
571
  {
558
572
  agent: "researcher",
559
573
  mode: "proactive",
560
- when: "When framework/library docs, repo graph context, or reference contracts may change the design.",
574
+ runPhase: "post-elicitation",
575
+ when: "When framework/library docs, repo graph context, or reference contracts may change the design. Runs only after the adaptive elicitation Q&A loop converges.",
561
576
  purpose: "Run search-before-read context synthesis before architecture locks.",
562
577
  requiresUserGate: false
563
578
  },
564
579
  {
565
580
  agent: "security-reviewer",
566
581
  mode: "proactive",
567
- when: "When trust boundaries, auth, secrets, sensitive data, or external inputs are involved.",
582
+ runPhase: "post-elicitation",
583
+ when: "When trust boundaries, auth, secrets, sensitive data, or external inputs are involved. Runs only after the adaptive elicitation Q&A loop converges.",
568
584
  purpose: "Catch design-level security risks before implementation.",
569
585
  requiresUserGate: false
570
586
  },
571
587
  {
572
588
  agent: "coherence-reviewer",
573
589
  mode: "proactive",
574
- when: "When design touches multiple subsystems or includes multiple alternatives sections.",
590
+ runPhase: "post-elicitation",
591
+ when: "When design touches multiple subsystems or includes multiple alternatives sections. Runs only after the adaptive elicitation Q&A loop converges.",
575
592
  purpose: "Detect internal contradictions, terminology drift, and broken cross-section references in design docs.",
576
593
  requiresUserGate: false,
577
594
  skill: "document-coherence-pass"
@@ -579,7 +596,8 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
579
596
  {
580
597
  agent: "feasibility-reviewer",
581
598
  mode: "proactive",
582
- when: "When design assumes runtime conditions, scaling behavior, or external service availability.",
599
+ runPhase: "post-elicitation",
600
+ when: "When design assumes runtime conditions, scaling behavior, or external service availability. Runs only after the adaptive elicitation Q&A loop converges.",
583
601
  purpose: "Validate that design assumptions remain feasible in real runtime and rollout constraints.",
584
602
  requiresUserGate: false,
585
603
  skill: "document-feasibility-pass"
@@ -36,8 +36,8 @@ export const BRAINSTORM = {
36
36
  },
37
37
  executionModel: {
38
38
  checklist: [
39
- "**Explore project context** inspect existing files/docs/recent activity before asking what to build; capture matching files/patterns/seeds in `Context > Discovered context` so downstream stages don't redo discovery.",
40
- "**Adaptive elicitation loop (shared skill)** — load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question at a time via harness-native question tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until context is clear or user signals to proceed.",
39
+ "**ADAPTIVE ELICITATION COMES FIRST (no exceptions, no subagent dispatch before).** Load `.cclaw/skills/adaptive-elicitation/SKILL.md`. Walk the brainstorm forcing questions one-at-a-time via the harness-native question tool, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`) after each user answer. Continue until all forcing questions are answered/skipped/waived OR user records an explicit stop-signal row. Only then proceed to delegations, drafts, or analysis. The linter `qa_log_below_min` rule will block `stage-complete` if Q&A Log is below floor.",
40
+ "**Explore project context** — after the elicitation loop converges, inspect existing files/docs/recent activity to refine the Discovered context section; capture matching files/patterns/seeds in `Context > Discovered context` so downstream stages don't redo discovery.",
41
41
  "**Brainstorm forcing questions (must be covered or explicitly waived)** — what pain are we solving, what is the direct path, what happens if we do nothing, who is the first operator/user affected, and what no-go boundaries are non-negotiable.",
42
42
  "**Classify stage depth** — choose `lite` for clear low-risk tasks, `standard` for normal engineering/product changes, or `deep` for ambiguity, architecture, external dependency, security/data risk, or explicit think-bigger requests.",
43
43
  "**Write the Problem Decision Record** — pick a free-form `Frame type` label that names how this work is framed (examples: product, technical-maintenance, research-spike, ops-incident, infrastructure), then fill the universal Framing fields: affected user/role/operator, current state/failure mode/opportunity, desired observable outcome, evidence/signal, why now, do-nothing consequence, and non-goals.",
@@ -52,7 +52,7 @@ export const BRAINSTORM = {
52
52
  "**Collect reaction before recommending** — ask which option feels closest and what concern remains, then recommend based on that reaction.",
53
53
  "**Write the `Not Doing` list** — name 3-5 things this brainstorm explicitly is not committing to (vs. deferred). This protects scope from silent enlargement and the next stage from rework.",
54
54
  "**Run early Ralph loop discipline** — after each producer iteration, append a `Critic Pass` JSONL row to `.cclaw/state/early-loop-log.jsonl`, refresh `.cclaw/state/early-loop.json`, and iterate until open concerns clear or convergence guard escalates.",
55
- "**Embedded Grill (post-pick)** — after `Selected Direction` is named, run 3-5 sharp checks on hidden constraints, reversibility/rollback, scope boundaries, existing-pattern conformance, and domain-language fit; record each question with recommended answer and disposition (accept/refine/reject).",
55
+ "**Embedded Grill (post-pick, one-at-a-time)** — after `Selected Direction` is named, if grilling triggers fire (irreversibility, security/auth boundary, domain-model ambiguity per `adaptive-elicitation:Conditional Grilling`), continue the elicitation loop with sharper questions **one at a time**, appended to `## Q&A Log` and reflected as rows in `## Embedded Grill`. Do NOT batch the 3-5 grill checks each one follows the Core Protocol (ask, wait, log, self-eval, ask next).",
56
56
  "**Self-review before user approval** — re-read the artifact and patch contradictions, weak trade-offs, placeholders, ambiguity, and weak handoff language. Record the result in `Self-Review Notes` using the calibrated review format: `- Status: Approved` (or `Issues Found`), `- Patches applied:` with inline note or sub-bullets, `- Remaining concerns:` with inline note or sub-bullets. Use `Patches applied: None` and `Remaining concerns: None` when there is nothing to record.",
57
57
  "**Request explicit approval to close the stage** — state exactly what direction is being approved after the adaptive elicitation loop converges; do not advance without approval and artifact review.",
58
58
  "**Handoff packet** — only after approval, produce a scope handoff packet with selected direction, why rejected options were rejected, explicit non-goals, unresolved questions, risk hints, and explicit drift from the initial ask so scope starts from locked upstream decisions instead of rediscovering intent."
@@ -40,7 +40,7 @@ export const DESIGN = {
40
40
  },
41
41
  executionModel: {
42
42
  checklist: [
43
- "**Adaptive elicitation loop (shared skill)** load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question per turn via harness-native tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until architecture context is clear or user signals to proceed.",
43
+ "**ADAPTIVE ELICITATION COMES FIRST (no exceptions, no subagent dispatch before).** Load `.cclaw/skills/adaptive-elicitation/SKILL.md`. Walk the design forcing questions one-at-a-time via the harness-native question tool, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`) after each user answer. Continue until all forcing questions are answered/skipped/waived OR user records an explicit stop-signal row. Only then proceed to research, investigator pass, architecture lock, or any delegations. The linter `qa_log_below_min` rule will block `stage-complete` if Q&A Log is below floor.",
44
44
  "**Design forcing questions (must be covered or explicitly waived)** — what is the end-to-end data flow, where are seams/ownership boundaries, which invariants must hold, and what will explicitly NOT be refactored now.",
45
45
  "Compact design lock — design does not decide what to build; it decides how the approved scope works. For simple slices, produce a tight lock: upstream handoff, existing fit, architecture boundary, one labeled diagram, data/state flow, critical path, failure/rescue, trust boundaries, test/perf expectations, rollout/rollback, rejected alternative, and spec handoff.",
46
46
  "Trivial-Change Escape Hatch — for <=3 files, no new interfaces, and no cross-module data flow, produce a mini-design (rationale, changed files, one risk) and proceed to spec.",
@@ -68,7 +68,7 @@ export const DESIGN = {
68
68
  "Classify ambiguity before acting. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope, architecture, security, data loss, public API, migration, auth/pricing, or required user approval. Design hypotheses must name validation path, rollback trigger, and owner before they can be carried forward.",
69
69
  "Before final approval, run the critic pass, reconcile material findings, and bound retries with the review-loop policy.",
70
70
  "For baseline approval, present the full design plus exact spec handoff and **STOP** until explicit approval.",
71
- "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` must be completed or explicitly waived, then close via `node .cclaw/hooks/stage-complete.mjs design`."
71
+ "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` runs **AFTER user approval of the design lock**, not before Q&A. Sequence is: Q&A loop -> draft design lock -> user approval -> `planner` delegation -> `stage-complete`. Legal fulfillment modes for `planner`: (a) **harness-native Task tool** — run the delegation, then record via `node .cclaw/hooks/delegation-record.mjs --stage=design --agent=planner --mode=mandatory --status=completed --span-id=<uuid> --dispatch-surface=cursor-task --agent-definition-path=<agent-md-path> --evidence-ref=<artifact#section>`; (b) **role-switch** — write planner output into the design artifact, then record with `--dispatch-surface=role-switch`; (c) **cclaw subagent helper** with `--dispatch-surface=isolated`. Run `node .cclaw/hooks/stage-complete.mjs design` from the tool layer (do not paste the command into chat); report only the resulting summary."
72
72
  ],
73
73
  process: [
74
74
  "Read upstream artifacts and current design docs.",
@@ -46,7 +46,7 @@ export const PLAN = {
46
46
  "Slice into vertical tasks — each task targets 2-5 minutes, produces one testable outcome, and touches one coherent area.",
47
47
  "Task Contract — every task has one coherent outcome, AC mapping, exact verification command/manual step, and expected evidence snippet or pass condition. Avoid vague `run tests` wording.",
48
48
  "Annotate slice-review metadata — task rows may carry `touchCount` (rough number of files expected to change), `touchPaths` (glob hints, e.g. `migrations/**`, `src/auth/**`), and optional `highRisk: true` to force a review pass. These fields feed the TDD stage's Per-Slice Review point.",
49
- "Map scope Locked Decisions — every LD#hash anchor from scope is referenced by at least one plan task (or explicitly marked deferred with reason).",
49
+ "Map scope Locked Decisions — every D-XX ID from scope is referenced by at least one plan task (or explicitly marked deferred with reason).",
50
50
  "Run anti-placeholder + anti-scope-reduction scans — block `TODO/TBD/...` and phrasing like `v1`, `for now`, `later` for locked boundaries.",
51
51
  "Define validation points — mark where progress must be checked before continuing, with concrete command and expected evidence.",
52
52
  "Define execution posture — record whether execution should be sequential, dependency-batched, parallel-safe, or blocked; include risk triggers and RED/GREEN/REFACTOR checkpoint/commit expectations when the repo workflow supports them. This fulfills the `plan_execution_posture_recorded` gate.",
@@ -38,6 +38,15 @@ export interface StageAutoSubagentDispatch {
38
38
  when: string;
39
39
  purpose: string;
40
40
  requiresUserGate: boolean;
41
+ /**
42
+ * When this delegation may run relative to the adaptive elicitation Q&A loop.
43
+ * - `pre-elicitation` — run before any user dialogue (rare; only for trivial info-gathering).
44
+ * - `post-elicitation` — run only after the Q&A loop converges (default for brainstorm/scope/design
45
+ * so subagents do not preempt the user dialogue).
46
+ * - `any` — no ordering constraint (default for stages that do not run elicitation:
47
+ * spec/plan/tdd/review/ship).
48
+ */
49
+ runPhase?: "pre-elicitation" | "post-elicitation" | "any";
41
50
  /** Role category used by generated routing tables and lifecycle checks. */
42
51
  dispatchClass?: StageSubagentDispatchClass;
43
52
  /** Strict status/evidence contract the dispatched agent must return. */
@@ -45,7 +45,7 @@ export const SCOPE = {
45
45
  },
46
46
  executionModel: {
47
47
  checklist: [
48
- "**Adaptive elicitation loop (shared skill)** load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question per turn via harness-native tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until scope clarity is sufficient or user signals to proceed.",
48
+ "**ADAPTIVE ELICITATION COMES FIRST (no exceptions, no subagent dispatch before).** Load `.cclaw/skills/adaptive-elicitation/SKILL.md`. Walk the scope forcing questions one-at-a-time via the harness-native question tool, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`) after each user answer. Continue until all forcing questions are answered/skipped/waived OR user records an explicit stop-signal row. Only then propose the scope contract draft, recommend a mode, or dispatch any delegations. The linter `qa_log_below_min` rule will block `stage-complete` if Q&A Log is below floor.",
49
49
  "**Scope forcing questions (must be covered or explicitly waived)** — what is definitely in/out, which upstream decisions are locked, and what rollback path protects users if scope assumptions fail.",
50
50
  "**Scope contract first** — read brainstorm handoff, name upstream decisions used, explicit drift, confidence, unresolved questions, and next-stage risk hints; draft the in-scope/out-of-scope/deferred/discretion contract before any design choice.",
51
51
  "**Premise and leverage check** — answer in the artifact: *Right problem? Direct path? What if nothing? Where can we leverage existing code? What is the reversibility cost?* Take a position; do not hedge.",
@@ -63,7 +63,7 @@ export const SCOPE = {
63
63
  "\"Strong success criteria let you loop independently. Weak criteria require constant clarification.\"",
64
64
  decisionProtocolInstruction("scope mode selection", "present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended)", "recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce"),
65
65
  "Run the shared adaptive elicitation cycle from `.cclaw/skills/adaptive-elicitation/SKILL.md`, including stop-signal handling (RU/EN/UA), smart-skip, conditional grilling triggers, and append-only `## Q&A Log` updates.",
66
- "Do not walk the full checklist by default. Lead with a proposed scope contract, selected depth (`lite`/`standard`/`deep`), and the one decision that matters most; label the mode as recommended, not selected, until the user answers.",
66
+ "**Lead with adaptive elicitation, not with a proposed contract.** First walk scope forcing questions one-at-a-time per `adaptive-elicitation` skill. Only AFTER the Q&A loop converges (forcing-Qs answered/waived OR user stop-signal row recorded) propose the scope contract draft for approval. Lite-tier may compress: ask the smallest forcing-Q set (>= linter floor for `lightweight`/`scope`), then propose contract.",
67
67
  "For low-risk concrete asks, keep the proposal compact but still explicit: recommend (do not auto-select) one mode, show exact in/out/deferred boundaries, and request explicit approval before finalizing the artifact or completing the stage.",
68
68
  "Challenge premise first, take a firm position, and name one concrete condition that would change it.",
69
69
  "Push back on weak framing: vague scope needs a specific user/problem, platform vision needs a narrow wedge, social proof needs behavioral evidence.",
@@ -71,7 +71,7 @@ export const SCOPE = {
71
71
  "If the user says no but cannot name the change, offer concrete moves: keep scope, add one obvious adjacent capability, reduce to wedge, or re-open stack/product direction.",
72
72
  "Before final approval, record outside-voice findings and a `## Scope Outside Voice Loop` table per the Scope Outside Voice Loop policy above.",
73
73
  "**STOP.** Wait for explicit user approval of the scope mode and scope contract before writing final approval language or advancing.",
74
- "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` must be completed or explicitly waived for a real blocker. If the active harness cannot isolate a planner, run a role-switch planner pass instead: announce `## cclaw role-switch: scope/planner (mandatory)`, write the planner output/evidence into the scope artifact, and append a completed delegation row with `fulfillmentMode: \"role-switch\"` plus non-empty `evidenceRefs`. Then close with `node .cclaw/hooks/stage-complete.mjs scope --passed=scope_mode_selected,scope_contract_written,scope_user_approved --evidence-json '{\"scope_mode_selected\":\"<user-approved mode + rationale>\",\"scope_contract_written\":\"<artifact path + sections>\",\"scope_user_approved\":\"<explicit user approval quote or summary>\"}'`. `scope_user_approved` must cite the user's approval; review-loop evidence alone is not approval."
74
+ "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` runs **AFTER user approval of the scope contract**, not before Q&A. Sequence is: Q&A loop -> propose contract -> user approval -> `planner` delegation -> `stage-complete`. If you delegate `planner` before the Q&A loop converges, you violate the elicitation contract and the linter will block stage-complete via `qa_log_below_min`. Legal fulfillment modes for `planner`: (a) **harness-native Task tool** — run the delegation, then record the lifecycle row via `node .cclaw/hooks/delegation-record.mjs --stage=scope --agent=planner --mode=mandatory --status=completed --span-id=<uuid> --dispatch-surface=cursor-task --agent-definition-path=<agent-md-path> --evidence-ref=<artifact#section>` (the helper sets `fulfillmentMode: \"generic-dispatch\"` automatically); (b) **role-switch** — announce `## cclaw role-switch: scope/planner (mandatory)`, write the planner output/evidence into the scope artifact, then record the row with `--dispatch-surface=role-switch --agent-definition-path=<artifact-anchor>` (helper sets `fulfillmentMode: \"role-switch\"` automatically); (c) **cclaw subagent helper** if available, with `--dispatch-surface=isolated`. Run `node .cclaw/hooks/stage-complete.mjs scope` from the tool layer (do not paste the command into chat); report only the resulting summary."
75
75
  ],
76
76
  process: [
77
77
  "Run pre-scope audit before premise challenge.",
@@ -97,7 +97,7 @@ export const SCOPE = {
97
97
  "Scope Contract captures requirements, locked decisions, discretion areas, accepted/rejected/deferred reference ideas from the Reference Pattern Registry, success definition, and design handoff.",
98
98
  "Decision Drivers section records weighted criteria and per-option scores used to choose mode and boundary moves.",
99
99
  "Scope Completeness Score is recorded (0.00-1.00) with the explicit blocker list for any remaining uncertainty.",
100
- "Locked Decisions section lists stable LD#hash anchors for non-negotiable boundaries.",
100
+ "Locked Decisions section lists stable D-XX IDs for non-negotiable boundaries.",
101
101
  "Premise challenge findings documented.",
102
102
  "Outside Voice findings and dispositions are recorded (accept/reject/defer with rationale) before final approval.",
103
103
  "Scope outside-voice loop summary includes a table with columns Iteration, Quality Score, Findings, plus Stop reason, Target score, Max iterations, and unresolved concerns. This is outside-voice evidence only; it does not satisfy user approval.",
@@ -161,7 +161,7 @@ export const SCOPE = {
161
161
  { section: "Ambitious Alternatives", required: false, validationRule: "Optional evidence heading for SCOPE EXPANSION/SELECTIVE: list larger alternatives considered and their disposition." },
162
162
  { section: "Ruthless Minimum Slice", required: false, validationRule: "Optional evidence heading for SCOPE REDUCTION or high-risk scope: define the smallest useful wedge and what it proves." },
163
163
  { section: "Requirements", required: false, validationRule: "Table of stable requirement IDs (R1, R2, R3…) one per row with observable outcome, priority, and source. IDs are assigned once and never renumbered across scope/design/spec/plan/review; dropped requirements stay with Priority `DROPPED`." },
164
- { section: "Locked Decisions (LD#hash)", required: false, validationRule: "List of stable locked decisions with unique `LD#<sha8>` anchors. Each anchor is derived from the normalized Decision cell and is referenced downstream for cross-stage traceability." },
164
+ { section: "Locked Decisions", required: false, validationRule: "List of stable locked decisions, each with a unique `D-XX` ID. IDs are stable across edits so downstream stages can reference them; renumbering or duplicating IDs breaks the cross-stage traceability check." },
165
165
  { section: "Implementation Alternatives", required: false, validationRule: "2-3 options with Name, Summary, Effort, Risk, Pros, Cons, and Reuses. Must include minimal viable and ideal architecture options." },
166
166
  { section: "Scope Mode", required: true, validationRule: "Must state selected mode and rationale with default heuristic justification." },
167
167
  { section: "Mode-Specific Analysis", required: false, validationRule: "Default path: one selected-mode row with rationale. Deep/complex scope only: document the expanded analysis matching the selected mode." },
@@ -1,4 +1,11 @@
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## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc` = only progression path.\n- Knowledge capture and recall use the `learnings` skill when requested.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive through closeout via `/cc` or cancel early via `node .cclaw/hooks/cancel-run.mjs`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Stage behavior: current stage skill plus `.cclaw/state/flow-state.json`.\n- Preamble budget: keep role/status announcements brief and avoid repeating\n them unless the stage or role changes.\n";
3
+ /**
4
+ * Always-on baseline rule materialized at `.cursor/rules/cclaw-guidelines.mdc`.
5
+ * Independent of skill activation — kicks in even when the agent skips
6
+ * loading skills. Three hard rules cover the most common Wave 22 regressions
7
+ * (premature draft, premature subagent dispatch, command-line echo to chat).
8
+ */
9
+ export declare const CURSOR_GUIDELINES_RULE_MDC = "---\ndescription: cclaw zero-install behavior baseline (always-on)\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-guidelines-rule -->\n\n# Cclaw Baseline Guidelines\n\nThese three rules apply to every Cursor agent session in this project,\nregardless of whether stage skills loaded.\n\n## 1. Q&A floor before drafting (brainstorm/scope/design)\n\nBefore drafting any `.cclaw/artifacts/01-brainstorm-*.md`,\n`02-scope-*.md`, or `03-design-*.md`, verify that the artifact's\n`## Q&A Log` table contains at least the floor count for the active track\n(see `questionBudgetHint(track, stage).min`). Walk the stage forcing\nquestions one at a time via the `AskQuestion` tool. If you find yourself\nproposing a draft after 1-2 questions, STOP and continue the loop.\n\nThe `qa_log_below_min` linter rule will block `stage-complete` when below\nfloor unless an explicit user stop-signal row is recorded.\n\n## 2. Mandatory subagents run after Q&A approval\n\nFor brainstorm / scope / design, mandatory subagents (\n`product-discovery`, `critic`, `planner`, `architect`,\n`test-author`) run **only AFTER the user approves the elicitation\noutcome**, never before the Q&A loop converges. Dispatching them early\npreempts the user dialogue and violates the elicitation contract \u2014 the\nlinter will block stage-complete.\n\nSee each stage's \"Run Phase: post-elicitation\" rows in the materialized\nAutomatic Subagent Dispatch table.\n\n## 3. Never echo cclaw command lines to chat\n\nThe user does not run cclaw helpers (`node .cclaw/hooks/...`) manually.\nNEVER paste full command lines, `--evidence-json '{...}'` payloads,\n`--waive-delegation=...`, or shell hash commands (`shasum`,\n`sha256sum`, `Get-FileHash`, `certutil`, etc.) into chat. Run the\nhelper via the tool layer and report only the resulting summary. On\nfailure, report a compact human-readable summary plus the helper JSON in\na single fenced `json` block.\n";
10
+ 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## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc` = only progression path.\n- Knowledge capture and recall use the `learnings` skill when requested.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive through closeout via `/cc` or cancel early via `node .cclaw/hooks/cancel-run.mjs`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- **For brainstorm / scope / design stages**: ask user input continuously via adaptive elicitation (one question per turn through the harness-native question tool \u2014 `AskQuestion` in Cursor). Walk the stage forcing-questions list one-by-one. Do NOT batch and do NOT defer to a single approval gate at the end. The `qa_log_below_min` linter rule will block `stage-complete` when below floor.\n- **For other stages** (spec/plan/tdd/build/review/ship): ask user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization), not for routine progress updates.\n- If you find yourself proposing a draft after 1-2 questions in brainstorm/scope/design, STOP \u2014 go back to the forcing-questions list and continue.\n- Mandatory subagents in brainstorm/scope/design run only AFTER the user approves the elicitation outcome (see each stage's \"Run Phase: post-elicitation\" rows). Dispatching them before the Q&A loop converges violates the contract.\n- Never echo cclaw command lines (`node .cclaw/hooks/...`, `--evidence-json '{...}'`) to chat \u2014 the user does not run cclaw manually. Run helpers via the tool layer; report only the resulting summary.\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Stage behavior: current stage skill plus `.cclaw/state/flow-state.json`.\n- Preamble budget: keep role/status announcements brief and avoid repeating\n them unless the stage or role changes.\n";
4
11
  export declare function buildRulesJson(): Record<string, unknown>;