core

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package core provides canonical types for AI assistant plugin/extension definitions.

Index

Constants

View Source
const DefaultDirMode fs.FileMode = 0700

DefaultDirMode is the default permission for generated directories.

View Source
const DefaultFileMode fs.FileMode = 0600

DefaultFileMode is the default permission for generated files.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the global adapter registry.

Functions

func AdapterNames

func AdapterNames() []string

AdapterNames returns adapter names from the default registry.

func Convert

func Convert(data []byte, from, to string) ([]byte, error)

Convert converts using the default registry.

func Register

func Register(adapter Adapter)

Register adds an adapter to the default registry.

func WriteCanonicalFile

func WriteCanonicalFile(plugin *Plugin, path string) error

WriteCanonicalFile writes a canonical plugin.json file.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter identifier (e.g., "claude", "gemini").
	Name() string

	// DefaultPaths returns default file paths for this tool's plugin manifest.
	DefaultPaths() []string

	// Parse converts tool-specific bytes to canonical Plugin.
	Parse(data []byte) (*Plugin, error)

	// Marshal converts canonical Plugin to tool-specific bytes.
	Marshal(plugin *Plugin) ([]byte, error)

	// ReadFile reads from path and returns canonical Plugin.
	ReadFile(path string) (*Plugin, error)

	// WriteFile writes canonical Plugin to path.
	WriteFile(plugin *Plugin, path string) error

	// WritePlugin writes the complete plugin structure to the given directory.
	// This includes the manifest file and any referenced component directories.
	WritePlugin(plugin *Plugin, dir string) error
}

Adapter converts between canonical Plugin and tool-specific formats.

func GetAdapter

func GetAdapter(name string) (Adapter, bool)

GetAdapter returns an adapter from the default registry.

type Dependency

type Dependency struct {
	Name     string `json:"name"`
	Command  string `json:"command,omitempty"`  // CLI command to check availability
	Optional bool   `json:"optional,omitempty"` // If true, missing dependency is a warning
}

Dependency represents a required or optional dependency.

type MCPServer

type MCPServer struct {
	Command string            `json:"command"`
	Args    []string          `json:"args,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
}

MCPServer represents an MCP server configuration.

type MarshalError

type MarshalError struct {
	Format string
	Err    error
}

MarshalError occurs when marshaling to tool-specific format fails.

func (*MarshalError) Error

func (e *MarshalError) Error() string

func (*MarshalError) Unwrap

func (e *MarshalError) Unwrap() error

type ParseError

type ParseError struct {
	Format string
	Path   string
	Err    error
}

ParseError occurs when parsing tool-specific format fails.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Plugin

type Plugin struct {
	// Metadata
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`
	Author      string `json:"author,omitempty"`
	License     string `json:"license,omitempty"`
	Repository  string `json:"repository,omitempty"`
	Homepage    string `json:"homepage,omitempty"`

	// Components - paths to spec files
	Commands string `json:"commands,omitempty"` // Directory containing command specs
	Skills   string `json:"skills,omitempty"`   // Directory containing skill specs
	Agents   string `json:"agents,omitempty"`   // Directory containing agent specs
	Hooks    string `json:"hooks,omitempty"`    // Path to hooks spec file

	// Context file content
	Context string `json:"context,omitempty"` // System prompt / context content

	// Dependencies
	Dependencies []Dependency `json:"dependencies,omitempty"`

	// MCP Servers (used by Gemini extensions)
	MCPServers map[string]MCPServer `json:"mcp_servers,omitempty"`
}

Plugin represents a canonical plugin/extension definition that can be converted to tool-specific formats (Claude, Gemini, etc.).

func NewPlugin

func NewPlugin(name, version, description string) *Plugin

NewPlugin creates a new Plugin with the given name, version, and description.

func ReadCanonicalFile

func ReadCanonicalFile(path string) (*Plugin, error)

ReadCanonicalFile reads a canonical plugin.json file.

func (*Plugin) AddDependency

func (p *Plugin) AddDependency(name, command string)

AddDependency adds a required dependency to the plugin.

func (*Plugin) AddMCPServer

func (p *Plugin) AddMCPServer(name string, server MCPServer)

AddMCPServer adds an MCP server configuration to the plugin.

func (*Plugin) AddOptionalDependency

func (p *Plugin) AddOptionalDependency(name, command string)

AddOptionalDependency adds an optional dependency to the plugin.

type ReadError

type ReadError struct {
	Path string
	Err  error
}

ReadError occurs when reading a file fails.

func (*ReadError) Error

func (e *ReadError) Error() string

func (*ReadError) Unwrap

func (e *ReadError) Unwrap() error

type Registry

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

Registry manages adapter registration and lookup.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new adapter registry.

func (*Registry) AdapterNames

func (r *Registry) AdapterNames() []string

AdapterNames returns all registered adapter names sorted alphabetically.

func (*Registry) Convert

func (r *Registry) Convert(data []byte, from, to string) ([]byte, error)

Convert converts plugin data from one format to another.

func (*Registry) GetAdapter

func (r *Registry) GetAdapter(name string) (Adapter, bool)

GetAdapter returns an adapter by name.

func (*Registry) Register

func (r *Registry) Register(adapter Adapter)

Register adds an adapter to the registry.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError occurs when a plugin configuration is invalid.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type WriteError

type WriteError struct {
	Path string
	Err  error
}

WriteError occurs when writing a file fails.

func (*WriteError) Error

func (e *WriteError) Error() string

func (*WriteError) Unwrap

func (e *WriteError) Unwrap() error

Jump to

Keyboard shortcuts

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