skills

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNameLength        = 64
	MaxDescriptionLength = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClawHubConfig added in v0.2.0

type ClawHubConfig struct {
	Enabled         bool
	BaseURL         string
	AuthToken       string
	SearchPath      string // e.g. "/api/v1/search"
	SkillsPath      string // e.g. "/api/v1/skills"
	DownloadPath    string // e.g. "/api/v1/download"
	Timeout         int    // seconds, 0 = default (30s)
	MaxZipSize      int    // bytes, 0 = default (50MB)
	MaxResponseSize int    // bytes, 0 = default (2MB)
}

ClawHubConfig configures the ClawHub registry.

type ClawHubRegistry added in v0.2.0

type ClawHubRegistry struct {
	// contains filtered or unexported fields
}

ClawHubRegistry implements SkillRegistry for the ClawHub platform.

func NewClawHubRegistry added in v0.2.0

func NewClawHubRegistry(cfg ClawHubConfig) *ClawHubRegistry

NewClawHubRegistry creates a new ClawHub registry client from config.

func (*ClawHubRegistry) DownloadAndInstall added in v0.2.0

func (c *ClawHubRegistry) DownloadAndInstall(
	ctx context.Context,
	slug, version, targetDir string,
) (*InstallResult, error)

DownloadAndInstall fetches metadata (with fallback), resolves version, downloads the skill ZIP, and extracts it to targetDir. Returns an InstallResult for the caller to use for moderation decisions.

func (*ClawHubRegistry) GetSkillMeta added in v0.2.0

func (c *ClawHubRegistry) GetSkillMeta(ctx context.Context, slug string) (*SkillMeta, error)

func (*ClawHubRegistry) Name added in v0.2.0

func (c *ClawHubRegistry) Name() string

func (*ClawHubRegistry) Search added in v0.2.0

func (c *ClawHubRegistry) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)

type InstallResult added in v0.2.0

type InstallResult struct {
	Version          string
	IsMalwareBlocked bool
	IsSuspicious     bool
	Summary          string
}

InstallResult is returned by DownloadAndInstall to carry metadata back to the caller for moderation and user messaging.

type RegistryConfig added in v0.2.0

type RegistryConfig struct {
	ClawHub               ClawHubConfig
	MaxConcurrentSearches int
}

RegistryConfig holds configuration for all skill registries. This is the input to NewRegistryManagerFromConfig.

type RegistryManager added in v0.2.0

type RegistryManager struct {
	// contains filtered or unexported fields
}

RegistryManager coordinates multiple skill registries. It fans out search requests and routes installs to the correct registry.

func NewRegistryManager added in v0.2.0

func NewRegistryManager() *RegistryManager

NewRegistryManager creates an empty RegistryManager.

func NewRegistryManagerFromConfig added in v0.2.0

func NewRegistryManagerFromConfig(cfg RegistryConfig) *RegistryManager

NewRegistryManagerFromConfig builds a RegistryManager from config, instantiating only the enabled registries.

func (*RegistryManager) AddRegistry added in v0.2.0

func (rm *RegistryManager) AddRegistry(r SkillRegistry)

AddRegistry adds a registry to the manager.

func (*RegistryManager) GetRegistry added in v0.2.0

func (rm *RegistryManager) GetRegistry(name string) SkillRegistry

GetRegistry returns a registry by name, or nil if not found.

func (*RegistryManager) SearchAll added in v0.2.0

func (rm *RegistryManager) SearchAll(ctx context.Context, query string, limit int) ([]SearchResult, error)

SearchAll fans out the query to all registries concurrently and merges results sorted by score descending.

type SearchCache added in v0.2.0

type SearchCache struct {
	// contains filtered or unexported fields
}

SearchCache provides lightweight caching for search results. It uses trigram-based similarity to match similar queries to cached results, avoiding redundant API calls. Thread-safe for concurrent access.

func NewSearchCache added in v0.2.0

func NewSearchCache(maxEntries int, ttl time.Duration) *SearchCache

NewSearchCache creates a new search cache. maxEntries is the maximum number of cached queries (excess evicts LRU). ttl is how long each entry lives before expiration.

func (*SearchCache) Get added in v0.2.0

func (sc *SearchCache) Get(query string) ([]SearchResult, bool)

Get looks up results for a query. Returns cached results and true if found (either exact or similar match above threshold). Returns nil, false on miss.

func (*SearchCache) Len added in v0.2.0

func (sc *SearchCache) Len() int

Len returns the number of entries (for testing).

func (*SearchCache) Put added in v0.2.0

func (sc *SearchCache) Put(query string, results []SearchResult)

Put stores results for a query. Evicts the oldest entry if at capacity.

type SearchResult added in v0.2.0

type SearchResult struct {
	Score        float64 `json:"score"`
	Slug         string  `json:"slug"`
	DisplayName  string  `json:"display_name"`
	Summary      string  `json:"summary"`
	Version      string  `json:"version"`
	RegistryName string  `json:"registry_name"`
}

SearchResult represents a single result from a skill registry search.

type SkillInfo

type SkillInfo struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Source      string `json:"source"`
	Description string `json:"description"`
}

type SkillInstaller

type SkillInstaller struct {
	// contains filtered or unexported fields
}

func NewSkillInstaller

func NewSkillInstaller(workspace string) *SkillInstaller

func (*SkillInstaller) InstallFromGitHub

func (si *SkillInstaller) InstallFromGitHub(ctx context.Context, repo string) error

func (*SkillInstaller) Uninstall

func (si *SkillInstaller) Uninstall(skillName string) error

type SkillMeta added in v0.2.0

type SkillMeta struct {
	Slug             string `json:"slug"`
	DisplayName      string `json:"display_name"`
	Summary          string `json:"summary"`
	LatestVersion    string `json:"latest_version"`
	IsMalwareBlocked bool   `json:"is_malware_blocked"`
	IsSuspicious     bool   `json:"is_suspicious"`
	RegistryName     string `json:"registry_name"`
}

SkillMeta holds metadata about a skill from a registry.

type SkillMetadata

type SkillMetadata struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type SkillRegistry added in v0.2.0

type SkillRegistry interface {
	// Name returns the unique name of this registry (e.g., "clawhub").
	Name() string
	// Search searches the registry for skills matching the query.
	Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
	// GetSkillMeta retrieves metadata for a specific skill by slug.
	GetSkillMeta(ctx context.Context, slug string) (*SkillMeta, error)
	// DownloadAndInstall fetches metadata, resolves the version, downloads and
	// installs the skill to targetDir. Returns an InstallResult with metadata
	// for the caller to use for moderation and user messaging.
	DownloadAndInstall(ctx context.Context, slug, version, targetDir string) (*InstallResult, error)
}

SkillRegistry is the interface that all skill registries must implement. Each registry represents a different source of skills (e.g., clawhub.ai)

type SkillsLoader

type SkillsLoader struct {
	// contains filtered or unexported fields
}

func NewSkillsLoader

func NewSkillsLoader(workspace string, globalSkills string, builtinSkills string) *SkillsLoader

func (*SkillsLoader) BuildSkillsSummary

func (sl *SkillsLoader) BuildSkillsSummary() string

func (*SkillsLoader) ListSkills

func (sl *SkillsLoader) ListSkills() []SkillInfo

func (*SkillsLoader) LoadSkill

func (sl *SkillsLoader) LoadSkill(name string) (string, bool)

func (*SkillsLoader) LoadSkillsForContext

func (sl *SkillsLoader) LoadSkillsForContext(skillNames []string) string

func (*SkillsLoader) SkillRoots added in v0.2.1

func (sl *SkillsLoader) SkillRoots() []string

SkillRoots returns all unique skill root directories used by this loader. The order follows resolution priority: workspace > global > builtin.

Jump to

Keyboard shortcuts

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