skills

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 9 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 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) All added in v0.7.0

func (m *Manager) All() []*Skill

All returns all loaded skills.

func (*Manager) Available added in v0.7.0

func (m *Manager) Available() []*Skill

Available returns skills that have all requirements met.

func (*Manager) AvailableCount added in v0.7.0

func (m *Manager) AvailableCount() int

AvailableCount returns the number of available skills.

func (*Manager) Count added in v0.7.0

func (m *Manager) Count() int

Count returns the total number of loaded skills.

func (*Manager) Get added in v0.7.0

func (m *Manager) Get(name string) *Skill

Get returns a skill by name, or nil if not found.

func (*Manager) Load added in v0.7.0

func (m *Manager) Load() error

Load discovers and loads skills from all configured sources. Skills from directories override embedded skills with the same name. Includes/excludes filters are applied after loading.

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
	Secrets []SecretRequirement `json:"secrets,omitempty"` // Declared secrets (INIT-OMNIAGENT-004)
}

Requires specifies skill prerequisites.

type SecretRequirement added in v0.18.0

type SecretRequirement struct {
	// Name is the logical secret name (e.g. "GITHUB_TOKEN"). Shown in the UI.
	Name string `json:"name"`
	// Description is a human-readable hint shown alongside the input.
	Description string `json:"description,omitempty"`
	// Required gates skill availability: an unresolved required secret marks
	// the skill unavailable with an actionable message.
	Required bool `json:"required,omitempty"`
	// Env is the environment variable the value is injected as; defaults to
	// Name when empty.
	Env string `json:"env,omitempty"`
}

SecretRequirement is a secret a skill declares it needs, GitHub-Actions style. Declaration is the allowlist: a skill can only ever be injected with secrets it declares here. The value is bound out-of-band (operator config or the agent Secrets UI) and injected as an environment variable.

func (SecretRequirement) EnvVar added in v0.18.0

func (r SecretRequirement) EnvVar() string

EnvVar returns the environment variable the secret is injected as, defaulting to Name when Env is unset.

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

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

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

func DiscoverFromFS added in v0.7.0

func DiscoverFromFS(fsys fs.FS, seen map[string]bool) ([]*Skill, error)

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

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) DeclaredSecrets added in v0.18.0

func (s *Skill) DeclaredSecrets() []SecretRequirement

DeclaredSecrets returns the secrets a skill declares in its SKILL.md frontmatter, or nil when it declares none.

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.

func (*Skill) UnmetRequiredSecrets added in v0.18.0

func (s *Skill) UnmetRequiredSecrets(available map[string]string) []*RequirementError

UnmetRequiredSecrets returns the declared secrets a skill marks required whose env-var name is absent from available (the resolved secret env, e.g. an agent's set secrets), with an actionable message per entry. A skill with unmet required secrets should be treated as unavailable — running it would hit the API with a missing credential (INIT-OMNIAGENT-004). Optional (non-required) declared secrets never gate availability.

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.
Package github provides a compiled skill for GitHub operations.
Package github provides a compiled skill for GitHub operations.
Package memory provides a compiled skill for semantic memory operations.
Package memory provides a compiled skill for semantic memory operations.
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.
Package web provides a compiled skill for web content extraction and analysis.
Package web provides a compiled skill for web content extraction and analysis.

Jump to

Keyboard shortcuts

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