入门
从 0 写你的第一个 DeepSeek Harness 插件
一切皆插件。从最小可运行的 dsh.bundle + apply(ctx, config) 骨架开始,装进 web profile 并验证生效。
一句话:一切皆插件
DeepSeek Harness (dsh) 围绕一个核心思想构建:CLI、Web UI、工具、命令、技能、MCP server、LLM 适配器和定时任务,全部都是插件。插件就是一个导出 apply(ctx, config) 的 JS/TS 模块。想通这一点后,dsh 的所有扩展点都是同一个技能,只是注册调用不同。
真正能加载的最小骨架
新手第一个坑:装上了却不生效。只有声明了 dsh.bundle(具体是 dsh.bundle.patch)的包才会成为 active profile layer。这是能工作的最小 package.json:
{
"name": "my-first-plugin",
"version": "0.1.0",
"type": "module",
"main": "index.ts",
"dsh": { "bundle": { "patch": ["index.ts"] } }
}插件本体:
export function apply(ctx, config) {
ctx.log('my-first-plugin activated');
ctx.commands.register('hello', {
description: 'Say hello from your first plugin',
action: () => `Hello from ${config.name ?? 'my-first-plugin'}`,
});
}apply(ctx, config) 就是契约:ctx 是插件注册能力的入口,config 是用户提供的配置。没有其他必需的生命周期钩子。
装进 web profile
dsh 在 $DSH_HOME/profiles/(默认 ~/.dsh)下按 profile 隔离插件 bundle。把本地插件指向 web profile 并重启:
dsh plugin --profile web add ./
npx @deepseek-ai/dsh web打开 http://127.0.0.1:3080,应该能看到激活日志和一个可执行的 /hello 命令。
验证,然后对照 Hub
如果没生效,最常见的元凶就是缺 dsh.bundle 声明。用 dsh plugin --profile web list 确认插件出现在 profile 列表里。
跑通之后,去本站 Top Rated 榜单打开一个你欣赏的插件——它们每一个都是同一个形态:一个导出 apply(ctx, config) 的模块。唯一的区别是它们在 ctx 上注册了什么。