plugins

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package plugins provides plugin installation and lifecycle management.

ABOUTME: Plugin installation and management operations ABOUTME: Handles install, uninstall, update operations for plugins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationConfig

type ActivationConfig struct {
	OnStartup bool     `json:"onStartup,omitempty"`
	Languages []string `json:"languages,omitempty"`
	Files     []string `json:"files,omitempty"`
	Projects  []string `json:"projects,omitempty"`
}

ActivationConfig defines when a plugin should activate

type ActivationContext

type ActivationContext struct {
	Languages    []string // Detected languages in project
	Files        []string // Important files in project
	ProjectTypes []string // Detected project types (e.g., "react", "django")
}

ActivationContext provides context for plugin activation decisions

type ConfigSchema

type ConfigSchema struct {
	Defaults map[string]interface{} `json:"defaults,omitempty"`
	Schema   map[string]interface{} `json:"schema,omitempty"`
}

ConfigSchema defines plugin configuration options

type Installer

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

Installer handles plugin installation operations

func NewInstaller

func NewInstaller(loader *Loader) *Installer

NewInstaller creates a new plugin installer

func (*Installer) Disable

func (i *Installer) Disable(name string) error

Disable disables a plugin

func (*Installer) Enable

func (i *Installer) Enable(name string) error

Enable enables a plugin

func (*Installer) Install

func (i *Installer) Install(source string) error

Install installs a plugin from a source (URL, git repo, or local path)

func (*Installer) Uninstall

func (i *Installer) Uninstall(name string) error

Uninstall removes a plugin

func (*Installer) Update

func (i *Installer) Update(name string) error

Update updates a plugin to the latest version

type Loader

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

Loader discovers and loads plugins from directories

func NewLoader

func NewLoader(pluginsDir, stateFile string) (*Loader, error)

NewLoader creates a new plugin loader

func (*Loader) DiscoverAll

func (l *Loader) DiscoverAll() ([]*Plugin, error)

DiscoverAll finds all plugins in the plugins directory

func (*Loader) GetPlugin

func (l *Loader) GetPlugin(name string) (*Plugin, error)

GetPlugin loads a specific plugin by name

func (*Loader) GetPluginsDir

func (l *Loader) GetPluginsDir() string

GetPluginsDir returns the plugins directory path

func (*Loader) LoadEnabled

func (l *Loader) LoadEnabled(context *ActivationContext) ([]*Plugin, error)

LoadEnabled loads all enabled plugins

func (*Loader) SaveState

func (l *Loader) SaveState() error

SaveState persists the current state to disk

func (*Loader) State

func (l *Loader) State() *State

State returns the current plugin state

func (*Loader) ValidatePlugin

func (l *Loader) ValidatePlugin(pluginDir string) error

ValidatePlugin checks if a plugin directory is valid

type MCPConfig

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

MCPConfig defines an MCP server configuration

type Manifest

type Manifest struct {
	// Required fields
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`

	// Optional metadata
	Author     string            `json:"author,omitempty"`
	License    string            `json:"license,omitempty"`
	Homepage   string            `json:"homepage,omitempty"`
	Repository *RepositoryInfo   `json:"repository,omitempty"`
	Keywords   []string          `json:"keywords,omitempty"`
	Engines    map[string]string `json:"engines,omitempty"`

	// Plugin dependencies
	Dependencies map[string]string `json:"dependencies,omitempty"`

	// What the plugin contributes
	Skills     []string               `json:"skills,omitempty"`
	Commands   []string               `json:"commands,omitempty"`
	Hooks      map[string]interface{} `json:"hooks,omitempty"`
	MCPServers map[string]MCPConfig   `json:"mcpServers,omitempty"`
	Agents     []string               `json:"agents,omitempty"`
	Templates  []string               `json:"templates,omitempty"`
	Scripts    map[string]string      `json:"scripts,omitempty"`
	Activation *ActivationConfig      `json:"activation,omitempty"`
	Config     *ConfigSchema          `json:"configuration,omitempty"`
}

Manifest represents a plugin's metadata and configuration

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest loads and validates a plugin manifest from a file

func (*Manifest) FullID

func (m *Manifest) FullID() string

FullID returns the full plugin identifier (name@version)

func (*Manifest) GetAgentPaths

func (m *Manifest) GetAgentPaths(pluginDir string) []string

GetAgentPaths returns full paths to agent files

func (*Manifest) GetCommandPaths

func (m *Manifest) GetCommandPaths(pluginDir string) []string

GetCommandPaths returns full paths to command files

func (*Manifest) GetSkillPaths

func (m *Manifest) GetSkillPaths(pluginDir string) []string

GetSkillPaths returns full paths to skill files

func (*Manifest) GetTemplatePaths

func (m *Manifest) GetTemplatePaths(pluginDir string) []string

GetTemplatePaths returns full paths to template files

func (*Manifest) Save

func (m *Manifest) Save(path string) error

Save writes a manifest to disk

func (*Manifest) ShouldActivate

func (m *Manifest) ShouldActivate(context *ActivationContext) bool

ShouldActivate checks if the plugin should activate in the current context

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate checks if the manifest has all required fields and valid values

type Plugin

type Plugin struct {
	Name      string
	Version   string
	Dir       string
	Manifest  *Manifest
	Enabled   bool
	Installed bool
}

Plugin represents a loaded plugin with its manifest and metadata

type PluginState

type PluginState struct {
	Enabled   bool      `json:"enabled"`
	Version   string    `json:"version"`
	Installed time.Time `json:"installed"`
	Updated   time.Time `json:"updated,omitempty"`
	Path      string    `json:"path"` // Full path to plugin directory
}

PluginState tracks an individual plugin's state

type Registry

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

Registry manages loaded plugins and their contributions

func DefaultRegistry

func DefaultRegistry() (*Registry, error)

DefaultRegistry creates a registry with default paths

func NewRegistry

func NewRegistry(pluginsDir, stateFile string) (*Registry, error)

NewRegistry creates a new plugin registry

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of loaded plugins

func (*Registry) Disable

func (r *Registry) Disable(name string) error

Disable disables a plugin

func (*Registry) Enable

func (r *Registry) Enable(name string) error

Enable enables a plugin

func (*Registry) Get

func (r *Registry) Get(name string) (*Plugin, bool)

Get retrieves a loaded plugin by name

func (*Registry) GetAgentPaths

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

GetAgentPaths returns all agent file paths from loaded plugins

func (*Registry) GetAll

func (r *Registry) GetAll() []*Plugin

GetAll returns all loaded plugins

func (*Registry) GetCommandPaths

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

GetCommandPaths returns all command file paths from loaded plugins

func (*Registry) GetHooks

func (r *Registry) GetHooks() map[string][]map[string]interface{}

GetHooks returns all hooks from loaded plugins

func (*Registry) GetMCPServers

func (r *Registry) GetMCPServers() map[string]MCPConfig

GetMCPServers returns all MCP server configs from loaded plugins

func (*Registry) GetPluginsDir

func (r *Registry) GetPluginsDir() string

GetPluginsDir returns the plugins directory path

func (*Registry) GetSkillPaths

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

GetSkillPaths returns all skill file paths from loaded plugins

func (*Registry) GetStateFile

func (r *Registry) GetStateFile() string

GetStateFile returns the state file path

func (*Registry) GetTemplatePaths

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

GetTemplatePaths returns all template file paths from loaded plugins

func (*Registry) Install

func (r *Registry) Install(source string) error

Install installs a plugin from a source

func (*Registry) List

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

List returns all loaded plugin names

func (*Registry) ListInstalled

func (r *Registry) ListInstalled() ([]*Plugin, error)

ListInstalled returns all installed plugins (enabled and disabled)

func (*Registry) LoadAll

func (r *Registry) LoadAll(context *ActivationContext) error

LoadAll discovers and loads all enabled plugins

func (*Registry) Uninstall

func (r *Registry) Uninstall(name string) error

Uninstall removes a plugin

func (*Registry) Update

func (r *Registry) Update(name string) error

Update updates a plugin to the latest version

type RepositoryInfo

type RepositoryInfo struct {
	Type string `json:"type"` // git, svn, etc.
	URL  string `json:"url"`
}

RepositoryInfo contains source repository metadata

type State

type State struct {
	Plugins map[string]*PluginState `json:"plugins"`
}

State tracks the installation state of all plugins

func LoadState

func LoadState(stateFile string) (*State, error)

LoadState loads plugin state from disk

func (*State) AddPlugin

func (s *State) AddPlugin(name, version, path string)

AddPlugin records a newly installed plugin

func (*State) DisablePlugin

func (s *State) DisablePlugin(name string) error

DisablePlugin disables a plugin

func (*State) EnablePlugin

func (s *State) EnablePlugin(name string) error

EnablePlugin enables a plugin

func (*State) GetPlugin

func (s *State) GetPlugin(name string) (*PluginState, error)

GetPlugin retrieves a plugin's state

func (*State) IsEnabled

func (s *State) IsEnabled(name string) bool

IsEnabled checks if a plugin is enabled

func (*State) IsInstalled

func (s *State) IsInstalled(name string) bool

IsInstalled checks if a plugin is installed

func (*State) ListAll

func (s *State) ListAll() []string

ListAll returns all plugin names

func (*State) ListEnabled

func (s *State) ListEnabled() []string

ListEnabled returns all enabled plugin names

func (*State) RemovePlugin

func (s *State) RemovePlugin(name string)

RemovePlugin removes a plugin from state

func (*State) Save

func (s *State) Save(stateFile string) error

Save writes the state to disk

func (*State) UpdatePlugin

func (s *State) UpdatePlugin(name, version string) error

UpdatePlugin updates a plugin's version and timestamp

Jump to

Keyboard shortcuts

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