plugin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package plugin implements discovery and execution of shell-script plugins for cloop. Plugins are executable files placed in .cloop/plugins/ (project-local) or ~/.cloop/plugins/ (global). Each plugin must implement a "describe" subcommand that prints a one-line description to stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Describe

func Describe(pluginPath string) (string, error)

Describe returns the one-line description of a plugin by running `<plugin> describe`. Returns an error if the describe subcommand fails or the output is empty.

func Resolve

func Resolve(workDir, name string) (string, error)

Resolve finds the absolute path for a plugin name. It checks .cloop/plugins/ before ~/.cloop/plugins/ and supports scripts with or without file extensions.

func Run

func Run(workDir, name string, args []string, extraEnv []string) error

Run executes a plugin by name with the given arguments and optional extra environment variables (KEY=value strings). The plugin process inherits the current process's stdio. extraEnv values are appended to os.Environ(). workDir is used for discovery if the plugin is referenced by name (not path).

Run uses a background context with no deadline; it is intended for interactive `cloop plugin run` invocations where the user can Ctrl+C. Non-interactive callers (e.g. orchestrator hooks) should use RunCtx with a timeout-bounded context to prevent hung plugins from stalling execution.

func RunCtx

func RunCtx(ctx context.Context, workDir, name string, args []string, extraEnv []string) error

RunCtx is the context-aware variant of Run. If ctx is cancelled or its deadline expires, the plugin process is killed.

Types

type Plugin

type Plugin struct {
	Name        string // base filename without extension
	Path        string // absolute path to the executable
	Description string // output of `<plugin> describe`
	Scope       string // "local" (.cloop/plugins/) or "global" (~/.cloop/plugins/)
}

Plugin describes a discovered plugin.

func Discover

func Discover(workDir string) ([]*Plugin, error)

Discover finds all executable plugin scripts in .cloop/plugins/ (workDir-relative) and ~/.cloop/plugins/ (global). Local plugins shadow global ones with the same name. Non-executable files and directories are silently skipped.

type Registry

type Registry struct {
	Plugins []RegistryPlugin `json:"plugins"`
}

Registry is the top-level structure of the remote plugin registry JSON.

func FetchRegistry

func FetchRegistry(url string) (*Registry, error)

FetchRegistry downloads and parses the plugin registry from the given URL.

type RegistryPlugin

type RegistryPlugin struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Author      string   `json:"author"`
	URL         string   `json:"url"`
	Version     string   `json:"version"`
	Tags        []string `json:"tags"`
}

RegistryPlugin describes a plugin entry in the remote registry.

func Search(reg *Registry, query string) []RegistryPlugin

Search filters registry plugins whose name, description, or tags contain all words in query (case-insensitive). If query is empty all plugins are returned.

Jump to

Keyboard shortcuts

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