claude-code-workflow 7.2.29 → 7.2.30

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 (124) hide show
  1. package/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json +2 -2
  2. package/.ccw/workflows/cli-templates/schemas/task-schema.json +14 -7
  3. package/.claude/agents/action-planning-agent.md +7 -4
  4. package/.claude/agents/cli-explore-agent.md +77 -63
  5. package/.claude/agents/cli-lite-planning-agent.md +11 -10
  6. package/.claude/agents/issue-plan-agent.md +421 -426
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/skills/ccw-chain/SKILL.md +119 -0
  9. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +21 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +47 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-issue.json +33 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +57 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-main.json +52 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-standard.json +39 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-team.json +10 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +31 -0
  17. package/.claude/skills/ccw-chain/phases/analyze-with-file.md +788 -0
  18. package/.claude/skills/ccw-chain/phases/brainstorm/SKILL.md +408 -0
  19. package/.claude/skills/ccw-chain/phases/brainstorm/phases/01-mode-routing.md +207 -0
  20. package/.claude/skills/ccw-chain/phases/brainstorm/phases/02-artifacts.md +567 -0
  21. package/.claude/skills/ccw-chain/phases/brainstorm/phases/03-role-analysis.md +748 -0
  22. package/.claude/skills/ccw-chain/phases/brainstorm/phases/04-synthesis.md +827 -0
  23. package/.claude/skills/ccw-chain/phases/brainstorm-with-file.md +482 -0
  24. package/.claude/skills/ccw-chain/phases/collaborative-plan-with-file.md +639 -0
  25. package/.claude/skills/ccw-chain/phases/debug-with-file.md +656 -0
  26. package/.claude/skills/ccw-chain/phases/integration-test-cycle.md +936 -0
  27. package/.claude/skills/ccw-chain/phases/issue-convert-to-plan.md +720 -0
  28. package/.claude/skills/ccw-chain/phases/issue-discover.md +483 -0
  29. package/.claude/skills/ccw-chain/phases/issue-execute.md +629 -0
  30. package/.claude/skills/ccw-chain/phases/issue-from-brainstorm.md +382 -0
  31. package/.claude/skills/ccw-chain/phases/issue-plan.md +343 -0
  32. package/.claude/skills/ccw-chain/phases/issue-queue.md +464 -0
  33. package/.claude/skills/ccw-chain/phases/refactor-cycle.md +852 -0
  34. package/.claude/skills/ccw-chain/phases/review-cycle/SKILL.md +132 -0
  35. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-fix.md +760 -0
  36. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-module.md +764 -0
  37. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-session.md +775 -0
  38. package/.claude/skills/ccw-chain/phases/roadmap-with-file.md +544 -0
  39. package/.claude/skills/ccw-chain/phases/spec-generator/SKILL.md +338 -0
  40. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-5-requirement-clarification.md +404 -0
  41. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-discovery.md +257 -0
  42. package/.claude/skills/ccw-chain/phases/spec-generator/phases/02-product-brief.md +274 -0
  43. package/.claude/skills/ccw-chain/phases/spec-generator/phases/03-requirements.md +184 -0
  44. package/.claude/skills/ccw-chain/phases/spec-generator/phases/04-architecture.md +248 -0
  45. package/.claude/skills/ccw-chain/phases/spec-generator/phases/05-epics-stories.md +178 -0
  46. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-5-auto-fix.md +144 -0
  47. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-readiness-check.md +480 -0
  48. package/.claude/skills/ccw-chain/phases/team-planex.md +123 -0
  49. package/.claude/skills/ccw-chain/phases/ui-design-explore-auto.md +678 -0
  50. package/.claude/skills/ccw-chain/phases/unified-execute-with-file.md +870 -0
  51. package/.claude/skills/ccw-chain/phases/workflow-execute/SKILL.md +625 -0
  52. package/.claude/skills/ccw-chain/phases/workflow-execute/phases/06-review.md +215 -0
  53. package/.claude/skills/ccw-chain/phases/workflow-lite-plan.md +616 -0
  54. package/.claude/skills/ccw-chain/phases/workflow-multi-cli-plan.md +424 -0
  55. package/.claude/skills/ccw-chain/phases/workflow-plan/SKILL.md +466 -0
  56. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/01-session-discovery.md +99 -0
  57. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/02-context-gathering.md +338 -0
  58. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/03-conflict-resolution.md +422 -0
  59. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/04-task-generation.md +440 -0
  60. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/05-plan-verify.md +395 -0
  61. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/06-replan.md +594 -0
  62. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/SKILL.md +527 -0
  63. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/01-session-discovery.md +57 -0
  64. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/02-context-gathering.md +407 -0
  65. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/03-test-coverage-analysis.md +172 -0
  66. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -0
  67. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/05-tdd-task-generation.md +473 -0
  68. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/06-tdd-structure-validation.md +189 -0
  69. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/07-tdd-verify.md +635 -0
  70. package/.claude/skills/ccw-chain/phases/workflow-test-fix/SKILL.md +482 -0
  71. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/01-session-start.md +60 -0
  72. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/02-test-context-gather.md +493 -0
  73. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/03-test-concept-enhanced.md +150 -0
  74. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/04-test-task-generate.md +346 -0
  75. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/05-test-cycle-execute.md +538 -0
  76. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  77. package/.claude/skills/ccw-chain/specs/intent-patterns.md +60 -0
  78. package/.claude/skills/chain-loader/SKILL.md +78 -0
  79. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  80. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  81. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  82. package/.claude/skills/chain-loader/specs/chain-schema.md +99 -0
  83. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  84. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  85. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  86. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  87. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  88. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  89. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  90. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  91. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  92. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  93. package/README.md +14 -0
  94. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  95. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  96. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  97. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  98. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  99. package/ccw/dist/tools/chain-loader.js +642 -0
  100. package/ccw/dist/tools/chain-loader.js.map +1 -0
  101. package/ccw/dist/tools/index.d.ts.map +1 -1
  102. package/ccw/dist/tools/index.js +2 -0
  103. package/ccw/dist/tools/index.js.map +1 -1
  104. package/ccw/dist/tools/json-builder.js +20 -0
  105. package/ccw/dist/tools/json-builder.js.map +1 -1
  106. package/ccw/dist/types/chain-types.d.ts +72 -0
  107. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  108. package/ccw/dist/types/chain-types.js +5 -0
  109. package/ccw/dist/types/chain-types.js.map +1 -0
  110. package/ccw/scripts/prepublish-clean.mjs +0 -1
  111. package/package.json +1 -3
  112. package/ccw-litellm/README.md +0 -180
  113. package/ccw-litellm/pyproject.toml +0 -35
  114. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  115. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  116. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  117. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  118. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  119. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  120. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  121. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  122. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  123. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  124. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -0,0 +1,426 @@
1
+ # Phase 4: Conflict Resolution (Conditional)
2
+
3
+ Detect and resolve conflicts with CLI analysis. This phase is **conditional** - only executes when `conflict_risk >= medium`.
4
+
5
+ ## Objective
6
+
7
+ - Detect conflicts between planned changes and existing codebase
8
+ - Detect module scenario uniqueness (functional overlaps)
9
+ - Present conflicts to user with resolution strategies
10
+ - Apply selected resolution strategies
11
+ - Update planning-notes.md with conflict decisions
12
+
13
+ ## Trigger Condition
14
+
15
+ Only execute when context-package.json indicates `conflict_risk` is "medium" or "high".
16
+ If `conflict_risk` is "none" or "low", skip directly to Phase 5.
17
+
18
+ ## Conflict Categories
19
+
20
+ | Category | Description |
21
+ |----------|-------------|
22
+ | **Architecture** | Incompatible design patterns, module structure changes |
23
+ | **API** | Breaking contract changes, signature modifications |
24
+ | **Data Model** | Schema modifications, type breaking changes |
25
+ | **Dependency** | Version incompatibilities, setup conflicts |
26
+ | **ModuleOverlap** | Functional overlap, scenario boundary ambiguity, duplicate responsibility |
27
+
28
+ ## Execution
29
+
30
+ ### Step 4.1: Validation
31
+
32
+ ```javascript
33
+ // 1. Verify session directory exists
34
+ const sessionDir = `.workflow/active/${sessionId}`;
35
+ if (!file_exists(sessionDir)) {
36
+ throw new Error(`Session directory not found: ${sessionDir}`);
37
+ }
38
+
39
+ // 2. Load context-package.json
40
+ const contextPackage = JSON.parse(Read(contextPath));
41
+
42
+ // 3. Check conflict_risk (skip if none/low)
43
+ const conflictRisk = contextPackage.conflict_detection?.risk_level || 'low';
44
+ if (conflictRisk === 'none' || conflictRisk === 'low') {
45
+ console.log("No significant conflicts detected, proceeding to TDD task generation");
46
+ // Skip directly to Phase 5
47
+ return;
48
+ }
49
+ ```
50
+
51
+ ### Step 4.2: CLI-Powered Conflict Analysis
52
+
53
+ **Agent Delegation**:
54
+
55
+ ```javascript
56
+ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
57
+ ## Context
58
+ - Session: ${sessionId}
59
+ - Risk: ${conflictRisk}
60
+ - Files: ${existing_files_list}
61
+
62
+ ## Exploration Context (from context-package.exploration_results)
63
+ - Exploration Count: ${contextPackage.exploration_results?.exploration_count || 0}
64
+ - Angles Analyzed: ${JSON.stringify(contextPackage.exploration_results?.angles || [])}
65
+ - Pre-identified Conflict Indicators: ${JSON.stringify(contextPackage.exploration_results?.aggregated_insights?.conflict_indicators || [])}
66
+ - Critical Files: ${JSON.stringify(contextPackage.exploration_results?.aggregated_insights?.critical_files?.map(f => f.path) || [])}
67
+ - All Patterns: ${JSON.stringify(contextPackage.exploration_results?.aggregated_insights?.all_patterns || [])}
68
+ - All Integration Points: ${JSON.stringify(contextPackage.exploration_results?.aggregated_insights?.all_integration_points || [])}
69
+
70
+ ## Analysis Steps
71
+
72
+ ### 0. Load Output Schema (MANDATORY)
73
+ Execute: ccw tool exec json_builder '{"cmd":"info","schema":"conflict"}'
74
+
75
+ ### 1. Load Context
76
+ - Read existing files from conflict_detection.existing_files
77
+ - Load plan from .workflow/active/${sessionId}/.process/context-package.json
78
+ - Load exploration_results and use aggregated_insights for enhanced analysis
79
+ - Extract role analyses and requirements
80
+
81
+ ### 2. Execute CLI Analysis (Enhanced with Exploration + Scenario Uniqueness)
82
+
83
+ Primary (Gemini):
84
+ ccw cli -p "
85
+ PURPOSE: Detect conflicts between plan and codebase, using exploration insights
86
+ TASK:
87
+ * Review pre-identified conflict_indicators from exploration results
88
+ * Compare architectures (use exploration key_patterns)
89
+ * Identify breaking API changes
90
+ * Detect data model incompatibilities
91
+ * Assess dependency conflicts
92
+ * Analyze module scenario uniqueness
93
+ - Use exploration integration_points for precise locations
94
+ - Cross-validate with exploration critical_files
95
+ - Generate clarification questions for boundary definition
96
+ MODE: analysis
97
+ CONTEXT: @**/*.ts @**/*.js @**/*.tsx @**/*.jsx @.workflow/active/${sessionId}/**/*
98
+ EXPECTED: Conflict list with severity ratings, including:
99
+ - Validation of exploration conflict_indicators
100
+ - ModuleOverlap conflicts with overlap_analysis
101
+ - Targeted clarification questions
102
+ CONSTRAINTS: Focus on breaking changes, migration needs, and functional overlaps | Prioritize exploration-identified conflicts | analysis=READ-ONLY
103
+ " --tool gemini --mode analysis --rule analysis-code-patterns --cd {project_root}
104
+
105
+ Fallback: Qwen (same prompt) -> Claude (manual analysis)
106
+
107
+ ### 3. Generate Strategies (2-4 per conflict)
108
+
109
+ Template per conflict:
110
+ - Severity: Critical/High/Medium
111
+ - Category: Architecture/API/Data/Dependency/ModuleOverlap
112
+ - Affected files + impact
113
+ - For ModuleOverlap: Include overlap_analysis with existing modules and scenarios
114
+ - Options with pros/cons, effort, risk
115
+ - For ModuleOverlap strategies: Add clarification_needed questions for boundary definition
116
+ - Recommended strategy + rationale
117
+
118
+ ### 4. Return Structured Conflict Data
119
+
120
+ Output to conflict-resolution.json (generated in Phase 4)
121
+
122
+ **Schema Reference**: Execute ccw tool exec json_builder '{"cmd":"info","schema":"conflict"}' to get schema summary
123
+
124
+ Return JSON following the schema. Key requirements:
125
+ - Minimum 2 strategies per conflict, max 4
126
+ - All text in Chinese for user-facing fields (brief, name, pros, cons, modification_suggestions)
127
+ - modifications.old_content: 20-100 chars for unique Edit tool matching
128
+ - modifications.new_content: preserves markdown formatting
129
+ - modification_suggestions: 2-5 actionable suggestions for custom handling
130
+
131
+ ### 5. Planning Notes Record (REQUIRED)
132
+ After analysis complete, append to planning-notes.md:
133
+
134
+ **File**: .workflow/active/${sessionId}/planning-notes.md
135
+ **Location**: Under "## Conflict Decisions (Phase 3)" section
136
+ **Format**:
137
+ ### [Conflict-Resolution Agent] YYYY-MM-DD
138
+ - **Note**: [Brief summary of conflict types, strategies, key decisions]
139
+ `)
140
+ ```
141
+
142
+ ### Step 4.3: Iterative User Interaction
143
+
144
+ ```javascript
145
+ const autoYes = workflowPreferences?.autoYes || false;
146
+
147
+ FOR each conflict:
148
+ round = 0, clarified = false, userClarifications = []
149
+
150
+ WHILE (!clarified && round++ < 10):
151
+ // 1. Display conflict info (text output for context)
152
+ displayConflictSummary(conflict) // id, brief, severity, overlap_analysis if ModuleOverlap
153
+
154
+ // 2. Strategy selection
155
+ if (autoYes) {
156
+ console.log(`[autoYes] Auto-selecting recommended strategy`)
157
+ selectedStrategy = conflict.strategies[conflict.recommended || 0]
158
+ clarified = true // Skip clarification loop
159
+ } else {
160
+ AskUserQuestion({
161
+ questions: [{
162
+ question: formatStrategiesForDisplay(conflict.strategies),
163
+ header: "Strategy",
164
+ multiSelect: false,
165
+ options: [
166
+ ...conflict.strategies.map((s, i) => ({
167
+ label: `${s.name}${i === conflict.recommended ? ' (Recommended)' : ''}`,
168
+ description: `${s.complexity} complexity | ${s.risk} risk${s.clarification_needed?.length ? ' | Needs clarification' : ''}`
169
+ })),
170
+ { label: "Custom modification", description: `Suggestions: ${conflict.modification_suggestions?.slice(0,2).join('; ')}` }
171
+ ]
172
+ }]
173
+ })
174
+
175
+ // 3. Handle selection
176
+ if (userChoice === "Custom modification") {
177
+ customConflicts.push({ id, brief, category, suggestions, overlap_analysis })
178
+ break
179
+ }
180
+
181
+ selectedStrategy = findStrategyByName(userChoice)
182
+ }
183
+
184
+ // 4. Clarification (if needed) - batched max 4 per call
185
+ if (!autoYes && selectedStrategy.clarification_needed?.length > 0) {
186
+ for (batch of chunk(selectedStrategy.clarification_needed, 4)) {
187
+ AskUserQuestion({
188
+ questions: batch.map((q, i) => ({
189
+ question: q, header: `Clarify${i+1}`, multiSelect: false,
190
+ options: [{ label: "Provide details", description: "Enter answer" }]
191
+ }))
192
+ })
193
+ userClarifications.push(...collectAnswers(batch))
194
+ }
195
+
196
+ // 5. Agent re-analysis
197
+ reanalysisResult = Agent({
198
+ subagent_type: "cli-execution-agent",
199
+ run_in_background: false,
200
+ prompt: `Conflict: ${conflict.id}, Strategy: ${selectedStrategy.name}
201
+ User Clarifications: ${JSON.stringify(userClarifications)}
202
+ Output: { uniqueness_confirmed, rationale, updated_strategy, remaining_questions }`
203
+ })
204
+
205
+ if (reanalysisResult.uniqueness_confirmed) {
206
+ selectedStrategy = { ...reanalysisResult.updated_strategy, clarifications: userClarifications }
207
+ clarified = true
208
+ } else {
209
+ selectedStrategy.clarification_needed = reanalysisResult.remaining_questions
210
+ }
211
+ } else {
212
+ clarified = true
213
+ }
214
+
215
+ if (clarified) resolvedConflicts.push({ conflict, strategy: selectedStrategy })
216
+ END WHILE
217
+ END FOR
218
+
219
+ selectedStrategies = resolvedConflicts.map(r => ({
220
+ conflict_id: r.conflict.id, strategy: r.strategy, clarifications: r.strategy.clarifications || []
221
+ }))
222
+ ```
223
+
224
+ ### Step 4.4: Apply Modifications
225
+
226
+ ```javascript
227
+ // 1. Extract modifications from resolved strategies
228
+ const modifications = [];
229
+ selectedStrategies.forEach(item => {
230
+ if (item.strategy && item.strategy.modifications) {
231
+ modifications.push(...item.strategy.modifications.map(mod => ({
232
+ ...mod,
233
+ conflict_id: item.conflict_id,
234
+ clarifications: item.clarifications
235
+ })));
236
+ }
237
+ });
238
+
239
+ console.log(`Applying ${modifications.length} modifications...`);
240
+
241
+ // 2. Apply each modification using Edit tool (with fallback to context-package.json)
242
+ const appliedModifications = [];
243
+ const failedModifications = [];
244
+ const fallbackConstraints = []; // For files that don't exist
245
+
246
+ modifications.forEach((mod, idx) => {
247
+ try {
248
+ console.log(`[${idx + 1}/${modifications.length}] Modifying ${mod.file}...`);
249
+
250
+ // Check if target file exists (brainstorm files may not exist in lite workflow)
251
+ if (!file_exists(mod.file)) {
252
+ console.log(` File not found, writing to context-package.json as constraint`);
253
+ fallbackConstraints.push({
254
+ source: "conflict-resolution",
255
+ conflict_id: mod.conflict_id,
256
+ target_file: mod.file,
257
+ section: mod.section,
258
+ change_type: mod.change_type,
259
+ content: mod.new_content,
260
+ rationale: mod.rationale
261
+ });
262
+ return; // Skip to next modification
263
+ }
264
+
265
+ if (mod.change_type === "update") {
266
+ Edit({ file_path: mod.file, old_string: mod.old_content, new_string: mod.new_content });
267
+ } else if (mod.change_type === "add") {
268
+ const fileContent = Read(mod.file);
269
+ const updated = insertContentAfterSection(fileContent, mod.section, mod.new_content);
270
+ Write(mod.file, updated);
271
+ } else if (mod.change_type === "remove") {
272
+ Edit({ file_path: mod.file, old_string: mod.old_content, new_string: "" });
273
+ }
274
+
275
+ appliedModifications.push(mod);
276
+ console.log(` Success`);
277
+ } catch (error) {
278
+ console.log(` Failed: ${error.message}`);
279
+ failedModifications.push({ ...mod, error: error.message });
280
+ }
281
+ });
282
+
283
+ // 3. Generate conflict-resolution.json output file
284
+ const resolutionOutput = {
285
+ session_id: sessionId,
286
+ resolved_at: new Date().toISOString(),
287
+ summary: {
288
+ total_conflicts: conflicts.length,
289
+ resolved_with_strategy: selectedStrategies.length,
290
+ custom_handling: customConflicts.length,
291
+ fallback_constraints: fallbackConstraints.length
292
+ },
293
+ resolved_conflicts: selectedStrategies.map(s => ({
294
+ conflict_id: s.conflict_id,
295
+ strategy_name: s.strategy.name,
296
+ strategy_approach: s.strategy.approach,
297
+ clarifications: s.clarifications || [],
298
+ modifications_applied: s.strategy.modifications?.filter(m =>
299
+ appliedModifications.some(am => am.conflict_id === s.conflict_id)
300
+ ) || []
301
+ })),
302
+ custom_conflicts: customConflicts.map(c => ({
303
+ id: c.id, brief: c.brief, category: c.category,
304
+ suggestions: c.suggestions, overlap_analysis: c.overlap_analysis || null
305
+ })),
306
+ planning_constraints: fallbackConstraints,
307
+ failed_modifications: failedModifications
308
+ };
309
+
310
+ const resolutionPath = `.workflow/active/${sessionId}/.process/conflict-resolution.json`;
311
+ Write(resolutionPath, JSON.stringify(resolutionOutput, null, 2));
312
+
313
+ // 4. Update context-package.json with resolution details
314
+ const contextPkg = JSON.parse(Read(contextPath));
315
+ contextPkg.conflict_detection.conflict_risk = "resolved";
316
+ contextPkg.conflict_detection.resolution_file = resolutionPath;
317
+ contextPkg.conflict_detection.resolved_conflicts = selectedStrategies.map(s => s.conflict_id);
318
+ contextPkg.conflict_detection.custom_conflicts = customConflicts.map(c => c.id);
319
+ contextPkg.conflict_detection.resolved_at = new Date().toISOString();
320
+ Write(contextPath, JSON.stringify(contextPkg, null, 2));
321
+
322
+ // 5. Output custom conflict summary with overlap analysis (if any)
323
+ if (customConflicts.length > 0) {
324
+ customConflicts.forEach(conflict => {
325
+ console.log(`[${conflict.category}] ${conflict.id}: ${conflict.brief}`);
326
+ if (conflict.category === 'ModuleOverlap' && conflict.overlap_analysis) {
327
+ console.log(`Overlap info: New module: ${conflict.overlap_analysis.new_module.name}`);
328
+ }
329
+ conflict.suggestions.forEach(s => console.log(` - ${s}`));
330
+ });
331
+ }
332
+ ```
333
+
334
+ ### TodoWrite Update (Phase 4 in progress - tasks attached, if conflict_risk >= medium)
335
+
336
+ ```json
337
+ [
338
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
339
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
340
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
341
+ {"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
342
+ {"content": " -> Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
343
+ {"content": " -> Present conflicts to user", "status": "pending", "activeForm": "Presenting conflicts"},
344
+ {"content": " -> Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
345
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
346
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
347
+ ]
348
+ ```
349
+
350
+ ### TodoWrite Update (Phase 4 completed - tasks collapsed)
351
+
352
+ ```json
353
+ [
354
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
355
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
356
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
357
+ {"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
358
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
359
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
360
+ ]
361
+ ```
362
+
363
+ ### Step 4.5: Update Planning Notes
364
+
365
+ After conflict resolution completes (if executed), update planning-notes.md:
366
+
367
+ ```javascript
368
+ if (conflictRisk === 'medium' || conflictRisk === 'high') {
369
+ const conflictResPath = `.workflow/active/${sessionId}/.process/conflict-resolution.json`;
370
+
371
+ if (file_exists(conflictResPath)) {
372
+ const conflictRes = JSON.parse(Read(conflictResPath));
373
+ const resolved = conflictRes.resolved_conflicts || [];
374
+ const modifiedArtifacts = conflictRes.modified_artifacts || [];
375
+ const planningConstraints = conflictRes.planning_constraints || [];
376
+
377
+ // Update Phase 4 section
378
+ Edit(planningNotesPath, {
379
+ old: '## Conflict Decisions (Phase 4)\n(To be filled if conflicts detected)',
380
+ new: `## Conflict Decisions (Phase 4)
381
+
382
+ - **RESOLVED**: ${resolved.map(r => `${r.type} -> ${r.strategy}`).join('; ') || 'None'}
383
+ - **MODIFIED_ARTIFACTS**: ${modifiedArtifacts.join(', ') || 'None'}
384
+ - **CONSTRAINTS**: ${planningConstraints.join('; ') || 'None'}`
385
+ })
386
+
387
+ // Append Phase 4 constraints to consolidated list
388
+ if (planningConstraints.length > 0) {
389
+ const currentNotes = Read(planningNotesPath);
390
+ const constraintCount = (currentNotes.match(/^\d+\./gm) || []).length;
391
+
392
+ Edit(planningNotesPath, {
393
+ old: '## Consolidated Constraints (Phase 5 Input)',
394
+ new: `## Consolidated Constraints (Phase 5 Input)
395
+ ${planningConstraints.map((c, i) => `${constraintCount + i + 1}. [Conflict] ${c}`).join('\n')}`
396
+ })
397
+ }
398
+ }
399
+ }
400
+ ```
401
+
402
+ **Auto-Continue**: Return to user showing conflict resolution results and selected strategies, then auto-continue.
403
+
404
+ **Auto Mode**: When `workflowPreferences.autoYes` is true, conflict-resolution automatically applies recommended resolution strategies without user confirmation.
405
+
406
+ ### Step 4.6: Memory State Check
407
+
408
+ Evaluate current context window usage and memory state:
409
+
410
+ - If memory usage is high (>110K tokens or approaching context limits):
411
+
412
+ ```javascript
413
+ Skill(skill="memory-capture")
414
+ ```
415
+
416
+ - Memory compaction is particularly important after analysis phase which may generate extensive documentation
417
+ - Ensures optimal performance and prevents context overflow
418
+
419
+ ## Output
420
+
421
+ - **File**: `conflict-resolution.json` (if conflicts resolved)
422
+ - **TodoWrite**: Mark Phase 4 completed, Phase 5 in_progress
423
+
424
+ ## Next Phase
425
+
426
+ Return to orchestrator, then auto-continue to [Phase 5: TDD Task Generation](05-tdd-task-generation.md).