Documentation
¶
Overview ¶
Package skill provides skill loading and management for LiteClaw.
Index ¶
- Constants
- func BuildSkillsPrompt(skills []*Skill) string
- func GetSkillSummary(skill *Skill) string
- func ReadSkillContent(filePath string) (string, error)
- func RemoveSkill(managedDir, slug string) error
- func SaveLockFile(managedDir string, lockFile *LockFile) error
- type ClawdbotMetadata
- type HubClient
- type HubSearchResult
- type HubSkill
- type HubSkillSummary
- type InstallOpt
- type LockFile
- type LockFileEntry
- type Requires
- type Skill
- type SkillSource
- type SkillStatus
Constants ¶
const ( // DefaultHubRegistry is the default ClawdHub registry URL. DefaultHubRegistry = "https://clawhub.ai" // HubTimeout is the default timeout for hub API requests. HubTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func BuildSkillsPrompt ¶
BuildSkillsPrompt builds the skills prompt for the agent.
func GetSkillSummary ¶
GetSkillSummary returns a brief summary for a skill.
func ReadSkillContent ¶
ReadSkillContent reads the full content of a SKILL.md file.
func RemoveSkill ¶
RemoveSkill removes an installed skill.
func SaveLockFile ¶
SaveLockFile saves the lock file after an install/update.
Types ¶
type ClawdbotMetadata ¶
type ClawdbotMetadata struct {
Emoji string `json:"emoji,omitempty"`
SkillKey string `json:"skillKey,omitempty"`
PrimaryEnv string `json:"primaryEnv,omitempty"`
Homepage string `json:"homepage,omitempty"`
Always bool `json:"always,omitempty"`
OS []string `json:"os,omitempty"`
Requires *Requires `json:"requires,omitempty"`
Install []InstallOpt `json:"install,omitempty"`
}
ClawdbotMetadata represents the clawdbot-specific metadata in skills.
func ParseMetadataJSON ¶
func ParseMetadataJSON(raw string) (*ClawdbotMetadata, error)
ParseMetadataJSON parses the metadata JSON from frontmatter.
type HubClient ¶
HubClient provides methods to interact with ClawdHub registry.
func NewHubClient ¶
NewHubClient creates a new ClawdHub client.
func (*HubClient) Download ¶
func (h *HubClient) Download(ctx context.Context, slug string, version string, targetDir string) error
Download downloads a skill from ClawdHub using v1 API.
func (*HubClient) GetSkillInfo ¶
GetSkillInfo gets detailed information about a skill using v1 API.
type HubSearchResult ¶
type HubSearchResult struct {
Skills []HubSkillSummary `json:"skills"`
Total int `json:"total"`
}
HubSearchResult represents search results from ClawdHub.
type HubSkill ¶
type HubSkill struct {
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
Author string `json:"author,omitempty"`
Version string `json:"version"`
Downloads int `json:"downloads,omitempty"`
Stars int `json:"stars,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
}
HubSkill represents a skill from ClawdHub registry.
type HubSkillSummary ¶
type HubSkillSummary struct {
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
}
HubSkillSummary represents a summary of a skill from search results.
type InstallOpt ¶
type InstallOpt struct {
ID string `json:"id,omitempty"`
Kind string `json:"kind"` // brew, node, go, uv, download
Formula string `json:"formula,omitempty"`
Package string `json:"package,omitempty"`
Module string `json:"module,omitempty"`
URL string `json:"url,omitempty"`
Bins []string `json:"bins,omitempty"`
Label string `json:"label,omitempty"`
OS []string `json:"os,omitempty"`
}
InstallOpt describes an installation option for missing dependencies.
type LockFile ¶
type LockFile struct {
Skills map[string]LockFileEntry `json:"skills"`
UpdateAt time.Time `json:"updatedAt"`
}
LockFile represents the .liteclaw/skills.lock.json file.
func LoadLockFile ¶
LoadLockFile loads the lock file.
type LockFileEntry ¶
type LockFileEntry struct {
Slug string `json:"slug"`
Version string `json:"version"`
Hash string `json:"hash"`
UpdatedAt time.Time `json:"updatedAt"`
}
LockFileEntry represents an entry in the skill lock file.
func ListInstalled ¶
func ListInstalled(managedDir string) ([]LockFileEntry, error)
ListInstalled lists installed skills from the managed directory.
type Requires ¶
type Requires struct {
Bins []string `json:"bins,omitempty"`
AnyBins []string `json:"anyBins,omitempty"`
Env []string `json:"env,omitempty"`
Config []string `json:"config,omitempty"`
}
Requires specifies skill requirements.
type Skill ¶
type Skill struct {
Name string `json:"name"`
Description string `json:"description"`
Homepage string `json:"homepage,omitempty"`
Emoji string `json:"emoji,omitempty"`
Author string `json:"author,omitempty"`
Version string `json:"version,omitempty"`
Metadata *ClawdbotMetadata `json:"metadata,omitempty"`
Source SkillSource `json:"source"`
BaseDir string `json:"baseDir"`
FilePath string `json:"filePath"`
Content string `json:"-"` // Full SKILL.md content (not serialized)
}
Skill represents a loaded skill from SKILL.md.
func LoadAllSkills ¶
LoadAllSkills loads skills from all configured directories.
func LoadFromDir ¶
func LoadFromDir(dir string, source SkillSource) ([]*Skill, error)
LoadFromDir loads all skills from a directory.
func LoadSkillFile ¶
func LoadSkillFile(filePath string, source SkillSource, baseDir string) (*Skill, error)
LoadSkillFile loads a skill from a SKILL.md file.
type SkillSource ¶
type SkillSource string
SkillSource indicates where the skill was loaded from.
const ( SourceBundled SkillSource = "bundled" SourceWorkspace SkillSource = "workspace" SourceManaged SkillSource = "managed" )
type SkillStatus ¶
type SkillStatus struct {
Skill *Skill `json:"skill"`
Eligible bool `json:"eligible"`
Disabled bool `json:"disabled"`
MissingBins []string `json:"missingBins,omitempty"`
MissingEnv []string `json:"missingEnv,omitempty"`
UnsupportedOS bool `json:"unsupportedOS,omitempty"`
InstallOptions []string `json:"installOptions,omitempty"`
}
SkillStatus represents the eligibility status of a skill.
func CheckEligibility ¶
func CheckEligibility(skill *Skill) *SkillStatus
CheckEligibility checks if a skill is eligible to be used.