cclaw-cli 0.49.0 → 0.51.1

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 (183) hide show
  1. package/README.md +57 -84
  2. package/dist/artifact-linter.d.ts +4 -0
  3. package/dist/artifact-linter.js +24 -3
  4. package/dist/cli.d.ts +1 -19
  5. package/dist/cli.js +49 -491
  6. package/dist/constants.d.ts +2 -13
  7. package/dist/constants.js +1 -43
  8. package/dist/content/closeout-guidance.d.ts +14 -0
  9. package/dist/content/closeout-guidance.js +42 -0
  10. package/dist/content/core-agents.js +55 -17
  11. package/dist/content/decision-protocol.d.ts +12 -0
  12. package/dist/content/decision-protocol.js +20 -0
  13. package/dist/content/diff-command.d.ts +1 -2
  14. package/dist/content/diff-command.js +8 -94
  15. package/dist/content/examples.d.ts +4 -10
  16. package/dist/content/examples.js +10 -20
  17. package/dist/content/hook-events.js +2 -2
  18. package/dist/content/hook-inline-snippets.d.ts +5 -2
  19. package/dist/content/hook-inline-snippets.js +33 -1
  20. package/dist/content/hook-manifest.d.ts +3 -4
  21. package/dist/content/hook-manifest.js +11 -12
  22. package/dist/content/hooks.js +44 -21
  23. package/dist/content/ideate-command.d.ts +2 -0
  24. package/dist/content/ideate-command.js +34 -25
  25. package/dist/content/iron-laws.d.ts +5 -5
  26. package/dist/content/iron-laws.js +5 -5
  27. package/dist/content/language-policy.d.ts +2 -0
  28. package/dist/content/language-policy.js +13 -0
  29. package/dist/content/learnings.d.ts +3 -4
  30. package/dist/content/learnings.js +26 -50
  31. package/dist/content/meta-skill.js +33 -22
  32. package/dist/content/next-command.js +41 -38
  33. package/dist/content/node-hooks.js +17 -345
  34. package/dist/content/opencode-plugin.js +5 -103
  35. package/dist/content/research-playbooks.js +14 -14
  36. package/dist/content/review-loop.d.ts +2 -0
  37. package/dist/content/review-loop.js +8 -0
  38. package/dist/content/session-hooks.js +15 -47
  39. package/dist/content/skills.d.ts +0 -5
  40. package/dist/content/skills.js +55 -128
  41. package/dist/content/stage-common-guidance.d.ts +0 -1
  42. package/dist/content/stage-common-guidance.js +17 -14
  43. package/dist/content/stage-schema.d.ts +26 -1
  44. package/dist/content/stage-schema.js +121 -40
  45. package/dist/content/stages/_lint-metadata/index.js +9 -15
  46. package/dist/content/stages/brainstorm.js +22 -43
  47. package/dist/content/stages/design.js +37 -57
  48. package/dist/content/stages/plan.js +22 -13
  49. package/dist/content/stages/review.js +24 -27
  50. package/dist/content/stages/scope.js +34 -46
  51. package/dist/content/stages/ship.js +7 -4
  52. package/dist/content/stages/spec.js +20 -9
  53. package/dist/content/stages/tdd.js +64 -44
  54. package/dist/content/start-command.js +13 -12
  55. package/dist/content/status-command.d.ts +2 -7
  56. package/dist/content/status-command.js +19 -146
  57. package/dist/content/subagents.d.ts +0 -5
  58. package/dist/content/subagents.js +51 -28
  59. package/dist/content/templates.d.ts +1 -1
  60. package/dist/content/templates.js +126 -135
  61. package/dist/content/track-render-context.d.ts +17 -0
  62. package/dist/content/track-render-context.js +44 -0
  63. package/dist/content/tree-command.d.ts +1 -2
  64. package/dist/content/tree-command.js +4 -87
  65. package/dist/content/utility-skills.d.ts +2 -29
  66. package/dist/content/utility-skills.js +2 -1534
  67. package/dist/content/view-command.js +31 -11
  68. package/dist/delegation.d.ts +1 -1
  69. package/dist/delegation.js +5 -15
  70. package/dist/doctor-registry.js +20 -21
  71. package/dist/doctor.js +88 -344
  72. package/dist/flow-state.d.ts +3 -0
  73. package/dist/flow-state.js +2 -0
  74. package/dist/harness-adapters.d.ts +1 -1
  75. package/dist/harness-adapters.js +51 -58
  76. package/dist/install.js +128 -358
  77. package/dist/internal/advance-stage.js +3 -9
  78. package/dist/internal/compound-readiness.d.ts +1 -1
  79. package/dist/internal/compound-readiness.js +1 -1
  80. package/dist/internal/tdd-loop-status.d.ts +1 -1
  81. package/dist/internal/tdd-loop-status.js +1 -1
  82. package/dist/knowledge-store.d.ts +16 -10
  83. package/dist/knowledge-store.js +51 -15
  84. package/dist/policy.js +16 -105
  85. package/dist/run-archive.d.ts +4 -6
  86. package/dist/run-archive.js +15 -20
  87. package/dist/run-persistence.d.ts +2 -2
  88. package/dist/run-persistence.js +3 -9
  89. package/package.json +1 -2
  90. package/dist/content/archive-command.d.ts +0 -2
  91. package/dist/content/archive-command.js +0 -124
  92. package/dist/content/compound-command.d.ts +0 -5
  93. package/dist/content/compound-command.js +0 -193
  94. package/dist/content/contexts.d.ts +0 -18
  95. package/dist/content/contexts.js +0 -24
  96. package/dist/content/contracts.d.ts +0 -2
  97. package/dist/content/contracts.js +0 -51
  98. package/dist/content/doctor-references.d.ts +0 -2
  99. package/dist/content/doctor-references.js +0 -150
  100. package/dist/content/eval-scaffold.d.ts +0 -15
  101. package/dist/content/eval-scaffold.js +0 -370
  102. package/dist/content/feature-command.d.ts +0 -2
  103. package/dist/content/feature-command.js +0 -123
  104. package/dist/content/flow-map.d.ts +0 -23
  105. package/dist/content/flow-map.js +0 -134
  106. package/dist/content/harness-doc.d.ts +0 -2
  107. package/dist/content/harness-doc.js +0 -202
  108. package/dist/content/harness-playbooks.d.ts +0 -24
  109. package/dist/content/harness-playbooks.js +0 -393
  110. package/dist/content/harness-tool-refs.d.ts +0 -20
  111. package/dist/content/harness-tool-refs.js +0 -268
  112. package/dist/content/ops-command.d.ts +0 -2
  113. package/dist/content/ops-command.js +0 -71
  114. package/dist/content/protocols.d.ts +0 -7
  115. package/dist/content/protocols.js +0 -215
  116. package/dist/content/retro-command.d.ts +0 -2
  117. package/dist/content/retro-command.js +0 -165
  118. package/dist/content/rewind-command.d.ts +0 -2
  119. package/dist/content/rewind-command.js +0 -106
  120. package/dist/content/tdd-log-command.d.ts +0 -2
  121. package/dist/content/tdd-log-command.js +0 -85
  122. package/dist/eval/agents/single-shot.d.ts +0 -27
  123. package/dist/eval/agents/single-shot.js +0 -79
  124. package/dist/eval/agents/with-tools.d.ts +0 -44
  125. package/dist/eval/agents/with-tools.js +0 -261
  126. package/dist/eval/agents/workflow.d.ts +0 -31
  127. package/dist/eval/agents/workflow.js +0 -155
  128. package/dist/eval/baseline.d.ts +0 -38
  129. package/dist/eval/baseline.js +0 -282
  130. package/dist/eval/config-loader.d.ts +0 -14
  131. package/dist/eval/config-loader.js +0 -395
  132. package/dist/eval/corpus.d.ts +0 -30
  133. package/dist/eval/corpus.js +0 -330
  134. package/dist/eval/cost-guard.d.ts +0 -102
  135. package/dist/eval/cost-guard.js +0 -190
  136. package/dist/eval/diff.d.ts +0 -64
  137. package/dist/eval/diff.js +0 -323
  138. package/dist/eval/llm-client.d.ts +0 -176
  139. package/dist/eval/llm-client.js +0 -267
  140. package/dist/eval/mode.d.ts +0 -28
  141. package/dist/eval/mode.js +0 -61
  142. package/dist/eval/progress.d.ts +0 -83
  143. package/dist/eval/progress.js +0 -59
  144. package/dist/eval/report.d.ts +0 -11
  145. package/dist/eval/report.js +0 -181
  146. package/dist/eval/rubric-loader.d.ts +0 -20
  147. package/dist/eval/rubric-loader.js +0 -143
  148. package/dist/eval/runner.d.ts +0 -81
  149. package/dist/eval/runner.js +0 -746
  150. package/dist/eval/runs.d.ts +0 -41
  151. package/dist/eval/runs.js +0 -114
  152. package/dist/eval/sandbox.d.ts +0 -38
  153. package/dist/eval/sandbox.js +0 -137
  154. package/dist/eval/tools/glob.d.ts +0 -2
  155. package/dist/eval/tools/glob.js +0 -163
  156. package/dist/eval/tools/grep.d.ts +0 -2
  157. package/dist/eval/tools/grep.js +0 -152
  158. package/dist/eval/tools/index.d.ts +0 -7
  159. package/dist/eval/tools/index.js +0 -35
  160. package/dist/eval/tools/read.d.ts +0 -2
  161. package/dist/eval/tools/read.js +0 -122
  162. package/dist/eval/tools/types.d.ts +0 -49
  163. package/dist/eval/tools/types.js +0 -41
  164. package/dist/eval/tools/write.d.ts +0 -2
  165. package/dist/eval/tools/write.js +0 -92
  166. package/dist/eval/types.d.ts +0 -561
  167. package/dist/eval/types.js +0 -47
  168. package/dist/eval/verifiers/judge.d.ts +0 -40
  169. package/dist/eval/verifiers/judge.js +0 -256
  170. package/dist/eval/verifiers/rules.d.ts +0 -24
  171. package/dist/eval/verifiers/rules.js +0 -218
  172. package/dist/eval/verifiers/structural.d.ts +0 -14
  173. package/dist/eval/verifiers/structural.js +0 -171
  174. package/dist/eval/verifiers/traceability.d.ts +0 -23
  175. package/dist/eval/verifiers/traceability.js +0 -84
  176. package/dist/eval/verifiers/workflow-consistency.d.ts +0 -21
  177. package/dist/eval/verifiers/workflow-consistency.js +0 -225
  178. package/dist/eval/workflow-corpus.d.ts +0 -7
  179. package/dist/eval/workflow-corpus.js +0 -207
  180. package/dist/feature-system.d.ts +0 -42
  181. package/dist/feature-system.js +0 -432
  182. package/dist/internal/knowledge-digest.d.ts +0 -7
  183. package/dist/internal/knowledge-digest.js +0 -93
@@ -1,5 +1,5 @@
1
1
  // ---------------------------------------------------------------------------
2
- // Knowledge store content for /cc-learn and stage self-improvement prompts.
2
+ // Knowledge store content for the learnings skill and stage self-improvement prompts.
3
3
  //
4
4
  // The knowledge store is a single canonical JSONL file. Each line is one
5
5
  // self-contained JSON object matching the strict schema in this module.
@@ -11,8 +11,8 @@ const LEARN_SKILL_NAME = "learnings";
11
11
  const LEARN_SKILL_DESCRIPTION = "Project-scoped knowledge store: append and query rule/pattern/lesson/compound entries in the canonical JSONL file at .cclaw/knowledge.jsonl. Strict schema, append-only, machine-queryable.";
12
12
  /**
13
13
  * Canonical required JSONL field order (matches strict validator keys).
14
- * Optional keys (for now: `source`, `severity`) may be appended after these
15
- * required fields.
14
+ * Optional keys (`source`, `severity`, `supersedes`, `superseded_by`) may
15
+ * be appended after these required fields.
16
16
  * Exported for tests and any programmatic writer that wants a stable base shape.
17
17
  */
18
18
  export const KNOWLEDGE_JSONL_FIELDS = [
@@ -23,7 +23,7 @@ export const KNOWLEDGE_JSONL_FIELDS = [
23
23
  "domain",
24
24
  "stage",
25
25
  "origin_stage",
26
- "origin_feature",
26
+ "origin_run",
27
27
  "frequency",
28
28
  "universality",
29
29
  "maturity",
@@ -49,7 +49,7 @@ Use the store to keep durable knowledge that should survive sessions:
49
49
  - **rule**: hard constraint to follow every time.
50
50
  - **pattern**: repeatable way that works well in this project.
51
51
  - **lesson**: non-obvious outcome from a failure or trade-off.
52
- - **compound**: post-ship insight about how to make the *next* feature faster (process accelerator, not domain rule).
52
+ - **compound**: post-ship insight about how to make the *next* run faster (process accelerator, not domain rule).
53
53
 
54
54
  ## Continuous capture (stage closeout path)
55
55
 
@@ -63,22 +63,25 @@ Knowledge capture is now stage-native:
63
63
  2. appends deduped entries to \`${KNOWLEDGE_PATH}\`,
64
64
  3. writes a harvest marker into the artifact.
65
65
 
66
- \`/cc-learn\` remains the manual/query surface (search, backfill, curation).
66
+ Manual/query operations (search, backfill, curation) use this skill when the
67
+ user asks for knowledge work. If a stage artifact contains JSON learnings but
68
+ \`${KNOWLEDGE_PATH}\` did not change, the missing step is almost always running
69
+ \`node .cclaw/hooks/stage-complete.mjs <stage>\` successfully.
67
70
 
68
71
  ## HARD-GATE
69
72
 
70
- Under \`/cc-learn\`, only modify \`${KNOWLEDGE_PATH}\`, \`${KNOWLEDGE_ARCHIVE_PATH}\`,
73
+ During manual knowledge operations, only modify \`${KNOWLEDGE_PATH}\`, \`${KNOWLEDGE_ARCHIVE_PATH}\`,
71
74
  or an explicitly user-approved summary file. Do not modify application code here.
72
75
  Do not invent alternate stores (no markdown mirror, no SQLite, no per-stage files).
73
76
 
74
77
  ## Entry format — strict JSONL schema
75
78
 
76
79
  Exactly one JSON object per line. Required fields must appear in the order:
77
- \`type, trigger, action, confidence, domain, stage, origin_stage, origin_feature, frequency, universality, maturity, created, first_seen_ts, last_seen_ts, project\`.
80
+ \`type, trigger, action, confidence, domain, stage, origin_stage, origin_run, frequency, universality, maturity, created, first_seen_ts, last_seen_ts, project\`.
78
81
  Optional fields \`source\` and \`severity\` may be appended after \`project\`.
79
82
 
80
83
  \`\`\`json
81
- {"type":"pattern","trigger":"when reviewing external payloads","action":"parse through zod before touching service layer","confidence":"high","domain":"api","stage":"review","origin_stage":"review","origin_feature":"payload-hardening","frequency":1,"universality":"project","maturity":"raw","created":"2026-04-14T12:00:00Z","first_seen_ts":"2026-04-14T12:00:00Z","last_seen_ts":"2026-04-14T12:00:00Z","project":"cclaw"}
84
+ {"type":"pattern","trigger":"when reviewing external payloads","action":"parse through zod before touching service layer","confidence":"high","domain":"api","stage":"review","origin_stage":"review","origin_run":"payload-hardening","frequency":1,"universality":"project","maturity":"raw","created":"2026-04-14T12:00:00Z","first_seen_ts":"2026-04-14T12:00:00Z","last_seen_ts":"2026-04-14T12:00:00Z","project":"cclaw"}
82
85
  \`\`\`
83
86
 
84
87
  | field | type | required | notes |
@@ -90,7 +93,7 @@ Optional fields \`source\` and \`severity\` may be appended after \`project\`.
90
93
  | \`domain\` | string \\| null | yes | Free-form taxonomy (\`api\`, \`infra\`, \`ui\`, \`security\`, \`testing\`, …). Use \`null\` when cross-cutting. |
91
94
  | \`stage\` | \`FlowStage\` \\| null | yes | One of brainstorm / scope / design / spec / plan / tdd / review / ship, or \`null\` when cross-stage. |
92
95
  | \`origin_stage\` | \`FlowStage\` \\| null | yes | Stage where this learning was first observed. |
93
- | \`origin_feature\` | string \\| null | yes | Feature/worktree label where it was observed first. |
96
+ | \`origin_run\` | string \\| null | yes | Optional run, branch, or topic label where it was observed first. |
94
97
  | \`frequency\` | integer >= 1 | yes | Number of times this same trigger/action pair has been observed. |
95
98
  | \`universality\` | \`"project" \\| "personal" \\| "universal"\` | yes | Scope of applicability. |
96
99
  | \`maturity\` | \`"raw" \\| "lifted-to-rule" \\| "lifted-to-enforcement"\` | yes | Lifecycle state of the learning. |
@@ -99,7 +102,7 @@ Optional fields \`source\` and \`severity\` may be appended after \`project\`.
99
102
  | \`last_seen_ts\` | ISO 8601 UTC string | yes | Last re-confirmed timestamp. |
100
103
  | \`project\` | string \\| null | yes | Repo or scope name. Use \`null\` when the entry crosses projects. |
101
104
  | \`source\` | \`"stage" \\| "retro" \\| "compound" \\| "ideate" \\| "manual" \\| null\` | no | Origin channel for the entry when known. |
102
- | \`severity\` | \`"critical" \\| "important" \\| "suggestion"\` | no | Priority signal for compound lifts; \`critical\` enables single-hit override in \`/cc-ops compound\`. |
105
+ | \`severity\` | \`"critical" \\| "important" \\| "suggestion"\` | no | Priority signal for compound lifts; \`critical\` enables single-hit override in compound readiness analysis. |
103
106
 
104
107
  Rules:
105
108
  - No other fields beyond the table above. Extra keys are forbidden and MUST be rejected by any writer.
@@ -111,68 +114,41 @@ Rules:
111
114
  ## Curation policy (target: ≤ 50 active entries)
112
115
 
113
116
  - The file is append-only — entries are never physically deleted.
114
- - When the canonical file exceeds 50 lines, \`/cc-learn curate\` proposes
117
+ - When the canonical file exceeds 50 lines, a curation pass proposes
115
118
  soft-archiving: the approved lines are **moved** to \`${KNOWLEDGE_ARCHIVE_PATH}\`
116
119
  verbatim (same JSONL shape). The working file stays lean.
117
- - See the **knowledge-curation** utility skill for the full curation protocol.
120
+ - Use the **Curate** action below for the full read-only audit and
121
+ user-approved soft-archive plan.
118
122
 
119
- ## Subcommands
123
+ ## Manual Actions
120
124
 
121
- ### \`/cc-learn\` (default)
125
+ ### Show recent entries
122
126
  - Read \`${KNOWLEDGE_PATH}\`. Stream the last 30 lines; pretty-print each
123
127
  line's \`type\` / \`trigger\` / \`action\` for human review.
124
- - If file is missing or empty, report that clearly and suggest \`/cc-learn add\`.
128
+ - If file is missing or empty, report that clearly and suggest adding a
129
+ manual entry through this skill.
125
130
 
126
- ### \`/cc-learn search <query>\`
131
+ ### Search \`<query>\`
127
132
  - Stream \`${KNOWLEDGE_PATH}\`, JSON.parse each line, filter where any of
128
133
  \`trigger\`, \`action\`, \`domain\`, \`project\` contains \`<query>\` (case-insensitive).
129
134
  - Return the matched lines pretty-printed (do not mutate the file).
130
135
 
131
- ### \`/cc-learn add\`
136
+ ### Add
132
137
  - Ask for required user-facing fields in order: \`type\`, \`trigger\`, \`action\`, \`confidence\`, \`domain\`, \`stage\`, \`universality\`, \`project\`.
133
138
  - \`confidence\` must be one of \`high\`, \`medium\`, \`low\`. Default to \`medium\` if the user declines to set it.
134
139
  - \`domain\`, \`stage\`, and \`project\` may be explicitly \`null\`.
135
140
  - Prefer stage-native \`## Learnings\` capture for new flow work; use \`add\` mainly for backfilling historical lessons or ad-hoc entries outside a stage closeout.
136
- - \`origin_stage\` defaults to \`stage\`; \`origin_feature\` defaults to active feature (or \`null\` if unknown).
141
+ - \`origin_stage\` defaults to \`stage\`; \`origin_run\` defaults to the current run, branch, or topic label (or \`null\` if unknown).
137
142
  - \`frequency\` starts at \`1\`.
138
143
  - \`maturity\` starts at \`raw\`.
139
144
  - \`created\`, \`first_seen_ts\`, and \`last_seen_ts\` are set automatically to current UTC ISO timestamp.
140
145
  - Append exactly one JSON line to \`${KNOWLEDGE_PATH}\` with the field order from the schema table above.
141
146
  - Re-read the file tail to confirm the new line is valid JSON and parses back to the same object.
142
147
 
143
- ### \`/cc-learn curate\`
144
- - Hand off to the **knowledge-curation** skill (read-only audit + soft-archive plan).
148
+ ### Curate
149
+ - Produce a read-only audit + soft-archive plan.
145
150
  - Never deletes. Soft-archive means **moving** full JSON lines from
146
151
  \`${KNOWLEDGE_PATH}\` to \`${KNOWLEDGE_ARCHIVE_PATH}\` as part of a
147
152
  user-approved curation pass.
148
153
  `;
149
154
  }
150
- export function learnCommandContract() {
151
- return `# /cc-learn
152
-
153
- ## Purpose
154
-
155
- Manage the project knowledge store. One canonical file, strict JSONL:
156
- - \`${KNOWLEDGE_PATH}\` — append-only JSONL, one entry per line.
157
- - \`${KNOWLEDGE_ARCHIVE_PATH}\` — soft-archive target written only by curate.
158
-
159
- Stage-native pipeline:
160
- - During \`stage-complete.mjs\`, cclaw harvests \`## Learnings\` from the current
161
- stage artifact into \`${KNOWLEDGE_PATH}\` automatically.
162
- - Use \`/cc-learn\` for query, backfill, and curation workflows.
163
-
164
- ## HARD-GATE
165
-
166
- Do not edit source code from this command. Only operate on \`${KNOWLEDGE_PATH}\`,
167
- \`${KNOWLEDGE_ARCHIVE_PATH}\`, or user-approved summary output.
168
-
169
- ## Subcommands
170
-
171
- | subcommand | args | description |
172
- |---|---|---|
173
- | (default) | — | Show recent knowledge entries (tail of JSONL, pretty-printed). |
174
- | \`search\` | \`<query>\` | Stream-filter the JSONL for matching \`trigger\`, \`action\`, \`domain\`, \`project\`. |
175
- | \`add\` | — | Append one JSON line (\`rule\` / \`pattern\` / \`lesson\` / \`compound\`) with the strict JSONL schema (15 required fields + optional \`source\` / \`severity\`). |
176
- | \`curate\` | — | Hand off to the **knowledge-curation** skill: read-only audit + soft-archive plan when the file exceeds the curation threshold. |
177
- `;
178
- }
@@ -1,10 +1,10 @@
1
- import { FLOW_MAP_REL_PATH } from "./flow-map.js";
2
- import { COMPLETION_PROTOCOL_REL_PATH, DECISION_PROTOCOL_REL_PATH, ETHOS_PROTOCOL_REL_PATH } from "./protocols.js";
1
+ import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
2
+ import { CLOSEOUT_CHAIN, closeoutChainInline, closeoutFlowMapSentence, closeoutProtocolBehaviorSentence } from "./closeout-guidance.js";
3
3
  export const META_SKILL_NAME = "using-cclaw";
4
4
  export function usingCclawSkillMarkdown() {
5
5
  return `---
6
6
  name: using-cclaw
7
- description: "Routing brain for cclaw. Decide whether to start/resume a stage, answer directly, or use utility commands like /cc-learn, /cc-ideate, /cc-view, and /cc-ops."
7
+ description: "Routing brain for cclaw. Decide whether to start/resume a stage, answer directly, or use visible commands like /cc, /cc-next, /cc-ideate, and /cc-view."
8
8
  ---
9
9
 
10
10
  # Using Cclaw
@@ -19,6 +19,7 @@ description: "Routing brain for cclaw. Decide whether to start/resume a stage, a
19
19
 
20
20
  If the user explicitly overrides a stage rule, record it in the artifact.
21
21
 
22
+ ${conversationLanguagePolicyMarkdown()}
22
23
  ## Skill-before-response gate
23
24
 
24
25
  If \`.cclaw/state/flow-state.json\` exists and \`currentStage\` is set,
@@ -58,9 +59,10 @@ Task arrives
58
59
  ├─ New software work? -> /cc <idea>
59
60
  ├─ Repo-improvement discovery? -> /cc-ideate
60
61
  ├─ Resume existing flow? -> /cc or /cc-next
61
- ├─ Knowledge operation? -> /cc-learn
62
+ ├─ Knowledge operation? -> load the learnings skill
62
63
  ├─ Read-only workspace view? -> /cc-view [status|tree|diff]
63
- └─ Workspace operation? -> /cc-ops [feature|tdd-log|retro|compound|archive|rewind]
64
+ ├─ Normal post-ship closeout? -> /cc-next drives ${closeoutChainInline()}
65
+ └─ Explicit early archival/reset? -> npx cclaw-cli archive [--name=<slug>]
64
66
  \`\`\`
65
67
 
66
68
  ## Task classification
@@ -84,35 +86,44 @@ Before stage work:
84
86
  ## Platform reliability notes
85
87
 
86
88
  - Managed hook dispatch uses \`.cclaw/hooks/run-hook.cmd\` (cross-platform wrapper).
87
- - If hooks fail due missing runtime deps (for example \`node\` not on \`PATH\`), run \`cclaw doctor\` before continuing.
89
+ - If hooks fail due missing runtime deps (for example \`node\` not on \`PATH\`), run \`npx cclaw-cli doctor\` before continuing.
88
90
  - Prefer cross-platform commands in artifacts/examples (\`npm test\`, \`pnpm test\`, \`python -m pytest\`, etc.) over shell-specific aliases whenever possible.
89
91
 
90
92
  ## Stage quick map
91
93
 
92
- brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship
94
+ Use \`/cc <idea>\` for new work, \`/cc-next\` for progression and closeout, \`/cc-view\` for read-only state, and \`/cc-ideate\` for backlog discovery.
93
95
 
94
- Tracks may skip stages via \`flow-state.track\` + \`skippedStages\`.
95
- For the full surface (stages, routers, Ralph Loop, state files) load
96
- \`${FLOW_MAP_REL_PATH}\` — it is the single-page overview of cclaw.
96
+ ## Main vs Operator Surfaces
97
97
 
98
- ## Contextual skill activation
98
+ - **Main workflow:** \`/cc\`, \`/cc-next\`, \`/cc-ideate\`, \`/cc-view status\`, and \`node .cclaw/hooks/stage-complete.mjs <stage>\` inside the installed harness runtime.
99
+ - **Installer/support surface:** \`npx cclaw-cli init\`, \`npx cclaw-cli sync\`, \`npx cclaw-cli upgrade\`, \`npx cclaw-cli doctor\`, and explicit support/archive actions. Do not ask users to install or run a \`cclaw\` binary during normal stage flow.
100
+ - **Read-only support:** \`/cc-view tree\` and \`/cc-view diff\`.
101
+ - Use operator/support surfaces only for install/runtime diagnosis, explicit archival, or deeper inspection. Do not make them part of the happy path.
99
102
 
100
- Load utility skills only when triggered by the current task:
103
+ ## Whole flow map
101
104
 
102
- - security, performance, debugging, docs, ci-cd
103
- - verification-before-completion before completion claims
104
- - finishing-a-development-branch during ship/finalization
105
- - document-review, receiving-code-review, and execution context skills
105
+ standard: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship -> ${CLOSEOUT_CHAIN}
106
+ medium: brainstorm -> spec -> plan -> tdd -> review -> ship -> ${CLOSEOUT_CHAIN}
107
+ quick: spec -> tdd -> review -> ship -> ${CLOSEOUT_CHAIN}
108
+
109
+ ${closeoutFlowMapSentence()}
110
+
111
+ Tracks may skip critical-path stages via \`flow-state.track\` + \`skippedStages\`.
112
+ Use the current stage skill plus \`.cclaw/state/flow-state.json\` for orientation.
113
+
114
+ ## Contextual Skill Activation
115
+
116
+ Use built-in judgment only when triggered by the current task:
117
+
118
+ - security, performance, debugging, docs, and CI/CD review lenses
119
+ - verification discipline before completion claims
120
+ - branch-finishing discipline during ship/finalization
106
121
  - iron-laws as policy arbitration when instructions conflict
107
122
  - language rule packs from \`.cclaw/config.yaml\` when enabled
108
123
 
109
- ## Protocol references
110
-
111
- Do not inline these protocols in stage skills; cite by path:
124
+ ## Protocol Behavior
112
125
 
113
- - Decision protocol: \`${DECISION_PROTOCOL_REL_PATH}\`
114
- - Completion/resume protocol: \`${COMPLETION_PROTOCOL_REL_PATH}\`
115
- - Engineering ethos + announce discipline: \`${ETHOS_PROTOCOL_REL_PATH}\`
126
+ ${closeoutProtocolBehaviorSentence()}
116
127
 
117
128
  ## Knowledge guidance
118
129
 
@@ -1,6 +1,7 @@
1
1
  import { RUNTIME_ROOT } from "../constants.js";
2
- import { FLOW_MAP_REL_PATH } from "./flow-map.js";
2
+ import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
3
3
  import { stageSchema } from "./stage-schema.js";
4
+ import { closeoutChainInline, closeoutNextCommandGuidance, closeoutSubstateInline, closeoutSubstateProtocolBullets } from "./closeout-guidance.js";
4
5
  import { stageSkillFolder } from "./skills.js";
5
6
  const NEXT_SKILL_FOLDER = "flow-next-step";
6
7
  const NEXT_SKILL_NAME = "flow-next-step";
@@ -58,21 +59,23 @@ export function nextCommandContract() {
58
59
 
59
60
  - **Current stage not started / in progress** → load its skill and execute it.
60
61
  - **Current stage complete (all gates passed)** → advance \`currentStage\` and load the next skill.
61
- - **Flow complete** → report done.
62
+ - **Ship complete** → continue the resumable ${closeoutChainInline()} closeout via \`/cc-next\`.
63
+ - **Flow complete** → report done after closeout has archived the run.
62
64
 
63
65
  This is the only progression command the user needs to drive the entire flow. Stage command contracts are internal implementation details loaded by \`/cc-next\`.
64
66
 
65
67
  ## HARD-GATE
66
68
 
69
+ ${conversationLanguagePolicyMarkdown()}
67
70
  - **Do not** invent gate completion: use only \`${flowPath}\` plus observable evidence in repo artifacts.
68
71
  - **Do not** skip stages: advance only from \`currentStage\` to its configured successor.
69
- - After ship completes, the closeout chain **retro -> compound -> archive** runs automatically, driven by \`closeout.shipSubstate\`. Do not ask the user to type those commands manually — follow the substate switch in Path B below.
72
+ - ${closeoutNextCommandGuidance()}
70
73
 
71
74
  ## Algorithm (mandatory)
72
75
 
73
76
  1. Read **\`${flowPath}\`**. If missing → **BLOCKED** (state missing).
74
77
  2. Parse JSON. Capture \`currentStage\` and \`stageGateCatalog[currentStage]\`.
75
- 3. If \`staleStages[currentStage]\` exists, do not advance automatically. Re-run the stage artifact work, then clear the marker with \`/cc-ops rewind --ack <currentStage>\`.
78
+ 3. If \`staleStages[currentStage]\` exists, do not advance automatically. Re-run the stage artifact work, then clear the marker with \`cclaw internal rewind --ack <currentStage>\`.
76
79
  4. Read **\`${reconciliationNoticesPath}\`** when present. If it contains entries for \`activeRunId + currentStage\` and the listed gate is still blocked in \`stageGateCatalog[currentStage].blocked\`, emit a structured warning before any stage-advance decision.
77
80
  5. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema.
78
81
  6. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state.
@@ -81,11 +84,11 @@ This is the only progression command the user needs to drive the entire flow. St
81
84
  9. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. Treat as satisfied only if each mandatory agent is **completed** or **waived**.
82
85
  10. For each satisfied mandatory delegation row, verify \`evidenceRefs\` is a non-empty array (unless status is \`waived\` with rationale). Missing evidenceRefs means delegation is unresolved.
83
86
  11. If any mandatory delegation is missing and no waiver exists: **STOP** and ask the user whether to dispatch now or waive with rationale. Do not mark gates passed while delegation is unresolved.
84
- 12. If \`currentStage === "review"\` and \`catalog.blocked\` includes \`review_criticals_resolved\`, treat this as a hard remediation branch: recommend \`/cc-ops rewind tdd "review_blocked_by_critical"\` with the blocking finding IDs, and do not attempt to advance toward ship.
87
+ 12. If \`currentStage === "review"\` and \`catalog.blocked\` includes \`review_criticals_resolved\`, treat this as a hard remediation branch: recommend \`cclaw internal rewind tdd "review_blocked_by_critical"\` with the blocking finding IDs, and do not attempt to advance toward ship.
85
88
 
86
89
  ### Path A: Current stage is NOT complete (any gate unmet or delegation missing)
87
90
 
88
- → Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<currentStage>.md\`** for the current stage.
91
+ → Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** for the current stage.
89
92
  → Execute that stage's protocol. The stage skill handles the full interaction including STOP points and gate tracking.
90
93
  → Stage completion must use \`node .cclaw/hooks/stage-complete.mjs <currentStage>\` (canonical), which validates delegations + gate evidence before mutating \`flow-state.json\`.
91
94
 
@@ -95,24 +98,11 @@ ${ralphLoopContractSnippet()}
95
98
 
96
99
  → If current stage's \`next\` is **\`done\`**:
97
100
 
98
- When \`currentStage === "ship"\`, route by **\`closeout.shipSubstate\`**:
99
- - \`"idle"\` or missing -> set \`closeout.shipSubstate = "retro_review"\`, then
100
- load \`${RUNTIME_ROOT}/commands/retro.md\` + \`${RUNTIME_ROOT}/skills/flow-retro/SKILL.md\`
101
- and execute the retro protocol (draft + one structured accept/edit/skip ask).
102
- - \`"retro_review"\` -> continue the retro protocol (re-ask the structured
103
- question; the draft already exists — do not regenerate it).
104
- - \`"compound_review"\` -> load \`${RUNTIME_ROOT}/commands/compound.md\` +
105
- \`${RUNTIME_ROOT}/skills/flow-compound/SKILL.md\`, execute the compound
106
- scan, ask user **one** structured question (apply / skip) per candidate
107
- cluster or a single accept-all / skip choice, and advance substate on
108
- completion or skip.
109
- - \`"ready_to_archive"\` -> load \`${RUNTIME_ROOT}/commands/archive.md\` +
110
- \`${RUNTIME_ROOT}/skills/flow-archive/SKILL.md\`, run archive, reset state.
111
- - \`"archived"\` (transient) -> report "run archived" and stop.
101
+ ${closeoutSubstateProtocolBullets()}
112
102
 
113
103
  Otherwise report **"Flow complete. All stages finished."** and stop.
114
104
 
115
- → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** for the successor stage. Execute that stage's protocol.
105
+ → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** for the successor stage. Execute that stage's protocol.
116
106
 
117
107
  ### Track-aware successor resolution
118
108
 
@@ -128,7 +118,7 @@ ${ralphLoopContractSnippet()}
128
118
  \`/cc-next\` in a **new session** = resume from where you left off:
129
119
  - Flow-state records \`currentStage\` and which gates have passed.
130
120
  - The stage skill reads upstream artifacts and picks up context.
131
- - \`closeout.shipSubstate\` carries the post-ship substate, so a crashed
121
+ - ${closeoutSubstateInline()} carries the post-ship substate, so a crashed
132
122
  session during retro/compound/archive resumes at the exact step without
133
123
  regenerating the retro draft.
134
124
  - No special resume command needed — \`/cc-next\` IS the resume command.
@@ -151,9 +141,7 @@ Validate envelopes with:
151
141
 
152
142
  ## Surface reference
153
143
 
154
- When you need the full shape of cclaw (stages, routers, Ralph Loop,
155
- state files) load \`${FLOW_MAP_REL_PATH}\`. It is the single-page
156
- overview and is safe to read at any time.
144
+ Use the flow-start skill plus \`.cclaw/state/flow-state.json\` for orientation when needed.
157
145
  `;
158
146
  }
159
147
  /**
@@ -182,6 +170,22 @@ description: "The primary progression command. Reads flow state, starts/resumes
182
170
 
183
171
  \`/cc-next\` is **the only command you need** to drive the entire cclaw flow.
184
172
 
173
+ ## Operator Output Contract
174
+
175
+ ${conversationLanguagePolicyMarkdown()}
176
+ Default output should be compact, like OMC/OMX operator surfaces:
177
+
178
+ \`\`\`
179
+ Stage: <currentStage> (<track>)
180
+ Gates: <passed>/<required> passed, <blocked> blocked
181
+ Delegations: <done>/<mandatory> done
182
+ Blockers: <none | gate/delegation/reconciliation ids>
183
+ Next: <exact next action, usually /cc-next or one named remediation>
184
+ \`\`\`
185
+
186
+ Only expand beyond this when blocked, when asking a structured question, or when
187
+ the user explicitly requests detail. Do not dump full artifacts in progression output.
188
+
185
189
  **How it works:**
186
190
  1. Reads \`flow-state.json\` to find \`currentStage\`
187
191
  2. Checks if all gates for that stage are satisfied
@@ -200,7 +204,7 @@ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (p
200
204
 
201
205
  1. Open **\`${flowPath}\`**.
202
206
  2. Record \`currentStage\` and \`stageGateCatalog[currentStage]\`.
203
- 3. If \`staleStages[currentStage]\` exists, re-run the stage and clear marker via \`/cc-ops rewind --ack <currentStage>\` before advancing.
207
+ 3. If \`staleStages[currentStage]\` exists, re-run the stage and clear marker via \`cclaw internal rewind --ack <currentStage>\` before advancing.
204
208
  4. If the file is missing or invalid JSON → **BLOCKED** (report and stop).
205
209
  5. Read \`${reconciliationNoticesPath}\` when present. For entries matching \`activeRunId + currentStage\` whose gate is still in \`stageGateCatalog[currentStage].blocked\`, show a warning with gate id + reason before proceeding.
206
210
 
@@ -221,42 +225,41 @@ If reconciliation warnings were emitted in Step 1, treat them as a pre-advance s
221
225
 
222
226
  **Path A — stage NOT complete (any gate unmet):**
223
227
 
224
- Load the current stage's skill and command contract:
228
+ Load the current stage skill:
225
229
  - \`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`
226
- - \`${RUNTIME_ROOT}/commands/<currentStage>.md\`
227
230
 
228
231
  Execute the stage protocol. The stage skill handles interaction, STOP points, gate tracking, and stage completion via \`node .cclaw/hooks/stage-complete.mjs <stage>\` (canonical flow-state mutation path).
229
232
 
230
233
  ${ralphLoopContractSnippet()}
231
234
 
232
- Special-case for review: if \`review_criticals_resolved\` is in \`blocked\`, route to rework instead of looping review forever — recommend \`/cc-ops rewind tdd "review_blocked_by_critical"\`.
235
+ Special-case for review: if \`review_criticals_resolved\` is in \`blocked\`, route to rework instead of looping review forever — recommend \`cclaw internal rewind tdd "review_blocked_by_critical"\`.
233
236
 
234
237
  **Path B — stage IS complete (all gates met, all delegations done):**
235
238
 
236
239
  If \`next\` is \`done\`:
237
240
 
238
241
  When \`currentStage\` is \`ship\`, automatically drive the **closeout chain**
239
- by inspecting \`closeout.shipSubstate\`:
242
+ by inspecting ${closeoutSubstateInline()}:
240
243
 
241
244
  | shipSubstate | Action |
242
245
  |-----------------------|-----------------------------------------------------|
243
246
  | \`idle\` / missing | Flip to \`retro_review\` and start retro protocol |
244
- | \`retro_review\` | Continue retro protocol (re-ask accept/edit/skip) |
245
- | \`compound_review\` | Run compound scan with a single approve/skip ask |
246
- | \`ready_to_archive\` | Run archive skill; reset flow-state on success |
247
+ | \`retro_review\` | Draft/update \`09-retro.md\`, ask accept/edit/skip |
248
+ | \`compound_review\` | Compound closeout: overlap scan, refresh/supersede, ask approve/skip |
249
+ | \`ready_to_archive\` | Run \`npx cclaw-cli archive\`; reset flow-state on success |
247
250
  | \`archived\` | Report "run archived"; stop |
248
251
 
249
- Each step owns its own state transition. \`/cc-next\` never shells out to
250
- \`cclaw doctor\` or \`cclaw archive\` automatically it loads the matching
251
- skill and command contract and executes the protocol in-session.
252
+ Each step owns its own state transition. \`/cc-next\` keeps retro and compound
253
+ in-session, then uses the archive runtime only at \`ready_to_archive\`.
252
254
 
253
255
  Otherwise report **"Flow complete. All stages finished."** and stop.
254
256
 
255
- Otherwise (non-terminal \`next\`): load the next stage's skill and command
256
- contract, begin execution.
257
+ Otherwise (non-terminal \`next\`): load the next stage skill and begin execution.
257
258
 
258
259
  ## Stage order
259
260
 
261
+ This table is the critical path. After \`ship\`, \`/cc-next\` continues closeout via ${closeoutSubstateInline()}: ${closeoutChainInline()}.
262
+
260
263
  | Stage | Next | Skill path |
261
264
  |---|---|---|
262
265
  ${stageRows}