Documentation
¶
Overview ¶
Package loader provides skill loaders for different formats.
Loaders convert external skill definitions (SKILL.md, OpenAPI, etc.) into the standard skill.Skill interface, enabling "define once, deploy everywhere" across different skill formats.
Index ¶
- Constants
- type DiscoveredCommand
- type ExtendedMetadata
- type GoSkillConstructor
- type GoSkillRegistry
- type InstallStep
- type MarkdownSkill
- func (s *MarkdownSkill) Close() error
- func (s *MarkdownSkill) Description() string
- func (s *MarkdownSkill) GetGuidance() string
- func (s *MarkdownSkill) GetInstallSteps() []InstallStep
- func (s *MarkdownSkill) Init(ctx context.Context) error
- func (s *MarkdownSkill) Name() string
- func (s *MarkdownSkill) Tools() []skill.Tool
- type OpenClawMetadata
- type Requirements
- type SkillFormat
- type SkillInfo
- type SkillMetadata
- type SkillType
- type UnifiedLoader
- func (l *UnifiedLoader) Load(dir string) (skill.Skill, SkillFormat, error)
- func (l *UnifiedLoader) LoadAll(root string) ([]skill.Skill, error)
- func (l *UnifiedLoader) LoadInfo(info *SkillInfo) (skill.Skill, SkillFormat, error)
- func (l *UnifiedLoader) RegisterGo(name string, constructor GoSkillConstructor)
Constants ¶
const ( // SkillMDFile is the standard name for markdown skill definitions. SkillMDFile = "SKILL.md" // SkillGoFile is the standard name for Go skill implementations. SkillGoFile = "skill.go" )
Standard file names for skill definitions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoveredCommand ¶
type DiscoveredCommand struct {
// Command is the executable name.
Command string
// Args are the command arguments.
Args []string
// FullLine is the complete command line.
FullLine string
// Description is extracted from surrounding context.
Description string
}
DiscoveredCommand represents a command found in markdown code blocks.
type ExtendedMetadata ¶
type ExtendedMetadata struct {
// OpenClaw contains OpenClaw-specific metadata.
OpenClaw *OpenClawMetadata `yaml:"openclaw" json:"openclaw,omitempty"`
}
ExtendedMetadata contains provider-specific metadata.
type GoSkillConstructor ¶
GoSkillConstructor is a function that creates a Go skill instance.
type GoSkillRegistry ¶
type GoSkillRegistry struct {
// contains filtered or unexported fields
}
GoSkillRegistry allows registration of Go skill constructors by name. This enables loading Go skills dynamically by directory name.
func NewGoSkillRegistry ¶
func NewGoSkillRegistry() *GoSkillRegistry
NewGoSkillRegistry creates a new Go skill registry.
func (*GoSkillRegistry) Get ¶
func (r *GoSkillRegistry) Get(name string) (skill.Skill, error)
Get returns a new instance of the Go skill with the given name.
func (*GoSkillRegistry) Has ¶
func (r *GoSkillRegistry) Has(name string) bool
Has returns true if a Go skill is registered with the given name.
func (*GoSkillRegistry) List ¶
func (r *GoSkillRegistry) List() []string
List returns all registered Go skill names.
func (*GoSkillRegistry) Register ¶
func (r *GoSkillRegistry) Register(name string, constructor GoSkillConstructor)
Register adds a Go skill constructor for a given name.
type InstallStep ¶
type InstallStep struct {
// Kind is the installation method: "go", "npm", "pip", "docker", etc.
Kind string `yaml:"kind" json:"kind"`
// Module is the package/module identifier.
// For Go: github.com/user/pkg@version
// For npm: package-name@version
Module string `yaml:"module" json:"module"`
// Bins lists the binaries installed by this step.
Bins []string `yaml:"bins" json:"bins,omitempty"`
// Script is an optional post-install script.
Script string `yaml:"script" json:"script,omitempty"`
}
InstallStep describes how to install a dependency.
type MarkdownSkill ¶
type MarkdownSkill struct {
// Metadata from YAML frontmatter.
Metadata SkillMetadata
// Guidance is the full markdown body (for AI context).
Guidance string
// Commands are discovered from code blocks.
Commands []DiscoveredCommand
// SourcePath is the SKILL.md file path.
SourcePath string
// contains filtered or unexported fields
}
MarkdownSkill implements skill.Skill for SKILL.md definitions.
MarkdownSkill parses OpenClaw-format SKILL.md files and exposes them as standard skills. The markdown content serves as guidance for AI agents, while discovered commands become callable Tools.
Example SKILL.md format:
---
name: notcrawl
description: "Notion archive search and sync"
metadata:
openclaw:
requires:
bins: [notcrawl]
install:
- kind: go
module: github.com/user/notcrawl@latest
---
# Usage
```bash
notcrawl search "query"
```
func LoadMarkdownSkill ¶
func LoadMarkdownSkill(path string) (*MarkdownSkill, error)
LoadMarkdownSkill loads a skill from a SKILL.md file.
func LoadMarkdownSkillDir ¶
func LoadMarkdownSkillDir(dir string) (*MarkdownSkill, error)
LoadMarkdownSkillDir loads a skill from a directory containing SKILL.md.
func ParseMarkdownSkill ¶
func ParseMarkdownSkill(content, sourcePath string) (*MarkdownSkill, error)
ParseMarkdownSkill parses a SKILL.md content string.
func (*MarkdownSkill) Description ¶
func (s *MarkdownSkill) Description() string
Description returns the skill description.
func (*MarkdownSkill) GetGuidance ¶
func (s *MarkdownSkill) GetGuidance() string
GetGuidance returns the full markdown guidance for AI context.
func (*MarkdownSkill) GetInstallSteps ¶
func (s *MarkdownSkill) GetInstallSteps() []InstallStep
GetInstallSteps returns the installation instructions.
func (*MarkdownSkill) Init ¶
func (s *MarkdownSkill) Init(ctx context.Context) error
Init initializes the skill.
func (*MarkdownSkill) Tools ¶
func (s *MarkdownSkill) Tools() []skill.Tool
Tools returns the tools discovered from the skill.
type OpenClawMetadata ¶
type OpenClawMetadata struct {
// Homepage is the project homepage URL.
Homepage string `yaml:"homepage" json:"homepage,omitempty"`
// Requires lists the skill's requirements.
Requires *Requirements `yaml:"requires" json:"requires,omitempty"`
// Install contains installation instructions.
Install []InstallStep `yaml:"install" json:"install,omitempty"`
}
OpenClawMetadata contains OpenClaw SKILL.md specific metadata.
type Requirements ¶
type Requirements struct {
// Bins lists required binary executables.
Bins []string `yaml:"bins" json:"bins,omitempty"`
}
Requirements lists what a skill needs to function.
type SkillFormat ¶
type SkillFormat string
SkillFormat represents the format of a skill definition.
const ( // FormatMarkdown is an OpenClaw SKILL.md definition. FormatMarkdown SkillFormat = "markdown" // FormatGo is a native Go skill implementation. FormatGo SkillFormat = "go" )
type SkillInfo ¶
type SkillInfo struct {
// Dir is the skill directory path.
Dir string
// Name is the skill name (from directory name or SKILL.md).
Name string
// Formats lists the available formats for this skill.
Formats []SkillFormat
// MarkdownPath is the path to SKILL.md if present.
MarkdownPath string
// GoPath is the path to skill.go if present.
GoPath string
// Metadata is parsed from SKILL.md frontmatter if available.
Metadata *SkillMetadata
}
SkillInfo contains metadata about a skill found in a directory.
func DiscoverSkills ¶
DiscoverSkills finds all skill directories under a root path.
func (*SkillInfo) HasMarkdown ¶
HasMarkdown returns true if a SKILL.md file exists.
func (*SkillInfo) LoadMarkdown ¶
func (i *SkillInfo) LoadMarkdown() (*MarkdownSkill, error)
LoadMarkdown loads the SKILL.md from a skill directory. Returns an error if no SKILL.md exists.
type SkillMetadata ¶
type SkillMetadata struct {
// Name is the skill identifier.
Name string `yaml:"name" json:"name"`
// Description is a human-readable description.
Description string `yaml:"description" json:"description"`
// Metadata contains extended metadata.
Metadata ExtendedMetadata `yaml:"metadata" json:"metadata"`
}
SkillMetadata contains metadata about a skill definition.
type SkillType ¶
type SkillType string
SkillType identifies the type of skill definition.
const ( // SkillTypeNativeGo is a compiled Go skill. SkillTypeNativeGo SkillType = "native_go" // SkillTypeMarkdown is a SKILL.md markdown skill. SkillTypeMarkdown SkillType = "markdown" // SkillTypeMCPServer is an MCP server skill. SkillTypeMCPServer SkillType = "mcp_server" // SkillTypeOpenAPI is an OpenAPI-defined skill. SkillTypeOpenAPI SkillType = "openapi" )
type UnifiedLoader ¶
type UnifiedLoader struct {
// contains filtered or unexported fields
}
UnifiedLoader loads skills from directories, preferring Go implementations when available but falling back to SKILL.md.
func NewUnifiedLoader ¶
func NewUnifiedLoader() *UnifiedLoader
NewUnifiedLoader creates a new unified loader.
func (*UnifiedLoader) Load ¶
func (l *UnifiedLoader) Load(dir string) (skill.Skill, SkillFormat, error)
Load loads a skill from a directory, preferring Go over SKILL.md.
func (*UnifiedLoader) LoadAll ¶
func (l *UnifiedLoader) LoadAll(root string) ([]skill.Skill, error)
LoadAll loads all skills from a directory.
func (*UnifiedLoader) LoadInfo ¶
func (l *UnifiedLoader) LoadInfo(info *SkillInfo) (skill.Skill, SkillFormat, error)
LoadInfo loads a skill from SkillInfo, preferring Go over SKILL.md.
func (*UnifiedLoader) RegisterGo ¶
func (l *UnifiedLoader) RegisterGo(name string, constructor GoSkillConstructor)
RegisterGo registers a Go skill constructor.