前言¶
DeepSeek Harness(DSH)把運行時能力拆成可安裝的插件 bundle,開發者通常需要同時處理 package.json 清單、cordis.patch.yml 註冊、TypeScript 構建入口,以及 profile 下的加載驗證。從零搭目錄結構和配置,容易在命名不一致或缺少構建產物時踩坑。
下面介紹維護者 bugmaker2 開源的 dsh-plugin-template。它是一個最小可運行的 Hello World 模板,用 TypeScript 和 tsdown 編譯出 Cordis 插件入口,適合作爲 fork 起點,而不是帶業務邏輯的成品插件。
這是什麼¶
dsh-plugin-template 是 DeepSeek Harness 的最小插件 bundle 模板。Harness 加載後會在控制檯輸出 [dsh-plugin-template] hello world。
SkillHub 是社區插件目錄,與 DeepSeek / 幻方無官方從屬關係;該頁標註插件「可安裝」,但未單獨列出與 README 不同的安裝命令,下文步驟以倉庫文檔爲準。
核心功能¶
模板當前只做一件事:演示 DSH 插件從源碼到 profile 加載的完整鏈路。
最小 Cordis 插件入口¶
src/index.ts 導出 name 與 apply,加載時打印日誌:
export const name = 'dsh-plugin-template'
export function apply(): void {
console.log('[dsh-plugin-template] hello world')
}
bundle 與 profile 註冊¶
package.json 通過 dsh.bundle.patch 聲明可安裝的 profile bundle;cordis.patch.yml 把插件行插入 profile:
- insert:
- id: dsh-plugin-template
name: dsh-plugin-template
TypeScript 構建¶
使用 tsdown 將 src/index.ts 編譯爲 lib/index.js。prepare 腳本會在安裝依賴時觸發構建,因此從 Git 直接安裝時也能加載已構建的 JavaScript 入口。
刻意保持精簡¶
模板只包含 Host 側 TypeScript 插件,不包含 React Client bundle、Remote contract 或測試框架。需要 Web UI、遠程調用或複雜測試時再自行擴展。
環境要求¶
package.json 聲明的運行時約束如下:
"engines": {
"node": "^22.19 || >=24",
"dsh": ">=0.1.0-rc.6"
}
開發依賴包括 TypeScript 與 tsdown;包管理示例使用 pnpm。
安裝與啓用¶
推薦從 fork 開始,在本地目錄安裝到指定 profile。先克隆你自己的 fork,進入目錄後安裝依賴並做類型檢查與構建:
git clone https://github.com/YOUR-USER/dsh-plugin-template.git
cd dsh-plugin-template
pnpm install
pnpm run check
將當前目錄作爲 bundle 加入名爲 hello 的 profile,並驗證配置中已出現插件名:
dsh plugin --profile hello add .
dsh --profile hello --dump-config | grep dsh-plugin-template
啓動該 profile,確認 Harness 輸出包含:
[dsh-plugin-template] hello world
從 profile 移除插件:
dsh plugin --profile hello remove dsh-plugin-template
典型用法¶
在模板基礎上開發¶
- Fork 倉庫後按上一節完成首次加載驗證。
- 編輯
src/index.ts實現你的插件邏輯。 - 執行
pnpm run build重新生成lib/。 - 重啓對應 profile,觀察 Harness 輸出或行爲變化。
重命名插件時保持三處一致¶
改包名時,以下字段必須同步,否則註冊與入口會對不上:
package.json→namesrc/index.ts→namecordis.patch.yml→id和name
發佈到社區時的可見性¶
給 fork 的 GitHub 倉庫添加 topic dsh-plugin,便於在 GitHub 主題頁被檢索。topic 是倉庫元數據,不是倉庫內文件:
gh api --method PUT repos/YOUR-USER/dsh-plugin-template/topics \
-H 'Accept: application/vnd.github+json' \
-f 'names[]=dsh-plugin'
倉庫結構¶
package.json # 聲明 dsh.bundle patch 和構建入口
src/index.ts # TypeScript Cordis 插件入口
lib/index.js # 自動生成的 Harness 入口
cordis.patch.yml # 把 package 註冊進 profile
tsconfig.json # TypeScript 類型檢查配置
pnpm-lock.yaml # 依賴鎖定
package.json 是 Harness 唯一需要的 manifest:dsh.bundle.patch 使 package 成爲可安裝的 profile bundle。
適用場景與注意¶
適合誰
- 第一次寫 DSH 插件、需要對照最小可運行示例的開發者。
- 打算 fork 後快速搭好 TypeScript + tsdown 構建鏈路的團隊。
- 只需要 Host 側邏輯、暫不引入 Web UI 或遠程合約的項目。
使用前注意
- 插件以當前
dsh進程的權限運行;安裝或啓用前請閱讀源碼並確認 MIT 許可證與依賴項。 - 模板輸出僅爲
hello world,不包含業務功能;實際能力需在你 fork 後的代碼中實現。 - SkillHub 頁顯示該插件約一週前更新至 v0.1.0;具體行爲以你安裝的 commit 爲準。
結尾¶
dsh-plugin-template 把 DSH 插件開發裏最容易漏掉的清單、patch 註冊、構建產物和 profile 驗證收成一套可復現步驟。需要最小起點時,可從目錄頁查看元信息,再 fork GitHub 倉庫按 README 走通加載流程。
- 目錄頁:https://www.skillhub.cn/plugins/bugmaker2/dsh-plugin-template
- GitHub:https://github.com/bugmaker2/dsh-plugin-template