DeepSeek Harness101 插件配置 返回首页 官方教程 ↗

从本地 overlay 到可安装组合包

打包、安装,也能干净卸载。

声明 bundle manifest,把配置层安装进 profile,先检查组合结果,再启动或回滚。

前置条件已安装 dsh CLI,并完成插件配置教程。源码运行时把 dsh 命令改为 pnpm dsh。
hello-plugin/package.json
{
  "name": "dsh-hello-plugin",
  "version": "0.1.0",
  "type": "module",
  "main": "index.js",
  "files": [
    "index.js",
    "cordis.patch.yml"
  ],
  "dsh": {
    "bundle": {
      "patch": "./cordis.patch.yml"
    }
  }
}

两个 manifest,回答两个问题

两者都写在 package.json 的 dsh 键下,但职责不能重叠。

dsh.bundle

这个包贡献什么?

作者编写并分发的 npm 包,携带一个插入或覆盖插件行的 patch 配置层。

dsh.profile

这套环境由什么组成?

位于 $DSH_HOME/profiles 下的可启动组合,记录有序 bundles 和用户 patch。

bundle 是你分发的东西,profile 是用户启动的东西。没有东西同时是两者。

用三个文件组成最小 bundle

package.json 声明配置层,cordis.patch.yml 按包名挂载插件,index.js 提供插件模块。安装后由 Node 从 profile 依赖中解析包名。

hello-plugin/package.json declares dsh.bundlecordis.patch.yml configuration layerindex.js plugin entry
shell
mkdir -p hello-plugin
hello-plugin/index.js
export const name = 'hello-plugin'

export function apply() {
  console.log('[hello-plugin] plugin loaded!')
}
hello-plugin/cordis.patch.yml
- insert:
    - id: hello
      name: dsh-hello-plugin

如果包没有 dsh.bundle 声明,它仍会作为普通依赖安装,但不会激活任何配置层。

先安装,再检查,最后启动

dsh plugin 在 profile 目录中转发 pnpm,并维护 dsh.profile.bundles。profile manifest 不需要手写。

安装 checkoutdsh plugin --profile demo add ./hello-plugin
检查组合结果dsh --profile demo --dump-config
启动 profiledsh --profile demo
移除依赖和层dsh plugin --profile demo remove dsh-hello-plugin
$DSH_HOME/profiles/demo/package.json
{
  "name": "dsh-profile-demo",
  "private": true,
  "dependencies": {
    "dsh-hello-plugin": "link:/path/to/hello-plugin"
  },
  "dsh": {
    "profile": {
      "bundles": [
        "@deepseek-ai/dsh-base",
        "dsh-hello-plugin"
      ]
    }
  }
}

后应用的配置层胜出

组合从空根开始,按固定顺序应用。覆盖某一行时,config 整体替换,不会按键深度合并。

bundles[]

dsh-base 在前,随后按安装顺序应用外部 bundle

profile/cordis.patch.yml

当前 profile 的用户覆盖

$DSH_HOME/cordis.patch.yml

所有 profile 共享的机器本地偏好

--patch

按命令行出现顺序应用的临时 overlay

覆盖规则

按 id 覆盖前一层的行时,必须重述该行需要的所有 config 键。用户仍可在 profile patch 中覆盖你的默认行,而无需修改包。

从 GitHub 安装会执行构建代码

Git 安装拉取源码,不会自动得到 TypeScript 的 lib 产物。作者需要 prepare,用户需要显式 allowBuilds。

作者负责

提供自包含的 prepare 脚本,从源码构建发布入口,不能依赖旁边存在 monorepo checkout。

用户负责

把 pnpm 打印的确切包键加入 profile 的 pnpm-workspace.yaml,然后重新 add。

pnpm-workspace.yaml
allowBuilds:
  dsh-hello-plugin: true
这是一项本机代码执行权限

prepare 在 Agent 沙箱之外运行。只允许源码可信的包,并锁定 commit:github:you/hello-plugin#<sha>。

npm发布预构建 lib,安装无需构建权限
tarballpnpm pack 后安装本地 .tgz

下一步,理解完整插件生命周期