Skip to main content

CLI Overview

The CLI is the primary active frontend in this repo. It is implemented in Rust under cli/, and it calls the Python core through PyO3. The CLI is not the agent brain; it is the terminal cockpit.

Its job is to:

  1. Keep startup and rendering fast.
  2. Let users choose a project, provider, and model.
  3. Render a fullscreen TUI with fixed panels, transcript, and bottom input.
  4. Stream progress from the Python runtime through local JSONL files.
  5. Display typed approval requests before workspace writes execute.
  6. Request live task cancellation when the user presses Esc or Ctrl-C.
  7. Store UI session summaries and expose trace/timeline/debug views.

Runtime Boundary

The Rust code calls functions in protoagent_core.agent_engine and expects JSON strings back. That boundary is deliberate: the CLI can stay a Rust UX shell while Python owns provider config, Context Loom, ProtoLink runtime startup, and agent orchestration.

Two Operating Modes

ModeEntry commandBest for
Fullscreen TUIproto-cli start, proto-cli tui, proto-cli cliDaily interactive work, panels, file tagging, model/key modal flows, live progress.
One-shot commandproto-cli run "task"Debugging, shell scripts, copy-pasteable trace capture, non-fullscreen usage.

The fullscreen TUI and one-shot runner share the same core functions and live progress parser. They differ in presentation.

Important Files

FileResponsibility
cli/src/main.rsCommand routing, PyO3 functions, shell output panels, project/config helpers.
cli/src/terminal_ui.rsFullscreen loop, slash command routing, task loop, cancellation polling.
cli/src/terminal_ui/render.rsHeader, panels, transcript, command bar, context meter, bottom input.
cli/src/terminal_ui/project.rs/project flow and @file picker.
cli/src/terminal_ui/model_picker.rs/model and /key modal flows.
cli/src/terminal_ui/approval.rsRuntime approval prompt.
cli/src/terminal_ui/diff_view.rsDiff review modal and summaries.
cli/src/progress.rsJSONL progress, context samples, approval/cancel control files.
cli/src/timeline.rsRunEvent to trace and timeline rendering.
cli/src/sessions.rsUI session ledger in sessions.json.

Data The CLI Owns

The CLI owns product-facing local state:

StateDefault locationOwner
Active project and memory toggle~/.protoagent/project.jsonRust CLI
UI session summaries~/.protoagent/sessions.jsonRust CLI
Temporary progress and control filesOS temp directoryRust CLI and Python bridge

Model-facing state is owned by ProtoLink through the Python core:

StateDefault locationOwner
Provider config and stored API keys~/.protoagent/config.jsonPython core
Per-agent conversation state~/.protoagent/conversations.sqliteProtoLink state APIs
Context Loom indexes~/.protoagent/indexes/*.sqlitePython core
Durable local trace telemetry~/.protoagent/traces.jsonlProtoLink telemetry when enabled

Agent Path

The CLI presents the runtime as an agent deck:

[USER]
|
v
[CONTEXT LOOM] deterministic workspace index and evidence pack
|
v
[ARCHITECT] intent, routing, approval gate
|
+--> [EXPLORER] context pack, read_file, list_directory, search_regex, git status
|
+--> [CODER] generate_unified_diff, create_new_file
|
v
[HUMAN APPROVAL] before writes land on disk

The CLI does not parse model prose to decide whether a write is allowed. Writes arrive as ProtoLink actions with capabilities, preview artifacts, and approval requests.