engine

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalComplete      = ".brr-complete"
	SignalNeedsApproval = ".brr-needs-approval"
)

Signal file paths used by the brr engine.

Variables

View Source
var ErrInterrupted = errors.New("interrupted")

ErrInterrupted is returned when the engine is stopped by a user signal (Ctrl+C).

Functions

func AcquireLock added in v0.3.0

func AcquireLock() (*os.File, error)

acquireLock attempts to acquire an exclusive lock on .brr.lock in the working directory. Returns the lock file handle (caller must defer releaseLock) or an error if another brr instance is already running in this directory.

func ReleaseLock added in v0.3.0

func ReleaseLock(f *os.File)

releaseLock releases the advisory lock and closes the file handle. The lock file is intentionally kept on disk to prevent a race where another process acquires the old inode just before it is unlinked.

Types

type Options

type Options struct {
	Prompt   string   // resolved prompt text
	Max      int      // max iterations (0 = unlimited)
	Command  []string // command + args to run (prompt piped to stdin)
	SkipLock bool     // skip lock acquisition (caller holds the lock)
}

Options configures a loop run.

type Result added in v0.2.0

type Result struct {
	Reason          StopReason
	ApprovalContent string // populated only for ReasonApproval
}

Result carries the structured stop reason from a completed engine run.

func Run

func Run(opts Options) (*Result, error)

Run executes the loop until completion, max iterations, or interrupt. The returned Result is always non-nil when error is nil, and may also be non-nil on error paths to communicate the stop reason.

type StopReason added in v0.2.0

type StopReason int

StopReason indicates why the engine stopped.

const (
	ReasonComplete      StopReason = iota // .brr-complete signal file
	ReasonApproval                        // .brr-needs-approval signal file
	ReasonMaxIterations                   // max iteration count reached
	ReasonFailStreak                      // too many consecutive failures
	ReasonInterrupted                     // user signal (Ctrl+C / SIGTERM)
)

Jump to

Keyboard shortcuts

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