cclaw-cli 0.10.1 → 0.12.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 (55) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.d.ts +6 -0
  3. package/dist/cli.js +297 -9
  4. package/dist/config.js +83 -3
  5. package/dist/content/core-agents.d.ts +44 -0
  6. package/dist/content/core-agents.js +225 -0
  7. package/dist/content/doctor-references.d.ts +2 -0
  8. package/dist/content/doctor-references.js +144 -0
  9. package/dist/content/examples.js +1 -1
  10. package/dist/content/harnesses-doc.d.ts +1 -0
  11. package/dist/content/harnesses-doc.js +95 -0
  12. package/dist/content/hook-events.d.ts +4 -0
  13. package/dist/content/hook-events.js +42 -0
  14. package/dist/content/hooks.js +81 -11
  15. package/dist/content/meta-skill.d.ts +0 -8
  16. package/dist/content/meta-skill.js +51 -341
  17. package/dist/content/next-command.js +2 -1
  18. package/dist/content/protocols.d.ts +7 -0
  19. package/dist/content/protocols.js +123 -0
  20. package/dist/content/research-playbooks.d.ts +8 -0
  21. package/dist/content/research-playbooks.js +135 -0
  22. package/dist/content/skills.js +202 -312
  23. package/dist/content/stage-common-guidance.d.ts +2 -0
  24. package/dist/content/stage-common-guidance.js +71 -0
  25. package/dist/content/stage-schema.d.ts +11 -1
  26. package/dist/content/stage-schema.js +155 -52
  27. package/dist/content/start-command.js +19 -13
  28. package/dist/content/subagents.d.ts +1 -1
  29. package/dist/content/subagents.js +23 -38
  30. package/dist/content/templates.d.ts +1 -1
  31. package/dist/content/templates.js +49 -11
  32. package/dist/delegation.d.ts +1 -0
  33. package/dist/delegation.js +27 -1
  34. package/dist/doctor-registry.d.ts +8 -0
  35. package/dist/doctor-registry.js +127 -0
  36. package/dist/doctor.d.ts +5 -0
  37. package/dist/doctor.js +133 -27
  38. package/dist/flow-state.d.ts +4 -0
  39. package/dist/flow-state.js +4 -1
  40. package/dist/gate-evidence.d.ts +9 -1
  41. package/dist/gate-evidence.js +121 -17
  42. package/dist/harness-adapters.d.ts +7 -0
  43. package/dist/harness-adapters.js +53 -9
  44. package/dist/init-detect.d.ts +2 -0
  45. package/dist/init-detect.js +45 -0
  46. package/dist/install.js +73 -1
  47. package/dist/policy.js +21 -13
  48. package/dist/runs.js +21 -4
  49. package/dist/track-heuristics.d.ts +12 -0
  50. package/dist/track-heuristics.js +144 -0
  51. package/dist/types.d.ts +26 -3
  52. package/dist/types.js +6 -3
  53. package/package.json +2 -1
  54. package/dist/content/agents.d.ts +0 -48
  55. package/dist/content/agents.js +0 -411
@@ -0,0 +1,71 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ export const STAGE_COMMON_GUIDANCE_REL_PATH = `${RUNTIME_ROOT}/references/stages/common-guidance.md`;
3
+ export function stageCommonGuidanceMarkdown() {
4
+ return `# Common Stage Guidance
5
+
6
+ Shared guidance loaded by every stage skill. Keep this file concise and stable so
7
+ per-stage skills can stay focused on stage-specific work.
8
+
9
+ ## Shared completion protocol
10
+
11
+ - Stage-specific skills expose **Completion Parameters** only.
12
+ - Generic execution steps live in \`.cclaw/references/protocols/completion.md\`.
13
+ - Do not restate the protocol in each stage file.
14
+
15
+ ## Shared decision protocol
16
+
17
+ - Decision wording, ask-tool format, retry budget, and escalation rules live in
18
+ \`.cclaw/references/protocols/decision.md\`.
19
+ - Stage files should reference that path, not duplicate the full text.
20
+
21
+ ## Shared handoff menu
22
+
23
+ Use this same closeout menu for every stage:
24
+
25
+ - **A) Advance** — run \`/cc-next\` and continue.
26
+ - **B) Revise this stage** — stay on current stage and apply feedback.
27
+ - **C) Pause / park** — stop now and resume later.
28
+ - **D) Rewind** — move to a prior stage explicitly chosen by the user.
29
+ - **E) Abandon** — cancel this flow; artifacts remain on disk.
30
+
31
+ Recommendation defaults:
32
+
33
+ - Completion status \`DONE\` -> recommend **A**.
34
+ - Completion status \`DONE_WITH_CONCERNS\` -> recommend **B**.
35
+ - Completion status \`BLOCKED\` -> recommend **B** or **C**.
36
+
37
+ ## Completion status vocabulary
38
+
39
+ - \`DONE\` — all required gates and checks satisfied.
40
+ - \`DONE_WITH_CONCERNS\` — required gates pass, but recommended items remain.
41
+ - \`BLOCKED\` — one or more required/triggered conditions fail.
42
+
43
+ ## Decision record template
44
+
45
+ Use when a stage makes a non-trivial architecture/scope/testing decision.
46
+
47
+ \`\`\`
48
+ Decision: <one-line title>
49
+ Context: <what forced this decision>
50
+ Options considered:
51
+ - A: ...
52
+ - B: ...
53
+ Chosen option: <A/B/...>
54
+ Why: <short rationale>
55
+ Risk: <main downside>
56
+ Rollback / fallback: <if decision proves wrong>
57
+ \`\`\`
58
+
59
+ ## Self-improvement reminder
60
+
61
+ If a reusable lesson appears during the stage, append one strict-schema JSONL
62
+ entry via \`/cc-learn add\`. Do not keep operational lessons only in chat.
63
+
64
+ ## Progressive disclosure baseline
65
+
66
+ - Start with the current stage skill.
67
+ - Load deeper references only when required by a blocker or gate.
68
+ - Prefer \`.cclaw/references/stages/<stage>-examples.md\` and protocol files over
69
+ copying large instruction blocks into stage skills.
70
+ `;
71
+ }
@@ -2,6 +2,9 @@ import type { FlowStage, TransitionRule } from "../types.js";
2
2
  export interface StageGate {
3
3
  id: string;
4
4
  description: string;
5
+ tier?: "required" | "recommended" | "conditional";
6
+ /** Used when tier=conditional. Predicate syntax mirrors conditional delegation rules. */
7
+ condition?: string;
5
8
  }
6
9
  export interface StageRationalization {
7
10
  claim: string;
@@ -24,10 +27,13 @@ export interface CrossStageTrace {
24
27
  export interface ArtifactValidation {
25
28
  section: string;
26
29
  required: boolean;
30
+ tier?: "required" | "recommended" | "conditional";
31
+ /** Optional predicate for conditional validations. */
32
+ condition?: string;
27
33
  validationRule: string;
28
34
  }
29
35
  export interface StageAutoSubagentDispatch {
30
- agent: "planner" | "spec-reviewer" | "code-reviewer" | "security-reviewer" | "test-author" | "doc-updater" | "repo-research-analyst" | "learnings-researcher" | "framework-docs-researcher" | "best-practices-researcher" | "git-history-analyzer";
36
+ agent: "planner" | "reviewer" | "security-reviewer" | "test-author" | "doc-updater";
31
37
  /**
32
38
  * - `mandatory` — must be dispatched (or explicitly waived) before stage transition.
33
39
  * - `proactive` — should be dispatched automatically when context matches `when`.
@@ -75,6 +81,8 @@ export interface StageSchema {
75
81
  requiredEvidence: string[];
76
82
  inputs: string[];
77
83
  requiredContext: string[];
84
+ /** In-thread research procedures for this stage (`.cclaw/skills/research/*.md`). */
85
+ researchPlaybooks?: string[];
78
86
  outputs: string[];
79
87
  blockers: string[];
80
88
  exitCriteria: string[];
@@ -106,6 +114,8 @@ export declare function conditionalDispatchesForStage(stage: FlowStage): StageAu
106
114
  export declare function stageSchema(stage: FlowStage): StageSchema;
107
115
  export declare function orderedStageSchemas(): StageSchema[];
108
116
  export declare function stageGateIds(stage: FlowStage): string[];
117
+ export declare function stageRecommendedGateIds(stage: FlowStage): string[];
118
+ export declare function stageConditionalGateIds(stage: FlowStage): string[];
109
119
  export declare function nextCclawCommand(stage: FlowStage): string;
110
120
  export declare function buildTransitionRules(): TransitionRule[];
111
121
  export declare function stagePolicyNeedles(stage: FlowStage): string[];
@@ -1,4 +1,122 @@
1
1
  import { COMMAND_FILE_ORDER } from "../constants.js";
2
+ /**
3
+ * Gate tiers:
4
+ * - required: blocking for stage completion.
5
+ * - recommended: quality signal; unmet -> DONE_WITH_CONCERNS, not BLOCKED.
6
+ * - conditional: becomes blocking only when triggered.
7
+ */
8
+ const REQUIRED_GATE_IDS = {
9
+ brainstorm: [
10
+ "brainstorm_approaches_compared",
11
+ "brainstorm_direction_approved",
12
+ "brainstorm_artifact_reviewed"
13
+ ],
14
+ scope: [
15
+ "scope_mode_selected",
16
+ "scope_contract_written",
17
+ "scope_user_approved"
18
+ ],
19
+ design: [
20
+ "design_architecture_locked",
21
+ "design_data_flow_mapped",
22
+ "design_failure_modes_mapped",
23
+ "design_test_and_perf_defined"
24
+ ],
25
+ spec: [
26
+ "spec_acceptance_measurable",
27
+ "spec_testability_confirmed",
28
+ "spec_user_approved"
29
+ ],
30
+ plan: [
31
+ "plan_tasks_sliced_2_5_min",
32
+ "plan_dependency_waves_defined",
33
+ "plan_acceptance_mapped",
34
+ "plan_wait_for_confirm"
35
+ ],
36
+ tdd: [
37
+ "tdd_red_test_written",
38
+ "tdd_green_full_suite",
39
+ "tdd_refactor_completed",
40
+ "tdd_traceable_to_plan"
41
+ ],
42
+ review: [
43
+ "review_layer1_spec_compliance",
44
+ "review_layer2_security",
45
+ "review_criticals_resolved",
46
+ "review_army_json_valid"
47
+ ],
48
+ ship: [
49
+ "ship_review_verdict_valid",
50
+ "ship_preflight_passed",
51
+ "ship_rollback_plan_ready",
52
+ "ship_finalization_executed"
53
+ ]
54
+ };
55
+ const CONDITIONAL_GATE_RULES = {
56
+ review: {
57
+ review_security_audit_swept: "diff_lines_gt:100||files_touched_gt:10||trust_boundary_changed"
58
+ },
59
+ ship: {
60
+ ship_post_merge_tests: "files_touched_gt:10||release_blast_radius_high"
61
+ }
62
+ };
63
+ const REQUIRED_ARTIFACT_SECTIONS = {
64
+ brainstorm: ["Context", "Problem", "Approaches", "Selected Direction"],
65
+ scope: ["Scope Mode", "In Scope / Out of Scope", "Completion Dashboard", "Scope Summary"],
66
+ design: ["Architecture Boundaries", "Architecture Diagram", "Failure Mode Table", "Completion Dashboard"],
67
+ spec: ["Acceptance Criteria", "Edge Cases", "Testability Map", "Approval"],
68
+ plan: ["Task List", "Dependency Waves", "Acceptance Mapping", "WAIT_FOR_CONFIRM"],
69
+ tdd: ["RED Evidence", "GREEN Evidence", "REFACTOR Notes", "Traceability"],
70
+ review: ["Layer 1 Verdict", "Review Army Contract", "Severity Summary", "Final Verdict"],
71
+ ship: ["Preflight Results", "Release Notes", "Rollback Plan", "Finalization"]
72
+ };
73
+ const CONDITIONAL_ARTIFACT_RULES = {
74
+ review: {
75
+ "Review Readiness Dashboard": "diff_lines_gt:100||files_touched_gt:10||trust_boundary_changed"
76
+ },
77
+ ship: {
78
+ Monitoring: "release_blast_radius_high"
79
+ }
80
+ };
81
+ function tieredStageGates(stage, gates) {
82
+ const requiredSet = new Set(REQUIRED_GATE_IDS[stage]);
83
+ const conditional = CONDITIONAL_GATE_RULES[stage] ?? {};
84
+ return gates.map((gate) => {
85
+ const condition = conditional[gate.id];
86
+ if (condition) {
87
+ return {
88
+ ...gate,
89
+ tier: "conditional",
90
+ condition
91
+ };
92
+ }
93
+ return {
94
+ ...gate,
95
+ tier: requiredSet.has(gate.id) ? "required" : "recommended"
96
+ };
97
+ });
98
+ }
99
+ function tieredArtifactValidation(stage, rows) {
100
+ const requiredSections = new Set(REQUIRED_ARTIFACT_SECTIONS[stage]);
101
+ const conditional = CONDITIONAL_ARTIFACT_RULES[stage] ?? {};
102
+ return rows.map((row) => {
103
+ const condition = conditional[row.section];
104
+ if (condition) {
105
+ return {
106
+ ...row,
107
+ tier: "conditional",
108
+ condition,
109
+ required: false
110
+ };
111
+ }
112
+ const required = requiredSections.has(row.section);
113
+ return {
114
+ ...row,
115
+ tier: required ? "required" : "recommended",
116
+ required
117
+ };
118
+ });
119
+ }
2
120
  const BRAINSTORM = {
3
121
  stage: "brainstorm",
4
122
  skillFolder: "brainstorming",
@@ -72,6 +190,10 @@ const BRAINSTORM = {
72
190
  "current behavior of affected area",
73
191
  "business and delivery constraints"
74
192
  ],
193
+ researchPlaybooks: [
194
+ "research/repo-scan.md",
195
+ "research/learnings-lookup.md"
196
+ ],
75
197
  outputs: [
76
198
  "approved design direction",
77
199
  "alternatives with trade-offs",
@@ -221,6 +343,9 @@ const SCOPE = {
221
343
  "existing capabilities and reusable components",
222
344
  "delivery deadlines and risk tolerance"
223
345
  ],
346
+ researchPlaybooks: [
347
+ "research/git-history.md"
348
+ ],
224
349
  outputs: ["scope mode decision", "scope contract", "discretion areas list", "deferred scope list", "scope summary", "scope completion dashboard"],
225
350
  blockers: [
226
351
  "scope mode not selected",
@@ -435,6 +560,10 @@ const DESIGN = {
435
560
  "operational constraints",
436
561
  "security and reliability expectations"
437
562
  ],
563
+ researchPlaybooks: [
564
+ "research/framework-docs-lookup.md",
565
+ "research/best-practices-lookup.md"
566
+ ],
438
567
  outputs: [
439
568
  "architecture lock",
440
569
  "risk and failure map",
@@ -1148,7 +1277,7 @@ const REVIEW = {
1148
1277
  checklist: [
1149
1278
  "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.",
1150
1279
  "Change-Size Check — ~100 lines = normal. ~300 lines = consider splitting. ~1000+ lines = strongly recommend stacked PRs. Flag large diffs to the user.",
1151
- "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 code-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).",
1280
+ "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).",
1152
1281
  "Load upstream evidence — read TDD artifact (RED + GREEN + REFACTOR), spec, and plan. Verify evidence chain is unbroken.",
1153
1282
  "Layer 1: Spec Compliance — check every acceptance criterion against implementation. Verdict: pass/fail per criterion.",
1154
1283
  "Layer 2a: Correctness — logic errors, race conditions, boundary violations, null handling.",
@@ -1524,20 +1653,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1524
1653
  when: "When request is ambiguous, multi-surface, or spans multiple modules.",
1525
1654
  purpose: "Map scope and alternatives before direction lock.",
1526
1655
  requiresUserGate: false
1527
- },
1528
- {
1529
- agent: "repo-research-analyst",
1530
- mode: "proactive",
1531
- when: "When the user's idea touches an unfamiliar module, stack, or integration surface.",
1532
- purpose: "Parallel fan-out: summarise existing code paths, tech stack, and similar features already present — feeds the alternatives list.",
1533
- requiresUserGate: false
1534
- },
1535
- {
1536
- agent: "learnings-researcher",
1537
- mode: "proactive",
1538
- when: "On every non-trivial brainstorm where `.cclaw/knowledge.jsonl` has entries.",
1539
- purpose: "Surface prior learnings and anti-patterns that apply to the current task before direction lock.",
1540
- requiresUserGate: false
1541
1656
  }
1542
1657
  ],
1543
1658
  scope: [
@@ -1547,13 +1662,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1547
1662
  when: "Always during scope shaping.",
1548
1663
  purpose: "Challenge premise, map alternatives, and produce explicit in/out contract.",
1549
1664
  requiresUserGate: false
1550
- },
1551
- {
1552
- agent: "git-history-analyzer",
1553
- mode: "proactive",
1554
- when: "When scope touches modules with churn, recent regressions, or unclear ownership.",
1555
- purpose: "Read recent commits, PRs, and issue references for the affected paths before scope lock.",
1556
- requiresUserGate: false
1557
1665
  }
1558
1666
  ],
1559
1667
  design: [
@@ -1570,20 +1678,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1570
1678
  when: "When trust boundaries, auth, secrets, or external inputs are involved.",
1571
1679
  purpose: "Catch design-level security risks before implementation.",
1572
1680
  requiresUserGate: false
1573
- },
1574
- {
1575
- agent: "framework-docs-researcher",
1576
- mode: "proactive",
1577
- when: "When a specific framework/library version is detected and a non-trivial API is in play.",
1578
- purpose: "Retrieve version-specific docs + migration notes so the design does not rely on stale training priors.",
1579
- requiresUserGate: false
1580
- },
1581
- {
1582
- agent: "best-practices-researcher",
1583
- mode: "conditional",
1584
- when: "When the user flags a quality axis (performance, accessibility, reliability) as primary.",
1585
- purpose: "Pull domain best-practices and contrast them with the current design choice.",
1586
- requiresUserGate: false
1587
1681
  }
1588
1682
  ],
1589
1683
  spec: [
@@ -1595,7 +1689,7 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1595
1689
  requiresUserGate: false
1596
1690
  },
1597
1691
  {
1598
- agent: "spec-reviewer",
1692
+ agent: "reviewer",
1599
1693
  mode: "proactive",
1600
1694
  when: "When acceptance criteria and edge cases are drafted and need independent validation before plan stage.",
1601
1695
  purpose: "Independent review of spec against measurability, testability, and completeness before locking the contract for plan.",
@@ -1629,17 +1723,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1629
1723
  ],
1630
1724
  review: [
1631
1725
  {
1632
- agent: "spec-reviewer",
1633
- mode: "mandatory",
1634
- when: "Always in review stage.",
1635
- purpose: "Verify implementation against acceptance criteria with file evidence.",
1636
- requiresUserGate: false
1637
- },
1638
- {
1639
- agent: "code-reviewer",
1726
+ agent: "reviewer",
1640
1727
  mode: "mandatory",
1641
1728
  when: "Always in review stage.",
1642
- purpose: "Assess correctness, maintainability, architecture, and ship risk.",
1729
+ purpose: "Run spec compliance and code-quality passes with file evidence.",
1643
1730
  requiresUserGate: false
1644
1731
  },
1645
1732
  {
@@ -1651,10 +1738,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1651
1738
  skill: "security-audit"
1652
1739
  },
1653
1740
  {
1654
- agent: "code-reviewer",
1741
+ agent: "reviewer",
1655
1742
  mode: "conditional",
1656
1743
  condition: "diff_lines_gt:100||files_touched_gt:10||trust_boundary_changed",
1657
- when: "When the diff exceeds 100 changed lines, touches more than 10 files, or modifies trust boundaries — dispatch a SECOND, independent code-reviewer with the adversarial-review skill loaded so the review army has at least two voices on a high-blast-radius change.",
1744
+ when: "When the diff exceeds 100 changed lines, touches more than 10 files, or modifies trust boundaries — dispatch a SECOND, independent reviewer with the adversarial-review skill loaded so the review army has at least two voices on a high-blast-radius change.",
1658
1745
  purpose: "Adversarial second-opinion review on large or trust-sensitive diffs. The second reviewer treats the implementation as hostile and tries to break it (hostile-user, future-maintainer, competitor lenses) instead of sympathetically explaining it.",
1659
1746
  requiresUserGate: false,
1660
1747
  skill: "adversarial-review"
@@ -1669,10 +1756,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1669
1756
  requiresUserGate: false
1670
1757
  },
1671
1758
  {
1672
- agent: "code-reviewer",
1759
+ agent: "security-reviewer",
1673
1760
  mode: "proactive",
1674
- when: "When release involves broad blast radius or unresolved concerns.",
1675
- purpose: "Provide final integration-scale quality pass.",
1761
+ when: "When release involves broad blast radius, trust-boundary movement, or unresolved security concerns.",
1762
+ purpose: "Provide final exploitability check before release finalization.",
1676
1763
  requiresUserGate: false
1677
1764
  }
1678
1765
  ]
@@ -1689,8 +1776,12 @@ export function conditionalDispatchesForStage(stage) {
1689
1776
  }
1690
1777
  export function stageSchema(stage) {
1691
1778
  const base = STAGE_SCHEMA_MAP[stage];
1779
+ const tieredGates = tieredStageGates(stage, base.requiredGates);
1780
+ const tieredValidation = tieredArtifactValidation(stage, base.artifactValidation);
1692
1781
  return {
1693
1782
  ...base,
1783
+ requiredGates: tieredGates,
1784
+ artifactValidation: tieredValidation,
1694
1785
  mandatoryDelegations: mandatoryDelegationsForStage(stage)
1695
1786
  };
1696
1787
  }
@@ -1698,7 +1789,19 @@ export function orderedStageSchemas() {
1698
1789
  return COMMAND_FILE_ORDER.map((stage) => stageSchema(stage));
1699
1790
  }
1700
1791
  export function stageGateIds(stage) {
1701
- return stageSchema(stage).requiredGates.map((gate) => gate.id);
1792
+ return stageSchema(stage).requiredGates
1793
+ .filter((gate) => gate.tier === "required")
1794
+ .map((gate) => gate.id);
1795
+ }
1796
+ export function stageRecommendedGateIds(stage) {
1797
+ return stageSchema(stage).requiredGates
1798
+ .filter((gate) => gate.tier === "recommended")
1799
+ .map((gate) => gate.id);
1800
+ }
1801
+ export function stageConditionalGateIds(stage) {
1802
+ return stageSchema(stage).requiredGates
1803
+ .filter((gate) => gate.tier === "conditional")
1804
+ .map((gate) => gate.id);
1702
1805
  }
1703
1806
  export function nextCclawCommand(stage) {
1704
1807
  const next = stageSchema(stage).next;
@@ -25,7 +25,7 @@ This is the **recommended way to start** working with cclaw. Use \`/cc-next\` fo
25
25
  ## HARD-GATE
26
26
 
27
27
  - **Do not** skip reading \`${flowPath}\` — always check current state before acting.
28
- - **Do not** start implementation stages directly from \`/cc <prompt>\` — always begin at the first stage of the resolved track (brainstorm for standard, spec for quick).
28
+ - **Do not** start implementation stages directly from \`/cc <prompt>\` — always begin at the first stage of the resolved track (brainstorm for medium/standard, spec for quick).
29
29
  - **Do not** start a stage pipeline for a task that is not a software change (pure question, non-software task, conversation).
30
30
 
31
31
  ## Algorithm
@@ -40,6 +40,7 @@ This is the **recommended way to start** working with cclaw. Use \`/cc-next\` fo
40
40
  | **pure-question** | "how does X work?", "explain Y", "what are the trade-offs of Z?" | Answer directly, do NOT open a stage. |
41
41
  | **trivial** | typo, one-liner, rename, config tweak, copy change, version bump with zero behavior change | Fast-path: skip \`brainstorm\` and \`scope\`, seed \`00-idea.md\`, move straight to \`design\` or \`spec\` depending on whether an interface change is involved. |
42
42
  | **software — bug fix with repro** | regression / hotfix / named symptom + repro steps | Fast-path: set track to \`quick\`, seed \`04-spec.md\` with the reproduction, enter \`tdd\` with a RED reproduction test first. |
43
+ | **software — medium** | additive feature following existing architecture | medium track (\`brainstorm → spec → plan → tdd → review → ship\`). |
43
44
  | **software — standard** | feature, refactor, migration, integration, architecture change | Full 8-stage flow starting at \`brainstorm\`. |
44
45
 
45
46
  Record the chosen class in \`.cclaw/artifacts/00-idea.md\` on the \`Class:\` line. Do NOT silently treat a non-software task as software.
@@ -63,20 +64,23 @@ This is the **recommended way to start** working with cclaw. Use \`/cc-next\` fo
63
64
  4. Read \`${flowPath}\`.
64
65
  5. If flow already has completed stages beyond brainstorm, warn the user that starting a new brainstorm will reset progress. Ask for confirmation before proceeding.
65
66
  6. **Track heuristic** — classify the idea text and **recommend** a track (the user can override before any state mutation):
67
+ - First, load \`${RUNTIME_ROOT}/config.yaml\`. If \`trackHeuristics\` is defined, apply those per-track rules (\`priority\`, \`fallback\`, \`tracks.<id>.{triggers,patterns,veto}\`) before built-in defaults.
66
68
  - **quick** (\`spec → tdd → review → ship\`) — single-purpose work where the spec is essentially already known.
67
69
  Triggers (case-insensitive substring or close variant): \`bug\`, \`bugfix\`, \`fix\`, \`hotfix\`, \`patch\`, \`typo\`, \`regression\`, \`copy change\`, \`rename\`, \`bump\`, \`upgrade dep\`, \`config tweak\`, \`docs only\`, \`comment\`, \`lint\`, \`format\`, \`small\`, \`tiny\`, \`one-liner\`, \`revert\`.
68
- - **standard** (full 8 stages default) — anything that introduces a new capability, touches multiple modules, or has unclear scope.
69
- Triggers: \`new feature\`, \`add\`, \`build\`, \`design\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`endpoint\`, \`schema\`, \`api\`, \`integrate\`, \`workflow\`, \`onboarding\`, or any prompt that does not match quick triggers.
70
- - When triggers conflict (e.g. "small refactor that touches 5 modules") prefer **standard** quick is opt-in and only safe when scope is genuinely tiny.
70
+ - **medium** (\`brainstorm spec plan → tdd → review → ship\`) — additive work that fits existing architecture and still needs product framing.
71
+ Triggers: \`add endpoint\`, \`add field\`, \`extend existing\`, \`wire integration\`, \`small migration\`, \`new screen following existing patterns\`.
72
+ - **standard** (full 8 stages default fallback) anything that introduces a new capability with architecture uncertainty, touches many modules, or has unclear scope.
73
+ Triggers: \`new feature\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`schema\`, \`integrate\`, \`workflow\`, \`onboarding\`, or any prompt that does not match quick/medium confidently.
74
+ - When triggers conflict, prefer **standard** over **medium**, and **medium** over **quick**.
71
75
  7. Present the recommendation as a single decision with explicit options:
72
- > \`Recommended track: <quick|standard>\` because \`<one-line reason citing matched triggers>\`.
73
- > Override? (A) keep \`<recommended>\` (B) switch to \`<other>\` (C) cancel.
76
+ > \`Recommended track: <quick|medium|standard>\` because \`<one-line reason citing matched triggers>\`.
77
+ > Override? (A) keep \`<recommended>\` (B) switch track (C) cancel.
74
78
  If \`AskQuestion\`/\`AskUserQuestion\` is available, send exactly ONE question; on schema error, fall back to plain text.
75
- 8. Persist the chosen track to \`${flowPath}\` (\`track\` field). Compute \`skippedStages\` from the track and write that too. Use the **first stage of the chosen track** as \`currentStage\` (quick → \`spec\`, standard → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\` per Phase 0).
79
+ 8. Persist the chosen track to \`${flowPath}\` (\`track\` field). Compute \`skippedStages\` from the track and write that too. Use the **first stage of the chosen track** as \`currentStage\` (quick → \`spec\`, medium/standard → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\` per Phase 0).
76
80
  9. Write the prompt to \`.cclaw/artifacts/00-idea.md\` with the following header lines: \`Class:\` (from Phase 0), \`Track:\` (chosen track + matched heuristic), \`Stack:\` (from Phase 2 detection, or \`unknown\`), and a \`Discovered context\` section if Phase 1 found origin docs.
77
81
  10. Load the **first-stage skill for the chosen track** and its command file:
78
82
  - quick → \`.cclaw/skills/specification-authoring/SKILL.md\` + \`.cclaw/commands/spec.md\`
79
- - standard → \`.cclaw/skills/brainstorming/SKILL.md\` + \`.cclaw/commands/brainstorm.md\`
83
+ - medium/standard → \`.cclaw/skills/brainstorming/SKILL.md\` + \`.cclaw/commands/brainstorm.md\`
80
84
  - trivial fast-path → design or spec skill per Phase 0 decision.
81
85
  11. Execute that stage with the prompt + Phase 1/Phase 2 context as initial input.
82
86
 
@@ -136,19 +140,21 @@ Do **not** silently discard an existing flow when the user provides a prompt. If
136
140
  - Ask: "Continue with reset? (A) Yes, start fresh (B) No, resume current flow"
137
141
  - If (B) → switch to Path B behavior.
138
142
  6. **Classify the idea** using the heuristic below and present a single track recommendation. Wait for explicit confirmation or override before mutating any state.
143
+ - If \`${RUNTIME_ROOT}/config.yaml\` defines \`trackHeuristics\`, apply that override first (priority/fallback/rules), then use built-in defaults only as fallback.
139
144
 
140
145
  **Track heuristic** (lowercase substring match against the user prompt):
141
146
 
142
147
  | Track | Triggers | Use when |
143
148
  |---|---|---|
144
149
  | \`quick\` | \`bug\`, \`bugfix\`, \`fix\`, \`hotfix\`, \`patch\`, \`typo\`, \`regression\`, \`rename\`, \`bump\`, \`upgrade dep\`, \`docs only\`, \`comment\`, \`lint\`, \`format\`, \`small\`, \`tiny\`, \`one-liner\`, \`revert\`, \`copy change\` | Single-purpose, spec is essentially known, low blast radius |
145
- | \`standard\` | \`new feature\`, \`add\`, \`build\`, \`design\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`endpoint\`, \`schema\`, \`api\`, \`integrate\`, \`workflow\`, \`onboarding\` (or no quick trigger matched) | Anything new, multi-module, or unclear scope |
150
+ | \`medium\` | \`add endpoint\`, \`add field\`, \`extend existing\`, \`wire integration\`, \`small migration\`, \`new screen following existing pattern\` | Additive work with existing architecture |
151
+ | \`standard\` | \`new feature\`, \`build\`, \`design\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`schema\`, \`api\`, \`integrate\`, \`workflow\`, \`onboarding\` (or no confident quick/medium match) | New or uncertain multi-module work |
146
152
 
147
- - On conflict, prefer \`standard\` (quick is opt-in for genuinely tiny work).
148
- - Always state the recommendation as a one-line reason citing the matched trigger.
149
- 7. Persist the chosen track in \`${flowPath}\` (\`track\` + \`skippedStages\`). Set \`currentStage\` to the first stage of the chosen track (\`quick\` → \`spec\`, \`standard\` → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\`). Reset gate catalog.
153
+ - On conflict, prefer \`standard\` over \`medium\`, and \`medium\` over \`quick\`.
154
+ - Always state the recommendation as a one-line reason citing matched triggers.
155
+ 7. Persist the chosen track in \`${flowPath}\` (\`track\` + \`skippedStages\`). Set \`currentStage\` to the first stage of the chosen track (\`quick\` → \`spec\`, \`medium\`/ \`standard\` → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\`). Reset gate catalog.
150
156
  8. Write \`${RUNTIME_ROOT}/artifacts/00-idea.md\` with the user's prompt plus header lines: \`Class:\`, \`Track:\`, \`Stack:\`, and a \`Discovered context\` section from Phase 1.
151
- 9. Load and execute the **first stage skill of the chosen track** (\`brainstorming\` for standard, \`specification-authoring\` for quick) plus its matching command file.
157
+ 9. Load and execute the **first stage skill of the chosen track** (\`brainstorming\` for medium/standard, \`specification-authoring\` for quick) plus its matching command file.
152
158
 
153
159
  ### Reclassification on discovery
154
160
 
@@ -7,7 +7,7 @@ export declare function subagentDrivenDevSkill(): string;
7
7
  export declare function parallelAgentsSkill(): string;
8
8
  /**
9
9
  * Returns markdown fragments augmenting each specialist persona with Task tool
10
- * delegation guidance. Combine with the existing `body` field from `agents.ts`.
10
+ * delegation guidance. Combine with the existing `body` field from `core-agents.ts`.
11
11
  */
12
12
  export declare function enhancedAgentBody(agentName: string): string;
13
13
  export declare function subagentsAgentsMdBlock(): string;