Skip to content

v0.8.10:插件市场假插件清理(manifest 自愈只收编真插件)/ Clean Fake Plugin Entries in the Marketplace (Profile Manifest Self-Heal)

Choose a tag to compare

@btsd321 btsd321 released this 28 Oct 01:55
· 24 commits to master since this release

中文

修复

  • 插件市场「已安装插件」里混入大量非插件(如 @standard-schema/spec、@codemirror/*):profile 的 nodeLinker: hoisted 把所有传递依赖摊到顶层 node_modules,而旧的 manifest 自愈把「有 package.json 且 manifest 未声明」的包一律按 "*" 收编成直接依赖;插件市场的已安装列表直接读 package.json.dependencies,于是这些包被当成插件显示。现在插件判定改为解析包自己的 dsh 元数据(用 node 读 JSON,grep 会漏掉跨行字段),非插件直接依赖一律清理——包括后来被 dshmarket update 改写成具体版本的残留(@lydell/node-pty: 1.2.0-beta.15、undici: ^8.11.2 这类)。
  • 真插件不再被写成 *:历史上被收编成 * 的真插件改钉 ^<已装版本>;node_modules 里存在但 manifest 未声明的真插件也按已装版本收编,避免版本随 pnpm update 漂移。
  • manifest 变化后同步收敛 pnpm-lock.yaml(pnpm install --lockfile-only --prefer-offline):manifest 与锁文件的 specifier 对不上时,pnpm 的 --frozen-lockfile 修复路径会直接拒绝(dshmarket #808)。收敛失败会回滚 manifest、下次连接重试,绝不留下不一致状态。
  • 自愈不再可能误删全部依赖:扫描命令非零退出或输出不完整(缺分段标记)时直接放弃本次自愈;manifest 缺失/损坏也不再猜内容。
  • 自愈异常不再阻断会话:整个自愈用 try/catch 兜底,传输/IO 异常降级为 warn。
  • 版本号不是 semver 的真插件保留原 spec(不猜 git/file 规格);* 改钉只接受严格 x.y.z[-pre][+build]。

升级须知

  • 已有 profile 在升级后第一次连接时自动清理,插件市场的已安装列表随之恢复为真正的插件。
  • 清理只改 manifest 与锁文件;被清理的包仍作为真插件的传递依赖留在 node_modules 里,不会卸载任何插件。
  • 若远端离线导致锁文件收敛失败,manifest 会回滚,下次连接再试(插件市场列表在清理成功前保持原样)。
  • 建议升级后强制重启一次远端会话:旧版本进程仍会按旧逻辑重新收编,必须先让新版本接管。

文档

  • lessons 新增 15b:hoisted 布局下 manifest 自愈的边界(只收编真插件)、锁文件收敛与回滚纪律、扫描失败的安全线。
  • 新增 tests/unit/plugin-store.test.ts(12 个用例):扫描结果解析(插件判定、回退链接/handoff 排除)与依赖计划(回收、清理非插件、* 改钉、插件收编、不猜非 semver)。

验证

  • pnpm run typecheck 零错误;scripts/check-plugin.ts 全通过;单元测试 676 个用例 673 通过 / 3 skipped(既有 POSIX-only)/ 0 失败。
  • 真机拷贝冒烟(WSL profile 的真实副本,manifest/lock 为真拷贝、node_modules 只读):注入 372 条 * 收编污染后运行自愈——依赖从 377 清理到 5 个真插件,manifest 与锁文件中的非插件条目归零,5 个插件依赖(dshmarket / dsh-better-sidebar / dsh-oh-my-terminal / skill-explorer / memory-plugin)全部保留;pnpm install --lockfile-only --frozen-lockfile 退出 0(锁文件一致);第二次调用返回未变更(幂等)。
  • build:plugin 重建后 lib/ 可复现(工作区干净),产物内联版本 0.8.10。

English

Fixes

  • The marketplace "installed plugins" list was flooded with non-plugins (@standard-schema/spec, @codemirror/*, ...): the profile uses nodeLinker: hoisted, so every transitive dependency sits at the top level of node_modules; the old manifest self-heal adopted any undeclared package as a direct dependency with spec "*", and the marketplace list reads package.json.dependencies directly. Plugin detection now parses the package's own dsh metadata with node (grep misses fields spread across lines), and every non-plugin direct dependency is removed — including leftovers that dshmarket updates had rewritten into concrete versions (@lydell/node-pty: 1.2.0-beta.15, undici: ^8.11.2, ...).
  • Real plugins are no longer pinned as *: entries historically adopted as * are rewritten to ^<installed version>, and plugins present in node_modules but missing from the manifest are adopted at their installed version, so versions cannot drift on pnpm update.
  • Manifest changes now realign pnpm-lock.yaml (pnpm install --lockfile-only --prefer-offline): when the lockfile specifiers disagree with the manifest, pnpm's --frozen-lockfile repair path refuses to run (dshmarket #808). If realignment fails the manifest is rolled back and retried on the next connection — an inconsistent state is never left behind.
  • Self-heal can no longer wipe all dependencies by accident: a non-zero scan exit or incomplete output (missing section markers) aborts this round; a missing/corrupt manifest is no longer guessed at.
  • Self-heal failures no longer block the session: the whole routine is wrapped in try/catch and degrades to a warning.
  • Plugins whose version is not semver keep their original spec (git/file specs are never invented); * pinning only accepts strict x.y.z[-pre][+build].

Upgrade Notes

  • Existing profiles are cleaned automatically on the first connection after upgrading; the marketplace list then shows only real plugins.
  • Cleanup only touches the manifest and lockfile; removed packages stay in node_modules as transitive dependencies of real plugins, and no plugin is uninstalled.
  • If the remote is offline and lockfile realignment fails, the manifest is rolled back and retried on the next connection (the marketplace list stays as-is until cleanup succeeds).
  • After upgrading, force-restart one remote session: the old process would re-adopt with the old logic, so the new version has to take over first.

Documentation

  • lessons gains 15b: manifest self-heal boundaries under the hoisted layout (adopt real plugins only), lockfile realignment and rollback discipline, and the scan-failure safety line.
  • New tests/unit/plugin-store.test.ts (12 cases): scan parsing (plugin detection, fallback-link/handoff exclusion) and the dependency plan (reclaim, non-plugin cleanup, * pinning, plugin adoption, non-semver versions left alone).

Verification

  • pnpm run typecheck clean; scripts/check-plugin.ts fully passing; 676 unit tests — 673 passed / 3 skipped (pre-existing POSIX-only) / 0 failed.
  • Real-host copy smoke (a true copy of the WSL profile: manifest/lockfile copied, node_modules read-only): after injecting 372 * adoption entries, the self-heal reduced 377 dependencies to 5 real plugins, removed every non-plugin entry from both the manifest and the lockfile, kept all 5 plugin dependencies (dshmarket / dsh-better-sidebar / dsh-oh-my-terminal / skill-explorer / memory-plugin), pnpm install --lockfile-only --frozen-lockfile exited 0 (consistent lockfile), and a second call reported no changes (idempotent).
  • build:plugin reproduces lib/ exactly (clean working tree); the bundle inlines version 0.8.10.

Full Changelog: v0.8.9...v0.8.10