Documentation
¶
Overview ¶
Package cli: root and subcommands for the BuildMax CLI.
Index ¶
- Constants
- func ExitCodeFor(err error) int
- func NewRootCommand() *cobra.Command
- type ExitError
- type InputBlock
- func (ib *InputBlock) Blur()
- func (ib *InputBlock) CanScroll() bool
- func (ib *InputBlock) Focus() tea.Cmd
- func (ib *InputBlock) Ghost() string
- func (ib *InputBlock) Height() int
- func (ib *InputBlock) Reset()
- func (ib *InputBlock) ScrollDown(lines int) tea.Cmd
- func (ib *InputBlock) ScrollUp(lines int) tea.Cmd
- func (ib *InputBlock) SetGhost(s string)
- func (ib *InputBlock) SetValue(v string)
- func (ib *InputBlock) SetWidth(w int)
- func (ib *InputBlock) SyncHeight()
- func (ib *InputBlock) Update(msg tea.Msg) tea.Cmd
- func (ib *InputBlock) Value() string
- func (ib *InputBlock) View() string
- type Model
- type OutputFormat
- type TUIApprovalHandler
- type TUIOpts
Constants ¶
const ( ExitOK = 0 ExitGeneric = 1 ExitUsage = 2 // bad flag, missing config (e.g. no model configured) ExitPolicyDenied = 3 // tool blocked by configured policy ExitModelError = 4 // LLM/agent runtime error ExitToolError = 5 // reserved ExitUserCancelled = 6 // SIGINT / ctx cancelled // ExitIterationCap is a run that reached agent.max_iterations. It is // separate from ExitModelError because the two ask different things of a // caller: a model error is a fault to retry, while an exhausted budget is // an answer — the run stopped where it was told to, and whatever it wrote // is real. A harness that retried this would pay for the same cap again. ExitIterationCap = 7 )
Exit codes for the CLI. Stable contract for shell scripts wrapping `buildmax -p`. Documented for users in docs/reference/cli.md.
const APIKeyPlaceholder = "REPLACE_WITH_YOUR_API_KEY"
APIKeyPlaceholder is what `buildmax init` writes when the user did not pass --api-key. checkModelConfig recognizes it, so a run that would otherwise fail inside the LLM client with a provider authentication error stops with an instruction instead.
Variables ¶
This section is empty.
Functions ¶
func ExitCodeFor ¶
ExitCodeFor returns the exit code embedded in err, or ExitGeneric when err is non-nil but not an ExitError, or ExitOK when err is nil.
func NewRootCommand ¶
NewRootCommand creates and returns the root cobra command for BuildMax.
Types ¶
type ExitError ¶
ExitError wraps an exit code so cobra's RunE can return it and main can surface it as the process exit code.
type InputBlock ¶
type InputBlock struct {
// contains filtered or unexported fields
}
InputBlock groups input state for the textarea at the bottom.
func NewInputBlock ¶
func NewInputBlock() InputBlock
NewInputBlock returns an InputBlock with textarea configured (prompt, placeholder, initial height/width, focused).
func (*InputBlock) CanScroll ¶
func (ib *InputBlock) CanScroll() bool
CanScroll reports whether the textarea has hidden wrapped lines above or below.
func (*InputBlock) Focus ¶
func (ib *InputBlock) Focus() tea.Cmd
Focus focuses the textarea and returns its command (for tea.Batch in Init).
func (*InputBlock) Ghost ¶
func (ib *InputBlock) Ghost() string
Ghost returns the suggestion currently on offer, or "" when there is none. It is on offer only while the input is empty: once the user has typed, the suggestion is not what they are about to send.
func (*InputBlock) Height ¶
func (ib *InputBlock) Height() int
Height returns the textarea height in lines.
func (*InputBlock) ScrollDown ¶
func (ib *InputBlock) ScrollDown(lines int) tea.Cmd
ScrollDown moves the textarea viewport/cursor downward by the requested number of lines.
func (*InputBlock) ScrollUp ¶
func (ib *InputBlock) ScrollUp(lines int) tea.Cmd
ScrollUp moves the textarea viewport/cursor upward by the requested number of lines.
func (*InputBlock) SetGhost ¶
func (ib *InputBlock) SetGhost(s string)
SetGhost offers text as the ghost suggestion, or clears it when s is empty.
func (*InputBlock) SetValue ¶
func (ib *InputBlock) SetValue(v string)
SetValue replaces the textarea content.
func (*InputBlock) SetWidth ¶
func (ib *InputBlock) SetWidth(w int)
SetWidth sets the textarea width.
func (*InputBlock) SyncHeight ¶
func (ib *InputBlock) SyncHeight()
SyncHeight sets the textarea height to match wrapped content (1 to inputMaxLines).
An empty input is measured against the ghost suggestion instead: the textarea renders the placeholder over its own height, so a two-line suggestion in a one-line box would be silently cut in half.
func (*InputBlock) Update ¶
func (ib *InputBlock) Update(msg tea.Msg) tea.Cmd
Update forwards the message to the textarea and returns its command.
func (*InputBlock) View ¶
func (ib *InputBlock) View() string
View returns the textarea's rendered content.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root Bubble Tea model in transcript mode. Chat history lives in the terminal scrollback; this model only manages the bottom live strip: streaming preview, input, slash panels, approval, and footer.
func (*Model) Close ¶
func (m *Model) Close()
Close stops foreground runs and releases background-job subscriptions before the AgentApp they use is closed.
func (*Model) CurrentSession ¶
func (m *Model) CurrentSession() *agentapp.SessionContext
CurrentSession is the session the model is holding now, which is not always the one it started with: /fork switches to the child it creates. Whoever releases the session at exit has to ask, rather than remember.
func (*Model) FocusInput ¶
FocusInput returns true when the input has focus (used by tests).
type OutputFormat ¶
type OutputFormat string
OutputFormat is the print-mode output format selected by --output.
const ( OutputText OutputFormat = "text" OutputJSON OutputFormat = "json" OutputJSONL OutputFormat = "jsonl" )
type TUIApprovalHandler ¶
type TUIApprovalHandler struct {
// contains filtered or unexported fields
}
TUIApprovalHandler implements agent.ApprovalHandler for the Bubble Tea TUI. Create it before the program, wire the program in after tea.NewProgram.
func NewTUIApprovalHandler ¶
func NewTUIApprovalHandler() *TUIApprovalHandler
func (*TUIApprovalHandler) RequestApproval ¶
func (h *TUIApprovalHandler) RequestApproval(ctx context.Context, name string, args map[string]any) agent.ApprovalDecision
RequestApproval sends an approval request to the TUI and blocks until the user answers: y (once), a (session), or n/Esc (deny).
func (*TUIApprovalHandler) SetProgram ¶
func (h *TUIApprovalHandler) SetProgram(p *tea.Program)
type TUIOpts ¶
type TUIOpts struct {
App *agentapp.AgentApp
Session *agentapp.SessionContext
ModelName string
Workspace util.Workspace
SessionsDir string
Approval agent.ApprovalHandler
GlamourStyle string // "dark" or "light", detected once before the program starts
RunStatus agentapp.RunUsage
}
TUIOpts holds dependencies and display config for the TUI (agent, session, model name, paths).
Source Files
¶
- admin.go
- chat.go
- chat_agents.go
- chat_approval.go
- chat_compact.go
- chat_diff.go
- chat_format.go
- chat_history_panel.go
- chat_info.go
- chat_input.go
- chat_jobs.go
- chat_mcp.go
- chat_models.go
- chat_plugins.go
- chat_session.go
- chat_skills.go
- chat_styles.go
- chat_tools.go
- chat_worktree.go
- doctor.go
- doctor_project.go
- exit_code.go
- info.go
- init.go
- issue.go
- login.go
- mode.go
- models.go
- plugin.go
- plugin_activations.go
- plugin_marketplace.go
- plugin_status.go
- plugin_validate.go
- print.go
- print_format.go
- project.go
- root.go
- sandbox.go
- session_target.go
- system_prompt.go
- tools.go
- tui.go
- tui_model.go
- tui_runs.go
- version.go