Documentation
¶
Overview ¶
Package skills provides OpenClaw/ClawHub skill loading and management.
Index ¶
- func DefaultSearchPaths() []string
- func InjectIntoPrompt(systemPrompt string, skills []*Skill, cfg InjectConfig) string
- type InjectConfig
- type Installer
- type Manager
- type ManagerConfig
- type OpenClawMeta
- type RequirementError
- type Requires
- type Skill
- func Discover(dirs []string) ([]*Skill, error)
- func DiscoverFromFS(fsys fs.FS, seen map[string]bool) ([]*Skill, error)
- func ExcludeByName(skills []*Skill, names []string) []*Skill
- func FilterAvailable(skills []*Skill) []*Skill
- func FilterByName(skills []*Skill, names []string) []*Skill
- func Load(skillDir string) (*Skill, error)
- func Parse(content string) (*Skill, error)
- type SkillMeta
- type SkillSource
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 Manager ¶ added in v0.7.0
type Manager struct {
// contains filtered or unexported fields
}
Manager handles loading and managing skills from multiple sources.
func NewManager ¶ added in v0.7.0
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new skill manager with the given configuration.
func (*Manager) Available ¶ added in v0.7.0
Available returns skills that have all requirements met.
func (*Manager) AvailableCount ¶ added in v0.7.0
AvailableCount returns the number of available skills.
type ManagerConfig ¶ added in v0.7.0
type ManagerConfig struct {
// Packs are embedded skill packs to load.
Packs []fs.FS
// Dirs are filesystem directories to search for skills.
// Directory skills override embedded skills with the same name.
Dirs []string
// Includes limits loaded skills to only these names.
// If empty, all skills are included.
Includes []string
// Excludes prevents these skills from being loaded.
// Applied after includes.
Excludes []string
}
ManagerConfig configures the skill manager.
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 (empty if embedded)
Source SkillSource `yaml:"-"` // Where the skill was loaded from
HasHooks bool `yaml:"-"` // Has hooks/ directory
HasScripts bool `yaml:"-"` // Has scripts/ directory
}
Skill represents a loaded SKILL.md file.
func Discover ¶
Discover finds all skills in the given directories. Skills are deduplicated by name (first occurrence wins).
func DiscoverFromFS ¶ added in v0.7.0
DiscoverFromFS finds all skills in an embedded filesystem. Skills are expected at skills/<name>/SKILL.md. The seen map is used to track already-loaded skills for deduplication.
func ExcludeByName ¶
ExcludeByName returns skills not matching any of the given names.
func FilterAvailable ¶
FilterAvailable returns only skills that have all requirements met.
func FilterByName ¶
FilterByName returns skills matching any of the given names.
func (*Skill) CheckRequirements ¶
CheckRequirements verifies all skill prerequisites. Returns a slice of errors for missing requirements.
func (*Skill) IsAvailable ¶
IsAvailable returns true if all requirements are met.
type SkillMeta ¶
type SkillMeta struct {
OpenClaw *OpenClawMeta `json:"openclaw,omitempty"`
}
SkillMeta contains platform-specific metadata.
type SkillSource ¶ added in v0.7.0
type SkillSource string
SkillSource indicates where a skill was loaded from.
const ( // SourceDirectory indicates the skill was loaded from a filesystem directory. SourceDirectory SkillSource = "directory" // SourceEmbedded indicates the skill was loaded from an embedded skill pack. SourceEmbedded SkillSource = "embedded" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compiled provides interfaces for compiled Go skills.
|
Package compiled provides interfaces for compiled Go skills. |
|
remote
|
|
|
mcp
Package mcp provides a compiled.Skill implementation that wraps an MCP server.
|
Package mcp provides a compiled.Skill implementation that wraps an MCP server. |
|
openapi
Package openapi provides a compiled.Skill implementation that wraps an OpenAPI spec.
|
Package openapi provides a compiled.Skill implementation that wraps an OpenAPI spec. |