auto

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package auto implements the automatic execution mode runner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaudeExecutor added in v0.9.0

type ClaudeExecutor struct {
	// WorkDir is the repository working directory
	WorkDir string
	// ClaudeMDDir is the directory containing CLAUDE.md for the executor
	ClaudeMDDir string
	// Model is the Claude model to use (optional)
	Model agent.Model
}

ClaudeExecutor executes tasks using Claude CLI via agent.Runner

func NewClaudeExecutor added in v0.9.0

func NewClaudeExecutor(workDir, claudeMDDir string) *ClaudeExecutor

NewClaudeExecutor creates a new ClaudeExecutor

func (*ClaudeExecutor) Execute added in v0.9.0

func (e *ClaudeExecutor) Execute(ctx context.Context, issueNumber int, title string) (int, error)

Execute implements TaskExecutor interface It fetches issue details, runs Claude CLI to implement, and creates a PR

type Config

type Config struct {
	Logger *log.Logger
}

Config holds configuration for the Runner

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration

type IssueInfo

type IssueInfo struct {
	Number int
	Title  string
}

IssueInfo holds issue information for batch addition

type Runner

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

Runner manages the automatic execution of approved tasks

func NewRunner

func NewRunner(executor TaskExecutor, cfg Config) *Runner

NewRunner creates a new auto mode runner

func (*Runner) AddTask

func (r *Runner) AddTask(issueNumber int, title string)

AddTask adds a task to be executed

func (*Runner) AddTasks

func (r *Runner) AddTasks(issues []IssueInfo)

AddTasks adds multiple tasks to be executed

func (*Runner) CompletedCount

func (r *Runner) CompletedCount() int

CompletedCount returns the number of completed tasks

func (*Runner) FailedCount

func (r *Runner) FailedCount() int

FailedCount returns the number of failed tasks

func (*Runner) Pause

func (r *Runner) Pause()

Pause pauses the runner

func (*Runner) PendingCount

func (r *Runner) PendingCount() int

PendingCount returns the number of pending tasks

func (*Runner) Reset

func (r *Runner) Reset()

Reset clears all tasks and returns to idle state

func (*Runner) Resume

func (r *Runner) Resume()

Resume resumes a paused runner

func (*Runner) Run

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

Run starts executing all pending tasks Blocks until all tasks are done or context is cancelled

func (*Runner) SetOnAllComplete

func (r *Runner) SetOnAllComplete(fn func(tasks []*Task))

SetOnAllComplete sets the callback for when all tasks are done

func (*Runner) SetOnTaskComplete

func (r *Runner) SetOnTaskComplete(fn func(task *Task))

SetOnTaskComplete sets the callback for when a task completes

func (*Runner) SetOnTaskStart

func (r *Runner) SetOnTaskStart(fn func(task *Task))

SetOnTaskStart sets the callback for when a task starts

func (*Runner) State

func (r *Runner) State() RunnerState

State returns the current runner state

func (*Runner) Stop

func (r *Runner) Stop()

Stop stops the runner

func (*Runner) Summary

func (r *Runner) Summary() string

Summary returns a summary string of the runner state

func (*Runner) Tasks

func (r *Runner) Tasks() []*Task

Tasks returns a copy of all tasks

type RunnerState

type RunnerState string

RunnerState represents the state of the runner

const (
	// RunnerStateIdle means the runner is not running
	RunnerStateIdle RunnerState = "idle"
	// RunnerStateRunning means the runner is executing tasks
	RunnerStateRunning RunnerState = "running"
	// RunnerStatePaused means the runner is paused
	RunnerStatePaused RunnerState = "paused"
	// RunnerStateCompleted means all tasks are done
	RunnerStateCompleted RunnerState = "completed"
)

type StubExecutor

type StubExecutor struct {
	// SimulatedDuration is how long each task "takes" to execute
	SimulatedDuration time.Duration
	// NextPRNumber is the next PR number to return (incremented after each call)
	NextPRNumber int
	// FailIssues is a list of issue numbers that should fail
	FailIssues map[int]error
	// Logger for output
	Logger *log.Logger
}

StubExecutor is a stub implementation of TaskExecutor for testing It simulates task execution by logging and returning a mock PR number

func NewStubExecutor

func NewStubExecutor() *StubExecutor

NewStubExecutor creates a new stub executor

func (*StubExecutor) ClearFailures

func (e *StubExecutor) ClearFailures()

ClearFailures removes all configured failures

func (*StubExecutor) Execute

func (e *StubExecutor) Execute(ctx context.Context, issueNumber int, title string) (int, error)

Execute simulates task execution

func (*StubExecutor) SetFailure

func (e *StubExecutor) SetFailure(issueNumber int, err error)

SetFailure configures an issue to fail with the given error

type Task

type Task struct {
	IssueNumber int
	Title       string
	State       TaskState
	StartedAt   time.Time
	CompletedAt time.Time
	Error       error
	PRNumber    int // PR number created after completion
}

Task represents a task to be executed

type TaskExecutor

type TaskExecutor interface {
	// Execute runs the task implementation
	// Returns the PR number on success, or an error on failure
	Execute(ctx context.Context, issueNumber int, title string) (prNumber int, err error)
}

TaskExecutor is the interface for executing tasks Implementations can be stubs or actual Claude agent integrations

type TaskState

type TaskState string

TaskState represents the state of a task

const (
	// TaskStatePending means the task is waiting to be executed
	TaskStatePending TaskState = "pending"
	// TaskStateRunning means the task is currently being executed
	TaskStateRunning TaskState = "running"
	// TaskStateCompleted means the task finished successfully
	TaskStateCompleted TaskState = "completed"
	// TaskStateFailed means the task failed
	TaskStateFailed TaskState = "failed"
)

Jump to

Keyboard shortcuts

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