skill

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSystemPrompt

func LoadSystemPrompt(skillDir string) string

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

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads and parses a skill.yaml file.

type Registry

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

Registry manages installed skills.

func NewRegistry

func NewRegistry(skillsDir string) *Registry

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

func (r *Registry) FormatList() string

FormatList returns a human-readable listing of installed skills.

func (*Registry) Get

func (r *Registry) Get(name string) *Skill

Get returns a skill by name, or nil if not found.

func (*Registry) HandleCommand

func (r *Registry) HandleCommand(command string) (string, bool)

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

func (r *Registry) Install(sourcePath string) error

Install copies a skill from sourcePath into the skills directory. The skill is validated before installation.

func (*Registry) List

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

List returns all loaded skills, sorted by name.

func (*Registry) Load

func (r *Registry) Load() error

Load discovers and loads all skills from the skills directory. Invalid skills are skipped with a warning logged to stderr.

func (*Registry) Remove

func (r *Registry) Remove(name string) error

Remove uninstalls a skill by name.

func (*Registry) SlashCommands

func (r *Registry) SlashCommands() []string

SlashCommands returns the slash commands registered by all skills.

func (*Registry) SystemPrompts

func (r *Registry) SystemPrompts() string

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.

Jump to

Keyboard shortcuts

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