wizard

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package wizard provides the pre-pipeline onboarding flow: it detects repo state, optionally creates a branch, commits uncommitted changes, and pushes to the no-slop gate, then hands off to the main TUI. It supports both the interactive wizard UI and the non-interactive auto-accept path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Context       context.Context
	RepoDir       string
	CurrentBranch string
	DefaultBranch string
	// AutoAdvance automatically presses Enter on each active wizard step,
	// preserving the interactive TUI while accepting the default path.
	AutoAdvance bool
	// DisableInput disables Bubble Tea input, which is useful for headless runs
	// and tests that drive cancellation through the caller context.
	DisableInput bool
	// NeedsBranch is true when the user has no usable feature branch yet -
	// either they're on the default branch, or HEAD is detached. The branch
	// step is only active when this is true.
	NeedsBranch bool
	IsDirty     bool
	GateRemote  string
	// Output overrides the Bubble Tea output writer and is also used for the
	// terminal-title reset sequence emitted when the wizard shuts down.
	Output io.Writer

	CreateBranch  func(ctx context.Context, name string) error
	CommitAll     func(ctx context.Context, msg string) error
	Push          func(ctx context.Context, branch string) error
	SuggestBranch func(ctx context.Context) (string, error)
	SuggestCommit func(ctx context.Context) (string, error)
	Track         func(action string, fields map[string]any)
	// WaitForRun, if set, runs after push succeeds and blocks while the
	// daemon-created run is still catching up. Keeps the alt screen up so the
	// handoff to the attach TUI has no visible gap. Only used by the
	// interactive Run path; headless RunAuto ignores it.
	WaitForRun func(ctx context.Context, branch string) error
}

Config describes the repo state and dependencies the wizard needs. Callers pre-detect git state so the wizard can decide up-front which steps to skip.

type Model

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

Model is the bubbletea model for the wizard.

func NewModel

func NewModel(cfg Config) Model

NewModel constructs a wizard Model. Which steps end up active depends on the supplied Config: if the current branch already differs from the default, the branch step is skipped; if the working tree is clean, the commit step is skipped; the push step always runs.

func (Model) Init

func (m Model) Init() tea.Cmd

Init returns the initial Cmd for the active step. State was already prepared in NewModel.

func (Model) Result

func (m Model) Result() Result

Result returns the terminal state of the wizard. Only meaningful once the program has exited.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles bubbletea events and drives the state machine.

func (Model) View

func (m Model) View() string

View renders the wizard.

type Result

type Result struct {
	Success       bool
	Aborted       bool
	BranchCreated bool
	CommitMade    bool
	Pushed        bool
	TargetBranch  string
	Err           error
}

Result reports what the wizard did. Success means the wizard completed all required steps: the push to the gate succeeded, and when WaitForRun is set, the daemon handoff completed so the caller can re-attach to pick up the new run.

func Run

func Run(cfg Config) (Result, error)

Run invokes the wizard as an interactive bubbletea program. Returns the terminal Result describing what happened.

func RunAuto

func RunAuto(cfg Config) (Result, error)

RunAuto executes the wizard steps non-interactively. It accepts the default automated path for each step: use agent suggestions for branch and commit, then push to the gate. Suggestion failures are returned immediately.

Jump to

Keyboard shortcuts

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