dsh-subagent-opencode
OpenCode 子智能体插件,用于 DeepSeek Harness。
把一个任务委派给本机或**远端(SSH)**的 OpenCode;OpenCode 用自己的模型和工具执行,Harness 负责验收。
功能
- 子代理 provider
opencode:可被标准子代理工具调用。 - 委派工具
opencode_delegate_<name>:先询问用户选择模型,然后默认在后台执行并返回 job id;完成后通知,用job_output收集结果。传wait: true可同步等待最终文本。 - 命令
/oc-<name> <task>:直接执行,不经过模型选择。 - 目标管理
opencode_targets:在对话中列出、添加、修改、删除、测试目标。 - 技能
dsh-opencode-subagent:引导模型在合适时委派,模糊请求先询问用户选择目标。
要求
- OpenCode 支持 ACP,即能运行
opencode acp;不限制版本。 - 本机模式:
opencode在PATH中,或填写可执行文件的绝对路径。Windows 桌面版自带的opencode-cli.exe通常不在PATH,需要填绝对路径。 - 远端模式:目标机已配置 SSH 免密登录,且
opencode在远端PATH中。远端需为 Linux 或 macOS。
安装
# GitHub(推荐)
dsh plugin --profile <profile> add github:NewSpringWei/dsh-subagent-opencode
# 预构建 tarball(安装更快,不需要本地构建)
dsh plugin --profile <profile> add https://github.com/NewSpringWei/dsh-subagent-opencode/releases/download/v0.1.0/dsh-subagent-opencode-0.1.0.tgz
# 本地 checkout(开发)
dsh plugin --profile <profile> add file:<path-to-plugin>/code
安装后打开「插件 → OpenCode 子智能体」配置目标,也可以直接在对话里用 opencode_targets 工具管理。
配置示例
- name: dsh-subagent-opencode
config:
providers:
- name: local
mode: local
command: opencode
args: ['acp']
permission: allow
- name: remote
mode: remote
sshHost: user@host
remoteCwd: /home/user/workspace
permission: allow
每个 providers 条目会注册一个子代理 provider、一个委派工具和一个 /oc-<name> 命令。配置保存后立即生效,不需要重启 dsh。
执行方式
委派默认后台执行,不阻塞当前会话:调用后立即返回 job id,任务完成后通过后台任务通知提醒,
用 job_output <job-id> 读取最终结果,job_kill <job-id> 可终止。需要当场拿到答案时传 wait: true。
目标卡片上的「测试」按钮会启动目标并完成 ACP 握手,用来确认连接是否正常。
字段
| 字段 | 默认 | 说明 |
|---|---|---|
name |
必填 | 实例名,用于 provider、工具名和历史记录 |
mode |
local |
local 或 remote |
command |
opencode |
启动 OpenCode 的命令;远端模式下为远端命令 |
args |
['acp'] |
命令参数 |
sshHost |
— | SSH 目标,remote 必填 |
sshArgs |
['-o','BatchMode=yes'] |
SSH 参数 |
remoteOs |
linux |
远端系统;linux/darwin 走 POSIX,windows 未验证 |
localCwd |
临时目录 | 远端模式下 SSH 子进程的本机工作目录 |
remoteCwd |
— | 远端工作目录,传给 OpenCode 的 session/new |
permission |
allow |
自动应答权限请求:allow 或 reject |
model |
— | 可选固定模型;默认由委派工具询问用户 |
env |
{} |
子进程环境变量 |
disposeEofGraceMs |
6000 |
子进程关闭前的宽限时间 |
disposeGraceMs |
3000 |
终止子进程的等待上限 |
模型选择
模型列表来自 OpenCode session/new 的 configOptions[id=model],一次列出全部可用模型:上次使用的模型排第一,其余按使用次数、名称排序;选项附带上下文、输出上限和输入模态。选择记录保存在 Harness 存储中。
兼容性
- DeepSeek Harness 0.2.x(开发验证版本 0.2.1-rc.2)。
- OpenCode 支持
opencode acp即可。 - 远端支持 Linux 和 macOS;Windows 远端暂未验证。
许可证
dsh-subagent-opencode (English)
An OpenCode subagent plugin for DeepSeek Harness.
Delegate a task to a local or remote (SSH) OpenCode instance. OpenCode runs it with its own models and tools; the Harness reviews the result.
Features
- Provider
opencode: callable by standard subagent tools. - Tool
opencode_delegate_<name>: asks the user to pick a model, then runs in the background and returns a job id by default; it notifies you when finished and you read the result withjob_output. Passwait: trueto block until the final text. - Command
/oc-<name> <task>: runs immediately without the model picker. - Tool
opencode_targets: list, add, update, remove, and test targets from a conversation. - Skill
dsh-opencode-subagent: guides the model to delegate when appropriate and to ask which target to use for ambiguous requests.
Requirements
- OpenCode with ACP support (
opencode acp); no version pin. - Local mode:
opencodeonPATH, or an absolute path. The Windows desktop build shipsopencode-cli.exeoutsidePATH, so use its absolute path. - Remote mode: passwordless SSH,
opencodeon the remotePATH, and a Linux or macOS remote.
Install
# GitHub (recommended)
dsh plugin --profile <profile> add github:NewSpringWei/dsh-subagent-opencode
# prebuilt tarball (faster, no local build)
dsh plugin --profile <profile> add https://github.com/NewSpringWei/dsh-subagent-opencode/releases/download/v0.1.0/dsh-subagent-opencode-0.1.0.tgz
# local checkout (development)
dsh plugin --profile <profile> add file:<path-to-plugin>/code
Open Plugins → OpenCode subagent to configure targets, or manage them from a conversation with opencode_targets.
Configuration example
- name: dsh-subagent-opencode
config:
providers:
- name: local
mode: local
command: opencode
args: ['acp']
permission: allow
- name: remote
mode: remote
sshHost: user@host
remoteCwd: /home/user/workspace
permission: allow
Each entry registers a provider, a delegate tool, and an /oc-<name> command. Changes apply immediately; no dsh restart is needed.
Execution model
Delegations run in the background by default and do not block the current session: the tool returns a job id immediately, a background-job notification arrives when the run finishes, and job_output <job-id> reads the final result (job_kill <job-id> stops it). Pass wait: true to block until the final text.
The Test button on a target card starts the target and runs the ACP handshake to verify the connection.
Fields
| Field | Default | Meaning |
|---|---|---|
name |
required | Instance name used by the provider, tool, and history |
mode |
local |
local or remote |
command |
opencode |
Launch command; the remote command in remote mode |
args |
['acp'] |
Command arguments |
sshHost |
— | SSH destination; required for remote |
sshArgs |
['-o','BatchMode=yes'] |
SSH arguments |
remoteOs |
linux |
Remote OS; linux/darwin use POSIX, windows is unverified |
localCwd |
temp dir | Local cwd for the SSH child process in remote mode |
remoteCwd |
— | Remote working directory passed to session/new |
permission |
allow |
Auto-answer permission requests: allow or reject |
model |
— | Optional fixed model; the delegate tool asks the user by default |
env |
{} |
Child process environment |
disposeEofGraceMs |
6000 |
Grace before the child is closed |
disposeGraceMs |
3000 |
Upper bound for terminating the child |
Model selection
The model list comes from session/new (configOptions[id=model]). One screen lists every available model: the previously used model first, then by pick count and name; each option carries its context size, output limit, and input modalities. Choices are stored in Harness storage.
Compatibility
- DeepSeek Harness 0.2.x (developed against 0.2.1-rc.2).
- OpenCode with
opencode acpsupport. - Remote: Linux and macOS; Windows remotes are unverified.
No comments yet. Be the first to write one.