skill

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package skill loads, validates, and exposes Agent Skills.

It implements the SKILL.md format and progressive-disclosure helpers without coupling skills to a particular agent implementation. Applications choose how to inject a catalog instruction and which skill tools to register.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoadTool

func NewLoadTool(catalog *Catalog, configure ...Option) (tool.Tool, error)

NewLoadTool creates a tool that returns one skill's complete instructions and bundled-resource paths.

func NewReadResourceTool

func NewReadResourceTool(catalog *Catalog, configure ...Option) (tool.Tool, error)

NewReadResourceTool creates a tool that reads one indexed UTF-8 text resource from a loaded skill. It never executes scripts.

Types

type Catalog

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

Catalog is an immutable, name-indexed collection of skills.

func Discover

func Discover(fsys fs.FS, roots ...string) (*Catalog, error)

Discover loads skills from the direct child directories of each root. Invalid skills and duplicate names cause discovery to fail.

func NewCatalog

func NewCatalog(skills ...Skill) (*Catalog, error)

NewCatalog constructs a catalog and rejects invalid or duplicate skills.

func (*Catalog) Instruction

func (c *Catalog) Instruction(configure ...Option) (string, error)

Instruction renders the catalog for request-scoped injection. It returns an empty string when the catalog contains no skills.

func (*Catalog) Skills

func (c *Catalog) Skills() []Skill

Skills returns an isolated copy of the catalog's skills, sorted by name.

type InstructionFormat

type InstructionFormat string

InstructionFormat controls how Catalog.Instruction renders the catalog.

const (
	// InstructionFormatText renders a compact, human-readable instruction.
	InstructionFormatText InstructionFormat = "text"
	// InstructionFormatJSON renders a machine-structured JSON instruction.
	InstructionFormatJSON InstructionFormat = "json"
)

type Option

type Option func(*options)

Option configures catalog instruction rendering and skill tools. The same options can be shared across Instruction, NewLoadTool, and NewReadResourceTool so tool names remain consistent.

func WithInstructionFormat

func WithInstructionFormat(format InstructionFormat) Option

WithInstructionFormat selects text or JSON catalog rendering.

func WithLoadToolName

func WithLoadToolName(name string) Option

WithLoadToolName overrides the default load_skill tool name.

func WithMaxResourceBytes

func WithMaxResourceBytes(limit int64) Option

WithMaxResourceBytes sets the maximum text resource size returned by NewReadResourceTool. The limit must be positive.

func WithReadResourceToolName

func WithReadResourceToolName(name string) Option

WithReadResourceToolName overrides the default read_skill_resource tool name.

func WithUsageInstruction added in v0.1.1

func WithUsageInstruction(text string) Option

WithUsageInstruction replaces the default instruction text appended after the skill list. The text should describe when the model should call the load-skill tool. An empty or whitespace-only value keeps the default.

type Skill

type Skill struct {
	Name          string
	Description   string
	License       string
	Compatibility string
	Metadata      map[string]string
	AllowedTools  []string
	Instructions  string
	Resources     []string
	// contains filtered or unexported fields
}

Skill is one parsed Agent Skill.

func Load

func Load(fsys fs.FS, dir string) (Skill, error)

Load reads and validates a skill directory from fsys. It also indexes bundled regular files for use by NewReadResourceTool.

func Parse

func Parse(data []byte) (Skill, error)

Parse parses and validates one SKILL.md document. Directory-name validation and bundled-resource discovery are performed by Load.

Jump to

Keyboard shortcuts

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