Skip to content

fix(installer): prevent duplicate installs across skill roots - #36

Open
Wunrry wants to merge 1 commit into
chuspeeism:mainfrom
Wunrry:fix/installer-target-selection
Open

fix(installer): prevent duplicate installs across skill roots#36
Wunrry wants to merge 1 commit into
chuspeeism:mainfrom
Wunrry:fix/installer-target-selection

Conversation

@Wunrry

@Wunrry Wunrry commented Aug 12, 2026

Copy link
Copy Markdown

起因

我通过下面的命令安装 skill:

npx dashi-ppt-skill@latest

安装完成后,我在 CLI 中调用 dashi-ppt,技能列表里出现了两个同名 skill。检查文件目录后发现,安装器分别写入了:

  • ~/.agents/skills/dashi-ppt
  • ~/.codex/skills/dashi-ppt

这两个目录是两份独立副本。当前安装器会收集所有已经存在的候选 skills 目录,再逐个执行安装。用户同时使用通用 skills 目录和 CLI 自带目录时,一次安装就会产生多份副本。

两份副本会分别保存 .npmrcnode_modules 和运行产物。它们后续可能出现配置或依赖差异,CLI 也可能同时发现两个同名 skill。

修改内容

默认安装现在会先查找已有的 dashi-ppt。如果只找到一份,安装器会继续在原目录更新。旧名称 dashiai-ppt 也会进入这套判断,并沿用原来的迁移流程。

全新安装优先写入通用目录 ~/.agents/skills。这个目录不存在时,如果只检测到一个宿主目录,安装器会使用该目录。

检测到多份已有安装时,安装器会列出所有路径并退出。检测到多个宿主目录,但无法判断该用哪一个时,也会停止安装。退出码为 2,已有文件不会被覆盖或删除。

用户仍然可以明确选择安装方式:

# 安装或更新指定目录
npx dashi-ppt-skill@latest --dir ~/.codex/skills

# 安装或更新所有检测到的目录
npx dashi-ppt-skill@latest --all

--all 保留了原来的多宿主安装能力。--dir--all 不能同时使用。

中英文 README 和 npm 包内的安装说明也做了同步。

测试

新增了基于 Node.js node:test 的安装器集成测试。每个用例都会创建独立的临时 HOME 和最小 npm 包,不会读写用户真实的 skills 目录。

测试覆盖全新安装、旧安装更新、旧名称迁移、重复安装检测、宿主目录回退、--dir--all 等路径。

node --test npm-dist/install.test.mjs

测试结果:

tests 10
pass 10
fail 0

安装器、发布脚本和测试文件也通过了 node --checkgit diff --check 没有发现空白错误。

发布同步

npm-dist/publish-npm-skill.mjs 中的注释说明,公开仓库里的安装器是发布流程同步出的审计副本。维护者发布新版本时,还需要把这次安装器改动同步回对应的私有开发仓库,避免后续发布覆盖本次修复。

SanHsien added a commit to SanHsien/dashi-ppt-skill that referenced this pull request Sep 4, 2026
First four-axis review since the fork point. The commit axis is empty (the
fork point is upstream's head); the PR and issue axes were both at zero, so
this covers everything upstream has.

Nothing adopted, no product file touched. The two Windows-relevant pull
requests (chuspeeism#34 path case comparison, chuspeeism#28 native PowerShell render entry) are
recorded with the condition that would make us revisit them, rather than
cherry-picked into a tree this fork does not maintain.

Issue chuspeeism#29 reproduces here: preview-freshness.mjs runs `npm run render:themes`
and project/package.json has no such script, so theme preview breaks once it
goes stale. Tracked as REVIEW.md R-06 and left for upstream to fix.

Watermarks advanced to PR 36 / issue 43.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant