skills

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package skills provides OpenClaw/ClawHub skill loading and management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSearchPaths

func DefaultSearchPaths() []string

DefaultSearchPaths returns the default skill directories to search.

func InjectIntoPrompt

func InjectIntoPrompt(systemPrompt string, skills []*Skill, cfg InjectConfig) string

InjectIntoPrompt appends skill content to the system prompt. Skills with missing requirements are skipped unless IncludeDisabled is true.

Types

type InjectConfig

type InjectConfig struct {
	MaxSkills       int    // Maximum skills to inject (0 = unlimited)
	IncludeDisabled bool   // Include skills with missing requirements
	Separator       string // Separator between skills
}

InjectConfig controls how skills are injected into prompts.

func DefaultInjectConfig

func DefaultInjectConfig() InjectConfig

DefaultInjectConfig returns sensible defaults.

type Installer

type Installer struct {
	ID      string   `json:"id"`
	Kind    string   `json:"kind"`              // brew, apt, go, npm, etc.
	Formula string   `json:"formula,omitempty"` // For brew
	Package string   `json:"package,omitempty"` // For apt
	Module  string   `json:"module,omitempty"`  // For go install
	Bins    []string `json:"bins,omitempty"`    // Binaries provided
	Label   string   `json:"label,omitempty"`   // Human-readable label
}

Installer specifies how to install a dependency.

type OpenClawMeta

type OpenClawMeta struct {
	Emoji    string      `json:"emoji,omitempty"`
	Requires *Requires   `json:"requires,omitempty"`
	Install  []Installer `json:"install,omitempty"`
	Always   bool        `json:"always,omitempty"`
}

OpenClawMeta is the openclaw-specific metadata block.

type RequirementError

type RequirementError struct {
	Type    string      // "binary" or "env"
	Name    string      // Name of the missing requirement
	Skill   string      // Skill that requires it
	Install []Installer // How to fix (for binaries)
}

RequirementError describes a missing requirement.

func (*RequirementError) Error

func (e *RequirementError) Error() string

func (*RequirementError) InstallHint

func (e *RequirementError) InstallHint() string

InstallHint returns a human-readable install suggestion.

type Requires

type Requires struct {
	Bins    []string `json:"bins,omitempty"`    // Required binaries on PATH
	AnyBins []string `json:"anyBins,omitempty"` // At least one required
	Env     []string `json:"env,omitempty"`     // Required environment variables
}

Requires specifies skill prerequisites.

type Skill

type Skill struct {
	// From YAML frontmatter
	Name        string    `yaml:"name"`
	Description string    `yaml:"description"`
	Homepage    string    `yaml:"homepage,omitempty"`
	Metadata    SkillMeta `yaml:"metadata"`

	// Parsed from file
	Content    string `yaml:"-"` // Markdown body
	Path       string `yaml:"-"` // Directory path
	HasHooks   bool   `yaml:"-"` // Has hooks/ directory
	HasScripts bool   `yaml:"-"` // Has scripts/ directory
}

Skill represents a loaded SKILL.md file.

func Discover

func Discover(dirs []string) ([]*Skill, error)

Discover finds all skills in the given directories. Skills are deduplicated by name (first occurrence wins).

func ExcludeByName

func ExcludeByName(skills []*Skill, names []string) []*Skill

ExcludeByName returns skills not matching any of the given names.

func FilterAvailable

func FilterAvailable(skills []*Skill) []*Skill

FilterAvailable returns only skills that have all requirements met.

func FilterByName

func FilterByName(skills []*Skill, names []string) []*Skill

FilterByName returns skills matching any of the given names.

func Load

func Load(skillDir string) (*Skill, error)

Load parses a single skill from its directory.

func Parse

func Parse(content string) (*Skill, error)

Parse extracts skill data from SKILL.md content.

func (*Skill) CheckRequirements

func (s *Skill) CheckRequirements() []error

CheckRequirements verifies all skill prerequisites. Returns a slice of errors for missing requirements.

func (*Skill) Emoji

func (s *Skill) Emoji() string

Emoji returns the skill's emoji or empty string.

func (*Skill) IsAvailable

func (s *Skill) IsAvailable() bool

IsAvailable returns true if all requirements are met.

type SkillMeta

type SkillMeta struct {
	OpenClaw *OpenClawMeta `json:"openclaw,omitempty"`
}

SkillMeta contains platform-specific metadata.

Jump to

Keyboard shortcuts

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