Sandbox
@r3bl-org/r3bl-open-core

Rust TUI framework and terminal app workspace

This workspace combines a Rust TUI framework with terminal apps and developer tooling. The framework supports full-screen TUIs, async readline, choice prompts, and a PTY multiplexer, while the apps show how to use those pieces for git workflows, markdown editing, and environment loading.

483 stars31 forksRustUpdated 6d ago
Who it's for

Builders who want reusable Rust pieces for terminal apps, CLI workflows, and developer productivity tools.

What it delivers

You can build richer terminal workflows and apps without wiring the low-level terminal pieces yourself.

What it does

Async TUI framework

The `tui` crate supports full-screen apps, async readline, choice prompts, spinners, and PTY multiplexing.

Reusable UI and layout primitives

It includes an `App` trait, flexbox-style layout, components, styling, and markdown rendering.

Terminal multiplexer

`PTYMux::run()` can wrap multiple child processes in one terminal view and switch between them.

Developer apps

The `cmdr` crate includes `giti`, `edi`, and `env-source` as built examples.

Build and doc tooling

The `build-infra` crate includes `cargo-rustdoc-fmt` for rustdoc formatting and link cleanup.

Task workflow system

The `task/` folder and `/r3bl-task` commands organize implementation plans and progress.

How to get it

  1. 1Use the bootstrap script to automatically install all required tools
    # Clone the repository
    git clone https://github.com/r3bl-org/r3bl-open-core.git
    cd r3bl-open-core
    
    # Run the bootstrap script
    ./bootstrap.sh
  2. 2Installation
    # Clone the extension repository
    git clone https://github.com/r3bl-org/r3bl-vscode-extensions.git
    cd r3bl-vscode-extensions
    
    # Install extensions (works with both VSCode and VSCode Insiders)
    ./install.sh

README

r3bl-open-core

██████╗  ██████╗  ██████╗
██╔══██╗██╔═══██╗██╔════╝
██████╔╝██║   ██║██║
██╔══██╗██║   ██║██║
██║  ██║╚██████╔╝╚██████╗
╚═╝  ╚═╝ ╚═════╝  ╚═════╝

Why R3BL TUI?

After leaving Google in 2021, I (Nazmul Idris) embarked on a journey to create infrastructure for modern, powerful, async CLI and TUI experiences built from the ground up in Rust.

The core architectural innovation: a purely async, immediate mode reactive UI (every state change triggers a render from scratch) where nothing blocks the main thread - unlike traditional approaches using platform-specific blocking operations like POSIX readline() on Linux/macOS or Windows ReadConsole().

R3BL TUI is fundamentally different from vim, neovim, and ratatui through its immediate mode reactive UI with clean separation between rendering and state mutation, and purely async nature.

This fully async, responsive framework works seamlessly across Linux, macOS, and Windows. It's optimized for use over SSH connections by painting only diffs, and handles complex concurrent operations with low latency while ensuring no thread blocking.

The Problem with Existing Solutions

I initially tried Node.js with ink, but encountered fundamental limitations:

  • Module incompatibilities and dependency conflicts
  • Limited control over keybindings and terminal behavior
  • High resource consumption for simple tasks
  • Screen flickering and poor rendering performance

The R3BL Solution: Web and Desktop App Inspired Terminal Apps

Our framework supports the full spectrum from CLI to hybrid TUI to full TUI experiences with deep system integration.

Key Innovation: "Applets" - A revolutionary state management system that allows processes to persist state across their lifecycle and share it with other instances or processes. And the underlying systems level infrastructure mechanisms that make this possible.

Built-from-Scratch Primitives

Async Readline: Unlike POSIX readline which is single-threaded and blocking, our implementation is fully async, interruptable, and non-blocking.

Choose API: Single-shot user interactions that enter raw mode without taking over the screen or disrupting the terminal's back buffer.

Full TUI: Complete raw mode with alternate screen support, fully async and non-destructive.

All components are end-to-end testable using our:

  • InputDevice and OutputDevice types for stdin, stdout, and stderr.
  • PTY infrastructure.
  • VT-100 parser / generator infrastructure.

Advanced Rendering & Styling

  • CSS-like styling with JSX-inspired declarative layouts
  • Gradient color support with automatic terminal capability detection
  • Double-buffered compositor for efficient rendering
  • Comprehensive color support that adapts to terminal capabilities (even handles macOS Terminal.app's lack of truecolor support)

Rich Component Ecosystem

  • Beautiful Markdown parser with syntax highlighting
  • Rich text editor components
  • Dialog box support
  • Animation framework (in development)
  • Process orchestration via the "script" module
  • Async REPL infrastructure

R3BL TUI brings the ergonomics of modern web development (React, flexbox, CSS) to terminal applications in Rust, creating a new paradigm for command-line productivity tools.

We are building command line apps with rich text user interfaces (TUI). We want to lean into the terminal as a place of productivity, and build all kinds of delightful, ergonomic, and useful experiences for it.

  1. 🔮 Instead of just building one app, we are building a library to enable any kind of rich TUI development w/ a twist: taking concepts that work really well for the frontend mobile and web development world and re-imagining them for TUI & Rust.
  • Taking inspiration from things like React, SolidJS, Elm, iced-rs, Jetpack Compose, JSX, CSS, but making everything async (so they can be run in parallel & concurrent via Tokio).
  • Even the thread running the main event loop doesn't block since it is async.
  • Using macros to create DSLs to implement something inspired by CSS & JSX.
  1. 🌎 We are building apps to enhance developer productivity & workflows.
  • The idea here is not to rebuild tmux in Rust (separate processes mux'd onto a single terminal window). Rather it is to build a set of integrated "apps" (or "tasks") that run in the same process that renders to one terminal window.
  • Inside of this terminal window, we can implement things like "applet" switching, routing, tiling layout, stacking layout, etc. so that we can manage a lot of TUI apps (which are tightly integrated) that are running in the same process, in the same window. So you can imagine that all these "applets" have shared application state. Each "applet" may also have its own local application state.
  • You can mix and match "Full TUI" with "Partial TUI" to build for whatever use case you need. r3bl_tui allows you to create application state that can be moved between various "applets", where each "applet" can be "Full TUI" or "Partial TUI".
  • Here are some examples of the types of "app"s we plan to build (for which this infrastructure acts as the open source engine):
    1. Multi user text editors w/ syntax highlighting.
    2. Integrations w/ github issues.
    3. Integrations w/ calendar, email, contacts APIs.

Welcome to the monorepo and workspace

All the crates in the r3bl-open-core monorepo provide lots of useful functionality to help you build TUI (text user interface) apps, along w/ general niceties & ergonomics that all Rustaceans 🦀 can enjoy 🎉.

Any top-level folder in this repository that contains a Cargo.toml file is a Rust project, also known as a crate. These crates are likely published to crates.io. Together, they form a Rust workspace.

Here's the changelog for this monorepo containing a Rust workspace. The changelog is a great place to start to get familiar with what has changed recently in each of the crates in this Rust workspace.

This workspace contains crates for building TUI, CLI, TTY apps

The r3bl_tui crate is the main crate that contains the core functionality for building TUI apps. It allows you to build apps that range from "full" TUI to "partial" TUI, and everything in the middle.

Here are some videos that you can watch to get a better understanding of TTY programming.

This crate provides five entry points for building interactive terminal applications. Each internalizes terminal availability and size checks, and returns a TuiAvailability<T> enum:

Entry PointPurposeBest For
TerminalWindow::main_event_loop()Full TUI frameworkComplex, multi-component apps with layouts, dialogs, and custom logic.
ReadlineAsyncContext::try_new()Async ReadlineCLI-style line input, REPLs, and background logging.
choose()Interactive SelectionPrompting user to select one or more items from a list.
PTYMuxBuilder::build()Terminal MultiplexerWrapping existing CLI tools (like htop, bash) in a multi-pane TUI.
Spinner::try_start()Indeterminate ProgressLong-running tasks needing visual feedback (standalone or embedded).

Full TUI (async, raw mode, full screen) for immersive TUI apps

tui gives you "raw mode", "alternate screen" and "full screen" support, while being totally async. It provides a full-featured framework with:

  • App trait: Unidirectional data flow architecture.
  • FlexBox: Responsive layout engine.
  • Component System: Reusable UI elements (editors, dialogs, etc.).

An example of this is the "Full TUI" app edi in the r3bl-cmdr crate. You can install & run this with the following command:

cargo install r3bl-cmdr
edi

Partial TUI (async, partial raw mode, async readline) for choice based user interaction

choose allows you to build less interactive apps that ask a user user to make choices from a list of options and then use a decision tree to perform actions.

An example of this is this "Partial TUI" app giti in the r3bl-cmdr crate. You can install & run this with the following command:

cargo install r3bl-cmdr
giti

Partial TUI (async, partial raw mode, async readline) for async REPL

readline_async gives you the ability to easily ask for user input in a line editor. You can customize the prompt, and other behaviors, like input history.

Using this, you can build your own async shell programs using "async readline & stdout". Use advanced features like showing indeterminate progress spinners, and even write to stdout in an async manner, without clobbering the prompt / async readline, or the spinner. When the spinner is active, it pauses output to stdout, and resumes it when the spinner is stopped.

An example of this is this "Partial TUI" app giti in the r3bl-cmdr crate. You can install & run this with the following command:

cargo install r3bl-cmdr
giti

Here are other examples of this:

  1. https://github.com/nazmulidris/rust-scratch/tree/main/tcp-api-server
  2. https://github.com/r3bl-org/r3bl-open-core/tree/main/tui/examples

Terminal multiplexer

PTYMux::run() lets you build a terminal multiplexer similar to tmux. It manages multiple child processes (each in its own PTY) with per-process virtual terminal buffers and instant switching. See the pty_mux_example for a working example that wraps bash, htop, and other CLI tools.

Power via composition

You can mix and match "Full TUI" with "Partial TUI" to build for whatever use case you need. r3bl_tui allows you to create application state that can be moved between various "applets", where each "applet" can be "Full TUI" or "Partial TUI".

Main library crate

There is just one main library crate in this workspace: r3bl_tui.

Main binary crate

There is just one main binary crate that contains user facing apps that are built using the library crates: r3bl-cmdr. This crate contains these apps:

  • giti: Interactive git workflows made easy.
  • edi: Beautiful Markdown editor with advanced rendering and editing features.
  • env-source: Fast cross-platform environment loader evaluating scripts across POSIX sh, Fish, PowerShell, and cmd.exe.

You can install & run this with the following command:

cargo install r3bl-cmdr
# Interactive git workflows made easy.
giti --version
# Beautiful Markdown editor with advanced rendering and editing features.
edi --version
# Fast cross-platform environment loader.
env-source --version

Build infrastructure and developer tooling crate

The r3bl-build-infra crate provides developer productivity tools:

  • cargo-rustdoc-fmt: Formats markdown tables and converts inline links to reference-style links in rustdoc comments.

You can install this binary with:

cargo install r3bl-build-infra
# Or from local source within this workspace:
fish run.fish install-build-infra

Project Task Organization

This project uses a task management system for organizing day-to-day development work using detailed task files with implementation plans in the ./task/ directory.

Task Management Files

  • ./task/ - Directory containing detailed task management files:
    • Active tasks: task_*.md files in root of ./task/ - Complex tasks currently in progress
    • pending/: Tasks queued for later work
    • done/: Completed task files moved from root after all steps are marked [COMPLETE]
    • archive/: Abandoned tasks retained for historical reference
    • AGENTS.md: Rules and format specifications for creating and maintaining task files

Task File Format

Detailed task files follow a structured format defined in ./task/AGENTS.md:

Structure:

# Task Overview

High-level description, architecture, context, and the "why"

# Implementation Plan

## Step 0: Do Something [STATUS]

Detailed instructions for this step

### Step 0.0: Do Subtask [STATUS]

Details about subtask

### Step 0.1: Do Another Subtask [STATUS]

Details about another subtask

## Step 1: Do Something Else [STATUS]

More detailed steps...

Hierarchical organization:

  • Steps are numbered (Step 0, Step 1, Step 2, etc.)
  • Substeps use decimal notation (Step 0.0, Step 0.1, etc.)
  • Table of contents automatically generated and maintained using doctoc
  • Formatting standardized with prettier

Status markers:

  • [COMPLETE] - Step finished and verified
  • [WORK_IN_PROGRESS] - Currently working on this step
  • [BLOCKED] - Cannot proceed (waiting for dependency)
  • [DEFERRED] - Postponed to later

Task Workflow Commands

The /r3bl-task slash command (defined in AGENTS.md) manages the task lifecycle:

Create a new task:

/r3bl-task create my_feature_name
  • Creates ./task/task_my_feature_name.md from your detailed plan
  • Use after you have a comprehensive plan in your todo list
  • Initializes structure with steps and status markers

Update an existing task:

/r3bl-task update my_feature_name
  • Updates progress markers in ./task/task_my_feature_name.md
  • Moves completed task files to ./task/done/ when all steps are [COMPLETE]

Resume working on a task:

/r3bl-task load my_feature_name
  • Loads ./task/task_my_feature_name.md for continued work
  • Resumes from the last step marked [WORK_IN_PROGRESS]
  • If none found, asks which incomplete step to start with

Workflow Connection

The task organization workflow connects strategic planning with tactical execution:

  • Strategic Planning (docs/ folder): Feature roadmaps, architectural dec

Files in the repo

Repository payload51 top-level entries
  • .agents
  • .cargo
  • .github
  • .idea
  • .vscode
  • analytics_schema
  • build-infra
  • cmdr
  • docs
  • rust-analyzer-mcp-server
  • task
  • tui
  • .gitconfig
  • .gitignore
  • .prettierignore
  • .prettierrc
  • 1.code-search
  • 2.code-search
  • AGENTS.md
  • bacon.toml
  • bootstrap.sh
  • Cargo.lock
  • Cargo.toml
  • CHANGELOG.md
  • check_cargo.fish
  • check_cli.fish
  • check_constants.fish
  • check_detection.fish
  • check_docs.fish
  • check_lock.fish
  • check_orchestrators.fish
  • check_recovery.fish
  • check_toolchain.fish
  • check_watch.fish
  • check.fish
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • deny.toml
  • LICENSE
  • lychee.toml
  • r3bl-term.svg
  • README.md
  • remove_toolchains.sh
  • run.fish
  • rust-toolchain-sync-to-toml.fish
  • rust-toolchain-update.fish
  • rust-toolchain-validate.fish
  • rust-toolchain.toml
  • rustfmt.toml
  • script_lib.fish
  • tmux-r3bl-dev.fish

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k