@te-river/opencode-team-mode 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -169,6 +169,55 @@ You can also invoke agents directly using the `@` mention in OpenCode Desktop:
169
169
  - `@tester` — Write tests
170
170
  - `@researcher` — Research a topic
171
171
 
172
+ ### Demo
173
+
174
+ A session transcript, recreated from how the flow actually looks. The user
175
+ picks `team` in the agent switcher (or enables `defaultAgent`, see
176
+ Configuration), then just types into a fresh chat:
177
+
178
+ > **User:** Add token-bucket rate limiting to our Express API — 100 requests
179
+ > per minute per user, return 429 when exceeded. Don't touch anything under
180
+ > `src/legacy/`.
181
+
182
+ ```text
183
+ team Breaking this down: design → implement → review → test.
184
+ Task board: .git/opencode-team/20260831-143012/rate-limiter/ (session folder + board inside .git/, auto-swept after idle TTL)
185
+
186
+ ▸ @architect — designing (writes 01-architect-design.md)
187
+ ✓ in-memory token bucket, per-user key, 429 + Retry-After
188
+ summary above, full design on the board
189
+
190
+ ▸ @implementer — building (Reads: 01; writes 02-implementer-middleware.md)
191
+ ✓ src/middleware/rateLimit.ts (new), wired into src/app.ts (+3 lines)
192
+
193
+ ▸ @reviewer — auditing the diff (Reads: 01, 02; writes 03-reviewer-findings-r1.md)
194
+ ⚠ 1 MAJOR — bucket refill does read-modify-write in two steps;
195
+ races under concurrent requests
196
+ → converted to a fix task; dispatched to @implementer with the
197
+ finding text (the user was not asked to approve this step)
198
+
199
+ ▸ @implementer r2 — fixing the race (Reads: 03-r1 §MAJOR; writes 04-implementer-r2.md)
200
+ ✓ refill restructured to single atomic update
201
+
202
+ ▸ @reviewer r2 — re-review of fixed scope only
203
+ ✓ clean — r1 finding resolved, no regressions
204
+
205
+ ▸ @tester — covering limiter + boundaries (writes 05-tester-report.md)
206
+ ✓ 14/14 pass — burst edge, window expiry, concurrent refill,
207
+ src/legacy/** byte-identical (user boundary verified in tests)
208
+
209
+ team Done.
210
+ rate limiter shipped: rateLimit.ts (new) · app.ts (+3) · 14 tests green
211
+ review loop: 1 major found → fixed → clean
212
+ assumption: in-memory only — say the word if you want Redis
213
+ src/legacy/ untouched
214
+ task board left in place — TTL sweep will reclaim it
215
+ ```
216
+
217
+ The only message the user typed was the first one. The reviewer's finding
218
+ became the implementer's work order without a prompt; every artifact stayed
219
+ out of chat and on the board, read only by the dispatch that needed it.
220
+
172
221
  ### Desktop-specific features
173
222
 
174
223
  In **OpenCode Desktop**, you get additional UX benefits:
@@ -212,30 +261,53 @@ opencode-team-mode/
212
261
 
213
262
  ## 🗂️ Shared Blackboard (with automatic cleanup)
214
263
 
215
- Sub-agents cannot message each other live (platform limitation), so TeamMode coordinates them through a **file blackboard**:
216
-
217
- - Each multi-agent task gets its own directory under
218
- `<repo>/.git/opencode-team/<task-slug>/` inside `.git/`, so your working
219
- tree and commits are **never polluted**. (Non-git workspaces fall back to
220
- the OS temp dir.)
221
- - Every agent writes its full deliverable to a designated artifact
222
- (`01-architect-design.md`, `03-review-findings.md`, …); the Team Lead
223
- relays *summary + file path* in each dispatch and keeps `MANIFEST.md` as
224
- the index. Full documents are shared verbatim no lossy telephone game,
225
- and fewer tokens.
264
+ Sub-agents cannot message each other live (platform limitation), so TeamMode coordinates them through a **file blackboard** with strict ownership:
265
+
266
+ - **Session isolation:** every conversation owns ONE timestamped session
267
+ folder, and each multi-agent task gets its own directory inside it:
268
+ `<repo>/.git/opencode-team/<session-key>/<task-slug>/` inside `.git/`,
269
+ so your working tree and commits are **never polluted**. (Non-git
270
+ workspaces fall back to the OS temp dir.) Since boards now linger until
271
+ the TTL sweep, the session layer keeps a fresh conversation from bumping
272
+ into or reading stale artifacts from a not-yet-swept board (timestamps
273
+ are second-granular, so overlap needs two conversations starting in the
274
+ same second).
275
+ - **File ownership:** every artifact is one topic-sized file written by
276
+ exactly one agent (`01-architect-auth-design.md`, `03-reviewer-auth-r1.md`).
277
+ ~100 lines max per file — split topics instead of letting files balloon.
278
+ - **Writes are frozen:** a revision is a new round-suffixed file
279
+ (`…-r2.md`); nothing is ever appended to or later agents reading stale rounds.
280
+ - **The Team Lead is the router:** every dispatch carries a manifest —
281
+ `Task:` (self-contained brief), `Reads:` (only the files that work package
282
+ needs), `Write to:` (the one file the agent owns). Specialists read nothing
283
+ that isn't listed, so long tasks never drown sub-agents in unnecessary context.
284
+ - **`MANIFEST.md` is the lead's state board:** a file index plus a ≤50-line
285
+ `## Current state` section (phase, decisions still valid, next steps),
286
+ updated every converged round — the lead's compressed memory across long tasks.
226
287
  - The Team Lead also enforces a review/test **feedback loop**: Critical/Major
227
288
  findings and product bugs automatically become tracked fix tasks until the
228
289
  deliverable converges.
229
290
 
230
- ### Cleanuptwo layers
291
+ ### Triagequestions don't become code edits
231
292
 
232
- | Layer | Who | When |
233
- |---|---|---|
234
- | Fast path | Team Lead (prompt rule) | Deletes the task directory right after the final report |
235
- | Safety net | Plugin code (in-process sweeper) | At startup + every hour: removes task directories idle **beyond the TTL** |
293
+ The Team Lead classifies every incoming message before acting: a question or
294
+ consult gets an answer (zero file changes, fixes merely proposed and awaiting
295
+ your go-ahead); only explicit action requests enter the workflow. And whenever
296
+ you spell out what may or may not be touched, **those boundaries outrank
297
+ everything else** — the lead restates them in every single dispatch.
236
298
 
237
- The sweeper is pure code it never relies on the model remembering to
238
- delete, and it also cleans up leftovers from crashes or force-kills.
299
+ ### Cleanupthe TTL sweeper is the only path
300
+
301
+ | Who | When |
302
+ |---|---|
303
+ | Plugin code (in-process sweeper) | At startup + every hour: removes task directories idle **beyond the TTL** |
304
+
305
+ The Team Lead never deletes task directories — finished boards stay
306
+ readable so you can audit how a run went, and reclamation is pure code
307
+ that never relies on the model remembering to do anything (crashes and
308
+ force-kills leave nothing behind either). The sweeper prunes stale task
309
+ dirs individually under a still-live session, and reclaims an entirely
310
+ idle session folder in one pass. Set `ttlDays` to taste.
239
311
 
240
312
  ### Configure the TTL
241
313
 
@@ -256,21 +328,31 @@ fall back to 5.
256
328
 
257
329
  ### Default agent
258
330
 
259
- TeamMode makes **`team` the default agent** (replacing the built-in `build`)
260
- so every new chat starts with the team orchestrator it appears above the
261
- rest in the switcher's default slot. To keep `build` (or any other agent)
262
- as the default, or pin a different one:
331
+ By default TeamMode **does not** touch the default agent new chats start
332
+ on the built-in `build` as before. This is a deliberate ordering trade-off:
333
+ the switcher pins the default agent to the **first slot** and sorts
334
+ everything else alphabetically, so "Team pinned as default (first)" and
335
+ "Team shown after Plan" are mutually exclusive. Leaving the default slot
336
+ alone gives you the picker order **build, plan, team**.
337
+
338
+ To promote Team as the default agent anyway (new chats start with the team
339
+ orchestrator, and Team is pinned first — order becomes **team, build,
340
+ plan**):
263
341
 
264
342
  ```jsonc
265
343
  {
266
344
  "plugin": [
267
- ["@te-river/opencode-team-mode@latest", { "defaultAgent": false }]
345
+ ["@te-river/opencode-team-mode@latest", { "defaultAgent": true }]
268
346
  ]
269
347
  }
270
348
  ```
271
349
 
272
- An explicitly configured non-`build` `default_agent` is always respected
273
- untouched.
350
+ An explicitly configured non-`build` `default_agent` in your own config is
351
+ always respected untouched, even with `defaultAgent: true`.
352
+
353
+ **Upgrade note:** since v1.4.4 the plugin no longer claims the default-agent
354
+ slot by default. If you relied on Team being your default agent before
355
+ (v1.4.2+), add `{ "defaultAgent": true }` to your plugin options.
274
356
 
275
357
  ---
276
358
 
package/README.zh-CN.md CHANGED
@@ -169,6 +169,51 @@ TeamMode 为 OpenCode 添加了六个斜杠命令,在聊天输入框中输入
169
169
  - `@tester` — 编写测试
170
170
  - `@researcher` — 调研主题
171
171
 
172
+ ### 演示
173
+
174
+ 以下是一段会话实录的还原。用户在代理选择器中选中 `team`(或按下方配置开启
175
+ `defaultAgent`),开新会话直接输入:
176
+
177
+ > **用户:** 给我们的 Express API 加令牌桶限流——每用户每分钟 100 请求,
178
+ > 超限返回 429。不要动 `src/legacy/` 下的任何东西。
179
+
180
+ ```text
181
+ team 拆解任务:设计 → 实现 → 审查 → 测试。
182
+ 任务黑板:.git/opencode-team/20260831-143012/rate-limiter/(会话目录 + 任务板,都在 .git/ 内,闲置超 TTL 自动清理)
183
+
184
+ ▸ @architect — 设计中(写入 01-architect-design.md)
185
+ ✓ 内存令牌桶、按用户键控、429 + Retry-After
186
+ 聊天里只有摘要,设计全文在黑板上
187
+
188
+ ▸ @implementer — 实现中(Reads: 01;写 02-implementer-middleware.md)
189
+ ✓ src/middleware/rateLimit.ts(新增),接入 src/app.ts(+3 行)
190
+
191
+ ▸ @reviewer — 审查改动(Reads: 01、02;写 03-reviewer-findings-r1.md)
192
+ ⚠ 1 个 MAJOR — 桶回充分两步读-改-写,并发下有竞态
193
+ → 已自动转为修复任务,发现原文随任务书派给 @implementer
194
+ (这一步没有要求用户拍板)
195
+
196
+ ▸ @implementer r2 — 修竞态(Reads: 03-r1 §MAJOR;写 04-implementer-r2.md)
197
+ ✓ 回充重构为单次原子更新
198
+
199
+ ▸ @reviewer r2 — 只复审改动范围
200
+ ✓ 通过 — r1 发现已解决,无回归
201
+
202
+ ▸ @tester — 覆盖限流器与边界(写 05-tester-report.md)
203
+ ✓ 14/14 通过 — 突发边界、窗口过期、并发回充、
204
+ src/legacy/** 逐字节未变(用户边界写进了测试断言)
205
+
206
+ team 完成。
207
+ 限流器已交付:rateLimit.ts(新增)· app.ts(+3)· 14 测试全绿
208
+ 审查闭环:1 个 major → 已修 → 清零
209
+ 假设:仅内存存储——要接 Redis 说一声
210
+ src/legacy/ 未动
211
+ 任务黑板留在原地,TTL 到期自动回收
212
+ ```
213
+
214
+ 用户输入的消息只有第一条。reviewer 的发现直接变成 implementer 的下一张
215
+ 工单;每份制品都留在黑板上而不是聊天里,只被需要它的那次派发读取。
216
+
172
217
  ### 桌面版专属特性
173
218
 
174
219
  在 **OpenCode 桌面版** 中,你还能获得额外的 UX 体验:
@@ -212,24 +257,42 @@ opencode-team-mode/
212
257
 
213
258
  ## 🗂️ 共享黑板(带自动清理)
214
259
 
215
- 子代理之间无法实时互发消息(平台限制),TeamMode 通过**文件黑板**让它们协作:
260
+ 子代理之间无法实时互发消息(平台限制),TeamMode 通过**严格所有权的文件黑板**让它们协作:
216
261
 
217
- - 每个多 Agent 任务在 `<repo>/.git/opencode-team/<task-slug>/` 下拥有独立目录 ——
262
+ - **会话隔离:** 每个会话拥有一个时间戳会话目录,多 Agent 任务在其内再各自
263
+ 独立建任务目录:`<repo>/.git/opencode-team/<session-key>/<task-slug>/` ——
218
264
  位于 `.git/` 内,**绝不污染**你的工作区和 commit(非 git 工作区自动回退到系统临时目录)。
219
- - 每个 Agent 把完整产出写入指定文件(`01-architect-design.md`、`03-review-findings.md`
220
- 等),Team Lead 在派发时传递*摘要 + 文件路径*,并维护 `MANIFEST.md` 索引。
221
- 全文档原文共享 —— 没有"传话失真",还省 token。
265
+ 正因为黑板现在会留到 TTL 清扫才消失,会话层让新对话几乎不可能撞上(或误读到)
266
+ 上一场还没被收走的旧黑板 —— 时间戳精确到秒,理论上只有同一秒开跑的两个会话才会重名。
267
+ - **文件所有权**:每个制品是一个"一主题一文件",只由一个 Agent 写
268
+ (`01-architect-auth-design.md`、`03-reviewer-auth-r1.md`)。单文件约 ≤100 行,
269
+ 超长就拆主题文件而不是任其膨胀。
270
+ - **写入即冻结**:修订 = 新的轮次后缀文件(`…-r2.md`);绝不追加旧文件,
271
+ 后续 Agent 也永远读不到过时轮次。
272
+ - **Team Lead 是路由器**:每次 dispatch 携带清单——`Task:`(自包含任务书)、
273
+ `Reads:`(仅列出该工作包需要的文件)、`Write to:`(该 Agent 本次拥有的唯一文件)。
274
+ 子代理不读清单之外的任何东西,超长任务因此不会把无关上下文灌进子代理。
275
+ - **`MANIFEST.md` 是 lead 的状态板**:文件索引 + 顶部 ≤50 行的 `## Current state`
276
+ 节(阶段、仍然有效的决策、下一步),每轮闭环后更新——lead 跨长任务的压缩记忆。
222
277
  - Team Lead 同时强制执行审查/测试**反馈闭环**:Critical/Major 问题和产品 bug
223
278
  自动转化为跟踪的修复任务,直到交付物收敛。
224
279
 
225
- ### 清理 —— 两层防御
280
+ ### Triage —— 提问不会变成代码修改
226
281
 
227
- | 层级 | 责任方 | 时机 |
228
- |---|---|---|
229
- | 快速路径 | Team Lead(prompt 规则) | 最终报告交付后立即删除任务目录 |
230
- | 安全网 | 插件代码(进程内清扫器) | 启动时 + 每小时:清除空闲超过 **TTL** 的任务目录 |
282
+ Team Lead 对每条消息先分类再行动:咨询/提问只得到回答(零文件改动,发现缺陷
283
+ 仅**提议**修复并等待你放行);只有明确的行动指令才进入工作流。并且一旦你写明
284
+ 了哪些能碰哪些不能碰,**这些边界高于一切规则**——lead 会在每次派发中原样重申。
231
285
 
232
- 清扫器是纯代码实现 —— 从不依赖模型"记得删",还能兜底清理崩溃/强杀留下的残骸。
286
+ ### 清理 —— 只有 TTL 清扫器一条路
287
+
288
+ | 责任方 | 时机 |
289
+ |---|---|
290
+ | 插件代码(进程内清扫器) | 启动时 + 每小时:清除空闲超过 **TTL** 的任务目录 |
291
+
292
+ Team Lead 不再删除任务目录 —— 跑完的黑板原地留给你回看审计;回收由纯代码
293
+ 完成,从不依赖模型"记得删",崩溃/强杀留下的残骸同样会被清扫。清扫器对活跃
294
+ 会话内的过期任务逐个回收,对整个闲置的会话目录一次性收走。TTL 可用
295
+ `ttlDays` 调节。
233
296
 
234
297
  ### 自定义 TTL
235
298
 
@@ -248,18 +311,26 @@ opencode-team-mode/
248
311
 
249
312
  ### 默认代理
250
313
 
251
- TeamMode 会将 **`team` 设为默认代理**(替代内建 `build`),新会话直接由团队
252
- 调度者接管。若想保持 `build` 或其他代理为默认:
314
+ TeamMode 默认**不再占用默认代理槽**——新会话仍从内建 `build` 开始。这是刻意的
315
+ 排序取舍:选择器会把**默认代理钉在第一位**,其余按名称字母升序,因此
316
+ 「Team 排默认(首位)」与「Team 显示在 Plan 之后」不可兼得。不占槽时顺序为
317
+ **build, plan, team**。
318
+
319
+ 若希望新会话直接由团队调度者接管(Team 被钉在首位,顺序变为
320
+ **team, build, plan**),开启 `defaultAgent`:
253
321
 
254
322
  ```jsonc
255
323
  {
256
324
  "plugin": [
257
- ["@te-river/opencode-team-mode@latest", { "defaultAgent": false }]
325
+ ["@te-river/opencode-team-mode@latest", { "defaultAgent": true }]
258
326
  ]
259
327
  }
260
328
  ```
261
329
 
262
- 用户显式配置的非 `build` 默认代理永远原样保留。
330
+ 即使用户显式配置了非 `build` 默认代理,也永远原样保留(开启与否都不覆写)。
331
+
332
+ **升级提示**:自 v1.4.4 起,插件默认不再占用默认代理槽。此前依赖 Team 作为
333
+ 默认代理(v1.4.2+)的用户,请在插件选项中添加 `{ "defaultAgent": true }`。
263
334
 
264
335
  ---
265
336
 
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAka7C,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAO9C,CAAA"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAqd7C,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAO9C,CAAA"}
package/dist/agents.js CHANGED
@@ -17,21 +17,25 @@
17
17
  * - Research findings carry confidence tags and critical ones are verified.
18
18
  */
19
19
  /* ------------------------------------------------------------------ */
20
- /* Blackboard write guarantee (appended to every specialist prompt) */
20
+ /* Blackboard rules (appended to every specialist prompt) */
21
21
  /* ------------------------------------------------------------------ */
22
22
  const BLACKBOARD_GUARANTEE = `
23
23
 
24
- ## Blackboard write guarantee
25
- - Writing your designated blackboard artifact is ALWAYS within your role.
26
- Any read-only constraint applies to PROJECT SOURCES and the code under
27
- review NEVER to the blackboard directory. Your tools can write there;
28
- do it yourself, in the file the dispatch names.
24
+ ## Blackboard rules
25
+ - You own exactly ONE artifact file: the one named in your dispatch under
26
+ \`Write to:\`. Create/overwrite only that file never append to existing
27
+ artifacts, never edit files owned by other roles, never rewrite history.
28
+ - Read ONLY the files listed in your dispatch's \`Reads:\`. Do not browse
29
+ the task directory for "extra context" — the lead scoped your reading
30
+ deliberately, and unlisted rounds will only pollute your context. If you
31
+ believe a needed file is missing from the list, say so in your reply
32
+ instead of opening files nobody authorized.
33
+ - Writing your artifact is ALWAYS within your role: any read-only
34
+ constraint applies to PROJECT SOURCES and the code under review — NEVER
35
+ to the blackboard. Your tools can write there; do it yourself.
29
36
  - NEVER reply "append this verbatim for me" or hand the full deliverable
30
37
  back to the dispatcher to transcribe — that defeats the entire point of
31
- the blackboard. Reply with your summary + the file path, nothing else.
32
- - Read ONLY the blackboard files explicitly listed in your dispatch. Do
33
- not browse the task directory for "extra context" — the lead scoped the
34
- reading deliberately, and stale rounds will only pollute yours.
38
+ the blackboard. Summary + your file path is the only valid reply shape.
35
39
  - If a write genuinely fails (permissions, missing directory), start your
36
40
  reply with the line \`BLACKBOARD WRITE FAILED: <reason>\` and only then
37
41
  include the full content as fallback, so the lead can retry the write
@@ -52,6 +56,24 @@ const teamLead = {
52
56
  You orchestrate the team: decompose work, dispatch it to specialist agents
53
57
  via the Task tool, integrate their outputs, and enforce quality gates.
54
58
 
59
+ ## Triage — classify before acting (Step 0, always)
60
+ - Question ≠ work order. When the user asks, analyzes, or consults
61
+ ("why does X fail?", "how would we do Y?"), ANSWER it — read code if
62
+ useful, change nothing. If answering needs external knowledge, dispatch
63
+ \`researcher\`; don't grind through it yourself.
64
+ - Before any modification, ask explicitly: "does this request need file
65
+ changes?" Anything weaker than a clear yes → touch zero files.
66
+ - Spotted an obvious defect while answering? Propose the fix and WAIT for
67
+ the go-ahead — never fix-on-the-sly.
68
+ - Explicit action request ("fix X", "add Y", "refactor Z") → enter the
69
+ workflow below.
70
+ - Genuinely ambiguous → one targeted question, then act.
71
+ - USER-STATED BOUNDARIES ARE SUPREME: whenever the user details what may
72
+ be touched and what must not (files, modules, features), those limits
73
+ outrank every rule in this prompt. Enforce them in your own work AND
74
+ restate them inside every dispatch; if a task seems to require crossing
75
+ one, stop and ask — do not "balance" the conflict yourself.
76
+
55
77
  ## Hard rule — TodoList discipline (non-negotiable)
56
78
  Before you touch anything on a medium-or-larger task you MUST create a todo
57
79
  list. A task qualifies as medium-or-larger if ANY of these hold:
@@ -82,8 +104,9 @@ Rules for the list:
82
104
  4. **Integrate** — collect outputs, resolve conflicts, synthesize; consult
83
105
  blackboard files whenever a summary is not enough.
84
106
  5. **Verify** — run the feedback loop below before declaring done.
85
- 6. **Report & clean up** — structured summary with changes, review/test
86
- verdict, risks; then delete the task blackboard directory.
107
+ 6. **Report** — structured summary with changes, review/test verdict,
108
+ risks. Leave the task directory in place: the plugin's TTL sweeper is
109
+ the only cleanup path (never delete it yourself).
87
110
 
88
111
  ## When you may edit directly
89
112
  Delegation is the default, not a straitjacket. You MAY make small direct
@@ -91,36 +114,64 @@ edits: config tweaks, typo/format fixes, doc updates, tiny glue code
91
114
  (≲ 10 lines). Anything substantive — feature logic, multi-file changes,
92
115
  API design — goes to \`implementer\`.
93
116
 
94
- ## Shared blackboard (sub-agent coordination)
95
- Sub-agents cannot message each other live, so the team coordinates through a
96
- file blackboard (root path is appended at the end of this prompt):
97
- - When a task involves 2+ agents, create ONE task directory under the board
98
- root: \`<root>/<task-slug>/\`.
99
- - Every dispatch must state: the task directory, the exact output file the
100
- agent should write (e.g. \`01-architect-design.md\`), and which prior files
101
- to read first.
102
- - Keep dispatches self-contained: include a 2–5 line summary of relevant
103
- prior work in the text AND point to the blackboard file holding the full
104
- content. Summary-in-prompt + file-path is the belt-and-braces protocol
105
- never rely on an agent "knowing" what another produced.
106
- - Scope the reading: list ONLY the blackboard files the work package
107
- actually needs (latest relevant round of each artifact) — never tell an
108
- agent to "read everything in the directory".
109
- - When an artifact is revised, write a new round-suffixed file
110
- (e.g. \`03-review-findings-r2.md\`) and reference only the latest round
111
- in dispatches, so stale iterations never enter a sub-agent's context.
117
+ Anti-pattern the lead's own hands (observed in production): while
118
+ building something, you drift into writing file after file yourself until
119
+ the whole deliverable is done inline. Guard rails:
120
+ - If the request meets the medium-or-larger bar (see TodoList rule),
121
+ hand-execution is NOT permitted — every work package on the list gets
122
+ dispatched, including "small" ones you feel like knocking out.
123
+ - Sunk cost is not a reason to continue: caught yourself mid-inline-build
124
+ on a multi-file package? STOP, dispatch the remainder (or the whole
125
+ package for review), and treat what you wrote as input to the specialist,
126
+ not as a fait accompli.
127
+ - A complete feature never arrives in the lead's own diffs. If your final
128
+ report would say "I wrote X, Y, Z" that is a triage failure, not
129
+ efficiency.
130
+
131
+ ## Shared blackboard (file ownership + your dispatch manifest)
132
+ Sub-agents cannot message each other live; the blackboard is their shared
133
+ memory and YOU are the router — you decide who writes what and who reads
134
+ what (root path is appended at the end of this prompt):
135
+ - SESSION ISOLATION: this conversation owns exactly ONE session folder
136
+ \`<root>/<session-key>/\` (compact clock timestamp, created on your first
137
+ board write, reused for every later task here — see the resolved-root
138
+ section). Never touch or reuse a session folder another conversation
139
+ created; boards past their TTL stay on disk until the sweeper runs, and
140
+ the session layer is what keeps a fresh run from bumping into them.
141
+ - One task directory per multi-agent task: \`<root>/<session-key>/<task-slug>/\`.
142
+ - FILE OWNERSHIP — every artifact is one topic-sized file written by
143
+ exactly one agent: \`NN-<role>-<topic>.md\` (e.g.
144
+ \`01-architect-auth-design.md\`, \`03-reviewer-auth-r1.md\`). Keep files
145
+ ~100 lines or less; when an artifact grows past that, split it into
146
+ topic files instead of letting it bloat.
147
+ - WRITES ARE FROZEN — a revision is a NEW file with a round suffix
148
+ (\`02-implementer-auth-r2.md\`). Never append to an existing artifact,
149
+ and reference only the latest round in later dispatches, so stale
150
+ iterations never enter a sub-agent's context.
151
+ - Every dispatch must carry a manifest (all fields required):
152
+ Task: self-contained description, with a 2–5 line summary of the
153
+ prior work it builds on (summary-in-prompt + file paths is
154
+ the belt-and-braces protocol)
155
+ Reads: ONLY the files this work package needs — never "read
156
+ everything in the directory"
157
+ Write to: the one new file this agent owns for this package
158
+ If the user stated boundaries, restate them in the dispatch text too.
159
+ - MANIFEST.md is yours alone: a file index (one line per artifact — file,
160
+ owner, status, one-line summary) topped by a \`## Current state\` section
161
+ of ≤ 50 lines (phase, decisions still valid, next steps). Update it
162
+ after every converged round — it is your compressed memory across long
163
+ tasks. Do not put it on specialists' Reads lists unless one genuinely
164
+ needs the index.
112
165
  - Sub-agents reply with a summary plus their file path; read the file
113
166
  yourself when you need detail, then relay the relevant parts onward.
114
167
  - A specialist asking you to transcribe its output verbatim is a protocol
115
168
  violation — send it back to write the file itself. Only if its reply
116
169
  contains \`BLACKBOARD WRITE FAILED\` may you write the artifact as a
117
170
  fallback; note the failure in MANIFEST.md so it is not silently tolerated.
118
- - Maintain \`MANIFEST.md\` in the task directory: one line per artifact
119
- (file role status — one-line summary).
120
- - After you deliver the final report, DELETE the task directory (use the
121
- platform-appropriate command). The plugin also auto-sweeps directories
122
- idle beyond the TTL — your deletion is the fast path, the sweeper is the
123
- safety net.
171
+ - Do NOT delete the task directory after your report — TTL sweeping owns
172
+ reclamation (see Auto-cleanup in the resolved-root section). Finished
173
+ boards stay readable so the user can audit the run; leftovers from
174
+ crashed sessions sweep the same way.
124
175
 
125
176
  ## Feedback loop (mandatory before "done")
126
177
  - Triage reviewer findings: **Critical/Major → spawn fix tasks** on the todo
@@ -214,7 +265,7 @@ When the team lead sends back a design flaw found in review or testing:
214
265
  `,
215
266
  color: "#38BDF8", // sky blue
216
267
  // Read-only on PROJECT sources; the blackboard artifact is explicitly
217
- // writable (see Blackboard write guarantee).
268
+ // writable (see Blackboard rules).
218
269
  permission: { edit: "allow", bash: "deny", webfetch: "allow" },
219
270
  };
220
271
  /* ------------------------------------------------------------------ */
@@ -310,7 +361,7 @@ by item (fixed / not fixed / partial).
310
361
  `,
311
362
  color: "#FB923C", // orange
312
363
  // May edit ONLY the blackboard artifact; never the reviewed code
313
- // (see Blackboard write guarantee + role rules).
364
+ // (see Blackboard rules + role rules).
314
365
  permission: { edit: "allow", bash: "allow", webfetch: "allow" },
315
366
  };
316
367
  /* ------------------------------------------------------------------ */
@@ -410,7 +461,7 @@ by the team — flag prominently if that is the case.
410
461
  color: "#A78BFA", // violet
411
462
  permission: { edit: "allow", bash: "allow", webfetch: "allow", websearch: "allow" },
412
463
  };
413
- /* Append the blackboard write guarantee to every specialist prompt. */
464
+ /* Append the blackboard rules to every specialist prompt. */
414
465
  for (const a of [architect, implementer, reviewer, tester, researcher]) {
415
466
  a.prompt = (a.prompt ?? "") + BLACKBOARD_GUARANTEE;
416
467
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AACxE,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;oCAgBO,CAAA;AAEpC,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,MAAM,QAAQ,GAAgB;IAC5B,IAAI,EAAE,SAAS;IACf,WAAW,EACT,2EAA2E;QAC3E,qEAAqE;QACrE,2EAA2E;QAC3E,2EAA2E;QAC3E,4BAA4B;IAC9B,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgHT;IACC,KAAK,EAAE,SAAS,EAAE,SAAS;IAC3B,UAAU,EAAE;QACV,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,OAAO;KACd;CACF,CAAA;AAED,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,MAAM,SAAS,GAAgB;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AAA;AAED,6DAA6D;AAC7D,KAAK,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,oBAAoB,CAAA;AACpD,CAAC;AAED,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AAExE,MAAM,CAAC,MAAM,MAAM,GAAgC;IACjD,MAAM,EAAE,QAAQ;IAChB,SAAS;IACT,WAAW;IACX,QAAQ;IACR,MAAM;IACN,UAAU;CACX,CAAA"}
@@ -2,12 +2,17 @@
2
2
  * Shared blackboard for sub-agent coordination + automatic maintenance.
3
3
  *
4
4
  * Sub-agents cannot message each other live (platform limitation), so
5
- * TeamMode uses a file blackboard under `<repo>/.git/opencode-team/<task>/`:
5
+ * TeamMode uses a file blackboard under
6
+ * `<repo>/.git/opencode-team/<session-key>/<task>/`:
7
+ * - <session-key> is a compact timestamp folder, one per conversation —
8
+ * a fresh conversation can never collide with a not-yet-swept board
9
+ * from an earlier one;
6
10
  * - each agent writes its full deliverable to a designated file;
7
11
  * - the team lead relays summaries + file paths in every dispatch;
8
- * - the team lead deletes the task directory when the workflow ends.
12
+ * - nobody deletes task directories by hand; the sweeper below reclaims
13
+ * them once idle past the TTL (sole cleanup path, by design).
9
14
  *
10
- * This module is the code-level safety net independent of the model:
15
+ * This module is the code-level reclamation path, independent of the model:
11
16
  * a sweeper removes task directories whose last activity is older than
12
17
  * the TTL, at plugin startup and hourly in-process. Placing the board
13
18
  * inside `.git/` guarantees the user's working tree and commits are never
@@ -31,8 +36,16 @@ export declare function teamRootFor(directory: string): string;
31
36
  */
32
37
  export declare function resolveTtlMs(options?: Record<string, unknown>): number;
33
38
  /**
34
- * Remove idle task directories under `root`.
35
- * Returns the number of directories deleted; never throws.
39
+ * Remove idle boards under `root`. Understands both layouts:
40
+ * - session-partitioned `<root>/<session-key>/<task>/`: stale tasks are
41
+ * pruned individually under a live session; an entirely idle session
42
+ * folder goes as a whole;
43
+ * - legacy flat `<root>/<task>/`: unchanged semantics — and if such a dir
44
+ * unexpectedly contains sub-directories, idle ones are pruned by the
45
+ * same rule (harmless hygiene, though counted as task dirs).
46
+ * Returns the number of task directories reclaimed; a wholesale session
47
+ * removal counts its task dirs (min 1, so a ghost empty stale session dir
48
+ * also counts 1). Never throws.
36
49
  */
37
50
  export declare function sweepStale(root: string, ttlMs?: number): number;
38
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"blackboard.d.ts","sourceRoot":"","sources":["../src/blackboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,cAAc,QAAyC,CAAA;AAQpE,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQzD;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAM1E;AAoBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAiB,GAAG,MAAM,CAwBvE;AAID;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EACjB,KAAK,SAAiB,GACrB,MAAM,CASR"}
1
+ {"version":3,"file":"blackboard.d.ts","sourceRoot":"","sources":["../src/blackboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,cAAc,QAAyC,CAAA;AAQpE,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQzD;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAM1E;AAuCD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAiB,GAAG,MAAM,CA6CvE;AAID;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EACjB,KAAK,SAAiB,GACrB,MAAM,CASR"}
@@ -2,12 +2,17 @@
2
2
  * Shared blackboard for sub-agent coordination + automatic maintenance.
3
3
  *
4
4
  * Sub-agents cannot message each other live (platform limitation), so
5
- * TeamMode uses a file blackboard under `<repo>/.git/opencode-team/<task>/`:
5
+ * TeamMode uses a file blackboard under
6
+ * `<repo>/.git/opencode-team/<session-key>/<task>/`:
7
+ * - <session-key> is a compact timestamp folder, one per conversation —
8
+ * a fresh conversation can never collide with a not-yet-swept board
9
+ * from an earlier one;
6
10
  * - each agent writes its full deliverable to a designated file;
7
11
  * - the team lead relays summaries + file paths in every dispatch;
8
- * - the team lead deletes the task directory when the workflow ends.
12
+ * - nobody deletes task directories by hand; the sweeper below reclaims
13
+ * them once idle past the TTL (sole cleanup path, by design).
9
14
  *
10
- * This module is the code-level safety net independent of the model:
15
+ * This module is the code-level reclamation path, independent of the model:
11
16
  * a sweeper removes task directories whose last activity is older than
12
17
  * the TTL, at plugin startup and hourly in-process. Placing the board
13
18
  * inside `.git/` guarantees the user's working tree and commits are never
@@ -57,15 +62,21 @@ export function resolveTtlMs(options = {}) {
57
62
  }
58
63
  return DEFAULT_TTL_MS;
59
64
  }
60
- /** Latest mtime among a directory and its immediate entries. */
61
- function lastActivity(dir) {
65
+ /**
66
+ * Latest mtime within `dir`, looking through up to `levels` sub-directory
67
+ * layers (artifacts live one level below a task dir, so 1 suffices per
68
+ * task and 2 from the session/root level).
69
+ */
70
+ function lastActivity(dir, levels = 0) {
62
71
  try {
63
72
  let latest = fs.statSync(dir).mtimeMs;
64
73
  for (const entry of fs.readdirSync(dir)) {
65
74
  try {
66
- const st = fs.statSync(path.join(dir, entry));
67
- if (st.mtimeMs > latest)
68
- latest = st.mtimeMs;
75
+ const child = path.join(dir, entry);
76
+ const st = fs.statSync(child);
77
+ const seen = st.isDirectory() && levels > 0 ? lastActivity(child, levels - 1) : st.mtimeMs;
78
+ if (seen > latest)
79
+ latest = seen;
69
80
  }
70
81
  catch {
71
82
  /* raced deletion — ignore */
@@ -78,8 +89,27 @@ function lastActivity(dir) {
78
89
  }
79
90
  }
80
91
  /**
81
- * Remove idle task directories under `root`.
82
- * Returns the number of directories deleted; never throws.
92
+ * True when a directory tree shows no activity within the TTL.
93
+ * `levels` must reach down to the artifact files: 1 for a task directory
94
+ * (files sit directly inside), 2 for a session directory (task dirs are
95
+ * one level deeper — depth 1 here would miss in-place rewrites and let a
96
+ * whole live session be reclaimed; regression-pinned by test fixture).
97
+ */
98
+ function isStale(dir, now, ttlMs, levels) {
99
+ const seen = lastActivity(dir, levels);
100
+ return seen !== 0 && now - seen > ttlMs;
101
+ }
102
+ /**
103
+ * Remove idle boards under `root`. Understands both layouts:
104
+ * - session-partitioned `<root>/<session-key>/<task>/`: stale tasks are
105
+ * pruned individually under a live session; an entirely idle session
106
+ * folder goes as a whole;
107
+ * - legacy flat `<root>/<task>/`: unchanged semantics — and if such a dir
108
+ * unexpectedly contains sub-directories, idle ones are pruned by the
109
+ * same rule (harmless hygiene, though counted as task dirs).
110
+ * Returns the number of task directories reclaimed; a wholesale session
111
+ * removal counts its task dirs (min 1, so a ghost empty stale session dir
112
+ * also counts 1). Never throws.
83
113
  */
84
114
  export function sweepStale(root, ttlMs = DEFAULT_TTL_MS) {
85
115
  let entries;
@@ -96,12 +126,37 @@ export function sweepStale(root, ttlMs = DEFAULT_TTL_MS) {
96
126
  try {
97
127
  if (!fs.statSync(dir).isDirectory())
98
128
  continue;
99
- const seen = lastActivity(dir);
100
- if (seen === 0)
101
- continue;
102
- if (now - seen > ttlMs) {
129
+ if (isStale(dir, now, ttlMs, 2)) {
130
+ // Entire tree idle: legacy flat task dir, or a finished session.
131
+ let tasks = 0;
132
+ for (const child of fs.readdirSync(dir)) {
133
+ try {
134
+ if (fs.statSync(path.join(dir, child)).isDirectory())
135
+ tasks++;
136
+ }
137
+ catch {
138
+ /* raced — ignore */
139
+ }
140
+ }
103
141
  fs.rmSync(dir, { recursive: true, force: true });
104
- removed++;
142
+ removed += Math.max(1, tasks);
143
+ continue;
144
+ }
145
+ // Live tree: prune per-task dirs (session layout; legacy dirs have
146
+ // no directory children, so this loop is a no-op for them).
147
+ for (const child of fs.readdirSync(dir)) {
148
+ const task = path.join(dir, child);
149
+ try {
150
+ if (!fs.statSync(task).isDirectory())
151
+ continue;
152
+ if (!isStale(task, now, ttlMs, 1))
153
+ continue;
154
+ fs.rmSync(task, { recursive: true, force: true });
155
+ removed++;
156
+ }
157
+ catch {
158
+ /* raced — skip this task */
159
+ }
105
160
  }
106
161
  }
107
162
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"blackboard.js","sourceRoot":"","sources":["../src/blackboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEpE,gCAAgC;AAChC,MAAM,iBAAiB,GAAG,EA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mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAwI/C,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAOlD,CAAA"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AA8I/C,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAOlD,CAAA"}
package/dist/commands.js CHANGED
@@ -101,27 +101,33 @@ const teamRun = {
101
101
  $ARGUMENTS
102
102
 
103
103
  ## Workflow
104
- 1. Understand the goal and acceptance criteria.
105
- 2. **Create a todo list FIRST** one item per work package, with checkable
104
+ 1. Triage first: if this is a question/consult rather than an action
105
+ request, answer it without touching files (propose fixes, wait for a
106
+ go-ahead). Honor and restate any user-stated boundaries everywhere.
107
+ 2. Understand the goal and acceptance criteria.
108
+ 3. **Create a todo list FIRST** — one item per work package, with checkable
106
109
  done-conditions. Update statuses live (exactly one in_progress).
107
- 3. Dispatch sub-tasks to the appropriate agents:
110
+ 4. Dispatch sub-tasks to the appropriate agents:
108
111
  - Design / architecture → architect
109
112
  - Implementation → implementer
110
113
  - Code review → reviewer
111
114
  - Testing → tester
112
115
  - Research → researcher
113
- Each dispatch must be self-contained (embed relevant prior outputs).
114
- 4. For multi-agent work, coordinate through the shared blackboard: create
115
- one task directory, have each agent write its full deliverable there,
116
- and relay summary + file path in every dispatch. Run independent
117
- sub-tasks in parallel.
118
- 5. Enforce the feedback loop: reviewer Critical/Major findings and tester
116
+ 5. Coordinate through the shared blackboard: this conversation owns one
117
+ session folder (<root>/<session-key>/ compact timestamp, created on
118
+ first board write), one task directory per task inside it; every
119
+ dispatch carries a manifest (Task / Reads: only the files needed /
120
+ Write to: one owned artifact file); artifacts are frozen — revisions are
121
+ new round-suffixed files; keep MANIFEST.md's \`## Current state\` header
122
+ updated each converged round. Run independent sub-tasks in parallel.
123
+ 6. Enforce the feedback loop: reviewer Critical/Major findings and tester
119
124
  product-bugs become fix tasks on the list → implementer fixes → re-review
120
125
  affected scope → re-run tests. Repeat until clean (max 2 loops, then
121
126
  escalate).
122
- 6. Collect all outputs, resolve conflicts, synthesize a final result.
123
- 7. Present a structured summary: changes, review/test verdict, remaining
124
- assumptions and risks. Then delete the task blackboard directory.`,
127
+ 7. Collect all outputs, resolve conflicts, synthesize a final result.
128
+ 8. Present a structured summary: changes, review/test verdict, remaining
129
+ assumptions and risks. Leave the task blackboard directory in place —
130
+ the plugin's TTL sweeper reclaims idle boards; never delete it yourself.`,
125
131
  };
126
132
  /* ------------------------------------------------------------------ */
127
133
  /* Export all commands keyed by name */
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,wEAAwE;AACxE,MAAM,QAAQ,GAAkB;IAC9B,WAAW,EACT,+FAA+F;IACjG,KAAK,EAAE,WAAW;IAClB,QAAQ,EAAE;;;;;;;;;;;;;kDAasC;CACjD,CAAA;AAED,wEAAwE;AACxE,MAAM,aAAa,GAAkB;IACnC,WAAW,EACT,0FAA0F;IAC5F,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE;;;;;;;;4DAQgD;CAC3D,CAAA;AAED,wEAAwE;AACxE,MAAM,UAAU,GAAkB;IAChC,WAAW,EACT,0EAA0E;IAC5E,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE;;;;;;;;;;;;;gEAaoD;CAC/D,CAAA;AAED,wEAAwE;AACxE,MAAM,QAAQ,GAAkB;IAC9B,WAAW,EACT,2EAA2E;IAC7E,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE;;;;;;;;;;;8BAWkB;CAC7B,CAAA;AAED,wEAAwE;AACxE,MAAM,YAAY,GAAkB;IAClC,WAAW,EACT,uEAAuE;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Q,EAAE;;;;;;;;;;;0DAW8C;CACzD,CAAA;AAED,wEAAwE;AACxE,MAAM,OAAO,GAAkB;IAC7B,WAAW,EACT,mGAAmG;IACrG,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAgCgE;CAC3E,CAAA;AAED,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AAExE,MAAM,CAAC,MAAM,QAAQ,GAAkC;IACrD,WAAW,EAAE,QAAQ;IACrB,gBAAgB,EAAE,aAAa;IAC/B,aAAa,EAAE,UAAU;IACzB,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,YAAY;IAC7B,UAAU,EAAE,OAAO;CACpB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -17,8 +17,13 @@
17
17
  * Options (via the tuple plugin form):
18
18
  * "plugin": [["@te-river/opencode-team-mode@latest", { "ttlDays": 7 }]]
19
19
  * - `ttlDays` → blackboard auto-cleanup TTL; default 5.
20
- * - `defaultAgent` → promote Team as the default agent (replacing the
21
- * built-in `build`); set `false` to opt out.
20
+ * - `defaultAgent` → promote Team as the default agent (opt-in: set `true`
21
+ * to enable). Trade-off when NOT enabled: new chats
22
+ * start on the built-in `build` agent, but the picker
23
+ * keeps Team in plain alphabetical order — after `plan`
24
+ * (the default agent is pinned first; everything else
25
+ * sorts by name, so "team first" and "team after plan"
26
+ * are mutually exclusive).
22
27
  */
23
28
  import type { OpenCodePlugin } from "./types.js";
24
29
  declare const plugin: OpenCodePlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,YAAY,CAAA;AAsBhE,QAAA,MAAM,MAAM,EAAE,cAyCb,CAAA;AAED,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,YAAY,CAAA;AA2BhE,QAAA,MAAM,MAAM,EAAE,cAyCb,CAAA;AAED,eAAe,MAAM,CAAA"}
package/dist/index.js CHANGED
@@ -17,8 +17,13 @@
17
17
  * Options (via the tuple plugin form):
18
18
  * "plugin": [["@te-river/opencode-team-mode@latest", { "ttlDays": 7 }]]
19
19
  * - `ttlDays` → blackboard auto-cleanup TTL; default 5.
20
- * - `defaultAgent` → promote Team as the default agent (replacing the
21
- * built-in `build`); set `false` to opt out.
20
+ * - `defaultAgent` → promote Team as the default agent (opt-in: set `true`
21
+ * to enable). Trade-off when NOT enabled: new chats
22
+ * start on the built-in `build` agent, but the picker
23
+ * keeps Team in plain alphabetical order — after `plan`
24
+ * (the default agent is pinned first; everything else
25
+ * sorts by name, so "team first" and "team after plan"
26
+ * are mutually exclusive).
22
27
  */
23
28
  import { agents } from "./agents.js";
24
29
  import { commands } from "./commands.js";
@@ -30,9 +35,14 @@ function blackboardNote(root, ttlDays) {
30
35
  "",
31
36
  "## Team Blackboard — resolved for this workspace",
32
37
  `Root directory: \`${root}\``,
33
- `- Create exactly ONE task sub-directory per multi-agent task: \`<root>/<task-slug>/\`.`,
34
- `- Auto-cleanup: the plugin sweeps task directories idle for more than ${ttlDays} days.`,
35
- ` Your own delete-after-report is the fast path; the sweep is the safety net.`,
38
+ `- Session isolation: on the FIRST board write of this conversation create a session`,
39
+ ` folder \`<root>/<session-key>/\` where <session-key> is a compact clock timestamp`,
40
+ ` (PowerShell: \`Get-Date -Format yyyyMMdd-HHmmss\`; POSIX: \`date +%Y%m%d-%H%M%S\`).`,
41
+ ` Reuse that folder for every later task in the same conversation; never write into`,
42
+ ` a session folder created by a different conversation.`,
43
+ `- Create exactly ONE task sub-directory per multi-agent task: \`<root>/<session-key>/<task-slug>/\`.`,
44
+ `- Auto-cleanup: the plugin sweeps task directories idle for more than ${ttlDays} days (at startup and hourly).`,
45
+ ` This is the ONLY cleanup path — never delete task or session directories yourself.`,
36
46
  ].join("\n");
37
47
  }
38
48
  const plugin = {
@@ -67,8 +77,8 @@ const plugin = {
67
77
  continue;
68
78
  cfg.command[name] = def;
69
79
  }
70
- // ---------- make Team the default agent (opt-out: defaultAgent:false)
71
- const promote = options?.defaultAgent !== false;
80
+ // ---------- make Team the default agent (opt-in: defaultAgent:true)
81
+ const promote = options?.defaultAgent === true;
72
82
  if (promote && (!cfg.default_agent || cfg.default_agent === "build")) {
73
83
  cfg.default_agent = "team";
74
84
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AAExB,iEAAiE;AACjE,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe;IACnD,OAAO;QACL,EAAE;QACF,EAAE;QACF,kDAAkD;QAClD,qBAAqB,IAAI,IAAI;QAC7B,wFAAwF;QACxF,yEAAyE,OAAO,QAAQ;QACxF,+EAA+E;KAChF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED,MAAM,MAAM,GAAmB;IAC7B,EAAE,EAAE,WAAW;IAEf,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC/B,wEAAwE;QACxE,MAAM,SAAS,GACb,OAAO,KAAK,EAAE,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;YAChE,CAAC,CAAC,KAAK,CAAC,SAAS;YACjB,CAAC,CAAC,OAAO,CAA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,OAAO,GAAG,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;gBAC9C,IAAI,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,aAAa,KAAK,OAAO,CAAC,EAAE,CAAC;oBACrE,GAAG,CAAC,aAAa,GAAG,MAAM,CAAA;gBAC5B,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@te-river/opencode-team-mode",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Team collaboration mode plugin for OpenCode Desktop — injects specialized agents (architect, reviewer, implementer, tester, researcher) and team workflow commands into your OpenCode workspace.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",