dsh-plugin-reload:按單個條目重啓 Cordis Loader 的 DSH 插件

前言

在 DeepSeek Harness(DSH)中,插件、MCP 連接和工具貢獻通常由 Cordis Loader 管理。改了一個 in-process plugin 的磁盤代碼,或者改了某個 mcp-client 對應的 MCP server 代碼後,常見做法是重啓 host。

dsh-plugin-reload 提供的粒度更細:它給 agent 一個 reload_plugin 工具,可按 entry id、module name 或 MCP config.serverName 重啓單個 Cordis Loader 條目,其他條目繼續運行。

定位

dsh-plugin-reload 是一個 DeepSeek Harness 插件,許可證爲 MIT。

它的目標不是提供設置界面,而是給 agent 一個可調用工具,用來在線重啓指定條目。倉庫地址:

https://github.com/reina4xa/dsh-plugin-reload

核心能力

插件提供 reload_plugin 工具。下面按條目類型說明行爲。

mcp-client 條目

對 mcp-client 條目,重啓會重新拉起 MCP server 子進程,並重新註冊其工具。sibling MCP 連接不受影響。

in-process plugin 條目

對 in-process plugin 條目,插件執行 hard reload:

  • 清除該條目的 ESM/CJS 模塊緩存。
  • 從磁盤重新導入代碼。
  • 把 fiber 切換到新模塊。
  • 如果重新導入或重新應用失敗,回滾到之前的代碼。

模式與預覽

reload_plugin 支持以下參數:

name     必填。entry id(優先)、module name,或 MCP config.serverName
mode     可選。auto、soft、hard
dry_run  可選。true 時只報告匹配結果和將執行的策略,不實際重啓

mode 的語義:

  • auto:in-process plugin 使用 hard reload;mcp-client 重啓 MCP server 子進程並重新註冊工具。
  • soft:只 dispose 並重新應用;不會取到 in-process 代碼變更。
  • hard:清除 ESM/CJS 緩存,並從磁盤重新導入 entry 代碼。

dry_run: true 適合先確認會匹配到哪個條目、會使用哪種策略,再真正執行。

匹配規則

匹配只遍歷非 group entries,優先級如下:

exact entry id > module name > mcp-client serverName

失敗行爲:

  • 零匹配:報錯,並列出可用條目。
  • 多匹配:報錯,列出候選 entry ids,不修改狀態。
  • group entries:不參與匹配。要重啓插件子樹,需要逐個 leaf entry 調用。

成功返回包括 entry id、module、可選 serverName、前後 fiber phases、策略和語義說明。

安裝與掛載

從 v0.1.2 起,包聲明瞭 dsh.bundle。使用 dsh plugin 安裝後會自動掛載:

dsh plugin --profile web add dsh-plugin-reload

後續更新:

dsh plugin --profile web update dsh-plugin-reload

如果使用普通 npm 安裝,或希望顯式維護 patch 行,可以插入 profile patch:~/.dsh/profiles/<name>/cordis.patch.yml,或 --patch overlay:

- insert:
    - id: plugin-reload
      name: 'dsh-plugin-reload'

注意:不要同時保留 bundle mount 和 manual row。重複工具註冊會在加載時失敗。

運行要求

需要 DeepSeek Harness profile 提供 web 或 headless bundle,並且可用:

@deepseek-ai/dsh-tools
@deepseek-ai/cordis-plugin-loader

適用場景與注意

適合:

  • 只想重啓某個 in-process plugin,不影響其他條目。
  • 修改某個 mcp-client 的 MCP server 代碼後,重新註冊該 server 的工具。
  • agent 在 DSH 會話中執行受控的插件級 reload。

注意:

  • 插件以當前 dsh 進程權限運行。安裝前請檢查源碼與 MIT 許可證。
  • 重載期間存在短暫工具中斷。被重載條目的貢獻,例如 MCP 工具,在 disposal 和 re-application 之間不可用,期間調用會失敗。
  • hard reload 只覆蓋插件自身代碼;node_modules 中的依賴不會被重新導入。修改這些依賴仍需要重啓 host。
  • reload 會重新執行插件頂層代碼。插件不應依賴頂層持久狀態跨 reload 存活。
  • 該插件面向 agent,沒有瀏覽器/UI surface;Settings plugin-inventory 標籤頁保持只讀。
  • 不支持 group reload;需要逐個 leaf entry 重啓插件子樹。

開發命令

npm install
npm run build
npm test
npm pack

鏈接

  • GitHub:https://github.com/reina4xa/dsh-plugin-reload
  • 插件目錄頁:https://www.skillhub.cn/plugins/reina4xa/dsh-plugin-reload
羽毛球分组比赛记分
小程序二维码

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

小夜