code

js/cli/code.md

fino code runs the Fino coding agent against the current directory. Given a prompt it runs one turn and streams its answer; without one, on a terminal, it opens an interactive interface. The agent reads, searches, and edits files under the project root, runs commands in the sandboxed shell, and can fan work out to sub-agents.

fino code "why does the h2 test time out?"
fino code --plan "how should the cache be invalidated?"
fino code --auto --continue "apply the fix and run the tests"
fino code --continue
fino code sessions

Interactive interface

Run fino code with no prompt on a terminal to open the interactive interface. The conversation is printed into ordinary terminal scrollback, and only a small footer (the running activity, any approval, the composer, and a status line) is redrawn in place, so the terminal's own scrolling, search, and copy keep working. Without a terminal, or with --json, a prompt is required.

Key Effect
Enter Send the message; while a turn runs, queue it.
Alt+Enter Insert a newline.
Shift+Tab Cycle the mode: build, auto, plan.
Esc Interrupt the running turn.
y / n Approve or reject the call shown above the prompt.
Ctrl+C Interrupt a turn, else clear the composer, else exit.
Ctrl+D Exit when no turn is running and the composer is empty.
Command Effect
/plan /build /auto Switch mode.
/model Choose the model from a list.
/model <id> Switch to the model <id>.
/new Start a new session.
/help List keys and commands.
/exit /quit Exit.

/model lists the models every configured provider reports, grouped by provider, in the footer: type to filter, move with the arrow keys, press Enter to switch and Esc to keep the current one, and Ctrl+R to fetch the list again. A provider that cannot list its models is named under the list, and /model <id> still reaches any id. A turn already running keeps the model it started with; the next message, the answer to an approval, and the follow-up once sub-agents report all use the new one. The conversation carries over unchanged, and sub-agents started afterwards that name no model use the new one too. It lasts for the rest of the run, including sessions started with /new; the next fino code starts from --model again. Under --max-cost only priced models are listed or accepted.

Before each approval the call's complete arguments are printed to scrollback, so what is approved is never truncated. --continue and --thread replay the session's history above the footer. Exiting during a turn abandons it without waiting for the model; whatever it had already checkpointed is finished by the next --continue.

Models

The model comes from --model, then FINO_CODE_MODEL, then the provider's default. A claude… id uses Anthropic and any other id an OpenAI-compatible API; --provider anthropic|openai overrides the guess. With no id, Anthropic is used when ANTHROPIC_API_KEY is set, otherwise OpenAI.

Variable Use
ANTHROPIC_API_KEY Anthropic credentials.
OPENAI_API_KEY OpenAI credentials.
OPENAI_BASE_URL An OpenAI-compatible server; no key is required.
FINO_CODE_MODEL Default model id.

Modes and approvals

Option Tools Edits and commands
(none) read, search, edit, shell Ask before each one.
--plan read and search only Not offered.
--auto read, search, edit, shell Run without asking.

On a terminal each gated call is confirmed. Without one it is rejected, and the agent is told to continue without it or to ask for --auto.

Every tool is bounded to the project root, as with fino mcp: paths outside it are refused, and shell runs under the strict process sandbox with no network access, failing closed where that sandbox is unavailable.

Fino tools

Alongside the file tools and shell, the agent runs Fino's own commands through narrow tools, each a fresh fino process under the same sandbox:

Tool Runs Offered
docs_search fino doc search Always; no approval.
docs_show fino doc show Always; no approval.
fino_lint fino lint Always; no approval.
fino_fmt fino fmt [--check] Not in --plan.
fino_test fino test Not in --plan.
fino_bench fino bench Not in --plan.

The docs tools take a source. By default they search the project's own fino doc build index and may refresh it inside docs/; without a docs/ directory they ask for a build instead of creating one. "fino" selects the documentation of the Fino runtime itself, "packages" the project's direct dependencies, and a package name one installed package, the same as fino doc --fino, --packages and --package. Those are built on first use into the shared docs cache, the one directory outside the project the docs tools may write. fino_fmt, fino_test and fino_bench ask for approval like edits, since they rewrite files or run project code.

Spend limit

--max-cost <usd> caps what one invocation spends across the agent and its sub-agents. Each model call is checked against the remaining amount, and the call that would exceed it fails and ends the turn. Spend is priced from fino:ai/context's pricing table, so a model missing from it is refused rather than counted as free.

Sub-agents

The agent can spawn sub-agents for independent pieces of work. Each runs concurrently in its own conversation and reports back for review. A turn does not end while sub-agents are working: when the agent stops first, fino code waits for them and continues the conversation with their reports until each is accepted, iterated on, or reported as failed. Sub-agents follow the session's mode, and in --plan they are read-only.

Sessions

Conversations are stored in .fino/code/sessions.db under the project root.

Option Effect
--continue Continue the most recent session.
--thread <id> Continue the session with this id.
--model <id> Model id.
--provider <name> anthropic or openai.
--max-cost <usd> Spend limit for this invocation.

Continuing a session first finishes what the previous process left: a run interrupted mid-step is re-driven from its last checkpoint, a pending approval is asked again, and sub-agents awaiting review are handed back to the agent.

fino code sessions lists sessions newest first with their title and attention state; --archived lists archived ones. All three commands accept --json; a turn's JSON result is { command, ok, status, threadId, text }, plus error when the turn failed.

Transcripts

fino code sessions show [id] prints a session's transcript as Markdown: each user and assistant message, every tool call with its complete arguments, and every tool result, followed by each sub-agent's conversation. Without an id it shows the most recent session.

fino code sessions show > session.md
fino code sessions show code-mx2k1-4f3a9c1e --json

The transcript is rendered from the stored conversation each time it is shown, so it covers every past session and cannot drift from what the agent resumes from. Attached images, audio, and documents appear as their media type and size rather than their contents. With --json the result is { command, ok, id, title, updatedAt, entries, subagents }, where each entry has a kind of user, assistant, tool_call, tool_result, or media.

The agent is built from public modules: sessions from fino:ai/session, titles and attention from fino:ai/threads, tools from fino:ai/tools, and sub-agents from fino:ai/subagents.