@@ -124,6 +124,9 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
124124
125125 ## Analysis Steps
126126
127+ ### 0. Load Output Schema (MANDATORY )
128+ Execute: cat ~ / . claude/ workflows/ cli- templates/ schemas/ conflict- resolution- schema .json
129+
127130 ### 1. Load Context
128131 - Read existing files from conflict_detection .existing_files
129132 - Load plan from .workflow / active/ {session_id}/ .process / context- package .json
@@ -171,123 +174,14 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
171174
172175 ⚠️ Output to conflict- resolution .json (generated in Phase 4 )
173176
174- Return JSON format for programmatic processing:
175-
176- \` \`\` json
177- {
178- "conflicts": [
179- {
180- "id": "CON-001",
181- "brief": "一行中文冲突摘要",
182- "severity": "Critical|High|Medium",
183- "category": "Architecture|API|Data|Dependency|ModuleOverlap",
184- "affected_files": [
185- ".workflow/active/{session}/.brainstorm/guidance-specification.md",
186- ".workflow/active/{session}/.brainstorm/system-architect/analysis.md"
187- ],
188- "description": "详细描述冲突 - 什么不兼容",
189- "impact": {
190- "scope": "影响的模块/组件",
191- "compatibility": "Yes|No|Partial",
192- "migration_required": true|false,
193- "estimated_effort": "人天估计"
194- },
195- "overlap_analysis": {
196- "// NOTE": "仅当 category=ModuleOverlap 时需要此字段",
197- "new_module": {
198- "name": "新模块名称",
199- "scenarios": ["场景1", "场景2", "场景3"],
200- "responsibilities": "职责描述"
201- },
202- "existing_modules": [
203- {
204- "file": "src/existing/module.ts",
205- "name": "现有模块名称",
206- "scenarios": ["场景A", "场景B"],
207- "overlap_scenarios": ["重叠场景1", "重叠场景2"],
208- "responsibilities": "现有模块职责"
209- }
210- ]
211- },
212- "strategies": [
213- {
214- "name": "策略名称(中文)",
215- "approach": "实现方法简述",
216- "complexity": "Low|Medium|High",
217- "risk": "Low|Medium|High",
218- "effort": "时间估计",
219- "pros": ["优点1", "优点2"],
220- "cons": ["缺点1", "缺点2"],
221- "clarification_needed": [
222- "// NOTE: 仅当需要用户进一步澄清时需要此字段(尤其是 ModuleOverlap)",
223- "新模块的核心职责边界是什么?",
224- "如何与现有模块 X 协作?",
225- "哪些场景应该由新模块处理?"
226- ],
227- "modifications": [
228- {
229- "file": ".workflow/active/{session}/.brainstorm/guidance-specification.md",
230- "section": "## 2. System Architect Decisions",
231- "change_type": "update",
232- "old_content": "原始内容片段(用于定位)",
233- "new_content": "修改后的内容",
234- "rationale": "为什么这样改"
235- },
236- {
237- "file": ".workflow/active/{session}/.brainstorm/system-architect/analysis.md",
238- "section": "## Design Decisions",
239- "change_type": "update",
240- "old_content": "原始内容片段",
241- "new_content": "修改后的内容",
242- "rationale": "修改理由"
243- }
244- ]
245- },
246- {
247- "name": "策略2名称",
248- "approach": "...",
249- "complexity": "Medium",
250- "risk": "Low",
251- "effort": "1-2天",
252- "pros": ["优点"],
253- "cons": ["缺点"],
254- "modifications": [...]
255- }
256- ],
257- "recommended": 0,
258- "modification_suggestions": [
259- "建议1:具体的修改方向或注意事项",
260- "建议2:可能需要考虑的边界情况",
261- "建议3:相关的最佳实践或模式"
262- ]
263- }
264- ],
265- "summary": {
266- "total": 2,
267- "critical": 1,
268- "high": 1,
269- "medium": 0
270- }
271- }
272- \`\`\`
273-
274- ⚠️ CRITICAL Requirements for modifications field:
275- - old_content: Must be exact text from target file (20-100 chars for unique match)
276- - new_content: Complete replacement text (maintains formatting)
277- - change_type: "update" (replace), "add" (insert), "remove" (delete)
278- - file: Full path relative to project root
279- - section: Markdown heading for context (helps locate position)
177+ ** Schema Reference** : Execute \` cat ~/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json\` to get full schema
178+
179+ Return JSON following the schema above. Key requirements:
280180 - Minimum 2 strategies per conflict, max 4
281- - All text in Chinese for user-facing fields (brief, name, pros, cons)
282- - modification_suggestions: 2-5 actionable suggestions for custom handling (Chinese)
283-
284- Quality Standards:
285- - Each strategy must have actionable modifications
286- - old_content must be precise enough for Edit tool matching
287- - new_content preserves markdown formatting and structure
288- - Recommended strategy (index) based on lowest complexity + risk
289- - modification_suggestions must be specific, actionable, and context-aware
290- - Each suggestion should address a specific aspect (compatibility, migration, testing, etc.)
181+ - All text in Chinese for user-facing fields (brief, name, pros, cons, modification_suggestions)
182+ - modifications.old_content: 20-100 chars for unique Edit tool matching
183+ - modifications.new_content: preserves markdown formatting
184+ - modification_suggestions: 2-5 actionable suggestions for custom handling
291185` )
292186` ` `
293187
@@ -312,143 +206,85 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
3122068. Return execution log path
313207` ` `
314208
315- ### Phase 3: Iterative User Interaction with Clarification Loop
209+ ### Phase 3: User Interaction Loop
316210
317- **Execution Flow**:
318- ` ` `
319- FOR each conflict (逐个处理,无数量限制):
320- clarified = false
321- round = 0
322- userClarifications = []
323-
324- WHILE (! clarified && round < 10 ):
325- round++
326-
327- // 1. Display conflict (包含所有关键字段)
328- - category, id, brief, severity, description
329- - IF ModuleOverlap: 展示 overlap_analysis
330- * new_module: {name, scenarios, responsibilities}
331- * existing_modules[]: {file, name, scenarios, overlap_scenarios, responsibilities}
332-
333- // 2. Display strategies (2-4个策略 + 自定义选项)
334- - FOR each strategy: {name, approach, complexity, risk, effort, pros, cons}
335- * IF clarification_needed: 展示待澄清问题列表
336- - 自定义选项: {suggestions: modification_suggestions[]}
337-
338- // 3. User selects strategy
339- userChoice = readInput ()
340-
341- IF userChoice == " 自定义" :
342- customConflicts .push ({id, brief, category, suggestions, overlap_analysis})
343- clarified = true
344- BREAK
345-
346- selectedStrategy = strategies[userChoice]
347-
348- // 4. Clarification loop
349- IF selectedStrategy .clarification_needed .length > 0 :
350- // 收集澄清答案
351- FOR each question:
352- answer = readInput ()
353- userClarifications .push ({question, answer})
354-
355- // Agent 重新分析
356- reanalysisResult = Task (cli- execution- agent, prompt= {
357- 冲突信息: {id, brief, category, 策略}
358- 用户澄清: userClarifications[]
359- 场景分析: overlap_analysis (if ModuleOverlap)
360-
361- 输出: {
362- uniqueness_confirmed: bool,
363- rationale: string,
364- updated_strategy: {name, approach, complexity, risk, effort, modifications[]},
365- remaining_questions: [] (如果仍有歧义)
366- }
211+ ` ` ` javascript
212+ FOR each conflict:
213+ round = 0 , clarified = false , userClarifications = []
214+
215+ WHILE (! clarified && round++ < 10 ):
216+ // 1. Display conflict info (text output for context)
217+ displayConflictSummary (conflict) // id, brief, severity, overlap_analysis if ModuleOverlap
218+
219+ // 2. Strategy selection via AskUserQuestion
220+ AskUserQuestion ({
221+ questions: [{
222+ question: formatStrategiesForDisplay (conflict .strategies ),
223+ header: " 策略选择" ,
224+ multiSelect: false ,
225+ options: [
226+ ... conflict .strategies .map ((s , i ) => ({
227+ label: ` ${ s .name }${ i === conflict .recommended ? ' (推荐)' : ' ' } ` ,
228+ description: ` ${ s .complexity } 复杂度 | ${ s .risk } 风险${ s .clarification_needed ? .length ? ' | ⚠️需澄清' : ' ' }`
229+ })),
230+ { label: "自定义修改", description: ` 建议: ${conflict .modification_suggestions ? .slice (0 ,2 ).join (' ; ' )}` }
231+ ]
232+ }]
233+ })
234+
235+ // 3. Handle selection
236+ if (userChoice === "自定义修改") {
237+ customConflicts.push({ id, brief, category, suggestions, overlap_analysis })
238+ break
239+ }
240+
241+ selectedStrategy = findStrategyByName(userChoice)
242+
243+ // 4. Clarification (if needed) - batched max 4 per call
244+ if (selectedStrategy.clarification_needed?.length > 0) {
245+ for (batch of chunk(selectedStrategy.clarification_needed, 4)) {
246+ AskUserQuestion({
247+ questions: batch.map((q, i) => ({
248+ question: q, header: ` 澄清${i+ 1 }` , multiSelect: false,
249+ options: [{ label: "详细说明", description: "提供答案" }]
250+ }))
251+ })
252+ userClarifications.push(...collectAnswers(batch))
253+ }
254+
255+ // 5. Agent re-analysis
256+ reanalysisResult = Task({
257+ subagent_type: "cli-execution-agent",
258+ run_in_background: false,
259+ prompt: ` Conflict: ${conflict .id }, Strategy: ${selectedStrategy .name }
260+ User Clarifications: ${JSON .stringify (userClarifications)}
261+ Output: { uniqueness_confirmed, rationale, updated_strategy, remaining_questions }`
367262 })
368263
369- IF reanalysisResult .uniqueness_confirmed :
370- selectedStrategy = updated_strategy
371- selectedStrategy .clarifications = userClarifications
264+ if (reanalysisResult.uniqueness_confirmed) {
265+ selectedStrategy = { ...reanalysisResult.updated_strategy, clarifications: userClarifications }
372266 clarified = true
373- ELSE :
374- // 更新澄清问题,继续下一轮
375- selectedStrategy . clarification_needed = remaining_questions
376- ELSE :
267+ } else {
268+ selectedStrategy.clarification_needed = reanalysisResult.remaining_questions
269+ }
270+ } else {
377271 clarified = true
272+ }
378273
379- resolvedConflicts .push ({conflict, strategy: selectedStrategy})
274+ if (clarified) resolvedConflicts.push({ conflict, strategy: selectedStrategy })
380275 END WHILE
381276END FOR
382277
383- // Build output
384278selectedStrategies = resolvedConflicts.map(r => ({
385- conflict_id, strategy, clarifications[]
279+ conflict_id: r.conflict.id , strategy: r.strategy , clarifications: r.strategy.clarifications || []
386280}))
387281` ` `
388282
389- **Key Data Structures**:
390-
391- ` ` ` javascript
392- // Custom conflict tracking
393- customConflicts[] = {
394- id, brief, category,
395- suggestions: modification_suggestions[],
396- overlap_analysis: { new_module{}, existing_modules[] } // ModuleOverlap only
397- }
398-
399- // Agent re-analysis prompt output
400- {
401- uniqueness_confirmed: bool,
402- rationale: string,
403- updated_strategy: {
404- name, approach, complexity, risk, effort,
405- modifications: [{file, section, change_type, old_content, new_content, rationale}]
406- },
407- remaining_questions: string[]
408- }
409- ` ` `
410-
411- **Text Output Example** (展示关键字段):
412-
413- ` ` ` markdown
414- ============================================================
415- 冲突 1 / 3 - 第 1 轮
416- ============================================================
417- 【ModuleOverlap】CON - 001 : 新增用户认证服务与现有模块功能重叠
418- 严重程度: High | 描述: 计划中的 UserAuthService 与现有 AuthManager 场景重叠
419-
420- -- - 场景重叠分析 -- -
421- 新模块: UserAuthService | 场景: 登录, Token验证, 权限, MFA
422- 现有模块: AuthManager (src/ auth/ AuthManager .ts ) | 重叠: 登录, Token验证
423-
424- -- - 解决策略 -- -
425- 1 ) 合并 (Low复杂度 | Low风险 | 2 - 3 天)
426- ⚠️ 需澄清: AuthManager是否能承担MFA ?
427-
428- 2 ) 拆分边界 (Medium复杂度 | Medium风险 | 4 - 5 天)
429- ⚠️ 需澄清: 基础/ 高级认证边界? Token验证归谁?
430-
431- 3 ) 自定义修改
432- 建议: 评估扩展性; 策略模式分离; 定义接口边界
433-
434- 请选择 (1 - 3 ): > 2
435-
436- -- - 澄清问答 (第1 轮) -- -
437- Q : 基础/ 高级认证边界?
438- A : 基础= 密码登录+ token验证, 高级= MFA + OAuth+ SSO
439-
440- Q : Token验证归谁?
441- A : 统一由 AuthManager 负责
442-
443- 🔄 重新分析...
444- ✅ 唯一性已确认 | 理由: 边界清晰 - AuthManager (基础+ token), UserAuthService (MFA + OAuth+ SSO )
445-
446- ============================================================
447- 冲突 2 / 3 - 第 1 轮 [下一个冲突]
448- ============================================================
449- ` ` `
450-
451- **Loop Characteristics**: 逐个处理 | 无限轮次(max 10) | 动态问题生成 | Agent重新分析判断唯一性 | ModuleOverlap场景边界澄清
283+ ** Key Points** :
284+ - AskUserQuestion: max 4 questions/ call, batch if more
285+ - Strategy options: 2 - 4 strategies + " 自定义修改"
286+ - Clarification loop: max 10 rounds, agent判断 uniqueness_confirmed
287+ - Custom conflicts: 记录 overlap_analysis 供后续手动处理
452288
453289### Phase 4 : Apply Modifications
454290
0 commit comments