skill

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package skill loads and parses flat-file skill definitions. Skills are markdown files with TOML frontmatter enclosed in +++ delimiters. They are text-only — no code is executed. Their content is injected into the agent's system prompt so the LLM knows what skills are available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPromptSection

func BuildPromptSection(skills []Skill) string

BuildPromptSection assembles a list of skills into a formatted system-prompt section. Returns an empty string if skills is empty.

Types

type MatchContext

type MatchContext struct {
	MessageText string // the user's message
	SkillName   string // set when a schedule fires for a specific skill
}

MatchContext carries the per-message information needed to decide which skills apply.

type Skill

type Skill struct {
	Name           string
	Description    string
	Version        string
	Triggers       []string  // raw trigger strings from frontmatter
	ParsedTriggers []Trigger // parsed at load time for efficient matching
	Requires       SkillRequires
	Body           string // markdown body — everything after the closing +++
	Source         string // file path, for logging/debugging
}

Skill represents a loaded skill file.

func LoadDir

func LoadDir(dir string, logger *slog.Logger) ([]Skill, error)

LoadDir scans dir for skill files and returns all valid ones. It looks for:

  • Top-level *.md files
  • Subdirectories containing a SKILL.md file

A non-existent directory is not an error — it returns an empty slice (safe for fresh installs). Files that fail to parse are logged as warnings and skipped; other valid files in the directory are still loaded.

func MatchSkills

func MatchSkills(skills []Skill, ctx MatchContext) []Skill

MatchSkills returns the subset of skills that should be injected for this message. Skills with no triggers are always included. Otherwise, a skill is included if any of its triggers match the context.

func MergeSkills

func MergeSkills(global, agentSpecific []Skill) []Skill

MergeSkills combines global and agent-specific skills. Agent-specific skills override global skills with the same name. Skills without a matching name in the other set are included as-is.

func ParseFile

func ParseFile(path string, content []byte) (*Skill, error)

ParseFile parses the content of a single skill file. path is used only for the Source field and error messages. Returns an error if the frontmatter delimiters are malformed, the TOML is invalid, or the name field is missing.

type SkillRequires

type SkillRequires struct {
	Tools []string `toml:"tools"`
}

SkillRequires lists optional capabilities a skill depends on.

type Trigger

type Trigger struct {
	Type    TriggerType
	Raw     string // original string, e.g. "command:briefing"
	Command string // lowercase command name, for TriggerCommand only
}

Trigger is a parsed trigger specification from a skill's frontmatter.

func ParseTrigger

func ParseTrigger(raw string) (Trigger, error)

ParseTrigger parses a raw trigger string like "command:briefing" into a Trigger.

func ParseTriggers

func ParseTriggers(raw []string) ([]Trigger, error)

ParseTriggers parses a slice of raw trigger strings. Returns an error if any trigger is invalid.

type TriggerType

type TriggerType int

TriggerType classifies how a skill is activated.

const (
	// TriggerCommand activates on a user command like "/briefing" or "!briefing".
	TriggerCommand TriggerType = iota
	// TriggerSchedule activates when the scheduler fires for the matching skill.
	TriggerSchedule
)

Jump to

Keyboard shortcuts

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