cclaw-cli 0.41.0 → 0.42.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.
package/README.md CHANGED
@@ -152,7 +152,7 @@ inside `/cc-ops` subcommands.
152
152
  |---|---|
153
153
  | **`/cc <idea>`** | Classify the task, discover origin docs (`docs/prd/**`, ADRs, root `PRD.md`, …), sniff the stack, recommend a track, then start the first stage of that track. `/cc` without arguments resumes the current flow. |
154
154
  | **`/cc-next`** | The one progression primitive. Reads `flow-state.json`, checks gates + mandatory subagent delegations, and either resumes the current stage or advances to the next. `/cc-next` in a new session is how you **resume**. |
155
- | **`/cc-ideate`** | Repository improvement discovery. Scans for TODOs, flaky tests, oversized modules, docs drift, and recurring knowledge-store lessons; returns a ranked backlog before you commit to a specific feature. |
155
+ | **`/cc-ideate`** | Repository improvement discovery. Scans for TODOs, flaky tests, oversized modules, docs drift, and recurring knowledge-store lessons, **persists the ranked backlog** to `.cclaw/artifacts/ideation-<date>-<slug>.md`, and ends with a concrete handoff: launch `/cc` on the selected candidate in the same session, save-and-close, or discard. Resume check on next run reuses any ideation artifact younger than 30 days. Never mutates `flow-state.json`. |
156
156
  | **`/cc-view`** | Read-only flow visibility. `/cc-view status` (default) shows stage progress, mandatory delegations with their fulfillment mode (isolated / generic-dispatch / role-switch), the ship closeout substate (retro → compound → archive), and the active harness parity row. `/cc-view tree` renders the same picture as a tree with a closeout sub-branch under ship and a per-harness playbook summary. `/cc-view diff` shows stage/gate/closeout/delegation deltas since the last run. Never mutates state (except diff's snapshot baseline). |
157
157
 
158
158
  > Power-user surface: `/cc-ops` is an operational router for manual
@@ -1,2 +1,9 @@
1
1
  export declare function ideateCommandContract(): string;
2
2
  export declare function ideateCommandSkillMarkdown(): string;
3
+ /**
4
+ * Exposed for tests and docs that need to mention the artifact convention
5
+ * without hard-coding the path string in two places.
6
+ */
7
+ export declare const IDEATION_ARTIFACT_PATH_PATTERN = ".cclaw/artifacts/ideation-<YYYY-MM-DD-slug>.md";
8
+ export declare const IDEATION_ARTIFACT_GLOB_PATTERN = ".cclaw/artifacts/ideation-*.md";
9
+ export declare const IDEATION_RESUME_WINDOW = 30;
@@ -1,39 +1,62 @@
1
1
  import { RUNTIME_ROOT } from "../constants.js";
2
2
  const IDEATE_SKILL_FOLDER = "flow-ideate";
3
3
  const IDEATE_SKILL_NAME = "flow-ideate";
4
+ /**
5
+ * Directory + filename convention for ideation artifacts. These are separate
6
+ * from stage artifacts (00-..08-*.md) because `/cc-ideate` runs outside the
7
+ * critical-path flow state machine and must not collide with stage numbering.
8
+ */
9
+ const IDEATION_ARTIFACT_GLOB = ".cclaw/artifacts/ideation-*.md";
10
+ const IDEATION_ARTIFACT_PATTERN = ".cclaw/artifacts/ideation-<YYYY-MM-DD-slug>.md";
11
+ const IDEATION_RESUME_WINDOW_DAYS = 30;
12
+ /**
13
+ * Structured-ask tool list reused across cclaw skills. Kept inline here (small
14
+ * enough) to avoid cross-module coupling; larger stage skills cite the shared
15
+ * protocol file instead.
16
+ */
17
+ const STRUCTURED_ASK_TOOLS = "`AskUserQuestion` on Claude, `AskQuestion` on Cursor, " +
18
+ "`question` on OpenCode when `permission.question: \"allow\"` is set, " +
19
+ "`request_user_input` on Codex in Plan / Collaboration mode; " +
20
+ "fall back to a plain-text lettered list when the tool is hidden or errors";
4
21
  export function ideateCommandContract() {
5
22
  return `# /cc-ideate
6
23
 
7
24
  ## Purpose
8
25
 
9
- Repository-improvement discovery mode. Generate a ranked backlog of high-value
10
- improvements before committing to a specific feature request.
26
+ Repository-improvement discovery mode. Generate a ranked backlog of
27
+ high-value improvements, persist it as an artifact on disk, and end with
28
+ an explicit handoff — either launch \`/cc\` on a chosen candidate in the
29
+ same session, or save/discard the backlog.
11
30
 
12
31
  ## HARD-GATE
13
32
 
14
- - This is discovery mode only. Do not start implementation automatically.
15
- - Every recommendation must include evidence from the current repository.
16
- - End with a decision prompt: pick one candidate or cancel.
33
+ - Discovery mode only. Never mutate \`.cclaw/state/flow-state.json\`.
34
+ - Every recommendation cites evidence from the current repository
35
+ (file path, command output, or knowledge-store entry id).
36
+ - Always write a persisted artifact to
37
+ \`${IDEATION_ARTIFACT_PATTERN}\`. Chat-only output is not acceptable —
38
+ the next session must be able to resume.
39
+ - Always end with a structured handoff prompt, not an open question.
17
40
 
18
41
  ## Algorithm
19
42
 
20
- 1. Scan repo signals:
21
- - open TODO/backlog notes
22
- - flaky or failing tests
23
- - oversized modules / complexity hotspots
24
- - docs drift vs changed code
25
- - repeated learnings from \`.cclaw/knowledge.jsonl\`
26
- 2. Produce 5-10 candidates with:
27
- - impact (High/Medium/Low)
28
- - effort (S/M/L)
29
- - confidence (High/Medium/Low)
30
- - evidence path(s)
31
- 3. Rank candidates by impact/effort ratio.
32
- 4. Present one recommendation as default.
33
- 5. Ask user to choose:
34
- - (A) start with recommended item
35
- - (B) choose another candidate
36
- - (C) cancel
43
+ 1. **Resume check.** Glob \`${IDEATION_ARTIFACT_GLOB}\`. If any artifact
44
+ has been modified within the last ${IDEATION_RESUME_WINDOW_DAYS} days,
45
+ offer the user: continue that backlog, start fresh, or cancel.
46
+ 2. **Scan repo signals:**
47
+ - open TODO/FIXME/XXX/HACK notes,
48
+ - flaky or failing tests,
49
+ - oversized modules / complexity hotspots,
50
+ - docs drift vs changed code,
51
+ - repeated entries in \`${RUNTIME_ROOT}/knowledge.jsonl\`.
52
+ 3. **Produce 5-10 candidates** with impact (High/Medium/Low),
53
+ effort (S/M/L), confidence (High/Medium/Low), and one evidence path
54
+ per candidate.
55
+ 4. **Rank by impact/effort**, recommend the top item.
56
+ 5. **Write the artifact** at
57
+ \`${IDEATION_ARTIFACT_PATTERN}\` using the schema in the skill.
58
+ 6. **Present the handoff prompt** with four concrete options — not A/B/C
59
+ letters. Default = "Start /cc on the top recommendation".
37
60
 
38
61
  ## Primary skill
39
62
 
@@ -43,31 +66,152 @@ improvements before committing to a specific feature request.
43
66
  export function ideateCommandSkillMarkdown() {
44
67
  return `---
45
68
  name: ${IDEATE_SKILL_NAME}
46
- description: "Repository ideation mode: detect and rank high-leverage improvements before implementation."
69
+ description: "Repository ideation mode: detect and rank high-leverage improvements, persist a backlog artifact, and hand off to /cc or save/discard."
47
70
  ---
48
71
 
49
72
  # /cc-ideate
50
73
 
51
74
  ## Announce at start
52
75
 
53
- "Using flow-ideate to identify highest-leverage improvements in this repository."
76
+ "Using flow-ideate to identify highest-leverage improvements in this
77
+ repository. Will persist a ranked backlog to
78
+ \`${IDEATION_ARTIFACT_PATTERN}\` and end with an explicit handoff."
54
79
 
55
80
  ## HARD-GATE
56
81
 
57
- Do not start coding in ideate mode. End with an explicit user choice.
82
+ - Do not start coding in ideate mode.
83
+ - Do not mutate \`.cclaw/state/flow-state.json\` — ideation sits outside
84
+ the critical-path flow.
85
+ - Always produce the artifact file on disk before presenting the handoff.
86
+ - Always end with a structured handoff that names the concrete follow-up
87
+ command for each option. No A/B/C letters without command context.
58
88
 
59
89
  ## Protocol
60
90
 
61
- 1. Collect evidence from the current repo state.
62
- 2. Build candidate improvements with impact/effort/confidence.
63
- 3. Rank and recommend one candidate.
64
- 4. Ask for explicit selection.
65
- 5. If user selects a candidate, hand off to \`/cc <selected idea>\`.
91
+ ### Phase 0 Resume check
66
92
 
67
- ## Candidate format
93
+ 1. Use the harness's file-glob tool (\`Glob\` pattern
94
+ \`${IDEATION_ARTIFACT_GLOB}\` or equivalent \`ls\`/\`find\`).
95
+ 2. Filter to files modified within the last ${IDEATION_RESUME_WINDOW_DAYS} days.
96
+ 3. If one or more match, present **one** structured ask using the
97
+ harness's native tool (${STRUCTURED_ASK_TOOLS}) with options:
98
+ - **Continue the existing backlog** — read the most-recent
99
+ ideation-*.md and work from its candidate list; skip re-scanning.
100
+ - **Start a fresh scan** — proceed to Phase 1; the old artifact stays
101
+ on disk for history.
102
+ - **Cancel** — stop; do not scan or write anything.
103
+ 4. If no recent artifact exists, proceed to Phase 1 silently.
68
104
 
69
- | ID | Improvement | Impact | Effort | Confidence | Evidence |
70
- |---|---|---|---|---|---|
71
- | I-1 | | High/Medium/Low | S/M/L | High/Medium/Low | path or command evidence |
105
+ ### Phase 1 Collect evidence
106
+
107
+ Scan the current repo. Examples of signals (not exhaustive):
108
+
109
+ - \`rg -n 'TODO|FIXME|XXX|HACK|TBD'\` grouped by file.
110
+ - Test-runner output (\`npm test\`, \`pytest\`, \`go test ./...\`) — note
111
+ failures, timeouts, deprecation warnings.
112
+ - Module size outliers (\`wc -l\` or \`du\`) with weak direct test coverage.
113
+ - Docs drift: check that \`README.md\` / \`docs/\` reference files that
114
+ still exist and flags/APIs that still match \`src/\`.
115
+ - \`${RUNTIME_ROOT}/knowledge.jsonl\` entries with \`type: "heuristic"\`
116
+ or repeated \`subject:\` values.
117
+
118
+ Record each finding with the exact file path or command that produced it.
119
+
120
+ ### Phase 2 — Build candidates
121
+
122
+ For each high-signal finding, construct a candidate:
123
+
124
+ - **ID** — \`I-1\`, \`I-2\`, …
125
+ - **Title** — one short imperative phrase
126
+ - **Impact** — High / Medium / Low
127
+ - **Effort** — S / M / L
128
+ - **Confidence** — High / Medium / Low
129
+ - **Evidence** — path(s) or command output, inline if short
130
+ - **Proposed handoff** — the exact \`/cc <phrase>\` the user would run
131
+ to act on this candidate
132
+
133
+ Aim for 5–10 candidates. Do not invent candidates without evidence.
134
+
135
+ ### Phase 3 — Rank and write the artifact
136
+
137
+ 1. Sort by impact/effort ratio; break ties with confidence.
138
+ 2. Compute the artifact filename:
139
+ - \`slug\` = first 3–5 words of the top recommendation, lowercase,
140
+ non-alphanumeric collapsed to \`-\`, trimmed. When ideation is
141
+ focus-hinted (user passed an argument), use the focus hint instead.
142
+ - \`date\` = today in \`YYYY-MM-DD\` (local time).
143
+ - Path = \`.cclaw/artifacts/ideation-<date>-<slug>.md\`.
144
+ 3. Use the harness's write-file tool (\`Write\`, \`apply_patch\`, or shell
145
+ \`cat <<EOF > path\`) to create the artifact with this schema:
146
+
147
+ \`\`\`markdown
148
+ # Ideation — <date>
149
+
150
+ **Focus:** <user-supplied focus or "open-ended scan">
151
+ **Generated:** <ISO-8601 timestamp>
152
+ **Recommendation:** I-1
153
+
154
+ ## Ranked backlog
155
+
156
+ | ID | Improvement | Impact | Effort | Confidence | Evidence |
157
+ |---|---|---|---|---|---|
158
+ | I-1 | Fix feature-worktree test timeouts | High | S | High | tests/unit/feature-system.test.ts:31 |
159
+ | … | … | … | … | … | … |
160
+
161
+ ## Candidate detail
162
+
163
+ ### I-1 — Fix feature-worktree test timeouts
164
+ - **Evidence:** \`npm test\` hangs 40s on tests/unit/feature-system.test.ts:31.
165
+ - **Handoff:** \`/cc Fix feature-worktree test timeouts on macOS\`
166
+
167
+ ### I-2 — …
168
+ \`\`\`
169
+
170
+ 4. Confirm in chat: "Wrote <path>."
171
+
172
+ ### Phase 4 — Handoff prompt
173
+
174
+ Present **one** structured ask using the harness's native tool
175
+ (${STRUCTURED_ASK_TOOLS}). Each option must name the concrete follow-up —
176
+ no bare A/B/C.
177
+
178
+ Required options, in this order:
179
+
180
+ 1. **Start /cc on the top recommendation** — the agent immediately loads
181
+ \`${RUNTIME_ROOT}/skills/using-cclaw/SKILL.md\` and invokes
182
+ \`/cc <I-1 handoff phrase>\` in the same turn. Default choice.
183
+ 2. **Pick a different candidate** — the agent asks which ID (I-2, I-3, …)
184
+ and then invokes \`/cc <that candidate's handoff phrase>\`.
185
+ 3. **Save and close** — leave the artifact on disk, do nothing else.
186
+ Next session: \`/cc-ideate\` will offer to resume it.
187
+ 4. **Discard** — delete the just-written artifact. Use only when the
188
+ scan produced nothing actionable.
189
+
190
+ When the structured-ask tool is unavailable, fall back to a plain-text
191
+ lettered list with the same four labels. Do not invent extra options.
192
+
193
+ ### Phase 5 — Execute the choice
194
+
195
+ - **Start /cc on I-1** or **different candidate:** announce
196
+ "Handing off to /cc <phrase>" and load the \`using-cclaw\` router
197
+ skill. From there, the normal \`/cc\` classification and stage flow
198
+ takes over. Do not produce a second artifact; the ideation file is
199
+ preserved as the origin document for this run.
200
+ - **Save and close:** reply with the artifact path and stop.
201
+ - **Discard:** delete the artifact file, confirm deletion, stop.
202
+
203
+ ## Do not
204
+
205
+ - Do not write into \`.cclaw/artifacts/0X-*.md\` (stage artifacts).
206
+ - Do not mutate \`.cclaw/state/flow-state.json\` at any phase.
207
+ - Do not end the turn with an ungrounded "pick one" question — every
208
+ option in the handoff prompt must reference a concrete command.
72
209
  `;
73
210
  }
211
+ /**
212
+ * Exposed for tests and docs that need to mention the artifact convention
213
+ * without hard-coding the path string in two places.
214
+ */
215
+ export const IDEATION_ARTIFACT_PATH_PATTERN = IDEATION_ARTIFACT_PATTERN;
216
+ export const IDEATION_ARTIFACT_GLOB_PATTERN = IDEATION_ARTIFACT_GLOB;
217
+ export const IDEATION_RESUME_WINDOW = IDEATION_RESUME_WINDOW_DAYS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {