claude-code-workflow 6.3.43 → 6.3.46

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 (78) hide show
  1. package/.claude/agents/tdd-developer.md +530 -0
  2. package/.claude/commands/ccw-coordinator.md +1042 -0
  3. package/.claude/commands/ccw.md +486 -0
  4. package/.claude/commands/issue/discover-by-prompt.md +5 -1
  5. package/.claude/commands/issue/discover.md +472 -468
  6. package/.claude/commands/issue/execute.md +580 -581
  7. package/.claude/commands/issue/new.md +417 -413
  8. package/.claude/commands/issue/plan.md +5 -1
  9. package/.claude/commands/issue/queue.md +445 -441
  10. package/.claude/commands/task/breakdown.md +207 -203
  11. package/.claude/commands/task/replan.md +440 -436
  12. package/.claude/commands/workflow/action-plan-verify.md +485 -447
  13. package/.claude/commands/workflow/brainstorm/artifacts.md +457 -453
  14. package/.claude/commands/workflow/brainstorm/auto-parallel.md +5 -1
  15. package/.claude/commands/workflow/brainstorm/synthesis.md +402 -398
  16. package/.claude/commands/workflow/clean.md +67 -35
  17. package/.claude/commands/workflow/debug-with-file.md +670 -666
  18. package/.claude/commands/workflow/debug.md +331 -327
  19. package/.claude/commands/workflow/develop-with-file.md +5 -1
  20. package/.claude/commands/workflow/execute.md +546 -498
  21. package/.claude/commands/workflow/lite-execute.md +44 -26
  22. package/.claude/commands/workflow/lite-fix.md +780 -730
  23. package/.claude/commands/workflow/lite-lite-lite.md +5 -1
  24. package/.claude/commands/workflow/lite-plan.md +87 -39
  25. package/.claude/commands/workflow/multi-cli-plan.md +572 -568
  26. package/.claude/commands/workflow/plan-verify.md +527 -0
  27. package/.claude/commands/workflow/plan.md +555 -551
  28. package/.claude/commands/workflow/replan.md +572 -515
  29. package/.claude/commands/workflow/review-fix.md +608 -610
  30. package/.claude/commands/workflow/session/complete.md +37 -14
  31. package/.claude/commands/workflow/session/solidify.md +303 -299
  32. package/.claude/commands/workflow/tdd-plan.md +630 -597
  33. package/.claude/commands/workflow/tdd-verify.md +391 -206
  34. package/.claude/commands/workflow/tools/conflict-resolution.md +24 -12
  35. package/.claude/commands/workflow/tools/task-generate-agent.md +583 -563
  36. package/.claude/commands/workflow/tools/task-generate-tdd.md +749 -517
  37. package/.claude/commands/workflow/ui-design/animation-extract.md +1154 -1150
  38. package/.claude/commands/workflow/ui-design/layout-extract.md +792 -788
  39. package/.claude/commands/workflow/ui-design/style-extract.md +777 -773
  40. package/.claude/skills/ccw-help/command.json +5 -5
  41. package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -337
  42. package/.claude/workflows/cli-templates/prompts/workflow-impl-plan-template.txt +1 -1
  43. package/ccw/dist/commands/issue.d.ts +4 -0
  44. package/ccw/dist/commands/issue.d.ts.map +1 -1
  45. package/ccw/dist/commands/issue.js +73 -6
  46. package/ccw/dist/commands/issue.js.map +1 -1
  47. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  48. package/ccw/dist/core/routes/cli-routes.js +32 -28
  49. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  50. package/ccw/dist/tools/claude-cli-tools.d.ts +10 -0
  51. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  52. package/ccw/dist/tools/claude-cli-tools.js +45 -0
  53. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  54. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  55. package/ccw/dist/tools/codex-lens.js +38 -11
  56. package/ccw/dist/tools/codex-lens.js.map +1 -1
  57. package/ccw/dist/tools/command-registry.d.ts +77 -0
  58. package/ccw/dist/tools/command-registry.d.ts.map +1 -0
  59. package/ccw/dist/tools/command-registry.js +265 -0
  60. package/ccw/dist/tools/command-registry.js.map +1 -0
  61. package/ccw/dist/tools/command-registry.test.d.ts +14 -0
  62. package/ccw/dist/tools/command-registry.test.d.ts.map +1 -0
  63. package/ccw/dist/tools/command-registry.test.js.map +1 -0
  64. package/ccw/dist/tools/index.d.ts +2 -0
  65. package/ccw/dist/tools/index.d.ts.map +1 -1
  66. package/ccw/dist/tools/index.js +2 -0
  67. package/ccw/dist/tools/index.js.map +1 -1
  68. package/ccw/src/commands/issue.ts +84 -6
  69. package/ccw/src/core/routes/cli-routes.ts +30 -25
  70. package/ccw/src/templates/dashboard-js/views/help.js +1 -1
  71. package/ccw/src/tools/claude-cli-tools.ts +50 -0
  72. package/ccw/src/tools/codex-lens.ts +40 -11
  73. package/ccw/src/tools/command-registry.test.ts +669 -0
  74. package/ccw/src/tools/command-registry.ts +308 -0
  75. package/ccw/src/tools/index.ts +4 -0
  76. package/package.json +1 -1
  77. package/.claude/skills/ccw/SKILL.md +0 -522
  78. package/.claude/skills/ccw/command.json +0 -641
@@ -1,327 +1,331 @@
1
- ---
2
- name: debug
3
- description: Interactive hypothesis-driven debugging with NDJSON logging, iterative until resolved
4
- argument-hint: "\"bug description or error message\""
5
- allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
6
- ---
7
-
8
- # Workflow Debug Command (/workflow:debug)
9
-
10
- ## Overview
11
-
12
- Evidence-based interactive debugging command. Systematically identifies root causes through hypothesis-driven logging and iterative verification.
13
-
14
- **Core workflow**: Explore → Add Logging → Reproduce → Analyze Log → Fix → Verify
15
-
16
- ## Usage
17
-
18
- ```bash
19
- /workflow:debug <BUG_DESCRIPTION>
20
-
21
- # Arguments
22
- <bug-description> Bug description, error message, or stack trace (required)
23
- ```
24
-
25
- ## Execution Process
26
-
27
- ```
28
- Session Detection:
29
- ├─ Check if debug session exists for this bug
30
- ├─ EXISTS + debug.log has content → Analyze mode
31
- └─ NOT_FOUND or empty log → Explore mode
32
-
33
- Explore Mode:
34
- ├─ Locate error source in codebase
35
- ├─ Generate testable hypotheses (dynamic count)
36
- ├─ Add NDJSON logging instrumentation
37
- └─ Output: Hypothesis list + await user reproduction
38
-
39
- Analyze Mode:
40
- ├─ Parse debug.log, validate each hypothesis
41
- └─ Decision:
42
- ├─ Confirmed → Fix root cause
43
- ├─ Inconclusive → Add more logging, iterate
44
- └─ All rejected Generate new hypotheses
45
-
46
- Fix & Cleanup:
47
- ├─ Apply fix based on confirmed hypothesis
48
- ├─ User verifies
49
- ├─ Remove debug instrumentation
50
- └─ If not fixed → Return to Analyze mode
51
- ```
52
-
53
- ## Implementation
54
-
55
- ### Session Setup & Mode Detection
56
-
57
- ```javascript
58
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
59
-
60
- const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
61
- const dateStr = getUtc8ISOString().substring(0, 10)
62
-
63
- const sessionId = `DBG-${bugSlug}-${dateStr}`
64
- const sessionFolder = `.workflow/.debug/${sessionId}`
65
- const debugLogPath = `${sessionFolder}/debug.log`
66
-
67
- // Auto-detect mode
68
- const sessionExists = fs.existsSync(sessionFolder)
69
- const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
70
-
71
- const mode = logHasContent ? 'analyze' : 'explore'
72
-
73
- if (!sessionExists) {
74
- bash(`mkdir -p ${sessionFolder}`)
75
- }
76
- ```
77
-
78
- ---
79
-
80
- ### Explore Mode
81
-
82
- **Step 1.1: Locate Error Source**
83
-
84
- ```javascript
85
- // Extract keywords from bug description
86
- const keywords = extractErrorKeywords(bug_description)
87
- // e.g., ['Stack Length', '未找到', 'registered 0']
88
-
89
- // Search codebase for error locations
90
- for (const keyword of keywords) {
91
- Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
92
- }
93
-
94
- // Identify affected files and functions
95
- const affectedLocations = [...] // from search results
96
- ```
97
-
98
- **Step 1.2: Generate Hypotheses (Dynamic)**
99
-
100
- ```javascript
101
- // Hypothesis categories based on error pattern
102
- const HYPOTHESIS_PATTERNS = {
103
- "not found|missing|undefined|未找到": "data_mismatch",
104
- "0|empty|zero|registered 0": "logic_error",
105
- "timeout|connection|sync": "integration_issue",
106
- "type|format|parse": "type_mismatch"
107
- }
108
-
109
- // Generate hypotheses based on actual issue (NOT fixed count)
110
- function generateHypotheses(bugDescription, affectedLocations) {
111
- const hypotheses = []
112
-
113
- // Analyze bug and create targeted hypotheses
114
- // Each hypothesis has:
115
- // - id: H1, H2, ... (dynamic count)
116
- // - description: What might be wrong
117
- // - testable_condition: What to log
118
- // - logging_point: Where to add instrumentation
119
-
120
- return hypotheses // Could be 1, 3, 5, or more
121
- }
122
-
123
- const hypotheses = generateHypotheses(bug_description, affectedLocations)
124
- ```
125
-
126
- **Step 1.3: Add NDJSON Instrumentation**
127
-
128
- For each hypothesis, add logging at the relevant location:
129
-
130
- **Python template**:
131
- ```python
132
- # region debug [H{n}]
133
- try:
134
- import json, time
135
- _dbg = {
136
- "sid": "{sessionId}",
137
- "hid": "H{n}",
138
- "loc": "{file}:{line}",
139
- "msg": "{testable_condition}",
140
- "data": {
141
- # Capture relevant values here
142
- },
143
- "ts": int(time.time() * 1000)
144
- }
145
- with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
146
- _f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
147
- except: pass
148
- # endregion
149
- ```
150
-
151
- **JavaScript/TypeScript template**:
152
- ```javascript
153
- // region debug [H{n}]
154
- try {
155
- require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
156
- sid: "{sessionId}",
157
- hid: "H{n}",
158
- loc: "{file}:{line}",
159
- msg: "{testable_condition}",
160
- data: { /* Capture relevant values */ },
161
- ts: Date.now()
162
- }) + "\n");
163
- } catch(_) {}
164
- // endregion
165
- ```
166
-
167
- **Output to user**:
168
- ```
169
- ## Hypotheses Generated
170
-
171
- Based on error "{bug_description}", generated {n} hypotheses:
172
-
173
- {hypotheses.map(h => `
174
- ### ${h.id}: ${h.description}
175
- - Logging at: ${h.logging_point}
176
- - Testing: ${h.testable_condition}
177
- `).join('')}
178
-
179
- **Debug log**: ${debugLogPath}
180
-
181
- **Next**: Run reproduction steps, then come back for analysis.
182
- ```
183
-
184
- ---
185
-
186
- ### Analyze Mode
187
-
188
- ```javascript
189
- // Parse NDJSON log
190
- const entries = Read(debugLogPath).split('\n')
191
- .filter(l => l.trim())
192
- .map(l => JSON.parse(l))
193
-
194
- // Group by hypothesis
195
- const byHypothesis = groupBy(entries, 'hid')
196
-
197
- // Validate each hypothesis
198
- for (const [hid, logs] of Object.entries(byHypothesis)) {
199
- const hypothesis = hypotheses.find(h => h.id === hid)
200
- const latestLog = logs[logs.length - 1]
201
-
202
- // Check if evidence confirms or rejects hypothesis
203
- const verdict = evaluateEvidence(hypothesis, latestLog.data)
204
- // Returns: 'confirmed' | 'rejected' | 'inconclusive'
205
- }
206
- ```
207
-
208
- **Output**:
209
- ```
210
- ## Evidence Analysis
211
-
212
- Analyzed ${entries.length} log entries.
213
-
214
- ${results.map(r => `
215
- ### ${r.id}: ${r.description}
216
- - **Status**: ${r.verdict}
217
- - **Evidence**: ${JSON.stringify(r.evidence)}
218
- - **Reason**: ${r.reason}
219
- `).join('')}
220
-
221
- ${confirmedHypothesis ? `
222
- ## Root Cause Identified
223
-
224
- **${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
225
-
226
- Ready to fix.
227
- ` : `
228
- ## Need More Evidence
229
-
230
- Add more logging or refine hypotheses.
231
- `}
232
- ```
233
-
234
- ---
235
-
236
- ### Fix & Cleanup
237
-
238
- ```javascript
239
- // Apply fix based on confirmed hypothesis
240
- // ... Edit affected files
241
-
242
- // After user verifies fix works:
243
-
244
- // Remove debug instrumentation (search for region markers)
245
- const instrumentedFiles = Grep({
246
- pattern: "# region debug|// region debug",
247
- output_mode: "files_with_matches"
248
- })
249
-
250
- for (const file of instrumentedFiles) {
251
- // Remove content between region markers
252
- removeDebugRegions(file)
253
- }
254
-
255
- console.log(`
256
- ## Debug Complete
257
-
258
- - Root cause: ${confirmedHypothesis.description}
259
- - Fix applied to: ${modifiedFiles.join(', ')}
260
- - Debug instrumentation removed
261
- `)
262
- ```
263
-
264
- ---
265
-
266
- ## Debug Log Format (NDJSON)
267
-
268
- Each line is a JSON object:
269
-
270
- ```json
271
- {"sid":"DBG-xxx-2025-12-18","hid":"H1","loc":"file.py:func:42","msg":"Check dict keys","data":{"keys":["a","b"],"target":"c","found":false},"ts":1734567890123}
272
- ```
273
-
274
- | Field | Description |
275
- |-------|-------------|
276
- | `sid` | Session ID |
277
- | `hid` | Hypothesis ID (H1, H2, ...) |
278
- | `loc` | Code location |
279
- | `msg` | What's being tested |
280
- | `data` | Captured values |
281
- | `ts` | Timestamp (ms) |
282
-
283
- ## Session Folder
284
-
285
- ```
286
- .workflow/.debug/DBG-{slug}-{date}/
287
- ├── debug.log # NDJSON log (main artifact)
288
- └── resolution.md # Summary after fix (optional)
289
- ```
290
-
291
- ## Iteration Flow
292
-
293
- ```
294
- First Call (/workflow:debug "error"):
295
- ├─ No session exists → Explore mode
296
- ├─ Extract error keywords, search codebase
297
- ├─ Generate hypotheses, add logging
298
- └─ Await user reproduction
299
-
300
- After Reproduction (/workflow:debug "error"):
301
- ├─ Session exists + debug.log has content → Analyze mode
302
- ├─ Parse log, evaluate hypotheses
303
- └─ Decision:
304
- ├─ Confirmed Fix → User verify
305
- ├─ Fixed CleanupDone
306
- └─ Not fixed Add logging → Iterate
307
- ├─ Inconclusive → Add logging → Iterate
308
- └─ All rejected New hypotheses Iterate
309
-
310
- Output:
311
- └─ .workflow/.debug/DBG-{slug}-{date}/debug.log
312
- ```
313
-
314
- ## Post-Completion Expansion
315
-
316
- 完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
317
-
318
- ---
319
-
320
- ## Error Handling
321
-
322
- | Situation | Action |
323
- |-----------|--------|
324
- | Empty debug.log | Verify reproduction triggered the code path |
325
- | All hypotheses rejected | Generate new hypotheses with broader scope |
326
- | Fix doesn't work | Iterate with more granular logging |
327
- | >5 iterations | Escalate to `/workflow:lite-fix` with evidence |
1
+ ---
2
+ name: debug
3
+ description: Interactive hypothesis-driven debugging with NDJSON logging, iterative until resolved
4
+ argument-hint: "[-y|--yes] \"bug description or error message\""
5
+ allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm all decisions (hypotheses, fixes, iteration), use recommended settings.
11
+
12
+ # Workflow Debug Command (/workflow:debug)
13
+
14
+ ## Overview
15
+
16
+ Evidence-based interactive debugging command. Systematically identifies root causes through hypothesis-driven logging and iterative verification.
17
+
18
+ **Core workflow**: Explore → Add Logging → Reproduce → Analyze Log → Fix → Verify
19
+
20
+ ## Usage
21
+
22
+ ```bash
23
+ /workflow:debug <BUG_DESCRIPTION>
24
+
25
+ # Arguments
26
+ <bug-description> Bug description, error message, or stack trace (required)
27
+ ```
28
+
29
+ ## Execution Process
30
+
31
+ ```
32
+ Session Detection:
33
+ ├─ Check if debug session exists for this bug
34
+ ├─ EXISTS + debug.log has content → Analyze mode
35
+ └─ NOT_FOUND or empty log → Explore mode
36
+
37
+ Explore Mode:
38
+ ├─ Locate error source in codebase
39
+ ├─ Generate testable hypotheses (dynamic count)
40
+ ├─ Add NDJSON logging instrumentation
41
+ └─ Output: Hypothesis list + await user reproduction
42
+
43
+ Analyze Mode:
44
+ ├─ Parse debug.log, validate each hypothesis
45
+ └─ Decision:
46
+ ├─ Confirmed → Fix root cause
47
+ ├─ Inconclusive Add more logging, iterate
48
+ └─ All rejected → Generate new hypotheses
49
+
50
+ Fix & Cleanup:
51
+ ├─ Apply fix based on confirmed hypothesis
52
+ ├─ User verifies
53
+ ├─ Remove debug instrumentation
54
+ └─ If not fixed → Return to Analyze mode
55
+ ```
56
+
57
+ ## Implementation
58
+
59
+ ### Session Setup & Mode Detection
60
+
61
+ ```javascript
62
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
63
+
64
+ const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
65
+ const dateStr = getUtc8ISOString().substring(0, 10)
66
+
67
+ const sessionId = `DBG-${bugSlug}-${dateStr}`
68
+ const sessionFolder = `.workflow/.debug/${sessionId}`
69
+ const debugLogPath = `${sessionFolder}/debug.log`
70
+
71
+ // Auto-detect mode
72
+ const sessionExists = fs.existsSync(sessionFolder)
73
+ const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
74
+
75
+ const mode = logHasContent ? 'analyze' : 'explore'
76
+
77
+ if (!sessionExists) {
78
+ bash(`mkdir -p ${sessionFolder}`)
79
+ }
80
+ ```
81
+
82
+ ---
83
+
84
+ ### Explore Mode
85
+
86
+ **Step 1.1: Locate Error Source**
87
+
88
+ ```javascript
89
+ // Extract keywords from bug description
90
+ const keywords = extractErrorKeywords(bug_description)
91
+ // e.g., ['Stack Length', '未找到', 'registered 0']
92
+
93
+ // Search codebase for error locations
94
+ for (const keyword of keywords) {
95
+ Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
96
+ }
97
+
98
+ // Identify affected files and functions
99
+ const affectedLocations = [...] // from search results
100
+ ```
101
+
102
+ **Step 1.2: Generate Hypotheses (Dynamic)**
103
+
104
+ ```javascript
105
+ // Hypothesis categories based on error pattern
106
+ const HYPOTHESIS_PATTERNS = {
107
+ "not found|missing|undefined|未找到": "data_mismatch",
108
+ "0|empty|zero|registered 0": "logic_error",
109
+ "timeout|connection|sync": "integration_issue",
110
+ "type|format|parse": "type_mismatch"
111
+ }
112
+
113
+ // Generate hypotheses based on actual issue (NOT fixed count)
114
+ function generateHypotheses(bugDescription, affectedLocations) {
115
+ const hypotheses = []
116
+
117
+ // Analyze bug and create targeted hypotheses
118
+ // Each hypothesis has:
119
+ // - id: H1, H2, ... (dynamic count)
120
+ // - description: What might be wrong
121
+ // - testable_condition: What to log
122
+ // - logging_point: Where to add instrumentation
123
+
124
+ return hypotheses // Could be 1, 3, 5, or more
125
+ }
126
+
127
+ const hypotheses = generateHypotheses(bug_description, affectedLocations)
128
+ ```
129
+
130
+ **Step 1.3: Add NDJSON Instrumentation**
131
+
132
+ For each hypothesis, add logging at the relevant location:
133
+
134
+ **Python template**:
135
+ ```python
136
+ # region debug [H{n}]
137
+ try:
138
+ import json, time
139
+ _dbg = {
140
+ "sid": "{sessionId}",
141
+ "hid": "H{n}",
142
+ "loc": "{file}:{line}",
143
+ "msg": "{testable_condition}",
144
+ "data": {
145
+ # Capture relevant values here
146
+ },
147
+ "ts": int(time.time() * 1000)
148
+ }
149
+ with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
150
+ _f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
151
+ except: pass
152
+ # endregion
153
+ ```
154
+
155
+ **JavaScript/TypeScript template**:
156
+ ```javascript
157
+ // region debug [H{n}]
158
+ try {
159
+ require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
160
+ sid: "{sessionId}",
161
+ hid: "H{n}",
162
+ loc: "{file}:{line}",
163
+ msg: "{testable_condition}",
164
+ data: { /* Capture relevant values */ },
165
+ ts: Date.now()
166
+ }) + "\n");
167
+ } catch(_) {}
168
+ // endregion
169
+ ```
170
+
171
+ **Output to user**:
172
+ ```
173
+ ## Hypotheses Generated
174
+
175
+ Based on error "{bug_description}", generated {n} hypotheses:
176
+
177
+ {hypotheses.map(h => `
178
+ ### ${h.id}: ${h.description}
179
+ - Logging at: ${h.logging_point}
180
+ - Testing: ${h.testable_condition}
181
+ `).join('')}
182
+
183
+ **Debug log**: ${debugLogPath}
184
+
185
+ **Next**: Run reproduction steps, then come back for analysis.
186
+ ```
187
+
188
+ ---
189
+
190
+ ### Analyze Mode
191
+
192
+ ```javascript
193
+ // Parse NDJSON log
194
+ const entries = Read(debugLogPath).split('\n')
195
+ .filter(l => l.trim())
196
+ .map(l => JSON.parse(l))
197
+
198
+ // Group by hypothesis
199
+ const byHypothesis = groupBy(entries, 'hid')
200
+
201
+ // Validate each hypothesis
202
+ for (const [hid, logs] of Object.entries(byHypothesis)) {
203
+ const hypothesis = hypotheses.find(h => h.id === hid)
204
+ const latestLog = logs[logs.length - 1]
205
+
206
+ // Check if evidence confirms or rejects hypothesis
207
+ const verdict = evaluateEvidence(hypothesis, latestLog.data)
208
+ // Returns: 'confirmed' | 'rejected' | 'inconclusive'
209
+ }
210
+ ```
211
+
212
+ **Output**:
213
+ ```
214
+ ## Evidence Analysis
215
+
216
+ Analyzed ${entries.length} log entries.
217
+
218
+ ${results.map(r => `
219
+ ### ${r.id}: ${r.description}
220
+ - **Status**: ${r.verdict}
221
+ - **Evidence**: ${JSON.stringify(r.evidence)}
222
+ - **Reason**: ${r.reason}
223
+ `).join('')}
224
+
225
+ ${confirmedHypothesis ? `
226
+ ## Root Cause Identified
227
+
228
+ **${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
229
+
230
+ Ready to fix.
231
+ ` : `
232
+ ## Need More Evidence
233
+
234
+ Add more logging or refine hypotheses.
235
+ `}
236
+ ```
237
+
238
+ ---
239
+
240
+ ### Fix & Cleanup
241
+
242
+ ```javascript
243
+ // Apply fix based on confirmed hypothesis
244
+ // ... Edit affected files
245
+
246
+ // After user verifies fix works:
247
+
248
+ // Remove debug instrumentation (search for region markers)
249
+ const instrumentedFiles = Grep({
250
+ pattern: "# region debug|// region debug",
251
+ output_mode: "files_with_matches"
252
+ })
253
+
254
+ for (const file of instrumentedFiles) {
255
+ // Remove content between region markers
256
+ removeDebugRegions(file)
257
+ }
258
+
259
+ console.log(`
260
+ ## Debug Complete
261
+
262
+ - Root cause: ${confirmedHypothesis.description}
263
+ - Fix applied to: ${modifiedFiles.join(', ')}
264
+ - Debug instrumentation removed
265
+ `)
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Debug Log Format (NDJSON)
271
+
272
+ Each line is a JSON object:
273
+
274
+ ```json
275
+ {"sid":"DBG-xxx-2025-12-18","hid":"H1","loc":"file.py:func:42","msg":"Check dict keys","data":{"keys":["a","b"],"target":"c","found":false},"ts":1734567890123}
276
+ ```
277
+
278
+ | Field | Description |
279
+ |-------|-------------|
280
+ | `sid` | Session ID |
281
+ | `hid` | Hypothesis ID (H1, H2, ...) |
282
+ | `loc` | Code location |
283
+ | `msg` | What's being tested |
284
+ | `data` | Captured values |
285
+ | `ts` | Timestamp (ms) |
286
+
287
+ ## Session Folder
288
+
289
+ ```
290
+ .workflow/.debug/DBG-{slug}-{date}/
291
+ ├── debug.log # NDJSON log (main artifact)
292
+ └── resolution.md # Summary after fix (optional)
293
+ ```
294
+
295
+ ## Iteration Flow
296
+
297
+ ```
298
+ First Call (/workflow:debug "error"):
299
+ ├─ No session exists → Explore mode
300
+ ├─ Extract error keywords, search codebase
301
+ ├─ Generate hypotheses, add logging
302
+ └─ Await user reproduction
303
+
304
+ After Reproduction (/workflow:debug "error"):
305
+ ├─ Session exists + debug.log has content Analyze mode
306
+ ├─ Parse log, evaluate hypotheses
307
+ └─ Decision:
308
+ ├─ ConfirmedFixUser verify
309
+ │ ├─ Fixed → Cleanup → Done
310
+ │ └─ Not fixed → Add logging → Iterate
311
+ ├─ Inconclusive → Add logging → Iterate
312
+ └─ All rejected → New hypotheses → Iterate
313
+
314
+ Output:
315
+ └─ .workflow/.debug/DBG-{slug}-{date}/debug.log
316
+ ```
317
+
318
+ ## Post-Completion Expansion
319
+
320
+ 完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
321
+
322
+ ---
323
+
324
+ ## Error Handling
325
+
326
+ | Situation | Action |
327
+ |-----------|--------|
328
+ | Empty debug.log | Verify reproduction triggered the code path |
329
+ | All hypotheses rejected | Generate new hypotheses with broader scope |
330
+ | Fix doesn't work | Iterate with more granular logging |
331
+ | >5 iterations | Escalate to `/workflow:lite-fix` with evidence |