skills

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package skills implements the agentskills.io discovery and execution protocol.

Skills are directories containing a SKILL.md file with YAML frontmatter (name, description) followed by Markdown instructions. An optional scripts/ subdirectory may contain executable files that agents can run.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSkills = errors.New("no skills found")

ErrNoSkills is returned by NewExecutor when the skills directory exists and was successfully scanned but contained no SKILL.md files. Callers can use errors.Is to detect this case and fall back to a no-op tool.

Functions

func BuildTool

func BuildTool(names []string) *genai.Tool

BuildTool creates the Gemini Tool definition for skill invocation.

func DefaultDir

func DefaultDir() string

DefaultDir returns the default system-wide directory for discovering skills. It resolves to ~/.agents/skills on all platforms.

func SystemPrompt

func SystemPrompt(skills []Skill) string

SystemPrompt returns the <available_skills> XML block for injection into a model system prompt, following the agentskills.io integration guide.

Types

type Executor

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

Executor runs an agentskills.io-compatible agentic loop.

func NewExecutor

func NewExecutor(dir string) (*Executor, error)

NewExecutor discovers skills in dir, then creates an Executor. The caller is responsible for creating the client and choosing a model.

Returns ErrNoSkills if dir was scanned successfully but contained no SKILL.md files. Other errors (e.g. dir does not exist, permission denied) are returned wrapped from Discover.

func (*Executor) HandleCall

func (e *Executor) HandleCall(ctx context.Context, call *genai.FunctionCall) (*ScriptResult, error)

HandleCall processes an 'activate_skill' or 'run_skill_script' call.

func (*Executor) HasSkills

func (e *Executor) HasSkills() bool

HasSkills returns true if the executor has any skills.

func (*Executor) SkillNames

func (e *Executor) SkillNames() []string

SkillNames returns the names of all discovered skills.

func (*Executor) SystemPrompt

func (e *Executor) SystemPrompt() string

SystemPrompt returns the agentskills.io instructional block for all skills.

type ScriptResult

type ScriptResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

ScriptResult holds the output of a RunScript call.

type Skill

type Skill struct {
	Name        string
	Description string
	Dir         string // absolute path to the skill directory
}

Skill represents a discovered agentskills.io skill.

func Discover

func Discover(dir string) ([]Skill, error)

Discover scans dir for agentskills.io-compatible skill directories and returns their parsed metadata. Invisible entries (names starting with ".") and entries that are not directories (including broken symlinks) are skipped. Directories that lack a valid SKILL.md are silently skipped.

func (Skill) Body

func (s Skill) Body() (string, error)

Body returns the Markdown body of the skill's SKILL.md with the YAML frontmatter stripped. This is the full instruction text to inject into a model context when the skill is activated.

func (Skill) RunScript

func (s Skill) RunScript(ctx context.Context, script string, args []string) (*ScriptResult, error)

RunScript executes scripts/<script> inside the skill directory and returns its stdout, stderr, and exit code. script must be a plain filename with no path separators to prevent traversal outside the scripts/ directory.

Jump to

Keyboard shortcuts

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