Documentation
¶
Index ¶
- Constants
- Variables
- type FileType
- type Frontmatter
- type Loader
- func (l *Loader) GlobalDir() string
- func (l *Loader) ListSkills(ctx context.Context) (string, error)
- func (l *Loader) LoadAll(ctx context.Context) ([]*Skill, error)
- func (l *Loader) LoadMetadataOnly(ctx context.Context) ([]SkillMetadata, error)
- func (l *Loader) LoadSkill(ctx context.Context, name string) (*Skill, error)
- func (l *Loader) LoadSkillContent(_ context.Context, skill *Skill) (string, error)
- func (l *Loader) ProjectDir() string
- type LoaderOption
- type Parser
- func (p *Parser) ExtractSection(body, heading string) string
- func (p *Parser) ExtractTOC(body string) string
- func (p *Parser) Parse(data []byte) (*Frontmatter, string, error)
- func (p *Parser) ParseFile(path string) (*Frontmatter, string, error)
- func (p *Parser) ParseMetadataOnly(path string) (*Frontmatter, error)
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) FindMatchingSkill(query string) *SkillMetadata
- func (r *Registry) GenerateSkillsInstructions() string
- func (r *Registry) GenerateSystemPromptSection() string
- func (r *Registry) Get(ctx context.Context, name string) (*Skill, error)
- func (r *Registry) GetContent(ctx context.Context, name string) (string, error)
- func (r *Registry) GetMetadata() []SkillMetadata
- func (r *Registry) Initialize(ctx context.Context) error
- func (r *Registry) Names() []string
- func (r *Registry) Reload(ctx context.Context) error
- func (r *Registry) StartWatching(ctx context.Context) error
- func (r *Registry) StopWatching() error
- type RegistryOption
- type Skill
- type SkillError
- type SkillFile
- type SkillMetadata
- type SkillSource
- type Watcher
- type WatcherOption
Constants ¶
const ( // MaxNameLength is the maximum length for skill names. MaxNameLength = 64 // MaxDescriptionLength is the maximum length for descriptions. MaxDescriptionLength = 1024 // SkillFileName is the required filename for skill definitions. SkillFileName = "SKILL.md" )
--- Constants and limits ---
Variables ¶
var ( ErrMissingName = &SkillError{Message: "skill name is required"} ErrNameTooLong = &SkillError{Message: "skill name exceeds maximum length"} ErrMissingDescription = &SkillError{Message: "skill description is required"} ErrDescriptionTooLong = &SkillError{Message: "skill description exceeds maximum length"} ErrSkillNotFound = &SkillError{Message: "skill not found"} ErrInvalidFrontmatter = &SkillError{Message: "invalid YAML frontmatter"} ErrMissingSkillMD = &SkillError{Message: "SKILL.md file not found"} )
Predefined errors
Functions ¶
This section is empty.
Types ¶
type Frontmatter ¶
type Frontmatter struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
// Optional fields
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Author string `json:"author,omitempty" yaml:"author,omitempty"`
License string `json:"license,omitempty" yaml:"license,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty" yaml:"allowed_tools,omitempty"`
// Capabilities lists the capability tags these skills provides (used for scheduler matching)
Capabilities []string `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
}
Frontmatter represents the YAML frontmatter of a SKILL.md file.
func (*Frontmatter) Validate ¶
func (f *Frontmatter) Validate() error
Validate checks if the frontmatter is valid.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles discovering and loading skills from the filesystem.
func NewLoader ¶
func NewLoader(opts ...LoaderOption) *Loader
NewLoader creates a new skills loader with the given options.
func (*Loader) ListSkills ¶
ListSkills returns a formatted list of available skills.
func (*Loader) LoadAll ¶
LoadAll loads all skills from both global and project directories. Project skills take precedence over global skills with the same name.
func (*Loader) LoadMetadataOnly ¶
func (l *Loader) LoadMetadataOnly(ctx context.Context) ([]SkillMetadata, error)
LoadMetadataOnly loads only skill metadata for system prompt injection. This is more efficient as it doesn't load full content.
func (*Loader) LoadSkillContent ¶
LoadSkillContent loads the full content of a skill's SKILL.md. Use this for on-demand loading when the skill is triggered.
func (*Loader) ProjectDir ¶
ProjectDir returns the project-level skills directory path.
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption configures the loader.
func WithGlobalSkillsDir ¶
func WithGlobalSkillsDir(dir string) LoaderOption
WithGlobalSkillsDir sets the global skills directory. Default: paths.ResolveGolemSkillsDir() (~/.echoryn/golem/skills)
func WithProjectSkillsDir ¶
func WithProjectSkillsDir(dir string) LoaderOption
WithProjectSkillsDir sets the project-level skills directory. Default: .echoryn/skills
type Parser ¶
type Parser struct{}
Parser handles parsing of SKILL.md files.
func (*Parser) ExtractSection ¶
ExtractSection extracts a specific markdown section by heading. Heading matching is case-insensitive.
func (*Parser) ExtractTOC ¶
ExtractTOC extracts all markdown headings and returns a formatted table of contents. Each heading is indented based on its level (H1 = no indent, H2 = 2 spaces, etc.).
func (*Parser) Parse ¶
func (p *Parser) Parse(data []byte) (*Frontmatter, string, error)
Parse parses SKILL.md content bytes and extracts frontmatter and body.
func (*Parser) ParseFile ¶
func (p *Parser) ParseFile(path string) (*Frontmatter, string, error)
ParseFile parses a SKILL.md file from the given path. Returns the frontmatter, markdown body, and any error.
func (*Parser) ParseMetadataOnly ¶
func (p *Parser) ParseMetadataOnly(path string) (*Frontmatter, error)
ParseMetadataOnly extracts only the frontmatter without loading the full body. This is more efficient for initial skill discovery.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages loaded skills and provides lookup functionality.
func NewRegistry ¶
func NewRegistry(loader *Loader, opts ...RegistryOption) *Registry
NewRegistry creates a new skills registry.
func (*Registry) FindMatchingSkill ¶
func (r *Registry) FindMatchingSkill(query string) *SkillMetadata
FindMatchingSkill finds a skill that matches the given query using keyword scoring.
func (*Registry) GenerateSkillsInstructions ¶
GenerateSkillsInstructions generates the <skills_instructions> XML section.
func (*Registry) GenerateSystemPromptSection ¶
GenerateSystemPromptSection generates the <available_skills> XML section for system prompts.
func (*Registry) GetContent ¶
GetContent retrieves the full content of a skill.
func (*Registry) GetMetadata ¶
func (r *Registry) GetMetadata() []SkillMetadata
GetMetadata returns all loaded skill metadata.
func (*Registry) Initialize ¶
Initialize loads all skill metadata from configured directories.
func (*Registry) StartWatching ¶
StartWatching begins monitoring skill directories for changes.
func (*Registry) StopWatching ¶
StopWatching stops monitoring skill directories.
type RegistryOption ¶
type RegistryOption func(*Registry)
RegistryOption configures the Registry.
func WithAutoWatch ¶
func WithAutoWatch(enabled bool) RegistryOption
WithAutoWatch enables automatic file watching after Initialize. When enabled, the registry will automatically reload when SKILL.md files change.
type Skill ¶
type Skill struct {
// Name is the skill identifier (from YAML front matter).
Name string `json:"name" yaml:"name"`
// Description describes what the skill does and when to use it.
Description string `json:"description" yaml:"description"`
// Path is the absolute path to the skill directory.
Path string `json:"path"`
// Content is the full markdown body (loaded on demand).
Content string `json:"-"`
// Files are additional files bundled with the skill.
Files []SkillFile `json:"files,omitempty"`
// Source indicates where the skill was loaded from.
Source SkillSource `json:"source"`
// LoadedAt is when the skill was loaded.
LoadedAt time.Time `json:"loaded_at"`
}
Skill represents a loaded skill with its metadata and content.
func (*Skill) SkillMDPath ¶
SkillMDPath returns the path to SKILL.md within the skill directory.
func (*Skill) ToMetaData ¶
func (s *Skill) ToMetaData() SkillMetadata
ToMetaData extracts lightweight metadata from a full skill.
type SkillError ¶
SkillError is the base error type for skill operations.
func (*SkillError) Error ¶
func (e *SkillError) Error() string
func (*SkillError) Unwrap ¶
func (e *SkillError) Unwrap() error
type SkillFile ¶
type SkillFile struct {
// RelPath is the path relative to skill directory.
RelPath string `json:"rel_path"`
// AbsPath is the absolute filesystem path
AbsPath string `json:"abs_path"`
// Type indicates the file category
Type FileType `json:"type"`
}
SkillFile represents an additional file bundled with a skill.
type SkillMetadata ¶
type SkillMetadata struct {
Name string `json:"name"`
Description string `json:"description"`
Source SkillSource `json:"source"`
Path string `json:"path"`
Capabilities []string `json:"capabilities,omitempty"`
}
SkillMetadata is the lightweight metadata loaded at startup. Only name and description are included to minimize context usage.
type SkillSource ¶
type SkillSource string
SkillSource indicates where a skill was loaded from.
const ( SourceGlobal SkillSource = "global" // ~/.echoryn/golem/skills/ SourceProject SkillSource = "project" // <project>/.echoryn/skills/ SourceBuiltin SkillSource = "builtin" // compiled into binary )
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors skill directories for changes and triggers reloads.
func NewWatcher ¶
func NewWatcher(registry *Registry, dirs []string, opts ...WatcherOption) (*Watcher, error)
NewWatcher creates a new file system watcher for skill directories.
type WatcherOption ¶
type WatcherOption func(watcher *Watcher)
WatcherOption configures the Watcher.
func WithDebounce ¶
func WithDebounce(d time.Duration) WatcherOption
WithDebounce sets the debounce duration for batching rapid file changes. Default 100ms.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package middleware provides the Skills middleware for integrating the skills system into Eino-based agents.
|
Package middleware provides the Skills middleware for integrating the skills system into Eino-based agents. |