README.md

kavu #

A tree-first SVG editor with an LLM in the loop.

The document tree on the right is the primary way of working: every element shows its attributes inline, editable in place, with the important ones and the ones already set visible and the rest a click away. A live canvas in the middle renders the document with the browser's own engine; drag to move, resize with handles, draw basic shapes. An assistant bar at the bottom sends the document to halfmind (the home box, via its OpenAI-wire gateway) or Claude and applies the edits it proposes as a single undoable step.

Dark, tabbed, dense — in the spirit of Pixelmator.

It runs as a small local Node server with a browser UI (no build step, one dependency: the Anthropic SDK). Files are read and written on disk through the server, so Open/Save work on real paths, and secrets never reach the browser.

Run #

npm install
npm start          # http://localhost:4470
npm run dev        # restarts on server changes
npm test           # node --test

Open a file directly: http://localhost:4470/?open=/path/to/file.svg.

As a desktop app #

kavu runs as a desktop app through mollusc, which needs to be installed once (npm link in its checkout); see mollusc.json.

npm run app        # mollusc dev .: the server and a native window, restarted on change
npm run app:build  # mollusc build .: kavu.app, zip and dmg in dist/

The app has a native menu, the system's Open and Save dialogs, and opens SVG files from the Finder. Unsaved documents are kept with the session and come back on the next launch.

What it does #

Tree. Disclosure triangles, drag-and-drop reordering (drop onto a row to nest, above/below to reorder), multi-select (⌘/⇧-click), hide and lock toggles (editor-only; never written to the file), filter box (#id, .class, tag, attribute values), context menu with add/insert/wrap/ungroup/reorder/convert. Text nodes and comments are rows too; double-click a text node to edit it.

Attributes, right there. Selecting an element opens its attribute block under the row. It shows the element's primary attributes (from a built-in schema of every SVG element) plus anything actually set, paired where it makes sense (x/y, width/height…). + attribute opens a searchable picker of every applicable attribute, grouped by category; all shows them all. style="" is expanded into per-property rows. Each value gets an editor for its type: colour swatches with native pickers, paint pickers that know the document's gradients and patterns, enums, scrubbable numbers (drag the label; ⇧ ×10, ⌥ ×0.1; ↑/↓ in the field), structured transform lists, path-data with tidy/lines, viewBox and preserveAspectRatio fields, href pickers with target checks, filter-input pickers that know the earlier result names, and a font-family field that knows what is embedded and installed.

Canvas. Pan (space-drag, middle-drag, or two-finger scroll), zoom (⌘-scroll or pinch, ⌘0 fit, ⌘1 100%), click to select the deepest element (⌥-click for its parent), marquee-select, drag to move (geometry attributes are edited directly — x/y, cx/cy, points, path data — falling back to transform for groups), eight resize handles (⇧ keeps aspect, ⌥ resizes from the centre), arrow-key nudging. Rect, ellipse, line and text tools draw new elements. Drop image files to embed them, drop SVG files to open them. A breadcrumb above the canvas walks the ancestry of the selection.

Drawer (⌘J) with contextual editors:

  • Source — the pretty-printed document, editable; apply re-parses it.
  • CSS — for <style> elements: a highlighted code editor and a structured rules view that stay in sync, with live "N matches" per selector, hover to highlight matches on the canvas, typed editors per declaration, @font-face.
  • Filters — the primitive chain of a <filter> as cards: inputs and result names, sliders for blur/offset/morphology/turbulence, a 5×4 grid for colour matrices, kernel grids, merge nodes, transfer functions and light sources; presets (drop shadow, glow, outline, sepia, emboss…); live preview; apply to selection.
  • Gradients — a colour ramp with draggable stops (click to add), stop colour/opacity/offset, geometry and units, presets, reverse, linear↔radial, apply as fill or stroke.
  • Fonts — fonts used by the document with their status (embedded, installed, missing), installed system fonts (via fontconfig or a directory scan), and Google Fonts. Embedding writes @font-face rules with data: URIs into a <style> in <defs>, so the file stays self-contained.
  • Assistant — the conversation log with each request's operations and a "revert to before" link.

Images. <image> elements get a chooser: browse the disk, upload, drop, paste, or paste a URL; embed as a data URI (optionally downscaled/re-encoded) or link. Linked images can be embedded later; embedded ones extracted to disk.

Export (⌘E). PNG, JPEG, WebP or SVG; by scale or explicit size; whole document or the selection's bounding box; transparent or coloured background; rendered by the browser (identical to the canvas) or, when installed, by rsvg-convert, Inkscape or ImageMagick. Download, save to a path, or copy to the clipboard.

Assistant. Type a request under the canvas. The document is sent with a temporary kid="N" on every element; the model answers with JSON operations (set, text, insert, replace, remove, move, wrap, document) which are applied as one undo step and the touched elements selected. Scope can be the whole document or the selection. Streaming, with a stop button. halfmind requests fall through a chain of models when the preferred one is busy.

Configuration #

  • ~/.config/kavu/config.json — provider and models, export defaults, allowed file roots, UI sizes. Editable in Settings (⌘,).
  • ~/.config/kavu/secrets.json — Anthropic API key and halfmind bearer token, chmod 600. ANTHROPIC_API_KEY in the environment also works.

Environment: KAVU_PORT, KAVU_CONFIG_DIR.

File access from the browser is limited to the configured roots (your home directory by default).

Layout #

server/     node:http server — config, LLM proxy (Claude SDK + halfmind), files, fonts, rasterizers
web/        the UI (ES modules, no build)
  lib/schema.js     SVG element/attribute knowledge base
  lib/doc.js        document model: parse, serialize, undo, selection, mutations
  lib/tree.js       the tree panel        lib/attrs.js    inline attribute block
  lib/editors.js    typed value editors   lib/canvas.js   viewport, selection, tools
  lib/css.js  lib/filters.js  lib/gradients.js  lib/fonts.js  lib/images.js  lib/exportdlg.js
  lib/ops.js        LLM serialization + operation interpreter   lib/llm.js  assistant bar
examples/   a sample document
test/       node --test for the pure modules

Development #

scripts/browse.mjs drives the UI in headless Chrome: it loads a URL, runs a script inside the page (window.kavu exposes the app), reports console errors and saves a screenshot. Handy for checking a change without clicking through.

Keyboard #

⌘N/⌘O/⌘S/⇧⌘S new/open/save/save as · ⌘E export · ⌘W close · ⌃Tab switch tabs · ⌘Z/⇧⌘Z undo/redo · ⌘D duplicate · ⌘G/⇧⌘G group/ungroup · ⌘]/⌘[ forward/backward · ⌫ delete · ⌘C/⌘V/⌘X copy/paste/cut as SVG · ⌘A select siblings · ⌘F filter tree · ⌘J drawer · ⌘K assistant · ⌘, settings · V H R E L T tools · Space pan.