前言¶
在 DSH(DeepSeek Harness)裏,profile 的插件清單往往靠約定或人工覈對:某幾個包不許裝、不許啓用。漏檢一次,被禁插件仍可能通過 Web 市場、CLI 或手工改 composition 進入運行環境。下面介紹社區 Host 插件 dsh-plugin-allcrash(維護者 YV3507),它在配置名單命中時讓 Host 進程立刻退出並留下崩潰報告,把「口頭禁止」變成機器執行的守衛。設計思路參考 Minecraft Forge 模組 allcrash;在 SkillHub 上歸類爲 admin-security。
這是什麼¶
dsh-plugin-allcrash 是 Cordis bundle 形態的 DSH Host 插件:名單裏的插件一旦被加載、被啓用、已安裝,或正被嘗試安裝,在默認 mode: crash 下會觸發 Host 崩潰並生成報告。實現上零依賴(僅 Node 內建模塊),Windows / macOS / Linux 共用同一份代碼;判定邏輯與崩潰鏈路分離,便於單測與隔離子進程端到端驗證。
運行環境需以 @deepseek-ai/dsh-app-boot 的 boot() 啓動 Host(DSH Desktop 與 dsh CLI 均適用)。崩潰優先走 boot 安裝的 fail-loud;若未安裝,插件內置 3 秒兜底 process.exit(1) 仍會結束進程。
核心功能¶
與 Forge allcrash 的對應¶
| 原型(Forge) | 本插件(DSH) |
|---|---|
config/allcrash-common.toml 的 crash_mod |
${DSH_HOME}/allcrash.json 的 crash_plugin |
| 模組加載時拋異常 | 未捕獲異常 → fail-loud → process.exit(1) |
crash-reports/crash-*.txt |
${DSH_HOME}/crash-reports/allcrash-<本地時間>-<pid>.txt |
| 服務端下發名單、攔截客戶端 | tools/pre-execute 攔截 plugin_manager 的安裝/啓用與守衛自拆 |
檢測通道¶
- L1:
tools/pre-execute,在plugin_manager執行前攔截安裝、啓用被禁插件,或關停/卸載守衛自身;命中時不把控制權交回工具鏈。 - L2:監聽
plugin-manager/changed、install-state、app-boot/config-reload、hmr/reload,profile 變更後立即重掃。 - L3:看門狗(默認 5s)與啓動時 boot 後 0 / 250 / 1000ms 掃描,覆蓋手工改 patch 等未觸發事件的路徑。
- L4:
agentPresets.compositionInventory(),覆蓋掛在 agent preset 裏、不在 loader 樹上的行。 - L5(可選):
plugin-manager/install-log,監聽 pnpm 輸出(需開啓crash_on_install_log)。
判定同時比對包名/路徑、loader 行 id、插件聲明名(fiber.runtime.name),任一命中即算。
響應模式¶
全局或條目級 mode 取更嚴格者:
| 值 | 可攔截動作(安裝/啓用/拆守衛) | 已加載的插件 |
|---|---|---|
crash(默認) |
崩 Host | 崩 Host |
deny |
拒絕工具調用,Host 存活 | 退化爲 warn |
warn |
告警並放行(dry-run) | 告警 + 審計 |
warn 命中時寫 ${DSH_HOME}/.allcrash/would-crash-<時間>-<pid>.txt,不寫進 crash-reports/(該目錄表示「真的崩過」)。
配置與防繞過¶
- 名單與審計日誌作用域爲 DSH_HOME(同機各 profile 默認共用);某 profile 需不同名單時,可在 composition 行寫
config(行配置優先級更高,改後需重啓)。 - 刪配置文件不會關守衛:曾讀到有效名單後文件消失,會沿用上次名單、寫回文件並告警;停用請顯式
"crash_plugin": []。 - 解析失敗時沿用上一次有效配置並告警,不會靜默退回佔位符名單。
安裝與啓用¶
從 GitHub 安裝(live profile 安裝後立即生效,startup profile 需重啓):
plugin_manager action=install_bundle target=github:YV3507/dsh-plugin-allcrash
dsh plugin --profile <profile> add github:YV3507/dsh-plugin-allcrash
從本地目錄安裝(開發/自用):
plugin_manager action=install_bundle target=<本目錄絕對路徑>
dsh plugin --profile <profile> add <本目錄絕對路徑>
安裝後清單中應出現 dsh-plugin-allcrash(enabled)。首次運行會在 ${DSH_HOME}/allcrash.json(默認 ~/.dsh/allcrash.json)生成默認配置;默認名單爲佔位符 ["example-plugin"],此時不會觸發崩潰。
倉庫 package.json 當前版本爲 1.1.0,要求 Node >=20,許可證 MIT。
典型用法¶
1. 編輯禁止名單¶
改動 ${DSH_HOME}/allcrash.json 中的 crash_plugin,下一次掃描(默認 ≤ 5 秒)生效,無需重啓 Host。示例結構:
{
"crash_plugin": [
"example-plugin",
"dshmarket@1.66.0",
"bad-plugin@<2.0.0",
{ "name": "risky-plugin", "version": ">=2.0.0", "mode": "deny", "reason": "2.x 會改數據格式" }
],
"mode": "crash",
"crash_on_install_attempt": true,
"guard_self_removal": true,
"watch_interval_ms": 5000,
"audit_log": true
}
名字可寫包名、loader 行 id 或聲明名;支持 name@version 與 semver 近似約束(= > >= < <= ^ ~ 等,不支持 || 與 - 區間)。版本拿不到時不算命中(fail-open),並在審計裏記 policy-note;裝完後的掃描會拿到確切版本再判。
2. 先用 warn 試名單¶
把全局 mode 設爲 warn,觀察 .allcrash/would-crash-*.txt 與 watch.log 裏的 would-crash,確認命中對象後再改爲 crash 或 deny。
3. 在 composition 裏覆蓋配置¶
需要某 profile 專用名單時(優先級高於全局 json,修改後需重啓):
- insert:
- id: allcrash
name: 'dsh-plugin-allcrash'
config:
crash_plugin: ['dshmarket']
4. 崩潰後排查¶
默認 mode: crash 時,Host(Electron utility process)退出後 Desktop 可能提示 DSH Host exited (1); restart the application to reconnect。報告路徑爲 ${DSH_HOME}/crash-reports/allcrash-<本地時間>-<pid>.txt,內含 Detected、Plugin tree、Environment、Recovery 等段;審計可 grep ${DSH_HOME}/.allcrash/watch.log 中的 CRASH、would-crash、DENY。
適用場景與注意¶
適合誰:需要在團隊或自用機器上把「絕不允許出現的插件」寫成可審計、可攔截策略的管理員;與 DSH「一切皆插件」生態配合,用 Host 側守衛補人工檢查的缺口。
使用前請知悉:
- 插件以當前 DSH Host 進程權限運行,安裝前請閱讀 GitHub 源碼 與 MIT 許可證,自行評估風險。
deny攔不住「已經加載」的被禁插件,此時僅warn或改回crash並卸掉違規插件。crash_on_install_log默認false;不經plugin_manager的安裝通道需按需開啓並瞭解 README「已知行爲」說明。- SkillHub 目錄頁與 GitHub 由社區維護,與 DeepSeek / 幻方無官方從屬關係;星標等元數據以各站點當時展示爲準。
結尾¶
dsh-plugin-allcrash 把禁止插件名單變成 L1–L5 多層檢測與可選 crash/deny/warn 響應,並在默認 crash 模式下用 fail-loud 與崩潰報告固定違規現場。若要查閱簡介與分類,可打開 SkillHub 目錄頁;安裝命令、配置字段與行爲細節以 GitHub README 爲準。