dsh-opencode-acp 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-opencode-acp contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # dsh-opencode-acp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/dsh-opencode-acp.svg)](https://www.npmjs.com/package/dsh-opencode-acp)
4
+ [![licence: MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](LICENSE)
5
+ [![topic: dsh-plugin](https://img.shields.io/badge/topic-dsh--plugin-8250df.svg)](https://github.com/topics/dsh-plugin)
6
+
7
+ Run [opencode](https://opencode.ai) as an ACP subagent inside DeepSeek Harness (DSH).
8
+
9
+ Your main agent keeps its own model and context; `subagent_opencode` hands a self-contained task to
10
+ opencode in a separate process, opencode does the work with **its own models, tools and free tier**,
11
+ and only the final answer comes back. A settings page lets you switch models, choose the permission
12
+ policy and working directory, and watch every run — including the opencode session id, duration and
13
+ token usage.
14
+
15
+ [中文说明](README.zh.md)
16
+
17
+ ## Why
18
+
19
+ - **Two harnesses, one conversation.** DSH stays the driver. opencode brings its own free models and
20
+ its own tooling; nothing it does lands in your context or your token bill.
21
+ - **You can see what happened.** Because this plugin speaks ACP itself, each run records the remote
22
+ session id, the model, the duration, tool-call count and token usage — so "which opencode session
23
+ was that?" has an answer.
24
+ - **Settings without restarts.** Settings are read at the start of every delegation, so a saved
25
+ change applies to the next run.
26
+
27
+ ## Requirements
28
+
29
+ | | |
30
+ |---|---|
31
+ | DeepSeek Harness | `>=0.2.1-rc.1 <0.3.0` (declared as `engines.dsh`; install refuses other versions) |
32
+ | opencode | v2 with the `acp` subcommand (`opencode --version`, `opencode acp --help`) |
33
+ | opencode auth | already logged in (`opencode auth login`); the child reuses your login and free models |
34
+
35
+ ## Install
36
+
37
+ From the DSH Plugins page, or from a terminal:
38
+
39
+ ```sh
40
+ # from npm (prebuilt, no build step)
41
+ dsh plugin --profile default add dsh-opencode-acp
42
+
43
+ # or from a tarball
44
+ dsh plugin --profile default add ./dsh-opencode-acp-0.1.1.tgz
45
+ ```
46
+
47
+ Then restart or refresh DSH. Two things appear:
48
+
49
+ - a **delegation tool** named `subagent_opencode` for every agent in the profile;
50
+ - **Settings → OpenCode 委派**, the configuration page.
51
+
52
+ ## Use
53
+
54
+ Just ask for it, or call the tool directly:
55
+
56
+ ```
57
+ Delegate to subagent_opencode: in this repo, add a unit test for parseDuration and report what you changed.
58
+ ```
59
+
60
+ The call returns immediately with a child id; the completion notice carries opencode's final answer.
61
+ The child gets only your task text and the working directory — never your conversation.
62
+
63
+ ## Settings
64
+
65
+ | Group | Setting | Meaning |
66
+ |---|---|---|
67
+ | Model | main model | Picker built from the models your opencode has used, plus a free-form id |
68
+ | Model | small model | opencode's model for titles and small jobs (blank = let opencode choose) |
69
+ | Model | health check | Runs `opencode --version` and reports whether the executable resolves |
70
+ | Execution | permission | `allow` auto-answers permission requests, `reject` denies them |
71
+ | Execution | working directory | Follow the calling session, or pin one path |
72
+ | Advanced | command / args | The opencode executable plus the `acp` argument |
73
+ | Advanced | grace | Process teardown window in milliseconds |
74
+ | Advanced | env | Extra environment variables as a JSON object |
75
+
76
+ Settings live in `$DSH_HOME/opencode-acp/settings.json`; runs in `runs.json` beside it (last 100).
77
+
78
+ ## How it works
79
+
80
+ ```
81
+ DSH agent ── subagent_opencode ──► ctx.subagents ──► dsh-opencode-acp (provider "opencode")
82
+ │ spawn: opencode acp
83
+ ▼
84
+ ACP over stdio (NDJSON JSON-RPC)
85
+ initialize → session/new → session/prompt
86
+ │
87
+ ◄── agent_message_chunk, usage_update
88
+ ```
89
+
90
+ - The ACP protocol carries no model parameter, so the model is decided on the opencode side. This
91
+ plugin injects `OPENCODE_CONFIG_CONTENT` into the child; `OPENCODE_CONFIG` (a file path) is
92
+ ignored by `opencode acp` in v2 — verified, not assumed.
93
+ - Runs are one-shot: an external ACP child cannot receive follow-up messages, so it is not
94
+ continuable. For multi-turn delegation use DSH's built-in `subagent` instead.
95
+ - The child process runs with your user account and is **not** confined by the DSH sandbox, exactly
96
+ like DSH's own `@deepseek-ai/dsh-subagent-acp`. Treat delegation as "opencode may do what you
97
+ could do".
98
+
99
+ ## Limits
100
+
101
+ - Only assistant text is returned; opencode's tool traffic, reasoning and plans stay in its own
102
+ session.
103
+ - A fresh process per run: expect a few seconds of startup on every delegation.
104
+ - Windows, macOS and Linux are all supported. The default command is the npm-global opencode on
105
+ Windows (`%APPDATA%\npm\node_modules\@opencode\cli\bin\opencode.exe`) and `opencode` on `PATH`
106
+ elsewhere; override **Advanced → command** if your install differs.
107
+
108
+ ## Uninstall
109
+
110
+ ```sh
111
+ dsh plugin --profile default remove dsh-opencode-acp
112
+ ```
113
+
114
+ Removing the bundle removes the tool and the settings page; `$DSH_HOME/opencode-acp` stays until you
115
+ delete it.
116
+
117
+ ## Development
118
+
119
+ Plain JavaScript, no build step.
120
+
121
+ ```sh
122
+ node --check index.js
123
+ node --check client.js
124
+ npm pack --dry-run
125
+ ```
126
+
127
+ The Host half is `index.js` (ACP client, provider, storage, HTTP routes under `/.dsh-opencode-acp`),
128
+ the browser half is `client.js` (a `settings.section` page registered through the client module
129
+ table). Both are named exports; `cordis.patch.yml` inserts the two rows.
130
+
131
+ ## Licence
132
+
133
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,121 @@
1
+ # dsh-opencode-acp
2
+
3
+ 把 [opencode](https://opencode.ai) 接成 DeepSeek Harness(DSH)的子代理。
4
+
5
+ 主代理继续用自己的模型和上下文;`subagent_opencode` 把一件独立的任务交给另一个进程里的
6
+ opencode,由它用**自己的模型、工具和免费额度**干活,只把最终答案带回来。设置页里可以切换模型、
7
+ 选择权限策略和工作目录,并查看每一次运行——包括 opencode 那边的会话 id、耗时和 token 用量。
8
+
9
+ [English](README.md)
10
+
11
+ ## 为什么值得装
12
+
13
+ - **两个 harness,一次对话。** DSH 负责调度,opencode 出模型和手脚;它干活的中间过程不进你的
14
+ 上下文,也不进你的账单。
15
+ - **看得见发生了什么。** 这个插件自己说 ACP,所以每次运行都会记下远端会话 id、模型、耗时、
16
+ 工具调用次数和 token——"刚才那次是 opencode 里的哪个会话"有答案。
17
+ - **改设置不用重启。** 设置在每次委派开始时读取,保存后下一次委派就生效。
18
+
19
+ ## 前置条件
20
+
21
+ | | |
22
+ |---|---|
23
+ | DeepSeek Harness | `>=0.2.1-rc.1 <0.3.0`(写在 `engines.dsh` 里,不匹配会拒绝安装) |
24
+ | opencode | v2,带 `acp` 子命令(`opencode --version`、`opencode acp --help` 能跑) |
25
+ | opencode 登录 | 已登录(`opencode auth login`);子进程复用它,包括免费模型 |
26
+
27
+ ## 安装
28
+
29
+ 在 DSH 的插件页面安装,或者用命令行:
30
+
31
+ ```sh
32
+ # 从 npm(预构建,无需构建步骤)
33
+ dsh plugin --profile default add dsh-opencode-acp
34
+
35
+ # 或者从 tarball
36
+ dsh plugin --profile default add ./dsh-opencode-acp-0.1.1.tgz
37
+ ```
38
+
39
+ 装完重启或刷新 DSH,会出现两样东西:
40
+
41
+ - 一个叫 `subagent_opencode` 的**委派工具**,该 profile 下所有 agent 都能用;
42
+ - **设置 → OpenCode 委派** 配置页。
43
+
44
+ ## 怎么用
45
+
46
+ 直接说,或者调工具:
47
+
48
+ ```
49
+ 交给 subagent_opencode:在这个仓库里给 parseDuration 补一个单元测试,并说明你改了什么。
50
+ ```
51
+
52
+ 调用立刻返回一个子代理 id,完成通知里带 opencode 的最终答复。子进程只拿到你的任务文本和工作
53
+ 目录,拿不到你的对话历史。
54
+
55
+ ## 设置项
56
+
57
+ | 分组 | 设置 | 含义 |
58
+ |---|---|---|
59
+ | 模型 | 主模型 | 下拉列出你 opencode 用过的模型,也允许手填 id |
60
+ | 模型 | 小模型 | opencode 生成标题/小任务用的模型(留空让它自己挑) |
61
+ | 模型 | 健康检查 | 跑一次 `opencode --version`,确认可执行文件找得到 |
62
+ | 执行 | 权限应答 | `allow` 自动放行权限请求,`reject` 一律拒绝 |
63
+ | 执行 | 工作目录 | 跟随调用方会话,或固定一个路径 |
64
+ | 高级 | 命令 / 参数 | opencode 可执行文件 + `acp` 参数 |
65
+ | 高级 | 收尾宽限 | 子进程退出等待,毫秒 |
66
+ | 高级 | 环境变量 | 额外环境变量(JSON 对象) |
67
+
68
+ 设置存在 `$DSH_HOME/opencode-acp/settings.json`,运行记录在同目录的 `runs.json`(最近 100 条)。
69
+
70
+ ## 原理
71
+
72
+ ```
73
+ DSH agent ── subagent_opencode ──► ctx.subagents ──► dsh-opencode-acp(provider 名 "opencode")
74
+ │ spawn: opencode acp
75
+ ▼
76
+ ACP over stdio(NDJSON JSON-RPC)
77
+ initialize → session/new → session/prompt
78
+ │
79
+ ◄── agent_message_chunk、usage_update
80
+ ```
81
+
82
+ - ACP 协议不带模型参数,所以模型只能在 opencode 侧决定。这个插件向子进程注入
83
+ `OPENCODE_CONFIG_CONTENT`;`OPENCODE_CONFIG`(文件路径)在 v2 的 `acp` 模式下会被忽略——这是
84
+ 实测结论,不是猜的。
85
+ - 一次性执行:外部 ACP 子代理收不到后续消息,所以不可追问。需要多轮请用 DSH 自带的 `subagent`。
86
+ - 子进程用你的用户账号运行,**不受 DSH 沙箱约束**,和 DSH 官方的
87
+ `@deepseek-ai/dsh-subagent-acp` 行为一致。把它当成"opencode 能干你本人能干的事"。
88
+
89
+ ## 已知限制
90
+
91
+ - 只回传 assistant 文本;opencode 的工具调用、思考、计划都留在它自己的会话里。
92
+ - 每次运行新起一个进程,有数秒启动开销。
93
+ - Windows / macOS / Linux 都支持。默认命令在 Windows 上是 npm 全局安装的
94
+ `%APPDATA%\npm\node_modules\@opencode\cli\bin\opencode.exe`,其他平台是 `PATH` 里的
95
+ `opencode`;装法不同就在 **高级 → 启动命令** 改掉。
96
+
97
+ ## 卸载
98
+
99
+ ```sh
100
+ dsh plugin --profile default remove dsh-opencode-acp
101
+ ```
102
+
103
+ 移除后工具和设置页一起消失;`$DSH_HOME/opencode-acp` 里的数据要手动删。
104
+
105
+ ## 开发
106
+
107
+ 纯 JavaScript,没有构建步骤。
108
+
109
+ ```sh
110
+ node --check index.js
111
+ node --check client.js
112
+ npm pack --dry-run
113
+ ```
114
+
115
+ 宿主半是 `index.js`(ACP 客户端、provider、存储、`/.dsh-opencode-acp` 下的 HTTP 路由),
116
+ 浏览器半是 `client.js`(通过客户端模块表注册的 `settings.section` 页面)。两半都是具名导出,
117
+ `cordis.patch.yml` 插入两行。
118
+
119
+ ## 许可
120
+
121
+ MIT