@te-river/opencode-team-mode 1.7.6 → 1.7.8

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.
Files changed (59) hide show
  1. package/README.md +1010 -1009
  2. package/README.zh-CN.md +907 -906
  3. package/dist/host/v2-browser-gate.js +2 -2
  4. package/dist/host/v2-guard.d.ts +135 -0
  5. package/dist/host/v2-guard.d.ts.map +1 -1
  6. package/dist/host/v2-guard.js +227 -2
  7. package/dist/host/v2-guard.js.map +1 -1
  8. package/dist/host/v2-offload.js +6 -6
  9. package/dist/host/v2-retry.d.ts +9 -1
  10. package/dist/host/v2-retry.d.ts.map +1 -1
  11. package/dist/host/v2-retry.js +10 -2
  12. package/dist/host/v2-retry.js.map +1 -1
  13. package/dist/host/v2-subagent.d.ts +21 -0
  14. package/dist/host/v2-subagent.d.ts.map +1 -1
  15. package/dist/host/v2-subagent.js +55 -9
  16. package/dist/host/v2-subagent.js.map +1 -1
  17. package/dist/host/v2.d.ts.map +1 -1
  18. package/dist/host/v2.js +77 -1
  19. package/dist/host/v2.js.map +1 -1
  20. package/dist/prompts/specialists.js +286 -286
  21. package/dist/task-offload.js +1 -1
  22. package/dist/tm/config-layers.d.ts +5 -2
  23. package/dist/tm/config-layers.d.ts.map +1 -1
  24. package/dist/tm/config-layers.js +10 -6
  25. package/dist/tm/config-layers.js.map +1 -1
  26. package/dist/tm/config.d.ts +3 -0
  27. package/dist/tm/config.d.ts.map +1 -1
  28. package/dist/tm/config.js +7 -1
  29. package/dist/tm/config.js.map +1 -1
  30. package/dist/tm/index.d.ts +5 -1
  31. package/dist/tm/index.d.ts.map +1 -1
  32. package/dist/tm/index.js +1 -1
  33. package/dist/tm/index.js.map +1 -1
  34. package/dist/tm/ledger.js +5 -5
  35. package/dist/tm/memory.js +9 -9
  36. package/dist/tm/search.d.ts +3 -0
  37. package/dist/tm/search.d.ts.map +1 -1
  38. package/dist/tm/search.js +67 -15
  39. package/dist/tm/search.js.map +1 -1
  40. package/dist/tm/stats.d.ts.map +1 -1
  41. package/dist/tm/stats.js +23 -0
  42. package/dist/tm/stats.js.map +1 -1
  43. package/dist/tm/tools.js +3 -3
  44. package/dist/tm/webfetch.d.ts +94 -5
  45. package/dist/tm/webfetch.d.ts.map +1 -1
  46. package/dist/tm/webfetch.js +285 -64
  47. package/dist/tm/webfetch.js.map +1 -1
  48. package/docs/installation-v2.md +2 -2
  49. package/docs/installation.md +505 -505
  50. package/docs/research/agent-data-exchange.md +117 -117
  51. package/docs/research/browser-pane.md +94 -94
  52. package/docs/research/host-http-api.md +132 -132
  53. package/docs/research/host-subagent-injection.md +187 -187
  54. package/docs/research/plugin-loader-contract.md +261 -261
  55. package/docs/research/v2-builtin-tools.md +447 -447
  56. package/docs/v2-port-notes.md +121 -78
  57. package/index.js +7 -7
  58. package/package.json +64 -64
  59. package/scripts/lib/config-surgery.cjs +239 -239
package/README.md CHANGED
@@ -1,1009 +1,1010 @@
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
- > 🤝 **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, no 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. This package supports **OpenCode 2.x
23
- > only** — the 1.18.x personality was removed in the 1.7.0 line:
24
- > 2.x → https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation-v2.md
25
- > (a 2.x plugin cannot create an agent, so the six roles and six `/team-*` commands come
26
- > from a generator step in that guide — that step is not optional.) Then verify the install
27
- > using the checks in that guide.
28
- > ```
29
- >
30
- > **The one command to remember afterwards:** `/team-run <task>` — the Team Lead
31
- > plans it, shows you the plan, waits for your approval, then runs the whole team.
32
-
33
- Everything else below is detail. When you're ready for it, here's the map:
34
-
35
- **[Why](#-why-teammode) · [The team](#-the-team) · [Install](#-install) · [Usage](#-usage) · [Tools & security](#-governed-tools--security) · [Configuration](#️-configuration) · [How it works](#-how-the-team-works) · [Troubleshooting](#-troubleshooting) · [Uninstall](#-uninstall)**
36
-
37
- ---
38
-
39
- ## 🤔 Why TeamMode?
40
-
41
- Because a single agent doing everything is how you get: a context window stuffed
42
- with 5000-line file dumps, twenty round-trips to `shell` for what one script could
43
- do, sub-agents that silently read `.env`, and web "research" that is really just
44
- the model's imagination.
45
-
46
- TeamMode's answer to each:
47
-
48
- | Pain | TeamMode's answer |
49
- |---|---|
50
- | 🔥 **Context flooding** | Every governed result over its content-class offload boundary (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. |
51
- | 🐌 **Round-trip overhead** | The host's own `execute` (Code Mode): the agent writes ONE program that makes N governed calls in a single turn. Zero LLM round-trips during the run. |
52
- | 🕳️ **Silent side effects** | The R6 env-protection face: a Team role's `read` of a `.env` is **denied** with no consent path, and a shell command that reads the environment goes to the host's own permission prompt. The plugin never approves on its own — it can only reject. |
53
- | 🌫️ **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. |
54
- | 🧭 **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 renderer's supported set is measured rather than assumed, and the prompts carry the negative half of that measurement — footnotes, `==highlight==`, a bare `---` rule and `$…$` math reach you as literal text, so agents are told not to use them, while `mermaid` diagrams are offered because this host does draw them. |
55
- | 🎯 **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 lead's ledger, `tm_join` says 目标未达成 and lists them, and the goal is carried through context compaction so a summarized transcript cannot redefine it. |
56
- | 🗣️ **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 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. |
57
- | ⏱️ **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 `execute` (Code Mode) program, 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. |
58
-
59
- And the workflow discipline underneath: deterministic routing, a ≤30-line plan
60
- you approve before ≥2 dispatches execute, structured `STATUS/CHANGES/FINDINGS/
61
- EVIDENCE/HANDOFF` replies between agents, and static verification (build /
62
- typecheck / tests) instead of vibes.
63
-
64
- That discipline is also why the recommendation is **medium-to-large
65
- projects**: on a two-file script the team simply has less to govern.
66
-
67
- ---
68
-
69
- ## 👥 The team
70
-
71
- | Agent | Role | When to use |
72
- |---|---|---|
73
- | 🎯 **Team Lead** (`@team`) | Orchestrator | Complex tasks that need planning + multi-step execution |
74
- | 🏗️ **Architect** | System designer | Design docs, module structure, API contracts — **dispatched only when the design is genuinely unknown** |
75
- | 💻 **Implementer** | Code writer | Building features, writing production code |
76
- | 🔍 **Reviewer** | Dimension-focused auditor | Single-dimension review by default; 3 in parallel only for high-risk changes |
77
- | 🧪 **Tester** | Test engineer | Tests with real edge cases; static verification (build / typecheck / lint); governed UI verification via the host's native `browser_*` tools |
78
- | 🔎 **Researcher** | Knowledge finder | Local repo first, then the web — one of the two network roles (with the Lead) |
79
-
80
- Out of the box, **Team is your default agent** — new chats open straight into the
81
- orchestrator (opt-out in [Configuration](#️-configuration)).
82
-
83
- ---
84
-
85
- ## 📦 Install
86
-
87
- ### Option 1 — Let your agent do it (recommended)
88
-
89
- Copy this into any coding agent — it will edit your config, restart-remind you, and verify:
90
-
91
- ```text
92
- Install the OpenCode plugin @te-river/opencode-team-mode. This package supports **OpenCode 2.x
93
- only** — the 1.18.x personality was removed in the 1.7.0 line:
94
- 2.x → https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation-v2.md
95
- (a 2.x plugin cannot create an agent, so the six roles and six `/team-*` commands come from
96
- a generator step in that guide — that step is not optional.)
97
- (If a URL is unreachable — common on mainland-China networks — retry with
98
- the mirror prefix: https://ghproxy.net/ + the same path. And if `npm` is
99
- slow or blocked, point it at a registry mirror for this install:
100
- `npm config set registry https://registry.npmmirror.com` — or add
101
- `--registry https://registry.npmmirror.com` to the one command that needs it.)
102
- Then verify the install using the checks in that guide.
103
- ```
104
-
105
- (The guide is the complete manual procedure — config file locations, plugin
106
- entry, restart, verification, update and uninstall. Your agent reads it and
107
- executes it faithfully; there is nothing else it needs.)
108
-
109
- ### Option 2 — One-line script
110
-
111
- macOS / Linux (bash):
112
-
113
- ```bash
114
- curl -fsSL https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.sh | bash
115
- ```
116
-
117
- Windows (PowerShell):
118
-
119
- ```powershell
120
- irm https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.ps1 | iex
121
- ```
122
-
123
- ### Option 3 — Manual
124
-
125
- Add the plugin to your `opencode.jsonc`:
126
-
127
- ```jsonc
128
- {
129
- "$schema": "https://opencode.ai/config.json",
130
- "plugins": [
131
- "@te-river/opencode-team-mode@latest"
132
- ]
133
- }
134
- ```
135
-
136
- OpenCode installs the plugin on next startup.
137
-
138
- > **The key is `plugins` (plural).** A 2.x host never reads the singular `plugin`
139
- > key, and it installs the package itself from the entry at startup. Entries
140
- > across config files are **applied lowest→highest rather than replacing one
141
- > another**, so keep exactly one Team entry — writing ours into both
142
- > `opencode.json` and `opencode.jsonc` loads the plugin twice. See
143
- > [docs/installation-v2.md](./docs/installation-v2.md) for the 2.x flow (a plugin
144
- > cannot create an agent there, so the six roles and six commands are generated
145
- > config files);
146
- > `docs/research/plugin-loader-contract.md` has the host's own loader code.
147
-
148
- ### ⚠️ Read this once, save yourself an hour later
149
-
150
- - **Restart to activate.** After touching the OpenCode config, fully quit and restart OpenCode (Desktop: quit from tray, not just the window).
151
- - **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:
152
-
153
- | OS | Purge command — recursive, covers BOTH cache layouts |
154
- |---|---|
155
- | macOS / Linux | `find ~/.cache/opencode/packages -type d -name '*opencode-team-mode*' -prune -exec rm -rf {} +` |
156
- | 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 } }` |
157
-
158
- ⚠️ 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).
159
-
160
- ⚠️ **A published version can be shadowed by your HOME.** For a package spec the host resolves the entrypoint through the nearest `node_modules` walk starting at HOME, so a stray `~/package.json` with a `devDependencies` entry pinning `@te-river/opencode-team-mode` makes the host load *that* copy. The diagnostic is the boot probe's `entrypoint=` line, not a guess about cache layers. Full recipe (including an agent-driven update prompt): [installation guide, Updating](./docs/installation-v2.md).
161
- - **Prerequisites:** [OpenCode](https://opencode.ai) (Desktop or CLI) and Node ≥ 18.
162
-
163
- ### 🖥️ What the installer changes on your machine
164
-
165
- Three things, all outside this repo — listed because a plugin that edits your
166
- environment without saying so is not one you can trust.
167
-
168
- | What | Where it lands | How long it stays |
169
- |---|---|---|
170
- | 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 |
171
- | 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 |
172
- | **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) |
173
-
174
- Why that third one is there: `task { background: true }` is the only sub-agent
175
- the OpenCode interface can **show** you — a card linking to the live child
176
- session, which you can stop. The host turns it on through a flag on **its own
177
- process**, and a plugin cannot set flags in the process that loads it, so the
178
- flag has to come from the environment. Without it nothing breaks: `task` simply
179
- blocks the lead and its card stays non-background. (On 2.x the plugin forces
180
- `background: true` on every `subagent` call regardless — this flag is about the
181
- *host's* `task` tool, which is the channel a human can watch.)
182
-
183
- Undo it:
184
-
185
- ```powershell
186
- # Windows — remove it from your user profile
187
- [Environment]::SetEnvironmentVariable("OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS", $null, "User")
188
- ```
189
-
190
- ```bash
191
- launchctl unsetenv OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # macOS
192
- systemctl --user unset-environment OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # Linux
193
- ```
194
-
195
- Or skip it at install time, and the installer touches only the two files above:
196
-
197
- ```powershell
198
- .\install.ps1 -NoBackgroundSubagents # or $env:TEAMMODE_SKIP_BACKGROUND_SUBAGENTS="1"
199
- ```
200
-
201
- ```bash
202
- TEAMMODE_SKIP_BACKGROUND_SUBAGENTS=1 bash install.sh
203
- ```
204
-
205
- Either way the installer prints what it changed, and reads the value back
206
- instead of trusting its own exit code.
207
-
208
- ### Verify
209
-
210
- Restart, open the agent picker, and look for **team, architect, implementer,
211
- reviewer, tester, researcher**. That's it — the team is hired.
212
-
213
- ---
214
-
215
- ## 📖 Usage
216
-
217
- ### Slash commands
218
-
219
- | Command | Agent | Description |
220
- |---|---|---|
221
- | `/team-plan <task>` | Architect | Implementation plan with architecture, file manifest, task breakdown |
222
- | `/team-implement <task>` | Implementer | Production code for a feature or task |
223
- | `/team-review [scope]` | Reviewer | Audit for bugs, security issues, quality problems |
224
- | `/team-test [scope]` | Tester | Comprehensive tests with edge-case coverage |
225
- | `/team-research <topic>` | Researcher | Local repo first; web via the governed tools |
226
- | `/team-run <task>` | Team Lead | **The full workflow** — plan → approval → orchestration → verification |
227
-
228
- Or `@`-mention agents directly: `@team`, `@architect`, `@implementer`,
229
- `@reviewer`, `@tester`, `@researcher`.
230
-
231
- ### What a run feels like
232
-
233
- Team is the default agent out of the box, so you just type into a fresh chat:
234
-
235
- > **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/`.
236
-
237
- ```text
238
- team Route: product behavior change → implementer → tester → reviewer
239
- (3 dispatches → approval gate applies)
240
-
241
- PLAN
242
- Goal: token-bucket limiter, 100 req/min/user, 429 + Retry-After
243
- Scope: src/middleware/rateLimit.ts (new), src/app.ts (+3 lines)
244
- Pipeline: implementer → tester → reviewer (correctness)
245
- Assumption: in-memory bucket, not Redis — say the word to change
246
- Boundary: src/legacy/** untouched
247
- Approve to proceed?
248
-
249
- you approved, go
250
-
251
- team ▸ @implementer — STATUS: done
252
- CHANGES: src/middleware/rateLimit.ts (new) · src/app.ts (+3)
253
- EVIDENCE: tsc clean
254
-
255
- ▸ @tester — STATUS: done · VERDICT: pass (14/14)
256
- FINDINGS: burst edge, window expiry, concurrent refill covered;
257
- src/legacy/** byte-identical
258
-
259
- ▸ @reviewer — STATUS: done · VERDICT: approve (correctness)
260
-
261
- team Done. rateLimit.ts (new) · app.ts (+3) · 14 tests green
262
- review: approve · assumption: in-memory only · src/legacy/ untouched
263
- ```
264
-
265
- You typed the task and four words. The plan was a routing-table lookup,
266
- execution waited for your approval, and every handoff between agents traveled
267
- as a structured skeleton — nothing landed in your repo, nothing was guessed.
268
-
269
- ---
270
-
271
- ## 🧰 Governed tools & security
272
-
273
- Every tool TeamMode adds runs under ONE governance pipeline: outputs above
274
- the offload threshold never enter the context window — the boundary is
275
- content-class aware (`offloadThresholdText` = 4000 for prose: text/log/markdown;
276
- `offloadThresholdData` = 2000 for json/csv/code/binary; an unknown class falls
277
- back to the global `offloadThreshold`) — and oversized results are offloaded to a
278
- run store and replaced by a content-aware preview plus an HMAC-signed handle that
279
- the agent pages through with `tm_fetch` when it genuinely needs the payload.
280
-
281
- | Tool | What it does | Roles |
282
- |---|---|---|
283
- | `tm_fetch` | Paged handle retrieval for offloaded results (JSON handles take a `fields` dot-path projection — a deliberately small jq subset like `items[].name`) | all six agents |
284
- | `tm_memory` | Session + project + global memory store (Markdown + frontmatter): add / search / list / forget / compact | all six agents |
285
- | `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 `shell` 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, capped by `boardMaxChars` + a per-session file limit | All six agents |
286
- | `tm_search` | Multi-engine web search with extracted, deduplicated, RRF-fused hit lists | Lead + Researcher |
287
- | `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 |
288
- | `tm_ledger` | **The lead's task ledger** (`add` / `doing` / `done` / `blocked` / `list`), stored in the host's own `ctx.storage` per session — the landing spot for the LEDGER rule, since OpenCode 2.x gives a plugin no `todowrite`. A repeated ask is ONE item, an id that matches two is refused with both printed, `blocked` carries the reason, and a write that did not reach storage is reported as a failure rather than as recorded | Lead only |
289
- | `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 stop a runaway, 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. **On 2.x it also registers the children the host's own `subagent` tool created** (the ack's `metadata.sessionID` is the seam), so a background dispatch is never reported as "nothing to collect" while the user watches it run — and such a row says where its reply actually arrives (the host's injected message) and whether it settled by event or by inference. **Stopping one is a real call:** `cancel: true` goes to the host's own `ctx.session.interrupt` on 2.x (`tm_join { ids: ["ses_…"], cancel: true }` stops ONE named child; without `ids` it stops every still-running one). The host's own contract is `interrupted=true` for an active execution and `false` for the idle no-op, so the answer comes back as **five distinct verdicts** — 已由宿主中断 / 空闲未中断(it wasn't running: our row was stale, not failed)/ 未确认(the call worked, no boolean came back)/ 无中断缝 / 被宿主拒绝(with the host's reason) — counted in the reply and written to the trajectory (`stop_tried` / `stop_confirmed` / `stop_refused` / `stop_unknown`, readable via `tm_stats`). It will not summarise five different facts as one "已取消", and `resume` is never sent, because resuming pending steering is the opposite of cancelling | Lead only |
290
- | `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), governance counts (blocked subresources, clamped shell timeouts, cache hits, redactions) — plus the **host capability matrix** (`已验证/存在未用/待观察/缺失/需人眼` per host surface) and the **layered-config section** (per-key source, red-line keys a file tried to set and lost, unknown keys, skipped layers, auto-create state). 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 |
291
-
292
- > **The v1 (1.18.x) personality was removed in full for the 1.7.0 line.** The package
293
- > exports `{id, setup}` and nothing else, so `tm_read` / `tm_grep` / `tm_bash` /
294
- > `tm_ptc_run` / `tm_pty` are gone with it — the host's own `read` / `grep` / `glob` /
295
- > `shell` and its `execute` (Code Mode) do that work now. The governance did NOT
296
- > disappear with them: an oversized native result is offloaded through
297
- > `tool.execute.after` (measured: `shell` 12,902 tokens arriving as a 78-token
298
- > preview), and the address red line plus R6's per-command classification ride the
299
- > host's `permission.evaluate`. `tm_ledger` is the lead's list where the host gives a
300
- > plugin no `todowrite`.
301
- > **Nothing we change reaches outside Team.** Every v2 hook fires for every session on
302
- > the host, so the tool-surface trim, the blackboard note, the offload
303
- > of native results, the R6/address strictening and the forced-background dispatch all ask
304
- > "is this one of our six roles?" first — `build`, `plan` and your own agents stay as a
305
- > fresh install leaves them. Calls whose owner the host did not tell us are left alone too,
306
- > and counted (`tm_stats` prints `作用域:我们 · 他人 · 未判定`).
307
- > The installer writes the six
308
- > role prompts, which name `read` / `grep` / `shell` instead of the removed aliases.
309
-
310
- > **On OpenCode 2.x, interactive browsing is the host's, and it stays ours.** The
311
- > desktop renders a browser in its side panel, and that panel attaches to the
312
- > server's own browser service — a plugin cannot register a page of its own into it
313
- > (forensics: `docs/research/browser-pane.md`). So the three roles with network
314
- > grants (lead, researcher, tester) are pointed at the host's `browser_*` tools
315
- > — the self-built `tm_browser` was removed in 1.7.0, so the host's catalog is the
316
- > only browser. On a host with no native browser catalog (CLI, standalone) there is
317
- > now no browser at all, and the agent reports that gap rather than simulating one.
318
- > Handing browsing over did not mean handing
319
- > governance over: `permission.evaluate` was observed NOT firing for `browser_*`, so
320
- > our gate sits on `tool.execute.before` instead — it classifies the URL of every
321
- > navigate/open, the path of every `browser_preview`, and every browser URL named
322
- > inside an `execute` program, refuses the ones out of policy, and if the host runs a
323
- > refused call anyway it replaces the page with the same refusal, so no
324
- > out-of-policy content reaches the context, the store or the trajectory. What we
325
- > cannot do is un-make a request the host already performed, and the reply says so
326
- > rather than claiming a block; `tm_stats` prints the two numbers apart (refused /
327
- > leaked past the refusal). One exception to the offload rule lives here: a
328
- > `browser_snapshot` is an addressing table, not a document, so it is CAPPED (every
329
- > `[ref=…]` line kept, static text dropped, budget `nativeSnapshotMaxTokens`
330
- > default 1 200) rather than replaced by a
331
- > handle. Measured on a 261-ref page: a head cut keeps 118 refs, this keeps 261 of
332
- > them using 1 044 of 11 326 tokens.
333
-
334
- > **Fixed tool priority ladder (every task): ① the user's own MCP/plugin
335
- > tools → ② TeamMode governed tools (`tm_*`) → ③ the model's own reasoning.**
336
- > It doubles as the fallback chain: when a tool errors (no browser on this
337
- > host, blocked host), the agent says so and drops to the next rung — and
338
- > rung ③ is where a missing capability gets reported, never fabricated.
339
- > One stated exception: on the **web** channel `tm_search` / `tm_webfetch` come
340
- > first, because that path is the only one carrying the
341
- > domain allowlist, the per-request confirmation dialog and the R6 red lines.
342
-
343
- > **What the host UI cannot show you.** OpenCode renders a *plugin* tool call
344
- > as a one-line card with no expandable body — its tool-renderer registry
345
- > holds only the built-in tool names, and an extension cannot add to it. The
346
- > governed output still exists: anything over the offload boundary is written
347
- > to disk as a handle, and `tm_stats { recent: 20 }` prints the call-by-call
348
- > recap with those handles and file paths, which you can open. Ask your agent
349
- > for it — "what did that tool actually return?"
350
-
351
- > **Delegation goes through the host's `task` — one channel, two shapes.**
352
- > OpenCode's own `task` tool is the only sub-agent the interface can SHOW you:
353
- > its card links to the live child session, and the user can stop it. Add
354
- > `background: true` and it is also non-blocking — the host wakes your lead when
355
- > the child finishes. That flag is experimental, so you turn it on yourself:
356
- >
357
- > ```
358
- > OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
359
- > ```
360
- >
361
- > (set it for the app process — `setx` on Windows, or launch from a shell that
362
- > exports it — then restart OpenCode; the installers do it for you, and that is
363
- > a **persistent user-scope write**, so see
364
- > [What the installer changes on your machine](#-what-the-installer-changes-on-your-machine)
365
- > for the exact value, its lifetime and the undo command). TeamMode
366
- > then keeps that channel inside your token budget: the injected full reply is
367
- > replaced by a preview plus a pointer, and nothing is copied to disk
368
- > (`taskOffload: "off"` restores the host's verbatim text). Cost of the host
369
- > path, stated plainly: each finished background task wakes the lead and costs a
370
- > turn. `tm_join` is the read side that stays — it pulls a named child's whole
371
- > reply back through the offload pipeline, stops a runaway, and rebuilds its
372
- > registry from the host session tree after a restart.
373
- >
374
- > There is deliberately **no plugin-side dispatcher**: an earlier `tm_dispatch`
375
- > created children the user could neither open from a card nor stop from the
376
- > interface, which is a worse trade than the batching it bought. Remove it,
377
- > and nothing breaks — the host's `task` was always the visible path.
378
-
379
- All governed tools are **parallel-safe**: the host may run a batch of
380
- `tm_search` / `tm_webfetch` / `tm_fetch` calls concurrently — each call gets
381
- its own step id and its own payload, and nothing cross-contaminates
382
- (proven by the parallel test suite).
383
-
384
- ### Context governance: offload, handles, previews
385
-
386
- Large tool outputs are context cost's main driver — every step re-sends the
387
- whole window. So results above the content-class offload boundary (prose →
388
- `offloadThresholdText`, structured data → `offloadThresholdData`,
389
- unknown → global `offloadThreshold`) are written to a local run store
390
- (`<repo>/.git/opencode-team/`, never your working tree) and replaced by a
391
- handle with a content-aware preview: JSON keys / CSV header + shape / log
392
- ERROR×N stats / code signatures / binary metadata, hard-capped at 80 tokens
393
- (`previewMaxTokens`). When the agent actually needs the payload, it pages
394
- through with `tm_fetch` using an HMAC-signed, run-scoped, expiring handle — and
395
- on a JSON handle it can ask for a `fields` dot-path projection instead (a
396
- deliberately small jq subset: `items[].name`, `[].stargazers_count`), so a big
397
- API dump narrows to just the values needed without the raw body ever entering
398
- the window.
399
-
400
- The same pipeline governs the **host's own tools**, not just ours — an
401
- oversized native result is rewritten at `tool.execute.after` into the same
402
- preview + handle shape. Report-shaped results are the third outcome: a table
403
- with a hole in it is not a table, so a result carrying a Markdown table is
404
- **capped keeping its table lines** (`nativeReportMaxTokens`) and the prose
405
- between them is what goes.
406
-
407
- ### Session + project + global memory (tm_memory)
408
-
409
- Durable facts — build commands, environment quirks, architecture decisions,
410
- your conventions — live as human-editable Markdown with frontmatter, in
411
- THREE tiers:
412
-
413
- - **`session`**: this conversation's transients only — in-process, TTL-swept
414
- (`memorySessionTtlMin`, default 240 min), invisible to other
415
- sessions; ephemeral unless `memorySessionPersist: "1"` writes them under
416
- `memories/sessions/<sid>/`.
417
- - **`project`** (default): `<repo>/.git/opencode-team/memories/…` — per checkout, git-adjacent. Facts about THIS repo: build commands, environment quirks, architecture decisions.
418
- - **`global`**: `~/.opencode-team/memories/global/` (override `memoryGlobalDir`) — **follows you across ALL projects**. User-level conventions: preferred package manager, commit style, tooling habits.
419
-
420
- Actions: `add` / `search` (deterministic keyword scoring) / `list` / `forget` /
421
- `compact`; 4000 chars per memory. `search` walks ALL tiers with **session >
422
- project > global precedence** — project entries get a +2 near-tie weight and a
423
- same-title higher-layer twin shadows the lower one (it never surfaces).
424
- Near-duplicates never pile up: an `add` that hits an existing entry in the same
425
- tier and category (dedup key, or title+keywords Jaccard ≥ 0.6) **folds into
426
- it** — new content wins, keywords union, the old slug moves to `supersedes:`,
427
- and the answer says 已合并 (that is normal; don't re-add under a variant title).
428
- When a tier reaches `memoryMaxEntries` (200 per scope) the add fails on
429
- purpose: run `compact` first — it dry-runs the merge plan by default, and
430
- re-running with `apply:true` performs it after copying every original to a
431
- timestamped `.compact-backup` tree (the rollback path). Entries older than
432
- `memoryStaleDays` (30) surface tagged `[stale Nd]` in search. Agents
433
- are prompted to search before assuming conventions and to save hard-won
434
- facts for the next conversation.
435
-
436
- ### 🌐 Web search that actually works (in China)
437
-
438
- `tm_search` is the open-ended-lookup front: **one call, one query, clean
439
- results**. The engine URL is built for you, fetched through the governed
440
- pipeline, and collapsed into a numbered title+URL hit list — the agent never
441
- sees raw SERP chrome.
442
-
443
- | Engine | Notes |
444
- |---|---|
445
- | `auto` (default) | Classifies the query, fans the matching engines out **in parallel** (every route has ≥2 legs, because a hit two engines agree on is worth more than one engine's opinion of itself), 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 `searchRelevanceFloor`), 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 `searchDefaultEngine` |
446
- | `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 |
447
- | `bing-int` | The same host with `&ensearch=1` for English results. It is deliberately **out of every `auto` route** — two layouts of one index would give bing a double vote |
448
- | `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 |
449
- | `hn` | Hacker News via Algolia API (no key) → story titles + snippets with direct article URLs |
450
- | `bilibili` | video search |
451
- | `moegirl` | MediaWiki search API — entry titles + snippets, structured |
452
- | `npm` | registry search → name@version + description, structured |
453
- | `github` | repo search API → stars + description, structured; `org:` / `user:` / `stars:` / `language:` qualifiers fold into the query (e.g. `vector db stars:>500 language:rust`) |
454
-
455
- All the HTML engines are reachable from mainland China **without API keys**, and
456
- every one of them sits on the seeded domain allowlist. The previous CN HTML
457
- SERPs (`sogou` / `so` / `baidu`) were **removed** — a live
458
- benchmark (2026-09-14) showed them serving anti-bot shells or 100% empty
459
- results; they are not even manually selectable. On an empty result,
460
- the error names the alternative engines instead of leaving the agent stuck.
461
- Two more channels complete the surface:
462
-
463
- - `tm_webfetch` — a known URL, one governed GET. Search-engine pages it
464
- fetches are auto-extracted to hit lists too. JSON endpoints like
465
- `registry.npmjs.org/<pkg>/latest` pass through untouched.
466
- - **Interactive browsing is the host's own `browser_*` tools** (`browser_tabs_open`
467
- · `browser_navigate` · `browser_snapshot` · `browser_click` · `browser_evaluate`
468
- …). The self-built `tm_browser` was **removed in 1.7.0** (a breaking change):
469
- the desktop renders a browser in its side panel and that panel attaches to the
470
- server's own browser service, so a plugin cannot register a page of its own
471
- (forensics: `docs/research/browser-pane.md`). The host catalog is policed by
472
- `src/host/v2-browser-gate.ts` at `execute.before` — the URL of every navigate/open,
473
- the path of every `browser_preview`, and every browser URL named inside an
474
- `execute` program are classified against the address red lines and the env-file
475
- rule, and a refused call the host runs anyway has its page replaced with the same
476
- refusal, so no out-of-policy content reaches the context, the store or the
477
- trajectory. Calling convention differs from the deleted tool: `evaluate` takes
478
- `{tabID, script}` where `script` is an **expression** (not function source) and
479
- the return value must be a scalar you `JSON.stringify` yourself; snapshot tokens
480
- read `@e8 [link]`. **Known cost, accepted:** on a host with no native browser
481
- catalog (CLI / standalone) there is now no browser at all — the agent reports that
482
- gap rather than simulating one.
483
-
484
- When a fetch still returns **403 after the real-Chrome headers**, the error
485
- is a DIRECTIVE: the gate is JS-challenge / TLS-fingerprint based and only a
486
- real browser passes — the agent is told to open that URL with the host's
487
- native `browser_navigate` (and read it with `browser_snapshot`). Search hit lists also
488
- filter known noise: engine-internal wrappers (`so.com/link?`, `ai.so.com`)
489
- and same-name-different-site domains (`maimai.cn` 脉脉 vs the maimai DX
490
- game) never ride along — extend the hit blacklist with `hitBlacklist`.
491
-
492
- Seeded allowlist (all three web tools; 22 hosts — baidu/moegirl/bilibili are
493
- PARENT domains, so every sibling subdomain — baike.baidu.com,
494
- mzh.moegirl.org.cn, space.bilibili.com — is covered):
495
- `baidu.com`, `bdimg.com` (Baidu's own script + asset CDN — not a baidu
496
- subdomain, and a page whose bundle we block is a blank page we would then
497
- report as "no content"), `moegirl.org.cn`, `bilibili.com`, `www.sogou.com`,
498
- `www.so.com`, `cn.bing.com`, `www.bing.com`, `zhihu.com`, `juejin.cn`,
499
- `csdn.net`, `cnblogs.com`, `gitee.com`, `github.com`, `api.github.com`,
500
- `raw.githubusercontent.com`, `gist.githubusercontent.com`, `ghproxy.net`
501
- (mainland mirror for github raw), `stackoverflow.com`, `npmjs.org`, `pypi.org`,
502
- `learn.microsoft.com` — plus the two JSON search-engine hosts
503
- (`api.stackexchange.com`, `hn.algolia.com`) while the default seed is in play,
504
- so 24 effective. Extend via `webfetchAllowedDomains` (`"*"` opens every host; a
505
- custom list REPLACES the seed, so keep the engine hosts or `tm_search` loses its
506
- targets). Architect / implementer / reviewer have NO network grant — web
507
- questions come back as a reported gap, never simulated. The tester carries the
508
- host's native `browser_*` tools ONLY, for governed UI verification of the project
509
- (local dev servers, preview routes); open web fetching stays with the two
510
- network roles.
511
-
512
- **Out-of-allowlist targets are a gate, not a wall.** When a fetch / search /
513
- browser-open points at a host outside the allowlist, the governed call **fails
514
- closed with a refusal naming the exits** — on 2.x a plugin cannot raise the
515
- host's dialog, so there is no window to wait for and a gate with no door is not
516
- a gate. Your doors are `privateSpace: "allow"` in `team-mode.jsonc`, or that one
517
- hostname in `webfetchAllowedDomains`. Below that gate sit the classes no config
518
- opens: cloud-metadata / link-local / multicast / reserved / benchmarking ranges
519
- are refused outright with no consent path, including their IPv4-mapped and
520
- DNS64 spellings (changing the notation is not a bypass), and env-file URLs and
521
- non-http(s) schemes are hard-rejected.
522
-
523
- ### Security: R6 env protection + R2 dangerous operations
524
-
525
- **R6 is armed by default, and it is a `strict` default.** `envProtect` accepts
526
- `strict` / `standard` / `off` and resolves to `strict` by default. With TeamMode
527
- active:
528
-
529
- - **Env-FILE reads are a hard `deny`** — a Team role's native `read` /
530
- `edit` / `glob` / `grep` of a `.env` is refused with no consent path. The
531
- host's `grep` reports the *pattern* as its permission resource rather than the
532
- path, so the same rule also runs on the whole tool input (`grep SECRET .env`
533
- cannot slip through). Templates (`*.env.example` / `.sample` / `.template` /
534
- `.dist`) stay readable.
535
- - **Env-variable reads in a shell command go to the host's permission prompt**
536
- (`ask`). The per-command classifier decides, so an ordinary `git status` asks
537
- nothing and an env dump still does; env reads no wildcard can express
538
- (embedded `$VAR` / `${VAR}` / `$env:` inside another command, command
539
- substitution) are **never** asked — they are refused. The audit log records
540
- only tool name + pattern category + verdict — never command text, paths,
541
- variable names or values.
542
-
543
- **R2 dangerous operations (the same face).** Delete, git publish, network
544
- fetch, package install/publish, process/system, privilege changes — none are
545
- silently allowed. The normal verification stack (`npm test`, `tsc`,
546
- `git status`) is NOT gated, so day-to-day work runs uninterrupted.
547
-
548
- **The plugin never self-allows.** Every hook it registers can only make a rule
549
- *stricter*; a permission it is asked about is replied `deny` or left alone, never
550
- `allow`.
551
-
552
- > ⚠️ **When you approve the host's own dialog, pick "once" — not "always".**
553
- > Verified on the live host, "always" records a far broader rule than the command
554
- > you saw: approving `Get-ChildItem env:PATH` with "always" stores `Get-ChildItem
555
- > *`, so every later `Get-ChildItem` runs with no dialog at all. The web channel
556
- > has the same trap and it is easier to fall into: one "always" on a host lets
557
- > **every agent session in that project** open it. The reply says which path let
558
- > a page in (static allowlist / the dialog you just answered / a saved rule that
559
- > answered in milliseconds), because an agent that cannot tell them apart reports
560
- > "no dialog" as "that site is allowed".
561
-
562
- > Deferral is per-session: the env face only applies in sessions running
563
- > TeamMode's generated roles. In any other session the plugin leaves the host's
564
- > behaviour exactly as it found it.
565
-
566
- ### Repo hygiene
567
-
568
- The offload/trajectory/memory stores live under `<repo>/.git/opencode-team/`
569
- (outside a git repo: the OS temp dir, sharded per workspace as
570
- `opencode-team/w-<hash>/`, so one project never reads another's payloads) —
571
- **never your working tree**. Every
572
- agent is instructed to delete scratch files before reporting done and to keep
573
- throwaway work in the OS temp dir. A TTL sweeper reclaims old task dirs at
574
- startup + hourly; the Team Lead never deletes boards itself, so you can audit
575
- any run.
576
-
577
- ---
578
-
579
- ## ⚙️ Configuration
580
-
581
- **Configuration is JSON, and only JSON.** `team-mode.jsonc` is the single
582
- configuration source. There is no environment layer, and **no `TM_*`
583
- configuration environment variable exists any more** — the ones you may still
584
- find in old configs are simply unknown keys, reported at boot and never applied.
585
- (Three `TM_*` names survive as internal/test switches, listed at the end of
586
- this section.)
587
-
588
- ### Where the file lives
589
-
590
- | Layer | Path | Precedence |
591
- |---|---|---|
592
- | **global** | `~/.config/opencode/team-mode.jsonc` (honours the host's `OPENCODE_CONFIG_DIR`) | lowest — applies to every project |
593
- | **project** | `<dir>/team-mode.jsonc`, for every directory from the workspace **up to the filesystem root** | higher — direct files merge farthest→closest |
594
- | **project** | `<dir>/.opencode/team-mode.jsonc`, same walk | **highest** — every `.opencode/` file overrides every direct file |
595
-
596
- That walk and precedence are the host's own config-layering rule, copied rather
597
- than invented. JSONC is supported: `//` and `/* */` comments are masked at the
598
- byte level, so a commented-out key cannot read as a live one. A layer that fails
599
- to parse is skipped **whole** (half a config is worse than none) while a single
600
- bad key loses only itself; unknown keys are warned about and never applied.
601
- `tm_stats` renders the result: per-key source, skipped layers, unknown keys, and
602
- the auto-create state.
603
-
604
- ### It writes itself
605
-
606
- When the global file is **absent**, the plugin creates it at boot — atomically,
607
- idempotently, and **never overwriting an existing file**. What it writes is an
608
- **inert** template: all **57** registry keys, each as a *comment* under a
609
- one-line description, so the file parses to `{}` and sets nothing until you
610
- uncomment what you want.
611
-
612
- ```jsonc
613
- // 全局配置。取消注释即可生效;默认全部注释 = 什么都不设置。
614
- {
615
- // "offloadThreshold": 2000, // 卸载阈值(估算 token;等于阈值也卸载)。
616
- // "envProtect": "strict", // R6 环境防护模式(strict/standard/off)。(红线:仅全局)
617
- // …共 57 个键,每个都带一行说明
618
- }
619
- ```
620
-
621
- Turn it off with the plugin option `autoCreate: false`, or the internal switch
622
- `TM_CONFIG_AUTOCREATE=off`.
623
-
624
- ### Red-line keys
625
-
626
- Five keys are **honored only in the global file**: `envProtect`, `r6FineAsk`,
627
- `privateSpace`, `webfetchAllowedDomains`, `bashReadonlyAllowed`. A project file
628
- may set them, but the value is **ignored and reported** — a committed project
629
- config must not be able to switch off a guard for everyone who clones the repo.
630
- The rule is derived from the registry itself (`redLine: true` on the spec), so a
631
- new red-line key is red-line by declaration.
632
-
633
- ### Plugin options
634
-
635
- Options live on the plugin entry, not in `team-mode.jsonc`:
636
-
637
- ```jsonc
638
- {
639
- "plugins": [
640
- { "package": "@te-river/opencode-team-mode@latest",
641
- "options": { "defaultAgent": true, "autoCreate": true, "ttlDays": 7, "envProtect": true } }
642
- ]
643
- }
644
- ```
645
-
646
- | Option | Default | Meaning |
647
- |---|---|---|
648
- | `defaultAgent` | `true` | Promote Team to the default agent slot. Opt out with `false`. |
649
- | `autoCreate` | `true` | Write the inert global `team-mode.jsonc` at boot when absent. |
650
- | `ttlDays` (alias `blackboardTtlDays`) | `5` | Blackboard retention, valid range (0, 365]. |
651
- | `envProtect` | `true` | Plugin-wide kill switch; `false` resolves the R6 mode to `off`. |
652
-
653
- On 2.x a plugin entry is either a **string** or an **object** with `package` and
654
- `options`. The 1.x tuple form `["@te-river/…", { … }]` is rejected
655
- (`path=$.plugins.1 kind=invalid`, measured 2026-10-06). Options do arrive — with
656
- the object form the boot row reads `board_ttl_days=9` for `{ "ttlDays": 9 }`, so
657
- this is measured, not documented-and-hoped.
658
-
659
- ### Model choice
660
-
661
- Every judgment — triage, decomposition, dispatch briefs, synthesis, review
662
- verdicts — flows through the Team Lead. A weak model in that seat degrades the
663
- whole pipeline no matter how strong the specialists are. Pin your best reasoning
664
- model to `team`:
665
-
666
- ```jsonc
667
- {
668
- "agent": {
669
- "team": { "model": "anthropic/claude-opus-4-5" }, // Lead earns your best model
670
- "implementer": { "model": "anthropic/claude-sonnet-4-6" } // specialists tolerate cheaper
671
- }
672
- }
673
- ```
674
-
675
- Your own agents named `team` / `architect` / … always take precedence; the
676
- plugin never clobbers user definitions. See [Customization](#-customization)
677
- for overrides, extra agents and disabling roles.
678
-
679
- ### Key reference (all 57)
680
-
681
- **Offload, previews and the store**
682
-
683
- | Key | Type | Default | Meaning |
684
- |---|---|---|---|
685
- | `offloadThreshold` | number | `2000` | Global offload boundary (estimated tokens, CJK-aware), used when the content class is unknown. A result AT the threshold offloads. |
686
- | `offloadThresholdText` | number | `4000` | Boundary for prose (text / log / markdown). Inherits the global value unless set. |
687
- | `offloadThresholdData` | number | `2000` | Boundary for structured payloads (json / csv / code / binary). Same inheritance. |
688
- | `previewLines` | number | `20` | Raw lines a preview builder may scan. |
689
- | `previewMaxTokens` | number | `80` | Hard preview cap. |
690
- | `fetchMaxLines` | number | `2000` | `tm_fetch` per-segment line cap. |
691
- | `blackboardDir` | string | auto | Run-payload store dir. Empty = `<repo>/.git/opencode-team/blackboard`. Explicit = absolute or project-relative. |
692
- | `trajectoryDir` | string | auto | Trajectory store dir. Empty = `<repo>/.git/opencode-team/trajectory`. |
693
- | `blackboardTtlDays` | number | `7` | Handle TTL and the physical sweep period for expired run dirs. |
694
- | `storeReclaim` | `on`/`off` | `on` | At boot, reclaim what an upgrade left behind: a per-workspace shard idle past the TTL, and the pre-shard `blackboard/` + `trajectory/` at the temp-dir fallback. **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. |
695
- | `taskOffload` | `on`/`off` | `on` | Keep the host's background sub-agent inside the context budget: when it finishes, the injected full reply is replaced by a preview + a `tm_join` pointer. Touches only synthetic parts carrying the host's own `<task id=… state="completed">` / `<subagent … state="completed">` envelope and over the text threshold — a typed message is never touched even if it contains a perfect envelope, and a `state="error"` child is never rewritten. **Nothing is copied to disk**: the text stays where the child session already wrote it. `off` restores the host's verbatim injection. |
696
- | `boardMaxChars` | number | `200000` | `tm_board_write` per-file character cap — over it the write **refuses** (with a "split the topic" hint) rather than truncating a deliverable. |
697
- | `boardMaxFiles` | number | `200` | Markdown files allowed per session folder. The TTL sweeper is the only reclaim path, so the refusal names it. |
698
- | `joinMaxWaitMs` | number | `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. |
699
- | `ledgerMaxItems` | number | `200` | Ceiling on `tm_ledger` items per session. The host's `ctx.storage` has no TTL and no quota (measured), so the list refuses to grow past this instead of quietly dropping the oldest asks — and a refusal is something the lead can act on, while a silent truncation is a claim nobody can re-check. |
700
-
701
- **Memory**
702
-
703
- | Key | Type | Default | Meaning |
704
- |---|---|---|---|
705
- | `memoryGlobalDir` | string | auto | GLOBAL tier store. Empty = `~/.opencode-team/memories/global`. |
706
- | `memorySessionTtlMin` | number | `240` | Session-tier entry TTL (lazy + boot sweep). |
707
- | `memoryMaxEntries` | number | `200` | Per-scope entry cap; over it `add` fails on purpose — run `compact`. |
708
- | `memoryStaleDays` | number | `30` | Age after which search hits are tagged `[stale Nd]` (`0` disables). |
709
- | `memorySessionPersist` | string | `""` | `""` = in-process only; `"1"` also writes session entries under `memories/sessions/<sid>/`. |
710
-
711
- **Web and search**
712
-
713
- | Key | Type | Default | Meaning |
714
- |---|---|---|---|
715
- | `webfetchAllowedDomains` | string[] | 22-host seed | **red line.** Outbound allowlist (`"*"` = any host; `[]` = deny all). A custom list **replaces** the seed — keep the engine hosts. `"*"` does **not** cover private space: loopback / RFC1918 / CGNAT / `.localhost` still need `privateSpace: "allow"`, 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 opens. |
716
- | `searchDefaultEngine` | string | `auto` | Engine when no `engine` arg is given (`auto` = classify + parallel fan-out + RRF fusion; any table name also pins a manual default). |
717
- | `searchMaxHits` | number | `10` | Hits kept per engine leg and in the fused list. |
718
- | `searchWeights` | record | `{}` | Per-engine fusion weight overrides, e.g. `{"bing": 0.3}`; anything unset keeps the built-in table. |
719
- | `searchDisabledEngines` | string[] | `[]` | Engines removed from the roster AND from every `auto` route. |
720
- | `searchRelevanceFloor` | number | `0.35` | Weight fraction kept by a hit sharing no query token with its title/snippet/host (demotes junk without deleting an engine). |
721
- | `hitBlacklist` | string[] | `[maimai.cn]` | Extra domains never listed as search hits (same-name-different-site noise like 脉脉). Merged with the built-in entry. |
722
- | `webCacheTtlSec` | number | `300` | How long a governed fetch may re-serve the same URL (`0` = off). One store shared by `tm_webfetch` / `tm_search`; entries are hash-named (a token-bearing query never hits disk) and are only read or written for hops the STATIC allowlist admitted — so a hit can neither resurrect a removed host nor substitute for consent. A re-served page says 缓存命中. |
723
-
724
- **Rounds, dispatch and context**
725
-
726
- | Key | Type | Default | Meaning |
727
- |---|---|---|---|
728
- | `prune` | `on`/`off` | `on` | Context pruning: replace a SETTLED message body with a self-explaining pointer (an offload handle, a child id, a note). Evidence is never destroyed — the reply skeleton, GOAL/ACCEPTANCE, provenance, system messages, a still-running child and an uncollected child id are protected whole, and the untouched messages stay byte-exact. `off` disables. |
729
- | `pruneAtPercent` | number | `70` | Prune once the request reaches this share of the model's window, derived from `limit.context` — never a hard-coded token count. **Clamped to 40–90.** |
730
- | `pruneKeepTailPercent` | number | `40` | Share of the window kept verbatim at the tail; the newest message is always kept. |
731
- | `splitAdvice` | `on`/`off` | `on` | Inject a split suggestion when a dispatch brief carries too many acceptance criteria. `off` stops the hint (the prompt discipline stays). |
732
- | `splitBriefTokens` | number | `4000` | The brief token threshold that triggers it. **Clamped to ≥200.** |
733
- | `splitMaxCriteria` | number | `3` | More acceptance criteria than this is a signal to split. |
734
- | `retry` | `on`/`off` | `on` | Retry governor: classify a quota / rate / transient / unknown error **by name and text only**, compute jittered backoff, and inject ONE directive naming the exact seconds to wait. After `retryBreakAfter` consecutive errors a cooldown denies new `subagent` dispatches. Honest boundary: there is no seam to intercept the model's own retry — it identifies, states the wait, and refuses new work; it does not wait for the model. |
735
- | `retryBaseMs` | number | `5000` | First backoff; doubles per consecutive error. |
736
- | `retryMaxMs` | number | `60000` | Ceiling for that backoff. |
737
- | `retryJitter` | number | `0.3` | ± fraction applied to the wait, so parallel sessions do not re-fire together. |
738
- | `retryBreakAfter` | number | `5` | Consecutive errors before the breaker trips. |
739
- | `retryCooldownMs` | number | `60000` | How long new sub-agent dispatches are refused once it has. |
740
-
741
- **Host-surface governance (2.x)**
742
-
743
- | Key | Type | Default | Meaning |
744
- |---|---|---|---|
745
- | `nativeOffload` | `on`/`off` | `on` | Govern the HOST's own `read`/`grep`/`glob`/`shell` results through the same pipeline. `off` restores the host behavior; the boot line distinguishes "you turned it off" from "this host has no execute.after". |
746
- | `nativeSnapshotMaxTokens` | number | `1200` | Budget a native `browser_snapshot` keeps in context. Addressing lines win it before static text does; past `budget × 4` the reply states how many ref lines did not fit, and kept + dropped always equals the total. |
747
- | `nativeReportMaxTokens` | number | `1600` | Budget a report-shaped native result (anything carrying a Markdown table) keeps. Table lines and their headings win the space; the full text still rides the handle. |
748
- | `probeChain` | `on`/`off` | `on` | After a run of native `read`/`grep`/`glob`/`shell` passes, append ONE line naming `execute` (Code Mode) and what it saves. A hint, never a gate: the original body is preserved verbatim, nothing is rejected, and the append is idempotent. |
749
- | `probeChainAfter` | number | `3` | How many consecutive native calls before the hint starts (`0` = off). |
750
- | `v2BrowserGate` | `on`/`off` | `on` | The gate over the host's `browser_*` catalog (URLs and preview paths at `execute.before`, plus the browser URLs named inside an `execute` program). `off` restores ungoverned browsing; the boot line and `tm_stats` say which world is running. |
751
- | `v2CodeMode` | string | `""` | `direct` sends `options.codemode=false`; empty = catalog mode. We used to send `direct` by default and claim direct delivery — **a live 2.0.16 desktop session disproved it**: with the flag sent, every `tm_*` still arrived inside the host's Code Mode catalog, so the default now sends nothing. The observable truth is `tools_in_request` in `tm_stats` (请求内实际可见=…), never the flag we sent. |
752
- | `bashTimeoutProbeMs` | number | `60000` | Ceiling forced onto a `timeout` the model set for a read-only probe command. Applies ONLY to a command the read-only allowlist already accepts, and never invents a timeout the model omitted (`0` disables). |
753
- | `bashTimeoutMaxMs` | number | `0` | Optional global ceiling for every other shell command. `0` = off, so a real build keeps the timeout it asked for. |
754
- | `envProtect` | `strict`/`standard`/`off` | `strict` | **red line.** R6 mode. `off` also disarms the shell escalation. Any unrecognised value resolves to `strict`. |
755
- | `r6FineAsk` | string | classifier | **red line.** `off` falls back to asking about EVERY shell command — which is also what happens automatically on a host that does not expose the per-action evaluation hook, and the boot note says which of the two caused it. |
756
- | `privateSpace` | `allow`/`deny`/`ask` | `deny` | **red line.** Private space (loopback, RFC1918, ULA, CGNAT, `.localhost`) through our tools. The default is `deny` because a 2.x plugin cannot raise a dialog — telling the agent to wait for a window that will never open is not a gate with a procedure, so `ask` is the honest spelling of "not answerable" and an unrecognised value falls back to it. Never conflated with the FORBIDDEN ranges. |
757
- | `bashReadonlyAllowed` | string[] | built-in | **red line.** The P3 read-only command allowlist. `tasklist` / `ps` / `findstr` are seeded in, because `已确认关闭` is only checkable if the agent can ask the OS for the pid — a user-facing verification with no read path is the same defect as a lie. |
758
-
759
- **Legacy keys** — kept listed and parseable so an old config still loads, with
760
- **no v2 reader**, and reported as such:
761
-
762
- | Key | Default | Status |
763
- |---|---|---|
764
- | `askTimeoutFloorMin` | `1` | **Orphaned.** Its only consumer was the v1 approval gate, which was deleted (a 2.x plugin cannot raise a dialog, so there was nothing to time out on). Say so rather than leaving a knob that does nothing. |
765
- | `compactionContext` | `on` | v1-only |
766
- | `shellEnv` | `""` | v1-only |
767
- | `ptcWebBridge` | `on` | v1-only |
768
-
769
- > **Compaction timing belongs to the host, not to this plugin.** An earlier
770
- > release triggered its own summarization at 75% of the window; that was removed
771
- > by user decision — a plugin that summarizes a live conversation by itself
772
- > takes a context-losing action you did not ask for. What remains is additive and
773
- > runs only when the HOST compacts: the must-survive list (reply skeleton,
774
- > offload handles, open sub-agent session ids, provenance, board paths) rides the
775
- > host's own `session.hook("compaction")`, and the host's summarizer prompt is
776
- > never replaced.
777
-
778
- ### The three surviving `TM_*` names
779
-
780
- These are **internal / test switches**, not configuration — they are read from
781
- the environment because a test or a diagnostic needs them without a config file:
782
-
783
- | Name | Effect |
784
- |---|---|
785
- | `TM_STORE_RECLAIM` | Overrides the `storeReclaim` key (`off` = leave the disk exactly as found). The test runner sets it, because suites boot real runtimes in temp dirs. |
786
- | `TM_V2_PROBE` | Path to a JSONL file where the surface probe records the host's real tool ids, permission action names and argument key **names**. Names and counts only — never a command line, path, URL or env value. It is how "does the host actually have X?" gets answered from the running build instead of from a doc. |
787
- | `TM_CONFIG_AUTOCREATE` | `off` suppresses the inert global-file auto-create. |
788
-
789
- Any **other** `TM_*` name in your environment is inert. If you have been setting
790
- one, move it into `team-mode.jsonc` under the matching key above.
791
-
792
- ---
793
-
794
- ## 🏗️ How the team works
795
-
796
- Sub-agents can't message each other live (platform limitation), so TeamMode
797
- coordinates them through a **structured reply skeleton** — every specialist
798
- reply is `STATUS: / CHANGES: / FINDINGS: / EVIDENCE: / HANDOFF:`, ≤50 lines,
799
- relayed verbatim by the Lead into the next dispatch. Files are the exception,
800
- not the rule: a deliverable over ~50 lines goes to ONE named board file under
801
- `<repo>/.git/opencode-team/` (round-suffixed, working tree untouched).
802
-
803
- - **Routing table:** question → direct answer; docs-only → implementer;
804
- product change → implementer → tester → reviewer; multi-module →
805
- architect → implementer → tester → reviewer(s); unknown tech → researcher
806
- first. Fixed minimums — a product change routed below 3 dispatches is a
807
- routing bug.
808
- - **One dispatch, one verifiable deliverable.** A dispatch is a unit of
809
- VERIFIABLE work, not a bucket for everything related. If the lead cannot say
810
- how a child's result will be verified *on its own*, it is not a dispatch yet —
811
- it is a wish. Cutting one deliverable into pieces that only make sense
812
- together is chopping, not splitting, and it costs you more rounds than it
813
- saves.
814
- - **The architect is conditional.** Dispatch it only when the design is
815
- genuinely unknown. With the root cause already verified (file:line evidence),
816
- skip it and dispatch the implementer with the exact fix spec; if the fix moves
817
- a contract or the strategy is undecided, keep the architect. The ceremony
818
- serves unknowns, not multi-file diffs.
819
- - **Tester and reviewer may run in the SAME round** — verification and review
820
- are independent of each other. Serialise them only when a fix invalidates
821
- both. Same for multiple implementers (each carrying its exact file ownership
822
- and verbatim data contracts) and testers on disjoint packages.
823
- - **Approval gate (count-based):** ≥2 dispatches → plan (≤30 lines) → **your
824
- approval** → execute. Blocking questions are batched and asked immediately.
825
- Splitting one ask into sub-2-dispatch pieces to dodge the gate is a protocol
826
- violation, not a trick.
827
- - **Only the Team Lead dispatches.** Specialists no longer hold the host's
828
- `task`/`subagent` capability, so no sub-agent spawns a sub-agent.
829
- - **Adaptive review:** one reviewer by default; three parallel dimensions
830
- only for high-risk profiles (auth/security, cross-module contracts, public APIs).
831
- - **Static verification:** build / typecheck / lint / tests. Improvised
832
- browser automation is banned; unverified UI work ends with
833
- `UI NOT VERIFIED: <what to check>`.
834
- - **Evidence standard:** "done / fixed / passed" claims need verifiable
835
- evidence — output, logs, diffs.
836
- - **Your language, not the tool's.** The governed tools answer in Chinese; the
837
- reply-language rule keeps your own language in the prose and quotes a Chinese
838
- string verbatim only where it IS the evidence.
839
-
840
- ---
841
-
842
- ## 🔧 Customization
843
-
844
- **Override an agent** — same name in your config wins:
845
-
846
- ```jsonc
847
- {
848
- "agent": {
849
- "reviewer": {
850
- "model": "anthropic/claude-sonnet-4-6",
851
- "prompt": "You are an extremely strict reviewer. Reject anything with a lint warning."
852
- }
853
- }
854
- }
855
- ```
856
-
857
- **Add your own agents** alongside the team:
858
-
859
- ```jsonc
860
- {
861
- "agent": {
862
- "devops": {
863
- "mode": "subagent",
864
- "description": "Handles CI/CD, Docker, and deployment tasks.",
865
- "prompt": "You are the DevOps engineer..."
866
- }
867
- }
868
- }
869
- ```
870
-
871
- **Disable one:** `"researcher": { "disable": true }`.
872
-
873
- Board retention, auto-create, the default slot and the R6 kill switch are
874
- plugin-entry `options` — see
875
- [Configuration](#️-configuration).
876
-
877
- ---
878
-
879
- ## ❓ Troubleshooting
880
-
881
- **Will this eat my tokens?**
882
- The opposite is the point. Offload + 80-token previews + the host's Code Mode
883
- `execute` exist because a five-agent pipeline naively bolted onto one context window
884
- *would* eat your tokens. The governance is the token-saver.
885
-
886
- **Is the web access safe?**
887
- It's the most guarded surface in the plugin: two full web roles plus a
888
- browser-only tester grant, a domain allowlist whose off-list calls fail closed,
889
- redirects re-checked per hop with the whole chain reported, env-file URL
890
- refusal, address red lines no setting opens, and every payload rides the same
891
- offload governance. No allowlisted page can bounce the fetch off-site.
892
-
893
- **Why doesn't the plugin auto-update?**
894
- OpenCode caches plugins by spec string and never re-resolves `@latest`
895
- (upstream limitation, not ours). **Re-run the installer — that IS the
896
- update** (it purges the cache and re-resolves npm copies); or delete the
897
- cache dir by hand. If the boot probe's `entrypoint=` line names a path outside
898
- `~/.cache/opencode/npm` or `~/.config/opencode/node_modules`, a `~/package.json`
899
- is pinning a different copy — that is the diagnostic, not a guess. Recipe above
900
- and in [docs/installation-v2.md](./docs/installation-v2.md).
901
-
902
- **A knob I set in an env var does nothing.**
903
- Configuration is JSON now. Any `TM_*` variable other than the three internal
904
- switches is inert; move the value into `team-mode.jsonc` under the registry key.
905
- Run `tm_stats` and read the layered-config section: it names the per-key source,
906
- so a value you expected to be honored shows up with a source that is not the file
907
- you edited.
908
-
909
- **A red-line key I set in the project file is ignored.**
910
- By design. The five red-line keys are honored only in the **global** file, and
911
- `tm_stats` reports the ignored attempt by name rather than dropping it silently.
912
-
913
- **My `AGENT NOT FOUND: "Team"`.**
914
- The file name IS the agent id, and Windows/APFS keep the existing spelling when
915
- a write opens that file through another one — so a pre-1.7.2 `team.md` survives
916
- every install and the host registers the lead as lowercase. Use `--agent team`.
917
- The installer's reclaim pass renames a case-only entry it has proven is the same
918
- file; a manual install may need the same rename.
919
-
920
- **Can agents run tools in parallel?**
921
- Yes — and they're *engineered* for it: parallel `tm_search` / `tm_webfetch` /
922
- `tm_fetch` calls get distinct step ids and isolated payloads. A regression
923
- here fails the test suite before it ever reaches you.
924
-
925
- **Does it work in the CLI (TUI), or only Desktop?**
926
- Both. Desktop adds the color-coded picker and panels; the governed tools and
927
- the whole workflow are host-agnostic. Interactive browsing is the host's own
928
- `browser_*` catalog, so a host with no native browser (CLI / standalone) has
929
- none — the agent reports that gap rather than simulating one.
930
-
931
- **What happens if I don't answer the host's permission prompt?**
932
- The host decides that, not this plugin. The plugin can only refuse: it never
933
- self-allows, and every guard it installs can only make a rule stricter. A
934
- session it does not recognize as one of its own is left exactly as the host
935
- behaved.
936
-
937
- ---
938
-
939
- ## 🗑️ Uninstall
940
-
941
- 1. Remove the entry from the `"plugins"` array in your config file; if you installed on 2.x, delete the generated `~/.config/opencode/agents/*.md` and `commands/team-*.md` too, and any `default_agent: "team"` you no longer want.
942
- 2. Delete the cache dir (table in [Install](#-read-this-once-save-yourself-an-hour-later)) if you want the disk space back.
943
- 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. The global `team-mode.jsonc` is yours to keep or delete — the plugin will simply write a fresh inert one if you remove it.
944
-
945
- No DLLs were harmed. Nothing was written to your working tree.
946
-
947
- ---
948
-
949
- ## 🏛️ Architecture (for the curious)
950
-
951
- ```
952
- opencode-team-mode/
953
- ├── src/
954
- │ ├── index.ts ← Plugin entry ({id, setup} — v2 only)
955
- │ ├── agents.ts ← Agent structure (modes, colors, temperatures, whitelist matrix)
956
- │ ├── prompts/ ← Agent prompts (lead / specialists / shared) — pinned by tests
957
- │ ├── commands.ts ← Slash command definitions
958
- │ ├── blackboard.ts ← Shared blackboard + TTL sweeper
959
- │ ├── envprotect.ts ← R6 facade (patterns / classifiers / gate predicates / hook)
960
- │ ├── identity.ts ← Agent-name identity (case-insensitive lead match)
961
- │ ├── tm/ ← Governed tools: pipelines / store / preview / guard / refs /
962
- │ │ config-layers (the 57-key registry) / config-files (the two
963
- │ │ layers) / config-template (the inert auto-created file) /
964
- │ │ webfetch / search / memory / board / ledger / dispatch
965
- │ ├── host/ ← v2 personality (setup / guard / offload / session / events / …)
966
- │ └── types.ts ← Loader-contract types
967
- ├── docs/installation.md ← Historical 1.18.x guide (no longer supported)
968
- ├── docs/installation-v2.md ← The 2.x install guide (roles arrive as generated config files)
969
- ├── scripts/ ← One-line installers (bash / PowerShell)
970
- ├── pt07/ ← PT-07 baseline suite (seeded A/B token measurement)
971
- └── README.*.md ← You are here (twice)
972
- ```
973
-
974
- The loader calls `setup(ctx)` once: it registers the `tm_*` tools, resolves the
975
- two config layers, installs the R6/address guard on `permission.evaluate`, attaches
976
- the JIT offload on `tool.execute.after`, and publishes the blackboard note. User-defined
977
- agents with the same name always win — the plugin never clobbers.
978
-
979
- The one rule that makes the config layer trustworthy: **`CONFIG_KEYS` is the
980
- registry and the single source of truth.** A key absent from it is reported as
981
- unknown and never applied; the red-line set is derived from that registry rather
982
- than hand-listed; and the auto-created global file is rendered *from* the
983
- registry, so it cannot drift from what the code actually reads.
984
-
985
- ---
986
-
987
- ## 🤝 Contributing
988
-
989
- Issues and PRs welcome. Especially wanted: localization of agent prompts,
990
- more agent roles, more command templates, and real-world reports of the
991
- search engines' behavior (they rearrange their markup; the extractor filters
992
- are intentionally loose but not psychic).
993
-
994
- ---
995
-
996
- ## 📄 License
997
-
998
- [Apache License 2.0](./LICENSE)
999
-
1000
- ---
1001
-
1002
- ## 🔗 Links
1003
-
1004
- - [npm Package](https://www.npmjs.com/package/@te-river/opencode-team-mode) — `@te-river/opencode-team-mode`
1005
- - [Installation guide, **OpenCode 2.x**](./docs/installation-v2.md) — the supported install: a 2.x plugin cannot create an agent, so the six roles and six commands are generated into the config directory
1006
- - [Installation guide, 1.18.x](./docs/installation.md) — **historical only**: the 1.18.x personality was removed in the 1.7.0 line, so this page is kept for reference and is not a working install path
1007
- - [OpenCode Desktop](https://opencode.ai) — Official website & download
1008
- - [OpenCode Docs](https://opencode.ai/docs) — Configuration & plugin documentation
1009
- - [OpenCode Plugin API](https://opencode.ai/docs/plugins) — Build your own plugins
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
+ > 🤝 **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, no 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. This package supports **OpenCode 2.x
23
+ > only** — the 1.18.x personality was removed in the 1.7.0 line:
24
+ > 2.x → https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation-v2.md
25
+ > (a 2.x plugin cannot create an agent, so the six roles and six `/team-*` commands come
26
+ > from a generator step in that guide — that step is not optional.) Then verify the install
27
+ > using the checks in that guide.
28
+ > ```
29
+ >
30
+ > **The one command to remember afterwards:** `/team-run <task>` — the Team Lead
31
+ > plans it, shows you the plan, waits for your approval, then runs the whole team.
32
+
33
+ Everything else below is detail. When you're ready for it, here's the map:
34
+
35
+ **[Why](#-why-teammode) · [The team](#-the-team) · [Install](#-install) · [Usage](#-usage) · [Tools & security](#-governed-tools--security) · [Configuration](#️-configuration) · [How it works](#-how-the-team-works) · [Troubleshooting](#-troubleshooting) · [Uninstall](#-uninstall)**
36
+
37
+ ---
38
+
39
+ ## 🤔 Why TeamMode?
40
+
41
+ Because a single agent doing everything is how you get: a context window stuffed
42
+ with 5000-line file dumps, twenty round-trips to `shell` for what one script could
43
+ do, sub-agents that silently read `.env`, and web "research" that is really just
44
+ the model's imagination.
45
+
46
+ TeamMode's answer to each:
47
+
48
+ | Pain | TeamMode's answer |
49
+ |---|---|
50
+ | 🔥 **Context flooding** | Every governed result over its content-class offload boundary (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. |
51
+ | 🐌 **Round-trip overhead** | The host's own `execute` (Code Mode): the agent writes ONE program that makes N governed calls in a single turn. Zero LLM round-trips during the run. |
52
+ | 🕳️ **Silent side effects** | The R6 env-protection face: a Team role's `read` of a `.env` is **denied** with no consent path, and a shell command that reads the environment goes to the host's own permission prompt. The plugin never approves on its own — it can only reject. |
53
+ | 🌫️ **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. |
54
+ | 🧭 **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 renderer's supported set is measured rather than assumed, and the prompts carry the negative half of that measurement — footnotes, `==highlight==`, a bare `---` rule and `$…$` math reach you as literal text, so agents are told not to use them, while `mermaid` diagrams are offered because this host does draw them. |
55
+ | 🎯 **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 lead's ledger, `tm_join` says 目标未达成 and lists them, and the goal is carried through context compaction so a summarized transcript cannot redefine it. |
56
+ | 🗣️ **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 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. |
57
+ | ⏱️ **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 `execute` (Code Mode) program, 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. |
58
+
59
+ And the workflow discipline underneath: deterministic routing, a ≤30-line plan
60
+ you approve before ≥2 dispatches execute, structured `STATUS/CHANGES/FINDINGS/
61
+ EVIDENCE/HANDOFF` replies between agents, and static verification (build /
62
+ typecheck / tests) instead of vibes.
63
+
64
+ That discipline is also why the recommendation is **medium-to-large
65
+ projects**: on a two-file script the team simply has less to govern.
66
+
67
+ ---
68
+
69
+ ## 👥 The team
70
+
71
+ | Agent | Role | When to use |
72
+ |---|---|---|
73
+ | 🎯 **Team Lead** (`@team`) | Orchestrator | Complex tasks that need planning + multi-step execution |
74
+ | 🏗️ **Architect** | System designer | Design docs, module structure, API contracts — **dispatched only when the design is genuinely unknown** |
75
+ | 💻 **Implementer** | Code writer | Building features, writing production code |
76
+ | 🔍 **Reviewer** | Dimension-focused auditor | Single-dimension review by default; 3 in parallel only for high-risk changes |
77
+ | 🧪 **Tester** | Test engineer | Tests with real edge cases; static verification (build / typecheck / lint); governed UI verification via the host's native `browser_*` tools |
78
+ | 🔎 **Researcher** | Knowledge finder | Local repo first, then the web — one of the two network roles (with the Lead) |
79
+
80
+ Out of the box, **Team is your default agent** — new chats open straight into the
81
+ orchestrator (opt-out in [Configuration](#️-configuration)).
82
+
83
+ ---
84
+
85
+ ## 📦 Install
86
+
87
+ ### Option 1 — Let your agent do it (recommended)
88
+
89
+ Copy this into any coding agent — it will edit your config, restart-remind you, and verify:
90
+
91
+ ```text
92
+ Install the OpenCode plugin @te-river/opencode-team-mode. This package supports **OpenCode 2.x
93
+ only** — the 1.18.x personality was removed in the 1.7.0 line:
94
+ 2.x → https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/docs/installation-v2.md
95
+ (a 2.x plugin cannot create an agent, so the six roles and six `/team-*` commands come from
96
+ a generator step in that guide — that step is not optional.)
97
+ (If a URL is unreachable — common on mainland-China networks — retry with
98
+ the mirror prefix: https://ghproxy.net/ + the same path. And if `npm` is
99
+ slow or blocked, point it at a registry mirror for this install:
100
+ `npm config set registry https://registry.npmmirror.com` — or add
101
+ `--registry https://registry.npmmirror.com` to the one command that needs it.)
102
+ Then verify the install using the checks in that guide.
103
+ ```
104
+
105
+ (The guide is the complete manual procedure — config file locations, plugin
106
+ entry, restart, verification, update and uninstall. Your agent reads it and
107
+ executes it faithfully; there is nothing else it needs.)
108
+
109
+ ### Option 2 — One-line script
110
+
111
+ macOS / Linux (bash):
112
+
113
+ ```bash
114
+ curl -fsSL https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.sh | bash
115
+ ```
116
+
117
+ Windows (PowerShell):
118
+
119
+ ```powershell
120
+ irm https://ghproxy.net/https://raw.githubusercontent.com/Te-River/Opencode-TeamMode/main/scripts/install.ps1 | iex
121
+ ```
122
+
123
+ ### Option 3 — Manual
124
+
125
+ Add the plugin to your `opencode.jsonc`:
126
+
127
+ ```jsonc
128
+ {
129
+ "$schema": "https://opencode.ai/config.json",
130
+ "plugins": [
131
+ "@te-river/opencode-team-mode@latest"
132
+ ]
133
+ }
134
+ ```
135
+
136
+ OpenCode installs the plugin on next startup.
137
+
138
+ > **The key is `plugins` (plural).** A 2.x host never reads the singular `plugin`
139
+ > key, and it installs the package itself from the entry at startup. Entries
140
+ > across config files are **applied lowest→highest rather than replacing one
141
+ > another**, so keep exactly one Team entry — writing ours into both
142
+ > `opencode.json` and `opencode.jsonc` loads the plugin twice. See
143
+ > [docs/installation-v2.md](./docs/installation-v2.md) for the 2.x flow (a plugin
144
+ > cannot create an agent there, so the six roles and six commands are generated
145
+ > config files);
146
+ > `docs/research/plugin-loader-contract.md` has the host's own loader code.
147
+
148
+ ### ⚠️ Read this once, save yourself an hour later
149
+
150
+ - **Restart to activate.** After touching the OpenCode config, fully quit and restart OpenCode (Desktop: quit from tray, not just the window).
151
+ - **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:
152
+
153
+ | OS | Purge command — recursive, covers BOTH cache layouts |
154
+ |---|---|
155
+ | macOS / Linux | `find ~/.cache/opencode/packages -type d -name '*opencode-team-mode*' -prune -exec rm -rf {} +` |
156
+ | 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 } }` |
157
+
158
+ ⚠️ 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).
159
+
160
+ ⚠️ **A published version can be shadowed by your HOME.** For a package spec the host resolves the entrypoint through the nearest `node_modules` walk starting at HOME, so a stray `~/package.json` with a `devDependencies` entry pinning `@te-river/opencode-team-mode` makes the host load *that* copy. The diagnostic is the boot probe's `entrypoint=` line, not a guess about cache layers. Full recipe (including an agent-driven update prompt): [installation guide, Updating](./docs/installation-v2.md).
161
+ - **Prerequisites:** [OpenCode](https://opencode.ai) (Desktop or CLI) and Node ≥ 18.
162
+
163
+ ### 🖥️ What the installer changes on your machine
164
+
165
+ Three things, all outside this repo — listed because a plugin that edits your
166
+ environment without saying so is not one you can trust.
167
+
168
+ | What | Where it lands | How long it stays |
169
+ |---|---|---|
170
+ | 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 |
171
+ | 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 |
172
+ | **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) |
173
+
174
+ Why that third one is there: `task { background: true }` is the only sub-agent
175
+ the OpenCode interface can **show** you — a card linking to the live child
176
+ session, which you can stop. The host turns it on through a flag on **its own
177
+ process**, and a plugin cannot set flags in the process that loads it, so the
178
+ flag has to come from the environment. Without it nothing breaks: `task` simply
179
+ blocks the lead and its card stays non-background. (On 2.x the plugin forces
180
+ `background: true` on every `subagent` call regardless — this flag is about the
181
+ *host's* `task` tool, which is the channel a human can watch.)
182
+
183
+ Undo it:
184
+
185
+ ```powershell
186
+ # Windows — remove it from your user profile
187
+ [Environment]::SetEnvironmentVariable("OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS", $null, "User")
188
+ ```
189
+
190
+ ```bash
191
+ launchctl unsetenv OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # macOS
192
+ systemctl --user unset-environment OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS # Linux
193
+ ```
194
+
195
+ Or skip it at install time, and the installer touches only the two files above:
196
+
197
+ ```powershell
198
+ .\install.ps1 -NoBackgroundSubagents # or $env:TEAMMODE_SKIP_BACKGROUND_SUBAGENTS="1"
199
+ ```
200
+
201
+ ```bash
202
+ TEAMMODE_SKIP_BACKGROUND_SUBAGENTS=1 bash install.sh
203
+ ```
204
+
205
+ Either way the installer prints what it changed, and reads the value back
206
+ instead of trusting its own exit code.
207
+
208
+ ### Verify
209
+
210
+ Restart, open the agent picker, and look for **team, architect, implementer,
211
+ reviewer, tester, researcher**. That's it — the team is hired.
212
+
213
+ ---
214
+
215
+ ## 📖 Usage
216
+
217
+ ### Slash commands
218
+
219
+ | Command | Agent | Description |
220
+ |---|---|---|
221
+ | `/team-plan <task>` | Architect | Implementation plan with architecture, file manifest, task breakdown |
222
+ | `/team-implement <task>` | Implementer | Production code for a feature or task |
223
+ | `/team-review [scope]` | Reviewer | Audit for bugs, security issues, quality problems |
224
+ | `/team-test [scope]` | Tester | Comprehensive tests with edge-case coverage |
225
+ | `/team-research <topic>` | Researcher | Local repo first; web via the governed tools |
226
+ | `/team-run <task>` | Team Lead | **The full workflow** — plan → approval → orchestration → verification |
227
+
228
+ Or `@`-mention agents directly: `@team`, `@architect`, `@implementer`,
229
+ `@reviewer`, `@tester`, `@researcher`.
230
+
231
+ ### What a run feels like
232
+
233
+ Team is the default agent out of the box, so you just type into a fresh chat:
234
+
235
+ > **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/`.
236
+
237
+ ```text
238
+ team Route: product behavior change → implementer → tester → reviewer
239
+ (3 dispatches → approval gate applies)
240
+
241
+ PLAN
242
+ Goal: token-bucket limiter, 100 req/min/user, 429 + Retry-After
243
+ Scope: src/middleware/rateLimit.ts (new), src/app.ts (+3 lines)
244
+ Pipeline: implementer → tester → reviewer (correctness)
245
+ Assumption: in-memory bucket, not Redis — say the word to change
246
+ Boundary: src/legacy/** untouched
247
+ Approve to proceed?
248
+
249
+ you approved, go
250
+
251
+ team ▸ @implementer — STATUS: done
252
+ CHANGES: src/middleware/rateLimit.ts (new) · src/app.ts (+3)
253
+ EVIDENCE: tsc clean
254
+
255
+ ▸ @tester — STATUS: done · VERDICT: pass (14/14)
256
+ FINDINGS: burst edge, window expiry, concurrent refill covered;
257
+ src/legacy/** byte-identical
258
+
259
+ ▸ @reviewer — STATUS: done · VERDICT: approve (correctness)
260
+
261
+ team Done. rateLimit.ts (new) · app.ts (+3) · 14 tests green
262
+ review: approve · assumption: in-memory only · src/legacy/ untouched
263
+ ```
264
+
265
+ You typed the task and four words. The plan was a routing-table lookup,
266
+ execution waited for your approval, and every handoff between agents traveled
267
+ as a structured skeleton — nothing landed in your repo, nothing was guessed.
268
+
269
+ ---
270
+
271
+ ## 🧰 Governed tools & security
272
+
273
+ Every tool TeamMode adds runs under ONE governance pipeline: outputs above
274
+ the offload threshold never enter the context window — the boundary is
275
+ content-class aware (`offloadThresholdText` = 4000 for prose: text/log/markdown;
276
+ `offloadThresholdData` = 2000 for json/csv/code/binary; an unknown class falls
277
+ back to the global `offloadThreshold`) — and oversized results are offloaded to a
278
+ run store and replaced by a content-aware preview plus an HMAC-signed handle that
279
+ the agent pages through with `tm_fetch` when it genuinely needs the payload.
280
+
281
+ | Tool | What it does | Roles |
282
+ |---|---|---|
283
+ | `tm_fetch` | Paged handle retrieval for offloaded results (JSON handles take a `fields` dot-path projection — a deliberately small jq subset like `items[].name`) | all six agents |
284
+ | `tm_memory` | Session + project + global memory store (Markdown + frontmatter): add / search / list / forget / compact | all six agents |
285
+ | `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 `shell` 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, capped by `boardMaxChars` + a per-session file limit | All six agents |
286
+ | `tm_search` | Multi-engine web search with extracted, deduplicated, RRF-fused hit lists | Lead + Researcher |
287
+ | `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 |
288
+ | `tm_ledger` | **The lead's task ledger** (`add` / `doing` / `done` / `blocked` / `list`), stored in the host's own `ctx.storage` per session — the landing spot for the LEDGER rule, since OpenCode 2.x gives a plugin no `todowrite`. A repeated ask is ONE item, an id that matches two is refused with both printed, `blocked` carries the reason, and a write that did not reach storage is reported as a failure rather than as recorded | Lead only |
289
+ | `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 stop a runaway, 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. **On 2.x it also registers the children the host's own `subagent` tool created** (the ack's `metadata.sessionID` is the seam), so a background dispatch is never reported as "nothing to collect" while the user watches it run — and such a row says where its reply actually arrives (the host's injected message) and whether it settled by event or by inference. **Stopping one is a real call:** `cancel: true` goes to the host's own `ctx.session.interrupt` on 2.x (`tm_join { ids: ["ses_…"], cancel: true }` stops ONE named child; without `ids` it stops every still-running one). The host's own contract is `interrupted=true` for an active execution and `false` for the idle no-op, so the answer comes back as **five distinct verdicts** — 已由宿主中断 / 空闲未中断(it wasn't running: our row was stale, not failed)/ 未确认(the call worked, no boolean came back)/ 无中断缝 / 被宿主拒绝(with the host's reason) — counted in the reply and written to the trajectory (`stop_tried` / `stop_confirmed` / `stop_refused` / `stop_unknown`, readable via `tm_stats`). It will not summarise five different facts as one "已取消", and `resume` is never sent, because resuming pending steering is the opposite of cancelling | Lead only |
290
+ | `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), governance counts (blocked subresources, clamped shell timeouts, cache hits, redactions) — plus the **host capability matrix** (`已验证/存在未用/待观察/缺失/需人眼` per host surface) and the **layered-config section** (per-key source, red-line keys a file tried to set and lost, unknown keys, skipped layers, auto-create state). 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 |
291
+
292
+ > **The v1 (1.18.x) personality was removed in full for the 1.7.0 line.** The package
293
+ > exports `{id, setup}` and nothing else, so `tm_read` / `tm_grep` / `tm_bash` /
294
+ > `tm_ptc_run` / `tm_pty` are gone with it — the host's own `read` / `grep` / `glob` /
295
+ > `shell` and its `execute` (Code Mode) do that work now. The governance did NOT
296
+ > disappear with them: an oversized native result is offloaded through
297
+ > `tool.execute.after` (measured: `shell` 12,902 tokens arriving as a 78-token
298
+ > preview), and the address red line plus R6's per-command classification ride the
299
+ > host's `permission.evaluate`. `tm_ledger` is the lead's list where the host gives a
300
+ > plugin no `todowrite`.
301
+ > **Nothing we change reaches outside Team.** Every v2 hook fires for every session on
302
+ > the host, so the tool-surface trim, the blackboard note, the offload
303
+ > of native results, the R6/address strictening and the forced-background dispatch all ask
304
+ > "is this one of our six roles?" first — `build`, `plan` and your own agents stay as a
305
+ > fresh install leaves them. Calls whose owner the host did not tell us are left alone too,
306
+ > and counted (`tm_stats` prints `作用域:我们 · 他人 · 未判定`).
307
+ > The installer writes the six
308
+ > role prompts, which name `read` / `grep` / `shell` instead of the removed aliases.
309
+
310
+ > **On OpenCode 2.x, interactive browsing is the host's, and it stays ours.** The
311
+ > desktop renders a browser in its side panel, and that panel attaches to the
312
+ > server's own browser service — a plugin cannot register a page of its own into it
313
+ > (forensics: `docs/research/browser-pane.md`). So the three roles with network
314
+ > grants (lead, researcher, tester) are pointed at the host's `browser_*` tools
315
+ > — the self-built `tm_browser` was removed in 1.7.0, so the host's catalog is the
316
+ > only browser. On a host with no native browser catalog (CLI, standalone) there is
317
+ > now no browser at all, and the agent reports that gap rather than simulating one.
318
+ > Handing browsing over did not mean handing
319
+ > governance over: `permission.evaluate` was observed NOT firing for `browser_*`, so
320
+ > our gate sits on `tool.execute.before` instead — it classifies the URL of every
321
+ > navigate/open, the path of every `browser_preview`, and every browser URL named
322
+ > inside an `execute` program, refuses the ones out of policy, and if the host runs a
323
+ > refused call anyway it replaces the page with the same refusal, so no
324
+ > out-of-policy content reaches the context, the store or the trajectory. What we
325
+ > cannot do is un-make a request the host already performed, and the reply says so
326
+ > rather than claiming a block; `tm_stats` prints the two numbers apart (refused /
327
+ > leaked past the refusal). One exception to the offload rule lives here: a
328
+ > `browser_snapshot` is an addressing table, not a document, so it is CAPPED (every
329
+ > `[ref=…]` line kept, static text dropped, budget `nativeSnapshotMaxTokens`
330
+ > default 1 200) rather than replaced by a
331
+ > handle. Measured on a 261-ref page: a head cut keeps 118 refs, this keeps 261 of
332
+ > them using 1 044 of 11 326 tokens.
333
+
334
+ > **Fixed tool priority ladder (every task): ① the user's own MCP/plugin
335
+ > tools → ② TeamMode governed tools (`tm_*`) → ③ the model's own reasoning.**
336
+ > It doubles as the fallback chain: when a tool errors (no browser on this
337
+ > host, blocked host), the agent says so and drops to the next rung — and
338
+ > rung ③ is where a missing capability gets reported, never fabricated.
339
+ > One stated exception: on the **web** channel `tm_search` / `tm_webfetch` come
340
+ > first, because that path is the only one carrying the
341
+ > domain allowlist, the per-request confirmation dialog and the R6 red lines.
342
+
343
+ > **What the host UI cannot show you.** OpenCode renders a *plugin* tool call
344
+ > as a one-line card with no expandable body — its tool-renderer registry
345
+ > holds only the built-in tool names, and an extension cannot add to it. The
346
+ > governed output still exists: anything over the offload boundary is written
347
+ > to disk as a handle, and `tm_stats { recent: 20 }` prints the call-by-call
348
+ > recap with those handles and file paths, which you can open. Ask your agent
349
+ > for it — "what did that tool actually return?"
350
+
351
+ > **Delegation goes through the host's `task` — one channel, two shapes.**
352
+ > OpenCode's own `task` tool is the only sub-agent the interface can SHOW you:
353
+ > its card links to the live child session, and the user can stop it. Add
354
+ > `background: true` and it is also non-blocking — the host wakes your lead when
355
+ > the child finishes. That flag is experimental, so you turn it on yourself:
356
+ >
357
+ > ```
358
+ > OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
359
+ > ```
360
+ >
361
+ > (set it for the app process — `setx` on Windows, or launch from a shell that
362
+ > exports it — then restart OpenCode; the installers do it for you, and that is
363
+ > a **persistent user-scope write**, so see
364
+ > [What the installer changes on your machine](#-what-the-installer-changes-on-your-machine)
365
+ > for the exact value, its lifetime and the undo command). TeamMode
366
+ > then keeps that channel inside your token budget: the injected full reply is
367
+ > replaced by a preview plus a pointer, and nothing is copied to disk
368
+ > (`taskOffload: "off"` restores the host's verbatim text). Cost of the host
369
+ > path, stated plainly: each finished background task wakes the lead and costs a
370
+ > turn. `tm_join` is the read side that stays — it pulls a named child's whole
371
+ > reply back through the offload pipeline, stops a runaway, and rebuilds its
372
+ > registry from the host session tree after a restart.
373
+ >
374
+ > There is deliberately **no plugin-side dispatcher**: an earlier `tm_dispatch`
375
+ > created children the user could neither open from a card nor stop from the
376
+ > interface, which is a worse trade than the batching it bought. Remove it,
377
+ > and nothing breaks — the host's `task` was always the visible path.
378
+
379
+ All governed tools are **parallel-safe**: the host may run a batch of
380
+ `tm_search` / `tm_webfetch` / `tm_fetch` calls concurrently — each call gets
381
+ its own step id and its own payload, and nothing cross-contaminates
382
+ (proven by the parallel test suite).
383
+
384
+ ### Context governance: offload, handles, previews
385
+
386
+ Large tool outputs are context cost's main driver — every step re-sends the
387
+ whole window. So results above the content-class offload boundary (prose →
388
+ `offloadThresholdText`, structured data → `offloadThresholdData`,
389
+ unknown → global `offloadThreshold`) are written to a local run store
390
+ (`<repo>/.git/opencode-team/`, never your working tree) and replaced by a
391
+ handle with a content-aware preview: JSON keys / CSV header + shape / log
392
+ ERROR×N stats / code signatures / binary metadata, hard-capped at 80 tokens
393
+ (`previewMaxTokens`). When the agent actually needs the payload, it pages
394
+ through with `tm_fetch` using an HMAC-signed, run-scoped, expiring handle — and
395
+ on a JSON handle it can ask for a `fields` dot-path projection instead (a
396
+ deliberately small jq subset: `items[].name`, `[].stargazers_count`), so a big
397
+ API dump narrows to just the values needed without the raw body ever entering
398
+ the window.
399
+
400
+ The same pipeline governs the **host's own tools**, not just ours — an
401
+ oversized native result is rewritten at `tool.execute.after` into the same
402
+ preview + handle shape. Report-shaped results are the third outcome: a table
403
+ with a hole in it is not a table, so a result carrying a Markdown table is
404
+ **capped keeping its table lines** (`nativeReportMaxTokens`) and the prose
405
+ between them is what goes.
406
+
407
+ ### Session + project + global memory (tm_memory)
408
+
409
+ Durable facts — build commands, environment quirks, architecture decisions,
410
+ your conventions — live as human-editable Markdown with frontmatter, in
411
+ THREE tiers:
412
+
413
+ - **`session`**: this conversation's transients only — in-process, TTL-swept
414
+ (`memorySessionTtlMin`, default 240 min), invisible to other
415
+ sessions; ephemeral unless `memorySessionPersist: "1"` writes them under
416
+ `memories/sessions/<sid>/`.
417
+ - **`project`** (default): `<repo>/.git/opencode-team/memories/…` — per checkout, git-adjacent. Facts about THIS repo: build commands, environment quirks, architecture decisions.
418
+ - **`global`**: `~/.opencode-team/memories/global/` (override `memoryGlobalDir`) — **follows you across ALL projects**. User-level conventions: preferred package manager, commit style, tooling habits.
419
+
420
+ Actions: `add` / `search` (deterministic keyword scoring) / `list` / `forget` /
421
+ `compact`; 4000 chars per memory. `search` walks ALL tiers with **session >
422
+ project > global precedence** — project entries get a +2 near-tie weight and a
423
+ same-title higher-layer twin shadows the lower one (it never surfaces).
424
+ Near-duplicates never pile up: an `add` that hits an existing entry in the same
425
+ tier and category (dedup key, or title+keywords Jaccard ≥ 0.6) **folds into
426
+ it** — new content wins, keywords union, the old slug moves to `supersedes:`,
427
+ and the answer says 已合并 (that is normal; don't re-add under a variant title).
428
+ When a tier reaches `memoryMaxEntries` (200 per scope) the add fails on
429
+ purpose: run `compact` first — it dry-runs the merge plan by default, and
430
+ re-running with `apply:true` performs it after copying every original to a
431
+ timestamped `.compact-backup` tree (the rollback path). Entries older than
432
+ `memoryStaleDays` (30) surface tagged `[stale Nd]` in search. Agents
433
+ are prompted to search before assuming conventions and to save hard-won
434
+ facts for the next conversation.
435
+
436
+ ### 🌐 Web search that actually works (in China)
437
+
438
+ `tm_search` is the open-ended-lookup front: **one call, one query, clean
439
+ results**. The engine URL is built for you, fetched through the governed
440
+ pipeline, and collapsed into a numbered title+URL hit list — the agent never
441
+ sees raw SERP chrome.
442
+
443
+ | Engine | Notes |
444
+ |---|---|
445
+ | `auto` (default) | Classifies the query, fans the matching engines out **in parallel** (every route has ≥2 legs, because a hit two engines agree on is worth more than one engine's opinion of itself), 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 `searchRelevanceFloor`), 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 `searchDefaultEngine` |
446
+ | `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 |
447
+ | `bing-int` | The same host with `&ensearch=1` for English results. It is deliberately **out of every `auto` route** — two layouts of one index would give bing a double vote |
448
+ | `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 |
449
+ | `hn` | Hacker News via Algolia API (no key) → story titles + snippets with direct article URLs |
450
+ | `bilibili` | video search |
451
+ | `moegirl` | MediaWiki search API — entry titles + snippets, structured |
452
+ | `npm` | registry search → name@version + description, structured |
453
+ | `github` | repo search API → stars + description, structured; `org:` / `user:` / `stars:` / `language:` qualifiers fold into the query (e.g. `vector db stars:>500 language:rust`) |
454
+
455
+ All the HTML engines are reachable from mainland China **without API keys**, and
456
+ every one of them sits on the seeded domain allowlist. The previous CN HTML
457
+ SERPs (`sogou` / `so` / `baidu`) were **removed** — a live
458
+ benchmark (2026-09-14) showed them serving anti-bot shells or 100% empty
459
+ results; they are not even manually selectable. On an empty result,
460
+ the error names the alternative engines instead of leaving the agent stuck.
461
+ Two more channels complete the surface:
462
+
463
+ - `tm_webfetch` — a known URL, one governed GET. Search-engine pages it
464
+ fetches are auto-extracted to hit lists too. JSON endpoints like
465
+ `registry.npmjs.org/<pkg>/latest` pass through untouched.
466
+ - **Interactive browsing is the host's own `browser_*` tools** (`browser_tabs_open`
467
+ · `browser_navigate` · `browser_snapshot` · `browser_click` · `browser_evaluate`
468
+ …). The self-built `tm_browser` was **removed in 1.7.0** (a breaking change):
469
+ the desktop renders a browser in its side panel and that panel attaches to the
470
+ server's own browser service, so a plugin cannot register a page of its own
471
+ (forensics: `docs/research/browser-pane.md`). The host catalog is policed by
472
+ `src/host/v2-browser-gate.ts` at `execute.before` — the URL of every navigate/open,
473
+ the path of every `browser_preview`, and every browser URL named inside an
474
+ `execute` program are classified against the address red lines and the env-file
475
+ rule, and a refused call the host runs anyway has its page replaced with the same
476
+ refusal, so no out-of-policy content reaches the context, the store or the
477
+ trajectory. Calling convention differs from the deleted tool: `evaluate` takes
478
+ `{tabID, script}` where `script` is an **expression** (not function source) and
479
+ the return value must be a scalar you `JSON.stringify` yourself; snapshot tokens
480
+ read `@e8 [link]`. **Known cost, accepted:** on a host with no native browser
481
+ catalog (CLI / standalone) there is now no browser at all — the agent reports that
482
+ gap rather than simulating one.
483
+
484
+ When a fetch still returns **403 after the real-Chrome headers**, the error
485
+ is a DIRECTIVE: the gate is JS-challenge / TLS-fingerprint based and only a
486
+ real browser passes — the agent is told to open that URL with the host's
487
+ native `browser_navigate` (and read it with `browser_snapshot`). Search hit lists also
488
+ filter known noise: engine-internal wrappers (`so.com/link?`, `ai.so.com`)
489
+ and same-name-different-site domains (`maimai.cn` 脉脉 vs the maimai DX
490
+ game) never ride along — extend the hit blacklist with `hitBlacklist`.
491
+
492
+ Seeded allowlist (all three web tools; 22 hosts — baidu/moegirl/bilibili are
493
+ PARENT domains, so every sibling subdomain — baike.baidu.com,
494
+ mzh.moegirl.org.cn, space.bilibili.com — is covered):
495
+ `baidu.com`, `bdimg.com` (Baidu's own script + asset CDN — not a baidu
496
+ subdomain, and a page whose bundle we block is a blank page we would then
497
+ report as "no content"), `moegirl.org.cn`, `bilibili.com`, `www.sogou.com`,
498
+ `www.so.com`, `cn.bing.com`, `www.bing.com`, `zhihu.com`, `juejin.cn`,
499
+ `csdn.net`, `cnblogs.com`, `gitee.com`, `github.com`, `api.github.com`,
500
+ `raw.githubusercontent.com`, `gist.githubusercontent.com`, `ghproxy.net`
501
+ (mainland mirror for github raw), `stackoverflow.com`, `npmjs.org`, `pypi.org`,
502
+ `learn.microsoft.com` — plus the two JSON search-engine hosts
503
+ (`api.stackexchange.com`, `hn.algolia.com`) while the default seed is in play,
504
+ so 24 effective. Extend via `webfetchAllowedDomains` (`"*"` opens every host; a
505
+ custom list REPLACES the seed, so keep the engine hosts or `tm_search` loses its
506
+ targets). Architect / implementer / reviewer have NO network grant — web
507
+ questions come back as a reported gap, never simulated. The tester carries the
508
+ host's native `browser_*` tools ONLY, for governed UI verification of the project
509
+ (local dev servers, preview routes); open web fetching stays with the two
510
+ network roles.
511
+
512
+ **Out-of-allowlist targets are a gate, not a wall.** When a fetch / search /
513
+ browser-open points at a host outside the allowlist, the governed call **fails
514
+ closed with a refusal naming the exits** — on 2.x a plugin cannot raise the
515
+ host's dialog, so there is no window to wait for and a gate with no door is not
516
+ a gate. Your doors are `privateSpace: "allow"` in `team-mode.jsonc`, or that one
517
+ hostname in `webfetchAllowedDomains`. Below that gate sit the classes no config
518
+ opens: cloud-metadata / link-local / multicast / reserved / benchmarking ranges
519
+ are refused outright with no consent path, including their IPv4-mapped and
520
+ DNS64 spellings (changing the notation is not a bypass), and env-file URLs and
521
+ non-http(s) schemes are hard-rejected.
522
+
523
+ ### Security: R6 env protection + R2 dangerous operations
524
+
525
+ **R6 is armed by default, and it is a `strict` default.** `envProtect` accepts
526
+ `strict` / `standard` / `off` and resolves to `strict` by default. With TeamMode
527
+ active:
528
+
529
+ - **Env-FILE reads are a hard `deny`** — a Team role's native `read` /
530
+ `edit` / `glob` / `grep` of a `.env` is refused with no consent path. The
531
+ host's `grep` reports the *pattern* as its permission resource rather than the
532
+ path, so the same rule also runs on the whole tool input (`grep SECRET .env`
533
+ cannot slip through). Templates (`*.env.example` / `.sample` / `.template` /
534
+ `.dist`) stay readable.
535
+ - **Env-variable reads in a shell command go to the host's permission prompt**
536
+ (`ask`). The per-command classifier decides, so an ordinary `git status` asks
537
+ nothing and an env dump still does; env reads no wildcard can express
538
+ (embedded `$VAR` / `${VAR}` / `$env:` inside another command, command
539
+ substitution) are **never** asked — they are refused. The audit log records
540
+ only tool name + pattern category + verdict — never command text, paths,
541
+ variable names or values.
542
+
543
+ **R2 dangerous operations (the same face).** Delete, git publish, network
544
+ fetch, package install/publish, process/system, privilege changes — none are
545
+ silently allowed. The normal verification stack (`npm test`, `tsc`,
546
+ `git status`) is NOT gated, so day-to-day work runs uninterrupted.
547
+
548
+ **The plugin never self-allows.** Every hook it registers can only make a rule
549
+ *stricter*; a permission it is asked about is replied `deny` or left alone, never
550
+ `allow`.
551
+
552
+ > ⚠️ **When you approve the host's own dialog, pick "once" — not "always".**
553
+ > Verified on the live host, "always" records a far broader rule than the command
554
+ > you saw: approving `Get-ChildItem env:PATH` with "always" stores `Get-ChildItem
555
+ > *`, so every later `Get-ChildItem` runs with no dialog at all. The web channel
556
+ > has the same trap and it is easier to fall into: one "always" on a host lets
557
+ > **every agent session in that project** open it. The reply says which path let
558
+ > a page in (static allowlist / the dialog you just answered / a saved rule that
559
+ > answered in milliseconds), because an agent that cannot tell them apart reports
560
+ > "no dialog" as "that site is allowed".
561
+
562
+ > Deferral is per-session: the env face only applies in sessions running
563
+ > TeamMode's generated roles. In any other session the plugin leaves the host's
564
+ > behaviour exactly as it found it.
565
+
566
+ ### Repo hygiene
567
+
568
+ The offload/trajectory/memory stores live under `<repo>/.git/opencode-team/`
569
+ (outside a git repo: the OS temp dir, sharded per workspace as
570
+ `opencode-team/w-<hash>/`, so one project never reads another's payloads) —
571
+ **never your working tree**. Every
572
+ agent is instructed to delete scratch files before reporting done and to keep
573
+ throwaway work in the OS temp dir. A TTL sweeper reclaims old task dirs at
574
+ startup + hourly; the Team Lead never deletes boards itself, so you can audit
575
+ any run.
576
+
577
+ ---
578
+
579
+ ## ⚙️ Configuration
580
+
581
+ **Configuration is JSON, and only JSON.** `team-mode.jsonc` is the single
582
+ configuration source. There is no environment layer, and **no `TM_*`
583
+ configuration environment variable exists any more** — the ones you may still
584
+ find in old configs are simply unknown keys, reported at boot and never applied.
585
+ (Three `TM_*` names survive as internal/test switches, listed at the end of
586
+ this section.)
587
+
588
+ ### Where the file lives
589
+
590
+ | Layer | Path | Precedence |
591
+ |---|---|---|
592
+ | **global** | `~/.config/opencode/team-mode.jsonc` (honours the host's `OPENCODE_CONFIG_DIR`) | lowest — applies to every project |
593
+ | **project** | `<dir>/team-mode.jsonc`, for every directory from the workspace **up to the filesystem root** | higher — direct files merge farthest→closest |
594
+ | **project** | `<dir>/.opencode/team-mode.jsonc`, same walk | **highest** — every `.opencode/` file overrides every direct file |
595
+
596
+ That walk and precedence are the host's own config-layering rule, copied rather
597
+ than invented. JSONC is supported: `//` and `/* */` comments are masked at the
598
+ byte level, so a commented-out key cannot read as a live one. A layer that fails
599
+ to parse is skipped **whole** (half a config is worse than none) while a single
600
+ bad key loses only itself; unknown keys are warned about and never applied.
601
+ `tm_stats` renders the result: per-key source, skipped layers, unknown keys, and
602
+ the auto-create state.
603
+
604
+ ### It writes itself
605
+
606
+ When the global file is **absent**, the plugin creates it at boot — atomically,
607
+ idempotently, and **never overwriting an existing file**. What it writes is an
608
+ **inert** template: all **58** registry keys, each as a *comment* under a
609
+ one-line description, so the file parses to `{}` and sets nothing until you
610
+ uncomment what you want.
611
+
612
+ ```jsonc
613
+ // 全局配置。取消注释即可生效;默认全部注释 = 什么都不设置。
614
+ {
615
+ // "offloadThreshold": 2000, // 卸载阈值(估算 token;等于阈值也卸载)。
616
+ // "envProtect": "strict", // R6 环境防护模式(strict/standard/off)。(红线:仅全局)
617
+ // …共 58 个键,每个都带一行说明
618
+ }
619
+ ```
620
+
621
+ Turn it off with the plugin option `autoCreate: false`, or the internal switch
622
+ `TM_CONFIG_AUTOCREATE=off`.
623
+
624
+ ### Red-line keys
625
+
626
+ Five keys are **honored only in the global file**: `envProtect`, `r6FineAsk`,
627
+ `privateSpace`, `webfetchAllowedDomains`, `bashReadonlyAllowed`. A project file
628
+ may set them, but the value is **ignored and reported** — a committed project
629
+ config must not be able to switch off a guard for everyone who clones the repo.
630
+ The rule is derived from the registry itself (`redLine: true` on the spec), so a
631
+ new red-line key is red-line by declaration.
632
+
633
+ ### Plugin options
634
+
635
+ Options live on the plugin entry, not in `team-mode.jsonc`:
636
+
637
+ ```jsonc
638
+ {
639
+ "plugins": [
640
+ { "package": "@te-river/opencode-team-mode@latest",
641
+ "options": { "defaultAgent": true, "autoCreate": true, "ttlDays": 7, "envProtect": true } }
642
+ ]
643
+ }
644
+ ```
645
+
646
+ | Option | Default | Meaning |
647
+ |---|---|---|
648
+ | `defaultAgent` | `true` | Promote Team to the default agent slot. Opt out with `false`. |
649
+ | `autoCreate` | `true` | Write the inert global `team-mode.jsonc` at boot when absent. |
650
+ | `ttlDays` (alias `blackboardTtlDays`) | `5` | Blackboard retention, valid range (0, 365]. |
651
+ | `envProtect` | `true` | Plugin-wide kill switch; `false` resolves the R6 mode to `off`. |
652
+
653
+ On 2.x a plugin entry is either a **string** or an **object** with `package` and
654
+ `options`. The 1.x tuple form `["@te-river/…", { … }]` is rejected
655
+ (`path=$.plugins.1 kind=invalid`, measured 2026-10-06). Options do arrive — with
656
+ the object form the boot row reads `board_ttl_days=9` for `{ "ttlDays": 9 }`, so
657
+ this is measured, not documented-and-hoped.
658
+
659
+ ### Model choice
660
+
661
+ Every judgment — triage, decomposition, dispatch briefs, synthesis, review
662
+ verdicts — flows through the Team Lead. A weak model in that seat degrades the
663
+ whole pipeline no matter how strong the specialists are. Pin your best reasoning
664
+ model to `team`:
665
+
666
+ ```jsonc
667
+ {
668
+ "agent": {
669
+ "team": { "model": "anthropic/claude-opus-4-5" }, // Lead earns your best model
670
+ "implementer": { "model": "anthropic/claude-sonnet-4-6" } // specialists tolerate cheaper
671
+ }
672
+ }
673
+ ```
674
+
675
+ Your own agents named `team` / `architect` / … always take precedence; the
676
+ plugin never clobbers user definitions. See [Customization](#-customization)
677
+ for overrides, extra agents and disabling roles.
678
+
679
+ ### Key reference (all 58)
680
+
681
+ **Offload, previews and the store**
682
+
683
+ | Key | Type | Default | Meaning |
684
+ |---|---|---|---|
685
+ | `offloadThreshold` | number | `2000` | Global offload boundary (estimated tokens, CJK-aware), used when the content class is unknown. A result AT the threshold offloads. |
686
+ | `offloadThresholdText` | number | `4000` | Boundary for prose (text / log / markdown). Inherits the global value unless set. |
687
+ | `offloadThresholdData` | number | `2000` | Boundary for structured payloads (json / csv / code / binary). Same inheritance. |
688
+ | `previewLines` | number | `20` | Raw lines a preview builder may scan. |
689
+ | `previewMaxTokens` | number | `80` | Hard preview cap. |
690
+ | `fetchMaxLines` | number | `2000` | `tm_fetch` per-segment line cap. |
691
+ | `blackboardDir` | string | auto | Run-payload store dir. Empty = `<repo>/.git/opencode-team/blackboard`. Explicit = absolute or project-relative. |
692
+ | `trajectoryDir` | string | auto | Trajectory store dir. Empty = `<repo>/.git/opencode-team/trajectory`. |
693
+ | `blackboardTtlDays` | number | `7` | Handle TTL and the physical sweep period for expired run dirs. |
694
+ | `storeReclaim` | `on`/`off` | `on` | At boot, reclaim what an upgrade left behind: a per-workspace shard idle past the TTL, and the pre-shard `blackboard/` + `trajectory/` at the temp-dir fallback. **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. |
695
+ | `taskOffload` | `on`/`off` | `on` | Keep the host's background sub-agent inside the context budget: when it finishes, the injected full reply is replaced by a preview + a `tm_join` pointer. Touches only synthetic parts carrying the host's own `<task id=… state="completed">` / `<subagent … state="completed">` envelope and over the text threshold — a typed message is never touched even if it contains a perfect envelope, and a `state="error"` child is never rewritten. **Nothing is copied to disk**: the text stays where the child session already wrote it. `off` restores the host's verbatim injection. |
696
+ | `subagentConcurrency` | number | `8` | Ceiling on **running + in-flight** sub-agent dispatches per caller. In-flight = a dispatch the gate admitted but the host has not registered yet, so a **burst in one message is capped too** — the old registered-only count could not do that (24 parallel dispatches all passed it, then later ones were refused). `0` disables. A slot is released when the child registers, when the call ends without one, or after a 60 s TTL, so a lost call cannot leak it. |
697
+ | `boardMaxChars` | number | `200000` | `tm_board_write` per-file character cap — over it the write **refuses** (with a "split the topic" hint) rather than truncating a deliverable. |
698
+ | `boardMaxFiles` | number | `200` | Markdown files allowed per session folder. The TTL sweeper is the only reclaim path, so the refusal names it. |
699
+ | `joinMaxWaitMs` | number | `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. |
700
+ | `ledgerMaxItems` | number | `200` | Ceiling on `tm_ledger` items per session. The host's `ctx.storage` has no TTL and no quota (measured), so the list refuses to grow past this instead of quietly dropping the oldest asks — and a refusal is something the lead can act on, while a silent truncation is a claim nobody can re-check. |
701
+
702
+ **Memory**
703
+
704
+ | Key | Type | Default | Meaning |
705
+ |---|---|---|---|
706
+ | `memoryGlobalDir` | string | auto | GLOBAL tier store. Empty = `~/.opencode-team/memories/global`. |
707
+ | `memorySessionTtlMin` | number | `240` | Session-tier entry TTL (lazy + boot sweep). |
708
+ | `memoryMaxEntries` | number | `200` | Per-scope entry cap; over it `add` fails on purpose — run `compact`. |
709
+ | `memoryStaleDays` | number | `30` | Age after which search hits are tagged `[stale Nd]` (`0` disables). |
710
+ | `memorySessionPersist` | string | `""` | `""` = in-process only; `"1"` also writes session entries under `memories/sessions/<sid>/`. |
711
+
712
+ **Web and search**
713
+
714
+ | Key | Type | Default | Meaning |
715
+ |---|---|---|---|
716
+ | `webfetchAllowedDomains` | string[] | 22-host seed | **red line.** Outbound allowlist (`"*"` = any host; `[]` = deny all). A custom list **replaces** the seed — keep the engine hosts. `"*"` does **not** cover private space: loopback / RFC1918 / CGNAT / `.localhost` still need `privateSpace: "allow"`, 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 opens. |
717
+ | `searchDefaultEngine` | string | `auto` | Engine when no `engine` arg is given (`auto` = classify + parallel fan-out + RRF fusion; any table name also pins a manual default). |
718
+ | `searchMaxHits` | number | `10` | Hits kept per engine leg and in the fused list. |
719
+ | `searchWeights` | record | `{}` | Per-engine fusion weight overrides, e.g. `{"bing": 0.3}`; anything unset keeps the built-in table. |
720
+ | `searchDisabledEngines` | string[] | `[]` | Engines removed from the roster AND from every `auto` route. |
721
+ | `searchRelevanceFloor` | number | `0.35` | Weight fraction kept by a hit sharing no query token with its title/snippet/host (demotes junk without deleting an engine). |
722
+ | `hitBlacklist` | string[] | `[maimai.cn]` | Extra domains never listed as search hits (same-name-different-site noise like 脉脉). Merged with the built-in entry. |
723
+ | `webCacheTtlSec` | number | `300` | How long a governed fetch may re-serve the same URL (`0` = off). One store shared by `tm_webfetch` / `tm_search`; entries are hash-named (a token-bearing query never hits disk) and are only read or written for hops the STATIC allowlist admitted — so a hit can neither resurrect a removed host nor substitute for consent. A re-served page says 缓存命中. |
724
+
725
+ **Rounds, dispatch and context**
726
+
727
+ | Key | Type | Default | Meaning |
728
+ |---|---|---|---|
729
+ | `prune` | `on`/`off` | `on` | Context pruning: replace a SETTLED message body with a self-explaining pointer (an offload handle, a child id, a note). Evidence is never destroyed — the reply skeleton, GOAL/ACCEPTANCE, provenance, system messages, a still-running child and an uncollected child id are protected whole, and the untouched messages stay byte-exact. `off` disables. |
730
+ | `pruneAtPercent` | number | `70` | Prune once the request reaches this share of the model's window, derived from `limit.context` — never a hard-coded token count. **Clamped to 40–90.** |
731
+ | `pruneKeepTailPercent` | number | `40` | Share of the window kept verbatim at the tail; the newest message is always kept. |
732
+ | `splitAdvice` | `on`/`off` | `on` | Inject a split suggestion when a dispatch brief carries too many acceptance criteria. `off` stops the hint (the prompt discipline stays). |
733
+ | `splitBriefTokens` | number | `4000` | The brief token threshold that triggers it. **Clamped to ≥200.** |
734
+ | `splitMaxCriteria` | number | `3` | More acceptance criteria than this is a signal to split. |
735
+ | `retry` | `on`/`off` | `on` | Retry governance on BOTH request-failure surfaces: (1) the provider-error governor — classify a quota / rate / transient / unknown error **by name and text only**, compute the fixed 5s/10s/20s ladder, and inject ONE directive naming the exact seconds to wait; after `retryBreakAfter` consecutive errors a cooldown denies new `subagent` dispatches; (2) the HTTP layer — a failed request inside `tm_webfetch` / every `tm_search` engine leg (network throw, per-request timeout, HTTP 429 or 5xx) is retried up to 3 times on the SAME ladder, and the reply labels it (`第N次重试后成功` / `重试3次…仍失败`). A policy refusal (off-allowlist, red line, env-file URL, 403/418, other 4xx) is never re-asked. Honest boundary: there is no seam to intercept the model's own retry — it identifies, states the wait, and refuses new work; it does not wait for the model. |
736
+ | `retryBaseMs` | number | `5000` | First rung of the ladder: retries #1/#2/#3 wait 5s / 10s / 20s (doubling), on both surfaces. |
737
+ | `retryMaxMs` | number | `60000` | Ceiling for that backoff. |
738
+ | `retryJitter` | number | `0` | ± fraction applied to the wait. Default `0` = NO jitter, so the 5s/10s/20s ladder is exact; set a fraction (≤0.95) if parallel sessions should not re-fire in lockstep. |
739
+ | `retryBreakAfter` | number | `5` | Consecutive errors before the breaker trips. |
740
+ | `retryCooldownMs` | number | `60000` | How long new sub-agent dispatches are refused once it has. |
741
+
742
+ **Host-surface governance (2.x)**
743
+
744
+ | Key | Type | Default | Meaning |
745
+ |---|---|---|---|
746
+ | `nativeOffload` | `on`/`off` | `on` | Govern the HOST's own `read`/`grep`/`glob`/`shell` results through the same pipeline. `off` restores the host behavior; the boot line distinguishes "you turned it off" from "this host has no execute.after". |
747
+ | `nativeSnapshotMaxTokens` | number | `1200` | Budget a native `browser_snapshot` keeps in context. Addressing lines win it before static text does; past `budget × 4` the reply states how many ref lines did not fit, and kept + dropped always equals the total. |
748
+ | `nativeReportMaxTokens` | number | `1600` | Budget a report-shaped native result (anything carrying a Markdown table) keeps. Table lines and their headings win the space; the full text still rides the handle. |
749
+ | `probeChain` | `on`/`off` | `on` | After a run of native `read`/`grep`/`glob`/`shell` passes, append ONE line naming `execute` (Code Mode) and what it saves. A hint, never a gate: the original body is preserved verbatim, nothing is rejected, and the append is idempotent. |
750
+ | `probeChainAfter` | number | `3` | How many consecutive native calls before the hint starts (`0` = off). |
751
+ | `v2BrowserGate` | `on`/`off` | `on` | The gate over the host's `browser_*` catalog (URLs and preview paths at `execute.before`, plus the browser URLs named inside an `execute` program). `off` restores ungoverned browsing; the boot line and `tm_stats` say which world is running. |
752
+ | `v2CodeMode` | string | `""` | `direct` sends `options.codemode=false`; empty = catalog mode. We used to send `direct` by default and claim direct delivery — **a live 2.0.16 desktop session disproved it**: with the flag sent, every `tm_*` still arrived inside the host's Code Mode catalog, so the default now sends nothing. The observable truth is `tools_in_request` in `tm_stats` (请求内实际可见=…), never the flag we sent. |
753
+ | `bashTimeoutProbeMs` | number | `60000` | Ceiling forced onto a `timeout` the model set for a read-only probe command. Applies ONLY to a command the read-only allowlist already accepts, and never invents a timeout the model omitted (`0` disables). |
754
+ | `bashTimeoutMaxMs` | number | `0` | Optional global ceiling for every other shell command. `0` = off, so a real build keeps the timeout it asked for. |
755
+ | `envProtect` | `strict`/`standard`/`off` | `strict` | **red line.** R6 mode. `off` also disarms the shell escalation. Any unrecognised value resolves to `strict`. |
756
+ | `r6FineAsk` | string | classifier | **red line.** `off` falls back to asking about EVERY shell command — which is also what happens automatically on a host that does not expose the per-action evaluation hook, and the boot note says which of the two caused it. |
757
+ | `privateSpace` | `allow`/`deny`/`ask` | `deny` | **red line.** Private space (loopback, RFC1918, ULA, CGNAT, `.localhost`) through our tools. The default is `deny` because a 2.x plugin cannot raise a dialog — telling the agent to wait for a window that will never open is not a gate with a procedure, so `ask` is the honest spelling of "not answerable" and an unrecognised value falls back to it. Never conflated with the FORBIDDEN ranges. |
758
+ | `bashReadonlyAllowed` | string[] | built-in | **red line.** The P3 read-only command allowlist. `tasklist` / `ps` / `findstr` are seeded in, because `已确认关闭` is only checkable if the agent can ask the OS for the pid — a user-facing verification with no read path is the same defect as a lie. |
759
+
760
+ **Legacy keys** — kept listed and parseable so an old config still loads, with
761
+ **no v2 reader**, and reported as such:
762
+
763
+ | Key | Default | Status |
764
+ |---|---|---|
765
+ | `askTimeoutFloorMin` | `1` | **Orphaned.** Its only consumer was the v1 approval gate, which was deleted (a 2.x plugin cannot raise a dialog, so there was nothing to time out on). Say so rather than leaving a knob that does nothing. |
766
+ | `compactionContext` | `on` | v1-only |
767
+ | `shellEnv` | `""` | v1-only |
768
+ | `ptcWebBridge` | `on` | v1-only |
769
+
770
+ > **Compaction timing belongs to the host, not to this plugin.** An earlier
771
+ > release triggered its own summarization at 75% of the window; that was removed
772
+ > by user decision — a plugin that summarizes a live conversation by itself
773
+ > takes a context-losing action you did not ask for. What remains is additive and
774
+ > runs only when the HOST compacts: the must-survive list (reply skeleton,
775
+ > offload handles, open sub-agent session ids, provenance, board paths) rides the
776
+ > host's own `session.hook("compaction")`, and the host's summarizer prompt is
777
+ > never replaced.
778
+
779
+ ### The three surviving `TM_*` names
780
+
781
+ These are **internal / test switches**, not configuration — they are read from
782
+ the environment because a test or a diagnostic needs them without a config file:
783
+
784
+ | Name | Effect |
785
+ |---|---|
786
+ | `TM_STORE_RECLAIM` | Overrides the `storeReclaim` key (`off` = leave the disk exactly as found). The test runner sets it, because suites boot real runtimes in temp dirs. |
787
+ | `TM_V2_PROBE` | Path to a JSONL file where the surface probe records the host's real tool ids, permission action names and argument key **names**. Names and counts only — never a command line, path, URL or env value. It is how "does the host actually have X?" gets answered from the running build instead of from a doc. |
788
+ | `TM_CONFIG_AUTOCREATE` | `off` suppresses the inert global-file auto-create. |
789
+
790
+ Any **other** `TM_*` name in your environment is inert. If you have been setting
791
+ one, move it into `team-mode.jsonc` under the matching key above.
792
+
793
+ ---
794
+
795
+ ## 🏗️ How the team works
796
+
797
+ Sub-agents can't message each other live (platform limitation), so TeamMode
798
+ coordinates them through a **structured reply skeleton** — every specialist
799
+ reply is `STATUS: / CHANGES: / FINDINGS: / EVIDENCE: / HANDOFF:`, ≤50 lines,
800
+ relayed verbatim by the Lead into the next dispatch. Files are the exception,
801
+ not the rule: a deliverable over ~50 lines goes to ONE named board file under
802
+ `<repo>/.git/opencode-team/` (round-suffixed, working tree untouched).
803
+
804
+ - **Routing table:** question → direct answer; docs-only → implementer;
805
+ product change → implementer → tester → reviewer; multi-module →
806
+ architect → implementer → tester → reviewer(s); unknown tech → researcher
807
+ first. Fixed minimums — a product change routed below 3 dispatches is a
808
+ routing bug.
809
+ - **One dispatch, one verifiable deliverable.** A dispatch is a unit of
810
+ VERIFIABLE work, not a bucket for everything related. If the lead cannot say
811
+ how a child's result will be verified *on its own*, it is not a dispatch yet —
812
+ it is a wish. Cutting one deliverable into pieces that only make sense
813
+ together is chopping, not splitting, and it costs you more rounds than it
814
+ saves.
815
+ - **The architect is conditional.** Dispatch it only when the design is
816
+ genuinely unknown. With the root cause already verified (file:line evidence),
817
+ skip it and dispatch the implementer with the exact fix spec; if the fix moves
818
+ a contract or the strategy is undecided, keep the architect. The ceremony
819
+ serves unknowns, not multi-file diffs.
820
+ - **Tester and reviewer may run in the SAME round** — verification and review
821
+ are independent of each other. Serialise them only when a fix invalidates
822
+ both. Same for multiple implementers (each carrying its exact file ownership
823
+ and verbatim data contracts) and testers on disjoint packages.
824
+ - **Approval gate (count-based):** ≥2 dispatches → plan (≤30 lines) → **your
825
+ approval** → execute. Blocking questions are batched and asked immediately.
826
+ Splitting one ask into sub-2-dispatch pieces to dodge the gate is a protocol
827
+ violation, not a trick.
828
+ - **Only the Team Lead dispatches.** Specialists no longer hold the host's
829
+ `task`/`subagent` capability, so no sub-agent spawns a sub-agent.
830
+ - **Adaptive review:** one reviewer by default; three parallel dimensions
831
+ only for high-risk profiles (auth/security, cross-module contracts, public APIs).
832
+ - **Static verification:** build / typecheck / lint / tests. Improvised
833
+ browser automation is banned; unverified UI work ends with
834
+ `UI NOT VERIFIED: <what to check>`.
835
+ - **Evidence standard:** "done / fixed / passed" claims need verifiable
836
+ evidence — output, logs, diffs.
837
+ - **Your language, not the tool's.** The governed tools answer in Chinese; the
838
+ reply-language rule keeps your own language in the prose and quotes a Chinese
839
+ string verbatim only where it IS the evidence.
840
+
841
+ ---
842
+
843
+ ## 🔧 Customization
844
+
845
+ **Override an agent** — same name in your config wins:
846
+
847
+ ```jsonc
848
+ {
849
+ "agent": {
850
+ "reviewer": {
851
+ "model": "anthropic/claude-sonnet-4-6",
852
+ "prompt": "You are an extremely strict reviewer. Reject anything with a lint warning."
853
+ }
854
+ }
855
+ }
856
+ ```
857
+
858
+ **Add your own agents** alongside the team:
859
+
860
+ ```jsonc
861
+ {
862
+ "agent": {
863
+ "devops": {
864
+ "mode": "subagent",
865
+ "description": "Handles CI/CD, Docker, and deployment tasks.",
866
+ "prompt": "You are the DevOps engineer..."
867
+ }
868
+ }
869
+ }
870
+ ```
871
+
872
+ **Disable one:** `"researcher": { "disable": true }`.
873
+
874
+ Board retention, auto-create, the default slot and the R6 kill switch are
875
+ plugin-entry `options` — see
876
+ [Configuration](#️-configuration).
877
+
878
+ ---
879
+
880
+ ## ❓ Troubleshooting
881
+
882
+ **Will this eat my tokens?**
883
+ The opposite is the point. Offload + 80-token previews + the host's Code Mode
884
+ `execute` exist because a five-agent pipeline naively bolted onto one context window
885
+ *would* eat your tokens. The governance is the token-saver.
886
+
887
+ **Is the web access safe?**
888
+ It's the most guarded surface in the plugin: two full web roles plus a
889
+ browser-only tester grant, a domain allowlist whose off-list calls fail closed,
890
+ redirects re-checked per hop with the whole chain reported, env-file URL
891
+ refusal, address red lines no setting opens, and every payload rides the same
892
+ offload governance. No allowlisted page can bounce the fetch off-site.
893
+
894
+ **Why doesn't the plugin auto-update?**
895
+ OpenCode caches plugins by spec string and never re-resolves `@latest`
896
+ (upstream limitation, not ours). **Re-run the installer — that IS the
897
+ update** (it purges the cache and re-resolves npm copies); or delete the
898
+ cache dir by hand. If the boot probe's `entrypoint=` line names a path outside
899
+ `~/.cache/opencode/npm` or `~/.config/opencode/node_modules`, a `~/package.json`
900
+ is pinning a different copy — that is the diagnostic, not a guess. Recipe above
901
+ and in [docs/installation-v2.md](./docs/installation-v2.md).
902
+
903
+ **A knob I set in an env var does nothing.**
904
+ Configuration is JSON now. Any `TM_*` variable other than the three internal
905
+ switches is inert; move the value into `team-mode.jsonc` under the registry key.
906
+ Run `tm_stats` and read the layered-config section: it names the per-key source,
907
+ so a value you expected to be honored shows up with a source that is not the file
908
+ you edited.
909
+
910
+ **A red-line key I set in the project file is ignored.**
911
+ By design. The five red-line keys are honored only in the **global** file, and
912
+ `tm_stats` reports the ignored attempt by name rather than dropping it silently.
913
+
914
+ **My `AGENT NOT FOUND: "Team"`.**
915
+ The file name IS the agent id, and Windows/APFS keep the existing spelling when
916
+ a write opens that file through another one — so a pre-1.7.2 `team.md` survives
917
+ every install and the host registers the lead as lowercase. Use `--agent team`.
918
+ The installer's reclaim pass renames a case-only entry it has proven is the same
919
+ file; a manual install may need the same rename.
920
+
921
+ **Can agents run tools in parallel?**
922
+ Yes — and they're *engineered* for it: parallel `tm_search` / `tm_webfetch` /
923
+ `tm_fetch` calls get distinct step ids and isolated payloads. A regression
924
+ here fails the test suite before it ever reaches you.
925
+
926
+ **Does it work in the CLI (TUI), or only Desktop?**
927
+ Both. Desktop adds the color-coded picker and panels; the governed tools and
928
+ the whole workflow are host-agnostic. Interactive browsing is the host's own
929
+ `browser_*` catalog, so a host with no native browser (CLI / standalone) has
930
+ none — the agent reports that gap rather than simulating one.
931
+
932
+ **What happens if I don't answer the host's permission prompt?**
933
+ The host decides that, not this plugin. The plugin can only refuse: it never
934
+ self-allows, and every guard it installs can only make a rule stricter. A
935
+ session it does not recognize as one of its own is left exactly as the host
936
+ behaved.
937
+
938
+ ---
939
+
940
+ ## 🗑️ Uninstall
941
+
942
+ 1. Remove the entry from the `"plugins"` array in your config file; if you installed on 2.x, delete the generated `~/.config/opencode/agents/*.md` and `commands/team-*.md` too, and any `default_agent: "team"` you no longer want.
943
+ 2. Delete the cache dir (table in [Install](#-read-this-once-save-yourself-an-hour-later)) if you want the disk space back.
944
+ 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. The global `team-mode.jsonc` is yours to keep or delete — the plugin will simply write a fresh inert one if you remove it.
945
+
946
+ No DLLs were harmed. Nothing was written to your working tree.
947
+
948
+ ---
949
+
950
+ ## 🏛️ Architecture (for the curious)
951
+
952
+ ```
953
+ opencode-team-mode/
954
+ ├── src/
955
+ │ ├── index.ts ← Plugin entry ({id, setup} — v2 only)
956
+ │ ├── agents.ts ← Agent structure (modes, colors, temperatures, whitelist matrix)
957
+ │ ├── prompts/ ← Agent prompts (lead / specialists / shared) — pinned by tests
958
+ │ ├── commands.ts ← Slash command definitions
959
+ │ ├── blackboard.ts ← Shared blackboard + TTL sweeper
960
+ │ ├── envprotect.ts ← R6 facade (patterns / classifiers / gate predicates / hook)
961
+ │ ├── identity.ts ← Agent-name identity (case-insensitive lead match)
962
+ │ ├── tm/ ← Governed tools: pipelines / store / preview / guard / refs /
963
+ │ │ config-layers (the 58-key registry) / config-files (the two
964
+ │ │ layers) / config-template (the inert auto-created file) /
965
+ │ │ webfetch / search / memory / board / ledger / dispatch
966
+ │ ├── host/ ← v2 personality (setup / guard / offload / session / events / …)
967
+ │ └── types.ts ← Loader-contract types
968
+ ├── docs/installation.md ← Historical 1.18.x guide (no longer supported)
969
+ ├── docs/installation-v2.md ← The 2.x install guide (roles arrive as generated config files)
970
+ ├── scripts/ ← One-line installers (bash / PowerShell)
971
+ ├── pt07/ ← PT-07 baseline suite (seeded A/B token measurement)
972
+ └── README.*.md ← You are here (twice)
973
+ ```
974
+
975
+ The loader calls `setup(ctx)` once: it registers the `tm_*` tools, resolves the
976
+ two config layers, installs the R6/address guard on `permission.evaluate`, attaches
977
+ the JIT offload on `tool.execute.after`, and publishes the blackboard note. User-defined
978
+ agents with the same name always win — the plugin never clobbers.
979
+
980
+ The one rule that makes the config layer trustworthy: **`CONFIG_KEYS` is the
981
+ registry and the single source of truth.** A key absent from it is reported as
982
+ unknown and never applied; the red-line set is derived from that registry rather
983
+ than hand-listed; and the auto-created global file is rendered *from* the
984
+ registry, so it cannot drift from what the code actually reads.
985
+
986
+ ---
987
+
988
+ ## 🤝 Contributing
989
+
990
+ Issues and PRs welcome. Especially wanted: localization of agent prompts,
991
+ more agent roles, more command templates, and real-world reports of the
992
+ search engines' behavior (they rearrange their markup; the extractor filters
993
+ are intentionally loose but not psychic).
994
+
995
+ ---
996
+
997
+ ## 📄 License
998
+
999
+ [Apache License 2.0](./LICENSE)
1000
+
1001
+ ---
1002
+
1003
+ ## 🔗 Links
1004
+
1005
+ - [npm Package](https://www.npmjs.com/package/@te-river/opencode-team-mode) — `@te-river/opencode-team-mode`
1006
+ - [Installation guide, **OpenCode 2.x**](./docs/installation-v2.md) — the supported install: a 2.x plugin cannot create an agent, so the six roles and six commands are generated into the config directory
1007
+ - [Installation guide, 1.18.x](./docs/installation.md) — **historical only**: the 1.18.x personality was removed in the 1.7.0 line, so this page is kept for reference and is not a working install path
1008
+ - [OpenCode Desktop](https://opencode.ai) — Official website & download
1009
+ - [OpenCode Docs](https://opencode.ai/docs) — Configuration & plugin documentation
1010
+ - [OpenCode Plugin API](https://opencode.ai/docs/plugins) — Build your own plugins