batch

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchDir

func BatchDir() string

BatchDir returns the directory where batch state and logs are stored

func ListBatches

func ListBatches() ([]string, error)

ListBatches returns all batch IDs sorted by most recent

Types

type BatchState

type BatchState struct {
	ID          string          `json:"id"`
	CreatedAt   time.Time       `json:"created_at"`
	Repo        string          `json:"repo"`
	Concurrency int             `json:"concurrency"`
	MaxBudget   float64         `json:"max_budget_usd,omitempty"`
	Prompt      string          `json:"prompt_template,omitempty"`
	Tickets     []*TicketResult `json:"tickets"`
	// contains filtered or unexported fields
}

BatchState persists the state of a batch run

func LoadBatch

func LoadBatch(id string) (*BatchState, error)

LoadBatch reads a batch state from disk

func NewBatch

func NewBatch(inputs []TicketInput, repo string, concurrency int, maxBudget float64, prompt string) *BatchState

NewBatch creates a new batch with the given tickets

func (*BatchState) Dir

func (b *BatchState) Dir() string

Dir returns the directory for this batch

func (*BatchState) PrintStatus

func (b *BatchState) PrintStatus()

PrintStatus displays the current batch status

func (*BatchState) RepoMutex

func (b *BatchState) RepoMutex(repoPath string) *sync.Mutex

RepoMutex returns a mutex for the given repo path, creating one if needed. This serializes worktree creation per source repo to avoid git lock conflicts.

func (*BatchState) Run

func (b *BatchState) Run(repoPath string, createWorktreeFn func(ticket *TicketResult) (*WorktreeResult, error)) error

Run executes the batch with the configured concurrency

func (*BatchState) Save

func (b *BatchState) Save() error

Save persists the batch state to disk

func (*BatchState) UpdateTicket

func (b *BatchState) UpdateTicket(id string, fn func(*TicketResult))

UpdateTicket updates a ticket's status thread-safely

type TicketInput

type TicketInput struct {
	ID    string
	Repos []string // Repos this ticket needs (first is primary workdir, rest get --add-dir)
}

TicketInput represents a parsed ticket from input (CLI or CSV)

func ParseTicketsFromCSV

func ParseTicketsFromCSV(path string) ([]TicketInput, error)

ParseTicketsFromCSV reads ticket IDs from a CSV file Supports:

  • One ID per line (no header)
  • Header row with "ticket"/"id"/"key" column and optional "repo" column
  • Multi-repo values both quoted ("repo-a,repo-b") and unquoted (repo-a,repo-b)

func ParseTicketsFromFile

func ParseTicketsFromFile(path string) ([]TicketInput, error)

ParseTicketsFromFile reads ticket IDs from a plain text file (one per line) or CSV

type TicketResult

type TicketResult struct {
	ID        string       `json:"id"`
	Repos     []string     `json:"repos,omitempty"` // Repos this ticket spans
	Status    TicketStatus `json:"status"`
	Branch    string       `json:"branch,omitempty"`
	PR        string       `json:"pr,omitempty"`
	Error     string       `json:"error,omitempty"`
	StartedAt *time.Time   `json:"started_at,omitempty"`
	DoneAt    *time.Time   `json:"done_at,omitempty"`
	LogFile   string       `json:"log_file,omitempty"`
}

TicketResult tracks a single ticket's progress

func (*TicketResult) Duration

func (t *TicketResult) Duration() time.Duration

Duration returns the elapsed time for this ticket

type TicketStatus

type TicketStatus string

TicketStatus represents the current state of a ticket in the batch

const (
	StatusQueued  TicketStatus = "queued"
	StatusRunning TicketStatus = "running"
	StatusDone    TicketStatus = "done"
	StatusFailed  TicketStatus = "failed"
	StatusBlocked TicketStatus = "blocked"
)

type WorktreeResult

type WorktreeResult struct {
	PrimaryPath string   // Main worktree path (workdir for claude)
	AddDirs     []string // Additional repo worktree paths (--add-dir)
	Branch      string   // Branch name
}

WorktreeResult holds the paths created for a ticket

Jump to

Keyboard shortcuts

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