skills

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package skills provides skill loading and matching for agents.

Index

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 NewLoader

func NewLoader(dirs ...string) *Loader

NewLoader creates a new skill loader for the given directories.

func WithConfig

func WithConfig(config LoaderConfig) *Loader

WithConfig creates a loader from configuration.

func (*Loader) Count

func (l *Loader) Count() int

Count returns the number of loaded skills.

func (*Loader) Get

func (l *Loader) Get(name string) (*Skill, error)

Get retrieves a skill by name, loading full instructions if needed.

func (*Loader) List

func (l *Loader) List() []*Skill

List returns all loaded skills (metadata only).

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) error

Load scans directories and loads skill metadata.

func (*Loader) Match

func (l *Loader) Match(message string) []SkillMatch

Match finds skills that match the given message.

func (*Loader) Names

func (l *Loader) Names() []string

Names returns the names of all loaded skills.

func (*Loader) Reload

func (l *Loader) Reload(ctx context.Context) error

Reload clears and reloads all skills.

func (*Loader) SetFilters

func (l *Loader) SetFilters(include, exclude []string)

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 Parse

func Parse(data []byte, path string) (*Skill, error)

Parse parses skill content from bytes.

func ParseFile

func ParseFile(path string) (*Skill, error)

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

func ParseMetadataOnly(path string) (*Skill, error)

ParseMetadataOnly parses only the frontmatter metadata without loading instructions.

func (*Skill) LoadInstructions

func (s *Skill) LoadInstructions() error

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"
)

Jump to

Keyboard shortcuts

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