メインコンテンツへスキップ
W

dsh-plugin-export

wwzdgqs/dsh-plugin-export

Adds an export tab and a per-plugin button to the Plugins page that pack any installed profile plugin into a .tgz npm tarball, built in-process with ustar/PAX and gzip, so a plugin set can be installed on another DSH with dsh plugin add; packages that ship with the DSH installation are excluded and archives are capped at 256 MiB.

インストール

dsh plugin --profile web add github:wwzdgqs/dsh-plugin-export

README

dsh-plugin-export

把已安装的 DSH 插件一键打成 .tgz,换台机器继续用。

License: MIT DSH

DSH 的插件页只提供了「安装 / 启用 / 卸载」,没有导出。换电脑、做备份、给同事复刻一套插件环境时,只能手动翻 node_modules 再自己打包。这个插件补上了这一块:

  • 插件页 → 「导出」标签页:列出当前 profile 声明的全部插件、版本和可导出状态,一键导出单个或「全部导出」。
  • 插件详情页 → 「导出 .tgz」按钮:在标题右侧,点了直接下载。
  • 标准 npm tarball:顶层是 package/,产物可以直接 pnpm add <file.tgz>、npm i 或贴进 DSH 的「添加插件」。
  • 进程内打包:自写 ustar + PAX + gzip,不依赖系统 tar,Windows / macOS / Linux 行为一致。
导出标签页详情页按钮
导出标签页详情页按钮

安装

任选一种,装完刷新 DSH 页面即可。

桌面版(Electron 应用)——用图形界面

DSH → 插件 → 添加插件 → 粘贴下列任一地址,回车:

  • 本仓库:git+https://github.com/WWZDGqs/dsh-plugin-export.git
  • Release 里的 .tgz:本地绝对路径,或 https://github.com/.../releases/download/v1.3.3/dsh-plugin-export-1.3.3.tgz

桌面版的 desktop profile 由应用独占管理,命令行 dsh plugin --profile desktop ... 会被拒绝并报 profile "desktop" is managed exclusively by the Electron application;桌面版请走上面的图形界面。

命令行 / 非桌面 profile(headless、自建 profile 等)

dsh plugin --profile <profile> add "git+https://github.com/WWZDGqs/dsh-plugin-export.git"
dsh plugin --profile <profile> add "C:/path/to/dsh-plugin-export-1.3.3.tgz"
dsh plugin --profile <profile> add "https://github.com/WWZDGqs/dsh-plugin-export/releases/download/v1.3.3/dsh-plugin-export-1.3.3.tgz"

<profile> 换成你的 profile 名。安装脚本为空(package.json 没有 scripts),不需要批准构建。 如果 CLI 启动就报 ERR_MODULE_NOT_FOUND: Cannot find package '@deepseek-ai/cordis-plugin-group',那是 @deepseek-ai/dsh 0.2.2-rc.5 的 npm 包漏声明了依赖,补一条 npm i -g @deepseek-ai/cordis-plugin-group@1.1.0 即可。

使用

  1. 刷新 DSH(http://127.0.0.1:xxxxx)。
  2. 左侧「插件」页顶部会多出 导出 标签:勾选要带走的插件,点「导出 .tgz」逐个下,或点「全部导出」按顺序打包。
  3. 或者进任意插件详情,点标题右侧的 导出 .tgz。

下载文件名形如 dsh-better-sidebar-0.33.0.tgz、deepseek-ai-dsh-experimental-plugin-market-bundle-0.2.2-rc.5.tgz(scoped 包把 / 换成 -)。

导入到另一台 DSH

# 桌面版:插件 → 添加插件 → 粘贴 tgz 绝对路径(desktop profile 不接受命令行)
# 命令行 / 非桌面 profile:
dsh plugin --profile <profile> add "D:/plugins/dsh-better-sidebar-0.33.0.tgz"

装完刷新页面,插件会出现在「已安装」里,开关状态保持你在这台机器上的设置(插件自己的持久化配置不打包)。

导入前先确认:

  • 目标机的 DSH 版本满足插件 engines.dsh;
  • 目标机能访问该插件依赖的 npm registry(依赖不打进 tarball,和 npm pack 一致);
  • 插件如果带 Host 端扩展点,安装后需要新开会话才完全生效。

工作原理

Host 半(lib/index.js)注册两条 owner-only 的精确 Fetch 路由,复用 DSH 浏览器 cookie 鉴权,没有自建 token:

路由作用
GET /api/plugin-export/list返回 { profile, generatedAt, bundles: [{ name, version, declaredVersion, exportable, reason? }] },不泄露绝对路径
GET /api/plugin-export/download?bundle=<name>返回 attachment 响应,文件名取自 RFC 6266 content-disposition
  • 只导出 profile 声明过的插件;随 DSH 安装包自带的包(如 @deepseek-ai/dsh-base、dsh-web-app)返回 403 builtin,因为换机器本来就有。
  • 打包时跳过 node_modules/、.git/、*.tgz,单包上限 256 MiB(超限 413)。
  • 路径超过 100 字节时写 PAX path= 扩展头,所以深层目录不会截断。
  • Client 半(lib/client.js)注册 plugins.detail.actions 按钮和 plugins.tab 标签页,样式走 --dsw-alias-* 主题变量,中英文跟随界面语言。

兼容性

项目范围
DSH>=0.2.2-rc.3 <0.3.0(engines.dsh)
平台Windows / macOS / Linux(主机路由 + 浏览器端)
运行时依赖无(不 import @deepseek-ai/*,打包器自带)

开发

dsh-plugin-export/
├─ cordis.patch.yml     # bundle 装载声明
├─ lib/index.js         # Host:profile 解析、路由、tar+gzip 打包
├─ lib/client.js        # Client:导出标签页 + 详情页按钮
├─ locale/{zh,en}.json  # 插件元数据
├─ docs/DETAIL.md       # 插件详情页长文
└─ icon.svg
# 本地打包(得到 package/ 顶层、可被 pnpm add 的 tarball)
npm pack

# 语法自检
node --check lib/index.js
node --check lib/client.js

已知限制

  • 只导插件本体,不含 profile 里的 pnpm-lock.yaml 与插件运行时产生的数据。
  • 私有 registry 上的插件,目标机需要配好同源认证。
  • 从 git 安装的插件,tarball 只保留当前检出的代码,不保留 git 历史。

License

MIT © 2026 WWZDGqs

関連プラグイン