Documentation
¶
Index ¶
- Constants
- func BuildInstallMetadataForRegistryInstance(registry SkillRegistry, target, version string) (string, string)
- func BuiltinDir() string
- func GitHubInstallDirNameFromToolsConfig(cfg config.SkillsToolsConfig, target string) (string, error)
- func NormalizeInstallTargetForRegistry(cfg config.SkillsToolsConfig, registryName, target string) string
- func NormalizeInstallTargetForRegistryInstance(registry SkillRegistry, target string) string
- func RegisterRegistryProviderBuilder(name string, builder RegistryProviderBuilder)
- func SkillDir(skillsRoot, name string) (string, error)
- func ValidateInstallTarget(target string) error
- func ValidateSkillName(name string) error
- type ClawHubConfig
- type ClawHubRegistry
- func (c *ClawHubRegistry) DownloadAndInstall(ctx context.Context, slug, version, targetDir string) (*InstallResult, error)
- func (c *ClawHubRegistry) GetSkillMeta(ctx context.Context, slug string) (*SkillMeta, error)
- func (c *ClawHubRegistry) Name() string
- func (c *ClawHubRegistry) ResolveInstallDirName(target string) (string, error)
- func (c *ClawHubRegistry) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
- func (c *ClawHubRegistry) SkillURL(slug, _ string) string
- type GitHubContent
- type GitHubRef
- type GitHubRegistry
- func (r *GitHubRegistry) DownloadAndInstall(ctx context.Context, target, version, targetDir string) (*InstallResult, error)
- func (r *GitHubRegistry) GetSkillMeta(ctx context.Context, target string) (*SkillMeta, error)
- func (r *GitHubRegistry) Name() string
- func (r *GitHubRegistry) NormalizeInstallTarget(target string) string
- func (r *GitHubRegistry) ResolveInstallDirName(target string) (string, error)
- func (r *GitHubRegistry) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
- func (r *GitHubRegistry) SkillURL(target, version string) string
- type GitHubRegistryConfig
- type InstallResult
- type InstallTargetNormalizer
- type RegistryConfig
- type RegistryManager
- type RegistryProvider
- type RegistryProviderBuilder
- type SearchCache
- func (sc *SearchCache) Get(query string) ([]SearchResult, bool)
- func (sc *SearchCache) GetLimited(query string, limit int) ([]SearchResult, bool)
- func (sc *SearchCache) Len() int
- func (sc *SearchCache) Put(query string, results []SearchResult)
- func (sc *SearchCache) PutLimited(query string, limit int, results []SearchResult)
- type SearchResult
- type SkillInfo
- type SkillInstaller
- type SkillMeta
- type SkillMetadata
- type SkillRegistry
- type SkillsLoader
Constants ¶
const ( MaxNameLength = 64 MaxDescriptionLength = 1024 // OriginInstalled marks a skill installed from a registry: third-party // instructions rather than ones the user wrote. OriginInstalled = "installed" )
Variables ¶
This section is empty.
Functions ¶
func BuildInstallMetadataForRegistryInstance ¶
func BuildInstallMetadataForRegistryInstance(registry SkillRegistry, target, version string) (string, string)
func BuiltinDir ¶
func BuiltinDir() string
BuiltinDir returns the directory built-in skills are loaded from: $COMPA_BUILTIN_SKILLS when set, otherwise a skills folder installed next to the executable, otherwise "" (none). The bundled default skills reach the agent through onboarding, which copies them into the workspace.
It never falls back to the working directory: launching Compa from a folder that happens to contain skills/ must not add those skills to the system prompt as built-ins.
func GitHubInstallDirNameFromToolsConfig ¶
func GitHubInstallDirNameFromToolsConfig(cfg config.SkillsToolsConfig, target string) (string, error)
func NormalizeInstallTargetForRegistry ¶
func NormalizeInstallTargetForRegistry(cfg config.SkillsToolsConfig, registryName, target string) string
func NormalizeInstallTargetForRegistryInstance ¶
func NormalizeInstallTargetForRegistryInstance(registry SkillRegistry, target string) string
func RegisterRegistryProviderBuilder ¶
func RegisterRegistryProviderBuilder(name string, builder RegistryProviderBuilder)
func SkillDir ¶
SkillDir returns the folder of the named skill inside skillsRoot. The name must be a valid skill name, so the result is always a direct child of skillsRoot: a name like `..\..\x` can't reach outside it on Windows.
func ValidateInstallTarget ¶
func ValidateSkillName ¶
Types ¶
type ClawHubConfig ¶
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 ¶
func (c ClawHubConfig) BuildRegistry() SkillRegistry
func (ClawHubConfig) IsEnabled ¶
func (c ClawHubConfig) IsEnabled() bool
type ClawHubRegistry ¶
type ClawHubRegistry struct {
// contains filtered or unexported fields
}
ClawHubRegistry implements SkillRegistry for the ClawHub platform.
func NewClawHubRegistry ¶
func NewClawHubRegistry(cfg ClawHubConfig) *ClawHubRegistry
NewClawHubRegistry creates a new ClawHub registry client from config.
func (*ClawHubRegistry) DownloadAndInstall ¶
func (c *ClawHubRegistry) DownloadAndInstall( ctx context.Context, slug, version, targetDir string, ) (*InstallResult, error)
DownloadAndInstall fetches metadata, resolves version, downloads the skill ZIP, and extracts it to targetDir. Moderation is checked before anything is downloaded: a skill whose metadata can't be fetched isn't installed, and a blocked one is reported through InstallResult.IsMalwareBlocked without being extracted.
func (*ClawHubRegistry) GetSkillMeta ¶
func (*ClawHubRegistry) Name ¶
func (c *ClawHubRegistry) Name() string
func (*ClawHubRegistry) ResolveInstallDirName ¶
func (c *ClawHubRegistry) ResolveInstallDirName(target string) (string, error)
func (*ClawHubRegistry) Search ¶
func (c *ClawHubRegistry) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
func (*ClawHubRegistry) SkillURL ¶
func (c *ClawHubRegistry) SkillURL(slug, _ string) string
type GitHubContent ¶
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 ¶
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 ¶
type GitHubRegistry struct {
// contains filtered or unexported fields
}
func (*GitHubRegistry) DownloadAndInstall ¶
func (r *GitHubRegistry) DownloadAndInstall( ctx context.Context, target, version, targetDir string, ) (*InstallResult, error)
func (*GitHubRegistry) GetSkillMeta ¶
func (*GitHubRegistry) Name ¶
func (r *GitHubRegistry) Name() string
func (*GitHubRegistry) NormalizeInstallTarget ¶
func (r *GitHubRegistry) NormalizeInstallTarget(target string) string
func (*GitHubRegistry) ResolveInstallDirName ¶
func (r *GitHubRegistry) ResolveInstallDirName(target string) (string, error)
func (*GitHubRegistry) Search ¶
func (r *GitHubRegistry) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
func (*GitHubRegistry) SkillURL ¶
func (r *GitHubRegistry) SkillURL(target, version string) string
type GitHubRegistryConfig ¶
func (GitHubRegistryConfig) BuildRegistry ¶
func (c GitHubRegistryConfig) BuildRegistry() SkillRegistry
func (GitHubRegistryConfig) IsEnabled ¶
func (c GitHubRegistryConfig) IsEnabled() bool
type InstallResult ¶
type InstallResult struct {
Version string
IsMalwareBlocked bool
IsSuspicious bool
Summary string
// Commit is the commit SHA a GitHub install was made from (empty for
// other registries). Record it with the install.
Commit string
// Unpinned is set for a GitHub install whose ref couldn't be resolved to
// a commit, so it was downloaded from the ref itself (Commit is empty).
Unpinned bool
}
InstallResult is returned by DownloadAndInstall to carry metadata back to the caller for moderation and user messaging.
type InstallTargetNormalizer ¶
InstallTargetNormalizer is implemented by registries that can canonicalize user-provided install targets into a stable slug for origin metadata.
type RegistryConfig ¶
type RegistryConfig struct {
Providers []RegistryProvider
MaxConcurrentSearches int
}
RegistryConfig holds configuration for all skill registries. This is the input to NewRegistryManagerFromConfig.
type RegistryManager ¶
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 ¶
func NewRegistryManager() *RegistryManager
NewRegistryManager creates an empty RegistryManager.
func NewRegistryManagerFromConfig ¶
func NewRegistryManagerFromConfig(cfg RegistryConfig) *RegistryManager
NewRegistryManagerFromConfig builds a RegistryManager from config, instantiating only the enabled registries.
func NewRegistryManagerFromToolsConfig ¶
func NewRegistryManagerFromToolsConfig(cfg config.SkillsToolsConfig) *RegistryManager
func (*RegistryManager) AddRegistry ¶
func (rm *RegistryManager) AddRegistry(r SkillRegistry)
AddRegistry adds a registry to the manager.
func (*RegistryManager) GetRegistry ¶
func (rm *RegistryManager) GetRegistry(name string) SkillRegistry
GetRegistry returns a registry by name, or nil if not found.
func (*RegistryManager) SearchAll ¶
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 ¶
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 ¶
type RegistryProviderBuilder func(name string, cfg config.SkillRegistryConfig) RegistryProvider
type SearchCache ¶
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 ¶
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 ¶
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) GetLimited ¶
func (sc *SearchCache) GetLimited(query string, limit int) ([]SearchResult, bool)
GetLimited is Get for results fetched with the given result limit; entries cached under another limit don't match.
func (*SearchCache) Len ¶
func (sc *SearchCache) Len() int
Len returns the number of entries (for testing).
func (*SearchCache) Put ¶
func (sc *SearchCache) Put(query string, results []SearchResult)
Put stores results for a query. Evicts the oldest entry if at capacity.
func (*SearchCache) PutLimited ¶
func (sc *SearchCache) PutLimited(query string, limit int, results []SearchResult)
PutLimited is Put for results fetched with the given result limit.
type SearchResult ¶
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"`
// Origin is OriginInstalled for a skill installed from a registry.
Origin string `json:"origin,omitempty"`
// unsupported OS or a missing binary). Such skills aren't offered to the
// agent.
Unavailable string `json:"unavailable,omitempty"`
}
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 ¶
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 ¶
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 ¶
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 SkillRegistry ¶
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 ¶
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
BuildSkillsSummary lists the skills offered to the agent. Skills that don't apply on this host are left out, and installed third-party skills show the source "installed".
func (*SkillsLoader) ListSkills ¶
func (sl *SkillsLoader) ListSkills() []SkillInfo
ListSkills lists the skills of every root, workspace first. A skill's identity is its folder name, which LoadSkill resolves too: a frontmatter name that differs is only logged, so a folder can't hide or take over another skill by declaring its name. When folder names collide (across roots, or by case) the first one wins in root order (workspace > global > builtin) and then folder order, and the others are skipped with a warning.
func (*SkillsLoader) LoadSkillsForContext ¶
func (sl *SkillsLoader) LoadSkillsForContext(skillNames []string) string
func (*SkillsLoader) SkillRoots ¶
func (sl *SkillsLoader) SkillRoots() []string
SkillRoots returns all unique skill root directories used by this loader. The order follows resolution priority: workspace > global > builtin.