dsh-bundle-dedup-guard:防止 DSH 插件启动时的重复 Loader Entry ID 崩溃

前言

DeepSeek Harness (DSH) 在加载插件时,loader 会先去重并创建条目,随后才实例化插件。如果 dsh.profile.bundles 列表中同时包含一个聚合 bundle(如 @linxin666/dsh-web-ui-all)及其所有子插件,loader 会收到重复的 entry id,导致在创建任何插件条目之前抛出 duplicate loader entry id 错误,使整个 profile 启动失败。

dsh-bundle-dedup-guard 是为此场景设计的 guard 插件,它在每次插件加载时检测重复的 loader entry ids,并审计整个插件环境,防止此类静默崩溃。

核心功能

该插件提供以下能力:

  1. 检测重复的 loader entry ids:识别被多次插入的 id,并追溯来源(哪个 bundle 或 patch 插入的)。
  2. 审计插件环境:检查 vendor tree、plugin junctions 和已知冲突对。
  3. 报告诊断信息:
    • 未解析的 bundles。
    • 无 bundle 的 packages(即配置了 dsh.bundle 但未包含在 bundles 列表中)。
    • 预测性 reconcile 警告。
  4. Site-level health checks:
    • 检测已知冲突对。
    • 检查 vendor tree 完整性。
    • 检查 plugin junction 完整性。

安装

使用 DSH 的 CLI 安装该插件:

dsh plugin --profile web add dsh-bundle-dedup-guard

用法

插件在加载时会自动运行检查。若需手动诊断(特别是启动已崩溃时),可使用以下命令:

# 检查所有 profile + site-level health
node bin/check.mjs

# 检查特定 profile
node bin/check.mjs --profile web

# 检查特定 profile,不写入报告文件(仅输出)
node bin/check.mjs --profile web -- --no-write

# 跳过 site-level health 审计
node bin/check.mjs --no-site

运行成功退出码为 0 表示健康;发现重复项、未解析 bundle 或 site-level 问题时退出码为 1(可用于 CI 流水线)。

注意事项

  • 只读诊断:插件仅进行诊断,不会修改任何文件。
  • 进程内限制:loader 在创建任何插件条目之前会进行去重。如果启动时重复项已经存在,进程内检查无法运行。此时需使用上述 CLI 进行纯磁盘读取的检查。
  • 适用场景:适合用于开发环境和生产环境,作为管理员/安全插件监控插件环境的完整性。

链接

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜