@hueyexe/opencode-ensemble 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -11
- package/dist/index.js +327 -22
- package/package.json +1 -1
- package/src/config.ts +75 -0
- package/src/hooks.ts +14 -0
- package/src/index.ts +46 -14
- package/src/progress.ts +85 -0
- package/src/system-prompt.ts +69 -3
- package/src/tools/team-cleanup.ts +83 -6
- package/src/tools/team-spawn.ts +15 -0
- package/src/tools/team-status.ts +25 -3
- package/src/watchdog.ts +67 -0
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# OpenCode Ensemble
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@hueyexe/opencode-ensemble)
|
|
4
|
+
[](https://www.npmjs.com/package/@hueyexe/opencode-ensemble)
|
|
5
|
+
[]()
|
|
6
|
+
[]()
|
|
7
|
+
[]()
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
|
|
3
10
|
Run parallel AI agents in OpenCode. Each agent gets its own session, context window, and task. They coordinate through messaging and a shared task board.
|
|
4
11
|
|
|
5
12
|
Plugin built on the public OpenCode SDK. No internal dependencies.
|
|
@@ -50,9 +57,10 @@ You: "How's the team doing?"
|
|
|
50
57
|
Lead calls team_status:
|
|
51
58
|
Team: validation (you are the lead)
|
|
52
59
|
Members:
|
|
53
|
-
alice [idle] agent: build
|
|
54
|
-
bob [idle] agent: build
|
|
55
|
-
carol [working]
|
|
60
|
+
alice [idle 2m, last msg: 1m ago] agent: build branch: ensemble-validation-alice
|
|
61
|
+
bob [idle 1m, last msg: 30s ago] agent: build branch: ensemble-validation-bob
|
|
62
|
+
carol [working 5m, last msg: 3m ago] agent: build branch: ensemble-validation-carol
|
|
63
|
+
task: Write integration tests for validated endpoints
|
|
56
64
|
Tasks: 5 total (3 completed, 1 in_progress, 1 pending)
|
|
57
65
|
```
|
|
58
66
|
|
|
@@ -66,7 +74,7 @@ Lead calls team_view({ member: "carol" })
|
|
|
66
74
|
-> Use the session picker (ctrl+p) to go back to the lead
|
|
67
75
|
```
|
|
68
76
|
|
|
69
|
-
When everything is done, the lead shuts down teammates and cleans up:
|
|
77
|
+
When everything is done, the lead shuts down teammates and cleans up. Worktree branches are automatically merged into your working directory as unstaged changes for review:
|
|
70
78
|
|
|
71
79
|
```
|
|
72
80
|
[toast] alice shut down
|
|
@@ -74,9 +82,13 @@ When everything is done, the lead shuts down teammates and cleans up:
|
|
|
74
82
|
[toast] carol shut down
|
|
75
83
|
|
|
76
84
|
Lead: "All validation and tests are complete. 5 endpoints validated,
|
|
77
|
-
12 test cases added. Team cleaned up.
|
|
85
|
+
12 test cases added. Team cleaned up.
|
|
86
|
+
Merged 3 branch(es) into working directory (unstaged).
|
|
87
|
+
Review changes with: git diff"
|
|
78
88
|
```
|
|
79
89
|
|
|
90
|
+
All teammate changes are now in your working directory, unstaged, ready for you to review file-by-file with `git diff`.
|
|
91
|
+
|
|
80
92
|
## Install
|
|
81
93
|
|
|
82
94
|
Two steps: add the plugin, then allowlist worktree paths.
|
|
@@ -193,23 +205,66 @@ Teammate messages arrive in the lead's session as `[Team message from alice]: ..
|
|
|
193
205
|
- **Crash recovery**: stale busy members marked as errored on restart, orphaned sessions aborted, orphaned worktrees cleaned up, undelivered messages redelivered
|
|
194
206
|
- **Spawn rollback**: if the initial prompt fails, the member, session, and worktree are all cleaned up
|
|
195
207
|
- **Timeout watchdog**: teammates stuck busy beyond the TTL are automatically timed out and aborted
|
|
208
|
+
- **Stall detection**: detects teammates making no progress (low output tokens or no communication) and escalates to the lead
|
|
209
|
+
- **Auto-merge on cleanup**: worktree branches are squash-merged into your working directory as unstaged changes for review
|
|
210
|
+
- **Spawn circuit breaker**: stops retrying after 3 consecutive spawn failures
|
|
196
211
|
- **Graceful shutdown**: busy teammates receive a shutdown message and finish their current work. Use `force: true` to abort immediately.
|
|
197
|
-
- **Rate limiting**: token bucket (configurable via `OPENCODE_ENSEMBLE_RATE_LIMIT`, default 10 tokens/sec)
|
|
212
|
+
- **Rate limiting**: token bucket (configurable via config file or `OPENCODE_ENSEMBLE_RATE_LIMIT`, default 10 tokens/sec)
|
|
198
213
|
|
|
199
214
|
## Configuration
|
|
200
215
|
|
|
216
|
+
Configure via JSON files, environment variables, or both. Project config overrides global config. Env vars override everything.
|
|
217
|
+
|
|
218
|
+
### Config file
|
|
219
|
+
|
|
220
|
+
**Global** (`~/.config/opencode/ensemble.json`):
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"mergeOnCleanup": true,
|
|
225
|
+
"stallThresholdMs": 180000,
|
|
226
|
+
"stallMinSteps": 3,
|
|
227
|
+
"stallTokenThreshold": 500,
|
|
228
|
+
"timeoutMs": 1800000,
|
|
229
|
+
"rateLimitCapacity": 10
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Project** (`.opencode/ensemble.json` in your project root) — same shape, overrides global per-key.
|
|
234
|
+
|
|
235
|
+
All fields are optional. Missing fields use defaults.
|
|
236
|
+
|
|
237
|
+
| Key | Default | Description |
|
|
238
|
+
|-----|---------|-------------|
|
|
239
|
+
| `mergeOnCleanup` | `true` | Auto-merge worktree branches on cleanup (squash + unstage) |
|
|
240
|
+
| `stallThresholdMs` | `180000` (3 min) | Time without communication before stall escalation. `0` disables. |
|
|
241
|
+
| `stallMinSteps` | `3` | Min model steps before token-based stall check kicks in |
|
|
242
|
+
| `stallTokenThreshold` | `500` | Output tokens per step below which the agent is considered stalled |
|
|
243
|
+
| `timeoutMs` | `1800000` (30 min) | Hard timeout for busy teammates. `0` disables. |
|
|
244
|
+
| `rateLimitCapacity` | `10` | Token bucket capacity for team tool calls. `0` disables. |
|
|
245
|
+
|
|
246
|
+
### Environment variables
|
|
247
|
+
|
|
248
|
+
Env vars override config file values. Useful for CI or one-off overrides.
|
|
249
|
+
|
|
201
250
|
```bash
|
|
251
|
+
# Adjust teammate timeout (default: 1800000ms = 30 minutes)
|
|
252
|
+
OPENCODE_ENSEMBLE_TIMEOUT=3600000
|
|
253
|
+
|
|
254
|
+
# Disable timeout watchdog
|
|
255
|
+
OPENCODE_ENSEMBLE_TIMEOUT=0
|
|
256
|
+
|
|
202
257
|
# Adjust rate limit (default: 10 tokens, refills 2/sec)
|
|
203
258
|
OPENCODE_ENSEMBLE_RATE_LIMIT=20
|
|
204
259
|
|
|
205
260
|
# Disable rate limiting
|
|
206
261
|
OPENCODE_ENSEMBLE_RATE_LIMIT=0
|
|
207
262
|
|
|
208
|
-
# Adjust
|
|
209
|
-
|
|
263
|
+
# Adjust stall detection threshold (default: 180000ms = 3 minutes)
|
|
264
|
+
STALL_THRESHOLD_MS=300000
|
|
210
265
|
|
|
211
|
-
# Disable
|
|
212
|
-
|
|
266
|
+
# Disable stall detection
|
|
267
|
+
STALL_THRESHOLD_MS=0
|
|
213
268
|
```
|
|
214
269
|
|
|
215
270
|
## Best practices
|
|
@@ -243,7 +298,7 @@ Same coordination model (shared tasks, peer messaging, lead coordination) with s
|
|
|
243
298
|
```bash
|
|
244
299
|
bun install
|
|
245
300
|
bun run typecheck
|
|
246
|
-
bun test #
|
|
301
|
+
bun test # 423 tests
|
|
247
302
|
bun run build
|
|
248
303
|
```
|
|
249
304
|
|