# Command-line reference

The `soundbox` command starts the server and manages models and engines. From
a clone it runs as `npx soundbox` after `npm run build`, or as
`npx tsx server/src/cli.ts` without a build. Both take the same arguments.

## soundbox

Starts the server. It serves the web app, the HTTP API and the MCP endpoint on
one port.

| Flag | Default | Description |
|---|---|---|
| `--host <HOST>` | `127.0.0.1` | Address to listen on. |
| `--port <PORT>` | `17494` | Port to listen on. |
| `--data-dir <DIR>` | `~/.mirli`, or `~/.soundbox` from an older install | The data folder. Applies to the server only. |
| `--profile <NAME>` | The last active profile | The library to open. |
| `--no-ui` | Off | Serve the API only. |
| `--log-level <LEVEL>` | `MIRLI_LOG_LEVEL`, else `info` | `debug`, `info`, `warning`, `error` or `critical`. |
| `--version` | | Print the version and exit. |
| `--help`, `-h` | | Print usage and exit. |

## soundbox model

Installs and reports the native engines.

| Command | Description |
|---|---|
| `model status audiocpp` | The audio.cpp version, detected backend and resolved path. |
| `model install audiocpp` | Download and verify the audio.cpp build for this machine. |
| `model status llm` | The same for `llama-server`, plus each prompt-assistant model and whether it is downloaded. |
| `model install llm` | Install `llama-server` and the default prompt-assistant model. |

| Flag | Applies to | Description |
|---|---|---|
| `--backend <NAME>` | `install` | Download the build for another backend, such as `cuda`, `metal`, `vulkan` or `cpu`. |
| `--version <TAG>` | `install` | Download this release. Takes the tag exactly as upstream's releases page shows it: `v0.9.6`, not `0.9.6`. |
| `--engine-only` | `install llm` | Install the engine without model weights. |
| `--model <ID>` | `install llm` | Install this prompt-assistant model instead of the one in Settings. |

A managed engine reports its version. An engine of yours reports
`external (env)` or `external (PATH)`. See
[Engines and GPU backends](https://mirli.app/docs/install-engines/index.md).

## Model commands

These run without the server. They read the data folder from
`MIRLI_DATA_DIR`, not from `--data-dir`.

| Command | Description |
|---|---|
| `list` | The catalogue, with what is downloaded. Entries from `custom.json` are tagged `[custom - from your custom.json]`. |
| `pull <MODEL_ID>` | Download a model's weights. |
| `rm <MODEL_ID>` | Delete a model's weights folder. |
| `run <MODEL_ID> "<PROMPT>"` | Render one sound. Offers to download a missing model first. |

`run` takes these flags:

| Flag | Description |
|---|---|
| `--out <FILE>` | Where to write the WAV. |
| `--duration <SECONDS>` | Length of the sound. |
| `--seed <N>`, `--steps <N>`, `--cfg <N>` | Sampler settings. |
| `--yes`, `-y` | Download a missing model without asking. |

## Commands that talk to a running server

These call the server's HTTP API. Each takes `--host` and `--port`, with the
same defaults as the server, and sends `MIRLI_API_TOKEN` when it is set.

| Command | Description |
|---|---|
| `ps` | The models loaded in memory. |
| `enhance "<PROMPT>"` | Rewrite a prompt with the prompt assistant. `--n <1-5>` sets how many variations, `--category` is `sfx` or `music`. |

## soundbox skills

Manages the agent skills bundled with Mirli.

| Command | Description |
|---|---|
| `skills list` | Each skill and where it is installed. |
| `skills path` | The folder the bundled skills are read from. |
| `skills install [<NAME>...]` | Copy skills into a client's folder. `--target` names the client (default `claude`); `--path` gives a folder instead. With no names, every skill is installed. |

## npm scripts

Run these from the repository root.

| Script | Description |
|---|---|
| `npm run build` | Build the web app into `server/web` and the server into `server/dist`. |
| `npm run dev` | The server on 17494 and the Vite dev server on 5174. |
| `npm run dev:ui` | Vite alone. Every `/api` call answers 502 until a server runs on 17494. |
| `npm run dev:mock` | The UI against an in-browser fake backend. No server and no models. |
| `npm run typecheck`, `npm run lint`, `npm test` | The checks CI runs. |
| `npm run desktop` | Build, then compile and open the desktop shell. |
| `npm run desktop:build` | Build a desktop installer. See [Build the desktop app](https://mirli.app/docs/desktop-build/index.md). |
| `npm run site:dev`, `npm run site:build` | The public site. |
| `npm run capture:media` | Regenerate the screenshots from the demo library. |

## Download behaviour

Mirli's own downloader fetches the prompt assistant, the artwork models and
the engines. It also fetches audio models when the audio.cpp runtime has no
package manager of its own; when it has one, audio.cpp does the transfer and
Mirli reports its progress.

| Stage | Behaviour |
|---|---|
| Before it starts | Compares what is left to download, plus 2 GB to keep free, with the free space on the drive that holds the models folder. If it does not fit, nothing is downloaded and the message names the three sizes and the folder. Engines and sampled instruments are checked without the 2 GB margin. |
| While it runs | Writes to `<FILE>.part`, with a `<FILE>.part.meta` beside it that records which version of the file the bytes came from. Progress shows the rate and the time left. |
| Dropped connection, stall, 429 or 5xx | Waits and tries again, up to five tries, waiting longer each time. Follows a `Retry-After` of a minute or less. Does not retry a 401, 403 or 404. |
| Each new try | Continues from the `.part` with an HTTP `Range` request. Starts again from the beginning if the file changed upstream or the server cannot continue it. |
| Finished | Checks the size, and the SHA-256 where the source publishes one, before renaming the file into place. |
| Every try failed | Keeps the `.part`. The model shows as **Incomplete** on the **Models** page with the reason, and **Repair** continues from where it stopped, even after a restart. The reason is kept in `models/download-failures.json` until a download succeeds, the weights are deleted or you dismiss it. |
| Cancelled, disk full, wrong size or checksum | Removes the `.part`. |
