diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b79883e --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,29 @@ +# Morphotype + +A type and logo lab. The geometry engine is Rust (`crates/morpho-core`), compiled to WebAssembly and run in a worker. The UI is React/TypeScript (`ui/src`), and materials are WebGL2 shaders (`ui/src/render`). `docs/ARCHITECTURE.md` explains how they fit together. + +## Designing in the app: use morpho + +Don't read the template or effect sources to learn what exists, and don't screenshot the editor to judge a design. Use the CLI (`docs/AGENT-TOOLS.md`): + +```sh +npm run morpho -- serve & # once: keeps a browser warm (drawing then takes < 1 s) +npm run morpho -- catalog # what exists; then: catalog chrome / glitch / star / motion / keyframes / layers +npm run morpho -- describe "UFO poster" # a design as text, changed settings only +npm run morpho -- scene "UFO poster" -o ufo.morpho +npm run morpho -- set ufo.morpho 'Title.gloss=0.4' 'Star.x=-120' +npm run morpho -- render ufo.morpho --frames 6 # one filmstrip image +npm run morpho -- vary ufo.morpho --vary 'Title.liquid=0.2,0.6,1.2' +npm run morpho -- check ufo.morpho # problems in words +npm run morpho -- compare ufo.morpho reference.png +``` + +Prefer `check`, `describe` and text output over images. When you do need to look, ask for one contact sheet (`--frames`, `vary`), not several renders. + +## Commands + +- `npm run dev`: the app at http://localhost:1420 (builds the engine in debug first) +- `npm test`: Rust and TypeScript unit tests +- `npm run typecheck` +- `npm run build && npm run test:e2e`: browser end-to-end test +- `npm run wasm:dev`: rebuild the engine after Rust changes diff --git a/README.md b/README.md index 48a9db0..7e5dba5 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ npm install | Build the web app | `npm run build` (output in `dist/`) | | Rust and UI unit tests | `npm test` | | Browser end-to-end test | `npm run build && npm run test:e2e` | +| Design from the command line, for AI agents and scripts (catalog, describe, edit, render, variations, checks; see [docs/AGENT-TOOLS.md](docs/AGENT-TOOLS.md)) | `npm run morpho -- help` | | Live render studio (templates → PNG, compare with a reference) | `node scripts/studio.mjs`, then e.g. `curl '127.0.0.1:7799/compare?tpl=UFO%20poster&ref=ref.png&out=diff.png'` | | Frame cost of moving geometry (1, 10, 50 animated pen lines, on the GPU) | `npx vite --port 1437`, then `node scripts/perf-geo.mjs` | | Measure an outline on a reference picture | `cargo run --release --example refpath -- mask.pgm` (a white-on-black PGM mask → path data) | @@ -155,8 +156,9 @@ src-tauri Desktop shell: system fonts, font install, dialogs ui/src/engine Worker + client for the engine ui/src/render WebGL2 renderer, SDF passes and effect shaders ui/src/components Editor UI +ui/src/agent The morpho CLI's side of the app: catalog, describe, edits, checks ui/public/fonts Bundled OFL fonts -scripts WASM build and end-to-end test +scripts WASM build, end-to-end test and the morpho CLI website Landing page (static; Vercel deploys it from main to morphotype.srivtx.xyz) ``` diff --git a/docs/AGENT-TOOLS.md b/docs/AGENT-TOOLS.md new file mode 100644 index 0000000..c29bfba --- /dev/null +++ b/docs/AGENT-TOOLS.md @@ -0,0 +1,91 @@ +# morpho: the app from the command line + +`scripts/morpho.mjs` drives Morphotype without its interface. It's built for AI agents (and scripts) designing in the app: every command answers in a few lines of text or in **one** PNG, so learning what exists, reading a design, editing it and judging it doesn't mean reading source files or taking a pile of screenshots. + +```sh +npm run morpho -- help +``` + +## Commands + +| Command | What it gives back | Browser? | +| --- | --- | --- | +| `catalog [query]` | What designs are made of. With no query, a one-screen index. With a section (`materials`, `modifiers`, `shapes`, `motion`, `keyframes`, `layers`, `presets`, `recipes`, `fonts`, `backgrounds`, `canvas`, `templates`), that whole section. With a name (`chrome`, `glitch`, `star`, `"Ice chrome"`), every setting with its range, default and label. Anything else is searched. | no | +| `describe ` | The design as a text tree, top layer first. Each layer is one line: what it is, where it sits, its material, modifiers, motion and keyframes, showing **only settings that differ from the defaults**. | no | +| `scene