Skip to content

feat(skills): inline references/ at load time for Anthropic Skills compat (#2214)#2230

Merged
esengine merged 1 commit into
esengine:mainfrom
nianyi778:feat/skill-references-loading
May 29, 2026
Merged

feat(skills): inline references/ at load time for Anthropic Skills compat (#2214)#2230
esengine merged 1 commit into
esengine:mainfrom
nianyi778:feat/skill-references-loading

Conversation

@nianyi778

Copy link
Copy Markdown

问题

关闭 #2214。遵循 Anthropic Skills spec 的技能会在 SKILL.md 旁边放一个 references/ 目录存放深度参考资料,通过 [[references/xxx]] 引用。Reasonix 目前只读 SKILL.md,reference 内容对模型不可见,来自 OpenKB 等工具生成的技能会失去核心参考材料。

方案(Option A — 加载时 inline)

parse() 时检测同级 references/ 目录,把找到的 .md 文件按字母序追加到 body:

## Reference: methodology

# Methodology
Be systematic.

## Reference: examples

# Examples
Case 1.

只影响 dir-layout 技能(带 SKILL.md 的目录形式),flat <name>.md 不受影响。

验证

  • 2 个新测试:references/ inline、flat skill 不受影响
  • npm run verify 通过

…lls compat (esengine#2214)

Skills following the Anthropic Skills spec ship a references/ subdirectory
with depth material. Reasonix only loaded SKILL.md, leaving [[references/...]]
wikilinks as dead text and making the depth content invisible to the model.

Append each references/*.md file to the skill body at load time under a
'## Reference: <slug>' header (sorted alphabetically). This follows Option A
from the issue: zero protocol overhead, all depth material available immediately.

Only dir-layout skills (those with a SKILL.md) can have a sibling references/;
flat <name>.md skills are unaffected.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@nianyi778

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — clean and safe. loadBodyWithReferences derives refsDir as a fixed sibling of SKILL.md (join(dirname(skillFilePath), "references")), gated on existsSync, and inlines the .md entries it reads from readdirSync(refsDir). Since the filenames come from the actual directory listing (not from parsing user-controlled [[references/...]] paths out of the body), there's no path-traversal exposure — join(refsDir, entry) can't escape the skill's own references dir. Skills without a references/ dir are untouched. Good Anthropic-Skills-spec compat (#2214). One minor note (non-blocking): there's no size cap on the inlined material, so a very large references/ dir bloats the skill body / prompt — fine for v1 since that's the skill author's call and the spec's intent, but a cap or lazy-load could be a follow-up if it bites. CI green. Merging.

@esengine esengine merged commit 868b61b into esengine:main May 29, 2026
4 checks passed
@icexin

icexin commented May 29, 2026

Copy link
Copy Markdown

我对这里的语义变化有个 concern:这个 PR 现在会在 skill 被解析/读取时,把该 skill 同级 references/*.md 的直接子文件全部 inline 到 skill.body 里。后续一旦这个 skill 通过 run_skill / /skill <name> / desktop skill run 被使用,或者作为 subagent skill 被启动,这些 reference 内容就会随 skill.body 一起进入当前 agent 或子 agent 的上下文。

我看了一下 OpenCode 和 Codex 的实现,它们对这类 skill 目录的处理更偏渐进式:

  • OpenCode 的 skills 是 on-demand:系统 prompt / tool description 里只列出可用 skill,agent 通过 skill tool 加载对应的 SKILL.mdskill tool 返回 SKILL.md 内容、skill base directory,并说明相对路径资源(如 scripts/reference/)在这个 base directory 下;它不会默认读取并 inline 所有 reference 内容。
  • Codex 也只在 skills list 里暴露 skill 名称、描述和 SKILL.md 路径。使用 skill 时先打开 SKILL.md;如果 SKILL.md 指向 references/,Codex 的规则是只加载当前任务需要的具体文件,不要 bulk-load everything。实际 injection 也是读取 SKILL.md 文件本身,不会遍历同级 references/ 目录并拼入正文。

所以我担心这个 PR 虽然解决了 “reference 内容不可见” 的问题,但会把原本的 progressive disclosure 语义变成 eager/bulk loading。对于 references/ 里主要放 API 文档、examples、edge cases、troubleshooting 等细节材料的 skill,一次性进入上下文可能会带来比较明显的 token/context 压力,也会稀释 SKILL.md 入口文件里的核心指令。

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.

3 participants