Skip to content

armgit / klad

Public Imported from GitHub
0

A drawing app built for agent/human collaboration

Rust

just builds into a folder per platform

Indicode BV4d1bddaa37d1
diff --git a/CLAUDE.md b/CLAUDE.md
index 1c3c590..0a8f1a5 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,12 +1,12 @@
# klad
-_Last updated: 2026-11-04 19:35_
+_Last updated: 2026-11-04 19:41_
Agent-first 2D art application in Rust: a `klad` CLI for agents and a native editor for people with a pen, sharing one document bundle on disk. What and why: `docs/DESIGN.md`. How to build, test and send a change: `CONTRIBUTING.md`. How an agent draws with it: `docs/skill/SKILL.md`.
## Toolchain
-- Rust stable through rustup with clippy and rustfmt (`rust-toolchain.toml`), `just` for recipes. Builds go to `target/` or to `$CARGO_TARGET_DIR`; run cargo from the repository root.
+- Rust stable through rustup with clippy and rustfmt (`rust-toolchain.toml`), `just` for recipes. `just` builds into a folder per platform, `target/` on macOS and `target/linux` (or `target/windows`) elsewhere, whatever `CARGO_TARGET_DIR` says, so a checkout shared between a Mac and a Linux machine never mixes their binaries (`KLAD_TARGET_DIR` overrides it); `just build` ends by running the binary, so a binary for the wrong platform fails there. Run cargo from the repository root, with `CARGO_TARGET_DIR` set to the same folder when calling cargo directly.
- The editor (`crates/app`, `klad open`) runs on macOS for now. It compiles and its tests run on Linux too; `klad open` exists only in the macOS build.
- The editor's panels run headless in tests through `egui_kittest` (`Editor::open` needs no GPU): click, type, drag, read sizes and accessible names. `just ui-pictures` and `cargo test -p klad-app -- --ignored start_pictures` render the UI into `scratch/ui/` with a blank canvas; `editor_picture` draws the canvas too (the kittest renderer gets the canvas resources, and the canvas is redrawn once it has caught up, since uploads made in a pass kittest did not render are lost). `just ui-time` measures UI work per frame.
- `cargo test -p klad-app` alone does not rebuild the `klad` binary that the job and thumbnail tests run; `just test` (the workspace) does.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 593f89e..af38c63 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,7 +13,7 @@ Thank you for looking. klad is young and changes fast; issues with a drawing tha
- Rust through [rustup](https://rustup.rs); `rust-toolchain.toml` picks the version. [`just`](https://github.com/casey/just) runs the recipes.
- macOS: the Xcode command line tools. Linux: `pkg-config`, `libfreetype-dev` and `libfontconfig1-dev`. Windows is not tested yet.
- The first build downloads a prebuilt Skia for your platform (`skia-bindings` does this), so it needs network once.
-- `just build`, `just test`, `just lint`. `just audit` needs [`cargo-deny`](https://github.com/EmbarkStudios/cargo-deny) and [`cargo-about`](https://github.com/EmbarkStudios/cargo-about) (`cargo install cargo-deny --locked` and `cargo install cargo-about --locked --features cli`).
+- `just build`, `just test`, `just lint`. They build into `target/` on macOS and `target/linux` on Linux, so one checkout can be built from both. `just audit` needs [`cargo-deny`](https://github.com/EmbarkStudios/cargo-deny) and [`cargo-about`](https://github.com/EmbarkStudios/cargo-about) (`cargo install cargo-deny --locked` and `cargo install cargo-about --locked --features cli`).
- The editor is `klad open`. Its panels are tested headless with `egui_kittest`; `cargo test -p klad-app -- --ignored editor_picture` (the editor with a sample drawing on its canvas), `start_pictures` and `just ui-pictures` write pictures of the UI to `scratch/ui/`.
## The rules the code follows
diff --git a/README.md b/README.md
index 41a0ef3..b2d1ad1 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ Early, and open for testing. What works today:
There are no downloads yet; build it from source (about ten minutes the first time).
1. Install Rust with [rustup](https://rustup.rs) and [`just`](https://github.com/casey/just) (`brew install just`, or `cargo install just`). On Linux also `pkg-config`, `libfreetype-dev` and `libfontconfig1-dev`.
-2. `git clone https://github.com/klad-app/klad && cd klad`, then `just build` makes the `klad` binary in `target/release/`.
+2. `git clone https://github.com/klad-app/klad && cd klad`, then `just build` makes the `klad` binary in `target/release/` (on Linux in `target/linux/release/`).
3. On a Mac, `target/release/klad open` starts the editor on its start window: make a drawing and start painting.
4. `just samples` builds the sample drawings in `samples/` (a lantern, a walking creature, painted solids, a bouncing ball, ink examples); open one with `target/release/klad open samples/lantern/lantern.draw`.
diff --git a/docs/skill/SKILL.md b/docs/skill/SKILL.md
index c4bdcfe..0cfc767 100644
--- a/docs/skill/SKILL.md
+++ b/docs/skill/SKILL.md
@@ -7,7 +7,7 @@ description: Make and edit 2D art with the klad CLI (`klad`) in a `.draw` bundle
A `.draw` bundle is a folder: `doc.json` (layers, cels, vector nodes, palette), `strokes/<layer>/<cel>.strokes` (paint strokes and fills as data), `brushes/<id>.json` (every brush its strokes use) and `.cache/` (renders, history, notes, tiles). The `klad` CLI edits it; The user edits the same bundle in the editor (`klad open`). Both see each other's changes within a second. The user starts and opens drawings from the editor's start window (cmd N, cmd O, recent) and can copy a drawing's path from the document menu at the bottom of the tool strip to hand it to you. To start one yourself: `klad new art.draw --width 1600 --height 1200 --background '#e9e4da' --sketch` (one paint layer, `l1`, and a vector layer named sketch on top, `l3`).
-Working on klad itself: the repository's `CLAUDE.md`, `CONTRIBUTING.md` and `docs/DESIGN.md` are the source of truth. Build the CLI with `just build`; the binary is `target/release/klad` (under `$CARGO_TARGET_DIR` when that is set).
+Working on klad itself: the repository's `CLAUDE.md`, `CONTRIBUTING.md` and `docs/DESIGN.md` are the source of truth. Build the CLI with `just build`; the binary is `target/release/klad` on macOS and `target/linux/release/klad` on Linux.
## The loop
diff --git a/justfile b/justfile
index 6c4492d..9734fe3 100644
--- a/justfile
+++ b/justfile
@@ -1,10 +1,14 @@
-target_dir := env("CARGO_TARGET_DIR", "target")
-klad := target_dir + "/release/klad"
+target_dir := env("KLAD_TARGET_DIR", if os() == "macos" { "target" } else { "target/" + os() })
+klad := target_dir / "release" / "klad" + if os() == "windows" { ".exe" } else { "" }
+
+export CARGO_TARGET_DIR := target_dir
+export KLAD_TARGET_DIR := target_dir
default: build
build:
cargo build --release -p klad-cli
+ {{klad}} --version
test:
cargo test --workspace
diff --git a/samples/bounce/build.sh b/samples/bounce/build.sh
index c29a500..3bcec27 100755
--- a/samples/bounce/build.sh
+++ b/samples/bounce/build.sh
@@ -2,7 +2,12 @@
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
-klad="${KLAD:-$root/${CARGO_TARGET_DIR:-target}/release/klad}"
+case "$(uname -s)" in
+ Darwin) built=target ;;
+ Linux) built=target/linux ;;
+ *) built=target/windows ;;
+esac
+klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"
out="${1:-$here/bounce.draw}"
if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; then
echo "$out exists and may hold edits made in the editor; give another path, or FORCE=1 to rebuild it from generate.py" >&2
diff --git a/samples/creature/build.sh b/samples/creature/build.sh
index 7314248..7fe9766 100755
--- a/samples/creature/build.sh
+++ b/samples/creature/build.sh
@@ -2,7 +2,12 @@
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
-klad="${KLAD:-$root/${CARGO_TARGET_DIR:-target}/release/klad}"
+case "$(uname -s)" in
+ Darwin) built=target ;;
+ Linux) built=target/linux ;;
+ *) built=target/windows ;;
+esac
+klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"
out="${1:-$here/creature.draw}"
if ! "$klad" arcs --help >/dev/null 2>&1; then
echo "$klad is older than this example (it has no klad arcs): run just build first" >&2
diff --git a/samples/ink-shapes/build.sh b/samples/ink-shapes/build.sh
index e230843..8988cef 100755
--- a/samples/ink-shapes/build.sh
+++ b/samples/ink-shapes/build.sh
@@ -2,7 +2,12 @@
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
-klad="${KLAD:-$root/${CARGO_TARGET_DIR:-target}/release/klad}"
+case "$(uname -s)" in
+ Darwin) built=target ;;
+ Linux) built=target/linux ;;
+ *) built=target/windows ;;
+esac
+klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"
out="${1:-$here/ink-shapes.draw}"
rm -rf "$out"
"$klad" new "$out" --width 960 --height 900 --layers 0 --background '#f4efe6' >/dev/null
diff --git a/samples/lantern/build.sh b/samples/lantern/build.sh
index f5cea3b..ff6e346 100755
--- a/samples/lantern/build.sh
+++ b/samples/lantern/build.sh
@@ -2,7 +2,12 @@
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
-klad="${KLAD:-$root/${CARGO_TARGET_DIR:-target}/release/klad}"
+case "$(uname -s)" in
+ Darwin) built=target ;;
+ Linux) built=target/linux ;;
+ *) built=target/windows ;;
+esac
+klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"
out="${1:-$here/lantern.draw}"
if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; then
echo "$out exists and may hold edits made in the editor; give another path, or FORCE=1 to rebuild it from generate.py" >&2
diff --git a/samples/solids/build.sh b/samples/solids/build.sh
index c2fdae7..41e3021 100755
--- a/samples/solids/build.sh
+++ b/samples/solids/build.sh
@@ -2,7 +2,12 @@
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
-klad="${KLAD:-$root/${CARGO_TARGET_DIR:-target}/release/klad}"
+case "$(uname -s)" in
+ Darwin) built=target ;;
+ Linux) built=target/linux ;;
+ *) built=target/windows ;;
+esac
+klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"
out="${1:-$here/solids.draw}"
if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; then
echo "$out exists and may hold edits made in the editor; give another path, or FORCE=1 to rebuild it from generate.py" >&2