Skip to content

skills: switch to directory-based resource scanning - #101

Merged
Quim Muntal (qmuntal) merged 2 commits into
mainfrom
qmuntal/skills-directory-scanning
Apr 14, 2026
Merged

skills: switch to directory-based resource scanning#101
Quim Muntal (qmuntal) merged 2 commits into
mainfrom
qmuntal/skills-directory-scanning

Conversation

@qmuntal

Copy link
Copy Markdown
Member

Port of microsoft/agent-framework#5078 and microsoft/agent-framework#5205.

Summary

Replace markdown-link-based resource extraction with directory-based scanning per the Agent Skills specification.

Changes

Resource discovery (loader.go)

  • Directory-based scanning: Resources are now discovered by scanning configured directories non-recursively, filtered by extension. Replaces the previous approach of extracting resource paths from markdown links in the SKILL.md body.
  • Default directories: references/ and assets/ (per the spec).
  • Default extensions: .md, .json, .yaml, .yml, .csv, .xml, .txt.
  • Root opt-in: Use "." in ResourceDirectories to scan the skill root; SKILL.md is always excluded.
  • Path validation: Uses filepath.IsLocal to reject absolute paths and .. segments. Normalizes with filepath.Clean + filepath.ToSlash.
  • Removed extractResourcePaths, validateResources, resourceLinkRegex.

Config (skills.go)

  • Added Config.ResourceDirectories -- configurable directories (replaces defaults when set).
  • Added Config.AllowedResourceExtensions -- configurable extensions (replaces defaults when set).
  • Updated New() doc to recommend os.Root.FS over os.DirFS for symlink protection.

Example

  • Updated 01_basic_skills to use os.OpenRoot().FS().

Tests

  • 17 new/updated tests covering default directories, custom directories, root opt-in, extension filtering, non-recursive scanning, nested paths, SKILL.md exclusion, config validation, and deduplication.

Port of microsoft/agent-framework#5078 and #5205.

Replace markdown-link-based resource extraction with directory-based
scanning per the Agent Skills specification:

- Scan 'references/' and 'assets/' subdirectories by default (non-recursive)
- Add Config.ResourceDirectories to customize scanned directories
- Add Config.AllowedResourceExtensions to customize file extensions
- Use '.' to opt into skill root scanning; SKILL.md always excluded
- Validate directory names with filepath.IsLocal; skip absolute/'..' paths
- Normalize paths with filepath.Clean + filepath.ToSlash
- Update example to use os.Root.FS for symlink-safe access
- Add comprehensive tests for directory scanning, extension filtering,
  deduplication, nested paths, and config validation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates skill resource discovery to match the Agent Skills spec by scanning configured directories (vs parsing markdown links), with configurable directories/extensions and updated examples/tests.

Changes:

  • Replace markdown-link-based resource extraction with non-recursive directory scanning (references/, assets/ by default), including path normalization/validation.
  • Add configuration for resource directories and allowed resource extensions.
  • Update example to use os.OpenRoot().FS() and expand test coverage for discovery/config behaviors.
Show a summary per file
File Description
memory/skills/loader.go Implements directory-based resource discovery, config normalization/validation, and extension filtering.
memory/skills/skills.go Wires new config fields into loader creation and updates New() guidance for safer FS usage.
memory/skills/skills_test.go Updates existing tests and adds extensive new tests for directory/extension scanning behavior.
examples/skills/01_basic_skills/main.go Switches example from os.DirFS to os.OpenRoot().FS() for symlink-escape hardening.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment thread memory/skills/loader.go
Comment thread memory/skills/loader.go
Comment thread examples/skills/01_basic_skills/main.go
Distinguish fs.ErrNotExist (silently skip) from other ReadDir errors
(log a warning) to avoid masking permission or I/O issues during
resource discovery.
@qmuntal
Quim Muntal (qmuntal) enabled auto-merge (squash) April 14, 2026 09:14
@qmuntal
Quim Muntal (qmuntal) merged commit 61c8deb into main Apr 14, 2026
4 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the qmuntal/skills-directory-scanning branch April 14, 2026 09:27
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