dsh-plugin-dev
Skill2 starsChanged 4 months agoMITView on GitHub
开发 DeepSeek Harness (DSH) 插件与 agent preset 的完整规范与避坑指南。当需要为 DSH 编写新插件、新增 agent preset、给 DSH 增加工具/命令/子代理/设置项/WebUI 组件,或排查 DSH 插件导致崩溃或加载失败的问题时使用。涵盖 Cordis 插件契约(name/inject/apply)、host 与 agent 双平面、client 打包格式(window.__ModuleLoader__)、settings 白名单、cordis.patch.yml 的 insert 格式、dsh.client.inject、UI 原语、部署流程等易崩溃陷阱。
- Installs packages
6 other projects use a version of this.
Adopted by
Most recently taken up by
- realchendahuang/dsh-skilltheir own version, first seen Oct 5, 2026
- Wenaixi/dsh-plugin-devtheir own version, first seen Oct 2, 2026
- wula1223/dsh-plugin-devtheir own version, first seen Sep 30, 2026
- zimodzh/dsh-plugin-dev-skillstheir own version, first seen Sep 4, 2026
- hackerFish/awesome-dsh-skillstheir own version, first seen Aug 17, 2026
- TrueHOOHA/dsh-plugin-dev-skilltheir own version, first seen Aug 14, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- realchendahuang/dsh-skill★ 22same name
- zimodzh/dsh-plugin-dev-skills★ 13same name
- hackerFish/awesome-dsh-skills★ 4same name
- TrueHOOHA/dsh-plugin-dev-skill★ 2same name
- wula1223/dsh-plugin-dev★ 1same name
- Wenaixi/dsh-plugin-dev★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Files
DSH 插件开发规范
DeepSeek Harness 是插件化的:几乎所有能力都是 npm 包插件,遵循 Cordis 契约。新增功能 = 新增插件包(+ agent preset + 配置),不改 DSH 核心源码。
三个核心事实
- 插件契约:每个插件包导出 { name, inject, apply };inject 声明依赖的 Cordis 服务名,apply(ctx) 里注册能力。伴生 invariant 用 ctx.invariants.register(PACKAGE_NAME, install) 声明包所有权。
- 双平面:
- HOST 平面(三个 bundle 包 dsh-base / dsh-web-app / dsh-headless 各自的 cordis.patch.yml,经 package.json 的 dsh.bundle.patch 声明,再加 profile 的 cordis.patch.yml / $DSH_HOME/cordis.patch.yml / --patch):注册表、沙箱、审批、持久化、模型路由、客户端 shell——跨会话共享。注意:没有名为 base.cordis.yml / web.cordis.yml 的文件,那是 shipped preset 注释里的概念指代。
- AGENT PRESET 平面(agent.cordis.yml):某个会话专属的工具、人设、提示词段、子代理工具——按会话挂载。
- 新增「模式」= 新增 agent preset 目录(
<id>/agent.cordis.yml +<id>/preset.yml),放在 ~/.dsh/.agent-presets/<id>/;preset 列表自动发现它。
崩溃陷阱(违反必崩,逐条遵守)
1. client 插件必须打成 window.ModuleLoader 手接格式
浏览器端插件不是裸 ESM。必须用 rolldown 打成:
window.__ModuleLoader__.load({ id: "pkg", factory: (require) => { /* ... */ return module.exports } })把 react 与所有 @deepseek-ai/* 设为 external(交给 loader 的 require)。直接用 tsdown 打出的 .mjs 会让 web 端崩溃。用 scripts/build-client.mjs(已含正确 external + handoff 包装)。
2. 新 settings namespace 必须加入白名单
DSH rc.6 的 dsh-host-apiproxy 只对 WEB_SETTINGS_NAMESPACES 白名单里的 namespace 开放给客户端;否则客户端 settingsScope.bind({namespace}) 返回 settings-not-exposed(设置页读不到)。把 namespace 名追加进 node_modules/@deepseek-ai/dsh-host-apiproxy/lib/index.js 的 WEB_SETTINGS_NAMESPACES(见 scripts/deploy.ps1 里的 patch 步骤)。
3. cordis.patch.yml 新增插件行用 - insert: 格式
- insert:
- id: omd
name: dsh-omd
- id: omd-client
name: dsh-omd-client不是裸的顶层 - id: ... / name: ... 行。
4. dsh.client.inject 必须列全 apply 用到的服务提供包
客户端 apply(ctx) 里用到的每个服务(如 ctx.settingsScope、ctx.slots、UI 原语)都要把它的提供包写进 dsh.client.inject,否则加载顺序错、服务未就绪即崩。例如用了 settings 就加 @deepseek-ai/dsh-client-ui-settings,用了 UI 就加 @deepseek-ai/dsh-client-ui-primitives。
5. WebUI 用 DSH 原语,不要手搓 div/input
一律从 @deepseek-ai/dsh-client-ui-primitives 引入 Menu / Button / Input / DisclosureRow / Pill 等(走 --dsw-* token,自动匹配主题)。权限选择器(Read Only / Workspace Write / Full access)用的就是 Menu + Button,做同类下拉直接复用这两个。手写 <div><input><fieldset> 会与 DSH UI 格格不入。
6. 类型与值导入必须分开
用 import type { X } 导类型、import { y } 导值。tsdown/rolldown 对「把类型当值导入」报 MISSING_EXPORT。tsconfig 开 verbatimModuleSyntax: true 让 tsc 先抓住。
7. 注册必须唯一(重复即抛错)
同作用域层里 systemPrompt.section 的 name、settings.register 的 namespace、commands.register 的 name 都必须唯一。host 插件与 agent 插件不要注册同名 section。
8. 部署用本地 file: 依赖(junction),重建即生效,无需卸载
npm install <本地路径> 在 profile 里生成 junction(软链)指向源码目录;改代码后只需重新构建(软链自动读到新产物),不需要 uninstall/reinstall。
开发流程(每步都要做)
- 先镜像现有插件:写之前必读 node_modules/@deepseek-ai/<同类插件>/lib/types/*.d.ts(编译后的类型即权威 API)+ 其 agent.cordis.yml / package.json。绝不凭空猜 API。
- 写代码:遵守上面的陷阱规则。
- 类型检查:npx tsc --noEmit -p tsconfig.check.json(strict + verbatimModuleSyntax)。
- 编译:host/agent 包 npx tsdown;client 包 npm run build(= tsdown + node build-client.mjs)。
- 冒烟测试:用 mock ctx 调 apply(mockCtx),断言注册了正确的 settings/section/command/service/slot,且不抛错。
- 部署:见 references/deployment.md。
- 重启 host 端到端验证(重启会中断当前会话,需用户执行)。
参考
- 架构、服务 API、preset 格式、slot 名:references/architecture.md
- 部署步骤、patch/白名单/junction 细节:references/deployment.md
- 高级注意事项(子代理 capability、isolate 规则、inject/ctx.get、session projection、complete 段、--dump-config):references/gotchas.md
- 对照源码的事实纠偏与增量(必读):references/spec-supplement.md —— Cordis 精确 Context API(无 ctx.scope/name/parent/dispose/baseDir,有 isolate/effect/fiber/baseUrl)、inject vs ctx.get、ctx.effect 生命周期、事件 dispatch 模式、单文件工具插件模式(apply(ctx, config) + Config + defineTool)、完整 slot 清单(single/list/keyed/chain + root/session/session-maybe)、host 组合物理结构、settings/schemastery 完整 API、agent presets roster(copy/standingKeyFor)、动态插件(cordis_* 工具集)、Client→Host RPC(harness.handle/host.call)。
- 完整规范(极致详细版,含 omd/vision-read 逐文件解读与端到端验收):工作区根
DSH插件开发规范.md - 可复用脚本:scripts/build-client.mjs(client 手接打包)、scripts/deploy.ps1(构建+装包+patch+白名单+preset)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

