skills

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package skills holds the domain-knowledge primitives used by experts.

A Skill is a Markdown body with a YAML frontmatter header describing its id, name, description, category, and priority. Skills may optionally include sibling "references" — named Markdown files the LLM can pull on demand via the load_reference tool.

Skill content is typically embedded into the consumer's binary with Go's embed directive and loaded into a Registry at startup using LoadFS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFS

func LoadFS(reg *Registry, fsys fs.FS, root string) error

LoadFS scans `root` inside fsys for `<slug>/SKILL.md` (or the lowercase `<slug>/skill.md`) entries and parses each into a Skill. Reference files live under `<slug>/references/*.md` and become entries in Skill.References keyed by their basename (without .md).

`SKILL.md` is the casing used by Anthropic's public Agent Skills spec (anthropics/skills) and is the preferred name for new skills; `skill.md` is kept for backwards compatibility with older content.

Missing references directories are not errors; malformed frontmatter is.

Typical usage from a consumer:

//go:embed all:content
var skillFS embed.FS

reg := skills.NewRegistry()
if err := skills.LoadFS(reg, skillFS, "content"); err != nil { ... }

func ResolveWorkspacePath

func ResolveWorkspacePath(workspaceRoot, relative string) (string, error)

ResolveWorkspacePath resolves a workspace-relative skills path without allowing absolute paths or traversal outside the admitted root.

func ScopePrecedence

func ScopePrecedence(scope string) int

ScopePrecedence derives deterministic override order. Explicit frontmatter precedence remains available for hosts with a more specific policy.

Types

type Diagnostic

type Diagnostic struct {
	Path  string
	Error string
}

Diagnostic records a quarantined skill that was not activated.

type LoadOptions

type LoadOptions struct {
	ContinueOnError bool
	MaxSkillBytes   int
	MaxTotalBytes   int
	OnDiagnostic    func(Diagnostic)
}

LoadOptions controls bounded, partial skill discovery.

type LoadReport

type LoadReport struct {
	Loaded      []string
	Quarantined []Diagnostic
	TotalBytes  int
}

LoadReport summarizes one discovery pass.

func LoadFSWithOptions

func LoadFSWithOptions(reg *Registry, fsys fs.FS, root string, opts LoadOptions) (LoadReport, error)

LoadFSWithOptions can quarantine malformed entries and continue. Strict LoadFS behavior remains the default when ContinueOnError is false.

type Registry

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

Registry holds registered skills.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty Registry.

func (*Registry) All

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

All returns every registered skill, sorted by priority ascending.

func (*Registry) AllIDs

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

AllIDs returns every registered skill ID.

func (*Registry) AssembleContext

func (r *Registry) AssembleContext(skillIDs []string) string

AssembleContext concatenates the formatted bodies of the named skills, sorted by priority, into a single prompt-ready block.

func (*Registry) AssembleContextBudget

func (r *Registry) AssembleContextBudget(skillIDs []string, maxTokens int) (string, []string, []string)

AssembleContextBudget renders skills in deterministic priority/ID order up to maxTokens. A non-positive budget is unlimited. Loaded and omitted IDs let hosts expose an honest prompt manifest and offer omitted skills through load_skill on demand.

func (*Registry) Get

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

Get fetches a skill by ID.

func (*Registry) GetByCategory

func (r *Registry) GetByCategory(category string) []*Skill

GetByCategory returns all skills in a category.

func (*Registry) GetMultiple

func (r *Registry) GetMultiple(ids []string) []*Skill

GetMultiple fetches multiple skills by ID. Missing IDs are silently skipped.

func (*Registry) GetReference

func (r *Registry) GetReference(skillID, refName string) (string, bool)

GetReference returns a named reference document attached to a skill.

func (*Registry) Register

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

Register adds a skill (overwriting any existing entry with the same ID).

func (*Registry) Status

func (r *Registry) Status() RegistryStatus

func (*Registry) Visible

func (r *Registry) Visible(snapshot policy.Snapshot) []*Skill

Visible returns only skills allowed by the admitted policy snapshot.

type RegistryStatus

type RegistryStatus struct {
	Generation  uint64       `json:"generation"`
	SkillCount  int          `json:"skill_count"`
	UpdatedAt   time.Time    `json:"updated_at"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}

type Skill

type Skill struct {
	ID            string
	Name          string
	Description   string
	Category      string
	Scope         string
	Source        string
	Trust         string
	Digest        string
	SchemaVersion int
	Precedence    int
	Priority      int
	// TokenEstimate is an optional author-supplied prompt cost. When zero, the
	// registry estimates cost from the rendered content.
	TokenEstimate int
	Content       string
	References    map[string]string
}

Skill is a single domain-knowledge module.

func (*Skill) FormatForPrompt

func (s *Skill) FormatForPrompt() string

FormatForPrompt renders the skill as a labeled block for prompt injection.

func (*Skill) ReferenceNames

func (s *Skill) ReferenceNames() []string

ReferenceNames returns the sorted list of reference document names.

type Watcher

type Watcher interface {
	Changes() <-chan struct{}
	Close() error
}

Watcher lets hosts connect filesystem or registry notifications without prescribing a platform-specific watch implementation.

Directories

Path Synopsis
cmd
check-content command
Quick sanity check: load all SKILL.md files under skills/content and print id, name, category, priority.
Quick sanity check: load all SKILL.md files under skills/content and print id, name, category, priority.

Jump to

Keyboard shortcuts

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