cclaw-cli 0.15.0 → 0.18.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.
Files changed (51) hide show
  1. package/dist/artifact-linter.js +154 -0
  2. package/dist/cli.js +2 -1
  3. package/dist/constants.d.ts +2 -2
  4. package/dist/constants.js +2 -3
  5. package/dist/content/contracts.js +1 -1
  6. package/dist/content/doctor-references.js +7 -6
  7. package/dist/content/feature-command.js +54 -51
  8. package/dist/content/harnesses-doc.js +2 -2
  9. package/dist/content/hooks.js +2 -2
  10. package/dist/content/learnings.d.ts +1 -1
  11. package/dist/content/learnings.js +22 -5
  12. package/dist/content/meta-skill.js +2 -2
  13. package/dist/content/next-command.js +2 -2
  14. package/dist/content/observe.js +3 -2
  15. package/dist/content/ops-command.js +1 -3
  16. package/dist/content/protocols.js +6 -34
  17. package/dist/content/rewind-command.d.ts +0 -1
  18. package/dist/content/rewind-command.js +19 -33
  19. package/dist/content/skills.js +2 -3
  20. package/dist/content/stage-schema.d.ts +2 -92
  21. package/dist/content/stage-schema.js +10 -1379
  22. package/dist/content/stages/brainstorm.d.ts +2 -0
  23. package/dist/content/stages/brainstorm.js +136 -0
  24. package/dist/content/stages/design.d.ts +2 -0
  25. package/dist/content/stages/design.js +215 -0
  26. package/dist/content/stages/index.d.ts +8 -0
  27. package/dist/content/stages/index.js +11 -0
  28. package/dist/content/stages/plan.d.ts +2 -0
  29. package/dist/content/stages/plan.js +157 -0
  30. package/dist/content/stages/review.d.ts +2 -0
  31. package/dist/content/stages/review.js +197 -0
  32. package/dist/content/stages/schema-types.d.ts +94 -0
  33. package/dist/content/stages/schema-types.js +1 -0
  34. package/dist/content/stages/scope.d.ts +2 -0
  35. package/dist/content/stages/scope.js +194 -0
  36. package/dist/content/stages/ship.d.ts +2 -0
  37. package/dist/content/stages/ship.js +142 -0
  38. package/dist/content/stages/spec.d.ts +2 -0
  39. package/dist/content/stages/spec.js +136 -0
  40. package/dist/content/stages/tdd.d.ts +2 -0
  41. package/dist/content/stages/tdd.js +185 -0
  42. package/dist/content/templates.js +105 -9
  43. package/dist/content/utility-skills.js +1 -1
  44. package/dist/delegation.d.ts +33 -3
  45. package/dist/delegation.js +56 -3
  46. package/dist/doctor.js +147 -88
  47. package/dist/feature-system.d.ts +22 -5
  48. package/dist/feature-system.js +267 -126
  49. package/dist/install.js +4 -8
  50. package/dist/policy.js +3 -4
  51. package/package.json +1 -1
@@ -0,0 +1,197 @@
1
+ // ---------------------------------------------------------------------------
2
+ // REVIEW — reference: superpowers code-review + gstack /review
3
+ // ---------------------------------------------------------------------------
4
+ export const REVIEW = {
5
+ stage: "review",
6
+ skillFolder: "two-layer-review",
7
+ skillName: "two-layer-review",
8
+ skillDescription: "Two-layer review stage: spec compliance first, then code quality and production readiness. Section-by-section with severity discipline.",
9
+ hardGate: "Do NOT ship, merge, or release until both review layers complete with an explicit verdict. No exceptions for urgency. Critical blockers MUST be resolved before handoff.",
10
+ ironLaw: "NO SHIP VERDICT UNTIL BOTH REVIEW LAYERS COMPLETE AND EVERY CRITICAL IS RESOLVED OR EXPLICITLY ACCEPTED.",
11
+ purpose: "Validate that implementation matches spec and meets quality/security/performance bar through structured two-layer review.",
12
+ whenToUse: [
13
+ "After TDD stage completes",
14
+ "Before any ship action",
15
+ "When release risk must be assessed explicitly"
16
+ ],
17
+ whenNotToUse: [
18
+ "There is no implementation diff to review",
19
+ "TDD stage evidence is missing or stale",
20
+ "The goal is direct release execution without layered quality checks"
21
+ ],
22
+ checklist: [
23
+ "Diff Scope — Run `git diff` against base branch. If no diff, exit early with APPROVED (no changes to review). Scope the review to changed files unless blast-radius analysis requires wider inspection.",
24
+ "Change-Size Check — ~100 lines = normal. ~300 lines = consider splitting. ~1000+ lines = strongly recommend stacked PRs. Flag large diffs to the user.",
25
+ "Adversarial Trigger Check — compute changed-line count (`git diff --shortstat <base>..HEAD`), files-touched count, and whether trust boundaries changed (auth/secrets/external inputs/permissions). If `lines > 100` OR `files > 10` OR `trust boundary changed`, **dispatch a SECOND reviewer agent with the `adversarial-review` skill loaded** and reconcile its findings into the review army (treat the conditional dispatch as mandatory whenever the trigger holds; record the trigger that fired in the dashboard).",
26
+ "Load upstream evidence — read TDD artifact (RED + GREEN + REFACTOR), spec, and plan. Verify evidence chain is unbroken.",
27
+ "Layer 1: Spec Compliance — check every acceptance criterion against implementation. Verdict: pass/fail per criterion.",
28
+ "Layer 2a: Correctness — logic errors, race conditions, boundary violations, null handling.",
29
+ "Layer 2b: Security — input validation, auth boundaries, secrets exposure, injection vectors. **Mandatory:** also load and execute the `.cclaw/skills/security-audit/SKILL.md` utility skill (proactive pattern sweep across diff + touched modules, not just the diff itself) and merge findings into the review army. The Layer 2 security pass is not complete until the audit sweep records a finding count (0 acceptable) with file:line evidence for every Critical.",
30
+ "Layer 2c: Performance — N+1 queries, memory leaks, missing caching, hot paths.",
31
+ "Layer 2d: Architecture Fit — does the implementation match the locked design? Coupling, cohesion, interface contracts.",
32
+ "Layer 2e: External Safety — SQL safety, concurrency, secrets in logs, enum completeness (grep outside diff), LLM trust boundaries.",
33
+ "Review Army reconciliation — normalize findings into structured records, dedup by fingerprint, and mark multi-specialist confirmations.",
34
+ "Meta-Review — Were tests actually run? Do test names match what they test? Are there real assertions?",
35
+ "Classify findings — Critical (blocks ship), Important (should fix), Suggestion (optional improvement).",
36
+ "Produce verdict — APPROVED, APPROVED_WITH_CONCERNS, or BLOCKED."
37
+ ],
38
+ interactionProtocol: [
39
+ "Run Layer 1 (spec compliance) completely before starting Layer 2.",
40
+ "In each review section, present findings ONE AT A TIME. Do NOT batch.",
41
+ "Classify every finding as Critical, Important, or Suggestion.",
42
+ "For each Critical finding: use the Decision Protocol — present resolution options (A/B/C) with trade-offs, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius. 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.",
43
+ "Resolve all critical blockers before ship.",
44
+ "For final verdict: use AskQuestion/AskUserQuestion only if runtime schema is confirmed; otherwise collect verdict with a plain-text single-choice prompt (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED).",
45
+ "**STOP.** Do NOT proceed to ship until the user provides an explicit verdict."
46
+ ],
47
+ process: [
48
+ "Layer 1: check acceptance criteria and requirement coverage.",
49
+ "Layer 2a: check correctness — logic, races, boundaries, null handling.",
50
+ "Layer 2b: check security — validation, auth, secrets, injection.",
51
+ "Layer 2c: check performance — queries, memory, caching, hot paths.",
52
+ "Layer 2d: check architecture fit — design compliance, coupling, interfaces.",
53
+ "Reconcile multi-agent findings into `.cclaw/artifacts/07-review-army.json` (dedup + confidence + conflict notes).",
54
+ "Classify and prioritize all findings.",
55
+ "Write review report artifact with explicit verdict."
56
+ ],
57
+ requiredGates: [
58
+ { id: "review_layer1_spec_compliance", description: "Spec compliance check completed with per-criterion verdict." },
59
+ { id: "review_layer2_correctness", description: "Correctness review completed." },
60
+ { id: "review_layer2_security", description: "Security review completed." },
61
+ { id: "review_layer2_performance", description: "Performance review completed." },
62
+ { id: "review_layer2_architecture", description: "Architecture fit review completed." },
63
+ { id: "review_severity_classified", description: "All findings are severity-tagged." },
64
+ { id: "review_criticals_resolved", description: "No unresolved critical blockers remain." },
65
+ { id: "review_army_json_valid", description: "07-review-army.json passes schema validation (validateReviewArmy)." },
66
+ { id: "review_completeness_scored", description: "Completeness score is computed and recorded (AC coverage, task coverage, slice coverage, adversarial pass)." },
67
+ { id: "review_security_audit_swept", description: "The security-audit utility skill was run against the diff scope and the modules it touches. Finding count (0 if clean) recorded in the review army with file:line evidence for every Critical." }
68
+ ],
69
+ requiredEvidence: [
70
+ "Artifact written to `.cclaw/artifacts/07-review.md`.",
71
+ "Artifact written to `.cclaw/artifacts/07-review-army.json`.",
72
+ "Layer 1 verdict captured with per-criterion pass/fail.",
73
+ "Layer 2 sections completed with findings.",
74
+ "Severity log includes critical/important/suggestion buckets.",
75
+ "Explicit final verdict: APPROVED, APPROVED_WITH_CONCERNS, or BLOCKED."
76
+ ],
77
+ inputs: ["implementation diff", "spec and plan artifacts", "test/build evidence"],
78
+ requiredContext: ["spec criteria", "tdd artifact", "rulebook constraints"],
79
+ outputs: ["review verdict", "severity-indexed findings", "reconciled review-army findings", "ship readiness decision"],
80
+ blockers: [
81
+ "layer 1 failed",
82
+ "critical findings unresolved",
83
+ "missing regression evidence"
84
+ ],
85
+ exitCriteria: [
86
+ "both layers completed",
87
+ "all review sections evaluated",
88
+ "critical blockers resolved",
89
+ "ship readiness explicitly stated"
90
+ ],
91
+ antiPatterns: [
92
+ "Single generic review without layered structure",
93
+ "No severity classification",
94
+ "Shipping with open criticals",
95
+ "Batching multiple findings into one report without individual resolution",
96
+ "Skipping Layer 2 sections because Layer 1 passed"
97
+ ],
98
+ redFlags: [
99
+ "No separate Layer 1/Layer 2 outcomes",
100
+ "No structured review-army reconciliation artifact",
101
+ "No critical bucket",
102
+ "No explicit ready/not-ready verdict",
103
+ "Review sections skipped or abbreviated",
104
+ "Findings not classified by severity"
105
+ ],
106
+ policyNeedles: ["Layer 1", "Layer 2", "Critical", "Review Army", "Ready to Ship", "One issue at a time"],
107
+ artifactFile: "07-review.md",
108
+ next: "ship",
109
+ reviewSections: [
110
+ {
111
+ title: "Layer 1: Spec Compliance",
112
+ evaluationPoints: [
113
+ "For each acceptance criterion: does the implementation satisfy it?",
114
+ "Are there spec requirements with no corresponding implementation?",
115
+ "Are there implementations with no corresponding spec requirement (scope creep)?",
116
+ "Is every edge case from the spec handled?"
117
+ ],
118
+ stopGate: true
119
+ },
120
+ {
121
+ title: "Layer 2a: Correctness",
122
+ evaluationPoints: [
123
+ "Logic errors and boundary violations",
124
+ "Race conditions and concurrency issues",
125
+ "Null/undefined handling",
126
+ "Error propagation and recovery paths"
127
+ ],
128
+ stopGate: true
129
+ },
130
+ {
131
+ title: "Layer 2b: Security",
132
+ evaluationPoints: [
133
+ "Input validation completeness",
134
+ "Authorization boundary enforcement",
135
+ "Secrets exposure risk",
136
+ "Injection vector assessment"
137
+ ],
138
+ stopGate: true
139
+ },
140
+ {
141
+ title: "Layer 2c: Performance",
142
+ evaluationPoints: [
143
+ "N+1 query patterns",
144
+ "Memory leak potential",
145
+ "Missing caching opportunities",
146
+ "Hot path complexity analysis"
147
+ ],
148
+ stopGate: true
149
+ },
150
+ {
151
+ title: "Layer 2d: Architecture Fit",
152
+ evaluationPoints: [
153
+ "Does implementation match the locked design?",
154
+ "Coupling and cohesion assessment",
155
+ "Interface contract compliance",
156
+ "Unintended architectural drift"
157
+ ],
158
+ stopGate: true
159
+ },
160
+ {
161
+ title: "Layer 2e: External Safety Checklist",
162
+ evaluationPoints: [
163
+ "SQL/database: parameterized queries, no raw string interpolation, migration safety",
164
+ "Concurrency: race conditions in shared state, lock ordering, timeout handling",
165
+ "Secrets: no hardcoded tokens, no secrets in logs, env vars for sensitive config",
166
+ "Enum/constant completeness: grep for sibling values OUTSIDE the diff — are all cases handled?",
167
+ "Trust boundaries: if LLM/AI output is used, is it validated before acting on it?"
168
+ ],
169
+ stopGate: true
170
+ },
171
+ {
172
+ title: "Meta-Review: Verify the Verification",
173
+ evaluationPoints: [
174
+ "Were tests actually run (not just assumed to pass)?",
175
+ "Do the test names match what they actually test?",
176
+ "Is there test coverage for the specific changes in this diff?",
177
+ "Are there assertions, or do tests just run without checking results?"
178
+ ],
179
+ stopGate: false
180
+ }
181
+ ],
182
+ completionStatus: ["APPROVED", "APPROVED_WITH_CONCERNS", "BLOCKED"],
183
+ crossStageTrace: {
184
+ readsFrom: [".cclaw/artifacts/06-tdd.md", ".cclaw/artifacts/04-spec.md", ".cclaw/artifacts/05-plan.md"],
185
+ writesTo: [".cclaw/artifacts/07-review.md", ".cclaw/artifacts/07-review-army.json"],
186
+ traceabilityRule: "Review verdict must reference specific spec criteria and TDD evidence. Downstream ship stage must reference review verdict."
187
+ },
188
+ artifactValidation: [
189
+ { section: "Layer 1 Verdict", required: true, validationRule: "Per-criterion pass/fail with references." },
190
+ { section: "Layer 2 Findings", required: true, validationRule: "Each finding has severity, description, and resolution status." },
191
+ { section: "Review Army Contract", required: true, validationRule: "Structured findings include id/severity/confidence/fingerprint/reportedBy/status with dedup reconciliation summary." },
192
+ { section: "Review Readiness Dashboard", required: true, validationRule: "Includes a per-pass table (Layer 1 / Layer 2 / Adversarial / Schema) with a 'Completed at' column, a Delegation log snapshot block (path .cclaw/state/delegation-log.json with required/completed/waived/pending), a Staleness signal block (commit at last review pass and current commit), and a Headline with open critical blockers + ship recommendation. At minimum, the section text must contain the substrings 'Completed at', 'delegation-log.json', 'commit at last review pass', and 'Ship recommendation'." },
193
+ { section: "Completeness Score", required: true, validationRule: "Records AC coverage, task coverage, test-slice coverage, and adversarial-review pass status as numeric or boolean values. At minimum, a line like 'AC coverage: N/M' or 'AC coverage: 100%'." },
194
+ { section: "Severity Summary", required: true, validationRule: "Per-severity count lines for critical, important, and suggestion buckets." },
195
+ { section: "Final Verdict", required: true, validationRule: "Exactly one of: APPROVED, APPROVED_WITH_CONCERNS, BLOCKED." }
196
+ ]
197
+ };
@@ -0,0 +1,94 @@
1
+ import type { FlowStage } from "../../types.js";
2
+ export interface StageGate {
3
+ id: string;
4
+ description: string;
5
+ tier?: "required" | "recommended" | "conditional";
6
+ /** Used when tier=conditional. Predicate syntax mirrors conditional delegation rules. */
7
+ condition?: string;
8
+ }
9
+ export interface ReviewSection {
10
+ title: string;
11
+ evaluationPoints: string[];
12
+ stopGate: boolean;
13
+ }
14
+ export interface CrossStageTrace {
15
+ readsFrom: string[];
16
+ writesTo: string[];
17
+ traceabilityRule: string;
18
+ }
19
+ export interface ArtifactValidation {
20
+ section: string;
21
+ required: boolean;
22
+ tier?: "required" | "recommended" | "conditional";
23
+ /** Optional predicate for conditional validations. */
24
+ condition?: string;
25
+ validationRule: string;
26
+ }
27
+ export interface StageAutoSubagentDispatch {
28
+ agent: "planner" | "reviewer" | "security-reviewer" | "test-author" | "doc-updater";
29
+ /**
30
+ * - `mandatory` — must be dispatched (or explicitly waived) before stage transition.
31
+ * - `proactive` — should be dispatched automatically when context matches `when`.
32
+ * - `conditional` — dispatched only when `condition` evaluates true at runtime; counted as
33
+ * mandatory **only when the condition holds**.
34
+ */
35
+ mode: "mandatory" | "proactive" | "conditional";
36
+ when: string;
37
+ purpose: string;
38
+ requiresUserGate: boolean;
39
+ /**
40
+ * Optional machine-friendly trigger expression for `conditional` rows.
41
+ * Supported predicates: `diff_lines_gt:<N>`, `files_touched_gt:<N>`,
42
+ * `trust_boundary_changed`, `release_blast_radius_high`.
43
+ * Multiple predicates joined by `||` mean ANY trigger satisfies the condition.
44
+ */
45
+ condition?: string;
46
+ /** Optional skill folder the dispatched agent should load as additional context. */
47
+ skill?: string;
48
+ }
49
+ export interface StageSchema {
50
+ stage: FlowStage;
51
+ skillFolder: string;
52
+ skillName: string;
53
+ skillDescription: string;
54
+ hardGate: string;
55
+ /**
56
+ * One-line "Iron Law" punchcard — the single rule that, if broken,
57
+ * invalidates the stage outright. Rendered in ALL-CAPS wrapped in
58
+ * <EXTREMELY-IMPORTANT> XML markers at the very top of the skill body.
59
+ * Reference: Superpowers (obra) "NO PRODUCTION CODE WITHOUT A FAILING
60
+ * TEST FIRST".
61
+ */
62
+ ironLaw: string;
63
+ purpose: string;
64
+ whenToUse: string[];
65
+ whenNotToUse: string[];
66
+ interactionProtocol: string[];
67
+ process: string[];
68
+ requiredGates: StageGate[];
69
+ requiredEvidence: string[];
70
+ inputs: string[];
71
+ requiredContext: string[];
72
+ /** In-thread research procedures for this stage (`.cclaw/skills/research/*.md`). */
73
+ researchPlaybooks?: string[];
74
+ outputs: string[];
75
+ blockers: string[];
76
+ exitCriteria: string[];
77
+ antiPatterns: string[];
78
+ redFlags: string[];
79
+ policyNeedles: string[];
80
+ artifactFile: string;
81
+ next: FlowStage | "done";
82
+ checklist: string[];
83
+ reviewSections: ReviewSection[];
84
+ completionStatus: string[];
85
+ crossStageTrace: CrossStageTrace;
86
+ artifactValidation: ArtifactValidation[];
87
+ /** When true, stage skill includes wave auto-execute guidance (tdd). */
88
+ waveExecutionAllowed?: boolean;
89
+ /** Sections that remain required even when the trivial-change escape hatch is active (design only). */
90
+ trivialOverrideSections?: string[];
91
+ /** Agent names that MUST be dispatched (or waived) before stage transition — derived from mandatory auto-subagent rows. */
92
+ mandatoryDelegations: string[];
93
+ }
94
+ export type StageSchemaInput = Omit<StageSchema, "mandatoryDelegations">;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { StageSchemaInput } from "./schema-types.js";
2
+ export declare const SCOPE: StageSchemaInput;
@@ -0,0 +1,194 @@
1
+ // ---------------------------------------------------------------------------
2
+ // SCOPE — reference: gstack CEO review
3
+ // ---------------------------------------------------------------------------
4
+ export const SCOPE = {
5
+ stage: "scope",
6
+ skillFolder: "scope-shaping",
7
+ skillName: "scope-shaping",
8
+ skillDescription: "Strategic scope stage. Challenge premise and lock explicit in-scope/out-of-scope boundaries using CEO-level thinking.",
9
+ hardGate: "Do NOT begin architecture, design, or code. This stage produces scope decisions only. Do not silently add or remove scope — every change is an explicit user opt-in.",
10
+ ironLaw: "EVERY SCOPE CHANGE IS AN EXPLICIT USER OPT-IN — NEVER A SILENT ENLARGEMENT OR TRIM.",
11
+ purpose: "Decide the right scope before technical lock-in using explicit mode selection and rigorous premise challenge.",
12
+ whenToUse: [
13
+ "After brainstorm approval",
14
+ "Before architecture/design lock-in",
15
+ "When ambition vs feasibility trade-off is unclear"
16
+ ],
17
+ whenNotToUse: [
18
+ "Brainstorm has not been approved yet",
19
+ "Scope boundaries are already locked and user requested no scope changes",
20
+ "The work is a pure implementation or debugging pass within existing scope"
21
+ ],
22
+ checklist: [
23
+ "**Assess complexity** — Read the brainstorm artifact. If project is simple (single component, clear architecture, personal/prototype), run light-touch scope: mode selection, 3-5 key in/out boundaries, deferred items. Skip Dream State Mapping and Temporal Interrogation. If project is complex (multi-component, team delivery, production), run the full checklist.",
24
+ "**Prime Directives** — Zero silent failures. For each in-scope capability, name concrete failure modes, the exact error surface, and trace all four data-flow paths (happy, nil, empty, upstream error). Include interaction edge cases (double-click, navigate-away, stale state), observability commitments, and explicit deferred-item logging.",
25
+ "**Premise Challenge** — Is this the right problem? What if we do nothing? What are we optimizing for?",
26
+ "**Existing Code Leverage** — Search for existing solutions before deciding to build new.",
27
+ "**Dream State Mapping** — (complex projects only) describe the ideal state 12 months out using `CURRENT STATE -> THIS PLAN -> 12-MONTH IDEAL`, then verify this scope moves toward that target.",
28
+ "**Implementation Alternatives** — Produce 2-3 distinct approaches. For each: Name, Summary, Effort (S/M/L/XL), Risk (Low/Med/High), 2-3 Pros, 2-3 Cons, and explicit Reuses. One option must be minimal viable, one must be ideal architecture.",
29
+ "**Temporal Interrogation** — (complex projects only) simulate implementation timeline: HOUR 1 foundations, HOUR 2-3 core logic, HOUR 4-5 integration surprises, HOUR 6+ polish/tests. Decide what must be locked now vs safely deferred.",
30
+ "**Mode Selection** — Present expand/selective/hold/reduce with recommendation and default heuristic: greenfield -> expand, feature enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius (>15 files or multi-team impact) -> reduce.",
31
+ "**Mode-Specific Analysis** — After mode is selected, run the matching analysis: EXPAND (10x and delight opportunities), SELECTIVE (hold-scope rigor then cherry-picked expansions), HOLD (minimum-change-set hardening), REDUCE (ruthless cuts and follow-up split).",
32
+ "**Error and Rescue Registry** — For each capability: what breaks, how detected, what fallback."
33
+ ],
34
+ interactionProtocol: [
35
+ "For scope mode selection: use the Decision Protocol — present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended). Do NOT use a numeric Completeness rubric; 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. 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.",
36
+ "Walk through the scope checklist interactively. Each checklist item that surfaces a decision should be presented to the user as a question, not as a monologue. Do not dump all items at once.",
37
+ "Challenge premise and verify the problem framing before anything else.",
38
+ "Take a position on every scope decision. Avoid hedging phrases like 'this could work' or 'there are many ways'; state your recommendation and one concrete condition that would change it.",
39
+ "Use pushback patterns when framing is weak: vague scope -> force a specific user/problem, platform vision -> force a narrowest viable wedge, social proof -> demand behavioral evidence.",
40
+ "Present one structural scope issue at a time for decision. Do NOT batch. Use structured options for each scope boundary question.",
41
+ "Record explicit in-scope and out-of-scope contract.",
42
+ "Once the user accepts or rejects a recommendation, commit fully. Do not re-argue.",
43
+ "Produce a clean scope summary after all issues are resolved.",
44
+ "**STOP.** Wait for explicit user approval of scope contract before advancing to design."
45
+ ],
46
+ process: [
47
+ "Run premise challenge and existing-solution leverage check.",
48
+ "Produce 2-3 scope alternatives in a structured format (Name, Summary, Effort, Risk, Pros, Cons, Reuses) with minimum viable and ideal architecture options included.",
49
+ "Choose scope mode with user approval.",
50
+ "Run mode-specific analysis that matches the selected scope mode.",
51
+ "Walk through scope review sections one at a time.",
52
+ "Write explicit scope contract, discretion areas, and deferred items.",
53
+ "Freeze non-negotiable boundaries as stable Locked Decisions (D-XX IDs).",
54
+ "Produce scope summary plus completion dashboard (checklist findings, number of resolved decisions, unresolved items or `None`)."
55
+ ],
56
+ requiredGates: [
57
+ { id: "scope_premise_challenged", description: "Problem framing and assumptions were challenged." },
58
+ { id: "scope_alternatives_produced", description: "At least 2 implementation alternatives were evaluated with explicit effort/risk and reuse fields." },
59
+ { id: "scope_mode_selected", description: "One scope mode was explicitly selected." },
60
+ { id: "scope_contract_written", description: "In-scope/out-of-scope contract is documented." },
61
+ { id: "scope_discretion_documented", description: "Discretion areas are documented (or explicitly marked as none)." },
62
+ { id: "scope_user_approved", description: "User approved the final scope direction." }
63
+ ],
64
+ requiredEvidence: [
65
+ "Artifact written to `.cclaw/artifacts/02-scope.md`.",
66
+ "In-scope and out-of-scope lists are explicit.",
67
+ "Discretion areas are explicit (or marked as `None`).",
68
+ "Selected mode and rationale are documented.",
69
+ "Locked Decisions section lists stable D-XX IDs for non-negotiable boundaries.",
70
+ "Premise challenge findings documented.",
71
+ "Deferred items list with one-line rationale for each.",
72
+ "Completion dashboard lists checklist findings, decision count, and unresolved items (or `None`)."
73
+ ],
74
+ inputs: ["brainstorm artifact", "timeline constraints", "product priorities"],
75
+ requiredContext: [
76
+ "approved brainstorm direction",
77
+ "existing capabilities and reusable components",
78
+ "delivery deadlines and risk tolerance"
79
+ ],
80
+ researchPlaybooks: [
81
+ "research/git-history.md"
82
+ ],
83
+ outputs: ["scope mode decision", "scope contract", "discretion areas list", "deferred scope list", "scope summary", "scope completion dashboard"],
84
+ blockers: [
85
+ "scope mode not selected",
86
+ "in/out boundaries ambiguous",
87
+ "discretion areas undefined",
88
+ "critical premise disagreement unresolved"
89
+ ],
90
+ exitCriteria: [
91
+ "scope contract approved by user",
92
+ "discretion areas recorded explicitly",
93
+ "required gates marked satisfied",
94
+ "deferred list recorded explicitly",
95
+ "locked decisions captured with stable D-XX IDs",
96
+ "completion dashboard produced",
97
+ "scope summary produced"
98
+ ],
99
+ antiPatterns: [
100
+ "Scope silently expanded during discussion",
101
+ "No explicit out-of-scope section",
102
+ "Premise accepted without challenge",
103
+ "Sycophantic agreement without evidence-based pushback",
104
+ "Hedged recommendations that avoid taking a position",
105
+ "Batching multiple scope issues into one question",
106
+ "Re-arguing for smaller scope after user rejects reduction",
107
+ "Using scope-reduction placeholders (`v1`, `for now`, `we can do later`) instead of explicit user-approved boundaries"
108
+ ],
109
+ redFlags: [
110
+ "No selected mode in artifact",
111
+ "Mode selected without heuristic justification",
112
+ "No discretion section (or explicit `None`) in artifact",
113
+ "No deferred/not-in-scope section",
114
+ "No user approval marker",
115
+ "Premise challenge missing or superficial",
116
+ "No implementation alternatives evaluated",
117
+ "Missing Locked Decisions section or decisions without D-XX IDs"
118
+ ],
119
+ policyNeedles: ["Scope mode", "In Scope", "Out of Scope", "Discretion Areas", "NOT in scope", "Premise Challenge", "Locked Decisions"],
120
+ artifactFile: "02-scope.md",
121
+ next: "design",
122
+ reviewSections: [
123
+ {
124
+ title: "Scope Boundary Audit",
125
+ evaluationPoints: [
126
+ "Are all in-scope items justified by the problem statement?",
127
+ "Are any in-scope items actually solving a proxy problem instead of the real one?",
128
+ "Could any in-scope item be deferred without blocking the core objective?"
129
+ ],
130
+ stopGate: true
131
+ },
132
+ {
133
+ title: "Deferred Items Review",
134
+ evaluationPoints: [
135
+ "Does each deferred item have a one-line rationale?",
136
+ "Are any deferred items actually blockers for the core scope?",
137
+ "Will deferring these items create technical debt that is expensive to unwind?"
138
+ ],
139
+ stopGate: true
140
+ },
141
+ {
142
+ title: "Risk and Reversibility Check",
143
+ evaluationPoints: [
144
+ "For each major scope decision: is it reversible?",
145
+ "What is the blast radius if this decision is wrong?",
146
+ "Are there hidden dependencies between in-scope and out-of-scope items?"
147
+ ],
148
+ stopGate: true
149
+ },
150
+ {
151
+ title: "Existing-Code Reuse Check",
152
+ evaluationPoints: [
153
+ "Has every sub-problem been mapped to existing code?",
154
+ "Is the plan rebuilding anything that already exists?",
155
+ "Are there integration opportunities that reduce new code?",
156
+ "Have you searched for built-in or library solutions before scoping custom work?"
157
+ ],
158
+ stopGate: true
159
+ },
160
+ {
161
+ title: "Error & Rescue Scope Check",
162
+ evaluationPoints: [
163
+ "For every new capability: what breaks if it fails?",
164
+ "Is failure detection in scope or deferred? If deferred, is that acceptable?",
165
+ "Are there rescue/fallback paths for critical user journeys?",
166
+ "Is observability (logging, metrics, alerts) explicitly in or out of scope?"
167
+ ],
168
+ stopGate: true
169
+ }
170
+ ],
171
+ completionStatus: ["DONE", "DONE_WITH_CONCERNS", "BLOCKED"],
172
+ crossStageTrace: {
173
+ readsFrom: [".cclaw/artifacts/01-brainstorm.md"],
174
+ writesTo: [".cclaw/artifacts/02-scope.md"],
175
+ traceabilityRule: "Every scope boundary must be traceable to a brainstorm decision. Every downstream design choice must stay within the scope contract."
176
+ },
177
+ artifactValidation: [
178
+ { section: "Prime Directives", required: true, validationRule: "For each scoped capability: named failure modes, explicit error surface, four data-flow paths, interaction edge cases, observability expectations, and deferred-item handling." },
179
+ { section: "Premise Challenge", required: true, validationRule: "Must contain explicit answers to: right problem? direct path? what if nothing?" },
180
+ { section: "Requirements", required: true, 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`." },
181
+ { section: "Locked Decisions (D-XX)", required: false, validationRule: "List of stable locked decisions with IDs D-01, D-02... Each ID appears once, includes rationale, and is intended for downstream cross-stage traceability." },
182
+ { section: "Implementation Alternatives", required: true, validationRule: "2-3 options with Name, Summary, Effort, Risk, Pros, Cons, and Reuses. Must include minimal viable and ideal architecture options." },
183
+ { section: "Scope Mode", required: true, validationRule: "Must state selected mode and rationale with default heuristic justification." },
184
+ { section: "Mode-Specific Analysis", required: true, validationRule: "Must document the analysis matching the selected scope mode: EXPAND (10x and delight opportunities), SELECTIVE (hold-scope baseline then cherry-picked expansions), HOLD (minimum-change-set hardening), REDUCE (ruthless cuts and follow-up split)." },
185
+ { section: "In Scope / Out of Scope", required: true, validationRule: "Two separate explicit lists. Out-of-scope must not be empty." },
186
+ { section: "Discretion Areas", required: true, validationRule: "Explicit list of implementer decision zones, or 'None' if scope is fully locked." },
187
+ { section: "Deferred Items", required: true, validationRule: "Each item has one-line rationale. If empty, state 'None' explicitly." },
188
+ { section: "Error & Rescue Registry", required: true, validationRule: "Each scoped capability has: failure mode, detection method, fallback decision." },
189
+ { section: "Completion Dashboard", required: true, validationRule: "Lists checklist findings, count of resolved decisions, and unresolved decisions (or 'None')." },
190
+ { section: "Scope Summary", required: true, validationRule: "Clean summary: mode, strongest challenges, recommended path, accepted scope, deferred, excluded." },
191
+ { section: "Dream State Mapping", required: false, validationRule: "If present (complex projects): CURRENT STATE, THIS PLAN, 12-MONTH IDEAL, and alignment verdict." },
192
+ { section: "Temporal Interrogation", required: false, validationRule: "If present (complex projects): timeline simulation table with decision pressures and lock-now vs defer verdicts." }
193
+ ]
194
+ };
@@ -0,0 +1,2 @@
1
+ import type { StageSchemaInput } from "./schema-types.js";
2
+ export declare const SHIP: StageSchemaInput;