@te-river/opencode-team-mode 1.5.15 → 1.6.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 +788 -690
- package/README.zh-CN.md +712 -631
- package/dist/agents.d.ts +5 -3
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +19 -8
- package/dist/agents.js.map +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/capabilities.js +2 -2
- package/dist/capabilities.js.map +1 -1
- package/dist/host-hooks.d.ts +13 -2
- package/dist/host-hooks.d.ts.map +1 -1
- package/dist/host-hooks.js +18 -5
- package/dist/host-hooks.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -14
- package/dist/index.js.map +1 -1
- package/dist/prompts/lead.d.ts +1 -1
- package/dist/prompts/lead.d.ts.map +1 -1
- package/dist/prompts/lead.js +92 -25
- package/dist/prompts/lead.js.map +1 -1
- package/dist/prompts/shared.d.ts +2 -2
- package/dist/prompts/shared.d.ts.map +1 -1
- package/dist/prompts/shared.js +62 -10
- package/dist/prompts/shared.js.map +1 -1
- package/dist/prompts/specialists.d.ts +2 -2
- package/dist/prompts/specialists.d.ts.map +1 -1
- package/dist/prompts/specialists.js +43 -10
- package/dist/prompts/specialists.js.map +1 -1
- package/dist/task-offload.d.ts +67 -0
- package/dist/task-offload.d.ts.map +1 -0
- package/dist/task-offload.js +123 -0
- package/dist/task-offload.js.map +1 -0
- package/dist/tm/args-schema.d.ts +4 -0
- package/dist/tm/args-schema.d.ts.map +1 -1
- package/dist/tm/args-schema.js +36 -3
- package/dist/tm/args-schema.js.map +1 -1
- package/dist/tm/board.d.ts +113 -0
- package/dist/tm/board.d.ts.map +1 -0
- package/dist/tm/board.js +275 -0
- package/dist/tm/board.js.map +1 -0
- package/dist/tm/browser.d.ts +325 -6
- package/dist/tm/browser.d.ts.map +1 -1
- package/dist/tm/browser.js +1329 -135
- package/dist/tm/browser.js.map +1 -1
- package/dist/tm/config.d.ts +36 -25
- package/dist/tm/config.d.ts.map +1 -1
- package/dist/tm/config.js +29 -7
- package/dist/tm/config.js.map +1 -1
- package/dist/tm/dispatch.d.ts +86 -53
- package/dist/tm/dispatch.d.ts.map +1 -1
- package/dist/tm/dispatch.js +254 -251
- package/dist/tm/dispatch.js.map +1 -1
- package/dist/tm/dupe-guard.js +1 -1
- package/dist/tm/dupe-guard.js.map +1 -1
- package/dist/tm/egress.d.ts +44 -0
- package/dist/tm/egress.d.ts.map +1 -0
- package/dist/tm/egress.js +191 -0
- package/dist/tm/egress.js.map +1 -0
- package/dist/tm/guard.js +1 -1
- package/dist/tm/guard.js.map +1 -1
- package/dist/tm/index.d.ts +28 -2
- package/dist/tm/index.d.ts.map +1 -1
- package/dist/tm/index.js +198 -19
- package/dist/tm/index.js.map +1 -1
- package/dist/tm/perm-ask.d.ts +47 -5
- package/dist/tm/perm-ask.d.ts.map +1 -1
- package/dist/tm/perm-ask.js +98 -7
- package/dist/tm/perm-ask.js.map +1 -1
- package/dist/tm/pipelines.d.ts.map +1 -1
- package/dist/tm/pipelines.js +24 -2
- package/dist/tm/pipelines.js.map +1 -1
- package/dist/tm/ptc/tool.d.ts.map +1 -1
- package/dist/tm/ptc/tool.js +2 -4
- package/dist/tm/ptc/tool.js.map +1 -1
- package/dist/tm/pty.d.ts.map +1 -1
- package/dist/tm/pty.js +6 -3
- package/dist/tm/pty.js.map +1 -1
- package/dist/tm/search.d.ts +5 -0
- package/dist/tm/search.d.ts.map +1 -1
- package/dist/tm/search.js +19 -17
- package/dist/tm/search.js.map +1 -1
- package/dist/tm/stats.d.ts +16 -0
- package/dist/tm/stats.d.ts.map +1 -1
- package/dist/tm/stats.js +34 -4
- package/dist/tm/stats.js.map +1 -1
- package/dist/tm/webfetch.d.ts +52 -0
- package/dist/tm/webfetch.d.ts.map +1 -1
- package/dist/tm/webfetch.js +124 -23
- package/dist/tm/webfetch.js.map +1 -1
- package/dist/tool-coerce.d.ts +24 -0
- package/dist/tool-coerce.d.ts.map +1 -0
- package/dist/tool-coerce.js +63 -0
- package/dist/tool-coerce.js.map +1 -0
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/installation.md +69 -2
- package/package.json +61 -61
package/README.md
CHANGED
|
@@ -1,690 +1,788 @@
|
|
|
1
|
-
# OpenCode TeamMode
|
|
2
|
-
|
|
3
|
-
**[English](./README.md)** | **[中文](./README.zh-CN.md)**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@te-river/opencode-team-mode)
|
|
6
|
-
[](https://www.npmjs.com/package/@te-river/opencode-team-mode)
|
|
7
|
-
[](./LICENSE)
|
|
8
|
-
|
|
9
|
-
> 🤝 **Your OpenCode just hired a team.**
|
|
10
|
-
>
|
|
11
|
-
> Six specialized agents — a Lead, an Architect, an Implementer, a Reviewer, a Tester and a Researcher — with governed tools, structured handoffs, and a plan-first approval gate. One plugin, zero config files to copy.
|
|
12
|
-
|
|
13
|
-
> 💡 **Best for medium-to-large projects.** The governance layer (approval gate, context offload, tool allowlists) is an asset once a codebase has real surface area — and mostly overhead on tiny scripts and one-off questions. Use it where the work is.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## TL;DR — skip the docs
|
|
18
|
-
|
|
19
|
-
> **The lazy path:** paste this to any coding agent and let it do the work:
|
|
20
|
-
>
|
|
21
|
-
> ```text
|
|
22
|
-
> Install the OpenCode plugin @te-river/opencode-team-mode following
|
|
23
|
-
> https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation.md
|
|
24
|
-
> Then verify the install using the checks in that guide.
|
|
25
|
-
> ```
|
|
26
|
-
>
|
|
27
|
-
> **The one command to remember afterwards:** `/team-run <task>` — the Team Lead
|
|
28
|
-
> plans it, shows you the plan, waits for your approval, then runs the whole team.
|
|
29
|
-
|
|
30
|
-
Everything else below is detail. When you're ready for it, here's the map:
|
|
31
|
-
|
|
32
|
-
**[Why](#-why-teammode) · [The team](#-the-team) · [Install](#-install) · [Usage](#-usage) · [Tools & security](#-governed-tools--security) · [Search](#-web-search-that-actually-works-in-china) · [Config](#️-configuration) · [How it works](#-how-the-team-works) · [FAQ](#-faq) · [Uninstall](#-uninstall)**
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## 🤔 Why TeamMode?
|
|
37
|
-
|
|
38
|
-
Because a single agent doing everything is how you get: a context window stuffed
|
|
39
|
-
with 5000-line file dumps, twenty round-trips to `bash` for what one script could
|
|
40
|
-
do, sub-agents that silently read `.env`, and web "research" that is really just
|
|
41
|
-
the model's imagination.
|
|
42
|
-
|
|
43
|
-
TeamMode's answer to each:
|
|
44
|
-
|
|
45
|
-
| Pain | TeamMode's answer |
|
|
46
|
-
|---|---|
|
|
47
|
-
| 🔥 **Context flooding** | Every governed tool output over its content-class offload threshold (prose 4000 / data 2000 tokens, CJK-aware) is offloaded to a local run store and replaced by an 80-token preview + an HMAC handle. The agent pages through what it needs — the window never drowns. |
|
|
48
|
-
| 🐌 **Round-trip overhead** | `tm_ptc_run`: the agent writes ONE program that makes N governed calls in a single turn. Zero LLM round-trips during the run. |
|
|
49
|
-
| 🕳️ **Silent side effects** | R6/R2 approval gate: env-var reads and dangerous ops route through OpenCode's official confirmation dialog, auto-rejected after 1 unanswered minute (default). The plugin never approves on its own — it only ever rejects. |
|
|
50
|
-
| 🌫️ **Hallucinated research** | Web access is a two-role grant with an allowlisted, governed tool chain. A fact that couldn't be fetched is reported as a gap — never fabricated. |
|
|
51
|
-
| 🧭 **Walls of text** | Replies are steered into the shape the host renders fastest: a markdown table for per-file / per-case / per-finding results, fenced code for diffs and configs, a browser screenshot attached as an inline image only when you ask for one. The host does not draw mermaid, so no agent pretends it does. |
|
|
52
|
-
| 🎯 **Goal drift** | The lead opens with `GOAL:` in your own words plus checkable `ACCEPTANCE:` criteria, and the run does not end while a criterion lacks evidence — the only legitimate stops are named (blocked on you, or provably unachievable). When a round settles with items still open on the host's todo list, `tm_join` says 目标未达成 and lists them, and the goal is carried through context compaction so a summarized transcript cannot redefine it. |
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
the
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- **
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
`tm_bash`
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
`
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
`
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
`
|
|
392
|
-
(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
[
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
`
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
1
|
+
# OpenCode TeamMode
|
|
2
|
+
|
|
3
|
+
**[English](./README.md)** | **[中文](./README.zh-CN.md)**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@te-river/opencode-team-mode)
|
|
6
|
+
[](https://www.npmjs.com/package/@te-river/opencode-team-mode)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
9
|
+
> 🤝 **Your OpenCode just hired a team.**
|
|
10
|
+
>
|
|
11
|
+
> Six specialized agents — a Lead, an Architect, an Implementer, a Reviewer, a Tester and a Researcher — with governed tools, structured handoffs, and a plan-first approval gate. One plugin, zero config files to copy.
|
|
12
|
+
|
|
13
|
+
> 💡 **Best for medium-to-large projects.** The governance layer (approval gate, context offload, tool allowlists) is an asset once a codebase has real surface area — and mostly overhead on tiny scripts and one-off questions. Use it where the work is.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## TL;DR — skip the docs
|
|
18
|
+
|
|
19
|
+
> **The lazy path:** paste this to any coding agent and let it do the work:
|
|
20
|
+
>
|
|
21
|
+
> ```text
|
|
22
|
+
> Install the OpenCode plugin @te-river/opencode-team-mode following
|
|
23
|
+
> https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation.md
|
|
24
|
+
> Then verify the install using the checks in that guide.
|
|
25
|
+
> ```
|
|
26
|
+
>
|
|
27
|
+
> **The one command to remember afterwards:** `/team-run <task>` — the Team Lead
|
|
28
|
+
> plans it, shows you the plan, waits for your approval, then runs the whole team.
|
|
29
|
+
|
|
30
|
+
Everything else below is detail. When you're ready for it, here's the map:
|
|
31
|
+
|
|
32
|
+
**[Why](#-why-teammode) · [The team](#-the-team) · [Install](#-install) · [Usage](#-usage) · [Tools & security](#-governed-tools--security) · [Search](#-web-search-that-actually-works-in-china) · [Config](#️-configuration) · [How it works](#-how-the-team-works) · [FAQ](#-faq) · [Uninstall](#-uninstall)**
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🤔 Why TeamMode?
|
|
37
|
+
|
|
38
|
+
Because a single agent doing everything is how you get: a context window stuffed
|
|
39
|
+
with 5000-line file dumps, twenty round-trips to `bash` for what one script could
|
|
40
|
+
do, sub-agents that silently read `.env`, and web "research" that is really just
|
|
41
|
+
the model's imagination.
|
|
42
|
+
|
|
43
|
+
TeamMode's answer to each:
|
|
44
|
+
|
|
45
|
+
| Pain | TeamMode's answer |
|
|
46
|
+
|---|---|
|
|
47
|
+
| 🔥 **Context flooding** | Every governed tool output over its content-class offload threshold (prose 4000 / data 2000 tokens, CJK-aware) is offloaded to a local run store and replaced by an 80-token preview + an HMAC handle. The agent pages through what it needs — the window never drowns. |
|
|
48
|
+
| 🐌 **Round-trip overhead** | `tm_ptc_run`: the agent writes ONE program that makes N governed calls in a single turn. Zero LLM round-trips during the run. |
|
|
49
|
+
| 🕳️ **Silent side effects** | R6/R2 approval gate: env-var reads and dangerous ops route through OpenCode's official confirmation dialog, auto-rejected after 1 unanswered minute (default). The plugin never approves on its own — it only ever rejects. |
|
|
50
|
+
| 🌫️ **Hallucinated research** | Web access is a two-role grant with an allowlisted, governed tool chain. A fact that couldn't be fetched is reported as a gap — never fabricated. |
|
|
51
|
+
| 🧭 **Walls of text** | Replies are steered into the shape the host renders fastest: a markdown table for per-file / per-case / per-finding results, fenced code for diffs and configs, a browser screenshot attached as an inline image only when you ask for one. The host does not draw mermaid, so no agent pretends it does. |
|
|
52
|
+
| 🎯 **Goal drift** | The lead opens with `GOAL:` in your own words plus checkable `ACCEPTANCE:` criteria, and the run does not end while a criterion lacks evidence — the only legitimate stops are named (blocked on you, or provably unachievable). When a round settles with items still open on the host's todo list, `tm_join` says 目标未达成 and lists them, and the goal is carried through context compaction so a summarized transcript cannot redefine it. |
|
|
53
|
+
|
|
54
|
+
| 🗣️ **Replies in a language you never chose** | The governed tools answer in Chinese, and an agent left to its own devices mirrors that straight back at you. Every role now carries a reply-language rule: your own language wins, and a Chinese string is quoted verbatim only where it IS the evidence (a close verdict, a refusal line) — translating a verdict is how an unchecked claim starts looking checked. |
|
|
55
|
+
| ⏱️ **Rounds spent for the sake of looking careful** | 效率至上 is written into the lead and all five specialists: one wide call instead of three narrow ones, independent calls in the same round, ≥3 probes collapsed into one `tm_ptc_run`, no re-running a check to watch it pass again — with the boundary stated too: efficiency never buys its way out of the evidence rule, because an unverified "done" costs you the round *and* the bug. |
|
|
56
|
+
|
|
57
|
+
And the workflow discipline underneath: deterministic routing, a ≤30-line plan
|
|
58
|
+
you approve before ≥2 dispatches execute, structured `STATUS/CHANGES/FINDINGS/
|
|
59
|
+
EVIDENCE/HANDOFF` replies between agents, and static verification (build /
|
|
60
|
+
typecheck / tests) instead of vibes.
|
|
61
|
+
|
|
62
|
+
That discipline is also why the recommendation is **medium-to-large
|
|
63
|
+
projects**: on a two-file script the team simply has less to govern.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 👥 The team
|
|
68
|
+
|
|
69
|
+
| Agent | Role | When to use |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| 🎯 **Team Lead** (`@team`) | Orchestrator | Complex tasks that need planning + multi-step execution |
|
|
72
|
+
| 🏗️ **Architect** | System designer | Design docs, module structure, API contracts |
|
|
73
|
+
| 💻 **Implementer** | Code writer | Building features, writing production code |
|
|
74
|
+
| 🔍 **Reviewer** | Dimension-focused auditor | Single-dimension review by default; 3 in parallel only for high-risk changes |
|
|
75
|
+
| 🧪 **Tester** | Test engineer | Tests with real edge cases; static verification (build / typecheck / lint); governed UI verification via `tm_browser` |
|
|
76
|
+
| 🔎 **Researcher** | Knowledge finder | Local repo first, then the web — one of the two network roles (with the Lead) |
|
|
77
|
+
|
|
78
|
+
Out of the box, **Team is your default agent** — new chats open straight into the
|
|
79
|
+
orchestrator (opt-out in [Configuration](#-configuration)).
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 📦 Install
|
|
84
|
+
|
|
85
|
+
### Option 1 — Let your agent do it (recommended)
|
|
86
|
+
|
|
87
|
+
Copy this into any coding agent — it will edit your config, restart-remind you, and verify:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
Install the OpenCode plugin @te-river/opencode-team-mode following
|
|
91
|
+
https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation.md
|
|
92
|
+
(If that URL is unreachable — common on mainland-China networks — retry with
|
|
93
|
+
the mirror prefix: https://ghproxy.net/ + the same path.)
|
|
94
|
+
Then verify the install using the checks in that guide.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
(The guide is the complete manual procedure — config file locations, plugin
|
|
98
|
+
entry, restart, verification, update and uninstall. Your agent reads it and
|
|
99
|
+
executes it faithfully; there is nothing else it needs.)
|
|
100
|
+
|
|
101
|
+
### Option 2 — One-line script
|
|
102
|
+
|
|
103
|
+
macOS / Linux (bash):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
curl -fsSL https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.sh | bash
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Windows (PowerShell):
|
|
110
|
+
|
|
111
|
+
```powershell
|
|
112
|
+
irm https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.ps1 | iex
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Option 3 — Manual
|
|
116
|
+
|
|
117
|
+
Add the plugin to your `opencode.jsonc`:
|
|
118
|
+
|
|
119
|
+
```jsonc
|
|
120
|
+
{
|
|
121
|
+
"$schema": "https://opencode.ai/config.json",
|
|
122
|
+
"plugin": [
|
|
123
|
+
"@te-river/opencode-team-mode@latest"
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
OpenCode installs the plugin on next startup.
|
|
129
|
+
|
|
130
|
+
### ⚠️ Read this once, save yourself an hour later
|
|
131
|
+
|
|
132
|
+
- **Restart to activate.** After touching `opencode.json`, fully quit and restart OpenCode (Desktop: quit from tray, not just the window).
|
|
133
|
+
- **Plugin updates: re-run the installer.** It is idempotent — a re-run re-patches the config (no-op when present), purges the stale plugin cache, and re-resolves any npm-installed copy. This exists because OpenCode caches plugins by spec string and does NOT re-resolve `@latest` when a new version publishes (upstream limitation). Manual recipe, if you prefer:
|
|
134
|
+
|
|
135
|
+
| OS | Purge command — recursive, covers BOTH cache layouts |
|
|
136
|
+
|---|---|
|
|
137
|
+
| macOS / Linux | `find ~/.cache/opencode/packages -type d -name '*opencode-team-mode*' -prune -exec rm -rf {} +` |
|
|
138
|
+
| Windows (PowerShell) | `foreach ($r in "$HOME\.cache\opencode\packages", "$env:LOCALAPPDATA\opencode\cache\packages") { if (Test-Path $r) { Get-ChildItem $r -Directory -Recurse -Filter '*opencode-team-mode*' -EA SilentlyContinue | Sort-Object { $_.FullName.Length } | Remove-Item -Recurse -Force -EA SilentlyContinue } }` |
|
|
139
|
+
|
|
140
|
+
⚠️ OpenCode loads the plugin from `~/.cache/opencode/packages/` — possibly nested inside the scoped `@te-river/` directory — **not** from `~/.config/opencode/node_modules`, which is why the delete must recurse (a top-level-only `rm -rf` silently misses the scoped copy).
|
|
141
|
+
|
|
142
|
+
If you also npm-installed the plugin into `~/.config/opencode`, its package-lock pins the version — run `npm install @te-river/opencode-team-mode@latest` there too. Full recipe (including an agent-driven update prompt): [installation guide, Updating](./docs/installation.md).
|
|
143
|
+
- **Prerequisites:** [OpenCode](https://opencode.ai) (Desktop or CLI) and Node ≥ 18.
|
|
144
|
+
|
|
145
|
+
### 🖥️ What the installer changes on your machine
|
|
146
|
+
|
|
147
|
+
Three things, all outside this repo — listed because a plugin that edits your
|
|
148
|
+
environment without saying so is not one you can trust.
|
|
149
|
+
|
|
150
|
+
| What | Where it lands | How long it stays |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| A plugin entry in the OpenCode config | `~/.config/opencode/opencode.jsonc` (created if missing; an existing `opencode.json` is **migrated into** the `.jsonc`, the original file left untouched) | until you delete the line |
|
|
153
|
+
| A purged plugin cache | `~/.cache/opencode/packages/*opencode-team-mode*` (including the nested `node_modules` copy that actually runs) | re-downloaded on next start — it is a cache, nothing to restore |
|
|
154
|
+
| **A user-level environment variable** | `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true` | **Windows: `setx` writes it into your user profile — it survives reboot and is visible to EVERY program you start afterwards, not just OpenCode.** macOS `launchctl setenv` / Linux `systemctl --user set-environment`: this login session only (re-run the installer after a reboot) |
|
|
155
|
+
|
|
156
|
+
Why that third one is there: `task { background: true }` is the only sub-agent
|
|
157
|
+
the OpenCode interface can **show** you — a card linking to the live child
|
|
158
|
+
session, which you can stop. The host turns it on through a flag on **its own
|
|
159
|
+
process**, and a plugin cannot set flags in the process that loads it, so the
|
|
160
|
+
flag has to come from the environment. Without it nothing breaks: `task` simply
|
|
161
|
+
blocks the lead and its card stays non-background.
|
|
162
|
+
|
|
163
|
+
Undo it:
|
|
164
|
+
|
|
165
|
+
```powershell
|
|
166
|
+
# Windows — remove it from the user profile
|
|
167
|
+
[Environment]::SetEnvironmentVariable("OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS", $null, "User")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
launchctl unsetenv OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # macOS
|
|
172
|
+
systemctl --user unset-environment OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # Linux
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Or skip it at install time, and the installer touches only the two files above:
|
|
176
|
+
|
|
177
|
+
```powershell
|
|
178
|
+
.\install.ps1 -NoBackgroundSubagents # or $env:TEAMMODE_SKIP_BACKGROUND_SUBAGENTS="1"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
TEAMMODE_SKIP_BACKGROUND_SUBAGENTS=1 bash install.sh
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Either way the installer prints what it changed, and reads the value back
|
|
186
|
+
instead of trusting its own exit code.
|
|
187
|
+
|
|
188
|
+
### Verify
|
|
189
|
+
|
|
190
|
+
Restart, open the agent picker, and look for **team, architect, implementer,
|
|
191
|
+
reviewer, tester, researcher**. That's it — the team is hired.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 📖 Usage
|
|
196
|
+
|
|
197
|
+
### Slash commands
|
|
198
|
+
|
|
199
|
+
| Command | Agent | Description |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `/team-plan <task>` | Architect | Implementation plan with architecture, file manifest, task breakdown |
|
|
202
|
+
| `/team-implement <task>` | Implementer | Production code for a feature or task |
|
|
203
|
+
| `/team-review [scope]` | Reviewer | Audit for bugs, security issues, quality problems |
|
|
204
|
+
| `/team-test [scope]` | Tester | Comprehensive tests with edge-case coverage |
|
|
205
|
+
| `/team-research <topic>` | Researcher | Local repo first; web via the governed tools |
|
|
206
|
+
| `/team-run <task>` | Team Lead | **The full workflow** — plan → approval → orchestration → verification |
|
|
207
|
+
|
|
208
|
+
Or `@`-mention agents directly: `@team`, `@architect`, `@implementer`,
|
|
209
|
+
`@reviewer`, `@tester`, `@researcher`.
|
|
210
|
+
|
|
211
|
+
### What a run feels like
|
|
212
|
+
|
|
213
|
+
Team is the default agent out of the box, so you just type into a fresh chat:
|
|
214
|
+
|
|
215
|
+
> **You:** Add token-bucket rate limiting to our Express API — 100 requests per minute per user, return 429 when exceeded. Don't touch anything under `src/legacy/`.
|
|
216
|
+
|
|
217
|
+
```text
|
|
218
|
+
team Route: product behavior change → implementer → tester → reviewer
|
|
219
|
+
(3 dispatches → approval gate applies)
|
|
220
|
+
|
|
221
|
+
PLAN
|
|
222
|
+
Goal: token-bucket limiter, 100 req/min/user, 429 + Retry-After
|
|
223
|
+
Scope: src/middleware/rateLimit.ts (new), src/app.ts (+3 lines)
|
|
224
|
+
Pipeline: implementer → tester → reviewer (correctness)
|
|
225
|
+
Assumption: in-memory bucket, not Redis — say the word to change
|
|
226
|
+
Boundary: src/legacy/** untouched
|
|
227
|
+
Approve to proceed?
|
|
228
|
+
|
|
229
|
+
you approved, go
|
|
230
|
+
|
|
231
|
+
team ▸ @implementer — STATUS: done
|
|
232
|
+
CHANGES: src/middleware/rateLimit.ts (new) · src/app.ts (+3)
|
|
233
|
+
EVIDENCE: tsc clean
|
|
234
|
+
|
|
235
|
+
▸ @tester — STATUS: done · VERDICT: pass (14/14)
|
|
236
|
+
FINDINGS: burst edge, window expiry, concurrent refill covered;
|
|
237
|
+
src/legacy/** byte-identical
|
|
238
|
+
|
|
239
|
+
▸ @reviewer — STATUS: done · VERDICT: approve (correctness)
|
|
240
|
+
|
|
241
|
+
team Done. rateLimit.ts (new) · app.ts (+3) · 14 tests green
|
|
242
|
+
review: approve · assumption: in-memory only · src/legacy/ untouched
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
You typed the task and four words. The plan was a routing-table lookup,
|
|
246
|
+
execution waited for your approval, and every handoff between agents traveled
|
|
247
|
+
as a structured skeleton — nothing landed in your repo, nothing was guessed.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 🧰 Governed tools & security
|
|
252
|
+
|
|
253
|
+
Every tool TeamMode adds runs under ONE governance pipeline: outputs above
|
|
254
|
+
the offload threshold never enter the context window — the boundary is
|
|
255
|
+
content-class aware (`TM_OFFLOAD_THRESHOLD_TEXT` = 4000 for prose:
|
|
256
|
+
text/log/markdown; `TM_OFFLOAD_THRESHOLD_DATA` = 2000 for json/csv/code/
|
|
257
|
+
binary; an unknown class falls back to the global `TM_OFFLOAD_THRESHOLD`) —
|
|
258
|
+
and oversized results are offloaded to a run store and replaced by a
|
|
259
|
+
content-aware preview plus an HMAC-signed handle that the agent pages
|
|
260
|
+
through with `tm_fetch` when it genuinely needs the payload.
|
|
261
|
+
|
|
262
|
+
| Tool | What it does | Roles |
|
|
263
|
+
|---|---|---|
|
|
264
|
+
| `tm_read` / `tm_grep` / `tm_bash` / `tm_fetch` | Governed file read / regex search / read-only shell (allowlist) / paged handle retrieval (JSON handles take a `fields` dot-path projection — a deliberately small jq subset like `items[].name`) | all six agents |
|
|
265
|
+
| `tm_memory` | Session + project + global memory store (Markdown + frontmatter): add / search / list / forget / compact | all six agents |
|
|
266
|
+
| `tm_board_write` | **The blackboard's write side**: places ONE new Markdown file at `<board-root>/<session-key>/<task-slug>/NN-<role>-<topic>[-rN].md` and chooses the name itself — a revision is a new round-suffixed file, never an overwrite, and the reply carries the path plus the byte count, never the content. It exists because the board used to need a file tool, and `architect` / `researcher` own none (no `write`, no `edit`, no `bash` even to stamp the session folder), so every oversized deliverable from those roles came back as `BLACKBOARD WRITE FAILED` plus the whole document pasted inline — the reply shape this team mandates was un-followable exactly where it mattered. Scope is enforced rather than asked: segments sanitized, target realpath-verified against the board root (a symlinked task dir is refused), the name always ends in `.md` so no `.env`/rc file can be produced, caps via `TM_BOARD_MAX_CHARS` + a per-session file limit | All six agents |
|
|
267
|
+
| `tm_ptc_run` | Batch orchestration: one program, N governed calls, zero LLM round-trips; web roles also get `tm.search` / `tm.webfetch` inside the program | all six agents |
|
|
268
|
+
| `tm_search` | Multi-engine web search with extracted, deduplicated, RRF-fused hit lists | Lead + Researcher |
|
|
269
|
+
| `tm_webfetch` | Single governed GET of an allowlisted page (search pages auto-extracted). Manual redirects, re-checked per hop, and a refusal names the WHOLE chain (`跳转链: a → b(停在第 2 跳)`) — an allowlisted shortener that bounces off-site used to report only the off-site host, which read as "that site will not fetch" and sent the agent back to retry the entry URL it had just watched fail. A 429/503 carries its own `Retry-After` when the server sends delta-seconds (an HTTP-date is deliberately not laundered into a countdown), so "come back later" never looks like "no content here". The page GET also asks for Markdown first (`Accept: text/markdown,…`) — measured on `learn.microsoft.com`: 60,778 B of HTML becomes 11,449 B of Markdown, and every other host tried returns the same document either way, so the preference is free where it is ignored | Lead + Researcher |
|
|
270
|
+
| `tm_join` | **Sub-agent collection** — there is no plugin-side dispatcher any more (`tm_dispatch` is removed: a child a plugin creates is a session the user can neither open nor stop from the interface). Delegation goes through the host's own `task` / `task { background: true }`, and `tm_join` is the read side: a status snapshot, a bounded `waitMs`, `cancel:true` to abort, and `claimNamedChild` so `tm_join { ids: ["ses_…"] }` pulls one child's WHOLE reply back through the offload pipeline (handle + ≤80-token preview) instead of kilotokens inline. It also rebuilds its registry from the host session tree after a restart, so leftover children are 接管 rather than lost | Lead only |
|
|
271
|
+
| `tm_pty` | **Non-blocking command execution** on the host's own terminal sessions (`start`/`status`/`list`/`kill`) — independent builds and test suites overlap instead of queueing behind one 120 s bash call. Captures no output (the command tees its own log; read it with `tm_read`), and every start passes the R6 classifier, the R2 danger-face globs **and** the official confirmation dialog before a process exists | Lead only |
|
|
272
|
+
| `tm_stats` | **The plugin reads its own trajectory back**: tokens kept out of the context window by offloading (net of the preview that arrived), seconds saved by dispatch overlap (serial cost minus the wall window the children actually used), PTC internals, governance counts (blocked subresources, refused `tm_pty` starts, clamped bash timeouts, cache hits, redactions) — plus the **host capability matrix** (`已验证/存在未用/待观察/缺失/需人眼` per host surface). Read-only over files this plugin wrote; run it first after an OpenCode upgrade. `{ recent: 20 }` appends a call-by-call recap — handle + payload path for every offloaded result, which is how you see what a governed tool actually returned (the host gives plugin tools no expandable card) | All agents |
|
|
273
|
+
| `tm_browser` | Interactive browser session (**your default browser**): 18 Playwright verbs (snapshot-first `take_snapshot` → uid-addressed `click`/`fill`/`drag`/…, **including multi-tab `new_page` / `close_page`** so you can hold two pages at once) + 5 legacy compat verbs (open/navigate/read/screenshot/close); Playwright engine needs Node ≥ 20, below that (or on any import failure) it auto-degrades to the legacy CDP engine. It drives YOUR default browser channel (an Edge Beta default opens Edge Beta), stays headful unless the operator sets `TM_BROWSER_HEADLESS`, loads a page's own images/CSS/JS via the `same-site` subresource policy, and `take_screenshot { image:true }` attaches a JPEG so the model can actually see the screen. **One browser per agent**: `open` returns an id (`b1`) and every reply is tagged with it — that window, its uid numbering and its dialog-approved hosts belong to YOUR session; another agent's id is refused with the owner named (an id is a name, not a key), and `close { id:"all" }` closes only your own. `click` reports what the PAGE did, not merely that a mouse event was sent: it reads the target's observable state before and after (`aria-expanded`, URL, DOM node count) and answers `已点击 … · aria-expanded: false → true`, retries once if the page had not finished loading — the measured cause of a click that lands on a node with no handler — and says 页面没有任何可观测变化 rather than implying success. `close` will not say 已确认关闭 until the browser's OS process is gone — it waits on the pid, terminates it once if it lingers, and prints the pid either way, because a dropped connection is not a closed browser; when no pid could be resolved it says 进程未核验 rather than borrowing that sentence. A browser this process launched but could not reap is recorded in a per-workspace ledger (pid, owner pid, executable) and reclaimed by the next boot — only entries whose owner process is dead *and* whose pid still is that executable, terminated as a whole tree (`taskkill /T` on Windows), never another window's live tab. **A blank page now explains itself**: `same-site` cannot know that a site's own bundle lives on a brand-unrelated CDN (Baidu serves its scripts from `bdimg.com`), so when a page comes back with `0 个可寻址节点` while a script host was blocked, the reply says the blankness is **our gate**, names the host, and offers `allow_host { host }` — one official dialog for one bare domain, for your browser only, for this session, nothing written to config (re-navigate afterwards, the gate decides per request). A page that is really a human-verification wall (百度安全验证 / Cloudflare / access denied) is reported as a wall, because the move there is another source, not another retry | Lead + Researcher + Tester (UI verification) |
|
|
274
|
+
|
|
275
|
+
> **Fixed tool priority ladder (every task): ① the user's own MCP/plugin
|
|
276
|
+
> tools → ② TeamMode governed tools (`tm_*`) → ③ the model's own reasoning.**
|
|
277
|
+
> It doubles as the fallback chain: when a tool errors (no browser on this
|
|
278
|
+
> host, blocked host), the agent says so and drops to the next rung — and
|
|
279
|
+
> rung ③ is where a missing capability gets reported, never fabricated.
|
|
280
|
+
> One stated exception: on the **web** channel `tm_search` / `tm_webfetch` /
|
|
281
|
+
> `tm_browser` come first, because that path is the only one carrying the
|
|
282
|
+
> domain allowlist, the per-request confirmation dialog and the R6 red lines.
|
|
283
|
+
|
|
284
|
+
> **What the host UI cannot show you.** OpenCode renders a *plugin* tool call
|
|
285
|
+
> as a one-line card with no expandable body — its tool-renderer registry
|
|
286
|
+
> holds only the built-in tool names, and an extension cannot add to it. The
|
|
287
|
+
> governed output still exists: anything over the offload boundary is written
|
|
288
|
+
> to disk as a handle, and `tm_stats { recent: 20 }` prints the call-by-call
|
|
289
|
+
> recap with those handles and file paths, which you can open. Ask your agent
|
|
290
|
+
> for it — "what did that tool actually return?"
|
|
291
|
+
|
|
292
|
+
> **Delegation goes through the host's `task` — one channel, two shapes.**
|
|
293
|
+
> OpenCode's own `task` tool is the only sub-agent the interface can SHOW you:
|
|
294
|
+
> its card links to the live child session, and the user can stop it. Add
|
|
295
|
+
> `background: true` and it is also non-blocking — the host wakes your lead when
|
|
296
|
+
> the child finishes. That flag is experimental, so you turn it on yourself:
|
|
297
|
+
>
|
|
298
|
+
> ```
|
|
299
|
+
> OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
|
|
300
|
+
> ```
|
|
301
|
+
>
|
|
302
|
+
> (set it for the app process — `setx` on Windows, or launch from a shell that
|
|
303
|
+
> exports it — then restart OpenCode; the installers do it for you, and that is
|
|
304
|
+
> a **persistent user-scope write**, so see
|
|
305
|
+
> [What the installer changes on your machine](#-what-the-installer-changes-on-your-machine)
|
|
306
|
+
> for the exact value, its lifetime and the undo command). TeamMode
|
|
307
|
+
> then keeps that channel inside your token budget: the injected full reply is
|
|
308
|
+
> replaced by a preview plus a pointer, and nothing is copied to disk
|
|
309
|
+
> (`TM_TASK_OFFLOAD=off` restores the host's verbatim text). Cost of the host
|
|
310
|
+
> path, stated plainly: each finished background task wakes the lead and costs a
|
|
311
|
+
> turn. `tm_join` is the read side that stays — it pulls a named child's whole
|
|
312
|
+
> reply back through the offload pipeline, aborts a runaway, and rebuilds its
|
|
313
|
+
> registry from the host session tree after a restart.
|
|
314
|
+
>
|
|
315
|
+
> There is deliberately **no plugin-side dispatcher**: an earlier `tm_dispatch`
|
|
316
|
+
> created children the user could neither open from a card nor stop from the
|
|
317
|
+
> interface, which is a worse trade than the batching it bought. Remove it,
|
|
318
|
+
> and nothing breaks — the host's `task` was always the visible path.
|
|
319
|
+
|
|
320
|
+
All governed tools are **parallel-safe**: the host may run a batch of
|
|
321
|
+
`tm_search` / `tm_webfetch` / `tm_fetch` calls concurrently — each call gets
|
|
322
|
+
its own step id and its own payload, and nothing cross-contaminates
|
|
323
|
+
(proven by the parallel test suite).
|
|
324
|
+
|
|
325
|
+
### Context governance: offload, handles, previews
|
|
326
|
+
|
|
327
|
+
Large tool outputs are context cost's main driver — every step re-sends the
|
|
328
|
+
whole window. So results above the content-class offload boundary (prose →
|
|
329
|
+
`TM_OFFLOAD_THRESHOLD_TEXT`, structured data → `TM_OFFLOAD_THRESHOLD_DATA`,
|
|
330
|
+
unknown → global `TM_OFFLOAD_THRESHOLD`) are written to a local run store
|
|
331
|
+
(`<repo>/.git/opencode-team/`, never your working tree) and replaced by a
|
|
332
|
+
handle with a content-aware preview: JSON keys / CSV header + shape / log
|
|
333
|
+
ERROR×N stats / code signatures / binary metadata, hard-capped at 80 tokens.
|
|
334
|
+
When the agent actually needs the payload, it pages through with `tm_fetch`
|
|
335
|
+
using an HMAC-signed, run-scoped, expiring handle — and on a JSON handle it
|
|
336
|
+
can ask for a `fields` dot-path projection instead (a deliberately small jq
|
|
337
|
+
subset: `items[].name`, `[].stargazers_count`), so a big API dump narrows to
|
|
338
|
+
just the values needed without the raw body ever entering the window.
|
|
339
|
+
`tm_bash` only allows read-only commands (allowlist), and failures come back
|
|
340
|
+
as structured errors instead of raw dumps.
|
|
341
|
+
|
|
342
|
+
### Session + project + global memory (tm_memory)
|
|
343
|
+
|
|
344
|
+
Durable facts — build commands, environment quirks, architecture decisions,
|
|
345
|
+
your conventions — live as human-editable Markdown with frontmatter, in
|
|
346
|
+
THREE tiers:
|
|
347
|
+
|
|
348
|
+
- **`session`**: this conversation's transients only — in-process, TTL-swept
|
|
349
|
+
(`TM_MEMORY_SESSION_TTL_MIN`, default 240 min), invisible to other
|
|
350
|
+
sessions; ephemeral unless `TM_MEMORY_SESSION_PERSIST=1` writes them under
|
|
351
|
+
`memories/sessions/<sid>/`.
|
|
352
|
+
- **`project`** (default): `<repo>/.git/opencode-team/memories/…` — per checkout, git-adjacent. Facts about THIS repo: build commands, environment quirks, architecture decisions.
|
|
353
|
+
- **`global`**: `~/.opencode-team/memories/global/` (override `TM_MEMORY_GLOBAL_DIR`) — **follows you across ALL projects**. User-level conventions: preferred package manager, commit style, tooling habits.
|
|
354
|
+
|
|
355
|
+
Actions: `add` / `search` (deterministic keyword scoring) / `list` / `forget` /
|
|
356
|
+
`compact`; 4000 chars per memory. `search` walks ALL tiers with **session >
|
|
357
|
+
project > global precedence** — project entries get a +2 near-tie weight and a
|
|
358
|
+
same-title higher-layer twin shadows the lower one (it never surfaces).
|
|
359
|
+
Near-duplicates never pile up: an `add` that hits an existing entry in the same
|
|
360
|
+
tier and category (dedup key, or title+keywords Jaccard ≥ 0.6) **folds into
|
|
361
|
+
it** — new content wins, keywords union, the old slug moves to `supersedes:`,
|
|
362
|
+
and the answer says 已合并 (that is normal; don't re-add under a variant title).
|
|
363
|
+
When a tier reaches `TM_MEMORY_MAX_ENTRIES` (200 per scope) the add fails on
|
|
364
|
+
purpose: run `compact` first — it dry-runs the merge plan by default, and
|
|
365
|
+
re-running with `apply:true` performs it after copying every original to a
|
|
366
|
+
timestamped `.compact-backup` tree (the rollback path). Entries older than
|
|
367
|
+
`TM_MEMORY_STALE_DAYS` (30) surface tagged `[stale Nd]` in search. Agents
|
|
368
|
+
are prompted to search before assuming conventions and to save hard-won
|
|
369
|
+
facts for the next conversation.
|
|
370
|
+
|
|
371
|
+
### 🌐 Web search that actually works (in China)
|
|
372
|
+
|
|
373
|
+
`tm_search` is the open-ended-lookup front: **one call, one query, clean
|
|
374
|
+
results**. The engine URL is built for you, fetched through the governed
|
|
375
|
+
pipeline, and collapsed into a numbered title+URL hit list — the agent never
|
|
376
|
+
sees raw SERP chrome.
|
|
377
|
+
|
|
378
|
+
| Engine | Notes |
|
|
379
|
+
|---|---|
|
|
380
|
+
| `auto` (default) | Classifies the query, fans the matching engines out **in parallel** (every route has ≥2 legs), dedupes by host+path and fuses them with weighted RRF into a top-10 list tagged with each hit's source engine(s). Ranking is scaled by real query-token overlap (floor `TM_SEARCH_RELEVANCE_FLOOR`), so a trusted engine's off-topic junk no longer outranks another engine's best hit. Routing: errors / camelCase APIs → `stackoverflow`+`github`+`bing`; dev-ecosystem (releases, frameworks, open source) → `hn`+`github`+`npm`; Chinese → `bing`+`moegirl`+`stackoverflow`+`hn`; other → `bing`+`stackoverflow`+`hn`+`github`. Pin another default via `TM_SEARCH_DEFAULT_ENGINE` |
|
|
381
|
+
| `bing` | cn.bing.com — the only live CN HTML SERP; multi-word CJK queries get their phrase boundary protected (quoted) so markup shuffle can't split the result list |
|
|
382
|
+
| `stackoverflow` | api.stackexchange.com question search (no key, 300/day/IP) → numbered questions with composite snippets; `auto` tracks the quota and swaps in `bing` once spent |
|
|
383
|
+
| `hn` | Hacker News via Algolia API (no key) → story titles + snippets with direct article URLs |
|
|
384
|
+
| `bilibili` | video search |
|
|
385
|
+
| `moegirl` | MediaWiki search API — entry titles + snippets, structured |
|
|
386
|
+
| `npm` | registry search → name@version + description, structured |
|
|
387
|
+
| `github` | repo search API → stars + description, structured; `org:` / `user:` / `stars:` / `language:` qualifiers fold into the query (e.g. `vector db stars:>500 language:rust`) |
|
|
388
|
+
|
|
389
|
+
All seven engines are reachable from mainland China **without API keys**, and
|
|
390
|
+
every one of them sits on the seeded domain allowlist. The previous CN HTML
|
|
391
|
+
SERPs (`sogou` / `so` / `baidu` / `bing-int`) were **removed** — a live
|
|
392
|
+
benchmark (2026-09-14) showed them serving anti-bot shells or 100% empty
|
|
393
|
+
results; they are not even manually selectable. On an empty result,
|
|
394
|
+
the error names the alternative engines instead of leaving the agent stuck.
|
|
395
|
+
Two more channels complete the surface:
|
|
396
|
+
|
|
397
|
+
- `tm_webfetch` — a known URL, one governed GET. Search-engine pages it
|
|
398
|
+
fetches are auto-extracted to hit lists too. JSON endpoints like
|
|
399
|
+
`registry.npmjs.org/<pkg>/latest` pass through untouched.
|
|
400
|
+
- `tm_browser` — JS-rendered pages: **your DEFAULT browser** (Windows
|
|
401
|
+
registry / Linux `xdg-settings`; Chromium-family only — Firefox falls back
|
|
402
|
+
to the Edge/Chrome probe order because CDP is Chromium-proprietary;
|
|
403
|
+
`TM_BROWSER_PATH` overrides), headful by default, isolated temp profile,
|
|
404
|
+
**domain allowlist enforced at the network layer** per request and per
|
|
405
|
+
redirect hop. The action surface is chrome-devtools-mcp aligned: **16
|
|
406
|
+
Playwright verbs** (`navigate_page` · `take_snapshot` · `click` · `fill` ·
|
|
407
|
+
`hover` · `drag` · `press_key` · `select_page` · `upload_file` · `wait_for`
|
|
408
|
+
· `evaluate_script` · `list_console_messages` · `list_network_requests` ·
|
|
409
|
+
`list_pages` · `take_screenshot` · `handle_dialog`) plus 5 legacy compat
|
|
410
|
+
verbs (`open` / `navigate` / `read` / `screenshot` / `close`).
|
|
411
|
+
Snapshot-first: `take_snapshot` returns the aria snapshot with injected
|
|
412
|
+
`[uid=eN]` tokens, follow-up actions address nodes by uid instead of
|
|
413
|
+
guessed locators; snapshots are hard-capped by
|
|
414
|
+
`TM_BROWSER_SNAPSHOT_MAX_TOKENS` (default 1200).
|
|
415
|
+
**Engine split:** the primary engine is `playwright-core` (an optional
|
|
416
|
+
dependency — needs **Node ≥ 20**; on older Node, or if the import fails,
|
|
417
|
+
the session auto-degrades per instance to the zero-dep `cdp-legacy`
|
|
418
|
+
engine, which keeps the core verbs only; pin either via
|
|
419
|
+
`TM_BROWSER_ENGINE=playwright|cdp-legacy`). No browser download is ever
|
|
420
|
+
involved — Playwright launches YOUR installed browser by path, so
|
|
421
|
+
`npx playwright install` is not part of the user flow (the dependency
|
|
422
|
+
itself resolves at npm install/publish time). Isolated temp profile by
|
|
423
|
+
default: persistent logins only if you explicitly set
|
|
424
|
+
`TM_BROWSER_USER_DATA_DIR`. No cookies by design — the agent opens a blank
|
|
425
|
+
profile, which is also why a risk-scored site (Baidu) may hand it a
|
|
426
|
+
verification wall your own window walks past. Want it logged in: point the
|
|
427
|
+
variable at a DEDICATED directory and log in once by hand. The browser's **own** site-permission bubble
|
|
428
|
+
("…wants to access other apps and services on this device") is
|
|
429
|
+
auto-**denied** at launch: that modal is not our confirmation channel, it has
|
|
430
|
+
no timeout, and on a machine left running unattended it would hang the page
|
|
431
|
+
indefinitely. Nothing is ever auto-allowed — a page that truly needs such a
|
|
432
|
+
permission fails visibly at that feature instead of invisibly at a dialog. A
|
|
433
|
+
window an agent forgets is now **reported**, not merely reaped: `open` states
|
|
434
|
+
the close duty in its own reply (with the real idle seconds), the reply
|
|
435
|
+
contract requires the tool's close verdict in `EVIDENCE`, and `tm_join` tells
|
|
436
|
+
the lead `⚠ N 个浏览器还开着` when a sub-agent settled while still holding one
|
|
437
|
+
— so you are never the only one who notices.
|
|
438
|
+
|
|
439
|
+
When a fetch still returns **403 after the real-Chrome headers**, the error
|
|
440
|
+
is a DIRECTIVE: the gate is JS-challenge / TLS-fingerprint based and only a
|
|
441
|
+
real browser passes — the agent is told to call `tm_browser`
|
|
442
|
+
(`action:"open"` → `action:"read"`) for that URL. Search hit lists also
|
|
443
|
+
filter known noise: engine-internal wrappers (`so.com/link?`, `ai.so.com`)
|
|
444
|
+
and same-name-different-site domains (`maimai.cn` 脉脉 vs the maimai DX
|
|
445
|
+
game) never ride along — extend the hit blacklist with `TM_HIT_BLACKLIST`.
|
|
446
|
+
|
|
447
|
+
Seeded allowlist (all three web tools; 23 hosts — baidu/moegirl/bilibili are
|
|
448
|
+
PARENT domains, so every sibling subdomain — baike.baidu.com,
|
|
449
|
+
mzh.moegirl.org.cn, space.bilibili.com — is covered):
|
|
450
|
+
`baidu.com`, `moegirl.org.cn`, `bilibili.com`, `www.sogou.com`, `www.so.com`,
|
|
451
|
+
`cn.bing.com`, `www.bing.com`, `zhihu.com`, `juejin.cn`, `csdn.net`,
|
|
452
|
+
`cnblogs.com`, `gitee.com`, `github.com`, `api.github.com`,
|
|
453
|
+
`raw.githubusercontent.com`, `gist.githubusercontent.com`, `ghproxy.net`
|
|
454
|
+
(mainland mirror for github raw), `stackoverflow.com`, `api.stackexchange.com`
|
|
455
|
+
+ `hn.algolia.com` (the two JSON search engines), `npmjs.org`, `pypi.org`,
|
|
456
|
+
`learn.microsoft.com` — extend via
|
|
457
|
+
`TM_WEBFETCH_ALLOWED_DOMAINS` (`"*"` opens every host; a custom list REPLACES
|
|
458
|
+
the seed, so keep the engine hosts or `tm_search` loses its targets). Architect /
|
|
459
|
+
implementer / reviewer have NO network grant — web questions come back as a
|
|
460
|
+
reported gap, never simulated. The tester carries `tm_browser` ONLY, for
|
|
461
|
+
governed UI verification of the project (local dev servers, preview routes);
|
|
462
|
+
open web fetching stays with the two network roles.
|
|
463
|
+
|
|
464
|
+
**Out-of-allowlist targets are a gate, not a wall.** When a fetch / search /
|
|
465
|
+
browser-open points at a host outside the allowlist, the tool hands the URL
|
|
466
|
+
to OpenCode's **official confirmation dialog** — you decide, once per
|
|
467
|
+
target (an unanswered dialog is auto-rejected on the usual 1-minute timer,
|
|
468
|
+
and the plugin still never self-allows). Every dialog also fires a
|
|
469
|
+
**system toast notification**, so you know something is waiting even when
|
|
470
|
+
you're not staring at the screen. Env-file URLs and non-http(s) schemes
|
|
471
|
+
remain hard-rejected with no dialog — R6 red lines are never consentable.
|
|
472
|
+
|
|
473
|
+
### Security: the R6 + R2 approval gate
|
|
474
|
+
|
|
475
|
+
**R6 environment protection.** With TeamMode active, the model cannot read
|
|
476
|
+
environment variables silently. Env reads (`printenv`, `env`, `Get-ChildItem
|
|
477
|
+
env:`, …) and env files (`.env`, shell rc) route through OpenCode's official
|
|
478
|
+
confirmation dialog; unanswered prompts are **auto-rejected after
|
|
479
|
+
`TM_ASK_TIMEOUT_MIN` (default 1 min)**. Env reads no wildcard can express
|
|
480
|
+
(embedded `$VAR` / `${VAR}` / `$env:` inside another command, command
|
|
481
|
+
substitution) and the `tm_*` wrapper channel stay a **hard block** — no dialog
|
|
482
|
+
to slip through. The audit log records only tool name + pattern category +
|
|
483
|
+
verdict — never command text, paths, variable names or values. Verdicts now
|
|
484
|
+
also explain a dialog that cannot be answered anymore: a reply that hits an
|
|
485
|
+
**already-closed** dialog (host 404 — the timer already auto-rejected) audits
|
|
486
|
+
as `already-closed` without degrading the gate, a plugin-side bad reply shape
|
|
487
|
+
audits as `rejected-shape-bug`, and a user reply that arrives *after* the
|
|
488
|
+
auto-reject is recorded as `late-<verdict>` for observability only (the
|
|
489
|
+
rejection stands — the plugin still never self-allows). The 1-minute auto-reject
|
|
490
|
+
floor is tunable via `TM_ASK_TIMEOUT_FLOOR_MIN`; the short default is safe
|
|
491
|
+
because a reply that races the timer audits as benign `already-closed` (host
|
|
492
|
+
404 on a closed dialog — no gate degrade), and the observed ~120 s is the
|
|
493
|
+
host-to-plugin event-bus *delivery* lag, not click-resolution latency.
|
|
494
|
+
|
|
495
|
+
**R2 dangerous operations (same dialog).** Delete, git publish, network
|
|
496
|
+
fetch, package install/publish, process/system, privilege changes — none are
|
|
497
|
+
silently allowed. The normal verification stack (`npm test`, `tsc`,
|
|
498
|
+
`git status`) is NOT gated, so day-to-day work runs uninterrupted.
|
|
499
|
+
|
|
500
|
+
> ⚠️ **When you approve a dialog, pick "once" — not "always".** Verified on
|
|
501
|
+
> the live host, "always" records a far broader rule than the command you
|
|
502
|
+
> saw: approving `Get-ChildItem env:PATH` with "always" stores `Get-ChildItem
|
|
503
|
+
> *`, so every later `Get-ChildItem` runs with no dialog at all. The web
|
|
504
|
+
> channel has the same trap and it is easier to fall into: one "always" on a
|
|
505
|
+
> host lets **every agent session in that project** open it, so the per-agent
|
|
506
|
+
> browser consent never gets asked again. The reply now says which path let a
|
|
507
|
+
> page in (static allowlist / the dialog you just answered / a saved rule that
|
|
508
|
+
> answered in milliseconds), because an agent that cannot tell them apart
|
|
509
|
+
> reports "no dialog" as "that site is allowed".
|
|
510
|
+
|
|
511
|
+
> Deferral to the dialog is per-session: env reads only route to the dialog
|
|
512
|
+
> in sessions running TeamMode's injected agents. In any other session the
|
|
513
|
+
> guard keeps hard-blocking env reads. `headless opencode run` auto-rejects
|
|
514
|
+
> unanswered `ask`s immediately (there is no human to prompt).
|
|
515
|
+
|
|
516
|
+
### Repo hygiene
|
|
517
|
+
|
|
518
|
+
The offload/trajectory/memory stores live under `<repo>/.git/opencode-team/`
|
|
519
|
+
(outside a git repo: the OS temp dir, sharded per workspace as
|
|
520
|
+
`opencode-team/w-<hash>/`, so one project never reads another's payloads) —
|
|
521
|
+
**never your working tree**. Every
|
|
522
|
+
agent is instructed to delete scratch files before reporting done and to keep
|
|
523
|
+
throwaway work in the OS temp dir. A TTL sweeper reclaims old task dirs at
|
|
524
|
+
startup + hourly; the Team Lead never deletes boards itself, so you can audit
|
|
525
|
+
any run.
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## ⚙️ Configuration
|
|
530
|
+
|
|
531
|
+
The plugin injects everything at startup — no agent files to copy.
|
|
532
|
+
|
|
533
|
+
> **Model choice matters.** Every judgment — triage, decomposition, dispatch
|
|
534
|
+
> briefs, synthesis, review verdicts — flows through the Team Lead. A weak
|
|
535
|
+
> model in that seat degrades the whole pipeline no matter how strong the
|
|
536
|
+
> specialists are. Pin your best reasoning model to `team`:
|
|
537
|
+
|
|
538
|
+
```jsonc
|
|
539
|
+
{
|
|
540
|
+
"agent": {
|
|
541
|
+
"team": { "model": "anthropic/claude-opus-4-5" }, // Lead earns your best model
|
|
542
|
+
"implementer": { "model": "anthropic/claude-sonnet-4-6" } // specialists tolerate cheaper
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**Global install** — put the plugin entry in `~/.config/opencode/opencode.jsonc` and every project gets the team.
|
|
548
|
+
|
|
549
|
+
**Keep Team off the default slot:**
|
|
550
|
+
|
|
551
|
+
```jsonc
|
|
552
|
+
{
|
|
553
|
+
"plugin": [
|
|
554
|
+
["@te-river/opencode-team-mode@latest", { "defaultAgent": false }]
|
|
555
|
+
]
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Your own agents named `team` / `architect` / … always take precedence; the
|
|
560
|
+
plugin never clobbers user definitions. See [Customization](#-customization)
|
|
561
|
+
for overrides, extra agents and disabling roles.
|
|
562
|
+
|
|
563
|
+
### Environment variables
|
|
564
|
+
|
|
565
|
+
| Env var | Default | Purpose |
|
|
566
|
+
|---|---|---|
|
|
567
|
+
| `TM_ENV_PROTECT` | `strict` | R6 mode: `strict` / `standard` / `off` (off also disarms the approval timer) |
|
|
568
|
+
| `TM_ASK_TIMEOUT_MIN` | `1` | minutes before an unanswered dialog is auto-rejected (floored at 1 min — safe: a racing reply audits as benign `already-closed`; the host's reply event reaching the plugin ~120 s late is event-bus delivery lag, not a click delay). Every governed tool ALSO ends the wait itself at this + 15 s, because the gate is only armed when R6 is on and the client can reply — and a tool that waits forever reads as a hang, not as a request for your attention |
|
|
569
|
+
| `TM_ASK_TIMEOUT_FLOOR_MIN` | `1` | minimum enforced for the ask timeout above |
|
|
570
|
+
| `TM_ENV_PROTECT_EXTRA_DENY` | — | extra block patterns (regex; always hard block, never dialog-governed) |
|
|
571
|
+
| `TM_OFFLOAD_THRESHOLD` | `2000` | global offload fallback (tokens, CJK-aware estimate) — used when the content class is unknown |
|
|
572
|
+
| `TM_OFFLOAD_THRESHOLD_TEXT` | `4000` | offload boundary for prose (text / log / markdown) |
|
|
573
|
+
| `TM_OFFLOAD_THRESHOLD_DATA` | `2000` | offload boundary for structured payloads (json / csv / code / binary) |
|
|
574
|
+
| `TM_PREVIEW_MAX_TOKENS` | `80` | preview hard cap |
|
|
575
|
+
| `TM_FETCH_MAX_LINES` | `2000` | tm_fetch page cap |
|
|
576
|
+
| `TM_BLACKBOARD_DIR` / `TM_TRAJECTORY_DIR` | `<repo>/.git/opencode-team/…` | offload store / trajectory ledger (tmpdir fallback, sharded per workspace by a path hash so `tm_stats's window is only THIS workspace's traffic; explicit = absolute or project-relative) |
|
|
577
|
+
| `TM_BLACKBOARD_TTL` | `7` | store retention (days) |
|
|
578
|
+
| `TM_BOARD_MAX_CHARS` | `200000` | tm_board_write: one board file's character cap — over it the write refuses (with a "split the topic" hint) instead of truncating a deliverable |
|
|
579
|
+
| `TM_BOARD_MAX_FILES` | `200` | tm_board_write: markdown files allowed per session folder; the TTL sweeper is the only reclaim path, so the refusal names it and the `ttlDays` option |
|
|
580
|
+
| `TM_BASH_READONLY_ALLOWED` | built-in table | tm_bash allowlist |
|
|
581
|
+
| `TM_SEARCH_DEFAULT_ENGINE` | `auto` | tm_search engine when no `engine` arg is given (`auto` = classify + parallel fan-out + RRF fusion; any table name also pins a manual default) |
|
|
582
|
+
| `TM_WEBFETCH_ALLOWED_DOMAINS` | the 24 seeded hosts | tm_webfetch / tm_search / tm_browser allowlist (`"*"` opens all; empty = deny all; a custom list REPLACES the seed — keep the engine hosts). A site's own asset CDN has to be seeded or `tm_browser` renders it blank — `bdimg.com` is there for exactly that reason; per-session gaps go through `tm_browser { action:"allow_host", host }` instead of an env edit. `"*"` does **not** cover private space: loopback / RFC1918 / CGNAT / `.localhost` still need the dialog on every use, and non-routable ranges (169.254.0.0/16 metadata, 0.0.0.0/8, multicast, reserved, plus the IPv4-mapped and DNS64 spellings of the same target) are a hard red line no setting can open |
|
|
583
|
+
| `TM_BROWSER_PATH` | auto-detect | tm_browser executable override (default: your DEFAULT browser when Chromium-family, else Edge/Chrome probes) |
|
|
584
|
+
| `TM_BROWSER_HEADLESS` | `auto` | `1` headless (CI) / `0` headful / `auto` (headless only on display-less Linux) |
|
|
585
|
+
| `TM_BROWSER_ENGINE` | `playwright` | `playwright` (needs Node ≥ 20; any import failure auto-degrades) / `cdp-legacy` (zero-dep CDP pipe, core verbs only) |
|
|
586
|
+
| `TM_BROWSER_SNAPSHOT_MAX_TOKENS` | `1200` | hard cap on `take_snapshot` payloads |
|
|
587
|
+
| `TM_BROWSER_SUBRESOURCE` | `same-site` | what a page may load after its navigation was allowed: `same-site` = images/media/fonts/stylesheets always, scripts/XHR only for a site this session actually opened; `passive` = only the passive types; `off` = the legacy every-request gate. Blocked requests surface as a "N 个子资源请求被拦截" note on the next snapshot, and when the page has nothing addressable left the note says the blankness is ours and points at `allow_host` / this env var |
|
|
588
|
+
| `TM_BROWSER_IDLE_MS` | `180000` | an untouched browser session closes itself after this many ms (0 disables) and tells the user — a window nobody owns is a user-facing bug |
|
|
589
|
+
| `TM_BROWSER_ASK_EVAL` | `on` | `evaluate_script` runs arbitrary JS in YOUR browser — the one verb the domain allowlist can't cover (it limits where we navigate, not what a loaded page hands back). One official-dialog consent per browser session; no ask bridge ⇒ refused. `off` restores the old behaviour; the result redaction (JWT/bearer/cookie/api-key shapes) is NOT switchable |
|
|
590
|
+
| `TM_WEB_CACHE_TTL_SEC` | `300` | how long a governed fetch may re-serve the same URL (0 = off). One store shared by tm_webfetch / tm_search / the PTC bridge; entries are hash-named (a token-bearing query never hits disk) and are only read or written for hops the STATIC allowlist admitted — dialog consent stays per-request, and a re-served page says 缓存命中 |
|
|
591
|
+
| `TM_BROWSER_IMAGE_MAX_BYTES` | `400000` | ceiling on the JPEG `take_screenshot { image:true }` inlines into the model's context (above it the reply stays path-only and says why) |
|
|
592
|
+
| `TM_SEARCH_WEIGHTS` | unset | per-engine fusion weight overrides, e.g. `bing=0.3,hn=0.25`; anything unset keeps the built-in table |
|
|
593
|
+
| `TM_SEARCH_RELEVANCE_FLOOR` | `0.35` | weight fraction kept by a hit that shares no query token with its title/snippet/host (demotes junk without deleting an engine) |
|
|
594
|
+
| `TM_SEARCH_MAX_HITS` | `10` | hits kept per engine leg and in the fused list |
|
|
595
|
+
| `TM_SEARCH_DISABLED_ENGINES` | unset | engines removed from the roster AND from every `auto` route (`sogou,baidu` style) |
|
|
596
|
+
| `TM_BASH_TIMEOUT_PROBE_MS` | `60000` | ceiling forced onto a `timeout` the model set for a read-only probe command (0 disables) |
|
|
597
|
+
| `TM_BASH_TIMEOUT_MAX_MS` | `0` | optional global ceiling for every other bash command — off by default so a real build keeps the timeout it asked for |
|
|
598
|
+
| `TM_PTY_MAX` | `4` | concurrent `tm_pty` terminal sessions this plugin may keep running at once |
|
|
599
|
+
| `TM_JOIN_MAX_WAIT_MS` | `60000` | ceiling on `tm_join { waitMs }`. Was 300 000, and a lead parked in it twice in a row (19 min of nothing) while its children worked — waiting is not parallelism, so the default now says "check, then work". A second consecutive wait after nothing settled is cut to 10 s and answered with what to do instead |
|
|
600
|
+
| `TM_STORE_RECLAIM` | `on` | at boot, reclaim what an upgrade left behind: a per-workspace store shard idle past the TTL, and the pre-shard `blackboard/` + `trajectory/` under the temp-dir fallback (503 MB of expired runs on one real machine, with no sweeper pointed at them any more). Only TTL-expired entries are ever removed — a fresh run dir survives, because a session started before the upgrade may still be writing there. `off` leaves the disk exactly as found (the test runner sets it) |
|
|
601
|
+
| `TM_TASK_OFFLOAD` | `on` | keep the HOST's background sub-agent inside the context budget: when `task { background: true }` finishes, the host injects the child's full reply into your session; this replaces an oversized body with a preview + a `tm_fetch`-style pointer (`tm_join { ids: [...] }`), touching ONLY synthetic parts that carry the host's own `<task id=… state="completed">` envelope and exceed the text offload threshold. Nothing is copied to disk — the text stays where it was written (the child session). `off` restores the host's verbatim injection |
|
|
602
|
+
| `TM_TOOL_HINTS` | `on` | append TeamMode's call-site discipline to the built-in `bash` / `task` tool DESCRIPTIONS via `tool.definition` (append-only, idempotent — the host text is never replaced) |
|
|
603
|
+
| `TM_AGENT_TEMPERATURE` | `off` | `on` applies a per-role sampling table (architect 0.35 / researcher 0.3 / reviewer 0.1 / rest 0.2) via `chat.params`; or give it `reviewer=0.05;team=0.4`. Off = the documented "all agents at 0.2" invariant stands |
|
|
604
|
+
| `TM_COMPACTION_CONTEXT` | `on` | on the host's pre-compaction hook, add the must-survive list (reply skeleton, offload handles, open sub-agent session ids, provenance, board paths). Additive — the host's own summarizer prompt is never replaced |
|
|
605
|
+
| `TM_COMPACTION_AUTOCONTINUE` | `on` | `off` stops the host from silently resuming the turn after a compaction, so a human re-reads state first |
|
|
606
|
+
| `TM_SHELL_NO_COLOR` | `on` | inject `NO_COLOR`/`TERM=dumb` into every child shell via `shell.env` (ANSI progress bars are pure context tax). Never overwrites a value the host already set |
|
|
607
|
+
| `TM_SHELL_ENV` | — | explicit `KEY=VALUE;KEY2=VALUE2` passthrough into child shells — deliberately allowlisted, so this hook can't become a side channel for the parent environment |
|
|
608
|
+
| `TM_BROWSER_USER_DATA_DIR` | — (isolated temp profile) | explicit persistent profile dir — the ONLY way logins survive between sessions, and honored by BOTH engines (playwright and cdp-legacy). Use a DEDICATED directory (e.g. `D:\tm-browser-profile`) and log in by hand the first time; pointing it at your browser's own data dir (`…\Microsoft\Edge\User Data`, `google-chrome`, Firefox `Profiles`) is refused before anything spawns, because that would have the agent browse as you while a force-kill reaper owns the process |
|
|
609
|
+
| `TM_MEMORY_GLOBAL_DIR` | `~/.opencode-team/memories/global/` | tm_memory GLOBAL tier store |
|
|
610
|
+
| `TM_MEMORY_SESSION_TTL_MIN` | `240` | session-tier entry TTL (lazy + boot sweep) |
|
|
611
|
+
| `TM_MEMORY_MAX_ENTRIES` | `200` | per-scope entry cap; over it `add` fails on purpose — run `compact` |
|
|
612
|
+
| `TM_MEMORY_STALE_DAYS` | `30` | age after which search hits are tagged `[stale Nd]` (`0` disables) |
|
|
613
|
+
| `TM_MEMORY_SESSION_PERSIST` | — (ephemeral) | `1` also writes session entries under `memories/sessions/<sid>/` |
|
|
614
|
+
| `TM_HIT_BLACKLIST` | `maimai.cn` | extra domains never listed as search hits (comma/semicolon separated; same-name-different-site noise like 脉脉) |
|
|
615
|
+
| `TM_PTC_MAX_PROGRAM_CHARS` | `4000` | PTC program source cap |
|
|
616
|
+
| `TM_PTC_MAX_CALLS` | `20` | PTC per-run bridge-call budget (1–200) |
|
|
617
|
+
| `TM_PTC_MAX_ERRORS` | `3` | PTC per-run error budget (1–50) |
|
|
618
|
+
| `TM_PTC_TIMEOUT_MS` | `60000` | PTC per-run wall-clock timeout (5s–10min) |
|
|
619
|
+
| `TM_PTC_ENGINE` | `auto` | `auto` (worker→inline degrade) / `worker` / `inline` |
|
|
620
|
+
| `TM_PTC_WEB_BRIDGE` | `on` | expose `tm.search` / `tm.webfetch` to PTC programs (`off` removes them from the bridge set) |
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
624
|
+
## 🏗️ How the team works
|
|
625
|
+
|
|
626
|
+
Sub-agents can't message each other live (platform limitation), so TeamMode
|
|
627
|
+
coordinates them through a **structured reply skeleton** — every specialist
|
|
628
|
+
reply is `STATUS: / CHANGES: / FINDINGS: / EVIDENCE: / HANDOFF:`, ≤50 lines,
|
|
629
|
+
relayed verbatim by the Lead into the next dispatch. Files are the exception,
|
|
630
|
+
not the rule: a deliverable over ~50 lines goes to ONE named board file under
|
|
631
|
+
`<repo>/.git/opencode-team/` (round-suffixed, working tree untouched).
|
|
632
|
+
|
|
633
|
+
- **Routing table:** question → direct answer; docs-only → implementer;
|
|
634
|
+
product change → implementer → tester → reviewer; multi-module →
|
|
635
|
+
architect → implementer → tester → reviewer(s); unknown tech → researcher
|
|
636
|
+
first. Fixed minimums — a product change routed below 3 dispatches is a
|
|
637
|
+
routing bug.
|
|
638
|
+
- **Approval gate (count-based):** ≥2 dispatches → plan (≤30 lines) → **your
|
|
639
|
+
approval** → execute. Blocking questions are batched and asked immediately.
|
|
640
|
+
- **Concurrent dispatch:** independent dispatches batch into the SAME round
|
|
641
|
+
(parallel implementers with per-file ownership + verbatim contracts,
|
|
642
|
+
3-dimension reviews, split test suites); only the Team Lead dispatches —
|
|
643
|
+
specialists no longer hold `task`, so no sub-agent spawns a sub-agent.
|
|
644
|
+
- **Adaptive review:** one reviewer by default; three parallel dimensions
|
|
645
|
+
only for high-risk profiles (auth/security, cross-module contracts, public APIs).
|
|
646
|
+
- **Static verification:** build / typecheck / lint / tests. Improvised
|
|
647
|
+
browser automation is banned; unverified UI work ends with
|
|
648
|
+
`UI NOT VERIFIED: <what to check>`.
|
|
649
|
+
- **Evidence standard:** "done / fixed / passed" claims need verifiable
|
|
650
|
+
evidence — output, logs, diffs.
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
## 🔧 Customization
|
|
655
|
+
|
|
656
|
+
**Override an agent** — same name in your config wins:
|
|
657
|
+
|
|
658
|
+
```jsonc
|
|
659
|
+
{
|
|
660
|
+
"agent": {
|
|
661
|
+
"reviewer": {
|
|
662
|
+
"model": "anthropic/claude-sonnet-4-6",
|
|
663
|
+
"prompt": "You are an extremely strict reviewer. Reject anything with a lint warning."
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
**Add your own agents** alongside the team:
|
|
670
|
+
|
|
671
|
+
```jsonc
|
|
672
|
+
{
|
|
673
|
+
"agent": {
|
|
674
|
+
"devops": {
|
|
675
|
+
"mode": "subagent",
|
|
676
|
+
"description": "Handles CI/CD, Docker, and deployment tasks.",
|
|
677
|
+
"prompt": "You are the DevOps engineer..."
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
**Disable one:** `"researcher": { "disable": true }`.
|
|
684
|
+
|
|
685
|
+
**Board retention** via the tuple form: `["@te-river/opencode-team-mode@latest", { "ttlDays": 7 }]` (valid range (0, 365], invalid values fall back to 5).
|
|
686
|
+
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
## ❓ FAQ
|
|
690
|
+
|
|
691
|
+
**Will this eat my tokens?**
|
|
692
|
+
The opposite is the point. Offload + 80-token previews + PTC batch programs
|
|
693
|
+
exist because a five-agent pipeline naively bolted onto one context window
|
|
694
|
+
*would* eat your tokens. The governance is the token-saver.
|
|
695
|
+
|
|
696
|
+
**Is the web access safe?**
|
|
697
|
+
It's the most guarded surface in the plugin: two full web roles plus a
|
|
698
|
+
browser-only tester grant, a domain
|
|
699
|
+
allowlist with dialog-gated escapes (you approve any out-of-allowlist
|
|
700
|
+
target in OpenCode's official dialog, with a toast notification), redirects
|
|
701
|
+
re-checked per hop, network-layer enforcement in the browser, env-file URL
|
|
702
|
+
refusal, and every payload rides the same offload governance. No allowlisted
|
|
703
|
+
page can bounce the fetch off-site.
|
|
704
|
+
|
|
705
|
+
**Why doesn't the plugin auto-update?**
|
|
706
|
+
OpenCode caches plugins by spec string and never re-resolves `@latest`
|
|
707
|
+
(upstream limitation, not ours). **Re-run the installer — that IS the
|
|
708
|
+
update** (it purges the cache and re-resolves npm copies); or delete the
|
|
709
|
+
cache dir by hand. Recipe above and in the
|
|
710
|
+
[installation guide](./docs/installation.md).
|
|
711
|
+
|
|
712
|
+
**Can agents run tools in parallel?**
|
|
713
|
+
Yes — and they're *engineered* for it: parallel `tm_search` / `tm_webfetch` /
|
|
714
|
+
`tm_fetch` calls get distinct step ids and isolated payloads. A regression
|
|
715
|
+
here fails the test suite before it ever reaches you.
|
|
716
|
+
|
|
717
|
+
**Does it work in the CLI (TUI), or only Desktop?**
|
|
718
|
+
Both. Desktop adds the color-coded picker and panels; the governed tools and
|
|
719
|
+
the whole workflow are host-agnostic. On display-less Linux, `tm_browser`
|
|
720
|
+
runs headless automatically.
|
|
721
|
+
|
|
722
|
+
**What happens if I don't answer a confirmation dialog?**
|
|
723
|
+
It auto-rejects after `TM_ASK_TIMEOUT_MIN` (default 1). The plugin never
|
|
724
|
+
self-approves — the only side it can take is yours or nobody's.
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
## 🗑️ Uninstall
|
|
729
|
+
|
|
730
|
+
1. Remove the entry from the `"plugin"` array in your config file.
|
|
731
|
+
2. Delete the cache dir (table in [Install](#-read-this-once-save-yourself-an-hour-later)) if you want the disk space back.
|
|
732
|
+
3. Restart OpenCode. The agents, commands and tools are gone; the stores under `<repo>/.git/opencode-team/` (and `~/.opencode-team/` for global memories) are plain files you can delete whenever.
|
|
733
|
+
|
|
734
|
+
No DLLs were harmed. Nothing was written to your working tree.
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
## 🏛️ Architecture (for the curious)
|
|
739
|
+
|
|
740
|
+
```
|
|
741
|
+
opencode-team-mode/
|
|
742
|
+
├── src/
|
|
743
|
+
│ ├── index.ts ← Plugin entry (config + R6 guard + approval gate + tool segment)
|
|
744
|
+
│ ├── agents.ts ← Agent structure (modes, colors, temperatures, whitelist matrix)
|
|
745
|
+
│ ├── prompts/ ← Agent prompts (lead / specialists / shared) — pinned by tests
|
|
746
|
+
│ ├── commands.ts ← Slash command definitions
|
|
747
|
+
│ ├── blackboard.ts ← Shared blackboard + TTL sweeper
|
|
748
|
+
│ ├── envprotect.ts ← R6 facade (patterns / classifiers / gate predicates / hook)
|
|
749
|
+
│ ├── approval-gate.ts ← Unified approval gate (dialog timeout auto-reject)
|
|
750
|
+
│ ├── tm/ ← Governed tools: pipelines / store / preview / guard / refs /
|
|
751
|
+
│ │ webfetch / search / memory / browser / shell-bridge / ptc/ (9 modules)
|
|
752
|
+
│ └── types.ts ← Loader-contract types (1.18.x)
|
|
753
|
+
├── docs/installation.md ← The agent-consumable install guide
|
|
754
|
+
├── scripts/ ← One-line installers (bash / PowerShell)
|
|
755
|
+
├── pt07/ ← PT-07 baseline suite (seeded A/B token measurement)
|
|
756
|
+
└── README.*.md ← You are here (twice)
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
The loader calls `server(input, options)` once: the `config` hook injects the
|
|
760
|
+
six agents and six commands, the same call installs the R6
|
|
761
|
+
`tool.execute.before` guard, arms the approval gate through an `event` hook,
|
|
762
|
+
and registers the `tm_*` tools. User-defined agents with the same name always
|
|
763
|
+
win — the plugin never clobbers.
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
## 🤝 Contributing
|
|
768
|
+
|
|
769
|
+
Issues and PRs welcome. Especially wanted: localization of agent prompts,
|
|
770
|
+
more agent roles, more command templates, and real-world reports of the
|
|
771
|
+
search engines' behavior (they rearrange their markup; the extractor filters
|
|
772
|
+
are intentionally loose but not psychic).
|
|
773
|
+
|
|
774
|
+
---
|
|
775
|
+
|
|
776
|
+
## 📄 License
|
|
777
|
+
|
|
778
|
+
[Apache License 2.0](./LICENSE)
|
|
779
|
+
|
|
780
|
+
---
|
|
781
|
+
|
|
782
|
+
## 🔗 Links
|
|
783
|
+
|
|
784
|
+
- [npm Package](https://www.npmjs.com/package/@te-river/opencode-team-mode) — `@te-river/opencode-team-mode`
|
|
785
|
+
- [Installation guide](./docs/installation.md) — the complete manual / agent-consumable procedure
|
|
786
|
+
- [OpenCode Desktop](https://opencode.ai) — Official website & download
|
|
787
|
+
- [OpenCode Docs](https://opencode.ai/docs) — Configuration & plugin documentation
|
|
788
|
+
- [OpenCode Plugin API](https://opencode.ai/docs/plugins) — Build your own plugins
|