claude-code-workflow 6.3.34 → 6.3.36

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 (34) hide show
  1. package/.claude/agents/cli-execution-agent.md +61 -0
  2. package/.claude/agents/cli-lite-planning-agent.md +322 -36
  3. package/.claude/agents/issue-plan-agent.md +95 -11
  4. package/.claude/commands/cli/codex-review.md +8 -2
  5. package/.claude/commands/issue/plan.md +20 -6
  6. package/.claude/commands/workflow/lite-execute.md +56 -16
  7. package/.claude/commands/workflow/lite-plan.md +1 -1
  8. package/.claude/workflows/cli-templates/schemas/issues-jsonl-schema.json +29 -0
  9. package/.claude/workflows/cli-templates/schemas/plan-json-schema.json +200 -0
  10. package/.codex/prompts/debug-with-file.md +609 -0
  11. package/ccw/dist/commands/cli.d.ts.map +1 -1
  12. package/ccw/dist/commands/cli.js +2 -3
  13. package/ccw/dist/commands/cli.js.map +1 -1
  14. package/ccw/dist/commands/issue.d.ts.map +1 -1
  15. package/ccw/dist/commands/issue.js +37 -4
  16. package/ccw/dist/commands/issue.js.map +1 -1
  17. package/ccw/dist/core/routes/hooks-routes.d.ts.map +1 -1
  18. package/ccw/dist/core/routes/hooks-routes.js +3 -0
  19. package/ccw/dist/core/routes/hooks-routes.js.map +1 -1
  20. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  21. package/ccw/dist/tools/codex-lens.js +66 -47
  22. package/ccw/dist/tools/codex-lens.js.map +1 -1
  23. package/ccw/scripts/IMPLEMENTATION-SUMMARY.md +2 -2
  24. package/ccw/scripts/QUICK-REFERENCE.md +1 -1
  25. package/ccw/scripts/README-memory-embedder.md +1 -1
  26. package/ccw/scripts/memory_embedder.py +1 -1
  27. package/ccw/src/commands/cli.ts +2 -3
  28. package/ccw/src/commands/issue.ts +41 -5
  29. package/ccw/src/core/routes/hooks-routes.ts +3 -0
  30. package/ccw/src/templates/dashboard-css/32-issue-manager.css +160 -0
  31. package/ccw/src/templates/dashboard-css/33-cli-stream-viewer.css +2 -2
  32. package/ccw/src/templates/dashboard-js/views/issue-manager.js +159 -0
  33. package/ccw/src/tools/codex-lens.ts +71 -44
  34. package/package.json +1 -1
@@ -61,6 +61,29 @@ Score = 0
61
61
 
62
62
  **Extract Keywords**: domains (auth, api, database, ui), technologies (react, typescript, node), actions (implement, refactor, test)
63
63
 
64
+ **Plan Context Loading** (when executing from plan.json):
65
+ ```javascript
66
+ // Load task-specific context from plan fields
67
+ const task = plan.tasks.find(t => t.id === taskId)
68
+ const context = {
69
+ // Base context
70
+ scope: task.scope,
71
+ modification_points: task.modification_points,
72
+ implementation: task.implementation,
73
+
74
+ // Medium/High complexity: WHY + HOW to verify
75
+ rationale: task.rationale?.chosen_approach, // Why this approach
76
+ verification: task.verification?.success_metrics, // How to verify success
77
+
78
+ // High complexity: risks + code skeleton
79
+ risks: task.risks?.map(r => r.mitigation), // Risk mitigations to follow
80
+ code_skeleton: task.code_skeleton, // Interface/function signatures
81
+
82
+ // Global context
83
+ data_flow: plan.data_flow?.diagram // Data flow overview
84
+ }
85
+ ```
86
+
64
87
  ---
65
88
 
66
89
  ## Phase 2: Context Discovery
@@ -129,6 +152,30 @@ EXPECTED: {clear_output_expectations}
129
152
  CONSTRAINTS: {constraints}
130
153
  ```
131
154
 
155
+ **5. Plan-Aware Prompt Enhancement** (when executing from plan.json):
156
+ ```bash
157
+ # Include rationale in PURPOSE (Medium/High)
158
+ PURPOSE: {task.description}
159
+ Approach: {task.rationale.chosen_approach}
160
+ Decision factors: {task.rationale.decision_factors.join(', ')}
161
+
162
+ # Include code skeleton in TASK (High)
163
+ TASK: {task.implementation.join('\n')}
164
+ Key interfaces: {task.code_skeleton.interfaces.map(i => i.signature)}
165
+ Key functions: {task.code_skeleton.key_functions.map(f => f.signature)}
166
+
167
+ # Include verification in EXPECTED
168
+ EXPECTED: {task.acceptance.join(', ')}
169
+ Success metrics: {task.verification.success_metrics.join(', ')}
170
+
171
+ # Include risk mitigations in CONSTRAINTS (High)
172
+ CONSTRAINTS: {constraints}
173
+ Risk mitigations: {task.risks.map(r => r.mitigation).join('; ')}
174
+
175
+ # Include data flow context (High)
176
+ Memory: Data flow: {plan.data_flow.diagram}
177
+ ```
178
+
132
179
  ---
133
180
 
134
181
  ## Phase 4: Tool Selection & Execution
@@ -205,11 +252,25 @@ find .workflow/active/ -name 'WFS-*' -type d
205
252
  **Timestamp**: {iso_timestamp} | **Session**: {session_id} | **Task**: {task_id}
206
253
 
207
254
  ## Phase 1: Intent {intent} | Complexity {complexity} | Keywords {keywords}
255
+ [Medium/High] Rationale: {task.rationale.chosen_approach}
256
+ [High] Risks: {task.risks.map(r => `${r.description} → ${r.mitigation}`).join('; ')}
257
+
208
258
  ## Phase 2: Files ({N}) | Patterns {patterns} | Dependencies {deps}
259
+ [High] Data Flow: {plan.data_flow.diagram}
260
+
209
261
  ## Phase 3: Enhanced Prompt
210
262
  {full_prompt}
263
+ [High] Code Skeleton:
264
+ - Interfaces: {task.code_skeleton.interfaces.map(i => i.name).join(', ')}
265
+ - Functions: {task.code_skeleton.key_functions.map(f => f.signature).join('; ')}
266
+
211
267
  ## Phase 4: Tool {tool} | Command {cmd} | Result {status} | Duration {time}
268
+
212
269
  ## Phase 5: Log {path} | Summary {summary_path}
270
+ [Medium/High] Verification Checklist:
271
+ - Unit Tests: {task.verification.unit_tests.join(', ')}
272
+ - Success Metrics: {task.verification.success_metrics.join(', ')}
273
+
213
274
  ## Next Steps: {actions}
214
275
  ```
215
276
 
@@ -77,6 +77,8 @@ Phase 4: planObject Generation
77
77
 
78
78
  ## CLI Command Template
79
79
 
80
+ ### Base Template (All Complexity Levels)
81
+
80
82
  ```bash
81
83
  ccw cli -p "
82
84
  PURPOSE: Generate plan for {task_description}
@@ -84,12 +86,18 @@ TASK:
84
86
  • Analyze task/bug description and context
85
87
  • Break down into tasks following schema structure
86
88
  • Identify dependencies and execution phases
89
+ • Generate complexity-appropriate fields (rationale, verification, risks, code_skeleton, data_flow)
87
90
  MODE: analysis
88
91
  CONTEXT: @**/* | Memory: {context_summary}
89
92
  EXPECTED:
90
93
  ## Summary
91
94
  [overview]
92
95
 
96
+ ## Approach
97
+ [high-level strategy]
98
+
99
+ ## Complexity: {Low|Medium|High}
100
+
93
101
  ## Task Breakdown
94
102
  ### T1: [Title] (or FIX1 for fix-plan)
95
103
  **Scope**: [module/feature path]
@@ -97,17 +105,54 @@ EXPECTED:
97
105
  **Description**: [what]
98
106
  **Modification Points**: - [file]: [target] - [change]
99
107
  **Implementation**: 1. [step]
100
- **Acceptance/Verification**: - [quantified criterion]
108
+ **Reference**: - Pattern: [pattern] - Files: [files] - Examples: [guidance]
109
+ **Acceptance**: - [quantified criterion]
101
110
  **Depends On**: []
102
111
 
112
+ [MEDIUM/HIGH COMPLEXITY ONLY]
113
+ **Rationale**:
114
+ - Chosen Approach: [why this approach]
115
+ - Alternatives Considered: [other options]
116
+ - Decision Factors: [key factors]
117
+ - Tradeoffs: [known tradeoffs]
118
+
119
+ **Verification**:
120
+ - Unit Tests: [test names]
121
+ - Integration Tests: [test names]
122
+ - Manual Checks: [specific steps]
123
+ - Success Metrics: [quantified metrics]
124
+
125
+ [HIGH COMPLEXITY ONLY]
126
+ **Risks**:
127
+ - Risk: [description] | Probability: [L/M/H] | Impact: [L/M/H] | Mitigation: [strategy] | Fallback: [alternative]
128
+
129
+ **Code Skeleton**:
130
+ - Interfaces: [name]: [definition] - [purpose]
131
+ - Functions: [signature] - [purpose] - returns [type]
132
+ - Classes: [name] - [purpose] - methods: [list]
133
+
134
+ ## Data Flow (HIGH COMPLEXITY ONLY)
135
+ **Diagram**: [A → B → C]
136
+ **Stages**:
137
+ - Stage [name]: Input=[type] → Output=[type] | Component=[module] | Transforms=[list]
138
+ **Dependencies**: [external deps]
139
+
140
+ ## Design Decisions (MEDIUM/HIGH)
141
+ - Decision: [what] | Rationale: [why] | Tradeoff: [what was traded]
142
+
103
143
  ## Flow Control
104
144
  **Execution Order**: - Phase parallel-1: [T1, T2] (independent)
145
+ **Exit Conditions**: - Success: [condition] - Failure: [condition]
105
146
 
106
147
  ## Time Estimate
107
148
  **Total**: [time]
108
149
 
109
150
  CONSTRAINTS:
110
151
  - Follow schema structure from {schema_path}
152
+ - Complexity determines required fields:
153
+ * Low: base fields only
154
+ * Medium: + rationale + verification + design_decisions
155
+ * High: + risks + code_skeleton + data_flow
111
156
  - Acceptance/verification must be quantified
112
157
  - Dependencies use task IDs
113
158
  - analysis=READ-ONLY
@@ -127,43 +172,80 @@ function extractSection(cliOutput, header) {
127
172
  }
128
173
 
129
174
  // Parse structured tasks from CLI output
130
- function extractStructuredTasks(cliOutput) {
175
+ function extractStructuredTasks(cliOutput, complexity) {
131
176
  const tasks = []
132
- const taskPattern = /### (T\d+): (.+?)\n\*\*File\*\*: (.+?)\n\*\*Action\*\*: (.+?)\n\*\*Description\*\*: (.+?)\n\*\*Modification Points\*\*:\n((?:- .+?\n)*)\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)\*\*Reference\*\*:\n((?:- .+?\n)+)\*\*Acceptance\*\*:\n((?:- .+?\n)+)\*\*Depends On\*\*: (.+)/g
177
+ // Split by task headers
178
+ const taskBlocks = cliOutput.split(/### (T\d+):/).slice(1)
133
179
 
134
- let match
135
- while ((match = taskPattern.exec(cliOutput)) !== null) {
136
- // Parse modification points
137
- const modPoints = match[6].trim().split('\n').filter(s => s.startsWith('-')).map(s => {
138
- const m = /- \[(.+?)\]: \[(.+?)\] - (.+)/.exec(s)
139
- return m ? { file: m[1], target: m[2], change: m[3] } : null
140
- }).filter(Boolean)
180
+ for (let i = 0; i < taskBlocks.length; i += 2) {
181
+ const taskId = taskBlocks[i].trim()
182
+ const taskText = taskBlocks[i + 1]
141
183
 
142
- // Parse reference
143
- const refText = match[8].trim()
144
- const reference = {
145
- pattern: (/- Pattern: (.+)/m.exec(refText) || [])[1]?.trim() || "No pattern",
146
- files: ((/- Files: (.+)/m.exec(refText) || [])[1] || "").split(',').map(f => f.trim()).filter(Boolean),
147
- examples: (/- Examples: (.+)/m.exec(refText) || [])[1]?.trim() || "Follow general pattern"
184
+ // Extract base fields
185
+ const titleMatch = /^(.+?)(?=\n)/.exec(taskText)
186
+ const scopeMatch = /\*\*Scope\*\*: (.+?)(?=\n)/.exec(taskText)
187
+ const actionMatch = /\*\*Action\*\*: (.+?)(?=\n)/.exec(taskText)
188
+ const descMatch = /\*\*Description\*\*: (.+?)(?=\n)/.exec(taskText)
189
+ const depsMatch = /\*\*Depends On\*\*: (.+?)(?=\n|$)/.exec(taskText)
190
+
191
+ // Parse modification points
192
+ const modPointsSection = /\*\*Modification Points\*\*:\n((?:- .+?\n)*)/.exec(taskText)
193
+ const modPoints = []
194
+ if (modPointsSection) {
195
+ const lines = modPointsSection[1].split('\n').filter(s => s.trim().startsWith('-'))
196
+ lines.forEach(line => {
197
+ const m = /- \[(.+?)\]: \[(.+?)\] - (.+)/.exec(line)
198
+ if (m) modPoints.push({ file: m[1].trim(), target: m[2].trim(), change: m[3].trim() })
199
+ })
148
200
  }
149
201
 
150
- // Parse depends_on
151
- const depsText = match[10].trim()
152
- const depends_on = depsText === '[]' ? [] : depsText.replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean)
202
+ // Parse implementation
203
+ const implSection = /\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)/.exec(taskText)
204
+ const implementation = implSection
205
+ ? implSection[1].split('\n').map(s => s.replace(/^\d+\. /, '').trim()).filter(Boolean)
206
+ : []
153
207
 
154
- tasks.push({
155
- id: match[1].trim(),
156
- title: match[2].trim(),
157
- file: match[3].trim(),
158
- action: match[4].trim(),
159
- description: match[5].trim(),
208
+ // Parse reference
209
+ const refSection = /\*\*Reference\*\*:\n((?:- .+?\n)+)/.exec(taskText)
210
+ const reference = refSection ? {
211
+ pattern: (/- Pattern: (.+)/m.exec(refSection[1]) || [])[1]?.trim() || "No pattern",
212
+ files: ((/- Files: (.+)/m.exec(refSection[1]) || [])[1] || "").split(',').map(f => f.trim()).filter(Boolean),
213
+ examples: (/- Examples: (.+)/m.exec(refSection[1]) || [])[1]?.trim() || "Follow pattern"
214
+ } : {}
215
+
216
+ // Parse acceptance
217
+ const acceptSection = /\*\*Acceptance\*\*:\n((?:- .+?\n)+)/.exec(taskText)
218
+ const acceptance = acceptSection
219
+ ? acceptSection[1].split('\n').map(s => s.replace(/^- /, '').trim()).filter(Boolean)
220
+ : []
221
+
222
+ const task = {
223
+ id: taskId,
224
+ title: titleMatch?.[1].trim() || "Untitled",
225
+ scope: scopeMatch?.[1].trim() || "",
226
+ action: actionMatch?.[1].trim() || "Implement",
227
+ description: descMatch?.[1].trim() || "",
160
228
  modification_points: modPoints,
161
- implementation: match[7].trim().split('\n').map(s => s.replace(/^\d+\. /, '')).filter(Boolean),
229
+ implementation,
162
230
  reference,
163
- acceptance: match[9].trim().split('\n').map(s => s.replace(/^- /, '')).filter(Boolean),
164
- depends_on
165
- })
231
+ acceptance,
232
+ depends_on: depsMatch?.[1] === '[]' ? [] : (depsMatch?.[1] || "").replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean)
233
+ }
234
+
235
+ // Add complexity-specific fields
236
+ if (complexity === "Medium" || complexity === "High") {
237
+ task.rationale = extractRationale(taskText)
238
+ task.verification = extractVerification(taskText)
239
+ }
240
+
241
+ if (complexity === "High") {
242
+ task.risks = extractRisks(taskText)
243
+ task.code_skeleton = extractCodeSkeleton(taskText)
244
+ }
245
+
246
+ tasks.push(task)
166
247
  }
248
+
167
249
  return tasks
168
250
  }
169
251
 
@@ -186,14 +268,155 @@ function extractFlowControl(cliOutput) {
186
268
  }
187
269
  }
188
270
 
271
+ // Parse rationale section for a task
272
+ function extractRationale(taskText) {
273
+ const rationaleMatch = /\*\*Rationale\*\*:\n- Chosen Approach: (.+?)\n- Alternatives Considered: (.+?)\n- Decision Factors: (.+?)\n- Tradeoffs: (.+)/s.exec(taskText)
274
+ if (!rationaleMatch) return null
275
+
276
+ return {
277
+ chosen_approach: rationaleMatch[1].trim(),
278
+ alternatives_considered: rationaleMatch[2].split(',').map(s => s.trim()).filter(Boolean),
279
+ decision_factors: rationaleMatch[3].split(',').map(s => s.trim()).filter(Boolean),
280
+ tradeoffs: rationaleMatch[4].trim()
281
+ }
282
+ }
283
+
284
+ // Parse verification section for a task
285
+ function extractVerification(taskText) {
286
+ const verificationMatch = /\*\*Verification\*\*:\n- Unit Tests: (.+?)\n- Integration Tests: (.+?)\n- Manual Checks: (.+?)\n- Success Metrics: (.+)/s.exec(taskText)
287
+ if (!verificationMatch) return null
288
+
289
+ return {
290
+ unit_tests: verificationMatch[1].split(',').map(s => s.trim()).filter(Boolean),
291
+ integration_tests: verificationMatch[2].split(',').map(s => s.trim()).filter(Boolean),
292
+ manual_checks: verificationMatch[3].split(',').map(s => s.trim()).filter(Boolean),
293
+ success_metrics: verificationMatch[4].split(',').map(s => s.trim()).filter(Boolean)
294
+ }
295
+ }
296
+
297
+ // Parse risks section for a task
298
+ function extractRisks(taskText) {
299
+ const risksPattern = /- Risk: (.+?) \| Probability: ([LMH]) \| Impact: ([LMH]) \| Mitigation: (.+?)(?: \| Fallback: (.+?))?(?=\n|$)/g
300
+ const risks = []
301
+ let match
302
+
303
+ while ((match = risksPattern.exec(taskText)) !== null) {
304
+ risks.push({
305
+ description: match[1].trim(),
306
+ probability: match[2] === 'L' ? 'Low' : match[2] === 'M' ? 'Medium' : 'High',
307
+ impact: match[3] === 'L' ? 'Low' : match[3] === 'M' ? 'Medium' : 'High',
308
+ mitigation: match[4].trim(),
309
+ fallback: match[5]?.trim() || undefined
310
+ })
311
+ }
312
+
313
+ return risks.length > 0 ? risks : null
314
+ }
315
+
316
+ // Parse code skeleton section for a task
317
+ function extractCodeSkeleton(taskText) {
318
+ const skeletonSection = /\*\*Code Skeleton\*\*:\n([\s\S]*?)(?=\n\*\*|$)/.exec(taskText)
319
+ if (!skeletonSection) return null
320
+
321
+ const text = skeletonSection[1]
322
+ const skeleton = {}
323
+
324
+ // Parse interfaces
325
+ const interfacesPattern = /- Interfaces: (.+?): (.+?) - (.+?)(?=\n|$)/g
326
+ const interfaces = []
327
+ let match
328
+ while ((match = interfacesPattern.exec(text)) !== null) {
329
+ interfaces.push({ name: match[1].trim(), definition: match[2].trim(), purpose: match[3].trim() })
330
+ }
331
+ if (interfaces.length > 0) skeleton.interfaces = interfaces
332
+
333
+ // Parse functions
334
+ const functionsPattern = /- Functions: (.+?) - (.+?) - returns (.+?)(?=\n|$)/g
335
+ const functions = []
336
+ while ((match = functionsPattern.exec(text)) !== null) {
337
+ functions.push({ signature: match[1].trim(), purpose: match[2].trim(), returns: match[3].trim() })
338
+ }
339
+ if (functions.length > 0) skeleton.key_functions = functions
340
+
341
+ // Parse classes
342
+ const classesPattern = /- Classes: (.+?) - (.+?) - methods: (.+?)(?=\n|$)/g
343
+ const classes = []
344
+ while ((match = classesPattern.exec(text)) !== null) {
345
+ classes.push({
346
+ name: match[1].trim(),
347
+ purpose: match[2].trim(),
348
+ methods: match[3].split(',').map(s => s.trim()).filter(Boolean)
349
+ })
350
+ }
351
+ if (classes.length > 0) skeleton.classes = classes
352
+
353
+ return Object.keys(skeleton).length > 0 ? skeleton : null
354
+ }
355
+
356
+ // Parse data flow section
357
+ function extractDataFlow(cliOutput) {
358
+ const dataFlowSection = /## Data Flow.*?\n([\s\S]*?)(?=\n## |$)/.exec(cliOutput)
359
+ if (!dataFlowSection) return null
360
+
361
+ const text = dataFlowSection[1]
362
+ const diagramMatch = /\*\*Diagram\*\*: (.+?)(?=\n|$)/.exec(text)
363
+ const depsMatch = /\*\*Dependencies\*\*: (.+?)(?=\n|$)/.exec(text)
364
+
365
+ // Parse stages
366
+ const stagesPattern = /- Stage (.+?): Input=(.+?) → Output=(.+?) \| Component=(.+?)(?: \| Transforms=(.+?))?(?=\n|$)/g
367
+ const stages = []
368
+ let match
369
+ while ((match = stagesPattern.exec(text)) !== null) {
370
+ stages.push({
371
+ stage: match[1].trim(),
372
+ input: match[2].trim(),
373
+ output: match[3].trim(),
374
+ component: match[4].trim(),
375
+ transformations: match[5] ? match[5].split(',').map(s => s.trim()).filter(Boolean) : undefined
376
+ })
377
+ }
378
+
379
+ return {
380
+ diagram: diagramMatch?.[1].trim() || null,
381
+ stages: stages.length > 0 ? stages : undefined,
382
+ dependencies: depsMatch ? depsMatch[1].split(',').map(s => s.trim()).filter(Boolean) : undefined
383
+ }
384
+ }
385
+
386
+ // Parse design decisions section
387
+ function extractDesignDecisions(cliOutput) {
388
+ const decisionsSection = /## Design Decisions.*?\n([\s\S]*?)(?=\n## |$)/.exec(cliOutput)
389
+ if (!decisionsSection) return null
390
+
391
+ const decisionsPattern = /- Decision: (.+?) \| Rationale: (.+?)(?: \| Tradeoff: (.+?))?(?=\n|$)/g
392
+ const decisions = []
393
+ let match
394
+
395
+ while ((match = decisionsPattern.exec(decisionsSection[1])) !== null) {
396
+ decisions.push({
397
+ decision: match[1].trim(),
398
+ rationale: match[2].trim(),
399
+ tradeoff: match[3]?.trim() || undefined
400
+ })
401
+ }
402
+
403
+ return decisions.length > 0 ? decisions : null
404
+ }
405
+
189
406
  // Parse all sections
190
407
  function parseCLIOutput(cliOutput) {
408
+ const complexity = (extractSection(cliOutput, "Complexity") || "Medium").trim()
191
409
  return {
192
- summary: extractSection(cliOutput, "Implementation Summary"),
193
- approach: extractSection(cliOutput, "High-Level Approach"),
194
- raw_tasks: extractStructuredTasks(cliOutput),
410
+ summary: extractSection(cliOutput, "Summary") || extractSection(cliOutput, "Implementation Summary"),
411
+ approach: extractSection(cliOutput, "Approach") || extractSection(cliOutput, "High-Level Approach"),
412
+ complexity,
413
+ raw_tasks: extractStructuredTasks(cliOutput, complexity),
195
414
  flow_control: extractFlowControl(cliOutput),
196
- time_estimate: extractSection(cliOutput, "Time Estimate")
415
+ time_estimate: extractSection(cliOutput, "Time Estimate"),
416
+ // High complexity only
417
+ data_flow: complexity === "High" ? extractDataFlow(cliOutput) : null,
418
+ // Medium/High complexity
419
+ design_decisions: (complexity === "Medium" || complexity === "High") ? extractDesignDecisions(cliOutput) : null
197
420
  }
198
421
  }
199
422
  ```
@@ -326,7 +549,8 @@ function inferFlowControl(tasks) {
326
549
 
327
550
  ```javascript
328
551
  function generatePlanObject(parsed, enrichedContext, input, schemaType) {
329
- const tasks = validateAndEnhanceTasks(parsed.raw_tasks, enrichedContext)
552
+ const complexity = parsed.complexity || input.complexity || "Medium"
553
+ const tasks = validateAndEnhanceTasks(parsed.raw_tasks, enrichedContext, complexity)
330
554
  assignCliExecutionIds(tasks, input.session.id) // MANDATORY: Assign CLI execution IDs
331
555
  const flow_control = parsed.flow_control?.execution_order?.length > 0 ? parsed.flow_control : inferFlowControl(tasks)
332
556
  const focus_paths = [...new Set(tasks.flatMap(t => [t.file || t.scope, ...t.modification_points.map(m => m.file)]).filter(Boolean))]
@@ -338,7 +562,7 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
338
562
  flow_control,
339
563
  focus_paths,
340
564
  estimated_time: parsed.time_estimate || `${tasks.length * 30} minutes`,
341
- recommended_execution: (input.complexity === "Low" || input.severity === "Low") ? "Agent" : "Codex",
565
+ recommended_execution: (complexity === "Low" || input.severity === "Low") ? "Agent" : "Codex",
342
566
  _metadata: {
343
567
  timestamp: new Date().toISOString(),
344
568
  source: "cli-lite-planning-agent",
@@ -348,6 +572,15 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
348
572
  }
349
573
  }
350
574
 
575
+ // Add complexity-specific top-level fields
576
+ if (complexity === "Medium" || complexity === "High") {
577
+ base.design_decisions = parsed.design_decisions || []
578
+ }
579
+
580
+ if (complexity === "High") {
581
+ base.data_flow = parsed.data_flow || null
582
+ }
583
+
351
584
  // Schema-specific fields
352
585
  if (schemaType === 'fix-plan') {
353
586
  return {
@@ -361,10 +594,63 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
361
594
  return {
362
595
  ...base,
363
596
  approach: parsed.approach || "Step-by-step implementation",
364
- complexity: input.complexity || "Medium"
597
+ complexity
365
598
  }
366
599
  }
367
600
  }
601
+
602
+ // Enhanced task validation with complexity-specific fields
603
+ function validateAndEnhanceTasks(rawTasks, enrichedContext, complexity) {
604
+ return rawTasks.map((task, idx) => {
605
+ const enhanced = {
606
+ id: task.id || `T${idx + 1}`,
607
+ title: task.title || "Unnamed task",
608
+ scope: task.scope || task.file || inferFile(task, enrichedContext),
609
+ action: task.action || inferAction(task.title),
610
+ description: task.description || task.title,
611
+ modification_points: task.modification_points?.length > 0
612
+ ? task.modification_points
613
+ : [{ file: task.scope || task.file, target: "main", change: task.description }],
614
+ implementation: task.implementation?.length >= 2
615
+ ? task.implementation
616
+ : [`Analyze ${task.scope || task.file}`, `Implement ${task.title}`, `Add error handling`],
617
+ reference: task.reference || { pattern: "existing patterns", files: enrichedContext.relevant_files.slice(0, 2), examples: "Follow existing structure" },
618
+ acceptance: task.acceptance?.length >= 1
619
+ ? task.acceptance
620
+ : [`${task.title} completed`, `Follows conventions`],
621
+ depends_on: task.depends_on || []
622
+ }
623
+
624
+ // Add Medium/High complexity fields
625
+ if (complexity === "Medium" || complexity === "High") {
626
+ enhanced.rationale = task.rationale || {
627
+ chosen_approach: "Standard implementation approach",
628
+ alternatives_considered: [],
629
+ decision_factors: ["Maintainability", "Performance"],
630
+ tradeoffs: "None significant"
631
+ }
632
+ enhanced.verification = task.verification || {
633
+ unit_tests: [`test_${task.id.toLowerCase()}_basic`],
634
+ integration_tests: [],
635
+ manual_checks: ["Verify expected behavior"],
636
+ success_metrics: ["All tests pass"]
637
+ }
638
+ }
639
+
640
+ // Add High complexity fields
641
+ if (complexity === "High") {
642
+ enhanced.risks = task.risks || [{
643
+ description: "Implementation complexity",
644
+ probability: "Low",
645
+ impact: "Medium",
646
+ mitigation: "Incremental development with checkpoints"
647
+ }]
648
+ enhanced.code_skeleton = task.code_skeleton || null
649
+ }
650
+
651
+ return enhanced
652
+ })
653
+ }
368
654
  ```
369
655
 
370
656
  ### Error Handling
@@ -56,14 +56,61 @@ Phase 4: Validation & Output (15%)
56
56
  ccw issue status <issue-id> --json
57
57
  ```
58
58
 
59
- **Step 2**: Analyze and classify
59
+ **Step 2**: Analyze failure history (if present)
60
+ ```javascript
61
+ function analyzeFailureHistory(issue) {
62
+ if (!issue.feedback || issue.feedback.length === 0) {
63
+ return { has_failures: false };
64
+ }
65
+
66
+ // Extract execution failures
67
+ const failures = issue.feedback.filter(f => f.type === 'failure' && f.stage === 'execute');
68
+
69
+ if (failures.length === 0) {
70
+ return { has_failures: false };
71
+ }
72
+
73
+ // Parse failure details
74
+ const failureAnalysis = failures.map(f => {
75
+ const detail = JSON.parse(f.content);
76
+ return {
77
+ solution_id: detail.solution_id,
78
+ task_id: detail.task_id,
79
+ error_type: detail.error_type, // test_failure, compilation, timeout, etc.
80
+ message: detail.message,
81
+ stack_trace: detail.stack_trace,
82
+ timestamp: f.created_at
83
+ };
84
+ });
85
+
86
+ // Identify patterns
87
+ const errorTypes = failureAnalysis.map(f => f.error_type);
88
+ const repeatedErrors = errorTypes.filter((e, i, arr) => arr.indexOf(e) !== i);
89
+
90
+ return {
91
+ has_failures: true,
92
+ failure_count: failures.length,
93
+ failures: failureAnalysis,
94
+ patterns: {
95
+ repeated_errors: repeatedErrors, // Same error multiple times
96
+ failed_approaches: [...new Set(failureAnalysis.map(f => f.solution_id))]
97
+ }
98
+ };
99
+ }
100
+ ```
101
+
102
+ **Step 3**: Analyze and classify
60
103
  ```javascript
61
104
  function analyzeIssue(issue) {
105
+ const failureAnalysis = analyzeFailureHistory(issue);
106
+
62
107
  return {
63
108
  issue_id: issue.id,
64
109
  requirements: extractRequirements(issue.context),
65
110
  scope: inferScope(issue.title, issue.context),
66
- complexity: determineComplexity(issue) // Low | Medium | High
111
+ complexity: determineComplexity(issue), // Low | Medium | High
112
+ failure_analysis: failureAnalysis, // Failure context for planning
113
+ is_replan: failureAnalysis.has_failures // Flag for replanning
67
114
  }
68
115
  }
69
116
  ```
@@ -104,6 +151,41 @@ mcp__ace-tool__search_context({
104
151
 
105
152
  #### Phase 3: Solution Planning
106
153
 
154
+ **Failure-Aware Planning** (when `issue.failure_analysis.has_failures === true`):
155
+
156
+ ```javascript
157
+ function planWithFailureContext(issue, exploration, failureAnalysis) {
158
+ // Identify what failed before
159
+ const failedApproaches = failureAnalysis.patterns.failed_approaches;
160
+ const rootCauses = failureAnalysis.failures.map(f => ({
161
+ error: f.error_type,
162
+ message: f.message,
163
+ task: f.task_id
164
+ }));
165
+
166
+ // Design alternative approach
167
+ const approach = `
168
+ **Previous Attempt Analysis**:
169
+ - Failed approaches: ${failedApproaches.join(', ')}
170
+ - Root causes: ${rootCauses.map(r => `${r.error} (${r.task}): ${r.message}`).join('; ')}
171
+
172
+ **Alternative Strategy**:
173
+ - [Describe how this solution addresses root causes]
174
+ - [Explain what's different from failed approaches]
175
+ - [Prevention steps to catch same errors earlier]
176
+ `;
177
+
178
+ // Add explicit verification tasks
179
+ const verificationTasks = rootCauses.map(rc => ({
180
+ verification_type: rc.error,
181
+ check: `Prevent ${rc.error}: ${rc.message}`,
182
+ method: `Add unit test / compile check / timeout limit`
183
+ }));
184
+
185
+ return { approach, verificationTasks };
186
+ }
187
+ ```
188
+
107
189
  **Multi-Solution Generation**:
108
190
 
109
191
  Generate multiple candidate solutions when:
@@ -303,15 +385,17 @@ Each line is a solution JSON containing tasks. Schema: `cat .claude/workflows/cl
303
385
  **ALWAYS**:
304
386
  1. **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
305
387
  2. Read schema first: `cat .claude/workflows/cli-templates/schemas/solution-schema.json`
306
- 2. Use ACE semantic search as PRIMARY exploration tool
307
- 3. Fetch issue details via `ccw issue status <id> --json`
308
- 4. Quantify acceptance.criteria with testable conditions
309
- 5. Validate DAG before output
310
- 6. Evaluate each solution with `analysis` and `score`
311
- 7. Write solutions to `.workflow/issues/solutions/{issue-id}.jsonl` (append mode)
312
- 8. For HIGH complexity: generate 2-3 candidate solutions
313
- 9. **Solution ID format**: `SOL-{issue-id}-{uid}` where uid is 4 random alphanumeric chars (e.g., `SOL-GH-123-a7x9`)
314
- 10. **GitHub Reply Task**: If issue has `github_url` or `github_number`, add final task to comment on GitHub issue with completion summary
388
+ 3. Use ACE semantic search as PRIMARY exploration tool
389
+ 4. Fetch issue details via `ccw issue status <id> --json`
390
+ 5. **Analyze failure history**: Check `issue.feedback` for type='failure', stage='execute'
391
+ 6. **For replanning**: Reference previous failures in `solution.approach`, add prevention steps
392
+ 7. Quantify acceptance.criteria with testable conditions
393
+ 8. Validate DAG before output
394
+ 9. Evaluate each solution with `analysis` and `score`
395
+ 10. Write solutions to `.workflow/issues/solutions/{issue-id}.jsonl` (append mode)
396
+ 11. For HIGH complexity: generate 2-3 candidate solutions
397
+ 12. **Solution ID format**: `SOL-{issue-id}-{uid}` where uid is 4 random alphanumeric chars (e.g., `SOL-GH-123-a7x9`)
398
+ 13. **GitHub Reply Task**: If issue has `github_url` or `github_number`, add final task to comment on GitHub issue with completion summary
315
399
 
316
400
  **CONFLICT AVOIDANCE** (for batch processing of similar issues):
317
401
  1. **File isolation**: Each issue's solution should target distinct files when possible