Documentation
¶
Overview ¶
Package executor provides CLI execution for Claude and Codex tools.
Index ¶
Constants ¶
const CodexReviewerAgentName = "reviewer"
CodexReviewerAgentName is the agent name registered with codex when features.multi_agent is enabled. shared with pkg/processor so the spawn_agent(agent=...) call in review prompts stays in sync with the registration here — if either side drifts, codex silently fails to resolve the agent and the review phase breaks.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaudeExecutor ¶
type ClaudeExecutor struct {
Command string // command to execute, defaults to "claude"
Args string // additional arguments (space-separated), defaults to standard args
ArgsSet bool // true when Args was explicitly set, including an empty value
Model string // model override (e.g., "opus", "sonnet", "haiku"); empty = CLI default
Effort string // reasoning effort override (e.g., "low", "medium", "high", "xhigh", "max"); empty = CLI default
OutputHandler func(text string) // called for each text chunk, can be nil
Debug bool // enable debug output
ErrorPatterns []string // patterns to detect in output (e.g., rate limit messages)
LimitPatterns []string // patterns to detect rate limits (checked before error patterns)
IdleTimeout time.Duration // kill session after this duration of no output, zero = disabled
PreserveAPIKey bool // when true, ANTHROPIC_API_KEY is passed through to the child; default false strips it
// contains filtered or unexported fields
}
ClaudeExecutor runs claude CLI commands with streaming JSON parsing.
type CodexExecutor ¶
type CodexExecutor struct {
Command string // command to execute, defaults to "codex"
Model string // model override; empty means inherit from ~/.codex/config.toml (no -c model= flag emitted)
ReasoningEffort string // reasoning effort override; empty means inherit from ~/.codex/config.toml
TimeoutMs int // stream idle timeout in ms, defaults to 3600000
Sandbox string // sandbox mode, defaults to "read-only"
ProjectDoc string // path to project documentation file
OutputHandler func(text string) // called for each filtered output line in real-time
Debug bool // enable debug output
ErrorPatterns []string // patterns to detect in output (e.g., rate limit messages)
LimitPatterns []string // patterns to detect rate limits (checked before error patterns)
MultiAgent bool // enable codex multi_agent feature + reviewer agent registration; set to true on the review-phase codex instance built by processor.New() for first-class --codex mode
PassClaudeMd bool // pass project-level CLAUDE.md to codex via project_doc_fallback_filenames (set by processor.New() only when cfg.AppConfig.Executor == ExecutorCodex)
IdleTimeout time.Duration // kill session after this duration of no output, zero = disabled
// contains filtered or unexported fields
}
CodexExecutor runs codex CLI commands and filters output.
func (*CodexExecutor) Run ¶
func (e *CodexExecutor) Run(ctx context.Context, prompt string) Result
Run executes codex CLI with the given prompt and returns filtered output. stderr is streamed line-by-line to OutputHandler for progress indication. stdout is captured entirely as the final response (returned in Result.Output).
type CodexRunner ¶
type CodexRunner interface {
Run(ctx context.Context, name string, args ...string) (streams CodexStreams, wait func() error, err error)
}
CodexRunner abstracts command execution for codex. Returns both stderr (streaming progress) and stdout (final response).
type CodexStreams ¶
CodexStreams holds both stderr and stdout from codex command.
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, name string, args ...string) (output io.Reader, wait func() error, err error)
}
CommandRunner abstracts command execution for testing. Returns an io.Reader for streaming output and a wait function for completion.
type CustomExecutor ¶ added in v0.8.0
type CustomExecutor struct {
Script string // path to the custom review script
OutputHandler func(text string) // called for each output line, can be nil
ErrorPatterns []string // patterns to detect in output (e.g., rate limit messages)
LimitPatterns []string // patterns to detect rate limits (checked before error patterns)
// contains filtered or unexported fields
}
CustomExecutor runs custom review scripts and streams output.
func (*CustomExecutor) Run ¶ added in v0.8.0
func (e *CustomExecutor) Run(ctx context.Context, promptContent string) Result
Run executes the custom review script with the prompt content written to a temp file. The script receives the path to the prompt file as its single argument. Output is streamed line-by-line to OutputHandler.
func (*CustomExecutor) SetRunner ¶ added in v0.8.0
func (e *CustomExecutor) SetRunner(r CustomRunner)
SetRunner sets the custom runner for testing purposes.
type CustomRunner ¶ added in v0.8.0
type CustomRunner interface {
Run(ctx context.Context, script, promptFile string) (stdout io.Reader, wait func() error, err error)
}
CustomRunner abstracts command execution for custom review scripts. Returns stdout reader and a wait function for completion.
type LimitPatternError ¶ added in v0.19.0
type LimitPatternError struct {
Pattern string // the pattern that matched
HelpCmd string // command to run for more information
}
LimitPatternError is returned when a configured rate limit pattern is detected in output. when wait-on-limit is configured, the caller retries instead of exiting.
func (*LimitPatternError) Error ¶ added in v0.19.0
func (e *LimitPatternError) Error() string
type PatternMatchError ¶ added in v0.6.0
type PatternMatchError struct {
Pattern string // the pattern that matched
HelpCmd string // command to run for more information (e.g., "claude /usage")
}
PatternMatchError is returned when a configured error pattern is detected in output.
func (*PatternMatchError) Error ¶ added in v0.6.0
func (e *PatternMatchError) Error() string
type Result ¶
type Result struct {
Output string // accumulated text output
RecentText string // last 10 text blocks joined, used for pattern matching to avoid false positives
Signal string // detected signal (COMPLETED, FAILED, etc.) or empty
Error error // execution error if any
IdleTimedOut bool // true when idle timeout fired (derived context canceled, parent alive)
}
Result holds execution result with output and detected signal.