dsh-claude-bridge:在 Claude Code 与 DeepSeek Harness 之间双向桥接

前言

在本地同时跑 DSH(DeepSeek Harness)和 Claude Code 时,常见做法是开两个终端、人工拷贝上下文,或用通知类插件提醒自己「这一轮结束了」。通知插件面向的是人;inbox、A2A 一类插件是把任务送进制 dsh。若你希望两边作为程序互相委派、等多轮结束、再读结果,需要一套本地事件流、阻塞式等待命令,以及把 acpx、mcacp、Claude Code 助手和 skill 装齐的配置流程。dsh-claude-bridge 针对的就是这个缺口:Claude Code 与 dsh 双向打通,并用一条 setup 命令完成安装与修复。

这是什么

dsh-claude-bridge 由 ahmedibrahim085 维护,归类为 DSH 社区目录中的工作流 / 集成类插件(当前 release 为 v0.4.1)。它把「一轮对话结束」写成 JSON Lines 本地事件,提供 dsh-wait-turn 等 CLI 做事件驱动等待(而非轮询),并通过 setup / doctor 配置 acpx、mcacp、Claude Code 双脑 helper,以及 dsh-harness skill,让 Claude Code 侧也知道该用哪条接入面。

核心能力(按方向)

README 用表格归纳了四个方向,下面按同一口径说明。

Claude Code → dsh

  • 通过 acpx(shell)或 mcacp(MCP 工具)从 Claude Code 发起可多轮、可恢复的 dsh 会话,也支持 headless 单次调用。
  • 多个 dsh 会话可同时存在;mcacp 侧共享一个 dsh 进程,dsh-harness skill 在三个及以上会话时会自动选用 mcacp。

dsh → 运行中的 Claude Code

  • dsh 获得 send_to_claude 工具;消息会一次性进入用 claude-dsh 启动的 Claude Code 会话(即便当时空闲),依赖 Claude Code channels(research preview)。

Claude Code → dsh:「这一轮结束」

  • setup 会向 ~/.claude/settings.json 添加 Stop hook,每结束一轮 Claude 写一行 JSON(含最终回复摘要);dsh-wait-turn --claude 阻塞等待该行。

dsh → Claude Code:「结束」与「去干活」

  • dsh 插件每轮结束写一行 JSON;dsh-wait-turn 阻塞等待,Claude Code Monitor 可被唤醒,dsh-turns 读取回答。
  • 两个 Claude Code helper 在 dsh 内可按名调用:subagent_claude_code(走你配置的 dsh provider)、subagent_claude_code_claude(走 Claude Code 登录)。helper 在后台跑,结果以后续 turn 形式回来。

dsh-claude-bridge doctor 会逐项检查链路;dsh-claude-bridge setup 安装或修补缺失项,可重复执行。

与 dsh-notify-tray、dsh-notify-plugin 等对比:后者是通知人;dsh-inbox-mcp、dsh-a2a-server 是把工作送进 dsh。本插件连接的是 dsh 与 Claude Code 两个运行时。

环境与安装

要求 macOS 或 Linux、Node ≥ 24.9、Python 3、zstd,以及 dsh 0.2.x(npm install -g @deepseek-ai/dsh)。Claude Code 可选,但若要用 skill 与 mcacp,需要安装 Claude Code。

下面两步来自 README 原文:先加入插件,再执行 setup。

dsh plugin --profile web add github:ahmedibrahim085/dsh-claude-bridge#v0.4.1
~/.dsh/profiles/web/node_modules/dsh-claude-bridge/bin/dsh-claude-bridge setup

首次 setup 会写入 ~/.config/dsh-claude-bridge/config 后退出。填好 provider 相关信息后再次运行 setup,重启正在运行的 dsh host,然后做 live 自检:

dsh-claude-bridge doctor --live      # 期望每行 [ok];--live 会跑一轮真实 dsh turn

升级时把上述两条命令里的 tag 换成新版本,再 setup;新 setup 会把其他 profile 迁到同一 release 并保留配置。重启 dsh host 后执行 dsh-claude-bridge doctor --live,升级前宜先读仓库 CHANGELOG.md 中标记 BREAKING 的条目。

卸载可先预览再执行:

dsh-claude-bridge uninstall --dry-run    # 只列出将删除的内容
dsh-claude-bridge uninstall              # 实际移除;--purge 会连同配置与 turn 事件文件

uninstall 只移除 setup 创建的内容(各 profile 中的托管块、链接、skill、channel 配置、Stop hook、acpx/mcacp 的 dsh agent 等);你自建的 profile 条目、dsh、pnpm、acpx 会保留。之后仍需重启 dsh host。

配置

配置写在 ~/.config/dsh-claude-bridge/config,示例字段如下(键名与 README 一致):

PROVIDER_ID=zai-glm                                   # any id; dsh shows it in the model list
PROVIDER_API=anthropic-messages
PROVIDER_BASE_URL=https://open.bigmodel.cn/api/anthropic
PROVIDER_KEY_FILE=~/.glm-env                          # an env file holding the key ...
PROVIDER_KEY_VAR=ANTHROPIC_AUTH_TOKEN                 # ... under this name (read at run time, never copied)
MODELS=glm-5.3 glm-5.3-flash                          # first = default
PROFILES=web acp headless
HELPERS=both                                          # provider | claude | both | none
HELPER_PERMISSION_MODE=auto                           # auto | acceptEdits | dontAsk | plan
MCACP=1
PASS_ENV=                                             # extra variables to pass into dsh
BIN_DIR=~/.local/bin

密钥留在 PROVIDER_KEY_FILE 中,运行时以变量名读取,不会写入 bridge 配置副本。dsh 运行时通过 BRIDGE_PROVIDER_KEY 注入。provider helper 需要 Anthropic 兼容端点(PROVIDER_API=anthropic-messages)。

setup 还会:把 dsh-claude-bridge、dsh-wait-turn、dsh-turns 链到 BIN_DIR,skill 链到 ~/.claude/skills/dsh-harness;在各 ~/.dsh/profiles/<p>/cordis.patch.yml 写入标记块;按需安装 pnpm、acpx、mcacp 并注册 dsh agent。

典型用法

经 bridge 启动 dsh

这样 dsh 拿到干净环境与 provider key:

dsh-claude-bridge run --profile web -- --no-open          # web UI
dsh-claude-bridge run --profile headless -- "summarise README.md"

从 Claude Code(或任意 shell)驱动 dsh

acpx dsh sessions new --name build
acpx --approve-all dsh prompt -s build --no-wait "run the tests and fix failures"
dsh-wait-turn --cwd "$PWD" --timeout 3600       # returns when that turn ends; exit 2 = timeout
dsh-turns --since 1h                            # what dsh answered

等待 Claude Code 一轮结束

例如从 dsh 的 shell 或脚本:

dsh-wait-turn --claude --cwd "$PWD" --timeout 3600

Claude 事件写在 ~/.local/state/claude-events/turns.jsonl,含 session_id、cwd、transcript_path 以及最终回复字段 last_assistant_message(前 8000 字符)。若不想安装 Stop hook,可设 CLAUDE_DONE=0。

dsh 主动发消息给 Claude

用 claude-dsh 代替 claude 启动 Claude Code(参数相同)。首次会提示 server:dsh-channel,本地开发场景下选择确认。dsh 可调用 send_to_claude,可选 cwd 限定目录。仅此类会话加载 channel server(约 37 MB),普通 claude 会话不加载。

在 dsh 内调用 helper

例如:use subagent_claude_code_claude to review this diff。

dsh 侧 turn 事件示例路径为 ~/.local/state/dsh-events/turns.jsonl,行格式类似:

{"ts":"2026-11-06T13:16:30.877Z","event":"turn-stopping","session_id":"session-d06e3c3a-…","cwd":"/work/repo","turn":6,"agent_preset":"standard"}

适用场景与注意

适合谁: 需要在 Claude Code 与 dsh 之间做多轮编排、脚本化等待轮次结束、或让两边互相派生子任务的本地开发者;已使用或愿意使用 acpx/mcacp 与 Claude Code channels 的用户。

权限与安全: 插件随当前 dsh 进程权限运行;安装前应自行查看源码与许可证(仓库含 LICENSE)。turn-events 插件仅观察、不写 shell、不走网络,事件文件本地 0600,写入失败不中断 turn。Claude Code helper 在 dsh 沙箱外运行;默认 HELPER_PERMISSION_MODE=auto 可在分类器拦截高风险操作的前提下 unattended 编辑与执行命令,不提供 bypassPermissions。

维护边界: turn 事件依赖 dsh 内部 agent/turn-stopping 事件,非公开 API;仓库 MAINTENANCE.md 列出升级可能破坏的点位与检查方式。helper 工具在 host 启动时注入,具体限制以 README「Limits」节为准。

DSH 生态强调「一切皆插件」;SkillHub 目录页 为社区站点,与 DeepSeek / 幻方无官方从属关系。

结尾

dsh-claude-bridge 把 Claude Code 与 dsh 之间的双向会话、结束事件和 helper 收成一套 setup + doctor 流程,用 JSONL 与 dsh-wait-turn 做程序级同步。要进一步核对命令与字段,以仓库 README 为准。

  • 目录页:https://www.skillhub.cn/plugins/ahmedibrahim085/dsh-claude-bridge
  • GitHub:https://github.com/ahmedibrahim085/dsh-claude-bridge
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye