A drawing app built for agent/human collaboration
Rust
CI: the tests must pass on Windows too, and the Windows stack setting lands where it is read
Indicode BVb79036066b22
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 04039fc..42d5dfc 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -109,6 +109,6 @@ jobs:reserve="$(python -c "import struct, sys; b = open(sys.argv[1], 'rb').read(4096); o = struct.unpack_from('<I', b, 0x3c)[0]; print(struct.unpack_from('<Q', b, o + 96)[0])" "$exe")"echo "::notice title=Windows main stack::$exe is linked with $reserve bytes"done- - name: Tests must pass where klad is tested- if: steps.tests.outcome == 'failure' && runner.os != 'Windows'+ - name: The tests must pass+ if: steps.tests.outcome == 'failure'run: exit 1diff --git a/README.md b/README.mdindex cf101a6..0fd9a1c 100644--- a/README.md+++ b/README.md@@ -1,5 +1,7 @@# klad+[](https://github.com/klad-app/klad/actions/workflows/build.yml)+**Give your agent real brushes.** klad is a 2D painting and animation app you share with a coding agent. You paint in the editor with a pen. The agent paints through the `klad` command line, with the same brushes, on the same drawing, and each of you sees the other's strokes instantly.@@ -18,7 +20,7 @@- **Site and guides:** [klad.studio](https://klad.studio), with these drawings replayed stroke by stroke.- **Licence:** source-available, not open source. Free to build and use for yourself, and inside a company with less than 500,000 euros a year in revenue. See [Licence](#licence).-- **Runs on:** macOS (pen pressure and tilt). The editor also starts on Linux, with the mouse for now. Windows is untested.+- **Runs on:** macOS (pen pressure and tilt). It also builds and passes its tests on Linux and Windows, checked on every change; the editor starts on Linux with the mouse for now, and nobody has drawn with it on Windows yet.- **Status:** early. This is the first public version, and you build it yourself: see [From source](#from-source).## Why not just generate the picture?@@ -104,7 +106,7 @@ Building takes about ten minutes the first time.## What's rough- **You build it yourself.** There are no installers yet. Signed builds for macOS, Windows and Linux are planned, under the same licence as the source; [leave your email on klad.studio](https://klad.studio/pricing) to hear when they are ready.-- **The editor is made on a Mac.** On Linux it starts and you draw with the mouse: tablets give no pressure there yet. On Windows nobody has run it on a real machine, so tell us what you see.+- **The editor is made on a Mac.** On Linux it starts and you draw with the mouse: tablets give no pressure there yet. On Windows it builds and its tests pass, but nobody has drawn with it there, so tell us what you see.- **Some illustration basics are missing:** selecting several shapes at once, align and distribute, snapping, a grid, and SVG import and export.- **Bones are a preview:** their commands may still change.- Drawings keep opening as klad changes: a new format version comes with a migration.diff --git a/crates/cli/build.rs b/crates/cli/build.rsdeleted file mode 100644index af822e9..0000000--- a/crates/cli/build.rs+++ /dev/null@@ -1,11 +0,0 @@-const MAIN_STACK: u32 = 8 * 1024 * 1024;--fn main() {- if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {- return;- }- match std::env::var("CARGO_CFG_TARGET_ENV").as_deref() {- Ok("msvc") => println!("cargo:rustc-link-arg-bins=/STACK:{MAIN_STACK}"),- _ => println!("cargo:rustc-link-arg-bins=-Wl,--stack,{MAIN_STACK}"),- }-}diff --git a/crates/version.rs b/crates/version.rsindex debf55b..f8bba1c 100644--- a/crates/version.rs+++ b/crates/version.rs@@ -1,6 +1,8 @@use std::path::Path;use std::process::Command;+const MAIN_STACK: u32 = 8 * 1024 * 1024;+fn main() {let git = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.git");["HEAD", "refs", "packed-refs"]@@ -19,4 +21,16 @@ fn main() {.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())});println!("cargo:rustc-env=KLAD_BUILD={}", described.unwrap_or_default());+ main_stack();+}++fn main_stack() {+ let windows = std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows");+ if !windows || env!("CARGO_PKG_NAME") != "klad-cli" {+ return;+ }+ match std::env::var("CARGO_CFG_TARGET_ENV").as_deref() {+ Ok("msvc") => println!("cargo:rustc-link-arg-bins=/STACK:{MAIN_STACK}"),+ _ => println!("cargo:rustc-link-arg-bins=-Wl,--stack,{MAIN_STACK}"),+ }}diff --git a/docs/DESIGN.md b/docs/DESIGN.mdindex 6f79d6a..6b3bf7b 100644--- a/docs/DESIGN.md+++ b/docs/DESIGN.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-10 19:40_+_Last updated: 2026-11-10 20:10_# klad: design@@ -29,7 +29,7 @@ crates/Two binaries from one crate: `klad`, the command line, and `klad-editor`, the editor alone (a windowed program on Windows, the executable of `klad.app` on a Mac, started by the Linux AppImage). `klad open [bundle]` launches the same editor from the command line, on the bundle or, without one, on the start window (new, open, recent). `--no-default-features` builds `klad` without the editor. `klad --version` and the editor's About show the version and `git describe` of the commit it was built from (`crates/version.rs`, shared by both crates' build scripts; `KLAD_BUILD` overrides it).-**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is a K in two brush strokes with paint body and a dry edge, an ink stem and one ember stroke for the arm and the leg; `build.sh <folder>` keeps the drawing to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `build` runs on every push to `main` and when started by hand from the Actions tab (on any branch), not on pull requests, since three builds per pull request is a lot; it does what the README tells someone who clones klad, on macOS, Linux and Windows: the Linux packages it lists, `just compile`, then a stroke painted and rendered with that build, then the tests. Each job writes what it saw (the errors and the last lines of each step) into its summary on the run's page. The tests have to pass on macOS and Linux; on Windows, where klad is not tested yet, they are reported only. Text files check out with unix line endings on every system (`.gitattributes`), because the agent skills and other texts are compiled into the binary and git on Windows would otherwise hand them over with Windows line endings; the fonts' licence texts, the notices and the drawings of earlier releases are kept byte for byte. Pixel hashes are the same on machines of one processor family only: the vector parts are drawn by Skia, whose fast paths differ between ARM and Intel. So the test that opens the drawings of each release (`crates/cli/tests/formats.rs`) compares pixels on ARM, where its hashes were made (the Macs and the macOS runner), and on Intel checks that every frame still opens and renders. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.+**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is a K in two brush strokes with paint body and a dry edge, an ink stem and one ember stroke for the arm and the leg; `build.sh <folder>` keeps the drawing to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `build` runs on every push to `main` and when started by hand from the Actions tab (on any branch), not on pull requests, since three builds per pull request is a lot; it does what the README tells someone who clones klad, on macOS, Linux and Windows: the Linux packages it lists, `just compile`, then a stroke painted and rendered with that build, then the tests. Each job writes what it saw (the errors and the last lines of each step) into its summary on the run's page. The tests have to pass on all three. On Windows a program's main thread gets 1 MB of stack against 8 MB elsewhere, so `crates/version.rs` (the build script of the command line and the editor crates) asks the linker for 8 MB for klad's binaries, and the command line crate is compiled at `opt-level = 1` in debug builds, where it otherwise needs 2 to 4 MB; the workflow prints the stack size the Windows binaries were linked with. Text files check out with unix line endings on every system (`.gitattributes`), because the agent skills and other texts are compiled into the binary and git on Windows would otherwise hand them over with Windows line endings; the fonts' licence texts, the notices and the drawings of earlier releases are kept byte for byte. Pixel hashes are the same on machines of one processor family only: the vector parts are drawn by Skia, whose fast paths differ between ARM and Intel. So the test that opens the drawings of each release (`crates/cli/tests/formats.rs`) compares pixels on ARM, where its hashes were made (the Macs and the macOS runner), and on Intel checks that every frame still opens and renders. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.### Stack