前言¶
DSH(DeepSeek Harness)的理念是「一切皆插件」。但裝插件這件事本身,現有流程是:把包放進 profile,手動編輯 cordis.patch.yml,重啓服務器,然後對下一個插件重複這套動作。裝兩三個還好,插件一多,改的永遠是同一份 YAML,走的永遠是同一條重啓流程。
下面介紹 dsh-plugin-manager。它把安裝、啓用/禁用、卸載收進 Web GUI、獨立 CLI 和一條聊天命令裏,全程不需要手改配置文件。
這是什麼¶
dsh-plugin-manager 是一個用來管理 dsh 插件的 dsh 插件,由 OSSKn4w7 維護,npm 包名 @osskn4w7/dsh-plugin-manager,當前版本 0.1.2,MIT 許可證,源碼在 GitHub 的 OSSKn4w7/dsh-plugin-manager 倉庫。
它替你寫 profile 的 cordis.patch.yml:改動寫入一個分隔的自動託管塊,你手寫的補丁逐字節保留;運行中服務器的用戶補丁監視器(HMR)會立即應用這些改動,所以多數操作不需要重啓。
整個包由四部分組成:
| 組成 | 作用 |
|---|---|
lib/index.js |
宿主半部:/plugin-manager/api 下的 JSON API + /plugin 聊天命令 |
lib/client.js |
瀏覽器半部:Settings → Plugins 裏的「插件管理」標籤頁 |
lib/core.mjs |
共享邏輯:cordis.patch.yml 的託管塊編輯、pnpm 運行器、bundle 對賬 |
bin/dsh-plugin-manager.mjs |
獨立 CLI(服務器停止時也可用) |
核心功能¶
- 在 Settings → Plugins 內提供「插件管理」Web GUI 標籤頁
- 按 npm 包名安裝插件,可附帶可選的 JSON 配置
- 一鍵啓用/禁用任意 loader 條目,即時生效,無需重啓
- 卸載插件
- 查看組合後的完整 Loader 樹、profile 的依賴與 bundles,以及管理器自身安裝了哪些條目
- 自動維護
cordis.patch.yml中的分隔託管塊,手寫補丁逐字節保留 - 獨立 CLI
dsh-plugin-manager,服務器停止時也能用 - 聊天命令
/plugin(list / enable / disable / install / remove) - 對聲明瞭
dsh.bundle的插件,自動把名字同步進package.json的dsh.profile.bundles,並報告needsRestart - 提供
/plugin-manager/api下的 JSON HTTP API
安裝¶
前置要求:PATH 裏有 pnpm;一個 web profile(或任何帶 web bundle 的 profile);一臺迴環綁定的服務器(默認即是)。
安裝方式有兩種,只能選其一,混用會導致同一條目被插入兩次。
方式 A:標準 dsh bundle 安裝¶
dsh plugin --profile web add @osskn4w7/dsh-plugin-manager
先執行上面的命令,再重啓 dsh web——bundle 補丁層是在啓動時讀取的。
方式 B:免重啓的即時安裝¶
dsh-plugin-manager bootstrap --profile web
bootstrap 會通過 pnpm 把這個包裝進 $DSH_HOME/profiles/web,並把它的 Loader 條目寫進 cordis.patch.yml。profile 補丁文件被即時監視,宿主半部立即激活;之後刷新一次瀏覽器,讓客戶端 bundle 被加載(Settings → Plugins → 插件管理)。
如果想在 profile 之外單獨使用 CLI:
npm i -g @osskn4w7/dsh-plugin-manager
dsh-plugin-manager list --profile web
典型用法¶
三個入口做的是同一件事。
Web GUI:在 Settings → Plugins 的「插件管理」標籤頁裏,按 npm 包名安裝(可填一段可選 JSON 配置)、點按鈕啓用/禁用、卸載,並查看完整 Loader 樹。
CLI:
dsh-plugin-manager list [--json] [--profile web]
dsh-plugin-manager enable <entry-id> # 禁用用 disable
dsh-plugin-manager install <pkg> [--config '{"a":1}']
dsh-plugin-manager remove <pkg>
dsh-plugin-manager bootstrap
聊天命令,在 web 聊天裏直接輸入:
/plugin list
/plugin enable <id>
/plugin disable <id>
/plugin install <pkg>
/plugin remove <pkg>
啓用/禁用背後做的事:在託管塊裏增刪一條按 id 定向的 disabled 補丁,監視器隨即重組樹,即時生效。
普通插件和 bundle 插件的行爲有區別,需要知道:
- 普通插件(manifest 裏沒有
dsh.bundle):install執行pnpm add,並在託管塊裏插入一條即時 Loader 條目,裝完即啓用。 - bundle 插件(聲明瞭
dsh.bundle):install執行pnpm add,並把名字同步進package.json的dsh.profile.bundles(與dsh plugin --profile … add同一條規則)。bundle 補丁層在啓動時讀取,所以這一步會報告needsRestart;重啓後它的條目纔會出現,之後可以正常切換。
託管塊的邊界¶
cordis.patch.yml 裏的託管塊用兩行註釋定界:
# >>> dsh-plugin-manager … >>>
# <<< dsh-plugin-manager <<<
塊內的編輯會被覆蓋,塊外的一切歸用戶所有——手寫補丁逐字節保留,這是它敢替你改文件的前提。
另外兩條細節值得留意:被禁用但 id 已不存在於組合樹中的行,會記錄一條良性的 loader 警告;卸載包時,管理器會移除它對應的補丁。
適用場景與注意¶
適合的人:頻繁安裝、試驗 dsh 插件的開發者;需要在服務器運行中切換插件啓停;不想再手動維護 cordis.patch.yml 的人。
使用前注意:
1、兩種安裝方式選一種,不要混用。
2、HTTP API 僅迴環監聽(與服務器默認綁定一致)且沒有鑑權,不要把 web 服務器暴露給不受信任的網絡。
3、bundle 插件安裝後會報告 needsRestart,重啓一次條目纔出現、纔可切換。
最後一條慣例提醒:插件以當前 dsh 進程的權限運行,安裝任何插件前應先檢查源碼與許可證。本插件是 MIT。
結尾¶
經過上面的步驟,插件管理從「改文件、重啓、再改」變成了「點一下、即時生效」,託管塊機制又把自動化寫入和你手寫的補丁隔開,兩不干擾。倉庫地址:https://github.com/OSSKn4w7/dsh-plugin-manager;收錄頁面見社區插件目錄:https://www.skillhub.cn/plugins/OSSKn4w7/dsh-plugin-manager(該目錄爲獨立社區站點,與 DeepSeek、幻方無官方從屬關係)。