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 ¶
- func LoadFS(reg *Registry, fsys fs.FS, root string) error
- func ResolveWorkspacePath(workspaceRoot, relative string) (string, error)
- func ScopePrecedence(scope string) int
- type Diagnostic
- type LoadOptions
- type LoadReport
- type Registry
- func (r *Registry) All() []*Skill
- func (r *Registry) AllIDs() []string
- func (r *Registry) AssembleContext(skillIDs []string) string
- func (r *Registry) AssembleContextBudget(skillIDs []string, maxTokens int) (string, []string, []string)
- func (r *Registry) Get(id string) (*Skill, bool)
- func (r *Registry) GetByCategory(category string) []*Skill
- func (r *Registry) GetMultiple(ids []string) []*Skill
- func (r *Registry) GetReference(skillID, refName string) (string, bool)
- func (r *Registry) Register(s *Skill)
- func (r *Registry) Status() RegistryStatus
- func (r *Registry) Visible(snapshot policy.Snapshot) []*Skill
- type RegistryStatus
- type Skill
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFS ¶
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 ¶
ResolveWorkspacePath resolves a workspace-relative skills path without allowing absolute paths or traversal outside the admitted root.
func ScopePrecedence ¶
ScopePrecedence derives deterministic override order. Explicit frontmatter precedence remains available for hosts with a more specific policy.
Types ¶
type Diagnostic ¶
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 (*Registry) AssembleContext ¶
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) GetByCategory ¶
GetByCategory returns all skills in a category.
func (*Registry) GetMultiple ¶
GetMultiple fetches multiple skills by ID. Missing IDs are silently skipped.
func (*Registry) GetReference ¶
GetReference returns a named reference document attached to a skill.
func (*Registry) Register ¶
Register adds a skill (overwriting any existing entry with the same ID).
func (*Registry) Status ¶
func (r *Registry) Status() RegistryStatus
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 ¶
FormatForPrompt renders the skill as a labeled block for prompt injection.
func (*Skill) ReferenceNames ¶
ReferenceNames returns the sorted list of reference document names.
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. |