skill

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package skill provides skill loading and management for LiteClaw.

Index

Constants

View Source
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

func BuildSkillsPrompt(skills []*Skill) string

BuildSkillsPrompt builds the skills prompt for the agent.

func GetSkillSummary

func GetSkillSummary(skill *Skill) string

GetSkillSummary returns a brief summary for a skill.

func ReadSkillContent

func ReadSkillContent(filePath string) (string, error)

ReadSkillContent reads the full content of a SKILL.md file.

func RemoveSkill

func RemoveSkill(managedDir, slug string) error

RemoveSkill removes an installed skill.

func SaveLockFile

func SaveLockFile(managedDir string, lockFile *LockFile) error

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

type HubClient struct {
	Registry   string
	HTTPClient *http.Client
}

HubClient provides methods to interact with ClawdHub registry.

func NewHubClient

func NewHubClient(registry string) *HubClient

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

func (h *HubClient) GetSkillInfo(ctx context.Context, slug string) (*HubSkill, error)

GetSkillInfo gets detailed information about a skill using v1 API.

func (*HubClient) Search

func (h *HubClient) Search(ctx context.Context, query string, limit int) (*HubSearchResult, error)

Search searches for skills on ClawdHub 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

func LoadLockFile(managedDir string) (*LockFile, error)

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

func LoadAllSkills(bundledDir, managedDir, workspaceDir string) ([]*Skill, error)

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.

Jump to

Keyboard shortcuts

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