Documentation
¶
Overview ¶
Package shellmode implements the ! prefix for direct shell command execution in the REPL input, bypassing the LLM entirely.
Index ¶
- Constants
- func ExtractCommand(input string) string
- func IsDestructive(cmdStr string) bool
- func IsShellCommand(input string) bool
- func ParsePipeline(cmdStr string) []string
- func RerouteCandidate(cmdStr string, stderr string, exitCode int) bool
- type Classification
- type Mode
- type ModeManager
- type Result
Constants ¶
const ( // DefaultTimeout is the maximum execution time for a shell command. DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func ExtractCommand ¶
ExtractCommand strips the ! prefix and returns the shell command.
func IsDestructive ¶
IsDestructive performs a basic heuristic check for potentially dangerous commands.
func IsShellCommand ¶
IsShellCommand checks if the input starts with ! indicating a direct shell command.
func ParsePipeline ¶
ParsePipeline splits a shell command string into individual piped commands for display purposes only (execution still uses the full string).
Types ¶
type Classification ¶
type Classification int
Classification is the result of input analysis.
const ( ClassShell Classification = iota // execute in shell ClassAgent // route to AI agent ClassNeutral // undetermined )
func ClassifyInput ¶
func ClassifyInput(input string) Classification
ClassifyInput determines whether input should go to shell or AI agent. This is the single source of truth for routing decisions in auto mode.
type ModeManager ¶
type ModeManager struct {
// contains filtered or unexported fields
}
ModeManager handles mode state and toggling.
func NewModeManager ¶
func NewModeManager() *ModeManager
NewModeManager creates a manager starting in auto mode.
func (*ModeManager) ClassifyWithMode ¶
func (mm *ModeManager) ClassifyWithMode(input string) Classification
ClassifyWithMode applies mode override to classification. In shell/agent mode, the mode takes precedence over auto-detection.
func (*ModeManager) Current ¶
func (mm *ModeManager) Current() Mode
Current returns the active mode.
func (*ModeManager) LoadPersistedMode ¶
func (mm *ModeManager) LoadPersistedMode()
LoadPersistedMode restores mode from disk.
func (*ModeManager) Set ¶
func (mm *ModeManager) Set(m Mode)
Set changes to a specific mode and persists it.
func (*ModeManager) Toggle ¶
func (mm *ModeManager) Toggle() Mode
Toggle cycles through modes: auto → shell → agent → auto.
type Result ¶
type Result struct {
Stdout string
Stderr string
ExitCode int
Duration time.Duration
Command string
}
Result holds the output of a shell command execution.
func ExecuteShell ¶
ExecuteShell runs a command directly in the user's shell.
func ExecuteShellWithTimeout ¶
ExecuteShellWithTimeout runs a command with a custom timeout.