Help us shape the future of Go! Take the 2026 Go Developer Survey

fsskills

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 12 Imported by: 0

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

func FSFromSkill

func FSFromSkill(skill *skills.Skill) (fs.FS, error)

FSFromSkill returns the root filesystem for a file-backed skill.

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

func NewSource(filesystems ...fs.FS) *Source

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.

func (*Source) Skills

func (s *Source) Skills(ctx context.Context) ([]*skills.Skill, error)

Skills discovers and loads valid skills from the configured filesystems. Each skill retains the instruction text read during discovery.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL