Documentation
¶
Overview ¶
Package runner orchestrates one review run end to end — checkout, prompt assembly, reviewer passes, result merging, and persistence — so every frontend (TUI, web GUI) drives the same pipeline and stores the same artifacts.
Index ¶
Constants ¶
const DiffFilesDir = ".review-diffs"
DiffFilesDir is where oversized diffs are written inside the checkout so the reviewer can Read them (the review session has no Bash to run git).
Variables ¶
This section is empty.
Functions ¶
func BuildRequests ¶
func BuildRequests(cfg config.Config, detail gitlabx.MRDetail, diffs []gitlabx.FileDiff, commits []gitlabx.Commit, template, repoPath string) ([]review.Request, []string, []string, error)
BuildRequests assembles the reviewer request(s) from project-resolved config: chunked diffs and combined custom instructions. The requests are agent-neutral; the runner specialises a copy per selected agent. Diffs too large to inline are written into the checkout under DiffFilesDir so the reviewer can still see them. It returns the requests, informational progress lines, and warnings worth persisting with the result (only genuine information loss qualifies).
func RebaseWarning ¶
RebaseWarning describes why the MR branch is not up to date with its target, for the findings-screen warning banner.
Types ¶
type CheckoutFunc ¶
type CheckoutFunc func(ctx context.Context, mr gitlabx.MRDetail, progress func(string)) (path string, cleanup func(context.Context) error, err error)
CheckoutFunc prepares a review worktree for an MR and returns its path plus a cleanup function. Progress lines go to the run's progress log.
type Outcome ¶
Outcome is everything a frontend needs after a run: the merged result, the stored record (nil on failure, cancellation, or when storage is disabled), and the progress log location.
type Runner ¶
type Runner struct {
Cfg config.Config
Svc gitlabx.Service
Reviewer review.Reviewer
Checkout CheckoutFunc
// Catalog is the available agents (builtins + user agents); nil means
// builtins only. Project agents shipped in the checkout are merged in
// after checkout, so they can shadow or satisfy selected names.
Catalog *agents.Catalog
// AgentNames is the agent selection for this run (from the picker or
// --agents); empty falls back to cfg.Review.Agents.
AgentNames []string
// AgentModels overrides the review model per agent (agent name → model
// ID), from the picker. It takes precedence over an agent's frontmatter
// model and cfg.Review.Model; agents absent from the map keep those
// defaults. Nil applies no overrides.
AgentModels map[string]string
// Logs stores the run's progress log; nil disables storing.
Logs *runlog.Store
// Results stores the run's result record; nil disables storing.
Results *resultstore.Store
}
Runner bundles everything one review run needs. Cfg must already be resolved for the MR's project (per-project overrides applied).
func (Runner) Run ¶
func (r Runner) Run(ctx context.Context, detail gitlabx.MRDetail, diffs []gitlabx.FileDiff, commits []gitlabx.Commit, emit func(string)) Outcome
Run executes the whole review, reporting every progress line through emit (may be nil) and mirroring it into the stored run log. On success the result is saved as a record so the review can be reopened later; curation screens keep re-saving the same record as states change.