registry

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned when a prompt or skill does not exist in the store.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	Required    bool   `yaml:"required" json:"required"`
	Default     string `yaml:"default,omitempty" json:"default,omitempty"`
}

Argument represents a parameter in a prompt template.

type ItemState

type ItemState string

ItemState represents the lifecycle state of a prompt or skill.

const (
	StateDraft    ItemState = "draft"
	StateActive   ItemState = "active"
	StateDisabled ItemState = "disabled"
)

type Prompt

type Prompt struct {
	Name        string     `yaml:"name" json:"name"`
	Description string     `yaml:"description" json:"description"`
	Content     string     `yaml:"content" json:"content"`
	Arguments   []Argument `yaml:"arguments,omitempty" json:"arguments,omitempty"`
	Tags        []string   `yaml:"tags,omitempty" json:"tags,omitempty"`
	State       ItemState  `yaml:"state" json:"state"`
}

Prompt represents a reusable prompt template.

func (*Prompt) Validate

func (p *Prompt) Validate() error

Validate checks a Prompt for correctness.

type RegistryStatus

type RegistryStatus struct {
	TotalPrompts  int `json:"totalPrompts"`
	ActivePrompts int `json:"activePrompts"`
	TotalSkills   int `json:"totalSkills"`
	ActiveSkills  int `json:"activeSkills"`
}

RegistryStatus contains summary statistics.

type Server

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

Server is an in-process MCP server that provides prompt and skill management. It implements mcp.AgentClient so it can be registered with the gateway router.

func New

func New(store *Store, toolCaller mcp.ToolCaller) *Server

New creates a registry server. The toolCaller parameter allows the registry to execute tools from other MCP servers when running skill chains. Pass nil if skill execution is not needed (e.g., prompts-only mode).

func (*Server) CallTool

func (s *Server) CallTool(ctx context.Context, name string, arguments map[string]any) (*mcp.ToolCallResult, error)

CallTool looks up a skill by name and executes its tool chain.

func (*Server) GetPrompt

func (s *Server) GetPrompt(name string) (*Prompt, error)

GetPrompt returns a specific prompt by name (for MCP prompts/get).

func (*Server) GetPromptData

func (s *Server) GetPromptData(name string) (*mcp.PromptData, error)

GetPromptData returns a prompt by name as MCP PromptData (implements mcp.PromptProvider).

func (*Server) HasContent

func (s *Server) HasContent() bool

HasContent returns true if the registry has any prompts or skills.

func (*Server) Initialize

func (s *Server) Initialize(ctx context.Context) error

Initialize loads the store and builds the MCP tool list from active skills.

func (*Server) IsInitialized

func (s *Server) IsInitialized() bool

IsInitialized returns whether the server has been initialized.

func (*Server) ListPromptData

func (s *Server) ListPromptData() []mcp.PromptData

ListPromptData returns all active prompts as MCP PromptData (implements mcp.PromptProvider).

func (*Server) Name

func (s *Server) Name() string

Name returns "registry".

func (*Server) Prompts

func (s *Server) Prompts() []*Prompt

Prompts returns all active prompts (for MCP prompts/list).

func (*Server) RefreshTools

func (s *Server) RefreshTools(ctx context.Context) error

RefreshTools re-scans the store and rebuilds the tools list.

func (*Server) ServerInfo

func (s *Server) ServerInfo() mcp.ServerInfo

ServerInfo returns server information.

func (*Server) Store

func (s *Server) Store() *Store

Store returns the underlying store for REST API access.

func (*Server) Tools

func (s *Server) Tools() []mcp.Tool

Tools returns the cached tools list.

type Skill

type Skill struct {
	Name        string     `yaml:"name" json:"name"`
	Description string     `yaml:"description" json:"description"`
	Steps       []Step     `yaml:"steps" json:"steps"`
	Input       []Argument `yaml:"input,omitempty" json:"input,omitempty"`
	Timeout     string     `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Tags        []string   `yaml:"tags,omitempty" json:"tags,omitempty"`
	State       ItemState  `yaml:"state" json:"state"`
}

Skill represents a composed tool workflow.

func (*Skill) Validate

func (sk *Skill) Validate() error

Validate checks a Skill for correctness.

type Step

type Step struct {
	Tool      string            `yaml:"tool" json:"tool"`
	Arguments map[string]string `yaml:"arguments,omitempty" json:"arguments,omitempty"`
}

Step represents a single step in a skill's tool chain.

type Store

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

Store manages prompt and skill YAML files on disk.

func NewStore

func NewStore(baseDir string) *Store

NewStore creates a store rooted at the given directory.

func (*Store) ActivePrompts

func (s *Store) ActivePrompts() []*Prompt

ActivePrompts returns only prompts with State == "active". Returned pointers are copies.

func (*Store) ActiveSkills

func (s *Store) ActiveSkills() []*Skill

ActiveSkills returns only skills with State == "active". Returned pointers are copies.

func (*Store) DeletePrompt

func (s *Store) DeletePrompt(name string) error

DeletePrompt removes a prompt file and cache entry.

func (*Store) DeleteSkill

func (s *Store) DeleteSkill(name string) error

DeleteSkill removes a skill file and cache entry.

func (*Store) GetPrompt

func (s *Store) GetPrompt(name string) (*Prompt, error)

GetPrompt returns a prompt by name.

func (*Store) GetSkill

func (s *Store) GetSkill(name string) (*Skill, error)

GetSkill returns a skill by name.

func (*Store) HasContent

func (s *Store) HasContent() bool

HasContent returns true if there is at least one prompt or skill.

func (*Store) ListPrompts

func (s *Store) ListPrompts() []*Prompt

ListPrompts returns all prompts (all states). Returned pointers are copies.

func (*Store) ListSkills

func (s *Store) ListSkills() []*Skill

ListSkills returns all skills (all states). Returned pointers are copies.

func (*Store) Load

func (s *Store) Load() error

Load scans the prompts/ and skills/ subdirectories for YAML files. Call this once at initialization. Individual file parse errors are logged and skipped.

func (*Store) SavePrompt

func (s *Store) SavePrompt(p *Prompt) error

SavePrompt creates or updates a prompt (validates, writes YAML, updates cache).

func (*Store) SaveSkill

func (s *Store) SaveSkill(sk *Skill) error

SaveSkill creates or updates a skill (validates, writes YAML, updates cache).

func (*Store) Status

func (s *Store) Status() RegistryStatus

Status returns registry summary counts.

Jump to

Keyboard shortcuts

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