前言¶
DeepSeek Harness (DSH) 默認只使用 DeepSeek 作爲主循環。如果需要在同一工作流中切換到 Claude Code,同時保留 DSH 的界面和日誌能力,就需要額外的方案。dsh-claude-code 插件正是爲此設計,它不自己替換主循環,而是定義一個 claude-code 引擎,配合 dsh-engine-switch 實現無縫切換。主會話選擇 Claude Code 時,工具、沙箱與人設都來自 Claude Code;子代理則繼續使用 DeepSeek。
核心功能¶
-
一鍵接入 Claude Code
插件定義了一個claude-code引擎,配合dsh-engine-switch使用。預設列表中出現「Claude Code」選項後,選中即可切換,選擇其它則使用 DeepSeek。 -
軌跡實時可見
文本、思考、工具調用與結果會實時流進 DSH 會話,每一步都實時顯示在界面中。 -
上下文佔用可見
Claude Code 的 token 用量與模型上下文窗口會寫入 DSH 會話日誌(TokenUsage+request/context),DSH 界面會據此顯示上下文佔用比例。 -
權限橋接
DSH 的沙箱模式與審批策略會映射到 Claude 的權限回調:工作區內寫操作放行,區外操作觸發審批。AskUserQuestion會使用 DSH 的選擇題 UI 作答。 -
工具與沙箱
預設只當路由鍵,不把 DSH 的 persona 或工具透傳過去。工具與沙箱都直接來自 Claude Code。 -
精確續接
通過旁路持久化 Claude 會話 id,續聊時可以接回同一個 Claude 會話,而不是開啓新會話。 -
子代理照舊 DeepSeek
不管主會話選了誰,子代理都繼續使用 DeepSeek。
安裝¶
本插件依賴 dsh-engine-switch,安裝前需先安裝該依賴。
dsh plugin --profile web add github:Yuki-takuya-kun/dsh-engine-switch
dsh plugin --profile web add github:Yuki-takuya-kun/dsh-claude-code
安裝要求:
* PATH 中包含 pnpm。
* 本機安裝了 claude CLI(需已登錄)或設置了 ANTHROPIC_API_KEY 環境變量。
配置與啓用¶
編輯 ~/.dsh/profiles/web/cordis.patch.yml,啓用 dsh-engine-switch 並配置 claude-code 引擎:
- id: dsh-engine-switch
config:
enabled: true
# 可選:claude-code 引擎的選項
engines:
claude-code:
executable: claude
# env: { ANTHROPIC_API_KEY: sk-... } # 未登錄時使用
重啓 web 應用。在預設列表中選擇「Claude Code」即可切換模式,選擇其它選項則繼續使用 DeepSeek。
工作原理¶
本插件在 apply() 中通過 ctx.engineSwitch.register(claudeCodeEngine) 註冊 claude-code 引擎。
每輪運行時,插件會調用 Claude Code 的 SDK,並將 SDK 產生的事件轉換爲 DSH 會話事件(turn / step / assistant / tool 等),實現實時流式輸出。
權限控制通過 canUseTool 回調實現橋接:工作區內寫操作放行,區外操作觸發審批。AskUserQuestion 也會複用 DSH 的選擇題 UI。
注意事項¶
- 本插件不自己替換主循環,只定義引擎。
- 需要配合
dsh-engine-switch使用。 - 第三方組件詳情見
THIRD_PARTY_NOTICES.md。