How to add a feature
formicaria is designed to be extended along its seams, without a plugin API. Here are the common recipes.
Add a command (backend function the UI can call)
A command is a pure function over the Store seam, fronted over HTTP. It touches
five places — keep them in sync. The fifth is the one that fails your build if you forget
it, and it was missing from this list until 2026-09-05:
-
The pure function —
crates/fm-app/src/commands.rs:#![allow(unused)] fn main() { /// All notes tagged `tag`, newest first. pub fn tagged(store: &dyn Store, tag: &str) -> Result<Vec<ObjectMeta>, StoreError> { let q = Query { filter: Filter::new().and(Predicate::TagsAll(vec![tag.to_string()])), sort: vec![SortKey::desc("created")], ..Default::default() }; Ok(store.query(&q)?.rows.iter().map(ObjectMeta::from).collect()) } }Add a unit test alongside the others in
crates/fm-app/tests/(drive it withMemoryStoreor a temp-dirFileStore). -
The dispatch arm —
crates/fm-app/src/dispatch.rs, indispatch():#![allow(unused)] fn main() { "tagged" => json(commands::tagged(&lock()?.store(scope), &s("tag")).map_err(err)?), }store(scope), notstore— the scope decides which vaults this caller may read, and every arm takes it. This sample said&lock()?.storeuntil 2026-09-05, which does not compile.Not in
fm-serve.dispatchis the single command surface; the server is a transport shell over it, so an arm added here is reachable from every frontend rather than only over HTTP.lock()takes the vault mutex for exactly as long as the arm needs it — if your command does anything slow (a subprocess, the network), clone what you need out and drop the guard first, the waybackup_statusdoes. -
The mock —
ui/src/lib/mock.ts, acaseinhandle()so dev/tests work without a backend. -
The typed wrapper —
ui/src/lib/ipc.ts:export const tagged = (tag: string) => invoke<ObjectMeta[]>('tagged', { tag }); -
The command reference —
docs/src/reference/commands.md: one row, in the table for the group it belongs to. This is the CI-enforced step.ci/checks.shchecks both directions and the count, so an arm with no row fails the build, and so does a documented command that no longer exists.CONTRIBUTING.mdsays the same thing; this page did not, which is how a contributor met the guard without having been told about it.
Args are camelCase in ipc.ts and map to the Rust snake_case params. That’s it —
no Tauri, no codegen.
Add a view (renderer)
A view is “a query + a renderer”.
- Add (or reuse) a command that returns the objects you want (above).
- Create
ui/src/renderers/MyView.sveltetaking{ cards, onopen }and painting them. It must stay generic: never hard-code a status literal (todo/doing/done) — color and group only viacard.type,col.value/col.label, andurgency(card.due)surfaced throughdata-value/data-urgency/data-type; the actual tints live inui/src/app.css. CI (ci/checks.sh) grepsui/src/renderers/**and fails the build on a leaked status word — this keeps renderers reusable. - Wire it into the pane workspace: add the kind to
PaneKindand give it afeedKeyinui/src/lib/panes.ts, fetch that feed inui/src/App.svelte, and render it fromui/src/lib/Pane.svelte. One view at a time is the default layout and the tiled grid is a setting; either way N panes over M distinct feeds cost M fetches.
Add a store
Implement the Store trait (crates/fm-core/src/lib.rs) for your backend — five
methods (get, put, delete, reindex, candidates) — query is a default
method that runs candidates and hands the residual filter to the pure engine once,
which is exactly what lets MultiStore federate by concatenating (you cannot union
already-sorted/grouped/paginated results and recover sort/limit/total). Because the query engine is
behind seam 1, your store only has to return objects; the engine does the rest.
Verify it against the shared contract the way FileStore does.
Add an extractor (make a new file type searchable)
Text extraction lives in crates/fm-core/src/ingest.rs (extract_text). Add a
match arm for the MIME type and shell out to the right tool (as the PDF arm
shells out to pdftotext). The extracted text lands in the asset note’s body and
becomes full-text searchable — no other change needed.
Add a theme
A theme is one CSS file. Override the semantic design tokens under a
:root[data-theme="…"] block in ui/src/app.css (see
Design system). Because every renderer reads tokens (via
the legacy aliases), a new theme re-skins the whole app with no component edits.
Add a subprocess tool
Pin it in pixi.toml [dependencies] (conda-forge) so it’s reproducible, then
shell out to it from fm-core following the backup.rs / ingest.rs pattern
(std::process::Command, map failure to StoreError). Do not link a GPL tool —
invoke it.
There is exactly one exception, and it is named rather than general: libgit2,
linked where the operating system ships no git binary (Android, and Windows).
It qualifies on its own GPL linking exception, and deny.toml records the scope.
Adding a second such dependency needs a dated decisions.md entry first.