opencode-swarm 1.0.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 +162 -0
- package/dist/agents/architect.d.ts +7 -0
- package/dist/agents/auditor.d.ts +2 -0
- package/dist/agents/coder.d.ts +2 -0
- package/dist/agents/index.d.ts +19 -0
- package/dist/agents/security-reviewer.d.ts +2 -0
- package/dist/agents/sme/active-directory.d.ts +2 -0
- package/dist/agents/sme/azure.d.ts +2 -0
- package/dist/agents/sme/base.d.ts +13 -0
- package/dist/agents/sme/index.d.ts +20 -0
- package/dist/agents/sme/linux.d.ts +2 -0
- package/dist/agents/sme/network.d.ts +2 -0
- package/dist/agents/sme/oracle.d.ts +2 -0
- package/dist/agents/sme/powershell.d.ts +2 -0
- package/dist/agents/sme/python.d.ts +2 -0
- package/dist/agents/sme/security.d.ts +2 -0
- package/dist/agents/sme/ui-ux.d.ts +2 -0
- package/dist/agents/sme/vmware.d.ts +2 -0
- package/dist/agents/sme/windows.d.ts +2 -0
- package/dist/agents/test-engineer.d.ts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +148 -0
- package/dist/config/constants.d.ts +20 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/loader.d.ts +23 -0
- package/dist/config/schema.d.ts +46 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/pipeline-tracker.d.ts +34 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +27412 -0
- package/dist/tools/domain-detector.d.ts +6 -0
- package/dist/tools/file-extractor.d.ts +5 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
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,162 @@
|
|
|
1
|
+
# OpenCode Swarm
|
|
2
|
+
|
|
3
|
+
Architect-centric agentic swarm plugin for OpenCode. Hub-and-spoke orchestration with SME consultation, code generation, and QA review.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
OpenCode Swarm implements a multi-agent development pipeline where:
|
|
8
|
+
|
|
9
|
+
1. **Architect** (central orchestrator) analyzes requests and coordinates all agents
|
|
10
|
+
2. **SME Agents** provide domain-specific technical expertise (serial execution)
|
|
11
|
+
3. **Coder** implements unified specifications
|
|
12
|
+
4. **QA Agents** (Security Reviewer + Auditor) validate code quality
|
|
13
|
+
5. **Test Engineer** generates test cases for approved code
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
User → Architect (analyze) → [SME Pool - serial] → Architect (collate)
|
|
17
|
+
→ Coder → [QA: Security + Auditor] → Architect (triage) → Test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bunx opencode-swarm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then start OpenCode:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
opencode
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
Edit `~/.config/opencode/opencode-swarm.json`:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"preset": "hybrid",
|
|
39
|
+
"presets": {
|
|
40
|
+
"remote": {
|
|
41
|
+
"architect": { "model": "anthropic/claude-sonnet-4.5" },
|
|
42
|
+
"coder": { "model": "openai/gpt-5.2-codex" },
|
|
43
|
+
"_sme": { "model": "google/gemini-3-flash" },
|
|
44
|
+
"_qa": { "model": "google/gemini-3-flash" },
|
|
45
|
+
"test_engineer": { "model": "google/gemini-3-flash" }
|
|
46
|
+
},
|
|
47
|
+
"hybrid": {
|
|
48
|
+
"architect": { "model": "anthropic/claude-sonnet-4.5" },
|
|
49
|
+
"coder": { "model": "ollama/qwen3:72b" },
|
|
50
|
+
"_sme": { "model": "npu/qwen3:14b" },
|
|
51
|
+
"_qa": { "model": "npu/qwen3:14b" },
|
|
52
|
+
"test_engineer": { "model": "npu/qwen3:14b" }
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"swarm_mode": "hybrid",
|
|
56
|
+
"gpu_url": "http://192.168.1.100:1234/v1",
|
|
57
|
+
"npu_url": "http://localhost:11435/v1",
|
|
58
|
+
"max_iterations": 5
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Category Defaults
|
|
63
|
+
|
|
64
|
+
Use `_sme` and `_qa` to set models for all agents in a category:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"agents": {
|
|
69
|
+
"_sme": { "model": "npu/qwen3:14b" },
|
|
70
|
+
"_qa": { "model": "npu/qwen3:14b" }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To override a specific agent within a category:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"agents": {
|
|
80
|
+
"_sme": { "model": "npu/qwen3:14b" },
|
|
81
|
+
"sme_oracle": { "model": "ollama/qwen3:72b" }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Custom Prompts
|
|
87
|
+
|
|
88
|
+
Place custom prompts in `~/.config/opencode/opencode-swarm/`:
|
|
89
|
+
|
|
90
|
+
- `{agent}.md` - Replace the default prompt entirely
|
|
91
|
+
- `{agent}_append.md` - Append to the default prompt
|
|
92
|
+
|
|
93
|
+
Example: `architect_append.md` to add custom instructions to the Architect.
|
|
94
|
+
|
|
95
|
+
## Agents
|
|
96
|
+
|
|
97
|
+
### Orchestrator
|
|
98
|
+
|
|
99
|
+
| Agent | Role |
|
|
100
|
+
|-------|------|
|
|
101
|
+
| `architect` | Central orchestrator, coordinates all phases |
|
|
102
|
+
|
|
103
|
+
### SME Specialists (Domain Experts)
|
|
104
|
+
|
|
105
|
+
| Agent | Domain |
|
|
106
|
+
|-------|--------|
|
|
107
|
+
| `sme_windows` | Windows OS internals, registry, services |
|
|
108
|
+
| `sme_powershell` | PowerShell scripting, cmdlets, modules |
|
|
109
|
+
| `sme_python` | Python ecosystem, libraries, best practices |
|
|
110
|
+
| `sme_oracle` | Oracle Database, SQL/PLSQL, administration |
|
|
111
|
+
| `sme_network` | Networking, firewalls, DNS, TLS/SSL |
|
|
112
|
+
| `sme_security` | STIG compliance, hardening, encryption |
|
|
113
|
+
| `sme_linux` | Linux administration, systemd, packages |
|
|
114
|
+
| `sme_vmware` | VMware vSphere, ESXi, PowerCLI |
|
|
115
|
+
| `sme_azure` | Azure cloud services, Entra ID, ARM/Bicep |
|
|
116
|
+
| `sme_active_directory` | Active Directory, LDAP, Group Policy |
|
|
117
|
+
| `sme_ui_ux` | UI/UX design, interaction patterns |
|
|
118
|
+
|
|
119
|
+
### Pipeline Agents
|
|
120
|
+
|
|
121
|
+
| Agent | Role |
|
|
122
|
+
|-------|------|
|
|
123
|
+
| `coder` | Implements specifications, writes production code |
|
|
124
|
+
| `security_reviewer` | Security vulnerability assessment |
|
|
125
|
+
| `auditor` | Code correctness and quality review |
|
|
126
|
+
| `test_engineer` | Test case and validation script generation |
|
|
127
|
+
|
|
128
|
+
## Workflow Phases
|
|
129
|
+
|
|
130
|
+
1. **ANALYZE** - Parse request, identify domains, create initial spec
|
|
131
|
+
2. **SME_CONSULTATION** - Consult domain experts serially
|
|
132
|
+
3. **COLLATE** - Synthesize SME outputs into unified spec
|
|
133
|
+
4. **CODE** - Generate implementation
|
|
134
|
+
5. **QA_REVIEW** - Security and quality review (parallel)
|
|
135
|
+
6. **TRIAGE** - Approve, request revision, or block
|
|
136
|
+
7. **TEST** - Generate tests for approved code
|
|
137
|
+
|
|
138
|
+
## Delegation Rules
|
|
139
|
+
|
|
140
|
+
The Architect enforces resource-aware delegation:
|
|
141
|
+
|
|
142
|
+
- **SME agents**: Execute serially (one at a time) to avoid overwhelming local inference
|
|
143
|
+
- **QA agents**: May execute in parallel (independent analysis)
|
|
144
|
+
- **Cross-category**: One agent per category may run simultaneously
|
|
145
|
+
|
|
146
|
+
## Tools
|
|
147
|
+
|
|
148
|
+
| Tool | Description |
|
|
149
|
+
|------|-------------|
|
|
150
|
+
| `detect_domains` | Auto-detect SME domains from text |
|
|
151
|
+
| `extract_code_blocks` | Extract and save code blocks to files |
|
|
152
|
+
|
|
153
|
+
## Environment Variables
|
|
154
|
+
|
|
155
|
+
| Variable | Description |
|
|
156
|
+
|----------|-------------|
|
|
157
|
+
| `OPENCODE_SWARM_PRESET` | Override preset selection |
|
|
158
|
+
| `OPENCODE_SWARM_DEBUG` | Enable debug logging (`1` to enable) |
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentConfig } from '@opencode-ai/sdk';
|
|
2
|
+
export interface AgentDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
config: AgentConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare function createArchitectAgent(model: string, customPrompt?: string, customAppendPrompt?: string): AgentDefinition;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentConfig as SDKAgentConfig } from '@opencode-ai/sdk';
|
|
2
|
+
import { type PluginConfig } from '../config';
|
|
3
|
+
import { type AgentDefinition } from './architect';
|
|
4
|
+
export type { AgentDefinition } from './architect';
|
|
5
|
+
/**
|
|
6
|
+
* Create all agent definitions with configuration applied
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAgents(config?: PluginConfig): AgentDefinition[];
|
|
9
|
+
/**
|
|
10
|
+
* Get agent configurations formatted for the OpenCode SDK.
|
|
11
|
+
* Converts agent definitions to SDK config format and applies mode metadata.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAgentConfigs(config?: PluginConfig): Record<string, SDKAgentConfig>;
|
|
14
|
+
export { createArchitectAgent } from './architect';
|
|
15
|
+
export { createCoderAgent } from './coder';
|
|
16
|
+
export { createSecurityReviewerAgent } from './security-reviewer';
|
|
17
|
+
export { createAuditorAgent } from './auditor';
|
|
18
|
+
export { createTestEngineerAgent } from './test-engineer';
|
|
19
|
+
export { createAllSMEAgents, createSMEAgent, listDomains } from './sme';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentDefinition } from '../architect';
|
|
2
|
+
/**
|
|
3
|
+
* SME domain configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface SMEDomainConfig {
|
|
6
|
+
domain: string;
|
|
7
|
+
description: string;
|
|
8
|
+
guidance: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create an SME agent definition
|
|
12
|
+
*/
|
|
13
|
+
export declare function createSMEAgent(agentName: string, domainConfig: SMEDomainConfig, model: string, customPrompt?: string, customAppendPrompt?: string): AgentDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentDefinition } from '../architect';
|
|
2
|
+
import { type SMEDomainConfig } from './base';
|
|
3
|
+
export declare const SME_CONFIGS: Record<string, SMEDomainConfig>;
|
|
4
|
+
export declare const AGENT_TO_DOMAIN: Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Create all SME agent definitions
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAllSMEAgents(getModel: (agentName: string) => string, loadPrompt: (agentName: string) => {
|
|
9
|
+
prompt?: string;
|
|
10
|
+
appendPrompt?: string;
|
|
11
|
+
}): AgentDefinition[];
|
|
12
|
+
/**
|
|
13
|
+
* Get list of available SME domains
|
|
14
|
+
*/
|
|
15
|
+
export declare function listDomains(): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Get SME agent name for a domain
|
|
18
|
+
*/
|
|
19
|
+
export declare function domainToAgent(domain: string): string | undefined;
|
|
20
|
+
export { createSMEAgent, type SMEDomainConfig } from './base';
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
|
|
4
|
+
// src/cli/index.ts
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as os from "os";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
var CONFIG_DIR = path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "opencode");
|
|
9
|
+
var OPENCODE_CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
|
|
10
|
+
var PLUGIN_CONFIG_PATH = path.join(CONFIG_DIR, "opencode-swarm.json");
|
|
11
|
+
var PROMPTS_DIR = path.join(CONFIG_DIR, "opencode-swarm");
|
|
12
|
+
function ensureDir(dir) {
|
|
13
|
+
if (!fs.existsSync(dir)) {
|
|
14
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function loadJson(filepath) {
|
|
18
|
+
try {
|
|
19
|
+
const content = fs.readFileSync(filepath, "utf-8");
|
|
20
|
+
const stripped = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, comment) => comment ? "" : match).replace(/,(\s*[}\]])/g, "$1");
|
|
21
|
+
return JSON.parse(stripped);
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function saveJson(filepath, data) {
|
|
27
|
+
fs.writeFileSync(filepath, JSON.stringify(data, null, 2) + `
|
|
28
|
+
`, "utf-8");
|
|
29
|
+
}
|
|
30
|
+
async function install() {
|
|
31
|
+
console.log(`\uD83D\uDC1D Installing OpenCode Swarm...
|
|
32
|
+
`);
|
|
33
|
+
ensureDir(CONFIG_DIR);
|
|
34
|
+
ensureDir(PROMPTS_DIR);
|
|
35
|
+
let opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
36
|
+
if (!opencodeConfig) {
|
|
37
|
+
opencodeConfig = {};
|
|
38
|
+
}
|
|
39
|
+
if (!opencodeConfig.plugin) {
|
|
40
|
+
opencodeConfig.plugin = [];
|
|
41
|
+
}
|
|
42
|
+
const pluginName = "opencode-swarm";
|
|
43
|
+
opencodeConfig.plugin = opencodeConfig.plugin.filter((p) => p !== pluginName && !p.startsWith(`${pluginName}@`));
|
|
44
|
+
opencodeConfig.plugin.push(pluginName);
|
|
45
|
+
if (!opencodeConfig.agent) {
|
|
46
|
+
opencodeConfig.agent = {};
|
|
47
|
+
}
|
|
48
|
+
opencodeConfig.agent.explore = { disable: true };
|
|
49
|
+
opencodeConfig.agent.general = { disable: true };
|
|
50
|
+
saveJson(OPENCODE_CONFIG_PATH, opencodeConfig);
|
|
51
|
+
console.log("\u2713 Added opencode-swarm to OpenCode plugins");
|
|
52
|
+
console.log("\u2713 Disabled default OpenCode agents (explore, general)");
|
|
53
|
+
if (!fs.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
54
|
+
const defaultConfig = {
|
|
55
|
+
preset: "remote",
|
|
56
|
+
presets: {
|
|
57
|
+
remote: {
|
|
58
|
+
architect: { model: "anthropic/claude-sonnet-4.5" },
|
|
59
|
+
coder: { model: "openai/gpt-5.2-codex" },
|
|
60
|
+
_sme: { model: "google/gemini-3-flash" },
|
|
61
|
+
_qa: { model: "google/gemini-3-flash" },
|
|
62
|
+
test_engineer: { model: "google/gemini-3-flash" }
|
|
63
|
+
},
|
|
64
|
+
hybrid: {
|
|
65
|
+
architect: { model: "anthropic/claude-sonnet-4.5" },
|
|
66
|
+
coder: { model: "ollama/qwen3:72b" },
|
|
67
|
+
_sme: { model: "npu/qwen3:14b" },
|
|
68
|
+
_qa: { model: "npu/qwen3:14b" },
|
|
69
|
+
test_engineer: { model: "npu/qwen3:14b" }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
swarm_mode: "remote",
|
|
73
|
+
max_iterations: 5,
|
|
74
|
+
auto_detect_domains: true,
|
|
75
|
+
inject_phase_reminders: true
|
|
76
|
+
};
|
|
77
|
+
saveJson(PLUGIN_CONFIG_PATH, defaultConfig);
|
|
78
|
+
console.log("\u2713 Created default plugin config at:", PLUGIN_CONFIG_PATH);
|
|
79
|
+
} else {
|
|
80
|
+
console.log("\u2713 Plugin config already exists at:", PLUGIN_CONFIG_PATH);
|
|
81
|
+
}
|
|
82
|
+
console.log(`
|
|
83
|
+
\uD83D\uDCC1 Configuration files:`);
|
|
84
|
+
console.log(` OpenCode config: ${OPENCODE_CONFIG_PATH}`);
|
|
85
|
+
console.log(` Plugin config: ${PLUGIN_CONFIG_PATH}`);
|
|
86
|
+
console.log(` Custom prompts: ${PROMPTS_DIR}/`);
|
|
87
|
+
console.log(`
|
|
88
|
+
\uD83D\uDE80 Installation complete!`);
|
|
89
|
+
console.log(`
|
|
90
|
+
Next steps:`);
|
|
91
|
+
console.log("1. Edit the plugin config to customize models and settings");
|
|
92
|
+
console.log('2. Run "opencode" to start using the swarm');
|
|
93
|
+
console.log("3. The Architect agent will orchestrate your requests");
|
|
94
|
+
console.log(`
|
|
95
|
+
\uD83D\uDCD6 Available SME domains:`);
|
|
96
|
+
console.log(` windows, powershell, python, oracle, network, security,
|
|
97
|
+
` + " linux, vmware, azure, active_directory, ui_ux");
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
function printHelp() {
|
|
101
|
+
console.log(`
|
|
102
|
+
opencode-swarm - Architect-centric agentic swarm plugin for OpenCode
|
|
103
|
+
|
|
104
|
+
Usage: bunx opencode-swarm [command] [OPTIONS]
|
|
105
|
+
|
|
106
|
+
Commands:
|
|
107
|
+
install Install and configure the plugin (default)
|
|
108
|
+
|
|
109
|
+
Options:
|
|
110
|
+
-h, --help Show this help message
|
|
111
|
+
|
|
112
|
+
Configuration:
|
|
113
|
+
Edit ~/.config/opencode/opencode-swarm.json to customize:
|
|
114
|
+
- Model assignments per agent or category
|
|
115
|
+
- Preset configurations (remote, hybrid)
|
|
116
|
+
- Local inference endpoints (GPU/NPU URLs)
|
|
117
|
+
- Max iterations and other settings
|
|
118
|
+
|
|
119
|
+
Custom Prompts:
|
|
120
|
+
Place custom prompts in ~/.config/opencode/opencode-swarm/
|
|
121
|
+
- {agent}.md - Replace default prompt
|
|
122
|
+
- {agent}_append.md - Append to default prompt
|
|
123
|
+
|
|
124
|
+
Examples:
|
|
125
|
+
bunx opencode-swarm install
|
|
126
|
+
bunx opencode-swarm --help
|
|
127
|
+
`);
|
|
128
|
+
}
|
|
129
|
+
async function main() {
|
|
130
|
+
const args = process.argv.slice(2);
|
|
131
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
132
|
+
printHelp();
|
|
133
|
+
process.exit(0);
|
|
134
|
+
}
|
|
135
|
+
const command = args[0] || "install";
|
|
136
|
+
if (command === "install") {
|
|
137
|
+
const exitCode = await install();
|
|
138
|
+
process.exit(exitCode);
|
|
139
|
+
} else {
|
|
140
|
+
console.error(`Unknown command: ${command}`);
|
|
141
|
+
console.error("Run with --help for usage information");
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
main().catch((err) => {
|
|
146
|
+
console.error("Fatal error:", err);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SME_AGENTS: readonly ["sme_windows", "sme_powershell", "sme_python", "sme_oracle", "sme_network", "sme_security", "sme_linux", "sme_vmware", "sme_azure", "sme_active_directory", "sme_ui_ux"];
|
|
2
|
+
export declare const QA_AGENTS: readonly ["security_reviewer", "auditor"];
|
|
3
|
+
export declare const PIPELINE_AGENTS: readonly ["coder", "test_engineer"];
|
|
4
|
+
export declare const ORCHESTRATOR_NAME: "architect";
|
|
5
|
+
export declare const ALL_SUBAGENT_NAMES: readonly ["sme_windows", "sme_powershell", "sme_python", "sme_oracle", "sme_network", "sme_security", "sme_linux", "sme_vmware", "sme_azure", "sme_active_directory", "sme_ui_ux", "security_reviewer", "auditor", "coder", "test_engineer"];
|
|
6
|
+
export declare const ALL_AGENT_NAMES: readonly ["architect", "sme_windows", "sme_powershell", "sme_python", "sme_oracle", "sme_network", "sme_security", "sme_linux", "sme_vmware", "sme_azure", "sme_active_directory", "sme_ui_ux", "security_reviewer", "auditor", "coder", "test_engineer"];
|
|
7
|
+
export type SMEAgentName = (typeof SME_AGENTS)[number];
|
|
8
|
+
export type QAAgentName = (typeof QA_AGENTS)[number];
|
|
9
|
+
export type PipelineAgentName = (typeof PIPELINE_AGENTS)[number];
|
|
10
|
+
export type AgentName = (typeof ALL_AGENT_NAMES)[number];
|
|
11
|
+
export declare const CATEGORY_PREFIXES: {
|
|
12
|
+
readonly sme: "_sme";
|
|
13
|
+
readonly qa: "_qa";
|
|
14
|
+
};
|
|
15
|
+
export declare const DEFAULT_MODELS: Record<string, string>;
|
|
16
|
+
export declare const DOMAIN_PATTERNS: Record<string, RegExp[]>;
|
|
17
|
+
export declare function domainToAgentName(domain: string): SMEAgentName;
|
|
18
|
+
export declare function isSMEAgent(name: string): name is SMEAgentName;
|
|
19
|
+
export declare function isQAAgent(name: string): name is QAAgentName;
|
|
20
|
+
export declare function isSubagent(name: string): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ALL_AGENT_NAMES, ALL_SUBAGENT_NAMES, CATEGORY_PREFIXES, DEFAULT_MODELS, DOMAIN_PATTERNS, ORCHESTRATOR_NAME, PIPELINE_AGENTS, QA_AGENTS, SME_AGENTS, domainToAgentName, isQAAgent, isSMEAgent, isSubagent, } from './constants';
|
|
2
|
+
export type { AgentName, PipelineAgentName, QAAgentName, SMEAgentName, } from './constants';
|
|
3
|
+
export { AgentOverrideConfigSchema, PluginConfigSchema, PresetSchema, SwarmModeSchema, } from './schema';
|
|
4
|
+
export type { AgentOverrideConfig, PluginConfig, Preset, SwarmMode, } from './schema';
|
|
5
|
+
export { getOutputDir, loadAgentPrompt, loadPluginConfig, } from './loader';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type PluginConfig } from './schema';
|
|
2
|
+
/**
|
|
3
|
+
* Load plugin configuration from user and project config files.
|
|
4
|
+
*
|
|
5
|
+
* Config locations:
|
|
6
|
+
* 1. User config: ~/.config/opencode/opencode-swarm.json
|
|
7
|
+
* 2. Project config: <directory>/.opencode/opencode-swarm.json
|
|
8
|
+
*
|
|
9
|
+
* Project config takes precedence. Nested objects are deep-merged.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadPluginConfig(directory: string): PluginConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Load custom prompt for an agent from the prompts directory.
|
|
14
|
+
* Checks for {agent}.md (replaces default) and {agent}_append.md (appends).
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadAgentPrompt(agentName: string): {
|
|
17
|
+
prompt?: string;
|
|
18
|
+
appendPrompt?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the output directory for generated files.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getOutputDir(config: PluginConfig, projectDir: string): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgentOverrideConfigSchema: z.ZodObject<{
|
|
3
|
+
model: z.ZodOptional<z.ZodString>;
|
|
4
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
|
|
8
|
+
export declare const PresetSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
9
|
+
model: z.ZodOptional<z.ZodString>;
|
|
10
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
export type Preset = z.infer<typeof PresetSchema>;
|
|
14
|
+
export declare const SwarmModeSchema: z.ZodEnum<{
|
|
15
|
+
remote: "remote";
|
|
16
|
+
hybrid: "hybrid";
|
|
17
|
+
}>;
|
|
18
|
+
export type SwarmMode = z.infer<typeof SwarmModeSchema>;
|
|
19
|
+
export declare const PluginConfigSchema: z.ZodObject<{
|
|
20
|
+
preset: z.ZodOptional<z.ZodString>;
|
|
21
|
+
presets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
+
model: z.ZodOptional<z.ZodString>;
|
|
23
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strip>>>>;
|
|
26
|
+
agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
27
|
+
model: z.ZodOptional<z.ZodString>;
|
|
28
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
}, z.core.$strip>>>;
|
|
31
|
+
max_iterations: z.ZodDefault<z.ZodNumber>;
|
|
32
|
+
output_dir: z.ZodOptional<z.ZodString>;
|
|
33
|
+
swarm_mode: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
remote: "remote";
|
|
35
|
+
hybrid: "hybrid";
|
|
36
|
+
}>>;
|
|
37
|
+
gpu_url: z.ZodOptional<z.ZodString>;
|
|
38
|
+
gpu_model: z.ZodOptional<z.ZodString>;
|
|
39
|
+
npu_url: z.ZodOptional<z.ZodString>;
|
|
40
|
+
npu_model: z.ZodOptional<z.ZodString>;
|
|
41
|
+
global_fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
auto_detect_domains: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
inject_phase_reminders: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type PluginConfig = z.infer<typeof PluginConfigSchema>;
|
|
46
|
+
export type { AgentName, SMEAgentName, QAAgentName, PipelineAgentName, } from './constants';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createPipelineTrackerHook } from './pipeline-tracker';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Tracker Hook
|
|
3
|
+
*
|
|
4
|
+
* Injects phase reminders into messages to keep the Architect on track.
|
|
5
|
+
* Uses experimental.chat.messages.transform so it doesn't show in UI.
|
|
6
|
+
*
|
|
7
|
+
* Research: "LLMs Get Lost In Multi-Turn Conversation" shows ~40% compliance
|
|
8
|
+
* drop after 2-3 turns without reminders.
|
|
9
|
+
*/
|
|
10
|
+
import type { PluginConfig } from '../config';
|
|
11
|
+
interface MessageInfo {
|
|
12
|
+
role: string;
|
|
13
|
+
agent?: string;
|
|
14
|
+
sessionID?: string;
|
|
15
|
+
}
|
|
16
|
+
interface MessagePart {
|
|
17
|
+
type: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
interface MessageWithParts {
|
|
22
|
+
info: MessageInfo;
|
|
23
|
+
parts: MessagePart[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates the experimental.chat.messages.transform hook for pipeline tracking.
|
|
27
|
+
* Only injects for the architect agent.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createPipelineTrackerHook(config: PluginConfig): {
|
|
30
|
+
'experimental.chat.messages.transform': (_input: Record<string, never>, output: {
|
|
31
|
+
messages: MessageWithParts[];
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* OpenCode Swarm Plugin
|
|
4
|
+
*
|
|
5
|
+
* Architect-centric agentic swarm for code generation.
|
|
6
|
+
* Hub-and-spoke architecture with:
|
|
7
|
+
* - Architect as central orchestrator
|
|
8
|
+
* - Dynamic SME consultation (serial)
|
|
9
|
+
* - Code generation with QA review
|
|
10
|
+
* - Iterative refinement with triage
|
|
11
|
+
*/
|
|
12
|
+
declare const OpenCodeSwarm: Plugin;
|
|
13
|
+
export default OpenCodeSwarm;
|
|
14
|
+
export type { AgentName, PluginConfig, SMEAgentName, QAAgentName, PipelineAgentName, SwarmMode, } from './config';
|
|
15
|
+
export type { AgentDefinition } from './agents';
|