Documentation
¶
Overview ¶
Package fsskills discovers and loads skills from a filesystem (an fs.FS), materializing skill directories, their resources, and file-backed scripts as skills.Skill values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FilterContext ¶
type FilterContext struct {
// SkillName is the name of the skill as declared in the SKILL.md frontmatter.
SkillName string
// RelativeFilePath is the path to the file relative to the skill directory,
// using forward slashes. For root-level files this is just the filename;
// for nested files it includes the subdirectory (e.g. "scripts/run.py").
RelativeFilePath string
}
FilterContext provides contextual information about a discovered file to the ScriptFilter and ResourceFilter predicates.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source discovers file-based skills from one or more filesystems.
A Source applies the normalized directory and extension configuration from SourceOptions across all provided filesystems and materializes discovered skills as skills.Skill values.
func NewSource ¶
NewSource creates a file-based skill source with default options. It panics if any filesystem is nil.
func NewSourceOptions ¶
func NewSourceOptions(opts SourceOptions, filesystems ...fs.FS) *Source
NewSourceOptions creates a file-based skill source using the provided options. It panics if any filesystem is nil.
type SourceOptions ¶
type SourceOptions struct {
// SearchDepth controls the maximum depth to search for resource and script
// files within each skill directory. A value of 1 searches only the skill
// root; a value of 2 also searches one level of subdirectories. When nil,
// the default depth of 2 is used. Explicit values must be at least 1.
//
// SearchDepth applies only to resource and script discovery within a skill
// directory. It does not affect the discovery of skill directories
// themselves (those containing a SKILL.md), which is bounded independently.
// This mirrors the .NET SDK, where the two concerns are configured
// separately.
SearchDepth *int
// ResourceFilter is an optional predicate applied to each candidate resource
// file after extension filtering. Return true to include the file or false to
// skip it. When nil, all files matching AllowedResourceExtensions are included.
ResourceFilter func(FilterContext) bool
// ScriptFilter is an optional predicate applied to each candidate script file
// after extension filtering. Return true to include the file or false to skip
// it. When nil, all files matching AllowedScriptExtensions are included.
ScriptFilter func(FilterContext) bool
// AllowedResourceExtensions specifies the allowed file extensions for skill
// resources.
//
// When nil, defaults to ".md", ".json", ".yaml", ".yml", ".csv",
// ".xml", and ".txt".
AllowedResourceExtensions []string
// AllowedScriptExtensions specifies the allowed file extensions for skill
// scripts.
//
// When nil, defaults to ".py", ".js", ".sh", ".ps1", ".cs", and
// ".csx".
AllowedScriptExtensions []string
// ScriptRunner executes discovered file-backed scripts. When nil, scripts are
// still discovered but return an error if run.
ScriptRunner skills.ScriptRunner
// Logger is used for discovery diagnostics. When nil, a discard logger is
// used.
Logger *slog.Logger
}
SourceOptions configures file-based skill discovery.
Use this struct to configure discovery without relying on positional constructor parameters. Additional options can be added here without changing the zero-options NewSource convenience API.