swarm-control 0.1.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/LICENSE +21 -0
- package/README.md +229 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +24 -0
- package/dist/cli.js.map +1 -0
- package/dist/installer.d.ts +4 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +87 -0
- package/dist/installer.js.map +1 -0
- package/dist/plugin/config.d.ts +5 -0
- package/dist/plugin/config.d.ts.map +1 -0
- package/dist/plugin/config.js +50 -0
- package/dist/plugin/config.js.map +1 -0
- package/dist/plugin/coordinator.d.ts +9 -0
- package/dist/plugin/coordinator.d.ts.map +1 -0
- package/dist/plugin/coordinator.js +153 -0
- package/dist/plugin/coordinator.js.map +1 -0
- package/dist/plugin/decomposer.d.ts +11 -0
- package/dist/plugin/decomposer.d.ts.map +1 -0
- package/dist/plugin/decomposer.js +77 -0
- package/dist/plugin/decomposer.js.map +1 -0
- package/dist/plugin/file-lock.d.ts +14 -0
- package/dist/plugin/file-lock.d.ts.map +1 -0
- package/dist/plugin/file-lock.js +55 -0
- package/dist/plugin/file-lock.js.map +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +138 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/state.d.ts +12 -0
- package/dist/plugin/state.d.ts.map +1 -0
- package/dist/plugin/state.js +75 -0
- package/dist/plugin/state.js.map +1 -0
- package/dist/plugin/types.d.ts +45 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +5 -0
- package/dist/plugin/types.js.map +1 -0
- package/dist/plugin/worker.d.ts +3 -0
- package/dist/plugin/worker.d.ts.map +1 -0
- package/dist/plugin/worker.js +40 -0
- package/dist/plugin/worker.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hanz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Swarm Control
|
|
2
|
+
|
|
3
|
+
OpenCode plugin for multi-agent swarm coordination. Decompose complex programming tasks and execute them in parallel across multiple AI subagents.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Task Decomposition**: Automatically breaks down complex tasks into file-based subtasks
|
|
8
|
+
- **Parallel Execution**: Spawns up to 4 worker subagents to work in parallel
|
|
9
|
+
- **Dependency Management**: Respects dependencies between subtasks
|
|
10
|
+
- **File Locking**: Prevents conflicts when multiple workers access the same files
|
|
11
|
+
- **State Persistence**: Tracks task progress and worker status
|
|
12
|
+
- **Partial Completion**: Continues execution even if some subtasks fail
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g swarm-control
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
After installation, run the setup command:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
swarm-control setup
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This will install the plugin to `~/.opencode/plugins/swarm-control/`.
|
|
29
|
+
|
|
30
|
+
**Important**: You must restart OpenCode after running setup for the plugin to be loaded.
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
Before using the swarm, you must configure the model used for task decomposition:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
/swarm_model <model-name>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For example:
|
|
41
|
+
```
|
|
42
|
+
/swarm_model anthropic/claude-3-5-sonnet-20241022
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The model is stored in your OpenCode config file (`~/.config/opencode/opencode.json`).
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Starting a Swarm Task
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
/swarm_spawn "your task description"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Example:**
|
|
56
|
+
```
|
|
57
|
+
/swarm_spawn "Add error handling to all API endpoints in src/api/"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Options:**
|
|
61
|
+
- `maxWorkers` (optional): Maximum number of workers (default: 4, max: 4)
|
|
62
|
+
|
|
63
|
+
**Example with options:**
|
|
64
|
+
```
|
|
65
|
+
/swarm_spawn "Refactor authentication module" --maxWorkers 2
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Checking Swarm Status
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
/swarm_status
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This shows:
|
|
75
|
+
- Current task information
|
|
76
|
+
- Subtask progress
|
|
77
|
+
- Worker status
|
|
78
|
+
- Any errors or failures
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
1. **Task Analysis**: The LLM analyzes your task and identifies relevant files
|
|
83
|
+
2. **Decomposition**: The task is broken down into 1-4 file-based subtasks
|
|
84
|
+
3. **Worker Spawning**: Child sessions (subagents) are created as workers
|
|
85
|
+
4. **Parallel Execution**: Independent subtasks run in parallel
|
|
86
|
+
5. **Dependency Resolution**: Subtasks with dependencies wait for completion
|
|
87
|
+
6. **File Locking**: Workers wait for files to be unlocked before accessing them
|
|
88
|
+
7. **Result Aggregation**: Results from all workers are combined into a summary
|
|
89
|
+
|
|
90
|
+
## File Locking
|
|
91
|
+
|
|
92
|
+
When multiple workers need to access the same file:
|
|
93
|
+
- First worker acquires the lock
|
|
94
|
+
- Subsequent workers wait in a queue
|
|
95
|
+
- Lock is released when the worker finishes
|
|
96
|
+
- Next worker in the queue acquires the lock
|
|
97
|
+
|
|
98
|
+
This prevents conflicts and ensures file integrity.
|
|
99
|
+
|
|
100
|
+
## Error Handling
|
|
101
|
+
|
|
102
|
+
- If a subtask fails, the swarm continues with other subtasks
|
|
103
|
+
- Failed subtasks are marked with ❌ and show error details
|
|
104
|
+
- File locks are automatically released on error
|
|
105
|
+
- The final summary shows both completed and failed subtasks
|
|
106
|
+
|
|
107
|
+
## Commands
|
|
108
|
+
|
|
109
|
+
### CLI Commands
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
swarm-control setup # Install the plugin
|
|
113
|
+
swarm-control uninstall # Remove the plugin
|
|
114
|
+
swarm-control reset # Reset swarm state (keeps configuration)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### OpenCode Tools
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
/swarm_model <model> # Set model for decomposition
|
|
121
|
+
/swarm_spawn <task> # Start a swarm task
|
|
122
|
+
/swarm_status # Check swarm status
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Configuration
|
|
126
|
+
|
|
127
|
+
The swarm model is stored in `~/.config/opencode/opencode.json`:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"swarm": {
|
|
132
|
+
"model": "anthropic/claude-3-5-sonnet-20241022"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## State Management
|
|
138
|
+
|
|
139
|
+
Swarm state is persisted to `~/.config/swarm-control/state.json`:
|
|
140
|
+
|
|
141
|
+
- Current task information
|
|
142
|
+
- Subtask status
|
|
143
|
+
- Worker information
|
|
144
|
+
- File locks
|
|
145
|
+
|
|
146
|
+
Use `swarm-control reset` to clear state without removing configuration.
|
|
147
|
+
|
|
148
|
+
## Requirements
|
|
149
|
+
|
|
150
|
+
- OpenCode >= 1.1.7
|
|
151
|
+
- Node.js >= 18.0.0
|
|
152
|
+
|
|
153
|
+
## Troubleshooting
|
|
154
|
+
|
|
155
|
+
### Plugin not loaded after installation
|
|
156
|
+
|
|
157
|
+
Make sure to restart OpenCode after running `swarm-control setup`.
|
|
158
|
+
|
|
159
|
+
### "Swarm model not configured" error
|
|
160
|
+
|
|
161
|
+
Run `/swarm_model <model-name>` to configure the model before using `/swarm_spawn`.
|
|
162
|
+
|
|
163
|
+
### "A swarm task is already in progress" error
|
|
164
|
+
|
|
165
|
+
Wait for the current task to complete or use `swarm-control reset` to clear state.
|
|
166
|
+
|
|
167
|
+
### Workers not creating sessions
|
|
168
|
+
|
|
169
|
+
Check that OpenCode has permission to create child sessions and that your API quota is sufficient.
|
|
170
|
+
|
|
171
|
+
### Decomposition fails
|
|
172
|
+
|
|
173
|
+
Try using a more capable model (e.g., Claude Sonnet instead of Haiku) for better decomposition quality.
|
|
174
|
+
|
|
175
|
+
## Examples
|
|
176
|
+
|
|
177
|
+
### Simple Single-File Task
|
|
178
|
+
```
|
|
179
|
+
/swarm_spawn "Add JSDoc comments to src/utils.ts"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Multi-File Task
|
|
183
|
+
```
|
|
184
|
+
/swarm_spawn "Add error handling to all API endpoints"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Parallelizable Task
|
|
188
|
+
```
|
|
189
|
+
/swarm_spawn "Add unit tests to all service files"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Task with Dependencies
|
|
193
|
+
```
|
|
194
|
+
/swarm_spawn "Refactor authentication and update all consuming code"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Limitations
|
|
198
|
+
|
|
199
|
+
- Maximum 4 workers (configurable via command, but limited to 4)
|
|
200
|
+
- File-based decomposition (may not work for complex architectural changes)
|
|
201
|
+
- No task history (status only shows current task)
|
|
202
|
+
- No automatic retry for failed subtasks
|
|
203
|
+
|
|
204
|
+
## Uninstallation
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
swarm-control uninstall
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
This removes:
|
|
211
|
+
- Plugin files from `~/.opencode/plugins/swarm-control/`
|
|
212
|
+
- Swarm configuration from OpenCode config
|
|
213
|
+
|
|
214
|
+
To also remove state, run `swarm-control reset` before uninstalling.
|
|
215
|
+
|
|
216
|
+
## Contributing
|
|
217
|
+
|
|
218
|
+
Contributions are welcome! Please feel free to submit issues or pull requests.
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
ISC
|
|
223
|
+
|
|
224
|
+
## Support
|
|
225
|
+
|
|
226
|
+
For issues or questions:
|
|
227
|
+
- Check the troubleshooting section above
|
|
228
|
+
- Open an issue on GitHub
|
|
229
|
+
- Join the OpenCode Discord community
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { setupPlugin } from './installer.js';
|
|
4
|
+
import { uninstallPlugin } from './installer.js';
|
|
5
|
+
import { resetState } from './installer.js';
|
|
6
|
+
const program = new Command();
|
|
7
|
+
program
|
|
8
|
+
.name('swarm-control')
|
|
9
|
+
.description('OpenCode swarm control plugin installer')
|
|
10
|
+
.version('1.0.0');
|
|
11
|
+
program
|
|
12
|
+
.command('setup')
|
|
13
|
+
.description('Install the swarm-control plugin to opencode')
|
|
14
|
+
.action(setupPlugin);
|
|
15
|
+
program
|
|
16
|
+
.command('uninstall')
|
|
17
|
+
.description('Remove the swarm-control plugin from opencode')
|
|
18
|
+
.action(uninstallPlugin);
|
|
19
|
+
program
|
|
20
|
+
.command('reset')
|
|
21
|
+
.description('Reset swarm-control state and configuration')
|
|
22
|
+
.action(resetState);
|
|
23
|
+
program.parse(process.argv);
|
|
24
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,eAAe,CAAC;KACrB,WAAW,CAAC,yCAAyC,CAAC;KACtD,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,8CAA8C,CAAC;KAC3D,MAAM,CAAC,WAAW,CAAC,CAAA;AAEtB,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,eAAe,CAAC,CAAA;AAE1B,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,UAAU,CAAC,CAAA;AAErB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAeA,wBAAsB,WAAW,kBA8BhC;AAED,wBAAsB,eAAe,kBAiBpC;AAED,wBAAsB,UAAU,kBAiB/B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const PLUGIN_SOURCE = path.join(__dirname, 'plugin');
|
|
9
|
+
const PLUGIN_TARGET = path.join(process.env.HOME, '.opencode/plugins/swarm-control');
|
|
10
|
+
const OPENCODE_CONFIG_DIR = path.join(process.env.HOME, '.config/opencode');
|
|
11
|
+
const OPENCODE_CONFIG_FILE = path.join(OPENCODE_CONFIG_DIR, 'opencode.json');
|
|
12
|
+
const SWARM_CONFIG_KEY = 'swarm';
|
|
13
|
+
export async function setupPlugin() {
|
|
14
|
+
const spinner = ora('Installing swarm-control plugin...').start();
|
|
15
|
+
try {
|
|
16
|
+
// Ensure target directory exists
|
|
17
|
+
await fs.ensureDir(PLUGIN_TARGET);
|
|
18
|
+
// Copy plugin files
|
|
19
|
+
await fs.copy(PLUGIN_SOURCE, PLUGIN_TARGET, {
|
|
20
|
+
overwrite: true,
|
|
21
|
+
filter: (src) => !src.endsWith('.map')
|
|
22
|
+
});
|
|
23
|
+
// Verify installation
|
|
24
|
+
const indexExists = await fs.pathExists(path.join(PLUGIN_TARGET, 'index.js'));
|
|
25
|
+
if (!indexExists) {
|
|
26
|
+
throw new Error('Installation failed - plugin files not found');
|
|
27
|
+
}
|
|
28
|
+
spinner.succeed(chalk.green('Plugin installed successfully!'));
|
|
29
|
+
console.log(chalk.bold('\nNext steps:'));
|
|
30
|
+
console.log('1. Restart opencode');
|
|
31
|
+
console.log('2. Configure the swarm model: /swarm_model <model-name>');
|
|
32
|
+
console.log('3. Start using: /swarm_spawn "your task"');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
spinner.fail(chalk.red('Installation failed'));
|
|
36
|
+
console.error(error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function uninstallPlugin() {
|
|
41
|
+
const spinner = ora('Uninstalling swarm-control plugin...').start();
|
|
42
|
+
try {
|
|
43
|
+
// Remove plugin files
|
|
44
|
+
await fs.remove(PLUGIN_TARGET);
|
|
45
|
+
// Remove swarm config from opencode config
|
|
46
|
+
await removeSwarmConfig();
|
|
47
|
+
spinner.succeed(chalk.green('Plugin uninstalled successfully'));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
spinner.fail(chalk.red('Uninstallation failed'));
|
|
51
|
+
console.error(error);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function resetState() {
|
|
56
|
+
const spinner = ora('Resetting swarm-control state...').start();
|
|
57
|
+
try {
|
|
58
|
+
// Remove state file
|
|
59
|
+
const stateFile = path.join(process.env.HOME, '.config/swarm-control/state.json');
|
|
60
|
+
await fs.remove(stateFile);
|
|
61
|
+
spinner.succeed(chalk.green('State reset successfully'));
|
|
62
|
+
console.log(chalk.yellow('\nNote: Configuration (swarm model) is preserved.'));
|
|
63
|
+
console.log('To remove configuration, run: swarm-control uninstall');
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
spinner.fail(chalk.red('Reset failed'));
|
|
67
|
+
console.error(error);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function removeSwarmConfig() {
|
|
72
|
+
try {
|
|
73
|
+
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
74
|
+
if (!configExists)
|
|
75
|
+
return;
|
|
76
|
+
const config = await fs.readJson(OPENCODE_CONFIG_FILE);
|
|
77
|
+
// Remove swarm config if it exists
|
|
78
|
+
if (config[SWARM_CONFIG_KEY]) {
|
|
79
|
+
delete config[SWARM_CONFIG_KEY];
|
|
80
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, config, { spaces: 2 });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.warn(chalk.yellow('Warning: Could not update opencode config'));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAA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AA0B,CAAC,CAAC,CAAA;QACxD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,mDAAmD,CAAC,CAAC,CAAA;QAC9E,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAA;IAEtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAA;QACvC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,iBAAiB;IAC9B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA;QAC9D,IAAI,CAAC,YAAY;YAAE,OAAM;QAEzB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAA;QAEtD,mCAAmC;QACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAA;YAC/B,MAAM,EAAE,CAAC,SAAS,CAAC,oBAAoB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;QACjE,CAAC;IAEH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SwarmConfig } from './types.js';
|
|
2
|
+
export declare function getConfig(): Promise<SwarmConfig | null>;
|
|
3
|
+
export declare function setConfig(config: SwarmConfig): Promise<void>;
|
|
4
|
+
export declare function clearConfig(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAMhE,wBAAsB,SAAS,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAc7D;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBlE;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAUjD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { SwarmConfigSchema } from './types.js';
|
|
4
|
+
const OPENCODE_CONFIG_DIR = path.join(process.env.HOME, '.config/opencode');
|
|
5
|
+
const OPENCODE_CONFIG_FILE = path.join(OPENCODE_CONFIG_DIR, 'opencode.json');
|
|
6
|
+
const SWARM_CONFIG_KEY = 'swarm';
|
|
7
|
+
export async function getConfig() {
|
|
8
|
+
try {
|
|
9
|
+
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
10
|
+
if (!configExists)
|
|
11
|
+
return null;
|
|
12
|
+
const data = await fs.readFile(OPENCODE_CONFIG_FILE, 'utf-8');
|
|
13
|
+
const parsed = JSON.parse(data);
|
|
14
|
+
if (!parsed[SWARM_CONFIG_KEY])
|
|
15
|
+
return null;
|
|
16
|
+
return SwarmConfigSchema.parse(parsed[SWARM_CONFIG_KEY]);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export async function setConfig(config) {
|
|
23
|
+
await fs.ensureDir(OPENCODE_CONFIG_DIR);
|
|
24
|
+
let existingConfig = {};
|
|
25
|
+
try {
|
|
26
|
+
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
27
|
+
if (configExists) {
|
|
28
|
+
existingConfig = await fs.readJson(OPENCODE_CONFIG_FILE);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Config doesn't exist or is invalid, start fresh
|
|
33
|
+
}
|
|
34
|
+
const newConfig = {
|
|
35
|
+
...existingConfig,
|
|
36
|
+
[SWARM_CONFIG_KEY]: config
|
|
37
|
+
};
|
|
38
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, newConfig, { spaces: 2 });
|
|
39
|
+
}
|
|
40
|
+
export async function clearConfig() {
|
|
41
|
+
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
42
|
+
if (!configExists)
|
|
43
|
+
return;
|
|
44
|
+
const config = await fs.readJson(OPENCODE_CONFIG_FILE);
|
|
45
|
+
if (config[SWARM_CONFIG_KEY]) {
|
|
46
|
+
delete config[SWARM_CONFIG_KEY];
|
|
47
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, config, { spaces: 2 });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AAEhE,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAK,EAAE,kBAAkB,CAAC,CAAA;AAC5E,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA;AAC5E,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,oB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AAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAEtD,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAA;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC,oBAAoB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SwarmConfig, SwarmTask, WorkerInfo } from './types.js';
|
|
2
|
+
import { StateManager } from './state.js';
|
|
3
|
+
export declare function createSwarmCoordinator(client: any, directory: string, config: SwarmConfig): {
|
|
4
|
+
execute(task: string, decomposition: any, maxWorkers: number): Promise<string>;
|
|
5
|
+
findIdleWorker(workers: WorkerInfo[]): WorkerInfo | undefined;
|
|
6
|
+
waitForDependencies(state: StateManager, taskId: string, depIds: string[], completedSubtasks: Set<string>): Promise<void>;
|
|
7
|
+
formatSummary(task: SwarmTask, decomposition: any): string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/plugin/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAW,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAGzC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW;kBAKG,MAAM,iBAAiB,GAAG,cAAc,MAAM;4BA6G1C,UAAU,EAAE,GAAG,UAAU,GAAG,SAAS;+BAKpD,YAAY,UACX,MAAM,UACN,MAAM,EAAE,qBACG,GAAG,CAAC,MAAM,CAAC;wBAmBZ,SAAS,iBAAiB,GAAG,GAAG,MAAM;EA6C7D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { lockManager } from './file-lock.js';
|
|
2
|
+
import { StateManager } from './state.js';
|
|
3
|
+
import { executeSubtask } from './worker.js';
|
|
4
|
+
export function createSwarmCoordinator(client, directory, config) {
|
|
5
|
+
const state = new StateManager();
|
|
6
|
+
return {
|
|
7
|
+
async execute(task, decomposition, maxWorkers) {
|
|
8
|
+
const taskId = `task-${Date.now()}`;
|
|
9
|
+
const swarmTask = {
|
|
10
|
+
id: taskId,
|
|
11
|
+
description: task,
|
|
12
|
+
status: 'in_progress',
|
|
13
|
+
subtasks: decomposition.subtasks,
|
|
14
|
+
createdAt: Date.now()
|
|
15
|
+
};
|
|
16
|
+
await state.setCurrentTask(swarmTask);
|
|
17
|
+
// Create worker sessions (child sessions)
|
|
18
|
+
const workers = [];
|
|
19
|
+
for (let i = 0; i < decomposition.numWorkers; i++) {
|
|
20
|
+
try {
|
|
21
|
+
const session = await client.session.create({
|
|
22
|
+
body: { title: `Swarm Worker ${i + 1}` }
|
|
23
|
+
});
|
|
24
|
+
workers.push({
|
|
25
|
+
id: `worker-${i}`,
|
|
26
|
+
sessionId: session.id,
|
|
27
|
+
status: 'idle'
|
|
28
|
+
});
|
|
29
|
+
await state.updateWorker(workers[i]);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
await client.app.log({
|
|
33
|
+
service: 'swarm-control',
|
|
34
|
+
level: 'error',
|
|
35
|
+
message: `Failed to create worker ${i}`,
|
|
36
|
+
extra: { error: error instanceof Error ? error.message : 'Unknown error' }
|
|
37
|
+
});
|
|
38
|
+
throw new Error(`Failed to create worker session: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Execute subtasks respecting dependencies
|
|
42
|
+
const results = [];
|
|
43
|
+
const completedSubtasks = new Set();
|
|
44
|
+
for (const subtask of decomposition.subtasks) {
|
|
45
|
+
// Wait for dependencies
|
|
46
|
+
if (subtask.dependsOn && subtask.dependsOn.length > 0) {
|
|
47
|
+
await this.waitForDependencies(state, taskId, subtask.dependsOn, completedSubtasks);
|
|
48
|
+
}
|
|
49
|
+
// Acquire file locks
|
|
50
|
+
for (const file of subtask.files) {
|
|
51
|
+
const worker = this.findIdleWorker(workers);
|
|
52
|
+
if (!worker) {
|
|
53
|
+
throw new Error('No available workers');
|
|
54
|
+
}
|
|
55
|
+
await lockManager.acquireLock(file, worker.id);
|
|
56
|
+
}
|
|
57
|
+
// Assign to worker
|
|
58
|
+
const worker = this.findIdleWorker(workers);
|
|
59
|
+
if (!worker) {
|
|
60
|
+
// Release locks and throw error
|
|
61
|
+
for (const file of subtask.files) {
|
|
62
|
+
lockManager.releaseLock(file);
|
|
63
|
+
}
|
|
64
|
+
throw new Error('No available workers');
|
|
65
|
+
}
|
|
66
|
+
worker.status = 'working';
|
|
67
|
+
worker.currentSubtaskId = subtask.id;
|
|
68
|
+
await state.updateWorker(worker);
|
|
69
|
+
await state.updateSubtaskStatus(taskId, subtask.id, 'in_progress');
|
|
70
|
+
// Execute subtask
|
|
71
|
+
try {
|
|
72
|
+
const result = await executeSubtask(client, worker, subtask, config.model);
|
|
73
|
+
results.push(result);
|
|
74
|
+
await state.updateSubtaskStatus(taskId, subtask.id, 'completed', result);
|
|
75
|
+
completedSubtasks.add(subtask.id);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
79
|
+
await client.app.log({
|
|
80
|
+
service: 'swarm-control',
|
|
81
|
+
level: 'error',
|
|
82
|
+
message: `Subtask ${subtask.id} failed`,
|
|
83
|
+
extra: { error: errorMsg, subtaskId: subtask.id }
|
|
84
|
+
});
|
|
85
|
+
await state.updateSubtaskStatus(taskId, subtask.id, 'failed', undefined, errorMsg);
|
|
86
|
+
}
|
|
87
|
+
// Release file locks
|
|
88
|
+
for (const file of subtask.files) {
|
|
89
|
+
lockManager.releaseLock(file);
|
|
90
|
+
}
|
|
91
|
+
worker.status = 'idle';
|
|
92
|
+
worker.currentSubtaskId = undefined;
|
|
93
|
+
await state.updateWorker(worker);
|
|
94
|
+
}
|
|
95
|
+
swarmTask.status = 'completed';
|
|
96
|
+
swarmTask.completedAt = Date.now();
|
|
97
|
+
await state.setCurrentTask(swarmTask);
|
|
98
|
+
return this.formatSummary(swarmTask, decomposition);
|
|
99
|
+
},
|
|
100
|
+
findIdleWorker(workers) {
|
|
101
|
+
return workers.find(w => w.status === 'idle');
|
|
102
|
+
},
|
|
103
|
+
async waitForDependencies(state, taskId, depIds, completedSubtasks) {
|
|
104
|
+
let attempts = 0;
|
|
105
|
+
const maxAttempts = 300; // 5 minutes timeout
|
|
106
|
+
while (attempts < maxAttempts) {
|
|
107
|
+
const task = await state.getCurrentTask();
|
|
108
|
+
if (!task)
|
|
109
|
+
break;
|
|
110
|
+
const allComplete = depIds.every(id => {
|
|
111
|
+
return completedSubtasks.has(id) || task.subtasks.find(s => s.id === id)?.status === 'completed';
|
|
112
|
+
});
|
|
113
|
+
if (allComplete)
|
|
114
|
+
break;
|
|
115
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
116
|
+
attempts++;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
formatSummary(task, decomposition) {
|
|
120
|
+
const completed = task.subtasks.filter((s) => s.status === 'completed').length;
|
|
121
|
+
const failed = task.subtasks.filter((s) => s.status === 'failed').length;
|
|
122
|
+
let summary = `## Swarm Task Completed\n\n`;
|
|
123
|
+
summary += `**Task:** ${task.description}\n\n`;
|
|
124
|
+
summary += `**Subtasks:** ${completed}/${task.subtasks.length} completed`;
|
|
125
|
+
if (failed > 0) {
|
|
126
|
+
summary += ` (${failed} failed)`;
|
|
127
|
+
}
|
|
128
|
+
summary += `\n\n`;
|
|
129
|
+
if (decomposition.analysis) {
|
|
130
|
+
summary += `**Approach:** ${decomposition.analysis}\n\n`;
|
|
131
|
+
}
|
|
132
|
+
summary += `**Details:**\n\n`;
|
|
133
|
+
for (const subtask of task.subtasks) {
|
|
134
|
+
const statusEmoji = subtask.status === 'completed' ? '✅' :
|
|
135
|
+
subtask.status === 'failed' ? '❌' :
|
|
136
|
+
subtask.status === 'in_progress' ? '⏳' : '⏸️';
|
|
137
|
+
summary += `${statusEmoji} **${subtask.description}**\n`;
|
|
138
|
+
if (subtask.files && subtask.files.length > 0) {
|
|
139
|
+
summary += ` Files: ${subtask.files.join(', ')}\n`;
|
|
140
|
+
}
|
|
141
|
+
if (subtask.result) {
|
|
142
|
+
summary += ` Result: ${subtask.result}\n`;
|
|
143
|
+
}
|
|
144
|
+
if (subtask.error) {
|
|
145
|
+
summary += ` Error: ${subtask.error}\n`;
|
|
146
|
+
}
|
|
147
|
+
summary += '\n';
|
|
148
|
+
}
|
|
149
|
+
return summary.trim();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../src/plugin/coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,UAAU,sBAAsB,CACpC,MAAW,EACX,SAAiB,EACjB,MAAmB;IAEnB,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAA;IAEhC,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,aAAkB,EAAE,UAAkB;YAChE,MAAM,MAAM,GAAG,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;YAEnC,MAAM,SAAS,GAAc;gBAC3B,EAAE,EAAE,MAAM;gBACV,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,aAAa;gBACrB,QAAQ,EA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,CAAC,IAAI,CAAA;gBACtD,CAAC;gBAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACnB,OAAO,IAAI,cAAc,OAAO,CAAC,MAAM,IAAI,CAAA;gBAC7C,CAAC;gBAED,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,IAAI,aAAa,OAAO,CAAC,KAAK,IAAI,CAAA;gBAC3C,CAAC;gBAED,OAAO,IAAI,IAAI,CAAA;YACjB,CAAC;YAED,OAAO,OAAO,CAAC,IAAI,EAAE,CAAA;QACvB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function decomposeTask(client: any, model: string, task: string, context: any): Promise<{
|
|
2
|
+
analysis: string;
|
|
3
|
+
numWorkers: number;
|
|
4
|
+
subtasks: {
|
|
5
|
+
id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
files: string[];
|
|
8
|
+
dependsOn?: string[] | undefined;
|
|
9
|
+
}[];
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=decomposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposer.d.ts","sourceRoot":"","sources":["../../src/plugin/decomposer.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,CACjC,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,GAAG;;;;;;;;;GAqEb"}
|