DeepSeek Harness 发布插件

2026-09-08 00:00    #AI   #工具   #DeepSeek  

三种分发方式对比

核心区别在于是否分发预构建产物。

方式用户安装命令安装到的是什么是否需要构建授权
npm 发布dsh plugin add your-package预构建的 lib/ 代码不需要
tarball 交付dsh plugin add ./hello-plugin-0.1.0.tgzpnpm pack 打出的包不需要
Git 安装dsh plugin --profile demo add github:you/hello-plugin源码(不是构建产物)需要(pnpm ≥ 10)

git 安装:构建脚本这道坎

Git 安装拉取的是源码,没有任何环节运行 build 脚本 → TypeScript 包到手时没有 lib/ 输出,加载失败。

作者侧:提供 prepare 脚本,pnpm 在 git 安装后运行它,从源码构建出发布入口。它必须自包含(不能假设仅开发环境才有的上下文,例如旁边有 monorepo checkout)。

1{
2  "name": "dsh-hello-plugin",
3  "scripts": {
4    "prepare": "tsdown -c tsdown.publish.ts"
5  }
6}

用户侧:为构建授权。pnpm ≥ 10 在显式允许前拒绝运行 git 依赖的 prepare 脚本,第一次 add 会失败;dsh 会指出修法——把 pnpm 打印的确切包键复制进该 profile 的 pnpm-workspace.yaml。

1dsh plugin --profile demo add github:you/hello-plugin
1# 文件路径:$DSH_HOME/profiles/demo/pnpm-workspace.yaml
2# 把 pnpm 打印的确切包键复制进来,允许它运行 prepare
3allowBuilds:
4  dsh-hello-plugin: true
1dsh plugin --profile demo add github:you/hello-plugin   # 第二次通过
授权含义

授权允许该包代码在安装时于你的机器上执行,且不在 agent 运行的任何沙箱之内。只对源码可信的包授权,并锁定 commit,让后续推送无法悄悄改变实际运行的内容:

1dsh plugin --profile demo add github:you/hello-plugin#a1b2c3d   # 锁定到具体 commit

npm 与 tarball:免构建授权

1# 作者侧:先构建再发布
2pnpm build
3pnpm publish
4
5# 用户侧:安装的是预构建代码,无需授权
6dsh plugin add your-package
1# 作者侧:打出 tgz
2pnpm pack
3
4# 用户侧:直接安装 tarball 文件
5dsh plugin add ./hello-plugin-0.1.0.tgz

选择建议

自测

  1. git 安装为什么加载失败?→ 没有构建产物(无 lib/),TypeScript 包加载失败;作者需提供自包含的 prepare 脚本
  2. 如何授权构建?→ 把 pnpm 打印的确切包键复制进 profile 的 pnpm-workspace.yaml 的 allowBuilds
  3. 锁定 commit 的作用?→ 防止后续推送悄悄改变实际运行的代码