registry

package
v0.1.0-alpha.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

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

Functions

func RenderSkillMD

func RenderSkillMD(skill *AgentSkill) ([]byte, error)

RenderSkillMD serializes an AgentSkill back to SKILL.md format.

func ValidateSkill

func ValidateSkill(s *AgentSkill) error

ValidateSkill validates an AgentSkill and returns just the error (convenience wrapper).

func ValidateSkillName

func ValidateSkillName(name string) error

ValidateSkillName validates a skill name against the agentskills.io spec.

Types

type AgentSkill

type AgentSkill struct {
	// --- Frontmatter fields (from YAML between --- delimiters) ---
	Name          string            `yaml:"name" json:"name"`
	Description   string            `yaml:"description" json:"description"`
	License       string            `yaml:"license,omitempty" json:"license,omitempty"`
	Compatibility string            `yaml:"compatibility,omitempty" json:"compatibility,omitempty"`
	Metadata      map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	AllowedTools  string            `yaml:"allowed-tools,omitempty" json:"allowedTools,omitempty"`

	// --- Gridctl extensions (not in agentskills.io spec) ---
	State ItemState `yaml:"state,omitempty" json:"state"`

	// --- Parsed from file content (not in frontmatter YAML) ---
	Body string `yaml:"-" json:"body"` // Markdown content after frontmatter

	// --- Computed fields (not serialized to YAML) ---
	FileCount int    `yaml:"-" json:"fileCount"` // Number of supporting files (scripts/, references/, assets/)
	Dir       string `yaml:"-" json:"-"`         // Relative path from skills/ root (e.g., "git-workflow/branch-fork")
}

AgentSkill represents an Agent Skills standard SKILL.md file. See https://agentskills.io/specification for the full spec.

func ParseSkillMD

func ParseSkillMD(data []byte) (*AgentSkill, error)

ParseSkillMD parses a SKILL.md file into an AgentSkill. The file format is YAML frontmatter between --- delimiters followed by a markdown body.

func (*AgentSkill) Validate

func (s *AgentSkill) Validate() error

Validate checks the skill against the agentskills.io specification.

type ItemState

type ItemState string

ItemState represents the lifecycle state of a skill. Note: state is a gridctl extension, not part of the agentskills.io spec.

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

type RegistryStatus

type RegistryStatus struct {
	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 serves Agent Skills as prompts. It implements mcp.AgentClient so it can be registered with the gateway router, and mcp.PromptProvider so the gateway can serve skills via MCP prompts and resources.

Agent Skills are knowledge documents, not executable tools. The server exposes them as MCP prompts (prompts/list, prompts/get) and resources (resources/list, resources/read) rather than as MCP tools.

func New

func New(store *Store) *Server

New creates a registry server. Unlike the previous version, no ToolCaller is needed — Agent Skills are knowledge documents served to clients, not executable operations.

func (*Server) CallTool

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

CallTool returns an error — Agent Skills are knowledge documents, not executable tools.

func (*Server) GetPromptData

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

GetPromptData returns a specific active skill's content as MCP PromptData.

func (*Server) HasContent

func (s *Server) HasContent() bool

HasContent returns true if the registry has any skills.

func (*Server) Initialize

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

Initialize loads the store.

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 active Agent Skills as MCP PromptData. Each skill gets a single optional "context" argument for clients to pass additional context when requesting the skill via prompts/get.

func (*Server) Name

func (s *Server) Name() string

Name returns "registry".

func (*Server) RefreshTools

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

RefreshTools reloads the store from disk.

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 an empty list. Agent Skills are not exposed as MCP tools.

type SkillFile

type SkillFile struct {
	Path  string `json:"path"`  // Relative path within the skill dir (e.g., "scripts/lint.sh")
	Size  int64  `json:"size"`  // File size in bytes
	IsDir bool   `json:"isDir"` // True for directories
}

SkillFile represents a file within a skill directory.

type Store

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

Store manages skill directories on disk. Each skill is a directory containing a required SKILL.md and optional supporting files (scripts/, references/, assets/).

func NewStore

func NewStore(baseDir string) *Store

NewStore creates a store rooted at the given directory.

func (*Store) ActiveSkills

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

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

func (*Store) DeleteFile

func (s *Store) DeleteFile(skillName, filePath string) error

DeleteFile removes a file from a skill directory.

func (*Store) DeleteSkill

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

DeleteSkill removes a skill directory and cache entry.

func (*Store) GetSkill

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

GetSkill returns a skill by name.

func (*Store) HasContent

func (s *Store) HasContent() bool

HasContent returns true if there is at least one skill.

func (*Store) ListFiles

func (s *Store) ListFiles(skillName string) ([]SkillFile, error)

ListFiles returns all files in a skill directory (excluding SKILL.md).

func (*Store) ListSkills

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

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

func (*Store) Load

func (s *Store) Load() error

Load scans the skills/ subdirectory for SKILL.md files and checks for legacy YAML registry files.

func (*Store) ReadFile

func (s *Store) ReadFile(skillName, filePath string) ([]byte, error)

ReadFile reads a specific file from a skill directory.

func (*Store) RenameSkill

func (s *Store) RenameSkill(oldName, newName string) error

RenameSkill renames a skill directory and updates its frontmatter.

func (*Store) SaveSkill

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

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

func (*Store) Status

func (s *Store) Status() RegistryStatus

Status returns registry summary counts.

func (*Store) WriteFile

func (s *Store) WriteFile(skillName, filePath string, data []byte) error

WriteFile writes a file to a skill directory, creating parent directories as needed.

type ValidationResult

type ValidationResult struct {
	Errors   []string // Fatal validation failures
	Warnings []string // Non-fatal advisories (e.g., body too long)
}

ValidationResult contains errors and warnings from skill validation.

func ValidateSkillFull

func ValidateSkillFull(s *AgentSkill) *ValidationResult

ValidateSkillFull validates an AgentSkill and returns both errors and warnings.

func (*ValidationResult) Error

func (v *ValidationResult) Error() error

Error returns the first error as a Go error, or nil if valid.

func (*ValidationResult) Valid

func (v *ValidationResult) Valid() bool

Valid returns true if there are no errors (warnings are OK).

Jump to

Keyboard shortcuts

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