opencode-swarm-plugin 0.5.0 → 0.6.0
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/.beads/issues.jsonl +443 -0
- package/README.md +76 -0
- package/examples/agents/swarm-planner.md +138 -0
- package/examples/commands/swarm.md +261 -34
- package/package.json +1 -1
- package/src/index.ts +12 -0
- package/src/learning.ts +13 -0
- package/src/swarm.integration.test.ts +284 -0
- package/src/swarm.ts +481 -3
package/README.md
CHANGED
|
@@ -131,6 +131,8 @@ Client-side, per-agent rate limits prevent abuse and ensure fair resource usage
|
|
|
131
131
|
| Tool | Description |
|
|
132
132
|
| ------------------------------ | ------------------------------------------------------------------------ |
|
|
133
133
|
| `swarm_init` | Check tool availability, report degraded features |
|
|
134
|
+
| `swarm_select_strategy` | Analyze task and recommend decomposition strategy |
|
|
135
|
+
| `swarm_plan_prompt` | Generate strategy-specific planning prompt with CASS integration |
|
|
134
136
|
| `swarm_decompose` | Generate decomposition prompt, optionally queries CASS for similar tasks |
|
|
135
137
|
| `swarm_validate_decomposition` | Validate decomposition response, detect instruction conflicts |
|
|
136
138
|
| `swarm_status` | Get swarm status by epic ID |
|
|
@@ -152,6 +154,80 @@ Client-side, per-agent rate limits prevent abuse and ensure fair resource usage
|
|
|
152
154
|
| `structured_parse_decomposition` | Parse and validate task decomposition |
|
|
153
155
|
| `structured_parse_bead_tree` | Parse and validate bead tree for epic creation |
|
|
154
156
|
|
|
157
|
+
## Decomposition Strategies
|
|
158
|
+
|
|
159
|
+
The plugin supports three decomposition strategies, auto-selected based on task keywords:
|
|
160
|
+
|
|
161
|
+
### File-Based Strategy
|
|
162
|
+
|
|
163
|
+
Best for: Refactoring, migrations, pattern changes across codebase
|
|
164
|
+
|
|
165
|
+
**Keywords**: refactor, migrate, rename, update all, convert, upgrade
|
|
166
|
+
|
|
167
|
+
**Guidelines**:
|
|
168
|
+
|
|
169
|
+
- Group files by directory or type
|
|
170
|
+
- Handle shared types/utilities first
|
|
171
|
+
- Minimize cross-directory dependencies
|
|
172
|
+
|
|
173
|
+
### Feature-Based Strategy
|
|
174
|
+
|
|
175
|
+
Best for: New features, adding functionality
|
|
176
|
+
|
|
177
|
+
**Keywords**: add, implement, build, create, feature, new
|
|
178
|
+
|
|
179
|
+
**Guidelines**:
|
|
180
|
+
|
|
181
|
+
- Each subtask is a complete vertical slice
|
|
182
|
+
- Start with data layer, then logic, then UI
|
|
183
|
+
- Keep related components together
|
|
184
|
+
|
|
185
|
+
### Risk-Based Strategy
|
|
186
|
+
|
|
187
|
+
Best for: Bug fixes, security issues, critical changes
|
|
188
|
+
|
|
189
|
+
**Keywords**: fix, bug, security, critical, urgent, hotfix
|
|
190
|
+
|
|
191
|
+
**Guidelines**:
|
|
192
|
+
|
|
193
|
+
- Write tests FIRST
|
|
194
|
+
- Isolate risky changes
|
|
195
|
+
- Audit similar code for same issue
|
|
196
|
+
|
|
197
|
+
### Strategy Selection
|
|
198
|
+
|
|
199
|
+
Use `swarm_select_strategy` to see the recommended strategy:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
swarm_select_strategy({ task: "Add user authentication" });
|
|
203
|
+
// Returns: { strategy: "feature-based", confidence: 0.85, reasoning: "..." }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Or let `swarm_plan_prompt` auto-select:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
swarm_plan_prompt({ task: "Refactor all components to use hooks" });
|
|
210
|
+
// Auto-selects file-based strategy
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Example Planner Agent
|
|
214
|
+
|
|
215
|
+
The plugin includes an example planner agent at `examples/agents/swarm-planner.md`.
|
|
216
|
+
|
|
217
|
+
Copy to your OpenCode agents directory:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
cp examples/agents/swarm-planner.md ~/.config/opencode/agents/
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Then invoke with:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
@swarm-planner "Add user authentication with OAuth"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The planner uses `swarm_select_strategy` and `swarm_plan_prompt` internally to create optimal decompositions.
|
|
230
|
+
|
|
155
231
|
### Schemas (for structured outputs)
|
|
156
232
|
|
|
157
233
|
The plugin exports Zod schemas for validated agent responses:
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm-planner
|
|
3
|
+
description: Strategic task decomposition for swarm coordination
|
|
4
|
+
model: claude-sonnet-4-5
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a swarm planner. Your job is to decompose complex tasks into optimal parallel subtasks.
|
|
8
|
+
|
|
9
|
+
## Your Role
|
|
10
|
+
|
|
11
|
+
You analyze tasks and create decomposition plans that:
|
|
12
|
+
|
|
13
|
+
- Maximize parallelization (agents work independently)
|
|
14
|
+
- Minimize conflicts (no file overlap between subtasks)
|
|
15
|
+
- Follow the best strategy for the task type
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
1. **Analyze** - Call `swarm_select_strategy` to understand the task
|
|
20
|
+
2. **Plan** - Call `swarm_plan_prompt` to get strategy-specific guidance
|
|
21
|
+
3. **Decompose** - Create a BeadTree following the guidelines
|
|
22
|
+
4. **Validate** - Ensure no file conflicts or circular dependencies
|
|
23
|
+
|
|
24
|
+
## Strategy Selection
|
|
25
|
+
|
|
26
|
+
The plugin auto-selects strategies based on task keywords:
|
|
27
|
+
|
|
28
|
+
| Strategy | Best For | Keywords |
|
|
29
|
+
| ----------------- | -------------------------------------------- | -------------------------------------- |
|
|
30
|
+
| **file-based** | Refactoring, migrations, pattern changes | refactor, migrate, rename, update all |
|
|
31
|
+
| **feature-based** | New features, adding functionality | add, implement, build, create, feature |
|
|
32
|
+
| **risk-based** | Bug fixes, security issues, critical changes | fix, bug, security, critical, urgent |
|
|
33
|
+
|
|
34
|
+
You can override with explicit strategy if the auto-detection is wrong.
|
|
35
|
+
|
|
36
|
+
## Output Format
|
|
37
|
+
|
|
38
|
+
Return ONLY valid JSON matching the BeadTree schema:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"epic": {
|
|
43
|
+
"title": "Epic title for beads tracker",
|
|
44
|
+
"description": "Brief description of the overall goal"
|
|
45
|
+
},
|
|
46
|
+
"subtasks": [
|
|
47
|
+
{
|
|
48
|
+
"title": "What this subtask accomplishes",
|
|
49
|
+
"description": "Detailed instructions for the agent",
|
|
50
|
+
"files": ["src/path/to/file.ts", "src/path/to/file.test.ts"],
|
|
51
|
+
"dependencies": [],
|
|
52
|
+
"estimated_complexity": 2
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**CRITICAL**: Return ONLY the JSON. No markdown, no explanation, no code blocks.
|
|
59
|
+
|
|
60
|
+
## Decomposition Rules
|
|
61
|
+
|
|
62
|
+
1. **2-7 subtasks** - Too few = not parallel, too many = coordination overhead
|
|
63
|
+
2. **No file overlap** - Each file appears in exactly one subtask
|
|
64
|
+
3. **Include tests** - Put test files with the code they test
|
|
65
|
+
4. **Order by dependency** - If B needs A's output, A comes first (lower index)
|
|
66
|
+
5. **Estimate complexity** - 1 (trivial) to 5 (complex)
|
|
67
|
+
|
|
68
|
+
## Anti-Patterns to Avoid
|
|
69
|
+
|
|
70
|
+
- Don't split tightly coupled files across subtasks
|
|
71
|
+
- Don't create subtasks that can't be tested independently
|
|
72
|
+
- Don't forget shared types/utilities that multiple files depend on
|
|
73
|
+
- Don't make one subtask do everything while others are trivial
|
|
74
|
+
|
|
75
|
+
## Example Decomposition
|
|
76
|
+
|
|
77
|
+
**Task**: "Add user authentication with OAuth"
|
|
78
|
+
|
|
79
|
+
**Strategy**: feature-based (detected from "add" keyword)
|
|
80
|
+
|
|
81
|
+
**Result**:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"epic": {
|
|
86
|
+
"title": "Add user authentication with OAuth",
|
|
87
|
+
"description": "Implement OAuth-based authentication flow with session management"
|
|
88
|
+
},
|
|
89
|
+
"subtasks": [
|
|
90
|
+
{
|
|
91
|
+
"title": "Set up OAuth provider configuration",
|
|
92
|
+
"description": "Configure OAuth provider (Google/GitHub), add environment variables, create auth config",
|
|
93
|
+
"files": ["src/auth/config.ts", "src/auth/providers.ts", ".env.example"],
|
|
94
|
+
"dependencies": [],
|
|
95
|
+
"estimated_complexity": 2
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"title": "Implement session management",
|
|
99
|
+
"description": "Create session store, JWT handling, cookie management",
|
|
100
|
+
"files": [
|
|
101
|
+
"src/auth/session.ts",
|
|
102
|
+
"src/auth/jwt.ts",
|
|
103
|
+
"src/middleware/auth.ts"
|
|
104
|
+
],
|
|
105
|
+
"dependencies": [0],
|
|
106
|
+
"estimated_complexity": 3
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"title": "Add protected route wrapper",
|
|
110
|
+
"description": "Create HOC/middleware for protecting routes, redirect logic",
|
|
111
|
+
"files": ["src/components/ProtectedRoute.tsx", "src/hooks/useAuth.ts"],
|
|
112
|
+
"dependencies": [1],
|
|
113
|
+
"estimated_complexity": 2
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"title": "Create login/logout UI",
|
|
117
|
+
"description": "Login page, logout button, auth state display",
|
|
118
|
+
"files": ["src/app/login/page.tsx", "src/components/AuthButton.tsx"],
|
|
119
|
+
"dependencies": [0],
|
|
120
|
+
"estimated_complexity": 2
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Usage
|
|
127
|
+
|
|
128
|
+
The coordinator invokes you like this:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
@swarm-planner "Add user authentication with OAuth"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
You respond with the BeadTree JSON. The coordinator then:
|
|
135
|
+
|
|
136
|
+
1. Validates with `swarm_validate_decomposition`
|
|
137
|
+
2. Creates beads with `beads_create_epic`
|
|
138
|
+
3. Spawns worker agents for each subtask
|
|
@@ -2,49 +2,276 @@
|
|
|
2
2
|
description: Decompose task into parallel subtasks and coordinate agents
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
You are a swarm coordinator.
|
|
5
|
+
You are a swarm coordinator. Take a complex task, break it into beads, and unleash parallel agents.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Usage
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```
|
|
10
|
+
/swarm <task description or bead-id>
|
|
11
|
+
/swarm --to-main <task> # Skip PR, push directly to main (use sparingly)
|
|
12
|
+
/swarm --no-sync <task> # Skip mid-task context sync (for simple independent tasks)
|
|
13
|
+
```
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
**Default behavior: Feature branch + PR with context sync.** All swarm work goes to a feature branch, agents share context mid-task, and creates a PR for review.
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
2. Analyze the task and create a decomposition with:
|
|
15
|
-
- Epic title and description
|
|
16
|
-
- 2-5 parallelizable subtasks with file assignments
|
|
17
|
-
- No file conflicts between subtasks
|
|
18
|
-
3. Create the epic using `beads_create_epic`
|
|
19
|
-
4. For each subtask:
|
|
20
|
-
- Mark bead in_progress with `beads_start`
|
|
21
|
-
- Use `swarm_spawn_subtask` to generate a prompt (includes Agent Mail/beads instructions)
|
|
22
|
-
- Spawn a Task agent with that prompt
|
|
23
|
-
5. Monitor progress via Agent Mail inbox
|
|
24
|
-
6. After all subtasks complete:
|
|
25
|
-
- Close the epic with `beads_close`
|
|
26
|
-
- Sync to git with `beads_sync`
|
|
17
|
+
## Step 1: Initialize Session
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
Use the plugin's agent-mail tools to register:
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
```
|
|
22
|
+
agentmail_init with project_path=$PWD, task_description="Swarm coordinator: <task>"
|
|
23
|
+
```
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
- **Beads** - `beads_update`, `beads_create`, `swarm_complete`
|
|
34
|
-
- All standard tools (Read, Write, Edit, Bash, etc.)
|
|
25
|
+
This returns your agent name and session state. Remember it.
|
|
35
26
|
|
|
36
|
-
|
|
27
|
+
## Step 2: Create Feature Branch
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
- Update bead status if blocked
|
|
40
|
-
- Create new beads for discovered issues
|
|
41
|
-
- Use `swarm_complete` when done
|
|
29
|
+
**CRITICAL: Never push directly to main.**
|
|
42
30
|
|
|
43
|
-
|
|
31
|
+
```bash
|
|
32
|
+
# Create branch from bead ID or task name
|
|
33
|
+
git checkout -b swarm/<bead-id> # e.g., swarm/trt-buddy-d7d
|
|
34
|
+
# Or for ad-hoc tasks:
|
|
35
|
+
git checkout -b swarm/<short-description> # e.g., swarm/contextual-checkins
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- Check `agentmail_inbox` periodically for updates
|
|
48
|
-
- Use `agentmail_summarize_thread` to get thread overview
|
|
37
|
+
git push -u origin HEAD
|
|
38
|
+
```
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
## Step 3: Understand the Task
|
|
41
|
+
|
|
42
|
+
If given a bead-id:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
beads_query with id=<bead-id>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If given a description, analyze it to understand scope.
|
|
49
|
+
|
|
50
|
+
## Step 4: Select Strategy & Decompose
|
|
51
|
+
|
|
52
|
+
### Option A: Use the Planner Agent (Recommended)
|
|
53
|
+
|
|
54
|
+
Spawn the `@swarm-planner` agent to handle decomposition:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Task(
|
|
58
|
+
subagent_type="general",
|
|
59
|
+
description="Plan swarm decomposition",
|
|
60
|
+
prompt="You are @swarm-planner. Decompose this task: <task description>. Use swarm_select_strategy and swarm_plan_prompt to guide your decomposition. Return ONLY valid BeadTree JSON."
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Option B: Manual Decomposition
|
|
65
|
+
|
|
66
|
+
1. **Select strategy**:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
swarm_select_strategy with task="<task description>"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. **Get planning prompt**:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
swarm_plan_prompt with task="<task description>", strategy="<selected or auto>"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
3. **Create decomposition** following the prompt guidelines
|
|
79
|
+
|
|
80
|
+
4. **Validate**:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
swarm_validate_decomposition with response="<your BeadTree JSON>"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Create Beads
|
|
87
|
+
|
|
88
|
+
Once you have a valid BeadTree:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
beads_create_epic with epic_title="<parent task>", subtasks=[{title, description, files, priority}...]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Decomposition rules:**
|
|
95
|
+
|
|
96
|
+
- Each bead should be completable by one agent
|
|
97
|
+
- Beads should be independent (parallelizable) where possible
|
|
98
|
+
- If there are dependencies, order them in the subtasks array
|
|
99
|
+
- Aim for 3-7 beads per swarm (too few = not parallel, too many = coordination overhead)
|
|
100
|
+
|
|
101
|
+
## Step 5: Reserve Files
|
|
102
|
+
|
|
103
|
+
For each subtask, reserve the files it will touch:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
agentmail_reserve with paths=[<files>], reason="<bead-id>: <brief description>"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Conflict prevention:**
|
|
110
|
+
|
|
111
|
+
- No two agents should edit the same file
|
|
112
|
+
- If overlap exists, merge beads or sequence them
|
|
113
|
+
|
|
114
|
+
## Step 6: Spawn the Swarm
|
|
115
|
+
|
|
116
|
+
**CRITICAL: Spawn ALL agents in a SINGLE message with multiple Task calls.**
|
|
117
|
+
|
|
118
|
+
Use the prompt generator for each subtask:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
swarm_spawn_subtask with bead_id="<bead-id>", epic_id="<epic-id>", subtask_title="<title>", subtask_description="<description>", files=[<files>], shared_context="Branch: swarm/<id>, sync_enabled: true"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Then spawn agents with the generated prompts:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
Task(
|
|
128
|
+
subagent_type="general",
|
|
129
|
+
description="Swarm worker: <bead-title>",
|
|
130
|
+
prompt="<output from swarm_spawn_subtask>"
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Spawn ALL agents in parallel in a single response.
|
|
135
|
+
|
|
136
|
+
## Step 7: Monitor Progress (unless --no-sync)
|
|
137
|
+
|
|
138
|
+
Check swarm status:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
swarm_status with epic_id="<parent-bead-id>"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Monitor inbox for progress updates:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
agentmail_inbox
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**When you receive progress updates:**
|
|
151
|
+
|
|
152
|
+
1. **Review decisions made** - Are agents making compatible choices?
|
|
153
|
+
2. **Check for pattern conflicts** - Different approaches to the same problem?
|
|
154
|
+
3. **Identify shared concerns** - Common blockers or discoveries?
|
|
155
|
+
|
|
156
|
+
**If you spot incompatibilities, broadcast shared context:**
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
agentmail_send with to=["*"], subject="Coordinator Update", body="<guidance>", thread_id="<epic-id>", importance="high"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Step 8: Collect Results
|
|
163
|
+
|
|
164
|
+
When agents complete, they send completion messages. Summarize the thread:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
agentmail_summarize_thread with thread_id="<epic-id>"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Step 9: Complete Swarm
|
|
171
|
+
|
|
172
|
+
Use the swarm completion tool:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
swarm_complete with project_key=$PWD, agent_name=<YOUR_NAME>, bead_id="<epic-id>", summary="<what was accomplished>", files_touched=[<all files>]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
This:
|
|
179
|
+
|
|
180
|
+
- Runs UBS bug scan on touched files
|
|
181
|
+
- Releases file reservations
|
|
182
|
+
- Closes the bead
|
|
183
|
+
- Records outcome for learning
|
|
184
|
+
|
|
185
|
+
Then sync beads:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
beads_sync
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Step 10: Create PR
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
gh pr create --title "feat: <epic title>" --body "$(cat <<'EOF'
|
|
195
|
+
## Summary
|
|
196
|
+
<1-3 bullet points from swarm results>
|
|
197
|
+
|
|
198
|
+
## Beads Completed
|
|
199
|
+
- <bead-id>: <summary>
|
|
200
|
+
- <bead-id>: <summary>
|
|
201
|
+
|
|
202
|
+
## Files Changed
|
|
203
|
+
<aggregate list>
|
|
204
|
+
|
|
205
|
+
## Testing
|
|
206
|
+
- [ ] Type check passes
|
|
207
|
+
- [ ] Tests pass (if applicable)
|
|
208
|
+
EOF
|
|
209
|
+
)"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Report summary:
|
|
213
|
+
|
|
214
|
+
```markdown
|
|
215
|
+
## Swarm Complete: <task>
|
|
216
|
+
|
|
217
|
+
### PR: #<number>
|
|
218
|
+
|
|
219
|
+
### Agents Spawned: N
|
|
220
|
+
|
|
221
|
+
### Beads Closed: N
|
|
222
|
+
|
|
223
|
+
### Work Completed
|
|
224
|
+
|
|
225
|
+
- [bead-id]: [summary]
|
|
226
|
+
|
|
227
|
+
### Files Changed
|
|
228
|
+
|
|
229
|
+
- [aggregate list]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Failure Handling
|
|
233
|
+
|
|
234
|
+
If an agent fails:
|
|
235
|
+
|
|
236
|
+
- Check its messages: `agentmail_inbox`
|
|
237
|
+
- The bead remains in-progress
|
|
238
|
+
- Manually investigate or re-spawn
|
|
239
|
+
|
|
240
|
+
If file conflicts occur:
|
|
241
|
+
|
|
242
|
+
- Agent Mail reservations should prevent this
|
|
243
|
+
- If it happens, one agent needs to wait
|
|
244
|
+
|
|
245
|
+
## Direct-to-Main Mode (--to-main)
|
|
246
|
+
|
|
247
|
+
Only use when explicitly requested. Skips branch/PR:
|
|
248
|
+
|
|
249
|
+
- Trivial fixes across many files
|
|
250
|
+
- Automated migrations with high confidence
|
|
251
|
+
- User explicitly says "push to main"
|
|
252
|
+
|
|
253
|
+
## No-Sync Mode (--no-sync)
|
|
254
|
+
|
|
255
|
+
Skip mid-task context sharing when tasks are truly independent:
|
|
256
|
+
|
|
257
|
+
- Simple mechanical changes (find/replace, formatting, lint fixes)
|
|
258
|
+
- Tasks with zero integration points
|
|
259
|
+
- Completely separate feature areas with no shared types
|
|
260
|
+
|
|
261
|
+
In this mode:
|
|
262
|
+
|
|
263
|
+
- Agents skip the mid-task progress message
|
|
264
|
+
- Coordinator skips Step 7 (monitoring)
|
|
265
|
+
- Faster execution, less coordination overhead
|
|
266
|
+
|
|
267
|
+
**Default is sync ON** - prefer sharing context. Use `--no-sync` deliberately.
|
|
268
|
+
|
|
269
|
+
## Strategy Reference
|
|
270
|
+
|
|
271
|
+
| Strategy | Best For | Auto-Detected Keywords |
|
|
272
|
+
| ----------------- | --------------------------- | ---------------------------------------------- |
|
|
273
|
+
| **file-based** | Refactoring, migrations | refactor, migrate, rename, update all, convert |
|
|
274
|
+
| **feature-based** | New features, functionality | add, implement, build, create, feature, new |
|
|
275
|
+
| **risk-based** | Bug fixes, security | fix, bug, security, critical, urgent, hotfix |
|
|
276
|
+
|
|
277
|
+
Use `swarm_select_strategy` to see which strategy is recommended and why.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -254,6 +254,12 @@ export {
|
|
|
254
254
|
* - swarmTools - Swarm orchestration tools
|
|
255
255
|
* - SwarmError, DecompositionError - Error classes
|
|
256
256
|
* - formatSubtaskPrompt, formatEvaluationPrompt - Prompt helpers
|
|
257
|
+
* - selectStrategy, formatStrategyGuidelines - Strategy selection helpers
|
|
258
|
+
* - STRATEGIES - Strategy definitions
|
|
259
|
+
*
|
|
260
|
+
* Types:
|
|
261
|
+
* - DecompositionStrategy - Strategy type union
|
|
262
|
+
* - StrategyDefinition - Strategy definition interface
|
|
257
263
|
*
|
|
258
264
|
* NOTE: Prompt template strings (DECOMPOSITION_PROMPT, etc.) are NOT exported
|
|
259
265
|
* to avoid confusing the plugin loader which tries to call all exports as functions
|
|
@@ -266,6 +272,12 @@ export {
|
|
|
266
272
|
formatSubtaskPromptV2,
|
|
267
273
|
formatEvaluationPrompt,
|
|
268
274
|
SUBTASK_PROMPT_V2,
|
|
275
|
+
// Strategy exports
|
|
276
|
+
STRATEGIES,
|
|
277
|
+
selectStrategy,
|
|
278
|
+
formatStrategyGuidelines,
|
|
279
|
+
type DecompositionStrategy,
|
|
280
|
+
type StrategyDefinition,
|
|
269
281
|
} from "./swarm";
|
|
270
282
|
|
|
271
283
|
/**
|
package/src/learning.ts
CHANGED
|
@@ -64,6 +64,16 @@ export const CriterionWeightSchema = z.object({
|
|
|
64
64
|
});
|
|
65
65
|
export type CriterionWeight = z.infer<typeof CriterionWeightSchema>;
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Decomposition strategies for tracking which approach was used
|
|
69
|
+
*/
|
|
70
|
+
export const DecompositionStrategySchema = z.enum([
|
|
71
|
+
"file-based",
|
|
72
|
+
"feature-based",
|
|
73
|
+
"risk-based",
|
|
74
|
+
]);
|
|
75
|
+
export type DecompositionStrategy = z.infer<typeof DecompositionStrategySchema>;
|
|
76
|
+
|
|
67
77
|
/**
|
|
68
78
|
* Outcome signals from a completed subtask
|
|
69
79
|
*
|
|
@@ -85,6 +95,8 @@ export const OutcomeSignalsSchema = z.object({
|
|
|
85
95
|
files_touched: z.array(z.string()).default([]),
|
|
86
96
|
/** Timestamp when outcome was recorded */
|
|
87
97
|
timestamp: z.string(), // ISO-8601
|
|
98
|
+
/** Decomposition strategy used for this task */
|
|
99
|
+
strategy: DecompositionStrategySchema.optional(),
|
|
88
100
|
});
|
|
89
101
|
export type OutcomeSignals = z.infer<typeof OutcomeSignalsSchema>;
|
|
90
102
|
|
|
@@ -435,4 +447,5 @@ export const learningSchemas = {
|
|
|
435
447
|
CriterionWeightSchema,
|
|
436
448
|
OutcomeSignalsSchema,
|
|
437
449
|
ScoredOutcomeSchema,
|
|
450
|
+
DecompositionStrategySchema,
|
|
438
451
|
};
|