agentui

module
v0.0.0-...-ec0414e Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0

README

agentui

Fork it. Hand it to your coding agent. Build the terminal product you want.

A Go reimplementation of Grok's TUI for building polished terminal experiences.

https://github.com/user-attachments/assets/7593e5bf-a042-4db3-aa04-48985ced11b6

Grok's TUI gets the small things right: natural scrolling, sticky prompts, clear agent activity, thoughtful spacing, and mouse interactions with real hover and press states. agentui recreates that experience in Go so the source can be adapted into many different terminal products.

The project is backend-neutral. It does not include an agent SDK, model transport, accounts, or credentials. The demo is local and entirely synthetic.

Try it

Requires Go 1.26 or newer.

git clone https://github.com/minoism/agentui.git
cd agentui
go run ./examples/chatdemo

The demo contains fake conversations and working examples of hooks, folds, sticky headers, workflows, subagents, queues, settings, permissions, Markdown, syntax highlighting, media, and command surfaces.

Useful shortcuts:

Key Action
/ browse slash commands
Ctrl+P open the command palette
Ctrl+G open tasks and subagents
Ctrl+; open the queue
Ctrl+X show shortcuts

Try /settings, /dashboard, /workflows, /skills, /permission-demo, and /turn-status-demo to explore the larger surfaces.

What is included

  • A custom cell-buffer renderer, terminal lifecycle, diffing, synchronized output, mouse protocols, and presenter backpressure.
  • A document-style transcript with folding, hook previews, sticky prompt headers, smooth scrolling, selection, hover, and press states.
  • A multiline composer, slash completion, command palette, search, Markdown, syntax highlighting, links, and prompt attachments.
  • Dashboard, sessions, workflows, tasks, subagents, queue, settings, skills, permissions, questions, plans, history, and media surfaces.
  • Deterministic fixtures plus PTY, interaction, race, and cross-platform tests.

Make it yours

The recommended workflow is simple: clone or fork the source and let your coding agent reshape it. Package boundaries, commands, layouts, colors, fixtures, and product surfaces are all intended to be edited.

This repository does not promise stable public APIs or release versions. Choose a commit that works for you and change it freely.

AGENTS.md gives coding agents a short architecture map. For example:

Read AGENTS.md and run the chat demo. Keep the terminal lifecycle and idle
loop invariants, then change the layout, commands, fixtures, and panels for
my product. Breaking the original package API is fine.

Common starting points:

Goal Start here
application layout and chrome runtime/app.go, runtime/*_ui.go
transcript, folds, sticky headers scrollback/
composer and completion input/, completion/, palette/
themes and rendering theme/, cellbuf/, markdown/
fake demo content examples/chatdemo/, package Demo* constructors

Optional surfaces

Built-in feature switches make it easy to start small:

features := runtime.CoreFeatures().With(
	runtime.FeatureDocs,
	runtime.FeatureSkills,
	runtime.FeaturePermissions,
)

app := runtime.New(runtime.Config{
	Features: features,
})

DefaultFeatures().Without(...) works in the other direction. Disabling a feature removes its commands, shortcuts, Store initialization, layout space, and rendering. These switches are conveniences for modifying the source, not a permanent plugin contract.

Why a custom renderer?

agentui is not built on Bubble Tea. Its cell diff, document projection, sticky-header geometry, terminal lifecycle, mouse semantics, and post-flush graphics behavior live in this repository. That control is what makes the Grok-style interaction model possible without forcing it into a component-tree abstraction.

The lower-level packages can also be used independently:

Area Packages
terminal and rendering cellbuf, term, present, minimal, graphics
document and input scrollback, textwrap, markdown, input, completion
UI shell runtime, overlay, palette, interaction
product state session, workflow, queue, tasks, catalog, goal

Connect a backend

agentui supplies UI state machines, Stores, callbacks, and demo data. Your product owns model transport, authentication, persistence, live task and workflow feeds, permission execution, media viewers, and account flows.

Keeping that boundary explicit makes the TUI useful with any agent or backend.

Development

go test -count=1 ./...
go test -race ./runtime ./scrollback ./term ./cellbuf
go vet ./...
go run ./examples/bench

The test suite includes real PTY coverage for terminal startup, resize, mouse/focus events, Kitty input, safe links, and ordered teardown.

License

Apache License 2.0. This project is an independent Go reimplementation inspired by Grok's TUI and is not affiliated with or endorsed by xAI. See THIRD-PARTY-NOTICES.

Directories

Path Synopsis
Package anim provides the animation primitives of the pager: spinners, shimmer ramps, eased transitions, and a coalescing animation clock that reports whether anything is still animating (so the event loop can park).
Package anim provides the animation primitives of the pager: spinners, shimmer ramps, eased transitions, and a coalescing animation clock that reports whether anything is still animating (so the event loop can park).
Package btw models Grok's correlated /btw side-question lifecycle without depending on a transport or renderer.
Package btw models Grok's correlated /btw side-question lifecycle without depending on a transport or renderer.
Package catalog models Grok's settings and extension browsers independently from configuration files, plugin installers, MCP transports, and memory persistence.
Package catalog models Grok's settings and extension browsers independently from configuration files, plugin installers, MCP transports, and memory persistence.
Package cellbuf provides agentui's cell-grid model: a Buffer of styled grapheme cells, a diff-based ANSI emitter that writes only changed cells (or scrolls an unchanged vertical row run), cursor-command de-duplication that preserves the terminal's cursor blink timer, and synchronized-output framing (CSI 2026).
Package cellbuf provides agentui's cell-grid model: a Buffer of styled grapheme cells, a diff-based ANSI emitter that writes only changed cells (or scrolls an unchanged vertical row run), cursor-command de-duplication that preserves the terminal's cursor blink timer, and synchronized-output framing (CSI 2026).
Package completion contains the deterministic models used by the prompt suggestion, shell-completion and @file surfaces.
Package completion contains the deterministic models used by the prompt suggestion, shell-completion and @file surfaces.
examples
bench command
Command bench is the offscreen render benchmark for agentui: no terminal, no writer — it renders a chatdemo-like scrollback into a 120×30 cell buffer at successive scroll offsets and diffs consecutive frames, measuring the full per-frame render+diff cost the runtime pays.
Command bench is the offscreen render benchmark for agentui: no terminal, no writer — it renders a chatdemo-like scrollback into a 120×30 cell buffer at successive scroll offsets and diffs consecutive frames, measuring the full per-frame render+diff cost the runtime pays.
chatdemo command
Command chatdemo is the interactive acceptance demo for agentui, imitating the real xai-grok-pager interaction: a preloaded multi-screen conversation (so scrolling, sticky headers, folding, selection, search and links are exercisable immediately), plus a live prompt at the bottom — type a message, press Enter, and a canned-but-varied agent reply streams back with animated accents.
Command chatdemo is the interactive acceptance demo for agentui, imitating the real xai-grok-pager interaction: a preloaded multi-screen conversation (so scrolling, sticky headers, folding, selection, search and links are exercisable immediately), plus a live prompt at the bottom — type a message, press Enter, and a canned-but-varied agent reply streams back with animated accents.
Package fuzzy implements fzf-style subsequence fuzzy matching — the Go counterpart of the nucleo matcher grok-build uses for its slash-command palette and history search.
Package fuzzy implements fzf-style subsequence fuzzy matching — the Go counterpart of the nucleo matcher grok-build uses for its slash-command palette and history search.
Package goal provides the product-independent state model behind Grok's expanded /goal detail overlay.
Package goal provides the product-independent state model behind Grok's expanded /goal detail overlay.
Package graphics implements terminal inline images over the kitty graphics protocol — the Go port of grok-build's terminal/image.rs: protocol detection by terminal brand, PNG transmission in chunked a=T direct mode, placement sizing in cells, and deletion.
Package graphics implements terminal inline images over the kitty graphics protocol — the Go port of grok-build's terminal/image.rs: protocol detection by terminal brand, PNG transmission in chunked a=T direct mode, placement sizing in cells, and deletion.
Package history is the transport-independent product model behind prompt history, turn timeline, rewind, fork and jump surfaces.
Package history is the transport-independent product model behind prompt history, turn timeline, rewind, fork and jump surfaces.
Package input implements a compact prompt editor: grapheme-safe cursor motion, basic emacs-style editing chords, single-line and soft-wrapped rendering, and optional hard newlines for textarea-style prompts.
Package input implements a compact prompt editor: grapheme-safe cursor motion, basic emacs-style editing chords, single-line and soft-wrapped rendering, and optional hard newlines for textarea-style prompts.
Package interaction contains host-independent state machines for Grok's blocking interaction surfaces.
Package interaction contains host-independent state machines for Grok's blocking interaction surfaces.
Package linkmap tracks OSC 8 hyperlinks and URL-shaped text in the scrollback so the app can underline-on-hover and open links on modifier-click — the Go analogue of grok-build's link_map.rs + hyperlink_route.rs, reduced to plain-text URL detection.
Package linkmap tracks OSC 8 hyperlinks and URL-shaped text in the scrollback so the app can underline-on-hover and open links on modifier-click — the Go analogue of grok-build's link_map.rs + hyperlink_route.rs, reduced to plain-text URL detection.
Package markdown implements an incremental Markdown content renderer for terminal UIs.
Package markdown implements an incremental Markdown content renderer for terminal UIs.
Package media identifies terminal-facing media attachments without loading or decoding them.
Package media identifies terminal-facing media attachments without loading or decoding them.
Package minimal builds terminal-write plans for an inline, native-scrollback UI.
Package minimal builds terminal-write plans for an inline, native-scrollback UI.
Package overlay implements the modal layer of the pager: a stack of centered/anchored overlays (command palette, pickers, help, confirm dialogs) rendered above the base UI, with focus routing — the Go analogue of grok-build's modals.rs dispatch structure, decoupled from any concrete modal content.
Package overlay implements the modal layer of the pager: a stack of centered/anchored overlays (command palette, pickers, help, confirm dialogs) rendered above the base UI, with focus routing — the Go analogue of grok-build's modals.rs dispatch structure, decoupled from any concrete modal content.
Package palette implements the slash-command system: a registry of commands with fuzzy filtering, MRU ordering, and the command-palette / argument-picker modals — the Go port of grok-build's slash/ registry + matcher + the palette modal in modals.rs.
Package palette implements the slash-command system: a registry of commands with fuzzy filtering, MRU ordering, and the command-palette / argument-picker modals — the Go port of grok-build's slash/ registry + matcher + the palette modal in modals.rs.
Package present implements the frame presenter: coalescing of draw requests, gating on in-flight frames, and draw cadence — a direct Go port of the Presenter in xai-grok-pager's event_loop.rs (Apache-2.0).
Package present implements the frame presenter: coalescing of draw requests, gating on in-flight frames, and draw cadence — a direct Go port of the Presenter in xai-grok-pager's event_loop.rs (Apache-2.0).
Package ptytest provides a small PTY acceptance harness and reusable assertions for terminal-protocol byte streams.
Package ptytest provides a small PTY acceptance harness and reusable assertions for terminal-protocol byte streams.
Package queue provides the product-independent dual-source prompt queue behind Grok's queue pane.
Package queue provides the product-independent dual-source prompt queue behind Grok's queue pane.
Package runtime wires terminal, presenter, scrollback and the prompt editor into a running application: the select-based event loop (input, writer acks, animation ticks that only fire while a block is Running, resize) — the Go analogue of xai-grok-pager's event_loop.rs with the scrollback surface plus Grok-style header and prompt chrome.
Package runtime wires terminal, presenter, scrollback and the prompt editor into a running application: the select-based event loop (input, writer acks, animation ticks that only fire while a block is Running, resize) — the Go analogue of xai-grok-pager's event_loop.rs with the scrollback surface plus Grok-style header and prompt chrome.
Package screenmode rebuilds a host application's argv for switching an active terminal session between fullscreen and native-scrollback modes.
Package screenmode rebuilds a host application's argv for switching an active terminal session between fullscreen and native-scrollback modes.
Package scrollback implements agentui's conversation display: typed content blocks with streaming updates, scroll state with bottom-follow, sticky prompt headers, mouse text selection with copy-fidelity, and scroll-aware viewport rendering with scratch-buffer clipping.
Package scrollback implements agentui's conversation display: typed content blocks with streaming updates, scroll state with bottom-follow, sticky prompt headers, mouse text selection with copy-fidelity, and scroll-aware viewport rendering with scratch-buffer clipping.
Package search implements background full-text search over the scrollback — the Go port of grok-build's ScrollbackSearchIndex + SearchDaemon (scrollback/search.rs): per-entry searchable-text cache, a worker goroutine that scans off the UI loop keeping only the latest query, and match navigation state.
Package search implements background full-text search over the scrollback — the Go port of grok-build's ScrollbackSearchIndex + SearchDaemon (scrollback/search.rs): per-entry searchable-text cache, a worker goroutine that scans off the UI loop keeping only the latest query, and match navigation state.
Package session models Grok-style session product state independently from rendering and transport.
Package session models Grok-style session product state independently from rendering and transport.
Package tasks provides the deterministic task, subagent and agent-definition catalogs rendered by runtime's Grok-compatible management panes.
Package tasks provides the deterministic task, subagent and agent-definition catalogs rendered by runtime's Grok-compatible management panes.
Package term owns the terminal session for agentui: raw mode + alternate screen setup, an incremental escape-sequence input parser (keys, SGR mouse, bracketed paste), SIGWINCH resize delivery, and an asynchronous frame writer goroutine with sequence-numbered backpressure — a Go port of xai-grok-pager's TermWriter/WriterSync (render/draw.rs, Apache-2.0).
Package term owns the terminal session for agentui: raw mode + alternate screen setup, an incremental escape-sequence input parser (keys, SGR mouse, bracketed paste), SIGWINCH resize delivery, and an asynchronous frame writer goroutine with sequence-numbered backpressure — a Go port of xai-grok-pager's TermWriter/WriterSync (render/draw.rs, Apache-2.0).
Package textwrap implements Unicode-aware word wrapping with continuation ("joiner") tracking, plus a (width, generation)-keyed wrap cache — the Go counterpart of xai-grok-pager's word_wrap_lines_with_joiners and WrapCache.
Package textwrap implements Unicode-aware word wrapping with continuation ("joiner") tracking, plus a (width, generation)-keyed wrap cache — the Go counterpart of xai-grok-pager's word_wrap_lines_with_joiners and WrapCache.
Package theme provides multi-theme support with OSC 11 terminal-background probing — the Go analogue of grok-build's theme/ + osc11 detection: named truecolor themes, a dark/light auto mode seeded by the terminal's reported background, and live switching.
Package theme provides multi-theme support with OSC 11 terminal-background probing — the Go analogue of grok-build's theme/ + osc11 detection: named truecolor themes, a dark/light auto mode seeded by the terminal's reported background, and live switching.
Package todo implements the Ctrl+T todo pane: a bordered side panel over the scrollback listing task items with states, hide-done filtering, and keyboard/mouse selection — the Go analogue of grok-build's todo pane (todo-pane-playground).
Package todo implements the Ctrl+T todo pane: a bordered side panel over the scrollback listing task items with states, hide-done filtering, and keyboard/mouse selection — the Go analogue of grok-build's todo pane (todo-pane-playground).
Package workflow provides the product-independent state model behind the /workflows run dashboard.
Package workflow provides the product-independent state model behind the /workflows run dashboard.

Jump to

Keyboard shortcuts

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