Documentation
¶
Index ¶
- Constants
- Variables
- func CombineImports(importGroups ...[]string) []string
- func Debug(message string)
- func DurationToGoExpr(d time.Duration) string
- func Error(message string)
- func ErrorWithErr(message string, err error)
- func Errorf(format string, args ...interface{})
- func GetAny(name string) (Decorator, DecoratorType, error)
- func Info(message string)
- func Infof(format string, args ...interface{})
- func IsActionDecorator(name string) bool
- func IsBlockDecorator(name string) bool
- func IsDecorator(name string) bool
- func IsPatternDecorator(name string) bool
- func IsValueDecorator(name string) bool
- func ListAll() ([]ValueDecorator, []ActionDecorator, []BlockDecorator, []PatternDecorator)
- func RegisterAction(decorator ActionDecorator)
- func RegisterBlock(decorator BlockDecorator)
- func RegisterPattern(decorator PatternDecorator)
- func RegisterValue(decorator ValueDecorator)
- func ResolvePositionalParameters(params []ast.NamedParameter, schema []ParameterSchema) ([]ast.NamedParameter, error)
- func SanitizeEnvironmentVariableName(envName string) (string, []string)
- func SanitizeNumericValue(value, min, max int) (int, bool)
- func SanitizePath(path string) (string, []string)
- func SanitizeShellCommand(command string) (string, []string)
- func SetGlobalLogLevel(level LogLevel)
- func SetJSONLogging()
- func SetLogFile(filename string) error
- func Trace(message string)
- func ValidateDuration(params []ast.NamedParameter, paramName string, ...) error
- func ValidateEnvironmentVariableName(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidateIntegerRange(params []ast.NamedParameter, paramName string, min, max int, ...) error
- func ValidateNoPrivilegeEscalation(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidateNumericBounds(params []ast.NamedParameter, paramName string, min, max int, ...) (int, error)
- func ValidateOptionalParameter(params []ast.NamedParameter, paramName string, expectedType ast.ExpressionType, ...) error
- func ValidateParameterCount(params []ast.NamedParameter, minParams, maxParams int, decoratorName string) error
- func ValidateParameterType(paramName string, paramValue ast.Expression, expectedType ast.ExpressionType, ...) error
- func ValidatePathSafety(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidatePositiveInteger(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidateRequiredParameter(params []ast.NamedParameter, paramName string, expectedType ast.ExpressionType, ...) error
- func ValidateResourceLimits(params []ast.NamedParameter, paramName string, maxValue int, ...) error
- func ValidateSchemaCompliance(params []ast.NamedParameter, schema []ParameterSchema, decoratorName string) error
- func ValidateShellCommandSafety(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidateStringContent(params []ast.NamedParameter, paramName string, decoratorName string) error
- func ValidateTimeoutSafety(params []ast.NamedParameter, paramName string, maxTimeout time.Duration, ...) error
- func Warn(message string)
- type ActionDecorator
- type BlockDecorator
- type CommandConnection
- type CommandDependencyProvider
- type CommandExecutor
- type ConcurrentExecutor
- type ConnectionPool
- func (cp *ConnectionPool) Close()
- func (cp *ConnectionPool) CloseConnection(conn *CommandConnection)
- func (cp *ConnectionPool) GetConnection(workingDir string, env []string) (*CommandConnection, error)
- func (cp *ConnectionPool) GetStats() map[string]interface{}
- func (cp *ConnectionPool) ReturnConnection(conn *CommandConnection)
- type Decorator
- type DecoratorType
- type ExecutionFunction
- type ImportRequirement
- func RequiresConcurrency() ImportRequirement
- func RequiresContext() ImportRequirement
- func RequiresCore() ImportRequirement
- func RequiresFileSystem() ImportRequirement
- func RequiresResourceCleanup() ImportRequirement
- func RequiresTime() ImportRequirement
- func RequiresTryCatchFinally() ImportRequirement
- func StandardImportRequirement(importGroups ...[]string) ImportRequirement
- type JSONFormatter
- type LogEntry
- type LogFormatter
- type LogLevel
- type LogManager
- type Logger
- func (l *Logger) AddOutput(writer io.Writer)
- func (l *Logger) Debug(message string)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(message string)
- func (l *Logger) ErrorWithErr(message string, err error)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(message string)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(message string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) LogDuration(level LogLevel, message string, duration time.Duration)
- func (l *Logger) SetFormatter(formatter LogFormatter)
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) Trace(message string)
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warn(message string)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WithDecorator(decoratorName string) *Logger
- func (l *Logger) WithExecutionID(executionID string) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields map[string]interface{}) *Logger
- type ParameterSchema
- type PatternDecorator
- type PatternSchema
- type PooledCommandExecutor
- type Registry
- func (r *Registry) GetAction(name string) (ActionDecorator, bool)
- func (r *Registry) GetAny(name string) (Decorator, DecoratorType, bool)
- func (r *Registry) GetBlock(name string) (BlockDecorator, bool)
- func (r *Registry) GetPattern(name string) (PatternDecorator, bool)
- func (r *Registry) GetValue(name string) (ValueDecorator, bool)
- func (r *Registry) ListAll() ([]ValueDecorator, []ActionDecorator, []BlockDecorator, []PatternDecorator)
- func (r *Registry) RegisterAction(decorator ActionDecorator)
- func (r *Registry) RegisterBlock(decorator BlockDecorator)
- func (r *Registry) RegisterPattern(decorator PatternDecorator)
- func (r *Registry) RegisterValue(decorator ValueDecorator)
- type RetryExecutor
- type SecurityValidationSummary
- type TextFormatter
- type TimeoutExecutor
- type ValueDecorator
Constants ¶
const ( // ConcurrentExecutionPattern - Generic pattern for running multiple operations concurrently // Variables: .MaxConcurrency, .Operations[] (each has .Code) ConcurrentExecutionPattern = `` /* 1037-byte string literal not displayed */ // TimeoutPattern - Generic timeout wrapper for any operation // Variables: .DurationExpr (string) - idiomatic Go time expression like "30 * time.Second" TimeoutPattern = `` /* 920-byte string literal not displayed */ // RetryPattern - Generic retry wrapper for any operation // Variables: .MaxAttempts, .DelayDuration (string), .Operation.Code RetryPattern = `` /* 829-byte string literal not displayed */ // CancellableOperationPattern - Generic cancellable operation // Variables: .Operation.Code CancellableOperationPattern = `` /* 719-byte string literal not displayed */ // SequentialExecutionPattern - Generic sequential execution with early termination // Variables: .Operations[] (each has .Code), .StopOnError (bool) SequentialExecutionPattern = `` /* 481-byte string literal not displayed */ // ConditionalExecutionPattern - Generic conditional execution // Variables: .Condition.Code, .ThenOperation.Code, .ElseOperation.Code (optional) ConditionalExecutionPattern = `` /* 425-byte string literal not displayed */ // ResourceCleanupPattern - Generic resource cleanup with defer // Variables: .SetupCode, .Operation.Code, .CleanupCode ResourceCleanupPattern = `` /* 293-byte string literal not displayed */ // ErrorCollectionPattern - Generic error collection from multiple operations // Variables: .Operations[] (each has .Code), .ContinueOnError (bool) ErrorCollectionPattern = `` /* 833-byte string literal not displayed */ // TryCatchFinallyPattern - Generic try-catch-finally pattern // Variables: .MainOperation.Code, .CatchOperation.Code (optional), .FinallyOperation.Code (optional), .HasCatch (bool), .HasFinally (bool) TryCatchFinallyPattern = `` /* 1325-byte string literal not displayed */ )
Variables ¶
var ( CoreImports = []string{"fmt"} ConcurrencyImports = []string{"sync"} TimeImports = []string{"time"} ContextImports = []string{"context"} FileSystemImports = []string{"os"} StringImports = []string{"strings"} )
Common import groups that patterns can reference
var PatternImports = map[string][]string{ "ConcurrentExecutionPattern": CombineImports(CoreImports, StringImports, ConcurrencyImports), "TimeoutPattern": CombineImports(ContextImports, CoreImports, TimeImports), "RetryPattern": CombineImports(CoreImports, TimeImports), "CancellableOperationPattern": CombineImports(ContextImports, CoreImports), "SequentialExecutionPattern": CombineImports(CoreImports), "ConditionalExecutionPattern": CombineImports(CoreImports), "ResourceCleanupPattern": CombineImports(CoreImports), "ErrorCollectionPattern": CombineImports(CoreImports), "TryCatchFinallyPattern": CombineImports(CoreImports, FileSystemImports), }
PatternImports maps each pattern to its required standard library imports
Functions ¶
func CombineImports ¶
CombineImports merges multiple import slices and deduplicates them
func DurationToGoExpr ¶
DurationToGoExpr converts a time.Duration to idiomatic Go time expression
func ErrorWithErr ¶
ErrorWithErr logs an error message with error using the default logger
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a formatted error message using the default logger
func GetAny ¶
func GetAny(name string) (Decorator, DecoratorType, error)
GetAny retrieves any decorator from the global registry
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a formatted info message using the default logger
func IsActionDecorator ¶
IsActionDecorator checks if a decorator is an action decorator
func IsBlockDecorator ¶
IsBlockDecorator checks if a decorator is a block decorator
func IsDecorator ¶
IsDecorator checks if a name is any type of decorator
func IsPatternDecorator ¶
IsPatternDecorator checks if a decorator is a pattern decorator
func IsValueDecorator ¶
IsValueDecorator checks if a decorator is a value decorator
func ListAll ¶
func ListAll() ([]ValueDecorator, []ActionDecorator, []BlockDecorator, []PatternDecorator)
ListAll returns all registered decorators from the global registry
func RegisterAction ¶
func RegisterAction(decorator ActionDecorator)
RegisterAction registers an action decorator in the global registry
func RegisterBlock ¶
func RegisterBlock(decorator BlockDecorator)
RegisterBlock registers a block decorator in the global registry
func RegisterPattern ¶
func RegisterPattern(decorator PatternDecorator)
RegisterPattern registers a pattern decorator in the global registry
func RegisterValue ¶
func RegisterValue(decorator ValueDecorator)
RegisterValue registers a value decorator in the global registry
func ResolvePositionalParameters ¶
func ResolvePositionalParameters(params []ast.NamedParameter, schema []ParameterSchema) ([]ast.NamedParameter, error)
ResolvePositionalParameters converts positional parameters to named parameters based on their position in the parameter schema. This implements Kotlin-style parameter handling where positional parameters are mapped to schema parameters by position, and named parameters are preserved as-is.
Rules: 1. Positional parameters (Name == "") are mapped to schema parameters by position 2. Named parameters are preserved as-is 3. Positional parameters must come before named parameters (Kotlin rule) 4. Cannot have more positional parameters than schema parameters
func SanitizeEnvironmentVariableName ¶
SanitizeEnvironmentVariableName sanitizes an environment variable name Returns the sanitized name and any issues found for logging
func SanitizeNumericValue ¶
SanitizeNumericValue clamps a numeric value to a safe range Returns the clamped value and whether it was modified
func SanitizePath ¶
SanitizePath sanitizes a file path by removing dangerous patterns Returns the sanitized path and any issues found for logging
func SanitizeShellCommand ¶
SanitizeShellCommand sanitizes a shell command string by removing dangerous patterns Returns the sanitized command and a list of removed patterns for logging
func SetGlobalLogLevel ¶
func SetGlobalLogLevel(level LogLevel)
SetGlobalLogLevel sets the log level for all loggers
func SetJSONLogging ¶
func SetJSONLogging()
SetJSONLogging configures all loggers to use JSON format
func SetLogFile ¶
SetLogFile configures file logging for all loggers
func ValidateDuration ¶
func ValidateDuration(params []ast.NamedParameter, paramName string, minDuration, maxDuration time.Duration, decoratorName string) error
ValidateDuration validates that a duration parameter is valid and within reasonable bounds
func ValidateEnvironmentVariableName ¶
func ValidateEnvironmentVariableName(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidateEnvironmentVariableName validates that an environment variable name is safe
func ValidateIntegerRange ¶
func ValidateIntegerRange(params []ast.NamedParameter, paramName string, min, max int, decoratorName string) error
ValidateIntegerRange validates that a numeric parameter is within a specific range
func ValidateNoPrivilegeEscalation ¶
func ValidateNoPrivilegeEscalation(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidateNoPrivilegeEscalation validates that parameters don't attempt privilege escalation
func ValidateNumericBounds ¶
func ValidateNumericBounds(params []ast.NamedParameter, paramName string, min, max int, decoratorName string, allowClamping bool) (int, error)
ValidateNumericBounds validates that a numeric parameter is within safe bounds This is more flexible than ValidateIntegerRange as it allows auto-clamping
func ValidateOptionalParameter ¶
func ValidateOptionalParameter(params []ast.NamedParameter, paramName string, expectedType ast.ExpressionType, decoratorName string) error
ValidateOptionalParameter validates that an optional parameter (if present) has the correct type
func ValidateParameterCount ¶
func ValidateParameterCount(params []ast.NamedParameter, minParams, maxParams int, decoratorName string) error
ValidateParameterCount validates that the number of parameters is within expected bounds
func ValidateParameterType ¶
func ValidateParameterType(paramName string, paramValue ast.Expression, expectedType ast.ExpressionType, decoratorName string) error
ValidateParameterType validates that a parameter value matches the expected type Allows both literal values and identifiers (which can resolve at runtime)
func ValidatePathSafety ¶
func ValidatePathSafety(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidatePathSafety validates that a path parameter is safe (no directory traversal, etc.)
func ValidatePositiveInteger ¶
func ValidatePositiveInteger(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidatePositiveInteger validates that a numeric parameter is positive
func ValidateRequiredParameter ¶
func ValidateRequiredParameter(params []ast.NamedParameter, paramName string, expectedType ast.ExpressionType, decoratorName string) error
ValidateRequiredParameter validates that a required parameter exists and has the correct type
func ValidateResourceLimits ¶
func ValidateResourceLimits(params []ast.NamedParameter, paramName string, maxValue int, decoratorName string) error
ValidateResourceLimits validates that resource-related parameters are within safe bounds
func ValidateSchemaCompliance ¶
func ValidateSchemaCompliance(params []ast.NamedParameter, schema []ParameterSchema, decoratorName string) error
ValidateSchemaCompliance validates parameters against a decorator's parameter schema
func ValidateShellCommandSafety ¶
func ValidateShellCommandSafety(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidateShellCommandSafety validates that a string doesn't contain shell injection patterns This is for parameters that might be used directly in shell commands
func ValidateStringContent ¶
func ValidateStringContent(params []ast.NamedParameter, paramName string, decoratorName string) error
ValidateStringContent validates that a string parameter doesn't contain dangerous content
func ValidateTimeoutSafety ¶
func ValidateTimeoutSafety(params []ast.NamedParameter, paramName string, maxTimeout time.Duration, decoratorName string) error
ValidateTimeoutSafety validates that timeout values are reasonable and safe
Types ¶
type ActionDecorator ¶
type ActionDecorator interface {
Decorator
// ExpandInterpreter executes and returns CommandResult for interpreter mode
ExpandInterpreter(ctx execution.InterpreterContext, params []ast.NamedParameter) *execution.ExecutionResult
// GenerateTemplate returns template for Go code that produces CommandResult for generator mode
GenerateTemplate(ctx execution.GeneratorContext, params []ast.NamedParameter) (*execution.TemplateResult, error)
// ExpandPlan returns description for dry-run display in plan mode
ExpandPlan(ctx execution.PlanContext, params []ast.NamedParameter) *execution.ExecutionResult
}
ActionDecorator represents decorators that execute commands with structured output Examples: @cmd - can be standalone or chained with shell operators
func GetAction ¶
func GetAction(name string) (ActionDecorator, error)
GetAction retrieves an action decorator from the global registry
func GetActionDecorator ¶
func GetActionDecorator(name string) (ActionDecorator, bool)
GetActionDecorator is an alias for GetAction but returns only the decorator (for compatibility)
type BlockDecorator ¶
type BlockDecorator interface {
Decorator
// ExecuteInterpreter provides execution for interpreter mode
ExecuteInterpreter(ctx execution.InterpreterContext, params []ast.NamedParameter, content []ast.CommandContent) *execution.ExecutionResult
// GenerateTemplate provides template-based code generation
GenerateTemplate(ctx execution.GeneratorContext, params []ast.NamedParameter, content []ast.CommandContent) (*execution.TemplateResult, error)
// ExecutePlan provides plan generation for plan mode
ExecutePlan(ctx execution.PlanContext, params []ast.NamedParameter, content []ast.CommandContent) *execution.ExecutionResult
}
BlockDecorator represents decorators that modify command execution behavior Examples: @watch, @stop, @parallel
func GetBlock ¶
func GetBlock(name string) (BlockDecorator, error)
GetBlock retrieves a block decorator from the global registry
func GetBlockDecorator ¶
func GetBlockDecorator(name string) (BlockDecorator, bool)
GetBlockDecorator is an alias for GetBlock but returns only the decorator (for compatibility)
type CommandConnection ¶
type CommandConnection struct {
ID string
CreatedAt time.Time
LastUsedAt time.Time
UsageCount int64
WorkingDir string
Environment []string
IsIdle bool
// contains filtered or unexported fields
}
CommandConnection represents a reusable command execution context
func NewCommandConnection ¶
func NewCommandConnection(id, workingDir string, env []string) *CommandConnection
NewCommandConnection creates a new command connection
func (*CommandConnection) Close ¶
func (cc *CommandConnection) Close()
Close closes the connection and cancels any running commands
func (*CommandConnection) IsExpired ¶
func (cc *CommandConnection) IsExpired(maxIdleTime time.Duration) bool
IsExpired checks if the connection has expired based on idle time
func (*CommandConnection) MarkIdle ¶
func (cc *CommandConnection) MarkIdle()
MarkIdle marks the connection as idle and available for reuse
type CommandDependencyProvider ¶
type CommandDependencyProvider interface {
// GetCommandDependencies returns the names of commands this decorator depends on
// Parameters: the decorator's parameters as provided in the AST
// Returns: slice of command names that must be declared before this decorator is used
GetCommandDependencies(params []ast.NamedParameter) []string
}
CommandDependencyProvider interface for decorators that reference other commands This allows the code generator to determine proper function declaration order
type CommandExecutor ¶
type CommandExecutor struct{}
CommandExecutor provides utilities for executing AST CommandContent with proper type handling
func NewCommandExecutor ¶
func NewCommandExecutor() *CommandExecutor
NewCommandExecutor creates a new command executor
func (*CommandExecutor) ExecuteCommandWithInterpreter ¶
func (ce *CommandExecutor) ExecuteCommandWithInterpreter(ctx execution.InterpreterContext, cmd ast.CommandContent) error
ExecuteCommandWithInterpreter executes a single command using interpreter context
func (*CommandExecutor) ExecuteCommandsWithInterpreter ¶
func (ce *CommandExecutor) ExecuteCommandsWithInterpreter(ctx execution.InterpreterContext, commands []ast.CommandContent) error
ExecuteCommandsWithInterpreter executes multiple commands sequentially
type ConcurrentExecutor ¶
type ConcurrentExecutor struct {
// contains filtered or unexported fields
}
ConcurrentExecutor provides utilities for safe parallel execution
func NewConcurrentExecutor ¶
func NewConcurrentExecutor(concurrency int) *ConcurrentExecutor
NewConcurrentExecutor creates a new concurrent executor
func (*ConcurrentExecutor) Cleanup ¶
func (ce *ConcurrentExecutor) Cleanup()
Cleanup is a no-op since context handles cancellation
func (*ConcurrentExecutor) Execute ¶
func (ce *ConcurrentExecutor) Execute(functions []ExecutionFunction) error
Execute runs functions concurrently with proper context cancellation
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool manages a pool of reusable command connections
func GetGlobalConnectionPool ¶
func GetGlobalConnectionPool() *ConnectionPool
GetGlobalConnectionPool returns the global connection pool
func NewConnectionPool ¶
func NewConnectionPool(maxConnections int, maxIdleTime, cleanupInterval time.Duration) *ConnectionPool
NewConnectionPool creates a new connection pool
func (*ConnectionPool) Close ¶
func (cp *ConnectionPool) Close()
Close closes all connections and stops the cleanup routine
func (*ConnectionPool) CloseConnection ¶
func (cp *ConnectionPool) CloseConnection(conn *CommandConnection)
CloseConnection closes and removes a connection from the pool
func (*ConnectionPool) GetConnection ¶
func (cp *ConnectionPool) GetConnection(workingDir string, env []string) (*CommandConnection, error)
GetConnection gets or creates a connection for the specified working directory and environment
func (*ConnectionPool) GetStats ¶
func (cp *ConnectionPool) GetStats() map[string]interface{}
GetStats returns pool statistics
func (*ConnectionPool) ReturnConnection ¶
func (cp *ConnectionPool) ReturnConnection(conn *CommandConnection)
ReturnConnection returns a connection to the pool
type Decorator ¶
type Decorator interface {
Name() string
Description() string
ParameterSchema() []ParameterSchema
// ImportRequirements returns the dependencies needed for code generation
ImportRequirements() ImportRequirement
}
Decorator is a union interface for all decorator types Used for registry and common operations
type DecoratorType ¶
type DecoratorType int
DecoratorType represents the type of decorator
const ( ValueType DecoratorType = iota ActionType BlockType PatternType )
func GetDecoratorType ¶
func GetDecoratorType(d Decorator) DecoratorType
GetDecoratorType returns the type of a decorator Note: Due to interface signature overlap, ActionDecorator and ValueDecorator cannot be reliably distinguished through type assertion alone
type ExecutionFunction ¶
type ExecutionFunction func() error
ExecutionFunction represents a function that can be executed with error handling
type ImportRequirement ¶
type ImportRequirement struct {
StandardLibrary []string // Standard library imports (e.g., "time", "context", "sync")
ThirdParty []string // Third-party imports (e.g., "github.com/pkg/errors")
GoModules map[string]string // Module dependencies for go.mod (module -> version)
}
ImportRequirement describes dependencies needed for code generation
func RequiresConcurrency ¶
func RequiresConcurrency() ImportRequirement
RequiresConcurrency is a helper for decorators that need concurrency primitives
func RequiresContext ¶
func RequiresContext() ImportRequirement
RequiresContext is a helper for decorators that need context operations
func RequiresCore ¶
func RequiresCore() ImportRequirement
RequiresCore is a helper for decorators that need basic fmt functionality
func RequiresFileSystem ¶
func RequiresFileSystem() ImportRequirement
RequiresFileSystem is a helper for decorators that need file system operations
func RequiresResourceCleanup ¶
func RequiresResourceCleanup() ImportRequirement
RequiresResourceCleanup is a helper for decorators that use ResourceCleanupPattern
func RequiresTime ¶
func RequiresTime() ImportRequirement
RequiresTime is a helper for decorators that need time operations
func RequiresTryCatchFinally ¶
func RequiresTryCatchFinally() ImportRequirement
RequiresTryCatchFinally is a helper for decorators that use TryCatchFinallyPattern
func StandardImportRequirement ¶
func StandardImportRequirement(importGroups ...[]string) ImportRequirement
StandardImportRequirement creates an ImportRequirement with standard library imports only
type JSONFormatter ¶
type JSONFormatter struct{}
JSONFormatter outputs logs in JSON format
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(entry *LogEntry) string
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level LogLevel `json:"level"`
Message string `json:"message"`
Component string `json:"component"`
Decorator string `json:"decorator,omitempty"`
ExecutionID string `json:"execution_id,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
Error string `json:"error,omitempty"`
Caller string `json:"caller,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
StackTrace []string `json:"stack_trace,omitempty"`
}
LogEntry represents a structured log entry
type LogFormatter ¶
LogFormatter interface for different log output formats
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
LogManager manages multiple loggers and global logging configuration
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the main logging interface
func (*Logger) ErrorWithErr ¶
ErrorWithErr logs an error message with an error object
func (*Logger) LogDuration ¶
LogDuration logs a message with duration information
func (*Logger) SetFormatter ¶
func (l *Logger) SetFormatter(formatter LogFormatter)
SetFormatter sets the log formatter
func (*Logger) WithDecorator ¶
WithDecorator creates a logger with decorator context
func (*Logger) WithExecutionID ¶
WithExecutionID creates a logger with execution ID context
func (*Logger) WithFields ¶
WithFields adds multiple fields to the logger context
type ParameterSchema ¶
type ParameterSchema struct {
Name string // Parameter name (e.g., "key", "default")
Type ast.ExpressionType // Parameter type (StringType, NumberType, etc.)
Required bool // Whether this parameter is required
Description string // Human-readable description
}
ParameterSchema describes a decorator parameter
type PatternDecorator ¶
type PatternDecorator interface {
Decorator
// ExecuteInterpreter provides execution for interpreter mode
ExecuteInterpreter(ctx execution.InterpreterContext, params []ast.NamedParameter, patterns []ast.PatternBranch) *execution.ExecutionResult
// GenerateTemplate provides template-based code generation
GenerateTemplate(ctx execution.GeneratorContext, params []ast.NamedParameter, patterns []ast.PatternBranch) (*execution.TemplateResult, error)
// ExecutePlan provides plan generation for plan mode
ExecutePlan(ctx execution.PlanContext, params []ast.NamedParameter, patterns []ast.PatternBranch) *execution.ExecutionResult
// PatternSchema defines what patterns this decorator accepts
PatternSchema() PatternSchema
}
PatternDecorator represents decorators that handle pattern matching Examples: @when, @try
func GetPattern ¶
func GetPattern(name string) (PatternDecorator, error)
GetPattern retrieves a pattern decorator from the global registry
func GetPatternDecorator ¶
func GetPatternDecorator(name string) (PatternDecorator, bool)
GetPatternDecorator is an alias for GetPattern but returns only the decorator (for compatibility)
type PatternSchema ¶
type PatternSchema struct {
AllowedPatterns []string // Specific patterns allowed (e.g., ["main", "error", "finally"] for @try)
RequiredPatterns []string // Patterns that must be present (e.g., ["main"] for @try)
AllowsWildcard bool // Whether "default" wildcard is allowed (e.g., true for @when)
AllowsAnyIdentifier bool // Whether any identifier is allowed (e.g., true for @when)
Description string // Human-readable description of pattern rules
}
PatternSchema describes what patterns a pattern decorator accepts
type PooledCommandExecutor ¶
type PooledCommandExecutor struct {
// contains filtered or unexported fields
}
PooledCommandExecutor provides command execution with connection pooling
func GetPooledCommandExecutor ¶
func GetPooledCommandExecutor() *PooledCommandExecutor
GetPooledCommandExecutor returns a command executor that uses the global connection pool
func NewPooledCommandExecutor ¶
func NewPooledCommandExecutor(pool *ConnectionPool) *PooledCommandExecutor
NewPooledCommandExecutor creates a new pooled command executor
func (*PooledCommandExecutor) Cleanup ¶
func (pce *PooledCommandExecutor) Cleanup()
Cleanup closes the connection pool if it's a default pool
func (*PooledCommandExecutor) ExecuteCommand ¶
func (pce *PooledCommandExecutor) ExecuteCommand(workingDir string, env []string, command string, args ...string) (*exec.Cmd, error)
ExecuteCommand executes a command using a pooled connection
func (*PooledCommandExecutor) GetPoolStats ¶
func (pce *PooledCommandExecutor) GetPoolStats() map[string]interface{}
GetPoolStats returns connection pool statistics
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all available decorators
func (*Registry) GetAction ¶
func (r *Registry) GetAction(name string) (ActionDecorator, bool)
GetAction retrieves an action decorator by name
func (*Registry) GetAny ¶
func (r *Registry) GetAny(name string) (Decorator, DecoratorType, bool)
GetAny retrieves any decorator by name, returning the decorator and its type
func (*Registry) GetBlock ¶
func (r *Registry) GetBlock(name string) (BlockDecorator, bool)
GetBlock retrieves a block decorator by name
func (*Registry) GetPattern ¶
func (r *Registry) GetPattern(name string) (PatternDecorator, bool)
GetPattern retrieves a pattern decorator by name
func (*Registry) GetValue ¶
func (r *Registry) GetValue(name string) (ValueDecorator, bool)
GetValue retrieves a value decorator by name
func (*Registry) ListAll ¶
func (r *Registry) ListAll() ([]ValueDecorator, []ActionDecorator, []BlockDecorator, []PatternDecorator)
ListAll returns all registered decorators by type
func (*Registry) RegisterAction ¶
func (r *Registry) RegisterAction(decorator ActionDecorator)
RegisterAction registers an action decorator
func (*Registry) RegisterBlock ¶
func (r *Registry) RegisterBlock(decorator BlockDecorator)
RegisterBlock registers a block decorator
func (*Registry) RegisterPattern ¶
func (r *Registry) RegisterPattern(decorator PatternDecorator)
RegisterPattern registers a pattern decorator
func (*Registry) RegisterValue ¶
func (r *Registry) RegisterValue(decorator ValueDecorator)
RegisterValue registers a value decorator
type RetryExecutor ¶
type RetryExecutor struct {
// contains filtered or unexported fields
}
RetryExecutor provides utilities for retry-based execution
func NewRetryExecutor ¶
func NewRetryExecutor(maxAttempts int, delay time.Duration) *RetryExecutor
NewRetryExecutor creates a new retry executor
func (*RetryExecutor) Execute ¶
func (re *RetryExecutor) Execute(fn ExecutionFunction) error
Execute runs a function with retry logic
type SecurityValidationSummary ¶
type SecurityValidationSummary struct {
ParameterCount int
PathValidations int
ShellValidations int
PrivilegeChecks int
ResourceLimitChecks int
ValidationErrors []string
}
SecurityValidationSummary provides a summary of security validations performed
func PerformComprehensiveSecurityValidation ¶
func PerformComprehensiveSecurityValidation(params []ast.NamedParameter, schema []ParameterSchema, decoratorName string) (*SecurityValidationSummary, error)
PerformComprehensiveSecurityValidation performs all relevant security validations
type TextFormatter ¶
TextFormatter outputs logs in human-readable text format
func (*TextFormatter) Format ¶
func (f *TextFormatter) Format(entry *LogEntry) string
type TimeoutExecutor ¶
type TimeoutExecutor struct {
// contains filtered or unexported fields
}
TimeoutExecutor provides utilities for timeout-based execution
func NewTimeoutExecutor ¶
func NewTimeoutExecutor(timeout time.Duration) *TimeoutExecutor
NewTimeoutExecutor creates a new timeout executor
func (*TimeoutExecutor) Cleanup ¶
func (te *TimeoutExecutor) Cleanup()
Cleanup is a no-op since context handles cancellation
func (*TimeoutExecutor) Execute ¶
func (te *TimeoutExecutor) Execute(fn ExecutionFunction) error
Execute runs a function with timeout
type ValueDecorator ¶
type ValueDecorator interface {
Decorator
// ExpandInterpreter returns the actual runtime value for interpreter mode
ExpandInterpreter(ctx execution.InterpreterContext, params []ast.NamedParameter) *execution.ExecutionResult
// GenerateTemplate returns template for Go code expression that evaluates to the value for generator mode
GenerateTemplate(ctx execution.GeneratorContext, params []ast.NamedParameter) (*execution.TemplateResult, error)
// ExpandPlan returns description for dry-run display in plan mode
ExpandPlan(ctx execution.PlanContext, params []ast.NamedParameter) *execution.ExecutionResult
}
ValueDecorator represents decorators that provide values for shell interpolation Examples: @var, @env - inline value substitution only
func GetValue ¶
func GetValue(name string) (ValueDecorator, error)
GetValue retrieves a value decorator from the global registry
func GetValueDecorator ¶
func GetValueDecorator(name string) (ValueDecorator, bool)
GetValueDecorator is an alias for GetValue but returns only the decorator (for compatibility)