registry

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package registry provides skill registration and discovery.

The registry is a central place to register skills and discover available tools across all registered skills.

Index

Constants

This section is empty.

Variables

View Source
var ErrSkillExists = errors.New("skill already registered")

ErrSkillExists is returned when attempting to register a skill that already exists.

View Source
var ErrSkillNotFound = errors.New("skill not found")

ErrSkillNotFound is returned when a skill is not found in the registry.

Functions

This section is empty.

Types

type Capability added in v0.11.0

type Capability string

Capability represents a skill capability that agents can query for. Capabilities describe what a skill can do at a semantic level, allowing agents to find skills by need rather than by name.

const (
	// File system capabilities
	CapabilityFileRead   Capability = "file:read"
	CapabilityFileWrite  Capability = "file:write"
	CapabilityFileDelete Capability = "file:delete"
	CapabilityFileList   Capability = "file:list"

	// Network capabilities
	CapabilityHTTPRequest Capability = "http:request"
	CapabilityHTTPServer  Capability = "http:server"
	CapabilityWebSocket   Capability = "websocket"

	// Code execution capabilities
	CapabilityCodeExecute   Capability = "code:execute"
	CapabilityCodeAnalyze   Capability = "code:analyze"
	CapabilityCodeGenerate  Capability = "code:generate"
	CapabilityCodeFormat    Capability = "code:format"
	CapabilityCodeLint      Capability = "code:lint"
	CapabilityCodeTest      Capability = "code:test"
	CapabilityCodeRefactor  Capability = "code:refactor"
	CapabilityCodeTransform Capability = "code:transform"

	// Git/VCS capabilities
	CapabilityGitRead   Capability = "git:read"
	CapabilityGitWrite  Capability = "git:write"
	CapabilityGitCommit Capability = "git:commit"
	CapabilityGitPush   Capability = "git:push"

	// Database capabilities
	CapabilityDatabaseRead  Capability = "database:read"
	CapabilityDatabaseWrite Capability = "database:write"
	CapabilityDatabaseAdmin Capability = "database:admin"

	// Communication capabilities
	CapabilityEmailSend    Capability = "email:send"
	CapabilityEmailRead    Capability = "email:read"
	CapabilitySlackSend    Capability = "slack:send"
	CapabilitySlackRead    Capability = "slack:read"
	CapabilityCalendarRead Capability = "calendar:read"
	CapabilityCalendarEdit Capability = "calendar:edit"

	// Search capabilities
	CapabilitySearchWeb   Capability = "search:web"
	CapabilitySearchCode  Capability = "search:code"
	CapabilitySearchLocal Capability = "search:local"

	// Document capabilities
	CapabilityDocumentRead    Capability = "document:read"
	CapabilityDocumentWrite   Capability = "document:write"
	CapabilityDocumentConvert Capability = "document:convert"

	// AI/ML capabilities
	CapabilityAIChat       Capability = "ai:chat"
	CapabilityAIEmbed      Capability = "ai:embed"
	CapabilityAIComplete   Capability = "ai:complete"
	CapabilityAIImageGen   Capability = "ai:image_gen"
	CapabilityAITranscribe Capability = "ai:transcribe"

	// System capabilities
	CapabilitySystemShell   Capability = "system:shell"
	CapabilitySystemProcess Capability = "system:process"
	CapabilitySystemEnv     Capability = "system:env"
)

Standard capability constants. These represent common categories of functionality that skills provide.

func AllCapabilities added in v0.11.0

func AllCapabilities() []Capability

AllCapabilities returns all standard capabilities.

func CapabilityFromKeywords added in v0.11.0

func CapabilityFromKeywords(keywords []string) []Capability

CapabilityFromKeywords infers capabilities from skill keywords/tags. This maps common keywords to their corresponding capabilities.

func ParseCapabilities added in v0.11.0

func ParseCapabilities(keywords []string) []Capability

ParseCapabilities parses a slice of strings into capabilities. Invalid strings are skipped.

func ParseCapability added in v0.11.0

func ParseCapability(s string) (Capability, bool)

ParseCapability parses a string into a Capability. Returns the capability and true if valid, or empty and false if invalid.

func (Capability) Action added in v0.11.0

func (c Capability) Action() string

Action returns the action part of the capability (after the colon).

func (Capability) Category added in v0.11.0

func (c Capability) Category() string

Category returns the category part of the capability (before the colon).

func (Capability) MatchesCategory added in v0.11.0

func (c Capability) MatchesCategory(category string) bool

MatchesCategory returns true if the capability belongs to the given category.

func (Capability) String added in v0.11.0

func (c Capability) String() string

String returns the string representation of the capability.

type CapabilityProvider added in v0.11.0

type CapabilityProvider interface {
	// Capabilities returns the capabilities this skill provides.
	Capabilities() []Capability
}

CapabilityProvider is implemented by skills that declare their capabilities. Skills implementing this interface enable capability-based discovery.

type DiscoveryInMemory added in v0.11.0

type DiscoveryInMemory struct {
	*InMemory
	// contains filtered or unexported fields
}

DiscoveryInMemory extends InMemory with capability-based discovery.

func NewDiscovery added in v0.11.0

func NewDiscovery() *DiscoveryInMemory

NewDiscovery creates a new in-memory registry with discovery support.

func (*DiscoveryInMemory) FindByAnyCapability added in v0.11.0

func (r *DiscoveryInMemory) FindByAnyCapability(caps []Capability) []skill.Skill

FindByAnyCapability returns skills that provide ANY of the given capabilities.

func (*DiscoveryInMemory) FindByCapabilities added in v0.11.0

func (r *DiscoveryInMemory) FindByCapabilities(caps []Capability) []skill.Skill

FindByCapabilities returns skills that provide ALL of the given capabilities.

func (*DiscoveryInMemory) FindByCapability added in v0.11.0

func (r *DiscoveryInMemory) FindByCapability(cap Capability) []skill.Skill

FindByCapability returns skills that provide the given capability.

func (*DiscoveryInMemory) FindByCategory added in v0.11.0

func (r *DiscoveryInMemory) FindByCategory(category string) []skill.Skill

FindByCategory returns skills with capabilities in the given category.

func (*DiscoveryInMemory) FindByKeyword added in v0.11.0

func (r *DiscoveryInMemory) FindByKeyword(keyword string) []skill.Skill

FindByKeyword returns skills matching the keyword in name, description, or tags.

func (*DiscoveryInMemory) GetCapabilities added in v0.11.0

func (r *DiscoveryInMemory) GetCapabilities(skillName string) []Capability

GetCapabilities returns all capabilities for a skill.

func (*DiscoveryInMemory) Register added in v0.11.0

func (r *DiscoveryInMemory) Register(s skill.Skill) error

Register adds a skill to the registry and indexes its capabilities.

func (*DiscoveryInMemory) RegisterCapabilities added in v0.11.0

func (r *DiscoveryInMemory) RegisterCapabilities(skillName string, caps []Capability)

RegisterCapabilities registers explicit capabilities for a skill.

func (*DiscoveryInMemory) Unregister added in v0.11.0

func (r *DiscoveryInMemory) Unregister(name string) error

Unregister removes a skill and its capability index entries.

type DiscoveryRegistry added in v0.11.0

type DiscoveryRegistry interface {
	Registry

	// FindByCapability returns skills that provide the given capability.
	FindByCapability(cap Capability) []skill.Skill

	// FindByCapabilities returns skills that provide ALL of the given capabilities.
	FindByCapabilities(caps []Capability) []skill.Skill

	// FindByAnyCapability returns skills that provide ANY of the given capabilities.
	FindByAnyCapability(caps []Capability) []skill.Skill

	// FindByKeyword returns skills matching the keyword in name, description, or tags.
	FindByKeyword(keyword string) []skill.Skill

	// FindByCategory returns skills with capabilities in the given category.
	FindByCategory(category string) []skill.Skill

	// RegisterCapabilities registers explicit capabilities for a skill.
	// This is used when a skill doesn't implement CapabilityProvider.
	RegisterCapabilities(skillName string, caps []Capability)
}

DiscoveryRegistry extends Registry with capability-based discovery.

type InMemory

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

InMemory is a thread-safe in-memory registry implementation.

func New

func New() *InMemory

New creates a new in-memory registry.

func (*InMemory) Close

func (r *InMemory) Close() error

Close closes all registered skills.

func (*InMemory) Count

func (r *InMemory) Count() int

Count returns the number of registered skills.

func (*InMemory) Get

func (r *InMemory) Get(name string) (skill.Skill, error)

Get returns a skill by name.

func (*InMemory) GetTool

func (r *InMemory) GetTool(fullName string) (skill.Tool, error)

GetTool returns a specific tool by its full name (skillname.toolname).

func (*InMemory) Init

func (r *InMemory) Init(ctx context.Context) error

Init initializes all registered skills.

func (*InMemory) List

func (r *InMemory) List() []skill.Skill

List returns all registered skills.

func (*InMemory) ListTools

func (r *InMemory) ListTools() []skill.Tool

ListTools returns all tools across all registered skills.

func (*InMemory) Register

func (r *InMemory) Register(s skill.Skill) error

Register adds a skill to the registry.

func (*InMemory) Unregister

func (r *InMemory) Unregister(name string) error

Unregister removes a skill from the registry.

type KeywordProvider added in v0.11.0

type KeywordProvider interface {
	// Keywords returns searchable keywords/tags for this skill.
	Keywords() []string
}

KeywordProvider is implemented by skills that declare keywords/tags. Keywords are used for text-based search and capability inference.

type Registry

type Registry interface {
	// Register adds a skill to the registry.
	// Returns ErrSkillExists if a skill with the same name is already registered.
	Register(s skill.Skill) error

	// Unregister removes a skill from the registry.
	// Returns ErrSkillNotFound if the skill is not registered.
	Unregister(name string) error

	// Get returns a skill by name.
	// Returns ErrSkillNotFound if the skill is not registered.
	Get(name string) (skill.Skill, error)

	// List returns all registered skills.
	List() []skill.Skill

	// ListTools returns all tools across all registered skills.
	// Tool names are prefixed with skill name: "skillname.toolname"
	ListTools() []skill.Tool

	// GetTool returns a specific tool by its full name (skillname.toolname).
	GetTool(fullName string) (skill.Tool, error)

	// Init initializes all registered skills.
	Init(ctx context.Context) error

	// Close closes all registered skills.
	Close() error
}

Registry manages skill registration and discovery.

Jump to

Keyboard shortcuts

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