Documentation
¶
Overview ¶
Package skills provides skill loading and matching for agents.
Index ¶
- type Loader
- func (l *Loader) Count() int
- func (l *Loader) Get(name string) (*Skill, error)
- func (l *Loader) List() []*Skill
- func (l *Loader) Load(ctx context.Context) error
- func (l *Loader) Match(message string) []SkillMatch
- func (l *Loader) Names() []string
- func (l *Loader) Reload(ctx context.Context) error
- func (l *Loader) SetFilters(include, exclude []string)
- type LoaderConfig
- type MatchOptions
- type Skill
- type SkillMatch
- type SkillMetadata
- type TriggerDef
- type TriggerType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader manages skill loading and discovery.
func WithConfig ¶
func WithConfig(config LoaderConfig) *Loader
WithConfig creates a loader from configuration.
func (*Loader) Match ¶
func (l *Loader) Match(message string) []SkillMatch
Match finds skills that match the given message.
func (*Loader) SetFilters ¶
SetFilters updates the include/exclude filters.
type LoaderConfig ¶
type LoaderConfig struct {
// Directories to scan for skills.
Directories []string
// Include filters skills by name pattern.
Include []string
// Exclude filters out skills by name pattern.
Exclude []string
// WatchForChanges enables file watching.
WatchForChanges bool
}
LoaderConfig configures the skill loader.
type MatchOptions ¶
type MatchOptions struct {
// MaxResults limits the number of matches returned.
MaxResults int
// MinScore filters out matches below this score.
MinScore float64
// RequiredTags only matches skills with all these tags.
RequiredTags []string
}
MatchOptions configures matching behavior.
type Skill ¶
type Skill struct {
// Name is the unique identifier for the skill.
Name string `yaml:"name"`
// Description briefly describes what the skill does.
Description string `yaml:"description"`
// Tags are categories for the skill.
Tags []string `yaml:"tags"`
// Tools are tool names this skill needs when active.
Tools []string `yaml:"tools,omitempty"`
// MCP lists MCP server names this skill needs when active.
MCP []string `yaml:"mcp,omitempty"`
// Triggers define when the skill should be activated.
Triggers []TriggerDef `yaml:"triggers"`
// Instructions is the markdown body (lazy loaded).
Instructions string `yaml:"-"`
// contains filtered or unexported fields
}
Skill represents a loadable skill definition.
func ParseFile ¶
ParseFile parses a SKILL.md file. The file format is:
---
name: skill-name
description: Brief description
tags: [tag1, tag2]
triggers:
- type: keyword
keywords: [word1, word2]
---
# Skill Title
Instructions markdown here...
func ParseMetadataOnly ¶
ParseMetadataOnly parses only the frontmatter metadata without loading instructions.
func (*Skill) LoadInstructions ¶
LoadInstructions loads the full instructions for a skill.
type SkillMatch ¶
type SkillMatch struct {
// Skill is the matched skill.
Skill *Skill
// Score is the relevance score (0.0-1.0).
Score float64
// Reason explains why the skill matched.
Reason string
}
SkillMatch represents a matched skill with its relevance score.
func MatchWithOptions ¶
func MatchWithOptions(skills map[string]*Skill, message string, opts MatchOptions) []SkillMatch
MatchWithOptions finds skills with custom options.
type SkillMetadata ¶
type SkillMetadata struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Tags []string `yaml:"tags"`
Tools []string `yaml:"tools,omitempty"`
MCP []string `yaml:"mcp,omitempty"`
Triggers []TriggerDef `yaml:"triggers"`
}
SkillMetadata contains only the metadata portion of a skill. Used for listing skills without loading full instructions.
type TriggerDef ¶
type TriggerDef struct {
// Type is the trigger type.
Type TriggerType `yaml:"type"`
// Keywords are words/phrases that trigger the skill (for keyword type).
Keywords []string `yaml:"keywords,omitempty"`
// Pattern is a regex pattern (for pattern type).
Pattern string `yaml:"pattern,omitempty"`
}
TriggerDef defines a skill trigger.
type TriggerType ¶
type TriggerType string
TriggerType identifies the type of skill trigger.
const ( // TriggerKeyword matches specific keywords in the message. TriggerKeyword TriggerType = "keyword" // TriggerPattern matches a regex pattern in the message. TriggerPattern TriggerType = "pattern" // TriggerAlways always includes the skill. TriggerAlways TriggerType = "always" )