@justsilver/opencode-team 0.2.2-beta.0 → 0.2.2-beta.2

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/CHANGELOG.md CHANGED
@@ -7,14 +7,23 @@
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.2.2-beta.0] - 2026-11-18
10
+ ## [0.2.2-beta.2] - 2026-11-18
11
+
12
+ ### Fixed
13
+
14
+ - TUI 入口改为发布预编译的 `dist/tui.js`:npm 插件位于 `node_modules`,宿主不会转换该路径下的
15
+ `.tsx`(anomalyco/opencode#39986),此前会出现面板首帧后不再重绘,或直接报找不到
16
+ `@opentui/solid`。
17
+ - `@opentui/*` 与 `solid-js` 恢复为 optional peerDependencies,避免 npm 安装与宿主并存的第二套运行时。
18
+
19
+ ## [0.2.2-beta.1] - 2026-11-18
11
20
 
12
21
  ### Changed
13
22
 
14
23
  - 旧包 `@justsilver/opencode-subagent-model` 已在 npm 标记 deprecated(覆盖全部已发布版本),
15
24
  弃用提示指向 `@justsilver/opencode-team`;旧包保留可安装,不撤包。
16
- - 修复从 npm 安装后面板无响应:`@opentui/core`、`@opentui/solid`、`solid-js` 改为 optional
17
- peerDependencies,npm 不再把宿主运行时副本装进插件目录。
25
+ - 修复从 npm 安装后面板无响应:`@opentui/*` 的 peer 范围从 `>=0.8.4` 收紧到 `>=0.8.4 <0.9.0`,
26
+ 避免 npm 装到与宿主不兼容的 `0.9.x`;这些 peer 继续保持必装,不能标记为 optional。
18
27
 
19
28
  ## [0.2.1] - 2026-11-18
20
29
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- 职责:使用者的项目介绍、特性、安装、快速开始、日常使用、迁移与疑难解答;不写:Agent 规则、权限与策略实现、开发发版流程、设计契约。 -->
1
+ <!-- 职责:使用者的项目介绍、特性、安装、快速开始与日常使用、迁移、常见问题;不写:Agent 规则、权限与策略实现、故障成因、开发与发版流程。 -->
2
2
 
3
3
  # opencode-team
4
4
 
@@ -7,12 +7,11 @@
7
7
 
8
8
  ## 特性
9
9
 
10
- - **零配置团队**:安装即获得 Orchestrator 主代理,以及 QA、Reviewer 两个子代理;复用内置
11
- `general`、`explore`,不需要手写 Agent 文件。
12
- - **按 Agent 覆盖模型**:只对指定 Agent ID 的子代理生效;没配置的 Agent 继续使用 OpenCode 原生选择。
13
- - **可视化管理**:`/team` 面板查看角色、模型来源、权限摘要与完整 System Prompt,并在面板内改模型与变体。
10
+ - **零配置团队**:安装即获得 Orchestrator 主代理与 QA、Reviewer 子代理,复用内置 `general`、`explore`。
11
+ - **按 Agent 覆盖模型**:只影响指定的子代理,其余 Agent 继续使用 OpenCode 原生选择。
12
+ - **可视化管理**:`/team` 面板查看角色、模型来源与完整 System Prompt,并直接改模型与变体。
14
13
  - **随时可逆**:清除团队覆盖后回到 Agent 配置或 OpenCode 原生选择。
15
- - **失败可见**:模型不可用、存储损坏或读取失败都明确报错,不静默回退。
14
+ - **失败可见**:模型不可用或读取失败都明确报错,不静默回退。
16
15
 
17
16
  ## 安装
18
17
 
@@ -20,15 +19,14 @@
20
19
  opencode plugin add @justsilver/opencode-team
21
20
  ```
22
21
 
23
- 预发布版用 `@justsilver/opencode-team@next`。
22
+ 预发布版用 `@justsilver/opencode-team@next`。安装后**完全退出并重新启动** OpenCode。
24
23
 
25
- 安装后**完全退出并重新启动** OpenCode,server 与 TUI 入口都在启动时加载。
26
- 也可以从本地源码目录加载:在 `plugins` 里给插件目录的绝对路径,
27
- 例如 `{ "package": "<仓库>/plugin/opencode-team" }`。两种方式同一个插件 ID,不要同时启用。
24
+ 也可以从本地源码目录加载:在 `plugins` 里写插件目录的绝对路径,例如
25
+ `{ "package": "<仓库>/plugin/opencode-team" }`;两种方式同一个插件 ID,不要同时启用。
28
26
 
29
27
  ## 快速开始
30
28
 
31
- 1. 安装并完全退出、重新启动 OpenCode。
29
+ 1. 安装并完全重启 OpenCode。
32
30
  2. 输入 `/` 选择 `/team`,或在命令面板搜索「Agent 团队与模型」。
33
31
  3. 用方向键选一个子代理(如 QA),按 `Enter` 打开模型配置。
34
32
  4. 选择模型;如果该模型有变体,先按 `Enter` 选思考等级,再按 `Enter` 保存。
@@ -44,63 +42,42 @@ opencode plugin add @justsilver/opencode-team
44
42
  | `General` | 内置子代理 | 通用多步任务,由 Orchestrator 复用 |
45
43
  | `Explore` | 内置子代理 | 代码库探索 |
46
44
 
47
- - Orchestrator 不会自动成为默认主代理;用 OpenCode 的 Agent 切换选择它,或设置
48
- `default_agent: "orchestrator"`。
49
- - QA 与 Reviewer 是叶子子代理:不能向用户提问,也不能再派发下级子代理。
50
- - 其余权限继承 OpenCode 默认值与你在 `opencode.json` 中的配置;要加硬限制请配置对应 Agent 权限。
45
+ Orchestrator 不会自动成为默认主代理;用 OpenCode 的 Agent 切换选择它,或设置
46
+ `default_agent: "orchestrator"`。QA 与 Reviewer 是叶子子代理,不能提问也不能再派发子代理;
47
+ 其余权限继承 OpenCode 默认值与你的配置,需要硬限制时请配置对应 Agent 权限。
51
48
 
52
49
  角色职责与提示词边界见[团队 Agent](docs/team-agents.md)。
53
50
 
54
51
  ## 团队面板
55
52
 
56
- - 左侧列出团队 Agent 与自定义子代理,每行显示状态:原生、继承或自定义;自定义额外显示当前模型。
57
- - 右侧显示角色说明、当前模型、权限摘要与只读 System Prompt;提示词完整展示,不提供编辑。
58
- - 搜索框常驻并默认聚焦,直接输入即过滤;方向键选择,`Enter` 打开模型配置,`Ctrl+R` 清除团队覆盖,
53
+ - 搜索框常驻聚焦,直接输入即过滤;方向键选择,`Enter` 打开模型配置,`Ctrl+R` 清除团队覆盖,
59
54
  `ESC` 返回或关闭。
60
- - 模型配置按 Provider 分组:`←`/`→` 与 `Tab` 切换区域和变体,`Enter` 选择并保存,
61
- `Ctrl+R` 恢复原生;保存结果与错误都显示在当前面板内。
62
- - 窄终端自动切换为列表/详情或模型/Variant 单栏。
63
-
64
- 使用规则:
65
-
66
- - 设置按 Agent ID 精确匹配,在同一 OpenCode 服务端数据库下全局共享,重启后保留。
67
- - 主代理(包括 Orchestrator)的模型始终由 OpenCode 会话选择,面板只读展示。
68
- - 清除团队覆盖后,如果该 Agent 在 `opencode.json` 配了模型,会回到该配置。
69
- - 子代理启动确认末尾会附本次生效的模型标记,便于确认策略是否生效。
70
-
71
- 当前版本不提供 Agent 创建、删除、重命名或 Prompt 编辑。
55
+ - 模型配置按 Provider 分组,`←`/`→` 与 `Tab` 切换区域和变体,`Enter` 保存,`Ctrl+R` 恢复原生。
56
+ - 模型设置全局共享、重启保留;主代理模型只读,由 OpenCode 会话选择。
57
+ - 窄终端自动切换为单栏布局。
72
58
 
73
59
  界面细节与键盘契约见 [TUI Dashboard](docs/team-tui.md)。
74
60
 
75
61
  ## 从旧版插件迁移
76
62
 
77
- 旧包为 `@justsilver/opencode-subagent-model`,使用独立的存储命名空间与全局模型策略。
78
- 新插件无法直接读取旧命名空间,因此需要旧插件仍在加载时完成交接:
79
-
80
- 1. 保留旧包配置,先安装 `@justsilver/opencode-team` 并完全重启 OpenCode。
81
- 2. 打开一次 `/team`。若检测到旧插件,会提示冲突与迁移结果;若提示迁移失败,确认旧插件已加载后重新打开一次。
82
- 3. 旧全局模型会导入到当前 location 中所有非主代理 Agent(含自定义子代理);旧设置为空时只记录迁移结果。
83
- 其他项目独有的自定义 Agent 不在当前列表中,需要在那个项目打开 `/team` 重新选择。
84
- 4. 移除旧包配置,完全重启 OpenCode。
85
- 5. 打开 `/team` 调整个别 Agent 的模型或恢复原生选择。
63
+ 旧包 `@justsilver/opencode-subagent-model` 使用独立存储命名空间,需要旧插件仍在加载时完成交接:
86
64
 
87
- 如果先移除了旧包再启动新插件,旧值仍在旧命名空间中,但官方插件 API 无法跨命名空间读取;
88
- 本插件不会直接访问数据库。此时直接在 `/team` 重新选择即可。
65
+ 1. 保留旧包配置,安装 `@justsilver/opencode-team` 并完全重启。
66
+ 2. 打开一次 `/team`,按提示完成旧全局模型导入;失败时确认旧插件已加载后重试。
67
+ 3. 移除旧包配置,完全重启。
68
+ 4. 打开 `/team` 按需调整模型或恢复原生选择。
89
69
 
90
- 旧 npm 包已在 registry 标记 deprecated:`@justsilver/opencode-subagent-model` 的全部版本安装时
91
- 都会提示迁移到 `@justsilver/opencode-team`。旧包保留可安装、不撤包,已经锁定旧版本的项目仍可重装。
70
+ 旧包全部版本已在 npm 标记 deprecated,安装时会提示迁移;旧包保留可安装、不撤包。
92
71
 
93
- ## 疑难解答
72
+ ## 常见问题
94
73
 
95
74
  | 现象 | 处理 |
96
75
  |---|---|
97
76
  | 找不到 `/team` | 确认插件已加载,且安装后完全重启过 OpenCode |
98
- | 提示旧插件冲突 | 按迁移步骤先打开 `/team` 完成导入,再移除旧包并重启 |
99
- | 提示团队 Agent 注册失败 | 按面板中的具体错误排查;旧宿主可升级 OpenCode。已存在的子代理仍可配置模型 |
77
+ | 提示旧插件冲突 | 先按迁移步骤打开 `/team` 完成导入,再移除旧包并重启 |
78
+ | 提示团队 Agent 注册失败 | 按面板中的具体错误排查;旧宿主可升级 OpenCode |
100
79
  | 提示功能不可用 | 当前宿主缺少工具钩子,或钩子注册失败;不会假装保存成功 |
101
- | 当前模型不可用 | 切到可用模型或恢复原生选择;不会静默换成其他模型 |
102
- | 命令重复或覆盖冲突 | 检查是否同时启用了旧包、本地目录和 npm 两份 |
103
- | 面板能打开但按键、搜索、点击都不生效 | 插件目录被装进了自带的 `solid-js` / `@opentui/*` 副本,与宿主运行时冲突;升级到修复后的版本即可,不要手动补装这些依赖 |
80
+ | 命令或配置重复 | 检查是否同时启用了旧包、本地目录和 npm 两份 |
104
81
 
105
- 开发与发布见 [CONTRIBUTING.md](CONTRIBUTING.md),Agent 协作规范见 [AGENTS.md](AGENTS.md),
106
- 设计契约见[策略](docs/team-policy.md)与[团队 Agent](docs/team-agents.md)。
82
+ 开发与发布见 [CONTRIBUTING.md](CONTRIBUTING.md),设计契约见[策略](docs/team-policy.md)与
83
+ [团队 Agent](docs/team-agents.md)。
@@ -0,0 +1,27 @@
1
+ // 模型 ID 本身可能包含 /,因此只在第一个 / 分隔供应商。
2
+ export function parseModelRef(input) {
3
+ const providerEnd = input.indexOf("/");
4
+ if (providerEnd <= 0) return undefined;
5
+ const variantStart = input.indexOf("#", providerEnd + 1);
6
+ const providerID = input.slice(0, providerEnd);
7
+ const id = input.slice(providerEnd + 1, variantStart === -1 ? undefined : variantStart);
8
+ const variant = variantStart === -1 ? undefined : input.slice(variantStart + 1);
9
+ if (!id || providerID.includes("#") || variant !== undefined && (!variant || variant.includes("#"))) {
10
+ return undefined;
11
+ }
12
+ return {
13
+ providerID,
14
+ id,
15
+ ...(variant === undefined ? {} : {
16
+ variant
17
+ })
18
+ };
19
+ }
20
+ export function formatModelRef(ref) {
21
+ return `${ref.providerID}/${ref.id}${ref.variant === undefined ? "" : `#${ref.variant}`}`;
22
+ }
23
+
24
+ /** 与宿主一致:未声明 type 的模型按 chat 处理。 */
25
+ export function isChatModel(model) {
26
+ return model.type === undefined || model.type === "chat";
27
+ }
package/dist/rpc.js ADDED
@@ -0,0 +1,104 @@
1
+ const emptyInput = {
2
+ type: "object",
3
+ properties: {},
4
+ additionalProperties: false
5
+ };
6
+ const agentModels = {
7
+ type: "object",
8
+ additionalProperties: {
9
+ type: "string"
10
+ }
11
+ };
12
+ const conflict = {
13
+ type: "object",
14
+ properties: {
15
+ pluginID: {
16
+ type: "string"
17
+ },
18
+ source: {
19
+ type: "string"
20
+ }
21
+ },
22
+ required: ["pluginID"],
23
+ additionalProperties: false
24
+ };
25
+ const migration = {
26
+ type: "object",
27
+ properties: {
28
+ from: {
29
+ type: "string"
30
+ },
31
+ status: {
32
+ type: "string"
33
+ },
34
+ agents: {
35
+ type: "array",
36
+ items: {
37
+ type: "string"
38
+ }
39
+ },
40
+ errors: {
41
+ type: "array",
42
+ items: {
43
+ type: "string"
44
+ }
45
+ }
46
+ },
47
+ required: ["from", "status"],
48
+ additionalProperties: false
49
+ };
50
+ const stateOutput = {
51
+ type: "object",
52
+ properties: {
53
+ ok: {
54
+ type: "boolean"
55
+ },
56
+ supported: {
57
+ type: "boolean"
58
+ },
59
+ agentsSupported: {
60
+ type: "boolean"
61
+ },
62
+ agentsError: {
63
+ type: "string"
64
+ },
65
+ models: agentModels,
66
+ errors: {
67
+ type: "array",
68
+ items: {
69
+ type: "string"
70
+ }
71
+ },
72
+ conflict,
73
+ migration
74
+ },
75
+ required: ["ok", "supported"],
76
+ additionalProperties: false
77
+ };
78
+ export const teamRpc = {
79
+ id: "opencode-team",
80
+ methods: {
81
+ getTeamPolicy: {
82
+ input: emptyInput,
83
+ output: stateOutput
84
+ },
85
+ setAgentModel: {
86
+ input: {
87
+ type: "object",
88
+ properties: {
89
+ agentID: {
90
+ type: "string",
91
+ minLength: 1
92
+ },
93
+ model: {
94
+ type: ["string", "null"]
95
+ }
96
+ },
97
+ required: ["agentID", "model"],
98
+ additionalProperties: false
99
+ },
100
+ output: stateOutput
101
+ }
102
+ },
103
+ events: {}
104
+ };
@@ -0,0 +1,2 @@
1
+ /** 团队成员与内置子代理的固定顺序;server 与 TUI 共用。 */
2
+ export const TEAM_SUBAGENT_IDS = ["general", "explore", "qa", "reviewer"];
package/dist/tui.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Plugin } from "@opencode/plugin/tui";
2
+ import { teamRpc } from "./rpc.js";
3
+ import { configureTeam } from "./view/configure.js";
4
+ export default Plugin.define({
5
+ id: teamRpc.id,
6
+ setup(context) {
7
+ context.keymap.layer(() => ({
8
+ mode: "global",
9
+ commands: [{
10
+ id: `${teamRpc.id}.configure`,
11
+ title: "Agent 团队与模型",
12
+ group: "Model",
13
+ slash: {
14
+ name: "team"
15
+ },
16
+ palette: true,
17
+ run: () => configureTeam(context)
18
+ }]
19
+ }));
20
+ }
21
+ });
@@ -0,0 +1,77 @@
1
+ import { createComponent as _$createComponent } from "@opentui/solid";
2
+ import { mergeProps as _$mergeProps } from "@opentui/solid";
3
+ /** @jsxImportSource @opentui/solid */
4
+
5
+ import { TeamDashboard } from "./dashboard.js";
6
+ import { currentLocation, loadTeamDashboard, refreshModels, restoreAgentModel, saveAgentModel } from "./team.js";
7
+
8
+ // A second /team while a model picker is open replaces the first flow; the old continuation
9
+ // must not reopen its dashboard on top of the newer one.
10
+ let latest = 0;
11
+ export async function configureTeam(ctx) {
12
+ const token = ++latest;
13
+ const location = currentLocation(ctx);
14
+ const result = await loadTeamDashboard(ctx, location);
15
+ if (token !== latest) return;
16
+ if (result.kind === "blocked") {
17
+ ctx.ui.toast.show({
18
+ variant: "error",
19
+ message: result.message
20
+ });
21
+ return;
22
+ }
23
+ const data = result.data;
24
+ let overrides = data.overrides;
25
+ let closed = false;
26
+ const open = () => {
27
+ if (token !== latest || closed) return;
28
+ ctx.ui.dialog.show(() => _$createComponent(TeamDashboard, _$mergeProps({
29
+ get agents() {
30
+ return data.agents;
31
+ },
32
+ overrides: overrides,
33
+ get models() {
34
+ return data.models;
35
+ },
36
+ get providers() {
37
+ return data.providers;
38
+ }
39
+ }, () => data.modelError === undefined ? {} : {
40
+ modelError: data.modelError
41
+ }, () => data.warning === undefined ? {} : {
42
+ warning: data.warning
43
+ }, {
44
+ get agentsSupported() {
45
+ return data.agentsSupported;
46
+ }
47
+ }, () => data.agentsError === undefined ? {} : {
48
+ agentsError: data.agentsError
49
+ }, {
50
+ refreshModels: () => refreshModels(ctx, location),
51
+ get theme() {
52
+ return ctx.theme;
53
+ },
54
+ layer: factory => ctx.keymap.layer(factory),
55
+ clearDialog: () => ctx.ui.dialog.clear(),
56
+ saveModel: async (agent, model) => {
57
+ const saved = await saveAgentModel(ctx, location, agent, model);
58
+ if (saved.saved && saved.models !== undefined) overrides = saved.models;
59
+ return saved;
60
+ },
61
+ restoreModel: async agent => {
62
+ const restored = await restoreAgentModel(ctx, location, agent);
63
+ if (restored.saved && restored.models !== undefined) overrides = restored.models;
64
+ return restored;
65
+ },
66
+ close: () => {
67
+ closed = true;
68
+ }
69
+ })), () => {});
70
+ // show() resets the dialog to medium; set the dashboard presentation after it is mounted.
71
+ ctx.ui.dialog.set({
72
+ size: "xlarge",
73
+ centered: true
74
+ });
75
+ };
76
+ open();
77
+ }