opencode-swarm 2.3.3 → 3.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/README.md CHANGED
@@ -1,112 +1,223 @@
1
- # OpenCode Swarm
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/version-3.0.0-blue" alt="Version">
3
+ <img src="https://img.shields.io/badge/license-MIT-green" alt="License">
4
+ <img src="https://img.shields.io/badge/opencode-plugin-purple" alt="OpenCode Plugin">
5
+ <img src="https://img.shields.io/badge/agents-20+-orange" alt="Agents">
6
+ </p>
7
+
8
+ <h1 align="center">🐝 OpenCode Swarm</h1>
9
+
10
+ <p align="center">
11
+ <strong>The only multi-agent framework that actually works.</strong><br>
12
+ Structured phases. Persistent memory. One task at a time. QA on everything.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="#why-swarm">Why Swarm?</a> •
17
+ <a href="#how-it-works">How It Works</a> •
18
+ <a href="#installation">Installation</a> •
19
+ <a href="#agents">Agents</a> •
20
+ <a href="#configuration">Configuration</a>
21
+ </p>
2
22
 
3
- ![License](https://img.shields.io/badge/license-MIT-blue)
4
- ![OpenCode Plugin](https://img.shields.io/badge/opencode-plugin-green)
5
- ![Architecture](https://img.shields.io/badge/architecture-architect--centric-purple)
6
- ![Version](https://img.shields.io/badge/version-2.2.1-orange)
23
+ ---
24
+
25
+ ## The Problem with Every Other Multi-Agent System
26
+
27
+ ```
28
+ You: "Build me an authentication system"
29
+
30
+ Other Frameworks:
31
+ ├── Agent 1 starts auth module...
32
+ ├── Agent 2 starts user model... (conflicts with Agent 1)
33
+ ├── Agent 3 starts database... (wrong schema)
34
+ ├── Agent 4 starts tests... (for code that doesn't exist yet)
35
+ └── Result: Chaos. Conflicts. Context lost. Start over.
36
+
37
+ OpenCode Swarm:
38
+ ├── Architect analyzes request
39
+ ├── Explorer scans codebase
40
+ ├── Security SME provides auth guidance
41
+ ├── Architect creates phased plan with acceptance criteria
42
+ ├── Phase 1: User model → QA → Tests → ✓
43
+ ├── Phase 2: Auth logic → QA → Tests → ✓
44
+ ├── Phase 3: Session management → QA → Tests → ✓
45
+ └── Result: Working code. Documented decisions. Resumable progress.
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Why Swarm?
51
+
52
+ <table>
53
+ <tr>
54
+ <td width="50%">
55
+
56
+ ### ❌ Other Frameworks
57
+
58
+ - Parallel chaos, hope it converges
59
+ - Single model = correlated failures
60
+ - No planning, just vibes
61
+ - Context lost between sessions
62
+ - QA as afterthought (if at all)
63
+ - Entire codebase in one prompt
64
+ - No way to resume projects
65
+
66
+ </td>
67
+ <td width="50%">
68
+
69
+ ### ✅ OpenCode Swarm
70
+
71
+ - **Serial execution** - predictable, traceable
72
+ - **Heterogeneous models** - different perspectives catch errors
73
+ - **Phased planning** - documented tasks with acceptance criteria
74
+ - **Persistent memory** - `.swarm/` files survive sessions
75
+ - **QA per task** - security + audit before anything ships
76
+ - **One task at a time** - focused, quality code
77
+ - **Resumable projects** - pick up exactly where you left off
7
78
 
8
- **Architect-driven, multi-agent development for OpenCode.**
79
+ </td>
80
+ </tr>
81
+ </table>
9
82
 
10
- Design-first orchestration with codebase discovery, domain-aware SMEs, heterogeneous model perspectives, and layered QA review.
83
+ ---
84
+
85
+ ## How It Works
11
86
 
12
87
  ```
13
- ┌──────────────────────────────────────────────────────────────────────────┐
14
- │ "Review this PowerShell application for security issues"
15
- └──────────────────────────────────────────────────────────────────────────┘
88
+ ┌─────────────────────────────────────────────────────────────────────────┐
89
+ USER: "Add user authentication with JWT"
90
+ └─────────────────────────────────────────────────────────────────────────┘
91
+
92
+
93
+ ┌─────────────────────────────────────────────────────────────────────────┐
94
+ │ PHASE 0: Check for .swarm/plan.md │
95
+ │ Exists? Resume. New? Continue. │
96
+ └─────────────────────────────────────────────────────────────────────────┘
97
+
98
+
99
+ ┌─────────────────────────────────────────────────────────────────────────┐
100
+ │ PHASE 1: Clarify (if needed) │
101
+ │ "Do you need refresh tokens? What's the session duration?" │
102
+ └─────────────────────────────────────────────────────────────────────────┘
103
+
104
+
105
+ ┌─────────────────────────────────────────────────────────────────────────┐
106
+ │ PHASE 2: Discover │
107
+ │ @explorer scans codebase → structure, languages, patterns │
108
+ └─────────────────────────────────────────────────────────────────────────┘
16
109
 
17
110
 
18
- ┌──────────────────────────────────────────────────────────────────────────┐
19
- ARCHITECT: Delegating to @explorer for codebase analysis...
20
- └──────────────────────────────────────────────────────────────────────────┘
111
+ ┌─────────────────────────────────────────────────────────────────────────┐
112
+ PHASE 3: Consult SMEs (serial, cached)
113
+ │ @sme_security → auth best practices │
114
+ │ @sme_api → JWT patterns, refresh flow │
115
+ │ Guidance saved to .swarm/context.md │
116
+ └─────────────────────────────────────────────────────────────────────────┘
21
117
 
22
118
 
23
- ┌──────────────────────────────────────────────────────────────────────────┐
24
- EXPLORER: PowerShell module, 12 files, domains: powershell, security
25
- Flagged: auth.ps1, invoke-command.ps1 for SME review
26
- └──────────────────────────────────────────────────────────────────────────┘
119
+ ┌─────────────────────────────────────────────────────────────────────────┐
120
+ PHASE 4: Plan
121
+ Creates .swarm/plan.md with phases, tasks, acceptance criteria
122
+ │ │
123
+ │ Phase 1: Foundation [3 tasks] │
124
+ │ Phase 2: Core Auth [4 tasks] │
125
+ │ Phase 3: Session Management [3 tasks] │
126
+ └─────────────────────────────────────────────────────────────────────────┘
27
127
 
28
128
 
29
- ┌──────────────────────────────────────────────────────────────────────────┐
30
- SME_POWERSHELL: Remoting patterns detected, needs constrained endpoints
31
- SME_SECURITY: Credential handling issues in auth.ps1:42-58
32
- └──────────────────────────────────────────────────────────────────────────┘
129
+ ┌─────────────────────────────────────────────────────────────────────────┐
130
+ PHASE 5: Execute (per task)
131
+
132
+ │ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌──────────┐ │
133
+ │ │ @coder │ → │@security │ → │@auditor │ → │ @test │ │
134
+ │ │ 1 task │ │ review │ │ verify │ │ generate │ │
135
+ │ └─────────┘ └──────────┘ └─────────┘ └──────────┘ │
136
+ │ │ │ │
137
+ │ └──── If rejected: retry with feedback ────────┘ │
138
+ │ │
139
+ │ Update plan.md: [x] Task complete │
140
+ │ Next task... │
141
+ └─────────────────────────────────────────────────────────────────────────┘
33
142
 
34
143
 
35
- ┌──────────────────────────────────────────────────────────────────────────┐
36
- ARCHITECT: Collated review with 3 HIGH findings, 2 recommendations
37
- └──────────────────────────────────────────────────────────────────────────┘
144
+ ┌─────────────────────────────────────────────────────────────────────────┐
145
+ PHASE 6: Phase Complete
146
+ │ Re-scan with @explorer │
147
+ │ Update context.md with learnings │
148
+ │ Archive to .swarm/history/ │
149
+ │ "Phase 1 complete. Ready for Phase 2?" │
150
+ └─────────────────────────────────────────────────────────────────────────┘
38
151
  ```
39
152
 
40
153
  ---
41
154
 
42
- ## Why OpenCode Swarm?
155
+ ## Persistent Project Memory
43
156
 
44
- Most agent frameworks parallelize everything and hope coherence emerges.
45
- **OpenCode Swarm enforces discipline:**
157
+ Other frameworks lose everything when the session ends. Swarm doesn't.
46
158
 
47
- | Problem | Our Solution |
48
- |---------|--------------|
49
- | Agents read the same files repeatedly | Explorer scans once, shares context |
50
- | All 11 SMEs consulted for every task | Only relevant domains (1-3) based on Explorer findings |
51
- | Single model = correlated failures | Different models per role = diverse perspectives |
52
- | No visibility into agent decisions | Serial execution with clear delegation traces |
53
- | Code ships without review | Mandatory Security → Audit → Test pipeline |
159
+ ```
160
+ .swarm/
161
+ ├── plan.md # Your project roadmap
162
+ ├── context.md # Everything a new Architect needs
163
+ └── history/
164
+ ├── phase-1.md # What was done, what was learned
165
+ └── phase-2.md
166
+ ```
54
167
 
55
- ---
168
+ ### plan.md - Living Roadmap
169
+ ```markdown
170
+ # Project: Auth System
171
+ Current Phase: 2
172
+
173
+ ## Phase 1: Foundation [COMPLETE]
174
+ - [x] Task 1.1: Create user model [SMALL]
175
+ - [x] Task 1.2: Add password hashing [SMALL]
176
+ - [x] Task 1.3: Database migrations [MEDIUM]
177
+
178
+ ## Phase 2: Core Auth [IN PROGRESS]
179
+ - [x] Task 2.1: Login endpoint [MEDIUM]
180
+ - [ ] Task 2.2: JWT generation [MEDIUM] (depends: 2.1) ← CURRENT
181
+ - Acceptance: Returns valid JWT with user claims
182
+ - Attempt 1: REJECTED - Missing expiration
183
+ - [ ] Task 2.3: Token validation middleware [MEDIUM]
184
+ - [BLOCKED] Task 2.4: Refresh tokens
185
+ - Reason: Waiting for decision on rotation strategy
186
+ ```
56
187
 
57
- ## Architecture
188
+ ### context.md - Institutional Knowledge
189
+ ```markdown
190
+ # Project Context: Auth System
58
191
 
59
- ```
60
- User Request
61
-
62
-
63
- ┌─────────────┐
64
- │ ARCHITECT │ ◄── Orchestrates everything, owns all decisions
65
- └─────────────┘
66
-
67
-
68
- ┌─────────────┐
69
- │ EXPLORER │ ◄── Fast codebase discovery (read-only)
70
- └─────────────┘ Returns: structure, languages, domains, flagged files
71
-
72
-
73
- ┌─────────────┐
74
- │ SMEs │ ◄── Domain experts consulted serially (read-only)
75
- └─────────────┘ Only domains identified by Explorer
76
-
77
-
78
- ┌─────────────┐
79
- │ CODER │ ◄── Implements unified specification
80
- └─────────────┘
81
-
82
-
83
- ┌─────────────┐ ┌─────────────┐
84
- │ SECURITY │ ──► │ AUDITOR │ ◄── QA review (read-only)
85
- └─────────────┘ └─────────────┘
86
-
87
-
88
- ┌─────────────┐
89
- │ TEST │ ◄── Generates tests for approved code
90
- └─────────────┘
91
- ```
192
+ ## Technical Decisions
193
+ - Using bcrypt (cost 12) for password hashing
194
+ - JWT expires in 15 minutes, refresh in 7 days
195
+ - Storing refresh tokens in Redis
92
196
 
93
- ### Agent Permissions
197
+ ## SME Guidance Cache
198
+ ### Security (Phase 1)
199
+ - Never log tokens or passwords
200
+ - Use constant-time comparison for tokens
201
+ - Implement rate limiting on login
94
202
 
95
- | Agent | Read | Write | Role |
96
- |-------|:----:|:-----:|------|
97
- | Architect | ✅ | ✅ | Orchestrator - can fall back if delegation fails |
98
- | Explorer | ✅ | ❌ | Discovery - scans, summarizes, identifies domains |
99
- | SMEs (×15) | ✅ | ❌ | Advisory - domain expertise, never implements |
100
- | Coder | | | Implementation - writes production code |
101
- | Security Reviewer | | ❌ | Audit - vulnerability assessment |
102
- | Auditor | ✅ | ❌ | Audit - correctness verification |
103
- | Test Engineer | ✅ | ✅ | Testing - generates test cases |
203
+ ### API (Phase 1)
204
+ - Return 401 for invalid credentials (not 404)
205
+ - Include token expiry in response body
206
+
207
+ ## Patterns Established
208
+ - Error handling: Custom ApiError class with status codes
209
+ - Validation: Zod schemas in /validators/
210
+ ```
211
+
212
+ **Start a new session tomorrow?** The Architect reads these files and picks up exactly where you left off.
104
213
 
105
214
  ---
106
215
 
107
- ## Heterogeneous Model Perspectives
216
+ ## Heterogeneous Models = Better Code
217
+
218
+ Most frameworks use one model for everything. Same blindspots everywhere.
108
219
 
109
- OpenCode Swarm allows **different models per role**, reducing correlated failures:
220
+ Swarm lets you mix models strategically:
110
221
 
111
222
  ```json
112
223
  {
@@ -115,38 +226,137 @@ OpenCode Swarm allows **different models per role**, reducing correlated failure
115
226
  "explorer": { "model": "google/gemini-2.0-flash" },
116
227
  "coder": { "model": "anthropic/claude-sonnet-4-5" },
117
228
  "_sme": { "model": "google/gemini-2.0-flash" },
118
- "_qa": { "model": "openai/gpt-4o" },
119
- "test_engineer": { "model": "google/gemini-2.0-flash" }
229
+ "security_reviewer": { "model": "openai/gpt-4o" },
230
+ "auditor": { "model": "google/gemini-2.0-flash" }
120
231
  }
121
232
  }
122
233
  ```
123
234
 
124
- **Why this matters:**
125
- - Reasoning-heavy model for Architect decisions
126
- - Fast/cheap model for Explorer and SME consultation
127
- - Different model family for QA catches errors the others miss
128
- - Mix local (Ollama) and cloud models based on cost/capability
235
+ | Role | Optimized For | Why Different Models? |
236
+ |------|---------------|----------------------|
237
+ | Architect | Deep reasoning | Needs to plan complex work |
238
+ | Explorer | Fast scanning | Speed over depth |
239
+ | Coder | Implementation | Best coding model you have |
240
+ | SMEs | Domain knowledge | Fast recall, not deep reasoning |
241
+ | Security Reviewer | Finding flaws | **Different vendor catches different bugs** |
242
+ | Auditor | Verification | Independent perspective |
243
+
244
+ **If Claude writes code and GPT reviews it, GPT catches Claude's blindspots.** This is why real teams have code review.
129
245
 
130
246
  ---
131
247
 
132
- ## Installation
248
+ ## Multiple Swarms
133
249
 
134
- Add to your `opencode.json`:
250
+ Run different model configurations simultaneously. Perfect for:
251
+ - **Cloud vs Local**: Premium cloud models for critical work, local models for quick tasks
252
+ - **Fast vs Quality**: Quick iterations with fast models, careful work with expensive ones
253
+ - **Cost Tiers**: Cheap models for exploration, premium for implementation
254
+
255
+ ### Configuration
135
256
 
136
257
  ```json
137
258
  {
138
- "plugin": ["opencode-swarm"]
259
+ "swarms": {
260
+ "cloud": {
261
+ "name": "Cloud",
262
+ "agents": {
263
+ "architect": { "model": "anthropic/claude-sonnet-4-5" },
264
+ "coder": { "model": "anthropic/claude-sonnet-4-5" },
265
+ "_sme": { "model": "google/gemini-2.0-flash" },
266
+ "_qa": { "model": "openai/gpt-4o" }
267
+ }
268
+ },
269
+ "local": {
270
+ "name": "Local",
271
+ "agents": {
272
+ "architect": { "model": "ollama/qwen2.5:32b" },
273
+ "coder": { "model": "ollama/qwen2.5:32b" },
274
+ "_sme": { "model": "ollama/qwen2.5:14b" },
275
+ "_qa": { "model": "ollama/qwen2.5:14b" }
276
+ }
277
+ }
278
+ }
139
279
  }
140
280
  ```
141
281
 
142
- Or install via CLI:
282
+ ### What Gets Created
283
+
284
+ | Swarm | Agents |
285
+ |-------|--------|
286
+ | `cloud` (default) | `architect`, `explorer`, `coder`, `sme_*`, etc. |
287
+ | `local` | `local_architect`, `local_explorer`, `local_coder`, `local_sme_*`, etc. |
288
+
289
+ The first swarm (or one named "default") creates unprefixed agents. Additional swarms prefix all agent names.
290
+
291
+ ### Usage
292
+
293
+ In OpenCode, you'll see multiple architects to choose from:
294
+ - `architect` - Cloud swarm (default)
295
+ - `local_architect` - Local swarm
296
+
297
+ Each architect automatically delegates to its own swarm's agents.
298
+
299
+ ---
300
+
301
+ ## Installation
143
302
 
144
303
  ```bash
304
+ # Add to opencode.json
305
+ {
306
+ "plugin": ["opencode-swarm"]
307
+ }
308
+
309
+ # Or install via CLI
145
310
  bunx opencode-swarm install
146
311
  ```
147
312
 
148
313
  ---
149
314
 
315
+ ## Agents
316
+
317
+ ### 🎯 Orchestrator
318
+ | Agent | Role |
319
+ |-------|------|
320
+ | `architect` | Central coordinator. Plans phases, delegates tasks, manages QA, maintains project memory. |
321
+
322
+ ### 🔍 Discovery
323
+ | Agent | Role |
324
+ |-------|------|
325
+ | `explorer` | Fast codebase scanner. Identifies structure, languages, frameworks, key files. |
326
+
327
+ ### 🧠 Domain Experts (15 SMEs)
328
+ | Agent | Domain |
329
+ |-------|--------|
330
+ | `sme_web` | Flutter, React, Vue, Angular, JS/TS, HTML/CSS |
331
+ | `sme_api` | REST, GraphQL, OAuth, JWT, webhooks |
332
+ | `sme_database` | SQL Server, PostgreSQL, MySQL, MongoDB, Redis |
333
+ | `sme_devops` | Docker, Kubernetes, CI/CD, Terraform |
334
+ | `sme_security` | STIG, hardening, CVE, encryption, PKI |
335
+ | `sme_python` | Python ecosystem, libraries, patterns |
336
+ | `sme_powershell` | PowerShell scripting, modules, remoting |
337
+ | `sme_windows` | Windows internals, registry, services, WMI |
338
+ | `sme_linux` | Linux, systemd, package management |
339
+ | `sme_network` | TCP/IP, firewalls, DNS, TLS |
340
+ | `sme_azure` | Azure services, Entra ID, ARM/Bicep |
341
+ | `sme_vmware` | vSphere, ESXi, PowerCLI |
342
+ | `sme_oracle` | Oracle Database, SQL/PLSQL |
343
+ | `sme_active_directory` | AD, LDAP, Group Policy, Kerberos |
344
+ | `sme_ui_ux` | UI/UX design, accessibility |
345
+
346
+ ### 💻 Implementation
347
+ | Agent | Role |
348
+ |-------|------|
349
+ | `coder` | Implements ONE task at a time with full context |
350
+ | `test_engineer` | Generates tests for each completed task |
351
+
352
+ ### ✅ Quality Assurance
353
+ | Agent | Role |
354
+ |-------|------|
355
+ | `security_reviewer` | Vulnerability assessment per task |
356
+ | `auditor` | Correctness verification per task |
357
+
358
+ ---
359
+
150
360
  ## Configuration
151
361
 
152
362
  Create `~/.config/opencode/opencode-swarm.json`:
@@ -166,143 +376,60 @@ Create `~/.config/opencode/opencode-swarm.json`:
166
376
 
167
377
  ### Category Defaults
168
378
 
169
- `_sme` and `_qa` set defaults for all agents in that category:
379
+ - `_sme` All 15 SME agents
380
+ - `_qa` → security_reviewer + auditor
170
381
 
382
+ Override specific agents:
171
383
  ```json
172
384
  {
173
- "agents": {
174
- "_sme": { "model": "google/gemini-2.0-flash" },
175
- "sme_oracle": { "model": "anthropic/claude-sonnet-4-5" }
176
- }
385
+ "_sme": { "model": "google/gemini-2.0-flash" },
386
+ "sme_security": { "model": "anthropic/claude-sonnet-4-5" }
177
387
  }
178
388
  ```
179
389
 
180
390
  ### Disable Unused Domains
181
-
182
391
  ```json
183
392
  {
184
- "agents": {
185
- "sme_vmware": { "disabled": true },
186
- "sme_azure": { "disabled": true }
187
- }
393
+ "sme_vmware": { "disabled": true },
394
+ "sme_oracle": { "disabled": true }
188
395
  }
189
396
  ```
190
397
 
191
- ### Custom Prompts
192
-
193
- Place in `~/.config/opencode/opencode-swarm/`:
194
- - `{agent}.md` - Replace default prompt
195
- - `{agent}_append.md` - Append to default prompt
196
-
197
398
  ---
198
399
 
199
- ## Agents
200
-
201
- ### Orchestrator
202
- | Agent | Description |
203
- |-------|-------------|
204
- | `architect` | Central orchestrator. Analyzes requests, delegates to specialists, synthesizes outputs, triages QA feedback. |
400
+ ## Comparison
205
401
 
206
- ### Discovery
207
- | Agent | Description |
208
- |-------|-------------|
209
- | `explorer` | Fast codebase scanner. Identifies structure, languages, frameworks, and flags files for SME review. |
210
-
211
- ### Domain Experts (SMEs)
212
- | Agent | Domain |
213
- |-------|--------|
214
- | `sme_windows` | Windows internals, registry, services, WMI/CIM |
215
- | `sme_powershell` | PowerShell scripting, cmdlets, modules, remoting |
216
- | `sme_python` | Python ecosystem, libraries, packaging |
217
- | `sme_oracle` | Oracle Database, SQL/PLSQL, administration |
218
- | `sme_network` | TCP/IP, firewalls, DNS, TLS, load balancing |
219
- | `sme_security` | STIG compliance, hardening, CVEs, PKI |
220
- | `sme_linux` | Linux administration, systemd, package management |
221
- | `sme_vmware` | vSphere, ESXi, PowerCLI, virtualization |
222
- | `sme_azure` | Azure services, Entra ID, ARM/Bicep |
223
- | `sme_active_directory` | AD, LDAP, Group Policy, Kerberos |
224
- | `sme_ui_ux` | UI/UX design, accessibility, interaction patterns |
225
- | `sme_web` | Flutter, React, Vue, Angular, JS/TS, HTML/CSS |
226
- | `sme_database` | SQL Server, PostgreSQL, MySQL, MongoDB, Redis |
227
- | `sme_devops` | Docker, Kubernetes, CI/CD, Terraform, GitHub Actions |
228
- | `sme_api` | REST, GraphQL, OAuth, JWT, webhooks |
229
-
230
- ### Implementation
231
- | Agent | Description |
232
- |-------|-------------|
233
- | `coder` | Writes production code from unified specifications |
234
- | `test_engineer` | Generates test cases and validation scripts |
235
-
236
- ### Quality Assurance
237
- | Agent | Description |
238
- |-------|-------------|
239
- | `security_reviewer` | Vulnerability assessment, injection risks, data exposure |
240
- | `auditor` | Correctness verification, logic errors, edge cases |
402
+ | Feature | OpenCode Swarm | AutoGen | CrewAI | LangGraph |
403
+ |---------|---------------|---------|--------|-----------|
404
+ | Execution | Serial (predictable) | Parallel (chaotic) | Parallel | Configurable |
405
+ | Planning | Phased with acceptance criteria | Ad-hoc | Role-based | Graph-based |
406
+ | Memory | Persistent `.swarm/` files | Session only | Session only | Checkpoints |
407
+ | QA | Per-task (security + audit) | Optional | Optional | Manual |
408
+ | Model mixing | Per-agent configuration | Limited | Limited | Manual |
409
+ | Resume projects | ✅ Native | ❌ | ❌ | Partial |
410
+ | SME domains | 15 specialized | Generic | Generic | Generic |
411
+ | Task granularity | One at a time | Batched | Batched | Varies |
241
412
 
242
413
  ---
243
414
 
244
- ## Tools
415
+ ## Design Principles
245
416
 
246
- | Tool | Description |
247
- |------|-------------|
248
- | `gitingest` | Fetch GitHub repository contents for analysis |
249
- | `detect_domains` | Auto-detect relevant SME domains from text |
250
- | `extract_code_blocks` | Extract code blocks to files |
251
-
252
- ### gitingest Example
253
-
254
- ```
255
- "Analyze the architecture of https://github.com/user/repo"
256
- "Use gitingest to fetch https://github.com/user/repo with pattern *.py include"
257
- ```
258
-
259
- ---
260
-
261
- ## Workflow Examples
262
-
263
- ### Code Review
264
- ```
265
- User: "Review this codebase for issues"
266
- → Explorer scans, identifies: TypeScript, React, needs sme_security
267
- → SME_Security reviews flagged files
268
- → Architect collates findings into review report
269
- ```
270
-
271
- ### Implementation
272
- ```
273
- User: "Add authentication to this API"
274
- → Explorer scans existing code
275
- → SME_Security + SME_Network consulted
276
- → Coder implements spec
277
- → Security_Reviewer → Auditor validates
278
- → Test_Engineer generates tests
279
- ```
280
-
281
- ### Bug Fix
282
- ```
283
- User: "Fix the null reference in user.ts:42"
284
- → Explorer locates context
285
- → Relevant SME consulted
286
- → Coder implements fix
287
- → QA validates
288
- ```
289
-
290
- ---
291
-
292
- ## Design Philosophy
293
-
294
- 1. **Single point of control** - Architect owns all decisions
295
- 2. **Discovery before action** - Explorer maps the terrain first
296
- 3. **Selective expertise** - Only relevant SMEs consulted
297
- 4. **Serial execution** - Traceable, debuggable, predictable
298
- 5. **Mandatory QA** - No code ships without security + audit review
299
- 6. **Fail-safe orchestration** - Architect can handle tasks itself if agents fail
417
+ 1. **Plan before code** - Documented phases with acceptance criteria
418
+ 2. **One task at a time** - Focused work, quality output
419
+ 3. **QA everything immediately** - Security + audit per task, not per project
420
+ 4. **Cache SME knowledge** - Don't re-ask answered questions
421
+ 5. **Persistent memory** - `.swarm/` files survive sessions
422
+ 6. **Serial execution** - Predictable, debuggable, no race conditions
423
+ 7. **Heterogeneous models** - Different perspectives catch different bugs
424
+ 8. **User checkpoints** - Confirm before proceeding to next phase
425
+ 9. **Failure tracking** - Document rejections, escalate after 3 attempts
426
+ 10. **Resumable by design** - Any Architect can pick up any project
300
427
 
301
428
  ---
302
429
 
303
430
  ## Documentation
304
431
 
305
- - [Architecture Details](docs/architecture.md)
432
+ - [Architecture Deep Dive](docs/architecture.md)
306
433
  - [Design Rationale](docs/design-rationale.md)
307
434
  - [Installation Guide](docs/installation.md)
308
435
 
@@ -311,3 +438,9 @@ User: "Fix the null reference in user.ts:42"
311
438
  ## License
312
439
 
313
440
  MIT
441
+
442
+ ---
443
+
444
+ <p align="center">
445
+ <strong>Stop hoping your agents figure it out. Start shipping code that works.</strong>
446
+ </p>
@@ -8,7 +8,6 @@ export type { AgentDefinition } from './architect';
8
8
  export declare function createAgents(config?: PluginConfig): AgentDefinition[];
9
9
  /**
10
10
  * Get agent configurations formatted for the OpenCode SDK.
11
- * Converts agent definitions to SDK config format and applies mode metadata.
12
11
  */
13
12
  export declare function getAgentConfigs(config?: PluginConfig): Record<string, SDKAgentConfig>;
14
13
  export { createArchitectAgent } from './architect';
@@ -1,5 +1,5 @@
1
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
2
  export type { AgentName, PipelineAgentName, QAAgentName, SMEAgentName, } from './constants';
3
- export { AgentOverrideConfigSchema, PluginConfigSchema, } from './schema';
4
- export type { AgentOverrideConfig, PluginConfig, } from './schema';
3
+ export { AgentOverrideConfigSchema, PluginConfigSchema, SwarmConfigSchema, } from './schema';
4
+ export type { AgentOverrideConfig, PluginConfig, SwarmConfig, } from './schema';
5
5
  export { loadAgentPrompt, loadPluginConfig, } from './loader';
@@ -5,12 +5,29 @@ export declare const AgentOverrideConfigSchema: z.ZodObject<{
5
5
  disabled: z.ZodOptional<z.ZodBoolean>;
6
6
  }, z.core.$strip>;
7
7
  export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
8
+ export declare const SwarmConfigSchema: z.ZodObject<{
9
+ name: z.ZodOptional<z.ZodString>;
10
+ agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
11
+ model: z.ZodOptional<z.ZodString>;
12
+ temperature: z.ZodOptional<z.ZodNumber>;
13
+ disabled: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>>>;
15
+ }, z.core.$strip>;
16
+ export type SwarmConfig = z.infer<typeof SwarmConfigSchema>;
8
17
  export declare const PluginConfigSchema: z.ZodObject<{
9
18
  agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
10
19
  model: z.ZodOptional<z.ZodString>;
11
20
  temperature: z.ZodOptional<z.ZodNumber>;
12
21
  disabled: z.ZodOptional<z.ZodBoolean>;
13
22
  }, z.core.$strip>>>;
23
+ swarms: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
24
+ name: z.ZodOptional<z.ZodString>;
25
+ agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
26
+ model: z.ZodOptional<z.ZodString>;
27
+ temperature: z.ZodOptional<z.ZodNumber>;
28
+ disabled: z.ZodOptional<z.ZodBoolean>;
29
+ }, z.core.$strip>>>;
30
+ }, z.core.$strip>>>;
14
31
  max_iterations: z.ZodDefault<z.ZodNumber>;
15
32
  multi_domain_sme: z.ZodDefault<z.ZodBoolean>;
16
33
  auto_detect_domains: z.ZodDefault<z.ZodBoolean>;
package/dist/index.js CHANGED
@@ -213,9 +213,6 @@ function isSMEAgent(name) {
213
213
  function isQAAgent(name) {
214
214
  return QA_AGENTS.includes(name);
215
215
  }
216
- function isSubagent(name) {
217
- return ALL_SUBAGENT_NAMES.includes(name);
218
- }
219
216
  // node_modules/zod/v4/classic/external.js
220
217
  var exports_external = {};
221
218
  __export(exports_external, {
@@ -13754,8 +13751,13 @@ var AgentOverrideConfigSchema = exports_external.object({
13754
13751
  temperature: exports_external.number().min(0).max(2).optional(),
13755
13752
  disabled: exports_external.boolean().optional()
13756
13753
  });
13754
+ var SwarmConfigSchema = exports_external.object({
13755
+ name: exports_external.string().optional(),
13756
+ agents: exports_external.record(exports_external.string(), AgentOverrideConfigSchema).optional()
13757
+ });
13757
13758
  var PluginConfigSchema = exports_external.object({
13758
13759
  agents: exports_external.record(exports_external.string(), AgentOverrideConfigSchema).optional(),
13760
+ swarms: exports_external.record(exports_external.string(), SwarmConfigSchema).optional(),
13759
13761
  max_iterations: exports_external.number().min(1).max(10).default(5),
13760
13762
  multi_domain_sme: exports_external.boolean().default(true),
13761
13763
  auto_detect_domains: exports_external.boolean().default(true),
@@ -13846,197 +13848,280 @@ function loadAgentPrompt(agentName) {
13846
13848
  return result;
13847
13849
  }
13848
13850
  // src/agents/architect.ts
13849
- var ARCHITECT_PROMPT = `You are Architect - an AI coding orchestrator that coordinates specialist LLM agents to deliver quality code.
13851
+ var ARCHITECT_PROMPT = `You are Architect - the orchestrator of a multi-agent coding swarm.
13852
+
13853
+ ## HOW TO DELEGATE
13854
+
13855
+ To delegate, mention the agent with @ and provide instructions:
13856
+ "Scanning codebase via @explorer..."
13857
+ "Consulting @sme_powershell for module patterns..."
13858
+ "Implementing via @coder..."
13859
+
13860
+ **You MUST delegate to agents. Do not implement code yourself unless delegation fails.**
13861
+
13862
+ ---
13863
+
13864
+ ## YOUR AGENTS
13865
+
13866
+ **Discovery:**
13867
+ @explorer - Scans codebase, returns structure/languages/key files
13868
+
13869
+ **Domain Experts (SMEs) - Advisory only, cannot write code:**
13870
+ @sme_windows @sme_powershell @sme_python @sme_oracle @sme_network
13871
+ @sme_security @sme_linux @sme_vmware @sme_azure @sme_active_directory
13872
+ @sme_ui_ux @sme_web @sme_database @sme_devops @sme_api
13873
+
13874
+ **Implementation:**
13875
+ @coder - Writes code (ONE task at a time)
13876
+ @test_engineer - Generates tests
13877
+
13878
+ **Quality Assurance - Review only, cannot write code:**
13879
+ @security_reviewer - Finds vulnerabilities
13880
+ @auditor - Verifies correctness
13881
+
13882
+ ---
13883
+
13884
+ ## WORKFLOW
13885
+
13886
+ ### Phase 0: Initialize or Resume
13850
13887
 
13851
- **Role**: Analyze requests, delegate to specialist agents with clear instructions, synthesize their outputs, and manage the pipeline.
13888
+ **FIRST**: Check if \`.swarm/plan.md\` exists in the project.
13889
+ - If EXISTS \u2192 Read plan.md and context.md, resume from current phase/task
13890
+ - If NOT EXISTS \u2192 New project, proceed to Phase 1
13852
13891
 
13853
- **CRITICAL: YOU ARE ORCHESTRATING OTHER LLMs**
13854
- The agents you delegate to are separate LLM instances, typically smaller/faster models optimized for specific tasks. They cannot read your mind or infer context. Your delegations must be:
13855
- - **Explicit**: State exactly what you want, not what you assume they know
13856
- - **Structured**: Use clear sections, numbered steps, specific file paths
13857
- - **Constrained**: Tell them what NOT to do, limit scope to prevent drift
13858
- - **Self-contained**: Include all context they need in the delegation message
13892
+ ### Phase 1: Clarify (if needed)
13859
13893
 
13860
- **CRITICAL RULE: SERIAL EXECUTION ONLY**
13861
- You MUST call agents ONE AT A TIME. After each delegation:
13862
- 1. Send to ONE agent
13863
- 2. STOP and wait for response
13864
- 3. Only then proceed to next agent
13865
- NEVER delegate to multiple agents in the same message. This is mandatory.
13894
+ If the user request is ambiguous:
13895
+ - Ask up to 3 targeted clarifying questions
13896
+ - Wait for answers before proceeding
13897
+ If clear \u2192 Proceed to Phase 2
13866
13898
 
13867
- **Agents**:
13899
+ ### Phase 2: Discover
13868
13900
 
13869
- @explorer - Fast codebase discovery and summarization (ALWAYS FIRST for code tasks)
13870
- @sme_windows - Windows OS internals, registry, services, WMI/CIM
13871
- @sme_powershell - PowerShell scripting, cmdlets, modules, remoting
13872
- @sme_python - Python ecosystem, libraries, best practices
13873
- @sme_oracle - Oracle Database, SQL/PLSQL, administration
13874
- @sme_network - Networking, firewalls, DNS, TLS/SSL, load balancing
13875
- @sme_security - STIG compliance, hardening, CVE, encryption, PKI
13876
- @sme_linux - Linux administration, systemd, package management
13877
- @sme_vmware - VMware vSphere, ESXi, PowerCLI, virtualization
13878
- @sme_azure - Azure cloud services, Entra ID, ARM/Bicep
13879
- @sme_active_directory - Active Directory, LDAP, Group Policy, Kerberos
13880
- @sme_ui_ux - UI/UX design, interaction patterns, accessibility
13881
- @sme_web - Web/frontend (Flutter, React, Vue, Angular, JS/TS, HTML/CSS)
13882
- @sme_database - Databases (SQL Server, PostgreSQL, MySQL, MongoDB, Redis)
13883
- @sme_devops - DevOps, CI/CD, Docker, Kubernetes, Terraform, GitHub Actions
13884
- @sme_api - API design, REST, GraphQL, OAuth, JWT, webhooks
13901
+ "Scanning codebase via @explorer..."
13902
+ Provide: task context, areas to focus on
13903
+ Wait for response before continuing.
13885
13904
 
13886
- @coder - Implementation specialist, writes production code
13887
- @security_reviewer - Security audit, vulnerability assessment
13888
- @auditor - Code quality review, correctness verification
13889
- @test_engineer - Test case generation and validation scripts
13905
+ @explorer returns: project summary, structure, languages, key files, relevant SME domains
13890
13906
 
13891
- **HOW TO DELEGATE TO EACH AGENT**:
13907
+ ### Phase 3: Consult SMEs
13892
13908
 
13893
- ## @explorer
13894
- Provide: The task context and what you need to understand
13895
- Format:
13896
- "Analyze this codebase for [task type].
13897
- Focus on: [specific areas]
13898
- Return: project summary, key files, relevant domains for SME consultation"
13909
+ Before calling an SME, check \`.swarm/context.md\` for cached guidance.
13910
+ Only call SMEs for NEW questions not already answered.
13899
13911
 
13900
- ## @sme_* (domain experts)
13901
- Provide: Specific files/code to review, what expertise you need
13902
- Format:
13903
- "Review the following for [domain] considerations:
13904
- Files: [list specific paths]
13905
- Context: [what the code does]
13906
- Provide: [specific guidance needed]
13907
- Constraints: Focus only on [domain], do not suggest unrelated changes"
13912
+ For each relevant domain (usually 1-3, based on @explorer findings):
13913
+ "Consulting @sme_[domain] for [specific guidance]..."
13914
+ Provide: file paths, context, specific questions
13915
+ **One SME at a time. Wait for each response.**
13908
13916
 
13909
- ## @coder
13910
- **IMPORTANT: ONE TASK AT A TIME**
13911
- If you have multiple coding tasks, send them to @coder ONE AT A TIME.
13912
- Do NOT batch multiple files or features into a single delegation.
13913
- Wait for @coder to complete each task before sending the next.
13917
+ Cache ALL SME guidance in context.md for future phases.
13914
13918
 
13915
- Provide: Complete specification for ONE focused task
13916
- Format:
13917
- "Implement the following:
13918
-
13919
- TASK: [one specific task - single file or single feature]
13920
-
13921
- FILE: [single path to create/modify]
13922
-
13923
- REQUIREMENTS:
13924
- 1. [specific requirement]
13925
- 2. [specific requirement]
13926
-
13927
- CONTEXT:
13928
- - [relevant info from explorer/SMEs]
13929
- - [patterns from existing code]
13930
-
13931
- DO NOT:
13932
- - Modify other files
13933
- - Add features not specified
13934
- - Refactor unrelated code
13935
-
13936
- OUTPUT: [single deliverable]"
13919
+ ### Phase 4: Plan
13937
13920
 
13938
- Example of CORRECT coding delegation:
13939
- Turn 1: "Implement the logging module" \u2192 @coder \u2192 wait for completion
13940
- Turn 2: "Implement the config parser" \u2192 @coder \u2192 wait for completion
13941
- Turn 3: "Implement the main entry point" \u2192 @coder \u2192 wait for completion
13921
+ Create/update \`.swarm/plan.md\` with:
13922
+ - Project overview
13923
+ - Phases broken into discrete tasks
13924
+ - Task dependencies (depends: X.X)
13925
+ - Acceptance criteria for each task
13926
+ - Complexity estimates [SMALL/MEDIUM/LARGE]
13942
13927
 
13943
- Example of WRONG batched delegation (NEVER DO THIS):
13944
- "Implement the logging module, config parser, and main entry point" \u2190 WRONG
13928
+ Create/update \`.swarm/context.md\` with:
13929
+ - Technical decisions
13930
+ - Architecture patterns
13931
+ - SME guidance cache
13932
+ - File map
13945
13933
 
13946
- ## @security_reviewer
13947
- Provide: Code to review with context
13948
- Format:
13949
- "Security review the following code:
13950
-
13951
- FILES: [paths]
13952
- PURPOSE: [what the code does]
13953
-
13954
- CHECK FOR:
13955
- - Injection vulnerabilities
13956
- - Data exposure
13957
- - Privilege issues
13958
- - Input validation
13959
-
13960
- RETURN: Risk level (LOW/MEDIUM/HIGH/CRITICAL) and specific findings with line numbers"
13934
+ **Planning rules:**
13935
+ - Each task = ONE focused unit (single file or feature)
13936
+ - Tasks must have clear acceptance criteria
13937
+ - Mark dependencies explicitly
13961
13938
 
13962
- ## @auditor
13963
- Provide: Code and specification to verify against
13964
- Format:
13965
- "Verify this implementation:
13966
-
13967
- FILES: [paths]
13968
- SPECIFICATION: [what it should do]
13969
-
13970
- CHECK:
13971
- - Logic correctness
13972
- - Edge cases handled
13973
- - Error handling
13974
- - Specification compliance
13975
-
13976
- RETURN: APPROVED or REJECTED with specific issues"
13939
+ ### Phase 5: Execute Current Phase
13977
13940
 
13978
- ## @test_engineer
13979
- Provide: Code and what to test
13980
- Format:
13981
- "Generate tests for:
13982
-
13983
- FILES: [paths]
13984
- FUNCTIONS TO TEST: [list]
13985
-
13986
- COVERAGE:
13987
- - Happy path
13988
- - Edge cases: [specific cases]
13989
- - Error conditions
13990
-
13991
- FRAMEWORK: [test framework to use]
13992
- OUTPUT: Test file(s) at [paths]"
13941
+ For EACH task in the current phase (respecting dependencies):
13993
13942
 
13994
- **WORKFLOW**:
13943
+ **5a. Implement**
13944
+ "Implementing [task] via @coder..."
13945
+ Provide:
13946
+ - TASK: [specific single task]
13947
+ - FILE: [single file path]
13948
+ - REQUIREMENTS: [numbered list]
13949
+ - CONTEXT: [SME guidance, patterns]
13950
+ - DO NOT: [constraints]
13951
+ - ACCEPTANCE: [criteria]
13995
13952
 
13996
- ## 1. Parse Request (you do this briefly)
13997
- Understand what the user wants. Determine task type.
13953
+ **ONE task per @coder call. Wait for response.**
13998
13954
 
13999
- ## 2. Explorer FIRST (one delegation, wait for response)
14000
- Delegate to @explorer with clear instructions. STOP and wait.
13955
+ **5b. Security Review**
13956
+ "Security review via @security_reviewer..."
13957
+ Provide: file path, purpose, what to check
13958
+ Wait for response.
14001
13959
 
14002
- ## 3. SME Consultation (ONE AT A TIME, wait between each)
14003
- Based on @explorer's domains, delegate to each SME serially.
14004
- Each SME delegation must be self-contained with file paths and context.
13960
+ **5c. Audit**
13961
+ "Verifying via @auditor..."
13962
+ Provide: file path, specification to verify against
13963
+ Wait for response.
14005
13964
 
14006
- ## 4. Collate (you do this)
14007
- Synthesize all inputs into a clear specification or report.
13965
+ **5d. Handle QA Result**
13966
+ - APPROVED \u2192 Continue to tests
13967
+ - REJECTED (attempt 1-2) \u2192 Send feedback to @coder, retry QA
13968
+ - REJECTED (attempt 3) \u2192 ESCALATE: Handle yourself or re-scope task
14008
13969
 
14009
- ## 5. Code (ONE TASK AT A TIME to @coder)
14010
- If you have multiple coding tasks:
14011
- - Break them into individual, focused tasks
14012
- - Send first task to @coder, WAIT for completion
14013
- - Review output, then send next task
14014
- - Repeat until all tasks complete
14015
- NEVER send multiple tasks/files to @coder in one delegation.
13970
+ Track attempts in plan.md.
14016
13971
 
14017
- ## 6. QA Review (serial: @security_reviewer first, wait, then @auditor)
14018
- Send completed code with context. Tell them exactly what to check.
13972
+ **5e. Test**
13973
+ "Generating tests via @test_engineer..."
13974
+ Provide: file path, functions, test cases needed
13975
+ Wait for response.
14019
13976
 
14020
- ## 7. Triage (you do this)
14021
- APPROVED \u2192 @test_engineer | REVISION_NEEDED \u2192 back to @coder with specific fixes | BLOCKED \u2192 explain
13977
+ **5f. Mark Complete**
13978
+ Update plan.md: mark task [x] complete
13979
+ Add learnings to context.md
13980
+ Proceed to next task.
14022
13981
 
14023
- ## 8. Test (one delegation to @test_engineer)
14024
- Send code with specific test requirements.
13982
+ ### Phase 6: Phase Complete
14025
13983
 
14026
- **DELEGATION RULES**:
14027
- - ONE agent per turn. Wait for response. Then next agent.
14028
- - ONE coding task per @coder delegation. Break multi-file work into separate calls.
14029
- - Every delegation must be self-contained (agent has no memory of prior context)
14030
- - Include file paths, not just descriptions
14031
- - Tell agents what NOT to do to prevent scope creep
14032
- - Use structured formats (numbered lists, sections) not prose
14033
- - If an agent's output is poor, provide clearer instructions or handle yourself
13984
+ When all tasks in a phase are done:
13985
+ 1. "Re-scanning codebase via @explorer..." (capture changes)
13986
+ 2. Update context.md with new patterns, lessons learned
13987
+ 3. Archive phase summary to .swarm/history/
13988
+ 4. Summarize to user what was accomplished
13989
+ 5. ASK: "Ready to proceed to Phase [N+1]?"
13990
+ - Do NOT auto-proceed without user confirmation
14034
13991
 
14035
- **COMMUNICATION**:
14036
- - Be direct with the user, no preamble or flattery
14037
- - Don't ask for confirmation between phases - proceed automatically
14038
- - If request is vague, ask ONE targeted question before starting
14039
- - You orchestrate and synthesize. Prefer delegation over doing it yourself.`;
13992
+ ### Handling Blockers
13993
+
13994
+ If a task cannot proceed:
13995
+ - Mark [BLOCKED] in plan.md with reason
13996
+ - Skip to next unblocked task
13997
+ - Inform user of blocker
13998
+
13999
+ ---
14000
+
14001
+ ## DELEGATION RULES
14002
+
14003
+ 1. **Delegate first, fallback if needed** - Try agents before doing it yourself
14004
+ 2. **ONE agent at a time** - Wait for response before next delegation
14005
+ 3. **ONE task per @coder** - Never batch multiple files/features
14006
+ 4. **Serial SME calls** - Never parallel
14007
+ 5. **QA every task** - Security review + audit before marking complete
14008
+ 6. **Self-contained instructions** - Agents have no memory of prior context
14009
+
14010
+ ---
14011
+
14012
+ ## DELEGATION TEMPLATES
14013
+
14014
+ **@explorer:**
14015
+ "Scanning codebase via @explorer...
14016
+ Analyze for: [purpose]
14017
+ Focus on: [areas]
14018
+ Return: structure, languages, frameworks, key files, relevant SME domains"
14019
+
14020
+ **@sme_*:**
14021
+ "Consulting @sme_[domain]...
14022
+ Files: [paths]
14023
+ Context: [what we're building]
14024
+ Questions:
14025
+ 1. [specific question]
14026
+ 2. [specific question]
14027
+ Constraints: Focus only on [domain]"
14028
+
14029
+ **@coder:**
14030
+ "Implementing via @coder...
14031
+ TASK: [single focused task]
14032
+ FILE: [single path]
14033
+ REQUIREMENTS:
14034
+ 1. [requirement]
14035
+ 2. [requirement]
14036
+ CONTEXT: [from SMEs, existing patterns]
14037
+ DO NOT: [constraints]
14038
+ ACCEPTANCE: [testable criteria]"
14039
+
14040
+ **@security_reviewer:**
14041
+ "Security review via @security_reviewer...
14042
+ FILE: [path]
14043
+ PURPOSE: [description]
14044
+ CHECK: injection, data exposure, privilege issues, input validation
14045
+ RETURN: Risk level + findings with line numbers"
14046
+
14047
+ **@auditor:**
14048
+ "Verifying via @auditor...
14049
+ FILE: [path]
14050
+ SPECIFICATION: [requirements]
14051
+ CHECK: correctness, edge cases, error handling
14052
+ RETURN: APPROVED or REJECTED with specifics"
14053
+
14054
+ **@test_engineer:**
14055
+ "Generating tests via @test_engineer...
14056
+ FILE: [path]
14057
+ FUNCTIONS: [names]
14058
+ CASES: happy path, edge cases, error conditions
14059
+ OUTPUT: [test file path]"
14060
+
14061
+ ---
14062
+
14063
+ ## PROJECT FILES
14064
+
14065
+ Maintain in .swarm/ directory:
14066
+
14067
+ **plan.md format:**
14068
+ \`\`\`markdown
14069
+ # Project: [Name]
14070
+ Created: [date] | Updated: [date] | Current Phase: [N]
14071
+
14072
+ ## Overview
14073
+ [Summary]
14074
+
14075
+ ## Phase 1: [Name] [COMPLETE]
14076
+ - [x] Task 1.1: [desc] [SMALL]
14077
+ - Acceptance: [criteria]
14078
+
14079
+ ## Phase 2: [Name] [IN PROGRESS]
14080
+ - [x] Task 2.1: [desc] [MEDIUM]
14081
+ - [ ] Task 2.2: [desc] [MEDIUM] (depends: 2.1) \u2190 CURRENT
14082
+ - Acceptance: [criteria]
14083
+ - Attempt 1: REJECTED - [reason]
14084
+ - [BLOCKED] Task 2.3: [desc]
14085
+ - Reason: [why]
14086
+ \`\`\`
14087
+
14088
+ **context.md format:**
14089
+ \`\`\`markdown
14090
+ # Project Context: [Name]
14091
+
14092
+ ## Technical Decisions
14093
+ - [Decision]: [rationale]
14094
+
14095
+ ## SME Guidance Cache
14096
+ ### [Domain] (Phase N)
14097
+ - [Guidance]
14098
+
14099
+ ## Patterns Established
14100
+ - [Pattern]: [usage]
14101
+
14102
+ ## File Map
14103
+ - [path]: [purpose]
14104
+ \`\`\`
14105
+
14106
+ ---
14107
+
14108
+ ## FALLBACK BEHAVIOR
14109
+
14110
+ If an agent fails or produces poor output:
14111
+ 1. Retry with clearer instructions (once)
14112
+ 2. If still failing \u2192 Handle the task yourself
14113
+ 3. Document the issue in context.md
14114
+
14115
+ You CAN write code directly if delegation repeatedly fails, but always try delegation first.
14116
+
14117
+ ---
14118
+
14119
+ ## COMMUNICATION
14120
+
14121
+ - Brief delegation notices: "Scanning via @explorer..." not lengthy explanations
14122
+ - Summarize agent responses for the user
14123
+ - Ask confirmation at phase boundaries
14124
+ - Be direct, no flattery or preamble`;
14040
14125
  function createArchitectAgent(model, customPrompt, customAppendPrompt) {
14041
14126
  let prompt = ARCHITECT_PROMPT;
14042
14127
  if (customPrompt) {
@@ -14817,79 +14902,120 @@ function createAllSMEAgents(getModel, loadPrompt) {
14817
14902
  }
14818
14903
 
14819
14904
  // src/agents/index.ts
14820
- function getModelForAgent(agentName, config2) {
14821
- const explicit = config2?.agents?.[agentName]?.model;
14905
+ function getModelForAgent(agentName, swarmAgents) {
14906
+ const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14907
+ const explicit = swarmAgents?.[baseAgentName]?.model;
14822
14908
  if (explicit)
14823
14909
  return explicit;
14824
- if (isSMEAgent(agentName)) {
14825
- const categoryModel = config2?.agents?.[CATEGORY_PREFIXES.sme]?.model;
14910
+ if (isSMEAgent(baseAgentName)) {
14911
+ const categoryModel = swarmAgents?.[CATEGORY_PREFIXES.sme]?.model;
14826
14912
  if (categoryModel)
14827
14913
  return categoryModel;
14828
14914
  return DEFAULT_MODELS._sme;
14829
14915
  }
14830
- if (isQAAgent(agentName)) {
14831
- const categoryModel = config2?.agents?.[CATEGORY_PREFIXES.qa]?.model;
14916
+ if (isQAAgent(baseAgentName)) {
14917
+ const categoryModel = swarmAgents?.[CATEGORY_PREFIXES.qa]?.model;
14832
14918
  if (categoryModel)
14833
14919
  return categoryModel;
14834
14920
  return DEFAULT_MODELS._qa;
14835
14921
  }
14836
- return DEFAULT_MODELS[agentName] ?? DEFAULT_MODELS.default;
14922
+ return DEFAULT_MODELS[baseAgentName] ?? DEFAULT_MODELS.default;
14837
14923
  }
14838
- function isAgentDisabled(agentName, config2) {
14839
- return config2?.agents?.[agentName]?.disabled === true;
14924
+ function isAgentDisabled(agentName, swarmAgents) {
14925
+ const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14926
+ return swarmAgents?.[baseAgentName]?.disabled === true;
14840
14927
  }
14841
- function getTemperatureOverride(agentName, config2) {
14842
- return config2?.agents?.[agentName]?.temperature;
14928
+ function getTemperatureOverride(agentName, swarmAgents) {
14929
+ const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14930
+ return swarmAgents?.[baseAgentName]?.temperature;
14843
14931
  }
14844
- function applyOverrides(agent, config2) {
14845
- const tempOverride = getTemperatureOverride(agent.name, config2);
14932
+ function applyOverrides(agent, swarmAgents) {
14933
+ const tempOverride = getTemperatureOverride(agent.name, swarmAgents);
14846
14934
  if (tempOverride !== undefined) {
14847
14935
  agent.config.temperature = tempOverride;
14848
14936
  }
14849
14937
  return agent;
14850
14938
  }
14851
- function createAgents(config2) {
14939
+ function createSwarmAgents(swarmId, swarmConfig, isDefault) {
14852
14940
  const agents = [];
14853
- const getModel = (name) => getModelForAgent(name, config2);
14941
+ const swarmAgents = swarmConfig.agents;
14942
+ const prefix = isDefault ? "" : `${swarmId}_`;
14943
+ const getModel = (name) => getModelForAgent(name, swarmAgents);
14854
14944
  const getPrompts = (name) => loadAgentPrompt(name);
14855
- if (!isAgentDisabled("architect", config2)) {
14945
+ const prefixName = (name) => `${prefix}${name}`;
14946
+ const subagentNames = ALL_SUBAGENT_NAMES.map((name) => `@${prefix}${name}`).join(" ");
14947
+ if (!isAgentDisabled("architect", swarmAgents)) {
14856
14948
  const architectPrompts = getPrompts("architect");
14857
14949
  const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt);
14858
- agents.push(applyOverrides(architect, config2));
14950
+ architect.name = prefixName("architect");
14951
+ if (!isDefault) {
14952
+ const swarmName = swarmConfig.name || swarmId;
14953
+ architect.description = `[${swarmName}] ${architect.description}`;
14954
+ architect.config.prompt = architect.config.prompt?.replace(/@explorer/g, `@${prefix}explorer`).replace(/@coder/g, `@${prefix}coder`).replace(/@test_engineer/g, `@${prefix}test_engineer`).replace(/@security_reviewer/g, `@${prefix}security_reviewer`).replace(/@auditor/g, `@${prefix}auditor`).replace(/@sme_(\w+)/g, `@${prefix}sme_$1`);
14955
+ }
14956
+ agents.push(applyOverrides(architect, swarmAgents));
14859
14957
  }
14860
- if (!isAgentDisabled("explorer", config2)) {
14958
+ if (!isAgentDisabled("explorer", swarmAgents)) {
14861
14959
  const explorerPrompts = getPrompts("explorer");
14862
14960
  const explorer = createExplorerAgent(getModel("explorer"), explorerPrompts.prompt, explorerPrompts.appendPrompt);
14863
- agents.push(applyOverrides(explorer, config2));
14961
+ explorer.name = prefixName("explorer");
14962
+ agents.push(applyOverrides(explorer, swarmAgents));
14864
14963
  }
14865
14964
  const smeAgents = createAllSMEAgents(getModel, getPrompts);
14866
14965
  for (const sme of smeAgents) {
14867
- if (!isAgentDisabled(sme.name, config2)) {
14868
- agents.push(applyOverrides(sme, config2));
14966
+ if (!isAgentDisabled(sme.name, swarmAgents)) {
14967
+ sme.name = prefixName(sme.name);
14968
+ agents.push(applyOverrides(sme, swarmAgents));
14869
14969
  }
14870
14970
  }
14871
- if (!isAgentDisabled("coder", config2)) {
14971
+ if (!isAgentDisabled("coder", swarmAgents)) {
14872
14972
  const coderPrompts = getPrompts("coder");
14873
14973
  const coder = createCoderAgent(getModel("coder"), coderPrompts.prompt, coderPrompts.appendPrompt);
14874
- agents.push(applyOverrides(coder, config2));
14974
+ coder.name = prefixName("coder");
14975
+ agents.push(applyOverrides(coder, swarmAgents));
14875
14976
  }
14876
- if (!isAgentDisabled("security_reviewer", config2)) {
14977
+ if (!isAgentDisabled("security_reviewer", swarmAgents)) {
14877
14978
  const securityPrompts = getPrompts("security_reviewer");
14878
14979
  const security = createSecurityReviewerAgent(getModel("security_reviewer"), securityPrompts.prompt, securityPrompts.appendPrompt);
14879
- agents.push(applyOverrides(security, config2));
14980
+ security.name = prefixName("security_reviewer");
14981
+ agents.push(applyOverrides(security, swarmAgents));
14880
14982
  }
14881
- if (!isAgentDisabled("auditor", config2)) {
14983
+ if (!isAgentDisabled("auditor", swarmAgents)) {
14882
14984
  const auditorPrompts = getPrompts("auditor");
14883
14985
  const auditor = createAuditorAgent(getModel("auditor"), auditorPrompts.prompt, auditorPrompts.appendPrompt);
14884
- agents.push(applyOverrides(auditor, config2));
14986
+ auditor.name = prefixName("auditor");
14987
+ agents.push(applyOverrides(auditor, swarmAgents));
14885
14988
  }
14886
- if (!isAgentDisabled("test_engineer", config2)) {
14989
+ if (!isAgentDisabled("test_engineer", swarmAgents)) {
14887
14990
  const testPrompts = getPrompts("test_engineer");
14888
14991
  const testEngineer = createTestEngineerAgent(getModel("test_engineer"), testPrompts.prompt, testPrompts.appendPrompt);
14889
- agents.push(applyOverrides(testEngineer, config2));
14992
+ testEngineer.name = prefixName("test_engineer");
14993
+ agents.push(applyOverrides(testEngineer, swarmAgents));
14890
14994
  }
14891
14995
  return agents;
14892
14996
  }
14997
+ function createAgents(config2) {
14998
+ const allAgents = [];
14999
+ const swarms = config2?.swarms;
15000
+ if (swarms && Object.keys(swarms).length > 0) {
15001
+ const swarmIds = Object.keys(swarms);
15002
+ const defaultSwarmId = swarmIds.includes("default") ? "default" : swarmIds[0];
15003
+ for (const swarmId of swarmIds) {
15004
+ const swarmConfig = swarms[swarmId];
15005
+ const isDefault = swarmId === defaultSwarmId;
15006
+ const swarmAgents = createSwarmAgents(swarmId, swarmConfig, isDefault);
15007
+ allAgents.push(...swarmAgents);
15008
+ }
15009
+ } else {
15010
+ const legacySwarmConfig = {
15011
+ name: "Default",
15012
+ agents: config2?.agents
15013
+ };
15014
+ const swarmAgents = createSwarmAgents("default", legacySwarmConfig, true);
15015
+ allAgents.push(...swarmAgents);
15016
+ }
15017
+ return allAgents;
15018
+ }
14893
15019
  function getAgentConfigs(config2) {
14894
15020
  const agents = createAgents(config2);
14895
15021
  return Object.fromEntries(agents.map((agent) => {
@@ -14897,9 +15023,9 @@ function getAgentConfigs(config2) {
14897
15023
  ...agent.config,
14898
15024
  description: agent.description
14899
15025
  };
14900
- if (agent.name === "architect") {
15026
+ if (agent.name === "architect" || agent.name.endsWith("_architect")) {
14901
15027
  sdkConfig.mode = "primary";
14902
- } else if (isSubagent(agent.name)) {
15028
+ } else {
14903
15029
  sdkConfig.mode = "subagent";
14904
15030
  }
14905
15031
  return [agent.name, sdkConfig];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "2.3.3",
3
+ "version": "3.1.0",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",