claude-code-workflow 6.3.37 → 6.3.39
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.
- package/.claude/commands/workflow/lite-execute.md +2 -0
- package/.codex/agents/action-planning-agent.md +885 -0
- package/.codex/agents/ccw-loop-b-complete.md +227 -0
- package/.codex/agents/ccw-loop-b-debug.md +172 -0
- package/.codex/agents/ccw-loop-b-develop.md +147 -0
- package/.codex/agents/ccw-loop-b-init.md +82 -0
- package/.codex/agents/ccw-loop-b-validate.md +204 -0
- package/.codex/agents/ccw-loop-executor.md +260 -0
- package/.codex/agents/cli-discuss-agent.md +391 -0
- package/.codex/agents/cli-execution-agent.md +333 -0
- package/.codex/agents/cli-explore-agent.md +186 -0
- package/.codex/agents/cli-lite-planning-agent.md +736 -0
- package/.codex/agents/cli-planning-agent.md +562 -0
- package/.codex/agents/code-developer.md +408 -0
- package/.codex/agents/conceptual-planning-agent.md +321 -0
- package/.codex/agents/context-search-agent.md +585 -0
- package/.codex/agents/debug-explore-agent.md +436 -0
- package/.codex/agents/doc-generator.md +334 -0
- package/.codex/agents/issue-plan-agent.md +417 -0
- package/.codex/agents/issue-queue-agent.md +311 -0
- package/.codex/agents/memory-bridge.md +96 -0
- package/.codex/agents/test-context-search-agent.md +402 -0
- package/.codex/agents/test-fix-agent.md +359 -0
- package/.codex/agents/ui-design-agent.md +595 -0
- package/.codex/agents/universal-executor.md +135 -0
- package/.codex/prompts/clean.md +409 -0
- package/.codex/prompts/issue-discover-by-prompt.md +364 -0
- package/.codex/prompts/issue-discover.md +261 -0
- package/.codex/prompts/issue-execute.md +10 -0
- package/.codex/prompts/issue-new.md +285 -0
- package/.codex/prompts/issue-plan.md +161 -63
- package/.codex/prompts/issue-queue.md +298 -288
- package/.codex/prompts/lite-execute.md +627 -133
- package/.codex/prompts/lite-fix.md +670 -0
- package/.codex/prompts/lite-plan-a.md +337 -0
- package/.codex/prompts/lite-plan-b.md +485 -0
- package/.codex/prompts/{lite-plan.md → lite-plan-c.md} +601 -469
- package/.codex/skills/ccw-loop/README.md +171 -0
- package/.codex/skills/ccw-loop/SKILL.md +349 -0
- package/.codex/skills/ccw-loop/phases/actions/action-complete.md +269 -0
- package/.codex/skills/ccw-loop/phases/actions/action-debug.md +286 -0
- package/.codex/skills/ccw-loop/phases/actions/action-develop.md +183 -0
- package/.codex/skills/ccw-loop/phases/actions/action-init.md +164 -0
- package/.codex/skills/ccw-loop/phases/actions/action-menu.md +205 -0
- package/.codex/skills/ccw-loop/phases/actions/action-validate.md +250 -0
- package/.codex/skills/ccw-loop/phases/orchestrator.md +416 -0
- package/.codex/skills/ccw-loop/phases/state-schema.md +388 -0
- package/.codex/skills/ccw-loop/specs/action-catalog.md +182 -0
- package/.codex/skills/ccw-loop-b/README.md +301 -0
- package/.codex/skills/ccw-loop-b/SKILL.md +322 -0
- package/.codex/skills/ccw-loop-b/phases/orchestrator.md +257 -0
- package/.codex/skills/ccw-loop-b/phases/state-schema.md +181 -0
- package/.codex/skills/ccw-loop-b/specs/action-catalog.md +383 -0
- package/.codex/skills/parallel-dev-cycle/README.md +382 -0
- package/.codex/skills/parallel-dev-cycle/SKILL.md +512 -0
- package/.codex/skills/parallel-dev-cycle/phases/agents/code-developer.md +242 -0
- package/.codex/skills/parallel-dev-cycle/phases/agents/exploration-planner.md +285 -0
- package/.codex/skills/parallel-dev-cycle/phases/agents/requirements-analyst.md +285 -0
- package/.codex/skills/parallel-dev-cycle/phases/agents/validation-archivist.md +381 -0
- package/.codex/skills/parallel-dev-cycle/phases/orchestrator.md +696 -0
- package/.codex/skills/parallel-dev-cycle/phases/state-schema.md +436 -0
- package/.codex/skills/parallel-dev-cycle/specs/communication-optimization.md +423 -0
- package/.codex/skills/parallel-dev-cycle/specs/coordination-protocol.md +391 -0
- package/.codex/skills/parallel-dev-cycle/specs/versioning-strategy.md +330 -0
- package/ccw/dist/cli.d.ts.map +1 -1
- package/ccw/dist/cli.js +4 -0
- package/ccw/dist/cli.js.map +1 -1
- package/ccw/dist/commands/install.d.ts.map +1 -1
- package/ccw/dist/commands/install.js +39 -8
- package/ccw/dist/commands/install.js.map +1 -1
- package/ccw/dist/commands/issue.d.ts +3 -0
- package/ccw/dist/commands/issue.d.ts.map +1 -1
- package/ccw/dist/commands/issue.js +107 -0
- package/ccw/dist/commands/issue.js.map +1 -1
- package/ccw/dist/commands/upgrade.js +1 -1
- package/ccw/dist/commands/upgrade.js.map +1 -1
- package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
- package/ccw/dist/config/litellm-api-config-manager.js +3 -2
- package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
- package/ccw/dist/core/memory-embedder-bridge.d.ts.map +1 -1
- package/ccw/dist/core/memory-embedder-bridge.js +2 -5
- package/ccw/dist/core/memory-embedder-bridge.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -1
- package/ccw/dist/core/routes/codexlens/config-handlers.js +7 -6
- package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -1
- package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts.map +1 -1
- package/ccw/dist/core/routes/codexlens/semantic-handlers.js +2 -2
- package/ccw/dist/core/routes/codexlens/semantic-handlers.js.map +1 -1
- package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/graph-routes.js +17 -2
- package/ccw/dist/core/routes/graph-routes.js.map +1 -1
- package/ccw/dist/core/routes/issue-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/issue-routes.js +280 -33
- package/ccw/dist/core/routes/issue-routes.js.map +1 -1
- package/ccw/dist/core/routes/loop-v2-routes.d.ts +9 -0
- package/ccw/dist/core/routes/loop-v2-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/loop-v2-routes.js +56 -4
- package/ccw/dist/core/routes/loop-v2-routes.js.map +1 -1
- package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/system-routes.js +3 -2
- package/ccw/dist/core/routes/system-routes.js.map +1 -1
- package/ccw/dist/core/server.d.ts.map +1 -1
- package/ccw/dist/core/server.js +5 -3
- package/ccw/dist/core/server.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +4 -3
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-config-manager.d.ts +1 -0
- package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
- package/ccw/dist/tools/cli-config-manager.js +2 -1
- package/ccw/dist/tools/cli-config-manager.js.map +1 -1
- package/ccw/dist/tools/codex-lens-lsp.d.ts.map +1 -1
- package/ccw/dist/tools/codex-lens-lsp.js +2 -5
- package/ccw/dist/tools/codex-lens-lsp.js.map +1 -1
- package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
- package/ccw/dist/tools/codex-lens.js +22 -32
- package/ccw/dist/tools/codex-lens.js.map +1 -1
- package/ccw/dist/tools/litellm-client.d.ts +6 -0
- package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
- package/ccw/dist/tools/litellm-client.js +15 -2
- package/ccw/dist/tools/litellm-client.js.map +1 -1
- package/ccw/dist/tools/loop-task-manager.d.ts +13 -2
- package/ccw/dist/tools/loop-task-manager.d.ts.map +1 -1
- package/ccw/dist/tools/loop-task-manager.js.map +1 -1
- package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -1
- package/ccw/dist/tools/native-session-discovery.js +35 -7
- package/ccw/dist/tools/native-session-discovery.js.map +1 -1
- package/ccw/dist/utils/codexlens-path.d.ts +36 -0
- package/ccw/dist/utils/codexlens-path.d.ts.map +1 -0
- package/ccw/dist/utils/codexlens-path.js +56 -0
- package/ccw/dist/utils/codexlens-path.js.map +1 -0
- package/ccw/dist/utils/uv-manager.d.ts.map +1 -1
- package/ccw/dist/utils/uv-manager.js +3 -2
- package/ccw/dist/utils/uv-manager.js.map +1 -1
- package/ccw/src/cli.ts +4 -0
- package/ccw/src/commands/install.ts +51 -8
- package/ccw/src/commands/issue.ts +119 -0
- package/ccw/src/commands/upgrade.ts +1 -1
- package/ccw/src/config/litellm-api-config-manager.ts +3 -2
- package/ccw/src/core/memory-embedder-bridge.ts +2 -6
- package/ccw/src/core/routes/cli-routes.ts +1 -1
- package/ccw/src/core/routes/codexlens/config-handlers.ts +7 -6
- package/ccw/src/core/routes/codexlens/semantic-handlers.ts +2 -2
- package/ccw/src/core/routes/graph-routes.ts +18 -2
- package/ccw/src/core/routes/issue-routes.ts +308 -33
- package/ccw/src/core/routes/loop-v2-routes.ts +64 -6
- package/ccw/src/core/routes/system-routes.ts +3 -2
- package/ccw/src/core/server.ts +6 -3
- package/ccw/src/templates/dashboard-css/02-session.css +2 -0
- package/ccw/src/templates/dashboard-css/04-lite-tasks.css +103 -1
- package/ccw/src/templates/dashboard-css/32-issue-manager.css +32 -0
- package/ccw/src/templates/dashboard-js/components/cli-history.js +48 -48
- package/ccw/src/templates/dashboard-js/components/navigation.js +6 -0
- package/ccw/src/templates/dashboard-js/components/notifications.js +6 -0
- package/ccw/src/templates/dashboard-js/components/version-check.js +38 -0
- package/ccw/src/templates/dashboard-js/i18n.js +126 -0
- package/ccw/src/templates/dashboard-js/state.js +2 -0
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +1 -1
- package/ccw/src/templates/dashboard-js/views/issue-manager.js +183 -1
- package/ccw/src/templates/dashboard-js/views/lite-tasks.js +55 -11
- package/ccw/src/templates/dashboard-js/views/loop-monitor.js +112 -11
- package/ccw/src/templates/dashboard.html +48 -2
- package/ccw/src/tools/claude-cli-tools.ts +4 -3
- package/ccw/src/tools/cli-config-manager.ts +3 -1
- package/ccw/src/tools/codex-lens-lsp.ts +2 -5
- package/ccw/src/tools/codex-lens.ts +27 -38
- package/ccw/src/tools/litellm-client.ts +16 -2
- package/ccw/src/tools/loop-task-manager.ts +13 -2
- package/ccw/src/tools/native-session-discovery.ts +38 -7
- package/ccw/src/utils/codexlens-path.ts +60 -0
- package/ccw/src/utils/uv-manager.ts +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# CCW Loop-B: Hybrid Orchestrator Pattern
|
|
2
|
+
|
|
3
|
+
Iterative development workflow using coordinator + specialized workers architecture.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
CCW Loop-B implements a flexible orchestration pattern:
|
|
8
|
+
- **Coordinator**: Main agent managing state, user interaction, worker scheduling
|
|
9
|
+
- **Workers**: Specialized agents (init, develop, debug, validate, complete)
|
|
10
|
+
- **Modes**: Interactive / Auto / Parallel execution
|
|
11
|
+
|
|
12
|
+
## Architecture
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Coordinator (Main Agent)
|
|
16
|
+
|
|
|
17
|
+
+-- Spawns Workers
|
|
18
|
+
| - ccw-loop-b-init.md
|
|
19
|
+
| - ccw-loop-b-develop.md
|
|
20
|
+
| - ccw-loop-b-debug.md
|
|
21
|
+
| - ccw-loop-b-validate.md
|
|
22
|
+
| - ccw-loop-b-complete.md
|
|
23
|
+
|
|
|
24
|
+
+-- Batch Wait (parallel mode)
|
|
25
|
+
+-- Sequential Wait (auto/interactive)
|
|
26
|
+
+-- State Management
|
|
27
|
+
+-- User Interaction
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Subagent API
|
|
31
|
+
|
|
32
|
+
Core APIs for worker orchestration:
|
|
33
|
+
|
|
34
|
+
| API | 作用 |
|
|
35
|
+
|-----|------|
|
|
36
|
+
| `spawn_agent({ message })` | 创建 worker,返回 `agent_id` |
|
|
37
|
+
| `wait({ ids, timeout_ms })` | 等待结果(唯一取结果入口) |
|
|
38
|
+
| `send_input({ id, message })` | 继续交互 |
|
|
39
|
+
| `close_agent({ id })` | 关闭回收 |
|
|
40
|
+
|
|
41
|
+
**可用模式**: 单 agent 深度交互 / 多 agent 并行 / 混合模式
|
|
42
|
+
|
|
43
|
+
## Execution Modes
|
|
44
|
+
|
|
45
|
+
### Interactive Mode (default)
|
|
46
|
+
|
|
47
|
+
Coordinator displays menu, user selects action, spawns corresponding worker.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
/ccw-loop-b TASK="Implement feature X"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Flow**:
|
|
54
|
+
1. Init: Parse task, create breakdown
|
|
55
|
+
2. Menu: Show options to user
|
|
56
|
+
3. User selects action (develop/debug/validate)
|
|
57
|
+
4. Spawn worker for selected action
|
|
58
|
+
5. Wait for result
|
|
59
|
+
6. Display result, back to menu
|
|
60
|
+
7. Repeat until complete
|
|
61
|
+
|
|
62
|
+
### Auto Mode
|
|
63
|
+
|
|
64
|
+
Automated sequential execution following predefined workflow.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
/ccw-loop-b --mode=auto TASK="Fix bug Y"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Flow**:
|
|
71
|
+
1. Init → 2. Develop → 3. Validate → 4. Complete
|
|
72
|
+
|
|
73
|
+
If issues found: loop back to Debug → Develop → Validate
|
|
74
|
+
|
|
75
|
+
### Parallel Mode
|
|
76
|
+
|
|
77
|
+
Spawn multiple workers simultaneously, batch wait for results.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
/ccw-loop-b --mode=parallel TASK="Analyze module Z"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Flow**:
|
|
84
|
+
1. Init: Create analysis plan
|
|
85
|
+
2. Spawn workers in parallel: [develop, debug, validate]
|
|
86
|
+
3. Batch wait: `wait({ ids: [w1, w2, w3] })`
|
|
87
|
+
4. Merge results
|
|
88
|
+
5. Coordinator decides next action
|
|
89
|
+
6. Complete
|
|
90
|
+
|
|
91
|
+
## Session Structure
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
.workflow/.loop/
|
|
95
|
+
+-- {loopId}.json # Master state
|
|
96
|
+
+-- {loopId}.workers/ # Worker outputs
|
|
97
|
+
| +-- init.output.json
|
|
98
|
+
| +-- develop.output.json
|
|
99
|
+
| +-- debug.output.json
|
|
100
|
+
| +-- validate.output.json
|
|
101
|
+
| +-- complete.output.json
|
|
102
|
+
+-- {loopId}.progress/ # Human-readable logs
|
|
103
|
+
+-- develop.md
|
|
104
|
+
+-- debug.md
|
|
105
|
+
+-- validate.md
|
|
106
|
+
+-- summary.md
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Worker Responsibilities
|
|
110
|
+
|
|
111
|
+
| Worker | Role | Specialization |
|
|
112
|
+
|--------|------|----------------|
|
|
113
|
+
| **init** | Session initialization | Task parsing, breakdown, planning |
|
|
114
|
+
| **develop** | Code implementation | File operations, pattern matching, incremental development |
|
|
115
|
+
| **debug** | Problem diagnosis | Root cause analysis, hypothesis testing, fix recommendations |
|
|
116
|
+
| **validate** | Testing & verification | Test execution, coverage analysis, quality gates |
|
|
117
|
+
| **complete** | Session finalization | Summary generation, commit preparation, cleanup |
|
|
118
|
+
|
|
119
|
+
## Usage Examples
|
|
120
|
+
|
|
121
|
+
### Example 1: Simple Feature Implementation
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
/ccw-loop-b TASK="Add user logout function"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Auto flow**:
|
|
128
|
+
- Init: Parse requirements
|
|
129
|
+
- Develop: Implement logout in `src/auth.ts`
|
|
130
|
+
- Validate: Run tests
|
|
131
|
+
- Complete: Generate commit message
|
|
132
|
+
|
|
133
|
+
### Example 2: Bug Investigation
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
/ccw-loop-b TASK="Fix memory leak in WebSocket handler"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Interactive flow**:
|
|
140
|
+
1. Init: Parse issue
|
|
141
|
+
2. User selects "debug" → Spawn debug worker
|
|
142
|
+
3. Debug: Root cause analysis → recommends fix
|
|
143
|
+
4. User selects "develop" → Apply fix
|
|
144
|
+
5. User selects "validate" → Verify fix works
|
|
145
|
+
6. User selects "complete" → Generate summary
|
|
146
|
+
|
|
147
|
+
### Example 3: Comprehensive Analysis
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
/ccw-loop-b --mode=parallel TASK="Analyze payment module for improvements"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Parallel flow**:
|
|
154
|
+
- Spawn [develop, debug, validate] workers simultaneously
|
|
155
|
+
- Develop: Analyze code quality and patterns
|
|
156
|
+
- Debug: Identify potential issues
|
|
157
|
+
- Validate: Check test coverage
|
|
158
|
+
- Wait for all three to complete
|
|
159
|
+
- Merge findings into comprehensive report
|
|
160
|
+
|
|
161
|
+
### Example 4: Resume Existing Loop
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
/ccw-loop-b --loop-id=loop-b-20260122-abc123
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Continues from previous state, respects status (running/paused).
|
|
168
|
+
|
|
169
|
+
## Key Features
|
|
170
|
+
|
|
171
|
+
### 1. Worker Specialization
|
|
172
|
+
|
|
173
|
+
Each worker focuses on one domain:
|
|
174
|
+
- **No overlap**: Clear boundaries between workers
|
|
175
|
+
- **Reusable**: Same worker for different tasks
|
|
176
|
+
- **Composable**: Combine workers for complex workflows
|
|
177
|
+
|
|
178
|
+
### 2. Flexible Coordination
|
|
179
|
+
|
|
180
|
+
Coordinator adapts to mode:
|
|
181
|
+
- **Interactive**: Menu-driven, user controls flow
|
|
182
|
+
- **Auto**: Predetermined sequence
|
|
183
|
+
- **Parallel**: Concurrent execution with batch wait
|
|
184
|
+
|
|
185
|
+
### 3. State Management
|
|
186
|
+
|
|
187
|
+
Unified state at `.workflow/.loop/{loopId}.json`:
|
|
188
|
+
- **API compatible**: Works with CCW API
|
|
189
|
+
- **Extension fields**: Skill-specific data in `skill_state`
|
|
190
|
+
- **Worker outputs**: Structured JSON for each action
|
|
191
|
+
|
|
192
|
+
### 4. Progress Tracking
|
|
193
|
+
|
|
194
|
+
Human-readable logs:
|
|
195
|
+
- **Per-worker progress**: `{action}.md` files
|
|
196
|
+
- **Summary**: Consolidated achievements
|
|
197
|
+
- **Commit-ready**: Formatted commit messages
|
|
198
|
+
|
|
199
|
+
## Best Practices
|
|
200
|
+
|
|
201
|
+
1. **Start with Init**: Always initialize before execution
|
|
202
|
+
2. **Use appropriate mode**:
|
|
203
|
+
- Interactive: Complex tasks needing user decisions
|
|
204
|
+
- Auto: Well-defined workflows
|
|
205
|
+
- Parallel: Independent analysis tasks
|
|
206
|
+
3. **Clean up workers**: `close_agent()` after each worker completes
|
|
207
|
+
4. **Batch wait wisely**: Use in parallel mode for efficiency
|
|
208
|
+
5. **Track progress**: Document in progress files
|
|
209
|
+
6. **Validate often**: After each develop phase
|
|
210
|
+
|
|
211
|
+
## Implementation Patterns
|
|
212
|
+
|
|
213
|
+
### Pattern 1: Single Worker Deep Interaction
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
const workerId = spawn_agent({ message: workerPrompt })
|
|
217
|
+
const result1 = wait({ ids: [workerId] })
|
|
218
|
+
|
|
219
|
+
// Continue with same worker
|
|
220
|
+
send_input({ id: workerId, message: "Continue with next task" })
|
|
221
|
+
const result2 = wait({ ids: [workerId] })
|
|
222
|
+
|
|
223
|
+
close_agent({ id: workerId })
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Pattern 2: Multi-Worker Parallel
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const workers = {
|
|
230
|
+
develop: spawn_agent({ message: developPrompt }),
|
|
231
|
+
debug: spawn_agent({ message: debugPrompt }),
|
|
232
|
+
validate: spawn_agent({ message: validatePrompt })
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Batch wait
|
|
236
|
+
const results = wait({ ids: Object.values(workers), timeout_ms: 900000 })
|
|
237
|
+
|
|
238
|
+
// Process all results
|
|
239
|
+
Object.values(workers).forEach(id => close_agent({ id }))
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Pattern 3: Sequential Worker Chain
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
const actions = ['init', 'develop', 'validate', 'complete']
|
|
246
|
+
|
|
247
|
+
for (const action of actions) {
|
|
248
|
+
const workerId = spawn_agent({ message: buildPrompt(action) })
|
|
249
|
+
const result = wait({ ids: [workerId] })
|
|
250
|
+
|
|
251
|
+
updateState(action, result)
|
|
252
|
+
close_agent({ id: workerId })
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Error Handling
|
|
257
|
+
|
|
258
|
+
| Error | Recovery |
|
|
259
|
+
|-------|----------|
|
|
260
|
+
| Worker timeout | `send_input` request convergence |
|
|
261
|
+
| Worker fails | Log error, coordinator decides retry strategy |
|
|
262
|
+
| Partial results | Use completed workers, mark incomplete |
|
|
263
|
+
| State corruption | Rebuild from progress files |
|
|
264
|
+
|
|
265
|
+
## File Structure
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
.codex/skills/ccw-loop-b/
|
|
269
|
+
+-- SKILL.md # Entry point
|
|
270
|
+
+-- README.md # This file
|
|
271
|
+
+-- phases/
|
|
272
|
+
| +-- state-schema.md # State structure definition
|
|
273
|
+
+-- specs/
|
|
274
|
+
+-- action-catalog.md # Action reference
|
|
275
|
+
|
|
276
|
+
.codex/agents/
|
|
277
|
+
+-- ccw-loop-b-init.md # Worker: Init
|
|
278
|
+
+-- ccw-loop-b-develop.md # Worker: Develop
|
|
279
|
+
+-- ccw-loop-b-debug.md # Worker: Debug
|
|
280
|
+
+-- ccw-loop-b-validate.md # Worker: Validate
|
|
281
|
+
+-- ccw-loop-b-complete.md # Worker: Complete
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Comparison: ccw-loop vs ccw-loop-b
|
|
285
|
+
|
|
286
|
+
| Aspect | ccw-loop | ccw-loop-b |
|
|
287
|
+
|--------|----------|------------|
|
|
288
|
+
| Pattern | Single agent, multi-phase | Coordinator + workers |
|
|
289
|
+
| Worker model | Single agent handles all | Specialized workers per action |
|
|
290
|
+
| Parallelization | Sequential only | Supports parallel mode |
|
|
291
|
+
| Flexibility | Fixed sequence | Mode-based (interactive/auto/parallel) |
|
|
292
|
+
| Best for | Simple linear workflows | Complex tasks needing specialization |
|
|
293
|
+
|
|
294
|
+
## Contributing
|
|
295
|
+
|
|
296
|
+
To add new workers:
|
|
297
|
+
1. Create worker role file in `.codex/agents/`
|
|
298
|
+
2. Define clear responsibilities
|
|
299
|
+
3. Update `action-catalog.md`
|
|
300
|
+
4. Add worker to coordinator spawn logic
|
|
301
|
+
5. Test integration with existing workers
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Hybrid orchestrator pattern for iterative development. Coordinator + specialized workers with batch wait support. Triggers on "ccw-loop-b".
|
|
3
|
+
argument-hint: TASK="<task description>" [--loop-id=<id>] [--mode=<interactive|auto|parallel>]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CCW Loop-B - Hybrid Orchestrator Pattern
|
|
7
|
+
|
|
8
|
+
协调器 + 专用 worker 的迭代开发工作流。支持单 agent 深度交互、多 agent 并行、混合模式灵活切换。
|
|
9
|
+
|
|
10
|
+
## Arguments
|
|
11
|
+
|
|
12
|
+
| Arg | Required | Description |
|
|
13
|
+
|-----|----------|-------------|
|
|
14
|
+
| TASK | No | Task description (for new loop) |
|
|
15
|
+
| --loop-id | No | Existing loop ID to continue |
|
|
16
|
+
| --mode | No | `interactive` (default) / `auto` / `parallel` |
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
+------------------------------------------------------------+
|
|
22
|
+
| Main Coordinator |
|
|
23
|
+
| 职责: 状态管理 + worker 调度 + 结果汇聚 + 用户交互 |
|
|
24
|
+
+------------------------------------------------------------+
|
|
25
|
+
|
|
|
26
|
+
+--------------------+--------------------+
|
|
27
|
+
| | |
|
|
28
|
+
v v v
|
|
29
|
+
+----------------+ +----------------+ +----------------+
|
|
30
|
+
| Worker-Develop | | Worker-Debug | | Worker-Validate|
|
|
31
|
+
| 专注: 代码实现 | | 专注: 问题诊断 | | 专注: 测试验证 |
|
|
32
|
+
+----------------+ +----------------+ +----------------+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Execution Modes
|
|
36
|
+
|
|
37
|
+
### Mode: Interactive (default)
|
|
38
|
+
|
|
39
|
+
协调器展示菜单,用户选择 action,spawn 对应 worker 执行。
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Coordinator -> Show menu -> User selects -> spawn worker -> wait -> Display result -> Loop
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Mode: Auto
|
|
46
|
+
|
|
47
|
+
自动按预设顺序执行,worker 完成后自动切换到下一阶段。
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Init -> Develop -> [if issues] Debug -> Validate -> [if fail] Loop back -> Complete
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Mode: Parallel
|
|
54
|
+
|
|
55
|
+
并行 spawn 多个 worker 分析不同维度,batch wait 汇聚结果。
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Coordinator -> spawn [develop, debug, validate] in parallel -> wait({ ids: all }) -> Merge -> Decide
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Session Structure
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
.workflow/.loop/
|
|
65
|
+
+-- {loopId}.json # Master state
|
|
66
|
+
+-- {loopId}.workers/ # Worker outputs
|
|
67
|
+
| +-- develop.output.json
|
|
68
|
+
| +-- debug.output.json
|
|
69
|
+
| +-- validate.output.json
|
|
70
|
+
+-- {loopId}.progress/ # Human-readable progress
|
|
71
|
+
+-- develop.md
|
|
72
|
+
+-- debug.md
|
|
73
|
+
+-- validate.md
|
|
74
|
+
+-- summary.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Subagent API
|
|
78
|
+
|
|
79
|
+
| API | 作用 |
|
|
80
|
+
|-----|------|
|
|
81
|
+
| `spawn_agent({ message })` | 创建 agent,返回 `agent_id` |
|
|
82
|
+
| `wait({ ids, timeout_ms })` | 等待结果(唯一取结果入口) |
|
|
83
|
+
| `send_input({ id, message })` | 继续交互 |
|
|
84
|
+
| `close_agent({ id })` | 关闭回收 |
|
|
85
|
+
|
|
86
|
+
## Implementation
|
|
87
|
+
|
|
88
|
+
### Coordinator Logic
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// ==================== HYBRID ORCHESTRATOR ====================
|
|
92
|
+
|
|
93
|
+
// 1. Initialize
|
|
94
|
+
const loopId = args['--loop-id'] || generateLoopId()
|
|
95
|
+
const mode = args['--mode'] || 'interactive'
|
|
96
|
+
let state = readOrCreateState(loopId, taskDescription)
|
|
97
|
+
|
|
98
|
+
// 2. Mode selection
|
|
99
|
+
switch (mode) {
|
|
100
|
+
case 'interactive':
|
|
101
|
+
await runInteractiveMode(loopId, state)
|
|
102
|
+
break
|
|
103
|
+
|
|
104
|
+
case 'auto':
|
|
105
|
+
await runAutoMode(loopId, state)
|
|
106
|
+
break
|
|
107
|
+
|
|
108
|
+
case 'parallel':
|
|
109
|
+
await runParallelMode(loopId, state)
|
|
110
|
+
break
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Interactive Mode (单 agent 交互或按需 spawn worker)
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
async function runInteractiveMode(loopId, state) {
|
|
118
|
+
while (state.status === 'running') {
|
|
119
|
+
// Show menu, get user choice
|
|
120
|
+
const action = await showMenuAndGetChoice(state)
|
|
121
|
+
|
|
122
|
+
if (action === 'exit') break
|
|
123
|
+
|
|
124
|
+
// Spawn specialized worker for the action
|
|
125
|
+
const workerId = spawn_agent({
|
|
126
|
+
message: buildWorkerPrompt(action, loopId, state)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// Wait for worker completion
|
|
130
|
+
const result = wait({ ids: [workerId], timeout_ms: 600000 })
|
|
131
|
+
const output = result.status[workerId].completed
|
|
132
|
+
|
|
133
|
+
// Update state and display result
|
|
134
|
+
state = updateState(loopId, action, output)
|
|
135
|
+
displayResult(output)
|
|
136
|
+
|
|
137
|
+
// Cleanup worker
|
|
138
|
+
close_agent({ id: workerId })
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Auto Mode (顺序执行 worker 链)
|
|
144
|
+
|
|
145
|
+
```javascript
|
|
146
|
+
async function runAutoMode(loopId, state) {
|
|
147
|
+
const actionSequence = ['init', 'develop', 'debug', 'validate', 'complete']
|
|
148
|
+
let currentIndex = state.skill_state?.action_index || 0
|
|
149
|
+
|
|
150
|
+
while (currentIndex < actionSequence.length && state.status === 'running') {
|
|
151
|
+
const action = actionSequence[currentIndex]
|
|
152
|
+
|
|
153
|
+
// Spawn worker
|
|
154
|
+
const workerId = spawn_agent({
|
|
155
|
+
message: buildWorkerPrompt(action, loopId, state)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const result = wait({ ids: [workerId], timeout_ms: 600000 })
|
|
159
|
+
const output = result.status[workerId].completed
|
|
160
|
+
|
|
161
|
+
// Parse worker result to determine next step
|
|
162
|
+
const workerResult = parseWorkerResult(output)
|
|
163
|
+
|
|
164
|
+
// Update state
|
|
165
|
+
state = updateState(loopId, action, output)
|
|
166
|
+
|
|
167
|
+
close_agent({ id: workerId })
|
|
168
|
+
|
|
169
|
+
// Determine next action
|
|
170
|
+
if (workerResult.needs_loop_back) {
|
|
171
|
+
// Loop back to develop or debug
|
|
172
|
+
currentIndex = actionSequence.indexOf(workerResult.loop_back_to)
|
|
173
|
+
} else if (workerResult.status === 'failed') {
|
|
174
|
+
// Stop on failure
|
|
175
|
+
break
|
|
176
|
+
} else {
|
|
177
|
+
currentIndex++
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Parallel Mode (批量 spawn + wait)
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
async function runParallelMode(loopId, state) {
|
|
187
|
+
// Spawn multiple workers in parallel
|
|
188
|
+
const workers = {
|
|
189
|
+
develop: spawn_agent({ message: buildWorkerPrompt('develop', loopId, state) }),
|
|
190
|
+
debug: spawn_agent({ message: buildWorkerPrompt('debug', loopId, state) }),
|
|
191
|
+
validate: spawn_agent({ message: buildWorkerPrompt('validate', loopId, state) })
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Batch wait for all workers
|
|
195
|
+
const results = wait({
|
|
196
|
+
ids: Object.values(workers),
|
|
197
|
+
timeout_ms: 900000 // 15 minutes for all
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
// Collect outputs
|
|
201
|
+
const outputs = {}
|
|
202
|
+
for (const [role, workerId] of Object.entries(workers)) {
|
|
203
|
+
outputs[role] = results.status[workerId].completed
|
|
204
|
+
close_agent({ id: workerId })
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Merge and analyze results
|
|
208
|
+
const mergedAnalysis = mergeWorkerOutputs(outputs)
|
|
209
|
+
|
|
210
|
+
// Update state with merged results
|
|
211
|
+
updateState(loopId, 'parallel-analysis', mergedAnalysis)
|
|
212
|
+
|
|
213
|
+
// Coordinator decides next action based on merged results
|
|
214
|
+
const decision = decideNextAction(mergedAnalysis)
|
|
215
|
+
return decision
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Worker Prompt Builder
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
function buildWorkerPrompt(action, loopId, state) {
|
|
223
|
+
const workerRoles = {
|
|
224
|
+
develop: '~/.codex/agents/ccw-loop-b-develop.md',
|
|
225
|
+
debug: '~/.codex/agents/ccw-loop-b-debug.md',
|
|
226
|
+
validate: '~/.codex/agents/ccw-loop-b-validate.md',
|
|
227
|
+
init: '~/.codex/agents/ccw-loop-b-init.md',
|
|
228
|
+
complete: '~/.codex/agents/ccw-loop-b-complete.md'
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return `
|
|
232
|
+
## TASK ASSIGNMENT
|
|
233
|
+
|
|
234
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
235
|
+
1. **Read role definition**: ${workerRoles[action]} (MUST read first)
|
|
236
|
+
2. Read: .workflow/project-tech.json
|
|
237
|
+
3. Read: .workflow/project-guidelines.json
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## LOOP CONTEXT
|
|
242
|
+
|
|
243
|
+
- **Loop ID**: ${loopId}
|
|
244
|
+
- **Action**: ${action}
|
|
245
|
+
- **State File**: .workflow/.loop/${loopId}.json
|
|
246
|
+
- **Output File**: .workflow/.loop/${loopId}.workers/${action}.output.json
|
|
247
|
+
- **Progress File**: .workflow/.loop/${loopId}.progress/${action}.md
|
|
248
|
+
|
|
249
|
+
## CURRENT STATE
|
|
250
|
+
|
|
251
|
+
${JSON.stringify(state, null, 2)}
|
|
252
|
+
|
|
253
|
+
## TASK DESCRIPTION
|
|
254
|
+
|
|
255
|
+
${state.description}
|
|
256
|
+
|
|
257
|
+
## EXPECTED OUTPUT
|
|
258
|
+
|
|
259
|
+
\`\`\`
|
|
260
|
+
WORKER_RESULT:
|
|
261
|
+
- action: ${action}
|
|
262
|
+
- status: success | failed | needs_input
|
|
263
|
+
- summary: <brief summary>
|
|
264
|
+
- files_changed: [list]
|
|
265
|
+
- next_suggestion: <suggested next action>
|
|
266
|
+
- loop_back_to: <action name if needs loop back>
|
|
267
|
+
|
|
268
|
+
DETAILED_OUTPUT:
|
|
269
|
+
<structured output specific to action type>
|
|
270
|
+
\`\`\`
|
|
271
|
+
|
|
272
|
+
Execute the ${action} action now.
|
|
273
|
+
`
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Worker Roles
|
|
278
|
+
|
|
279
|
+
| Worker | Role File | 专注领域 |
|
|
280
|
+
|--------|-----------|----------|
|
|
281
|
+
| init | ccw-loop-b-init.md | 会话初始化、任务解析 |
|
|
282
|
+
| develop | ccw-loop-b-develop.md | 代码实现、重构 |
|
|
283
|
+
| debug | ccw-loop-b-debug.md | 问题诊断、假设验证 |
|
|
284
|
+
| validate | ccw-loop-b-validate.md | 测试执行、覆盖率 |
|
|
285
|
+
| complete | ccw-loop-b-complete.md | 总结收尾 |
|
|
286
|
+
|
|
287
|
+
## State Schema
|
|
288
|
+
|
|
289
|
+
See [phases/state-schema.md](phases/state-schema.md)
|
|
290
|
+
|
|
291
|
+
## Usage
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Interactive mode (default)
|
|
295
|
+
/ccw-loop-b TASK="Implement user authentication"
|
|
296
|
+
|
|
297
|
+
# Auto mode
|
|
298
|
+
/ccw-loop-b --mode=auto TASK="Fix login bug"
|
|
299
|
+
|
|
300
|
+
# Parallel analysis mode
|
|
301
|
+
/ccw-loop-b --mode=parallel TASK="Analyze and improve payment module"
|
|
302
|
+
|
|
303
|
+
# Resume existing loop
|
|
304
|
+
/ccw-loop-b --loop-id=loop-b-20260122-abc123
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Error Handling
|
|
308
|
+
|
|
309
|
+
| Situation | Action |
|
|
310
|
+
|-----------|--------|
|
|
311
|
+
| Worker timeout | send_input 请求收敛 |
|
|
312
|
+
| Worker failed | Log error, 协调器决策是否重试 |
|
|
313
|
+
| Batch wait partial timeout | 使用已完成结果继续 |
|
|
314
|
+
| State corrupted | 从 progress 文件重建 |
|
|
315
|
+
|
|
316
|
+
## Best Practices
|
|
317
|
+
|
|
318
|
+
1. **协调器保持轻量**: 只做调度和状态管理,具体工作交给 worker
|
|
319
|
+
2. **Worker 职责单一**: 每个 worker 专注一个领域
|
|
320
|
+
3. **结果标准化**: Worker 输出遵循统一 WORKER_RESULT 格式
|
|
321
|
+
4. **灵活模式切换**: 根据任务复杂度选择合适模式
|
|
322
|
+
5. **及时清理**: Worker 完成后 close_agent 释放资源
|