skills

package
v0.54.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package skills loads SKILL.md files: YAML frontmatter (name, description, optional allowed-tools) followed by Markdown instructions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry holds the skills found at startup. The first registration of a name wins, so roots are loaded in priority order.

func LoadRoots

func LoadRoots(roots []Root) *Registry

LoadRoots scans each root (in priority order) for SKILL.md files and registers them; a later root never replaces an earlier skill of the same name. Missing roots are skipped; an invalid SKILL.md is logged and skipped.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Get

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

Get returns the named skill.

func (*Registry) Len

func (r *Registry) Len() int

Len is the number of registered skills.

func (*Registry) List

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

List returns the skills sorted by name.

func (*Registry) Register

func (r *Registry) Register(s Skill) bool

Register adds s unless a skill with the same name (case-insensitive) is already registered; it reports whether s was added.

func (*Registry) Search

func (r *Registry) Search(query string, limit int) []Skill

Search ranks skills against query: each query word found in the name scores 3, in the description 1 (substring match, case-insensitive). CJK runs are also split into overlapping two-character words so "前端页面设计" finds a description saying "前端设计". Skills scoring 0 are dropped; ties keep name order. At most limit skills are returned.

func (*Registry) Shadowed

func (r *Registry) Shadowed() []ShadowedSkill

Shadowed reports the same-name skills dropped in favour of an earlier root.

func (*Registry) Skipped

func (r *Registry) Skipped() []SkippedSkill

Skipped reports the SKILL.md files that could not be registered.

type Root

type Root struct {
	Dir string
	// Workspace marks a root inside the workspace (project skills).
	Workspace bool
}

Root is one directory scanned for skills.

type ShadowedSkill

type ShadowedSkill struct {
	Name   string
	Winner string
	Loser  string
}

ShadowedSkill is a skill whose name was already registered by an earlier root: Winner is the SKILL.md that stays in effect, Loser the dropped one.

type Skill

type Skill struct {
	Name        string
	Description string
	// AllowedTools is informational only (shown, never enforced).
	AllowedTools []string
	// AlwaysLoad (frontmatter metadata.always_load or always_load) asks for
	// the body to be put in the system prompt instead of loaded on demand.
	AlwaysLoad bool
	// Workspace marks a skill found under the workspace (vs the user's home).
	Workspace bool
	// Path is the SKILL.md file; Dir its directory (other skill files live there).
	Path string
	Dir  string
}

Skill is one parsed SKILL.md.

func Parse

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

Parse splits data into the skill metadata and the Markdown body. The file must start with a "---" line and close the frontmatter with another; CRLF line endings are accepted.

func ParseFile

func ParseFile(path string) (Skill, string, error)

ParseFile reads and parses one SKILL.md.

type SkippedSkill

type SkippedSkill struct {
	Path string
	Err  string
}

SkippedSkill is a SKILL.md that was found but not registered, with the reason (a parse or validation error).

Jump to

Keyboard shortcuts

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