opencode-swarm 2.1.2 → 2.3.1

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
@@ -2,78 +2,312 @@
2
2
 
3
3
  ![License](https://img.shields.io/badge/license-MIT-blue)
4
4
  ![OpenCode Plugin](https://img.shields.io/badge/opencode-plugin-green)
5
- ![Agentic Architecture](https://img.shields.io/badge/architecture-architect--centric-purple)
5
+ ![Architecture](https://img.shields.io/badge/architecture-architect--centric-purple)
6
+ ![Version](https://img.shields.io/badge/version-2.2.1-orange)
6
7
 
7
- **Architect-driven, multi-agent development for OpenCode.**
8
- Design-first orchestration with domain-aware SMEs, heterogeneous model perspectives, production-grade code generation, and layered QA.
8
+ **Architect-driven, multi-agent development for OpenCode.**
9
9
 
10
- OpenCode Swarm is built for engineers who want **structured reasoning, controlled delegation, and predictable outcomes**—not parallel agent noise.
10
+ Design-first orchestration with codebase discovery, domain-aware SMEs, heterogeneous model perspectives, and layered QA review.
11
11
 
12
- ---
12
+ ```
13
+ ┌──────────────────────────────────────────────────────────────────────────┐
14
+ │ "Review this PowerShell application for security issues" │
15
+ └──────────────────────────────────────────────────────────────────────────┘
16
+
17
+
18
+ ┌──────────────────────────────────────────────────────────────────────────┐
19
+ │ ARCHITECT: Delegating to @explorer for codebase analysis... │
20
+ └──────────────────────────────────────────────────────────────────────────┘
21
+
22
+
23
+ ┌──────────────────────────────────────────────────────────────────────────┐
24
+ │ EXPLORER: PowerShell module, 12 files, domains: powershell, security │
25
+ │ → Flagged: auth.ps1, invoke-command.ps1 for SME review │
26
+ └──────────────────────────────────────────────────────────────────────────┘
27
+
28
+
29
+ ┌──────────────────────────────────────────────────────────────────────────┐
30
+ │ SME_POWERSHELL: Remoting patterns detected, needs constrained endpoints │
31
+ │ SME_SECURITY: Credential handling issues in auth.ps1:42-58 │
32
+ └──────────────────────────────────────────────────────────────────────────┘
33
+
34
+
35
+ ┌──────────────────────────────────────────────────────────────────────────┐
36
+ │ ARCHITECT: Collated review with 3 HIGH findings, 2 recommendations │
37
+ └──────────────────────────────────────────────────────────────────────────┘
38
+ ```
13
39
 
14
- ## Why OpenCode Swarm
40
+ ---
15
41
 
16
- Most agent frameworks parallelize everything and hope coherence emerges later.
17
- OpenCode Swarm enforces discipline:
42
+ ## Why OpenCode Swarm?
18
43
 
19
- - A single Architect owns analysis and decisions
20
- - Experts are consulted only when technically relevant
21
- - Agents execute serially for traceability
22
- - Security and correctness are validated before delivery
23
- - Different models can be assigned per role, introducing genuinely distinct perspectives
44
+ Most agent frameworks parallelize everything and hope coherence emerges.
45
+ **OpenCode Swarm enforces discipline:**
24
46
 
25
- This design improves **accuracy, efficiency, and failure detection**, especially on complex or high-stakes tasks.
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 |
26
54
 
27
55
  ---
28
56
 
29
- ## Key Advantage: Heterogeneous Model Perspectives
30
-
31
- OpenCode Swarm allows **per-role model selection** so that each cognitive function is optimized independently:
57
+ ## Architecture
32
58
 
33
- - Architect → deep reasoning and synthesis
34
- - SMEs → domain recall and speed
35
- - Coder → implementation fidelity
36
- - QA → adversarial review and audit rigor
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
+ ```
37
92
 
38
- Using different models per role reduces correlated failure modes, increases early error detection, and mirrors how real engineering teams benefit from diverse expertise.
93
+ ### Agent Permissions
39
94
 
40
- See: [docs/design-rationale.md](docs/design-rationale.md)
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 |
41
104
 
42
105
  ---
43
106
 
44
- ## Architecture Overview
107
+ ## Heterogeneous Model Perspectives
45
108
 
46
- OpenCode Swarm implements a hub-and-spoke pipeline with a single controlling Architect.
109
+ OpenCode Swarm allows **different models per role**, reducing correlated failures:
47
110
 
48
- ```
49
- User → Architect (analysis)
50
- Reader (optional)
51
- Relevant SMEs (serial)
52
- Architect (spec synthesis)
53
- Coder
54
- Security Review Audit
55
- Architect (triage)
56
- Test Engineer
111
+ ```json
112
+ {
113
+ "agents": {
114
+ "architect": { "model": "anthropic/claude-sonnet-4-5" },
115
+ "explorer": { "model": "google/gemini-2.0-flash" },
116
+ "coder": { "model": "anthropic/claude-sonnet-4-5" },
117
+ "_sme": { "model": "google/gemini-2.0-flash" },
118
+ "_qa": { "model": "openai/gpt-4o" },
119
+ "test_engineer": { "model": "google/gemini-2.0-flash" }
120
+ }
121
+ }
57
122
  ```
58
123
 
59
- See: [docs/architecture.md](docs/architecture.md)
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
60
129
 
61
130
  ---
62
131
 
63
132
  ## Installation
64
133
 
134
+ Add to your `opencode.json`:
135
+
65
136
  ```json
66
137
  {
67
138
  "plugin": ["opencode-swarm"]
68
139
  }
69
140
  ```
70
141
 
142
+ Or install via CLI:
143
+
71
144
  ```bash
72
145
  bunx opencode-swarm install
73
146
  ```
74
147
 
75
148
  ---
76
149
 
150
+ ## Configuration
151
+
152
+ Create `~/.config/opencode/opencode-swarm.json`:
153
+
154
+ ```json
155
+ {
156
+ "agents": {
157
+ "architect": { "model": "anthropic/claude-sonnet-4-5" },
158
+ "explorer": { "model": "google/gemini-2.0-flash" },
159
+ "coder": { "model": "anthropic/claude-sonnet-4-5" },
160
+ "_sme": { "model": "google/gemini-2.0-flash" },
161
+ "_qa": { "model": "google/gemini-2.0-flash" },
162
+ "test_engineer": { "model": "google/gemini-2.0-flash" }
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### Category Defaults
168
+
169
+ `_sme` and `_qa` set defaults for all agents in that category:
170
+
171
+ ```json
172
+ {
173
+ "agents": {
174
+ "_sme": { "model": "google/gemini-2.0-flash" },
175
+ "sme_oracle": { "model": "anthropic/claude-sonnet-4-5" }
176
+ }
177
+ }
178
+ ```
179
+
180
+ ### Disable Unused Domains
181
+
182
+ ```json
183
+ {
184
+ "agents": {
185
+ "sme_vmware": { "disabled": true },
186
+ "sme_azure": { "disabled": true }
187
+ }
188
+ }
189
+ ```
190
+
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
+ ---
198
+
199
+ ## Agents
200
+
201
+ ### Orchestrator
202
+ | Agent | Description |
203
+ |-------|-------------|
204
+ | `architect` | Central orchestrator. Analyzes requests, delegates to specialists, synthesizes outputs, triages QA feedback. |
205
+
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 |
241
+
242
+ ---
243
+
244
+ ## Tools
245
+
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
300
+
301
+ ---
302
+
303
+ ## Documentation
304
+
305
+ - [Architecture Details](docs/architecture.md)
306
+ - [Design Rationale](docs/design-rationale.md)
307
+ - [Installation Guide](docs/installation.md)
308
+
309
+ ---
310
+
77
311
  ## License
78
312
 
79
313
  MIT
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from './architect';
2
+ export declare function createExplorerAgent(model: string, customPrompt?: string, customAppendPrompt?: string): AgentDefinition;
@@ -13,7 +13,7 @@ export declare function createAgents(config?: PluginConfig): AgentDefinition[];
13
13
  export declare function getAgentConfigs(config?: PluginConfig): Record<string, SDKAgentConfig>;
14
14
  export { createArchitectAgent } from './architect';
15
15
  export { createCoderAgent } from './coder';
16
- export { createReaderAgent } from './reader';
16
+ export { createExplorerAgent } from './explorer';
17
17
  export { createSecurityReviewerAgent } from './security-reviewer';
18
18
  export { createAuditorAgent } from './auditor';
19
19
  export { createTestEngineerAgent } from './test-engineer';
@@ -0,0 +1,2 @@
1
+ import type { SMEDomainConfig } from './base';
2
+ export declare const apiSMEConfig: SMEDomainConfig;
@@ -0,0 +1,2 @@
1
+ import type { SMEDomainConfig } from './base';
2
+ export declare const databaseSMEConfig: SMEDomainConfig;
@@ -0,0 +1,2 @@
1
+ import type { SMEDomainConfig } from './base';
2
+ export declare const devopsSMEConfig: SMEDomainConfig;
@@ -0,0 +1,2 @@
1
+ import type { SMEDomainConfig } from './base';
2
+ export declare const webSMEConfig: SMEDomainConfig;
@@ -1,9 +1,9 @@
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"];
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", "sme_web", "sme_database", "sme_devops", "sme_api"];
2
2
  export declare const QA_AGENTS: readonly ["security_reviewer", "auditor"];
3
- export declare const PIPELINE_AGENTS: readonly ["reader", "coder", "test_engineer"];
3
+ export declare const PIPELINE_AGENTS: readonly ["explorer", "coder", "test_engineer"];
4
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", "reader", "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", "reader", "coder", "test_engineer"];
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", "sme_web", "sme_database", "sme_devops", "sme_api", "security_reviewer", "auditor", "explorer", "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", "sme_web", "sme_database", "sme_devops", "sme_api", "security_reviewer", "auditor", "explorer", "coder", "test_engineer"];
7
7
  export type SMEAgentName = (typeof SME_AGENTS)[number];
8
8
  export type QAAgentName = (typeof QA_AGENTS)[number];
9
9
  export type PipelineAgentName = (typeof PIPELINE_AGENTS)[number];
package/dist/index.js CHANGED
@@ -22,10 +22,14 @@ var SME_AGENTS = [
22
22
  "sme_vmware",
23
23
  "sme_azure",
24
24
  "sme_active_directory",
25
- "sme_ui_ux"
25
+ "sme_ui_ux",
26
+ "sme_web",
27
+ "sme_database",
28
+ "sme_devops",
29
+ "sme_api"
26
30
  ];
27
31
  var QA_AGENTS = ["security_reviewer", "auditor"];
28
- var PIPELINE_AGENTS = ["reader", "coder", "test_engineer"];
32
+ var PIPELINE_AGENTS = ["explorer", "coder", "test_engineer"];
29
33
  var ORCHESTRATOR_NAME = "architect";
30
34
  var ALL_SUBAGENT_NAMES = [
31
35
  ...SME_AGENTS,
@@ -42,7 +46,7 @@ var CATEGORY_PREFIXES = {
42
46
  };
43
47
  var DEFAULT_MODELS = {
44
48
  architect: "anthropic/claude-sonnet-4-5",
45
- reader: "google/gemini-2.0-flash",
49
+ explorer: "google/gemini-2.0-flash",
46
50
  coder: "anthropic/claude-sonnet-4-5",
47
51
  test_engineer: "google/gemini-2.0-flash",
48
52
  _sme: "google/gemini-2.0-flash",
@@ -13844,11 +13848,18 @@ function loadAgentPrompt(agentName) {
13844
13848
  // src/agents/architect.ts
13845
13849
  var ARCHITECT_PROMPT = `You are Architect - an AI coding orchestrator that coordinates specialists to deliver quality code.
13846
13850
 
13847
- **Role**: Analyze requests, consult domain SMEs, delegate implementation, and manage QA review.
13851
+ **Role**: Analyze requests, delegate discovery to Explorer, consult domain SMEs, delegate implementation, and manage QA review.
13852
+
13853
+ **CRITICAL RULE: SERIAL EXECUTION ONLY**
13854
+ You MUST call agents ONE AT A TIME. After each delegation:
13855
+ 1. Send to ONE agent
13856
+ 2. STOP and wait for response
13857
+ 3. Only then proceed to next agent
13858
+ NEVER delegate to multiple agents in the same message. This is mandatory.
13848
13859
 
13849
13860
  **Agents**:
13850
13861
 
13851
- @reader - Fast data processing agent for analyzing large files, codebases, or outputs
13862
+ @explorer - Fast codebase discovery and summarization (ALWAYS FIRST for code tasks)
13852
13863
  @sme_windows - Windows OS internals, registry, services, WMI/CIM
13853
13864
  @sme_powershell - PowerShell scripting, cmdlets, modules, remoting
13854
13865
  @sme_python - Python ecosystem, libraries, best practices
@@ -13860,64 +13871,71 @@ var ARCHITECT_PROMPT = `You are Architect - an AI coding orchestrator that coord
13860
13871
  @sme_azure - Azure cloud services, Entra ID, ARM/Bicep
13861
13872
  @sme_active_directory - Active Directory, LDAP, Group Policy, Kerberos
13862
13873
  @sme_ui_ux - UI/UX design, interaction patterns, accessibility
13874
+ @sme_web - Web/frontend (Flutter, React, Vue, Angular, JS/TS, HTML/CSS)
13875
+ @sme_database - Databases (SQL Server, PostgreSQL, MySQL, MongoDB, Redis)
13876
+ @sme_devops - DevOps, CI/CD, Docker, Kubernetes, Terraform, GitHub Actions
13877
+ @sme_api - API design, REST, GraphQL, OAuth, JWT, webhooks
13863
13878
 
13864
13879
  @coder - Implementation specialist, writes production code
13865
13880
  @security_reviewer - Security audit, vulnerability assessment
13866
13881
  @auditor - Code quality review, correctness verification
13867
13882
  @test_engineer - Test case generation and validation scripts
13868
13883
 
13869
- **CRITICAL: @reader MUST be your FIRST delegation for code reviews**
13870
- When asked to review, analyze, or examine any codebase:
13871
- 1. IMMEDIATELY delegate to @reader - do not read the code yourself
13872
- 2. Wait for @reader's summary
13873
- 3. Use that summary to decide which SMEs to consult
13874
- 4. Never skip @reader for code review tasks
13884
+ **WORKFLOW**:
13885
+
13886
+ ## 1. Parse Request (you do this briefly)
13887
+ Understand what the user wants. Determine task type:
13888
+ - Code review/analysis \u2192 Explorer \u2192 SMEs (serial) \u2192 Collate
13889
+ - New implementation \u2192 Explorer \u2192 SMEs (serial) \u2192 Coder \u2192 QA (serial) \u2192 Test
13890
+ - Bug fix \u2192 Explorer \u2192 SMEs (serial) \u2192 Coder \u2192 QA (serial)
13891
+ - Question about codebase \u2192 Explorer \u2192 answer
13875
13892
 
13876
- **Workflow**:
13893
+ ## 2. Explorer FIRST (one delegation, wait for response)
13894
+ "Delegating to @explorer for codebase analysis..."
13895
+ STOP HERE. Wait for @explorer response before proceeding.
13877
13896
 
13878
- ## 1. Analyze Request (you do this briefly)
13879
- Parse what user wants. If it involves reviewing code \u2192 go directly to step 2.
13897
+ ## 3. SME Consultation (ONE AT A TIME, wait between each)
13898
+ From @explorer's "Relevant Domains" list:
13899
+ - Delegate to first SME, WAIT for response
13900
+ - Then delegate to second SME, WAIT for response
13901
+ - Then delegate to third SME (if needed), WAIT for response
13902
+ - Usually 1-3 SMEs total, NEVER call them in parallel
13880
13903
 
13881
- ## 2. Reader FIRST (for any code review/analysis)
13882
- "Delegating to @reader for codebase analysis..."
13883
- - Send the codebase/files to @reader
13884
- - Wait for summary response
13885
- - Use summary to identify domains and issues
13904
+ Example of CORRECT serial SME calls:
13905
+ Turn 1: "Consulting @sme_powershell..." \u2192 wait
13906
+ Turn 2: (after response) "Consulting @sme_security..." \u2192 wait
13907
+ Turn 3: (after response) "Consulting @sme_windows..." \u2192 wait
13886
13908
 
13887
- ## 3. SME Consultation (based on @reader's findings)
13888
- Consult only SMEs for domains identified from @reader's summary.
13889
- Usually 1-3 SMEs, not all 11. Wait for each response.
13909
+ Example of WRONG parallel calls (NEVER DO THIS):
13910
+ "Consulting @sme_powershell, @sme_security, and @sme_windows..." \u2190 WRONG
13890
13911
 
13891
13912
  ## 4. Collate (you do this)
13892
- Combine @reader summary + SME inputs into final review or specification.
13913
+ After ALL SME responses received, synthesize into:
13914
+ - For reviews: final findings report
13915
+ - For implementation: unified specification for @coder
13893
13916
 
13894
- ## 5. Code (delegate to @coder) - only if writing new code
13895
- Send specification to @coder. Wait for implementation.
13917
+ ## 5. Code (one delegation to @coder, wait for response)
13896
13918
 
13897
- ## 6. QA Review (delegate serially) - only if code was written
13898
- @security_reviewer first, then @auditor.
13919
+ ## 6. QA Review (serial: @security_reviewer first, wait, then @auditor)
13899
13920
 
13900
13921
  ## 7. Triage (you do this)
13901
13922
  APPROVED \u2192 @test_engineer | REVISION_NEEDED \u2192 @coder | BLOCKED \u2192 explain
13902
13923
 
13903
- ## 8. Test (delegate to @test_engineer) - if approved
13924
+ ## 8. Test (one delegation to @test_engineer)
13904
13925
 
13905
- **Order of Operations for Code Review**:
13906
- 1. @reader (ALWAYS FIRST - analyzes codebase)
13907
- 2. @sme_* (only relevant domains based on @reader findings)
13908
- 3. Collate findings into review
13926
+ **DELEGATION RULES**:
13927
+ - ONE agent per turn. Wait for response. Then next agent.
13928
+ - @explorer is ALWAYS first for code tasks
13929
+ - SMEs are called serially based on @explorer's domain detection
13930
+ - QA agents are called serially: security_reviewer \u2192 auditor
13931
+ - Brief notices: "Delegating to @explorer..." not lengthy explanations
13932
+ - If an agent fails, you can handle it yourself
13909
13933
 
13910
- **Order of Operations for New Code**:
13911
- 1. @reader (if analyzing existing code first)
13912
- 2. @sme_* (relevant domains)
13913
- 3. @coder (implementation)
13914
- 4. @security_reviewer \u2192 @auditor (QA)
13915
- 5. @test_engineer (tests)
13916
-
13917
- **Communication**:
13918
- - Be direct, no preamble
13919
- - Don't ask for confirmation between phases
13920
- - You analyze, collate, and triage. You never write code yourself.`;
13934
+ **COMMUNICATION**:
13935
+ - Be direct, no preamble or flattery
13936
+ - Don't ask for confirmation between phases - proceed automatically
13937
+ - If request is vague, ask ONE targeted question before starting
13938
+ - You orchestrate and synthesize. Prefer delegation over doing it yourself.`;
13921
13939
  function createArchitectAgent(model, customPrompt, customAppendPrompt) {
13922
13940
  let prompt = ARCHITECT_PROMPT;
13923
13941
  if (customPrompt) {
@@ -13999,7 +14017,12 @@ ${customAppendPrompt}`;
13999
14017
  config: {
14000
14018
  model,
14001
14019
  temperature: 0.1,
14002
- prompt
14020
+ prompt,
14021
+ tools: {
14022
+ write: false,
14023
+ edit: false,
14024
+ patch: false
14025
+ }
14003
14026
  }
14004
14027
  };
14005
14028
  }
@@ -14050,63 +14073,85 @@ ${customAppendPrompt}`;
14050
14073
  };
14051
14074
  }
14052
14075
 
14053
- // src/agents/reader.ts
14054
- var READER_PROMPT = `You are Reader - a fast data processing specialist.
14076
+ // src/agents/explorer.ts
14077
+ var EXPLORER_PROMPT = `You are Explorer - a fast codebase discovery and analysis specialist.
14055
14078
 
14056
- **Role**: Quickly analyze large datasets, codebases, or outputs and provide concise summaries for the Architect.
14079
+ **Role**: Quickly scan and summarize codebases so the Architect can make informed decisions. You are ALWAYS the first agent called for any task involving existing code.
14057
14080
 
14058
- **Behavior**:
14059
- - Read and process the provided content efficiently
14060
- - Extract key information relevant to the task
14061
- - Summarize findings in a structured, actionable format
14062
- - Focus on what matters for implementation decisions
14081
+ **Capabilities**:
14082
+ - Scan directory structure (glob, ls, tree)
14083
+ - Read and summarize key files (README, configs, entry points)
14084
+ - Identify languages, frameworks, patterns
14085
+ - Search for specific patterns (grep)
14086
+ - Provide file paths for deeper analysis
14063
14087
 
14064
- **Use cases**:
14065
- - Analyzing gitingest output to understand a codebase
14066
- - Reviewing large log files or data dumps
14067
- - Summarizing documentation or specifications
14068
- - Processing API responses or test results
14088
+ **Behavior**:
14089
+ - Be fast - scan broadly, read selectively
14090
+ - Focus on understanding structure before diving into details
14091
+ - Identify which technical domains are relevant (powershell, python, security, etc.)
14092
+ - Flag files that need deeper SME review
14069
14093
 
14070
14094
  **Output Format**:
14071
- <summary>
14072
- [2-3 sentence overview of what you analyzed]
14073
- </summary>
14074
14095
 
14075
- <key_findings>
14076
- - [Finding 1: specific, actionable]
14077
- - [Finding 2: specific, actionable]
14078
- - [Finding 3: specific, actionable]
14079
- </key_findings>
14096
+ <codebase_summary>
14097
+ **Project**: [name/type - e.g., "PowerShell module for AD management"]
14098
+ **Languages**: [primary languages detected]
14099
+ **Framework/Stack**: [if applicable]
14100
+
14101
+ **Structure**:
14102
+ \`\`\`
14103
+ [brief directory tree of key folders]
14104
+ \`\`\`
14105
+
14106
+ **Key Files**:
14107
+ - \`/path/to/entry.ps1\` - Main entry point, [brief description]
14108
+ - \`/path/to/config.json\` - Configuration, [what it configures]
14109
+
14110
+ **Architecture**:
14111
+ [2-3 sentences on how the code is organized]
14112
+
14113
+ **Patterns Observed**:
14114
+ - [coding patterns, conventions, potential issues]
14115
+
14116
+ **Relevant Domains**: [comma-separated: powershell, security, windows, etc.]
14117
+ </codebase_summary>
14080
14118
 
14081
- <relevant_details>
14082
- [Specific code patterns, file paths, function names, or data points the Architect needs]
14083
- </relevant_details>
14119
+ <files_for_review>
14120
+ [List specific files that need deeper analysis, with brief reason]
14121
+ - \`/path/to/file1.ps1\` - Complex logic, needs @sme_powershell review
14122
+ - \`/path/to/auth.ps1\` - Security-sensitive, needs @sme_security review
14123
+ </files_for_review>
14084
14124
 
14085
- <recommendations>
14086
- [Brief suggestions based on your analysis]
14087
- </recommendations>
14125
+ <initial_observations>
14126
+ [Any immediate concerns, questions, or notable findings]
14127
+ </initial_observations>
14088
14128
 
14089
14129
  **Constraints**:
14090
- - No code writing
14091
- - No delegation
14092
- - Focus on speed and accuracy
14093
- - Keep total output under 2000 characters`;
14094
- function createReaderAgent(model, customPrompt, customAppendPrompt) {
14095
- let prompt = READER_PROMPT;
14130
+ - Keep total output under 4000 characters
14131
+ - No code writing or modification
14132
+ - No delegation to other agents
14133
+ - Focus on discovery, not implementation`;
14134
+ function createExplorerAgent(model, customPrompt, customAppendPrompt) {
14135
+ let prompt = EXPLORER_PROMPT;
14096
14136
  if (customPrompt) {
14097
14137
  prompt = customPrompt;
14098
14138
  } else if (customAppendPrompt) {
14099
- prompt = `${READER_PROMPT}
14139
+ prompt = `${EXPLORER_PROMPT}
14100
14140
 
14101
14141
  ${customAppendPrompt}`;
14102
14142
  }
14103
14143
  return {
14104
- name: "reader",
14105
- description: "Fast data processing agent for analyzing large files, codebases, or outputs. Returns concise summaries.",
14144
+ name: "explorer",
14145
+ description: "Fast codebase discovery and analysis. Scans directory structure, identifies languages/frameworks, summarizes key files, and flags areas needing SME review.",
14106
14146
  config: {
14107
14147
  model,
14108
14148
  temperature: 0.1,
14109
- prompt
14149
+ prompt,
14150
+ tools: {
14151
+ write: false,
14152
+ edit: false,
14153
+ patch: false
14154
+ }
14110
14155
  }
14111
14156
  };
14112
14157
  }
@@ -14163,7 +14208,12 @@ ${customAppendPrompt}`;
14163
14208
  config: {
14164
14209
  model,
14165
14210
  temperature: 0.1,
14166
- prompt
14211
+ prompt,
14212
+ tools: {
14213
+ write: false,
14214
+ edit: false,
14215
+ patch: false
14216
+ }
14167
14217
  }
14168
14218
  };
14169
14219
  }
@@ -14288,7 +14338,12 @@ ${customAppendPrompt}`;
14288
14338
  config: {
14289
14339
  model,
14290
14340
  temperature: 0.2,
14291
- prompt
14341
+ prompt,
14342
+ tools: {
14343
+ write: false,
14344
+ edit: false,
14345
+ patch: false
14346
+ }
14292
14347
  }
14293
14348
  };
14294
14349
  }
@@ -14317,6 +14372,30 @@ var activeDirectorySMEConfig = {
14317
14372
  - Group Policy preferences vs policies`
14318
14373
  };
14319
14374
 
14375
+ // src/agents/sme/api.ts
14376
+ var apiSMEConfig = {
14377
+ domain: "api",
14378
+ description: "API design, REST, GraphQL, authentication, and backend integration patterns",
14379
+ guidance: `For API tasks, provide:
14380
+ - **REST**: Resource naming, HTTP methods (GET/POST/PUT/PATCH/DELETE), status codes, HATEOAS, versioning strategies
14381
+ - **GraphQL**: Schema design, resolvers, mutations, subscriptions, N+1 prevention, Apollo/Relay patterns
14382
+ - **gRPC**: Protocol buffer definitions, streaming types, service implementation
14383
+ - **WebSockets**: Connection lifecycle, Socket.io, SignalR, heartbeat patterns
14384
+ - **OpenAPI/Swagger**: Specification authoring, code generation, documentation hosting
14385
+ - **OAuth 2.0**: Authorization code flow, client credentials, PKCE for public clients, token refresh
14386
+ - **OpenID Connect**: ID tokens, userinfo endpoint, discovery document
14387
+ - **JWT**: Token structure, signing algorithms, claims design, refresh token rotation
14388
+ - API key management and rate limiting
14389
+ - RBAC/ABAC authorization patterns
14390
+ - Pagination strategies (cursor, offset, keyset)
14391
+ - Error response formats (RFC 7807 Problem Details)
14392
+ - Request validation and sanitization
14393
+ - CORS configuration
14394
+ - API gateway patterns (Kong, AWS API Gateway, Azure APIM)
14395
+ - Webhook design (signatures, retry logic, idempotency keys)
14396
+ - Common gotchas (token expiration, CORS preflight, rate limit handling)`
14397
+ };
14398
+
14320
14399
  // src/agents/sme/azure.ts
14321
14400
  var azureSMEConfig = {
14322
14401
  domain: "azure",
@@ -14340,6 +14419,49 @@ var azureSMEConfig = {
14340
14419
  - Azure Government differences if applicable`
14341
14420
  };
14342
14421
 
14422
+ // src/agents/sme/database.ts
14423
+ var databaseSMEConfig = {
14424
+ domain: "database",
14425
+ description: "Database design, SQL, and data management (SQL Server, PostgreSQL, MySQL, MongoDB, Redis)",
14426
+ guidance: `For database tasks, provide:
14427
+ - **SQL Server**: T-SQL syntax, stored procedures, CTEs, window functions, SSMS usage, Always On availability
14428
+ - **PostgreSQL**: PL/pgSQL, extensions (pgvector, PostGIS), JSONB operations, full-text search, partitioning
14429
+ - **MySQL/MariaDB**: InnoDB specifics, replication setup, MySQL Workbench, character set handling
14430
+ - **SQLite**: Embedded usage, WAL mode, mobile/desktop considerations, size limits
14431
+ - **MongoDB**: Document modeling, aggregation pipeline, indexing strategies, Atlas features
14432
+ - **Redis**: Data structures (strings, hashes, lists, sets, sorted sets), caching patterns, pub/sub, Lua scripting
14433
+ - Database design principles (normalization, denormalization tradeoffs)
14434
+ - Index design and query optimization (execution plans, covering indexes)
14435
+ - Transaction isolation levels and locking behavior
14436
+ - Connection pooling and management
14437
+ - Migration strategies and schema versioning
14438
+ - ORM patterns (Entity Framework, SQLAlchemy, Prisma, TypeORM)
14439
+ - N+1 query prevention
14440
+ - Backup and recovery strategies
14441
+ - Common gotchas (NULL handling, implicit conversions, timezone issues)`
14442
+ };
14443
+
14444
+ // src/agents/sme/devops.ts
14445
+ var devopsSMEConfig = {
14446
+ domain: "devops",
14447
+ description: "DevOps, CI/CD, containers, and infrastructure-as-code (Docker, Kubernetes, GitHub Actions, Terraform)",
14448
+ guidance: `For DevOps tasks, provide:
14449
+ - **Docker**: Dockerfile best practices, multi-stage builds, compose files, networking modes, volume mounts, registry usage
14450
+ - **Kubernetes**: Deployment/Service/Ingress manifests, ConfigMaps, Secrets, Helm charts, kubectl commands, resource limits
14451
+ - **GitHub Actions**: Workflow syntax, job dependencies, matrix builds, secrets management, reusable workflows, artifact handling
14452
+ - **Azure DevOps**: Pipeline YAML, stages/jobs/steps, variable groups, service connections, artifact feeds
14453
+ - **GitLab CI**: .gitlab-ci.yml structure, runners, environments, Auto DevOps
14454
+ - **Terraform**: HCL syntax, provider configuration, state management, modules, workspaces, import existing resources
14455
+ - **Ansible**: Playbook structure, roles, inventory management, vault encryption, idempotency
14456
+ - Container image optimization (layer caching, minimal base images, security scanning)
14457
+ - CI/CD pipeline design (build, test, deploy stages)
14458
+ - Branch strategies (GitFlow, trunk-based development)
14459
+ - Secrets management (HashiCorp Vault, Azure Key Vault, AWS Secrets Manager)
14460
+ - Infrastructure patterns (immutable infrastructure, blue-green, canary)
14461
+ - Monitoring and observability setup (Prometheus, Grafana, ELK)
14462
+ - Common gotchas (state drift, secret exposure, resource cleanup)`
14463
+ };
14464
+
14343
14465
  // src/agents/sme/linux.ts
14344
14466
  var linuxSMEConfig = {
14345
14467
  domain: "linux",
@@ -14510,6 +14632,27 @@ var vmwareSMEConfig = {
14510
14632
  - Performance metrics and monitoring (Get-Stat)`
14511
14633
  };
14512
14634
 
14635
+ // src/agents/sme/web.ts
14636
+ var webSMEConfig = {
14637
+ domain: "web",
14638
+ description: "Web and frontend development (Flutter, React, Vue, Angular, JavaScript/TypeScript, HTML/CSS)",
14639
+ guidance: `For web/frontend tasks, provide:
14640
+ - **Flutter**: Dart syntax, widget composition, state management (Provider, Riverpod, Bloc), platform channels, pub.dev packages, hot reload workflow
14641
+ - **React**: Hooks (useState, useEffect, useMemo), context, Redux/Zustand, Next.js App Router, server components, React Native considerations
14642
+ - **Vue**: Composition API, Pinia stores, Nuxt 3, Vue Router, reactive refs
14643
+ - **Angular**: Components, services, dependency injection, RxJS patterns, NgRx, Angular CLI commands
14644
+ - **Svelte**: Runes ($state, $derived), SvelteKit routing, stores
14645
+ - **JavaScript/TypeScript**: ES modules, async/await, type narrowing, bundler config (Vite, webpack, esbuild)
14646
+ - **HTML/CSS**: Semantic markup, Flexbox/Grid layouts, CSS custom properties, Tailwind utility classes, SCSS
14647
+ - **Browser APIs**: DOM manipulation, Fetch API, Web Storage, Service Workers, WebSockets
14648
+ - Framework selection guidance based on project requirements
14649
+ - Component architecture and reusability patterns
14650
+ - State management strategies (local vs global)
14651
+ - Build optimization and code splitting
14652
+ - Responsive design and accessibility (WCAG)
14653
+ - Common gotchas (hydration mismatches, bundle size, memory leaks)`
14654
+ };
14655
+
14513
14656
  // src/agents/sme/windows.ts
14514
14657
  var windowsSMEConfig = {
14515
14658
  domain: "windows",
@@ -14540,7 +14683,11 @@ var SME_CONFIGS = {
14540
14683
  vmware: vmwareSMEConfig,
14541
14684
  azure: azureSMEConfig,
14542
14685
  active_directory: activeDirectorySMEConfig,
14543
- ui_ux: uiUxSMEConfig
14686
+ ui_ux: uiUxSMEConfig,
14687
+ web: webSMEConfig,
14688
+ database: databaseSMEConfig,
14689
+ devops: devopsSMEConfig,
14690
+ api: apiSMEConfig
14544
14691
  };
14545
14692
  var AGENT_TO_DOMAIN = {
14546
14693
  sme_windows: "windows",
@@ -14553,7 +14700,11 @@ var AGENT_TO_DOMAIN = {
14553
14700
  sme_vmware: "vmware",
14554
14701
  sme_azure: "azure",
14555
14702
  sme_active_directory: "active_directory",
14556
- sme_ui_ux: "ui_ux"
14703
+ sme_ui_ux: "ui_ux",
14704
+ sme_web: "web",
14705
+ sme_database: "database",
14706
+ sme_devops: "devops",
14707
+ sme_api: "api"
14557
14708
  };
14558
14709
  function createAllSMEAgents(getModel, loadPrompt) {
14559
14710
  return Object.entries(AGENT_TO_DOMAIN).map(([agentName, domain2]) => {
@@ -14605,10 +14756,10 @@ function createAgents(config2) {
14605
14756
  const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt);
14606
14757
  agents.push(applyOverrides(architect, config2));
14607
14758
  }
14608
- if (!isAgentDisabled("reader", config2)) {
14609
- const readerPrompts = getPrompts("reader");
14610
- const reader = createReaderAgent(getModel("reader"), readerPrompts.prompt, readerPrompts.appendPrompt);
14611
- agents.push(applyOverrides(reader, config2));
14759
+ if (!isAgentDisabled("explorer", config2)) {
14760
+ const explorerPrompts = getPrompts("explorer");
14761
+ const explorer = createExplorerAgent(getModel("explorer"), explorerPrompts.prompt, explorerPrompts.appendPrompt);
14762
+ agents.push(applyOverrides(explorer, config2));
14612
14763
  }
14613
14764
  const smeAgents = createAllSMEAgents(getModel, getPrompts);
14614
14765
  for (const sme of smeAgents) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "2.1.2",
3
+ "version": "2.3.1",
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",
@@ -1,2 +0,0 @@
1
- import type { AgentDefinition } from './architect';
2
- export declare function createReaderAgent(model: string, customPrompt?: string, customAppendPrompt?: string): AgentDefinition;