Documentation
¶
Overview ¶
Package skills provides an enhanced skill registry for Phase 2 intelligent routing. It loads skills from SKILL.md files and supports embedding-based semantic matching.
Index ¶
- type EmbeddingEngine
- type Registry
- func (r *Registry) GetAllSkills() []SkillInfo
- func (r *Registry) GetAllSkillsAsPointers() []*Skill
- func (r *Registry) GetSkill(id string) (*Skill, error)
- func (r *Registry) GetSkillCount() int
- func (r *Registry) GetUsageStats() map[string]int64
- func (r *Registry) HasEmbeddings() bool
- func (r *Registry) LoadAll(skillsDir string) error
- func (r *Registry) MatchSkill(queryEmbedding []float32) (*SkillMatchResult, error)
- func (r *Registry) SetEmbeddingEngine(engine EmbeddingEngine)
- type Skill
- type SkillInfo
- type SkillMatchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbeddingEngine ¶
type EmbeddingEngine interface {
// Embed computes the embedding vector for a text
Embed(text string) ([]float32, error)
// CosineSimilarity computes the cosine similarity between two vectors
CosineSimilarity(a, b []float32) float64
}
EmbeddingEngine defines the interface for computing embeddings. This allows the skill registry to work with or without the embedding engine.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the collection of skills and provides semantic matching. It reuses the existing SKILL.md parsing logic from lua_engine.go.
func NewRegistry ¶
NewRegistry creates a new skill registry.
Parameters:
- threshold: Minimum confidence score for skill matching (default: 0.80)
Returns:
- *Registry: A new registry instance
func (*Registry) GetAllSkills ¶
GetAllSkills returns all loaded skills as an interface slice.
Returns:
- []SkillInfo: A slice of all skills as interfaces
func (*Registry) GetAllSkillsAsPointers ¶
GetAllSkillsAsPointers returns all loaded skills as pointers. This is used internally when concrete types are needed.
Returns:
- []*Skill: A slice of all skills
func (*Registry) GetSkill ¶
GetSkill retrieves a skill by its ID.
Parameters:
- id: The skill ID
Returns:
- *Skill: The skill, or nil if not found
- error: Any error encountered
func (*Registry) GetSkillCount ¶
GetSkillCount returns the total number of loaded skills.
Returns:
- int: The number of skills
func (*Registry) GetUsageStats ¶
GetUsageStats returns usage statistics for all skills.
Returns:
- map[string]int64: Map of skill ID to usage count
func (*Registry) HasEmbeddings ¶
HasEmbeddings returns whether embeddings have been computed for skills.
Returns:
- bool: true if embeddings are available
func (*Registry) LoadAll ¶
LoadAll loads all skills from the specified directory. It walks the directory tree and parses all SKILL.md files. This reuses the parsing logic from lua_engine.go.
Parameters:
- skillsDir: Path to the skills directory
Returns:
- error: Any error encountered during loading
func (*Registry) MatchSkill ¶
func (r *Registry) MatchSkill(queryEmbedding []float32) (*SkillMatchResult, error)
MatchSkill finds the best matching skill for a query embedding. Returns nil if no skill matches above the confidence threshold.
Parameters:
- queryEmbedding: The embedding vector of the query
Returns:
- *SkillMatchResult: The match result, or nil if no match
- error: Any error encountered
func (*Registry) SetEmbeddingEngine ¶
func (r *Registry) SetEmbeddingEngine(engine EmbeddingEngine)
SetEmbeddingEngine sets the embedding engine for semantic matching. This should be called before LoadAll() to enable embedding computation.
Parameters:
- engine: The embedding engine instance
type Skill ¶
type Skill struct {
// ID is the unique identifier for the skill (derived from directory name)
ID string `json:"id" yaml:"-"`
// Name is the human-readable name of the skill
Name string `json:"name" yaml:"name"`
// Description explains what the skill does
Description string `json:"description" yaml:"description"`
// RequiredCapability specifies which capability slot this skill needs
RequiredCapability string `json:"required_capability" yaml:"required-capability"`
// SystemPrompt is the full content of the SKILL.md file
SystemPrompt string `json:"system_prompt" yaml:"-"`
// Embedding is the pre-computed embedding vector for semantic matching
// This is populated when the embedding engine is available
Embedding []float32 `json:"-" yaml:"-"`
}
Skill represents a domain-specific expertise definition with system prompts and model requirements. Skills are loaded from SKILL.md files.
func (*Skill) GetDescription ¶
GetDescription returns the skill description.
func (*Skill) GetEmbeddingLength ¶
GetEmbeddingLength returns the length of the embedding vector.
func (*Skill) GetRequiredCapability ¶
GetRequiredCapability returns the required capability.
func (*Skill) GetSystemPrompt ¶
GetSystemPrompt returns the system prompt.
type SkillInfo ¶
type SkillInfo interface {
GetID() string
GetName() string
GetDescription() string
GetRequiredCapability() string
GetSystemPrompt() string
GetEmbeddingLength() int
}
SkillInfo is an interface for accessing skill information. This allows skills to be used through interfaces in other packages.
type SkillMatchResult ¶
type SkillMatchResult struct {
// Skill is the matched skill
Skill *Skill `json:"skill"`
// Confidence is the similarity score (0.0-1.0)
Confidence float64 `json:"confidence"`
}
SkillMatchResult represents the result of matching a query to a skill.