前言¶
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