claude-code-workflow 6.3.37 → 6.3.39

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 (173) hide show
  1. package/.claude/commands/workflow/lite-execute.md +2 -0
  2. package/.codex/agents/action-planning-agent.md +885 -0
  3. package/.codex/agents/ccw-loop-b-complete.md +227 -0
  4. package/.codex/agents/ccw-loop-b-debug.md +172 -0
  5. package/.codex/agents/ccw-loop-b-develop.md +147 -0
  6. package/.codex/agents/ccw-loop-b-init.md +82 -0
  7. package/.codex/agents/ccw-loop-b-validate.md +204 -0
  8. package/.codex/agents/ccw-loop-executor.md +260 -0
  9. package/.codex/agents/cli-discuss-agent.md +391 -0
  10. package/.codex/agents/cli-execution-agent.md +333 -0
  11. package/.codex/agents/cli-explore-agent.md +186 -0
  12. package/.codex/agents/cli-lite-planning-agent.md +736 -0
  13. package/.codex/agents/cli-planning-agent.md +562 -0
  14. package/.codex/agents/code-developer.md +408 -0
  15. package/.codex/agents/conceptual-planning-agent.md +321 -0
  16. package/.codex/agents/context-search-agent.md +585 -0
  17. package/.codex/agents/debug-explore-agent.md +436 -0
  18. package/.codex/agents/doc-generator.md +334 -0
  19. package/.codex/agents/issue-plan-agent.md +417 -0
  20. package/.codex/agents/issue-queue-agent.md +311 -0
  21. package/.codex/agents/memory-bridge.md +96 -0
  22. package/.codex/agents/test-context-search-agent.md +402 -0
  23. package/.codex/agents/test-fix-agent.md +359 -0
  24. package/.codex/agents/ui-design-agent.md +595 -0
  25. package/.codex/agents/universal-executor.md +135 -0
  26. package/.codex/prompts/clean.md +409 -0
  27. package/.codex/prompts/issue-discover-by-prompt.md +364 -0
  28. package/.codex/prompts/issue-discover.md +261 -0
  29. package/.codex/prompts/issue-execute.md +10 -0
  30. package/.codex/prompts/issue-new.md +285 -0
  31. package/.codex/prompts/issue-plan.md +161 -63
  32. package/.codex/prompts/issue-queue.md +298 -288
  33. package/.codex/prompts/lite-execute.md +627 -133
  34. package/.codex/prompts/lite-fix.md +670 -0
  35. package/.codex/prompts/lite-plan-a.md +337 -0
  36. package/.codex/prompts/lite-plan-b.md +485 -0
  37. package/.codex/prompts/{lite-plan.md → lite-plan-c.md} +601 -469
  38. package/.codex/skills/ccw-loop/README.md +171 -0
  39. package/.codex/skills/ccw-loop/SKILL.md +349 -0
  40. package/.codex/skills/ccw-loop/phases/actions/action-complete.md +269 -0
  41. package/.codex/skills/ccw-loop/phases/actions/action-debug.md +286 -0
  42. package/.codex/skills/ccw-loop/phases/actions/action-develop.md +183 -0
  43. package/.codex/skills/ccw-loop/phases/actions/action-init.md +164 -0
  44. package/.codex/skills/ccw-loop/phases/actions/action-menu.md +205 -0
  45. package/.codex/skills/ccw-loop/phases/actions/action-validate.md +250 -0
  46. package/.codex/skills/ccw-loop/phases/orchestrator.md +416 -0
  47. package/.codex/skills/ccw-loop/phases/state-schema.md +388 -0
  48. package/.codex/skills/ccw-loop/specs/action-catalog.md +182 -0
  49. package/.codex/skills/ccw-loop-b/README.md +301 -0
  50. package/.codex/skills/ccw-loop-b/SKILL.md +322 -0
  51. package/.codex/skills/ccw-loop-b/phases/orchestrator.md +257 -0
  52. package/.codex/skills/ccw-loop-b/phases/state-schema.md +181 -0
  53. package/.codex/skills/ccw-loop-b/specs/action-catalog.md +383 -0
  54. package/.codex/skills/parallel-dev-cycle/README.md +382 -0
  55. package/.codex/skills/parallel-dev-cycle/SKILL.md +512 -0
  56. package/.codex/skills/parallel-dev-cycle/phases/agents/code-developer.md +242 -0
  57. package/.codex/skills/parallel-dev-cycle/phases/agents/exploration-planner.md +285 -0
  58. package/.codex/skills/parallel-dev-cycle/phases/agents/requirements-analyst.md +285 -0
  59. package/.codex/skills/parallel-dev-cycle/phases/agents/validation-archivist.md +381 -0
  60. package/.codex/skills/parallel-dev-cycle/phases/orchestrator.md +696 -0
  61. package/.codex/skills/parallel-dev-cycle/phases/state-schema.md +436 -0
  62. package/.codex/skills/parallel-dev-cycle/specs/communication-optimization.md +423 -0
  63. package/.codex/skills/parallel-dev-cycle/specs/coordination-protocol.md +391 -0
  64. package/.codex/skills/parallel-dev-cycle/specs/versioning-strategy.md +330 -0
  65. package/ccw/dist/cli.d.ts.map +1 -1
  66. package/ccw/dist/cli.js +4 -0
  67. package/ccw/dist/cli.js.map +1 -1
  68. package/ccw/dist/commands/install.d.ts.map +1 -1
  69. package/ccw/dist/commands/install.js +39 -8
  70. package/ccw/dist/commands/install.js.map +1 -1
  71. package/ccw/dist/commands/issue.d.ts +3 -0
  72. package/ccw/dist/commands/issue.d.ts.map +1 -1
  73. package/ccw/dist/commands/issue.js +107 -0
  74. package/ccw/dist/commands/issue.js.map +1 -1
  75. package/ccw/dist/commands/upgrade.js +1 -1
  76. package/ccw/dist/commands/upgrade.js.map +1 -1
  77. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  78. package/ccw/dist/config/litellm-api-config-manager.js +3 -2
  79. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  80. package/ccw/dist/core/memory-embedder-bridge.d.ts.map +1 -1
  81. package/ccw/dist/core/memory-embedder-bridge.js +2 -5
  82. package/ccw/dist/core/memory-embedder-bridge.js.map +1 -1
  83. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  84. package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -1
  85. package/ccw/dist/core/routes/codexlens/config-handlers.js +7 -6
  86. package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -1
  87. package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts.map +1 -1
  88. package/ccw/dist/core/routes/codexlens/semantic-handlers.js +2 -2
  89. package/ccw/dist/core/routes/codexlens/semantic-handlers.js.map +1 -1
  90. package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -1
  91. package/ccw/dist/core/routes/graph-routes.js +17 -2
  92. package/ccw/dist/core/routes/graph-routes.js.map +1 -1
  93. package/ccw/dist/core/routes/issue-routes.d.ts.map +1 -1
  94. package/ccw/dist/core/routes/issue-routes.js +280 -33
  95. package/ccw/dist/core/routes/issue-routes.js.map +1 -1
  96. package/ccw/dist/core/routes/loop-v2-routes.d.ts +9 -0
  97. package/ccw/dist/core/routes/loop-v2-routes.d.ts.map +1 -1
  98. package/ccw/dist/core/routes/loop-v2-routes.js +56 -4
  99. package/ccw/dist/core/routes/loop-v2-routes.js.map +1 -1
  100. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  101. package/ccw/dist/core/routes/system-routes.js +3 -2
  102. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  103. package/ccw/dist/core/server.d.ts.map +1 -1
  104. package/ccw/dist/core/server.js +5 -3
  105. package/ccw/dist/core/server.js.map +1 -1
  106. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  107. package/ccw/dist/tools/claude-cli-tools.js +4 -3
  108. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  109. package/ccw/dist/tools/cli-config-manager.d.ts +1 -0
  110. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  111. package/ccw/dist/tools/cli-config-manager.js +2 -1
  112. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  113. package/ccw/dist/tools/codex-lens-lsp.d.ts.map +1 -1
  114. package/ccw/dist/tools/codex-lens-lsp.js +2 -5
  115. package/ccw/dist/tools/codex-lens-lsp.js.map +1 -1
  116. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  117. package/ccw/dist/tools/codex-lens.js +22 -32
  118. package/ccw/dist/tools/codex-lens.js.map +1 -1
  119. package/ccw/dist/tools/litellm-client.d.ts +6 -0
  120. package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
  121. package/ccw/dist/tools/litellm-client.js +15 -2
  122. package/ccw/dist/tools/litellm-client.js.map +1 -1
  123. package/ccw/dist/tools/loop-task-manager.d.ts +13 -2
  124. package/ccw/dist/tools/loop-task-manager.d.ts.map +1 -1
  125. package/ccw/dist/tools/loop-task-manager.js.map +1 -1
  126. package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -1
  127. package/ccw/dist/tools/native-session-discovery.js +35 -7
  128. package/ccw/dist/tools/native-session-discovery.js.map +1 -1
  129. package/ccw/dist/utils/codexlens-path.d.ts +36 -0
  130. package/ccw/dist/utils/codexlens-path.d.ts.map +1 -0
  131. package/ccw/dist/utils/codexlens-path.js +56 -0
  132. package/ccw/dist/utils/codexlens-path.js.map +1 -0
  133. package/ccw/dist/utils/uv-manager.d.ts.map +1 -1
  134. package/ccw/dist/utils/uv-manager.js +3 -2
  135. package/ccw/dist/utils/uv-manager.js.map +1 -1
  136. package/ccw/src/cli.ts +4 -0
  137. package/ccw/src/commands/install.ts +51 -8
  138. package/ccw/src/commands/issue.ts +119 -0
  139. package/ccw/src/commands/upgrade.ts +1 -1
  140. package/ccw/src/config/litellm-api-config-manager.ts +3 -2
  141. package/ccw/src/core/memory-embedder-bridge.ts +2 -6
  142. package/ccw/src/core/routes/cli-routes.ts +1 -1
  143. package/ccw/src/core/routes/codexlens/config-handlers.ts +7 -6
  144. package/ccw/src/core/routes/codexlens/semantic-handlers.ts +2 -2
  145. package/ccw/src/core/routes/graph-routes.ts +18 -2
  146. package/ccw/src/core/routes/issue-routes.ts +308 -33
  147. package/ccw/src/core/routes/loop-v2-routes.ts +64 -6
  148. package/ccw/src/core/routes/system-routes.ts +3 -2
  149. package/ccw/src/core/server.ts +6 -3
  150. package/ccw/src/templates/dashboard-css/02-session.css +2 -0
  151. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +103 -1
  152. package/ccw/src/templates/dashboard-css/32-issue-manager.css +32 -0
  153. package/ccw/src/templates/dashboard-js/components/cli-history.js +48 -48
  154. package/ccw/src/templates/dashboard-js/components/navigation.js +6 -0
  155. package/ccw/src/templates/dashboard-js/components/notifications.js +6 -0
  156. package/ccw/src/templates/dashboard-js/components/version-check.js +38 -0
  157. package/ccw/src/templates/dashboard-js/i18n.js +126 -0
  158. package/ccw/src/templates/dashboard-js/state.js +2 -0
  159. package/ccw/src/templates/dashboard-js/views/cli-manager.js +1 -1
  160. package/ccw/src/templates/dashboard-js/views/issue-manager.js +183 -1
  161. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +55 -11
  162. package/ccw/src/templates/dashboard-js/views/loop-monitor.js +112 -11
  163. package/ccw/src/templates/dashboard.html +48 -2
  164. package/ccw/src/tools/claude-cli-tools.ts +4 -3
  165. package/ccw/src/tools/cli-config-manager.ts +3 -1
  166. package/ccw/src/tools/codex-lens-lsp.ts +2 -5
  167. package/ccw/src/tools/codex-lens.ts +27 -38
  168. package/ccw/src/tools/litellm-client.ts +16 -2
  169. package/ccw/src/tools/loop-task-manager.ts +13 -2
  170. package/ccw/src/tools/native-session-discovery.ts +38 -7
  171. package/ccw/src/utils/codexlens-path.ts +60 -0
  172. package/ccw/src/utils/uv-manager.ts +3 -2
  173. package/package.json +1 -1
@@ -0,0 +1,269 @@
1
+ # Action: COMPLETE
2
+
3
+ Complete CCW Loop session and generate summary report.
4
+
5
+ ## Purpose
6
+
7
+ - Generate completion report
8
+ - Aggregate all phase results
9
+ - Provide follow-up recommendations
10
+ - Offer expansion to issues
11
+ - Mark status as completed
12
+
13
+ ## Preconditions
14
+
15
+ - [ ] state.status === 'running'
16
+ - [ ] state.skill_state !== null
17
+
18
+ ## Execution Steps
19
+
20
+ ### Step 1: Verify Control Signals
21
+
22
+ ```javascript
23
+ const state = JSON.parse(Read(`.workflow/.loop/${loopId}.json`))
24
+
25
+ if (state.status !== 'running') {
26
+ return {
27
+ action: 'COMPLETE',
28
+ status: 'failed',
29
+ message: `Cannot complete: status is ${state.status}`,
30
+ next_action: state.status === 'paused' ? 'PAUSED' : 'STOPPED'
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Step 2: Aggregate Statistics
36
+
37
+ ```javascript
38
+ const stats = {
39
+ // Time statistics
40
+ duration: Date.now() - new Date(state.created_at).getTime(),
41
+ iterations: state.current_iteration,
42
+
43
+ // Development statistics
44
+ develop: {
45
+ total_tasks: state.skill_state.develop.total,
46
+ completed_tasks: state.skill_state.develop.completed,
47
+ completion_rate: state.skill_state.develop.total > 0
48
+ ? ((state.skill_state.develop.completed / state.skill_state.develop.total) * 100).toFixed(1)
49
+ : 0
50
+ },
51
+
52
+ // Debug statistics
53
+ debug: {
54
+ iterations: state.skill_state.debug.iteration,
55
+ hypotheses_tested: state.skill_state.debug.hypotheses.length,
56
+ root_cause_found: state.skill_state.debug.confirmed_hypothesis !== null
57
+ },
58
+
59
+ // Validation statistics
60
+ validate: {
61
+ runs: state.skill_state.validate.test_results.length,
62
+ passed: state.skill_state.validate.passed,
63
+ coverage: state.skill_state.validate.coverage,
64
+ failed_tests: state.skill_state.validate.failed_tests.length
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### Step 3: Generate Summary Report
70
+
71
+ ```javascript
72
+ const timestamp = getUtc8ISOString()
73
+
74
+ const summaryReport = `# CCW Loop Session Summary
75
+
76
+ **Loop ID**: ${loopId}
77
+ **Task**: ${state.description}
78
+ **Started**: ${state.created_at}
79
+ **Completed**: ${timestamp}
80
+ **Duration**: ${formatDuration(stats.duration)}
81
+
82
+ ---
83
+
84
+ ## Executive Summary
85
+
86
+ ${state.skill_state.validate.passed
87
+ ? 'All tests passed, validation successful'
88
+ : state.skill_state.develop.completed === state.skill_state.develop.total
89
+ ? 'Development complete, validation not passed - needs debugging'
90
+ : 'Task partially complete - pending items remain'}
91
+
92
+ ---
93
+
94
+ ## Development Phase
95
+
96
+ | Metric | Value |
97
+ |--------|-------|
98
+ | Total Tasks | ${stats.develop.total_tasks} |
99
+ | Completed | ${stats.develop.completed_tasks} |
100
+ | Completion Rate | ${stats.develop.completion_rate}% |
101
+
102
+ ### Completed Tasks
103
+
104
+ ${state.skill_state.develop.tasks.filter(t => t.status === 'completed').map(t => `
105
+ - ${t.description}
106
+ - Files: ${t.files_changed?.join(', ') || 'N/A'}
107
+ - Completed: ${t.completed_at}
108
+ `).join('\n')}
109
+
110
+ ### Pending Tasks
111
+
112
+ ${state.skill_state.develop.tasks.filter(t => t.status !== 'completed').map(t => `
113
+ - ${t.description}
114
+ `).join('\n') || '_None_'}
115
+
116
+ ---
117
+
118
+ ## Debug Phase
119
+
120
+ | Metric | Value |
121
+ |--------|-------|
122
+ | Iterations | ${stats.debug.iterations} |
123
+ | Hypotheses Tested | ${stats.debug.hypotheses_tested} |
124
+ | Root Cause Found | ${stats.debug.root_cause_found ? 'Yes' : 'No'} |
125
+
126
+ ${stats.debug.root_cause_found ? `
127
+ ### Confirmed Root Cause
128
+
129
+ ${state.skill_state.debug.confirmed_hypothesis}: ${state.skill_state.debug.hypotheses.find(h => h.id === state.skill_state.debug.confirmed_hypothesis)?.description}
130
+ ` : ''}
131
+
132
+ ---
133
+
134
+ ## Validation Phase
135
+
136
+ | Metric | Value |
137
+ |--------|-------|
138
+ | Test Runs | ${stats.validate.runs} |
139
+ | Status | ${stats.validate.passed ? 'PASSED' : 'FAILED'} |
140
+ | Coverage | ${stats.validate.coverage || 'N/A'}% |
141
+ | Failed Tests | ${stats.validate.failed_tests} |
142
+
143
+ ---
144
+
145
+ ## Recommendations
146
+
147
+ ${generateRecommendations(stats, state)}
148
+
149
+ ---
150
+
151
+ ## Session Artifacts
152
+
153
+ | File | Description |
154
+ |------|-------------|
155
+ | \`develop.md\` | Development progress timeline |
156
+ | \`debug.md\` | Debug exploration and learnings |
157
+ | \`validate.md\` | Validation report |
158
+ | \`test-results.json\` | Test execution results |
159
+
160
+ ---
161
+
162
+ *Generated by CCW Loop at ${timestamp}*
163
+ `
164
+
165
+ Write(`${progressDir}/summary.md`, summaryReport)
166
+ ```
167
+
168
+ ### Step 4: Update State to Completed
169
+
170
+ ```javascript
171
+ state.status = 'completed'
172
+ state.completed_at = timestamp
173
+ state.updated_at = timestamp
174
+ state.skill_state.last_action = 'COMPLETE'
175
+ state.skill_state.summary = stats
176
+
177
+ Write(`.workflow/.loop/${loopId}.json`, JSON.stringify(state, null, 2))
178
+ ```
179
+
180
+ ## Output Format
181
+
182
+ ```
183
+ ACTION_RESULT:
184
+ - action: COMPLETE
185
+ - status: success
186
+ - message: Loop completed. Duration: {duration}, Iterations: {N}
187
+ - state_updates: {
188
+ "status": "completed",
189
+ "completed_at": "{timestamp}"
190
+ }
191
+
192
+ FILES_UPDATED:
193
+ - .workflow/.loop/{loopId}.json: Status set to completed
194
+ - .workflow/.loop/{loopId}.progress/summary.md: Summary report generated
195
+
196
+ NEXT_ACTION_NEEDED: COMPLETED
197
+ ```
198
+
199
+ ## Expansion Options
200
+
201
+ After completion, offer expansion to issues:
202
+
203
+ ```
204
+ ## Expansion Options
205
+
206
+ Would you like to create follow-up issues?
207
+
208
+ 1. [test] Add more test cases
209
+ 2. [enhance] Feature enhancements
210
+ 3. [refactor] Code refactoring
211
+ 4. [doc] Documentation updates
212
+ 5. [none] No expansion needed
213
+
214
+ Select options (comma-separated) or 'none':
215
+ ```
216
+
217
+ ## Helper Functions
218
+
219
+ ```javascript
220
+ function formatDuration(ms) {
221
+ const seconds = Math.floor(ms / 1000)
222
+ const minutes = Math.floor(seconds / 60)
223
+ const hours = Math.floor(minutes / 60)
224
+
225
+ if (hours > 0) {
226
+ return `${hours}h ${minutes % 60}m`
227
+ } else if (minutes > 0) {
228
+ return `${minutes}m ${seconds % 60}s`
229
+ } else {
230
+ return `${seconds}s`
231
+ }
232
+ }
233
+
234
+ function generateRecommendations(stats, state) {
235
+ const recommendations = []
236
+
237
+ if (stats.develop.completion_rate < 100) {
238
+ recommendations.push('- Complete remaining development tasks')
239
+ }
240
+
241
+ if (!stats.validate.passed) {
242
+ recommendations.push('- Fix failing tests')
243
+ }
244
+
245
+ if (stats.validate.coverage && stats.validate.coverage < 80) {
246
+ recommendations.push(`- Improve test coverage (current: ${stats.validate.coverage}%)`)
247
+ }
248
+
249
+ if (recommendations.length === 0) {
250
+ recommendations.push('- Consider code review')
251
+ recommendations.push('- Update documentation')
252
+ recommendations.push('- Prepare for deployment')
253
+ }
254
+
255
+ return recommendations.join('\n')
256
+ }
257
+ ```
258
+
259
+ ## Error Handling
260
+
261
+ | Error Type | Recovery |
262
+ |------------|----------|
263
+ | Report generation failed | Show basic stats, skip file write |
264
+ | Issue creation failed | Log error, continue completion |
265
+
266
+ ## Next Actions
267
+
268
+ - None (terminal state)
269
+ - To continue: Use `/ccw-loop --loop-id={loopId}` to reopen (will set status back to running)
@@ -0,0 +1,286 @@
1
+ # Action: DEBUG
2
+
3
+ Hypothesis-driven debugging with understanding evolution documentation.
4
+
5
+ ## Purpose
6
+
7
+ - Locate error source
8
+ - Generate testable hypotheses
9
+ - Add NDJSON instrumentation
10
+ - Analyze log evidence
11
+ - Correct understanding based on evidence
12
+ - Apply fixes
13
+
14
+ ## Preconditions
15
+
16
+ - [ ] state.status === 'running'
17
+ - [ ] state.skill_state !== null
18
+
19
+ ## Mode Detection
20
+
21
+ ```javascript
22
+ const understandingPath = `${progressDir}/debug.md`
23
+ const debugLogPath = `${progressDir}/debug.log`
24
+
25
+ const understandingExists = fs.existsSync(understandingPath)
26
+ const logHasContent = fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
27
+
28
+ const debugMode = logHasContent ? 'analyze' : (understandingExists ? 'continue' : 'explore')
29
+ ```
30
+
31
+ ## Execution Steps
32
+
33
+ ### Mode: Explore (First Debug)
34
+
35
+ #### Step E1: Get Bug Description
36
+
37
+ ```javascript
38
+ // From test failures or user input
39
+ const bugDescription = state.skill_state.validate?.failed_tests?.[0]
40
+ || await getUserInput('Describe the bug:')
41
+ ```
42
+
43
+ #### Step E2: Search Codebase
44
+
45
+ ```javascript
46
+ // Use ACE search_context to find related code
47
+ const searchResults = mcp__ace-tool__search_context({
48
+ project_root_path: '.',
49
+ query: `code related to: ${bugDescription}`
50
+ })
51
+ ```
52
+
53
+ #### Step E3: Generate Hypotheses
54
+
55
+ ```javascript
56
+ const hypotheses = [
57
+ {
58
+ id: 'H1',
59
+ description: 'Most likely cause',
60
+ testable_condition: 'What to check',
61
+ logging_point: 'file.ts:functionName:42',
62
+ evidence_criteria: {
63
+ confirm: 'If we see X, hypothesis confirmed',
64
+ reject: 'If we see Y, hypothesis rejected'
65
+ },
66
+ likelihood: 1,
67
+ status: 'pending',
68
+ evidence: null,
69
+ verdict_reason: null
70
+ },
71
+ // H2, H3...
72
+ ]
73
+ ```
74
+
75
+ #### Step E4: Create Understanding Document
76
+
77
+ ```javascript
78
+ const initialUnderstanding = `# Understanding Document
79
+
80
+ **Loop ID**: ${loopId}
81
+ **Bug Description**: ${bugDescription}
82
+ **Started**: ${getUtc8ISOString()}
83
+
84
+ ---
85
+
86
+ ## Exploration Timeline
87
+
88
+ ### Iteration 1 - Initial Exploration (${getUtc8ISOString()})
89
+
90
+ #### Current Understanding
91
+
92
+ Based on bug description and code search:
93
+
94
+ - Error pattern: [identified pattern]
95
+ - Affected areas: [files/modules]
96
+ - Initial hypothesis: [first thoughts]
97
+
98
+ #### Evidence from Code Search
99
+
100
+ [Search results summary]
101
+
102
+ #### Hypotheses
103
+
104
+ ${hypotheses.map(h => `
105
+ **${h.id}**: ${h.description}
106
+ - Testable condition: ${h.testable_condition}
107
+ - Logging point: ${h.logging_point}
108
+ - Likelihood: ${h.likelihood}
109
+ `).join('\n')}
110
+
111
+ ---
112
+
113
+ ## Current Consolidated Understanding
114
+
115
+ [Summary of what we know so far]
116
+ `
117
+
118
+ Write(understandingPath, initialUnderstanding)
119
+ Write(`${progressDir}/hypotheses.json`, JSON.stringify({ hypotheses, iteration: 1 }, null, 2))
120
+ ```
121
+
122
+ #### Step E5: Add NDJSON Logging Points
123
+
124
+ ```javascript
125
+ // For each hypothesis, add instrumentation
126
+ for (const hypothesis of hypotheses) {
127
+ const [file, func, line] = hypothesis.logging_point.split(':')
128
+
129
+ const logStatement = `console.log(JSON.stringify({
130
+ hid: "${hypothesis.id}",
131
+ ts: Date.now(),
132
+ func: "${func}",
133
+ data: { /* relevant context */ }
134
+ }))`
135
+
136
+ // Add to file using Edit tool
137
+ }
138
+ ```
139
+
140
+ ### Mode: Analyze (Has Logs)
141
+
142
+ #### Step A1: Parse Debug Log
143
+
144
+ ```javascript
145
+ const logContent = Read(debugLogPath)
146
+ const entries = logContent.split('\n')
147
+ .filter(l => l.trim())
148
+ .map(l => JSON.parse(l))
149
+
150
+ // Group by hypothesis ID
151
+ const byHypothesis = entries.reduce((acc, e) => {
152
+ acc[e.hid] = acc[e.hid] || []
153
+ acc[e.hid].push(e)
154
+ return acc
155
+ }, {})
156
+ ```
157
+
158
+ #### Step A2: Evaluate Evidence
159
+
160
+ ```javascript
161
+ const hypothesesData = JSON.parse(Read(`${progressDir}/hypotheses.json`))
162
+
163
+ for (const hypothesis of hypothesesData.hypotheses) {
164
+ const evidence = byHypothesis[hypothesis.id] || []
165
+
166
+ // Evaluate against criteria
167
+ if (matchesConfirmCriteria(evidence, hypothesis.evidence_criteria.confirm)) {
168
+ hypothesis.status = 'confirmed'
169
+ hypothesis.evidence = evidence
170
+ hypothesis.verdict_reason = 'Evidence matches confirm criteria'
171
+ } else if (matchesRejectCriteria(evidence, hypothesis.evidence_criteria.reject)) {
172
+ hypothesis.status = 'rejected'
173
+ hypothesis.evidence = evidence
174
+ hypothesis.verdict_reason = 'Evidence matches reject criteria'
175
+ } else {
176
+ hypothesis.status = 'inconclusive'
177
+ hypothesis.evidence = evidence
178
+ hypothesis.verdict_reason = 'Insufficient evidence'
179
+ }
180
+ }
181
+ ```
182
+
183
+ #### Step A3: Update Understanding
184
+
185
+ ```javascript
186
+ const iteration = hypothesesData.iteration + 1
187
+ const timestamp = getUtc8ISOString()
188
+
189
+ const analysisEntry = `
190
+ ### Iteration ${iteration} - Evidence Analysis (${timestamp})
191
+
192
+ #### Log Analysis Results
193
+
194
+ ${hypothesesData.hypotheses.map(h => `
195
+ **${h.id}**: ${h.status.toUpperCase()}
196
+ - Evidence: ${JSON.stringify(h.evidence?.slice(0, 3))}
197
+ - Reasoning: ${h.verdict_reason}
198
+ `).join('\n')}
199
+
200
+ #### Corrected Understanding
201
+
202
+ [Any corrections to previous assumptions]
203
+
204
+ ${confirmedHypothesis ? `
205
+ #### Root Cause Identified
206
+
207
+ **${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
208
+ ` : `
209
+ #### Next Steps
210
+
211
+ [What to investigate next]
212
+ `}
213
+
214
+ ---
215
+ `
216
+
217
+ const existingUnderstanding = Read(understandingPath)
218
+ Write(understandingPath, existingUnderstanding + analysisEntry)
219
+ ```
220
+
221
+ ### Step: Update State
222
+
223
+ ```javascript
224
+ state.skill_state.debug.active_bug = bugDescription
225
+ state.skill_state.debug.hypotheses = hypothesesData.hypotheses
226
+ state.skill_state.debug.hypotheses_count = hypothesesData.hypotheses.length
227
+ state.skill_state.debug.iteration = iteration
228
+ state.skill_state.debug.last_analysis_at = timestamp
229
+
230
+ if (confirmedHypothesis) {
231
+ state.skill_state.debug.confirmed_hypothesis = confirmedHypothesis.id
232
+ }
233
+
234
+ state.skill_state.last_action = 'DEBUG'
235
+ state.updated_at = timestamp
236
+ Write(`.workflow/.loop/${loopId}.json`, JSON.stringify(state, null, 2))
237
+ ```
238
+
239
+ ## Output Format
240
+
241
+ ```
242
+ ACTION_RESULT:
243
+ - action: DEBUG
244
+ - status: success
245
+ - message: {Mode description} - {result summary}
246
+ - state_updates: {
247
+ "debug.iteration": {N},
248
+ "debug.confirmed_hypothesis": "{id or null}"
249
+ }
250
+
251
+ FILES_UPDATED:
252
+ - .workflow/.loop/{loopId}.progress/debug.md: Understanding updated
253
+ - .workflow/.loop/{loopId}.progress/hypotheses.json: Hypotheses updated
254
+ - [Source files]: Instrumentation added
255
+
256
+ NEXT_ACTION_NEEDED: {DEBUG | VALIDATE | DEVELOP | MENU}
257
+ ```
258
+
259
+ ## Next Action Selection
260
+
261
+ ```javascript
262
+ if (confirmedHypothesis) {
263
+ // Root cause found, apply fix and validate
264
+ return 'VALIDATE'
265
+ } else if (allRejected) {
266
+ // Generate new hypotheses
267
+ return 'DEBUG'
268
+ } else {
269
+ // Need more evidence - prompt user to reproduce bug
270
+ return 'WAITING_INPUT' // User needs to trigger bug
271
+ }
272
+ ```
273
+
274
+ ## Error Handling
275
+
276
+ | Error Type | Recovery |
277
+ |------------|----------|
278
+ | Empty debug.log | Prompt user to reproduce bug |
279
+ | All hypotheses rejected | Generate new hypotheses |
280
+ | >5 iterations | Suggest escalation |
281
+
282
+ ## Next Actions
283
+
284
+ - Root cause found: `VALIDATE`
285
+ - Need more evidence: `DEBUG` (after reproduction)
286
+ - All rejected: `DEBUG` (new hypotheses)