Skip to content

fix(bind): dirHash 递归收集文件,技能目录含子目录不再抛 EISDIR - #64

Merged
stack-wuh merged 5 commits into
mainfrom
fix/20261012-fix-bind-dirhash-subdirs
Oct 12, 2026
Merged

stack-wuh merged 5 commits into
mainfrom
fix/20261012-fix-bind-dirhash-subdirs

Conversation

@stack-wuh

@stack-wuh stack-wuh commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

变更

  • lib/domains/bind.mjs:dirHash 改为递归收集文件,键用相对路径并以正斜杠归一、按字典序拼接后求 sha256;附注释说明旧实现为何假设扁平是错的。
  • test/cli.test.mjs:新增「技能目录含子目录时哈希与绑定仍成立」用例,含三条反证(子目录内容参与指纹、同内容重绑哈希稳定、unbind 递归删除)。

影响

  • 行为/触发面变化:bind execute 不再因技能目录里存在子目录(references/、templates/ 等)而抛 EISDIR 崩;sidecar 的哈希值算得更全(子目录内容进入指纹),因此首次重绑时托管技能目录的哈希会变——这是内容指纹的正常刷新,schema 与形态(64 位十六进制)不变。
  • 明确不受影响的范围:命令目录零变化,无新命令键 → 插件 requiresCommands 与 cliVersion 判定不受影响;cpSync 的递归复制行为本就如此,本次只是让指纹与之同口径;bind plan 的 blocked/entries 判定不变;宿主既有扁平技能目录的哈希不受影响(无子目录时集合等同)。
  • 解除了插件侧一条落位约束:shadow-dev-workflow 的 norms/pr-message.md 里「规范/模板不得放 skills/*/ 子目录」这条是基于本缺陷写的,需等含本修复的版本发布后由插件另立 change 撤除——本 PR 不代劳。
  • 回滚方式:revert 即恢复旧 dirHash,新用例会随之判红(正是它锁住的行为)。

验证

  • 缺陷复刻(改前):把 dirHash 临时换回旧实现跑新用例 → ✖ bind: 技能目录含子目录时哈希与绑定仍成立,报错原文 ✗ EISDIR: EISDIR,bind execute exit 1。用例确实看得见缺陷。
  • 修复后:node --test --test-name-pattern bind test/cli.test.mjs → 3 用例 3 绿 0 红,既有的 bind copies managed skills with a sidecar… 不回归。
  • 反证三条:只改 references/step-01.md 内容重绑 → 哈希必须变;同内容连续重绑两次 → 哈希逐字相同;unbind 后含子目录的技能目录不存在。
  • 未覆盖项(明说):本地只跑了 bind 子集;全量套件与 windows/macos/ubuntu × node 20/22/24 矩阵由本 PR 的 test.yml 判定。

关联

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.

[bug] bind 的 dirHash 遇技能子目录抛 EISDIR,bind execute 整体失败

1 participant