borealis

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 12 Imported by: 10 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

borealis

THE pleme-io terminal design system — an aurora in the terminal. The brand name is literal and load-bearing: borealis (aurora borealis) is the Nord Aurora family, so the brand, the palette, and the design system are one coherent idea (BOREALIS theory §2.9).

borealis owns the one render verb, the one Theme token bundle (a single type name fleet-wide), and one producer per charm-stack themeable surface. Every *-go primitive (errors-go, logging-go, todoku-go, lifecycle-go, shigoto-go, cli-go) renders its user-facing output through borealis, so two fleet tools cannot drift in how they look.

Built on the v2 charm stack: charm.land/lipgloss/v2, bubbletea/v2, bubbles/v2, huh/v2, and fang for CLI styling.

The canonical surface (BOREALIS §3.5)

import "github.com/pleme-io/borealis"

t, _ := borealis.FromConfig(cfg.Borealis)       // resolve the token bundle (pure)
fmt.Println(borealis.Render(t, status))          // the ONE render verb
Symbol Shape Role
borealis.Theme type alias of theme.Theme the single token-bundle type name fleet-wide
borealis.Render(t Theme, x T) string generic dispatcher the one render verb — no RenderReceipt/StatusString variants
borealis.FromConfig(cfg Config) (Theme, error) pure consumer takes the loaded sub-struct; never calls shikumi.Load
borealis.Config shikumi-loadable struct {Theme, Mode, Color, Accessible}, yaml-tagged
borealis.Nord() / borealis.Default() brand theme the Nord aurora palette
borealis.Execute(ctx, root, opts…) wired over cli-go canonical CLI entrypoint — lowers cli-go's root to cobra and runs it under the fang decorator (Nord ColorScheme)

Render dispatches over: a Renderable (renders itself), a fmt.Stringer, a comp.Tabler, []comp.Item (status list), []comp.Pair (key/value), a plain string (pass-through), and a total muted fallback for anything else.

Packages

Package Stack What
borealis lipgloss v2 canonical entry: Theme, Render, Config, FromConfig, Nord
theme lipgloss v2 design tokens: Theme, Color, Role, Nord() + the Nord palette constants
comp lipgloss v2 renderable typed values: Header, Badge, Glyph, Rule, StatusList, KV, Table (Tabler)
style lipgloss v2 ready-to-use Lip Gloss styles derived from a Theme (style.New(t))
Gated leaves (Law 6 / Law 8 — the core carries no heavy charm-stack dep)
Leaf Dep Surface (the three themeable surfaces)
fangx fang + cobra fangx.ColorScheme(t), fangx.Execute(ctx, root, t, opts…) — styled CLI help/usage/errors/version/man/completions
huhx huh v2 huhx.HuhTheme(t) — themed interactive forms
bubblesx bubbles v2 bubblesx.New(t) — themed spinner/table/progress styles
tui bubbletea v2 TUI render target: tui.RenderModel[T] lifts borealis.Render into a tea.Model; tui.Program(model, opts…) themed program runner; tui.StatusBoard board
svg stdlib only diagram render target: a typed svg.Diagram (Node+Edge carrying a Role) → Diagram.SVG(t) (themed SVG document) / Diagram.Mermaid(t) (mermaid flowchart source)
cfg shikumi-go cfg.Load(ctx, app) — load Config from env/file via shikumi

The Nord palette (Law 4 target state)

The palette is hardcoded here today (theme.Nord0…Nord15, the exact upstream Nord hex values bound to semantic roles). The committed direction is ishou-generation of these tokens via an ishou render --target lipgloss target plus a generated theme.FromTokens; until that upstream target lands, the hardcoded palette is the source of truth (BOREALIS §2.9 "Target state, not present tense"). When it lands, the constants are replaced byte-for-byte.

Render targets — terminal, TUI, and diagram

Every render target draws from the same Theme, so a tool's CLI output, its live TUI, and a generated diagram are brand-coherent by construction.

import (
	"github.com/pleme-io/borealis"
	"github.com/pleme-io/borealis/comp"
	"github.com/pleme-io/borealis/svg"
	"github.com/pleme-io/borealis/tui"
)

t := borealis.Tundra()

// 1. terminal (the core render verb)
items := []comp.Item{{Role: borealis.Success, Label: "build", Detail: "ok"}}
fmt.Println(borealis.Render(t, items))

// 2. live TUI — RenderModel lifts the SAME render into a bubbletea program
p := tui.Program(tui.NewRenderModel(t, items))
// p.Run()  // View is byte-identical to borealis.Render(t, items)

// 3. diagram — a typed graph → themed SVG document or mermaid source
d := svg.Diagram{
	Title:     "auth flow",
	Direction: svg.LeftRight,
	Nodes: []svg.Node{
		{ID: "cli", Label: "cli", Role: borealis.Active},
		{ID: "gw", Label: "gateway", Role: borealis.Info},
		{ID: "ok", Label: "session", Role: borealis.Success},
	},
	Edges: []svg.Edge{
		{From: "cli", To: "gw", Label: "resolve"},
		{From: "gw", To: "ok", Label: "token"},
	},
}
doc := d.SVG(t)     // standalone <svg>…</svg>
mmd := d.Mermaid(t) // mermaid flowchart with a token-bound %%{init}%% block

svg is pure stdlib (no charm-stack dependency) — node/edge colours come entirely from Theme.RoleColor, so the one model renders identically in Nord, Tundra, or any downstream-overridden theme. Both SVG and Mermaid are deterministic and golden-testable.

Build

go build ./...
go test ./...

Documentation

Overview

Package borealis is THE pleme-io terminal design system: one Theme token bundle, one render verb, and one producer per charm-stack themeable surface.

It is the canonical fleet-wide entrypoint named in BOREALIS §2.9 / §3.5. The resolved token bundle has exactly one type name fleet-wide — Theme — and everything user-facing across the *-go family is rendered through the single verb Render. The brand name is literal and load-bearing: borealis (aurora borealis) IS the Nord Aurora family (see package theme), so the brand, the palette, and the design system are one idea.

Architecture (BOREALIS Law 8 — no core↔core cycle; Law 6 — weight is import-gated):

  • The CORE (this package + theme + comp + style) is built on the stable lipgloss v1 surface and carries no heavy charm-stack deps. It is the surface already consumed by shikumi-go/diag and logging-go/console (comp.StatusList / comp.KV / comp.Glyph / comp.Table), so it stays offline-buildable and back-compatible.
  • The three charm-stack themeable surfaces live in GATED LEAF sub-packages that import the v2 stack: fangx (CLI help/errors via fang+cobra), huhx (huh forms), bubblesx (bubbles widgets). Each takes a borealis.Theme and produces that framework's theme struct from the same Nord tokens.

Uniformity contract (the trivial-tooling payoff, BOREALIS §4):

t, _ := borealis.FromConfig(cfg.Borealis)   // resolve the token bundle
fmt.Println(borealis.Render(t, status))      // the one render verb
return borealis.Execute(ctx, root)           // styled CLI (cli-go root in)

Index

Constants

View Source
const (
	Neutral = theme.Neutral
	Active  = theme.Active
	Info    = theme.Info
	Success = theme.Success
	Warning = theme.Warning
	Danger  = theme.Danger
)

Semantic roles, re-exported from package theme for a single import surface.

Variables

This section is empty.

Functions

func ColorScheme

func ColorScheme(t Theme) fang.ColorSchemeFunc

ColorScheme maps a Theme onto fang's semantic colour slots, returning a fang.ColorSchemeFunc (the shape WithColorSchemeFunc wants). Every CLI's help/usage/errors is therefore themed from the same Nord tokens as the rest of the design system — closing the headline auto-help loop (BOREALIS §2.9).

It lives in the borealis CORE (not the fangx leaf) so that Execute can wire fang without importing fangx — fangx imports borealis for the Theme, so a core→fangx import would form a cycle (Law 8). The fangx leaf re-exports this for back-compatible callers.

func Execute

func Execute(ctx context.Context, root *cli.App, opts ...fang.Option) error

Execute is the canonical CLI entrypoint named in BOREALIS §3.5 (`borealis.Execute(ctx, root, opts…) error`). It is the OUTERMOST entrypoint for every fleet CLI: cli-go's typed root *cli.App is PASSED to it, never redeclared. A service is just a CLI whose `serve` subcommand's Run calls lifecycle.New(...).Run(ctx); borealis.Execute is always the outermost shell.

It realises the grammar/presentation split (§2.2): cli-go owns the typed grammar (the single source of truth — one tree that derives parse, validation, and help structure), and borealis owns 100% of presentation. Execute lowers the typed cli-go tree onto a cobra command via the cli-go/cobrax leaf (Law 8: the lowering lives in cli-go, not here), then runs it under the borealis-themed fang decorator with the Nord ColorScheme pinned. The result:

return borealis.Execute(ctx, root)   // styled help/errors/version, Nord

is the entire CLI entrypoint — no hand-rolled argv switch, no monochrome help, no per-tool styling.

The theme is Nord (the borealis brand palette). opts are forwarded to fang for per-tool extras (extra version info, man metadata, custom completions); the ColorScheme is always pinned first so a tool cannot accidentally un-theme the fleet surface.

func Render

func Render[T any](t Theme, x T) string

Render is THE one render verb (BOREALIS §3.5). Every user-facing value in the fleet — errors-go, todoku-go, lifecycle-go, shigoto-go, cli-go help prose — is rendered through this single function, so two fleet tools cannot drift in how their output looks. Classifiers/producers (Explain, Status, Report) emit a typed value; that value is rendered here. There is no RenderReceipt / StatusString / free-function-with-theme variant.

Render dispatches over the canonical renderable kinds:

  • a Renderable renders itself;
  • the comp typed values (comp.StatusList-shaped slices, comp.Table, comp.KV) render via the comp package;
  • a comp.Tabler renders as a borealis table;
  • a plain string passes through (already-rendered);
  • anything else falls back to a muted fmt rendering so Render is total.

func RunCobra

func RunCobra(ctx context.Context, root *cobra.Command, t Theme, opts ...fang.Option) error

RunCobra is the exported funnel the fangx leaf re-exports as fangx.Execute: it runs an already-lowered *cobra.Command under the borealis-themed fang decorator. Tools that hold a typed cli-go root should call Execute instead (it lowers for you); this entry exists for callers that already have a cobra command (and for the fangx leaf's back-compatible surface).

Types

type ColorMode

type ColorMode string

ColorMode controls colour output. Auto downsamples to the detected terminal profile; Always forces colour; Never disables it (honouring NO_COLOR).

const (
	ColorAuto   ColorMode = "auto"
	ColorAlways ColorMode = "always"
	ColorNever  ColorMode = "never"
)

type Config

type Config struct {
	// Theme overrides individual tokens. A zero Theme means "use the brand
	// default" (Nord). Any non-empty field overrides the corresponding token.
	Theme theme.Theme `json:"theme" yaml:"theme"`

	// Mode selects light/dark adaptation. Default ModeAuto.
	Mode Mode `json:"mode" yaml:"mode"`

	// Color controls colour output. Default ColorAuto. NO_COLOR in the
	// environment forces ColorNever regardless of this value (§8 item 8).
	Color ColorMode `json:"color" yaml:"color"`

	// Accessible passes huh's accessible mode through and biases components
	// toward high-contrast, no-colour-dependent output.
	Accessible bool `json:"accessible" yaml:"accessible"`
}

Config is the shikumi-loadable runtime knob surface for the design system (BOREALIS §2.9 / elevation §8 item 7). It is a typed struct with yaml tags; it is loaded ONCE at main via shikumi (see github.com/pleme-io/borealis/cfg) and the already-loaded sub-struct is handed to FromConfig — which never itself calls shikumi.Load (BOREALIS §3.5).

Theme is an embedded, fully-overridable token bundle: leaving it zero selects the Nord brand default; a yaml file may override any token (pure data), which is the consume-an-upstream-generated-theme seam for Law 4.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the brand defaults: Nord theme, auto mode, auto colour.

func (Config) NoColor

func (c Config) NoColor() bool

NoColor reports whether colour must be suppressed: NO_COLOR set in the environment (the cross-tool convention) OR Color explicitly Never. The gated leaves consult this when constructing their framework theme structs.

type Mode

type Mode string

Mode selects light/dark adaptation. Auto defers to terminal background detection (done by the v2 writers in the gated leaves); Light/Dark force it.

const (
	ModeAuto  Mode = "auto"
	ModeLight Mode = "light"
	ModeDark  Mode = "dark"
)

type Renderable

type Renderable interface {
	RenderBorealis(t Theme) string
}

Renderable is any typed value that knows how to render itself through a Theme. Domain values that already produce a string from a theme (the comp set, classifier outputs like todoku's Explain or lifecycle's Status) implement this so Render dispatches uniformly. This is the carrier interface behind the one render verb (BOREALIS Law 5).

type Role

type Role = theme.Role

Role is a semantic intent re-exported so consumers can stay inside the borealis package surface (borealis.Success, borealis.Danger, …).

type Theme

type Theme = theme.Theme

Theme is the resolved design-token bundle — THE single type name fleet-wide (BOREALIS §3.5: "the resolved theme token bundle has exactly one type name fleet-wide: borealis.Theme"). It is an alias of theme.Theme so the canonical name and the back-compat package surface are byte-identical: a sibling that already takes a theme.Theme (shikumi-go/diag, logging-go/console) is automatically passing a borealis.Theme.

func Default

func Default() Theme

Default returns the borealis brand theme (the Nord aurora palette).

func FromConfig

func FromConfig(cfg Config) (Theme, error)

FromConfig resolves a Config into the canonical Theme token bundle (BOREALIS §3.5: `pkg.FromConfig(cfg pkg.Config) (*T, error)` shape — here T is the value type Theme since the bundle is pure data). It takes the already-loaded sub-struct and MUST NOT call shikumi.Load.

Resolution: start from the Nord brand default, then overlay any non-zero token from cfg.Theme. NO_COLOR (or Color==Never) is recorded by the gated leaves at render time via Config.NoColor; FromConfig itself stays pure so it is total and deterministic.

func Nord

func Nord() Theme

Nord returns the borealis brand theme built from the hardcoded Nord palette. It is the single source of truth every producer derives from.

func Tundra

func Tundra() Theme

Tundra returns the borealis "tundra" theme: the Nord aurora idea in a cooler, deeper, higher-contrast arctic palette variant. It binds the same semantic roles as Nord, so any consumer written against a Theme renders unchanged. Tundra is a NEUTRAL palette — it carries no downstream brand name; a profile that selects it owns the brand and keeps it out of borealis (WORLDS-SEPARATE, see theory/borealis-profiles.md).

Directories

Path Synopsis
Package bubblesx is the GATED LEAF that themes the stock-widgets surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package bubblesx is the GATED LEAF that themes the stock-widgets surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package cfg is the GATED LEAF that loads a borealis.Config through shikumi-go (BOREALIS Law 3 / Law 8).
Package cfg is the GATED LEAF that loads a borealis.Config through shikumi-go (BOREALIS Law 3 / Law 8).
Package comp provides themed, render-to-string terminal components built on a theme.Theme.
Package comp provides themed, render-to-string terminal components built on a theme.Theme.
Package fangx is the GATED LEAF that themes the CLI help/usage/errors surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package fangx is the GATED LEAF that themes the CLI help/usage/errors surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package huhx is the GATED LEAF that themes the interactive-forms surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package huhx is the GATED LEAF that themes the interactive-forms surface — one of the exactly-three themeable surfaces of a charm-stack tool (BOREALIS §2.9).
Package style turns a theme.Theme into a ready-to-use set of Lip Gloss styles.
Package style turns a theme.Theme into a ready-to-use set of Lip Gloss styles.
Package svg is the GATED LEAF that renders a typed borealis diagram model to an ishou-themed SVG document or a mermaid source string — the two document-render targets named in the pattern registry §4d (borealis row: "ishou-themed SVG/mermaid render helper").
Package svg is the GATED LEAF that renders a typed borealis diagram model to an ishou-themed SVG document or a mermaid source string — the two document-render targets named in the pattern registry §4d (borealis row: "ishou-themed SVG/mermaid render helper").
Package theme defines borealis's design tokens: a small set of semantic colours that everything else derives from.
Package theme defines borealis's design tokens: a small set of semantic colours that everything else derives from.
Package tui is the GATED LEAF of borealis tea.Model components — live, interactive widgets that carry an injected borealis.Theme so a TUI is themed from the same Nord tokens as static render output (elevation §8 item 10).
Package tui is the GATED LEAF of borealis tea.Model components — live, interactive widgets that carry an injected borealis.Theme so a TUI is themed from the same Nord tokens as static render output (elevation §8 item 10).

Jump to

Keyboard shortcuts

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