Skip fenced code blocks in skill file-reference extraction#1658
Open
johnsonr wants to merge 1 commit into
Open
Skip fenced code blocks in skill file-reference extraction#1658johnsonr wants to merge 1 commit into
johnsonr wants to merge 1 commit into
Conversation
InstructionFileReferenceExtractor scans the entire skill body for
markdown links and resource paths, including content inside ``` and
~~~ fenced code blocks. JS/TS/Python examples that interpolate
variables or mention illustrative paths get treated as real local
file references — failing skill load with "references missing files".
Concrete trigger: a JS template literal of the shape
`\`- [${hit.title}](${hit.url})\`` inside a code fence is parsed as a
markdown link with local target `${hit.url}`. Any skill teaching code
runs into this.
Fix: pre-strip fenced code blocks (CommonMark fence rules — ``` or
~~~ with up to 3 leading spaces of indent, matching closing fence,
implicit close at EOF) before running the link and resource-path
regexes. Inline code spans (single backticks) are left untouched —
they're commonly used for real filename references in prose.
Tests cover: link inside fence, resource path inside fence, tilde
fence, fence with language tag, unclosed fence (CommonMark implicit
close), interleaved prose-and-fence, prose immediately after a
closing fence.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
InstructionFileReferenceExtractorscans the entire skill body for markdown links and resource paths, including content inside```/~~~fenced code blocks. Any skill that teaches code can accidentally surface "references" that are just illustrations.`- [${hit.title}](${hit.url})`inside a code fence is parsed as a markdown link with local target${hit.url}, and skill load fails withreferences missing files: ${hit.url}.```or~~~, up to 3 leading spaces of indent, matching closing fence, implicit close at EOF) before running the link and resource-path regexes. Inline code spans (single backticks) are deliberately left in place — they're commonly used for real filename references in prose.Test plan
embabel-agent-skillstest suite green (205 tests).🤖 Generated with Claude Code