tui

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlyphCheck = "✓"
	GlyphCross = "✗"
	GlyphWarn  = "⚠"
	GlyphArrow = "→"
	GlyphDash  = "—"
	GlyphDot   = "·"
)

Variables

View Source
var (
	Leaf  lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#4A9E6F", Light: "#2D7A4B"}
	Bark  lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#D4AF37", Light: "#7A5E10"}
	Stone lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#6B7280", Light: "#4B5563"}
	Water lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#7EC8E3", Light: "#1A7FA0"}
	Moss  lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#73D677", Light: "#2D8A3E"}
	Ember lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#E36F6F", Light: "#C53030"}
	Amber lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#E3C16F", Light: "#B7791F"}
	Sand  lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#C4B7A6", Light: "#6B5E4F"}
	Petal lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#D4A0C0", Light: "#9B4D8A"}
	Moon  lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#F5F5F5", Light: "#1A1A1A"}
	Slate lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#2D2D3D", Light: "#E5E7EB"}
)
View Source
var (
	ColorPrimary   = Leaf  // Brand accent — headings, primary action, banner title
	ColorSecondary = Bark  // Field labels, category headers
	ColorAccent    = Moon  // Interactive chrome — cursor, selectors, bold emphasis
	ColorSubtle    = Sand  // Body text, option labels
	ColorMuted     = Stone // Hints, descriptions, at-rest borders
	ColorSuccess   = Moss  // Success states
	ColorDanger    = Ember // Errors
	ColorWarning   = Amber // Warnings
	ColorInfo      = Water // Info panels, review box
	ColorSurface   = Slate // Neutral UI surface — idle button backgrounds, inactive chrome
)
View Source
var (
	ColorLeafDim lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#3A7253", Light: "#3D6D53"}
	ColorRule    lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#3B4049", Light: "#D4D0CA"}
	ColorRule2   lipgloss.TerminalColor = lipgloss.AdaptiveColor{Dark: "#4A4F58", Light: "#B9B5AF"}
)

Enso / rule chrome tokens — used by the init-flow chrome. Dimmer shades of Leaf/Stone for at-rest rail segments and thin dividers. Kept separate from the primary semantic tokens above so other commands keep their current palette untouched.

View Source
var (
	StyleTitle   = lipgloss.NewStyle().Bold(true).Foreground(ColorPrimary)
	StyleLabel   = lipgloss.NewStyle().Bold(true).Foreground(ColorSecondary)
	StyleMuted   = lipgloss.NewStyle().Foreground(ColorMuted)
	StyleSuccess = lipgloss.NewStyle().Foreground(ColorSuccess)
	StyleError   = lipgloss.NewStyle().Foreground(ColorDanger)
	StyleWarning = lipgloss.NewStyle().Foreground(ColorWarning)
	StyleAccent  = lipgloss.NewStyle().Foreground(ColorInfo)
	StyleSand    = lipgloss.NewStyle().Foreground(ColorSubtle)
)
View Source
var (
	PanelSuccess = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorSuccess).
					Padding(1, 2)
	PanelError = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorDanger).
				Padding(1, 2)
	PanelWarning = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorWarning).
					Padding(1, 2)
	PanelInfo = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorInfo).
				Padding(1, 2)
	PanelEmpty = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorMuted).
				Padding(1, 2)
)
View Source
var (
	HarnessHeader = lipgloss.NewStyle().Padding(0, 2).Foreground(ColorMuted)
	HarnessCrumb  = lipgloss.NewStyle().Foreground(ColorPrimary).Bold(true)
	HarnessFooter = lipgloss.NewStyle().Padding(0, 2).Foreground(ColorMuted)
)

Functions

func Answer added in v0.2.0

func Answer(label, value string)

Answer prints a compact styled summary of an answered prompt so prior answers stay visible as the user advances through a multi-step flow. Example output: ▸ Project name my-project

func AskConfirm

func AskConfirm(title string, defaultVal bool) (bool, error)

AskConfirm prompts for yes/no confirmation.

func AskMultiSelect

func AskMultiSelect(title string, options []huh.Option[string]) ([]string, error)

AskMultiSelect prompts for multiple selections.

func AskSelect

func AskSelect(title string, options []huh.Option[string]) (string, error)

AskSelect prompts for a single selection.

func AskText

func AskText(title, defaultVal string, required bool) (string, error)

AskText prompts for text input.

func Banner(version, action string)

Banner prints the Bonsai welcome banner. version is the build version (pass "" or "dev" to hide). action is an optional contextual sub-line (e.g., "Initializing new project"). Pass "" for no action line.

func Blank

func Blank()

Blank prints an empty line.

func BonsaiTheme

func BonsaiTheme() *huh.Theme

BonsaiTheme returns a custom Huh form theme matching the Zen Garden palette.

func CardFields

func CardFields(pairs [][2]string) string

CardFields builds aligned key:value field lines as a string for embedding in panels.

func CatalogTable

func CatalogTable(headers []string, rows [][]string)

CatalogTable renders a styled table for abilities.

func DisableColor added in v0.2.0

func DisableColor()

DisableColor forces all output to plain text (no ANSI escapes).

func EmptyPanel

func EmptyPanel(msg string)

EmptyPanel renders a dim panel for empty states.

func Error

func Error(msg string)

Error prints a red cross message.

func ErrorDetail added in v0.2.0

func ErrorDetail(title, detail, hint string)

ErrorDetail renders a structured non-fatal error. Same shape as FatalPanel but does not exit. title: what happened (bold, error color). detail: why. hint: how to fix (muted).

func ErrorPanel

func ErrorPanel(msg string)

ErrorPanel renders a red-bordered panel.

func FatalPanel added in v0.2.0

func FatalPanel(title, detail, hint string)

FatalPanel renders a structured error and exits. title: what happened. detail: why. hint: how to fix.

func Fields

func Fields(pairs [][2]string)

Fields renders aligned key:value pairs to stdout.

func FileTree

func FileTree(files []string, rootLabel string) string

FileTree builds a tree display from flat file paths.

func Heading

func Heading(title string)

Heading prints a primary section heading.

func Hint

func Hint(msg string)

Hint prints dimmed helper text, aligned with message text.

func Info

func Info(msg string)

Info prints dimmed informational text.

func InfoPanel

func InfoPanel(content, title string)

InfoPanel renders a blue-bordered panel.

func ItemTree

func ItemTree(root string, categories []Category, describe func(string) string) string

ItemTree renders a tree with category branches and item leaves.

func PickItems

func PickItems(label string, available []ItemOption, defaults []string) ([]string, error)

PickItems shows a section heading and multi-select for abilities. Items whose names appear in defaults are pre-selected. Items marked Required are auto-included and shown as a locked info line. Returns machine identifiers (Value fields), not display names.

func RenderFileTree added in v0.2.0

func RenderFileTree(nodes []TreeNode, opts FileTreeOpts) string

RenderFileTree renders nodes (and the optional Root) into a string safe to embed inside AltScreen views.

func Section

func Section(title string)

Section prints a secondary section heading.

func SectionHeader

func SectionHeader(title string)

SectionHeader prints a section title with a trailing rule line.

func Success

func Success(msg string)

Success prints a green checkmark message.

func SuccessPanel

func SuccessPanel(content, title string)

SuccessPanel renders a green-bordered panel.

func TitledPanel

func TitledPanel(title, content string, color lipgloss.TerminalColor)

TitledPanel renders a bordered panel with the title embedded in the top border. The panel is capped to the terminal width so borders don't break when content is wider than the visible columns; over-long lines are truncated with an ellipsis.

func TitledPanelString added in v0.2.0

func TitledPanelString(title, content string, color lipgloss.TerminalColor) string

TitledPanelString renders the same bordered panel as TitledPanel and returns the result as a string (with a leading newline, matching the side-effecting TitledPanel's fmt.Println output). Use inside AltScreen or when composing with other styled content.

func Warning

func Warning(msg string)

Warning prints a yellow warning message.

func WarningPanel

func WarningPanel(msg string)

WarningPanel renders a yellow-bordered panel.

Types

type Category

type Category struct {
	Name  string
	Items []string
}

Category is a named group of items for tree rendering.

type FileTreeOpts added in v0.2.0

type FileTreeOpts struct {
	// Root, when non-nil, renders a prefix line with the root's name and note
	// above the main tree. The root itself is not counted as a sibling of the
	// top-level nodes; its children (if any) are ignored.
	Root *TreeNode
	// Dense collapses sibling spacing to a single line each (no blank line
	// between siblings at any depth).
	Dense bool
	// MaxWidth caps the rendered width of each row. 0 means auto-detect via
	// the terminal width (falling back to 80).
	MaxWidth int
}

FileTreeOpts tunes the renderer.

type ItemOption

type ItemOption struct {
	Name     string
	Value    string
	Desc     string
	Required bool
}

ItemOption describes an item for multi-select prompts. Name is the human-readable display label. Value is the machine identifier returned as the selection result; if empty, Name is used.

type NodeKind added in v0.2.0

type NodeKind int

NodeKind discriminates directories from files for rendering purposes.

const (
	// NodeFile is a leaf (document).
	NodeFile NodeKind = iota
	// NodeDir is an internal directory node whose Children may be nested.
	NodeDir
)

type NodeStatus added in v0.2.0

type NodeStatus int

NodeStatus styles a node and optionally attaches a right-aligned badge.

const (
	// NodeNormal renders the node with the default foreground colors; no badge.
	NodeNormal NodeStatus = iota
	// NodeNew marks newly-written files: Leaf-colored name + "NEW" badge.
	NodeNew
	// NodeRequired marks required files: bold Subtle name + "REQUIRED" badge.
	NodeRequired
	// NodeCurrent tints a whole subtree with a leaf border + background.
	NodeCurrent
)

type TreeNode added in v0.2.0

type TreeNode struct {
	Name     string
	Kind     NodeKind
	Status   NodeStatus
	Note     string
	Children []TreeNode
}

TreeNode is one entry in the rendered tree. Kind=NodeFile entries ignore Children. Status controls coloring and badge. Note is a one-line caption rendered after the name in muted text.

Directories

Path Synopsis
Package addflow implements the cinematic 4-stage `bonsai add` flow.
Package addflow implements the cinematic 4-stage `bonsai add` flow.
Package catalogflow implements the cinematic tabbed browser for `bonsai catalog`.
Package catalogflow implements the cinematic tabbed browser for `bonsai catalog`.
Package guideflow implements the cinematic `bonsai guide` viewer — a tabbed BubbleTea scroll viewport that renders bundled markdown guides through glamour inside the shared initflow chrome (header + footer + min-size floor).
Package guideflow implements the cinematic `bonsai guide` viewer — a tabbed BubbleTea scroll viewport that renders bundled markdown guides through glamour inside the shared initflow chrome (header + footer + min-size floor).
Package harness provides a single long-lived BubbleTea program that owns the screen for the lifetime of an interactive Bonsai command.
Package harness provides a single long-lived BubbleTea program that owns the screen for the lifetime of an interactive Bonsai command.
Package hints provides the 3-layer yield-stage hints renderer (Plan 31 Phase H).
Package hints provides the 3-layer yield-stage hints renderer (Plan 31 Phase H).
Package initflow implements the cinematic 4-stage `bonsai init` flow.
Package initflow implements the cinematic 4-stage `bonsai init` flow.
Package listflow renders the cinematic `bonsai list` surface — a static, non-interactive string output composed of the shared initflow chrome (header + min-size floor) plus per-agent panels and a counts footer.
Package listflow renders the cinematic `bonsai list` surface — a static, non-interactive string output composed of the shared initflow chrome (header + min-size floor) plus per-agent panels and a counts footer.
Package removeflow implements the cinematic 4-stage `bonsai remove` flow.
Package removeflow implements the cinematic 4-stage `bonsai remove` flow.
Package updateflow implements the cinematic 5-stage `bonsai update` flow.
Package updateflow implements the cinematic 5-stage `bonsai update` flow.

Jump to

Keyboard shortcuts

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