AI-native design editor. Open-source Figma alternative.
Update README and AGENTS.md for monorepo structure and CLI
Danila Poyarkov97428949fcda
diff --git a/AGENTS.md b/AGENTS.mdindex 91e72a6fa..460a59847 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -2,6 +2,15 @@Vue 3 + CanvasKit (Skia WASM) + Yoga WASM design editor. Tauri v2 desktop, also runs in browser.+## Monorepo++Bun workspace with two packages:++- `packages/core` — `@open-pencil/core`: scene graph, renderer, layout, codec, kiwi, clipboard, vector, snap, undo. Zero DOM deps, runs headless in Bun.+- `packages/cli` — `@open-pencil/cli`: headless CLI for .fig inspection, export, linting. Uses `citty` + `agentfmt`.++The root app (`src/`) is the Tauri/Vite desktop editor. Its `src/engine/` files are thin re-export shims from `@open-pencil/core`.+## Commands- `bun run check` — lint + typecheck (run before committing)@@ -9,24 +18,30 @@ Vue 3 + CanvasKit (Skia WASM) + Yoga WASM design editor. Tauri v2 desktop, also- `bun test ./tests/engine` — unit tests- `bun run test` — Playwright visual regression- `bun run tauri dev` — desktop app with hot reload+- `bun open-pencil info <file>` — document stats+- `bun open-pencil tree <file>` — node tree+- `bun open-pencil find <file>` — search nodes+- `bun open-pencil export <file>` — headless render to PNG/JPG/WEBP## Code conventions-- `@/` import alias for cross-directory imports, `./` for same directory+- `@/` import alias for app cross-directory imports, relative imports within core- No `any` — use proper types, generics, declaration merging- No `!` non-null assertions — use guards, `?.`, `??`-- Shared types (GUID, Color, Vector, Matrix, Rect) live in `src/types.ts`-- Window API extensions (showOpenFilePicker, queryLocalFonts) live in `src/global.d.ts`+- Shared types (GUID, Color, Vector, Matrix, Rect) live in `packages/core/src/types.ts`+- Window API extensions (showOpenFilePicker, queryLocalFonts) live in `src/global.d.ts` and `packages/core/src/global.d.ts`- Use `culori` for color conversions — don't reimplement parseColor/colorToRgba- Use `@vueuse/core` hooks (useEventListener, etc.) — don't do manual addEventListener/removeEventListener-- `src/kiwi/kiwi-schema/` is vendored — don't modify+- `packages/core/src/kiwi/kiwi-schema/` is vendored — don't modify+- Core code must guard browser APIs: `typeof window !== 'undefined'`, `typeof document === 'undefined'`## Rendering- Canvas is CanvasKit (Skia WASM) on a WebGL surface, not DOM-- Rendering is coalesced via rAF — call `scheduleRender()`, not `renderNow()`+- `renderVersion` vs `sceneVersion`: `renderVersion` = canvas repaint (pan/zoom/hover); `sceneVersion` = scene graph mutations. UI panels watch `sceneVersion` only.+- `requestRender()` bumps both counters; `requestRepaint()` bumps only `renderVersion`- `renderNow()` is only for surface recreation and font loading (need immediate draw)-- Resize observer uses rAF throttle, not debounce — debounce causes canvas skew (old WebGL surface stretched into resized element)+- Resize observer uses rAF throttle, not debounce — debounce causes canvas skew- Viewport culling skips off-screen nodes; unclipped parents are NOT culled (children may extend beyond bounds)- Selection border width must be constant regardless of zoom — divide by scale- Section/frame title text never scales — render at fixed font size, ellipsize to fit@@ -65,14 +80,15 @@ Vue 3 + CanvasKit (Skia WASM) + Yoga WASM design editor. Tauri v2 desktop, also- ScrubInput (drag-to-change number) — cursor and pointerdown on outer container, not inner spans- Icons: use unplugin-icons with Iconify/Lucide (`<icon-lucide-*>`) — don't use raw SVG or Unicode symbols- Sections are draggable by title pill, not by the area to the right of the title+- CSS `contain: paint layout style` on side panels to isolate repaints from WebGL canvas## File format-- .fig files use Kiwi binary codec — schema in `src/kiwi/codec.ts`+- .fig files use Kiwi binary codec — schema in `packages/core/src/kiwi/codec.ts`- `NodeChange` is the central type for Kiwi encode/decode-- Vector data uses reverse-engineered `vectorNetworkBlob` binary format — encoder/decoder in `src/engine/vector.ts`+- Vector data uses reverse-engineered `vectorNetworkBlob` binary format — encoder/decoder in `packages/core/src/vector.ts`- showOpenFilePicker/showSaveFilePicker are File System Access API (Chrome/Edge), not Tauri-only — code has fallbacks-- Tauri detection: `IS_TAURI` constant from `src/constants.ts` — don't use `'__TAURI_INTERNALS__' in window` inline+- Tauri detection: `IS_TAURI` constant from `packages/core/src/constants.ts` — don't use `'__TAURI_INTERNALS__' in window` inline- .fig export: compression with fflate (browser) or Tauri Rust commands- Test .fig round-trip by exporting and reimporting in Figma@@ -82,6 +98,12 @@ Vue 3 + CanvasKit (Skia WASM) + Yoga WASM design editor. Tauri v2 desktop, also- File system permissions must be configured in `desktop/tauri.conf.json` — "Internal error" on save means missing permissions- Dev tools: add a menu item to toggle, don't rely on keyboard shortcut+## Publishing++- `bun publish` from package dirs — resolves `workspace:*` → actual versions+- Core: `prepublishOnly` runs `tsc` to build `dist/` for Node.js consumers+- CLI requires Bun runtime (`#!/usr/bin/env bun`)+## Reference[figma-use](https://github.com/dannote/figma-use) — our Figma toolkit. Use as reference for:diff --git a/README.md b/README.mdindex 86faf09f5..20b2b519a 100644--- a/README.md+++ b/README.md@@ -15,6 +15,8 @@ Open-source, AI-native design editor. Figma alternative built from scratch with- **Components & instances** — with live sync, overrides, component sets- **Pen tool** — bezier curves with tangent handles- **Inline text editing** — multi-line text with system fonts+- **Image export** — PNG, JPG, WEBP at any scale+- **Headless CLI** — inspect, search, and render .fig files without a GUI- **Undo/redo** — all operations are undoable- **Snap guides** — edge and center snapping- **Color picker** — HSV, hue/alpha sliders, hex input, gradients@@ -31,6 +33,7 @@ Open-source, AI-native design editor. Figma alternative built from scratch with| File format | Kiwi binary (vendored) + Zstd + ZIP || Color | culori || Desktop | Tauri v2 |+| CLI | citty, agentfmt || Testing | Playwright (visual regression), bun:test (unit) || Tooling | Vite 7, oxlint, oxfmt, typescript-go |@@ -41,6 +44,20 @@ bun installbun run dev```+## CLI++Headless .fig file operations — no GUI needed:++```sh+bun open-pencil info design.fig # Document stats, node types, fonts+bun open-pencil tree design.fig # Visual node tree+bun open-pencil find design.fig --type TEXT # Search by name or type+bun open-pencil export design.fig # Render to PNG+bun open-pencil export design.fig -f jpg -s 2 -q 90 # JPG at 2x+```++All commands support `--json` for machine-readable output.+## Scripts| Command | Description |@@ -69,15 +86,17 @@ Cross-compilation to other platforms requires their respective toolchains or CI## Project Structure```+packages/+ core/ @open-pencil/core — engine (scene graph, renderer, layout, codec)+ cli/ @open-pencil/cli — headless CLI (info, tree, find, export)src/components/ Vue SFCs (canvas, panels, toolbar, color picker)composables/ Canvas input, keyboard shortcuts, renderingstores/ Editor state (Vue reactivity)- engine/ Scene graph, renderer, layout, clipboard, undo, vector, snap- kiwi/ Figma file format (Kiwi codec, .fig import)- kiwi-schema/ Vendored from evanw/kiwi+ engine/ Re-export shims from @open-pencil/core+ kiwi/ Re-export shims from @open-pencil/coretypes.ts Shared types- constants.ts UI colors, defaults, thresholds+ constants.ts App-specific constants + re-exports from coredesktop/ Tauri v2 (Rust + config)tests/e2e/ Playwright visual regression