plugins

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package plugins provides a plugin system for monox.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = defaultLanguageRegistry

DefaultRegistry returns the default language plugin registry.

Functions

func GetForProject

func GetForProject(project *api.Project) (api.LanguagePlugin, bool)

GetForProject returns the appropriate language plugin for a project.

func List

func List() []api.LanguagePlugin

List returns all registered language plugins.

func Register

func Register(plugin api.LanguagePlugin)

Register registers a language plugin.

Types

type AnalysisResult

type AnalysisResult struct {
	Issues  []Issue        `json:"issues"`
	Metrics map[string]any `json:"metrics"`
}

AnalysisResult holds analysis results.

type AnalyzerPlugin

type AnalyzerPlugin interface {
	Plugin
	Analyze(ctx context.Context, project *api.ProjectConfig) (*AnalysisResult, error)
}

AnalyzerPlugin analyzes code.

type ExecPlugin

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

ExecPlugin wraps an external executable as a plugin.

func (*ExecPlugin) Call

func (p *ExecPlugin) Call(ctx context.Context, method string, args map[string]any) (map[string]any, error)

Call invokes the plugin with the given method and args.

func (*ExecPlugin) Initialize

func (p *ExecPlugin) Initialize(config map[string]any) error

func (*ExecPlugin) Name

func (p *ExecPlugin) Name() string

func (*ExecPlugin) Shutdown

func (p *ExecPlugin) Shutdown() error

func (*ExecPlugin) Type

func (p *ExecPlugin) Type() PluginType

func (*ExecPlugin) Version

func (p *ExecPlugin) Version() string

type ExecutorPlugin

type ExecutorPlugin interface {
	Plugin
	CanExecute(target *api.TargetConfig) bool
	Execute(ctx context.Context, project *api.ProjectConfig, target *api.TargetConfig) error
}

ExecutorPlugin executes tasks.

type GeneratorPlugin

type GeneratorPlugin interface {
	Plugin
	Generators() []GeneratorSpec
	Generate(ctx context.Context, spec string, options map[string]any) error
}

GeneratorPlugin generates code.

type GeneratorSpec

type GeneratorSpec struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Schema      any    `json:"schema"`
}

GeneratorSpec describes a generator.

type HookPlugin

type HookPlugin interface {
	Plugin
	OnPreBuild(ctx context.Context, project *api.ProjectConfig) error
	OnPostBuild(ctx context.Context, project *api.ProjectConfig, success bool) error
	OnPreTest(ctx context.Context, project *api.ProjectConfig) error
	OnPostTest(ctx context.Context, project *api.ProjectConfig, success bool) error
}

HookPlugin provides lifecycle hooks.

type Issue

type Issue struct {
	Severity string `json:"severity"`
	Message  string `json:"message"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	Column   int    `json:"column"`
	Rule     string `json:"rule"`
}

Issue represents an analysis issue.

type LanguagePluginRegistry

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

LanguagePluginRegistry manages language-specific plugins.

func (*LanguagePluginRegistry) DetectLanguage

func (r *LanguagePluginRegistry) DetectLanguage(projectPath string) string

DetectLanguage detects the language for a project path.

func (*LanguagePluginRegistry) Get

Get returns a language plugin by name.

type Loader

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

Loader provides plugin discovery and loading.

func NewLoader

func NewLoader(registry *Registry) *Loader

NewLoader creates a new plugin loader.

func (*Loader) AddSearchPath

func (l *Loader) AddSearchPath(path string)

AddSearchPath adds a path to search for plugins.

func (*Loader) Discover

func (l *Loader) Discover() error

Discover discovers and loads all plugins.

func (*Loader) Install

func (l *Loader) Install(source string) error

Install installs a plugin from a source.

type Plugin

type Plugin interface {
	Name() string
	Version() string
	Type() PluginType
	Initialize(config map[string]any) error
	Shutdown() error
}

Plugin is the interface all plugins must implement.

type PluginManifest

type PluginManifest struct {
	Name        string         `json:"name"`
	Version     string         `json:"version"`
	Description string         `json:"description"`
	Author      string         `json:"author"`
	Type        PluginType     `json:"type"`
	Entrypoint  string         `json:"entrypoint"`
	Config      map[string]any `json:"config"`
	Hooks       []string       `json:"hooks"`
}

PluginManifest describes a plugin.

type PluginType

type PluginType string

PluginType represents the type of plugin.

const (
	// PluginTypeExecutor provides custom task execution.
	PluginTypeExecutor PluginType = "executor"
	// PluginTypeGenerator provides code generation.
	PluginTypeGenerator PluginType = "generator"
	// PluginTypeAnalyzer provides code analysis.
	PluginTypeAnalyzer PluginType = "analyzer"
	// PluginTypeCache provides custom caching.
	PluginTypeCache PluginType = "cache"
	// PluginTypeHook provides lifecycle hooks.
	PluginTypeHook PluginType = "hook"
)

type Registry

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

Registry manages loaded plugins.

func Global

func Global() *Registry

Global returns the global plugin registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry.

func (*Registry) Analyzers

func (r *Registry) Analyzers() []AnalyzerPlugin

Analyzers returns all analyzer plugins.

func (*Registry) Executors

func (r *Registry) Executors() []ExecutorPlugin

Executors returns all executor plugins.

func (*Registry) Generators

func (r *Registry) Generators() []GeneratorPlugin

Generators returns all generator plugins.

func (*Registry) Get

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

Get returns a plugin by name.

func (*Registry) Hooks

func (r *Registry) Hooks() []HookPlugin

Hooks returns all hook plugins.

func (*Registry) Initialize

func (r *Registry) Initialize(globalConfig map[string]any) error

Initialize initializes all loaded plugins.

func (*Registry) Load

func (r *Registry) Load(path string) error

Load loads a plugin from the given path.

func (*Registry) LoadFromDirectory

func (r *Registry) LoadFromDirectory(dir string) error

LoadFromDirectory loads all plugins from a directory.

func (*Registry) Shutdown

func (r *Registry) Shutdown() error

Shutdown shuts down all plugins.

Directories

Path Synopsis
Package golang provides the Go language plugin for monox.
Package golang provides the Go language plugin for monox.
Package node provides plugin support for Node.js/TypeScript projects.
Package node provides plugin support for Node.js/TypeScript projects.
Package nodejs provides the Node.js/TypeScript language plugin for monox.
Package nodejs provides the Node.js/TypeScript language plugin for monox.
Package python provides the Python language plugin for monox.
Package python provides the Python language plugin for monox.

Jump to

Keyboard shortcuts

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