ui

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Overview

Package ui provides terminal styling for beads CLI output.

Package ui provides terminal styling and pager support for beads CLI output.

Package ui provides terminal styling for beads CLI output. Uses the Ayu color theme with adaptive light/dark mode support.

Package ui provides terminal styling and output helpers for beads CLI.

Index

Constants

View Source
const (
	IconPass = "✓"
	IconWarn = "⚠"
	IconFail = "✖"
	IconSkip = "-"
	IconInfo = "ℹ"
)

Status icons - consistent semantic indicators

View Source
const (
	StatusIconOpen       = "○" // available to work (hollow circle)
	StatusIconInProgress = "◐" // active work (half-filled)
	StatusIconBlocked    = "●" // needs attention (filled circle)
	StatusIconClosed     = "✓" // completed (checkmark)
	StatusIconDeferred   = "❄" // scheduled for later (snowflake)
	StatusIconPinned     = "📌" // elevated priority
	StatusIconCustom     = "◇" // custom/uncategorized status (diamond)
)

Issue status icons - used consistently across all commands Design principle: icons > text labels for scannability IMPORTANT: Use small Unicode symbols, NOT emoji-style icons (🔴🟠 etc.) Emoji blobs cause cognitive overload and break visual consistency

View Source
const (
	TreeChild  = "⎿ "  // child indicator
	TreeLast   = "└─ " // last child / detail line
	TreeIndent = "  "  // 2-space indent per level
)

Tree characters for hierarchical display

View Source
const (
	SeparatorLight = "" /* 126-byte string literal not displayed */
	SeparatorHeavy = "" /* 126-byte string literal not displayed */
)

Separators

View Source
const PriorityIcon = "●"

Priority icon - small filled circle, colored by priority level IMPORTANT: Use this small circle, NOT emoji blobs (🔴🟠🟡🔵⚪)

Variables

View Source
var (
	// Core semantic colors (Ayu theme - adaptive light/dark)
	ColorPass   color.Color = lipgloss.NoColor{}
	ColorWarn   color.Color = lipgloss.NoColor{}
	ColorFail   color.Color = lipgloss.NoColor{}
	ColorMuted  color.Color = lipgloss.NoColor{}
	ColorAccent color.Color = lipgloss.NoColor{}

	// === Workflow Status Colors ===
	ColorStatusOpen       color.Color = lipgloss.NoColor{}
	ColorStatusInProgress color.Color = lipgloss.NoColor{}
	ColorStatusClosed     color.Color = lipgloss.NoColor{}
	ColorStatusBlocked    color.Color = lipgloss.NoColor{}
	ColorStatusPinned     color.Color = lipgloss.NoColor{}
	ColorStatusHooked     color.Color = lipgloss.NoColor{}

	// === Priority Colors ===
	ColorPriorityP0 color.Color = lipgloss.NoColor{}
	ColorPriorityP1 color.Color = lipgloss.NoColor{}
	ColorPriorityP2 color.Color = lipgloss.NoColor{}
	ColorPriorityP3 color.Color = lipgloss.NoColor{}
	ColorPriorityP4 color.Color = lipgloss.NoColor{}

	// === Issue Type Colors ===
	ColorTypeBug     color.Color = lipgloss.NoColor{}
	ColorTypeFeature color.Color = lipgloss.NoColor{}
	ColorTypeTask    color.Color = lipgloss.NoColor{}
	ColorTypeEpic    color.Color = lipgloss.NoColor{}
	ColorTypeChore   color.Color = lipgloss.NoColor{}

	// === Issue ID Color ===
	ColorID color.Color = lipgloss.NoColor{}
)

Ayu theme color palette Dark: https://terminalcolors.com/themes/ayu/dark/ Light: https://terminalcolors.com/themes/ayu/light/ Source: https://github.com/ayu-theme/ayu-colors

View Source
var (
	PassStyle   = lipgloss.NewStyle()
	WarnStyle   = lipgloss.NewStyle()
	FailStyle   = lipgloss.NewStyle()
	MutedStyle  = lipgloss.NewStyle()
	AccentStyle = lipgloss.NewStyle()
)

Core styles - consistent across all commands

View Source
var (
	StatusOpenStyle       = lipgloss.NewStyle()
	StatusInProgressStyle = lipgloss.NewStyle()
	StatusClosedStyle     = lipgloss.NewStyle()
	StatusBlockedStyle    = lipgloss.NewStyle()
	StatusPinnedStyle     = lipgloss.NewStyle()
	StatusHookedStyle     = lipgloss.NewStyle()
)

Status styles for workflow states

View Source
var (
	PriorityP0Style = lipgloss.NewStyle()
	PriorityP1Style = lipgloss.NewStyle()
	PriorityP2Style = lipgloss.NewStyle()
	PriorityP3Style = lipgloss.NewStyle()
	PriorityP4Style = lipgloss.NewStyle()
)

Priority styles

View Source
var (
	TypeBugStyle     = lipgloss.NewStyle()
	TypeFeatureStyle = lipgloss.NewStyle()
	TypeTaskStyle    = lipgloss.NewStyle()
	TypeEpicStyle    = lipgloss.NewStyle()
	TypeChoreStyle   = lipgloss.NewStyle()
)

Type styles for issue categories

View Source
var BoldStyle = lipgloss.NewStyle()

BoldStyle for emphasis

View Source
var CategoryStyle = lipgloss.NewStyle()

CategoryStyle for section headers - bold with accent color

View Source
var CommandStyle = lipgloss.NewStyle()

CommandStyle for command names - subtle contrast, not attention-grabbing

View Source
var IDStyle = lipgloss.NewStyle()

Issue ID style

Functions

func DisableColors added in v1.0.0

func DisableColors()

DisableColors resets all styles to plain text output. Called from hook contexts to prevent ANSI escape sequence leaks.

func GetStatusIcon added in v0.47.0

func GetStatusIcon(status string) string

GetStatusIcon returns just the icon character without styling Useful when you need to apply custom styling or for non-TTY output

func GetStatusIconWithCategory added in v0.62.0

func GetStatusIconWithCategory(status string, category types.StatusCategory) string

GetStatusIconWithCategory returns the icon character for a status using category fallback.

func GetStatusStyle added in v0.47.0

func GetStatusStyle(status string) lipgloss.Style

GetStatusStyle returns the lipgloss style for a given status Use this when you need to apply the semantic color to custom text Example: ui.GetStatusStyle("in_progress").Render(myCustomText)

func IsAgentMode added in v0.42.0

func IsAgentMode() bool

IsAgentMode returns true if the CLI is running in agent-optimized mode. This is triggered by:

  • BD_AGENT_MODE=1 environment variable (explicit)
  • CLAUDE_CODE environment variable (auto-detect Claude Code)

Agent mode provides ultra-compact output optimized for LLM context windows.

func IsStderrTerminal added in v1.0.3

func IsStderrTerminal() bool

IsStderrTerminal returns true if stderr is connected to a terminal (TTY). Used to suppress advisory messages (e.g. deprecation notices) when stderr is captured by test harnesses or piped to another process.

func IsTerminal added in v0.42.0

func IsTerminal() bool

IsTerminal returns true if stdout is connected to a terminal (TTY).

func RenderAccent

func RenderAccent(s string) string

RenderAccent renders text with accent (blue) styling

func RenderBold added in v0.33.0

func RenderBold(s string) string

RenderBold renders text in bold

func RenderCategory

func RenderCategory(s string) string

RenderCategory renders a category header in uppercase with accent color

func RenderClosedLine added in v0.33.0

func RenderClosedLine(line string) string

RenderClosedLine renders an entire line in the closed/dimmed style

func RenderCommand added in v0.33.0

func RenderCommand(s string) string

RenderCommand renders a command name with subtle styling

func RenderFail

func RenderFail(s string) string

RenderFail renders text with fail (red) styling

func RenderFailIcon

func RenderFailIcon() string

RenderFailIcon renders the fail icon with styling

func RenderID added in v0.33.0

func RenderID(id string) string

RenderID renders an issue ID with semantic styling

func RenderInfoIcon

func RenderInfoIcon() string

RenderInfoIcon renders the info icon with styling

func RenderIssueCompact added in v0.33.0

func RenderIssueCompact(id string, priority int, issueType, status, title string) string

RenderIssueCompact renders a compact one-line issue summary Format: ID [Priority] [Type] Status - Title When status is "closed", the entire line is dimmed to show it's done

func RenderMarkdown added in v0.47.0

func RenderMarkdown(markdown string) string

RenderMarkdown renders markdown text using glamour with beads theme colors. Returns the rendered markdown or the original text if rendering fails. Word wraps at terminal width (or 80 columns if width can't be detected).

func RenderMuted

func RenderMuted(s string) string

RenderMuted renders text with muted (gray) styling

func RenderPass

func RenderPass(s string) string

RenderPass renders text with pass (green) styling

func RenderPassIcon

func RenderPassIcon() string

RenderPassIcon renders the pass icon with styling

func RenderPriority added in v0.33.0

func RenderPriority(priority int) string

RenderPriority renders a priority level with semantic styling Format: ● P0 (icon + label) P0/P1 get color; P2/P3/P4 use standard text

func RenderPriorityCompact added in v0.47.0

func RenderPriorityCompact(priority int) string

RenderPriorityCompact renders just the priority label without icon Use when space is constrained or icon would be redundant

func RenderPriorityForStatus added in v0.33.0

func RenderPriorityForStatus(priority int, status string) string

RenderPriorityForStatus renders priority with color only if not closed

func RenderSeparator

func RenderSeparator() string

RenderSeparator renders the light separator line in muted color

func RenderSkipIcon

func RenderSkipIcon() string

RenderSkipIcon renders the skip icon with styling

func RenderStatus added in v0.33.0

func RenderStatus(status string) string

RenderStatus renders a status with semantic styling in_progress/blocked/pinned get color; open/closed use standard text

func RenderStatusIcon added in v0.47.0

func RenderStatusIcon(status string) string

RenderStatusIcon returns the appropriate icon for a status with semantic coloring. This is the canonical source for status icon rendering - use this everywhere. For custom statuses, call RenderStatusIconWithCategory for category-aware rendering.

func RenderStatusIconWithCategory added in v0.62.0

func RenderStatusIconWithCategory(status string, category types.StatusCategory) string

RenderStatusIconWithCategory returns the icon for a status, using category to determine icon/color for custom statuses.

func RenderType added in v0.33.0

func RenderType(issueType string) string

RenderType renders an issue type with semantic styling bugs and epics get color; all other types use standard text Note: Orchestrator-specific types (agent, role, rig) now fall through to default

func RenderTypeForStatus added in v0.33.0

func RenderTypeForStatus(issueType, status string) string

RenderTypeForStatus renders type with color only if not closed

func RenderWarn

func RenderWarn(s string) string

RenderWarn renders text with warning (yellow) styling

func RenderWarnIcon

func RenderWarnIcon() string

RenderWarnIcon renders the warning icon with styling

func SanitizeForTerminal added in v1.0.0

func SanitizeForTerminal(s string) string

SanitizeForTerminal removes ANSI escape sequences and control characters from a string to prevent terminal injection attacks. External tracker content (issue titles, descriptions) should be sanitized before terminal display.

Preserves printable UTF-8 characters including common punctuation and emoji. Strips: ANSI CSI sequences (\x1b[...), OSC sequences (\x1b]...\x07), other escape sequences, and C0/C1 control characters (except \n and \t).

func ShouldUseColor added in v0.42.0

func ShouldUseColor() bool

ShouldUseColor determines if ANSI color codes should be used. Respects standard conventions:

  • BD_GIT_HOOK=1: disables color in git hook context (prevents OSC 11 queries, GH#1303)
  • NO_COLOR: https://no-color.org/ - disables color if set
  • CLICOLOR=0: disables color
  • CLICOLOR_FORCE: forces color even in non-TTY
  • Falls back to TTY detection

func ShouldUseEmoji added in v0.42.0

func ShouldUseEmoji() bool

ShouldUseEmoji determines if emoji decorations should be used. Disabled in non-TTY mode to keep output machine-readable. Can be controlled with BD_NO_EMOJI environment variable.

func ToPager added in v0.42.0

func ToPager(content string, opts PagerOptions) error

ToPager pipes content to a pager if appropriate. If pager should not be used (not a TTY, --no-pager, etc.), prints directly. If content fits in terminal, prints directly without pager.

Types

type PagerOptions added in v0.42.0

type PagerOptions struct {
	// NoPager disables pager for this command (--no-pager flag)
	NoPager bool
}

PagerOptions controls pager behavior

Jump to

Keyboard shortcuts

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