Project memory #
This repository keeps durable project knowledge in machine-memory, in a remote database shared by every checkout. Every database command takes --remote. machine-memory help workflow explains each step below in full.
- Before changing code, scan once and read the records that bear on the task:
machine-memory suggest --files "a.ts,b.ts" --remote --json-minfor known files, ormachine-memory query "<topic>" --hybrid --remote --json-minfor a topic or a task that touches no files; thenmachine-memory get <id,id> --remote. Results are candidates: judge them bymatch_strength, and "nothing relevant" is a valid outcome. - When the user's instruction contradicts a stored record, follow the user and update the record.
- Write one fact per record, start it with the command, path or identifier it is about, and name its sources in
--refs(stalechecks them). Store decisions, constraints, preferences, references and gotchas. Put delivery state in onestatusrecord with--expires-after-days. Leave out pixel values, UI state and deploy outcomes, and put facts about one machine in that machine's guidance file. - Check size before writing:
machine-memory size "<text>", or--dry-runonaddandupdate. - Change a record with
machine-memory update <id> "<whole new content>" --remote. It replaces the content, so read the record first and keep the details that still hold. Leave the content out to change only tags, type or certainty. Create one withmachine-memory add "<content>" --upsert-match "<topic>" --type <type> --remote, which updates a strong match instead of adding a duplicate. - When a write reports
droppedorreview_candidates(also on stderr, in amachine-memory:line), restore details dropped by mistake, and update or deprecate the listed records that rely on what you changed. --certainty verifiedrequires--evidence:user_requirement,observed_implementation,verified_mechanismortested_behavior. Reading the code proves onlyobserved_implementation.- When delegating, scan once and pass the record ids to child agents. Children return findings with their evidence; the parent writes them.
- Before the final response, run
machine-memory checkpoint --remote --json-min, then add, update or deprecate records for what the task established.
Project preference: replace obsolete systems when practical; preserve backwards compatibility only when it is explicitly required.
Build and test #
Rust workspace: crates/core (the memory engine), crates/cli (the clanka binary and the code host plugins share), crates/protocol (the messages of clanka rpc), crates/app (the macOS app, on Rune; see below), crates/py (Python bindings for the Hermes plugin in hermes/clanka).
- Format:
cargo fmt --all - Lint:
cargo clippy --workspace --exclude clanka-app --all-targets -- -D warnings - Test:
cargo test --workspace --exclude clanka-app(no model provider, keyring, Hermes or network needed) - The app, on macOS:
cargo clippy -p clanka-app --all-targets -- -D warningsandcargo test -p clanka-app - Build the CLI:
cargo build -p clanka(target/debug/clanka) - On Windows (
x86_64-pc-windows-msvc): Visual Studio Build Tools with the C++ workload, a Perl that OpenSSL's Configure accepts (Strawberry Perl works) and NASM onPATH(Strawberry Perl ships one inc\bin; without it the vendored OpenSSL builds with no assembly and CI's jobs fail). Run cargo in PowerShell, never Git Bash: thereperlis MSYS's, and a clean build of the vendored OpenSSL fails inConfigure(Can't locate Locale/Maketext/Simple.pm).crates/pyneeds a Python 3.11 or newer;PYO3_PYTHONnames it whenpythonis not onPATH. The same three commands are the gate there, with nothing ignored.bun run checkcannot pass on Windows (oxlint reads ts-standard's plugin path as/C:/..., and ts-standard comparestsconfigpaths with a backslash), so its parts run separately there and CI'scheckjob is the real gate.bun run --cwd docs buildthere skips the search index (spawn pagefind.cmd ENOENT) and still exits 0.
CI (.github/workflows/ci.yml) runs on pushes to main and stable and on pull requests into them, and on no other branch push: first the advisory check (.github/workflows/advisories.yml, cargo deny check advisories against Cargo.lock), then the format check, lint and tests on Linux (rust, every crate but the app), the same lint and tests on Windows (windows) and on macOS (macos), and the app's build, lint and headless tests on macOS (app), all skipped when the advisory check fails. Rune's crates are in Cargo.lock, so the advisory check covers them. An advisory with no fix yet needs an ignore entry in deny.toml before anything else is checked.
To run the CLI without touching real companions or the keyring, point it at a throwaway directory whose config.toml holds [keys] and store = "file". On every platform CLANKA_HOME=<dir> puts config in <dir>/config and data in <dir>/data, so the file is <dir>/config/config.toml; this is the way on Windows, where the files otherwise live in %LOCALAPPDATA%\clanka:
$env:CLANKA_HOME = '<dir>'; .\target\debug\clanka.exe ...
Without it:
On Linux the file is <dir>/config/clanka/config.toml:
env XDG_CONFIG_HOME=<dir>/config XDG_DATA_HOME=<dir>/data DBUS_SESSION_BUS_ADDRESS=unix:path=/nonexistent ./target/debug/clanka ...
On macOS config and data both live in $HOME/Library/Application Support/clanka, so the file is <dir>/Library/Application Support/clanka/config.toml:
env HOME=<dir> ./target/debug/clanka ...
Releases #
The version is [workspace.package] version in Cargo.toml, which every crate inherits, and version in hermes/clanka/plugin.yaml; a test fails when the two differ. To release, bump both (semver: a schema change or a breaking CLI change is at least a minor bump while below 1.0) and land the bump on main; open a pull request from main into stable and merge it with a merge commit; then tag and push v<version> on a commit that is on stable, such as the main commit that pull request merged. .github/workflows/release.yml refuses a tag whose commit is not on stable (re-run it after the merge if the tag went first), checks the tag against both files, builds x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, aarch64-apple-darwin and x86_64-pc-windows-msvc (no Intel macOS: ort has no prebuilt ONNX Runtime for it), and publishes clanka-<target>.tar.gz (the CLI, hermes/clanka/ with _clanka.abi3.so, _clanka.pyd on Windows, skills/soul-writer/SKILL.md, and on macOS Clanka.app from crates/app/bundle.sh, ad hoc signed, holding the app and its own clanka) and SHA256SUMS. hermes/install.sh installs Clanka.app into ~/Applications; clanka upgrade replaces it only where it is installed. hermes/install.sh, hermes/install.ps1 (Windows) and clanka upgrade (crates/cli/src/upgrade.rs) install the latest release only after its archive matches SHA256SUMS, so keep the archive names and layout in step across the four. The Windows build runs in PowerShell and fails without NASM on PATH, since without it the vendored OpenSSL would build with no assembly. The docs site serves hermes/install.sh at clanka.jfa.dev/install.sh and hermes/install.ps1 at clanka.jfa.dev/install.ps1 (docs/src/pages/install.sh.ts, install.ps1.ts); a push to main that changes either redeploys the site, since the Workers Builds trigger does not exclude them. Tag only when asked.
A schema change is a new file in crates/core/src/migrations/, added to MIGRATIONS in crates/core/src/db.rs; never edit a migration that has shipped.
Docs site #
docs/ is the Nimbus (Astro) documentation site for clanka.jfa.dev and iac/alchemy.run.ts is the Alchemy stack that deploys it. The stack holds four Workers: the docs (clanka-docs, a Cloudflare.Website.StaticSite that runs bun run build in docs/), the diagnostics endpoint (clanka-ingest, ingest/, an Effect program over a D1 database), the telemetry console (clanka-admin, admin/, a Cloudflare.Website.Foldkit page with a Worker that reads the same D1 database through an Effect HttpApi and never writes to it) and the router (clanka-router, router/, Hono), which has the custom domain, sends /ingest to the endpoint with the prefix stripped, /admin to the console with its prefix kept and everything else to the docs. Only the router has a hostname; it reaches the other three over service bindings. A Cloudflare Access application guards clanka.jfa.dev/admin, and the console's Worker also verifies each request's Cf-Access-Jwt-Assertion against that application's team and audience (the deploy config's access, passed to the Worker as ACCESS_TEAM_DOMAIN and ACCESS_AUD), refusing everything without them. The console's components are foldcn copies (admin/components.json, bunx shadcn@4.23.0 add @foldcn/<name>) restyled with jfa.dev's branding tokens, which admin/src/styles.css copies from jfa.dev's common/src/styles.css. Which of them a deployment has, and its hostname and Access application, come from a deploy config (iac/src/deploy-config.ts, iac/README.md): clanka.jfa.dev's (everything) is not in the repository: the package scripts take it from CLANKA_DEPLOY_CONFIG, a build variable of the Workers Builds trigger holding the JSON, else from the gitignored iac/clanka.production.deploy.json, and anyone else deploys with their own gitignored iac/clanka.deploy.json, or none for the endpoint alone on workers.dev. Keep that working: a part that needs a value only clanka.jfa.dev has goes in the deploy config, not in the stack. Every deploy of the stack deploys all the parts it has. A schema change to the endpoint is a new file in ingest/migrations/; A sender makes its own token with clanka diagnostics token --new and gives you the hash it prints; let it in with INSERT INTO tokens (hash, label, created_at) VALUES ('<hash>', '<label>', unixepoch() * 1000) on the clanka-diagnostics D1 database, and revoke it with UPDATE tokens SET revoked_at = unixepoch() * 1000 WHERE label = '<label>'. They form a Bun workspace (root package.json) that the Rust build does not use. docs/AGENT.md covers authoring.
- Install:
bun install(repo root); itspreparepatches tsrs and oxlint with the Effect builds. - Check:
bun run check(repo root) is the one read-only gate:lint,format:check,typecheckandtestin every workspace, thenoxfmt --checkon the root's files.bun run fixis the one command that rewrites files. Every package has the same verbs; reach one with--cwd, as inbun run --cwd router test.STANDARD.mdlists the exceptions to them. - Typecheck is
effect-tsgo tsrs --noEmit, with the Effect diagnostics turned on by the plugin entry intsconfig.base.json; docs usesastro check. Tests are vitest; the endpoint's and the console's tests run onnode:sqlitewith the real migrations. bun run --cwd docs buildvalidates the sidebar and producesdocs/dist/pagefind/;checkdoes not build. It also rewrites the tracked files indocs/.nimbus/, andnimbus-docs lint(check) checks internal links againstroutes.jsonthere: commit them with any change to a page or the sidebar, and drop a diff that only movesbuiltAt.- Work on the console:
bun run --cwd admin devserves the page alone; its API needs a Worker with a D1 binding and an Access token - Plan:
bun run plan(read-only); deploy:bun run deploy. Deploy only when asked. - CI:
.github/workflows/ci.ymlruns on pushes tomainandstableand on pull requests into them; a push to any other branch runs it only through its pull request. Those triggers differ from the standard's reference, which an exception forworkflows/ci-referenceinstandard.config.tsallows; it excuses any other difference ofci.ymlfrom the reference too, so check a change toci.ymlagainstnode_modules/@jfalava/ts-standard/reference/ci.ymlby eye.STANDARD.mdlists every exception; change it withstandard.config.ts. Itschangesjob (dorny/paths-filter, the same in every repo of the standard) setscodeandrust;check(bun run check) runs unlesscodeisfalse, andadvisories,rust,windows,appandmacosunlessrustisfalse.windows(windows-2025) runs its cargo steps in the runner's PowerShell, not Git Bash, because under Git Bashperlis MSYS's, which fails the vendored OpenSSL's Configure, and it fails unless NASM is onPATH(its step prints where it found it); it has no-D warningsinRUSTFLAGS, which would fail on the linker's LNK4099 for the vendored OpenSSL.app,macos(the workspace's lint and tests but the app, whose tests keep keys in files under temporary directories and so reach no keychain), andrelease.yml's macOS build, run on the owner's Mac (self-hosted runnerclanka-mac, as jfalava, in~/actions-runner/clankawith its ownCARGO_HOME) when themacjob finds it online with theRUNNERS_TOKENsecret, else onmacos-15; that Mac has no rustup, so "Install Rust" checks its Nix Rust isrust-versioninstead, and the repo requires approval for every external contributor's pull request because a fork could aim a workflow at the Mac. Therustfilter's comment in the workflow says what it holds; keep it in step with what cargo reads, and the README's Development section with the jobs. Themainruleset requirescheckandrust; thestableruleset requirescheck,rust,windowsandmacos. Both refuse deletion and force pushes, and the admin role bypasses both. Cloudflare Workers Builds on theclanka-routerWorker only deploys: a push tomainrunsbun run ci:build(bun run checkagain) and thenbun run ci:deploy, which deploys the whole stack, unless every file the push changes matches one of the trigger's excluded build watch paths (it includes*and excludes what neither the site nor the stack reads, such ascrates/*and.github/*); a push of 20 or more commits, or 3000 or more changed files, always builds. The excludes are kept only in the trigger's settings in Cloudflare, not in this repository.hermes/install.shandhermes/install.ps1are not excluded, because the docs serve them.plan,deploy,ci:deployanddestroypass--stage live_jfalava, the stage the stack was first deployed from, so builds and local runs share one state whateverALCHEMY_STAGEorUSERsay.
The CLI pages under docs/src/content/docs/cli/ mirror clanka help <command>, and configuration.mdx mirrors the defaults in crates/core. Update them with the command or setting they describe.
The App pages' screenshots (docs/public/app/) come in pairs, <name>.png dark and <name>-light.png light, and docs/src/lib/themed-screenshots.ts (a hast plugin in docs/astro.config.ts) shows the one that matches the site's theme. Take them all with cargo build -p clanka-app && bun run --cwd docs screenshots (docs/scripts/app-screenshots.ts lists each file's scene and size), after a UI change and after a version bump, since home.png shows the version.
The Licenses page (docs/src/content/docs/licenses.mdx) lists every direct dependency of the Rust and Bun workspaces from docs/src/lib/licenses.ts. After adding, removing or upgrading a dependency, regenerate it with bun run --cwd docs licenses (it needs cargo, installed packages and network); bun run --cwd docs licenses:check fails when it is stale. It is not part of check, so neither CI nor Workers Builds runs it: the Workers Build has no cargo, and a check must not need the network.
The app and clanka rpc #
crates/app (clanka-app) is the macOS app, on Rune with rune-kit's components, branded by jfalava-ui-rune (jfalava/ui's rune/, a git dependency at a commit): its kit(dark) in place of Kit::neutral, its fonts in spec(), and its UpdateBadge, Callout, Mark and code, which view/parts.rs builds on. The plan, with the owner's decisions and the order of the releases, is machine-memory records #3720 and #3721. It never opens a database or the keychain: it starts clanka rpc (crates/cli/src/rpc/), as a child for this Mac and as ssh <target> clanka rpc for another machine, and talks JSON-RPC 2.0 over its stdio. crates/protocol declares every method, its parameters and its answer, and PROTOCOL, which the app compares on connect: raise it with any change to a method. docs/src/content/docs/cli/rpc.mdx describes both; update it with them.
- Each action is one function in
crates/cli/src/actions.rsreturning the protocol's types; the command prints it and the rpc method sends it. The core's types reach the protocol's through JSON, and the protocol's refuse unknown fields, so a field added to one and not the other fails the rpc tests (crates/cli/src/rpc/tests.rs). every_command_is_in_the_app_or_says_why_notincrates/cli/src/main.rsfails when a CLI subcommand has no rpc method and is in neitherCLI_ONLY(chat, mcp, debug, eval, diagnostics, rpc, anddoctor delete-all) norLATER, the commands a later release brings to the app. A release moves its commands fromLATERtoIN_THE_APPwith their methods.- Repairs: the app's doctor switch, off at launch and per companion, replaces
clanka web --doctor. Nothing freezes on its own; a delete or a rollback shows the core's own plan (doctor.delete_plan,doctor.rollback_plan) and asks first, a rollback needs the companion's name typed, anddelete-allstays a command the app only prints. - Rune is pinned to a rev of its
devbranch incrates/app/Cargo.toml, and its[patch.crates-io]list is repeated at the same rev in the rootCargo.toml; bump both together, copying the list from that rev'sCargo.toml, and check thatcargo build -p clanka-appsays no patch went unused.jfalava-ui-runedeclares Rune itself, without re-exporting it, so its rev must be the same: bump Rune in jfalava/ui first, then move both revs here. At two revs Cargo builds two Rune copies and the app stops compiling (aKitthat is not aKit);cargo_lock_has_one_runeincrates/app/src/tests.rssays so first. Linux never builds the app:--exclude clanka-app. - Check the UI headless:
target/debug/clanka-app --snap <png> --scene <name> --size 1100x720(--list-scenes,--tree <json>); the scenes are fixtures and start no process. For the companions on this Mac the app runs theclankanext to its own binary first, so build both.
License #
AGPL-3.0-only (LICENSE, Cargo.toml, every package.json); releases up to 0.1.6 were MIT. REUSE.toml lists the files that keep another license (the foldcn copies in admin/, the Nimbus registry components in docs/, a vendored font); add an annotation there when you copy in third-party code.
ARCHITECTURE.mdmaps this repo. Update it in the same change when you add, move, rename or remove a package, entry point or boundary; otherwise leave it alone. Decisions, conventions and gotchas go in machine-memory, not there.