@te-river/opencode-team-mode 1.4.5 → 1.4.7

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,474 +1,508 @@
1
- # OpenCode TeamMode
2
-
3
- **[English](./README.md)** | **[中文](./README.zh-CN.md)**
4
-
5
- [![npm version](https://img.shields.io/npm/v/@te-river/opencode-team-mode.svg)](https://www.npmjs.com/package/@te-river/opencode-team-mode)
6
- [![npm downloads](https://img.shields.io/npm/dm/@te-river/opencode-team-mode.svg)](https://www.npmjs.com/package/@te-river/opencode-team-mode)
7
- [![license](https://img.shields.io/npm/l/@te-river/opencode-team-mode.svg)](./LICENSE)
8
-
9
- > 🤝 **Multi-agent team collaboration plugin for [OpenCode Desktop](https://opencode.ai)**
10
- >
11
- > Adds a complete team of specialized AI agents — Architect, Implementer, Reviewer, Tester, Researcher — orchestrated by a Team Lead, all accessible via simple slash commands.
12
-
13
- ---
14
-
15
- ## ✨ What is TeamMode?
16
-
17
- TeamMode transforms OpenCode Desktop from a single-agent coding assistant into a **full development team**. Each agent has a distinct role, expertise, and personality — just like a real engineering team.
18
-
19
- Instead of one agent trying to do everything, you get:
20
-
21
- | Agent | Role | When to use |
22
- |---|---|---|
23
- | 🎯 **Team Lead** | Orchestrator | Complex tasks that need planning + multi-step execution |
24
- | 🏗️ **Architect** | System designer | Design docs, module structure, API contracts |
25
- | 💻 **Implementer** | Code writer | Building features, writing production code |
26
- | 🔍 **Reviewer** | Code auditor | Bug hunting, security review, quality checks |
27
- | 🧪 **Tester** | Test engineer | Unit tests, integration tests, edge-case coverage |
28
- | 🔎 **Researcher** | Knowledge finder | Library evaluation, API docs, best practices |
29
-
30
- ---
31
-
32
- ## 🚀 Quick Start
33
-
34
- ### Prerequisites
35
-
36
- 1. **Install OpenCode Desktop** (if you haven't already):
37
-
38
- | Platform | Install command |
39
- |---|---|
40
- | macOS (Apple Silicon) | `brew install --cask opencode-desktop` |
41
- | macOS (Intel) | `brew install --cask opencode-desktop` |
42
- | Windows | `scoop bucket add extras && scoop install extras/opencode-desktop` |
43
- | Linux | Download from [opencode.ai/download](https://opencode.ai/download) |
44
-
45
- Or install the **CLI/TUI** version:
46
- ```bash
47
- # one-line script (all platforms)
48
- curl -fsSL https://opencode.ai/install | bash
49
-
50
- # or via npm
51
- npm install -g opencode-ai
52
- ```
53
-
54
- 2. **Node.js ≥ 18** (for npm)
55
-
56
- ### Install TeamMode
57
-
58
- **Option A — One-line installer (recommended):**
59
-
60
- macOS / Linux (bash):
61
- ```bash
62
- curl -fsSL https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.sh | bash
63
- ```
64
-
65
- Windows (PowerShell):
66
- ```powershell
67
- irm https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.ps1 | iex
68
- ```
69
-
70
- These scripts install the npm package and automatically register the plugin in your `opencode.jsonc`.
71
-
72
- **Option B — Manual npm install:**
73
-
74
- ```bash
75
- # 1. Install the plugin package
76
- npm install -g @te-river/opencode-team-mode
77
-
78
- # 2. Add the plugin to your opencode.jsonc
79
- # (see "Configuration" below)
80
- ```
81
-
82
- **Option C — Local dev install (from this repo):**
83
-
84
- ```bash
85
- git clone https://github.com/Te-River/Opencode-TeamMode.git
86
- cd Opencode-TeamMode
87
- npm install
88
- npm run build
89
- npm link
90
- ```
91
-
92
- ---
93
-
94
- ## ⚙️ Configuration
95
-
96
- After installing, add the plugin to your `opencode.jsonc`:
97
-
98
- ```jsonc
99
- {
100
- "$schema": "https://opencode.ai/config.json",
101
- "plugin": [
102
- "@te-river/opencode-team-mode@latest"
103
- ]
104
- }
105
- ```
106
-
107
- That's it. The plugin automatically injects all team agents and commands when OpenCode starts. **No need to manually copy agent files or command definitions.**
108
-
109
- > 💡 **Tip:** After modifying `opencode.json`, **restart OpenCode Desktop** for changes to take effect.
110
-
111
- > ⚠️ **Model choice matters.** Every judgment in the workflow — triage,
112
- > decomposition, dispatch briefs, synthesis, review-loop verdicts — flows
113
- > through the **Team Lead**. A weak model in that seat degrades the whole
114
- > pipeline no matter how strong the specialists are. Pin your best
115
- > reasoning model to the `team` agent (recipe in
116
- > [Customization](#customization) below).
117
-
118
- ### Global install (all projects)
119
-
120
- To enable TeamMode in every project, add the plugin to your global config:
121
-
122
- ```jsonc
123
- // ~/.config/opencode/opencode.jsonc
124
- {
125
- "$schema": "https://opencode.ai/config.json",
126
- "plugin": [
127
- "@te-river/opencode-team-mode@latest"
128
- ]
129
- }
130
- ```
131
-
132
- ---
133
-
134
- ## 📖 Usage
135
-
136
- ### Slash Commands
137
-
138
- TeamMode adds six slash commands to OpenCode. Type them in the chat input:
139
-
140
- | Command | Agent | Description |
141
- |---|---|---|
142
- | `/team-plan <task>` | Architect | Create a detailed implementation plan with architecture, file manifest, and task breakdown |
143
- | `/team-implement <task>` | Implementer | Write production code for a feature or task |
144
- | `/team-review [scope]` | Reviewer | Audit code for bugs, security issues, and quality problems |
145
- | `/team-test [scope]` | Tester | Generate comprehensive tests with edge-case coverage |
146
- | `/team-research <topic>` | Researcher | Investigate libraries, APIs, or best practices |
147
- | `/team-run <task>` | Team Lead | **Full workflow** — orchestrates all agents end-to-end |
148
-
149
- #### Example workflow
150
-
151
- ```
152
- # 1. Plan the feature
153
- /team-plan Add user authentication with OAuth2 and JWT tokens
154
-
155
- # 2. Review the plan, then implement
156
- /team-implement Implement the auth module as planned
157
-
158
- # 3. Review the code
159
- /team-review src/auth/
160
-
161
- # 4. Write tests
162
- /team-test src/auth/
163
-
164
- # Or let the team lead handle everything:
165
- /team-run Add user authentication with OAuth2 and JWT tokens
166
- ```
167
-
168
- ### Agent Picker
169
-
170
- You can also invoke agents directly using the `@` mention in OpenCode Desktop:
171
-
172
- - `@team` — Orchestrate a complex task
173
- - `@architect` — Design a system or module
174
- - `@implementer` — Write code
175
- - `@reviewer` — Review code quality
176
- - `@tester` — Write tests
177
- - `@researcher` — Research a topic
178
-
179
- ### Demo
180
-
181
- A session transcript, recreated from how the flow actually looks. Team is the
182
- default agent out of the box (see Configuration to opt out), so the user just
183
- types into a fresh chat:
184
-
185
- > **User:** Add token-bucket rate limiting to our Express API — 100 requests
186
- > per minute per user, return 429 when exceeded. Don't touch anything under
187
- > `src/legacy/`.
188
-
189
- ```text
190
- team Breaking this down: design → implement → review → test.
191
- Task board: .git/opencode-team/20260831-143012/rate-limiter/ (session folder + board inside .git/, auto-swept after idle TTL)
192
-
193
- ▸ @architect — designing (writes 01-architect-design.md)
194
- ✓ in-memory token bucket, per-user key, 429 + Retry-After
195
- summary above, full design on the board
196
-
197
- ▸ @implementer — building (Reads: 01; writes 02-implementer-middleware.md)
198
- ✓ src/middleware/rateLimit.ts (new), wired into src/app.ts (+3 lines)
199
-
200
- ▸ @reviewer — auditing the diff (Reads: 01, 02; writes 03-reviewer-findings-r1.md)
201
- ⚠ 1 MAJOR — bucket refill does read-modify-write in two steps;
202
- races under concurrent requests
203
- → converted to a fix task; dispatched to @implementer with the
204
- finding text (the user was not asked to approve this step)
205
-
206
- ▸ @implementer r2 — fixing the race (Reads: 03-r1 §MAJOR; writes 04-implementer-r2.md)
207
- ✓ refill restructured to single atomic update
208
-
209
- ▸ @reviewer r2 — re-review of fixed scope only
210
- ✓ clean — r1 finding resolved, no regressions
211
-
212
- ▸ @tester — covering limiter + boundaries (writes 05-tester-report.md)
213
- ✓ 14/14 pass — burst edge, window expiry, concurrent refill,
214
- src/legacy/** byte-identical (user boundary verified in tests)
215
-
216
- team Done.
217
- rate limiter shipped: rateLimit.ts (new) · app.ts (+3) · 14 tests green
218
- review loop: 1 major found → fixed → clean
219
- assumption: in-memory only — say the word if you want Redis
220
- src/legacy/ untouched
221
- task board left in place — TTL sweep will reclaim it
222
- ```
223
-
224
- The only message the user typed was the first one. The reviewer's finding
225
- became the implementer's work order without a prompt; every artifact stayed
226
- out of chat and on the board, read only by the dispatch that needed it.
227
-
228
- ### Desktop-specific features
229
-
230
- In **OpenCode Desktop**, you get additional UX benefits:
231
-
232
- - 🎨 **Color-coded agents** — Each agent has a distinct color in the chat UI for easy identification.
233
- - 📋 **Agent picker** — Click the agent dropdown to switch between team agents visually.
234
- - 🔀 **Parallel sub-tasks** — The Team Lead can dispatch multiple sub-agents simultaneously, with results shown in parallel panels.
235
- - 📊 **Session history** — All team interactions are saved and searchable in the Desktop session sidebar.
236
-
237
- ---
238
-
239
- ## 🏗️ Architecture
240
-
241
- ```
242
- opencode-team-mode/
243
- ├── package.json ← npm package definition
244
- ├── tsconfig.json ← TypeScript config
245
- ├── src/
246
- │ ├── index.ts ← Plugin entry (server() + config hook, id: "team-mode")
247
- │ ├── agents.ts ← Agent definitions (prompts, modes, colors)
248
- │ ├── commands.ts ← Command definitions (templates, agent bindings)
249
- │ ├── blackboard.ts ← Shared blackboard + TTL auto-cleanup sweeper
250
- │ └── types.ts ← Loader-contract type definitions (1.18.x)
251
- ├── scripts/
252
- │ ├── install.sh ← One-click installer (bash)
253
- │ └── install.ps1 ← One-click installer (PowerShell)
254
- ├── LICENSE ← Apache 2.0
255
- ├── README.md ← English documentation
256
- └── README.zh-CN.md ← Chinese documentation
257
- ```
258
-
259
- ### How it works
260
-
261
- 1. OpenCode Desktop starts and loads `opencode.json(c)`.
262
- 2. It sees `"@te-river/opencode-team-mode@latest"` in the `plugin` array and loads the npm package.
263
- 3. The loader calls the plugin's `server(input, options)`, which registers a `config` hook; the hook injects 6 agents and 6 commands into the merged config.
264
- 4. The plugin's `id: "team-mode"` is displayed as the plugin name in the Desktop UI.
265
- 5. Agents and commands are immediately available in the Desktop UI — no file copying needed. User-defined agents with the same name always win (the plugin never clobbers them).
266
-
267
- ---
268
-
269
- ## 🗂️ Shared Blackboard (with automatic cleanup)
270
-
271
- Sub-agents cannot message each other live (platform limitation), so TeamMode coordinates them through a **file blackboard** with strict ownership:
272
-
273
- - **Session isolation:** every conversation owns ONE timestamped session
274
- folder, and each multi-agent task gets its own directory inside it:
275
- `<repo>/.git/opencode-team/<session-key>/<task-slug>/` — inside `.git/`,
276
- so your working tree and commits are **never polluted**. (Non-git
277
- workspaces fall back to the OS temp dir.) Since boards now linger until
278
- the TTL sweep, the session layer keeps a fresh conversation from bumping
279
- into — or reading stale artifacts from — a not-yet-swept board (timestamps
280
- are second-granular, so overlap needs two conversations starting in the
281
- same second).
282
- - **File ownership:** every artifact is one topic-sized file written by
283
- exactly one agent (`01-architect-auth-design.md`, `03-reviewer-auth-r1.md`).
284
- ~100 lines max per file — split topics instead of letting files balloon.
285
- - **Writes are frozen:** a revision is a new round-suffixed file
286
- (`…-r2.md`); nothing is ever appended to or later agents reading stale rounds.
287
- - **The Team Lead is the router:** every dispatch carries a manifest —
288
- `Task:` (self-contained brief), `Reads:` (only the files that work package
289
- needs), `Write to:` (the one file the agent owns). Specialists read nothing
290
- that isn't listed, so long tasks never drown sub-agents in unnecessary context.
291
- - **`MANIFEST.md` is the lead's state board:** a file index plus a ≤50-line
292
- `## Current state` section (phase, decisions still valid, next steps),
293
- updated every converged round — the lead's compressed memory across long tasks.
294
- - The Team Lead also enforces a review/test **feedback loop**: Critical/Major
295
- findings and product bugs automatically become tracked fix tasks until the
296
- deliverable converges.
297
-
298
- ### Triage — questions don't become code edits
299
-
300
- The Team Lead classifies every incoming message before acting: a question or
301
- consult gets an answer (zero file changes, fixes merely proposed and awaiting
302
- your go-ahead); only explicit action requests enter the workflow. And whenever
303
- you spell out what may or may not be touched, **those boundaries outrank
304
- everything else** — the lead restates them in every single dispatch.
305
-
306
- ### Cleanup — the TTL sweeper is the only path
307
-
308
- | Who | When |
309
- |---|---|
310
- | Plugin code (in-process sweeper) | At startup + every hour: removes task directories idle **beyond the TTL** |
311
-
312
- The Team Lead never deletes task directories — finished boards stay
313
- readable so you can audit how a run went, and reclamation is pure code
314
- that never relies on the model remembering to do anything (crashes and
315
- force-kills leave nothing behind either). The sweeper prunes stale task
316
- dirs individually under a still-live session, and reclaims an entirely
317
- idle session folder in one pass. Set `ttlDays` to taste.
318
-
319
- ### Configure the TTL
320
-
321
- Default is **5 days**. To choose your own, use the tuple plugin form in
322
- `opencode.jsonc`:
323
-
324
- ```jsonc
325
- {
326
- "$schema": "https://opencode.ai/config.json",
327
- "plugin": [
328
- ["@te-river/opencode-team-mode@latest", { "ttlDays": 7 }]
329
- ]
330
- }
331
- ```
332
-
333
- `ttlDays` accepts any number of days in `(0, 365]`; invalid values silently
334
- fall back to 5.
335
-
336
- ### Default agent
337
-
338
- By default TeamMode **makes Team your default agent** — new chats open
339
- directly in the team orchestrator. One side effect comes with the default
340
- slot: the switcher pins the default agent to the **first position** and
341
- sorts everything else alphabetically, so the picker order is
342
- **team, build, plan**. (Want Team below Plan instead? That requires
343
- giving up the default slot — see the opt-out below; the two are
344
- mutually exclusive by the server's sort.)
345
-
346
- To opt out (`build` stays the default, picker order **build, plan,
347
- team**):
348
-
349
- ```jsonc
350
- {
351
- "plugin": [
352
- ["@te-river/opencode-team-mode@latest", { "defaultAgent": false }]
353
- ]
354
- }
355
- ```
356
-
357
- An explicitly configured non-`build` `default_agent` in your own config is
358
- always respected untouched — the plugin never clobbers it.
359
-
360
- **Upgrade note:** v1.4.4 briefly made this promotion opt-in; v1.4.5 restores
361
- Team-as-default as the shipped behavior. If you pinned `{ "defaultAgent":
362
- true }` during v1.4.4, you can drop that option (or switch it to `false` to
363
- opt out).
364
-
365
- ---
366
-
367
- ## 🔧 Customization
368
-
369
- ### The Team Lead's model matters most
370
-
371
- The Lead is the orchestrating brain: it classifies every message, cuts the
372
- work into packages, writes each dispatch manifest, judges reviewer/tester
373
- findings, and synthesizes the final deliverable. Quality failures there
374
- **multiply down the pipeline** — a mediocre Lead mis-decomposes, briefs the
375
- experts vaguely, and waves weak work through; no specialist can rescue an
376
- assignment it was never correctly given.
377
-
378
- So run the strongest model you can afford **in the Lead seat**. The other
379
- roles tolerate cheaper models — they work from tight briefs with scoped
380
- reading. Pin models per agent:
381
-
382
- ```jsonc
383
- {
384
- "agent": {
385
- // Team Lead — orchestration earns your best model
386
- "team": { "model": "anthropic/claude-opus-4-5" },
387
- // specialists — cheaper models are usually fine
388
- "implementer": { "model": "anthropic/claude-sonnet-4-6" }
389
- }
390
- }
391
- ```
392
-
393
- (Model IDs above are placeholders — use whatever your provider exposes.
394
- Your own `agent.team` definition always takes precedence over the plugin's.)
395
-
396
- ### Override an agent
397
-
398
- Add an agent with the same name in your `opencode.json` — your definition takes precedence:
399
-
400
- ```jsonc
401
- {
402
- "agent": {
403
- "reviewer": {
404
- "model": "anthropic/claude-sonnet-4-6",
405
- "prompt": "You are an extremely strict reviewer. Reject anything with a lint warning."
406
- }
407
- }
408
- }
409
- ```
410
-
411
- ### Add your own agents
412
-
413
- TeamMode does not prevent you from adding more agents. Define them alongside the team:
414
-
415
- ```jsonc
416
- {
417
- "agent": {
418
- "devops": {
419
- "mode": "subagent",
420
- "description": "Handles CI/CD, Docker, and deployment tasks.",
421
- "prompt": "You are the DevOps engineer..."
422
- }
423
- }
424
- }
425
- ```
426
-
427
- ### Disable an agent
428
-
429
- ```jsonc
430
- {
431
- "agent": {
432
- "researcher": { "disable": true }
433
- }
434
- }
435
- ```
436
-
437
- ---
438
-
439
- ## 📦 Publishing to npm
440
-
441
- If you want to publish your own fork:
442
-
443
- ```bash
444
- npm run build # compile TypeScript → dist/
445
- npm version patch # bump version
446
- npm publish # publish to npm registry
447
- ```
448
-
449
- ---
450
-
451
- ## 🤝 Contributing
452
-
453
- Contributions are welcome! Areas where we need help:
454
-
455
- - 🌐 **Localization** — Translate agent prompts to other languages
456
- - 🎨 **More agent roles** — DevOps, DBA, Security Specialist, UX Designer
457
- - 🔧 **Additional commands** — `/team-deploy`, `/team-docs`, `/team-refactor`
458
- - 📝 **Better prompts** — Improve agent behavior through prompt engineering
459
-
460
- ---
461
-
462
- ## 📄 License
463
-
464
- [Apache License 2.0](./LICENSE)
465
-
466
- ---
467
-
468
- ## 🔗 Links
469
-
470
- - [npm Package](https://www.npmjs.com/package/@te-river/opencode-team-mode) — `@te-river/opencode-team-mode` on npm
471
- - [OpenCode Desktop](https://opencode.ai) — Official website & download
472
- - [OpenCode Docs](https://opencode.ai/docs) — Configuration & plugin documentation
473
- - [OpenCode Plugin API](https://opencode.ai/docs/plugins) — Build your own plugins
474
- - [OpenCode GitHub](https://github.com/anomalyco/opencode) — Source code for OpenCode itself
1
+ # OpenCode TeamMode
2
+
3
+ **[English](./README.md)** | **[中文](./README.zh-CN.md)**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@te-river/opencode-team-mode.svg)](https://www.npmjs.com/package/@te-river/opencode-team-mode)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@te-river/opencode-team-mode.svg)](https://www.npmjs.com/package/@te-river/opencode-team-mode)
7
+ [![license](https://img.shields.io/npm/l/@te-river/opencode-team-mode.svg)](./LICENSE)
8
+
9
+ > 🤝 **Multi-agent team collaboration plugin for [OpenCode Desktop](https://opencode.ai)**
10
+ >
11
+ > Adds a complete team of specialized AI agents — Architect, Implementer, Reviewer, Tester, Researcher — orchestrated by a Team Lead, all accessible via simple slash commands.
12
+
13
+ ---
14
+
15
+ ## ✨ What is TeamMode?
16
+
17
+ TeamMode transforms OpenCode Desktop from a single-agent coding assistant into a **full development team**. Each agent has a distinct role, expertise, and personality — just like a real engineering team.
18
+
19
+ Instead of one agent trying to do everything, you get:
20
+
21
+ | Agent | Role | When to use |
22
+ |---|---|---|
23
+ | 🎯 **Team Lead** | Orchestrator | Complex tasks that need planning + multi-step execution |
24
+ | 🏗️ **Architect** | System designer | Design docs, module structure, API contracts |
25
+ | 💻 **Implementer** | Code writer | Building features, writing production code |
26
+ | 🔍 **Reviewer** | Dimension-focused auditor | Single-dimension review (completeness / correctness / impact) — the lead runs 3 in parallel |
27
+ | 🧪 **Tester** | Test engineer | Unit tests, integration tests, edge-case coverage, static verification (build / typecheck / lint / API tests) |
28
+ | 🔎 **Researcher** | Knowledge finder | Library evaluation, API docs, best practices |
29
+
30
+ ---
31
+
32
+ ## 🚀 Quick Start
33
+
34
+ ### Prerequisites
35
+
36
+ 1. **Install OpenCode Desktop** (if you haven't already):
37
+
38
+ | Platform | Install command |
39
+ |---|---|
40
+ | macOS (Apple Silicon) | `brew install --cask opencode-desktop` |
41
+ | macOS (Intel) | `brew install --cask opencode-desktop` |
42
+ | Windows | `scoop bucket add extras && scoop install extras/opencode-desktop` |
43
+ | Linux | Download from [opencode.ai/download](https://opencode.ai/download) |
44
+
45
+ Or install the **CLI/TUI** version:
46
+ ```bash
47
+ # one-line script (all platforms)
48
+ curl -fsSL https://opencode.ai/install | bash
49
+
50
+ # or via npm
51
+ npm install -g opencode-ai
52
+ ```
53
+
54
+ 2. **Node.js ≥ 18** (for npm)
55
+
56
+ ### Install TeamMode
57
+
58
+ **Option A — One-line installer (recommended):**
59
+
60
+ macOS / Linux (bash):
61
+ ```bash
62
+ curl -fsSL https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.sh | bash
63
+ ```
64
+
65
+ Windows (PowerShell):
66
+ ```powershell
67
+ irm https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.ps1 | iex
68
+ ```
69
+
70
+ These scripts install the npm package and automatically register the plugin in your `opencode.jsonc`.
71
+
72
+ **Option B — Manual npm install:**
73
+
74
+ ```bash
75
+ # 1. Install the plugin package
76
+ npm install -g @te-river/opencode-team-mode
77
+
78
+ # 2. Add the plugin to your opencode.jsonc
79
+ # (see "Configuration" below)
80
+ ```
81
+
82
+ **Option C — Local dev install (from this repo):**
83
+
84
+ ```bash
85
+ git clone https://github.com/Te-River/Opencode-TeamMode.git
86
+ cd Opencode-TeamMode
87
+ npm install
88
+ npm run build
89
+ npm link
90
+ ```
91
+
92
+ ---
93
+
94
+ ## ⚙️ Configuration
95
+
96
+ After installing, add the plugin to your `opencode.jsonc`:
97
+
98
+ ```jsonc
99
+ {
100
+ "$schema": "https://opencode.ai/config.json",
101
+ "plugin": [
102
+ "@te-river/opencode-team-mode@latest"
103
+ ]
104
+ }
105
+ ```
106
+
107
+ That's it. The plugin automatically injects all team agents and commands when OpenCode starts. **No need to manually copy agent files or command definitions.**
108
+
109
+ > 💡 **Tip:** After modifying `opencode.json`, **restart OpenCode Desktop** for changes to take effect.
110
+
111
+ > ⚠️ **Model choice matters.** Every judgment in the workflow — triage,
112
+ > decomposition, dispatch briefs, synthesis, review-loop verdicts — flows
113
+ > through the **Team Lead**. A weak model in that seat degrades the whole
114
+ > pipeline no matter how strong the specialists are. Pin your best
115
+ > reasoning model to the `team` agent (recipe in
116
+ > [Customization](#customization) below).
117
+
118
+ ### Global install (all projects)
119
+
120
+ To enable TeamMode in every project, add the plugin to your global config:
121
+
122
+ ```jsonc
123
+ // ~/.config/opencode/opencode.jsonc
124
+ {
125
+ "$schema": "https://opencode.ai/config.json",
126
+ "plugin": [
127
+ "@te-river/opencode-team-mode@latest"
128
+ ]
129
+ }
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 📖 Usage
135
+
136
+ ### Slash Commands
137
+
138
+ TeamMode adds six slash commands to OpenCode. Type them in the chat input:
139
+
140
+ | Command | Agent | Description |
141
+ |---|---|---|
142
+ | `/team-plan <task>` | Architect | Create a detailed implementation plan with architecture, file manifest, and task breakdown |
143
+ | `/team-implement <task>` | Implementer | Write production code for a feature or task |
144
+ | `/team-review [scope]` | Reviewer | Audit code for bugs, security issues, and quality problems |
145
+ | `/team-test [scope]` | Tester | Generate comprehensive tests with edge-case coverage |
146
+ | `/team-research <topic>` | Researcher | Investigate libraries, APIs, or best practices |
147
+ | `/team-run <task>` | Team Lead | **Full workflow** — orchestrates all agents end-to-end |
148
+
149
+ #### Example workflow
150
+
151
+ ```
152
+ # 1. Plan the feature
153
+ /team-plan Add user authentication with OAuth2 and JWT tokens
154
+
155
+ # 2. Review the plan, then implement
156
+ /team-implement Implement the auth module as planned
157
+
158
+ # 3. Review the code
159
+ /team-review src/auth/
160
+
161
+ # 4. Write tests
162
+ /team-test src/auth/
163
+
164
+ # Or let the team lead handle everything:
165
+ /team-run Add user authentication with OAuth2 and JWT tokens
166
+ ```
167
+
168
+ ### Agent Picker
169
+
170
+ You can also invoke agents directly using the `@` mention in OpenCode Desktop:
171
+
172
+ - `@team` — Orchestrate a complex task
173
+ - `@architect` — Design a system or module
174
+ - `@implementer` — Write code
175
+ - `@reviewer` — Review code quality
176
+ - `@tester` — Write tests
177
+ - `@researcher` — Research a topic
178
+
179
+ ### Demo
180
+
181
+ A session transcript, recreated from how the flow actually looks. Team is the
182
+ default agent out of the box (see Configuration to opt out), so the user just
183
+ types into a fresh chat:
184
+
185
+ > **User:** Add token-bucket rate limiting to our Express API — 100 requests
186
+ > per minute per user, return 429 when exceeded. Don't touch anything under
187
+ > `src/legacy/`.
188
+
189
+ ```text
190
+ team Route: product behavior change → implementer → tester → reviewer
191
+ (3 dispatches → approval gate applies)
192
+
193
+ Research: read README, src/app.ts, src/middleware/*
194
+ Blocking questions: none — 1 assumption listed below
195
+
196
+ PLAN
197
+ Goal: token-bucket limiter, 100 req/min/user, 429 + Retry-After
198
+ Scope: src/middleware/rateLimit.ts (new), src/app.ts (+3 lines)
199
+ Pipeline: implementer → tester → reviewer (correctness)
200
+ Assumption: in-memory bucket, not Redis — say the word to change
201
+ Boundary: src/legacy/** untouched
202
+ Approve to proceed?
203
+
204
+ user approved, go
205
+
206
+ team ▸ @implementer — STATUS: done
207
+ CHANGES: src/middleware/rateLimit.ts (new) · src/app.ts (+3)
208
+ HANDOFF: bucket {tokens, lastRefill}; refill() is a single atomic pass
209
+ EVIDENCE: tsc clean (output above)
210
+
211
+ ▸ @tester — STATUS: done · VERDICT: pass (14/14)
212
+ FINDINGS: burst edge, window expiry, concurrent refill covered;
213
+ src/legacy/** byte-identical
214
+ EVIDENCE: vitest 14 passed
215
+
216
+ ▸ @reviewer — STATUS: done · VERDICT: approve (correctness)
217
+ FINDINGS: no Critical/Major; 1 Minor (log line noise) noted
218
+
219
+ team Done.
220
+ rate limiter shipped: rateLimit.ts (new) · app.ts (+3) · 14 tests green
221
+ review: approve · assumption: in-memory only · src/legacy/ untouched
222
+ ```
223
+
224
+ The only message the user typed was the task and "approved, go". The
225
+ pipeline was a routing-table lookup, execution waited for plan approval,
226
+ and every handoff traveled as a structured skeleton — no file ceremony.
227
+
228
+ ### Desktop-specific features
229
+
230
+ In **OpenCode Desktop**, you get additional UX benefits:
231
+
232
+ - 🎨 **Color-coded agents** — Each agent has a distinct color in the chat UI for easy identification.
233
+ - 📋 **Agent picker** — Click the agent dropdown to switch between team agents visually.
234
+ - 🔀 **Parallel sub-tasks** — The Team Lead can dispatch multiple sub-agents simultaneously, with results shown in parallel panels.
235
+ - 📊 **Session history** — All team interactions are saved and searchable in the Desktop session sidebar.
236
+
237
+ ---
238
+
239
+ ## 🏗️ Architecture
240
+
241
+ ```
242
+ opencode-team-mode/
243
+ ├── package.json ← npm package definition
244
+ ├── tsconfig.json ← TypeScript config
245
+ ├── src/
246
+ │ ├── index.ts ← Plugin entry (server() + config hook, id: "team-mode")
247
+ │ ├── agents.ts ← Agent definitions (prompts, modes, colors)
248
+ │ ├── commands.ts ← Command definitions (templates, agent bindings)
249
+ │ ├── blackboard.ts ← Shared blackboard + TTL auto-cleanup sweeper
250
+ │ └── types.ts ← Loader-contract type definitions (1.18.x)
251
+ ├── scripts/
252
+ │ ├── install.sh ← One-click installer (bash)
253
+ │ └── install.ps1 ← One-click installer (PowerShell)
254
+ ├── LICENSE ← Apache 2.0
255
+ ├── README.md ← English documentation
256
+ └── README.zh-CN.md ← Chinese documentation
257
+ ```
258
+
259
+ ### How it works
260
+
261
+ 1. OpenCode Desktop starts and loads `opencode.json(c)`.
262
+ 2. It sees `"@te-river/opencode-team-mode@latest"` in the `plugin` array and loads the npm package.
263
+ 3. The loader calls the plugin's `server(input, options)`, which registers a `config` hook; the hook injects 6 agents and 6 commands into the merged config.
264
+ 4. The plugin's `id: "team-mode"` is displayed as the plugin name in the Desktop UI.
265
+ 5. Agents and commands are immediately available in the Desktop UI — no file copying needed. User-defined agents with the same name always win (the plugin never clobbers them).
266
+
267
+ ---
268
+
269
+ ## 🗂️ Coordination: structured handoffs first, files second (hybrid)
270
+
271
+ Sub-agents cannot message each other live (platform limitation), so TeamMode
272
+ coordinates them through a **structured reply skeleton**, with a file
273
+ blackboard reserved for oversized output:
274
+
275
+ - **Reply skeleton (primary channel):** every specialist's final reply starts
276
+ with `STATUS: / CHANGES: / FINDINGS: / EVIDENCE: / HANDOFF:` and stays ≤50
277
+ lines. Deliverables at that size travel inline — zero file I/O, nothing to
278
+ fall out of sync. The lead relays `HANDOFF` verbatim into the next
279
+ dispatch and machine-checks the skeleton (missing → one retry with it
280
+ inline, then downgrade and note the violation).
281
+ - **Board files (exception only):** when a full deliverable exceeds ~50 lines
282
+ (e.g. a complete architecture doc), the dispatch names ONE file:
283
+ `<repo>/.git/opencode-team/<session-key>/<task-slug>/NN-<role>-<topic>.md`
284
+ — inside `.git/`, so your working tree and commits are **never polluted**
285
+ (non-git workspaces fall back to the OS temp dir). Writes are frozen: a
286
+ revision is a new round-suffixed file (`…-r2.md`); session folders keep a
287
+ fresh conversation from touching a not-yet-swept board.
288
+ - **No MANIFEST.md:** the lead's state memory is its todo list.
289
+ - **Feedback loop:** Critical/Major findings and product bugs automatically
290
+ become tracked fix tasks until the deliverable converges (max 2 loops,
291
+ then escalate to you).
292
+
293
+ ### Deterministic routing, approval gate & adaptive review (v1.4.7)
294
+
295
+ - **Routing table:** the lead picks a fixed pipeline row by task shape —
296
+ question → direct answer; docs-only → implementer; product behavior
297
+ change → implementer → tester → reviewer; multi-module feature →
298
+ architect → implementer → tester → reviewer(s); unknown external tech →
299
+ researcher first. Pipelines have fixed minimums: a product change routed
300
+ below 3 dispatches is a routing bug, and splitting one request into
301
+ sub-3-dispatch pieces to dodge the gate is a protocol violation.
302
+ - **Approval gate (count-based):** ≥3 planned dispatches → the lead
303
+ researches (reading the repo itself; a researcher dispatch only for
304
+ unknown external tech), presents a ≤30-line plan, and **waits for your
305
+ approval** before executing anything. 0-2 dispatches run with a 1-2 line
306
+ notice. A task that grows a third dispatch mid-run pauses for approval.
307
+ Blocking uncertainties are batched and asked immediately — never guessed,
308
+ never drip-fed.
309
+ - **Adaptive review:** default is ONE reviewer dispatch (correctness);
310
+ three parallel dimensions (completeness / correctness / impact) only for
311
+ high-risk profiles — auth/security surface, cross-module data contracts,
312
+ public APIs across ≥3 files.
313
+ - **Static verification:** testers verify via build, typecheck, static
314
+ analysis, and API/unit tests. Improvised browser automation (headless
315
+ screenshots, DOM stubs) is banned; user-visible frontend changes end with
316
+ `UI NOT VERIFIED: <what needs manual checking>` unless the project
317
+ already ships real browser-test tooling.
318
+ - **No-ceremony fast path:** a root cause the lead has already verified
319
+ (file:line evidence) goes straight to the implementer as a fix spec —
320
+ investigation dispatches serve unknowns, not ritual.
321
+ - **Brevity discipline:** route selection is a table lookup; user-visible
322
+ planning text stays ≤5 lines.
323
+ - **Evidence standard (kept):** "done / fixed / passed" claims need
324
+ verifiable evidence — command output, logs, diffs. Narratives are
325
+ progress notes, not proof.
326
+ - **Verbatim contracts (kept):** parallel implementers that must
327
+ interoperate get the exact data contract (endpoints, field names, types)
328
+ pasted verbatim into every affected dispatch.
329
+ - **CHANGELOG care (kept):** delivered changes append an entry to the
330
+ project's CHANGELOG.md (Keep a Changelog style) when one exists.
331
+
332
+ ### Triage — questions don't become code edits
333
+
334
+ The Team Lead classifies every incoming message before acting: a question or
335
+ consult gets an answer (zero file changes, fixes merely proposed and awaiting
336
+ your go-ahead); only explicit action requests enter the workflow. And whenever
337
+ you spell out what may or may not be touched, **those boundaries outrank
338
+ everything else** — the lead restates them in every single dispatch.
339
+
340
+ ### Cleanup — the TTL sweeper is the only path
341
+
342
+ | Who | When |
343
+ |---|---|
344
+ | Plugin code (in-process sweeper) | At startup + every hour: removes task directories idle **beyond the TTL** |
345
+
346
+ The Team Lead never deletes task directories — finished boards stay
347
+ readable so you can audit how a run went, and reclamation is pure code
348
+ that never relies on the model remembering to do anything (crashes and
349
+ force-kills leave nothing behind either). The sweeper prunes stale task
350
+ dirs individually under a still-live session, and reclaims an entirely
351
+ idle session folder in one pass. Set `ttlDays` to taste.
352
+
353
+ ### Configure the TTL
354
+
355
+ Default is **5 days**. To choose your own, use the tuple plugin form in
356
+ `opencode.jsonc`:
357
+
358
+ ```jsonc
359
+ {
360
+ "$schema": "https://opencode.ai/config.json",
361
+ "plugin": [
362
+ ["@te-river/opencode-team-mode@latest", { "ttlDays": 7 }]
363
+ ]
364
+ }
365
+ ```
366
+
367
+ `ttlDays` accepts any number of days in `(0, 365]`; invalid values silently
368
+ fall back to 5.
369
+
370
+ ### Default agent
371
+
372
+ By default TeamMode **makes Team your default agent** — new chats open
373
+ directly in the team orchestrator. One side effect comes with the default
374
+ slot: the switcher pins the default agent to the **first position** and
375
+ sorts everything else alphabetically, so the picker order is
376
+ **team, build, plan**. (Want Team below Plan instead? That requires
377
+ giving up the default slot — see the opt-out below; the two are
378
+ mutually exclusive by the server's sort.)
379
+
380
+ To opt out (`build` stays the default, picker order **build, plan,
381
+ team**):
382
+
383
+ ```jsonc
384
+ {
385
+ "plugin": [
386
+ ["@te-river/opencode-team-mode@latest", { "defaultAgent": false }]
387
+ ]
388
+ }
389
+ ```
390
+
391
+ An explicitly configured non-`build` `default_agent` in your own config is
392
+ always respected untouched — the plugin never clobbers it.
393
+
394
+ **Upgrade note:** v1.4.4 briefly made this promotion opt-in; v1.4.5 restores
395
+ Team-as-default as the shipped behavior. If you pinned `{ "defaultAgent":
396
+ true }` during v1.4.4, you can drop that option (or switch it to `false` to
397
+ opt out).
398
+
399
+ ---
400
+
401
+ ## 🔧 Customization
402
+
403
+ ### The Team Lead's model matters most
404
+
405
+ The Lead is the orchestrating brain: it classifies every message, cuts the
406
+ work into packages, writes each dispatch manifest, judges reviewer/tester
407
+ findings, and synthesizes the final deliverable. Quality failures there
408
+ **multiply down the pipeline** — a mediocre Lead mis-decomposes, briefs the
409
+ experts vaguely, and waves weak work through; no specialist can rescue an
410
+ assignment it was never correctly given.
411
+
412
+ So run the strongest model you can afford **in the Lead seat**. The other
413
+ roles tolerate cheaper models — they work from tight briefs with scoped
414
+ reading. Pin models per agent:
415
+
416
+ ```jsonc
417
+ {
418
+ "agent": {
419
+ // Team Lead — orchestration earns your best model
420
+ "team": { "model": "anthropic/claude-opus-4-5" },
421
+ // specialists — cheaper models are usually fine
422
+ "implementer": { "model": "anthropic/claude-sonnet-4-6" }
423
+ }
424
+ }
425
+ ```
426
+
427
+ (Model IDs above are placeholders — use whatever your provider exposes.
428
+ Your own `agent.team` definition always takes precedence over the plugin's.)
429
+
430
+ ### Override an agent
431
+
432
+ Add an agent with the same name in your `opencode.json` — your definition takes precedence:
433
+
434
+ ```jsonc
435
+ {
436
+ "agent": {
437
+ "reviewer": {
438
+ "model": "anthropic/claude-sonnet-4-6",
439
+ "prompt": "You are an extremely strict reviewer. Reject anything with a lint warning."
440
+ }
441
+ }
442
+ }
443
+ ```
444
+
445
+ ### Add your own agents
446
+
447
+ TeamMode does not prevent you from adding more agents. Define them alongside the team:
448
+
449
+ ```jsonc
450
+ {
451
+ "agent": {
452
+ "devops": {
453
+ "mode": "subagent",
454
+ "description": "Handles CI/CD, Docker, and deployment tasks.",
455
+ "prompt": "You are the DevOps engineer..."
456
+ }
457
+ }
458
+ }
459
+ ```
460
+
461
+ ### Disable an agent
462
+
463
+ ```jsonc
464
+ {
465
+ "agent": {
466
+ "researcher": { "disable": true }
467
+ }
468
+ }
469
+ ```
470
+
471
+ ---
472
+
473
+ ## 📦 Publishing to npm
474
+
475
+ If you want to publish your own fork:
476
+
477
+ ```bash
478
+ npm run build # compile TypeScript → dist/
479
+ npm version patch # bump version
480
+ npm publish # publish to npm registry
481
+ ```
482
+
483
+ ---
484
+
485
+ ## 🤝 Contributing
486
+
487
+ Contributions are welcome! Areas where we need help:
488
+
489
+ - 🌐 **Localization** — Translate agent prompts to other languages
490
+ - 🎨 **More agent roles** — DevOps, DBA, Security Specialist, UX Designer
491
+ - 🔧 **Additional commands** — `/team-deploy`, `/team-docs`, `/team-refactor`
492
+ - 📝 **Better prompts** — Improve agent behavior through prompt engineering
493
+
494
+ ---
495
+
496
+ ## 📄 License
497
+
498
+ [Apache License 2.0](./LICENSE)
499
+
500
+ ---
501
+
502
+ ## 🔗 Links
503
+
504
+ - [npm Package](https://www.npmjs.com/package/@te-river/opencode-team-mode) — `@te-river/opencode-team-mode` on npm
505
+ - [OpenCode Desktop](https://opencode.ai) — Official website & download
506
+ - [OpenCode Docs](https://opencode.ai/docs) — Configuration & plugin documentation
507
+ - [OpenCode Plugin API](https://opencode.ai/docs/plugins) — Build your own plugins
508
+ - [OpenCode GitHub](https://github.com/anomalyco/opencode) — Source code for OpenCode itself