style

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ContentOffset = 2

ContentOffset is the column at which every block's text begins.

The UI keeps one left-edge contract: a marker (gutter glyph, tool bullet, receipt check) occupies column 0, a single space follows, and text starts at ContentOffset. Blocks with no marker — assistant prose — are indented to the same column, so the transcript reads as one aligned text column with markers hanging in the left margin. Anything that draws a left edge must honour this, or the eye sees a ragged margin and reads it as misalignment rather than as structure.

View Source
const GutterGlyph = "▌"

GutterGlyph is the single character used to mark a block's left edge throughout the UI: user messages, alerts, permission prompts and any other element that needs to be visually attributed.

One glyph, colored by role, replaces what used to be three competing conventions (a thick ┃ for user messages, a light │ for alerts, and bare indentation for tool bodies). A half-block reads as a deliberate stripe at any font weight, where box-drawing characters vary between terminals and invite the eye to look for a matching corner that never comes.

Variables

This section is empty.

Functions

func ActiveThemeName

func ActiveThemeName() string

ActiveThemeName returns the name of the currently active theme by comparing against known entries. Returns "custom" if no match is found.

func AdaptiveColor

func AdaptiveColor(light, dark string) color.Color

AdaptiveColor picks between a light-mode and dark-mode hex color string based on the detected terminal background. This replaces the old lipgloss.AdaptiveColor{Light: ..., Dark: ...} pattern from v1.

func ApplyGradient

func ApplyGradient(text string, colorA, colorB color.Color) string

ApplyGradient applies a color gradient from colorA to colorB across the text. Uses ~8 color stops for performance rather than per-character coloring.

func ApplyTheme

func ApplyTheme(name string) error

ApplyTheme loads a theme by name and sets it as the active global theme. The selection is persisted to ~/.config/kit/preferences.yml so it survives across sessions. Persistence errors are silently ignored — the theme is still applied in-memory even if the write fails.

func ApplyThemeWithoutSave

func ApplyThemeWithoutSave(name string) error

ApplyThemeWithoutSave loads a theme by name and sets it as the active global theme without persisting the choice. Used at startup to restore a previously saved preference without redundantly re-writing it.

func CreateBadge

func CreateBadge(text string, c color.Color) string

CreateBadge generates a styled badge or label with inverted colors (text on colored background) for highlighting important tags, statuses, or categories.

func GetMarkdownTypography

func GetMarkdownTypography() *herald.Typography

GetMarkdownTypography returns a herald.Typography configured with our active theme colors. The typography is cached and only rebuilt when the theme changes via SetTheme.

func GetUITypography added in v0.85.1

func GetUITypography() *herald.Typography

GetUITypography returns the shared herald.Typography used for message block rendering, configured from the active theme. The instance is cached and only rebuilt after a theme change (SetTheme invalidates it).

func GutterBorder added in v0.89.0

func GutterBorder() lipgloss.Border

GutterBorder returns a lipgloss border consisting only of a left edge drawn with GutterGlyph. Callers enable just the left side; the remaining fields exist because lipgloss requires a complete Border value.

func Indent added in v0.89.0

func Indent(s string, n int) string

Indent prefixes every non-empty line of s with n spaces. Empty lines are left untouched so the indent never leaves trailing whitespace behind.

func IsDarkBackground

func IsDarkBackground() bool

IsDarkBackground returns the cached terminal background detection result.

func KitBanner

func KitBanner() string

KitBanner returns the KIT ASCII art title with KITT scanner lights, rendered with a KITT red gradient.

This is the banner used in `--help` output, where the art stands alone and is centered by its own leading padding. The TUI splash uses KitLogoLines instead, which is unpadded so it can sit inside a gutter-marked block.

func KitLogoLines added in v0.89.0

func KitLogoLines(contentWidth int) []string

KitLogoLines returns the KIT wordmark as gradient-colored lines, sized for a block that will be rendered at the given content width.

Fixed-width block art cannot wrap, so below the width it needs the wordmark degrades to a plain bold "KIT" rather than spilling across the terminal.

func ListThemes

func ListThemes() []string

ListThemes returns the names of all available themes (built-in + user).

func ProjectThemesDir

func ProjectThemesDir() string

projectThemesDir returns .kit/themes/ relative to the working directory. Returns "" if the directory doesn't exist (does NOT create it).

func RegisterThemeFromConfig

func RegisterThemeFromConfig(name string, primary, secondary, success, warning, error_, info, text, muted, veryMuted, background, border, mutedBorder, system, tool, accent, highlight, mdHeading, mdLink, mdKeyword, mdString, mdNumber, mdComment [2]string)

RegisterThemeFromConfig adds a theme to the runtime registry from an extension's ThemeColorConfig (string hex pairs). Replaces any existing entry with the same name. The theme is immediately available via ListThemes, LoadThemeByName, and ApplyTheme.

func SetTheme

func SetTheme(theme Theme)

SetTheme updates the global UI theme, affecting all subsequent rendering operations. This allows runtime theme switching for different visual preferences. It also invalidates the markdownTypographyCache so the next call to GetMarkdownTypography picks up the new theme.

func SplashBlock added in v0.89.0

func SplashBlock(lines []string) string

SplashBlock renders the startup splash: content lines indented to the shared content column, with no left stripe.

KIT
anthropic · claude-opus-5

context   ~/project/AGENTS.md
skills    btca-cli, kit-extensions

The splash carries no gutter glyph because it is not attributed to anyone — it is the application introducing itself, not a message from the user, the assistant or a tool. A stripe here would compete with the wordmark it sits beside and imply an authorship the block does not have.

The block costs exactly as many rows as it has something to say, so a session with no skills or extensions loaded produces a shorter splash.

func SyntaxStyle added in v0.89.0

func SyntaxStyle() *chroma.Style

SyntaxStyle returns a chroma style built from the active theme's markdown colors.

Syntax highlighting used to be pinned to an external palette, which meant a warm red/amber theme rendered code in blues, purples and greens — a second, unrelated color scheme living inside the first. Deriving the style from the theme keeps code blocks in the same family as everything around them, and makes every user theme (and every custom theme file) apply to code as well.

Token backgrounds are left unset so the containing lipgloss style controls the fill; setting both produces visible seams at each token boundary.

func ToMarkdown

func ToMarkdown(content string, width int) string

ToMarkdown renders markdown content using herald-md and wraps the result to the given width so that long lines do not overflow the terminal.

func UserThemesDir

func UserThemesDir() string

userThemesDir returns ~/.config/kit/themes, creating it if needed.

Types

type CachedStyles added in v0.59.0

type CachedStyles struct {
	// render/blocks.go
	FileTokenAccent lipgloss.Style // Foreground(Accent).Bold(true)
	Muted           lipgloss.Style // Foreground(Muted)
	VeryMuted       lipgloss.Style // Foreground(VeryMuted)
	Accent          lipgloss.Style // Foreground(Accent)
	MarginBottom1   lipgloss.Style // MarginBottom(1)

	// stream.go - spinner phases
	SpinnerBright lipgloss.Style // Foreground(Primary)
	SpinnerMed    lipgloss.Style // Foreground(Muted)
	SpinnerDim    lipgloss.Style // Foreground(VeryMuted)
	SpinnerOff    lipgloss.Style // Foreground(MutedBorder)

	// message_items.go - bash output
	BashHeader lipgloss.Style // Foreground(Muted).Italic(true)
	BashStderr lipgloss.Style // Foreground(Error)

	// render/blocks.go - tool block
	ToolSuccess lipgloss.Style // Foreground(Success)
	ToolError   lipgloss.Style // Foreground(Error)
	ToolInfo    lipgloss.Style // Foreground(Info).Bold(true)
	ToolMuted   lipgloss.Style // Foreground(Muted)

	// common
	ErrorFg  lipgloss.Style // Foreground(Error)
	TextBold lipgloss.Style // Foreground(Text).Bold(true)
}

CachedStyles holds pre-built lipgloss styles that are reused across render frames. Invalidated by SetTheme, lazily rebuilt on next access. Only accessed from BubbleTea's single-threaded Update/View cycle.

func GetCachedStyles added in v0.59.0

func GetCachedStyles() *CachedStyles

GetCachedStyles returns the pre-built style cache, creating it lazily from the current theme. Invalidated by SetTheme.

type MarkdownThemeColors

type MarkdownThemeColors struct {
	Text    color.Color
	Muted   color.Color
	Heading color.Color
	Emph    color.Color
	Strong  color.Color
	Link    color.Color
	Code    color.Color
	Error   color.Color
	Keyword color.Color
	String  color.Color
	Number  color.Color
	Comment color.Color
}

MarkdownThemeColors defines colors for markdown rendering and syntax highlighting.

type Theme

type Theme struct {
	Primary     color.Color
	Secondary   color.Color
	Success     color.Color
	Warning     color.Color
	Error       color.Color
	Info        color.Color
	Text        color.Color
	Muted       color.Color
	VeryMuted   color.Color
	Background  color.Color
	Border      color.Color
	MutedBorder color.Color
	System      color.Color
	Tool        color.Color
	Accent      color.Color
	Highlight   color.Color

	// Diff block backgrounds
	DiffInsertBg  color.Color // Green-tinted bg for added lines
	DiffDeleteBg  color.Color // Red-tinted bg for removed lines
	DiffEqualBg   color.Color // Neutral bg for context lines
	DiffMissingBg color.Color // Empty-cell bg when sides are uneven

	// Code/output block backgrounds
	CodeBg   color.Color // Background for code blocks (Read tool)
	GutterBg color.Color // Line-number gutter background
	WriteBg  color.Color // Green-tinted bg for Write tool content

	// InputBg fills the composer bar. It is a shade off the terminal
	// background — enough to read as a distinct surface, not enough to
	// compete with message content for attention.
	InputBg color.Color

	// Markdown rendering and syntax highlighting colors
	Markdown MarkdownThemeColors
}

Theme defines a comprehensive color scheme for the application's UI, supporting both light and dark terminal modes through adaptive colors. Inspired by the Knight Rider KITT aesthetic — scanner reds, amber dashboard glows, and dark cockpit tones.

func DefaultTheme

func DefaultTheme() Theme

DefaultTheme creates and returns the default KIT theme inspired by the Knight Rider KITT aesthetic — scanner reds, amber dashboard glows, and a dark cockpit. Everything stays in the warm red/amber/gray family of KITT's instrument panel, with two deliberate exceptions.

Success and Error must never be mistaken for Warning or for the brand red, because they carry opposite meanings and they appear in the same places (the turn receipt, the activity row, tool markers). Success therefore leans olive-green and Error leans crimson: both still warm, both unmistakably not amber and not scanner red.

func GetTheme

func GetTheme() Theme

GetTheme returns the currently active UI theme. The theme controls all color and styling decisions throughout the application's interface.

func LoadThemeByName

func LoadThemeByName(name string) (Theme, error)

LoadThemeByName looks up a theme by name, loads it if needed, and returns it.

type ThemeEntry

type ThemeEntry struct {
	Name   string // Display name (filename stem or preset name)
	Source string // "builtin" or absolute file path
	// contains filtered or unexported fields
}

ThemeEntry is a named, loadable theme — either built-in or discovered from disk.

func (*ThemeEntry) Theme

func (e *ThemeEntry) Theme() (Theme, error)

Theme returns the resolved ui.Theme, loading from disk on first access.

Jump to

Keyboard shortcuts

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