cclaw-cli 0.13.0 → 0.15.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 (41) hide show
  1. package/dist/cli.js +11 -0
  2. package/dist/config.js +0 -8
  3. package/dist/constants.d.ts +1 -1
  4. package/dist/constants.js +3 -0
  5. package/dist/content/archive-command.d.ts +2 -0
  6. package/dist/content/archive-command.js +98 -0
  7. package/dist/content/contracts.js +1 -1
  8. package/dist/content/diff-command.js +2 -2
  9. package/dist/content/feature-command.js +7 -7
  10. package/dist/content/harnesses-doc.js +15 -8
  11. package/dist/content/hooks.js +2 -2
  12. package/dist/content/learnings.d.ts +0 -3
  13. package/dist/content/learnings.js +0 -38
  14. package/dist/content/meta-skill.js +3 -2
  15. package/dist/content/next-command.js +12 -5
  16. package/dist/content/ops-command.d.ts +2 -0
  17. package/dist/content/ops-command.js +60 -0
  18. package/dist/content/protocols.js +14 -2
  19. package/dist/content/retro-command.js +3 -3
  20. package/dist/content/rewind-command.js +5 -5
  21. package/dist/content/stage-common-guidance.js +14 -5
  22. package/dist/content/stage-schema.d.ts +0 -16
  23. package/dist/content/stage-schema.js +7 -181
  24. package/dist/content/status-command.d.ts +2 -2
  25. package/dist/content/status-command.js +13 -13
  26. package/dist/content/tdd-log-command.js +6 -6
  27. package/dist/content/templates.d.ts +1 -1
  28. package/dist/content/templates.js +2 -2
  29. package/dist/content/tree-command.js +3 -3
  30. package/dist/content/utility-skills.js +1 -1
  31. package/dist/content/view-command.d.ts +2 -0
  32. package/dist/content/view-command.js +57 -0
  33. package/dist/doctor-registry.js +22 -4
  34. package/dist/doctor.js +8 -32
  35. package/dist/harness-adapters.d.ts +1 -0
  36. package/dist/harness-adapters.js +15 -54
  37. package/dist/install.js +13 -10
  38. package/dist/policy.js +1 -1
  39. package/dist/runs.js +1 -1
  40. package/dist/types.d.ts +1 -3
  41. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -115,6 +115,17 @@ function buildInitSurfacePreview(harnesses) {
115
115
  ".cclaw/config.yaml",
116
116
  ".cclaw/commands/*.md",
117
117
  ".cclaw/skills/*/SKILL.md",
118
+ ".cclaw/contexts/*.md",
119
+ ".cclaw/templates/*",
120
+ ".cclaw/agents/*.md",
121
+ ".cclaw/hooks/*",
122
+ ".cclaw/rules/**",
123
+ ".cclaw/adapters/*.md",
124
+ ".cclaw/custom-skills/README.md",
125
+ ".cclaw/features/**",
126
+ ".cclaw/runs/**",
127
+ ".cclaw/artifacts/**",
128
+ ".cclaw/knowledge.jsonl",
118
129
  ".cclaw/state/*.json|*.jsonl",
119
130
  ".cclaw/references/**",
120
131
  "AGENTS.md (managed block)"
package/dist/config.js CHANGED
@@ -15,7 +15,6 @@ const ALLOWED_CONFIG_KEYS = new Set([
15
15
  "version",
16
16
  "flowVersion",
17
17
  "harnesses",
18
- "autoAdvance",
19
18
  "promptGuardMode",
20
19
  "tddEnforcement",
21
20
  "tddTestGlobs",
@@ -60,7 +59,6 @@ export function createDefaultConfig(harnesses = DEFAULT_HARNESSES, defaultTrack
60
59
  version: CCLAW_VERSION,
61
60
  flowVersion: FLOW_VERSION,
62
61
  harnesses,
63
- autoAdvance: false,
64
62
  promptGuardMode: "advisory",
65
63
  tddEnforcement: "advisory",
66
64
  tddTestGlobs: ["**/*.test.*", "**/*.spec.*", "**/test/**"],
@@ -81,7 +79,6 @@ export function createProfileConfig(profile, overrides = {}) {
81
79
  return {
82
80
  ...base,
83
81
  harnesses: overrides.harnesses ?? ["claude"],
84
- autoAdvance: false,
85
82
  promptGuardMode: "advisory",
86
83
  tddEnforcement: "advisory",
87
84
  gitHookGuards: false,
@@ -92,7 +89,6 @@ export function createProfileConfig(profile, overrides = {}) {
92
89
  return {
93
90
  ...base,
94
91
  harnesses: overrides.harnesses ?? DEFAULT_HARNESSES,
95
- autoAdvance: false,
96
92
  promptGuardMode: "advisory",
97
93
  tddEnforcement: "advisory",
98
94
  gitHookGuards: false,
@@ -103,7 +99,6 @@ export function createProfileConfig(profile, overrides = {}) {
103
99
  return {
104
100
  ...base,
105
101
  harnesses: overrides.harnesses ?? DEFAULT_HARNESSES,
106
- autoAdvance: false,
107
102
  promptGuardMode: "strict",
108
103
  tddEnforcement: "strict",
109
104
  gitHookGuards: true,
@@ -147,8 +142,6 @@ export async function readConfig(projectRoot) {
147
142
  const harnesses = hasHarnessesField
148
143
  ? [...new Set(validatedHarnesses)]
149
144
  : DEFAULT_HARNESSES;
150
- const autoAdvanceRaw = parsed.autoAdvance;
151
- const autoAdvance = typeof autoAdvanceRaw === "boolean" ? autoAdvanceRaw : false;
152
145
  const promptGuardModeRaw = parsed.promptGuardMode;
153
146
  if (Object.prototype.hasOwnProperty.call(parsed, "promptGuardMode") &&
154
147
  promptGuardModeRaw !== "advisory" &&
@@ -261,7 +254,6 @@ export async function readConfig(projectRoot) {
261
254
  version: parsed.version ?? CCLAW_VERSION,
262
255
  flowVersion: parsed.flowVersion ?? FLOW_VERSION,
263
256
  harnesses,
264
- autoAdvance,
265
257
  promptGuardMode,
266
258
  tddEnforcement,
267
259
  tddTestGlobs,
@@ -7,6 +7,6 @@ export declare const DEFAULT_HARNESSES: HarnessId[];
7
7
  export declare const REQUIRED_DIRS: readonly [".cclaw", ".cclaw/commands", ".cclaw/skills", ".cclaw/contexts", ".cclaw/templates", ".cclaw/artifacts", ".cclaw/features", ".cclaw/state", ".cclaw/runs", ".cclaw/rules", ".cclaw/adapters", ".cclaw/agents", ".cclaw/hooks", ".cclaw/custom-skills"];
8
8
  export declare const REQUIRED_GITIGNORE_PATTERNS: readonly ["# cclaw generated artifacts", ".cclaw/", ".claude/commands/cc-*.md", ".claude/commands/cc.md", ".cursor/commands/cc-*.md", ".cursor/commands/cc.md", ".opencode/commands/cc-*.md", ".opencode/commands/cc.md", ".codex/commands/cc-*.md", ".codex/commands/cc.md", ".claude/hooks/hooks.json", ".cursor/hooks.json", ".codex/hooks.json", ".opencode/plugins/cclaw-plugin.mjs", ".cursor/rules/cclaw-workflow.mdc"];
9
9
  export declare const COMMAND_FILE_ORDER: FlowStage[];
10
- export declare const UTILITY_COMMANDS: readonly ["learn", "next", "status", "tree", "diff", "feature", "tdd-log", "retro", "rewind", "rewind-ack"];
10
+ export declare const UTILITY_COMMANDS: readonly ["learn", "next", "view", "status", "tree", "diff", "ops", "feature", "tdd-log", "retro", "archive", "rewind", "rewind-ack"];
11
11
  export declare const SUBAGENT_SKILL_FOLDERS: readonly ["subagent-dev", "parallel-dispatch"];
12
12
  export type UtilityCommand = (typeof UTILITY_COMMANDS)[number];
package/dist/constants.js CHANGED
@@ -54,12 +54,15 @@ export const COMMAND_FILE_ORDER = [
54
54
  export const UTILITY_COMMANDS = [
55
55
  "learn",
56
56
  "next",
57
+ "view",
57
58
  "status",
58
59
  "tree",
59
60
  "diff",
61
+ "ops",
60
62
  "feature",
61
63
  "tdd-log",
62
64
  "retro",
65
+ "archive",
63
66
  "rewind",
64
67
  "rewind-ack"
65
68
  ];
@@ -0,0 +1,2 @@
1
+ export declare function archiveCommandContract(): string;
2
+ export declare function archiveCommandSkillMarkdown(): string;
@@ -0,0 +1,98 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ const ARCHIVE_SKILL_FOLDER = "flow-archive";
3
+ const ARCHIVE_SKILL_NAME = "flow-archive";
4
+ function flowStatePath() {
5
+ return `${RUNTIME_ROOT}/state/flow-state.json`;
6
+ }
7
+ function runsPath() {
8
+ return `${RUNTIME_ROOT}/runs`;
9
+ }
10
+ function activeArtifactsPath() {
11
+ return `${RUNTIME_ROOT}/artifacts`;
12
+ }
13
+ export function archiveCommandContract() {
14
+ return `# /cc-ops archive
15
+
16
+ ## Purpose
17
+
18
+ Archive the active cclaw run from inside the harness flow (agent-first finish).
19
+
20
+ This command removes the user-facing CLI gap: users can stay in \`/cc-*\` flow and
21
+ finish with \`/cc-ops archive\` after ship + retro are complete.
22
+
23
+ ## HARD-GATE
24
+
25
+ - Do not archive a shipped run when retro is still incomplete.
26
+ - Do not manually move files between \`${activeArtifactsPath()}\` and \`${runsPath()}\`.
27
+ - Use the archive runtime so state snapshots + manifest stay consistent.
28
+
29
+ ## Inputs
30
+
31
+ \`/cc-ops archive [--name=<slug>] [--skip-retro --retro-reason=<text>]\`
32
+
33
+ ## Algorithm
34
+
35
+ 1. Read \`${flowStatePath()}\`.
36
+ 2. If ship is complete and \`retro.completedAt\` is absent:
37
+ - block with explicit instruction: run \`/cc-ops retro\` first.
38
+ 3. Build archive command:
39
+ - base: \`npx cclaw archive\`
40
+ - optional: \`--name=<slug>\`
41
+ - optional override: \`--skip-retro --retro-reason=<text>\`
42
+ 4. Execute archive command in project root.
43
+ 5. Surface result:
44
+ - archive id/path,
45
+ - reset stage (brainstorm/spec depending on track default),
46
+ - knowledge curation hint when threshold exceeded.
47
+
48
+ ## Output format
49
+
50
+ \`\`\`
51
+ cclaw archive
52
+ status: archived
53
+ run: <archive-id>
54
+ path: .cclaw/runs/<archive-id>
55
+ next: /cc <new-idea>
56
+ \`\`\`
57
+
58
+ ## Primary skill
59
+
60
+ **${RUNTIME_ROOT}/skills/${ARCHIVE_SKILL_FOLDER}/SKILL.md**
61
+ `;
62
+ }
63
+ export function archiveCommandSkillMarkdown() {
64
+ return `---
65
+ name: ${ARCHIVE_SKILL_NAME}
66
+ description: "Archive the active cclaw run from harness flow and reset runtime safely."
67
+ ---
68
+
69
+ # /cc-ops archive
70
+
71
+ ## HARD-GATE
72
+
73
+ Never simulate archive by hand-editing runtime files. Always execute the archive
74
+ runtime command so state snapshots and manifest generation stay atomic.
75
+
76
+ ## Protocol
77
+
78
+ 1. Read \`${flowStatePath()}\`:
79
+ - confirm whether ship is completed,
80
+ - check \`retro.completedAt\` for post-ship runs.
81
+ 2. If ship complete and retro incomplete -> stop and direct user to \`/cc-ops retro\`.
82
+ 3. Build shell command:
83
+ - \`npx cclaw archive\`
84
+ - append \`--name=<slug>\` when provided
85
+ - append \`--skip-retro --retro-reason=<text>\` only when user explicitly requests skip
86
+ 4. Run command from repo root.
87
+ 5. Relay key lines from output:
88
+ - archive destination under \`${runsPath()}\`
89
+ - flow reset confirmation
90
+ - knowledge curation recommendation
91
+
92
+ ## Validation
93
+
94
+ - \`${runsPath()}\` contains a new archive folder.
95
+ - \`${activeArtifactsPath()}\` is reset for the next run.
96
+ - \`${flowStatePath()}\` is valid JSON and points to the initial stage.
97
+ `;
98
+ }
@@ -36,7 +36,7 @@ ${schema.hardGate}
36
36
  ${hydrationLines}
37
37
  4. Stream \`.cclaw/knowledge.jsonl\` and apply relevant JSON-line entries (strict schema: type, trigger, action, confidence, domain, stage, created, project).
38
38
  5. Write stage output to ${writeStepPaths}.
39
- 6. Do NOT copy artifacts into \`.cclaw/runs/\`; archival is handled only by \`cclaw archive\`.
39
+ 6. Do NOT copy artifacts into \`.cclaw/runs/\`; archival is handled by \`/cc-ops archive\` (agent-facing wrapper over archive runtime).
40
40
 
41
41
  ## Gates
42
42
  ${gateIds}
@@ -8,7 +8,7 @@ function snapshotPath() {
8
8
  return `${RUNTIME_ROOT}/state/flow-state.snapshot.json`;
9
9
  }
10
10
  export function diffCommandContract() {
11
- return `# /cc-diff
11
+ return `# /cc-view diff
12
12
 
13
13
  ## Purpose
14
14
 
@@ -54,7 +54,7 @@ name: ${DIFF_SKILL_NAME}
54
54
  description: "Compare current flow-state against saved snapshot and render gate/stage deltas."
55
55
  ---
56
56
 
57
- # /cc-diff
57
+ # /cc-view diff
58
58
 
59
59
  ## HARD-GATE
60
60
 
@@ -14,7 +14,7 @@ function runtimeStatePath() {
14
14
  return `${RUNTIME_ROOT}/state`;
15
15
  }
16
16
  export function featureCommandContract() {
17
- return `# /cc-feature
17
+ return `# /cc-ops feature
18
18
 
19
19
  ## Purpose
20
20
 
@@ -34,19 +34,19 @@ Feature snapshots live under \`${featuresRoot()}/<feature-id>/\`.
34
34
 
35
35
  ## Subcommands
36
36
 
37
- ### \`/cc-feature status\`
37
+ ### \`/cc-ops feature status\`
38
38
  Show active feature id and snapshot location.
39
39
 
40
- ### \`/cc-feature list\`
40
+ ### \`/cc-ops feature list\`
41
41
  List all feature ids in \`${featuresRoot()}/\` (directory names).
42
42
 
43
- ### \`/cc-feature new <feature-id>\`
43
+ ### \`/cc-ops feature new <feature-id>\`
44
44
  Create \`${featuresRoot()}/<feature-id>/artifacts\` and \`${featuresRoot()}/<feature-id>/state\`.
45
45
 
46
46
  Optional flag:
47
47
  - \`--clone-active\`: clone current active runtime into the new feature snapshot.
48
48
 
49
- ### \`/cc-feature switch <feature-id>\`
49
+ ### \`/cc-ops feature switch <feature-id>\`
50
50
  1. Snapshot current active runtime into \`${featuresRoot()}/<active>/\`.
51
51
  2. Restore target snapshot from \`${featuresRoot()}/<feature-id>/\` into active runtime:
52
52
  - \`${runtimeArtifactsPath()}\`
@@ -73,7 +73,7 @@ name: ${FEATURE_SKILL_NAME}
73
73
  description: "Manage cclaw multi-feature workspaces (status/list/new/switch) while preserving active flow runtime."
74
74
  ---
75
75
 
76
- # /cc-feature — Feature Workspace Manager
76
+ # /cc-ops feature — Feature Workspace Manager
77
77
 
78
78
  ## HARD-GATE
79
79
 
@@ -113,7 +113,7 @@ Do not switch feature by editing only \`active-feature.json\`. A valid switch mu
113
113
 
114
114
  ## Safety checks
115
115
 
116
- - If target feature does not exist: block and suggest \`/cc-feature new <id>\`.
116
+ - If target feature does not exist: block and suggest \`/cc-ops feature new <id>\`.
117
117
  - If snapshot copy fails: abort switch, keep current active feature unchanged.
118
118
  - Preserve global pointer file \`active-feature.json\` when restoring state.
119
119
  `;
@@ -65,15 +65,22 @@ All harnesses receive the same utility commands:
65
65
 
66
66
  - \`/cc\` - flow entry and resume
67
67
  - \`/cc-next\` - stage progression
68
+ - \`/cc-view\` - read-only router for status/tree/diff
68
69
  - \`/cc-learn\` - knowledge capture/lookup
69
- - \`/cc-status\` - read-only visual flow snapshot
70
- - \`/cc-tree\` - deep flow tree (stages, artifacts, stale markers)
71
- - \`/cc-diff\` - before/after flow-state diff map
72
- - \`/cc-feature\` - multi-feature workspace management
73
- - \`/cc-tdd-log\` - explicit RED/GREEN/REFACTOR evidence log
74
- - \`/cc-retro\` - mandatory retrospective gate before archive
75
- - \`/cc-rewind\` - rewind flow and invalidate downstream stages
76
- - \`/cc-rewind-ack\` - clear stale stage markers after redo
70
+ - \`/cc-ops\` - operations router for feature/tdd-log/retro/archive/rewind
71
+
72
+ Read-only subcommands:
73
+ - \`/cc-view status\` - visual flow snapshot
74
+ - \`/cc-view tree\` - deep flow tree (stages, artifacts, stale markers)
75
+ - \`/cc-view diff\` - before/after flow-state diff map
76
+
77
+ Operations subcommands:
78
+ - \`/cc-ops feature ...\` - multi-feature workspace management
79
+ - \`/cc-ops tdd-log ...\` - explicit RED/GREEN/REFACTOR evidence log
80
+ - \`/cc-ops retro\` - mandatory retrospective gate before archive
81
+ - \`/cc-ops archive\` - archive active run from harness flow
82
+ - \`/cc-ops rewind ...\` - rewind flow and invalidate downstream stages
83
+ - \`/cc-ops rewind-ack ...\` - clear stale stage markers after redo
77
84
 
78
85
  Stage order remains canonical:
79
86
  \`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
@@ -496,7 +496,7 @@ To disable suggestions persistently set ${RUNTIME_ROOT}/state/suggestion-memory.
496
496
  fi
497
497
  if [ -n "$STALE_STAGES" ]; then
498
498
  CTX="$CTX
499
- Stale stages pending acknowledgement: $STALE_STAGES (use /cc-rewind-ack <stage> after redo)."
499
+ Stale stages pending acknowledgement: $STALE_STAGES (use /cc-ops rewind-ack <stage> after redo)."
500
500
  fi
501
501
  if [ -n "$KNOWLEDGE_DIGEST" ]; then
502
502
  CTX="$CTX
@@ -742,7 +742,7 @@ if [ "$CHECKPOINT_WRITTEN" -eq 0 ]; then
742
742
  CHECKPOINT_NOTE="Checkpoint update failed. Review ${RUNTIME_ROOT}/state/checkpoint.json manually."
743
743
  fi
744
744
 
745
- RUN_SYNC_NOTE="Run metadata sync removed; active artifacts stay in ${RUNTIME_ROOT}/artifacts until cclaw archive."
745
+ RUN_SYNC_NOTE="Run metadata sync removed; active artifacts stay in ${RUNTIME_ROOT}/artifacts until /cc-ops archive (or cclaw archive runtime)."
746
746
 
747
747
  # --- Escape for JSON ---
748
748
  ${ESCAPE_FN}
@@ -5,6 +5,3 @@
5
5
  export declare const KNOWLEDGE_JSONL_FIELDS: readonly ["type", "trigger", "action", "confidence", "domain", "stage", "created", "project"];
6
6
  export declare function learnSkillMarkdown(): string;
7
7
  export declare function learnCommandContract(): string;
8
- export declare function selfImprovementBlock(stageName: string): string;
9
- export declare function learningsSearchPreamble(stage: string): string;
10
- export declare function learningsAgentsMdBlock(): string;
@@ -134,41 +134,3 @@ Do not edit source code from this command. Only operate on \`${KNOWLEDGE_PATH}\`
134
134
  | \`curate\` | — | Hand off to the **knowledge-curation** skill: read-only audit + soft-archive plan when the file exceeds the curation threshold. |
135
135
  `;
136
136
  }
137
- export function selfImprovementBlock(stageName) {
138
- return `## Operational Self-Improvement
139
-
140
- After this stage, ask:
141
- - Did I discover a non-obvious reusable **rule** or **pattern**?
142
- - Did a failure reveal a reusable **lesson**?
143
-
144
- If yes, append one concise JSON line to the canonical knowledge store
145
- (\`${KNOWLEDGE_PATH}\`) using the strict 8-field schema:
146
-
147
- \`\`\`bash
148
- TS="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
149
- printf '%s\\n' '{"type":"pattern","trigger":"when <situation>","action":"<concrete move>","confidence":"medium","domain":null,"stage":"${stageName}","created":"'"$TS"'","project":null}' >> ${KNOWLEDGE_PATH}
150
- \`\`\`
151
-
152
- Type must be exactly one of: \`rule\`, \`pattern\`, \`lesson\`, \`compound\`.
153
- Fields must appear in the order: \`type, trigger, action, confidence, domain, stage, created, project\`.
154
- Missing optional values must be emitted as \`null\`, never omitted.
155
- `;
156
- }
157
- export function learningsSearchPreamble(stage) {
158
- return `## Prior Knowledge (load at stage start)
159
-
160
- Before stage work, stream \`${KNOWLEDGE_PATH}\` and filter for entries relevant to
161
- this stage (\`${stage}\`), affected domains, and key constraints. Apply matching
162
- entries explicitly. If the file is empty, continue normally.
163
- `;
164
- }
165
- export function learningsAgentsMdBlock() {
166
- return `### Knowledge Store
167
-
168
- \`${KNOWLEDGE_PATH}\` — append-only JSONL memory with entry types \`rule\`, \`pattern\`, \`lesson\`, \`compound\`.
169
- Strict 8-field schema: \`type, trigger, action, confidence, domain, stage, created, project\`.
170
- At session start and stage transitions, tail the file and apply relevant entries.
171
- If a non-obvious reusable rule/pattern/lesson is discovered, append a new line
172
- through \`/cc-learn add\` (never hand-edit).
173
- `;
174
- }
@@ -3,7 +3,7 @@ export const META_SKILL_NAME = "using-cclaw";
3
3
  export function usingCclawSkillMarkdown() {
4
4
  return `---
5
5
  name: using-cclaw
6
- description: "Routing brain for cclaw. Decide whether to start/resume a stage, answer directly, or use utility commands like /cc-learn, /cc-status, /cc-tree, and /cc-diff."
6
+ description: "Routing brain for cclaw. Decide whether to start/resume a stage, answer directly, or use utility commands like /cc-learn, /cc-view, and /cc-ops."
7
7
  ---
8
8
 
9
9
  # Using Cclaw
@@ -27,7 +27,8 @@ Task arrives
27
27
  ├─ New software work? -> /cc <idea>
28
28
  ├─ Resume existing flow? -> /cc or /cc-next
29
29
  ├─ Knowledge operation? -> /cc-learn
30
- └─ Workspace operation? -> /cc-status, /cc-tree, /cc-diff, /cc-feature, /cc-tdd-log, /cc-retro, /cc-rewind
30
+ ├─ Read-only workspace view? -> /cc-view [status|tree|diff]
31
+ └─ Workspace operation? -> /cc-ops [feature|tdd-log|retro|archive|rewind|rewind-ack]
31
32
  \`\`\`
32
33
 
33
34
  ## Task classification
@@ -33,13 +33,13 @@ This is the only progression command the user needs to drive the entire flow. St
33
33
 
34
34
  - **Do not** invent gate completion: use only \`${flowPath}\` plus observable evidence in repo artifacts.
35
35
  - **Do not** skip stages: advance only from \`currentStage\` to its configured successor.
36
- - If the flow is at the terminal stage with all ship gates satisfied, **report completion**.
36
+ - If the flow reaches terminal ship completion, route closeout in order: **/cc-ops retro -> /cc-ops archive**.
37
37
 
38
38
  ## Algorithm (mandatory)
39
39
 
40
40
  1. Read **\`${flowPath}\`**. If missing → **BLOCKED** (state missing).
41
41
  2. Parse JSON. Capture \`currentStage\` and \`stageGateCatalog[currentStage]\`.
42
- 3. If \`staleStages[currentStage]\` exists, do not advance automatically. Re-run the stage artifact work, then clear the marker with \`/cc-rewind-ack <currentStage>\`.
42
+ 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>\`.
43
43
  4. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema.
44
44
  5. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state.
45
45
  6. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
@@ -54,7 +54,10 @@ This is the only progression command the user needs to drive the entire flow. St
54
54
 
55
55
  ### Path B: Current stage IS complete (all gates passed, all delegations satisfied)
56
56
 
57
- → If current stage's \`next\` is **\`done\`**: report **"Flow complete. All stages finished."** and stop.
57
+ → If current stage's \`next\` is **\`done\`**:
58
+ - if \`currentStage === "ship"\` and \`retro.completedAt\` is missing -> route to \`/cc-ops retro\`,
59
+ - if \`currentStage === "ship"\` and \`retro.completedAt\` is present -> route to \`/cc-ops archive\`,
60
+ - otherwise report **"Flow complete. All stages finished."** and stop.
58
61
  → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** for the successor stage. Execute that stage's protocol.
59
62
 
60
63
  ### Track-aware successor resolution
@@ -121,7 +124,7 @@ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (p
121
124
 
122
125
  1. Open **\`${flowPath}\`**.
123
126
  2. Record \`currentStage\` and \`stageGateCatalog[currentStage]\`.
124
- 3. If \`staleStages[currentStage]\` exists, re-run the stage and clear marker via \`/cc-rewind-ack <currentStage>\` before advancing.
127
+ 3. If \`staleStages[currentStage]\` exists, re-run the stage and clear marker via \`/cc-ops rewind-ack <currentStage>\` before advancing.
125
128
  4. If the file is missing or invalid JSON → **BLOCKED** (report and stop).
126
129
 
127
130
  ### Step 2: Evaluate gates
@@ -144,7 +147,11 @@ Execute the stage protocol. The stage skill handles interaction, STOP points, ga
144
147
 
145
148
  **Path B — stage IS complete (all gates met, all delegations done):**
146
149
 
147
- If \`next\` is \`done\` → report **"Flow complete. All stages finished."** and stop.
150
+ If \`next\` is \`done\`:
151
+
152
+ - If \`currentStage\` is \`ship\` and \`retro.completedAt\` is missing -> route to \`/cc-ops retro\`.
153
+ - If \`currentStage\` is \`ship\` and \`retro.completedAt\` exists -> route to \`/cc-ops archive\`.
154
+ - Otherwise report **"Flow complete. All stages finished."** and stop.
148
155
 
149
156
  Otherwise load the next stage's skill and command contract, begin execution.
150
157
 
@@ -0,0 +1,2 @@
1
+ export declare function opsCommandContract(): string;
2
+ export declare function opsCommandSkillMarkdown(): string;
@@ -0,0 +1,60 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ const OPS_SKILL_FOLDER = "flow-ops";
3
+ const OPS_SKILL_NAME = "flow-ops";
4
+ export function opsCommandContract() {
5
+ return `# /cc-ops
6
+
7
+ ## Purpose
8
+
9
+ Unified operational command surface for non-stage flow actions.
10
+
11
+ Subcommands:
12
+ - \`feature\` -> \`/cc-ops feature\`
13
+ - \`tdd-log\` -> \`/cc-ops tdd-log\`
14
+ - \`retro\` -> \`/cc-ops retro\`
15
+ - \`archive\` -> \`/cc-ops archive\`
16
+ - \`rewind\` -> \`/cc-ops rewind\`
17
+ - \`rewind-ack\` -> \`/cc-ops rewind-ack\`
18
+
19
+ ## HARD-GATE
20
+
21
+ - \`/cc-ops\` is a routing wrapper; execute only one target subcommand per call.
22
+ - Preserve target command safety contracts (retro gate, archive gate, rewind atomicity, etc.).
23
+
24
+ ## Routing
25
+
26
+ 1. Parse required subcommand token.
27
+ 2. Dispatch:
28
+ - \`feature\` -> \`${RUNTIME_ROOT}/commands/feature.md\`
29
+ - \`tdd-log\` -> \`${RUNTIME_ROOT}/commands/tdd-log.md\`
30
+ - \`retro\` -> \`${RUNTIME_ROOT}/commands/retro.md\`
31
+ - \`archive\` -> \`${RUNTIME_ROOT}/commands/archive.md\`
32
+ - \`rewind\` -> \`${RUNTIME_ROOT}/commands/rewind.md\`
33
+ - \`rewind-ack\` -> \`${RUNTIME_ROOT}/commands/rewind-ack.md\`
34
+ 3. Unknown subcommand -> print supported values and stop.
35
+
36
+ ## Primary skill
37
+
38
+ **${RUNTIME_ROOT}/skills/${OPS_SKILL_FOLDER}/SKILL.md**
39
+ `;
40
+ }
41
+ export function opsCommandSkillMarkdown() {
42
+ return `---
43
+ name: ${OPS_SKILL_NAME}
44
+ description: "Unified operational router for feature/tdd-log/retro/archive/rewind commands."
45
+ ---
46
+
47
+ # /cc-ops
48
+
49
+ ## HARD-GATE
50
+
51
+ This wrapper only dispatches. It must not apply state mutations itself.
52
+
53
+ ## Protocol
54
+
55
+ 1. Require a subcommand (\`feature|tdd-log|retro|archive|rewind|rewind-ack\`).
56
+ 2. Route to the matching command contract + skill pair.
57
+ 3. Preserve pass-through args after the subcommand (e.g. \`/cc-ops rewind design\`).
58
+ 4. Echo which subcommand was dispatched for auditability.
59
+ `;
60
+ }
@@ -46,8 +46,20 @@ Shared closeout sequence applied by every stage skill.
46
46
  - update \`guardEvidence\`.
47
47
  3. Persist stage artifact under \`.cclaw/artifacts/\`.
48
48
  4. Run \`npx cclaw doctor\` and resolve failures.
49
- 5. Notify user with stage completion and next action (\`/cc-next\`).
50
- 6. Stop; do not auto-run the next stage unless user asks.
49
+ 5. Capture reusable learnings from this stage artifact:
50
+ - append 1-3 strict-schema JSONL entries when the stage produced non-obvious
51
+ decisions, patterns, or lessons,
52
+ - use \`type=rule|pattern|lesson\` (\`compound\` stays retro-focused).
53
+ 6. Notify user with stage completion and next action (\`/cc-next\`).
54
+ 7. Stop; do not auto-run the next stage unless user asks.
55
+
56
+ ## Automatic learning capture policy
57
+
58
+ - \`standard\` / \`medium\` tracks: required for \`design\`, \`tdd\`, and \`review\`;
59
+ recommended for other stages.
60
+ - \`quick\` track: recommended only (avoid overhead for tiny fixes).
61
+ - "No learning captured" is acceptable only when explicitly justified (e.g. pure
62
+ mechanical change, no new trade-offs).
51
63
 
52
64
  ## Resume protocol
53
65
 
@@ -11,7 +11,7 @@ function knowledgePath() {
11
11
  return `${RUNTIME_ROOT}/knowledge.jsonl`;
12
12
  }
13
13
  export function retroCommandContract() {
14
- return `# /cc-retro
14
+ return `# /cc-ops retro
15
15
 
16
16
  ## Purpose
17
17
 
@@ -36,7 +36,7 @@ Mandatory retrospective gate before archive once ship is complete.
36
36
  - \`required: true\`
37
37
  - \`completedAt: <ISO>\`
38
38
  - \`compoundEntries: <count>\`
39
- 5. Report completion summary and remind user that \`cclaw archive\` is now unblocked.
39
+ 5. Report completion summary and remind user that \`/cc-ops archive\` is now unblocked.
40
40
 
41
41
  ## Primary skill
42
42
 
@@ -49,7 +49,7 @@ name: ${RETRO_SKILL_NAME}
49
49
  description: "Run mandatory retrospective and record compound knowledge before archive."
50
50
  ---
51
51
 
52
- # /cc-retro
52
+ # /cc-ops retro
53
53
 
54
54
  ## HARD-GATE
55
55
 
@@ -11,7 +11,7 @@ function rewindLogPath() {
11
11
  return `${RUNTIME_ROOT}/state/rewind-log.jsonl`;
12
12
  }
13
13
  export function rewindCommandContract() {
14
- return `# /cc-rewind
14
+ return `# /cc-ops rewind
15
15
 
16
16
  ## Purpose
17
17
 
@@ -25,7 +25,7 @@ Rewind active flow to an earlier stage and atomically invalidate downstream work
25
25
 
26
26
  ## Inputs
27
27
 
28
- \`/cc-rewind <target-stage> [reason]\`
28
+ \`/cc-ops rewind <target-stage> [reason]\`
29
29
 
30
30
  ## Algorithm
31
31
 
@@ -55,7 +55,7 @@ Rewind active flow to an earlier stage and atomically invalidate downstream work
55
55
  `;
56
56
  }
57
57
  export function rewindAcknowledgeCommandContract() {
58
- return `# /cc-rewind-ack
58
+ return `# /cc-ops rewind-ack
59
59
 
60
60
  ## Purpose
61
61
 
@@ -63,7 +63,7 @@ Acknowledge and clear stale-stage markers after downstream work is intentionally
63
63
 
64
64
  ## Input
65
65
 
66
- \`/cc-rewind-ack <stage>\`
66
+ \`/cc-ops rewind-ack <stage>\`
67
67
 
68
68
  ## HARD-GATE
69
69
 
@@ -89,7 +89,7 @@ name: ${REWIND_SKILL_NAME}
89
89
  description: "Rewind active flow stage safely and acknowledge stale invalidations."
90
90
  ---
91
91
 
92
- # /cc-rewind + /cc-rewind-ack
92
+ # /cc-ops rewind + /cc-ops rewind-ack
93
93
 
94
94
  ## HARD-GATE
95
95
 
@@ -24,9 +24,9 @@ Use this same closeout menu for every stage:
24
24
 
25
25
  - **A) Advance** — run \`/cc-next\` and continue.
26
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.
27
+ - **C) Pause / park** — run \`/cc-view status\`, then stop and resume later.
28
+ - **D) Rewind** — run \`/cc-ops rewind <target-stage>\`.
29
+ - **E) Abandon** — archive with \`/cc-ops archive --skip-retro --retro-reason="<reason>"\` when user explicitly wants to end the run.
30
30
 
31
31
  Recommendation defaults:
32
32
 
@@ -58,8 +58,17 @@ Rollback / fallback: <if decision proves wrong>
58
58
 
59
59
  ## Self-improvement reminder
60
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.
61
+ Before closeout, capture 1-3 reusable insights in \`.cclaw/knowledge.jsonl\`
62
+ whenever the stage produced non-obvious decisions, patterns, or lessons.
63
+ Prefer \`type=rule|pattern|lesson\` (\`compound\` stays retro-focused).
64
+
65
+ Track policy:
66
+ - \`standard\` / \`medium\`: required for \`design\`, \`tdd\`, and \`review\`;
67
+ recommended for other stages.
68
+ - \`quick\`: recommended only.
69
+
70
+ "No learning captured" is acceptable only with an explicit reason
71
+ (for example, purely mechanical edits with no new decisions).
63
72
 
64
73
  ## Progressive disclosure baseline
65
74