Documentation
¶
Index ¶
- Variables
- func SetReadFileForTest(fn func(string) ([]byte, error)) (restore func())
- type Activation
- type ActivationContext
- type Definition
- type Handler
- type HandlerFunc
- type KeywordMatcher
- type LoaderOptions
- type MatchResult
- type Matcher
- type MatcherFunc
- type Registry
- func (r *Registry) Execute(ctx context.Context, name string, ac ActivationContext) (Result, error)
- func (r *Registry) Get(name string) (*Skill, bool)
- func (r *Registry) List() []Definition
- func (r *Registry) Match(ctx ActivationContext) []Activation
- func (r *Registry) Register(def Definition, handler Handler) error
- type Result
- type Skill
- type SkillFile
- type SkillMetadata
- type SkillRegistration
- type TagMatcher
- type ToolList
- type TraitMatcher
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDuplicateSkill indicates an attempt to register the same name twice. ErrDuplicateSkill = errors.New("skills: duplicate registration") // ErrUnknownSkill is returned by Execute/Get when a skill is missing. ErrUnknownSkill = errors.New("skills: unknown skill") )
Functions ¶
func SetReadFileForTest ¶
SetReadFileForTest swaps the file reader; intended for white-box tests only.
Types ¶
type Activation ¶
Activation is a resolved auto-activation candidate.
func (Activation) Definition ¶
func (a Activation) Definition() Definition
Definition returns metadata for the activation.
type ActivationContext ¶
type ActivationContext struct {
Prompt string
Channels []string
Tags map[string]string
Traits []string
Metadata map[string]any
}
ActivationContext captures conversational state used for auto-activation.
func (ActivationContext) Clone ¶
func (c ActivationContext) Clone() ActivationContext
Clone produces an isolated copy of the activation context.
type Definition ¶
type Definition struct {
Name string
Description string
Priority int
MutexKey string
// DisableAutoActivation keeps the skill available for manual invocation
// while excluding it from automatic activation matching.
DisableAutoActivation bool
Metadata map[string]string
Matchers []Matcher
}
Definition describes a declarative skill registration entry.
func (Definition) Validate ¶
func (d Definition) Validate() error
Validate performs cheap sanity checks before accepting a definition.
type Handler ¶
type Handler interface {
Execute(context.Context, ActivationContext) (Result, error)
}
Handler executes a skill.
type HandlerFunc ¶
type HandlerFunc func(context.Context, ActivationContext) (Result, error)
HandlerFunc adapts ordinary functions to Handler.
func (HandlerFunc) Execute ¶
func (fn HandlerFunc) Execute(ctx context.Context, ac ActivationContext) (Result, error)
Execute implements Handler.
type KeywordMatcher ¶
KeywordMatcher inspects prompt text for keywords.
func (KeywordMatcher) Match ¶
func (m KeywordMatcher) Match(ctx ActivationContext) MatchResult
Match implements Matcher.
type LoaderOptions ¶
type LoaderOptions struct {
ProjectRoot string
// Deprecated: user-level scanning has been removed; this field is ignored.
UserHome string
// Deprecated: user-level scanning has been removed; this flag is ignored.
EnableUser bool
// FS is the filesystem abstraction layer for loading skills.
// If nil, falls back to os.* functions for backward compatibility.
FS *config.FS
}
LoaderOptions controls how skills are discovered from the filesystem.
type MatchResult ¶
MatchResult represents the outcome of a matcher evaluation.
func (MatchResult) BetterThan ¶
func (r MatchResult) BetterThan(other MatchResult) bool
BetterThan orders two match results. Unmatched entries always lose, then higher scores are preferred. When scores tie reasons act as a tiebreaker to keep deterministic ordering.
type Matcher ¶
type Matcher interface {
Match(ActivationContext) MatchResult
}
Matcher evaluates whether the activation context should trigger a skill.
type MatcherFunc ¶
type MatcherFunc func(ActivationContext) MatchResult
MatcherFunc adapts a function to Matcher.
func (MatcherFunc) Match ¶
func (fn MatcherFunc) Match(ctx ActivationContext) MatchResult
Match implements Matcher.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry coordinates skill registration and activation.
func (*Registry) List ¶
func (r *Registry) List() []Definition
List returns the registered skill definitions sorted by priority + name.
func (*Registry) Match ¶
func (r *Registry) Match(ctx ActivationContext) []Activation
Match evaluates all auto-activating skills against the provided context while enforcing priority ordering and mutex groups.
type Skill ¶
type Skill struct {
// contains filtered or unexported fields
}
Skill represents a single registered skill.
func (*Skill) Definition ¶
func (s *Skill) Definition() Definition
Definition returns an immutable copy of the skill metadata.
type SkillFile ¶
type SkillFile struct {
Name string
Path string
Metadata SkillMetadata
// contains filtered or unexported fields
}
SkillFile captures an on-disk SKILL.md entry.
type SkillMetadata ¶
type SkillMetadata struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
License string `yaml:"license,omitempty"`
Compatibility string `yaml:"compatibility,omitempty"`
Metadata map[string]string `yaml:"metadata,omitempty"`
AllowedTools ToolList `yaml:"allowed-tools,omitempty"`
}
SkillMetadata mirrors the YAML frontmatter fields inside SKILL.md.
type SkillRegistration ¶
type SkillRegistration struct {
Definition Definition
Handler Handler
}
SkillRegistration wires a definition to its handler.
func LoadFromFS ¶
func LoadFromFS(opts LoaderOptions) ([]SkillRegistration, []error)
LoadFromFS loads skills from the filesystem. Errors are aggregated so one broken file will not block others. Duplicate names are skipped with a warning entry in the error list.
type TagMatcher ¶
TagMatcher enforces metadata tag requirements/exclusions.
func (TagMatcher) Match ¶
func (m TagMatcher) Match(ctx ActivationContext) MatchResult
Match implements Matcher.
type ToolList ¶ added in v0.5.1
type ToolList []string
ToolList supports YAML string or sequence, normalizing to a de-duplicated list.
type TraitMatcher ¶
type TraitMatcher struct {
Traits []string
}
TraitMatcher matches against declared user/system traits.
func (TraitMatcher) Match ¶
func (m TraitMatcher) Match(ctx ActivationContext) MatchResult
Match implements Matcher.