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
羽毛球分组比赛记分
小程序二维码

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

小夜