Documentation
¶
Overview ¶
* ChatCLI - ChatCLI.dev Registry Adapter * Copyright (c) 2024 Edilson Freitas * License: MIT * * Implements SkillRegistry for the official ChatCLI skill registry. * Migrated and enhanced from cli/skills/registry.go.
* ChatCLI - ClawHub Registry Adapter * Copyright (c) 2024 Edilson Freitas * License: MIT * * Implements SkillRegistry for clawhub.ai — a public skill marketplace. * Based on the ClawHub HTTP API v1: * - GET /api/v1/search?q=<query>&limit=<n> * - GET /api/v1/skills/<slug> * - GET /api/v1/download?slug=<s>&version=<v>
* ChatCLI - Skill Registry Configuration * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Custom/Generic Registry Adapter * Copyright (c) 2024 Edilson Freitas * License: MIT * * Implements SkillRegistry for user-configured registries. * Assumes the same API contract as ChatCLI.dev (standard REST endpoints).
* ChatCLI - Skill Installer * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Skill Registry Interface * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Registry Manager * Copyright (c) 2024 Edilson Freitas * License: MIT * * Coordinates fan-out parallel search across multiple skill registries. * Auto-disables registries after consecutive failures with cooldown.
* ChatCLI - Skill Moderation * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Trigram Fuzzy Search Cache * Copyright (c) 2024 Edilson Freitas * License: MIT
Index ¶
- func CheckModeration(meta *SkillMeta) string
- func ConfigPath() string
- func ExtractTrigrams(s string) map[string]bool
- func FormatModerationTag(flags ModerationFlags) string
- func JaccardSimilarity(a, b map[string]bool) float64
- func SaveConfig(cfg RegistriesConfig) error
- func ShouldBlock(flags ModerationFlags) bool
- type ChatCLIRegistry
- func (r *ChatCLIRegistry) DownloadSkill(ctx context.Context, meta *SkillMeta) ([]byte, error)
- func (r *ChatCLIRegistry) Enabled() bool
- func (r *ChatCLIRegistry) GetSkillMeta(ctx context.Context, nameOrSlug string) (*SkillMeta, error)
- func (r *ChatCLIRegistry) Name() string
- func (r *ChatCLIRegistry) Search(ctx context.Context, query string) ([]SkillMeta, error)
- type ClawHubRegistry
- func (r *ClawHubRegistry) DownloadSkill(ctx context.Context, meta *SkillMeta) ([]byte, error)
- func (r *ClawHubRegistry) Enabled() bool
- func (r *ClawHubRegistry) GetSkillMeta(ctx context.Context, nameOrSlug string) (*SkillMeta, error)
- func (r *ClawHubRegistry) Name() string
- func (r *ClawHubRegistry) Search(ctx context.Context, query string) ([]SkillMeta, error)
- type CustomRegistry
- func (r *CustomRegistry) DownloadSkill(ctx context.Context, meta *SkillMeta) ([]byte, error)
- func (r *CustomRegistry) Enabled() bool
- func (r *CustomRegistry) GetSkillMeta(ctx context.Context, nameOrSlug string) (*SkillMeta, error)
- func (r *CustomRegistry) Name() string
- func (r *CustomRegistry) Search(ctx context.Context, query string) ([]SkillMeta, error)
- type InstallResult
- type InstalledSkillInfo
- type Installer
- func (inst *Installer) GetInstallDir() string
- func (inst *Installer) GetInstalledInfo(name string) *InstalledSkillInfo
- func (inst *Installer) Install(meta *SkillMeta, content []byte) (*InstallResult, error)
- func (inst *Installer) IsInstalled(name string) bool
- func (inst *Installer) ListInstalled() ([]InstalledSkillInfo, error)
- func (inst *Installer) Uninstall(name string) error
- type ModerationFlags
- type RegistriesConfig
- type RegistryEntry
- type RegistryInfo
- type RegistryManager
- func (rm *RegistryManager) ClearCache()
- func (rm *RegistryManager) GetConfigPath() string
- func (rm *RegistryManager) GetInstallDir() string
- func (rm *RegistryManager) GetInstalledInfo(name string) *InstalledSkillInfo
- func (rm *RegistryManager) GetRegistries() []RegistryInfo
- func (rm *RegistryManager) GetSkillMeta(ctx context.Context, nameOrSlug string) (*SkillMeta, error)
- func (rm *RegistryManager) Install(ctx context.Context, nameOrSlug string) (*InstallResult, error)
- func (rm *RegistryManager) IsInstalled(name string) bool
- func (rm *RegistryManager) ListInstalled() ([]InstalledSkillInfo, error)
- func (rm *RegistryManager) SearchAll(ctx context.Context, query string) ([]SkillMeta, []SearchResult)
- func (rm *RegistryManager) Uninstall(name string) error
- type SearchResult
- type SkillMeta
- type SkillRegistry
- type TrigramCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckModeration ¶
CheckModeration evaluates a SkillMeta and returns a human-readable warning. Returns empty string if no moderation flags are raised.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the path to the registries config file.
func ExtractTrigrams ¶
ExtractTrigrams returns the set of 3-character substrings from a string.
func FormatModerationTag ¶
func FormatModerationTag(flags ModerationFlags) string
FormatModerationTag returns a short tag for display in search results.
func JaccardSimilarity ¶
JaccardSimilarity computes |A intersection B| / |A union B|.
func SaveConfig ¶
func SaveConfig(cfg RegistriesConfig) error
SaveConfig writes the registries config to disk.
func ShouldBlock ¶
func ShouldBlock(flags ModerationFlags) bool
ShouldBlock returns true if the moderation flags indicate the skill should NOT be installed.
Types ¶
type ChatCLIRegistry ¶
type ChatCLIRegistry struct {
// contains filtered or unexported fields
}
ChatCLIRegistry implements SkillRegistry for registry.chatcli.dev.
func NewChatCLIRegistry ¶
func NewChatCLIRegistry(entry RegistryEntry, logger *zap.Logger) *ChatCLIRegistry
NewChatCLIRegistry creates a new ChatCLI.dev registry adapter.
func (*ChatCLIRegistry) DownloadSkill ¶
DownloadSkill downloads the skill content.
func (*ChatCLIRegistry) Enabled ¶
func (r *ChatCLIRegistry) Enabled() bool
func (*ChatCLIRegistry) GetSkillMeta ¶
GetSkillMeta returns full metadata for a specific skill.
func (*ChatCLIRegistry) Name ¶
func (r *ChatCLIRegistry) Name() string
type ClawHubRegistry ¶
type ClawHubRegistry struct {
// contains filtered or unexported fields
}
ClawHubRegistry implements SkillRegistry for clawhub.ai.
func NewClawHubRegistry ¶
func NewClawHubRegistry(entry RegistryEntry, logger *zap.Logger) *ClawHubRegistry
NewClawHubRegistry creates a new ClawHub registry adapter.
func (*ClawHubRegistry) DownloadSkill ¶
DownloadSkill downloads the skill content as a zip.
func (*ClawHubRegistry) Enabled ¶
func (r *ClawHubRegistry) Enabled() bool
func (*ClawHubRegistry) GetSkillMeta ¶
GetSkillMeta returns full metadata for a specific skill.
func (*ClawHubRegistry) Name ¶
func (r *ClawHubRegistry) Name() string
type CustomRegistry ¶
type CustomRegistry struct {
// contains filtered or unexported fields
}
CustomRegistry implements SkillRegistry for user-configured registries. It follows the ChatCLI.dev API contract:
- GET /skills/search?q=<query> -> { "skills": [...] } or [...]
- GET /skills/<slug> -> skill meta object
- GET /skills/<slug>/download -> skill content
func NewCustomRegistry ¶
func NewCustomRegistry(entry RegistryEntry, logger *zap.Logger) *CustomRegistry
NewCustomRegistry creates a new generic registry adapter.
func (*CustomRegistry) DownloadSkill ¶
DownloadSkill downloads the skill content.
func (*CustomRegistry) Enabled ¶
func (r *CustomRegistry) Enabled() bool
func (*CustomRegistry) GetSkillMeta ¶
GetSkillMeta returns full metadata for a specific skill.
func (*CustomRegistry) Name ¶
func (r *CustomRegistry) Name() string
type InstallResult ¶
type InstallResult struct {
Name string
Version string
InstallPath string
Source string
Moderation ModerationFlags
WasDuplicate bool
}
InstallResult reports what happened during installation.
type InstalledSkillInfo ¶
type InstalledSkillInfo struct {
Name string
Description string
Version string
Source string // registry name or "local"
Path string
}
InstalledSkillInfo describes a locally installed skill.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer handles downloading, verifying, and writing skills to disk.
func NewInstaller ¶
NewInstaller creates a new skill installer.
func (*Installer) GetInstallDir ¶
GetInstallDir returns the install directory path.
func (*Installer) GetInstalledInfo ¶
func (inst *Installer) GetInstalledInfo(name string) *InstalledSkillInfo
GetInstalledInfo returns metadata for a specific installed skill, or nil if not found.
func (*Installer) Install ¶
func (inst *Installer) Install(meta *SkillMeta, content []byte) (*InstallResult, error)
Install writes skill content atomically to the install directory. It creates a V2 skill package (directory with SKILL.md).
func (*Installer) IsInstalled ¶
IsInstalled checks if a skill exists locally.
func (*Installer) ListInstalled ¶
func (inst *Installer) ListInstalled() ([]InstalledSkillInfo, error)
ListInstalled returns all installed skills with their metadata.
type ModerationFlags ¶
type ModerationFlags struct {
MalwareDetected bool `json:"malware_detected"`
SuspiciousContent bool `json:"suspicious_content"`
Quarantined bool `json:"quarantined"`
Reason string `json:"reason,omitempty"`
}
ModerationFlags represents safety signals from a registry about a skill.
type RegistriesConfig ¶
type RegistriesConfig struct {
Registries []RegistryEntry `yaml:"registries" json:"registries"`
InstallDir string `yaml:"install_dir,omitempty" json:"install_dir,omitempty"`
MaxConcurrent int `yaml:"max_concurrent,omitempty" json:"max_concurrent,omitempty"`
SearchCacheSize int `yaml:"search_cache_size,omitempty" json:"search_cache_size,omitempty"`
}
RegistriesConfig is the top-level config for all registries.
func DefaultConfig ¶
func DefaultConfig() RegistriesConfig
DefaultConfig returns the default registries configuration.
func LoadConfig ¶
func LoadConfig() (RegistriesConfig, error)
LoadConfig reads the registries config from disk. If the file doesn't exist, it creates it with defaults.
type RegistryEntry ¶
type RegistryEntry struct {
Name string `yaml:"name" json:"name"`
URL string `yaml:"url" json:"url"`
IsActive bool `yaml:"enabled" json:"enabled"`
CacheTTL time.Duration `yaml:"cache_ttl" json:"cache_ttl"`
Token string `yaml:"token,omitempty" json:"token,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"` // "chatcli", "clawhub", "custom"
}
RegistryEntry represents a single registry in the user's config.
type RegistryInfo ¶
type RegistryInfo struct {
Name string
URL string
Enabled bool
TempDisabled bool // auto-disabled due to consecutive failures
DisabledUntil *time.Time // when the cooldown expires
FailureCount int
}
RegistryInfo describes a configured registry.
type RegistryManager ¶
type RegistryManager struct {
// contains filtered or unexported fields
}
RegistryManager coordinates multiple registries for fan-out search.
func NewRegistryManager ¶
func NewRegistryManager(cfg RegistriesConfig, logger *zap.Logger) (*RegistryManager, error)
NewRegistryManager creates a new registry manager from configuration.
func (*RegistryManager) ClearCache ¶
func (rm *RegistryManager) ClearCache()
ClearCache clears the search cache.
func (*RegistryManager) GetConfigPath ¶
func (rm *RegistryManager) GetConfigPath() string
GetConfigPath returns the config file path.
func (*RegistryManager) GetInstallDir ¶
func (rm *RegistryManager) GetInstallDir() string
GetInstallDir returns the installation directory.
func (*RegistryManager) GetInstalledInfo ¶
func (rm *RegistryManager) GetInstalledInfo(name string) *InstalledSkillInfo
GetInstalledInfo returns metadata for a specific installed skill.
func (*RegistryManager) GetRegistries ¶
func (rm *RegistryManager) GetRegistries() []RegistryInfo
GetRegistries returns info about all configured registries.
func (*RegistryManager) GetSkillMeta ¶
GetSkillMeta retrieves metadata for a skill (returns first found across registries). Skips results with empty names.
func (*RegistryManager) Install ¶
func (rm *RegistryManager) Install(ctx context.Context, nameOrSlug string) (*InstallResult, error)
Install downloads and installs a skill from the best matching registry.
func (*RegistryManager) IsInstalled ¶
func (rm *RegistryManager) IsInstalled(name string) bool
IsInstalled checks if a skill is installed locally.
func (*RegistryManager) ListInstalled ¶
func (rm *RegistryManager) ListInstalled() ([]InstalledSkillInfo, error)
ListInstalled returns all locally installed skills.
func (*RegistryManager) SearchAll ¶
func (rm *RegistryManager) SearchAll(ctx context.Context, query string) ([]SkillMeta, []SearchResult)
SearchAll performs a fan-out parallel search across all enabled registries. Results are merged and deduplicated by skill name (first registry wins).
func (*RegistryManager) Uninstall ¶
func (rm *RegistryManager) Uninstall(name string) error
Uninstall removes an installed skill from disk.
type SearchResult ¶
SearchResult wraps search results from a single registry.
type SkillMeta ¶
type SkillMeta struct {
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description"`
Version string `json:"version"`
Author string `json:"author"`
Tags []string `json:"tags"`
Downloads int `json:"downloads"`
DownloadURL string `json:"download_url"`
RegistryName string `json:"registry_name"`
Moderation ModerationFlags `json:"moderation"`
}
SkillMeta is the metadata returned by a registry about a skill.
type SkillRegistry ¶
type SkillRegistry interface {
// Name returns the human-readable name of this registry.
Name() string
// Search returns skills matching the query string.
Search(ctx context.Context, query string) ([]SkillMeta, error)
// GetSkillMeta returns full metadata for a specific skill by name/slug.
GetSkillMeta(ctx context.Context, nameOrSlug string) (*SkillMeta, error)
// DownloadSkill downloads the skill content and returns it as bytes.
DownloadSkill(ctx context.Context, meta *SkillMeta) ([]byte, error)
// Enabled returns whether this registry is currently active.
Enabled() bool
}
SkillRegistry is the interface each registry adapter must implement.
type TrigramCache ¶
type TrigramCache struct {
// contains filtered or unexported fields
}
TrigramCache provides fuzzy-matching local search over cached skill metadata. Uses trigram-based Jaccard similarity to match similar queries without network calls.
func NewTrigramCache ¶
func NewTrigramCache(maxSize int, ttl time.Duration) *TrigramCache
NewTrigramCache creates a new trigram-based fuzzy search cache.
func (*TrigramCache) Clear ¶
func (tc *TrigramCache) Clear()
Clear removes all entries from the cache.
func (*TrigramCache) Get ¶
func (tc *TrigramCache) Get(query string) []SkillMeta
Get retrieves cached results for an exact or fuzzy match. Returns nil if no match found or all matches are expired.
func (*TrigramCache) Invalidate ¶
func (tc *TrigramCache) Invalidate(query string)
Invalidate removes a specific query from the cache.
func (*TrigramCache) Put ¶
func (tc *TrigramCache) Put(query string, results []SkillMeta)
Put stores results for a query in the cache.
func (*TrigramCache) Size ¶
func (tc *TrigramCache) Size() int
Size returns the number of entries in the cache.