swarm-control 0.1.5 → 0.1.7
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/README.md +4 -2
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +46 -32
- package/dist/installer.js.map +1 -1
- package/index.ts +1 -0
- package/package.json +17 -4
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ After installation, run the setup command:
|
|
|
25
25
|
swarm-control setup
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
This will
|
|
28
|
+
This will:
|
|
29
|
+
1. Install the swarm-control package to OpenCode's node_modules
|
|
30
|
+
2. Add it to the plugin list in your OpenCode config
|
|
29
31
|
|
|
30
32
|
**Important**: You must restart OpenCode after running setup for the plugin to be loaded.
|
|
31
33
|
|
|
@@ -208,7 +210,7 @@ swarm-control uninstall
|
|
|
208
210
|
```
|
|
209
211
|
|
|
210
212
|
This removes:
|
|
211
|
-
-
|
|
213
|
+
- `swarm-control` from OpenCode's plugin list
|
|
212
214
|
- Swarm configuration from OpenCode config
|
|
213
215
|
|
|
214
216
|
To also remove state, run `swarm-control reset` before uninstalling.
|
package/dist/installer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAoBA,wBAAsB,WAAW,kBAkBhC;AAED,wBAAsB,eAAe,kBAepC;AAED,wBAAsB,UAAU,kBAiB/B"}
|
package/dist/installer.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
+
import JSON5 from 'json5';
|
|
4
5
|
import chalk from 'chalk';
|
|
5
6
|
import ora from 'ora';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
// Determine
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const PLUGIN_DIST_PATH = path.join(PACKAGE_ROOT, 'dist/plugin');
|
|
13
|
-
const PLUGIN_TEMPLATE = path.join(PACKAGE_ROOT, 'templates/swarm-control.template.ts');
|
|
14
|
-
const PLUGIN_TARGET = path.join(process.env.HOME, '.config/opencode/plugin/swarm-control.ts');
|
|
9
|
+
// Determine if running from npm global install
|
|
10
|
+
const IS_GLOBAL_INSTALL = __dirname.includes('node_modules') &&
|
|
11
|
+
__dirname.includes(process.env.HOME || '') &&
|
|
12
|
+
!__dirname.includes('node_modules/swarm-control');
|
|
15
13
|
const OPENCODE_CONFIG_DIR = path.join(process.env.HOME, '.config/opencode');
|
|
16
14
|
const OPENCODE_CONFIG_FILE = path.join(OPENCODE_CONFIG_DIR, 'opencode.json');
|
|
15
|
+
const OPENCODE_CACHE_DIR = path.join(process.env.HOME, '.cache/opencode');
|
|
17
16
|
const SWARM_CONFIG_KEY = 'swarm';
|
|
18
17
|
export async function setupPlugin() {
|
|
19
18
|
const spinner = ora('Installing swarm-control plugin...').start();
|
|
20
19
|
try {
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
// Replace placeholder with the actual package path
|
|
24
|
-
// Use .js extension since this is an ESM module
|
|
25
|
-
const packagePath = path.join(PACKAGE_ROOT, 'dist/plugin/index.js');
|
|
26
|
-
const pluginContent = template.replace('PLACEHOLDER_PACKAGE_PATH', packagePath);
|
|
27
|
-
// Ensure plugin directory exists
|
|
28
|
-
const pluginDir = path.dirname(PLUGIN_TARGET);
|
|
29
|
-
await fs.ensureDir(pluginDir);
|
|
30
|
-
// Write the generated plugin file
|
|
31
|
-
await fs.writeFile(PLUGIN_TARGET, pluginContent, 'utf-8');
|
|
32
|
-
// Verify installation
|
|
33
|
-
const exists = await fs.pathExists(PLUGIN_TARGET);
|
|
34
|
-
if (!exists) {
|
|
35
|
-
throw new Error('Installation failed - plugin file not found');
|
|
36
|
-
}
|
|
20
|
+
// Add plugin to OpenCode config
|
|
21
|
+
await addToConfig();
|
|
37
22
|
spinner.succeed(chalk.green('Plugin installed successfully!'));
|
|
38
23
|
console.log(chalk.bold('\nNext steps:'));
|
|
39
24
|
console.log('1. Restart opencode');
|
|
40
|
-
console.log('2. Configure
|
|
25
|
+
console.log('2. Configure swarm model: /swarm_model <model-name>');
|
|
41
26
|
console.log('3. Start using: /swarm_spawn "your task"');
|
|
42
27
|
}
|
|
43
28
|
catch (error) {
|
|
@@ -49,11 +34,10 @@ export async function setupPlugin() {
|
|
|
49
34
|
export async function uninstallPlugin() {
|
|
50
35
|
const spinner = ora('Uninstalling swarm-control plugin...').start();
|
|
51
36
|
try {
|
|
52
|
-
// Remove plugin
|
|
53
|
-
await
|
|
54
|
-
// Remove swarm config from opencode config
|
|
55
|
-
await removeSwarmConfig();
|
|
37
|
+
// Remove plugin from OpenCode config
|
|
38
|
+
await removeFromConfig();
|
|
56
39
|
spinner.succeed(chalk.green('Plugin uninstalled successfully'));
|
|
40
|
+
console.log(chalk.yellow('\nNote: Run "npm uninstall -g swarm-control" to remove the global package'));
|
|
57
41
|
}
|
|
58
42
|
catch (error) {
|
|
59
43
|
spinner.fail(chalk.red('Uninstallation failed'));
|
|
@@ -77,17 +61,47 @@ export async function resetState() {
|
|
|
77
61
|
process.exit(1);
|
|
78
62
|
}
|
|
79
63
|
}
|
|
80
|
-
async function
|
|
64
|
+
async function addToConfig() {
|
|
65
|
+
try {
|
|
66
|
+
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
67
|
+
if (!configExists) {
|
|
68
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, { plugin: ['swarm-control'] }, { spaces: 2 });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Read config as text (it may have comments)
|
|
72
|
+
const configText = await fs.readFile(OPENCODE_CONFIG_FILE, 'utf-8');
|
|
73
|
+
// Parse config with json5 (supports comments)
|
|
74
|
+
const config = JSON5.parse(configText);
|
|
75
|
+
// Add swarm-control to plugin list
|
|
76
|
+
if (!config.plugin) {
|
|
77
|
+
config.plugin = [];
|
|
78
|
+
}
|
|
79
|
+
if (!config.plugin.includes('swarm-control')) {
|
|
80
|
+
config.plugin.push('swarm-control');
|
|
81
|
+
}
|
|
82
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, config, { spaces: 2 });
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.warn(chalk.yellow('Warning: Could not update opencode config'));
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function removeFromConfig() {
|
|
81
90
|
try {
|
|
82
91
|
const configExists = await fs.pathExists(OPENCODE_CONFIG_FILE);
|
|
83
92
|
if (!configExists)
|
|
84
93
|
return;
|
|
85
|
-
const
|
|
86
|
-
|
|
94
|
+
const configText = await fs.readFile(OPENCODE_CONFIG_FILE, 'utf-8');
|
|
95
|
+
const config = JSON5.parse(configText);
|
|
96
|
+
// Remove swarm-control from plugin list
|
|
97
|
+
if (config.plugin && Array.isArray(config.plugin)) {
|
|
98
|
+
config.plugin = config.plugin.filter((p) => p !== 'swarm-control');
|
|
99
|
+
}
|
|
100
|
+
// Remove swarm config
|
|
87
101
|
if (config[SWARM_CONFIG_KEY]) {
|
|
88
102
|
delete config[SWARM_CONFIG_KEY];
|
|
89
|
-
await fs.writeJson(OPENCODE_CONFIG_FILE, config, { spaces: 2 });
|
|
90
103
|
}
|
|
104
|
+
await fs.writeJson(OPENCODE_CONFIG_FILE, config, { spaces: 2 });
|
|
91
105
|
}
|
|
92
106
|
catch (error) {
|
|
93
107
|
console.warn(chalk.yellow('Warning: Could not update opencode config'));
|
package/dist/installer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,eAAe,CAAC,CAAA;QAC5E,CAAC;QAED,sBAAsB;QACtB,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACjC,CAAC;QAED,MAAM,EAAE,CAAC,SAAS,CAAC,oBAAoB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IAEjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SwarmControlPlugin } from "./dist/plugin/index.js"
|
package/package.json
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swarm-control",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin for multi-agent swarm coordination",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"module": "index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./index.ts",
|
|
11
|
+
"types": "./index.ts"
|
|
12
|
+
},
|
|
13
|
+
"./cli": {
|
|
14
|
+
"import": "./dist/cli.js",
|
|
15
|
+
"types": "./dist/cli.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
7
18
|
"bin": {
|
|
8
19
|
"swarm-control": "./dist/cli.js"
|
|
9
20
|
},
|
|
10
21
|
"files": [
|
|
22
|
+
"index.ts",
|
|
11
23
|
"dist/",
|
|
12
24
|
"templates/",
|
|
13
25
|
"README.md",
|
|
@@ -22,10 +34,11 @@
|
|
|
22
34
|
"dependencies": {
|
|
23
35
|
"@opencode-ai/plugin": "^1.1.7",
|
|
24
36
|
"@opencode-ai/sdk": "^1.1.7",
|
|
25
|
-
"commander": "^11.0.0",
|
|
26
37
|
"chalk": "^5.3.0",
|
|
27
|
-
"
|
|
38
|
+
"commander": "^11.0.0",
|
|
28
39
|
"fs-extra": "^11.0.0",
|
|
40
|
+
"json5": "^2.2.3",
|
|
41
|
+
"ora": "^7.0.0",
|
|
29
42
|
"zod": "^3.22.0"
|
|
30
43
|
},
|
|
31
44
|
"devDependencies": {
|