@hueyexe/opencode-ensemble 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/dist/index.js +13275 -0
- package/package.json +44 -0
- package/src/db.ts +23 -0
- package/src/hooks.ts +96 -0
- package/src/index.ts +282 -0
- package/src/messaging.ts +78 -0
- package/src/notify.ts +54 -0
- package/src/rate-limit.ts +76 -0
- package/src/recovery.ts +71 -0
- package/src/schema.ts +83 -0
- package/src/state.ts +103 -0
- package/src/tools/team-approve-plan.ts +42 -0
- package/src/tools/team-broadcast.ts +59 -0
- package/src/tools/team-claim.ts +36 -0
- package/src/tools/team-cleanup.ts +45 -0
- package/src/tools/team-create.ts +32 -0
- package/src/tools/team-message.ts +37 -0
- package/src/tools/team-shutdown.ts +51 -0
- package/src/tools/team-spawn.ts +77 -0
- package/src/tools/team-status.ts +49 -0
- package/src/tools/team-tasks-add.ts +49 -0
- package/src/tools/team-tasks-complete.ts +48 -0
- package/src/tools/team-tasks-list.ts +23 -0
- package/src/tools/team-view.ts +23 -0
- package/src/types.ts +82 -0
- package/src/util.ts +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 opencode-ensemble contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# OpenCode Ensemble
|
|
2
|
+
|
|
3
|
+
Agent teams for [OpenCode](https://opencode.ai). Run multiple agents in parallel with messaging, shared tasks, and coordinated execution.
|
|
4
|
+
|
|
5
|
+
Built as a plugin on the public OpenCode SDK. Zero internal dependencies.
|
|
6
|
+
|
|
7
|
+
## What actually happens
|
|
8
|
+
|
|
9
|
+
You ask the agent to do something complex. The agent decides it needs help, creates a team, and spawns teammates. Each teammate gets its own OpenCode session with a fresh context window and a specific task.
|
|
10
|
+
|
|
11
|
+
Here's a real interaction:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
You: "Add input validation to all API endpoints and write tests for each one."
|
|
15
|
+
|
|
16
|
+
The lead agent:
|
|
17
|
+
1. Creates a team called "validation"
|
|
18
|
+
2. Adds tasks to the shared board: one per endpoint
|
|
19
|
+
3. Spawns 3 teammates:
|
|
20
|
+
- alice: validate user endpoints (POST /users, PUT /users/:id)
|
|
21
|
+
- bob: validate order endpoints (POST /orders, PUT /orders/:id)
|
|
22
|
+
- carol: write integration tests for all validated endpoints
|
|
23
|
+
4. carol's tasks depend on alice and bob finishing first
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
From here, things happen in parallel. Alice and bob work simultaneously in their own sessions. You see toast notifications as they make progress:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
[toast] Teammate alice spawned (build)
|
|
30
|
+
[toast] Teammate bob spawned (build)
|
|
31
|
+
[toast] Teammate carol spawned (build)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The teammates talk to each other and to the lead:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
alice -> lead: "User validation done. Added zod schemas to POST /users and PUT /users/:id."
|
|
38
|
+
bob -> lead: "Order validation done. Found an edge case in PUT /orders/:id — negative quantities were allowed."
|
|
39
|
+
bob -> alice: "Did you handle email format validation? I want to match the pattern for order contact emails."
|
|
40
|
+
alice -> bob: "Yes, using z.string().email() — see src/validators/user.ts line 12."
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
When alice and bob finish, carol's blocked tasks unblock automatically. Carol starts writing tests using the actual validation schemas alice and bob created.
|
|
44
|
+
|
|
45
|
+
The lead keeps you updated throughout. You can check on things at any time:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
You: "How's the team doing?"
|
|
49
|
+
|
|
50
|
+
Lead calls team_status:
|
|
51
|
+
Team: validation (you are the lead)
|
|
52
|
+
Members:
|
|
53
|
+
alice [idle] agent: build session: ses_abc
|
|
54
|
+
bob [idle] agent: build session: ses_def
|
|
55
|
+
carol [working] agent: build session: ses_ghi
|
|
56
|
+
Tasks: 5 total (3 completed, 1 in_progress, 1 pending)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Want to see what carol is actually doing? The lead can switch your view to her session:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
You: "Show me what carol is working on."
|
|
63
|
+
|
|
64
|
+
Lead calls team_view({ member: "carol" })
|
|
65
|
+
-> TUI switches to carol's session, showing her full chat log
|
|
66
|
+
-> Use the session picker (ctrl+p) to go back to the lead
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
When everything is done, the lead shuts down teammates and cleans up:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
[toast] alice shut down
|
|
73
|
+
[toast] bob shut down
|
|
74
|
+
[toast] carol shut down
|
|
75
|
+
|
|
76
|
+
Lead: "All validation and tests are complete. 5 endpoints validated,
|
|
77
|
+
12 test cases added. Team cleaned up."
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bun add opencode-ensemble
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Add to your OpenCode config (`.opencode/config.json`):
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"plugins": {
|
|
91
|
+
"ensemble": {
|
|
92
|
+
"module": "opencode-ensemble"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For local development, create `.opencode/plugins/ensemble.ts`:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
export { default } from "opencode-ensemble"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Tools
|
|
105
|
+
|
|
106
|
+
13 tools total. The lead has all of them. Teammates get 6 (messaging + tasks).
|
|
107
|
+
|
|
108
|
+
**Team lifecycle** (lead only)
|
|
109
|
+
|
|
110
|
+
| Tool | What it does |
|
|
111
|
+
|------|-------------|
|
|
112
|
+
| `team_create` | Create a team. Caller becomes the lead. |
|
|
113
|
+
| `team_spawn` | Start a new teammate with a task. |
|
|
114
|
+
| `team_shutdown` | Ask a teammate to stop. |
|
|
115
|
+
| `team_cleanup` | Remove the team when done. |
|
|
116
|
+
| `team_approve_plan` | Approve or reject a teammate's plan before they write code. |
|
|
117
|
+
| `team_status` | See all members, their status, and a task summary. |
|
|
118
|
+
| `team_view` | Switch the TUI to a teammate's session. |
|
|
119
|
+
|
|
120
|
+
**Communication** (everyone)
|
|
121
|
+
|
|
122
|
+
| Tool | What it does |
|
|
123
|
+
|------|-------------|
|
|
124
|
+
| `team_message` | Send a direct message to a teammate or the lead. |
|
|
125
|
+
| `team_broadcast` | Message everyone on the team. |
|
|
126
|
+
|
|
127
|
+
**Task board** (everyone)
|
|
128
|
+
|
|
129
|
+
| Tool | What it does |
|
|
130
|
+
|------|-------------|
|
|
131
|
+
| `team_tasks_list` | See all tasks with status and assignee. |
|
|
132
|
+
| `team_tasks_add` | Add tasks to the shared board. |
|
|
133
|
+
| `team_tasks_complete` | Mark a task done. Unblocks dependents. |
|
|
134
|
+
| `team_claim` | Claim a pending task. Atomic, prevents double-claims. |
|
|
135
|
+
|
|
136
|
+
## What you see in the TUI
|
|
137
|
+
|
|
138
|
+
The plugin works within OpenCode's existing TUI. There's no custom team panel (that requires core TUI changes, which are [in progress upstream](https://github.com/sst/opencode)).
|
|
139
|
+
|
|
140
|
+
What you do get:
|
|
141
|
+
|
|
142
|
+
- **Toast notifications** when teammates spawn, finish, error, or shut down
|
|
143
|
+
- **Rich tool titles** in the sidebar (e.g. "Spawned alice (build)", "Message -> bob", "Task board (3 tasks)")
|
|
144
|
+
- **Session switching** via `team_view` to see any teammate's full chat log
|
|
145
|
+
- **Status checks** via `team_status` for a snapshot of the whole team
|
|
146
|
+
|
|
147
|
+
Teammate messages arrive in the lead's session as `[Team message from alice]: ...` blocks. They look like user messages in the TUI because that's how `promptAsync` delivery works. The content is clearly labeled with the sender's name.
|
|
148
|
+
|
|
149
|
+
## Architecture
|
|
150
|
+
|
|
151
|
+
- **SQLite** (`bun:sqlite`, WAL mode) for teams, members, tasks, and messages
|
|
152
|
+
- **promptAsync** for message delivery: injects a message and starts the prompt loop in one call
|
|
153
|
+
- **Sub-agent isolation**: teammates' sub-agents can't use team tools (parent chain tracking, max depth 10)
|
|
154
|
+
- **Crash recovery**: stale busy members marked as errored on restart, undelivered messages redelivered
|
|
155
|
+
- **Rate limiting**: token bucket (configurable via `OPENCODE_ENSEMBLE_RATE_LIMIT`, default 10 tokens/sec)
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Adjust rate limit (default: 10 tokens, refills 2/sec)
|
|
161
|
+
OPENCODE_ENSEMBLE_RATE_LIMIT=20
|
|
162
|
+
|
|
163
|
+
# Disable rate limiting
|
|
164
|
+
OPENCODE_ENSEMBLE_RATE_LIMIT=0
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
bun install
|
|
171
|
+
bun run typecheck
|
|
172
|
+
bun test # 144 tests
|
|
173
|
+
bun run build
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|