Documentation
¶
Index ¶
- func AugmentAuditMetadata(ctx Context, candidate *Candidate, metadata map[string]interface{}) error
- func CheckApprovalRequired(candidate *Candidate) bool
- func ExecutePostExecutionHooks(ctx Context, candidate *Candidate, sandboxID string, exitCode int, ...) error
- func ExecutePreExecutionHooks(ctx Context, candidate *Candidate) error
- func LoadBuiltins() error
- func Register(plugin Plugin, metadata *PluginMetadata) error
- type AuditHookData
- type Candidate
- type CheckResult
- type Context
- type ExecutionHookData
- type HookFunc
- type HookType
- type Loader
- type Plugin
- type PluginError
- type PluginMetadata
- type Registry
- func (r *Registry) Disable(name string) error
- func (r *Registry) Enable(name string) error
- func (r *Registry) ExecuteHooks(hookType HookType, ctx Context, data interface{}) error
- func (r *Registry) Get(name string) (Plugin, error)
- func (r *Registry) GetMetadata(name string) (*PluginMetadata, error)
- func (r *Registry) List() []Plugin
- func (r *Registry) ListEnabled() []Plugin
- func (r *Registry) Register(plugin Plugin, metadata *PluginMetadata) error
- func (r *Registry) RegisterHook(hookType HookType, fn HookFunc)
- func (r *Registry) Unregister(name string) error
- type Risk
- type Step
- type TranslateHookData
- type UndoStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AugmentAuditMetadata ¶
AugmentAuditMetadata adds plugin metadata to audit entries
func CheckApprovalRequired ¶
CheckApprovalRequired checks if any plugin requires approval for a candidate
func ExecutePostExecutionHooks ¶
func ExecutePostExecutionHooks(ctx Context, candidate *Candidate, sandboxID string, exitCode int, stdout, stderr []byte) error
ExecutePostExecutionHooks runs post-execution hooks
func ExecutePreExecutionHooks ¶
ExecutePreExecutionHooks runs pre-execution hooks
func LoadBuiltins ¶
func LoadBuiltins() error
LoadBuiltins loads built-in plugins into the default registry
func Register ¶
func Register(plugin Plugin, metadata *PluginMetadata) error
Register registers a plugin with the default registry
Types ¶
type AuditHookData ¶
AuditHookData contains data for audit metadata hooks
type Candidate ¶
type Candidate struct {
Command string
Explanation string
Breakdown []Step
Confidence int
RiskLevel Risk
AffectedPaths []string
NetworkTargets []string
Destructive bool
RequiresConfirm bool
DocLinks []string
// Plugin-specific metadata
PluginName string
PluginMetadata map[string]interface{}
UndoStrategy *UndoStrategy
}
Candidate represents a command candidate with plugin metadata
type CheckResult ¶
type CheckResult struct {
Allowed bool
Reason string
RequiresApproval bool
ApprovalMessage string
AdditionalChecks []string
Metadata map[string]interface{}
}
CheckResult contains the result of a pre-run safety check
func PreRunCheckWithPlugins ¶
func PreRunCheckWithPlugins(ctx Context, candidate *Candidate) (*CheckResult, error)
PreRunCheckWithPlugins performs pre-run checks using plugins
type Context ¶
type Context struct {
WorkingDir string
User string
Timestamp time.Time
Metadata map[string]interface{}
}
Context provides execution context to plugins
type ExecutionHookData ¶
type ExecutionHookData struct {
Candidate *Candidate
SandboxID string
ExitCode int
Stdout []byte
Stderr []byte
}
ExecutionHookData contains data for execution hooks
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles plugin loading and initialization
func DefaultLoader ¶
func DefaultLoader() *Loader
DefaultLoader returns a loader for the default registry
func (*Loader) LoadBuiltins ¶
LoadBuiltins loads all built-in plugins
func (*Loader) LoadPlugin ¶
func (l *Loader) LoadPlugin(plugin Plugin, metadata *PluginMetadata) error
LoadPlugin loads a single plugin
func (*Loader) ReloadPlugin ¶
func (l *Loader) ReloadPlugin(name string, plugin Plugin, metadata *PluginMetadata) error
ReloadPlugin reloads a plugin
func (*Loader) UnloadPlugin ¶
UnloadPlugin unloads a plugin by name
type Plugin ¶
type Plugin interface {
// Name returns the unique name of the plugin
Name() string
// Translate attempts to translate a natural language prompt into command candidates
// Returns empty slice if the plugin doesn't handle this prompt
Translate(ctx Context, prompt string) ([]*Candidate, error)
// PreRunCheck performs safety checks before command execution
// Can add additional approval requirements or deny execution
PreRunCheck(ctx Context, candidate *Candidate) (*CheckResult, error)
// RequiresApproval returns true if this candidate requires approval
RequiresApproval(candidate *Candidate) bool
// Scopes returns the required scopes/permissions for this plugin
Scopes() []string
}
Plugin defines the interface that all QuickCMD plugins must implement
func ListEnabled ¶
func ListEnabled() []Plugin
ListEnabled returns all enabled plugins from the default registry
type PluginError ¶
PluginError represents a plugin-specific error
func (*PluginError) Error ¶
func (e *PluginError) Error() string
func (*PluginError) Unwrap ¶
func (e *PluginError) Unwrap() error
type PluginMetadata ¶
type PluginMetadata struct {
Name string
Version string
Description string
Author string
Scopes []string
Enabled bool
}
PluginMetadata contains plugin registration metadata
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages plugin registration and lifecycle
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns the global plugin registry
func (*Registry) ExecuteHooks ¶
ExecuteHooks executes all hooks of a given type
func (*Registry) GetMetadata ¶
func (r *Registry) GetMetadata(name string) (*PluginMetadata, error)
GetMetadata retrieves plugin metadata
func (*Registry) ListEnabled ¶
ListEnabled returns all enabled plugins
func (*Registry) Register ¶
func (r *Registry) Register(plugin Plugin, metadata *PluginMetadata) error
Register registers a plugin with the registry
func (*Registry) RegisterHook ¶
RegisterHook registers a hook function
func (*Registry) Unregister ¶
Unregister removes a plugin from the registry
type TranslateHookData ¶
TranslateHookData contains data for translation hooks