athanor 3.3.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,766 +1,170 @@
1
1
  # athanor
2
2
 
3
- **Athanor — personal LLM alchemy.** Discover, download, configure, and switch between MLX and llama.cpp models on Apple Silicon from a single TUI or CLI, while keeping an OpenAI-compatible HTTP endpoint live for downstream tools (pi-agent, editors, etc.).
3
+ A local LLM workbench for Apple Silicon. Discover, run, configure, and switch between MLX and `llama.cpp` (GGUF) models from a TUI or CLI, while keeping an OpenAI-compatible HTTP ingress active for tools like [pi-agent](https://github.com/badlogic/pi-mono).
4
4
 
5
- ## What it does
6
-
7
- - **Discovers** MLX models in your HuggingFace cache and GGUF files in `~/.models`.
8
- - **Downloads** new models from HuggingFace via the `hf` CLI.
9
- - **Runs** them via `mlx_lm.server` or `llama-server`, one or more at a time, each on a stable port.
10
- - **Supervises** the processes as detached children with per-process log files and automatic reattach.
11
- - **Publishes** exposed models to pi-agent (`~/.pi/agent/models.json`) — by default via ingress-backed `athanor-mlx` / `athanor-llama` aggregators — leaving your other (cloud, Ollama, etc.) providers alone.
12
- - **Exposes** an optional local control API so other tools can ask athanor to activate a model on demand.
13
-
14
- ## Prerequisites
15
-
16
- - macOS on Apple Silicon
17
- - Node.js ≥ 18
18
- - `mlx_lm.server` (from [`mlx-lm`](https://github.com/ml-explore/mlx-lm)) — text-only MLX models
19
- - `mlx_vlm.server` (from [`mlx-vlm`](https://github.com/Blaizzy/mlx-vlm)) — vision/multimodal MLX models; optional if you never run VLMs
20
- - `llama-server` (from [`llama.cpp`](https://github.com/ggml-org/llama.cpp))
21
- - `hf` (from [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/guides/cli)) — only required for `athanor pull`
22
-
23
- Run `athanor doctor` at any point to verify all four are on your `PATH`.
24
-
25
- ## Agent-assisted setup
26
-
27
- If you use an AI coding agent (Claude Code, Cursor, Aider, etc.), the fastest path is to open this repo in the agent and ask it to set athanor up for you. `AGENTS.md` has an **Onboarding a user** section written for that case: it tells the agent how to install the CLI (`npm start` vs `npm link`), run `athanor doctor`, install any missing runtime binaries, profile the host (Apple Silicon check, unified memory via `vm_stat`, HF cache size), and pick a starter model sized for the machine.
5
+ ---
28
6
 
29
- A minimal prompt, once the repo is open:
7
+ ## What It Does
30
8
 
31
- > Set up athanor on this machine. Profile what I have, install anything missing, and suggest a starter model I can actually run.
9
+ - **Unified Runtimes**: Runs Apple MLX (`mlx_lm.server`, `mlx_vlm.server`) and GGUF (`llama-server`) models with Metal acceleration.
10
+ - **Zero Daemon**: No persistent background service. Runtimes run as detached child processes bound to stable ports that persist across restarts.
11
+ - **OpenAI-Compatible Ingress**: Single-port reverse proxy (`http://127.0.0.1:40879/v1`) with on-demand model activation and stream-drain safety.
12
+ - **Pi-Agent Integration**: Synchronizes exposed models to `~/.pi/agent/models.json` via aggregator providers (`athanor-mlx` and `athanor-llama`) while leaving non-athanor providers (OpenAI, Anthropic, Ollama, etc.) untouched.
13
+ - **Terminal UI & Scriptable CLI**: Switch models, tail logs, adjust formulas, and monitor token throughput from an Ink TUI or CLI.
32
14
 
33
- The rest of this README walks the same path manually.
15
+ ---
34
16
 
35
- ## Setup
17
+ ## Quick Install
36
18
 
37
- Install the three runtime helpers athanor shells out to. All three land on your `PATH` and can be verified with `athanor doctor`.
19
+ ### Prerequisites
38
20
 
39
- ### mlx-lm (MLX runtime)
21
+ - **Hardware**: macOS on Apple Silicon (M1/M2/M3/M4)
22
+ - **Runtime**: Node.js ≥ 22
23
+ - **External Binaries**: `mlx_lm.server`, `llama-server`, `hf`
40
24
 
41
- `mlx-lm` is a Python package; the `mlx_lm.server` entry point is what athanor invokes. A dedicated virtualenv keeps it isolated from your system Python.
25
+ ### 1-Minute Setup
42
26
 
43
27
  ```bash
44
- # with uv (recommended)
45
- brew install uv
28
+ # Install external runtimes
29
+ brew install uv llama.cpp
46
30
  uv tool install mlx-lm
47
- # ⇒ `mlx_lm.server` is now on PATH via ~/.local/bin
48
-
49
- # or with pipx
50
- brew install pipx
51
- pipx install mlx-lm
52
-
53
- # or with a plain venv
54
- python3 -m venv ~/.venvs/mlx && source ~/.venvs/mlx/bin/activate
55
- pip install -U mlx-lm
56
- ```
57
-
58
- Verify:
59
-
60
- ```bash
61
- mlx_lm.server --help
62
- ```
63
-
64
- MLX requires Apple Silicon and macOS 13.5+. Models are downloaded to `~/.cache/huggingface/hub` on first use.
65
-
66
- ### mlx-vlm (MLX vision/multimodal runtime)
67
-
68
- Required only if you flip a model to `mlxFlavor: "vlm"` to feed it actual image input. Athanor defaults every MLX entry to `mlx_lm.server`, which handles text-only chat for most VLM-tagged repos (Qwen2-VL, Qwen2.5-VL, Qwen3-VL, LLaVA, etc.) without torch. Only install this when you actually need vision — and then opt in per model with `athanor flavor <slug> vlm`.
69
-
70
- `mlx_vlm.server` imports `transformers`' VLM processors, which in turn import PyTorch and Torchvision. Installing `mlx-vlm` alone is not enough; `torch` and `torchvision` must be present in the same environment. With `uv`:
71
-
72
- ```bash
73
- uv tool install mlx-vlm --with torch --with torchvision
74
- ```
75
-
76
- Or with pipx:
77
-
78
- ```bash
79
- pipx install mlx-vlm
80
- pipx inject mlx-vlm torch torchvision
81
- ```
82
-
83
- Or with pip into the same venv you used for mlx-lm:
84
-
85
- ```bash
86
- pip install -U mlx-vlm torch torchvision
87
- ```
88
-
89
- Verify:
90
-
91
- ```bash
92
- mlx_vlm.server --help
93
- python3 -c "import torch, torchvision; print(torch.__version__, torchvision.__version__)"
94
- ```
95
-
96
- If `mlx_vlm.server` starts but a request fails with `Qwen3VLVideoProcessor requires the PyTorch library` (or similar), torch/torchvision are missing or installed into a different interpreter than `mlx_vlm.server` is using. Re-run the install above into the right environment.
97
-
98
- ### llama.cpp (GGUF runtime)
99
-
100
- The easiest path on macOS is Homebrew — the bottle is built with Metal enabled, so GPU acceleration works out of the box:
101
-
102
- ```bash
103
- brew install llama.cpp
104
- ```
105
-
106
- You can also build from source if you want a specific revision or custom flags:
107
-
108
- ```bash
109
- git clone https://github.com/ggml-org/llama.cpp
110
- cd llama.cpp
111
- cmake -B build
112
- cmake --build build --config Release -j
113
- # copy or symlink build/bin/llama-server onto your PATH
114
- ```
115
-
116
- Verify:
117
-
118
- ```bash
119
- llama-server --help
120
- ```
121
-
122
- ### hf (HuggingFace CLI — only for `athanor pull`)
123
-
124
- Needed only if you want athanor to download new models from the Hub. Skip if you'll populate `~/.cache/huggingface/hub` by other means (e.g. `mlx_lm.server --model <repo>` auto-downloads on first use).
125
-
126
- The Hugging Face Hub team has replaced the legacy `huggingface-cli` command with a new CLI called `hf`. Athanor invokes `hf download`. The recommended install path is the standalone installer, which drops a self-contained `hf` binary onto your `PATH` without touching system Python:
127
-
128
- ```bash
129
- curl -LsSf https://hf.co/cli/install.sh | bash
130
- ```
31
+ uv tool install huggingface_hub
131
32
 
132
- Alternatives:
33
+ # Clone and install athanor
34
+ git clone https://github.com/MylesBorins/athanor.git
35
+ cd athanor
36
+ npm install && npm run build && npm link
133
37
 
134
- ```bash
135
- # Homebrew
136
- brew install hf
137
-
138
- # via uvx — runs the latest release on demand, no install step
139
- uvx hf --help
140
-
141
- # via pip (the `hf` entry point ships with huggingface_hub ≥ 0.34)
142
- pip install -U huggingface_hub
143
- ```
144
-
145
- Verify:
146
-
147
- ```bash
148
- hf --help
149
- # optional: log in if you need access to gated/private repos
150
- hf auth login
151
- ```
152
-
153
- ### Final check
154
-
155
- ```bash
38
+ # Verify dependencies
156
39
  athanor doctor
157
- # mlx_lm.server: /Users/you/.local/bin/mlx_lm.server version 0.31.3 (uv)
158
- # mlx_vlm.server: /Users/you/.local/bin/mlx_vlm.server version 0.4.4 (uv)
159
- # llama-server: /opt/homebrew/bin/llama-server version 9010 (brew)
160
- # hf: /Users/you/.local/bin/hf version 1.13.0 (uv)
161
-
162
- athanor doctor --check-updates
163
- # ... latest <version> up to date
164
- # ... or latest <version> update available
165
- # ... hint uv tool upgrade <tool>
166
- ```
167
-
168
- ## Quick start
169
-
170
- ### Fastest path
171
-
172
- If you want one working local text model quickly on a typical 16 GB+ Apple Silicon Mac:
173
-
174
- ```bash
175
- npm install
176
- npm start -- doctor
177
- npm start -- pull mlx-community/Qwen3.5-9B-MLX-4bit
178
- npm start -- start qwen3-5-9b-mlx-4bit
179
- npm start -- expose qwen3-5-9b-mlx-4bit
180
- ```
181
-
182
- Then in pi-agent, select provider `athanor-mlx-qwen3-5-9b-mlx-4bit` and model `mlx-community/Qwen3.5-9B-MLX-4bit`.
183
-
184
- If you only want text chat, you do **not** need `mlx_vlm.server`; `mlx_lm.server` is enough even for many VLM-tagged repos when used as text-only models.
185
-
186
- ### Full quick start
187
-
188
- ```bash
189
- npm install
190
-
191
- # verify external runtime binaries are on PATH
192
- npm start -- doctor
193
-
194
- # one-time: ingest whatever's already on disk
195
- npm start -- scan
196
-
197
- # see what's in the registry — if empty, this prints curated
198
- # starter models with reviewed 8 / 16 / 32 GB memory tiers and task tags
199
- # that you can copy the `athanor pull ...` line from
200
- npm start -- ls
201
-
202
- # pull one and start it (by slug)
203
- npm start -- pull mlx-community/Qwen3.5-9B-MLX-4bit
204
- npm start -- start qwen3-5-9b-mlx-4bit
205
-
206
- # or drop into the TUI (no args) — the empty state has the same
207
- # suggestions with memory tiers/task tags and pulls them inline when you press Enter
208
- npm start
209
- ```
210
-
211
- `npm start` runs the app via `tsx`, so no build step is needed for development. For a live development loop, use:
212
-
213
- ```bash
214
- npm run dev
215
- ```
216
-
217
- That runs a small custom watcher (`scripts/dev-watch.mjs`) which watches only `src/**/*.ts` and `src/**/*.tsx`, then respawns `tsx src/index.tsx` with `ATHANOR_DEV_TUI=1`. This avoids `tsx watch`'s stdin/restart behavior, which can interfere with Ink/TUI key handling in tmux. In this dev mode athanor still starts the real ingress path (router when needed, control API if enabled) so pi-agent integration behaves like the normal app, but it skips the alt-screen/cursor toggles to make UI iteration safer in split panes. The TUI also collapses to compact/minimal layouts in short or narrow terminals so model selection stays usable in tmux splits. Router-driven model switches are reflected in the TUI by polling persisted live instance state, not only the local process's in-memory supervisor map. For one-shot runs without the dev safeguards, keep using `npm start`.
218
-
219
- If you want a compiled build or to install the `athanor` binary globally:
220
-
221
- ```bash
222
- npm run build # emit dist/
223
- npm link # expose `athanor` on PATH
224
- athanor ls # now usable directly
225
- ```
226
-
227
- `bin/athanor` imports `dist/index.js`, so `npm link` requires a prior `npm run build`. Linked mode does not auto-rebuild; re-run the build after pulling changes or stay on `npm start` for the dev loop.
228
-
229
- ## Concepts
230
-
231
- ### Registry
232
-
233
- `~/.athanor/models.json` is the source of truth. Every model has:
234
-
235
- | field | purpose |
236
- | ----------- | ------------------------------------------------------------- |
237
- | `id` | stable canonical id (HF repo, repo+file, or `local:…`) |
238
- | `slug` | short user-editable handle (`qwen-32b`) |
239
- | `path` | on-disk location athanor passes to the runtime |
240
- | `runtime` | `mlx` or `llama.cpp` |
241
- | `source` | `{ type: "hf", repo, [revision], [file] }` or `{ type: "local" }` |
242
- | `port` | **stable** port allocated once per model, never changes |
243
- | `formula` | per-model overrides that merge on top of global runtime config |
244
- | `mlxFlavor` | `"lm"` or `"vlm"` — picks which MLX binary to use (MLX only) |
245
- | `publish` | whether pi-agent sees this model |
246
- | `piAlias` | optional llama launch alias; when set to something other than `slug`, overrides the default runtime model id |
247
- | `tags` | free-form labels (`chat`, `coder`, …) |
248
-
249
- ### Stable per-model ports
250
-
251
- Each model is bound to a port at first ingest and keeps it forever. This means pi-agent's catalog is configured **once per model**; switching which model is active does not change pi's URLs, only the `status` field athanor writes into each entry.
252
-
253
- Port range is configurable (`portRange` in `~/.athanor/config.json`, default 40880–40979).
254
-
255
- On load, athanor collapses duplicate registry rows that share the same normalized on-disk path (keeping the HF-sourced entry when present) and upgrades local GGUF paths under `org--repo/` directories to HF source metadata when possible.
256
-
257
- ### MLX capabilities and flavor routing
258
-
259
- MLX entries track two independent axes:
260
-
261
- - `mlxCapabilities` — *what the model advertises*. Detected from the snapshot's `config.json` at scan and pull time, primarily by looking for a `vision_config` block, with fallbacks for known VLM `model_type` values (`qwen2_vl`, `qwen2_5_vl`, `llava*`, `mllama`, `pixtral`, `idefics2/3`, `phi3_v`) and architecture-name patterns such as `Qwen2VLForConditionalGeneration`. Today the only capability is `"vlm"`. Capabilities are refreshed on every scan.
262
- - `mlxFlavor` — *which server binary to launch*. `"lm"` routes to `mlx_lm.server` (the default, no torch/torchvision required); `"vlm"` routes to `mlx_vlm.server` (requires torch + torchvision; needed for actual image input). Never set automatically — you choose with `athanor flavor <slug> lm|vlm`.
263
-
264
- The split is deliberate: many VLM-tagged repos (e.g. Qwen2.5-VL, Qwen3-VL-MLX) run fine as text-only under `mlx_lm.server`, which is lighter, faster to load, and doesn't need a PyTorch install. Auto-routing every VLM-capable repo to `mlx_vlm.server` would silently break text-only workflows whenever torch isn't available. So athanor defaults everything to `lm` and leaves the upgrade to you.
265
-
266
- In `athanor ls` and `athanor show`, entries with `mlxFlavor: "vlm"` display `mlx-vlm` in the runtime column; `athanor show` also prints a `caps` row and, for vision-capable entries still on `lm`, a hint pointing at `athanor flavor <slug> vlm`. In the TUI model list, hub-backed entries show the HF repo as the primary label with the slug dimmed after it; local entries show the slug only. In pi-agent, VLM-flavored entries render as `[mlx-vlm] <repo> (athanor)`; the provider id stays `athanor-mlx-<slug>` regardless of flavor, so pi URLs don't churn if a model's flavor is toggled later.
267
-
268
- ### Supervisor and policies
269
-
270
- The runtime supervisor manages N concurrent child processes. Three policies:
271
-
272
- - `single-active` (default) — starting a model stops any others.
273
- - `multi-active-lru` — keep up to `supervisor.maxConcurrent` running; evict the least-recently-started.
274
- - `manual` — never auto-stop; you decide.
275
-
276
- Children are started with `detached: true`, stdio redirected to `~/.athanor/logs/<slug>-<pid>.log`, and `unref()`ed so the CLI/TUI can exit without killing them. On next launch athanor reattaches via PID.
277
-
278
- Readiness is detected by polling the runtime's health endpoint (`/health` for llama.cpp, `/v1/models` for mlx_lm.server), not by matching stdout strings.
279
-
280
- ### Observability
281
-
282
- The TUI banner shows a second line with system CPU and RAM bars plus the 1-minute load average, refreshed once a second. Each running row in the model list gets a compact suffix `CPU% · RSS · tok/s` (e.g. `340% · 4.2G · 22.5 tok/s`). The CLI mirrors this: `athanor status` adds CPU, RSS, and tok/s columns for every running instance.
283
-
284
- Caveats worth knowing:
285
-
286
- - **CPU% is per-core, not per-machine**, matching `ps` and Activity Monitor. A runtime using 8 cores reads as ~800%. Divide by `os.cpus().length` yourself if you want a whole-machine number.
287
- - **RSS is resident set size**, not reserved allocation. On Apple Silicon's unified memory this is the honest "how much of my RAM is this model currently pinning" number.
288
- - **tok/s is post-request, not live.** Athanor does not sit in the request path — clients connect directly to each runtime's port. The number is parsed from the per-completion timing line the runtime already writes to its log (`eval time = … tokens per second` for llama.cpp, `Generation: … tokens, … tokens-per-sec` for mlx_lm / mlx_vlm), and updates once a generation finishes. While a request is streaming, the most recent completed request's rate is shown. If no completion has happened yet, the column is blank.
289
- - Sampling is best-effort — if `ps` fails, the log format changes, or timing lines are not yet present, the affected column is hidden rather than showing a wrong number.
290
-
291
- ### Pi-agent sync
292
-
293
- Athanor publishes into pi-agent's [custom providers](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/models.md) system. On every state change it rewrites `~/.pi/agent/models.json`.
294
-
295
- **Default shape (ingress on):** pi sees up to two aggregator providers — `athanor-mlx` and `athanor-llama` — both pointing at the ingress port (`127.0.0.1:40879/v1` by default). Each lists only exposed models of that runtime. See [Ingress](#ingress) for lifecycle and request routing.
296
-
297
- **Direct shape (`router.enabled: false`):** each exposed model becomes **its own pi provider** named `athanor-<runtime>-<slug>` (e.g. `athanor-mlx-qwen3-32b`), with `baseUrl` pointing at that model's stable port. One provider per model is required because a pi provider has exactly one `baseUrl` and each athanor model runs on its own port.
298
-
299
- Common rules for both shapes:
300
-
301
- - Providers whose name does **not** start with `athanor-` are preserved untouched — your OpenAI, Anthropic, Ollama, OpenRouter, etc. entries are safe.
302
- - Each athanor provider uses `api: "openai-completions"`, a placeholder `apiKey: "athanor"`, and runtime-appropriate `compat` flags.
303
- - pi's `/model` picker lists models by **`id`**, not `name`. The `name` field is advisory detail text. Athanor sets both so they stay aligned with what each runtime was launched with:
304
- - **MLX HF-sourced models** — launched with `--model <repo>`; pi `id` is that repo string.
305
- - **MLX local models** — launched with `--model <path>`; pi `id` is that path.
306
- - **llama.cpp HF GGUF** — launched with `--alias <registry-id>` where the id is `author/repo:file.gguf`; pi `id` matches. This keeps hub source visible in pi the same way MLX repos are. Slug and canonical id remain valid request aliases via the ingress resolver.
307
- - **llama.cpp local / custom alias** — launched with `--alias <piAlias|slug>` when you've set an explicit `piAlias` different from `slug`; pi `id` is that alias.
308
- - Hub-backed entries use `[runtime] <repo> (athanor)` for the pi `name` field regardless of runtime.
309
- - `~/.pi/agent/settings.json` is only touched when an athanor model is started as the active default.
310
-
311
- Example aggregator model entry (llama GGUF, HF-sourced):
312
-
313
- ```json
314
- {
315
- "id": "unsloth/Qwen3.6-27B-GGUF:Qwen3.6-27B-Q4_K_M.gguf",
316
- "name": "[llama.cpp] unsloth/Qwen3.6-27B-GGUF (athanor)",
317
- "input": ["text"],
318
- "contextWindow": 32768
319
- }
320
- ```
321
-
322
- Example direct provider (MLX, HF-sourced):
323
-
324
- ```json
325
- {
326
- "providers": {
327
- "athanor-mlx-qwen3-32b": {
328
- "baseUrl": "http://127.0.0.1:40880/v1",
329
- "api": "openai-completions",
330
- "apiKey": "athanor",
331
- "compat": {
332
- "supportsDeveloperRole": false,
333
- "supportsReasoningEffort": false
334
- },
335
- "models": [
336
- {
337
- "id": "mlx-community/Qwen3-32B-4bit",
338
- "name": "[mlx] mlx-community/Qwen3-32B-4bit (athanor)",
339
- "input": ["text"],
340
- "contextWindow": 32768
341
- }
342
- ]
343
- }
344
- }
345
- }
346
- ```
347
-
348
- After upgrading athanor or changing runtime ids, run `athanor sync` and **restart** affected llama models so `--alias` matches what pi expects. pi reloads `models.json` when you open `/model`.
349
-
350
- Disable athanor's sync entirely with `"enablePiSync": false` in `~/.athanor/config.json`.
351
-
352
- ## CLI reference
353
-
354
- ```
355
- athanor launch the TUI
356
- athanor scan rescan model dirs and update registry
357
- athanor ls list registry entries (with live status)
358
- athanor status list running instances
359
- athanor show <id|slug> inspect a model: runtime, effective config, launch command
360
- athanor snippet <id|slug> generate OpenAI API and pi-agent integration code snippets
361
- athanor start <id|slug> start a model
362
- athanor stop [<id|slug>|--all]stop one or all
363
- athanor restart <id|slug> stop + start
364
- athanor logs <id|slug> [-n N] tail last N lines of a running model's log
365
- athanor pull <repo> [--file F] [--revision R]
366
- download from HuggingFace and register
367
- athanor search [q] [--mlx|--gguf|--any] [--author A] [--sort S] [--limit N]
368
- search the HuggingFace Hub
369
- athanor trending [--mlx|--gguf] [--limit N]
370
- top trending MLX/GGUF models
371
- athanor formula <slug> show|set k=v...|unset k...|clear|apply <name>|save <name>
372
- view or modify a model's formula
373
- athanor formulas [delete <name>] list or manage formulas in library
374
- athanor flavor <slug> lm|vlm force MLX runtime flavor (lm = mlx_lm, vlm = mlx_vlm)
375
- athanor expose <id|slug> include in pi-agent catalog
376
- athanor hide <id|slug> remove from pi-agent catalog
377
- athanor rm <id|slug> remove from registry (must be stopped)
378
- athanor sync manually rewrite pi catalog
379
- athanor router [--host H] [--port P] [--verbose]
380
- run the ingress server in the foreground
381
- athanor config print resolved config and its path
382
- athanor doctor check that required binaries are on PATH and show installed versions
383
- athanor doctor --check-updates also compare installed versions with latest available and print upgrade hints
384
- ```
385
-
386
- `<id|slug>` accepts either the canonical id or the short slug.
387
-
388
- ## TUI key bindings
389
-
390
- | key | action |
391
- | ---------- | --------------------------------------------------- |
392
- | `↑` / `↓` / wheel | move selection (one entry per wheel notch) |
393
- | `⏎` | start (if idle) / stop (if running) the highlighted model |
394
- | `r` | restart the highlighted model |
395
- | `k` | kill the highlighted model |
396
- | `P` | toggle pi-agent visibility (expose/hide) |
397
- | `d` | remove the highlighted entry from the registry |
398
- | `D` | open the downloads modal |
399
- | `s` | rescan and ingest new models (automatic on start and when the HF cache changes) |
400
- | `p` | open the pull modal (`esc` cancels in progress) |
401
- | `e` | open the formula editor for the highlighted model |
402
- | `t` | open the telemetry modal for the highlighted model |
403
- | `/` | filter the list by substring of slug or id |
404
- | `tab` | hide the model selector and expand the log pane; press again to restore |
405
- | `q` | quit (does **not** stop running models) |
406
-
407
- The downloads modal shows queued/running/completed pulls. Inside it: `↑↓` selects a task, `c` cancels the selected running task, `C` clears finished tasks, and `esc` closes the modal. Inside the formula editor (`e`): `Tab` toggles between Simple and Advanced modes. In Simple mode: `↑↓` selects smart compound knobs (Context, KV Cache, Speculative, Sampling Mode, GPU Offload), `◀/▶` cycles options, and `⏎` enters custom values. In Advanced mode: keys are grouped by category with full granular control. In both modes: `1-7` applies formulas, `s` saves custom formulas, `y` copies formula config & command to clipboard, `u` unsets a field, `c` prompts confirmation to clear, `v` toggles MLX flavor (`lm`/`vlm`), and `esc` closes.
408
-
409
- With the selector hidden (`tab`), the log pane grows to fill the space and the arrow keys switch roles:
410
-
411
- | key | action |
412
- | --------------------- | ---------------------------------------------------- |
413
- | mouse wheel | scroll the log (3 lines per notch) |
414
- | `↑` / `↓` | scroll the log one line at a time |
415
- | `PgUp` / `PgDn` | scroll by half a page |
416
- | `g` / `Home` | jump to the top of the buffer |
417
- | `G` / `End` | jump back to the tail (resumes live follow) |
418
-
419
- When scrolled up, the header shows `+N ↑ paused` and the log stops auto-updating until you return to the tail. All other keys (`r`, `k`, `⏎`, `tab`) still act on the model you had selected before hiding the list.
420
-
421
- Mouse reporting is enabled only while the TUI is running (SGR mode, `\x1b[?1000h\x1b[?1006h`) and disabled on exit, including on uncaught exceptions and `SIGTERM`/`SIGHUP`. While it's active, click-and-drag text selection in some terminals (iTerm2, Terminal.app) requires holding `⌥`/`Alt`; copy-on-select typically still works. If the process is killed with `SIGKILL`, nothing can reset the terminal — run `reset` or relaunch the TUI to restore it.
422
-
423
- The bottom pane continuously tails the log file of whichever model is highlighted. When any model enters the running set — whether you started it, restarted it, or the router auto-started it on an incoming request — the cursor jumps to it so its logs appear immediately; if an active filter hides the newcomer, the filter is cleared.
424
-
425
- Press `tab` for a full-screen log view that shows model details (id, runtime, port, path), live instance telemetry (pid, uptime, CPU, RSS, tok/s), and a larger log tail. It honors the same cursor-follows-active behavior, so a router-driven model swap auto-switches the view to the new active model. `tab` again returns to the split list+log layout.
426
-
427
- Models downloaded out-of-band (`hf download` in another terminal, or pulled while the TUI was closed) are picked up automatically: every TUI start runs a scan, and while the TUI is running an `fs.watch` on `modelDirs.mlx` / `modelDirs.llama` debounces cache changes into an incremental `ingestDiscovered` call. New entries toast in the footer as `+N new: <slug>…`. Pressing `s` still works as an explicit rescan.
428
-
429
- ## Configuration
430
-
431
- `~/.athanor/config.json`. Missing fields fall back to these defaults:
432
-
433
- ```json
434
- {
435
- "portRange": { "min": 40880, "max": 40979 },
436
- "enablePiSync": true,
437
- "modelDirs": {
438
- "mlx": "~/.cache/huggingface/hub",
439
- "llama": "~/.models"
440
- },
441
- "mlx": {
442
- "prefillStepSize": 512,
443
- "promptCacheSize": 32768,
444
- "decodeConcurrency": 1
445
- },
446
- "llama": {
447
- "nGpuLayers": 999,
448
- "threads": 8,
449
- "ctxSize": 32768,
450
- "batchSize": 512,
451
- "ubatchSize": 256,
452
- "parallel": 1
453
- },
454
- "supervisor": {
455
- "policy": "single-active",
456
- "maxConcurrent": 1,
457
- "startupTimeoutMs": 120000,
458
- "healthPollIntervalMs": 500
459
- },
460
- "controlApi": {
461
- "enabled": false,
462
- "port": 40878,
463
- "host": "127.0.0.1"
464
- },
465
- "router": {
466
- "enabled": true,
467
- "port": 40879,
468
- "host": "127.0.0.1",
469
- "drainTimeoutMs": 30000,
470
- "verbose": false
471
- }
472
- }
473
- ```
474
-
475
- ### Per-model formulas
476
-
477
- `mlx` and `llama` above are **global defaults**. Athanor ships a practical 64K default context baseline; built-in formulas scale that up or down by use case. Any model in the registry can override the globals with its `formula` field, which is merged on top per-runtime. Manage formulas via the CLI (preferred) or the TUI (press `e` on a highlighted model):
478
-
479
- ```bash
480
- # inspect effective config, launch command, and running state
481
- athanor show qwen-32b
482
-
483
- # set / unset individual fields — kebab-case and camelCase both work
484
- athanor formula qwen-32b set ctx-size=32768 nGpuLayers=48
485
- athanor formula qwen-32b unset ctx-size
486
- athanor formula qwen-32b clear
487
-
488
- # apply a named formula for the model's runtime
489
- athanor formula qwen-32b apply thinking
490
-
491
- # save a model's current formula tuning as a reusable custom formula
492
- athanor formula qwen-32b save my-reasoning-formula
493
-
494
- # list built-in + user formulas and every tunable key per runtime
495
- athanor formulas
496
-
497
- # delete a custom formula from your library
498
- athanor formulas delete my-reasoning-formula
499
40
  ```
500
41
 
501
- *(Note: `athanor preset` and `athanor recipes` remain supported as backward-compatible aliases).*
502
-
503
- Built-in formulas: `balanced`, `fast`, `long-context`, `q8-kv`, `thinking`, `instruct`, `mtp`.
504
-
505
- - `balanced` — recommended default, 64K context
506
- - `fast` — lower latency, 8K context
507
- - `long-context` — 128K context for large documents (with Q8_0 KV cache on both MLX and llama.cpp)
508
- - `q8-kv` — Q8_0 KV cache quantization for reduced memory footprint across both MLX and llama.cpp
509
- - `thinking` — reasoning model sampling (temp=1.0, topP=0.95, topK=20)
510
- - `instruct` — standard instruct sampling (temp=0.7, topP=0.80, presencePenalty=1.5)
511
- - `mtp` — Multi-Token Prediction speculative decoding (requires an MTP-capable GGUF model)
512
-
513
- `balanced` is an explicit formula; clearing a formula is a separate action (`athanor formula <slug> clear`). Save your own tuning as custom named formulas via `athanor formula <slug> save <name>` or by editing `~/.athanor/formulas.json` (a plain list or `{ "formulas": [...] }`). User formulas override built-ins of the same name.
514
-
515
- Formulas survive re-scans: `athanor scan` only refreshes `path`, `sizeBytes`, and — for MLX — `mlxCapabilities`. Everything else is left alone. `athanor ls` marks tuned models with `[tuned]`.
516
-
517
- Under the hood, a formula looks like this in `~/.athanor/models.json` — you can edit it directly if you prefer:
518
-
519
- ```json
520
- {
521
- "id": "mlx-community/Qwen2.5-32B-Instruct-4bit",
522
- "slug": "qwen-32b",
523
- "formula": {
524
- "runtime": "mlx",
525
- "mlx": { "decodeConcurrency": 1, "prefillStepSize": 512, "promptCacheSize": 32768 }
526
- }
527
- }
528
- ```
529
-
530
- Restart the model for the formula to take effect.
531
-
532
- pi-agent receives the model's effective served context window from athanor's merged runtime configuration (global defaults plus any per-model formula), so pi metadata matches the actual launch settings rather than only explicit override fields.
533
-
534
- ### KV Cache Quantization & Flash Attention (llama.cpp only)
535
-
536
- Large context windows (32K–128K+) with default FP16 KV cache can consume 10–30+ GB of memory alone. On Apple Silicon unified memory, this can trigger OS paging and swap thrashing, collapsing throughput from 15+ tok/s down to single digits.
537
-
538
- Quantizing the KV cache to `q8_0` (or `q4_0`) roughly halves the KV cache memory while preserving reasoning accuracy:
539
-
540
- ```bash
541
- # Halve KV cache size with Q8_0 quantization and enable Flash Attention
542
- athanor preset qwen-27b set cache-type-k=q8_0 cache-type-v=q8_0 flash-attn=on
543
-
544
- # Or apply the built-in q8-kv recipe
545
- athanor preset qwen-27b apply q8-kv
546
- ```
42
+ *(For detailed setup options including `pipx`, dedicated virtual environments, and MLX vision dependencies, see the [Setup Guide](docs/setup.md)).*
547
43
 
548
- Available keys:
549
- - `cache-type-k` / `cacheTypeK` / `ctk` — KV cache key data type (`f16`, `q8_0`, `q4_0`, `q4_1`, `iq4_nl`, `q5_0`, `q5_1`, `bf16`, `f32`)
550
- - `cache-type-v` / `cacheTypeV` / `ctv` — KV cache value data type (`f16`, `q8_0`, `q4_0`, etc.)
551
- - `cache-ram` / `cacheRam` / `cram` — maximum prompt cache memory in MiB (`llama.cpp` defaults to 8192; 2048–4096 recommended on 36 GB Macs to avoid swap thrashing on long jobs)
552
- - `flash-attn` / `flashAttn` / `fa` — Flash Attention mode (`on`, `off`, `auto`). Required when using quantized KV cache in `llama.cpp`.
553
- - `spec-draft-type-k` / `specDraftCacheTypeK` / `ctkd` — Draft model KV cache key data type
554
- - `spec-draft-type-v` / `specDraftCacheTypeV` / `ctvd` — Draft model KV cache value data type
555
-
556
- ### Speculative Decoding & MTP (llama.cpp only)
557
-
558
- Recent builds of `llama.cpp` support speculative decoding and Multi-Token Prediction (MTP) draft decoding. This can speed up token generation by 1.5–2× on Apple Silicon.
559
-
560
- Configure these parameters on a GGUF model via a preset:
561
-
562
- ```bash
563
- # Example 1: Multi-Token Prediction (MTP) for models with built-in draft heads
564
- # (MTP draft heads are baked into the model weights, so spec-draft-model is NOT required)
565
- athanor preset deepseek-coder set spec-type=draft-mtp spec-draft-ngl=32
566
-
567
- # Example 2: Traditional speculative decoding using a separate small draft model
568
- athanor preset llama-3 set spec-type=draft spec-draft-model=~/.models/llama-3-draft.gguf spec-draft-ngl=32
569
- ```
570
-
571
- Available keys:
572
- - `spec-type` / `specType` — Speculative decoding type (`draft-mtp`, `draft`, `draft-simple`, `ngram-simple`, etc.)
573
- - `spec-draft-model` / `specDraftModel` — Path/repo/file of the separate draft model (not required for `draft-mtp`)
574
- - `spec-draft-ngl` / `specDraftNgl` / `ngl-draft` — Number of draft model GPU layers to offload to Metal (highly recommended on Apple Silicon so draft evaluation runs on GPU)
575
- - `spec-draft-n-max` / `specDraftNMax` — Max tokens to draft per step (default: 3)
576
- - `spec-draft-n-min` / `specDraftNMin` — Min tokens to draft per step
577
- - `spec-draft-p-min` / `specDraftPMin` — Min draft confidence threshold (default: 0.00)
578
- - `spec-draft-p-split` / `specDraftPSplit` — Split probability (default: 0.10)
579
-
580
- Athanor performs cross-field validation on these settings during `athanor show <slug>` and alerts you of potential issues (e.g., if you configure draft options without a `spec-type`, or if you specify a draft model for `draft-mtp` where it is ignored).
581
-
582
- ### Reasoning Effort (llama.cpp only)
583
-
584
- Models with thinking/reasoning templates (e.g. Qwen3.8-27B) consume a `reasoning_effort` parameter (`xhigh`, `medium`, `low`). Stock templates default to `xhigh`, which can lead to expensive 20+ minute generations and 20,000+ reasoning tokens.
585
-
586
- Athanor provides first-class, model-validated reasoning effort support:
587
-
588
- ```bash
589
- # Set reasoning effort via formula
590
- athanor formula qwen3.8-27b set reasoning-effort=medium
591
-
592
- # Or using aliases: reasoningEffort, reasoning_effort, effort
593
- athanor formula qwen3.8-27b set effort=low
594
- ```
595
-
596
- Features:
597
- - **Write-time validation:** Rejects invalid effort strings or attempts to configure reasoning effort on unsupported models before modifying processes.
598
- - **Enforced safe default:** When registering models whose templates default to `xhigh`, Athanor automatically sets a formula default of `medium`.
599
- - **Dynamic proxy handling:** Injects the model's formula default on chat completions when omitted by the client, validates client-supplied overrides against the model's allowed enum (returning 400 Bad Request if invalid), and strips reasoning effort for unsupported models to prevent template crashes in `llama-server`.
600
- - **TUI integration:** The Preset Editor includes a compound knob for Reasoning Effort on supported models.
601
-
602
- ### Environment variables
603
-
604
- - `ATHANOR_HOME` — overrides `~/.athanor`. Useful for running multiple profiles side by side or for tests.
605
- - `PI_HOME` — overrides `~/.pi`.
44
+ ---
606
45
 
607
- ## Finding new models
46
+ ## Quick Start
608
47
 
609
- Browse the Hub without leaving the terminal. Both commands query `https://huggingface.co/api/models` with MLX/GGUF tag filters and print a grouped, readable list. No auth is required for public models.
48
+ ### 1. Using the CLI
610
49
 
611
50
  ```bash
612
- # free-text search, both runtimes (default)
613
- athanor search qwen
51
+ # 1. Download a starter model from Hugging Face
52
+ athanor pull mlx-community/Qwen3.5-9B-MLX-4bit
614
53
 
615
- # restrict to one runtime
616
- athanor search coder --mlx
617
- athanor search llama --gguf
54
+ # 2. Start the model (binds to its stable port and activates the ingress proxy)
55
+ athanor start qwen3-5-9b-mlx-4bit
618
56
 
619
- # by author and sort key
620
- athanor search --author mlx-community --sort downloads --limit 30
621
- athanor search --author bartowski --gguf --sort likes
57
+ # 3. Expose to pi-agent
58
+ athanor expose qwen3-5-9b-mlx-4bit
622
59
 
623
- # what's hot right now (sorts by HF's trendingScore)
624
- athanor trending
625
- athanor trending --mlx --limit 15
60
+ # 4. Inspect status and generation metrics
61
+ athanor status
626
62
  ```
627
63
 
628
- Supported sorts: `downloads` (default), `likes`, `trending`, `modified`, `size`. Each row shows download count, likes, license, and a relative last-modified time.
64
+ In **pi-agent**, select provider **`athanor-mlx`** and model **`mlx-community/Qwen3.5-9B-MLX-4bit`**.
629
65
 
630
- Search is intentionally biased toward athanor's actual domain: the Hub query asks for `pipeline_tag=text-generation`, and athanor also prunes obvious non-LLM tasks client-side (ASR, TTS, feature-extraction, image-generation, etc.). The goal is to surface local text-generation candidates for MLX / llama.cpp, not to behave like a general-purpose Hugging Face browser.
66
+ ### 2. Using the Interactive TUI
631
67
 
632
- The footer hints at the follow-up:
633
-
634
- ```
635
- → athanor pull <repo> # MLX: downloads the whole repo
636
- → athanor pull <repo> --file F.gguf # GGUF: pick one file
637
- ```
638
-
639
- ## HuggingFace pull
68
+ Launch athanor without arguments to enter the TUI:
640
69
 
641
70
  ```bash
642
- athanor pull mlx-community/Qwen2.5-7B-Instruct-4bit
643
- athanor pull bartowski/Meta-Llama-3.1-8B-Instruct-GGUF \
644
- --file Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf
71
+ athanor
645
72
  ```
646
73
 
647
- What happens:
648
-
649
- 1. `GET https://huggingface.co/api/models/<repo>` is used to list siblings and decide runtime.
650
- - any `.gguf` sibling → `llama.cpp` (you must specify `--file` if more than one exists)
651
- - `tags: ["mlx"]` or `mlx` in the repo id → `mlx`
652
- - `.safetensors` only, nothing matching MLX → fallback to `mlx`
653
- 2. `hf download` is invoked, output streamed.
654
- 3. On success, a registry entry is created with `publish: true`, a fresh port from `portRange`, and `piAlias: slug`.
655
-
656
- Cancellation is safe: press `Ctrl-C` during `athanor pull` (or `Esc` in the TUI pull modal) and athanor SIGTERMs the `hf` child — escalating to SIGKILL after 3s if it ignores the signal — and exits with code 130. No registry entry is written on abort, so you can re-run the same `pull` later without cleanup.
657
-
74
+ Press `Enter` to start/stop the highlighted model, `p` to pull new models, `e` to tune parameters, or `tab` to inspect full-screen streaming logs.
658
75
 
659
- ## Control API (optional)
660
-
661
- When `controlApi.enabled` is `true`, athanor exposes a small local HTTP server (default `127.0.0.1:40878`) that other tools can drive:
662
-
663
- ```
664
- GET /status running instances + registry summary
665
- POST /activate { "id": "<id|slug>" } start a model (respects supervisor policy)
666
- POST /deactivate { "id": "<id|slug>" } stop a model
667
- ```
668
-
669
- This is off by default. Enable it only on trusted machines.
670
-
671
- ## Ingress
672
-
673
- Athanor exposes an OpenAI-compatible ingress (default `127.0.0.1:40879`) that fronts every exposed model on a single port. Pi-agent sees up to **two** providers — `athanor-mlx` and `athanor-llama` — both pointing at that ingress, each listing only models of its runtime. The split exists because pi's per-provider compat flags differ between engines (mlx_lm/vlm don't accept the `developer` role; llama-server does), and it also makes it obvious in pi's `/model` picker which backend is serving a given request. Switching models inside pi becomes a normal "different `model` field in the request body" swap, and athanor starts the target on demand (respecting supervisor policy) before proxying the request.
674
-
675
- Ingress lifecycle follows active model serving state rather than the foreground TUI. When athanor is open it ensures ingress availability; when active models remain after the UI exits, the detached ingress companion stays up; when the last model stops, the detached ingress companion stops too. This lets you start a model, close the TUI, and keep pi-agent connectivity until you stop or switch models. Reopening the TUI later reattaches to the same detached runtime/ingress state and reflects ingress-driven model switches from persisted instance state.
676
-
677
- ```
678
- GET /health 200 OK
679
- GET /v1/models synthesised list of exposed models
680
- POST /v1/chat/completions { "model": ... } activate + proxy (SSE streamed through)
681
- POST /v1/completions { "model": ... } same
682
- POST /v1/embeddings { "model": ... } same
683
- ```
684
-
685
- The ingress config lives under `router` in `~/.athanor/config.json` for backward compatibility:
686
-
687
- ```json
688
- { "router": { "enabled": true, "port": 40879, "host": "127.0.0.1", "drainTimeoutMs": 30000, "verbose": false } }
689
- ```
690
-
691
- By default, pi sync emits the ingress-backed aggregator providers (not per-model providers). If you've exposed only MLX models you'll see `athanor-mlx` alone; only GGUF, just `athanor-llama`. The `model` field in requests may be the runtime model id (HF repo for MLX; registry `author/repo:file.gguf` for hub GGUF; custom `piAlias` or slug for local llama), the athanor slug, or the canonical registry id; all resolve. Unknown models return `404`.
76
+ ---
692
77
 
693
- For users who don't want to keep the TUI open, `athanor router` runs the ingress server in the foreground and blocks on `Ctrl-C`:
78
+ ## CLI Reference
79
+
80
+ ```
81
+ athanor launch the interactive TUI
82
+ athanor scan re-scan model dirs and update registry
83
+ athanor ls list registry entries with live status
84
+ athanor status list running instances with CPU, RSS, and tok/s
85
+ athanor show <id|slug> inspect a model's config and resolved launch command
86
+ athanor snippet <id|slug> generate integration snippets (curl, OpenAI SDK, pi)
87
+ athanor start <id|slug> [-y] start a model (bypassing confirmation with -y)
88
+ athanor stop [<id|slug>|--all] stop one or all running models
89
+ athanor restart <id|slug> [-y] stop + start a model
90
+ athanor logs <id|slug> [-n N] tail last N lines of a model's log
91
+ athanor pull <repo> [--file F] download from Hugging Face and register
92
+ athanor search [q] [--mlx|--gguf] search Hugging Face Hub
93
+ athanor trending [--mlx|--gguf] view trending models on Hugging Face
94
+ athanor formula <slug> ... tune launch flags (set, unset, clear, apply, save)
95
+ athanor formulas [delete <name>] list or manage custom formulas in library
96
+ athanor flavor <slug> lm|vlm switch MLX runtime flavor (lm = text, vlm = vision)
97
+ athanor expose <id|slug> include model in pi-agent catalog
98
+ athanor hide <id|slug> remove model from pi-agent catalog
99
+ athanor rm <id|slug> remove model from registry (must be stopped)
100
+ athanor sync manually rewrite pi-agent catalog
101
+ athanor router [--port P] run the ingress server in the foreground
102
+ athanor config print resolved configuration and file paths
103
+ athanor doctor [--check-updates] verify required binaries and check for updates
104
+ athanor telemetry [<slug>|clear] view historical generation throughput and metrics
105
+ ```
106
+
107
+ `<id|slug>` accepts either the canonical repository ID or the short model slug.
694
108
 
695
- ```bash
696
- athanor router # uses config.router.host / .port
697
- athanor router --port 9000 # override
698
- athanor router --host 0.0.0.0 --port 40879
699
- athanor router --verbose # log every request to ~/.athanor/logs/router.log
700
- ```
701
-
702
- The subcommand ignores `router.enabled` — invoking it is itself the opt-in — but it still respects `127.0.0.1` as the default host.
109
+ ---
703
110
 
704
- ### Verbose request logging
111
+ ## TUI Keybindings
112
+
113
+ | Key | Action |
114
+ |---|---|
115
+ | `↑` / `↓` / Wheel | Move highlighted selection |
116
+ | `⏎` (Enter) | Start (if idle) or stop (if running) the highlighted model |
117
+ | `r` | Restart highlighted model |
118
+ | `k` | Force kill highlighted model process |
119
+ | `P` | Toggle pi-agent visibility (`expose` / `hide`) |
120
+ | `d` | Remove entry from registry (must be stopped) |
121
+ | `D` | Open Downloads modal |
122
+ | `s` | Rescan models from cache |
123
+ | `p` | Open Pull modal to download a model |
124
+ | `e` | Open Formula Editor to adjust runtime parameters |
125
+ | `t` | Open Telemetry modal |
126
+ | `/` | Filter model list by text |
127
+ | `tab` | Toggle full-screen log viewer mode |
128
+ | `q` | Quit TUI (running models remain active in background) |
705
129
 
706
- When `router.verbose` is `true` in config (or `--verbose` is passed on the command line), the ingress logs every inbound request — method, path, model field (for POST), response status, and latency in milliseconds — to `~/.athanor/logs/router.log`. This is useful for diagnosing routing, cold-start latency, and model resolution issues without needing to intercept traffic externally. Off by default to avoid noise.
130
+ ---
707
131
 
708
- Caveats:
132
+ ## Documentation Guides
709
133
 
710
- - **Cold start.** First request on an idle model blocks until the runtime is healthy (often 10–60s for large MLX). No keepalive is injected into the stream — make sure your client's timeout is generous.
711
- - **In-flight safety.** `athanor stop` on a currently-streaming model waits briefly (up to `router.drainTimeoutMs`, default 30s) for open proxied streams to finish before SIGTERM; past that, the runtime is terminated and in-flight responses are cut.
712
- - **Listen posture.** Same as the control API: `127.0.0.1` only, no auth.
134
+ Deep-dive documentation is available in the [`docs/`](docs/) directory:
713
135
 
714
- ## Troubleshooting
136
+ - 🛠️ **[Setup & Installation Guide](docs/setup.md)**: Detailed runtime installation (`uv`, `pipx`, venvs), PyTorch extras for MLX vision models, building `llama.cpp` from source, and update checking.
137
+ - 🧪 **[Formulas & Model Tuning](docs/formulas.md)**: Customizing runtime flags, built-in formulas (`balanced`, `thinking`, `fast`, etc.), Quantized KV Cache (`q8_0`), Flash Attention, Speculative Decoding / MTP, and Reasoning Effort.
138
+ - 🏛️ **[Architecture & Ingress](docs/architecture.md)**: OpenAI-compatible ingress proxy, aggregator providers for pi-agent, stable per-model port allocation, detached supervisor lifecycle, and full `config.json` reference.
139
+ - 🖥️ **[Terminal User Interface (TUI)](docs/tui.md)**: Screen layout, interactive modal dialogs (Downloads, Formulas, Telemetry), log scrolling, mouse support, and tmux dev workflow.
140
+ - 🔍 **[Troubleshooting Guide](docs/troubleshooting.md)**: Fixing port conflicts, startup timeouts, missing PyTorch for VLMs, and pi-agent catalog synchronization.
715
141
 
716
- - **`athanor start` hangs or times out.** Check `~/.athanor/logs/<slug>-<pid>.log`. Most startup failures are the runtime itself complaining (missing weights, wrong quant, out of memory). Raise `supervisor.startupTimeoutMs` for very large models.
717
- - **`port already in use`.** Another process is on the model's stable port. Either stop it, or edit the entry's `port` in `~/.athanor/models.json` and restart.
718
- - **Pi-agent can't see a new model.** Make sure it's exposed (CLI: `athanor expose <slug>`) and run `athanor sync`. Confirm `~/.pi/agent/models.json` contains the expected athanor provider shape (per-model when `router.enabled` is false, `athanor-mlx` / `athanor-llama` aggregators when true — the default), then open `/model` in pi (the file reloads on open). If you upgraded athanor and llama model ids changed, restart the model after syncing.
719
- - **Models from other tools disappeared from pi.** They shouldn't — athanor only rewrites providers whose name starts with `athanor-`. If this happens, open an issue with the before/after of `~/.pi/agent/models.json`.
720
- - **Stale PID / router state.** If a child or detached router crashed without athanor noticing, reopening athanor or running `athanor sync` / `athanor status` will reconcile persisted state and clear dead router metadata opportunistically. If a model port is still held, run `athanor stop <slug>` (a no-op when nothing is live) then `athanor start <slug>`.
721
- - **`doctor` reports a missing binary.** Install `mlx_lm`, `mlx_vlm`, `llama.cpp`, or `huggingface_hub`, or adjust your shell's `PATH`. `mlx_vlm.server` is only needed if you plan to run VLM models; `athanor start` on a VLM entry will fail with a clear error if it's missing.
722
- - **`doctor --check-updates` reports `update available`.** Follow the printed one-line hint. Today the built-in hints cover uv-managed Python tools (`uv tool upgrade mlx-lm`, `uv tool upgrade mlx-vlm`, `uv tool upgrade hf`) and Homebrew's `llama.cpp` formula (`brew upgrade llama.cpp`).
142
+ ---
723
143
 
724
144
  ## Development
725
145
 
726
146
  ```bash
727
147
  npm install
728
148
  npx tsc --noEmit # typecheck
729
- npm test # lint + vitest run (one shot)
730
- npm run test:watch # vitest (watch)
731
- npm run build # tsc -> dist/
149
+ npm test # lint + vitest test suite
150
+ npm run test:watch # vitest in watch mode
151
+ npm run build # compile typescript to dist/
152
+ npm run dev # live development loop with TUI dev watcher
732
153
  ```
733
154
 
734
- Tests redirect `ATHANOR_HOME` and `PI_HOME` to per-run temporary directories via `test/setup.ts`, so running the suite never touches your real config.
155
+ Tests run in an isolated environment by redirecting `ATHANOR_HOME` and `PI_HOME` to temporary directories via `test/setup.ts`, ensuring your local configuration is never touched.
735
156
 
736
- ### Layout
157
+ ---
737
158
 
738
- ```
739
- src/
740
- adapters/ # mlx (lm + vlm) + llama.cpp command builders, health probes, runtime model ids
741
- cli/ # hand-rolled CLI dispatcher, doctor, output formatting
742
- config/ # config file load + defaults
743
- control/ # optional HTTP control API (off by default)
744
- discovery/ # HF cache scanner + registry ingest (MLX capability detection lives here)
745
- presets/ # preset merge, tunable-key metadata, recipes
746
- pull/ # HuggingFace repo inspection and download
747
- registry/ # models.json CRUD, slug + port allocation, dedup, display labels
748
- search/ # HuggingFace Hub search + trending
749
- supervisor/ # detached process lifecycle, policy, reattach
750
- sync/ # namespaced pi-agent catalog merge
751
- ui/ # Ink TUI (list, pull modal, preset editor)
752
- types/ # shared types
753
- ```
754
159
  ## Credits and Acknowledgements
755
160
 
756
- Parts of Athanor's technical implementation, mathematical equations, and developer features were inspired by and adapted from the open-source project [whichllm](https://github.com/Andyyyy64/whichllm) under the MIT License:
757
-
758
- - **Memory Bandwidth & Hardware Profiling**: Unified memory bandwidth constants mapped from sysctl-reported chip names (`src/machine/profile.ts`).
759
- - **Context-Aware VRAM Footprint Calculations**: Context-aware VRAM footprint calculations using FP16 coefficients (3.5 MB per B-active-param per K-context-token), MoE multipliers, and dynamic activation sizes (`src/registry/recommend.ts`).
760
- - **Programmatic Search Synthesis**: Programmatically converting raw safetensors base models into realistic MLX and GGUF quantized variant search results (`src/search/hf.ts`).
761
- - **Developer Snippets Command**: The `athanor snippet` command templates for client integration (`src/cli/snippet-commands.ts`).
161
+ Parts of athanor's hardware profiling, context VRAM estimation equations, and developer features were inspired by and adapted from the open-source project [whichllm](https://github.com/Andyyyy64/whichllm) under the MIT License:
162
+ - Memory bandwidth mapping from Apple Silicon chip brand strings (`src/machine/profile.ts`).
163
+ - Context-aware VRAM calculations and MoE active parameter scaling (`src/registry/recommend.ts`).
164
+ - Search synthesis for MLX/GGUF repository variants (`src/search/hf.ts`).
165
+ - Developer integration snippet generation (`src/cli/snippet-commands.ts`).
762
166
 
763
- We thank `@Andyyyy64` and the `whichllm` contributors for their excellent research and open-source contributions.
167
+ We thank `@Andyyyy64` and the `whichllm` contributors for their excellent research.
764
168
 
765
169
  ---
766
170
 
@@ -768,4 +172,4 @@ We thank `@Andyyyy64` and the `whichllm` contributors for their excellent resear
768
172
 
769
173
  Copyright 2026 Myles Borins.
770
174
 
771
- Licensed under the Apache License, Version 2.0. See [`LICENSE`](./LICENSE) for the full text, or <http://www.apache.org/licenses/LICENSE-2.0> for the canonical copy.
175
+ Licensed under the Apache License, Version 2.0. See [`LICENSE`](./LICENSE) for details.