@citisen/dsh-plugin-dev:DSH 插件開發的 compose → boot → 驗證閉環

前言

在 DeepSeek Harness(dsh)裏做插件,單元測試往往覆蓋不到一類失敗:profile 組合錯誤(某一行解析不了、patch 整段替換 config、provider id 衝突),或客戶端 bundle 根本沒掛上。這些問題要到真機啓動、打開界面時纔會暴露,反饋又常常是「應用壞了」,排查會拖很久。

@citisen/dsh-plugin-dev 是一套面向 DSH 插件開發的工作流工具:用一小套可重複的 CLI 把「組合 → 對比 → 啓動 → 目視檢查」固定下來,並附帶 agent skill,在需要判斷「該用哪條命令、爲什麼」時給出指引。倉庫由 caparisen 維護,在 SkillHub 插件目錄 中歸類爲工作流。npm 包名爲 @citisen/dsh-plugin-dev,當前資料中的版本爲 0.1.0,許可證 MIT。

這是什麼

一句話:Development kit for DeepSeek Harness plugins——組合 profile、啓動可丟棄的 shadow 實例、驗證 host 側、抓取 client 側表現,並在 profile 弄壞時回滾。

實現上不重複造輪子:compose 調用真實的 dsh --profile <p> --dump-config 並做 diff;shadow 調用 dsh --profile <copy> --no-open --port 0 讀取啓動器打印的 URL;shot 通過 DevTools 協議驅動瀏覽器。Host 側只註冊一個 skill provider(讀取 skills/dsh-plugin-dev/SKILL.md),設計上不應拖垮 profile 啓動。

核心功能

下面按 README 中的命令表歸納,均爲資料中已寫明的能力。

命令 作用
doctor 檢測啓動器及版本、列出 profiles、檢查所選 profile 能否 compose、查找 Chromium
compose 經真實啓動器組合 profile;--save 記 baseline,--check 在漂移時 exit 1,--json 列出條目與重複 id
shadow 複製 profile(文件複製、node_modules 鏈接),在系統分配端口上啓動,等待 URL、探測後輸出 url/token/log
shot 用 headless Chromium(CDP)渲染 URL:PNG、DOM 統計、控制台錯誤與未捕獲異常;--fail-on-console-error 可將控制台錯誤視爲失敗
snapshot 保存、列出、恢復決定 profile 組合的三份文件;restore 前會先快照當前狀態

通用參數包括 --dsh <path>、--json、--help。

工具包把若干手工坑寫進命令裏,例如:desktop profile 被 CLI 拒絕(僅 Electron 管理)時需在副本上檢查;GUI 無 token 會 401、就緒態是 303 token 交換而非 200;對 SPA 直接用 chrome --headless --screenshot 可能掛死;link: 依賴被包管理器替換時可能刪掉含 .git 的工作樹。

安裝與啓用

推薦以 bundle 安裝,以便 agent 目錄中出現對應 skill:

dsh plugin --profile desktop add @citisen/dsh-plugin-dev

包會註冊 skill provider,dsh-plugin-dev 出現在 agent 目錄;不改動其他 profile 行,禁用 bundle 即可移除。

僅需 CLI、不要 skill 時:

npx @citisen/dsh-plugin-dev doctor

或:

npm i -g @citisen/dsh-plugin-dev

環境要求(來自 README):

  • dsh:桌面應用(內置 CLI 會自動找到)、已發佈且位於 PATH 的 CLI,或 --dsh <path> / $DSH_CLI
  • Node 20+
  • shot 需要 Chromium、Chrome 或 Edge(自動查找,否則 --browser <path> 或 CHROME_PATH)
  • 支持 Windows、macOS、Linux;桌面應用可選,任意可用的 dsh 即可

版本說明:資料記載在 Windows 11 上曾與 dsh 0.2.1-rc.2(Electron 44 / Node 24.21)聯測。若啓動器變更 --dump-config、dsh web: 啓動行或 desktop profile 策略,doctor 傾向於報錯而非靜默給出錯誤結果;可附 doctor --json 輸出到倉庫 issue。

典型用法

README 給出的最短閉環如下。先做環境自檢,再查看啓動器會掛載的組合樹,啓動臨時 shadow,截圖並抓控制台,必要時爲 desktop profile 留快照。

dsh-plugin-dev doctor                              # what this machine can test
dsh-plugin-dev compose --profile desktop --json    # the tree the launcher would mount
dsh-plugin-dev shadow  --from desktop --hold       # boot a throwaway copy, print url + token
dsh-plugin-dev shot    --url "$URL" --out shot.png # render it, capture console errors
dsh-plugin-dev snapshot save --profile desktop     # something to go back to

shadow --hold 會保持進程,便於把打印出的 URL 與 token 傳給 shot。組合與漂移檢查可配合 compose --save 與 compose --check 使用;profile 組合文件損壞時用 snapshot restore(恢復前會自動快照當前狀態)。

適用場景與注意

適合:正在編寫或維護 dsh 插件 / bundle,需要在本機反覆驗證 profile 組合、host 註冊與 Web 客戶端是否正常掛載的開發者。

注意:

  • 插件與 dsh 以你當前用戶權限運行;安裝前請自行查看 GitHub 源碼 與 MIT 許可證。
  • SkillHub 等社區目錄與 DeepSeek / 幻方無官方從屬關係,安裝來源以你信任的 registry 與倉庫爲準。
  • 目錄頁線索爲 caparisen/dsh-plugin-dev,npm 安裝名以 README 爲準:@citisen/dsh-plugin-dev。

結尾

多數插件故障出在組合與客戶端掛載,而不是某段業務代碼。@citisen/dsh-plugin-dev 把 compose、shadow、shot、snapshot 收成固定步驟,並 bundled skill 說明何時用哪一步。進一步瞭解可看 SkillHub 目錄頁 與 GitHub 倉庫。

羽毛球分组比赛记分
小程序二维码

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

小夜