# Terminal

> Run Raw from the terminal with one-shot tasks or the saved REPL, and adjust output density, reasoning, color, icons and theme.

Raw has two terminal modes. A one-shot run executes one task and exits. The REPL keeps a saved session open for several tasks. Both modes use the same agents, tools and sessions.

## One-shot tasks

```sh
raw "Explain the tests in this repository"
raw --agent deepseek "Fix the failing tests"
```

Raw prints the assistant’s answer to stdout. Status lines, tool activity and the footer go to stderr. Redirecting stdout therefore saves only the answer:

```sh
raw "Summarize the open TODOs" > todos.md
```

If a task begins with a dash, put `--` before it so Raw does not read the task as a flag.

## The REPL

Run `raw` with no task, or `raw --interactive`, to open the REPL. On a Unicode terminal the prompt is `❯`. In ASCII or plain output it is `> `.

Each line you type is a task. The session keeps its history between tasks and between process restarts. These commands must occupy a whole line:

| Command    | Effect                                                                         |
| ---------- | ------------------------------------------------------------------------------ |
| `/compact` | Summarize older model context now, using the selected model.                   |
| `/clear`   | Start a new saved session. The old history stays available.                    |
| `/stats`   | Show cumulative request, token and cache counts. This does not call the model. |
| `/exit`    | Close the session and exit.                                                    |

Any other line starting with `/` is sent as ordinary task text.

When you open the REPL on a saved session, Raw first shows its latest 20 saved items. Raw prints a `raw --resume ID "query"` command when you exit, so you can return to the same session later. See [Sessions](https://raw.tlelabs.com/docs/guides/sessions/).

### Cancel and exit

- Ctrl-C during a task cancels the active work and returns to the prompt.
- Ctrl-C while idle returns to the prompt. A second Ctrl-C while idle exits the REPL.
- End-of-file (Ctrl-D) cancels any active work and exits after cleanup.
- A one-shot run cancelled with Ctrl-C exits with status 130. See the [CLI reference](https://raw.tlelabs.com/docs/reference/cli/) for all exit codes.

## Tool activity

Each tool call prints a status line on stderr. Before a tool runs, Raw prints its readable arguments. A `bash` call shows the full ordered commands. A `write_file` call shows the target paths, modes and payload sizes, but not the file contents. Long argument lists are shortened for display only. The model receives the full arguments.

Each tool result also has a short preview. The preview is bounded and only affects what you see. It never changes the result sent to the model. Use `--max-output-bytes` to change the model-facing cap, not the preview.

## Output options

Set these in the `ui` object at the root of `config.json`, or override them for one run with flags.

| Setting     | Values                         | Flag          | Behavior                                                                                                                                                                                               |
| ----------- | ------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `density`   | `compact`, `normal`, `verbose` | `--display`   | `compact` hides successful preview bodies and emphasizes the answer. `normal` shows up to four source lines of a preview. `verbose` shows the full retained preview. Errors always keep their preview. |
| `reasoning` | `hidden`, `summary`, `full`    | `--reasoning` | Controls provider-supplied reasoning text. `summary` shows a short activity label, not a rewrite of the reasoning. The default is `full` with verbose density and `summary` otherwise.                 |
| `color`     | `auto`, `always`, `never`      | `--color`     | `auto` uses color on an interactive terminal. `NO_COLOR` disables color in `auto` mode.                                                                                                                |
| `icons`     | `auto`, `unicode`, `ascii`     | `--icons`     | Selects icon glyphs or text labels for the same states.                                                                                                                                                |
| `theme`     | `terminal`, `dark`, `light`    | `--theme`     | `terminal` uses your terminal’s own colors. `dark` and `light` use fixed palettes.                                                                                                                     |

For example:

```sh
raw --theme dark --display verbose "Inspect this module"
```

```json
{
  "ui": {
    "density": "normal",
    "reasoning": "summary",
    "color": "auto",
    "icons": "auto",
    "theme": "terminal",
    "palette": { "accent": "cyan", "thinking": "magenta" }
  }
}
```

### Palette roles

The optional `palette` object maps semantic roles to basic ANSI color names. Each value is a basic color name, its `bright_` variant, or `default`. Escape sequences are not accepted. The roles are:

`accent`, `text`, `muted`, `thinking`, `path`, `code`, `success`, `warning`, `error`, `syntax_keyword`, `syntax_string`, `syntax_number`, `syntax_comment`, `syntax_type`, `syntax_punctuation`.

Unknown roles and unknown option values fail config validation.

### Icons

The normal view uses these glyphs: brand `◆`, assistant `●`, read `↳`, write `✎`, Bash `$`, skill `◇`, MCP `↗`, success `✓`, failure `✗`, attention `!` and continuation `↪`. ASCII mode shows the same states with text labels.

## Output rules

- **Redirected output.** When stdout is not a terminal, the answer is written exactly as the assistant produced it. Raw does not reformat it.
- **Plain output.** Redirected streams, `TERM=dumb` and disabled color print plain text with append-only lines.
- **Interactive output.** On a shared interactive terminal, Raw can redraw the line that is still streaming and the activity indicator. It commits completed text once.
- **Final newline.** A completed turn ends with a newline, even if the streamed text did not.

## Footer

After each run, Raw prints a footer on stderr:

- the outcome: `Done`, `Failed`, `Cancelled` or `Stopped: max steps`,
- elapsed time and the number of tool calls,
- an estimate of the current context, marked with `~`, with a percentage when the model declares a context window,
- cumulative session input, output and cache-read counts, only when the provider reports every field, and
- a copyable resume command when the session is still usable.

The percentage is an estimate. Missing counts are shown as unknown, not as zero. Use `/stats` or verbose mode for coverage details. See [Context and compaction](https://raw.tlelabs.com/docs/guides/context-and-compaction/).

## Markdown and code

Answers render Markdown in an interactive terminal. Headings, lists, quotes, links, inline code, fenced code and tables are supported. Fenced code and read-file previews are highlighted for these languages: JavaScript and JSX, TypeScript and TSX, Python, Bash and sh, JSON and JSONC, YAML, HTML and XML, CSS, SQL, Go, Rust, C and C++, Java, Markdown and diff. Other languages are shown as plain code.

Streaming text appears as it arrives. A very large unfinished code block is shown as literal text until its closing fence, so output does not stall.

### Mermaid diagrams

Mermaid diagrams render in the [dashboard](https://raw.tlelabs.com/docs/guides/dashboard/), both in chat and in the side panel. A `mermaid` fence in a terminal answer is shown as ordinary code, because the terminal does not draw diagrams. Diagram source is limited to 16 KiB of UTF-8, and the renderer rejects directives, links, embedded HTML and external resources. Source that cannot be rendered stays visible with a short diagnostic.

## Preview the output styles

Checkouts of the repository include a fixed preview script that prints sample records without a model, an API key or a config file:

```sh
node scripts/preview-terminal.mjs --width 80 --theme dark --icons unicode
```

Run it in a real terminal to see colors. Redirected output is plain text.

> **Note:**
>
> Viewing a saved session also uses these settings. `raw sessions show ID` replays the stored history with your current appearance settings, without running tools or calling the model.
