opencode-swarm 6.22.3 → 6.22.4

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,131 +1,182 @@
1
- # 🐝 OpenCode Swarm
1
+ # OpenCode Swarm
2
2
 
3
3
  **Your AI writes the code. Swarm makes sure it actually works.**
4
4
 
5
5
  https://swarmai.site/
6
6
 
7
- OpenCode Swarm is a plugin for [OpenCode](https://opencode.ai) that turns a single AI coding agent into a team of nine. One agent writes the code. A different agent reviews it. Another writes and runs tests. Another catches security issues. Nothing ships until every check passes. Your project state is saved to disk, so you can close your laptop, come back tomorrow, and pick up exactly where you left off.
7
+ OpenCode Swarm is a plugin for [OpenCode](https://opencode.ai) that turns a single AI coding session into an architect-led team of specialized agents. One agent writes the code. A different agent reviews it. Another writes and runs tests. Another checks security. Nothing ships until every required gate passes.
8
+
9
+ You do **not** manually switch between Swarm's internal agents during normal use.
10
+
11
+ You continue talking to OpenCode normally. Swarm intercepts the session, the **architect** coordinates the internal pipeline behind the scenes, and all project state is persisted to `.swarm/` so work can resume later.
8
12
 
9
13
  ```bash
10
14
  npm install -g opencode-swarm
11
15
  ```
12
16
 
13
- That's it. Open your project with `opencode` and start building. Swarm activates automatically.
14
-
15
- ---
17
+ * * *
16
18
 
17
19
  ## What Actually Happens
18
20
 
19
- You say: *"Build me a JWT auth system."*
21
+ You say:
20
22
 
21
- Here's what Swarm does behind the scenes:
23
+ ```text
24
+ Build me a JWT auth system.
25
+ ```
22
26
 
23
- 1. **Asks you clarifying questions** (only the ones it can't figure out itself)
24
- 2. **Scans your codebase** to understand what already exists
25
- 3. **Consults domain experts** (security, API design, whatever your project needs) and caches the guidance so it never re-asks
26
- 4. **Writes a phased plan** with concrete tasks, acceptance criteria, and dependencies
27
- 5. **A separate critic agent reviews the plan** before any code is written
28
- 6. **Implements one task at a time.** For each task:
29
- - A coder agent writes the code
30
- - 7 automated checks run (syntax, imports, linting, secrets, security, build, quality)
31
- - A reviewer agent (running on a *different* AI model) checks for correctness
32
- - A test engineer agent writes tests, runs them, and checks coverage
33
- - If anything fails, it goes back to the coder with specific feedback
34
- - If it passes everything, the task is marked done and the next one starts
35
- 7. **After each phase completes**, documentation updates automatically, and a retrospective captures what worked and what didn't. Those learnings carry into the next phase.
27
+ Swarm then:
36
28
 
37
- All of this state lives in a `.swarm/` folder in your project:
29
+ 1. Clarifies only what it cannot infer.
30
+ 2. Scans the codebase to understand what already exists.
31
+ 3. Consults domain experts when needed and caches the guidance.
32
+ 4. Writes a phased implementation plan.
33
+ 5. Sends that plan through a critic gate before coding starts.
34
+ 6. Executes one task at a time through the QA pipeline:
38
35
 
39
- ```
36
+ * coder writes code
37
+ * automated checks run
38
+ * reviewer checks correctness
39
+ * test engineer writes and runs tests
40
+ * failures loop back with structured feedback
41
+
42
+ 7. After each phase, docs and retrospectives are updated.
43
+
44
+ All project state lives in `.swarm/`:
45
+
46
+ ```text
40
47
  .swarm/
41
- ├── plan.md # Your project roadmap (tasks, status, what's done, what's next)
42
- ├── context.md # Decisions made, expert guidance, established patterns
43
- ├── evidence/ # Review verdicts, test results, diffs for every completed task
44
- └── history/ # Phase retrospectives and metrics
48
+ ├── plan.md
49
+ ├── context.md
50
+ ├── evidence/
51
+ └── history/
45
52
  ```
46
53
 
47
- Close your terminal. Come back next week. Swarm reads these files and picks up exactly where it stopped.
54
+ That means Swarm is resumable by design. If you come back later and `.swarm/` already exists, the architect may go straight into **RESUME** or **EXECUTE** instead of replaying the full first-run discovery flow.
48
55
 
49
56
  ---
50
57
 
51
58
  ## Why This Exists
52
59
 
53
- Most AI coding tools let one model write code and then ask *that same model* if the code is good. That's like asking someone to proofread their own essay. They'll miss the same things they missed while writing it.
60
+ Most AI coding tools let one model write code and then ask that same model whether the code is good. That misses too much.
54
61
 
55
- Swarm fixes this by splitting the work across specialized agents and requiring that different models handle writing vs. reviewing. The coder writes. A different model reviews. Another model tests. Different training data, different blind spots, different failure modes.
56
-
57
- The other thing most tools get wrong: they try to do everything in parallel. That sounds fast, but in practice you get three agents writing conflicting code at the same time with no coordination. Swarm runs one task at a time through a fixed pipeline. Slower per-task, but you don't redo work.
62
+ Swarm separates planning, implementation, review, testing, and documentation into specialized internal roles, and it enforces gated execution instead of letting multiple agents mutate the codebase in parallel.
58
63
 
59
64
  ---
60
65
 
61
66
  ## Quick Start
62
67
 
63
- ### Install
68
+ ### 1. Install
64
69
 
65
70
  ```bash
66
71
  npm install -g opencode-swarm
67
72
  ```
68
73
 
69
- ### Verify
70
-
71
- Open a project with `opencode` and run:
74
+ ### 2. Open your project in OpenCode
72
75
 
76
+ ```bash
77
+ opencode
73
78
  ```
79
+
80
+ ### 3. Verify Swarm is loaded
81
+
82
+ Run these once in a project:
83
+
84
+ ```text
74
85
  /swarm diagnose
86
+ /swarm agents
87
+ /swarm config
75
88
  ```
76
89
 
77
- This checks that everything is wired up correctly.
90
+ What they tell you:
91
+
92
+ * `/swarm diagnose` verifies Swarm health and setup
93
+ * `/swarm agents` shows the registered internal agents and model assignments
94
+ * `/swarm config` shows the resolved configuration currently in effect
95
+
96
+ ### 4. Start normally
97
+
98
+ Just tell OpenCode what you want to build.
99
+
100
+ ```text
101
+ Build a REST API with user registration, login, and JWT auth.
102
+ ```
103
+
104
+ You do **not** manually choose `architect`, `coder`, `reviewer`, `critic`, or other internal agents. The **architect** coordinates them automatically.
105
+
106
+ ### 5. Understand first run vs later runs
78
107
 
79
- ### Configure Models (Optional)
108
+ On a brand-new project with no `.swarm/` state, Swarm usually starts by clarifying, discovering, consulting, and planning.
80
109
 
81
- By default, Swarm v6.14+ uses free OpenCode Zen models (no API key required). You can override any agent's model by creating `.opencode/opencode-swarm.json` in your project. See the [LLM Provider Guide](#llm-provider-guide) for all options.
110
+ On a project that already has `.swarm/plan.md`, Swarm may resume immediately. That is expected.
111
+
112
+ Use these commands any time:
113
+
114
+ ```text
115
+ /swarm status
116
+ /swarm plan
117
+ /swarm history
118
+ ```
119
+
120
+ ### 6. Start over when needed
121
+
122
+ If you want a completely fresh Swarm run for the current project:
123
+
124
+ ```text
125
+ /swarm reset --confirm
126
+ ```
127
+
128
+ Use this only when you intentionally want to discard current Swarm state.
129
+
130
+ ### 7. Configure models (optional)
131
+
132
+ By default, Swarm works with its default model setup. If you want to override agent models, create:
133
+
134
+ ```text
135
+ .opencode/opencode-swarm.json
136
+ ```
137
+
138
+ Example:
82
139
 
83
140
  ```json
84
141
  {
85
142
  "agents": {
86
- "architect": { "model": "anthropic/claude-opus-4-6" },
87
- "coder": { "model": "minimax-coding-plan/MiniMax-M2.5" },
88
- "reviewer": { "model": "zai-coding-plan/glm-5" }
89
- },
90
- "guardrails": {
91
- "max_tool_calls": 200,
92
- "max_duration_minutes": 30,
93
- "profiles": {
94
- "coder": { "max_tool_calls": 500 }
95
- }
96
- },
97
- "tool_filter": {
98
- "enabled": true,
99
- "overrides": {}
100
- },
101
- "review_passes": {
102
- "always_security_review": false,
103
- "security_globs": ["**/*auth*", "**/*crypto*", "**/*session*"]
104
- },
105
- "automation": {
106
- "mode": "manual",
107
- "capabilities": {
108
- "plan_sync": false,
109
- "phase_preflight": false,
110
- "config_doctor_on_startup": false,
111
- "evidence_auto_summaries": false,
112
- "decision_drift_detection": false
113
- }
143
+ "coder": { "model": "opencode/minimax-m2.5-free" },
144
+ "reviewer": { "model": "opencode/big-pickle" }
114
145
  }
115
146
  }
116
147
  ```
117
148
 
118
- You only need to specify the agents you want to override. The rest use the default.
149
+ You only need to specify the agents you want to override.
119
150
 
120
- ### Start Building
151
+ > Note: if `architect` is not set explicitly, it inherits the current model selected in the OpenCode UI.
121
152
 
122
- Just tell OpenCode what you want to build. Swarm handles the rest.
153
+ ## Common First-Run Questions
123
154
 
124
- ```
125
- > Build a REST API with user registration, login, and JWT auth
155
+ ### "Do I need to use the Architect agent specifically?"
156
+
157
+ No. In normal use, you just use OpenCode. Swarm's architect runs inside the plugin and coordinates the other internal agents automatically.
158
+
159
+ ### "Why did the second run start coding immediately?"
160
+
161
+ Because Swarm persists state in `.swarm/` and resumes from where it left off. Check `/swarm status` or `/swarm plan`.
162
+
163
+ ### "How do I know Swarm is really active?"
164
+
165
+ Run:
166
+
167
+ ```text
168
+ /swarm diagnose
169
+ /swarm agents
170
+ /swarm config
126
171
  ```
127
172
 
128
- Use `/swarm status` at any time to see where things stand.
173
+ ### "How do I force a clean restart?"
174
+
175
+ Run:
176
+
177
+ ```text
178
+ /swarm reset --confirm
179
+ ```
129
180
 
130
181
  ---
131
182
 
@@ -198,19 +249,37 @@ For production use, mix providers to maximize quality across writing vs. reviewi
198
249
 
199
250
  ## The Agents
200
251
 
201
- Swarm has nine agents. You don't interact with them directly. The architect orchestrates everything.
252
+ Swarm has specialized internal agents, but you do **not** manually switch into them during normal use.
253
+
254
+ The **architect** is the coordinator. It decides when to invoke the other agents and what they should do.
255
+
256
+ That means the normal user workflow is:
257
+
258
+ 1. open the project in OpenCode
259
+ 2. describe what you want built or changed
260
+ 3. let Swarm coordinate the internal pipeline
261
+ 4. inspect progress with `/swarm status`, `/swarm plan`, and `/swarm evidence`
262
+
263
+ Agent roles:
202
264
 
203
265
  | Agent | Role | When It Runs |
204
- |-------|------|-------------|
205
- | **architect** | Plans the project, delegates tasks, enforces quality gates | Always (it's the coordinator) |
206
- | **explorer** | Scans your codebase to understand what exists | Before planning, after each phase |
207
- | **sme** | Domain expert (security, APIs, databases, whatever is needed) | During planning, guidance is cached |
208
- | **critic** | Reviews the plan before any code is written | After planning, before execution |
209
- | **coder** | Writes code, one task at a time | During execution |
210
- | **reviewer** | Reviews code for correctness and security issues | After every task |
211
- | **test_engineer** | Writes and runs tests, including adversarial edge cases | After every task |
212
- | **designer** | Generates UI scaffolds and design tokens (opt-in) | Before UI tasks |
213
- | **docs** | Updates documentation to match what was actually built | After each phase |
266
+ |---|---|---|
267
+ | `architect` | Coordinates the workflow, writes plans, enforces gates | Always |
268
+ | `explorer` | Scans the codebase and gathers context | Before planning, after phase wrap |
269
+ | `sme` | Provides domain guidance | During planning / consultation |
270
+ | `critic` | Reviews the plan before execution | Before coding starts |
271
+ | `coder` | Implements one task at a time | During execution |
272
+ | `reviewer` | Reviews correctness and security | After each task |
273
+ | `test_engineer` | Writes and runs tests | After each task |
274
+ | `designer` | Generates UI scaffolds and design tokens when needed | UI-specific work |
275
+ | `docs` | Updates docs to match what was actually built | After each phase |
276
+
277
+ If you want to see what is active right now, run:
278
+
279
+ ```text
280
+ /swarm status
281
+ /swarm agents
282
+ ```
214
283
 
215
284
  ---
216
285
 
@@ -259,16 +328,24 @@ If any step fails, the coder gets structured feedback and retries. After 5 failu
259
328
 
260
329
  The architect moves through these modes automatically:
261
330
 
262
- | Mode | What Happens |
263
- |------|-------------|
264
- | `RESUME` | Checks if `.swarm/plan.md` exists, picks up where it left off |
265
- | `CLARIFY` | Asks you questions (only what it can't infer) |
331
+ | Mode | What It Means |
332
+ |---|---|
333
+ | `RESUME` | Existing `.swarm/` state was found, so Swarm continues where it left off |
334
+ | `CLARIFY` | Swarm asks for missing information it cannot infer |
266
335
  | `DISCOVER` | Explorer scans the codebase |
267
336
  | `CONSULT` | SME agents provide domain guidance |
268
- | `PLAN` | Architect writes the phased plan |
269
- | `CRITIC-GATE` | Critic reviews the plan (max 2 revision cycles) |
337
+ | `PLAN` | Architect writes or updates the phased plan |
338
+ | `CRITIC-GATE` | Critic reviews the plan before execution |
270
339
  | `EXECUTE` | Tasks are implemented one at a time through the QA pipeline |
271
- | `PHASE-WRAP` | Phase completes, docs update, retrospective written |
340
+ | `PHASE-WRAP` | A phase closes out, docs are updated, and a retrospective is written |
341
+
342
+ ### Important
343
+
344
+ A second or later run does **not** necessarily look like a first run.
345
+
346
+ If `.swarm/plan.md` already exists, the architect may enter `RESUME` and then go directly into `EXECUTE`. That is expected and does **not** mean Swarm stopped using agents.
347
+
348
+ Use `/swarm status` if you are unsure what Swarm is doing.
272
349
 
273
350
  </details>
274
351
 
@@ -1077,8 +1154,25 @@ Upcoming: v6.22 focuses on further context optimization and agent coordination i
1077
1154
 
1078
1155
  ---
1079
1156
 
1157
+ ## FAQ
1158
+
1159
+ ### Do I need to use the Architect agent specifically?
1160
+ No. In normal use, you just use OpenCode. Swarm's architect runs inside the plugin and coordinates the other internal agents automatically.
1161
+
1162
+ ### Why did Swarm start coding immediately on my second run?
1163
+ Because Swarm resumes from `.swarm/` state when it exists. Check `/swarm status` to see the current mode.
1164
+
1165
+ ### How do I know which agents and models are active?
1166
+ Run `/swarm agents` and `/swarm config`.
1167
+
1168
+ ### How do I start over?
1169
+ Run `/swarm reset --confirm`.
1170
+
1171
+ ---
1172
+
1080
1173
  ## Documentation
1081
1174
 
1175
+ - [Getting Started](docs/getting-started.md)
1082
1176
  - [Architecture Deep Dive](docs/architecture.md)
1083
1177
  - [Design Rationale](docs/design-rationale.md)
1084
1178
  - [Installation Guide](docs/installation.md)
@@ -1086,6 +1180,7 @@ Upcoming: v6.22 focuses on further context optimization and agent coordination i
1086
1180
  - [LLM Operator Installation Guide](docs/installation-llm-operator.md)
1087
1181
  - [Pre-Swarm Planning Guide](docs/planning.md)
1088
1182
  - [Swarm Briefing for LLMs](docs/swarm-briefing.md)
1183
+ - [Configuration](docs/configuration.md)
1089
1184
 
1090
1185
  ---
1091
1186
 
@@ -7,6 +7,25 @@
7
7
  * - Layer 2 (Hard Block @ 100%): Throws error in toolBefore to block further calls, injects STOP message
8
8
  */
9
9
  import { type GuardrailsConfig } from '../config/schema';
10
+ /**
11
+ * Retrieves stored input args for a given callID.
12
+ * Used by other hooks (e.g., delegation-gate) to access tool input args.
13
+ * @param callID The callID to look up
14
+ * @returns The stored args or undefined if not found
15
+ */
16
+ export declare function getStoredInputArgs(callID: string): unknown | undefined;
17
+ /**
18
+ * Stores input args for a given callID.
19
+ * Used by guardrails toolBefore hook; may be used by other hooks if needed.
20
+ * @param callID The callID to store args under
21
+ * @param args The tool input args to store
22
+ */
23
+ export declare function setStoredInputArgs(callID: string, args: unknown): void;
24
+ /**
25
+ * Deletes stored input args for a given callID (cleanup after retrieval).
26
+ * @param callID The callID to delete
27
+ */
28
+ export declare function deleteStoredInputArgs(callID: string): void;
10
29
  /**
11
30
  * Creates guardrails hooks for circuit breaker protection
12
31
  * @param directoryOrConfig Working directory (from plugin init context) OR legacy config object for backward compatibility