Skip to content

[fix] bind 的 dirHash 遇技能子目录抛 EISDIR,改为递归收集文件 #63

Closed

Description

@stack-wuh

动机

lib/domains/bind.mjs 的 dirHash 用 readdirSync(skill 目录) 后对每个条目直接 readFileSync。技能目录里一旦出现子目录(按需加载用的 references/、templates/ 等),readFileSync 读到目录即抛 EISDIR: illegal operation on a directory, read,bind execute 整体崩——绑定这条分发路径被一个隐式约束(「技能目录必须扁平」)锁死,而该约束既没写在任何契约里,也没有门拦着。

GitHub issue #62 记录了复刻实测。

引用规范

(brief 缺少该节)

决策

  • 修实现而非改约定:cpSync(..., { recursive: true }) 早已递归复制,产物侧 pack.mjs 也递归收录目录——唯独哈希这一处假设扁平,属实现不一致而非设计选择。
  • 键序用相对路径字典序(非 readdirSync 返回序),保证 Windows/POSIX 与不同创建序下 sidecar 哈希一致,与既有「确定性输出」契约同源(见 bind copies managed skills… 用例里对字典序的断言)。
  • 不改 sidecar schema:只是哈希值算得更全,老宿主重绑一次即刷新。

任务

  • task-1 — lib/domains/bind.mjs — dirHash 递归化 + 相对路径字典序归一
  • task-2 — test/cli.test.mjs — 子目录绑定用例 + 「子目录内容变化必须改哈希」的反证 + unbind 递归清除
  • task-3 — 观察点 — 复现旧崩溃的最小复刻、新用例通过、既有 bind/workflow 用例不回归

补充

关联既有 issue #62:本 change 即其修复载体。

完整 brief:shadow-docs/changes/20261012-fix-bind-dirhash-subdirs/brief.md

Activity

  1. stack-wuh commented on Oct 12, 2026

    @stack-wuh
    OwnerAuthor

    修复已随 PR #64 合并进 main(squash 959a023),并由 PR #67/#69 走完九腿矩阵;v1.6.1 发布链产物 uploader=github-actions[bot] 为自动化硬证据。本 issue 是 #64 的载体记录,与缺陷来源 #62 同批关闭。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions