cclaw-cli 0.11.0 → 0.13.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 (67) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.d.ts +8 -0
  3. package/dist/cli.js +311 -10
  4. package/dist/config.js +19 -0
  5. package/dist/constants.d.ts +2 -2
  6. package/dist/constants.js +13 -1
  7. package/dist/content/core-agents.d.ts +44 -0
  8. package/dist/content/core-agents.js +225 -0
  9. package/dist/content/diff-command.d.ts +2 -0
  10. package/dist/content/diff-command.js +83 -0
  11. package/dist/content/doctor-references.d.ts +2 -0
  12. package/dist/content/doctor-references.js +144 -0
  13. package/dist/content/examples.js +1 -1
  14. package/dist/content/feature-command.d.ts +2 -0
  15. package/dist/content/feature-command.js +120 -0
  16. package/dist/content/harnesses-doc.d.ts +1 -0
  17. package/dist/content/harnesses-doc.js +103 -0
  18. package/dist/content/hook-events.d.ts +4 -0
  19. package/dist/content/hook-events.js +42 -0
  20. package/dist/content/hooks.js +47 -1
  21. package/dist/content/meta-skill.js +3 -2
  22. package/dist/content/next-command.js +8 -6
  23. package/dist/content/observe.d.ts +5 -1
  24. package/dist/content/observe.js +134 -2
  25. package/dist/content/protocols.js +34 -6
  26. package/dist/content/research-playbooks.d.ts +8 -0
  27. package/dist/content/research-playbooks.js +135 -0
  28. package/dist/content/retro-command.d.ts +2 -0
  29. package/dist/content/retro-command.js +77 -0
  30. package/dist/content/rewind-command.d.ts +3 -0
  31. package/dist/content/rewind-command.js +120 -0
  32. package/dist/content/skills.js +20 -0
  33. package/dist/content/stage-schema.d.ts +3 -1
  34. package/dist/content/stage-schema.js +20 -51
  35. package/dist/content/status-command.js +43 -35
  36. package/dist/content/subagents.d.ts +1 -1
  37. package/dist/content/subagents.js +23 -38
  38. package/dist/content/tdd-log-command.d.ts +2 -0
  39. package/dist/content/tdd-log-command.js +75 -0
  40. package/dist/content/templates.d.ts +1 -1
  41. package/dist/content/templates.js +84 -16
  42. package/dist/content/tree-command.d.ts +2 -0
  43. package/dist/content/tree-command.js +91 -0
  44. package/dist/delegation.d.ts +1 -0
  45. package/dist/delegation.js +27 -1
  46. package/dist/doctor-registry.d.ts +8 -0
  47. package/dist/doctor-registry.js +127 -0
  48. package/dist/doctor.d.ts +5 -0
  49. package/dist/doctor.js +261 -7
  50. package/dist/feature-system.d.ts +18 -0
  51. package/dist/feature-system.js +247 -0
  52. package/dist/flow-state.d.ts +25 -0
  53. package/dist/flow-state.js +8 -1
  54. package/dist/harness-adapters.d.ts +7 -0
  55. package/dist/harness-adapters.js +127 -13
  56. package/dist/init-detect.d.ts +2 -0
  57. package/dist/init-detect.js +45 -0
  58. package/dist/install.js +98 -3
  59. package/dist/policy.js +27 -0
  60. package/dist/runs.d.ts +33 -1
  61. package/dist/runs.js +365 -6
  62. package/dist/tdd-cycle.d.ts +22 -0
  63. package/dist/tdd-cycle.js +82 -0
  64. package/dist/types.d.ts +4 -0
  65. package/package.json +2 -1
  66. package/dist/content/agents.d.ts +0 -48
  67. package/dist/content/agents.js +0 -411
@@ -19,6 +19,9 @@ function checkpointPath() {
19
19
  function stageActivityPath() {
20
20
  return `${RUNTIME_ROOT}/state/stage-activity.jsonl`;
21
21
  }
22
+ function snapshotPath() {
23
+ return `${RUNTIME_ROOT}/state/flow-state.snapshot.json`;
24
+ }
22
25
  /**
23
26
  * Command contract for /cc-status — a read-only snapshot command.
24
27
  * Does not mutate state. Always safe to run.
@@ -30,8 +33,8 @@ export function statusCommandContract() {
30
33
 
31
34
  ## Purpose
32
35
 
33
- **Read-only snapshot of the cclaw run.** Shows track, current stage, completed stages,
34
- gate coverage, mandatory delegations, and the top 3 knowledge highlights.
36
+ **Read-only visual snapshot of the cclaw run.** Shows progress bar, current stage,
37
+ gate coverage, delegation status, stale markers, and top knowledge highlights.
35
38
 
36
39
  This command **never mutates state**. Use it at session start to orient, or at any
37
40
  time to answer "where are we?" without advancing the flow.
@@ -41,6 +44,7 @@ time to answer "where are we?" without advancing the flow.
41
44
  - **Do not** use \`/cc-status\` output to infer gate completion for decisions — cite
42
45
  artifact evidence via \`/cc-next\` when advancing.
43
46
  - **Do not** mutate \`${flowPath}\` or delegation log from this command.
47
+ - **Do not** rewrite \`${snapshotPath()}\` from this command (use \`/cc-diff\`).
44
48
 
45
49
  ## Algorithm
46
50
 
@@ -54,38 +58,32 @@ time to answer "where are we?" without advancing the flow.
54
58
  - Otherwise scan \`${stageActivityPath()}\` from the end for the first entry whose \`stage\` matches \`currentStage\` and use its \`ts\`.
55
59
  - Compute the duration as \`now - signalTimestamp\` and render compactly: \`<X>m\`, \`<X>h<Y>m\`, or \`<X>d<Y>h\`.
56
60
  - If no signal exists, render \`(unknown)\`.
57
- 5. Read the top of **\`${knowledgePath}\`** surface up to 3 most recent entries
61
+ 5. Optionally read **\`${snapshotPath()}\`** to compute gate delta versus prior baseline:
62
+ - If missing or invalid, render \`delta: (baseline unavailable; run /cc-diff)\`.
63
+ 6. Read the top of **\`${knowledgePath}\`** — surface up to 3 most recent entries
58
64
  (by trailing timestamp or source marker).
59
- 6. Emit the status block described below. Do **not** load any stage skill.
65
+ 7. Emit the visual status block described below. Do **not** load any stage skill.
66
+
67
+ ## Visual markers
68
+
69
+ Default UTF markers: \`✓\` passed, \`▶\` current, \`○\` pending, \`⊘\` skipped, \`⏸\` stale, \`✗\` blocked.
70
+ ASCII fallback (no UTF locale): \`[x]\`, \`[>]\`, \`[ ]\`, \`[-]\`, \`[=]\`, \`[!]\`.
60
71
 
61
72
  ## Status Block Format
62
73
 
63
74
  \`\`\`
64
75
  cclaw status
65
- track: <quick|standard>
66
- current stage: <stage> (<N>/<total> in track)
67
- time in stage: <Xd Yh | Yh Zm | Zm | unknown>
68
- context mode: <activeMode> (default | execution | review | incident | …)
69
- completed stages: <list or "none">
70
- skipped stages: <list or "none">
71
-
72
- gates:
73
- passed: <count> of <required>
74
- blocked: <count>
75
- unmet: <list of gate ids>
76
-
77
- delegations (current stage):
78
- required: <list>
79
- completed: <list>
80
- pending: <list>
81
-
82
- knowledge highlights:
83
- - <latest entry summary line>
84
- - <second entry summary line>
85
- - <third entry summary line>
86
-
87
- next action:
88
- /cc-next (advance or resume current stage)
76
+ flow: <track> · run=<runId> · feature=<feature-id>
77
+ stage: <stage> (<N>/<total>) · time <Xd|XhYm|Xm|unknown> · mode <activeMode>
78
+ bar: [✓ brainstorm] [✓ scope] [▶ design] [○ spec] [○ plan] [○ tdd] [○ review] [○ ship]
79
+ gates: now <passed>/<required> · blocked <count> · delta <summary or baseline-unavailable>
80
+ delegations: [✓ <role>] [○ <role>] ...
81
+ stale: <list or none>
82
+ knowledge:
83
+ - <latest entry summary>
84
+ - <second entry summary>
85
+ - <third entry summary>
86
+ next: /cc-next · /cc-tree · /cc-diff
89
87
  \`\`\`
90
88
 
91
89
  ## Anti-patterns
@@ -93,6 +91,7 @@ cclaw status
93
91
  - Inventing gate status without reading \`${flowPath}\`.
94
92
  - Reporting delegations as satisfied when the log says \`pending\`.
95
93
  - Advancing the stage from \`/cc-status\` — progression belongs to \`/cc-next\`.
94
+ - Hiding stale stages; stale markers must be surfaced directly in the status line.
96
95
 
97
96
  ## Primary skill
98
97
 
@@ -107,7 +106,7 @@ export function statusCommandSkillMarkdown() {
107
106
  const delegationPath = delegationLogPath();
108
107
  return `---
109
108
  name: ${STATUS_SKILL_NAME}
110
- description: "Read-only snapshot of the cclaw flow: track, stage, gate coverage, delegations, knowledge highlights. Never mutates state."
109
+ description: "Read-only visual snapshot of the cclaw flow with progress bar, gate delta, delegations, and stale markers."
111
110
  ---
112
111
 
113
112
  # /cc-status — Flow Status Snapshot
@@ -120,7 +119,7 @@ advancing or mutating anything. Safe to run at any point.
120
119
  ## HARD-GATE
121
120
 
122
121
  Do **not** mutate \`${flowPath}\` or \`${delegationPath}\` from this skill. This is
123
- a read-only command.
122
+ a read-only command. Do **not** update \`${snapshotPath()}\` here.
124
123
 
125
124
  ## Algorithm
126
125
 
@@ -131,19 +130,28 @@ a read-only command.
131
130
  - Prefer \`${checkpointPath()}\` when \`stage === currentStage\` and \`timestamp\` parses as ISO 8601.
132
131
  - Else scan \`${stageActivityPath()}\` from tail for the most recent entry whose \`stage === currentStage\`; use its \`ts\`.
133
132
  - Render \`<X>d<Y>h\`, \`<X>h<Y>m\`, \`<X>m\`, or \`(unknown)\`.
134
- 5. Read \`${RUNTIME_ROOT}/knowledge.jsonl\`. If missing or empty → knowledge highlights are \`(none recorded)\`. Parse each line as JSON and surface its \`trigger\`/\`action\`.
135
- 6. For each gate in \`stageGateCatalog[currentStage].required\`:
133
+ 5. Try reading \`${snapshotPath()}\` for gate delta:
134
+ - If available, compare current stage \`passed\` / \`blocked\` sets against baseline.
135
+ - If unavailable, render \`delta: (baseline unavailable; run /cc-diff)\`.
136
+ 6. Read \`${RUNTIME_ROOT}/knowledge.jsonl\`. If missing or empty → knowledge highlights are \`(none recorded)\`. Parse each line as JSON and surface its \`trigger\`/\`action\`.
137
+ 7. For each gate in \`stageGateCatalog[currentStage].required\`:
136
138
  - Satisfied if present in \`passed\` and absent from \`blocked\`.
137
- 7. Build and print the status block (see command contract for layout).
138
- 8. Suggest the next action:
139
+ 8. Build and print the visual status block:
140
+ - stage header
141
+ - one-line progress bar with per-stage markers
142
+ - gate summary + delta
143
+ - delegation row
144
+ - stale stage row
145
+ 9. Suggest the next action:
139
146
  - If current stage has unmet gates → \`/cc-next\` to resume.
140
147
  - If current stage is complete → \`/cc-next\` to advance (or report "Flow complete" if terminal).
141
148
 
142
149
  ## Output Guidelines
143
150
 
144
- - Keep output compact (≤ 25 lines) — status, not narrative.
151
+ - Keep output compact (≤ 30 lines) — status, not narrative.
145
152
  - Report counts, not full artifact contents.
146
153
  - If any data source is missing or corrupt, say so explicitly rather than guessing.
154
+ - Include \`/cc-tree\` for deep structure and \`/cc-diff\` for before/after map in the final line.
147
155
 
148
156
  ## Anti-patterns
149
157
 
@@ -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;
@@ -5,16 +5,10 @@
5
5
  */
6
6
  const SUBAGENT_AGENT_NAMES = [
7
7
  "planner",
8
- "spec-reviewer",
9
- "code-reviewer",
8
+ "reviewer",
10
9
  "security-reviewer",
11
10
  "test-author",
12
- "doc-updater",
13
- "repo-research-analyst",
14
- "learnings-researcher",
15
- "framework-docs-researcher",
16
- "best-practices-researcher",
17
- "git-history-analyzer",
11
+ "doc-updater"
18
12
  ];
19
13
  export function subagentDrivenDevSkill() {
20
14
  return `---
@@ -40,7 +34,7 @@ For cclaw flow stages, machine-only specialist work should auto-dispatch without
40
34
 
41
35
  - **design/plan:** planner
42
36
  - **tdd:** test-author
43
- - **review:** spec-reviewer + code-reviewer + security-reviewer (security-reviewer is always mandatory; produce an explicit no-change attestation when no trust boundaries moved)
37
+ - **review:** reviewer + security-reviewer (security-reviewer is always mandatory; produce an explicit no-change attestation when no trust boundaries moved)
44
38
  - **ship:** doc-updater
45
39
 
46
40
  Human input remains mandatory only at explicit approval gates (plan approval, user challenge resolution, release finalization mode).
@@ -69,8 +63,8 @@ If delegation tooling is unavailable in the active harness, run the same control
69
63
  | Tier | Use for | Example agents |
70
64
  |---|---|---|
71
65
  | \`deep\` | one heavy reasoning pass per stage (planner, final reconciliation) | planner |
72
- | \`balanced\` | spec compliance + code/security review with enough context | spec-reviewer, code-reviewer, security-reviewer, test-author |
73
- | \`fast\` | read-only research / narrow machine checks / docs updates safe to fan out | repo-research-analyst, learnings-researcher, framework-docs-researcher, best-practices-researcher, git-history-analyzer, doc-updater |
66
+ | \`balanced\` | spec compliance + code/security review with enough context | reviewer, security-reviewer, test-author |
67
+ | \`fast\` | bounded maintenance updates and doc hygiene | doc-updater |
74
68
 
75
69
  **Routing rules:**
76
70
  - At most ONE \`deep\` agent per stage (planner OR final reconciliation, not both).
@@ -84,14 +78,14 @@ Concrete per-stage rules so the controller does not have to guess which tier fit
84
78
 
85
79
  | Stage | Deep slot | Balanced slot(s) | Fast fan-out | Trigger to escalate |
86
80
  |---|---|---|---|---|
87
- | brainstorm | planner (only if ambiguity spans >1 module) | — | repo-research-analyst · learnings-researcher (2 in parallel) | promote to \`balanced\` spec-reviewer once direction locks |
88
- | scope | planner (always) | — | git-history-analyzer (if churn / recent regression on the surface) | promote to \`balanced\` planner if scope touches external contracts |
89
- | design | planner (always) | security-reviewer (if trust boundary touched) | framework-docs-researcher · best-practices-researcher (up to 2 in parallel) | escalate one specialist to \`deep\` only if a failure mode is Critical-severity |
90
- | spec | — | spec-reviewer (if spec > 200 lines or multiple ACs) | — | escalate to \`deep\` only for spec ↔ design contradictions |
81
+ | brainstorm | planner (only if ambiguity spans >1 module) | — | run in-thread research playbooks | promote to \`balanced\` reviewer once direction locks |
82
+ | scope | planner (always) | — | run \`research/git-history.md\` in-thread when churn is high | promote to \`balanced\` planner if scope touches external contracts |
83
+ | design | planner (always) | security-reviewer (if trust boundary touched) | run \`research/framework-docs-lookup.md\` + \`research/best-practices-lookup.md\` in-thread | escalate one specialist to \`deep\` only if a failure mode is Critical-severity |
84
+ | spec | — | reviewer (if spec > 200 lines or multiple ACs) | — | escalate to \`deep\` only for spec ↔ design contradictions |
91
85
  | plan | planner (solo, always) | — | — | never fan out at plan stage; one owner for dependency graph |
92
- | tdd | — | test-author (each slice) · code-reviewer (slice-local) | doc-updater (API surface changes) | escalate to \`deep\` only when a RED test cannot be expressed (design leak) |
93
- | review | — | spec-reviewer · code-reviewer · security-reviewer (all mandatory) | doc-updater + framework-docs-researcher for narrow lookups | escalate a \`balanced\` reviewer to \`deep\` only when two reviewers disagree on severity |
94
- | ship | — | | doc-updater (changelog/migration notes) | escalate to \`balanced\` code-reviewer only if preflight finds a regression |
86
+ | tdd | — | test-author (each slice) · reviewer (slice-local) | doc-updater (API surface changes) | escalate to \`deep\` only when a RED test cannot be expressed (design leak) |
87
+ | review | — | reviewer · security-reviewer (both mandatory) | doc-updater for release-note drift checks | escalate a \`balanced\` reviewer to \`deep\` only when two reviewers disagree on severity |
88
+ | ship | — | security-reviewer (if blast radius is high) | doc-updater (changelog/migration notes) | escalate to \`balanced\` reviewer only if preflight finds a regression |
95
89
 
96
90
  **De-escalation rules (avoid over-spending):**
97
91
  - If a \`deep\` planner run returns low-uncertainty output (single unambiguous plan), do **not** add a second \`deep\` pass in the same stage.
@@ -121,7 +115,7 @@ If you catch yourself writing “read PLAN.md Task 3” or “implement the next
121
115
  2. **For each task sequentially (NEVER parallel implementation subagents — file conflicts):**
122
116
  1. **Dispatch implementer subagent** with the **full task text pasted in** (not a file reference).
123
117
  2. **Check return status:** \`DONE\` / \`DONE_WITH_CONCERNS\` / \`NEEDS_CONTEXT\` / \`BLOCKED\`
124
- 3. If \`DONE\`: dispatch **spec-reviewer** subagent to verify actual code matches spec.
118
+ 3. If \`DONE\`: dispatch **reviewer** subagent to verify actual code matches spec and quality expectations.
125
119
  4. If spec review **FAIL**: dispatch **fixer subagent** (a **new** agent — not an inline patch from the parent — to avoid context pollution).
126
120
  5. Dispatch **code-quality reviewer** (maintainability/PR hygiene).
127
121
  6. **Mark task complete** only after concerns are triaged or explicitly accepted with rationale.
@@ -350,7 +344,7 @@ Write a structured reconciliation artifact at \`.cclaw/artifacts/07-review-army.
350
344
  "severity": "Critical|Important|Suggestion",
351
345
  "confidence": 1,
352
346
  "fingerprint": "hash-or-stable-key",
353
- "reportedBy": ["spec-reviewer", "code-reviewer"],
347
+ "reportedBy": ["reviewer", "security-reviewer"],
354
348
  "status": "open|accepted|resolved",
355
349
  "location": { "file": "path", "line": 123 },
356
350
  "recommendation": "..."
@@ -501,7 +495,7 @@ function specReviewerEnhancedBody() {
501
495
 
502
496
  ## Task Tool Delegation
503
497
 
504
- For spec-compliance audits, use the Task tool with the following **spec-reviewer** payload (fill placeholders in the parent session).
498
+ For review audits, use the Task tool with the following **reviewer** payload (fill placeholders in the parent session).
505
499
 
506
500
  \`\`\`
507
501
  You are a specification compliance reviewer (subagent).
@@ -544,6 +538,9 @@ Output format (mandatory):
544
538
 
545
539
  `;
546
540
  }
541
+ function reviewerEnhancedBody() {
542
+ return `${specReviewerEnhancedBody()}${codeReviewerEnhancedBody()}`;
543
+ }
547
544
  function securityReviewerEnhancedBody() {
548
545
  return `
549
546
 
@@ -603,7 +600,7 @@ function repoResearchAnalystEnhancedBody() {
603
600
 
604
601
  ## Task Tool Delegation
605
602
 
606
- Launch **read-only repo exploration** at the start of brainstorm/scope/design so the primary agent plans on a grounded map, not guesses. Run as a \`fast\` tier agent — cheap to fan out alongside learnings-researcher and best-practices-researcher.
603
+ Launch **read-only repo exploration** at the start of brainstorm/scope/design so the primary agent plans on a grounded map, not guesses. Use this as an in-thread research procedure.
607
604
 
608
605
  \`\`\`
609
606
  You are a repo research analyst subagent.
@@ -761,32 +758,20 @@ Tasks:
761
758
  }
762
759
  /**
763
760
  * Returns markdown fragments augmenting each specialist persona with Task tool
764
- * delegation guidance. Combine with the existing `body` field from `agents.ts`.
761
+ * delegation guidance. Combine with the existing `body` field from `core-agents.ts`.
765
762
  */
766
763
  export function enhancedAgentBody(agentName) {
767
764
  switch (agentName) {
768
765
  case "planner":
769
766
  return plannerEnhancedBody();
770
- case "spec-reviewer":
771
- return specReviewerEnhancedBody();
772
- case "code-reviewer":
773
- return codeReviewerEnhancedBody();
767
+ case "reviewer":
768
+ return reviewerEnhancedBody();
774
769
  case "security-reviewer":
775
770
  return securityReviewerEnhancedBody();
776
771
  case "test-author":
777
772
  return testAuthorEnhancedBody();
778
773
  case "doc-updater":
779
774
  return docUpdaterEnhancedBody();
780
- case "repo-research-analyst":
781
- return repoResearchAnalystEnhancedBody();
782
- case "learnings-researcher":
783
- return learningsResearcherEnhancedBody();
784
- case "framework-docs-researcher":
785
- return frameworkDocsResearcherEnhancedBody();
786
- case "best-practices-researcher":
787
- return bestPracticesResearcherEnhancedBody();
788
- case "git-history-analyzer":
789
- return gitHistoryAnalyzerEnhancedBody();
790
775
  default:
791
776
  return `
792
777
 
@@ -809,7 +794,7 @@ Status contract: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED.
809
794
 
810
795
  - Controller sequentially dispatches **implementer → reviewer** loops per task.
811
796
  - HARD-GATE: paste **self-contained task text**; never point subagents at plan files to “discover” scope.
812
- - **Spec fixers** are **fresh agents** after failed spec reviews — avoids parent-context pollution.
797
+ - **Review fixers** are **fresh agents** after failed review passes — avoids parent-context pollution.
813
798
  - **Machine-only flow checks auto-dispatch** by stage (design/plan/tdd/review/ship) without asking the user to trigger each specialist manually.
814
799
 
815
800
  ### Parallel Agents (\`dispatching-parallel-agents\` skill)
@@ -0,0 +1,2 @@
1
+ export declare function tddLogCommandContract(): string;
2
+ export declare function tddLogCommandSkillMarkdown(): string;
@@ -0,0 +1,75 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ const TDD_LOG_SKILL_FOLDER = "tdd-cycle-log";
3
+ const TDD_LOG_SKILL_NAME = "tdd-cycle-log";
4
+ function logPath() {
5
+ return `${RUNTIME_ROOT}/state/tdd-cycle-log.jsonl`;
6
+ }
7
+ function flowStatePath() {
8
+ return `${RUNTIME_ROOT}/state/flow-state.json`;
9
+ }
10
+ export function tddLogCommandContract() {
11
+ return `# /cc-tdd-log
12
+
13
+ ## Purpose
14
+
15
+ Record explicit RED/GREEN/REFACTOR evidence used by workflow guard and doctor checks.
16
+
17
+ ## HARD-GATE
18
+
19
+ - Every implementation write in tdd must be preceded by a logged RED event.
20
+ - Use append-only JSONL at \`${logPath()}\`; never rewrite prior lines.
21
+
22
+ ## Subcommands
23
+
24
+ - \`/cc-tdd-log red <slice> <command> [note]\`
25
+ - \`/cc-tdd-log green <slice> <command> [note]\`
26
+ - \`/cc-tdd-log refactor <slice> <command> [note]\`
27
+ - \`/cc-tdd-log show\`
28
+
29
+ ## Log Schema
30
+
31
+ Each JSON line must include:
32
+ - \`ts\` (ISO timestamp)
33
+ - \`runId\` (from flow-state)
34
+ - \`stage\` (usually \`tdd\`)
35
+ - \`slice\` (e.g. \`S-1\`)
36
+ - \`phase\` (\`red\` | \`green\` | \`refactor\`)
37
+ - \`command\`
38
+ - optional: \`files\`, \`exitCode\`, \`note\`
39
+
40
+ ## Primary skill
41
+
42
+ **${RUNTIME_ROOT}/skills/${TDD_LOG_SKILL_FOLDER}/SKILL.md**
43
+ `;
44
+ }
45
+ export function tddLogCommandSkillMarkdown() {
46
+ return `---
47
+ name: ${TDD_LOG_SKILL_NAME}
48
+ description: "Append RED/GREEN/REFACTOR entries into tdd-cycle-log.jsonl for guard/doctor enforcement."
49
+ ---
50
+
51
+ # /cc-tdd-log
52
+
53
+ ## HARD-GATE
54
+
55
+ Do not fake RED evidence. A \`red\` entry must correspond to a failing test command.
56
+
57
+ ## Protocol
58
+
59
+ 1. Read \`${flowStatePath()}\` and capture \`activeRunId\` + \`currentStage\`.
60
+ 2. Build JSON entry:
61
+ - \`ts\`: now ISO
62
+ - \`runId\`: activeRunId
63
+ - \`stage\`: currentStage
64
+ - \`slice\`: user-provided slice id
65
+ - \`phase\`: red|green|refactor
66
+ - \`command\`: test command or refactor verification command
67
+ 3. Append one line to \`${logPath()}\`.
68
+ 4. \`show\`: print the last 20 lines grouped by slice.
69
+
70
+ ## Validation
71
+
72
+ - File remains valid JSONL (one JSON object per line).
73
+ - For each slice, first phase must be \`red\`.
74
+ `;
75
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const ARTIFACT_TEMPLATES: Record<string, string>;
2
2
  export declare const RULEBOOK_MARKDOWN = "# Cclaw Rulebook\n\n## MUST_ALWAYS\n- Follow flow order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\n- Require explicit user confirmation after plan before TDD\n- Keep evidence artifacts in `.cclaw/artifacts/`\n- Enforce RED before GREEN in TDD\n- Run two-layer review (spec_compliance and code_quality) before ship\n- Validate all inputs before processing \u2014 never trust external data without sanitization\n- Prefer immutable data patterns and pure functions where the language supports them\n- Follow existing repo conventions, patterns, and directory structure \u2014 match the codebase\n- Verify claims with fresh evidence: \"tests pass\" requires running tests in this message\n- Use conventional commits: `type(scope): description` (feat, fix, refactor, test, docs, chore)\n\n## MUST_NEVER\n- Skip RED phase and jump directly to GREEN in TDD\n- Ship with critical review findings\n- Start implementation during /brainstorm\n- Modify generated cclaw files manually when CLI can regenerate them\n- Commit `.cclaw/` or generated shim files\n- Expose secrets, tokens, API keys, or absolute system paths in agent output\n- Duplicate existing functionality without explicit justification \u2014 search before building\n- Bypass security checks, linting hooks, or type checking to \"move faster\"\n- Claim success (\"Done,\" \"All good,\" \"Tests pass\") without running verification in this message\n- Make changes outside the blast radius of the current task without user consent\n\n## DELEGATION\nWhen a task requires specialist knowledge (security audit, performance profiling, database review),\ndelegate to a specialized agent or skill if the harness supports it. The primary agent should:\n1. Identify the specialist domain\n2. Provide focused context (relevant files, the specific concern)\n3. Evaluate the specialist output before acting on it \u2014 do not blindly apply recommendations\n";
3
- export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n- Follow stage order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship.\n- Read `.cclaw/state/flow-state.json` before acting; continue from current stage when active.\n- Use `/cc-next` only after required gates pass; never bypass explicit pause/approval rules.\n- Keep evidence in `.cclaw/artifacts/`; archive completed feature artifacts only via `cclaw archive`.\n- For machine-only checks in design/plan/tdd/review/ship, dispatch required specialists automatically when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, user challenge resolution, ship finalization).\n- Treat `.cclaw/skills/using-cclaw/SKILL.md` as routing source of truth; load contextual utility skills only when their triggers apply.\n";
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-next`.\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 or medium 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-next` = only progression path.\n- `/cc-learn` = knowledge capture and recall.\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 only via `cclaw archive`.\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- Protocols: `.cclaw/references/protocols/*.md`.\n- Preamble budget: `.cclaw/references/protocols/ethos.md`.\n";
4
4
  export declare function buildRulesJson(): Record<string, unknown>;
@@ -386,11 +386,11 @@ Execution rule: complete and verify each wave before starting the next wave.
386
386
 
387
387
  | Pass | Status | Completed at (UTC) | Reviewer / source | Commit at review | Drift vs HEAD |
388
388
  |---|---|---|---|---|---|
389
- | Layer 1 — spec compliance | pass / fail / pending | <ISO 8601> | spec-reviewer | <short sha> | <files changed since> |
390
- | Layer 2 — correctness | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
389
+ | Layer 1 — spec compliance | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
390
+ | Layer 2 — correctness | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
391
391
  | Layer 2 — security | pass / fail / pending | <ISO 8601> | security-reviewer | <short sha> | <files changed since> |
392
- | Layer 2 — performance | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
393
- | Layer 2 — architecture | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
392
+ | Layer 2 — performance | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
393
+ | Layer 2 — architecture | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
394
394
  | Adversarial review | pass / fail / n/a | <ISO 8601 or —> | adversarial-review skill | <short sha or —> | <drift or —> |
395
395
  | Review army schema valid | pass / fail | <ISO 8601> | jsonschema | <short sha> | n/a |
396
396
 
@@ -480,11 +480,41 @@ Execution rule: complete and verify each wave before starting the next wave.
480
480
  - SHIPPED | SHIPPED_WITH_EXCEPTIONS | BLOCKED
481
481
  - Exceptions (if any):
482
482
 
483
- ## Compound Step
484
- _Optional retrospective. The goal is to make the **next** feature faster, not to evaluate this one._
485
- _If you have nothing to add, write the explicit line: \`No compound insight this run.\`_
486
- - Insight: <one short line about what should accelerate the next run>
487
- - Action: append one strict-schema JSON line with \`"type":"compound"\` to \`.cclaw/knowledge.jsonl\` capturing the insight (fields: type, trigger, action, confidence, domain, stage, created, project)
483
+ ## Retro Gate Handoff
484
+ - Run \`/cc-retro\` before archive.
485
+ - Retro artifact path: \`.cclaw/artifacts/09-retro.md\`
486
+ - Archive remains blocked until retro gate is complete.
487
+ `,
488
+ "09-retro.md": `# Retro Artifact
489
+
490
+ ## Run Summary
491
+ - Flow track:
492
+ - Scope delivered:
493
+ - Main outcome:
494
+
495
+ ## Friction Log
496
+ | Category | What slowed us down | Evidence | Prevention rule |
497
+ |---|---|---|---|
498
+ | | | | |
499
+
500
+ ## Acceleration Log
501
+ | Category | What helped | Evidence | Reuse trigger |
502
+ |---|---|---|---|
503
+ | | | | |
504
+
505
+ ## Compound Decisions
506
+ | Insight | Trigger pattern | Action rule for next run |
507
+ |---|---|---|
508
+ | | | |
509
+
510
+ ## Knowledge Writes
511
+ - Compound entries appended to \`.cclaw/knowledge.jsonl\`: <N>
512
+ - Entry ids / timestamps:
513
+
514
+ ## Retro Completion
515
+ - RETRO_COMPLETE: yes
516
+ - Completed at (UTC):
517
+ - Notes:
488
518
  `
489
519
  };
490
520
  export const RULEBOOK_MARKDOWN = `# Cclaw Rulebook
@@ -531,13 +561,51 @@ alwaysApply: true
531
561
 
532
562
  # Cclaw Workflow Guardrails
533
563
 
534
- - Follow stage order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship.
535
- - Read \`.cclaw/state/flow-state.json\` before acting; continue from current stage when active.
536
- - Use \`/cc-next\` only after required gates pass; never bypass explicit pause/approval rules.
537
- - Keep evidence in \`.cclaw/artifacts/\`; archive completed feature artifacts only via \`cclaw archive\`.
538
- - For machine-only checks in design/plan/tdd/review/ship, dispatch required specialists automatically when tooling supports it.
539
- - Ask for user input only at explicit approval gates (scope mode, plan approval, user challenge resolution, ship finalization).
540
- - Treat \`.cclaw/skills/using-cclaw/SKILL.md\` as routing source of truth; load contextual utility skills only when their triggers apply.
564
+ ## Activation Rule
565
+
566
+ Before responding to coding work:
567
+ 1. Read \`.cclaw/state/flow-state.json\`.
568
+ 2. Start with \`/cc\` or continue with \`/cc-next\`.
569
+ 3. If no software-stage flow applies, respond normally.
570
+
571
+ ## Stage Order
572
+
573
+ \`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
574
+
575
+ Track-specific skips are allowed only when \`flow-state.track\` + \`skippedStages\` explicitly say so.
576
+
577
+ ## Task Classification
578
+
579
+ | Class | Route |
580
+ |---|---|
581
+ | non-trivial software work | \`/cc <idea>\` |
582
+ | trivial software fix | \`/cc <idea>\` (quick or medium track) |
583
+ | bugfix with repro | \`/cc <idea>\` and enforce RED-first in tdd |
584
+ | pure question / non-software | direct answer (no stage flow) |
585
+
586
+ ## Command Surface
587
+
588
+ - \`/cc\` = entry and resume.
589
+ - \`/cc-next\` = only progression path.
590
+ - \`/cc-learn\` = knowledge capture and recall.
591
+
592
+ ## Verification Discipline
593
+
594
+ - No completion claim without fresh command evidence in this turn.
595
+ - Do not mark gates passed from memory.
596
+ - Keep evidence in \`.cclaw/artifacts/\`; archive only via \`cclaw archive\`.
597
+
598
+ ## Delegation And Approvals
599
+
600
+ - Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.
601
+ - Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).
602
+ - If harness capabilities are partial, record waiver reasons in delegation logs.
603
+
604
+ ## Routing Source Of Truth
605
+
606
+ - Primary router: \`.cclaw/skills/using-cclaw/SKILL.md\`.
607
+ - Protocols: \`.cclaw/references/protocols/*.md\`.
608
+ - Preamble budget: \`.cclaw/references/protocols/ethos.md\`.
541
609
  `;
542
610
  export function buildRulesJson() {
543
611
  return {
@@ -0,0 +1,2 @@
1
+ export declare function treeCommandContract(): string;
2
+ export declare function treeCommandSkillMarkdown(): string;
@@ -0,0 +1,91 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ const TREE_SKILL_FOLDER = "flow-tree";
3
+ const TREE_SKILL_NAME = "flow-tree";
4
+ function flowStatePath() {
5
+ return `${RUNTIME_ROOT}/state/flow-state.json`;
6
+ }
7
+ function delegationLogPath() {
8
+ return `${RUNTIME_ROOT}/state/delegation-log.json`;
9
+ }
10
+ function artifactsPath() {
11
+ return `${RUNTIME_ROOT}/artifacts`;
12
+ }
13
+ function rewindLogPath() {
14
+ return `${RUNTIME_ROOT}/state/rewind-log.jsonl`;
15
+ }
16
+ export function treeCommandContract() {
17
+ return `# /cc-tree
18
+
19
+ ## Purpose
20
+
21
+ Render a visual flow tree for quick orientation across stages, gates, delegations,
22
+ stale markers, and artifact presence.
23
+
24
+ ## HARD-GATE
25
+
26
+ - \`/cc-tree\` is read-only. Do not mutate flow-state or artifacts.
27
+ - Use values from \`${flowStatePath()}\` and \`${delegationLogPath()}\`; never infer missing evidence.
28
+
29
+ ## Algorithm
30
+
31
+ 1. Read \`${flowStatePath()}\`.
32
+ 2. Read \`${delegationLogPath()}\` (if missing, treat current-stage delegations as pending).
33
+ 3. Detect artifact files in \`${artifactsPath()}\`.
34
+ 4. Read rewind records from \`${rewindLogPath()}\` when present for stale-stage context.
35
+ 5. Render the tree using stage order from active track:
36
+ - stage node marker: passed/current/pending/skipped/stale
37
+ - gate summary: \`passed/required\`
38
+ - delegation summary for current stage
39
+ - artifact marker per stage (exists / stale copy / missing)
40
+
41
+ ## Tree Format
42
+
43
+ \`\`\`
44
+ cclaw flow tree (track=<track>, run=<runId>)
45
+ ├─ [✓] brainstorm gates 6/6 artifact 01-brainstorm.md
46
+ ├─ [✓] scope gates 5/5 artifact 02-scope.md
47
+ ├─ [▶] design gates 2/7 artifact 03-design.md
48
+ │ ├─ delegations: [✓] planner [○] reviewer
49
+ │ └─ stale: none
50
+ ├─ [○] spec gates - artifact missing
51
+ └─ [○] plan gates - artifact missing
52
+ \`\`\`
53
+
54
+ Use UTF markers by default, ASCII fallback when terminal cannot render UTF.
55
+
56
+ ## Primary skill
57
+
58
+ **${RUNTIME_ROOT}/skills/${TREE_SKILL_FOLDER}/SKILL.md**
59
+ `;
60
+ }
61
+ export function treeCommandSkillMarkdown() {
62
+ return `---
63
+ name: ${TREE_SKILL_NAME}
64
+ description: "Render a visual flow tree for stages, gates, delegations, and artifacts."
65
+ ---
66
+
67
+ # /cc-tree
68
+
69
+ ## HARD-GATE
70
+
71
+ Do not modify state in this command. It is a pure read/render operation.
72
+
73
+ ## Protocol
74
+
75
+ 1. Read \`${flowStatePath()}\` as source of truth.
76
+ 2. Read \`${delegationLogPath()}\` for current-stage delegation status.
77
+ 3. Inspect \`${artifactsPath()}\` for per-stage artifact presence and stale copies.
78
+ 4. Render one compact tree:
79
+ - stage marker: passed/current/pending/skipped/stale
80
+ - gates summary
81
+ - artifact summary
82
+ - delegation branch for current stage
83
+ 5. If rewind records exist in \`${rewindLogPath()}\`, include latest rewind note in footer.
84
+
85
+ ## Validation
86
+
87
+ - Output must mention the active \`track\` and \`currentStage\`.
88
+ - Exactly one stage is marked current.
89
+ - Missing files are reported explicitly; never guessed as complete.
90
+ `;
91
+ }
@@ -28,5 +28,6 @@ export declare function checkMandatoryDelegations(projectRoot: string, stage: Fl
28
28
  satisfied: boolean;
29
29
  missing: string[];
30
30
  waived: string[];
31
+ autoWaived: string[];
31
32
  staleIgnored: string[];
32
33
  }>;