runner

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DotQPDir is the top-level project state directory.
	DotQPDir = ".qp"

	// CacheSubdir is the subdirectory for task result caches.
	CacheSubdir = "cache"

	// LastGuardFile is the filename for the last guard run result.
	LastGuardFile = "last-guard.json"
)
View Source
const (
	StatusPass      = "pass"
	StatusFail      = "fail"
	StatusSkipped   = "skipped"
	StatusCancelled = "cancelled"
	StatusTimeout   = "timeout"
)

Variables

This section is empty.

Functions

func CacheDir added in v0.5.2

func CacheDir(repoRoot string) string

CacheDir returns the absolute path to the cache directory for a given repo root.

func LastGuardPath added in v0.5.2

func LastGuardPath(repoRoot string) string

LastGuardPath returns the absolute path to the last-guard.json file.

Types

type ErrorEntry

type ErrorEntry struct {
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
	Message  string `json:"message"`
	Severity string `json:"severity,omitempty"`
}

type EventStream

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

func NewEventStream

func NewEventStream(w io.Writer) *EventStream

func (*EventStream) EmitApprovalRequired added in v0.5.0

func (s *EventStream) EmitApprovalRequired(task string, reason string, metadata map[string]any)

func (*EventStream) EmitComplete

func (s *EventStream) EmitComplete(status string, durationMS int64)

func (*EventStream) EmitDone

func (s *EventStream) EmitDone(task, status string, durationMS int64)

func (*EventStream) EmitIteration added in v0.5.0

func (s *EventStream) EmitIteration(task string, iteration int, max int, status string)

func (*EventStream) EmitOutput

func (s *EventStream) EmitOutput(task, stream, line string)

func (*EventStream) EmitPlan

func (s *EventStream) EmitPlan(rootTask string)

func (*EventStream) EmitPlanGraph added in v0.5.0

func (s *EventStream) EmitPlanGraph(rootTask string, nodes []string, edges [][2]string)

func (*EventStream) EmitRetry added in v0.5.0

func (s *EventStream) EmitRetry(task string, attempt int, max int, reason string, delayMS int64)

func (*EventStream) EmitSkipped

func (s *EventStream) EmitSkipped(task, reason string)

func (*EventStream) EmitStart

func (s *EventStream) EmitStart(task string)

func (*EventStream) Err added in v0.5.2

func (s *EventStream) Err() error

Err returns the first encoding error encountered during event emission, or nil if no errors occurred.

type ExecutionContext added in v0.5.2

type ExecutionContext struct {
	// State will hold the shared JSON state map in P2.
	// Parallel nodes receive a snapshot; outputs are merged after completion.
	State map[string]any
}

ExecutionContext carries shared state through the runner execution pipeline. For now it is a pass-through placeholder — P2 will add a flowing JSON state object that nodes read from and write to.

func NewExecutionContext added in v0.5.2

func NewExecutionContext() *ExecutionContext

NewExecutionContext returns an empty execution context.

type Executor added in v0.5.2

type Executor interface {
	Run(taskName string, opts Options) (Result, error)
}

Executor is the interface for running tasks. External consumers (e.g. MCP) should depend on this interface rather than constructing a Runner directly.

type Options

type Options struct {
	JSON        bool
	DryRun      bool
	Verbose     bool
	Quiet       bool
	NoCache     bool
	AllowUnsafe bool
	Stdout      io.Writer
	Stderr      io.Writer
	Env         map[string]string
	Params      map[string]string
	Events      *EventStream
}

type Result

type Result struct {
	Task        string       `json:"task"`
	Type        string       `json:"type"`
	Needs       []Result     `json:"needs,omitempty"`
	ResolvedCmd *string      `json:"resolved_cmd,omitempty"`
	Parallel    bool         `json:"parallel,omitempty"`
	Status      string       `json:"status"`
	ExitCode    int          `json:"exit_code"`
	Stdout      string       `json:"stdout,omitempty"`
	Stderr      string       `json:"stderr,omitempty"`
	Errors      []ErrorEntry `json:"errors,omitempty"`
	SkipReason  string       `json:"skip_reason,omitempty"`
	Cached      bool         `json:"cached,omitempty"`
	DurationMS  int64        `json:"duration_ms"`
	StartedAt   string       `json:"started_at"`
	FinishedAt  string       `json:"finished_at"`
	Steps       []StepResult `json:"steps,omitempty"`
}

type Runner

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

func New

func New(cfg *config.Config, repoRoot string) *Runner

func (*Runner) Run

func (r *Runner) Run(taskName string, opts Options) (Result, error)

type StepResult

type StepResult struct {
	Index       int          `json:"index"`
	Name        string       `json:"name"`
	Type        string       `json:"type,omitempty"`
	ResolvedCmd *string      `json:"resolved_cmd"`
	Parallel    bool         `json:"parallel,omitempty"`
	Status      string       `json:"status"`
	ExitCode    int          `json:"exit_code"`
	Stdout      *string      `json:"stdout"`
	Stderr      *string      `json:"stderr"`
	Errors      []ErrorEntry `json:"errors,omitempty"`
	SkipReason  string       `json:"skip_reason,omitempty"`
	DurationMS  *int64       `json:"duration_ms"`
	StartedAt   *string      `json:"started_at"`
	FinishedAt  *string      `json:"finished_at"`
	Steps       []StepResult `json:"steps,omitempty"`
}

Jump to

Keyboard shortcuts

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