Documentation
¶
Index ¶
- Constants
- func ValidateName(name string) error
- type Activation
- type CompositeValidator
- type Def
- type EventDispatcher
- type FileLoader
- type InMemoryManager
- func (m *InMemoryManager) Activate(ctx context.Context, name string, sessionID string) (*Activation, error)
- func (m *InMemoryManager) ActiveSkills(sessionID string) []*Activation
- func (m *InMemoryManager) ClearSession(ctx context.Context, sessionID string)
- func (m *InMemoryManager) Deactivate(ctx context.Context, name string, sessionID string) error
- func (m *InMemoryManager) LoadResource(ctx context.Context, sessionID string, skillName string, resourceType string, ...) (*Resource, error)
- type InMemoryRegistry
- type Loader
- type Manager
- type ManagerOption
- type NameValidator
- type Registry
- type RegistryOption
- type Resource
- type SizeValidator
- type StructureValidator
- type Validator
Constants ¶
const ( ResourceTypeScript = "script" ResourceTypeReference = "reference" ResourceTypeAsset = "asset" )
Resource type constants.
const MaxInstructionLines = 500
MaxInstructionLines is the maximum number of lines allowed in skill instructions.
Variables ¶
This section is empty.
Functions ¶
func ValidateName ¶
ValidateName checks that a skill name contains only lowercase letters, digits, and hyphens.
Types ¶
type Activation ¶
type Activation struct {
SkillName string
SessionID string
ActivatedAt time.Time
// contains filtered or unexported fields
}
Activation records an active skill for a session.
func (*Activation) SkillDef ¶
func (a *Activation) SkillDef() Def
Def returns a copy of the skill definition to prevent external mutation.
type CompositeValidator ¶
type CompositeValidator struct {
// contains filtered or unexported fields
}
CompositeValidator chains multiple validators and returns the first error.
func DefaultValidator ¶
func DefaultValidator() *CompositeValidator
DefaultValidator returns the default composite validator chain.
func NewCompositeValidator ¶
func NewCompositeValidator(vs ...Validator) *CompositeValidator
NewCompositeValidator creates a CompositeValidator from the given validators.
func (*CompositeValidator) Validate ¶
func (c *CompositeValidator) Validate(def *Def) error
type Def ¶
type Def struct {
Name string `json:"name"`
Description string `json:"description"`
License string `json:"license,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Instructions string `json:"instructions"`
BasePath string `json:"base_path,omitempty"`
Resources []Resource `json:"resources,omitempty"`
}
Def defines a skill's metadata and instructions.
type EventDispatcher ¶
EventDispatcher is a callback for dispatching events without importing the hook package.
type FileLoader ¶
type FileLoader struct{}
FileLoader loads skills from the filesystem.
type InMemoryManager ¶
type InMemoryManager struct {
// contains filtered or unexported fields
}
InMemoryManager is an in-memory implementation of Manager.
func NewManager ¶
func NewManager(registry Registry, opts ...ManagerOption) *InMemoryManager
NewManager creates a new InMemoryManager with the given registry and options.
func (*InMemoryManager) Activate ¶
func (m *InMemoryManager) Activate(ctx context.Context, name string, sessionID string) (*Activation, error)
Activate activates a skill for the given session.
func (*InMemoryManager) ActiveSkills ¶
func (m *InMemoryManager) ActiveSkills(sessionID string) []*Activation
ActiveSkills returns all active skill activations for the given session.
func (*InMemoryManager) ClearSession ¶
func (m *InMemoryManager) ClearSession(ctx context.Context, sessionID string)
ClearSession removes all skill activations for the given session.
func (*InMemoryManager) Deactivate ¶
Deactivate removes a skill activation from the given session.
type InMemoryRegistry ¶
type InMemoryRegistry struct {
// contains filtered or unexported fields
}
InMemoryRegistry is a thread-safe in-memory skill registry.
func NewRegistry ¶
func NewRegistry(opts ...RegistryOption) *InMemoryRegistry
NewRegistry creates an empty InMemoryRegistry with the given options.
func (*InMemoryRegistry) Get ¶
func (r *InMemoryRegistry) Get(name string) (*Def, bool)
Get returns the skill definition with the given name.
func (*InMemoryRegistry) List ¶
func (r *InMemoryRegistry) List() []*Def
List returns all registered skill definitions.
func (*InMemoryRegistry) Match ¶
func (r *InMemoryRegistry) Match(query string) []*Def
Match returns skills whose Name or Description contains all query words (case-insensitive, AND semantics).
func (*InMemoryRegistry) Register ¶
func (r *InMemoryRegistry) Register(def *Def) error
Register validates and stores a skill definition. Rejects duplicates.
func (*InMemoryRegistry) Unregister ¶
func (r *InMemoryRegistry) Unregister(name string)
Unregister removes a skill by name. Silently succeeds if the name does not exist.
type Loader ¶
type Loader interface {
Load(ctx context.Context, path string) (*Def, error)
Discover(ctx context.Context, dir string) ([]*Def, error)
}
Loader loads skill definitions from the filesystem.
type Manager ¶
type Manager interface {
Activate(ctx context.Context, name string, sessionID string) (*Activation, error)
Deactivate(ctx context.Context, name string, sessionID string) error
ActiveSkills(sessionID string) []*Activation
ClearSession(ctx context.Context, sessionID string)
LoadResource(ctx context.Context, sessionID string, skillName string, resourceType string, resourceName string) (*Resource, error)
}
Manager manages skill activations per session.
type ManagerOption ¶
type ManagerOption func(*InMemoryManager)
ManagerOption configures an InMemoryManager during construction.
func WithEventDispatcher ¶
func WithEventDispatcher(d EventDispatcher) ManagerOption
WithEventDispatcher sets the optional event dispatcher callback.
type NameValidator ¶
type NameValidator struct{}
NameValidator validates the skill name format.
func (NameValidator) Validate ¶
func (NameValidator) Validate(def *Def) error
type Registry ¶
type Registry interface {
Register(def *Def) error
Unregister(name string)
Get(name string) (*Def, bool)
List() []*Def
Match(query string) []*Def
}
Registry manages registered skill definitions.
type RegistryOption ¶
type RegistryOption func(*InMemoryRegistry)
RegistryOption configures an InMemoryRegistry during construction.
func WithValidator ¶
func WithValidator(v Validator) RegistryOption
WithValidator sets the validator used when registering skills.
type Resource ¶
type Resource struct {
Type string `json:"type"`
Name string `json:"name"`
Path string `json:"path"`
Content string `json:"content,omitempty"`
}
Resource describes a file resource associated with a skill.
type SizeValidator ¶
type SizeValidator struct{}
SizeValidator checks that the instructions do not exceed MaxInstructionLines.
func (SizeValidator) Validate ¶
func (SizeValidator) Validate(def *Def) error
type StructureValidator ¶
type StructureValidator struct{}
StructureValidator checks that only allowed subdirectories exist under BasePath.
func (StructureValidator) Validate ¶
func (StructureValidator) Validate(def *Def) error