opencode-swarm 2.0.2 → 2.1.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
@@ -1,161 +1,78 @@
1
1
  # OpenCode Swarm
2
2
 
3
- Architect-centric agentic swarm plugin for OpenCode. Hub-and-spoke orchestration with SME consultation, code generation, and QA review.
3
+ ![License](https://img.shields.io/badge/license-MIT-blue)
4
+ ![OpenCode Plugin](https://img.shields.io/badge/opencode-plugin-green)
5
+ ![Agentic Architecture](https://img.shields.io/badge/architecture-architect--centric-purple)
4
6
 
5
- ## Overview
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.
6
9
 
7
- OpenCode Swarm implements a multi-agent development pipeline where:
10
+ OpenCode Swarm is built for engineers who want **structured reasoning, controlled delegation, and predictable outcomes**—not parallel agent noise.
8
11
 
9
- 1. **Architect** (central orchestrator) analyzes requests and coordinates all agents
10
- 2. **SME Agents** provide domain-specific technical expertise (serial execution)
11
- 3. **Coder** implements unified specifications
12
- 4. **QA Agents** (Security Reviewer + Auditor) validate code quality
13
- 5. **Test Engineer** generates test cases for approved code
12
+ ---
14
13
 
15
- ```
16
- User → Architect (analyze) → [SME Pool - serial] → Architect (collate)
17
- → Coder → [QA: Security + Auditor] → Architect (triage) → Test
18
- ```
14
+ ## Why OpenCode Swarm
19
15
 
20
- ## Installation
16
+ Most agent frameworks parallelize everything and hope coherence emerges later.
17
+ OpenCode Swarm enforces discipline:
21
18
 
22
- ```bash
23
- bunx opencode-swarm install
24
- ```
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
25
24
 
26
- Then start OpenCode:
25
+ This design improves **accuracy, efficiency, and failure detection**, especially on complex or high-stakes tasks.
27
26
 
28
- ```bash
29
- opencode
30
- ```
31
-
32
- ## Configuration
27
+ ---
33
28
 
34
- Edit `~/.config/opencode/opencode-swarm.json`:
35
-
36
- ```json
37
- {
38
- "preset": "hybrid",
39
- "presets": {
40
- "remote": {
41
- "architect": { "model": "anthropic/claude-sonnet-4.5" },
42
- "coder": { "model": "openai/gpt-5.2-codex" },
43
- "_sme": { "model": "google/gemini-3-flash" },
44
- "_qa": { "model": "google/gemini-3-flash" },
45
- "test_engineer": { "model": "google/gemini-3-flash" }
46
- },
47
- "hybrid": {
48
- "architect": { "model": "anthropic/claude-sonnet-4.5" },
49
- "coder": { "model": "ollama/qwen3:72b" },
50
- "_sme": { "model": "npu/qwen3:14b" },
51
- "_qa": { "model": "npu/qwen3:14b" },
52
- "test_engineer": { "model": "npu/qwen3:14b" }
53
- }
54
- },
55
- "swarm_mode": "hybrid",
56
- "gpu_url": "http://192.168.1.100:1234/v1",
57
- "npu_url": "http://localhost:11435/v1",
58
- "max_iterations": 5
59
- }
60
- ```
29
+ ## Key Advantage: Heterogeneous Model Perspectives
61
30
 
62
- ### Category Defaults
31
+ OpenCode Swarm allows **per-role model selection** so that each cognitive function is optimized independently:
63
32
 
64
- Use `_sme` and `_qa` to set models for all agents in a category:
33
+ - Architect deep reasoning and synthesis
34
+ - SMEs → domain recall and speed
35
+ - Coder → implementation fidelity
36
+ - QA → adversarial review and audit rigor
65
37
 
66
- ```json
67
- {
68
- "agents": {
69
- "_sme": { "model": "npu/qwen3:14b" },
70
- "_qa": { "model": "npu/qwen3:14b" }
71
- }
72
- }
73
- ```
38
+ Using different models per role reduces correlated failure modes, increases early error detection, and mirrors how real engineering teams benefit from diverse expertise.
74
39
 
75
- To override a specific agent within a category:
40
+ See: [docs/design-rationale.md](docs/design-rationale.md)
76
41
 
77
- ```json
78
- {
79
- "agents": {
80
- "_sme": { "model": "npu/qwen3:14b" },
81
- "sme_oracle": { "model": "ollama/qwen3:72b" }
82
- }
83
- }
84
- ```
42
+ ---
85
43
 
86
- ### Custom Prompts
44
+ ## Architecture Overview
87
45
 
88
- Place custom prompts in `~/.config/opencode/opencode-swarm/`:
46
+ OpenCode Swarm implements a hub-and-spoke pipeline with a single controlling Architect.
89
47
 
90
- - `{agent}.md` - Replace the default prompt entirely
91
- - `{agent}_append.md` - Append to the default prompt
92
-
93
- Example: `architect_append.md` to add custom instructions to the Architect.
94
-
95
- ## Agents
96
-
97
- ### Orchestrator
98
-
99
- | Agent | Role |
100
- |-------|------|
101
- | `architect` | Central orchestrator, coordinates all phases |
102
-
103
- ### SME Specialists (Domain Experts)
104
-
105
- | Agent | Domain |
106
- |-------|--------|
107
- | `sme_windows` | Windows OS internals, registry, services |
108
- | `sme_powershell` | PowerShell scripting, cmdlets, modules |
109
- | `sme_python` | Python ecosystem, libraries, best practices |
110
- | `sme_oracle` | Oracle Database, SQL/PLSQL, administration |
111
- | `sme_network` | Networking, firewalls, DNS, TLS/SSL |
112
- | `sme_security` | STIG compliance, hardening, encryption |
113
- | `sme_linux` | Linux administration, systemd, packages |
114
- | `sme_vmware` | VMware vSphere, ESXi, PowerCLI |
115
- | `sme_azure` | Azure cloud services, Entra ID, ARM/Bicep |
116
- | `sme_active_directory` | Active Directory, LDAP, Group Policy |
117
- | `sme_ui_ux` | UI/UX design, interaction patterns |
118
-
119
- ### Pipeline Agents
120
-
121
- | Agent | Role |
122
- |-------|------|
123
- | `coder` | Implements specifications, writes production code |
124
- | `security_reviewer` | Security vulnerability assessment |
125
- | `auditor` | Code correctness and quality review |
126
- | `test_engineer` | Test case and validation script generation |
127
-
128
- ## Workflow Phases
129
-
130
- 1. **ANALYZE** - Parse request, identify domains, create initial spec
131
- 2. **SME_CONSULTATION** - Consult domain experts serially
132
- 3. **COLLATE** - Synthesize SME outputs into unified spec
133
- 4. **CODE** - Generate implementation
134
- 5. **QA_REVIEW** - Security and quality review (parallel)
135
- 6. **TRIAGE** - Approve, request revision, or block
136
- 7. **TEST** - Generate tests for approved code
137
-
138
- ## Delegation Rules
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
57
+ ```
139
58
 
140
- The Architect enforces resource-aware delegation:
59
+ See: [docs/architecture.md](docs/architecture.md)
141
60
 
142
- - **SME agents**: Execute serially (one at a time) to avoid overwhelming local inference
143
- - **QA agents**: May execute in parallel (independent analysis)
144
- - **Cross-category**: One agent per category may run simultaneously
61
+ ---
145
62
 
146
- ## Tools
63
+ ## Installation
147
64
 
148
- | Tool | Description |
149
- |------|-------------|
150
- | `detect_domains` | Auto-detect SME domains from text |
151
- | `extract_code_blocks` | Extract and save code blocks to files |
65
+ ```json
66
+ {
67
+ "plugin": ["opencode-swarm"]
68
+ }
69
+ ```
152
70
 
153
- ## Environment Variables
71
+ ```bash
72
+ bunx opencode-swarm install
73
+ ```
154
74
 
155
- | Variable | Description |
156
- |----------|-------------|
157
- | `OPENCODE_SWARM_PRESET` | Override preset selection |
158
- | `OPENCODE_SWARM_DEBUG` | Enable debug logging (`1` to enable) |
75
+ ---
159
76
 
160
77
  ## License
161
78
 
@@ -13,7 +13,8 @@ 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
17
  export { createSecurityReviewerAgent } from './security-reviewer';
17
18
  export { createAuditorAgent } from './auditor';
18
19
  export { createTestEngineerAgent } from './test-engineer';
19
- export { createUnifiedSMEAgent, AVAILABLE_DOMAINS } from './sme-unified';
20
+ export { createAllSMEAgents, createSMEAgent, listDomains } from './sme';
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from './architect';
2
+ export declare function createReaderAgent(model: string, customPrompt?: string, customAppendPrompt?: string): AgentDefinition;
@@ -1,19 +1,20 @@
1
- export declare const SME_AGENT: "sme";
1
+ export declare const SME_AGENTS: readonly ["sme_windows", "sme_powershell", "sme_python", "sme_oracle", "sme_network", "sme_security", "sme_linux", "sme_vmware", "sme_azure", "sme_active_directory", "sme_ui_ux"];
2
2
  export declare const QA_AGENTS: readonly ["security_reviewer", "auditor"];
3
- export declare const PIPELINE_AGENTS: readonly ["coder", "test_engineer"];
3
+ export declare const PIPELINE_AGENTS: readonly ["reader", "coder", "test_engineer"];
4
4
  export declare const ORCHESTRATOR_NAME: "architect";
5
- export declare const ALL_SUBAGENT_NAMES: readonly ["sme", "security_reviewer", "auditor", "coder", "test_engineer"];
6
- export declare const ALL_AGENT_NAMES: readonly ["architect", "sme", "security_reviewer", "auditor", "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", "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"];
7
+ export type SMEAgentName = (typeof SME_AGENTS)[number];
7
8
  export type QAAgentName = (typeof QA_AGENTS)[number];
8
9
  export type PipelineAgentName = (typeof PIPELINE_AGENTS)[number];
9
10
  export type AgentName = (typeof ALL_AGENT_NAMES)[number];
10
- export type SMEAgentName = 'sme';
11
11
  export declare const CATEGORY_PREFIXES: {
12
12
  readonly sme: "_sme";
13
13
  readonly qa: "_qa";
14
14
  };
15
15
  export declare const DEFAULT_MODELS: Record<string, string>;
16
16
  export declare const DOMAIN_PATTERNS: Record<string, RegExp[]>;
17
- export declare function domainToAgentName(_domain: string): 'sme';
17
+ export declare function domainToAgentName(domain: string): SMEAgentName;
18
+ export declare function isSMEAgent(name: string): name is SMEAgentName;
18
19
  export declare function isQAAgent(name: string): name is QAAgentName;
19
20
  export declare function isSubagent(name: string): boolean;
@@ -1,4 +1,4 @@
1
- export { ALL_AGENT_NAMES, ALL_SUBAGENT_NAMES, CATEGORY_PREFIXES, DEFAULT_MODELS, DOMAIN_PATTERNS, ORCHESTRATOR_NAME, PIPELINE_AGENTS, QA_AGENTS, SME_AGENT, domainToAgentName, isQAAgent, isSubagent, } from './constants';
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
3
  export { AgentOverrideConfigSchema, PluginConfigSchema, } from './schema';
4
4
  export type { AgentOverrideConfig, PluginConfig, } from './schema';
package/dist/index.js CHANGED
@@ -11,12 +11,24 @@ var __export = (target, all) => {
11
11
  };
12
12
 
13
13
  // src/config/constants.ts
14
- var SME_AGENT = "sme";
14
+ var SME_AGENTS = [
15
+ "sme_windows",
16
+ "sme_powershell",
17
+ "sme_python",
18
+ "sme_oracle",
19
+ "sme_network",
20
+ "sme_security",
21
+ "sme_linux",
22
+ "sme_vmware",
23
+ "sme_azure",
24
+ "sme_active_directory",
25
+ "sme_ui_ux"
26
+ ];
15
27
  var QA_AGENTS = ["security_reviewer", "auditor"];
16
- var PIPELINE_AGENTS = ["coder", "test_engineer"];
28
+ var PIPELINE_AGENTS = ["reader", "coder", "test_engineer"];
17
29
  var ORCHESTRATOR_NAME = "architect";
18
30
  var ALL_SUBAGENT_NAMES = [
19
- SME_AGENT,
31
+ ...SME_AGENTS,
20
32
  ...QA_AGENTS,
21
33
  ...PIPELINE_AGENTS
22
34
  ];
@@ -29,13 +41,13 @@ var CATEGORY_PREFIXES = {
29
41
  qa: "_qa"
30
42
  };
31
43
  var DEFAULT_MODELS = {
32
- architect: "anthropic/claude-sonnet-4.5",
33
- sme: "google/gemini-3-flash",
34
- coder: "anthropic/claude-sonnet-4.5",
35
- test_engineer: "google/gemini-3-flash",
36
- _sme: "google/gemini-3-flash",
37
- _qa: "google/gemini-3-flash",
38
- default: "google/gemini-3-flash"
44
+ architect: "anthropic/claude-sonnet-4-5",
45
+ reader: "google/gemini-2.0-flash",
46
+ coder: "anthropic/claude-sonnet-4-5",
47
+ test_engineer: "google/gemini-2.0-flash",
48
+ _sme: "google/gemini-2.0-flash",
49
+ _qa: "google/gemini-2.0-flash",
50
+ default: "google/gemini-2.0-flash"
39
51
  };
40
52
  var DOMAIN_PATTERNS = {
41
53
  windows: [
@@ -191,6 +203,9 @@ var DOMAIN_PATTERNS = {
191
203
  /\bresponsive\b/i
192
204
  ]
193
205
  };
206
+ function isSMEAgent(name) {
207
+ return SME_AGENTS.includes(name);
208
+ }
194
209
  function isQAAgent(name) {
195
210
  return QA_AGENTS.includes(name);
196
211
  }
@@ -13829,32 +13844,42 @@ function loadAgentPrompt(agentName) {
13829
13844
  // src/agents/architect.ts
13830
13845
  var ARCHITECT_PROMPT = `You are Architect - an AI coding orchestrator that coordinates specialists to deliver quality code.
13831
13846
 
13832
- **Role**: Analyze requests, consult SME for domain expertise, delegate implementation, and manage QA review.
13847
+ **Role**: Analyze requests, consult domain SMEs, delegate implementation, and manage QA review.
13833
13848
 
13834
13849
  **Agents**:
13835
13850
 
13836
- @sme - Multi-domain subject matter expert (handles all technical domains in one call)
13851
+ @reader - Fast data processing agent for analyzing large files, codebases, or outputs
13852
+ @sme_windows - Windows OS internals, registry, services, WMI/CIM
13853
+ @sme_powershell - PowerShell scripting, cmdlets, modules, remoting
13854
+ @sme_python - Python ecosystem, libraries, best practices
13855
+ @sme_oracle - Oracle Database, SQL/PLSQL, administration
13856
+ @sme_network - Networking, firewalls, DNS, TLS/SSL, load balancing
13857
+ @sme_security - STIG compliance, hardening, CVE, encryption, PKI
13858
+ @sme_linux - Linux administration, systemd, package management
13859
+ @sme_vmware - VMware vSphere, ESXi, PowerCLI, virtualization
13860
+ @sme_azure - Azure cloud services, Entra ID, ARM/Bicep
13861
+ @sme_active_directory - Active Directory, LDAP, Group Policy, Kerberos
13862
+ @sme_ui_ux - UI/UX design, interaction patterns, accessibility
13863
+
13837
13864
  @coder - Implementation specialist, writes production code
13838
13865
  @security_reviewer - Security audit, vulnerability assessment
13839
13866
  @auditor - Code quality review, correctness verification
13840
13867
  @test_engineer - Test case generation and validation scripts
13841
13868
 
13842
- **Available SME Domains**: windows, powershell, python, oracle, network, security, linux, vmware, azure, active_directory, ui_ux
13843
-
13844
13869
  **Workflow**:
13845
13870
 
13846
13871
  ## 1. Analyze (you do this)
13847
13872
  Parse request: explicit requirements + implicit needs.
13848
- Identify which domains are relevant.
13873
+ Identify which domains are relevant (usually 1-3, not all).
13849
13874
  Create initial specification.
13850
13875
 
13851
- ## 2. SME Consultation (single call to @sme)
13852
- Delegate to @sme with ALL relevant domains in one request.
13853
- Example: "I need expertise for: windows, powershell, security"
13854
- Wait for response.
13876
+ ## 2. SME Consultation (delegate only relevant SMEs, serially)
13877
+ For each relevant domain, delegate to @sme_* agent one at a time.
13878
+ Only consult SMEs for domains that actually apply to the task.
13879
+ Wait for each response before calling the next.
13855
13880
 
13856
13881
  ## 3. Collate (you do this)
13857
- Synthesize SME input into unified specification.
13882
+ Synthesize SME inputs into unified specification.
13858
13883
  Ensure clarity and completeness.
13859
13884
 
13860
13885
  ## 4. Code (delegate to @coder)
@@ -13874,11 +13899,17 @@ Review QA feedback and decide:
13874
13899
  ## 7. Test (delegate to @test_engineer)
13875
13900
  Send approved code to @test_engineer for test generation.
13876
13901
 
13902
+ **Using @reader**:
13903
+ - Delegate to @reader when you need to process large amounts of data
13904
+ - Use for: analyzing gitingest output, reviewing large files, summarizing codebases
13905
+ - @reader returns condensed summaries you can use for decision-making
13906
+
13877
13907
  **Delegation Rules**:
13878
13908
  - All agents run serially (one at a time)
13879
13909
  - Wait for each agent response before calling the next
13910
+ - Only consult SMEs for domains relevant to the task (1-3 typically)
13880
13911
  - Reference paths/lines, don't paste entire files
13881
- - Brief delegation notices: "Consulting @sme for windows, powershell..."
13912
+ - Brief delegation notices: "Consulting @sme_powershell..."
13882
13913
 
13883
13914
  **Communication**:
13884
13915
  - Be direct, no preamble or flattery
@@ -14017,6 +14048,67 @@ ${customAppendPrompt}`;
14017
14048
  };
14018
14049
  }
14019
14050
 
14051
+ // src/agents/reader.ts
14052
+ var READER_PROMPT = `You are Reader - a fast data processing specialist.
14053
+
14054
+ **Role**: Quickly analyze large datasets, codebases, or outputs and provide concise summaries for the Architect.
14055
+
14056
+ **Behavior**:
14057
+ - Read and process the provided content efficiently
14058
+ - Extract key information relevant to the task
14059
+ - Summarize findings in a structured, actionable format
14060
+ - Focus on what matters for implementation decisions
14061
+
14062
+ **Use cases**:
14063
+ - Analyzing gitingest output to understand a codebase
14064
+ - Reviewing large log files or data dumps
14065
+ - Summarizing documentation or specifications
14066
+ - Processing API responses or test results
14067
+
14068
+ **Output Format**:
14069
+ <summary>
14070
+ [2-3 sentence overview of what you analyzed]
14071
+ </summary>
14072
+
14073
+ <key_findings>
14074
+ - [Finding 1: specific, actionable]
14075
+ - [Finding 2: specific, actionable]
14076
+ - [Finding 3: specific, actionable]
14077
+ </key_findings>
14078
+
14079
+ <relevant_details>
14080
+ [Specific code patterns, file paths, function names, or data points the Architect needs]
14081
+ </relevant_details>
14082
+
14083
+ <recommendations>
14084
+ [Brief suggestions based on your analysis]
14085
+ </recommendations>
14086
+
14087
+ **Constraints**:
14088
+ - No code writing
14089
+ - No delegation
14090
+ - Focus on speed and accuracy
14091
+ - Keep total output under 2000 characters`;
14092
+ function createReaderAgent(model, customPrompt, customAppendPrompt) {
14093
+ let prompt = READER_PROMPT;
14094
+ if (customPrompt) {
14095
+ prompt = customPrompt;
14096
+ } else if (customAppendPrompt) {
14097
+ prompt = `${READER_PROMPT}
14098
+
14099
+ ${customAppendPrompt}`;
14100
+ }
14101
+ return {
14102
+ name: "reader",
14103
+ description: "Fast data processing agent for analyzing large files, codebases, or outputs. Returns concise summaries.",
14104
+ config: {
14105
+ model,
14106
+ temperature: 0.1,
14107
+ prompt
14108
+ }
14109
+ };
14110
+ }
14111
+
14020
14112
  // src/agents/security-reviewer.ts
14021
14113
  var SECURITY_REVIEWER_PROMPT = `You are Security Reviewer - a security audit specialist.
14022
14114
 
@@ -14141,60 +14233,56 @@ ${customAppendPrompt}`;
14141
14233
  };
14142
14234
  }
14143
14235
 
14144
- // src/agents/sme-unified.ts
14145
- var DOMAIN_EXPERTISE = {
14146
- windows: `Windows OS: Registry, services, WMI/CIM, event logs, scheduled tasks, Group Policy, installers, WinRM`,
14147
- powershell: `PowerShell: Cmdlets, modules, remoting, Pester testing, pipeline, error handling, PSCustomObject`,
14148
- python: `Python: pip, venv, Django, Flask, pandas, numpy, pytest, async/await, type hints`,
14149
- oracle: `Oracle DB: SQL/PLSQL, tablespaces, RMAN, DataGuard, ASM, RAC, TNS, ORA errors`,
14150
- network: `Networking: TCP/UDP, DNS, DHCP, firewalls, VLANs, routing, load balancing, TLS/SSL, certificates`,
14151
- security: `Security: STIG compliance, hardening, CVE remediation, SCAP, FIPS, PKI, encryption, CAC`,
14152
- linux: `Linux: systemd, bash, yum/apt, cron, permissions, SELinux, journalctl`,
14153
- vmware: `VMware: vSphere, ESXi, vCenter, VSAN, NSX, PowerCLI, datastores, vMotion`,
14154
- azure: `Azure: Entra ID, ARM/Bicep, KeyVault, Blob storage, Azure DevOps, managed identities`,
14155
- active_directory: `Active Directory: LDAP, Group Policy, Kerberos, SPNs, domain trusts, ADUC, replication`,
14156
- ui_ux: `UI/UX: Interaction patterns, accessibility (WCAG), responsive design, typography, color theory, layout`
14157
- };
14158
- var UNIFIED_SME_PROMPT = `You are SME (Subject Matter Expert) - a multi-domain technical specialist.
14236
+ // src/agents/sme/base.ts
14237
+ function createSMEPrompt(config2) {
14238
+ const { domain: domain2, description, guidance } = config2;
14239
+ return `You are ${domain2}_SME - a subject matter expert in ${description}.
14240
+
14241
+ **Role**: Provide domain-specific technical context to enhance the Architect's specification. Your output will be read by the Architect for collation, not directly by a human or coder.
14159
14242
 
14160
- **Role**: Provide domain-specific technical context for all requested domains in a single response. Your output will be read by the Architect for collation.
14243
+ **Domain Expertise**:
14244
+ ${guidance}
14161
14245
 
14162
14246
  **Behavior**:
14163
- - Address ALL domains listed in the request
14164
- - Be specific: exact names, paths, parameters, API signatures
14165
- - Be concise: focus only on implementation-relevant details
14247
+ - Be specific: exact names, paths, parameters, not general advice
14248
+ - Be concise: under 4000 characters
14166
14249
  - Be actionable: information the Coder can directly use
14167
-
14168
- **Domain Expertise Available**:
14169
- ${Object.entries(DOMAIN_EXPERTISE).map(([domain2, desc]) => `- ${domain2}: ${desc}`).join(`
14170
- `)}
14250
+ - Focus on implementation-relevant details only
14251
+ - Include version-specific notes if applicable
14171
14252
 
14172
14253
  **Output Format**:
14173
- <sme_context>
14174
- For each relevant domain, provide:
14254
+ <${domain2}_context>
14255
+ **Critical Considerations**:
14256
+ [Must-know information that affects implementation]
14257
+
14258
+ **Recommended Approach**:
14259
+ [Best practices and patterns for this domain]
14175
14260
 
14176
- **[Domain Name]**:
14177
- - Critical considerations for implementation
14178
- - Recommended approach and patterns
14179
- - Specific APIs, cmdlets, or functions to use
14180
- - Common gotchas to avoid
14181
- - Dependencies required
14261
+ **API/Syntax Details**:
14262
+ [Exact cmdlet names, function signatures, class names]
14182
14263
 
14183
- </sme_context>
14264
+ **Gotchas**:
14265
+ [Common mistakes to avoid]
14184
14266
 
14185
- Keep total response under 4000 characters for efficient processing.`;
14186
- function createUnifiedSMEAgent(model, customPrompt, customAppendPrompt) {
14187
- let prompt = UNIFIED_SME_PROMPT;
14267
+ **Dependencies**:
14268
+ [Required modules, services, permissions]
14269
+
14270
+ **Code Patterns**:
14271
+ [Short snippets showing correct usage if helpful]
14272
+ </${domain2}_context>`;
14273
+ }
14274
+ function createSMEAgent(agentName, domainConfig, model, customPrompt, customAppendPrompt) {
14275
+ let prompt = createSMEPrompt(domainConfig);
14188
14276
  if (customPrompt) {
14189
14277
  prompt = customPrompt;
14190
14278
  } else if (customAppendPrompt) {
14191
- prompt = `${UNIFIED_SME_PROMPT}
14279
+ prompt = `${prompt}
14192
14280
 
14193
14281
  ${customAppendPrompt}`;
14194
14282
  }
14195
14283
  return {
14196
- name: "sme",
14197
- description: "Multi-domain subject matter expert. Provides technical context for multiple domains in a single call.",
14284
+ name: agentName,
14285
+ description: `Subject matter expert for ${domainConfig.description}. Provides domain-specific technical context for the Architect.`,
14198
14286
  config: {
14199
14287
  model,
14200
14288
  temperature: 0.2,
@@ -14202,14 +14290,284 @@ ${customAppendPrompt}`;
14202
14290
  }
14203
14291
  };
14204
14292
  }
14205
- var AVAILABLE_DOMAINS = Object.keys(DOMAIN_EXPERTISE);
14293
+
14294
+ // src/agents/sme/active-directory.ts
14295
+ var activeDirectorySMEConfig = {
14296
+ domain: "active_directory",
14297
+ description: "Active Directory and identity management",
14298
+ guidance: `For Active Directory tasks, provide:
14299
+ - AD PowerShell module cmdlets (Get-ADUser, Set-ADUser, etc.)
14300
+ - LDAP filter syntax and examples
14301
+ - Distinguished name (DN) formats
14302
+ - Group Policy structure and processing order
14303
+ - Kerberos authentication flow considerations
14304
+ - SPN (Service Principal Name) configuration
14305
+ - AD schema and common attributes
14306
+ - Replication and site topology concepts
14307
+ - Organizational Unit (OU) design patterns
14308
+ - Security group types (Domain Local, Global, Universal)
14309
+ - Delegation of control patterns
14310
+ - Fine-grained password policies
14311
+ - AD object GUIDs and SIDs
14312
+ - Trust relationships
14313
+ - ADSI/DirectoryServices .NET classes
14314
+ - Common AD error codes and resolutions
14315
+ - Group Policy preferences vs policies`
14316
+ };
14317
+
14318
+ // src/agents/sme/azure.ts
14319
+ var azureSMEConfig = {
14320
+ domain: "azure",
14321
+ description: "Microsoft Azure cloud services",
14322
+ guidance: `For Azure tasks, provide:
14323
+ - Az PowerShell module cmdlets (Az.Accounts, Az.Compute, etc.)
14324
+ - Azure CLI (az) command syntax
14325
+ - ARM template structure and syntax
14326
+ - Bicep syntax and patterns
14327
+ - Entra ID (formerly Azure AD) configuration
14328
+ - RBAC role assignments and custom roles
14329
+ - Resource naming conventions and constraints
14330
+ - Service principal and managed identity configuration
14331
+ - Azure resource provider namespaces
14332
+ - Common Azure resource types and properties
14333
+ - Subscription and resource group scoping
14334
+ - Azure networking (VNet, NSG, Load Balancer)
14335
+ - Storage account types and access tiers
14336
+ - Azure Key Vault integration patterns
14337
+ - Cost management considerations
14338
+ - Azure Government differences if applicable`
14339
+ };
14340
+
14341
+ // src/agents/sme/linux.ts
14342
+ var linuxSMEConfig = {
14343
+ domain: "linux",
14344
+ description: "Linux system administration",
14345
+ guidance: `For Linux tasks, provide:
14346
+ - Distribution-specific commands (RHEL/CentOS vs Ubuntu/Debian)
14347
+ - Systemd unit file structure (service, timer, socket units)
14348
+ - File permissions and ownership (chmod, chown, ACLs)
14349
+ - SELinux/AppArmor considerations (contexts, policies, booleans)
14350
+ - Package management commands (yum/dnf vs apt)
14351
+ - Cron syntax and systemd timer alternatives
14352
+ - Log file locations (/var/log, journalctl)
14353
+ - Service management patterns (systemctl, enable, start)
14354
+ - User and group management
14355
+ - Filesystem hierarchy standard (FHS) paths
14356
+ - Shell scripting best practices (bash, POSIX compliance)
14357
+ - Process management (ps, top, kill signals)
14358
+ - Network configuration (nmcli, ip, netplan)
14359
+ - Environment variables and profile scripts`
14360
+ };
14361
+
14362
+ // src/agents/sme/network.ts
14363
+ var networkSMEConfig = {
14364
+ domain: "network",
14365
+ description: "network architecture, protocols, and security",
14366
+ guidance: `For network tasks, provide:
14367
+ - Protocol specifications and standard port numbers
14368
+ - Firewall rule syntax (Windows Firewall, iptables, firewalld)
14369
+ - DNS record types and configuration (A, AAAA, CNAME, MX, TXT, SRV)
14370
+ - Certificate requirements and chain validation
14371
+ - TLS/SSL configuration best practices (cipher suites, protocols)
14372
+ - Load balancer and proxy considerations
14373
+ - Network troubleshooting commands (ping, tracert, nslookup, netstat)
14374
+ - Security group and ACL patterns
14375
+ - IP addressing and subnetting
14376
+ - VLAN configuration concepts
14377
+ - NAT and port forwarding
14378
+ - HTTP/HTTPS specifics (headers, status codes, methods)
14379
+ - Socket programming considerations
14380
+ - Common network errors and their causes`
14381
+ };
14382
+
14383
+ // src/agents/sme/oracle.ts
14384
+ var oracleSMEConfig = {
14385
+ domain: "oracle",
14386
+ description: "Oracle Database administration and SQL/PLSQL",
14387
+ guidance: `For Oracle tasks, provide:
14388
+ - Correct SQL syntax for Oracle (not MySQL/SQL Server)
14389
+ - PL/SQL block structure and exception handling
14390
+ - CDB/PDB architecture considerations
14391
+ - Parameter names and valid values (init.ora, spfile)
14392
+ - Required privileges and roles (DBA, SYSDBA, specific grants)
14393
+ - Data dictionary views (DBA_*, ALL_*, USER_*, V$*, GV$*)
14394
+ - RMAN commands and syntax
14395
+ - TNS configuration and connectivity (tnsnames.ora, listener.ora)
14396
+ - Oracle-specific functions (NVL, DECODE, LISTAGG, etc.)
14397
+ - Bind variable usage for performance
14398
+ - Transaction handling (COMMIT, ROLLBACK, savepoints)
14399
+ - LOB handling (CLOB, BLOB operations)
14400
+ - Date/timestamp handling (TO_DATE, TO_TIMESTAMP, NLS settings)
14401
+ - Execution plan analysis (EXPLAIN PLAN, hints)`
14402
+ };
14403
+
14404
+ // src/agents/sme/powershell.ts
14405
+ var powershellSMEConfig = {
14406
+ domain: "powershell",
14407
+ description: "PowerShell scripting and automation",
14408
+ guidance: `For PowerShell tasks, provide:
14409
+ - Correct cmdlet names, parameters, and syntax
14410
+ - Required modules and how to import them (Import-Module, #Requires)
14411
+ - Pipeline patterns and object handling
14412
+ - Error handling with try/catch and $ErrorActionPreference
14413
+ - Output formatting and object types ([PSCustomObject], etc.)
14414
+ - Remote execution (PSSession, Invoke-Command, -ComputerName)
14415
+ - Module compatibility (Windows PowerShell 5.1 vs PowerShell 7+)
14416
+ - Common parameter patterns (-Verbose, -WhatIf, -Confirm, -ErrorAction)
14417
+ - Splatting for complex parameter sets
14418
+ - Advanced function patterns ([CmdletBinding()], param blocks)
14419
+ - Pester testing patterns for the code
14420
+ - Credential handling (Get-Credential, [PSCredential])
14421
+ - Output streams (Write-Output, Write-Verbose, Write-Error)`
14422
+ };
14423
+
14424
+ // src/agents/sme/python.ts
14425
+ var pythonSMEConfig = {
14426
+ domain: "python",
14427
+ description: "Python development and ecosystem",
14428
+ guidance: `For Python tasks, provide:
14429
+ - Recommended libraries for the task (stdlib vs third-party)
14430
+ - Windows-specific modules (pywin32, wmi, winreg, ctypes)
14431
+ - Correct API usage patterns and idioms
14432
+ - Virtual environment considerations (venv, pip install)
14433
+ - Type hints and dataclass usage
14434
+ - Exception handling patterns (specific exceptions, context managers)
14435
+ - File handling (pathlib vs os.path, encoding considerations)
14436
+ - Cross-platform compatibility notes
14437
+ - Async patterns if applicable (asyncio, aiohttp)
14438
+ - Logging configuration (logging module setup)
14439
+ - Package structure for larger scripts
14440
+ - Python version compatibility (3.8+ features)
14441
+ - Common gotchas (mutable default arguments, import cycles)`
14442
+ };
14443
+
14444
+ // src/agents/sme/security.ts
14445
+ var securitySMEConfig = {
14446
+ domain: "security",
14447
+ description: "cybersecurity, compliance, and hardening",
14448
+ guidance: `For security tasks, provide:
14449
+ - STIG requirements and check IDs (V-#####, SV-#####)
14450
+ - DISA compliance requirements
14451
+ - FIPS 140-2/3 considerations (approved algorithms, modes)
14452
+ - CAC/PIV/PKI implementation details
14453
+ - Encryption standards and key management
14454
+ - Audit logging requirements (what to log, retention)
14455
+ - Least privilege patterns
14456
+ - Secure configuration baselines
14457
+ - CIS Benchmark references if applicable
14458
+ - Common vulnerability patterns to avoid
14459
+ - Authentication and authorization best practices
14460
+ - Secrets management (no hardcoding, secure storage)
14461
+ - Input validation and sanitization
14462
+ - Secure communication requirements (TLS versions, cipher suites)
14463
+ - DoD/Federal specific requirements if applicable`
14464
+ };
14465
+
14466
+ // src/agents/sme/ui-ux.ts
14467
+ var uiUxSMEConfig = {
14468
+ domain: "ui_ux",
14469
+ description: "UI/UX design, interaction patterns, and visual systems",
14470
+ guidance: `For UI/UX tasks, provide:
14471
+ - Information architecture and navigation flow
14472
+ - Interaction patterns and states (loading, empty, error, success)
14473
+ - Responsive layout guidance and breakpoints
14474
+ - Typography scale and hierarchy recommendations
14475
+ - Spacing system (8px grid, consistent margins/padding)
14476
+ - Color usage (primary, secondary, semantic colors)
14477
+ - Contrast and accessibility requirements (WCAG 2.1 AA)
14478
+ - Component structure and reusability patterns
14479
+ - Form design best practices (labels, validation, feedback)
14480
+ - Motion/animation guidance (purposeful, not excessive)
14481
+ - Touch target sizes for mobile (44px minimum)
14482
+ - Focus management for keyboard navigation
14483
+ - Icon usage and consistency
14484
+ - Empty states and error message design
14485
+ - Progressive disclosure patterns
14486
+ - Loading and skeleton states`
14487
+ };
14488
+
14489
+ // src/agents/sme/vmware.ts
14490
+ var vmwareSMEConfig = {
14491
+ domain: "vmware",
14492
+ description: "VMware vSphere and virtualization",
14493
+ guidance: `For VMware tasks, provide:
14494
+ - PowerCLI cmdlet names and syntax (Get-VM, Set-VM, etc.)
14495
+ - vSphere API objects and methods
14496
+ - ESXi shell commands (esxcli, vim-cmd)
14497
+ - Datastore path formats ([datastore1] path/to/file.vmdk)
14498
+ - VM hardware version compatibility
14499
+ - vMotion and DRS requirements and constraints
14500
+ - Storage policy configuration (SPBM)
14501
+ - Network adapter types and configurations (vmxnet3, e1000e)
14502
+ - Snapshot management considerations
14503
+ - Template and clone operations
14504
+ - Resource pool and cluster concepts
14505
+ - vCenter Server connection handling
14506
+ - Certificate and authentication requirements
14507
+ - Common vSphere error codes and solutions
14508
+ - Performance metrics and monitoring (Get-Stat)`
14509
+ };
14510
+
14511
+ // src/agents/sme/windows.ts
14512
+ var windowsSMEConfig = {
14513
+ domain: "windows",
14514
+ description: "Windows operating system internals and administration",
14515
+ guidance: `For Windows tasks, provide:
14516
+ - Registry paths and correct hive locations (HKLM, HKCU, HKU)
14517
+ - WMI/CIM class names and properties (Win32_*, CIM_*)
14518
+ - Service names (exact), dependencies, and startup types
14519
+ - File system locations (System32, SysWOW64, ProgramData, AppData)
14520
+ - Permission requirements (admin, SYSTEM, TrustedInstaller)
14521
+ - COM objects and interfaces when relevant
14522
+ - Event log sources, channels, and event IDs
14523
+ - Scheduled task configuration (triggers, actions, principals)
14524
+ - Windows API calls if needed (P/Invoke signatures)
14525
+ - UAC considerations and elevation requirements
14526
+ - 32-bit vs 64-bit considerations (WoW64 redirection)`
14527
+ };
14528
+
14529
+ // src/agents/sme/index.ts
14530
+ var SME_CONFIGS = {
14531
+ windows: windowsSMEConfig,
14532
+ powershell: powershellSMEConfig,
14533
+ python: pythonSMEConfig,
14534
+ oracle: oracleSMEConfig,
14535
+ network: networkSMEConfig,
14536
+ security: securitySMEConfig,
14537
+ linux: linuxSMEConfig,
14538
+ vmware: vmwareSMEConfig,
14539
+ azure: azureSMEConfig,
14540
+ active_directory: activeDirectorySMEConfig,
14541
+ ui_ux: uiUxSMEConfig
14542
+ };
14543
+ var AGENT_TO_DOMAIN = {
14544
+ sme_windows: "windows",
14545
+ sme_powershell: "powershell",
14546
+ sme_python: "python",
14547
+ sme_oracle: "oracle",
14548
+ sme_network: "network",
14549
+ sme_security: "security",
14550
+ sme_linux: "linux",
14551
+ sme_vmware: "vmware",
14552
+ sme_azure: "azure",
14553
+ sme_active_directory: "active_directory",
14554
+ sme_ui_ux: "ui_ux"
14555
+ };
14556
+ function createAllSMEAgents(getModel, loadPrompt) {
14557
+ return Object.entries(AGENT_TO_DOMAIN).map(([agentName, domain2]) => {
14558
+ const config2 = SME_CONFIGS[domain2];
14559
+ const model = getModel(agentName);
14560
+ const prompts = loadPrompt(agentName);
14561
+ return createSMEAgent(agentName, config2, model, prompts.prompt, prompts.appendPrompt);
14562
+ });
14563
+ }
14206
14564
 
14207
14565
  // src/agents/index.ts
14208
14566
  function getModelForAgent(agentName, config2) {
14209
14567
  const explicit = config2?.agents?.[agentName]?.model;
14210
14568
  if (explicit)
14211
14569
  return explicit;
14212
- if (agentName === "sme") {
14570
+ if (isSMEAgent(agentName)) {
14213
14571
  const categoryModel = config2?.agents?.[CATEGORY_PREFIXES.sme]?.model;
14214
14572
  if (categoryModel)
14215
14573
  return categoryModel;
@@ -14245,10 +14603,16 @@ function createAgents(config2) {
14245
14603
  const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt);
14246
14604
  agents.push(applyOverrides(architect, config2));
14247
14605
  }
14248
- if (!isAgentDisabled("sme", config2)) {
14249
- const smePrompts = getPrompts("sme");
14250
- const sme = createUnifiedSMEAgent(getModel("sme"), smePrompts.prompt, smePrompts.appendPrompt);
14251
- agents.push(applyOverrides(sme, config2));
14606
+ if (!isAgentDisabled("reader", config2)) {
14607
+ const readerPrompts = getPrompts("reader");
14608
+ const reader = createReaderAgent(getModel("reader"), readerPrompts.prompt, readerPrompts.appendPrompt);
14609
+ agents.push(applyOverrides(reader, config2));
14610
+ }
14611
+ const smeAgents = createAllSMEAgents(getModel, getPrompts);
14612
+ for (const sme of smeAgents) {
14613
+ if (!isAgentDisabled(sme.name, config2)) {
14614
+ agents.push(applyOverrides(sme, config2));
14615
+ }
14252
14616
  }
14253
14617
  if (!isAgentDisabled("coder", config2)) {
14254
14618
  const coderPrompts = getPrompts("coder");
@@ -26802,6 +27166,40 @@ Errors:
26802
27166
  return result;
26803
27167
  }
26804
27168
  });
27169
+ // src/tools/gitingest.ts
27170
+ async function fetchGitingest(args) {
27171
+ const response = await fetch("https://gitingest.com/api/ingest", {
27172
+ method: "POST",
27173
+ headers: { "Content-Type": "application/json" },
27174
+ body: JSON.stringify({
27175
+ input_text: args.url,
27176
+ max_file_size: args.maxFileSize ?? 50000,
27177
+ pattern: args.pattern ?? "",
27178
+ pattern_type: args.patternType ?? "exclude"
27179
+ })
27180
+ });
27181
+ if (!response.ok) {
27182
+ throw new Error(`gitingest API error: ${response.status} ${response.statusText}`);
27183
+ }
27184
+ const data = await response.json();
27185
+ return `${data.summary}
27186
+
27187
+ ${data.tree}
27188
+
27189
+ ${data.content}`;
27190
+ }
27191
+ var gitingest = tool({
27192
+ description: "Fetch a GitHub repository's full content via gitingest.com. Returns summary, directory tree, and file contents optimized for LLM analysis. Use when you need to understand an external repository's structure or code.",
27193
+ args: {
27194
+ url: tool.schema.string().describe("GitHub repository URL (e.g., https://github.com/owner/repo)"),
27195
+ maxFileSize: tool.schema.number().optional().describe("Maximum file size in bytes to include (default: 50000)"),
27196
+ pattern: tool.schema.string().optional().describe("Glob pattern to filter files (e.g., '*.ts' or 'src/**/*.py')"),
27197
+ patternType: tool.schema.enum(["include", "exclude"]).optional().describe("Whether pattern includes or excludes matching files (default: exclude)")
27198
+ },
27199
+ async execute(args, _context) {
27200
+ return fetchGitingest(args);
27201
+ }
27202
+ });
26805
27203
  // src/utils/logger.ts
26806
27204
  var DEBUG = process.env.OPENCODE_SWARM_DEBUG === "1";
26807
27205
  function log(message, data) {
@@ -26830,7 +27228,8 @@ var OpenCodeSwarm = async (ctx) => {
26830
27228
  agent: agents,
26831
27229
  tool: {
26832
27230
  detect_domains,
26833
- extract_code_blocks
27231
+ extract_code_blocks,
27232
+ gitingest
26834
27233
  },
26835
27234
  config: async (opencodeConfig) => {
26836
27235
  if (!opencodeConfig.agent) {
@@ -0,0 +1,15 @@
1
+ import { tool } from '@opencode-ai/plugin';
2
+ export interface GitingestArgs {
3
+ url: string;
4
+ maxFileSize?: number;
5
+ pattern?: string;
6
+ patternType?: 'include' | 'exclude';
7
+ }
8
+ /**
9
+ * Fetch repository content via gitingest.com API
10
+ */
11
+ export declare function fetchGitingest(args: GitingestArgs): Promise<string>;
12
+ /**
13
+ * Gitingest tool for fetching GitHub repository contents
14
+ */
15
+ export declare const gitingest: ReturnType<typeof tool>;
@@ -1,2 +1,3 @@
1
1
  export { detect_domains } from './domain-detector';
2
2
  export { extract_code_blocks } from './file-extractor';
3
+ export { gitingest, fetchGitingest, type GitingestArgs } from './gitingest';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "2.0.2",
3
+ "version": "2.1.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",