cli
A line-mode REPL for CLI agents, driven by Node's readline instead of the alt-screen TUI engine in std::ui. It gives up the pinned status line, live spinner, and in-app scrolling. In exchange, every prompt and reply is a plain line in the terminal's scrollback, so you get native search, copy/paste, link clicks, line editing, and history for free. It shares std::ui's repl call signature, so switching modes is a one-line import change:
// TUI mode (alt-screen)
import { repl } from "std::ui"
// Line mode (scrollback)
import { repl } from "std::ui/cli"Functions
repl
repl(
status: any,
onSubmit: any,
prompt: string = "> ",
historyFile: string = "",
historyMax: number = 1000,
paletteCommands: any = null,
)Line-mode REPL with the same call signature as the std::ui TUI repl, so switching modes is a one-line import change.
Each iteration prints prompt, awaits one line of input (full line editing, history, bracketed paste), and calls onSubmit(line). Returning false exits; returning a non-empty string prints it; anything else is ignored. Also exits on Ctrl+D (EOF) or Ctrl+C at an idle prompt. Type /paste (TTY only) to open a multi-line editor: Enter inserts a newline, Ctrl+D submits the whole buffer as one message, and Ctrl+C / Esc cancels.
@param status - Callback returning {left, right, context} @param onSubmit - Called with the submitted line; return false to exit or a string to print @param prompt - String shown before the input buffer (default "> ") @param historyFile - Path to a JSON history file; loaded at start and saved on exit. Empty string disables persistence. @param historyMax - Trim history to this many most-recent entries @param paletteCommands - Map of /cmd -> description
- Line-mode sibling of the std::ui TUI repl. Current limitations:
statusis accepted for signature parity but not yet rendered;paletteCommandshas no tab completion yet; there is no busy- spinner and no Ctrl+C cancel of an in-flight turn.
Parameters:
| Name | Type | Default |
|---|---|---|
| status | any | |
| onSubmit | any | |
| prompt | string | "> " |
| historyFile | string | "" |
| historyMax | number | 1000 |
| paletteCommands | any | null |
(source)
clearScreen
clearScreen()Clear the terminal screen.
(source)
clearHistory
clearHistory()Clear the input history of the currently running repl() session: both its in-session up-arrow recall and the historyFile that session was started with. A no-op when called outside an interactive repl().
(source)
hline
hline(char: string = "─", width: number = null): stringReturn a horizontal rule: char repeated width times (terminal width when width is omitted).
Parameters:
| Name | Type | Default |
|---|---|---|
| char | string | "─" |
| width | number | null |
Returns: string
(source)
interruptChoice
interruptChoice(
title: string,
body: string,
items: any[],
allowFreeText: boolean = false,
allowCancel: boolean = false,
): stringApproval prompt for line mode: renders a sticky footer pinned to the bottom of the terminal so concurrent tool-call output streams above it instead of burying the prompt. Type an option key or a rejection reason, then press Enter. Falls back to chooseOption when no line-mode REPL is active (the TUI, a non-TTY, or a headless run), so every non-line-mode path keeps its current behavior.
@param title - Prompt heading (the interrupt message). @param body - Multi-line context shown under the title (or ""). @param items - The {key, label} choices. @param allowFreeText - Accept a free-form rejection reason. @param allowCancel - When true, Escape cancels the whole request.
Parameters:
| Name | Type | Default |
|---|---|---|
| title | string | |
| body | string | |
| items | any[] | |
| allowFreeText | boolean | false |
| allowCancel | boolean | false |
Returns: string
(source)