decorators

package
v0.0.0-...-69549a0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
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

func CombineImports(importGroups ...[]string) []string

CombineImports merges multiple import slices and deduplicates them

func Debug

func Debug(message string)

Debug logs a debug message using the default logger

func DurationToGoExpr

func DurationToGoExpr(d time.Duration) string

DurationToGoExpr converts a time.Duration to idiomatic Go time expression

func Error

func Error(message string)

Error logs an error message using the default logger

func ErrorWithErr

func ErrorWithErr(message string, err error)

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 Info

func Info(message string)

Info logs an info message using the default logger

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted info message using the default logger

func IsActionDecorator

func IsActionDecorator(name string) bool

IsActionDecorator checks if a decorator is an action decorator

func IsBlockDecorator

func IsBlockDecorator(name string) bool

IsBlockDecorator checks if a decorator is a block decorator

func IsDecorator

func IsDecorator(name string) bool

IsDecorator checks if a name is any type of decorator

func IsPatternDecorator

func IsPatternDecorator(name string) bool

IsPatternDecorator checks if a decorator is a pattern decorator

func IsValueDecorator

func IsValueDecorator(name string) bool

IsValueDecorator checks if a decorator is a value decorator

func ListAll

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

func SanitizeEnvironmentVariableName(envName string) (string, []string)

SanitizeEnvironmentVariableName sanitizes an environment variable name Returns the sanitized name and any issues found for logging

func SanitizeNumericValue

func SanitizeNumericValue(value, min, max int) (int, bool)

SanitizeNumericValue clamps a numeric value to a safe range Returns the clamped value and whether it was modified

func SanitizePath

func SanitizePath(path string) (string, []string)

SanitizePath sanitizes a file path by removing dangerous patterns Returns the sanitized path and any issues found for logging

func SanitizeShellCommand

func SanitizeShellCommand(command string) (string, []string)

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

func SetLogFile(filename string) error

SetLogFile configures file logging for all loggers

func Trace

func Trace(message string)

Trace logs a trace message using the default logger

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

func Warn

func Warn(message string)

Warn logs a warning message using the default logger

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) Execute

func (cc *CommandConnection) Execute(command string, args ...string) (*exec.Cmd, error)

Execute runs a command using this connection

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) Cleanup

func (ce *CommandExecutor) Cleanup()

Cleanup is a no-op

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

type LogFormatter interface {
	Format(entry *LogEntry) string
}

LogFormatter interface for different log output formats

type LogLevel

type LogLevel int

LogLevel represents different logging levels

const (
	LogLevelTrace LogLevel = iota
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelFatal
)

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of log level

type LogManager

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

LogManager manages multiple loggers and global logging configuration

func GetLogManager

func GetLogManager() *LogManager

GetLogManager returns the global log manager

type Logger

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

Logger is the main logging interface

func GetLogger

func GetLogger(component string) *Logger

GetLogger returns a logger for the specified component

func NewLogger

func NewLogger(component string) *Logger

NewLogger creates a new logger instance

func (*Logger) AddOutput

func (l *Logger) AddOutput(writer io.Writer)

AddOutput adds an additional output writer

func (*Logger) Debug

func (l *Logger) Debug(message string)

Debug logs a debug message

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message

func (*Logger) Error

func (l *Logger) Error(message string)

Error logs an error message

func (*Logger) ErrorWithErr

func (l *Logger) ErrorWithErr(message string, err error)

ErrorWithErr logs an error message with an error object

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

Fatal logs a fatal message and exits

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits

func (*Logger) Info

func (l *Logger) Info(message string)

Info logs an info message

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted info message

func (*Logger) LogDuration

func (l *Logger) LogDuration(level LogLevel, message string, duration time.Duration)

LogDuration logs a message with duration information

func (*Logger) SetFormatter

func (l *Logger) SetFormatter(formatter LogFormatter)

SetFormatter sets the log formatter

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the minimum log level

func (*Logger) Trace

func (l *Logger) Trace(message string)

Trace logs a trace message

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...interface{})

Tracef logs a formatted trace message

func (*Logger) Warn

func (l *Logger) Warn(message string)

Warn logs a warning message

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message

func (*Logger) WithDecorator

func (l *Logger) WithDecorator(decoratorName string) *Logger

WithDecorator creates a logger with decorator context

func (*Logger) WithExecutionID

func (l *Logger) WithExecutionID(executionID string) *Logger

WithExecutionID creates a logger with execution ID context

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField adds a field to the logger context

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

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 NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new decorator registry

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

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) Cleanup

func (re *RetryExecutor) Cleanup()

Cleanup is a no-op

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

type TextFormatter struct {
	ShowCaller    bool
	ShowTimestamp bool
	UseColors     bool
}

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)

Jump to

Keyboard shortcuts

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