claude-code-workflow 7.2.20 → 7.2.22

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 (43) hide show
  1. package/.claude/commands/workflow/analyze-with-file.md +25 -12
  2. package/.codex/skills/analyze-with-file/SKILL.md +235 -497
  3. package/.codex/skills/brainstorm-with-file/SKILL.md +661 -751
  4. package/.codex/skills/csv-wave-pipeline/SKILL.md +192 -198
  5. package/.codex/skills/team-arch-opt/SKILL.md +24 -0
  6. package/.codex/skills/team-arch-opt/roles/coordinator/role.md +22 -0
  7. package/.codex/skills/team-brainstorm/SKILL.md +24 -0
  8. package/.codex/skills/team-brainstorm/roles/coordinator/role.md +20 -0
  9. package/.codex/skills/team-coordinate/SKILL.md +24 -0
  10. package/.codex/skills/team-coordinate/roles/coordinator/role.md +40 -12
  11. package/.codex/skills/team-frontend/SKILL.md +24 -0
  12. package/.codex/skills/team-frontend/roles/coordinator/role.md +20 -0
  13. package/.codex/skills/team-frontend-debug/SKILL.md +24 -0
  14. package/.codex/skills/team-frontend-debug/roles/coordinator/role.md +21 -0
  15. package/.codex/skills/team-issue/SKILL.md +24 -0
  16. package/.codex/skills/team-issue/roles/coordinator/role.md +19 -0
  17. package/.codex/skills/team-iterdev/SKILL.md +24 -0
  18. package/.codex/skills/team-iterdev/roles/coordinator/role.md +20 -0
  19. package/.codex/skills/team-lifecycle-v4/SKILL.md +24 -0
  20. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +28 -2
  21. package/.codex/skills/team-perf-opt/SKILL.md +24 -0
  22. package/.codex/skills/team-perf-opt/roles/coordinator/role.md +20 -0
  23. package/.codex/skills/team-planex/SKILL.md +24 -0
  24. package/.codex/skills/team-planex/roles/coordinator/role.md +19 -0
  25. package/.codex/skills/team-quality-assurance/SKILL.md +24 -0
  26. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +21 -0
  27. package/.codex/skills/team-review/SKILL.md +24 -0
  28. package/.codex/skills/team-review/roles/coordinator/role.md +21 -0
  29. package/.codex/skills/team-roadmap-dev/SKILL.md +24 -0
  30. package/.codex/skills/team-roadmap-dev/roles/coordinator/role.md +19 -0
  31. package/.codex/skills/team-tech-debt/SKILL.md +24 -0
  32. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +19 -0
  33. package/.codex/skills/team-testing/SKILL.md +24 -0
  34. package/.codex/skills/team-testing/roles/coordinator/role.md +21 -0
  35. package/.codex/skills/team-uidesign/SKILL.md +24 -0
  36. package/.codex/skills/team-uidesign/roles/coordinator/role.md +20 -0
  37. package/.codex/skills/team-ultra-analyze/SKILL.md +24 -0
  38. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +20 -0
  39. package/.codex/skills/team-ux-improve/SKILL.md +24 -0
  40. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +20 -0
  41. package/package.json +1 -1
  42. package/.codex/skills/collaborative-plan-with-file/SKILL.md +0 -830
  43. package/.codex/skills/unified-execute-with-file/SKILL.md +0 -797
@@ -1,830 +0,0 @@
1
- ---
2
- name: collaborative-plan-with-file
3
- description: Serial collaborative planning with Plan Note - Multi-domain serial task generation, unified plan-note.md, conflict detection. No agent delegation.
4
- argument-hint: "[-y|--yes] <task description> [--max-domains=5]"
5
- ---
6
-
7
- # Collaborative-Plan-With-File Workflow
8
-
9
- ## Quick Start
10
-
11
- Serial collaborative planning workflow using **Plan Note** architecture. Analyzes requirements, identifies sub-domains, generates detailed plans per domain serially, and detects conflicts across domains.
12
-
13
- ```bash
14
- # Basic usage
15
- /codex:collaborative-plan-with-file "Implement real-time notification system"
16
-
17
- # With options
18
- /codex:collaborative-plan-with-file "Refactor authentication module" --max-domains=4
19
- /codex:collaborative-plan-with-file "Add payment gateway support" -y
20
- ```
21
-
22
- **Core workflow**: Understand → Template → Serial Domain Planning → Conflict Detection → Completion
23
-
24
- **Key features**:
25
- - **plan-note.md**: Shared collaborative document with pre-allocated sections per domain
26
- - **Serial domain planning**: Each sub-domain planned sequentially with full codebase context
27
- - **Conflict detection**: Automatic file, dependency, and strategy conflict scanning
28
- - **No merge needed**: Pre-allocated sections eliminate merge conflicts
29
-
30
- ## Auto Mode
31
-
32
- When `--yes` or `-y`: Auto-approve splits, skip confirmations.
33
-
34
- ## Overview
35
-
36
- This workflow enables structured planning through sequential phases:
37
-
38
- 1. **Understanding & Template** — Analyze requirements, identify sub-domains, create plan-note.md template
39
- 2. **Serial Domain Planning** — Plan each sub-domain sequentially using direct search and analysis
40
- 3. **Conflict Detection** — Scan plan-note.md for conflicts across all domains
41
- 4. **Completion** — Generate human-readable plan.md summary
42
-
43
- The key innovation is the **Plan Note** architecture — a shared collaborative document with pre-allocated sections per sub-domain, eliminating merge conflicts even in serial execution.
44
-
45
- ```
46
- ┌─────────────────────────────────────────────────────────────────────────┐
47
- │ PLAN NOTE COLLABORATIVE PLANNING │
48
- ├─────────────────────────────────────────────────────────────────────────┤
49
- │ │
50
- │ Phase 1: Understanding & Template Creation │
51
- │ ├─ Analyze requirements (inline search & analysis) │
52
- │ ├─ Identify 2-5 sub-domains (focus areas) │
53
- │ ├─ Create plan-note.md with pre-allocated sections │
54
- │ └─ Assign TASK ID ranges (no conflicts) │
55
- │ │
56
- │ Phase 2: Serial Domain Planning │
57
- │ ┌──────────────┐ │
58
- │ │ Domain 1 │→ Explore codebase → Generate .task/TASK-*.json │
59
- │ │ Section 1 │→ Fill task pool + evidence in plan-note.md │
60
- │ └──────┬───────┘ │
61
- │ ┌──────▼───────┐ │
62
- │ │ Domain 2 │→ Explore codebase → Generate .task/TASK-*.json │
63
- │ │ Section 2 │→ Fill task pool + evidence in plan-note.md │
64
- │ └──────┬───────┘ │
65
- │ ┌──────▼───────┐ │
66
- │ │ Domain N │→ ... │
67
- │ └──────────────┘ │
68
- │ │
69
- │ Phase 3: Conflict Detection (Single Source) │
70
- │ ├─ Parse plan-note.md (all sections) │
71
- │ ├─ Detect file/dependency/strategy conflicts │
72
- │ └─ Update plan-note.md conflict section │
73
- │ │
74
- │ Phase 4: Completion (No Merge) │
75
- │ ├─ Collect domain .task/*.json → session .task/*.json │
76
- │ ├─ Generate plan.md (human-readable) │
77
- │ └─ Ready for execution │
78
- │ │
79
- └─────────────────────────────────────────────────────────────────────────┘
80
- ```
81
-
82
- ## Output Structure
83
-
84
- > **Schema**: `cat ~/.ccw/workflows/cli-templates/schemas/task-schema.json`
85
-
86
- ```
87
- {projectRoot}/.workflow/.planning/CPLAN-{slug}-{date}/
88
- ├── plan-note.md # ⭐ Core: Requirements + Tasks + Conflicts
89
- ├── requirement-analysis.json # Phase 1: Sub-domain assignments
90
- ├── domains/ # Phase 2: Per-domain plans
91
- │ ├── {domain-1}/
92
- │ │ └── .task/ # Per-domain task JSON files
93
- │ │ ├── TASK-001.json
94
- │ │ └── ...
95
- │ ├── {domain-2}/
96
- │ │ └── .task/
97
- │ │ ├── TASK-101.json
98
- │ │ └── ...
99
- │ └── ...
100
- ├── plan.json # Plan overview (plan-overview-base-schema.json)
101
- ├── .task/ # ⭐ Merged task JSON files (all domains)
102
- │ ├── TASK-001.json
103
- │ ├── TASK-101.json
104
- │ └── ...
105
- ├── conflicts.json # Phase 3: Conflict report
106
- └── plan.md # Phase 4: Human-readable summary
107
- ```
108
-
109
- ## Output Artifacts
110
-
111
- ### Phase 1: Understanding & Template
112
-
113
- | Artifact | Purpose |
114
- |----------|---------|
115
- | `plan-note.md` | Collaborative template with pre-allocated task pool and evidence sections per domain |
116
- | `requirement-analysis.json` | Sub-domain assignments, TASK ID ranges, complexity assessment |
117
-
118
- ### Phase 2: Serial Domain Planning
119
-
120
- | Artifact | Purpose |
121
- |----------|---------|
122
- | `domains/{domain}/.task/TASK-*.json` | Task JSON files per domain (one file per task with convergence) |
123
- | Updated `plan-note.md` | Task pool and evidence sections filled for each domain |
124
-
125
- ### Phase 3: Conflict Detection
126
-
127
- | Artifact | Purpose |
128
- |----------|---------|
129
- | `conflicts.json` | Detected conflicts with types, severity, and resolutions |
130
- | Updated `plan-note.md` | Conflict markers section populated |
131
-
132
- ### Phase 4: Completion
133
-
134
- | Artifact | Purpose |
135
- |----------|---------|
136
- | `.task/TASK-*.json` | Merged task JSON files from all domains (consumable by unified-execute) |
137
- | `plan.json` | Plan overview following plan-overview-base-schema.json |
138
- | `plan.md` | Human-readable summary with requirements, tasks, and conflicts |
139
-
140
- ---
141
-
142
- ## Implementation Details
143
-
144
- ### Session Initialization
145
-
146
- ##### Step 0: Initialize Session
147
-
148
- ```javascript
149
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
150
-
151
- // Detect project root
152
- const projectRoot = Bash(`git rev-parse --show-toplevel 2>/dev/null || pwd`).trim()
153
-
154
- // Parse arguments
155
- const autoMode = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
156
- const maxDomainsMatch = $ARGUMENTS.match(/--max-domains=(\d+)/)
157
- const maxDomains = maxDomainsMatch ? parseInt(maxDomainsMatch[1]) : 5
158
-
159
- // Clean task description
160
- const taskDescription = $ARGUMENTS
161
- .replace(/--yes|-y|--max-domains=\d+/g, '')
162
- .trim()
163
-
164
- const slug = taskDescription.toLowerCase()
165
- .replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
166
- .substring(0, 30)
167
- const dateStr = getUtc8ISOString().substring(0, 10)
168
- const sessionId = `CPLAN-${slug}-${dateStr}`
169
- const sessionFolder = `${projectRoot}/.workflow/.planning/${sessionId}`
170
-
171
- // Auto-detect continue: session folder + plan-note.md exists → continue mode
172
- // If continue → load existing state and resume from incomplete phase
173
- Bash(`mkdir -p ${sessionFolder}/domains`)
174
- ```
175
-
176
- **Session Variables**:
177
- - `sessionId`: Unique session identifier
178
- - `sessionFolder`: Base directory for all artifacts
179
- - `maxDomains`: Maximum number of sub-domains (default: 5)
180
- - `autoMode`: Boolean for auto-confirmation
181
-
182
- **Auto-Detection**: If session folder exists with plan-note.md, automatically enters continue mode.
183
-
184
- ---
185
-
186
- ## Phase 1: Understanding & Template Creation
187
-
188
- **Objective**: Analyze task requirements, identify parallelizable sub-domains, and create the plan-note.md template with pre-allocated sections.
189
-
190
- ### Step 1.1: Analyze Task Description
191
-
192
- Use built-in tools directly to understand the task scope and identify sub-domains.
193
-
194
- **Analysis Activities**:
195
- 1. **Search for references** — Find related documentation, README files, and architecture guides
196
- - Use: `mcp__ace-tool__search_context`, Grep, Glob, Read
197
- - Run: `ccw spec load --category planning` (if spec system available)
198
- 2. **Extract task keywords** — Identify key terms and concepts from the task description
199
- 3. **Identify ambiguities** — List any unclear points or multiple possible interpretations
200
- 4. **Clarify with user** — If ambiguities found, use request_user_input for clarification
201
- 5. **Identify sub-domains** — Split into 2-{maxDomains} parallelizable focus areas based on task complexity
202
- 6. **Assess complexity** — Evaluate overall task complexity (Low/Medium/High)
203
-
204
- **Sub-Domain Identification Patterns**:
205
-
206
- | Pattern | Keywords |
207
- |---------|----------|
208
- | Backend API | 服务, 后端, API, 接口 |
209
- | Frontend | 界面, 前端, UI, 视图 |
210
- | Database | 数据, 存储, 数据库, 持久化 |
211
- | Testing | 测试, 验证, QA |
212
- | Infrastructure | 部署, 基础, 运维, 配置 |
213
-
214
- **Guideline**: Prioritize identifying latest documentation (README, design docs, architecture guides). When ambiguities exist, ask user for clarification instead of assuming interpretations.
215
-
216
- ### Step 1.2: Create plan-note.md Template
217
-
218
- Generate a structured template with pre-allocated sections for each sub-domain.
219
-
220
- **plan-note.md Structure**:
221
-
222
- ```yaml
223
- ---
224
- session_id: CPLAN-{slug}-{date}
225
- original_requirement: "{task description}"
226
- created_at: "{ISO timestamp}"
227
- complexity: Low | Medium | High
228
- sub_domains: ["{domain-1}", "{domain-2}", ...]
229
- domain_task_id_ranges:
230
- "{domain-1}": [1, 100]
231
- "{domain-2}": [101, 200]
232
- status: planning
233
- ---
234
- ```
235
-
236
- **Sections**:
237
- - `## 需求理解` — Core objectives, key points, constraints, split strategy
238
- - `## 任务池 - {Domain N}` — Pre-allocated task section per domain (TASK-{range})
239
- - `## 依赖关系` — Auto-generated after all domains complete
240
- - `## 冲突标记` — Populated in Phase 3
241
- - `## 上下文证据 - {Domain N}` — Evidence section per domain
242
-
243
- **TASK ID Range Allocation**: Each domain receives a non-overlapping range of 100 IDs (e.g., Domain 1: TASK-001~100, Domain 2: TASK-101~200).
244
-
245
- ### Step 1.3: Generate requirement-analysis.json
246
-
247
- ```javascript
248
- Write(`${sessionFolder}/requirement-analysis.json`, JSON.stringify({
249
- session_id: sessionId,
250
- original_requirement: taskDescription,
251
- complexity: complexity, // Low | Medium | High
252
- sub_domains: subDomains.map(sub => ({
253
- focus_area: sub.focus_area,
254
- description: sub.description,
255
- task_id_range: sub.task_id_range,
256
- estimated_effort: sub.estimated_effort,
257
- dependencies: sub.dependencies // cross-domain dependencies
258
- })),
259
- total_domains: subDomains.length
260
- }, null, 2))
261
- ```
262
-
263
- **Success Criteria**:
264
- - Latest documentation identified and referenced (if available)
265
- - Ambiguities resolved via user clarification (if any found)
266
- - 2-{maxDomains} clear sub-domains identified
267
- - Each sub-domain can be planned independently
268
- - Plan Note template includes all pre-allocated sections
269
- - TASK ID ranges have no overlap (100 IDs per domain)
270
- - Requirements understanding is comprehensive
271
-
272
- ---
273
-
274
- ## Phase 2: Serial Sub-Domain Planning
275
-
276
- **Objective**: Plan each sub-domain sequentially, generating detailed plans and updating plan-note.md.
277
-
278
- **Execution Model**: Serial inline execution — each domain explored and planned directly using search tools, one at a time.
279
-
280
- ### Step 2.1: User Confirmation (unless autoMode)
281
-
282
- Display identified sub-domains and confirm before starting.
283
-
284
- ```javascript
285
- if (!autoMode) {
286
- request_user_input({
287
- questions: [{
288
- header: "确认规划",
289
- id: "confirm",
290
- question: `已识别 ${subDomains.length} 个子领域:\n${subDomains.map((s, i) =>
291
- `${i+1}. ${s.focus_area}: ${s.description}`).join('\n')}\n\n确认开始规划?`,
292
- options: [
293
- { label: "开始规划(Recommended)", description: "逐域进行规划" },
294
- { label: "调整拆分", description: "修改子领域划分" },
295
- { label: "取消", description: "退出规划" }
296
- ]
297
- }]
298
- })
299
- }
300
- ```
301
-
302
- ### Step 2.2: Serial Domain Planning
303
-
304
- For each sub-domain, execute the full planning cycle inline:
305
-
306
- ```javascript
307
- for (const sub of subDomains) {
308
- // 1. Create domain directory with .task/ subfolder
309
- Bash(`mkdir -p ${sessionFolder}/domains/${sub.focus_area}/.task`)
310
-
311
- // 2. Explore codebase for domain-relevant context
312
- // Use: mcp__ace-tool__search_context, Grep, Glob, Read
313
- // Focus on:
314
- // - Modules/components related to this domain
315
- // - Existing patterns to follow
316
- // - Integration points with other domains
317
- // - Architecture constraints
318
-
319
- // 3. Generate task JSON records (following task-schema.json)
320
- const domainTasks = [
321
- // For each task within the assigned ID range:
322
- {
323
- id: `TASK-${String(sub.task_id_range[0]).padStart(3, '0')}`,
324
- title: "...",
325
- description: "...", // scope/goal of this task
326
- type: "feature", // infrastructure|feature|enhancement|fix|refactor|testing
327
- priority: "medium", // high|medium|low
328
- effort: "medium", // small|medium|large
329
- scope: "...", // Brief scope description
330
- depends_on: [], // TASK-xxx references
331
- convergence: {
332
- criteria: ["... (testable)"], // Testable conditions
333
- verification: "... (executable)", // Command or steps
334
- definition_of_done: "... (business language)"
335
- },
336
- files: [ // Files to modify
337
- {
338
- path: "...",
339
- action: "modify", // modify|create|delete
340
- changes: ["..."], // Change descriptions
341
- conflict_risk: "low" // low|medium|high
342
- }
343
- ],
344
- source: {
345
- tool: "collaborative-plan-with-file",
346
- session_id: sessionId,
347
- original_id: `TASK-${String(sub.task_id_range[0]).padStart(3, '0')}`
348
- }
349
- }
350
- // ... more tasks
351
- ]
352
-
353
- // 4. Write individual task JSON files (one per task)
354
- domainTasks.forEach(task => {
355
- Write(`${sessionFolder}/domains/${sub.focus_area}/.task/${task.id}.json`,
356
- JSON.stringify(task, null, 2))
357
- })
358
-
359
- // 5. Sync summary to plan-note.md
360
- // Read current plan-note.md
361
- // Locate pre-allocated sections:
362
- // - Task Pool: "## 任务池 - ${toTitleCase(sub.focus_area)}"
363
- // - Evidence: "## 上下文证据 - ${toTitleCase(sub.focus_area)}"
364
- // Fill with task summaries and evidence
365
- // Write back plan-note.md
366
- }
367
- ```
368
-
369
- **Task Summary Format** (for plan-note.md task pool sections):
370
-
371
- ```markdown
372
- ### TASK-{ID}: {Title} [{focus-area}]
373
- - **状态**: pending
374
- - **类型**: feature/fix/refactor/enhancement/testing/infrastructure
375
- - **优先级**: high/medium/low
376
- - **工作量**: small/medium/large
377
- - **依赖**: TASK-xxx (if any)
378
- - **范围**: Brief scope description
379
- - **修改文件**: `file-path` (action): change summary
380
- - **收敛标准**:
381
- - criteria 1
382
- - criteria 2
383
- - **验证方式**: executable command or steps
384
- - **完成定义**: business language definition
385
- ```
386
-
387
- **Evidence Format** (for plan-note.md evidence sections):
388
-
389
- ```markdown
390
- - **相关文件**: file list with relevance
391
- - **现有模式**: patterns identified
392
- - **约束**: constraints discovered
393
- ```
394
-
395
- **Domain Planning Rules**:
396
- - Each domain modifies ONLY its pre-allocated sections in plan-note.md
397
- - Use assigned TASK ID range exclusively
398
- - Include convergence criteria for each task (criteria + verification + definition_of_done)
399
- - Include `files[]` with conflict_risk assessment per file
400
- - Reference cross-domain dependencies explicitly
401
- - Each task record must be self-contained (can be independently consumed by unified-execute)
402
-
403
- ### Step 2.3: Verify plan-note.md Consistency
404
-
405
- After all domains are planned, verify the shared document.
406
-
407
- **Verification Activities**:
408
- 1. Read final plan-note.md
409
- 2. Verify all task pool sections are populated
410
- 3. Verify all evidence sections are populated
411
- 4. Validate TASK ID uniqueness across all domains
412
- 5. Check for any section format inconsistencies
413
-
414
- **Success Criteria**:
415
- - `domains/{domain}/.task/TASK-*.json` created for each domain (one file per task)
416
- - Each task has convergence (criteria + verification + definition_of_done)
417
- - `plan-note.md` updated with all task pools and evidence sections
418
- - Task summaries follow consistent format
419
- - No TASK ID overlaps across domains
420
-
421
- ---
422
-
423
- ## Phase 3: Conflict Detection
424
-
425
- **Objective**: Analyze plan-note.md for conflicts across all domain contributions.
426
-
427
- ### Step 3.1: Parse plan-note.md
428
-
429
- Extract all tasks from all "任务池" sections and domain .task/*.json files.
430
-
431
- ```javascript
432
- // parsePlanNote(markdown)
433
- // - Extract YAML frontmatter between `---` markers
434
- // - Scan for heading patterns: /^(#{2,})\s+(.+)$/
435
- // - Build sections array: { level, heading, start, content }
436
- // - Return: { frontmatter, sections }
437
-
438
- // Also load all domain .task/*.json for detailed data
439
- // loadDomainTasks(sessionFolder, subDomains):
440
- // const allTasks = []
441
- // for (const sub of subDomains) {
442
- // const taskDir = `${sessionFolder}/domains/${sub.focus_area}/.task`
443
- // const taskFiles = Glob(`${taskDir}/TASK-*.json`)
444
- // taskFiles.forEach(file => {
445
- // allTasks.push(JSON.parse(Read(file)))
446
- // })
447
- // }
448
- // return allTasks
449
-
450
- // extractTasksFromSection(content, sectionHeading)
451
- // - Match: /### (TASK-\d+):\s+(.+?)\s+\[(.+?)\]/
452
- // - For each: extract taskId, title, author
453
- // - Parse details: status, type, priority, effort, depends_on, files, convergence
454
- // - Return: array of task objects
455
-
456
- // parseTaskDetails(content)
457
- // - Extract via regex:
458
- // - /\*\*状态\*\*:\s*(.+)/ → status
459
- // - /\*\*类型\*\*:\s*(.+)/ → type
460
- // - /\*\*优先级\*\*:\s*(.+)/ → priority
461
- // - /\*\*工作量\*\*:\s*(.+)/ → effort
462
- // - /\*\*依赖\*\*:\s*(.+)/ → depends_on (extract TASK-\d+ references)
463
- // - Extract files: /- `([^`]+)` \((\w+)\):\s*(.+)/ → path, action, change
464
- // - Return: { status, type, priority, effort, depends_on[], files[], convergence }
465
- ```
466
-
467
- ### Step 3.2: Detect Conflicts
468
-
469
- Scan all tasks for three categories of conflicts.
470
-
471
- **Conflict Types**:
472
-
473
- | Type | Severity | Detection Logic | Resolution |
474
- |------|----------|-----------------|------------|
475
- | file_conflict | high | Same file:location modified by multiple domains | Coordinate modification order or merge changes |
476
- | dependency_cycle | critical | Circular dependencies in task graph (DFS detection) | Remove or reorganize dependencies |
477
- | strategy_conflict | medium | Multiple high-risk tasks in same file from different domains | Review approaches and align on single strategy |
478
-
479
- **Detection Functions**:
480
-
481
- ```javascript
482
- // detectFileConflicts(tasks)
483
- // Build fileMap: { "file-path": [{ task_id, task_title, source_domain, changes }] }
484
- // For each file with modifications from multiple domains:
485
- // → conflict: type='file_conflict', severity='high'
486
- // → include: file, tasks_involved, domains_involved, changes
487
- // → resolution: 'Coordinate modification order or merge changes'
488
-
489
- // detectDependencyCycles(tasks)
490
- // Build dependency graph: { taskId: [dependsOn_taskIds] }
491
- // DFS with recursion stack to detect cycles:
492
- function detectCycles(tasks) {
493
- const graph = new Map(tasks.map(t => [t.id, t.depends_on || []]))
494
- const visited = new Set(), inStack = new Set(), cycles = []
495
- function dfs(node, path) {
496
- if (inStack.has(node)) { cycles.push([...path, node].join(' → ')); return }
497
- if (visited.has(node)) return
498
- visited.add(node); inStack.add(node)
499
- ;(graph.get(node) || []).forEach(dep => dfs(dep, [...path, node]))
500
- inStack.delete(node)
501
- }
502
- tasks.forEach(t => { if (!visited.has(t.id)) dfs(t.id, []) })
503
- return cycles
504
- }
505
-
506
- // detectStrategyConflicts(tasks)
507
- // Group tasks by files they modify (from task.files[].path)
508
- // For each file with tasks from multiple domains:
509
- // Filter for tasks with files[].conflict_risk === 'high' or 'medium'
510
- // If >1 high-risk from different domains:
511
- // → conflict: type='strategy_conflict', severity='medium'
512
- // → resolution: 'Review approaches and align on single strategy'
513
- ```
514
-
515
- ### Step 3.3: Generate Conflict Artifacts
516
-
517
- Write conflict results and update plan-note.md.
518
-
519
- ```javascript
520
- // 1. Write conflicts.json
521
- Write(`${sessionFolder}/conflicts.json`, JSON.stringify({
522
- detected_at: getUtc8ISOString(),
523
- total_tasks: allTasks.length,
524
- total_domains: subDomains.length,
525
- total_conflicts: allConflicts.length,
526
- conflicts: allConflicts // { type, severity, tasks_involved, description, suggested_resolution }
527
- }, null, 2))
528
-
529
- // 2. Update plan-note.md "## 冲突标记" section
530
- // generateConflictMarkdown(conflicts):
531
- // If empty: return '✅ 无冲突检测到'
532
- // For each conflict:
533
- // ### CONFLICT-{padded_index}: {description}
534
- // - **严重程度**: critical | high | medium
535
- // - **涉及任务**: TASK-xxx, TASK-yyy
536
- // - **涉及领域**: domain-a, domain-b
537
- // - **问题详情**: (based on conflict type)
538
- // - **建议解决方案**: ...
539
- // - **决策状态**: [ ] 待解决
540
-
541
- // replaceSectionContent(markdown, sectionHeading, newContent):
542
- // Find section heading position via regex
543
- // Find next heading of same or higher level
544
- // Replace content between heading and next section
545
- // If section not found: append at end
546
- ```
547
-
548
- **Success Criteria**:
549
- - All tasks extracted and analyzed
550
- - `conflicts.json` written with detection results
551
- - `plan-note.md` updated with conflict markers
552
- - All conflict types checked (file, dependency, strategy)
553
-
554
- ---
555
-
556
- ## Phase 4: Completion
557
-
558
- **Objective**: Generate human-readable plan summary and finalize workflow.
559
-
560
- ### Step 4.1: Collect Domain .task/*.json to Session .task/
561
-
562
- Copy all per-domain task JSON files into a single session-level `.task/` directory.
563
-
564
- ```javascript
565
- // Create session-level .task/ directory
566
- Bash(`mkdir -p ${sessionFolder}/.task`)
567
-
568
- // Collect all domain task files
569
- for (const sub of subDomains) {
570
- const taskDir = `${sessionFolder}/domains/${sub.focus_area}/.task`
571
- const taskFiles = Glob(`${taskDir}/TASK-*.json`)
572
- taskFiles.forEach(file => {
573
- const filename = path.basename(file)
574
- // Copy domain task file to session .task/ directory
575
- Bash(`cp ${file} ${sessionFolder}/.task/${filename}`)
576
- })
577
- }
578
- ```
579
-
580
- ### Step 4.2: Generate plan.json
581
-
582
- Generate a plan overview following the plan-overview-base-schema.
583
-
584
- ```javascript
585
- // Generate plan.json (plan-overview-base-schema)
586
- const allTaskFiles = Glob(`${sessionFolder}/.task/TASK-*.json`)
587
- const taskIds = allTaskFiles.map(f => JSON.parse(Read(f)).id).sort()
588
-
589
- // Guard: skip plan.json if no tasks generated
590
- if (taskIds.length === 0) {
591
- console.warn('No tasks generated; skipping plan.json')
592
- } else {
593
-
594
- const planOverview = {
595
- summary: `Collaborative plan for: ${taskDescription}`,
596
- approach: `Multi-domain planning across ${subDomains.length} sub-domains: ${subDomains.map(s => s.focus_area).join(', ')}`,
597
- task_ids: taskIds,
598
- task_count: taskIds.length,
599
- complexity: complexity,
600
- recommended_execution: "Agent",
601
- _metadata: {
602
- timestamp: getUtc8ISOString(),
603
- source: "direct-planning",
604
- planning_mode: "direct",
605
- plan_type: "collaborative",
606
- schema_version: "2.0"
607
- }
608
- }
609
- Write(`${sessionFolder}/plan.json`, JSON.stringify(planOverview, null, 2))
610
-
611
- } // end guard
612
- ```
613
-
614
- ### Step 4.3: Generate plan.md
615
-
616
- Create a human-readable summary from plan-note.md content.
617
-
618
- **plan.md Structure**:
619
-
620
- | Section | Content |
621
- |---------|---------|
622
- | Header | Session ID, task description, creation time |
623
- | 需求 (Requirements) | Copied from plan-note.md "需求理解" section |
624
- | 子领域拆分 (Sub-Domains) | Each domain with description, task range, estimated effort |
625
- | 任务概览 (Task Overview) | All tasks with complexity, dependencies, and target files |
626
- | 冲突报告 (Conflict Report) | Summary of detected conflicts or "无冲突" |
627
- | 执行指令 (Execution) | Command to execute the plan |
628
-
629
- ```javascript
630
- const planMd = `# Collaborative Plan
631
-
632
- **Session**: ${sessionId}
633
- **Requirement**: ${taskDescription}
634
- **Created**: ${getUtc8ISOString()}
635
- **Complexity**: ${complexity}
636
- **Domains**: ${subDomains.length}
637
-
638
- ## 需求理解
639
-
640
- ${requirementSection}
641
-
642
- ## 子领域拆分
643
-
644
- | # | Focus Area | Description | TASK Range | Effort |
645
- |---|-----------|-------------|------------|--------|
646
- ${subDomains.map((s, i) => `| ${i+1} | ${s.focus_area} | ${s.description} | ${s.task_id_range[0]}-${s.task_id_range[1]} | ${s.estimated_effort} |`).join('\n')}
647
-
648
- ## 任务概览
649
-
650
- ${subDomains.map(sub => {
651
- const domainTasks = allTasks.filter(t => t.source?.original_id?.startsWith('TASK') && t.source?.session_id === sessionId)
652
- return `### ${sub.focus_area}\n\n` +
653
- domainTasks.map(t => `- **${t.id}**: ${t.title} (${t.type}, ${t.effort}) ${t.depends_on.length ? '← ' + t.depends_on.join(', ') : ''}`).join('\n')
654
- }).join('\n\n')}
655
-
656
- ## 冲突报告
657
-
658
- ${allConflicts.length === 0
659
- ? '✅ 无冲突检测到'
660
- : allConflicts.map(c => `- **${c.type}** (${c.severity}): ${c.description}`).join('\n')}
661
-
662
- ## 执行
663
-
664
- \`\`\`bash
665
- /workflow:unified-execute-with-file PLAN="${sessionFolder}/.task/"
666
- \`\`\`
667
-
668
- **Session artifacts**: \`${sessionFolder}/\`
669
- `
670
- Write(`${sessionFolder}/plan.md`, planMd)
671
- ```
672
-
673
- ### Step 4.4: Display Completion Summary
674
-
675
- Present session statistics and next steps.
676
-
677
- ```javascript
678
- // Display:
679
- // - Session ID and directory path
680
- // - Total domains planned
681
- // - Total tasks generated
682
- // - Conflict status (count and severity)
683
- // - Execution command for next step
684
-
685
- if (!autoMode) {
686
- request_user_input({
687
- questions: [{
688
- header: "下一步",
689
- id: "next_step",
690
- question: `规划完成:\n- ${subDomains.length} 个子领域\n- ${allTasks.length} 个任务\n- ${allConflicts.length} 个冲突\n\n下一步:`,
691
- options: [
692
- { label: "Execute Plan(Recommended)", description: "使用 unified-execute 执行计划" },
693
- { label: "Review Conflicts", description: "查看并解决冲突" },
694
- { label: "Done", description: "保存产物,稍后执行" }
695
- ]
696
- }]
697
- })
698
- }
699
- ```
700
-
701
- | Selection | Action |
702
- |-----------|--------|
703
- | Execute Plan | `Skill(skill="workflow:unified-execute-with-file", args="PLAN=\"${sessionFolder}/.task/\"")` |
704
- | Review Conflicts | Display conflicts.json content for manual resolution |
705
- | Export | Copy plan.md + plan-note.md to user-specified location |
706
- | Done | Display artifact paths, end workflow |
707
-
708
- ### Step 4.5: Sync Session State
709
-
710
- ```bash
711
- $session-sync -y "Plan complete: {domains} domains, {tasks} tasks"
712
- ```
713
-
714
- Updates specs/*.md with planning insights and project-tech.json with planning session entry.
715
-
716
- **Success Criteria**:
717
- - `plan.md` generated with complete summary
718
- - `.task/TASK-*.json` collected at session root (consumable by unified-execute)
719
- - All artifacts present in session directory
720
- - Session state synced via `$session-sync`
721
- - User informed of completion and next steps
722
-
723
- ---
724
-
725
- ## Configuration
726
-
727
- | Flag | Default | Description |
728
- |------|---------|-------------|
729
- | `--max-domains` | 5 | Maximum sub-domains to identify |
730
- | `-y, --yes` | false | Auto-confirm all decisions |
731
-
732
- ## Iteration Patterns
733
-
734
- ### New Planning Session
735
-
736
- ```
737
- User initiates: TASK="task description"
738
- ├─ No session exists → New session mode
739
- ├─ Analyze task with inline search tools
740
- ├─ Identify sub-domains
741
- ├─ Create plan-note.md template
742
- ├─ Generate requirement-analysis.json
743
-
744
- ├─ Serial domain planning:
745
- │ ├─ Domain 1: explore → .task/TASK-*.json → fill plan-note.md
746
- │ ├─ Domain 2: explore → .task/TASK-*.json → fill plan-note.md
747
- │ └─ Domain N: ...
748
-
749
- ├─ Collect domain .task/*.json → session .task/
750
-
751
- ├─ Verify plan-note.md consistency
752
- ├─ Detect conflicts
753
- ├─ Generate plan.md summary
754
- └─ Report completion
755
- ```
756
-
757
- ### Continue Existing Session
758
-
759
- ```
760
- User resumes: TASK="same task"
761
- ├─ Session exists → Continue mode
762
- ├─ Load plan-note.md and requirement-analysis.json
763
- ├─ Identify incomplete domains (empty task pool sections)
764
- ├─ Plan remaining domains serially
765
- └─ Continue with conflict detection
766
- ```
767
-
768
- ---
769
-
770
- ## Error Handling & Recovery
771
-
772
- | Situation | Action | Recovery |
773
- |-----------|--------|----------|
774
- | No codebase detected | Normal flow, pure requirement planning | Proceed without codebase context |
775
- | Codebase search fails | Continue with available context | Note limitation in plan-note.md |
776
- | Domain planning fails | Record error, continue with next domain | Retry failed domain or plan manually |
777
- | Section not found in plan-note | Create section defensively | Continue with new section |
778
- | No tasks generated for a domain | Review domain description | Refine scope and retry |
779
- | Conflict detection fails | Continue with empty conflicts | Note in completion summary |
780
- | Session folder conflict | Append timestamp suffix | Create unique folder |
781
- | plan-note.md format inconsistency | Validate and fix format after each domain | Re-read and normalize |
782
-
783
- ---
784
-
785
- ## Best Practices
786
-
787
- ### Before Starting Planning
788
-
789
- 1. **Clear Task Description**: Detailed requirements lead to better sub-domain splitting
790
- 2. **Reference Documentation**: Ensure latest README and design docs are identified during Phase 1
791
- 3. **Clarify Ambiguities**: Resolve unclear requirements before committing to sub-domains
792
-
793
- ### During Planning
794
-
795
- 1. **Review Plan Note**: Check plan-note.md between domains to verify progress
796
- 2. **Verify Independence**: Ensure sub-domains are truly independent and have minimal overlap
797
- 3. **Check Dependencies**: Cross-domain dependencies should be documented explicitly
798
- 4. **Inspect Details**: Review `domains/{domain}/.task/TASK-*.json` for specifics when needed
799
- 5. **Consistent Format**: Follow task summary format strictly across all domains
800
- 6. **TASK ID Isolation**: Use pre-assigned non-overlapping ranges to prevent ID conflicts
801
-
802
- ### After Planning
803
-
804
- 1. **Resolve Conflicts**: Address high/critical conflicts before execution
805
- 2. **Review Summary**: Check plan.md for completeness and accuracy
806
- 3. **Validate Tasks**: Ensure all tasks have clear scope and modification targets
807
-
808
- ## When to Use
809
-
810
- **Use collaborative-plan-with-file when:**
811
- - A complex task spans multiple sub-domains (backend + frontend + database, etc.)
812
- - Need structured multi-domain task breakdown with conflict detection
813
- - Planning a feature that touches many parts of the codebase
814
- - Want pre-allocated section organization for clear domain separation
815
-
816
- **Use lite-plan when:**
817
- - Single domain, clear task with no sub-domain splitting needed
818
- - Quick planning without conflict detection
819
-
820
- **Use req-plan-with-file when:**
821
- - Requirement-level progressive roadmap needed (MVP → iterations)
822
- - Higher-level decomposition before detailed planning
823
-
824
- **Use analyze-with-file when:**
825
- - Need in-depth analysis before planning
826
- - Understanding and discussion, not task generation
827
-
828
- ---
829
-
830
- **Now execute collaborative-plan-with-file for**: $ARGUMENTS