skills

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxNameLength        = 64
	MaxDescriptionLength = 1024
)

Variables

This section is empty.

Functions

func BuildInstallMetadataForRegistryInstance added in v0.2.7

func BuildInstallMetadataForRegistryInstance(registry SkillRegistry, target, version string) (string, string)

func GitHubInstallDirNameFromToolsConfig added in v0.2.7

func GitHubInstallDirNameFromToolsConfig(cfg config.SkillsToolsConfig, target string) (string, error)

func NormalizeInstallTargetForRegistry added in v0.2.7

func NormalizeInstallTargetForRegistry(cfg config.SkillsToolsConfig, registryName, target string) string

func NormalizeInstallTargetForRegistryInstance added in v0.2.7

func NormalizeInstallTargetForRegistryInstance(registry SkillRegistry, target string) string

func RegisterRegistryProviderBuilder added in v0.2.7

func RegisterRegistryProviderBuilder(name string, builder RegistryProviderBuilder)

func ValidateInstallTarget added in v0.2.7

func ValidateInstallTarget(target string) error

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.

func (ClawHubConfig) BuildRegistry added in v0.2.7

func (c ClawHubConfig) BuildRegistry() SkillRegistry

func (ClawHubConfig) IsEnabled added in v0.2.7

func (c ClawHubConfig) IsEnabled() bool

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) ResolveInstallDirName added in v0.2.7

func (c *ClawHubRegistry) ResolveInstallDirName(target string) (string, error)

func (*ClawHubRegistry) Search added in v0.2.0

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

func (*ClawHubRegistry) SkillURL added in v0.2.7

func (c *ClawHubRegistry) SkillURL(slug, _ string) string

type GitHubContent added in v0.2.3

type GitHubContent struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Type        string `json:"type"` // "file" or "dir"
	DownloadURL string `json:"download_url"`
	URL         string `json:"url"` // API URL for subdirectories
}

GitHubContent represents a file or directory in GitHub API response

type GitHubRef added in v0.2.3

type GitHubRef struct {
	Owner    string // Repository owner
	RepoName string // Repository name
	Ref      string // Git reference (branch, tag, or commit)
	SubPath  string // Path within the repository
}

GitHubRef represents a parsed GitHub reference

type GitHubRegistry added in v0.2.7

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

func (*GitHubRegistry) DownloadAndInstall added in v0.2.7

func (r *GitHubRegistry) DownloadAndInstall(
	ctx context.Context,
	target, version, targetDir string,
) (*InstallResult, error)

func (*GitHubRegistry) GetSkillMeta added in v0.2.7

func (r *GitHubRegistry) GetSkillMeta(ctx context.Context, target string) (*SkillMeta, error)

func (*GitHubRegistry) Name added in v0.2.7

func (r *GitHubRegistry) Name() string

func (*GitHubRegistry) NormalizeInstallTarget added in v0.2.7

func (r *GitHubRegistry) NormalizeInstallTarget(target string) string

func (*GitHubRegistry) ResolveInstallDirName added in v0.2.7

func (r *GitHubRegistry) ResolveInstallDirName(target string) (string, error)

func (*GitHubRegistry) Search added in v0.2.7

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

func (*GitHubRegistry) SkillURL added in v0.2.7

func (r *GitHubRegistry) SkillURL(target, version string) string

type GitHubRegistryConfig added in v0.2.7

type GitHubRegistryConfig struct {
	Enabled   bool
	BaseURL   string
	AuthToken string
	Proxy     string
}

func (GitHubRegistryConfig) BuildRegistry added in v0.2.7

func (c GitHubRegistryConfig) BuildRegistry() SkillRegistry

func (GitHubRegistryConfig) IsEnabled added in v0.2.7

func (c GitHubRegistryConfig) IsEnabled() bool

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 InstallTargetNormalizer added in v0.2.7

type InstallTargetNormalizer interface {
	NormalizeInstallTarget(target string) string
}

InstallTargetNormalizer is implemented by registries that can canonicalize user-provided install targets into a stable slug for origin metadata.

type RegistryConfig added in v0.2.0

type RegistryConfig struct {
	Providers             []RegistryProvider
	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 NewRegistryManagerFromToolsConfig added in v0.2.7

func NewRegistryManagerFromToolsConfig(cfg config.SkillsToolsConfig) *RegistryManager

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 RegistryProvider added in v0.2.7

type RegistryProvider interface {
	IsEnabled() bool
	BuildRegistry() SkillRegistry
}

RegistryProvider creates a registry instance from configuration. Different hubs can implement this to plug into the shared manager.

type RegistryProviderBuilder added in v0.2.7

type RegistryProviderBuilder func(name string, cfg config.SkillRegistryConfig) RegistryProvider

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, githubToken, proxy string) (*SkillInstaller, error)

NewSkillInstaller creates a new skill installer. proxy is an optional HTTP/HTTPS/SOCKS5 proxy URL for downloading skills.

func NewSkillInstallerWithBaseURL added in v0.2.7

func NewSkillInstallerWithBaseURL(workspace, githubBaseURL, githubToken, proxy string) (*SkillInstaller, error)

NewSkillInstallerWithBaseURL creates a new skill installer with a custom GitHub base URL. For github.com this can be left empty. For GitHub Enterprise, set it to the web URL.

func (*SkillInstaller) InstallFromGitHub

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

func (*SkillInstaller) InstallFromGitHubToDir added in v0.2.7

func (si *SkillInstaller) InstallFromGitHubToDir(
	ctx context.Context,
	repo, version, skillDirectory string,
) (*InstallResult, 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
	// ResolveInstallDirName returns the directory name to use under workspace/skills
	// for a given install target. Different registries can interpret the target
	// differently (for example, a slug vs owner/repo/path).
	ResolveInstallDirName(target string) (string, error)
	// SkillURL returns the web URL for a skill slug if the registry exposes one.
	// version is optional and can be used by registries whose URLs depend on a ref.
	SkillURL(slug, version string) 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)

func LookupRegistryFromToolsConfig added in v0.2.7

func LookupRegistryFromToolsConfig(cfg config.SkillsToolsConfig, name string) SkillRegistry

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