processor

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package processor provides the main orchestration loop for ralphex execution.

Index

Constants

View Source
const (
	SignalCompleted  = status.Completed
	SignalFailed     = status.Failed
	SignalReviewDone = status.ReviewDone
	SignalCodexDone  = status.CodexDone
	SignalQuestion   = status.Question
	SignalPlanReady  = status.PlanReady
	SignalPlanDraft  = status.PlanDraft
)

signal constants are aliases to the shared status package for convenience within processor. all signal values are defined in pkg/status to avoid circular dependencies.

View Source
const DefaultIterationDelay = 2 * time.Second

DefaultIterationDelay is the pause between iterations to allow system to settle.

Variables

View Source
var ErrNoPlanDraftSignal = errors.New("no plan draft signal found")

ErrNoPlanDraftSignal indicates no plan draft signal was found in output

View Source
var ErrNoQuestionSignal = errors.New("no question signal found")

ErrNoQuestionSignal indicates no question signal was found in output

View Source
var ErrUserRejectedPlan = errors.New("user rejected plan")

ErrUserRejectedPlan is returned when user rejects the plan draft.

Functions

func IsCodexDone

func IsCodexDone(signal string) bool

IsCodexDone returns true if signal indicates codex phase is complete.

func IsPlanReady added in v0.4.0

func IsPlanReady(signal string) bool

IsPlanReady returns true if signal indicates plan creation is complete.

func IsReviewDone

func IsReviewDone(signal string) bool

IsReviewDone returns true if signal indicates review phase is complete.

func ParsePlanDraftPayload added in v0.6.0

func ParsePlanDraftPayload(output string) (string, error)

ParsePlanDraftPayload extracts plan content from output containing PLAN_DRAFT signal. returns ErrNoPlanDraftSignal if no plan draft signal is found. returns other error if signal is found but content is malformed.

Types

type Config

type Config struct {
	PlanFile         string         // path to plan file (required for full mode)
	PlanDescription  string         // plan description for interactive plan creation mode
	ProgressPath     string         // path to progress file
	Mode             Mode           // execution mode
	MaxIterations    int            // maximum iterations for task phase
	Debug            bool           // enable debug output
	NoColor          bool           // disable color output
	IterationDelayMs int            // delay between iterations in milliseconds
	TaskRetryCount   int            // number of times to retry failed tasks
	CodexEnabled     bool           // whether codex review is enabled
	FinalizeEnabled  bool           // whether finalize step is enabled
	DefaultBranch    string         // default branch name (detected from repo)
	AppConfig        *config.Config // full application config (for executors and prompts)
}

Config holds runner configuration.

type Executor

type Executor interface {
	Run(ctx context.Context, prompt string) executor.Result
}

Executor runs CLI commands and returns results.

type GitChecker added in v0.9.0

type GitChecker interface {
	HeadHash() (string, error)
}

GitChecker provides git state inspection for the review loop.

type InputCollector added in v0.4.0

type InputCollector interface {
	AskQuestion(ctx context.Context, question string, options []string) (string, error)
	AskDraftReview(ctx context.Context, question string, planContent string) (action string, feedback string, err error)
}

InputCollector provides interactive input collection for plan creation.

type Logger

type Logger interface {
	Print(format string, args ...any)
	PrintRaw(format string, args ...any)
	PrintSection(section status.Section)
	PrintAligned(text string)
	LogQuestion(question string, options []string)
	LogAnswer(answer string)
	LogDraftReview(action string, feedback string)
	Path() string
}

Logger provides logging functionality.

type Mode

type Mode string

Mode represents the execution mode.

const (
	ModeFull      Mode = "full"       // full execution: tasks + reviews + codex
	ModeReview    Mode = "review"     // skip tasks, run full review pipeline
	ModeCodexOnly Mode = "codex-only" // skip tasks and first review, run only codex loop
	ModeTasksOnly Mode = "tasks-only" // run only task phase, skip all reviews
	ModePlan      Mode = "plan"       // interactive plan creation mode
)

type QuestionPayload added in v0.4.0

type QuestionPayload struct {
	Question string   `json:"question"`
	Options  []string `json:"options"`
	Context  string   `json:"context,omitempty"`
}

QuestionPayload represents a question signal from Claude during plan creation

func ParseQuestionPayload added in v0.4.0

func ParseQuestionPayload(output string) (*QuestionPayload, error)

ParseQuestionPayload extracts a QuestionPayload from output containing QUESTION signal. returns ErrNoQuestionSignal if no question signal is found. returns other error if signal is found but JSON is malformed.

type Runner

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

Runner orchestrates the execution loop.

func New

func New(cfg Config, log Logger, holder *status.PhaseHolder) *Runner

New creates a new Runner with the given configuration and shared phase holder. If codex is enabled but the binary is not found in PATH, it is automatically disabled with a warning.

func NewWithExecutors

func NewWithExecutors(cfg Config, log Logger, claude, codex Executor, custom *executor.CustomExecutor, holder *status.PhaseHolder) *Runner

NewWithExecutors creates a new Runner with custom executors (for testing).

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run executes the main loop based on configured mode.

func (*Runner) SetGitChecker added in v0.9.0

func (r *Runner) SetGitChecker(g GitChecker)

SetGitChecker sets the git checker for no-commit detection in review loops.

func (*Runner) SetInputCollector added in v0.4.0

func (r *Runner) SetInputCollector(c InputCollector)

SetInputCollector sets the input collector for plan creation mode.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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