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 ¶
- func Describe(pluginPath string) (string, error)
- func Resolve(workDir, name string) (string, error)
- func Run(workDir, name string, args []string, extraEnv []string) error
- func RunCtx(ctx context.Context, workDir, name string, args []string, extraEnv []string) error
- type Plugin
- type Registry
- type RegistryPlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Describe ¶
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 ¶
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 ¶
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.
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.
type Registry ¶
type Registry struct {
Plugins []RegistryPlugin `json:"plugins"`
}
Registry is the top-level structure of the remote plugin registry JSON.
func FetchRegistry ¶
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 ¶
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.