plugins

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package plugins installs, validates, and loads Codog plugin bundles.

Index

Constants

View Source
const DisabledMarker = ".disabled"
View Source
const LifecycleDefaultTimeout = 30 * time.Second

LifecycleDefaultTimeout is the per-command timeout used for plugin lifecycle hooks.

Variables

This section is empty.

Functions

func DataDir

func DataDir(workspace string, id string) string

func DataDirForManifest

func DataDirForManifest(manifest Manifest) string

func DataRoot

func DataRoot(workspace string) string

func Disabled

func Disabled(dir string) bool

func LifecycleCommands

func LifecycleCommands(manifest Manifest, phase string) ([]string, bool)

LifecycleCommands returns the manifest commands configured for a lifecycle phase.

func LoadMCPServers

func LoadMCPServers(workspace string) (map[string]config.MCPServerConfig, error)

func LoadMCPServersFromManifests

func LoadMCPServersFromManifests(manifests []Manifest) map[string]config.MCPServerConfig

LoadMCPServersFromManifests resolves MCP contributions from an already resolved runtime plugin set.

func NormalizeLifecyclePhase

func NormalizeLifecyclePhase(phase string) (string, error)

NormalizeLifecyclePhase returns the canonical lifecycle phase for a phase alias.

func PluginMCPServerName

func PluginMCPServerName(pluginID string, serverName string) string

func Remove

func Remove(workspace, id string) error

func ResolveContentPath

func ResolveContentPath(root string, value string) (string, error)

func Root

func Root(workspace string) string

func UnsupportedLifecyclePhaseError

func UnsupportedLifecyclePhaseError(phase string) error

UnsupportedLifecyclePhaseError reports an unsupported lifecycle phase with suggestions.

func ValidToolPermission

func ValidToolPermission(permission string) bool

func VerifyMarketplace

func VerifyMarketplace(index MarketplaceIndex, publicKey string) error

Types

type HookConfigFile

type HookConfigFile struct {
	PluginID string            `json:"plugin_id"`
	Path     string            `json:"path"`
	Config   config.HookConfig `json:"config"`
}

func LoadHookConfigs

func LoadHookConfigs(workspace string) ([]HookConfigFile, error)

func LoadHookConfigsFromManifests

func LoadHookConfigsFromManifests(manifests []Manifest) ([]HookConfigFile, error)

LoadHookConfigsFromManifests loads hook contributions from an already resolved runtime plugin set.

type LifecycleCommandResult

type LifecycleCommandResult struct {
	Index           int    `json:"index"`
	Command         string `json:"command"`
	WorkingDir      string `json:"working_dir,omitempty"`
	Status          string `json:"status"`
	ExitCode        int    `json:"exit_code"`
	DurationMS      int64  `json:"duration_ms"`
	Stdout          string `json:"stdout,omitempty"`
	Stderr          string `json:"stderr,omitempty"`
	StdoutTruncated bool   `json:"stdout_truncated,omitempty"`
	StderrTruncated bool   `json:"stderr_truncated,omitempty"`
	TimedOut        bool   `json:"timed_out,omitempty"`
	Error           string `json:"error,omitempty"`
}

LifecycleCommandResult records one lifecycle command invocation.

type LifecycleConfig

type LifecycleConfig struct {
	Init     []string `json:"init,omitempty"`
	Shutdown []string `json:"shutdown,omitempty"`
}

LifecycleConfig declares plugin lifecycle commands without executing them.

func (LifecycleConfig) Empty

func (l LifecycleConfig) Empty() bool

Empty reports whether no lifecycle commands are configured.

type LifecycleRunResult

type LifecycleRunResult struct {
	PluginID     string                   `json:"plugin_id"`
	Phase        string                   `json:"phase"`
	Status       string                   `json:"status"`
	CommandCount int                      `json:"command_count"`
	Commands     []LifecycleCommandResult `json:"commands"`
	Message      string                   `json:"message,omitempty"`
}

LifecycleRunResult summarizes an explicit plugin lifecycle phase execution.

func RunLifecycle

func RunLifecycle(ctx context.Context, manifest Manifest, phase string, timeout time.Duration) LifecycleRunResult

RunLifecycle executes one lifecycle phase for a plugin manifest.

type Manifest

type Manifest struct {
	ID          string                            `json:"id"`
	Name        string                            `json:"name"`
	Version     string                            `json:"version,omitempty"`
	Description string                            `json:"description,omitempty"`
	Lifecycle   LifecycleConfig                   `json:"lifecycle,omitempty"`
	Tools       []ToolManifest                    `json:"tools,omitempty"`
	Commands    []string                          `json:"commands,omitempty"`
	Skills      []string                          `json:"skills,omitempty"`
	Agents      []string                          `json:"agents,omitempty"`
	Hooks       []string                          `json:"hooks,omitempty"`
	MCPServers  map[string]config.MCPServerConfig `json:"mcp_servers,omitempty"`
	Path        string                            `json:"path,omitempty"`
	Root        string                            `json:"root,omitempty"`
	Enabled     bool                              `json:"enabled"`
	Session     bool                              `json:"session,omitempty"`
	DataPath    string                            `json:"data_path,omitempty"`
}

func Disable

func Disable(workspace, id string) (Manifest, error)

func Enable

func Enable(workspace, id string) (Manifest, error)

func Install

func Install(workspace, source string) (Manifest, error)

func Load

func Load(workspace string) ([]Manifest, error)

func LoadManifest

func LoadManifest(dir string) (Manifest, error)

func LoadWithDirs

func LoadWithDirs(workspace string, pluginDirs []string) ([]Manifest, error)

LoadWithDirs loads installed plugins plus session-scoped plugin directories. A session plugin replaces an installed plugin with the same id without changing the workspace installation.

type MarketplaceIndex

type MarketplaceIndex struct {
	Name           string         `json:"name,omitempty"`
	Plugins        []RemotePlugin `json:"plugins,omitempty"`
	Signature      string         `json:"signature,omitempty"`
	Source         string         `json:"source,omitempty"`
	SignatureValid bool           `json:"signature_valid,omitempty"`
}

func FetchMarketplace

func FetchMarketplace(ctx context.Context, indexURL, publicKey string) (MarketplaceIndex, error)

func (MarketplaceIndex) Find

func (index MarketplaceIndex) Find(id string) (RemotePlugin, bool)

type MarketplaceSource

type MarketplaceSource struct {
	URL       string
	PublicKey string
}

type MarketplaceUpdate

type MarketplaceUpdate struct {
	MarketplaceURL  string `json:"marketplace_url"`
	ID              string `json:"id"`
	CurrentVersion  string `json:"current_version,omitempty"`
	LatestVersion   string `json:"latest_version,omitempty"`
	UpdateAvailable bool   `json:"update_available"`
	URL             string `json:"url"`
	SHA256          string `json:"sha256"`
	SignatureValid  bool   `json:"signature_valid,omitempty"`
}

func CheckUpdates

func CheckUpdates(ctx context.Context, workspace string, sources []MarketplaceSource) ([]MarketplaceUpdate, error)

type RemoteInstallResult

type RemoteInstallResult struct {
	MarketplaceURL string   `json:"marketplace_url"`
	ID             string   `json:"id"`
	Version        string   `json:"version,omitempty"`
	URL            string   `json:"url"`
	SHA256         string   `json:"sha256"`
	ChecksumValid  bool     `json:"checksum_valid"`
	SignatureValid bool     `json:"signature_valid,omitempty"`
	Manifest       Manifest `json:"manifest"`
}

func InstallRemote

func InstallRemote(ctx context.Context, workspace, indexURL, id, publicKey string) (RemoteInstallResult, error)

func InstallRemoteFromIndex

func InstallRemoteFromIndex(ctx context.Context, workspace string, index MarketplaceIndex, id string) (RemoteInstallResult, error)

type RemotePlugin

type RemotePlugin struct {
	ID          string `json:"id"`
	Name        string `json:"name,omitempty"`
	Version     string `json:"version,omitempty"`
	Description string `json:"description,omitempty"`
	URL         string `json:"url"`
	SHA256      string `json:"sha256"`
}

type RemoteUpdateResult

type RemoteUpdateResult struct {
	MarketplaceURL  string   `json:"marketplace_url"`
	ID              string   `json:"id"`
	PreviousVersion string   `json:"previous_version,omitempty"`
	Version         string   `json:"version,omitempty"`
	URL             string   `json:"url"`
	SHA256          string   `json:"sha256"`
	ChecksumValid   bool     `json:"checksum_valid"`
	SignatureValid  bool     `json:"signature_valid,omitempty"`
	BackupPath      string   `json:"backup_path"`
	Manifest        Manifest `json:"manifest"`
	Updated         bool     `json:"updated"`
}

func UpdateRemote

func UpdateRemote(ctx context.Context, workspace string, sources []MarketplaceSource, id string) (RemoteUpdateResult, error)

func UpdateRemoteFromIndex

func UpdateRemoteFromIndex(ctx context.Context, workspace string, index MarketplaceIndex, id, previousVersion string) (RemoteUpdateResult, error)

type ToolManifest

type ToolManifest struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Command     string         `json:"command,omitempty"`
	Args        []string       `json:"args,omitempty"`
	InputSchema map[string]any `json:"input_schema,omitempty"`
	Permission  string         `json:"permission,omitempty"`
}

type ValidationMessage

type ValidationMessage struct {
	Path    string `json:"path"`
	Message string `json:"message"`
	Code    string `json:"code,omitempty"`
}

type ValidationResult

type ValidationResult struct {
	Success  bool                `json:"success"`
	Errors   []ValidationMessage `json:"errors"`
	Warnings []ValidationMessage `json:"warnings"`
	FilePath string              `json:"file_path"`
	FileType string              `json:"file_type"`
	Manifest *Manifest           `json:"manifest,omitempty"`
}

func Validate

func Validate(source string) (ValidationResult, error)

Jump to

Keyboard shortcuts

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