claude-code-workflow 6.3.48 → 6.3.50

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 (228) hide show
  1. package/.claude/CLAUDE.md +6 -8
  2. package/.claude/agents/action-planning-agent.md +28 -45
  3. package/.claude/agents/cli-lite-planning-agent.md +93 -1
  4. package/.claude/agents/code-developer.md +144 -27
  5. package/.claude/commands/ccw-coordinator.md +175 -21
  6. package/.claude/commands/ccw-debug.md +832 -0
  7. package/.claude/commands/ccw.md +90 -9
  8. package/.claude/commands/cli/cli-init.md +1 -0
  9. package/.claude/commands/issue/convert-to-plan.md +718 -0
  10. package/.claude/commands/issue/from-brainstorm.md +382 -0
  11. package/.claude/commands/issue/new.md +1 -2
  12. package/.claude/commands/memory/tips.md +332 -0
  13. package/.claude/commands/workflow/analyze-with-file.md +804 -0
  14. package/.claude/commands/workflow/brainstorm/auto-parallel.md +18 -43
  15. package/.claude/commands/workflow/brainstorm/role-analysis.md +705 -0
  16. package/.claude/commands/workflow/brainstorm-with-file.md +1153 -0
  17. package/.claude/commands/workflow/debug-with-file.md +7 -5
  18. package/.claude/commands/workflow/execute.md +6 -4
  19. package/.claude/commands/workflow/lite-plan.md +2 -2
  20. package/.claude/commands/workflow/plan-verify.md +162 -327
  21. package/.claude/commands/workflow/plan.md +162 -26
  22. package/.claude/commands/workflow/replan.md +78 -2
  23. package/.claude/commands/workflow/{review-fix.md → review-cycle-fix.md} +6 -6
  24. package/.claude/commands/workflow/review-module-cycle.md +2 -2
  25. package/.claude/commands/workflow/review-session-cycle.md +2 -2
  26. package/.claude/commands/workflow/tools/conflict-resolution.md +16 -26
  27. package/.claude/commands/workflow/tools/context-gather.md +81 -118
  28. package/.claude/commands/workflow/tools/task-generate-agent.md +94 -10
  29. package/.claude/skills/ccw-help/command.json +4 -4
  30. package/.claude/skills/lite-skill-generator/SKILL.md +650 -0
  31. package/.claude/skills/lite-skill-generator/templates/simple-skill.md +68 -0
  32. package/.claude/skills/lite-skill-generator/templates/style-guide.md +64 -0
  33. package/.claude/skills/skill-generator/SKILL.md +277 -85
  34. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +4 -15
  35. package/.claude/skills/skill-generator/phases/02-structure-generation.md +72 -17
  36. package/.claude/skills/skill-generator/phases/03-phase-generation.md +218 -51
  37. package/.claude/skills/skill-generator/phases/04-specs-templates.md +111 -41
  38. package/.claude/skills/skill-generator/phases/05-validation.md +139 -56
  39. package/.claude/skills/skill-generator/templates/autonomous-action.md +78 -268
  40. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +14 -0
  41. package/.claude/skills/skill-generator/templates/code-analysis-action.md +12 -0
  42. package/.claude/skills/skill-generator/templates/llm-action.md +12 -0
  43. package/.claude/skills/skill-generator/templates/script-template.md +368 -0
  44. package/.claude/skills/skill-generator/templates/sequential-phase.md +14 -0
  45. package/.claude/skills/skill-generator/templates/skill-md.md +14 -0
  46. package/.claude/skills/skill-tuning/SKILL.md +130 -266
  47. package/.claude/skills/skill-tuning/phases/orchestrator.md +95 -283
  48. package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +90 -198
  49. package/.claude/skills/skill-tuning/specs/tuning-strategies.md +193 -1345
  50. package/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json +47 -0
  51. package/.claude/workflows/cli-templates/schemas/verify-json-schema.json +158 -0
  52. package/.claude/workflows/cli-tools-usage.md +1 -1
  53. package/.codex/AGENTS.md +1 -3
  54. package/.codex/prompts/analyze-with-file.md +610 -0
  55. package/.codex/prompts/brainstorm-to-cycle.md +456 -0
  56. package/.codex/prompts/brainstorm-with-file.md +937 -0
  57. package/.codex/prompts/clean.md +7 -2
  58. package/.codex/prompts/compact.md +5 -3
  59. package/.codex/prompts/debug-with-file.md +21 -22
  60. package/.codex/prompts/execute.md +6 -2
  61. package/.codex/prompts/issue-execute.md +10 -2
  62. package/.codex/prompts/issue-new.md +390 -285
  63. package/.codex/prompts/lite-execute.md +8 -7
  64. package/.codex/prompts/lite-fix.md +6 -2
  65. package/.codex/prompts/lite-plan-a.md +6 -2
  66. package/.codex/prompts/lite-plan-b.md +6 -2
  67. package/.codex/prompts/lite-plan-c.md +6 -2
  68. package/.codex/skills/ccw-cli-tools/SKILL.md +559 -0
  69. package/ccw/dist/cli.d.ts.map +1 -1
  70. package/ccw/dist/cli.js +1 -0
  71. package/ccw/dist/cli.js.map +1 -1
  72. package/ccw/dist/commands/cli.d.ts +1 -0
  73. package/ccw/dist/commands/cli.d.ts.map +1 -1
  74. package/ccw/dist/commands/cli.js +80 -9
  75. package/ccw/dist/commands/cli.js.map +1 -1
  76. package/ccw/dist/commands/issue.d.ts +2 -0
  77. package/ccw/dist/commands/issue.d.ts.map +1 -1
  78. package/ccw/dist/commands/issue.js +62 -20
  79. package/ccw/dist/commands/issue.js.map +1 -1
  80. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  81. package/ccw/dist/config/litellm-api-config-manager.js +5 -3
  82. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  83. package/ccw/dist/config/litellm-provider-models.d.ts +73 -0
  84. package/ccw/dist/config/litellm-provider-models.d.ts.map +1 -0
  85. package/ccw/dist/config/litellm-provider-models.js +172 -0
  86. package/ccw/dist/config/litellm-provider-models.js.map +1 -0
  87. package/ccw/dist/config/provider-models.d.ts +25 -51
  88. package/ccw/dist/config/provider-models.d.ts.map +1 -1
  89. package/ccw/dist/config/provider-models.js +84 -149
  90. package/ccw/dist/config/provider-models.js.map +1 -1
  91. package/ccw/dist/config/storage-paths.d.ts.map +1 -1
  92. package/ccw/dist/config/storage-paths.js +23 -5
  93. package/ccw/dist/config/storage-paths.js.map +1 -1
  94. package/ccw/dist/core/auth/csrf-middleware.js +3 -3
  95. package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
  96. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  97. package/ccw/dist/core/dashboard-generator.js +3 -1
  98. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  99. package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
  100. package/ccw/dist/core/routes/claude-routes.js +206 -14
  101. package/ccw/dist/core/routes/claude-routes.js.map +1 -1
  102. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  103. package/ccw/dist/core/routes/cli-routes.js +16 -1
  104. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  105. package/ccw/dist/core/routes/commands-routes.d.ts +7 -0
  106. package/ccw/dist/core/routes/commands-routes.d.ts.map +1 -0
  107. package/ccw/dist/core/routes/commands-routes.js +480 -0
  108. package/ccw/dist/core/routes/commands-routes.js.map +1 -0
  109. package/ccw/dist/core/routes/model-routes.d.ts +11 -0
  110. package/ccw/dist/core/routes/model-routes.d.ts.map +1 -0
  111. package/ccw/dist/core/routes/model-routes.js +112 -0
  112. package/ccw/dist/core/routes/model-routes.js.map +1 -0
  113. package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -1
  114. package/ccw/dist/core/routes/nav-status-routes.js +84 -1
  115. package/ccw/dist/core/routes/nav-status-routes.js.map +1 -1
  116. package/ccw/dist/core/routes/provider-routes.d.ts +11 -0
  117. package/ccw/dist/core/routes/provider-routes.d.ts.map +1 -0
  118. package/ccw/dist/core/routes/provider-routes.js +67 -0
  119. package/ccw/dist/core/routes/provider-routes.js.map +1 -0
  120. package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
  121. package/ccw/dist/core/routes/skills-routes.js +219 -7
  122. package/ccw/dist/core/routes/skills-routes.js.map +1 -1
  123. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  124. package/ccw/dist/core/routes/system-routes.js +58 -6
  125. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  126. package/ccw/dist/core/server.d.ts.map +1 -1
  127. package/ccw/dist/core/server.js +13 -0
  128. package/ccw/dist/core/server.js.map +1 -1
  129. package/ccw/dist/mcp-server/index.js +2 -2
  130. package/ccw/dist/mcp-server/index.js.map +1 -1
  131. package/ccw/dist/tools/claude-cli-tools.d.ts +48 -11
  132. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  133. package/ccw/dist/tools/claude-cli-tools.js +146 -50
  134. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  135. package/ccw/dist/tools/cli-config-manager.d.ts +1 -13
  136. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  137. package/ccw/dist/tools/cli-config-manager.js +3 -27
  138. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  139. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  140. package/ccw/dist/tools/cli-executor-core.js +7 -2
  141. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  142. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
  143. package/ccw/dist/tools/cli-history-store.d.ts +11 -0
  144. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  145. package/ccw/dist/tools/cli-history-store.js +82 -2
  146. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  147. package/ccw/dist/tools/command-registry.d.ts +7 -0
  148. package/ccw/dist/tools/command-registry.d.ts.map +1 -1
  149. package/ccw/dist/tools/command-registry.js +14 -1
  150. package/ccw/dist/tools/command-registry.js.map +1 -1
  151. package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -1
  152. package/ccw/dist/tools/generate-module-docs.js +11 -7
  153. package/ccw/dist/tools/generate-module-docs.js.map +1 -1
  154. package/ccw/dist/tools/litellm-executor.d.ts +1 -0
  155. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
  156. package/ccw/dist/tools/litellm-executor.js +11 -9
  157. package/ccw/dist/tools/litellm-executor.js.map +1 -1
  158. package/ccw/dist/types/skill-types.d.ts +97 -0
  159. package/ccw/dist/types/skill-types.d.ts.map +1 -0
  160. package/ccw/dist/types/skill-types.js +6 -0
  161. package/ccw/dist/types/skill-types.js.map +1 -0
  162. package/ccw/src/cli.ts +1 -0
  163. package/ccw/src/commands/cli.ts +87 -9
  164. package/ccw/src/commands/issue.ts +81 -26
  165. package/ccw/src/config/litellm-api-config-manager.ts +5 -3
  166. package/ccw/src/config/litellm-provider-models.ts +222 -0
  167. package/ccw/src/config/provider-models.ts +91 -190
  168. package/ccw/src/config/storage-paths.ts +20 -5
  169. package/ccw/src/core/auth/csrf-middleware.ts +3 -3
  170. package/ccw/src/core/dashboard-generator.ts +3 -1
  171. package/ccw/src/core/routes/claude-routes.ts +233 -15
  172. package/ccw/src/core/routes/cli-routes.ts +18 -4
  173. package/ccw/src/core/routes/commands-routes.ts +620 -0
  174. package/ccw/src/core/routes/nav-status-routes.ts +95 -1
  175. package/ccw/src/core/routes/provider-routes.ts +78 -0
  176. package/ccw/src/core/routes/skills-routes.ts +266 -45
  177. package/ccw/src/core/routes/system-routes.ts +102 -50
  178. package/ccw/src/core/server.ts +13 -0
  179. package/ccw/src/mcp-server/index.ts +2 -2
  180. package/ccw/src/templates/dashboard-css/18-cli-settings.css +35 -0
  181. package/ccw/src/templates/dashboard-css/37-commands.css +193 -0
  182. package/ccw/src/templates/dashboard-js/components/navigation.js +4 -0
  183. package/ccw/src/templates/dashboard-js/i18n.js +116 -0
  184. package/ccw/src/templates/dashboard-js/views/cli-manager.js +249 -4
  185. package/ccw/src/templates/dashboard-js/views/commands-manager.js +503 -0
  186. package/ccw/src/templates/dashboard-js/views/issue-manager.js +7 -7
  187. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +2 -7
  188. package/ccw/src/templates/dashboard-js/views/skills-manager.js +164 -23
  189. package/ccw/src/templates/dashboard.html +7 -0
  190. package/ccw/src/tools/claude-cli-tools.ts +170 -56
  191. package/ccw/src/tools/cli-config-manager.ts +2 -33
  192. package/ccw/src/tools/cli-executor-core.ts +8 -2
  193. package/ccw/src/tools/cli-history-store.ts +92 -2
  194. package/ccw/src/tools/command-registry.ts +16 -1
  195. package/ccw/src/tools/generate-module-docs.ts +11 -7
  196. package/ccw/src/tools/litellm-executor.ts +13 -9
  197. package/ccw/src/types/skill-types.ts +99 -0
  198. package/package.json +1 -1
  199. package/.claude/commands/enhance-prompt.md +0 -93
  200. package/.claude/commands/memory/code-map-memory.md +0 -687
  201. package/.claude/commands/memory/docs.md +0 -615
  202. package/.claude/commands/memory/load-skill-memory.md +0 -182
  203. package/.claude/commands/memory/skill-memory.md +0 -525
  204. package/.claude/commands/memory/swagger-docs.md +0 -773
  205. package/.claude/commands/memory/tech-research-rules.md +0 -310
  206. package/.claude/commands/memory/workflow-skill-memory.md +0 -517
  207. package/.claude/commands/task/breakdown.md +0 -208
  208. package/.claude/commands/task/create.md +0 -152
  209. package/.claude/commands/task/execute.md +0 -270
  210. package/.claude/commands/task/replan.md +0 -441
  211. package/.claude/commands/version.md +0 -254
  212. package/.claude/commands/workflow/action-plan-verify.md +0 -485
  213. package/.claude/commands/workflow/brainstorm/api-designer.md +0 -587
  214. package/.claude/commands/workflow/brainstorm/data-architect.md +0 -220
  215. package/.claude/commands/workflow/brainstorm/product-manager.md +0 -200
  216. package/.claude/commands/workflow/brainstorm/product-owner.md +0 -200
  217. package/.claude/commands/workflow/brainstorm/scrum-master.md +0 -200
  218. package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
  219. package/.claude/commands/workflow/brainstorm/system-architect.md +0 -389
  220. package/.claude/commands/workflow/brainstorm/ui-designer.md +0 -221
  221. package/.claude/commands/workflow/brainstorm/ux-expert.md +0 -221
  222. package/.claude/commands/workflow/debug.md +0 -331
  223. package/.claude/commands/workflow/develop-with-file.md +0 -1044
  224. package/.claude/skills/ccw-loop/README.md +0 -303
  225. package/.claude/skills/skill-generator/templates/script-bash.md +0 -277
  226. package/.claude/skills/skill-generator/templates/script-python.md +0 -198
  227. package/.codex/prompts/debug.md +0 -318
  228. package/ccw/src/core/routes/mcp-routes.ts.backup +0 -549
@@ -0,0 +1,610 @@
1
+ ---
2
+ description: Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding. Supports depth control and iteration limits.
3
+ argument-hint: "TOPIC=\"<topic or question>\" [--depth=standard|deep|full] [--max-iterations=<n>] [--verbose]"
4
+ ---
5
+
6
+ # Codex Analyze-With-File Prompt
7
+
8
+ ## Overview
9
+
10
+ Interactive collaborative analysis workflow with **documented discussion process**. Records understanding evolution, facilitates multi-round Q&A, and uses deep analysis for codebase and concept exploration.
11
+
12
+ **Core workflow**: Topic → Explore → Discuss → Document → Refine → Conclude
13
+
14
+ **Key features**:
15
+ - **discussion.md**: Timeline of discussions and understanding evolution
16
+ - **Multi-round Q&A**: Iterative clarification with user
17
+ - **Analysis-assisted exploration**: Deep codebase and concept analysis
18
+ - **Consolidated insights**: Synthesizes discussions into actionable conclusions
19
+ - **Flexible continuation**: Resume analysis sessions to build on previous work
20
+
21
+ ## Target Topic
22
+
23
+ **$TOPIC**
24
+
25
+ - `--depth`: Analysis depth (standard|deep|full)
26
+ - `--max-iterations`: Max discussion rounds
27
+
28
+ ## Execution Process
29
+
30
+ ```
31
+ Session Detection:
32
+ ├─ Check if analysis session exists for topic
33
+ ├─ EXISTS + discussion.md exists → Continue mode
34
+ └─ NOT_FOUND → New session mode
35
+
36
+ Phase 1: Topic Understanding
37
+ ├─ Parse topic/question
38
+ ├─ Identify analysis dimensions (architecture, implementation, concept, etc.)
39
+ ├─ Initial scoping with user
40
+ └─ Document initial understanding in discussion.md
41
+
42
+ Phase 2: Exploration (Parallel)
43
+ ├─ Search codebase for relevant patterns
44
+ ├─ Analyze code structure and dependencies
45
+ └─ Aggregate findings into exploration summary
46
+
47
+ Phase 3: Interactive Discussion (Multi-Round)
48
+ ├─ Present exploration findings
49
+ ├─ Facilitate Q&A with user
50
+ ├─ Capture user insights and requirements
51
+ ├─ Update discussion.md with each round
52
+ └─ Repeat until user is satisfied or clarity achieved
53
+
54
+ Phase 4: Synthesis & Conclusion
55
+ ├─ Consolidate all insights
56
+ ├─ Update discussion.md with conclusions
57
+ ├─ Generate actionable recommendations
58
+ └─ Optional: Create follow-up tasks or issues
59
+
60
+ Output:
61
+ ├─ .workflow/.analysis/{slug}-{date}/discussion.md (evolving document)
62
+ ├─ .workflow/.analysis/{slug}-{date}/explorations.json (findings)
63
+ └─ .workflow/.analysis/{slug}-{date}/conclusions.json (final synthesis)
64
+ ```
65
+
66
+ ## Implementation Details
67
+
68
+ ### Session Setup & Mode Detection
69
+
70
+ ```javascript
71
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
72
+
73
+ const topicSlug = "$TOPIC".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
74
+ const dateStr = getUtc8ISOString().substring(0, 10)
75
+
76
+ const sessionId = `ANL-${topicSlug}-${dateStr}`
77
+ const sessionFolder = `.workflow/.analysis/${sessionId}`
78
+ const discussionPath = `${sessionFolder}/discussion.md`
79
+ const explorationsPath = `${sessionFolder}/explorations.json`
80
+ const conclusionsPath = `${sessionFolder}/conclusions.json`
81
+
82
+ // Auto-detect mode
83
+ const sessionExists = fs.existsSync(sessionFolder)
84
+ const hasDiscussion = sessionExists && fs.existsSync(discussionPath)
85
+
86
+ const mode = hasDiscussion ? 'continue' : 'new'
87
+
88
+ if (!sessionExists) {
89
+ bash(`mkdir -p ${sessionFolder}`)
90
+ }
91
+ ```
92
+
93
+ ---
94
+
95
+ ### Phase 1: Topic Understanding
96
+
97
+ #### Step 1.1: Parse Topic & Identify Dimensions
98
+
99
+ ```javascript
100
+ // Analyze topic to determine analysis dimensions
101
+ const ANALYSIS_DIMENSIONS = {
102
+ architecture: ['架构', 'architecture', 'design', 'structure', '设计'],
103
+ implementation: ['实现', 'implement', 'code', 'coding', '代码'],
104
+ performance: ['性能', 'performance', 'optimize', 'bottleneck', '优化'],
105
+ security: ['安全', 'security', 'auth', 'permission', '权限'],
106
+ concept: ['概念', 'concept', 'theory', 'principle', '原理'],
107
+ comparison: ['比较', 'compare', 'vs', 'difference', '区别'],
108
+ decision: ['决策', 'decision', 'choice', 'tradeoff', '选择']
109
+ }
110
+
111
+ function identifyDimensions(topic) {
112
+ const text = topic.toLowerCase()
113
+ const matched = []
114
+
115
+ for (const [dimension, keywords] of Object.entries(ANALYSIS_DIMENSIONS)) {
116
+ if (keywords.some(k => text.includes(k))) {
117
+ matched.push(dimension)
118
+ }
119
+ }
120
+
121
+ return matched.length > 0 ? matched : ['general']
122
+ }
123
+
124
+ const dimensions = identifyDimensions("$TOPIC")
125
+ ```
126
+
127
+ #### Step 1.2: Initial Scoping (New Session Only)
128
+
129
+ Ask user to scope the analysis:
130
+
131
+ - Focus areas: 代码实现 / 架构设计 / 最佳实践 / 问题诊断
132
+ - Analysis depth: Quick Overview / Standard Analysis / Deep Dive
133
+
134
+ #### Step 1.3: Create/Update discussion.md
135
+
136
+ For new session:
137
+
138
+ ```markdown
139
+ # Analysis Discussion
140
+
141
+ **Session ID**: ${sessionId}
142
+ **Topic**: $TOPIC
143
+ **Started**: ${getUtc8ISOString()}
144
+ **Dimensions**: ${dimensions.join(', ')}
145
+
146
+ ---
147
+
148
+ ## User Context
149
+
150
+ **Focus Areas**: ${userFocusAreas.join(', ')}
151
+ **Analysis Depth**: ${analysisDepth}
152
+
153
+ ---
154
+
155
+ ## Discussion Timeline
156
+
157
+ ### Round 1 - Initial Understanding (${timestamp})
158
+
159
+ #### Topic Analysis
160
+
161
+ Based on topic "$TOPIC":
162
+
163
+ - **Primary dimensions**: ${dimensions.join(', ')}
164
+ - **Initial scope**: ${initialScope}
165
+ - **Key questions to explore**:
166
+ - ${question1}
167
+ - ${question2}
168
+ - ${question3}
169
+
170
+ #### Next Steps
171
+
172
+ - Search codebase for relevant patterns
173
+ - Gather insights via analysis
174
+ - Prepare discussion points for user
175
+
176
+ ---
177
+
178
+ ## Current Understanding
179
+
180
+ ${initialUnderstanding}
181
+ ```
182
+
183
+ For continue session, append:
184
+
185
+ ```markdown
186
+ ### Round ${n} - Continuation (${timestamp})
187
+
188
+ #### Previous Context
189
+
190
+ Resuming analysis based on prior discussion.
191
+
192
+ #### New Focus
193
+
194
+ ${newFocusFromUser}
195
+ ```
196
+
197
+ ---
198
+
199
+ ### Phase 2: Exploration
200
+
201
+ #### Step 2.1: Codebase Search
202
+
203
+ ```javascript
204
+ // Extract keywords from topic
205
+ const keywords = extractTopicKeywords("$TOPIC")
206
+
207
+ // Search codebase for relevant code
208
+ const searchResults = []
209
+ for (const keyword of keywords) {
210
+ const results = Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
211
+ searchResults.push({ keyword, results })
212
+ }
213
+
214
+ // Identify affected files and patterns
215
+ const relevantLocations = analyzeSearchResults(searchResults)
216
+ ```
217
+
218
+ #### Step 2.2: Pattern Analysis
219
+
220
+ Analyze the codebase from identified dimensions:
221
+
222
+ 1. Architecture patterns and structure
223
+ 2. Implementation conventions
224
+ 3. Dependency relationships
225
+ 4. Potential issues or improvements
226
+
227
+ #### Step 2.3: Aggregate Findings
228
+
229
+ ```javascript
230
+ // Aggregate into explorations.json
231
+ const explorations = {
232
+ session_id: sessionId,
233
+ timestamp: getUtc8ISOString(),
234
+ topic: "$TOPIC",
235
+ dimensions: dimensions,
236
+ sources: [
237
+ { type: "codebase", summary: codebaseSummary },
238
+ { type: "analysis", summary: analysisSummary }
239
+ ],
240
+ key_findings: [...],
241
+ discussion_points: [...],
242
+ open_questions: [...]
243
+ }
244
+
245
+ Write(explorationsPath, JSON.stringify(explorations, null, 2))
246
+ ```
247
+
248
+ #### Step 2.4: Update discussion.md
249
+
250
+ ```markdown
251
+ #### Exploration Results (${timestamp})
252
+
253
+ **Sources Analyzed**:
254
+ ${sources.map(s => `- ${s.type}: ${s.summary}`).join('\n')}
255
+
256
+ **Key Findings**:
257
+ ${keyFindings.map((f, i) => `${i+1}. ${f}`).join('\n')}
258
+
259
+ **Points for Discussion**:
260
+ ${discussionPoints.map((p, i) => `${i+1}. ${p}`).join('\n')}
261
+
262
+ **Open Questions**:
263
+ ${openQuestions.map((q, i) => `- ${q}`).join('\n')}
264
+ ```
265
+
266
+ ---
267
+
268
+ ### Phase 3: Interactive Discussion (Multi-Round)
269
+
270
+ #### Step 3.1: Present Findings & Gather Feedback
271
+
272
+ ```javascript
273
+ // Maximum discussion rounds
274
+ const MAX_ROUNDS = 5
275
+ let roundNumber = 1
276
+ let discussionComplete = false
277
+
278
+ while (!discussionComplete && roundNumber <= MAX_ROUNDS) {
279
+ // Display current findings
280
+ console.log(`
281
+ ## Discussion Round ${roundNumber}
282
+
283
+ ${currentFindings}
284
+
285
+ ### Key Points for Your Input
286
+ ${discussionPoints.map((p, i) => `${i+1}. ${p}`).join('\n')}
287
+ `)
288
+
289
+ // Gather user input
290
+ // Options:
291
+ // - 同意,继续深入: Deepen analysis in current direction
292
+ // - 需要调整方向: Get user's adjusted focus
293
+ // - 分析完成: Exit loop
294
+ // - 有具体问题: Answer specific questions
295
+
296
+ // Process user response and update understanding
297
+ updateDiscussionDocument(roundNumber, userResponse, findings)
298
+ roundNumber++
299
+ }
300
+ ```
301
+
302
+ #### Step 3.2: Document Each Round
303
+
304
+ Append to discussion.md:
305
+
306
+ ```markdown
307
+ ### Round ${n} - Discussion (${timestamp})
308
+
309
+ #### User Input
310
+
311
+ ${userInputSummary}
312
+
313
+ ${userResponse === 'adjustment' ? `
314
+ **Direction Adjustment**: ${adjustmentDetails}
315
+ ` : ''}
316
+
317
+ ${userResponse === 'questions' ? `
318
+ **User Questions**:
319
+ ${userQuestions.map((q, i) => `${i+1}. ${q}`).join('\n')}
320
+
321
+ **Answers**:
322
+ ${answers.map((a, i) => `${i+1}. ${a}`).join('\n')}
323
+ ` : ''}
324
+
325
+ #### Updated Understanding
326
+
327
+ Based on user feedback:
328
+ - ${insight1}
329
+ - ${insight2}
330
+
331
+ #### Corrected Assumptions
332
+
333
+ ${corrections.length > 0 ? corrections.map(c => `
334
+ - ~~${c.wrong}~~ → ${c.corrected}
335
+ - Reason: ${c.reason}
336
+ `).join('\n') : 'None'}
337
+
338
+ #### New Insights
339
+
340
+ ${newInsights.map(i => `- ${i}`).join('\n')}
341
+ ```
342
+
343
+ ---
344
+
345
+ ### Phase 4: Synthesis & Conclusion
346
+
347
+ #### Step 4.1: Consolidate Insights
348
+
349
+ ```javascript
350
+ const conclusions = {
351
+ session_id: sessionId,
352
+ topic: "$TOPIC",
353
+ completed: getUtc8ISOString(),
354
+ total_rounds: roundNumber,
355
+
356
+ summary: "...",
357
+
358
+ key_conclusions: [
359
+ { point: "...", evidence: "...", confidence: "high|medium|low" }
360
+ ],
361
+
362
+ recommendations: [
363
+ { action: "...", rationale: "...", priority: "high|medium|low" }
364
+ ],
365
+
366
+ open_questions: [...],
367
+
368
+ follow_up_suggestions: [
369
+ { type: "issue", summary: "..." },
370
+ { type: "task", summary: "..." }
371
+ ]
372
+ }
373
+
374
+ Write(conclusionsPath, JSON.stringify(conclusions, null, 2))
375
+ ```
376
+
377
+ #### Step 4.2: Final discussion.md Update
378
+
379
+ ```markdown
380
+ ---
381
+
382
+ ## Conclusions (${timestamp})
383
+
384
+ ### Summary
385
+
386
+ ${summaryParagraph}
387
+
388
+ ### Key Conclusions
389
+
390
+ ${conclusions.key_conclusions.map((c, i) => `
391
+ ${i+1}. **${c.point}** (Confidence: ${c.confidence})
392
+ - Evidence: ${c.evidence}
393
+ `).join('\n')}
394
+
395
+ ### Recommendations
396
+
397
+ ${conclusions.recommendations.map((r, i) => `
398
+ ${i+1}. **${r.action}** (Priority: ${r.priority})
399
+ - Rationale: ${r.rationale}
400
+ `).join('\n')}
401
+
402
+ ### Remaining Questions
403
+
404
+ ${conclusions.open_questions.map(q => `- ${q}`).join('\n')}
405
+
406
+ ---
407
+
408
+ ## Current Understanding (Final)
409
+
410
+ ### What We Established
411
+
412
+ ${establishedPoints.map(p => `- ${p}`).join('\n')}
413
+
414
+ ### What Was Clarified/Corrected
415
+
416
+ ${corrections.map(c => `- ~~${c.original}~~ → ${c.corrected}`).join('\n')}
417
+
418
+ ### Key Insights
419
+
420
+ ${keyInsights.map(i => `- ${i}`).join('\n')}
421
+
422
+ ---
423
+
424
+ ## Session Statistics
425
+
426
+ - **Total Rounds**: ${totalRounds}
427
+ - **Duration**: ${duration}
428
+ - **Sources Used**: ${sources.join(', ')}
429
+ - **Artifacts Generated**: discussion.md, explorations.json, conclusions.json
430
+ ```
431
+
432
+ #### Step 4.3: Post-Completion Options
433
+
434
+ Offer follow-up options:
435
+ - Create Issue: Convert conclusions to actionable issues
436
+ - Generate Task: Create implementation tasks
437
+ - Export Report: Generate standalone analysis report
438
+ - Complete: No further action needed
439
+
440
+ ---
441
+
442
+ ## Session Folder Structure
443
+
444
+ ```
445
+ .workflow/.analysis/ANL-{slug}-{date}/
446
+ ├── discussion.md # Evolution of understanding & discussions
447
+ ├── explorations.json # Exploration findings
448
+ ├── conclusions.json # Final synthesis
449
+ └── exploration-*.json # Individual exploration results (optional)
450
+ ```
451
+
452
+ ## Discussion Document Template
453
+
454
+ ```markdown
455
+ # Analysis Discussion
456
+
457
+ **Session ID**: ANL-xxx-2025-01-25
458
+ **Topic**: [topic or question]
459
+ **Started**: 2025-01-25T10:00:00+08:00
460
+ **Dimensions**: [architecture, implementation, ...]
461
+
462
+ ---
463
+
464
+ ## User Context
465
+
466
+ **Focus Areas**: [user-selected focus]
467
+ **Analysis Depth**: [quick|standard|deep]
468
+
469
+ ---
470
+
471
+ ## Discussion Timeline
472
+
473
+ ### Round 1 - Initial Understanding (2025-01-25 10:00)
474
+
475
+ #### Topic Analysis
476
+ ...
477
+
478
+ #### Exploration Results
479
+ ...
480
+
481
+ ### Round 2 - Discussion (2025-01-25 10:15)
482
+
483
+ #### User Input
484
+ ...
485
+
486
+ #### Updated Understanding
487
+ ...
488
+
489
+ #### Corrected Assumptions
490
+ - ~~[wrong]~~ → [corrected]
491
+
492
+ ### Round 3 - Deep Dive (2025-01-25 10:30)
493
+ ...
494
+
495
+ ---
496
+
497
+ ## Conclusions (2025-01-25 11:00)
498
+
499
+ ### Summary
500
+ ...
501
+
502
+ ### Key Conclusions
503
+ ...
504
+
505
+ ### Recommendations
506
+ ...
507
+
508
+ ---
509
+
510
+ ## Current Understanding (Final)
511
+
512
+ ### What We Established
513
+ - [confirmed points]
514
+
515
+ ### What Was Clarified/Corrected
516
+ - ~~[original assumption]~~ → [corrected understanding]
517
+
518
+ ### Key Insights
519
+ - [insights gained]
520
+
521
+ ---
522
+
523
+ ## Session Statistics
524
+
525
+ - **Total Rounds**: 3
526
+ - **Duration**: 1 hour
527
+ - **Sources Used**: codebase exploration, analysis
528
+ - **Artifacts Generated**: discussion.md, explorations.json, conclusions.json
529
+ ```
530
+
531
+ ## Iteration Flow
532
+
533
+ ```
534
+ First Call (TOPIC="topic"):
535
+ ├─ No session exists → New mode
536
+ ├─ Identify analysis dimensions
537
+ ├─ Scope with user
538
+ ├─ Create discussion.md with initial understanding
539
+ ├─ Launch explorations
540
+ └─ Enter discussion loop
541
+
542
+ Continue Call (TOPIC="topic"):
543
+ ├─ Session exists → Continue mode
544
+ ├─ Load discussion.md
545
+ ├─ Resume from last round
546
+ └─ Continue discussion loop
547
+
548
+ Discussion Loop:
549
+ ├─ Present current findings
550
+ ├─ Gather user feedback
551
+ ├─ Process response:
552
+ │ ├─ Agree → Deepen analysis
553
+ │ ├─ Adjust → Change direction
554
+ │ ├─ Question → Answer then continue
555
+ │ └─ Complete → Exit loop
556
+ ├─ Update discussion.md
557
+ └─ Repeat until complete or max rounds
558
+
559
+ Completion:
560
+ ├─ Generate conclusions.json
561
+ ├─ Update discussion.md with final synthesis
562
+ └─ Offer follow-up options
563
+ ```
564
+
565
+ ## Consolidation Rules
566
+
567
+ When updating "Current Understanding":
568
+
569
+ 1. **Promote confirmed insights**: Move validated findings to "What We Established"
570
+ 2. **Track corrections**: Keep important wrong→right transformations
571
+ 3. **Focus on current state**: What do we know NOW
572
+ 4. **Avoid timeline repetition**: Don't copy discussion details
573
+ 5. **Preserve key learnings**: Keep insights valuable for future reference
574
+
575
+ **Bad (cluttered)**:
576
+ ```markdown
577
+ ## Current Understanding
578
+
579
+ In round 1 we discussed X, then in round 2 user said Y, and we explored Z...
580
+ ```
581
+
582
+ **Good (consolidated)**:
583
+ ```markdown
584
+ ## Current Understanding
585
+
586
+ ### What We Established
587
+ - The authentication flow uses JWT with refresh tokens
588
+ - Rate limiting is implemented at API gateway level
589
+
590
+ ### What Was Clarified
591
+ - ~~Assumed Redis for sessions~~ → Actually uses database-backed sessions
592
+
593
+ ### Key Insights
594
+ - Current architecture supports horizontal scaling
595
+ - Security audit recommended before production
596
+ ```
597
+
598
+ ## Error Handling
599
+
600
+ | Situation | Action |
601
+ |-----------|--------|
602
+ | Exploration fails | Continue with available context, note limitation |
603
+ | User timeout in discussion | Save state, show resume instructions |
604
+ | Max rounds reached | Force synthesis, offer continuation option |
605
+ | No relevant findings | Broaden search, ask user for clarification |
606
+ | Session folder conflict | Append timestamp suffix |
607
+
608
+ ---
609
+
610
+ **Now execute the analyze-with-file workflow for topic**: $TOPIC