Documentation
¶
Overview ¶
Package skill implements a local plugin system for polycode. Skills are directories containing a skill.yaml manifest, optional system prompt, and optional tool definitions with handler scripts.
Index ¶
- func LoadSystemPrompt(skillDir string) string
- type Manifest
- type Registry
- func (r *Registry) ExecuteTool(ctx context.Context, fullName string, arguments string) (string, error)
- func (r *Registry) FormatList() string
- func (r *Registry) Get(name string) *Skill
- func (r *Registry) HandleCommand(command string) (string, bool)
- func (r *Registry) Install(sourcePath string) error
- func (r *Registry) List() []*Skill
- func (r *Registry) Load() error
- func (r *Registry) Remove(name string) error
- func (r *Registry) SlashCommands() []string
- func (r *Registry) SystemPrompts() string
- func (r *Registry) ToToolDefinitions() []provider.ToolDefinition
- type Skill
- type ToolManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSystemPrompt ¶
LoadSystemPrompt reads the system_prompt.md file from a skill directory, returning empty string if the file does not exist.
Types ¶
type Manifest ¶
type Manifest struct {
Name string `yaml:"name"`
Version string `yaml:"version,omitempty"`
Description string `yaml:"description"`
Command string `yaml:"command,omitempty"` // slash command name (without /)
Tools []ToolManifest `yaml:"tools,omitempty"`
Enabled bool `yaml:"enabled,omitempty"`
}
Manifest describes a skill's metadata and capabilities.
func LoadManifest ¶
LoadManifest reads and parses a skill.yaml file.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages installed skills.
func NewRegistry ¶
NewRegistry creates a Registry that loads skills from the given directory.
func (*Registry) ExecuteTool ¶
func (r *Registry) ExecuteTool(ctx context.Context, fullName string, arguments string) (string, error)
ExecuteTool runs a skill tool's handler script and returns the output. The tool name should be in the format "skill_{skillname}_{toolname}".
func (*Registry) FormatList ¶
FormatList returns a human-readable listing of installed skills.
func (*Registry) HandleCommand ¶
HandleCommand dispatches a slash command to the appropriate skill. Returns the skill's system prompt context and true if handled, or empty and false.
func (*Registry) Install ¶
Install copies a skill from sourcePath into the skills directory. The skill is validated before installation.
func (*Registry) Load ¶
Load discovers and loads all skills from the skills directory. Invalid skills are skipped with a warning logged to stderr.
func (*Registry) SlashCommands ¶
SlashCommands returns the slash commands registered by all skills.
func (*Registry) SystemPrompts ¶
SystemPrompts returns the concatenated system prompts from all loaded skills.
func (*Registry) ToToolDefinitions ¶
func (r *Registry) ToToolDefinitions() []provider.ToolDefinition
ToToolDefinitions returns provider.ToolDefinition objects for all tools provided by all loaded skills. Tool names are prefixed with "skill_{name}_" to avoid collisions.
type Skill ¶
type Skill struct {
Manifest Manifest
Dir string // absolute path to skill directory
SystemPrompt string // contents of system_prompt.md (may be empty)
}
Skill is a loaded, ready-to-use skill instance.
type ToolManifest ¶
type ToolManifest struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Parameters map[string]any `yaml:"parameters,omitempty"` // JSON Schema object
Handler string `yaml:"handler"` // shell command to execute
}
ToolManifest describes a tool provided by a skill.