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.
- package/.claude/agents/tdd-developer.md +530 -0
- package/.claude/commands/ccw-coordinator.md +1042 -0
- package/.claude/commands/ccw.md +486 -0
- package/.claude/commands/issue/discover-by-prompt.md +5 -1
- package/.claude/commands/issue/discover.md +472 -468
- package/.claude/commands/issue/execute.md +580 -581
- package/.claude/commands/issue/new.md +417 -413
- package/.claude/commands/issue/plan.md +5 -1
- package/.claude/commands/issue/queue.md +445 -441
- package/.claude/commands/task/breakdown.md +207 -203
- package/.claude/commands/task/replan.md +440 -436
- package/.claude/commands/workflow/action-plan-verify.md +485 -447
- package/.claude/commands/workflow/brainstorm/artifacts.md +457 -453
- package/.claude/commands/workflow/brainstorm/auto-parallel.md +5 -1
- package/.claude/commands/workflow/brainstorm/synthesis.md +402 -398
- package/.claude/commands/workflow/clean.md +67 -35
- package/.claude/commands/workflow/debug-with-file.md +670 -666
- package/.claude/commands/workflow/debug.md +331 -327
- package/.claude/commands/workflow/develop-with-file.md +5 -1
- package/.claude/commands/workflow/execute.md +546 -498
- package/.claude/commands/workflow/lite-execute.md +44 -26
- package/.claude/commands/workflow/lite-fix.md +780 -730
- package/.claude/commands/workflow/lite-lite-lite.md +5 -1
- package/.claude/commands/workflow/lite-plan.md +87 -39
- package/.claude/commands/workflow/multi-cli-plan.md +572 -568
- package/.claude/commands/workflow/plan-verify.md +527 -0
- package/.claude/commands/workflow/plan.md +555 -551
- package/.claude/commands/workflow/replan.md +572 -515
- package/.claude/commands/workflow/review-fix.md +608 -610
- package/.claude/commands/workflow/session/complete.md +37 -14
- package/.claude/commands/workflow/session/solidify.md +303 -299
- package/.claude/commands/workflow/tdd-plan.md +630 -597
- package/.claude/commands/workflow/tdd-verify.md +391 -206
- package/.claude/commands/workflow/tools/conflict-resolution.md +24 -12
- package/.claude/commands/workflow/tools/task-generate-agent.md +583 -563
- package/.claude/commands/workflow/tools/task-generate-tdd.md +749 -517
- package/.claude/commands/workflow/ui-design/animation-extract.md +1154 -1150
- package/.claude/commands/workflow/ui-design/layout-extract.md +792 -788
- package/.claude/commands/workflow/ui-design/style-extract.md +777 -773
- package/.claude/skills/ccw-help/command.json +5 -5
- package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -337
- package/.claude/workflows/cli-templates/prompts/workflow-impl-plan-template.txt +1 -1
- package/ccw/dist/commands/issue.d.ts +4 -0
- package/ccw/dist/commands/issue.d.ts.map +1 -1
- package/ccw/dist/commands/issue.js +73 -6
- package/ccw/dist/commands/issue.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js +32 -28
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts +10 -0
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +45 -0
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
- package/ccw/dist/tools/codex-lens.js +38 -11
- package/ccw/dist/tools/codex-lens.js.map +1 -1
- package/ccw/dist/tools/command-registry.d.ts +77 -0
- package/ccw/dist/tools/command-registry.d.ts.map +1 -0
- package/ccw/dist/tools/command-registry.js +265 -0
- package/ccw/dist/tools/command-registry.js.map +1 -0
- package/ccw/dist/tools/command-registry.test.d.ts +14 -0
- package/ccw/dist/tools/command-registry.test.d.ts.map +1 -0
- package/ccw/dist/tools/command-registry.test.js.map +1 -0
- package/ccw/dist/tools/index.d.ts +2 -0
- package/ccw/dist/tools/index.d.ts.map +1 -1
- package/ccw/dist/tools/index.js +2 -0
- package/ccw/dist/tools/index.js.map +1 -1
- package/ccw/src/commands/issue.ts +84 -6
- package/ccw/src/core/routes/cli-routes.ts +30 -25
- package/ccw/src/templates/dashboard-js/views/help.js +1 -1
- package/ccw/src/tools/claude-cli-tools.ts +50 -0
- package/ccw/src/tools/codex-lens.ts +40 -11
- package/ccw/src/tools/command-registry.test.ts +669 -0
- package/ccw/src/tools/command-registry.ts +308 -0
- package/ccw/src/tools/index.ts +4 -0
- package/package.json +1 -1
- package/.claude/skills/ccw/SKILL.md +0 -522
- 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
├─
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
├─
|
|
41
|
-
└─
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Fix
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
${
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
`
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
//
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
|
279
|
-
|
|
280
|
-
| `
|
|
281
|
-
| `
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
├─
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
|
327
|
-
|
|
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
|
+
├─ Confirmed → Fix → User 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 |
|