tui-builder
Build terminal UIs by writing YAML. Wire HTTP / subprocess / file data
sources into them. Merge sources across clusters, accounts, or
environments. Stream long-running output into a logview. Drill into
multi-screen flows with stable cursor state across refreshes.
Docs: https://jsdrews.github.io/tui-builder/ — quick start, guide,
full config reference, CLIs and every example.
Built on top of tuilib: the
component library does the rendering and theming; tui-builder turns
declarative config into a live composition.
Two binaries, one config. Data wrangling is a first-class concern,
not a TUI implementation detail:
wrangl — runs the data layer only and dumps JSON / NDJSON to
stdout. Pipe it into jq, duckdb, miller, a notebook, or another
pipeline. Zero terminal-UI dependencies.
tui-builder — uses the same data layer, then renders it
through tuilib components. The TUI is one sink, not the product.
The data.sources: block holds every named, addressable producer of
data — both leaf sources (http / exec / file / websocket / static /
merge) and operator pipelines (filter, project, derive, sort,
union, compose, join, cache, passthrough). Every entry
carries a type: discriminator that picks its kind. Operator
expressions use an embedded expression language (expr-lang). Any
entry can declare its own typed parameters: block, bindable via
wrangl --param.
See docs/reference/sources.md and
docs/reference/pipelines.md for every field, and
docs/data-layer.md for how the data layer fits together.
┌ All pods (3 clusters merged) ────────────────────────────────────┐
│ Cluster │ Namespace │ Name │ Status │
├──────────────┼───────────┼─────────────────────────┼─────────────┤
│ pods_prod │ default │ nginx-56c45fd5ff-7p9mw │ Running │
│ pods_prod │ default │ nginx-56c45fd5ff-dv862 │ Running │
│ pods_staging │ default │ api-7d8b6c5b4-x2k7p │ Running │
│ pods_dev │ default │ broken-544795c8b5-5hxfg │ CrashLoop… │
│ pods_dev │ default │ scratch-7c98... │ Running │
└──────────────────────────────────────────────────────────────────┘
? help
What you get
| Capability |
What it looks like |
| Declarative TUIs |
One YAML file per app: data.sources: + tui.components: + tui.screen: / tui.screens:. No Go to write for the common case. |
| Components |
list, table, inspector, tree, logview, textview, eventlog — every tuilib component except those that don't fit a config model |
| Data sources |
http, exec, file, websocket, static, merge — plus operator kinds (filter, project, derive, sort, union, compose, join, cache, passthrough) layered on top |
| Multi-screen |
Push/pop with breadcrumbs; ${selection.*} substitutes parent row into child config (URL, title, fields) |
| Streaming |
Long-running exec + websocket push events into a logview as they arrive |
| Live data |
Per-source refresh: <duration> polling with in-place updates — cursor / filter / sort survive every refresh |
| Color |
Theme-wide palettes (Nord, Dracula, …) + per-component colors: overrides + per-value color_rules: ("Running" → green, "ERROR" → red) |
| Templating |
${selection.col} (parent row), ${env.VAR} (env var) substitute anywhere a string lives — titles, URLs, headers, action argv |
| Actions |
Named, addressable units of work (exec subprocess or http request) with typed inputs:. Bound to keys per screen; optional confirm: modal; interactive (TTY handoff) or captured (streams into the output console). Inspectable headlessly via wrangl --list-actions / --describe-action |
| Output console |
One sink for every action result, subprocess line, and fetch error. o opens it; an unread badge tints red on failure. No blocking error modals anywhere |
| Errors |
Failed subprocesses surface in an alert modal with stderr captured; failed merge children surface in the statusbar without blanking the table |
Quickstart
Install prebuilt binaries (Linux and macOS; no Go needed):
curl -fsSL https://raw.githubusercontent.com/jsdrews/tui-builder/main/scripts/install.sh | sh
Release archives, go install and other options are in the
quick start. To
work from a clone with the examples:
git clone git@github.com:jsdrews/tui-builder.git
cd tui-builder
task build # → bin/tui-builder, bin/example-launcher, bin/wrangl
# Browse every example in a launcher TUI:
task examples
# Or run one directly:
task example NAME=table
task example NAME=http_countries # live REST API
task example NAME=merge_sources # local merge of file + 2 exec sources
# Or skip the TUI entirely and pipe data:
go run ./cmd/wrangl --list examples/http_countries.yaml
go run ./cmd/wrangl examples/http_countries.yaml all_countries | jq '.[0].name.common'
task --list shows the full menu.
Two ways to consume a config
Once you've written a YAML config with data.sources: + (optionally)
tui.components: + tui.screen:, you can either render it as a TUI
or just dump the data:
# Render the TUI:
bin/tui-builder examples/http_countries.yaml
# Or dump every defined entry:
bin/wrangl --list examples/http_countries.yaml
# NAME KIND LIFECYCLE UPSTREAM
# all_countries pipeline / passthrough polled (refresh: 5m) countries
# countries source / http polled (refresh: 5m)
# Or pipe one pipeline's output downstream:
bin/wrangl examples/http_countries.yaml all_countries | jq '.[0]'
bin/wrangl --limit 50 examples/stream_l1.yaml l1 | jq '.data.s'
# Or run a parameterized pipeline (operator expressions get
# `params.X` access alongside item fields):
bin/wrangl examples/filter_demo.yaml long_usernames --param min=12
# Or describe a pipeline's schema (operator kind, lifecycle, params):
bin/wrangl examples/filter_demo.yaml users_with_posts --describe
wrangl is the same data layer the TUI uses — the architecture
guarantees there's no second pipeline implementation drifting out of
sync. A CI check enforces that cmd/wrangl and the data-layer packages
never import any TUI code.
A first config
mkdir my-project && cd my-project
tui-builder init -o tui-builder.yaml
tui-builder tui-builder.yaml
init prints a small commented config that runs offline: a static
source of four rows, a filterable table bound to it, and one screen,
with an http source and an exec source commented out as next steps.
Each section links its reference page. The whole file is shown in the
quick start.
In the app, tab cycles focus, / filters, [/]/s step the sort
column, q quits, and o opens the output console.
The mouse works too: click a pane to focus it, click a row to move its
cursor, scroll with the wheel, and double-click a row for enter — the
same action the keyboard fires. Right-click a row opens the action
menu against THAT row — one gesture, not click-then-press-a.
Mouse reporting takes over the terminal's own click-drag text selection —
hold shift (or alt in iTerm2) while dragging to select text for a copy.
tui-builder init <kind> prints an example of any one component or
source instead, init table or init http, with every field it takes
commented out underneath.
Every command that makes a config prints it, and -o FILE writes it
instead: tui-builder init table | tui-builder - runs one without saving
it.
From there, tui-builder add exec -- <command> writes a config for any
command that prints JSON, and tui-builder gen <openapi spec> one for an
HTTP API.
Tour by feature
Data sources
Bind a component to a source by name. The same dot-path resolver works
across all source types; the same color_rules syntax works against
any pluckable value.
data:
sources:
countries:
type: http
url: https://raw.githubusercontent.com/mledoze/countries/master/countries.json
refresh: 5m
tui:
components:
countries:
type: table
source: countries
columns:
- {title: Name, value: name.common}
- {title: Region, value: region}
- {title: Area, value: area, sort: number, align: right}
Source kinds (leaf — fetch externally):
| Type |
When |
Notes |
http |
REST and GraphQL APIs, JSON endpoints, kube proxies |
url, query, headers, a json / form / body / graphql body, auth (bearer, basic, API key, OAuth 2 client credentials; masked in output), retry with rate-limit headers, conditional GET, empty_on / error_path |
exec |
Anything that prints JSON: kubectl get -o json, gh api, terraform output -json, custom scripts |
Per-source env: adds to inherited env |
file |
Fixtures, generated dumps, lab notebook output |
refresh: <duration> re-reads; omit for once |
websocket |
Live event streams: chat, custom buses |
headers and auth go on the upgrade request |
static |
Inline data, fixtures, lookup tables |
data: carries the value directly — list, object, scalar |
merge |
Compose N children, union the rows, tag each item by source — cross-cluster / cross-account / cross-anything |
tag_field: writes child name into each item; on_error: skip returns survivors + a partial-error notice |
Operator kinds (transform an upstream entry):
| Type |
What it does |
passthrough |
Stable addressable alias over an upstream (from:); no transformation |
filter |
Drop items whose where: predicate doesn't match |
project |
Rebuild each item from declared output keys (keep:) |
derive |
Copy each item and add computed fields (compute:) |
sort |
Reorder by key expression (by:, order: asc|desc) |
union |
Flatten N homogeneous upstreams into one list (same shape as merge but children can be operators too) |
compose |
Bundle N heterogeneous upstreams into one object (parts: {key: upstream-name}) |
join |
Per-row enrichment: driver iterable + per-row lookup fetches |
cache |
TTL-memoise an upstream's Fetch |
See docs/reference/components.md for every field.
Sources against one API share their base URL, headers, auth and retry
through a preset under data.presets:, which each source
extends::
data:
presets:
github:
type: http
url: https://api.github.com
auth: {bearer: "${env.GITHUB_TOKEN}"}
retry: {max: 3}
sources:
issues:
extends: github
url: /repos/${params.repo}/issues # appended to the preset's url
http actions can extends: the same preset, so a write takes the same
base URL and auth as the reads beside it. See
docs/reference/sources.md.
Paging a remote API
An http or exec source over more rows than fit in memory has two
options, and they trade against each other:
paginate: # walk every page up front, hand back one list
strategy: link # or cursor, offset, page
next_path: "link:next" # a body path, or the Link header
window: # fetch only the rows on screen; the SERVER
offset_param: offset # answers the filter and the sort
limit_param: limit
total_path: numFound
search_param: q
filters: {Author: author}
With window: the bound table holds one page of a much larger set and
paints the rest as · until you scroll there. Typing author:tolkien
searches every row the server has, not the hundred that happen to be
resident — which is the part paginate: can't do at any page count.
Binding a table to a windowed source is what switches it into that mode;
there's no second flag. An API that pages by number uses
page_param: page in place of offset_param:; an API with no server
filter is windowed under a table without filterable:. Either way the
response must carry a total.
The rule of thumb: sort and filter run where all the rows are. Under a
few thousand rows, paginate: holds them all and the table sorts and
filters locally, whatever the API supports (a walk cut short at
max_pages says so). Past that, window:, and the API's own sort and
filter are all there is.
window: works on exec too — there the request templates into the
argv instead of a query string, via ${window.offset},
${window.limit}, ${window.search}, and ${window.filters.<name>}:
command: [myreport, --offset=${window.offset}, --limit=${window.limit},
--author=${window.filters.author}]
An element whose window tokens all resolve empty is dropped, so with no
author: term typed the --author= flag disappears entirely rather than
being passed empty.
See examples/http_window.yaml,
examples/http_pages.yaml,
examples/exec_window.yaml, and
window.
Streaming
Long-running subprocess (exec + follow: true) or WebSocket
connection. Events arrive over time; the bound component receives them
without resetting cursor / filter / scroll.
Into a logview — lines append as-is:
data:
sources:
logs:
type: exec
follow: true
command: [kubectl, logs, -f, "-n", default, my-pod]
tui:
components:
log:
type: logview
source: logs
color_rules:
- {when: "~\\b(ERROR|FATAL)\\b", color: red}
- {when: "~\\bWARN\\b", color: yellow}
Into a table — two modes:
Ring buffer (live-tape pattern) — each frame appends, oldest scroll
off past max_rows:
components:
trades_table:
type: table
source: trades
max_rows: 100
columns:
- {title: Price, value: data.price_str, sort: number, align: right}
- {title: Amount, value: data.amount_str, sort: number, align: right}
Keyed upsert (L1 / status-grid pattern) — one row per row_key,
updates in place when the key recurs, append when the key is new:
components:
l1_book:
type: table
source: l1
row_key: data.s # symbol = row identity
columns:
- {title: Symbol, value: data.s}
- {title: Best bid, value: data.b, sort: number, align: right}
- {title: Best ask, value: data.a, sort: number, align: right}
The cursor stays on whichever row you'd selected while ticks flow —
even at hundreds of updates per second.
Multi-screen drilldown
A screen can push another when the user hits enter on a focused list /
table. The selected row's values flow into the child's config via
${selection.col} (table) or ${selection} (list).
data:
sources:
pod_detail:
type: http
url: http://localhost:8001/api/v1/namespaces/${selection.Namespace}/pods/${selection.Name}
tui:
screens:
pods:
layout: {component: pods_table}
actions:
- {key: enter, name: open_detail, push: detail, from: pods_table}
detail:
title: ${selection.Name}
layout: {component: pod_inspector}
initial: pods
esc pops; breadcrumbs accumulate at the top of the screen.
Actions
Actions are the write side, declared in a top-level actions: block and
bound to keys by a screen. The split is deliberate: an action says what
to run and what inputs it needs; a binding says which key, which
pane's row feeds it, and whether to confirm.
actions:
pod_delete:
description: Delete a pod
inputs:
namespace: {type: string, required: true}
name: {type: string, required: true}
run: [kubectl, delete, -n, "${inputs.namespace}", pod, "${inputs.name}"]
message: "deleted ${inputs.name}"
tui:
screens:
pods:
actions:
- key: D
action: pod_delete
label: delete
from: pods_table
confirm: "Delete ${selection.Name}? Cannot be undone."
bind:
namespace: ${selection.Namespace}
name: ${selection.Name}
An action never mentions ${selection.*} — that keeps it reusable from
any screen. from: is required exactly when a template reads a
selection (or the action is a push) and rejected otherwise, so a verb
needing no row simply omits it.
Press a for the menu. That is where verbs live: it lists every
action the screen has, with a reason next to anything unavailable, and
owns the confirm modal, cancellation, and the console entry. key: is
optional — enter still fires directly (double-click is its mouse
spelling), any other key is a shortcut that works while the menu is
open, and a binding with no key at all is menu-only. That last one is
the point: the alphabet stops capping how many verbs a screen can have.
Pushes are actions too. push: <screen> opens another screen; the
binding's bind: fills the destination's parameters: rather than the
action's inputs. There is one registry, not a separate on_key: block.
Actions are also addressable from the CLI, which makes them testable
without a TTY:
wrangl --list-actions examples/kube.yaml
# NAME KIND INPUTS DESCRIPTION
# pod_delete exec name*, namespace* Delete a pod
wrangl --describe-action examples/kube.yaml pod_delete \
--param namespace=default --param name=nginx-abc
# ...
# DRY RUN
# kubectl delete -n default pod nginx-abc
There is no wrangl --run: every safety gate an action has is TUI state,
and a headless caller would bypass all of it.
HTTP actions. type: http is for APIs with no CLI in the loop —
method / url / headers / body, plus a result contract for APIs
that don't use status codes honestly:
actions:
sync_app:
type: http
method: POST
url: ${env.ARGOCD_URL}/api/v1/applications/${inputs.app}/sync
headers: {Authorization: "Bearer ${env.ARGOCD_TOKEN}"}
inputs: {app: {type: string, required: true}}
success: code < 400 or code == 409 # already syncing isn't a failure
error_message: ${body.message} # the API's reason, not "→ 403"
Inputs the caller doesn't bind get collected in a form generated
from the input declarations — there is no separate prompts: schema, so
the form can't drift out of step with the argv. The data type picks the
widget: type: bool is a toggle, anything with options: is a select,
everything else is a text input.
Where results go
Every action reports to the app-wide output console (o), and only
there. Its stdout/stderr stream in line by line as they arrive; the
summary line paints the statusbar; a persistent unread badge in the
statusbar's right slot goes red if anything failed and stays until you
read it.
There are no error modals — not for actions, not for failed fetches. The
statusbar's centre slot wipes on the next keypress, which is why modals
existed; the console plus a badge that doesn't wipe is the better fix,
and nothing blocks.
Actions also never refresh your views. A view owns its own refresh cycle:
one that should converge after a mutation declares refresh:, and r
refetches on demand. Coupling a mutation to a repaint would make every
action responsible for knowing which panes it invalidated.
Color rules
Per-column for tables, per-field for inspectors, top-level for
lists/logviews. Same matcher syntax everywhere:
color_rules:
- {when: Running, color: green} # exact string
- {when: "~CrashLoopBackOff", color: red} # regex
- {when: ">5", color: red} # numeric > 5
- {when: ">=2M", color: bright_red} # SI-suffix numeric
- {when: "", color: gray} # wildcard / default
Colors accept named (red, bright_green, gray), 0-255 indices
("160"), hex ("#ff8800"), and theme tokens (theme:accent).
Examples
Run any via task example NAME=<filename-without-yaml>, or browse all
via task examples.
| File |
What it shows |
examples/list.yaml |
Filterable list, navigation keys |
examples/table.yaml |
Filterable + sortable table, filter syntax (key:value, ~regex) |
examples/table_columns.yaml |
Column sizing (fixed / auto / flex / max_width) + alignment |
examples/table_styled.yaml |
Colored cells + clickable hyperlinks, initial_sort |
examples/table_wide.yaml |
Wide table with horizontal scroll (←/→, 0/$) |
examples/inspector.yaml |
Two-column label/value record viewer, nested groups |
examples/inspector_auto.yaml |
auto: true — an inspector that derives its fields from any JSON response |
examples/tree.yaml |
Hierarchical view, expand/collapse, search |
examples/tree_source.yaml |
Source-bound tree: a file source bucketed by group_by: team, surviving refresh: polling |
examples/logview.yaml |
Streaming-log pane, /-search, filter mode |
examples/eventlog.yaml |
An eventlog paging a 2,000-event job log through an exec window: search, server-side filter, enter to open an event |
examples/anchored.yaml |
An eventlog over an Anchored source: a log walked by timestamp with window.cursor: (the search_after shape), opening at the newest line |
examples/span_table.yaml |
A span table over the same Anchored log: rows walked from the newest, marks that hold as older pages load, and a multi action over them |
examples/textview.yaml |
Static-text viewer: inline content: plus a source-bound clock; /-search, w wrap |
examples/layout.yaml |
Nested vstack / hstack with mixed flex weights |
examples/themes.yaml |
Theme picker reference |
examples/chrome.yaml |
app.glyphs + app.borders — glyph vocabulary and border shapes |
examples/marking.yaml |
Multi-select with markable: + mark_key: |
examples/activity.yaml |
Row activity: pods spin while Pending or Terminating, read from the data every 2s poll; FAIL=1 shows the "reads failing" title |
examples/colors.yaml |
Per-component colors: overrides |
examples/multi.yaml |
Multi-screen drilldown with breadcrumbs |
examples/on_cursor.yaml |
on_cursor: — a repos table drives a detail inspector below it via ${cursor.*} |
examples/on_cursor_fs.yaml |
on_cursor: from a tree over the filesystem; ${cursor.path} feeds stat in a textview |
examples/http_countries.yaml |
A table over public JSON (the mledoze/countries dataset on GitHub), polled every 5m |
examples/http_github.yaml |
GitHub API drilldown: users → repos → repo detail |
examples/http_github_auth.yaml |
Authenticated GitHub (${env.GITHUB_TOKEN}) |
examples/http_refresh.yaml |
CoinGecko prices with 10s polling |
examples/http_paginated.yaml |
paginate: — walk every page up front into one list |
examples/http_window.yaml |
window: over http — page and filter a remote API from the table; the server answers author:tolkien across all 2M Open Library books while the table holds 100 rows |
examples/exec_window.yaml |
window: over exec — the same loop templated into an argv; git log --skip/--max-count/--author/--grep answers the table's paging and filtering |
examples/exec_local.yaml |
exec source: git log as a table |
examples/file_fixture.yaml |
file source with live re-read |
examples/merge_sources.yaml |
merge source unioning file + 2 exec children |
examples/stream_exec.yaml |
exec follow mode → logview |
examples/stream_websocket.yaml |
websocket source → logview |
examples/stream_trades_table.yaml |
websocket source → live table (max_rows: 100 ring buffer of bitstamp BTC/USD trades) |
examples/stream_l1.yaml |
L1 ticker JOINED from two Binance.us streams (bookTicker for fast bid/ask + @ticker for last price + 24h stats), merged by symbol via row_key: data.s. Deep-merge composes both sources' fields onto each row |
examples/prompts_boot.yaml |
Boot-time form collects params (app.prompts) before the main screen renders; values become env vars, feed into the source URL via ${env.USER}. Includes a mask: true field for a token |
examples/action_prompts.yaml |
The action menu (a): one verb on enter, one as a menu shortcut, one with no key at all. Unbound inputs: open a generated form. All echo, so it runs anywhere |
examples/push_actions.yaml |
Pushes as actions — enter drills GitHub users → repos; a keyless verb opens starred from the menu |
examples/action_http_argocd.yaml |
type: http actions against the Argo CD API — bearer auth, success: for a 409-is-fine API, error_message: ${body.message} |
examples/kube.yaml |
Single-cluster kube: namespaces → pods → pod detail + logs |
examples/kube_multi.yaml |
Multi-cluster kube: 3 clusters merged into one table |
examples/demo.yaml |
Kitchen sink: list and table side by side |
The two kube examples are wired to Taskfile tasks — see Kubernetes
demos below.
Kubernetes demos
Two layers — single cluster (one TUI binding) and multi-cluster (merge
across 3 kind clusters).
Single cluster
task kube:up # creates `tui-builder` kind cluster + workloads
task kube:proxy # in another terminal: kubectl proxy --port=8001
task kube:demo # opens examples/kube.yaml
task kube:down # cleans up
examples/kube.yaml drills namespaces → pods → pod detail + tailing
logs. The pods table demonstrates kubectl-style STATUS computation via
a value: fallback chain (waiting.reason → terminated.reason → status.phase).
Multi-cluster (3 kind clusters merged)
Per-terminal — each proxy is foreground:
task kube:multi:up # creates tb-prod / tb-staging / tb-dev
task kube:multi:proxy:prod # terminal 1
task kube:multi:proxy:staging # terminal 2
task kube:multi:proxy:dev # terminal 3
task kube:multi:check # verify all 3 are reachable
task kube:multi:demo # opens examples/kube_multi.yaml
task kube:multi:down # tears down all 3 clusters
task kube:multi:proxy:status shows port binding state (regardless of
how a proxy got started). kube:multi:check additionally pings each
endpoint and counts the pods.
Project layout
golang-standards/project-layout:
cmd/
tui-builder/ # CLI: tui-builder <config.yaml> (TUI sink)
wrangl/ # CLI: wrangl [flags] <config.yaml> (data sink: JSON / NDJSON)
example-launcher/ # TUI for browsing every example
internal/
config/ # YAML schema: cfg.Source bag-of-fields + Type-discriminator dispatch
datasource/ # ds.Source interface + http / exec / file / websocket / static / merge builders
pipeline/ # operator builders: filter / project / derive / sort / union / compose / join / cache / passthrough
expr/ # embedded expression language adapter (expr-lang/expr); used by every operator
output/ # JSON / NDJSON stdout sink used by wrangl
build/ # cfg → live tuilib components + binding layer [TUI side]
screen/ # screen.Screen impl: focus, push/pop, modals, lifecycle [TUI side]
examples/ # one YAML per feature, plus the kube demos
scripts/
check-data-layer-boundary.sh # enforces no-TUI-imports in the data layer
docs/
reference/ # every config field, one page per area
data-layer.md # how sources, pipelines and wrangl fit together
AGENTS.md # rules for AI agents working in this repo
Taskfile.yml # go-task entry points (`task --list`)
The horizontal split — config / datasource / pipeline / output / cmd/wrangl
above; build / screen / cmd/tui-builder below — is enforced by a CI
check (scripts/check-data-layer-boundary.sh). The data layer must
stay buildable, testable, and runnable without dragging in Bubble Tea
or tuilib. If you ever need a TUI helper from the data layer, that's a
sign the boundary is wrong, not that you need an exception.
Where to go next
docs/reference/ — every config
field: app and layout, components, sources, pipelines, actions, and
the ${…} token, dot-path, expression and color syntax.
AGENTS.md — agent guidance: architecture brief,
rules to follow, anti-patterns. Read this before generating tui-builder
code with an LLM.
- Examples —
task examples launches a picker; each file is
heavily commented and meant to be copy-and-adapt material.
Development
task build # binaries → ./bin
task test # go vet + go test
task tidy # go mod tidy
task clean # rm bin/
Tests live under internal/datasource/source_test.go (data-source
contract) and internal/screen/datasource_test.go +
internal/screen/multi_e2e_test.go (end-to-end through the app shell
with stub servers).
Built on