Development setup
This section is for working on Kaio. To run it, see Installation.
Toolchain
Section titled “Toolchain”-
Nix (recommended). A
shell.nixis provided and pins the whole toolchain:Terminal window nix-shell -
Alternatively, Rust 1.80+ and Node.js 22+.
Building from source also needs Skopeo on the host, since the update checker shells out to it. The production image already bundles it.
Workspace
Section titled “Workspace”nix-shellmake installmake install fetches the Rust dependencies (cargo fetch) and installs the
frontend packages (npm install).
Start both servers in parallel:
make dev| Process | URL | Serves |
|---|---|---|
| Backend | http://127.0.0.1:8080 |
REST API, SSE streams, WebSocket shells |
| Frontend | http://127.0.0.1:5173 |
Vite dev server with HMR |
make dev runs cargo fmt first and points the backend at
sqlite:../data/kaio.db, so the dev database lives in data/ at the
repository root.
Develop against 5173, not 8080. Both ports serve the dashboard, but 5173 is Vite
with hot reload, while 8080 serves the copy compiled into kaio-server, which is
whatever npm run build last produced. On a checkout where the frontend has
never been built, 8080 serves a placeholder page and says so in its log.
Where code goes
Section titled “Where code goes”kaio-core holds every rule: what a stack is, what state it is in, what needs
attention, who may act on it, what gets written to the audit log. The HTTP
server, the MCP endpoint, the CLI, the TUI and the web dashboard are clients of
it and hold only what is theirs: reading a request, drawing a table, binding a
key. A rule written in a client is a rule the other clients miss.
kaio-core depends on no web framework. A request reaches it as plain facts,
its headers in kaio_core::request::Headers, and an error leaves it as an
AppError with a stable code(); kaio-server alone turns that into an HTTP
status and body, in server/src/error.rs. Outgoing calls to other nodes and
registries still go through reqwest inside kaio-core, the one piece of
transport left there.
Inside a module of kaio-core, stacks/ for one, the rules that need no disk,
database or Docker sit in rules.rs and are tested on their own; store.rs,
files.rs and compose.rs hold SQLite, the stack directory and docker compose, visible to kaio-core alone; mod.rs holds the use cases the clients
call, each of which checks what it must once, then acts.
The web dashboard reads the same models as the Rust clients: their TypeScript
types are generated from kaio-core into frontend/src/lib/generated/ by
make types, behind the ts feature of kaio-core, and are not edited by
hand. make verify and CI regenerate them and fail when the committed ones
differ.
Make targets
Section titled “Make targets”| Target | What it does |
|---|---|
make server |
Backend only |
make tui |
Launch the TUI against a running server |
make cli ARGS="stack ls" |
Run one CLI command |
make types |
Regenerate the TypeScript types of the API in frontend/src/lib/generated/ from the Rust models |
make verify |
fmt --check + clippy -D warnings + cargo test + tsc --noEmit |
make dist |
The release tarball for this host’s architecture, under dist/ |
make docs-dev |
Documentation site with live reload on http://localhost:4321/ |
make docs-check |
Reference pages checked against the Rust sources, then a full site build |
make verify is the gate to run before pushing; it mirrors what CI checks.
Documentation
Section titled “Documentation”The site lives in docs/, built with Astro and Starlight. make docs-check
runs docs/scripts/check-docs.py, which compares the CLI commands, HTTP routes,
environment variables, TUI keys and database tables documented here against the
Rust sources, then builds the site. CI runs the same check on every pull request
touching the documentation.
Related
Section titled “Related”Kaio, built by Régis Gaidot