skills

package
v0.502.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const SkillFileName = "SKILL.md"

Variables

This section is empty.

Functions

func ConfiguredDiscoveryPaths added in v0.502.6

func ConfiguredDiscoveryPaths(workDir string, extraPaths []string) []string

ConfiguredDiscoveryPaths returns the full ordered list of skill search paths (highest precedence first): the built-in discovery paths followed by any extra paths from configuration. Relative extra paths are resolved against workDir. This is the single source of truth shared by the agent's skill loader and the API/UI skill listing so they never diverge.

func DiscoveryPaths

func DiscoveryPaths(workDir string) []string

DiscoveryPaths returns the ordered list of skill search paths (highest precedence first).

func EstimateTokens

func EstimateTokens(text string) int

EstimateTokens estimates token count (~4 chars per token).

func MatchSkillToPrompt

func MatchSkillToPrompt(metadata SkillMetadata, prompt string) bool

MatchSkillToPrompt checks if a skill should activate based on its when-to-use field.

Types

type CLIToolSkill

type CLIToolSkill struct {
	// contains filtered or unexported fields
}

CLIToolSkill wraps a CLI executable as a BaseTool.

func DiscoverCLITools

func DiscoverCLITools(paths []string) []CLIToolSkill

DiscoverCLITools scans skill directories for CLI tool skills. A CLI tool skill is a directory containing an executable named "tool" and a README.md.

func (*CLIToolSkill) Info

func (t *CLIToolSkill) Info() tools.ToolInfo

Info returns tool metadata.

func (*CLIToolSkill) Run

Run executes the CLI tool with the given parameters as JSON stdin.

type ContextManager

type ContextManager struct {
	// contains filtered or unexported fields
}

ContextManager tracks token usage and manages skill loading levels.

func NewContextManager

func NewContextManager(manager *SkillManager, maxContextTokens int) *ContextManager

func (*ContextManager) ActivateSkill

func (cm *ContextManager) ActivateSkill(name string) (string, error)

ActivateSkill loads Level 2 instructions for a skill, evicting if needed.

func (*ContextManager) GetMetadataPrompt

func (cm *ContextManager) GetMetadataPrompt() string

GetMetadataPrompt returns the always-loaded Level 1 metadata for all skills formatted for injection into the system prompt. ~50 tokens per skill.

func (*ContextManager) ShouldActivate

func (cm *ContextManager) ShouldActivate(prompt string) []string

ShouldActivate checks if a skill should be auto-activated based on prompt.

func (*ContextManager) TokenUsage

func (cm *ContextManager) TokenUsage() (used, max int)

TokenUsage returns current token usage stats.

type Skill

type Skill struct {
	Metadata     SkillMetadata
	Instructions string
	Resources    []SkillResource
	SourcePath   string
	LoadedLevel  SkillLevel
	LastAccessed time.Time
}

func DiscoverSkills

func DiscoverSkills(paths []string) ([]*Skill, error)

DiscoverSkills scans all paths for SKILL.md files and returns skills ordered by precedence. Skills from higher-precedence paths override same-named skills from lower paths.

func ParseSkillFile

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

type SkillLevel

type SkillLevel int
const (
	LevelMetadata     SkillLevel = 1
	LevelInstructions SkillLevel = 2
	LevelResources    SkillLevel = 3
)

type SkillManager

type SkillManager struct {
	// contains filtered or unexported fields
}

func NewSkillManager

func NewSkillManager(maxCache int) *SkillManager

func (*SkillManager) EstimateTokens

func (m *SkillManager) EstimateTokens(text string) int

func (*SkillManager) EvictLRU

func (m *SkillManager) EvictLRU()

func (*SkillManager) GetAllMetadata

func (m *SkillManager) GetAllMetadata() []SkillMetadata

func (*SkillManager) GetInstructions

func (m *SkillManager) GetInstructions(name string) (string, error)

func (*SkillManager) GetResource

func (m *SkillManager) GetResource(name, resourcePath string) ([]byte, error)

func (*SkillManager) IsLoaded

func (m *SkillManager) IsLoaded(name string) bool

func (*SkillManager) LoadAll

func (m *SkillManager) LoadAll(paths []string) error

func (*SkillManager) Recall

func (m *SkillManager) Recall(name string) error

func (*SkillManager) SetLoaded

func (m *SkillManager) SetLoaded(name string, loaded bool) error

type SkillMetadata

type SkillMetadata struct {
	Name                   string `yaml:"name"`
	Description            string `yaml:"description"`
	Version                string `yaml:"version"`
	Author                 string `yaml:"author"`
	License                string `yaml:"license"`
	Compatibility          string `yaml:"compatibility"`
	AllowedTools           string `yaml:"allowed-tools"`
	UserInvocable          bool   `yaml:"user-invocable"`
	WhenToUse              string `yaml:"when-to-use"`
	WhenNotToUse           string `yaml:"when-not-to-use"`
	DisableModelInvocation bool   `yaml:"disable-model-invocation"`
	Context                string `yaml:"context"`
}

type SkillResource

type SkillResource struct {
	Path    string
	Content []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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