Skip to content

Interactive CLI & TUI

microharness ships a full-screen curses TUI (core/tui.py, core/tui_session.py) and a line-oriented interactive fallback (core/session.py), both backed by a single shared command router (core/interactive.py) so slash commands behave identically across frontends.


Launching Interactive Mode

# Start full-screen TUI in the current repository
uv run microharness

# Start with an initial task and stay interactive afterward
uv run microharness "Audit error handling in core/model.py"

# Resume the latest session (workspace-aware) or a specific run ID
uv run microharness --resume
uv run microharness --resume run-2026-10-03-xxxx

Between turns, the prompt displays your current context budget:

─── Context: 1.4k / 8k (17.8%) ───
You:

Built-in Slash Commands

All built-in slash commands execute locally with zero model calls:

Command Aliases Purpose
/model [name\|idx] /models List configured models or switch active model live (Tab-autocompleted in TUI). Unrecognized names are rejected with the valid list.
/reasoning [level] — Inspect or switch reasoning effort (low, medium, high, xhigh, max, token budget, or off).
/cache [5m\|1h\|off] — Inspect or switch prompt caching TTL on the fly.
/status /context Show context window size, message breakdown, budget usage, active preset, and cache hit rates.
/compact — Manually trigger memory compaction to collapse older tool observations.
/undo — Revert workspace changes from the last agent turn using the pre-turn checkpoint.
/permissions [auto\|ask\|ro] /permission, /mode Inspect or switch host execution permission mode (auto, ask, or read-only / ro).
/skill [name] /skills List discovered skills or activate a skill directly into conversation context.
/agent [name] [task] /agents, /subagent, /subagents List built-in and .microharness/agents/*.md subagents, inspect config, or delegate a task directly.
/preset /presets Show the active agent preset and list available presets.
/plugin [subcommand] /plugins List or manage plugins (list, install, enable, disable, update, remove).
/resume [id\|idx] /resumes List recent sessions for the current workspace (falling back to a full scan if needed) or resume one in-place.
/login [provider] — Inspect credential sources or store an API key in ~/.microharness/auth.json.
/logout [provider] — Remove stored credentials for a provider from auth.json.
/image [path\|clear] /img Attach a local image file (.png, .jpg, .gif, .webp) for the next message, inspect queued images, or clear them.
/paste — Paste an image from the system clipboard (Ctrl+V / Alt+V shortcut in TUI) for the next message.
/new /reset Clear conversation history while keeping workspace files intact.
/help — List all built-in, custom (.microharness/commands/*.md), and discovered commands.
/exit /quit Finalize, save session trace (trace.json / trace.md), and exit.

@file Tagging, Images & TUI Features

  • @file & @image expansion: Mentioning @path/to/file.py injects file text, while @path/to/screenshot.png (or dragging/pasting an absolute image path, /image <path>, /paste, or Ctrl+V / Alt+V) attaches validated multimodal image_url blocks via core/discovery.py and core/types.py.
  • Floating Tab Autocomplete: Typing / or @ in the TUI opens interactive completion for slash commands, models, providers, subagents, and workspace files (including workspace images labeled [image]).
  • Live SSE Streaming: Models implementing StreamingModel (such as HttpChatModel) stream reasoning previews, assistant text tokens, and tool-call preparation live into both the TUI (TUIState / TuiTurnRunner) and CLI (CliStreamRenderer), falling back cleanly to blocking JSON when an endpoint rejects stream: true (or when --no-stream / "stream": false is configured).
  • Turn Visuals & Scrolling: Supports mouse and keyboard scrolling, Markdown rendering, unified Enter/Tab input behavior, and live subagent child-step action lines.

Cancelling a Running Turn

The two cancel keys behave differently while a turn is active:

  • Ctrl+C (Immediate Abort): Aborts the active step immediately, including an in-flight model request. The incomplete tool turn is dropped cleanly and the session remains usable.
  • Esc (Cooperative Cancel): Takes effect between SSE stream chunks (closing the active HTTP stream cleanly), during retry/backoff waits (for example during rate-limit throttling), and at step boundaries, printing Cancelling… aborting the pending model request.

Why Esc cannot interrupt before the first byte of a blocking read

The HTTP socket timeout covers time-to-first-byte for slow reasoning models, so shortening it would break legitimate responses. Once an SSE stream begins delivering lines or keepalives, Esc aborts cooperatively between chunks; use Ctrl+C when you want to kill a stalled request immediately.