前言¶
在能上网的开发机上,用 DSH 插件管理器装几个扩展并不难;一旦机器处于物理或逻辑隔离的内网,常见做法是手工拷贝目录、自己猜依赖,或指望内网里还能跑 pnpm install。DSH Desktop 的配置档使用扁平化的 node_modules,启动时也不读 pnpm-lock.yaml,单靠拷贝单个插件包往往缺运行时依赖,升级还容易把现有环境搅乱。
下面介绍社区插件 dsh-plugin-porter(维护者 FlameSky-S,分类 admin-security)。它在有网环境导出「选定插件 + 传递依赖闭包 + 文档与校验和」,整包拷到 U 盘或文件交换区后,在内网扫描、比对版本并安装或更新,且可在内网首次通过随包脚本自举安装,无需 npm、pnpm 或外网。
这是什么¶
dsh-plugin-porter 面向「外网导出、内网导入」的 DSH 插件分发:导出侧打包插件、dependencies 与 optionalDependencies 的传递闭包、本地与上游 GitHub README 等文档,以及 SHA-256;导入侧校验完整性、展示 new / same / update / downgrade 状态,按事务方式写入当前 profile 的 node_modules 与 package.json,并更新 dsh.profile.bundles。仓库:https://github.com/FlameSky-S/dsh-plugin-porter;社区目录页:https://www.skillhub.cn/plugins/FlameSky-S/dsh-plugin-porter。许可证 MIT;package.json 中版本为 0.1.1,要求 DSH >= 0.2.0。
核心功能¶
导出(在线机器)¶
- 安装并启用本插件后,打开 Settings → Plugin Porter → Export。
- 勾选要带走的插件;输出目录默认为桌面。
- 点击 Export selected plugins。导出以后台任务运行,避免大闭包因 HTTP 超时失败;完成后面板会给出目标文件夹。
生成目录结构大致如下:
dsh-plugin-porter-export-YYYYMMDD-HHmmss/
├─ manifest.json plugin/dependency/version metadata
├─ checksums.json SHA-256 for every file
├─ packages/ plugins + dependency closure
├─ docs/ local docs + upstream GitHub README
├─ porter/ this plugin, used by the installer
├─ install-porter.ps1 intranet self-install (PowerShell)
├─ install-porter.cmd Windows launcher
├─ install-porter.sh Linux / macOS launcher
├─ porter-cli.cmd / .sh
├─ INSTALL.md operator steps (Chinese)
导出时会递归计算运行时依赖,跳过 peerDependencies / devDependencies,并将 @deepseek-ai/* 视为 DSH 已提供。可选:包含本地文档、拉取上游 GitHub README。若同一包出现多版本,导出会保留全部并在导入侧给出警告。
内网自举安装 Porter 本身¶
将整个导出文件夹复制到内网后,完全退出 DSH(含托盘),再执行随包脚本。Windows 示例:
install-porter.cmd
或:
powershell -NoProfile -ExecutionPolicy Bypass -File .\install-porter.ps1
脚本会定位 profile(默认 %USERPROFILE%\.dsh\profiles\desktop,可用 -ProfileDir),把 porter/ 拷入 node_modules,写入 dependencies 与 dsh.profile.bundles,并备份原有 package.json 与包目录。Linux / macOS:
./install-porter.sh /path/to/profile
重启 DSH 后,在 Settings → Plugin Porter 中应能看到界面。
导入与更新插件¶
- 打开 Settings → Plugin Porter → Import。
- 选择传输过来的导出目录(或粘贴绝对路径)并扫描。
- 核对校验和、版本与各插件状态。
- 安装所选插件;受影响的包与
package.json会先备份,失败则回滚。 - 完全退出并重启 DSH(仅刷新浏览器不够)。
导入逻辑与 DSH 扁平 node_modules 一致:缺失包复制到 <profile>/node_modules/<name>;目标已存在的依赖版本尽量保留;仅替换所选插件本体;把插件加入 package.json 的 dependencies 并追加 bundle 名。不涉及 registry 与 pnpm。
CLI¶
在仓库或已安装的 bin/porter.mjs 上,可用 Node 执行子命令,例如:
node bin/porter.mjs list
node bin/porter.mjs status
node bin/porter.mjs export --plugins dsh-skill-hub,dsh-ssh --out D:\porter-out
node bin/porter.mjs scan --dir E:\dsh-plugin-porter-export-...
node bin/porter.mjs verify --dir E:\...
node bin/porter.mjs install --dir E:\... --plugins dsh-skill-hub
全局选项包括 --profile-dir <path>、--json、--help、--version。
安装与启用(开发机 / 有网环境)¶
本插件目录即完整 bundle,官方 README 给出两种方式:
- 通过 DSH 插件管理器的
install_bundle,目标路径为本仓库目录的绝对路径。 - 使用桌面端「安装本地插件」后重启 DSH,在 Settings → Plugin Porter 确认。
预编译包可从 GitHub Actions 工作流 Build plugin package 下载最新 dsh-plugin-porter-<version> 构件;推送 v* 标签会发布 Release 并附带 .sha256。中文操作说明见仓库内 README.zh-CN.md 与导出包中的 INSTALL.md。
资料中未提供 dsh plugin add github:... 一类命令,请勿凭插件名拼接安装语句。
典型工作流¶
常见拓扑是:在线机导出 → 介质或文件交换 → 隔离内网先 install-porter.* 再 Import。导出机与内网机宜保持相同的 DSH 主版本、操作系统与 CPU 架构;原生模块是按拷贝分发,不会在导入时重编译。
Web 相关路由在 DSH 信任边界(回环、浏览器会话、同源)之上,POST 还需请求头 x-dsh-plugin-porter: 1。仅修改当前 profile,不改动 DSH 安装目录。
适用场景与注意¶
适合谁:需要在隔离内网部署或更新 DSH 插件、又希望依赖闭包与文档一次性可验证的团队;运维与安全分类(admin-security)下做介质摆渡与完整性校验的场景。
务必注意:
- 插件以当前 DSH 进程权限运行,安装前应自行审阅源码与 MIT 许可证。
peerDependencies不会被打进包,需由 DSH 或其他已装插件满足。- 导入后不会更新
pnpm-lock.yaml;日后若在在线环境再次pnpm install,依赖可能被重新解析。 - 同一扁平
node_modules无法并存两版本;冲突时优先保护目标环境已有版本。 - 导出目录内的符号链接在导出时解引用;导入时若链接逃出导出根会被拒绝。
排障要点:看不到 Plugin Porter 时检查 dsh.profile.bundles 是否含 dsh-plugin-porter、node_modules/dsh-plugin-porter/package.json 是否存在,并完全重启;扫描慢因全文件哈希;复制失败常因 DSH 未完全退出导致文件锁定。
结尾¶
dsh-plugin-porter 把「插件 + 依赖闭包 + 文档 + 校验」打成可搬运目录,用 UI 或 CLI 完成外网导出与内网安装,并支持无 npm 的自举脚本,适合 DSH 隔离部署链路。目录与源码:
- https://www.skillhub.cn/plugins/FlameSky-S/dsh-plugin-porter
- https://github.com/FlameSky-S/dsh-plugin-porter
社区插件目录由 SkillHub 等生态站点维护,与 DeepSeek / 幻方无官方从属关系;DSH 本身仍遵循「一切皆插件」的扩展方式,本插件是其中面向离线分发的一环。