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,639 @@
1
+ ---
2
+ name: workflow:collaborative-plan-with-file
3
+ description: Collaborative planning with Plan Note - Understanding agent creates shared plan-note.md template, parallel agents fill pre-allocated sections, conflict detection without merge. Outputs executable plan-note.md.
4
+ argument-hint: "[-y|--yes] <task description> [--max-agents=5]"
5
+ allowed-tools: TodoWrite(*), Agent(*), AskUserQuestion(*), Read(*), Bash(*), Write(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*)
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-approve splits, skip confirmations.
11
+
12
+ # Collaborative Planning Command
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Basic usage
18
+ /workflow:collaborative-plan-with-file "Implement real-time notification system"
19
+
20
+ # With options
21
+ /workflow:collaborative-plan-with-file "Refactor authentication module" --max-agents=4
22
+ /workflow:collaborative-plan-with-file "Add payment gateway support" -y
23
+ ```
24
+
25
+ **Context Source**: Understanding-Agent + Per-agent exploration
26
+ **Output Directory**: `.workflow/.planning/{session-id}/`
27
+ **Default Max Agents**: 5 (actual count based on requirement complexity)
28
+ **Core Innovation**: Plan Note - shared collaborative document, no merge needed
29
+
30
+ ## Output Artifacts
31
+
32
+ ### Phase 1: Understanding Agent
33
+
34
+ | Artifact | Description |
35
+ |----------|-------------|
36
+ | `plan-note.md` | Shared collaborative document with pre-allocated sections |
37
+ | `requirement-analysis.json` | Sub-domain assignments and TASK ID ranges |
38
+
39
+ ### Phase 2: Per Sub-Agent
40
+
41
+ | Artifact | Description |
42
+ |----------|-------------|
43
+ | `planning-context.md` | Evidence paths + synthesized understanding |
44
+ | `plan.json` | Plan overview with task_ids[] (NO embedded tasks[]) |
45
+ | `.task/TASK-*.json` | Independent task files following task-schema.json |
46
+ | Updates to `plan-note.md` | Agent fills pre-allocated sections |
47
+
48
+ ### Phase 3: Final Output
49
+
50
+ | Artifact | Description |
51
+ |----------|-------------|
52
+ | `plan-note.md` | ⭐ Executable plan with conflict markers |
53
+ | `conflicts.json` | Detected conflicts with resolution options |
54
+ | `plan.md` | Human-readable summary |
55
+
56
+ ## Overview
57
+
58
+ Unified collaborative planning workflow using **Plan Note** architecture:
59
+
60
+ 1. **Understanding**: Agent analyzes requirements and creates plan-note.md template with pre-allocated sections
61
+ 2. **Parallel Planning**: Each agent generates plan.json + fills their pre-allocated section in plan-note.md
62
+ 3. **Conflict Detection**: Scan plan-note.md for conflicts (no merge needed)
63
+ 4. **Completion**: Generate plan.md summary, ready for execution
64
+
65
+ ```
66
+ ┌─────────────────────────────────────────────────────────────────────────┐
67
+ │ PLAN NOTE COLLABORATIVE PLANNING │
68
+ ├─────────────────────────────────────────────────────────────────────────┤
69
+ │ │
70
+ │ Phase 1: Understanding & Template Creation │
71
+ │ ├─ Understanding-Agent analyzes requirements │
72
+ │ ├─ Identify 2-5 sub-domains (focus areas) │
73
+ │ ├─ Create plan-note.md with pre-allocated sections │
74
+ │ └─ Assign TASK ID ranges (no conflicts) │
75
+ │ │
76
+ │ Phase 2: Parallel Agent Execution (No Locks Needed) │
77
+ │ ┌──────────────┬──────────────┬──────────────┐ │
78
+ │ │ Agent 1 │ Agent 2 │ Agent N │ │
79
+ │ ├──────────────┼──────────────┼──────────────┤ │
80
+ │ │ Own Section │ Own Section │ Own Section │ ← Pre-allocated │
81
+ │ │ plan.json │ plan.json │ plan.json │ ← Detailed plans │
82
+ │ └──────────────┴──────────────┴──────────────┘ │
83
+ │ │
84
+ │ Phase 3: Conflict Detection (Single Source) │
85
+ │ ├─ Parse plan-note.md (all sections) │
86
+ │ ├─ Detect file/dependency/strategy conflicts │
87
+ │ └─ Update plan-note.md conflict section │
88
+ │ │
89
+ │ Phase 4: Completion (No Merge) │
90
+ │ ├─ Generate plan.md (human-readable) │
91
+ │ └─ Ready for execution │
92
+ │ │
93
+ └─────────────────────────────────────────────────────────────────────────┘
94
+ ```
95
+
96
+ ## Output Structure
97
+
98
+ ```
99
+ .workflow/.planning/{CPLAN-slug-YYYY-MM-DD}/
100
+ ├── plan-note.md # Core: Requirements + Tasks + Conflicts
101
+ ├── requirement-analysis.json # Phase 1: Sub-domain assignments
102
+ ├── agents/ # Phase 2: Per-agent detailed plans
103
+ │ ├── {focus-area-1}/
104
+ │ │ ├── planning-context.md # Evidence + understanding
105
+ │ │ ├── plan.json # Plan overview with task_ids[] (NO embedded tasks[])
106
+ │ │ └── .task/ # Independent task files
107
+ │ │ ├── TASK-{ID}.json # Task file following task-schema.json
108
+ │ │ └── ...
109
+ │ ├── {focus-area-2}/
110
+ │ │ └── ...
111
+ │ └── {focus-area-N}/
112
+ │ └── ...
113
+ ├── conflicts.json # Phase 3: Conflict details
114
+ └── plan.md # Phase 4: Human-readable summary
115
+ ```
116
+
117
+ ## Implementation
118
+
119
+ ### Session Initialization
120
+
121
+ **Objective**: Create session context and directory structure for collaborative planning.
122
+
123
+ **Required Actions**:
124
+ 1. Extract task description from `$ARGUMENTS`
125
+ 2. Generate session ID with format: `CPLAN-{slug}-{date}`
126
+ - slug: lowercase, alphanumeric, max 30 chars
127
+ - date: YYYY-MM-DD (UTC+8)
128
+ 3. Define session folder: `.workflow/.planning/{session-id}`
129
+ 4. Parse command options:
130
+ - `--max-agents=N` (default: 5)
131
+ - `-y` or `--yes` for auto-approval mode
132
+ 5. Create directory structure: `{session-folder}/agents/`
133
+
134
+ **Session Variables**:
135
+ - `sessionId`: Unique session identifier
136
+ - `sessionFolder`: Base directory for all artifacts
137
+ - `maxAgents`: Maximum number of parallel agents
138
+ - `autoMode`: Boolean for auto-confirmation
139
+
140
+ ### Phase 1: Understanding & Template Creation
141
+
142
+ **Objective**: Analyze requirements and create the plan-note.md template with pre-allocated sections for parallel agents.
143
+
144
+ **Prerequisites**:
145
+ - Session initialized with valid sessionId and sessionFolder
146
+ - Task description available from $ARGUMENTS
147
+
148
+ **Guideline**: In Understanding phase, prioritize identifying latest documentation (README, design docs, architecture guides). When ambiguities exist, ask user for clarification instead of assuming interpretations.
149
+
150
+ **Workflow Steps**:
151
+
152
+ 1. **Initialize Progress Tracking**
153
+ - Create 4 todo items for workflow phases
154
+ - Set Phase 1 status to `in_progress`
155
+
156
+ 2. **Launch Understanding Agent**
157
+ - Agent type: `cli-lite-planning-agent`
158
+ - Execution mode: synchronous (run_in_background: false)
159
+
160
+ 3. **Agent Tasks**:
161
+ - **Identify Latest Documentation**: Search for and prioritize latest README, design docs, architecture guides
162
+ - **Understand Requirements**: Extract core objective, key points, constraints from task description and latest docs
163
+ - **Identify Ambiguities**: List any unclear points or multiple possible interpretations
164
+ - **Form Clarification Checklist**: Prepare questions for user if ambiguities found (use AskUserQuestion)
165
+ - **Split Sub-Domains**: Identify 2-{maxAgents} parallelizable focus areas
166
+ - **Create Plan Note**: Generate plan-note.md with pre-allocated sections
167
+
168
+ **Output Files**:
169
+
170
+ | File | Purpose |
171
+ |------|---------|
172
+ | `{sessionFolder}/plan-note.md` | Collaborative template with pre-allocated sections per agent |
173
+ | `{sessionFolder}/requirement-analysis.json` | Sub-domain assignments and TASK ID ranges |
174
+
175
+ **requirement-analysis.json Schema**:
176
+ - `session_id`: Session identifier
177
+ - `original_requirement`: Task description
178
+ - `complexity`: Low | Medium | High
179
+ - `sub_domains[]`: Array of focus areas with task_id_range and estimated_effort
180
+ - `total_agents`: Number of agents to spawn
181
+
182
+ **Success Criteria**:
183
+ - Latest documentation identified and referenced (if available)
184
+ - Ambiguities resolved via user clarification (if any found)
185
+ - 2-{maxAgents} clear sub-domains identified
186
+ - Each sub-domain can be planned independently
187
+ - Plan Note template includes all pre-allocated sections
188
+ - TASK ID ranges have no overlap (100 IDs per agent)
189
+ - Requirements understanding is comprehensive
190
+
191
+ **Completion**:
192
+ - Log created artifacts
193
+ - Update Phase 1 todo status to `completed`
194
+
195
+ **Agent Call**:
196
+ ```javascript
197
+ Task(
198
+ subagent_type="cli-lite-planning-agent",
199
+ run_in_background=false,
200
+ description="Understand requirements and create plan template",
201
+ prompt=`
202
+ ## Mission: Create Plan Note Template
203
+
204
+ ### Key Guidelines
205
+ 1. **Prioritize Latest Documentation**: Search for and reference latest README, design docs, architecture guides when available
206
+ 2. **Handle Ambiguities**: When requirement ambiguities exist, ask user for clarification (use AskUserQuestion) instead of assuming interpretations
207
+
208
+ ### Project Context (MANDATORY)
209
+ Read and incorporate:
210
+ - \`.workflow/project-tech.json\` (if exists): Technology stack, architecture
211
+ - \`.ccw/specs/*.md\` (if exists): Constraints, conventions -- apply as HARD CONSTRAINTS on sub-domain splitting and plan structure
212
+
213
+ ### Input Requirements
214
+ ${taskDescription}
215
+
216
+ ### Tasks
217
+ 1. **Understand Requirements**: Extract core objective, key points, constraints (reference latest docs when available)
218
+ 2. **Identify Ambiguities**: List any unclear points or multiple possible interpretations
219
+ 3. **Form Clarification Checklist**: Prepare questions for user if ambiguities found
220
+ 4. **Split Sub-Domains**: Identify 2-${maxAgents} parallelizable focus areas
221
+ 5. **Create Plan Note**: Generate plan-note.md with pre-allocated sections
222
+
223
+ ### Output Files
224
+
225
+ **File 1**: ${sessionFolder}/plan-note.md
226
+
227
+ Structure Requirements:
228
+ - YAML frontmatter: session_id, original_requirement, created_at, contributors, sub_domains, agent_sections, agent_task_id_ranges, status
229
+ - Section: ## 需求理解 (Core objectives, key points, constraints, split strategy)
230
+ - Section: ## 任务池 - {Focus Area 1} (Pre-allocated task section for agent 1, TASK-001 ~ TASK-100)
231
+ - Section: ## 任务池 - {Focus Area 2} (Pre-allocated task section for agent 2, TASK-101 ~ TASK-200)
232
+ - ... (One task pool section per sub-domain)
233
+ - Section: ## 依赖关系 (Auto-generated after all agents complete)
234
+ - Section: ## 冲突标记 (Populated in Phase 3)
235
+ - Section: ## 上下文证据 - {Focus Area 1} (Evidence for agent 1)
236
+ - Section: ## 上下文证据 - {Focus Area 2} (Evidence for agent 2)
237
+ - ... (One evidence section per sub-domain)
238
+
239
+ **File 2**: ${sessionFolder}/requirement-analysis.json
240
+ - session_id, original_requirement, complexity, sub_domains[], total_agents
241
+
242
+ ### Success Criteria
243
+ - [ ] 2-${maxAgents} clear sub-domains identified
244
+ - [ ] Each sub-domain can be planned independently
245
+ - [ ] Plan Note template includes all pre-allocated sections
246
+ - [ ] TASK ID ranges have no overlap (100 IDs per agent)
247
+ `
248
+ )
249
+ ```
250
+
251
+ ### Phase 2: Parallel Sub-Agent Execution
252
+
253
+ **Objective**: Launch parallel planning agents to fill their pre-allocated sections in plan-note.md.
254
+
255
+ **Prerequisites**:
256
+ - Phase 1 completed successfully
257
+ - `{sessionFolder}/requirement-analysis.json` exists with sub-domain definitions
258
+ - `{sessionFolder}/plan-note.md` template created
259
+
260
+ **Workflow Steps**:
261
+
262
+ 1. **Load Sub-Domain Configuration**
263
+ - Read `{sessionFolder}/requirement-analysis.json`
264
+ - Extract sub-domains array with focus_area, description, task_id_range
265
+
266
+ 2. **Update Progress Tracking**
267
+ - Set Phase 2 status to `in_progress`
268
+ - Add sub-todo for each agent
269
+
270
+ 3. **User Confirmation** (unless autoMode)
271
+ - Display identified sub-domains with descriptions
272
+ - Options: "开始规划" / "调整拆分" / "取消"
273
+ - Skip if autoMode enabled
274
+
275
+ 4. **Create Agent Directories**
276
+ - For each sub-domain: `{sessionFolder}/agents/{focus-area}/`
277
+
278
+ 5. **Launch Parallel Agents**
279
+ - Agent type: `cli-lite-planning-agent`
280
+ - Execution mode: synchronous (run_in_background: false)
281
+ - Launch ALL agents in parallel (single message with multiple Task calls)
282
+
283
+ **Per-Agent Context**:
284
+ - Focus area name and description
285
+ - Assigned TASK ID range (no overlap with other agents)
286
+ - Session ID and folder path
287
+
288
+ **Per-Agent Tasks**:
289
+
290
+ | Task | Output | Description |
291
+ |------|--------|-------------|
292
+ | Generate plan.json + .task/*.json | `{sessionFolder}/agents/{focus-area}/plan.json` + `.task/` | Two-layer output: plan overview + independent task files |
293
+ | Update plan-note.md | Sync to shared file | Fill pre-allocated task pool and evidence sections |
294
+
295
+ **Task Summary Format** (for plan-note.md):
296
+ - Task header: `### TASK-{ID}: {Title} [{focus-area}]`
297
+ - Status, Complexity, Dependencies
298
+ - Scope description
299
+ - Modification points with file:line references
300
+ - Conflict risk assessment
301
+
302
+ **Evidence Format** (for plan-note.md):
303
+ - Related files with relevance scores
304
+ - Existing patterns identified
305
+ - Constraints discovered
306
+
307
+ **Agent Execution Rules**:
308
+ - Each agent modifies ONLY its pre-allocated sections
309
+ - Use assigned TASK ID range exclusively
310
+ - No locking needed (exclusive sections)
311
+ - Include conflict_risk assessment for each task
312
+
313
+ **Completion**:
314
+ - Wait for all agents to complete
315
+ - Log generated artifacts for each agent
316
+ - Update Phase 2 todo status to `completed`
317
+
318
+ **User Confirmation** (unless autoMode):
319
+ ```javascript
320
+ if (!autoMode) {
321
+ AskUserQuestion({
322
+ questions: [{
323
+ question: `已识别 ${subDomains.length} 个子领域:\n${subDomains.map((s, i) => `${i+1}. ${s.focus_area}: ${s.description}`).join('\n')}\n\n确认开始并行规划?`,
324
+ header: "Confirm Split",
325
+ multiSelect: false,
326
+ options: [
327
+ { label: "开始规划", description: "启动并行sub-agent" },
328
+ { label: "调整拆分", description: "修改子领域划分" },
329
+ { label: "取消", description: "退出规划" }
330
+ ]
331
+ }]
332
+ })
333
+ }
334
+ ```
335
+
336
+ **Launch Parallel Agents** (single message, multiple Task calls):
337
+ ```javascript
338
+ // Create agent directories
339
+ subDomains.forEach(sub => {
340
+ Bash(`mkdir -p ${sessionFolder}/agents/${sub.focus_area}`)
341
+ })
342
+
343
+ // Launch all agents in parallel
344
+ subDomains.map(sub =>
345
+ Task(
346
+ subagent_type="cli-lite-planning-agent",
347
+ run_in_background=false,
348
+ description=`Plan: ${sub.focus_area}`,
349
+ prompt=`
350
+ ## Sub-Agent Context
351
+
352
+ **Focus Area**: ${sub.focus_area}
353
+ **Description**: ${sub.description}
354
+ **TASK ID Range**: ${sub.task_id_range[0]}-${sub.task_id_range[1]}
355
+ **Session**: ${sessionId}
356
+
357
+ ### Project Context (MANDATORY)
358
+ Read and incorporate:
359
+ - \`.workflow/project-tech.json\` (if exists): Technology stack, architecture
360
+ - \`.ccw/specs/*.md\` (if exists): Constraints, conventions -- apply as HARD CONSTRAINTS
361
+
362
+ ## Dual Output Tasks
363
+
364
+ ### Task 1: Generate Two-Layer Plan Output
365
+ Output: ${sessionFolder}/agents/${sub.focus_area}/plan.json
366
+ Output: ${sessionFolder}/agents/${sub.focus_area}/.task/TASK-*.json
367
+ Schema (plan): ~/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json
368
+ Schema (tasks): ~/.ccw/workflows/cli-templates/schemas/task-schema.json
369
+
370
+ ### Task 2: Sync Summary to plan-note.md
371
+
372
+ **Locate Your Sections**:
373
+ - Task Pool: "## 任务池 - ${toTitleCase(sub.focus_area)}"
374
+ - Evidence: "## 上下文证据 - ${toTitleCase(sub.focus_area)}"
375
+
376
+ **Task Summary Format**:
377
+ - Task header: ### TASK-${sub.task_id_range[0]}: Task Title [${sub.focus_area}]
378
+ - Fields: 状态, 复杂度, 依赖, 范围, 修改点, 冲突风险
379
+
380
+ **Evidence Format**:
381
+ - 相关文件, 现有模式, 约束
382
+
383
+ ## Execution Steps
384
+ 1. Create .task/ directory: mkdir -p ${sessionFolder}/agents/${sub.focus_area}/.task
385
+ 2. Generate individual task files in .task/TASK-*.json following task-schema.json
386
+ 3. Generate plan.json with task_ids[] referencing .task/ files (NO embedded tasks[])
387
+ 4. Extract summary from .task/*.json files
388
+ 5. Read ${sessionFolder}/plan-note.md
389
+ 6. Locate and replace your task pool section
390
+ 7. Locate and replace your evidence section
391
+ 8. Write back plan-note.md
392
+
393
+ ## Important
394
+ - Only modify your pre-allocated sections
395
+ - Use assigned TASK ID range: ${sub.task_id_range[0]}-${sub.task_id_range[1]}
396
+ `
397
+ )
398
+ )
399
+ ```
400
+
401
+ ### Phase 3: Conflict Detection
402
+
403
+ **Objective**: Analyze plan-note.md for conflicts across all agent contributions without merging files.
404
+
405
+ **Prerequisites**:
406
+ - Phase 2 completed successfully
407
+ - All agents have updated plan-note.md with their sections
408
+ - `{sessionFolder}/plan-note.md` contains all task and evidence sections
409
+
410
+ **Workflow Steps**:
411
+
412
+ 1. **Update Progress Tracking**
413
+ - Set Phase 3 status to `in_progress`
414
+
415
+ 2. **Parse Plan Note**
416
+ - Read `{sessionFolder}/plan-note.md`
417
+ - Extract YAML frontmatter (session metadata)
418
+ - Parse markdown sections by heading levels
419
+ - Identify all "任务池" sections
420
+
421
+ 3. **Extract All Tasks**
422
+ - For each "任务池" section:
423
+ - Extract tasks matching pattern: `### TASK-{ID}: {Title} [{author}]`
424
+ - Parse task details: status, complexity, dependencies, modification points, conflict risk
425
+ - Consolidate into single task list
426
+
427
+ 4. **Detect Conflicts**
428
+
429
+ **File Conflicts**:
430
+ - Group modification points by file:location
431
+ - Identify locations modified by multiple agents
432
+ - Record: severity=high, tasks involved, agents involved, suggested resolution
433
+
434
+ **Dependency Cycles**:
435
+ - Build dependency graph from task dependencies
436
+ - Detect cycles using depth-first search
437
+ - Record: severity=critical, cycle path, suggested resolution
438
+
439
+ **Strategy Conflicts**:
440
+ - Group tasks by files they modify
441
+ - Identify files with high/medium conflict risk from multiple agents
442
+ - Record: severity=medium, tasks involved, agents involved, suggested resolution
443
+
444
+ 5. **Generate Conflict Artifacts**
445
+
446
+ **conflicts.json**:
447
+ - Write to `{sessionFolder}/conflicts.json`
448
+ - Include: detected_at, total_tasks, total_agents, conflicts array
449
+ - Each conflict: type, severity, tasks_involved, description, suggested_resolution
450
+
451
+ **Update plan-note.md**:
452
+ - Locate "## 冲突标记" section
453
+ - Generate markdown summary of conflicts
454
+ - Replace section content with conflict markdown
455
+
456
+ 6. **Completion**
457
+ - Log conflict detection summary
458
+ - Display conflict details if any found
459
+ - Update Phase 3 todo status to `completed`
460
+
461
+ **Conflict Types**:
462
+
463
+ | Type | Severity | Detection Logic |
464
+ |------|----------|-----------------|
465
+ | file_conflict | high | Same file:location modified by multiple agents |
466
+ | dependency_cycle | critical | Circular dependencies in task graph |
467
+ | strategy_conflict | medium | Multiple high-risk tasks in same file from different agents |
468
+
469
+ **Conflict Detection Functions**:
470
+
471
+ **parsePlanNote(markdown)**:
472
+ - Input: Raw markdown content of plan-note.md
473
+ - Process:
474
+ - Extract YAML frontmatter between `---` markers
475
+ - Parse frontmatter as YAML to get session metadata
476
+ - Scan for heading patterns `^(#{2,})\s+(.+)$`
477
+ - Build sections array with: level, heading, start position, content
478
+ - Output: `{ frontmatter: object, sections: array }`
479
+
480
+ **extractTasksFromSection(content, sectionHeading)**:
481
+ - Input: Section content text, section heading for attribution
482
+ - Process:
483
+ - Match task pattern: `### (TASK-\d+):\s+(.+?)\s+\[(.+?)\]`
484
+ - For each match: extract taskId, title, author
485
+ - Call parseTaskDetails for additional fields
486
+ - Output: Array of task objects with id, title, author, source_section, ...details
487
+
488
+ **parseTaskDetails(content)**:
489
+ - Input: Task content block
490
+ - Process:
491
+ - Extract fields via regex patterns:
492
+ - `**状态**:\s*(.+)` → status
493
+ - `**复杂度**:\s*(.+)` → complexity
494
+ - `**依赖**:\s*(.+)` → depends_on (extract TASK-\d+ references)
495
+ - `**冲突风险**:\s*(.+)` → conflict_risk
496
+ - Extract modification points: `-\s+\`([^`]+):\s*([^`]+)\`:\s*(.+)` → file, location, summary
497
+ - Output: Details object with status, complexity, depends_on[], modification_points[], conflict_risk
498
+
499
+ **detectFileConflicts(tasks)**:
500
+ - Input: All tasks array
501
+ - Process:
502
+ - Build fileMap: `{ "file:location": [{ task_id, task_title, source_agent, change }] }`
503
+ - For each location with multiple modifications from different agents:
504
+ - Create conflict with type='file_conflict', severity='high'
505
+ - Include: location, tasks_involved, agents_involved, modifications
506
+ - Suggested resolution: 'Coordinate modification order or merge changes'
507
+ - Output: Array of file conflict objects
508
+
509
+ **detectDependencyCycles(tasks)**:
510
+ - Input: All tasks array
511
+ - Process:
512
+ - Build dependency graph: `{ taskId: [dependsOn_taskIds] }`
513
+ - Use DFS with recursion stack to detect cycles
514
+ - For each cycle found:
515
+ - Create conflict with type='dependency_cycle', severity='critical'
516
+ - Include: cycle path as tasks_involved
517
+ - Suggested resolution: 'Remove or reorganize dependencies'
518
+ - Output: Array of dependency cycle conflict objects
519
+
520
+ **detectStrategyConflicts(tasks)**:
521
+ - Input: All tasks array
522
+ - Process:
523
+ - Group tasks by files they modify
524
+ - For each file with tasks from multiple agents:
525
+ - Filter for high/medium conflict_risk tasks
526
+ - If >1 high-risk tasks from different agents:
527
+ - Create conflict with type='strategy_conflict', severity='medium'
528
+ - Include: file, tasks_involved, agents_involved
529
+ - Suggested resolution: 'Review approaches and align on single strategy'
530
+ - Output: Array of strategy conflict objects
531
+
532
+ **generateConflictMarkdown(conflicts)**:
533
+ - Input: Array of conflict objects
534
+ - Process:
535
+ - If empty: return '✅ 无冲突检测到'
536
+ - For each conflict:
537
+ - Generate header: `### CONFLICT-{padded_index}: {description}`
538
+ - Add fields: 严重程度, 涉及任务, 涉及Agent
539
+ - Add 问题详情 based on conflict type
540
+ - Add 建议解决方案
541
+ - Add 决策状态: [ ] 待解决
542
+ - Output: Markdown string for plan-note.md "## 冲突标记" section
543
+
544
+ **replaceSectionContent(markdown, sectionHeading, newContent)**:
545
+ - Input: Original markdown, target section heading, new content
546
+ - Process:
547
+ - Find section heading position via regex
548
+ - Find next heading of same or higher level
549
+ - Replace content between heading and next section
550
+ - If section not found: append at end
551
+ - Output: Updated markdown string
552
+
553
+ ### Phase 4: Completion
554
+
555
+ **Objective**: Generate human-readable plan summary and finalize workflow.
556
+
557
+ **Prerequisites**:
558
+ - Phase 3 completed successfully
559
+ - Conflicts detected and documented in plan-note.md
560
+ - All artifacts generated
561
+
562
+ **Workflow Steps**:
563
+
564
+ 1. **Update Progress Tracking**
565
+ - Set Phase 4 status to `in_progress`
566
+
567
+ 2. **Read Final State**
568
+ - Read `{sessionFolder}/plan-note.md`
569
+ - Extract frontmatter metadata
570
+ - Load conflicts from Phase 3
571
+
572
+ 3. **Generate plan.md**
573
+ - Create human-readable summary including:
574
+ - Session metadata
575
+ - Requirements understanding
576
+ - Sub-domain breakdown
577
+ - Task overview by focus area
578
+ - Conflict report
579
+ - Execution instructions
580
+
581
+ 4. **Write Summary File**
582
+ - Write to `{sessionFolder}/plan.md`
583
+
584
+ 5. **Display Completion Summary**
585
+ - Session statistics
586
+ - File structure
587
+ - Execution command
588
+ - Conflict status
589
+
590
+ 6. **Sync Session State**
591
+ - Execute: `/workflow:session:sync -y "Plan complete: ${subDomains.length} domains, ${allTasks.length} tasks"`
592
+ - Updates specs/*.md with planning insights and project-tech.json with planning session entry
593
+
594
+ 7. **Update Todo**
595
+ - Set Phase 4 status to `completed`
596
+
597
+ **plan.md Structure**:
598
+
599
+ | Section | Content |
600
+ |---------|---------|
601
+ | Header | Session ID, created time, original requirement |
602
+ | Requirements | Copy from plan-note.md "## 需求理解" section |
603
+ | Sub-Domain Split | List each focus area with description and task ID range |
604
+ | Task Overview | Tasks grouped by focus area with complexity and dependencies |
605
+ | Conflict Report | Summary of detected conflicts or "无冲突" |
606
+ | Execution | Command to execute the plan |
607
+
608
+ **Required Function** (semantic description):
609
+ - **generateHumanReadablePlan**: Extract sections from plan-note.md and format as readable plan.md with session info, requirements, tasks, and conflicts
610
+
611
+ ## Configuration
612
+
613
+ | Flag | Default | Description |
614
+ |------|---------|-------------|
615
+ | `--max-agents` | 5 | Maximum sub-agents to spawn |
616
+ | `-y, --yes` | false | Auto-confirm all decisions |
617
+
618
+ ## Error Handling
619
+
620
+ | Error | Resolution |
621
+ |-------|------------|
622
+ | Understanding agent fails | Retry once, provide more context |
623
+ | Planning agent fails | Skip failed agent, continue with others |
624
+ | Section not found in plan-note | Agent creates section (defensive) |
625
+ | Conflict detection fails | Continue with empty conflicts |
626
+
627
+
628
+ ## Best Practices
629
+
630
+ 1. **Clear Requirements**: Detailed requirements → better sub-domain splitting
631
+ 2. **Reference Latest Documentation**: Understanding agent should prioritize identifying and referencing latest docs (README, design docs, architecture guides)
632
+ 3. **Ask When Uncertain**: When ambiguities or multiple interpretations exist, ask user for clarification instead of assuming
633
+ 4. **Review Plan Note**: Check plan-note.md before execution
634
+ 5. **Resolve Conflicts**: Address high/critical conflicts before execution
635
+ 6. **Inspect Details**: Use agents/{focus-area}/plan.json for deep dive
636
+
637
+ ---
638
+
639
+ **Now execute collaborative-plan-with-file for**: $ARGUMENTS