athanor 3.4.0 → 3.6.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/AGENTS.md +22 -14
- package/README.md +112 -711
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/discovery/scanner.d.ts +14 -2
- package/dist/discovery/scanner.d.ts.map +1 -1
- package/dist/discovery/scanner.js +185 -4
- package/dist/discovery/scanner.js.map +1 -1
- package/dist/registry/materialize.d.ts +3 -0
- package/dist/registry/materialize.d.ts.map +1 -1
- package/dist/registry/materialize.js +17 -2
- package/dist/registry/materialize.js.map +1 -1
- package/dist/registry/recommend.d.ts +12 -0
- package/dist/registry/recommend.d.ts.map +1 -1
- package/dist/registry/recommend.js +74 -21
- package/dist/registry/recommend.js.map +1 -1
- package/dist/supervisor/index.d.ts +15 -1
- package/dist/supervisor/index.d.ts.map +1 -1
- package/dist/supervisor/index.js +36 -3
- package/dist/supervisor/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +3 -12
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/ConfirmModal.d.ts.map +1 -1
- package/dist/ui/ConfirmModal.js +4 -5
- package/dist/ui/ConfirmModal.js.map +1 -1
- package/dist/ui/SearchBrowser.d.ts.map +1 -1
- package/dist/ui/SearchBrowser.js +3 -12
- package/dist/ui/SearchBrowser.js.map +1 -1
- package/dist/ui/useMouseWheel.d.ts +2 -2
- package/dist/ui/useMouseWheel.d.ts.map +1 -1
- package/package.json +7 -4
- package/dist/cli/commands.d.ts +0 -8
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -7
- package/dist/cli/commands.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -10,9 +10,9 @@ Not a library. Not a daemon. No network listeners except the runtime children th
|
|
|
10
10
|
|
|
11
11
|
## Invariants
|
|
12
12
|
|
|
13
|
-
These are
|
|
13
|
+
These invariants are mandatory. Do not change them without an explicit user decision.
|
|
14
14
|
|
|
15
|
-
1. **Stable port per model.** Ports are allocated on first discovery from `config.portRange` and persisted on the registry entry
|
|
15
|
+
1. **Stable port per model.** Ports are allocated on first discovery from `config.portRange` and persisted on the registry entry. A model's port does not change after allocation; pi-agent provider URLs must remain stable across restarts.
|
|
16
16
|
2. **Atomic registry writes.** `~/.athanor/models.json` is always written via temp-file + rename in `src/registry/index.ts`. Never partial-write it, never keep it open across awaits.
|
|
17
17
|
3. **Preserve non-athanor pi entries.** `src/sync/pi.ts` rewrites only providers whose name starts with `athanor-`. Everything else in `~/.pi/agent/models.json` (OpenAI, Anthropic, Ollama, OpenRouter, user customs) must round-trip untouched. Same for `~/.pi/agent/settings.json` — only `defaultProvider` / `defaultModel` are touched, and only when a model is started as the active default.
|
|
18
18
|
4. **Pi sync shape follows `config.router.enabled`.** Default (`router.enabled: true`): up to two aggregator providers — `athanor-mlx` and `athanor-llama` — both pointing at the ingress `baseUrl`, each listing only models of its runtime and carrying runtime-specific compat flags (MLX sets `supportsDeveloperRole: false`; llama-server doesn't). Providers with zero exposed members are suppressed. When `router.enabled` is false: each exposed model becomes its own pi provider `athanor-<runtime>-<slug>` with one `baseUrl` per model. Never emit both shapes. The CLI verbs are `expose` / `hide`; the underlying registry field is `publish: boolean` (storage name, kept stable for backward-compat of on-disk `models.json`).
|
|
@@ -20,9 +20,9 @@ These are load-bearing. If a change seems to need to break one, stop and ask.
|
|
|
20
20
|
6. **Pi context metadata reflects effective served context.** `src/sync/pi.ts` must advertise the model's effective runtime context window from merged runtime config (`mergedConfigFor(entry)`), not only explicit per-model formula fields and not the model's theoretical maximum. pi should see what athanor will actually serve.
|
|
21
21
|
7. **MLX capability detection and flavor routing are separate axes.** Two fields live on an MLX entry:
|
|
22
22
|
- `mlxCapabilities: ("vlm")[]` — a detected *fact* about the model (does config.json advertise a vision tower?). Refreshed by `ingestDiscovered` and `pull` via `detectMlxCapabilities()` in `src/discovery/scanner.ts`. Safe to overwrite on re-scan.
|
|
23
|
-
- `mlxFlavor: "lm" | "vlm"` — user *intent* about which server binary to launch. `"vlm"` routes to `mlx_vlm.server`; `"lm"` (or absent) routes to `mlx_lm.server`. Only set by `athanor flavor <slug> lm|vlm` (`cmdFlavor` in `src/cli/commands.ts`). Discovery and ingest must never touch it.
|
|
23
|
+
- `mlxFlavor: "lm" | "vlm"` — user *intent* about which server binary to launch. `"vlm"` routes to `mlx_vlm.server`; `"lm"` (or absent) routes to `mlx_lm.server`. Only set by `athanor flavor <slug> lm|vlm` (`cmdFlavor` in `src/cli/model-commands.ts`). Discovery and ingest must never touch it.
|
|
24
24
|
|
|
25
|
-
Detection is advisory because many VLM-tagged repos run fine as text-only under `mlx_lm.server` with no torch/torchvision installed, and that's usually the preferred path. `cmdShow` surfaces the capability with a hint that points at `athanor flavor`. Do not add VLM detection anywhere other than `detectMlxCapabilities`; keep it
|
|
25
|
+
Detection is advisory because many VLM-tagged repos run fine as text-only under `mlx_lm.server` with no torch/torchvision installed, and that's usually the preferred path. `cmdShow` surfaces the capability with a hint that points at `athanor flavor`. Do not add VLM detection anywhere other than `detectMlxCapabilities`; keep it the sole detection function.
|
|
26
26
|
8. **Supervisor default policy is `single-active`.** Starting model B stops model A unless the user opts into `multi-active-lru` (or `manual`) in `config.json`. Policies live in `src/supervisor/policies.ts`.
|
|
27
27
|
9. **Formulas are additive, scans are non-destructive.** `athanor scan` refreshes `path`, `sizeBytes`, and `mlxCapabilities`. `formula`, `publish`, `piAlias`, `tags`, `port`, `slug`, and `mlxFlavor` must survive re-scans. Built-in formulas are explicit; `balanced` is not shorthand for clearing a formula, and `formula clear` is the separate remove action.
|
|
28
28
|
10. **All mutations go through helpers.** Use `setFormulaFields` / `unsetFormulaFields` from `src/presets/edit.ts`, `formulaToRuntime` from `src/presets/recipes.ts`, and `updateModel` / `setModelFormula` from `src/registry/index.ts`. Do not hand-edit registry objects in commands or UI components.
|
|
@@ -30,12 +30,15 @@ These are load-bearing. If a change seems to need to break one, stop and ask.
|
|
|
30
30
|
## Layout
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
+
docs/ # deep-dive user guides: setup, formulas, architecture, tui, troubleshooting
|
|
33
34
|
src/
|
|
34
35
|
adapters/ # mlx_lm + mlx_vlm + llama-server command builders, health probes, runtime model ids (model-id.ts)
|
|
35
|
-
|
|
36
|
+
app/ # application orchestration (model operations, preflight, sync side-effects)
|
|
37
|
+
cli/ # dispatcher (index.ts), command modules, doctor, formatting
|
|
36
38
|
config/ # config load + defaults
|
|
37
39
|
control/ # optional HTTP control API (opt-in)
|
|
38
40
|
discovery/ # HF cache scanner + ingest + fs.watch watcher; detectMlxCapabilities lives here
|
|
41
|
+
machine/ # Apple Silicon hardware profiling, bandwidth constants, memory estimation
|
|
39
42
|
presets/ # formula merge, tunable-key metadata, built-in + user formulas engine
|
|
40
43
|
pull/ # HF repo inspection + `hf` download wrapper
|
|
41
44
|
registry/ # atomic models.json CRUD, slug + port allocation, dedup on load, display labels
|
|
@@ -63,9 +66,12 @@ Context discipline:
|
|
|
63
66
|
- avoid re-reading the entire repository unless the task is cross-cutting, the map is stale, or the user asks for a fresh architectural review
|
|
64
67
|
- prefer incremental context: changed files, directly related modules, and affected invariants
|
|
65
68
|
- after meaningful architectural refactors, update the relevant file(s) under `context/`
|
|
69
|
+
- when completing a task tracked in `context/plans/`, move the plan into `context/plans/done/`, update its status to `Completed`, and update the remaining backlog in `context/ARCH_REVIEW.md`
|
|
66
70
|
|
|
67
71
|
## Development
|
|
68
72
|
|
|
73
|
+
Requires Node.js ≥ 22 on Apple Silicon (macOS 13.5+).
|
|
74
|
+
|
|
69
75
|
```bash
|
|
70
76
|
npm install
|
|
71
77
|
npx tsc --noEmit # typecheck — must be clean
|
|
@@ -82,6 +88,7 @@ Before sending a change:
|
|
|
82
88
|
2. `npm test` green.
|
|
83
89
|
3. If you added a new command or TUI key, update `README.md` (CLI reference / TUI bindings tables) in the same change.
|
|
84
90
|
4. If you touched an invariant above, flag it explicitly in the PR description.
|
|
91
|
+
5. If completing a planned task, ensure the plan is moved to `context/plans/done/` and `context/ARCH_REVIEW.md` is updated.
|
|
85
92
|
|
|
86
93
|
## Onboarding a user
|
|
87
94
|
|
|
@@ -89,7 +96,7 @@ When a user opens this repo with an agent and asks to "set up athanor", work in
|
|
|
89
96
|
|
|
90
97
|
### CLI install modes
|
|
91
98
|
|
|
92
|
-
`bin/athanor` resolves `../
|
|
99
|
+
`bin/athanor` resolves `../dist/index.js` (the compiled entry), so the binary only works after a build. Pick one:
|
|
93
100
|
|
|
94
101
|
| Mode | Setup | Invocation |
|
|
95
102
|
|---|---|---|
|
|
@@ -101,10 +108,10 @@ Linked mode does not auto-rebuild. Re-run `npm run build` after pulling changes
|
|
|
101
108
|
|
|
102
109
|
### External binaries
|
|
103
110
|
|
|
104
|
-
Run `athanor doctor` first — it prints presence, installed versions, and paths for each dependency
|
|
111
|
+
Run `athanor doctor` first — it prints presence, installed versions, and paths for each dependency. When you specifically need to check staleness, run `athanor doctor --check-updates` as well:
|
|
105
112
|
|
|
106
113
|
- `mlx_lm.server` — required for MLX text models. `uv tool install mlx-lm` (or `pipx install mlx-lm`).
|
|
107
|
-
- `mlx_vlm.server` — optional, for vision MLX models. `uv tool install mlx-vlm --with torch --with torchvision`. The torch/torchvision extras are
|
|
114
|
+
- `mlx_vlm.server` — optional, for vision MLX models. `uv tool install mlx-vlm --with torch --with torchvision`. The torch/torchvision extras are required: `mlx-vlm` itself doesn't depend on them, but the `transformers` VLM processors it imports do, so installing `mlx-vlm` alone passes `athanor doctor` and then fails at request time with `Qwen3VLVideoProcessor requires the PyTorch library but it was not found in your environment`. Equivalent forms: `pipx install mlx-vlm && pipx inject mlx-vlm torch torchvision`, or `pip install -U mlx-vlm torch torchvision` in an active venv.
|
|
108
115
|
- `llama-server` — optional, for GGUF models. `brew install llama.cpp` or build from source.
|
|
109
116
|
- `hf` — required for `athanor pull`. `uv tool install huggingface_hub --with hf_transfer` (or `pip install -U huggingface_hub[cli]`).
|
|
110
117
|
|
|
@@ -138,7 +145,7 @@ Quantization reading:
|
|
|
138
145
|
- **MLX:** prefer `mlx-community/*` — they carry the right conversion manifest. Suffix `-4bit` is the default; `-6bit` / `-8bit` cost ~1.5×/2× disk and memory for modest quality gains; `-bf16` is rarely worth it for serving on a Mac.
|
|
139
146
|
- **GGUF:** `Q4_K_M` is the balanced default, `Q5_K_M` / `Q6_K` trade size for quality, `Q8_0` is near-lossless but large. Avoid `Q2_*` and `Q3_*` except on tight memory.
|
|
140
147
|
|
|
141
|
-
After pull, `athanor show <slug>` shows detected capabilities, resolved launch command, and merged preset. For MLX entries where `caps` includes `vlm`, only flip `athanor flavor <slug> vlm` if the user actually needs image input — most VLM repos serve text fine under `mlx_lm.server` without the torch install (see invariant #
|
|
148
|
+
After pull, `athanor show <slug>` shows detected capabilities, resolved launch command, and merged preset. For MLX entries where `caps` includes `vlm`, only flip `athanor flavor <slug> vlm` if the user actually needs image input — most VLM repos serve text fine under `mlx_lm.server` without the torch install (see invariant #7).
|
|
142
149
|
|
|
143
150
|
### Running a model
|
|
144
151
|
|
|
@@ -163,7 +170,7 @@ To make a running model available to `pi-agent` downstream, `athanor expose <slu
|
|
|
163
170
|
## How to add things
|
|
164
171
|
|
|
165
172
|
- **New adapter (runtime).** Add a file in `src/adapters/`, export `buildCommand(entry, config): { cmd, args }` and a health probe. Register it in `src/adapters/index.ts`. Add a fixture to `__fixtures.ts` and a test alongside.
|
|
166
|
-
- **New CLI command.** Implement it in the relevant CLI module (`src/cli/model-commands.ts`, `preset-commands.ts`, `system-commands.ts`, or a new focused module),
|
|
173
|
+
- **New CLI command.** Implement it in the relevant CLI module (`src/cli/model-commands.ts`, `preset-commands.ts`, `system-commands.ts`, or a new focused module), and wire it in `src/cli/index.ts`'s dispatcher. Keep output going through `src/cli/format.ts` / `style.ts` so colors respect `NO_COLOR`.
|
|
167
174
|
- **New TUI key.** Bind it in `src/ui/App.tsx`'s `useInput` handler and document it in the footer string and the README key table.
|
|
168
175
|
- **New registry field.** Add it to `ModelEntry` in `src/types/index.ts`, teach `ingestDiscovered` how to populate/refresh it, add a migration-safe default (optional field, never required of older entries), and surface it in `athanor show` if user-relevant.
|
|
169
176
|
- **New tunable runtime flag.** Add to `TUNABLE_KEYS` in `src/presets/edit.ts` with both kebab-case CLI name and camelCase JSON name, then reference it in the relevant adapter's `buildCommand`.
|
|
@@ -173,8 +180,9 @@ To make a running model available to `pi-agent` downstream, `athanor expose <slu
|
|
|
173
180
|
| Path | Purpose |
|
|
174
181
|
|---|---|
|
|
175
182
|
| `~/.athanor/config.json` | user config: scan roots, port range, supervisor policy, control API |
|
|
176
|
-
| `~/.athanor/models.json` | registry —
|
|
183
|
+
| `~/.athanor/models.json` | registry — storage for slugs, ports, formulas, publish state |
|
|
177
184
|
| `~/.athanor/formulas.json` | optional user formulas; overrides built-ins of the same name (with auto-migration from legacy `recipes.json`) |
|
|
185
|
+
| `~/.athanor/telemetry.json` | persistent generation telemetry history (tok/s, prompt eval, latency) |
|
|
178
186
|
| `~/.athanor/logs/<slug>-<pid>.log` | per-run supervisor log |
|
|
179
187
|
| `~/.athanor/state.json` | running PIDs / ports for reattach (see `src/supervisor/state.ts`) |
|
|
180
188
|
| `~/.pi/agent/models.json` | pi-agent providers; athanor namespace only |
|
|
@@ -185,15 +193,15 @@ To make a running model available to `pi-agent` downstream, `athanor expose <slu
|
|
|
185
193
|
|
|
186
194
|
- TypeScript strict; no `any` unless unavoidable. Prefer `unknown` at boundaries and narrow.
|
|
187
195
|
- Functions named after what they do, not how. Side-effecting helpers end in verbs (`ingestDiscovered`, `updateModel`, `syncPi`).
|
|
188
|
-
-
|
|
196
|
+
- Keep comments concise. Do not annotate obvious code or explain the rationale for a change inside a comment — that belongs in the PR.
|
|
189
197
|
- No new files unless necessary. Prefer editing an existing module. Especially: do not create new top-level docs (`*.md`) without being asked.
|
|
190
|
-
-
|
|
198
|
+
- Format command output clearly. Tables go through `format.ts`. Errors exit non-zero with a one-line message plus, when useful, a hint on the next line.
|
|
191
199
|
|
|
192
200
|
## Roadmap
|
|
193
201
|
|
|
194
202
|
### Router — completed capabilities
|
|
195
203
|
|
|
196
|
-
The router in `src/router/server.ts` is live (see invariant #4 and
|
|
204
|
+
The router in `src/router/server.ts` is live (see invariant #4, `README.md`, and `docs/architecture.md`). Headless mode (`athanor router` subcommand), in-flight stream safety (`src/supervisor/inflight.ts` + `supervisor.stop()` drain before SIGTERM, bounded by `config.router.drainTimeoutMs`), and live token accounting via passthrough Transform (`SSETokenCounter` feeding `src/supervisor/metrics.ts` `updateLiveRouterStats` and consumed by CLI/TUI) are all complete.
|
|
197
205
|
|
|
198
206
|
## License
|
|
199
207
|
|