skills

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func NewRegistry(threshold float64) *Registry

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

func (r *Registry) GetAllSkills() []SkillInfo

GetAllSkills returns all loaded skills as an interface slice.

Returns:

  • []SkillInfo: A slice of all skills as interfaces

func (*Registry) GetAllSkillsAsPointers

func (r *Registry) GetAllSkillsAsPointers() []*Skill

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

func (r *Registry) GetSkill(id string) (*Skill, error)

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

func (r *Registry) GetSkillCount() int

GetSkillCount returns the total number of loaded skills.

Returns:

  • int: The number of skills

func (*Registry) GetUsageStats

func (r *Registry) GetUsageStats() map[string]int64

GetUsageStats returns usage statistics for all skills.

Returns:

  • map[string]int64: Map of skill ID to usage count

func (*Registry) HasEmbeddings

func (r *Registry) HasEmbeddings() bool

HasEmbeddings returns whether embeddings have been computed for skills.

Returns:

  • bool: true if embeddings are available

func (*Registry) LoadAll

func (r *Registry) LoadAll(skillsDir string) error

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

func (s *Skill) GetDescription() string

GetDescription returns the skill description.

func (*Skill) GetEmbeddingLength

func (s *Skill) GetEmbeddingLength() int

GetEmbeddingLength returns the length of the embedding vector.

func (*Skill) GetID

func (s *Skill) GetID() string

GetID returns the skill ID.

func (*Skill) GetName

func (s *Skill) GetName() string

GetName returns the skill name.

func (*Skill) GetRequiredCapability

func (s *Skill) GetRequiredCapability() string

GetRequiredCapability returns the required capability.

func (*Skill) GetSystemPrompt

func (s *Skill) GetSystemPrompt() string

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.

Jump to

Keyboard shortcuts

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