@yoltra/devtools-cli

Browse the API reference β†’

Terminal UI for Yoltra DevTools: inspect stores from the command line.

@yoltra/devtools-cli is a React + Ink terminal application that embeds a DevTools hub and renders a full-featured TUI for inspecting Yoltra stores. Useful when you would rather keep the inspector in a terminal, or in an SSH session where a browser is not available.


#Installation

bash
npm install -g @yoltra/devtools-cli

Or run directly:

bash
npx @yoltra/devtools-cli

#Quick Start

bash
# Start the CLI (auto-starts hub on port 9800)
npx @yoltra/devtools-cli

# Custom port and history size
npx @yoltra/devtools-cli --port 8900 --history-size 2000

# A hub that requires a token (the panel presents the same one)
YOLTRA_DEVTOOLS_TOKEN=s3cret npx @yoltra/devtools-cli

Then connect your app's store to that hub. transport: "websocket" sends it to the hub even when the browser extension is installed:

typescript
import { withDevtools } from "@yoltra/devtools-browser-agent";

withDevtools(store, { port: 9800, transport: "websocket" });

The CLI will display connected stores and live event data.


#Features

  • Embedded DevTools hub (auto-starts, skips if one is already running)
  • Tabbed store selector for multiple connected stores
  • Event timeline with channel/type display
  • Interactive state tree explorer
  • Time travel through the recorded events, for a store that allows replay
  • Subscriptions panel (reducers, effects, middleware)
  • Performance metrics dashboard
  • Event emitter for injecting test events
  • Keyboard navigation with focus management

#Panels

Six panels, in this order. There are no per-panel shortcuts: Tab moves to the next panel and Shift+Tab to the previous one.

PanelDescription
EventsLive event stream with channel, type, and timestamp
StateCollapsible state tree with current values
Time TravelScrub the recorded events; only for a store that allows replay (allowReplay)
SubscriptionsRegistered reducers, effects, middleware
MetricsEvent count, rate, processing time, queue depth
EmitCompose and emit events to the selected store
KeyAction
Tab / Shift+TabNext / previous panel
] / [Next / previous connected store
← / β†’On Time Travel: step one event back / forward
rOn Time Travel: resume live state
qQuit
EscOn Emit: leave the form, so the keys above work again
EnterOn Emit, outside the form: back into it

The Emit form takes the keyboard when its tab opens. While a field has focus, every key above is typed into it, so a payload such as ["a"] or a channel with a q in it is safe to enter.


#CLI Options

FlagDefaultDescription
--port9800Hub server port
--history-size1000Max events retained for late-connecting clients
--tokennoneToken the hub requires of every client

--token can also come from the YOLTRA_DEVTOOLS_TOKEN environment variable, which keeps it out of the process list; the flag wins when both are set. The embedded hub requires the token, and the terminal panel presents it, so the same value also lets the CLI attach to a hub already running with it. Pass the same token to each store agent (authToken).

These symbols are exported too (parseArgs, CliArgs, CliArgsError, DEFAULT_PORT, DEFAULT_HISTORY_SIZE, TOKEN_ENV), so a tool that embeds the hub can reuse the same argument contract instead of deriving it again.


#How It Works

ts
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your App    β”‚     β”‚  CLI         β”‚     β”‚  Ink TUI     β”‚
β”‚  (with       β”‚ WS  β”‚  (embedded   β”‚     β”‚  (React +    β”‚
β”‚  withDevtools│────►│   hub)       │────►│   Ink)       β”‚
β”‚  )           β”‚     β”‚              β”‚     β”‚              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. The CLI starts an embedded DevtoolsHub (or detects an existing one via probe())
  2. The Ink TUI connects to the hub as an extension using @yoltra/devtools-ui hooks
  3. Your app's store agent connects to the hub via WebSocket
  4. Events, state, and commands flow through the hub in real time

The CLI is two things in one process: an optional hub and a panel. It starts the hub only when DevtoolsHub.probe finds nothing listening on the port, and the terminal UI always connects as a regular extension through HubProvider, so it behaves the same against its own hub or one already running.

How the CLI starts or reuses a hub. The CLI parses its arguments, starts an embedded hub only when nothing listens on the port, and renders a terminal UI that joins the hub as a regular extension, while the app store agent connects to the same hub.How the CLI starts or reuses a hub. The CLI parses its arguments, starts an embedded hub only when nothing listens on the port, and renders a terminal UI that joins the hub as a regular extension, while the app store agent connects to the same hub.

#Architecture

FileResponsibility
index.tsCLI entry point, argument parsing, hub lifecycle
app.tsxRoot Ink component with HubProvider
components/StoreTabs.tsxTabbed store selector
components/EventTimeline.tsxTerminal event log
components/StateTree.tsxCollapsible state tree
components/SubscriptionsPanel.tsxSubscription inventory
components/MetricsDashboard.tsxPerformance counters
components/EventEmitter.tsxEvent composition form
components/StatusBar.tsxConnection status bar
hooks/useKeyBindings.tsKeyboard shortcut management
hooks/useFocusManager.tsFocus cycling between panels


#License

MIT: Free to use in commercial and open-source projects.

Report a problem with this page