Cornacai: a terminal client for coding agents¶
Cornacai (kor-NAH-kai: Portuguese cornaca, the elephant's rider and
guide, plus "AI") is a terminal front end for coding agents that speak the
Agent Client Protocol (ACP): Claude Code
through its ACP adapter, Gemini CLI, Codex and the others. You ride and
steer; the agent does the heavy lifting. It is a crate of its own,
cornacai, built on
intuiTUIve, rs-rich-acp (the protocol) and
rs-rich-embed (the shell pane).
Here it runs against a fake agent that replays a recorded conversation: a
prompt with an @ file mention, a plan and an answer streaming in, the
agent's edit reviewed as a diff and accepted, a permission prompt for a
command, and the finished turn.
An @ mention |
An edit to review | A permission prompt | Done |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Install and start¶
cargo install cornacai
cornacai # the configured agent, or one found on PATH
cornacai --agent "gemini --experimental-acp"
cornacai -- claude-agent-acp # the agent's command after --
cornacai --agents # the agents Cornacai knows, and which are installed
cornacai --sessions # the sessions kept to reopen
cornacai --resume ID # reopen one (session/load)
cornacai --pty # the agent's commands on a terminal
The first time, with no agent configured, Cornacai looks on PATH for the
agents it knows, offers the ones it finds, and saves the choice in
cornacai/config.toml in your config directory ($XDG_CONFIG_HOME, else
~/.config). An agent given with --agent is saved the same way when none
is configured yet. Cornacai never installs an agent: --agents says what to
install, and you do it. For Claude, that is the ACP adapter,
npm install -g @agentclientprotocol/claude-agent-acp (the command
claude-agent-acp); the older @zed-industries/claude-code-acp
(claude-code-acp) is deprecated, though Cornacai still starts it. On
Windows, npm's .cmd launchers are what Cornacai runs.
If the agent does not answer within 20 seconds, Cornacai says so; and when
it fails to start or to open a session, the notice quotes the error the
agent wrote, which F2 shows in full.
Agents from the marketplace¶
The plugin marketplace lists agents too, as the agent
kind: each listing gives the agent's launch command, the environment
variables it reads, and how to install its program.
rich plugin search --kind agent
rich plugin install echo-agent # records its command; installs nothing
Installing an agent listing downloads nothing and runs nothing: rich
records the listing's verified command in agents.json in its plugin
directory, and prints the install hint for you to follow. cornacai
--agents and the first-run choice then offer it after the built-in ones,
once its program is on PATH. rich plugin remove ID forgets it.
The workspace is the current directory (or --cwd DIR): the sessions'
working directory, and the root the agent's file reads and writes through
Cornacai are kept inside.
The screen¶
- The tabs, at the top: one per session, titled by the agent when it
names the session, with
…while a turn runs; then the agent's name and version as it reports them, or that it has disconnected. - The conversation. Your prompts, the agent's answers as Markdown,
streaming in, and its thoughts folded under Thinking. The view
follows the end while the agent writes; scroll up and it stays where you
are, however the answers above or below it grow, and a line under it
counts what has arrived since (
↓ 3 new entries below: messages, tool calls and notices, not each streamed word). Alt+L, or scrolling back to the end, follows again. Each tab keeps its own place, and its cards stay folded or open as you left them. Only the entries near the view are built, so a long conversation costs a screenful. - Tool calls are folded cards: the kind and the agent's title, a
status at the right (pending, a spinner while it runs,
✓or✗ failed), and a one-line summary while folded: the file and the size of its change (diff src/main.rs (+3 −1)), or the output's last line. Enter or a click unfolds one: its command, its output (its last 40 lines), its diffs and its terminals' output. The summary describes what the agent sent; only the status says whether it succeeded. - The plan, when the agent has one, above the prompt:
✓done,▸under way,○to do. Each plan update replaces it whole. - The prompt, which grows to six rows, then scrolls; its title says whether the agent is working, cancelling, has not stopped, or has disconnected, and the session's mode, by the name the agent gives it, with the keys that change it.
Keys¶
| Key | What it does |
|---|---|
| Enter | Send the prompt (takes the completion while its list is open) |
| Alt+Enter, Shift+Enter | A new line in the prompt |
| Up, Down on the prompt's first or last line | Earlier prompts, this session's |
@ |
Complete a file or directory of the workspace |
| Esc | Ask the agent to cancel the running turn (again, if it has not stopped) |
| Alt+Q | Queue the prompt as a follow-up; with none typed, resume a paused queue |
| F5 | The session's queued follow-ups: reorder, remove, edit, resume |
| Shift+Tab | The session's next mode |
| Alt+M | Choose the session's mode from a list |
| Ctrl+N | A new session |
| Ctrl+O | Reopen an earlier session of this agent in this workspace |
| Alt+N, Alt+P, Alt+1 … Alt+9 | The next, the previous, or the numbered session |
| Ctrl+T | Open or close the shell pane (and move into or out of it) |
| F2 | The agent's log (what it wrote to its standard error) |
| F3 | The session's activity: its tool calls, by status |
| F4 | Inspect a tool call whole: the one chosen in F3, else the last |
| Alt+L | Back to the latest, following the end again |
| Ctrl+R | Restart the agent, for every tab; at once when it has disconnected |
| Ctrl+Q | Quit |
A click on a tab opens its session too. The row of hints at the bottom
lists the keys that work now, from the bindings themselves, so it follows
a keys file. cornacai/keys.toml, beside config.toml, remaps them by
id, one id = "keys" a line (none unbinds), and is read again when it
changes:
# cornacai/keys.toml
session.new = "ctrl+j"
session.reopen = "ctrl+o"
tab.next = "alt+n"
tab.previous = "alt+p"
shell.toggle = "ctrl+t"
log.show = "f2"
app.quit = "ctrl+q"
agent.restart = "ctrl+r"
activity.show = "f3"
prompt.queue = "alt+q"
queue.show = "f5"
tool.inspect = "f4"
transcript.latest = "alt+l"
turn.cancel = "escape"
Enter and Alt+Enter are the prompt's own keys and are not remapped there.
@ file mentions¶
Type @ and part of a path: the prompt offers the workspace's files that
match, fuzzily, best first (.git, target and node_modules are not
walked). Enter takes one. When the prompt is sent, each @path that names
a file or directory inside the workspace goes with it as a
resource_link (the file's URI, its name and its size), which every ACP
agent accepts; the agent reads the file itself. The conversation shows
which files went with the prompt.
What the agent asks¶
The agent runs with whatever its own process may do; ACP does not sandbox it. Cornacai guards what the agent asks the client to do, and shows you the rest.
- Permission prompts. Every
session/request_permissionopens a prompt. It leads with what will happen, in words: "Edit src/app.rs: 12 lines added, 3 removed", "Runcargo testin the workspace", "Read notes.md", "Fetch URL". Then why, in the agent's own words: the last paragraph or two it wrote in this turn before the tool call (or, when it wrote nothing, adescriptionits tool's input carries). Then one button per option the agent offers, numbered 1 to 9, each listed with what it means: once (it asks again next time), always (it stops asking for this; the agent keeps the choice, usually for the session), or refuse. Last, dimmed, the technical detail: the agent's title for the call, the files and the command in full. Esc rejects once. "Always" choices are the agent's to remember; Cornacai keeps no allow-list of its own. - Changes in a permission prompt. Some agents (Claude's adapter is
one) apply their edits themselves, after asking; the request then
carries the change as a diff, which the prompt shows, to be taken or
left whole:
yaccepts the change (the agent's allow-once option),xor Esc rejects it, and the numbers pick any of the agent's options ("allow all edits during this session", say).nandpmove between its hunks. A permission is all or nothing, soa,r,AandRonly say so; an edit the agent writes through Cornacai (below) is reviewed hunk by hunk. - Changes made without asking. In a mode that accepts edits, or once you chose an "always" option, the agent asks nothing and its change shows only in the conversation. Its card then says so: "applied without asking, in Accept edits mode", or "applied without asking: you chose “Yes, allow all edits during this session” earlier".
- Edits. Every
fs/write_text_fileopens the file's text and the agent's as a diff.nandpmove between hunks,aandraccept or reject the one under the cursor,AandRall of them; the last decision writes what you accepted.ywrites as decided so far (undecided hunks keep the old lines),xor Esc refuses the write. A write refused whole is answered with an error, so the agent knows; a partial one is written and noted in the conversation (the agent is told the write succeeded). Files that control what runs (.git/, editor and agent settings, MCP configuration) are flagged. - Commands. Every
terminal/createasks first, with the command line and its directory. An allowed command runs in the workspace, on pipes by default, and its output, as the agent reads it, shows in its card. With--pty(orpty = trueunder[terminal]in the config) each command runs on a terminal of its own (120 x 40), so programs that look for one colour their output and draw their progress; what they write is read as the terminal shows it, as plain text (colour and cursor movement dropped, a progress bar at its last state). A command whose terminal cannot be opened runs on pipes instead. - Reads inside the workspace are answered without asking. A path outside it is refused, whatever the agent says.
--no-read, --no-write and --no-terminal (or [capabilities] in the
config) stop offering a capability at all: the agent is then refused before
Cornacai sees the request.
Everything the agent says is untrusted: control characters in its text and
in command output are neutralised, so it cannot move the cursor or retitle
the terminal, and characters that hide or reorder text (bidirectional
controls, zero-width characters, tags) are shown as <U+202E> in titles,
paths, commands and options.
Modes¶
Agents that have modes (Claude's adapter: Manual, Accept edits, Plan,
Auto, Bypass permissions) say which ones when a session opens. The
prompt's title names the current one; Shift+Tab moves to the next, and
Alt+M lists them with what each does, to pick one. Cornacai asks the
agent (session/set_mode) and shows the new mode once it agrees; if it
refuses, a notice says why and the mode stays. The agent can change the
mode itself, too, and the title follows.
When the agent offers a plan mode, the title names it
(Shift+Tab, Alt+M · Plan mode too), and the hints row lists the two keys. In plan mode the
agent works out a plan and changes nothing; when it is ready it asks to
leave plan mode, and that prompt shows the plan, as Markdown, with the
agent's options (to start in which mode, or to keep planning).
The shell pane¶
Ctrl+T opens a shell beside the conversation: your $SHELL (or --shell
CMD, or shell in the config) on a real terminal, which lives as long as
Cornacai does, so cd and environment changes stick. It is yours, not the
agent's: nothing typed there or printed by it reaches the agent. While it
has the focus every key goes to the shell except Ctrl+T (back to the
prompt), Ctrl+Q, Alt+N and Alt+P.
Sessions¶
Ctrl+N opens another session on the same agent connection; each has its own conversation, plan, prompt and history, and its tab. A permission prompt or an edit from a session in the background still opens at once, naming its session.
Reopening a session¶
Cornacai keeps the sessions it opens in cornacai/sessions.jsonl in your
state directory ($XDG_STATE_HOME, else ~/.local/state): each one's id,
the agent's command, the workspace, its title (the agent's, else your
first prompt) and when it was last used; the 200 most recent. The
conversation itself is the agent's to keep.
When the agent offers session/load (its loadSession capability),
Ctrl+O lists the sessions of this agent in this workspace, newest first,
and the one you pick opens in a tab of its own (or its tab, if it is open
already): the agent replays the conversation into it, and you go on from
there. cornacai --resume ID starts with one, and cornacai --sessions
lists them all. An agent without session/load says so, and --resume
opens a new session instead.
Follow-ups¶
While the agent works, Enter does not send: it says the agent is still working and keeps your draft. Alt+Q queues the draft as a follow-up of this session instead, shown above the prompt, and you can write the next. With nothing running or queued, Alt+Q just sends.
Queued prompts go to the session they were queued in, whichever tab is
in front, one at a time: the next goes only when the turn before it has
ended normally (end_turn). Their @ files are named when you queue
them; the agent reads them when it gets the prompt.
The queue pauses, and says why, after a turn that was cancelled,
failed, ended any other way, or may not have reached the agent, and when
the agent disconnects or restarts. Nothing more is sent until you resume
it (Alt+Q with nothing typed, or r in F5). A restart keeps the queue.
F5 lists the session's queue: K/J move a prompt up or down, d
removes it, e takes it back into the prompt to edit (Alt+Q queues it
again, last), r resumes. The queue lasts while Cornacai runs; it is
not kept for the next start.
Activity and tool output¶
F3 lists the session's tool calls as they are now, with their status
and summary, and counts them by filter: 1 all, 2 running (pending or
under way), 3 failed, 4 asking you (a permission prompt is open for
it); Tab cycles. It opens no card and moves nothing. Enter goes to the
one picked: it is marked ▶ and brought to the top of the conversation,
and stays marked as it updates. i inspects it.
F4 shows a tool call whole (the one marked, else the last): its arguments as the agent sent them, its output whole (not the card's last 40 lines), every hunk of each diff, its terminals' output, and its raw output. Each part says how much of it is there: an output is all the agent sent (an agent may shorten one itself, and the protocol does not say when); a terminal that dropped its start for its byte limit says that no fuller output exists. Only the rows in view are built.
When a turn will not stop, or the agent goes¶
A turn ends only when the agent says it has, so the prompt's title says where it is, and nothing claims a turn is over before the agent does:
- Esc sends the agent
session/cancel, and the title reads cancelling… until the agent ends the turn. If the cancel cannot be sent (the agent stopped reading), the tab says so, and the turn goes on. - After the grace period (10 seconds;
[turn] cancel_gracein the configuration), a turn still open reads the agent has not stopped, and the tab says what you can do: wait, press Esc to ask again, or restart the agent. The turn stays open meanwhile, and no other prompt is sent in that session: Enter keeps your draft and says why. A long turn that was never cancelled is never cut short. - When the agent exits or closes its connection, every tab says so, with how it ended (its exit code) and its last words on standard error. A turn that was running is marked interrupted: what it finished is not known, and Cornacai does not send it again. Prompts still open for it (a permission, a write to review, a command) say they no longer ask anything; what you choose in them is not sent, and a write under review is not written. Commands it started are ended.
- Ctrl+R restarts the agent. It is one process for every tab, so
while it is connected Cornacai asks first, listing the tabs and which
turns would be interrupted; once it has gone, Ctrl+R starts it again
at once. Your conversations and drafts stay as they are. An agent that
offers
session/loadreopens each tab's session (what it replays is not shown again, as the tab holds the conversation); one that does not gives each tab a new session, and the tab says the agent will not remember the conversation above it. Nothing is resent: the prompt you were writing is still yours to send.
Answers that arrive late from an agent that was replaced (an update, a turn's end, a request) reach no tab. Starting, signing in, opening and reopening a session, and changing a mode wait two minutes for the agent; a prompt waits as long as it takes.
Signing in¶
Some agents need you to sign in before they open a session or answer.
When one answers "authentication required", Cornacai shows the sign-in
methods the agent offered when it started, one button each; the one you
pick is sent to the agent (authenticate), which does the signing in its
own way (a browser page, an API key it reads), and what failed is sent
again: the session opens, or your prompt goes through. Esc signs in with
none.
A method marked in this terminal is one the agent asks the client to
run: Cornacai gives the terminal to the agent's own command with that
method's arguments (for the Claude adapter, claude-agent-acp --cli auth
login --claudeai for a Claude subscription, or --console for the
Anthropic Console), you sign in there, and Cornacai comes back and sends
what failed again. Agents offer these methods only to a client that says
it runs them, which Cornacai does when it starts the agent itself.
An agent that wants a sign-in and offers no method Cornacai can use gets a notice listing what it offered, then two steps: how to sign in by hand, and Ctrl+N to open a session. For Claude's adapter the first step is the command to paste into another terminal, built from the one Cornacai started it with:
claude-agent-acp --cli auth login --claudeai # a Claude subscription
claude-agent-acp --cli auth login --console # an Anthropic Console account
(or set ANTHROPIC_API_KEY before starting Cornacai). For Gemini and
Codex it names their own sign-in and API-key variable.
Configuration¶
# cornacai/config.toml
agent = ["claude-agent-acp"] # or a string, split on spaces
shell = ["bash", "-l"]
[capabilities]
read = true # answer reads inside the workspace
write = true # review each write as a diff
terminal = true # ask about each command
[terminal]
pty = true # the agent's commands on a terminal (default: pipes)
[turn]
cancel_grace = 10 # seconds after Esc before "the agent has not stopped"
As a library¶
The app is a library too: cornacai::app::app(Options) returns the
intuiTUIve App and a handle on its connection. With Launch::Replay,
rs-rich-acp's fake agent plays a recorded transcript, which is how the
crate's tests drive it on intuiTUIve's Driver (no agent, no network) and
how the tape above runs (the binary's test-only fake-agent feature reads
the transcripts named by CORNACAI_FAKE_AGENT, a list as PATH is: the
first is the agent, each next one a restart's, as Options::then_replay
gives them). A transcript's {"close": "output"} step is the agent
exiting.
use std::time::Duration;
use cornacai::app::{Launch, Options, app, wait_for};
use rich_acp::replay::Transcript;
let transcript = Transcript::read("conversation.jsonl")?;
let launch = Launch::Replay { transcript, timeout: Some(Duration::from_secs(10)) };
let (app, handle) = app(Options::new(launch, "/path/to/workspace"));
let mut driver = app.driver(100, 30);
wait_for(&mut driver, "Prompt", Duration::from_secs(10));
What is not there yet¶
- An agent terminal shown live as a terminal in its card: on a PTY its output is read as plain text.
- Sending a selection from the shell pane to the agent.
The design, its security model and its open questions are in the design note. Cornacai is written clean-room from the public ACP specification; it is inspired by Toad's public feature list, and none of Toad's code is used.



