Repository navigation
feat: discover all readable text files as skill resources (#54) - #55
Merged
Merged
Conversation
Resource discovery previously used a hardcoded extension allowlist (.md/.json/.yaml/.yml/.csv/.xml/.txt) with no way to extend it, so common text assets a skill ships (.sql, .toml, .jinja, ...) were silently invisible even when SKILL.md referenced them (issue #54). Replace the allowlist with allow-all-text discovery plus guardrails: - Any file that decodes as UTF-8 is a resource, in any subdirectory. Detection decodes a bounded 64KB prefix (files within the window are validated exactly), matching the loader's read_text('utf-8') without reading whole files. - Files discovered as scripts are excluded from resources (a file is never both). - New `exclude_resources` glob-pattern parameter (extends, never replaces, the built-in DEFAULT_RESOURCE_EXCLUDES: __pycache__, *.pyc, *.pyo, .DS_Store, .git) threaded through discover_skills, SkillsDirectory, Skill.from_file, SkillsToolset, and SkillsCapability (+ from_spec). This is a behavior change: skills may now expose more files by default. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Each exception test constructed Mock() inside the pytest.raises block, giving it two invocations that could throw. Assign ctx = Mock() before the block so only the awaited call remains inside, satisfying python:S5778. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
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.



What & why
Closes #54. Resource discovery used a hardcoded extension allowlist (
.md,.json,.yaml,.yml,.csv,.xml,.txt) with no way to extend it, so common text assets a skill ships —.sql,.toml,.jinja,.tmpl— were silently invisible to the model, even whenSKILL.mdreferenced them by name.read_skill_resource(...)would then raiseModelRetry("... not found").Rather than just widening the allowlist, this flips the model: any readable text file in the skill folder is a resource, with guardrails to keep discovery safe and quiet.
What changed
_discover_resourceswas rewritten from per-extensionrglobloops to a singlerglob('*')+ filter._is_text_filedecodes at most a 64 KB prefix (via an incremental UTF-8 decoder), matching the loader'sread_text('utf-8')contract without reading whole files. Files that fit in the window are validated exactly; larger files are prefix-checked (a multibyte char split by the window is not a false reject). Binaries fail on the first invalid byte._discover_scriptsare excluded from resources via ascript_urisset (scripts discovered first, then passed into resource discovery).exclude_resourcesparameter: glob patterns that extend (never replace) the built-inDEFAULT_RESOURCE_EXCLUDES(__pycache__,*.pyc,*.pyo,.DS_Store,.git). A pattern matches the full skill-relative posix path or any single path component. Threaded throughdiscover_skills,SkillsDirectory,Skill.from_file,SkillsToolset, andSkillsCapability(+from_spec, so it works in agent specs).DEFAULT_RESOURCE_EXCLUDESis exported for easy extension.Reviewer notes
.logornotes.org). This is intentional and matches our expectations that files in the skill bundle are readable; noise/binaries are filtered.exclude_resourcesis a deny-list, not an allow-list — its default contains noise patterns, so allow-list semantics wouldn't make sense. User patterns are additive so noise stays excluded even when custom patterns are supplied._is_text_fileto stay in lockstep with the loader'sread_text('utf-8'). If the loader's encoding ever becomes configurable, this must track it.Tests
Added coverage for: arbitrary text extensions discovered by default, binary skip, invalid-UTF-8 rejection (a case the old approach would misclassify), multibyte acceptance, script exclusion, default noise exclusion, and additive
exclude_resources— across discovery, toolset, and capability layers. Full suite: 459 passed; pre-commit (ruff + mypy) clean.🤖 Generated with Claude Code