Skip to content

AI-native design editor. Open-source Figma alternative.

Translate reference & development pages prose for all locales

Anton A Sf4cb76b2e29d
diff --git a/packages/docs/de/development/contributing.md b/packages/docs/de/development/contributing.md
index c6c5a15d9..84392c507 100644
--- a/packages/docs/de/development/contributing.md
+++ b/packages/docs/de/development/contributing.md
@@ -1,94 +1,88 @@
# Mitwirken
-## Project Structure
+## Projektstruktur
```
packages/
- core/ @open-pencil/core — engine (zero DOM deps)
- src/ Scene graph, renderer, layout, codec, kiwi, types
- cli/ @open-pencil/cli — headless CLI for .fig operations
+ core/ @open-pencil/core — Engine (keine DOM-Abhängigkeiten)
+ src/ Szenengraph, Renderer, Layout, Codec, Kiwi, Typen
+ cli/ @open-pencil/cli — Headless-CLI für .fig-Operationen
src/commands/ info, tree, find, export
src/
- components/ Vue SFCs (canvas, panels, toolbar, color picker)
- properties/ Property panel sections (Appearance, Fill, Stroke, etc.)
- composables/ Canvas input, keyboard shortcuts, rendering hooks
- stores/ Editor state (Vue reactivity)
- engine/ Re-export shims from @open-pencil/core
- kiwi/ Re-export shims from @open-pencil/core
- types.ts Shared types (re-exported from core)
- constants.ts UI colors, defaults, thresholds
-desktop/ Tauri v2 (Rust + config)
+ components/ Vue SFCs (Canvas, Panels, Werkzeugleiste, Farbauswahl)
+ properties/ Eigenschaftspanel-Abschnitte
+ composables/ Canvas-Input, Tastenkürzel, Rendering-Hooks
+ stores/ Editor-Zustand (Vue-Reaktivität)
+ engine/ Re-Export-Shims von @open-pencil/core
+desktop/ Tauri v2 (Rust + Konfiguration)
tests/
- e2e/ Playwright visual regression
- engine/ Unit tests (bun:test)
-docs/ VitePress documentation site
+ e2e/ Playwright visuelle Regression
+ engine/ Unit-Tests (bun:test)
+packages/docs/ VitePress-Dokumentationsseite
openspec/
- specs/ Capability specifications (source of truth)
- changes/ Active and archived changes
+ specs/ Fähigkeitsspezifikationen (Wahrheitsquelle)
+ changes/ Aktive und archivierte Änderungen
```
-## Development Setup
+## Entwicklungsumgebung
```sh
bun install
-bun run dev # Editor at localhost:1420
-bun run docs:dev # Docs at localhost:5173
+bun run dev # Editor auf localhost:1420
+bun run docs:dev # Dokumentation auf localhost:5173
```
-## Code Style
+## Code-Stil
-### Tooling
+### Werkzeuge
-| Tool | Command | Purpose |
-|------|---------|---------|
-| oxlint | `bun run lint` | Linting (Rust-based, fast) |
-| oxfmt | `bun run format` | Code formatting |
-| tsgo | `bun run typecheck` | Type checking (Go-based TypeScript checker) |
+| Werkzeug | Befehl | Zweck |
+|----------|--------|-------|
+| oxlint | `bun run lint` | Linting (Rust-basiert, schnell) |
+| oxfmt | `bun run format` | Code-Formatierung |
+| tsgo | `bun run typecheck` | Typprüfung (Go-basierter TypeScript-Prüfer) |
-Run all checks:
+Alle Prüfungen ausführen:
```sh
bun run check
```
-### Conventions
-
-- **File names** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
-- **Components** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
-- **Constants** — SCREAMING_SNAKE_CASE
-- **Functions/variables** — camelCase
-- **Types/interfaces** — PascalCase
-
-### AI Agent Conventions
-
-Developers and AI agents working on the codebase should read `AGENTS.md` in the repo root ([view on GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Covers rendering, scene graph, components & instances, layout, UI, file format, Tauri conventions, and known issues.
-
-## Making Changes
-
-1. Check existing [openspec specs](/development/openspec) for the capability you're modifying
-2. Create an openspec change if adding new behavior: `openspec new change "my-change"`
-3. Implement the change
-4. Run `bun run check` and `bun run test`
-5. Submit a pull request
-
-## Key Files
-
-Engine source lives in `packages/core/src/`. The app's `src/engine/` and `src/kiwi/` are re-export shims — edit the core package, not the shims.
-
-| File | Purpose |
-|------|---------|
-| `packages/core/src/scene-graph.ts` | Scene graph: nodes, variables, instances, hit testing |
-| `packages/core/src/renderer.ts` | CanvasKit rendering pipeline |
-| `packages/core/src/layout.ts` | Yoga layout adapter |
-| `packages/core/src/undo.ts` | Undo/redo manager |
-| `packages/core/src/clipboard.ts` | Figma-compatible clipboard |
-| `packages/core/src/vector.ts` | Vector network model |
-| `packages/core/src/render-image.ts` | Offscreen image export (PNG/JPG/WEBP) |
-| `packages/core/src/kiwi/codec.ts` | Kiwi binary encoder/decoder |
-| `packages/core/src/kiwi/fig-import.ts` | .fig file import logic |
-| `packages/cli/src/index.ts` | CLI entry point |
-| `packages/cli/src/commands/` | CLI commands (info, tree, find, export) |
-| `src/stores/editor.ts` | Global editor state |
-| `src/composables/use-canvas.ts` | Canvas rendering composable |
-| `src/composables/use-canvas-input.ts` | Mouse/touch input handling |
-| `src/composables/use-keyboard.ts` | Keyboard shortcut handling |
+### Konventionen
+
+- **Dateinamen** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
+- **Komponenten** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
+- **Konstanten** — SCREAMING_SNAKE_CASE
+- **Funktionen/Variablen** — camelCase
+- **Typen/Interfaces** — PascalCase
+
+### KI-Agent-Konventionen
+
+Entwickler und KI-Agenten sollten `AGENTS.md` im Repo-Root lesen ([auf GitHub ansehen](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Behandelt Rendering, Szenengraph, Komponenten & Instanzen, Layout, UI, Dateiformat, Tauri-Konventionen und bekannte Probleme.
+
+## Änderungen vornehmen
+
+1. Vorhandene [OpenSpec-Spezifikationen](/de/development/openspec) für die zu ändernde Fähigkeit prüfen
+2. Bei neuem Verhalten eine OpenSpec-Änderung erstellen: `openspec new change "meine-aenderung"`
+3. Änderung implementieren
+4. `bun run check` und `bun run test` ausführen
+5. Pull Request einreichen
+
+## Schlüsseldateien
+
+Engine-Quellcode lebt in `packages/core/src/`. Die `src/engine/`- und `src/kiwi/`-Dateien der App sind Re-Export-Shims — bearbeiten Sie das Core-Paket, nicht die Shims.
+
+| Datei | Zweck |
+|-------|-------|
+| `packages/core/src/scene-graph.ts` | Szenengraph: Knoten, Variablen, Instanzen, Hit-Testing |
+| `packages/core/src/renderer.ts` | CanvasKit-Rendering-Pipeline |
+| `packages/core/src/layout.ts` | Yoga-Layout-Adapter |
+| `packages/core/src/undo.ts` | Rückgängig/Wiederherstellen-Manager |
+| `packages/core/src/clipboard.ts` | Figma-kompatible Zwischenablage |
+| `packages/core/src/vector.ts` | Vektornetzwerk-Modell |
+| `packages/core/src/kiwi/codec.ts` | Kiwi-Binär-Encoder/Decoder |
+| `packages/core/src/kiwi/fig-import.ts` | .fig-Datei-Import-Logik |
+| `packages/cli/src/index.ts` | CLI-Einstiegspunkt |
+| `src/stores/editor.ts` | Globaler Editor-Zustand |
+| `src/composables/use-canvas.ts` | Canvas-Rendering-Composable |
+| `src/composables/use-keyboard.ts` | Tastenkürzel-Behandlung |
diff --git a/packages/docs/de/development/openspec.md b/packages/docs/de/development/openspec.md
index 697b6fc17..4df42a87a 100644
--- a/packages/docs/de/development/openspec.md
+++ b/packages/docs/de/development/openspec.md
@@ -1,107 +1,73 @@
# OpenSpec-Workflow
-OpenPencil uses [OpenSpec](https://github.com/Fission-AI/OpenSpec) for spec-driven development. Specifications are the source of truth for what the system does.
+OpenPencil verwendet OpenSpec für spezifikationsgetriebene Entwicklung. Spezifikationen sind die Wahrheitsquelle.
-## Structure
+## Struktur
```
openspec/
-├── specs/ # Source of truth: how the system works now
+├── specs/ # Source of truth
│ ├── scene-graph/
-│ │ └── spec.md
│ ├── canvas-rendering/
-│ │ └── spec.md
│ ├── auto-layout/
-│ │ └── spec.md
-│ └── ... # 19 capability specs total
-├── changes/ # Proposed changes (one directory per change)
-│ └── archive/ # Completed changes
-└── config.yaml # Optional configuration
+│ └── ... # 19 capability specs
+├── changes/
+│ └── archive/
+└── config.yaml
```
-## Current Specs
+## Aktuelle Spezifikationen
| Capability | Description |
|-----------|-------------|
-| scene-graph | Flat Map storage, CRUD, hit testing |
-| canvas-rendering | CanvasKit WASM rendering pipeline |
-| canvas-navigation | Pan, zoom, hand tool |
-| selection-manipulation | Click/marquee select, move, resize, rotate |
-| undo-redo | Inverse-command pattern |
-| text-editing | Text tool, Paragraph API, font loading |
-| pen-tool | Vector network model, bezier curves |
-| auto-layout | Yoga WASM flexbox, Shift+A toggle |
-| figma-clipboard | Bidirectional Kiwi binary clipboard |
-| fig-import | .fig file import pipeline |
-| kiwi-codec | Kiwi binary codec, sparse field IDs |
-| editor-ui | Vue 3 panels, toolbar, color picker |
-| snap-guides | Edge/center snapping, rotation-aware |
-| rulers | Canvas rulers, selection highlight |
-| group-ungroup | ⌘G/⇧⌘G, position-based sort |
-| desktop-app | Tauri v2, macOS menu bar |
-| testing | Playwright E2E, bun:test unit |
-| scrub-input | Drag-to-scrub numeric inputs |
-| tooling | Vite 7, oxlint, oxfmt, tsgo, VitePress |
+| scene-graph | Flat Map, CRUD, hit testing |
+| canvas-rendering | CanvasKit WASM rendering |
+| auto-layout | Yoga WASM flexbox |
+| fig-import | .fig file import |
+| kiwi-codec | Kiwi binary codec |
+| editor-ui | Vue 3 panels, toolbar |
+| desktop-app | Tauri v2 |
+| testing | Playwright + bun:test |
+| tooling | Vite, oxlint, tsgo |
## Workflow
-### 1. Propose a Change
+### 1. Änderung vorschlagen
```
-/opsx:propose add-dark-mode
+/opsx:propose change-name
```
-Creates `openspec/changes/add-dark-mode/` with:
-- `proposal.md` — why and what changes
-- `design.md` — technical approach
-- `specs/` — delta specifications (ADDED/MODIFIED/REMOVED requirements)
-- `tasks.md` — implementation checklist
+→ proposal.md, design.md, specs/, tasks.md
-### 2. Implement
+### 2. Implementieren
```
/opsx:apply
```
-Execute tasks from tasks.md, checking off items as they're completed.
-
-### 3. Archive
+### 3. Archivieren
```
/opsx:archive
```
-- Merges delta specs into `openspec/specs/` (the baseline)
-- Moves the change to `openspec/changes/archive/`
-
-## Spec Format
-
-Each spec file follows a consistent structure:
+## Spezifikationsformat
```markdown
# capability-name Specification
-
-## Purpose
-One-line description of what this capability does.
-
## Requirements
-
### Requirement: Name
-Description using SHALL/MUST for normative requirements.
-
#### Scenario: Name
- **WHEN** condition
- **THEN** expected outcome
```
-Every requirement has at least one scenario. Scenarios are potential test cases.
-
-## CLI Commands
+## CLI-Befehle
```sh
-openspec list # List active changes
-openspec show <name> # Show change details
-openspec status --change <name> # Artifact status
-openspec archive <name> # Archive completed change
-openspec update # Regenerate skills/prompts
+openspec list
+openspec show <name>
+openspec status --change <name>
+openspec archive <name>
```
diff --git a/packages/docs/de/development/roadmap.md b/packages/docs/de/development/roadmap.md
index 9355b5198..93a1d5ccf 100644
--- a/packages/docs/de/development/roadmap.md
+++ b/packages/docs/de/development/roadmap.md
@@ -1,145 +1,32 @@
# Fahrplan
-## Phases
+## Phase 1 ✅
+SceneGraph, Skia rendering, shapes, selection, zoom/pan, undo/redo, snap guides.
-### Phase 1: Core Engine ✅
+## Core-Engine ✅
+Vue 3 + Reka UI panels, properties, layers, toolbar, Yoga auto-layout, inline text editing, canvas rulers.
-SceneGraph, Skia rendering, basic shapes, selection, zoom/pan, undo/redo.
+## Phase 2 ✅
+.fig import/export, Kiwi codec, clipboard, pen tool, vector networks, groups, Tauri v2 desktop, sections, multi-page, hover highlight, Tier 1 rendering.
-**Delivered:**
-- Scene graph with flat Map storage and parent-child tree
-- CanvasKit WASM rendering for all shape types
-- Click/shift/marquee selection with resize handles and rotation
-- Zoom/pan with keyboard shortcuts and trackpad gestures
-- Undo/redo wired into all operations
-- Snap guides with edge and center snapping
+## Editor-UI + Layout ✅
+Components, instances, overrides, component sets, variables (COLOR/FLOAT/STRING/BOOLEAN), collections, modes, image export, context menu, rich text formatting.
-### Phase 2: Editor UI + Layout ✅
+## Phase 3 🟡
+@open-pencil/core, CLI (12 commands), MCP server (29+ tools), AI chat (OpenRouter), JSX renderer, code panel.
-Properties panel, layers panel, toolbar, Yoga layout integration, text editing.
+**Planned:** port remaining figma-use tools, attached mode, design guidelines, screenshot verification loop.
-**Delivered:**
-- Vue 3 + Reka UI panels (properties, layers, toolbar)
-- Properties panel split into sections (Appearance, Fill, Stroke, Typography, Layout, Position)
-- ScrubInput component for all numeric inputs
-- Color picker (HSV, hex, opacity)
-- Layers panel with tree view, drag reorder, visibility toggle
-- Auto-layout with Yoga WASM (direction, gap, padding, justify, align)
-- Inline text editing with CanvasKit Paragraph API
-- System font loading via Local Font Access API
-- Canvas rulers with selection highlight
+## Datei-I/O + Visuelle Features 🔲
+Prototyping, comments, PWA, Linux Tauri builds, performance optimization, full Figma compatibility test suite.
-### Phase 3: File I/O + Visual Features ✅
+## Phase 4
-.fig import/export, Kiwi codec, clipboard, sections, pages, advanced rendering.
-
-**Delivered:**
-- .fig file import via Kiwi binary codec
-- .fig file export with Kiwi encoding, Zstd compression, thumbnail generation
-- Save (⌘S) and Save As (⇧⌘S) with native OS dialogs
-- Zstd compression via Tauri Rust command (deflate fallback in browser)
-- Vendored kiwi-schema with ESM + sparse field ID patches
-- Figma-compatible clipboard (bidirectional Kiwi binary)
-- Pen tool with vector network model
-- vectorNetworkBlob binary encode/decode
-- Group/ungroup (⌘G/⇧⌘G)
-- Tauri v2 desktop app with native menu bar (macOS/Windows/Linux)
-- Sections (S key) with title pills, auto-adopt, luminance-adaptive text
-- Multi-page documents with pages panel, per-page viewport
-- Hover highlight with shape-aware outlines
-- Tier 1 rendering: gradients, image fills, effects, strokes (cap/join/dash), arcs
-- Fill type picker with solid/gradient/image tabs and gradient stop editing
-- Canvas background color per page
-- Fig-import unit tests, layout unit tests, layers-panel E2E tests
-
-### Phase 4: Components + Variables ✅
-
-Components, instances, overrides, variables, collections, modes, image export.
-
-**Delivered:**
-- Component creation from frame/group or multi-selection (⌥⌘K)
-- Component sets from multiple components (⇧⌘K) with dashed purple border
-- Instance creation from components with child cloning and componentId mapping
-- Live component-instance sync with override preservation
-- Detach instance back to frame (⌥⌘B)
-- Go to main component (cross-page navigation)
-- Always-visible purple component/instance labels with diamond icon
-- Opaque container hit testing (click selects component, double-click enters)
-- Right-click context menu with clipboard, z-order, grouping, component, visibility, lock, move-to-page actions
-- Z-order manipulation (] bring to front, [ send to back)
-- Toggle visibility (⇧⌘H) and lock (⇧⌘L)
-- Move nodes between pages via context menu
-- Viewport culling, Paint reuse, RAF render coalescing
-- Effects panel UI (drop shadow, inner shadow, layer/background/foreground blur)
-- Independent corner radius controls (per-corner toggle in Appearance section)
-- GitHub Actions CI/CD for Windows (x64, arm64) and macOS (x64, arm64) builds
-- Polygon and Star drawing tools with pointCount and starInnerRadius
-- Resizable left/right panels via reka-ui Splitter (persistent layout)
-- @/ import alias, shared types module (src/types.ts, src/global.d.ts)
-- Codebase lint-clean: 0 oxlint warnings, 0 tsgo type errors
-- Variables: COLOR type with collections, modes, bindings, FillSection variable picker, .fig import
-- Variables dialog: TanStack Table with resizable columns, mode columns, collection tabs with rename, search, demo collections (Primitives/Semantic/Spacing), undo/redo for all variable operations
-- Image export: PNG/JPG/WEBP with ExportSection (scale, format, live preview), ⇧⌘E shortcut, context menu
-- Canvas-native text editing: TextEditor class in core, phantom textarea, cursor/selection/word boundaries on canvas, caret blinking, selection highlights
-- System font enumeration via font-kit Rust crate, OnceLock cache, preload on startup
-- Font picker: virtual scroll (reka-ui ListboxVirtualizer), search filter, CSS font preview
-- ColorInput component extraction, ColorPicker alpha slider checkerboard fix
-- App identity: pencil icon, Cargo crate open_pencil, macOS Dock "OpenPencil"
-- Splash loader during WASM initialization
-- Rich text style runs: per-selection ⌘B/I/U, StyleRun model, ParagraphBuilder pushStyle/pop, .fig roundtrip
-- B/I/U/S toggle buttons in TypographySection
-- Double-click (word), triple-click (select all) text selection
-
-**Remaining (deferred to Phase 6):**
-- Variant switching
-- Variable types: FLOAT, STRING, BOOLEAN editing UI
-- Variable-driven theming
-
-### Phase 5: AI Integration & Tooling 🟡
-
-Core extraction, CLI, MCP server, design guidelines, screenshot verification loop.
-
-**Delivered:**
-- @open-pencil/core extracted to packages/core/ (zero DOM deps, Bun workspace)
-- @open-pencil/cli with headless .fig operations (info, tree, find, export, analyze, node, pages, variables), CanvasKit CPU rasterization, --json output
-- JSX renderer: TreeNode builders (Frame, Text, Rectangle, etc.), renderTreeNode/renderJsx, Tailwind-like shorthand props, 27 tests
-- jscpd copy-paste detection (15.6% → 0.62%), kiwi-serialize.ts consolidation
-- .fig roundtrip tests with LFS fixtures (material3.fig 87K nodes, nuxtui.fig 314K nodes)
-- .fig import O(n²) → O(n) fix (37s → 535ms on 87K nodes), ByteBuffer optimization
-- test:coverage script
-- AI chat: OpenRouter direct (no backend), Stronghold key storage, 26 tools (create_shape, set_fill, set_effects, set_constraints, components, groups, pages, variables, eval_code, etc.), model selector, ⌘J toggle, streaming markdown, Playwright tests with mock transport
-- Code panel: sceneNodeToJsx() export, Prism.js highlighting, line numbers, copy button, 14 tests
-- Properties panel restructured: Design | Code | AI tabs
-- npm publishing preparation for core and cli packages
-
-**Planned:**
-- Port remaining figma-use tools (118 total, 26 currently implemented)
-- Attached mode: WebSocket to running editor for eval, create, export, screenshot
-- Design guidelines system
-- AI-driven design workflow via MCP
-- Screenshot verification loop
-
-### Phase 6: Polish + Distribution 🔲
-
-Prototyping, comments, desktop distribution, documentation, public launch.
-
-**Planned:**
-- Prototyping (frame connections, transitions)
-- Comments (pin, threads, resolve)
-- Linux Tauri builds (macOS and Windows already covered by CI)
-- PWA support
-- Documentation site (VitePress)
-- Performance optimization (Lighthouse > 90)
-- Full Figma compatibility test suite
-- Deferred from Phase 4: variant switching, FLOAT/STRING/BOOLEAN variable UI, variable-driven theming
-
-## Timeline
-
-| Phase | Estimated Duration | Status |
-|-------|-------------------|--------|
-| Phase 1: Core Engine | 3 months | ✅ Complete |
-| Phase 2: Editor UI + Layout | 3 months | ✅ Complete |
-| Phase 3: File I/O + Visual Features | 2 months | ✅ Complete |
-| Phase 4: Components + Variables | 2 months | ✅ Complete |
-| Phase 5: AI Integration & Tooling | 2 months | 🟡 In Progress |
-| Phase 6: Polish + Distribution | 2 months | 🔲 Planned |
+| Phase | Komponenten + Variablen | Phase 5: KI-Integration & Werkzeuge:Phase 6: Feinschliff + Verteilung:Zeitplan:Geschätzte Dauer:Status |
+|-------|------|-----|
+| Phase 1 | 3 months | ✅ |
+| Core-Engine | 3 months | ✅ |
+| Phase 2 | 2 months | ✅ |
+| Editor-UI + Layout | 2 months | ✅ |
+| Phase 3 | 2 months | 🟡 |
+| Datei-I/O + Visuelle Features | 2 months | 🔲 |
diff --git a/packages/docs/de/development/testing.md b/packages/docs/de/development/testing.md
index 3c6871d2c..65bb63308 100644
--- a/packages/docs/de/development/testing.md
+++ b/packages/docs/de/development/testing.md
@@ -1,6 +1,6 @@
# Testen
-## Overview
+## Übersicht
| Type | Framework | Command | Location |
|------|-----------|---------|----------|
@@ -8,84 +8,45 @@
| Figma CDP reference | Playwright | `bun run test:figma` | `tests/figma/` |
| Unit tests | bun:test | `bun run test:unit` | `tests/engine/` |
-## E2E Visual Regression
-
-Playwright creates shapes on the canvas and compares screenshots against baseline PNGs.
+## E2E Visuelle Regression
```sh
-bun run test # Run tests, compare against baselines
-bun run test:update # Regenerate baseline screenshots
+bun run test # Compare against baselines
+bun run test:update # Regenerate baselines
```
-### How It Works
-
-1. Tests load the editor in a headless browser
-2. The editor signals readiness via a `data-ready` HTML attribute
-3. Tests create shapes via the editor's API
-4. Screenshots are taken and compared against baselines using `toMatchSnapshot`
-5. Page is reused across test cases for speed (~2s total)
-
-### No-Chrome Test Mode
-
-The editor supports a test mode that hides UI chrome (toolbar, panels) for clean screenshot capture. Activated via URL parameter.
+1. Playwright → headless browser
+2. `data-ready` HTML attribute
+3. Create shapes → screenshot → `toMatchSnapshot`
-## Figma CDP Reference Tests
-
-A separate Playwright project connects to Figma via Chrome DevTools Protocol to capture reference screenshots for pixel-perfect comparison.
+## Figma CDP-Referenztests
```sh
bun run figma:debug # Launch Figma with debugging port
-bun run test:figma # Connect to Figma, capture references
+bun run test:figma # Connect via CDP
```
-Requires Figma desktop app running with `--remote-debugging-port=9222`.
-
-## Unit Tests
-
-Engine unit tests use bun:test and target < 50ms execution:
+## Unit-Tests
```sh
bun run test:unit
```
-Tests cover:
-- Scene graph CRUD operations, parent-child relationships, z-ordering, hit testing
-- **Fig-import pipeline** — node type mapping, transforms, fills/strokes/effects, gradients, images, arcs, nested hierarchies (`tests/engine/fig-import.test.ts`)
-- **Layout computation** — Yoga auto-layout: direction, gap, padding, justify, align, child sizing (fixed/fill/hug), cross-axis sizing, wrap, nested layouts (`tests/engine/layout.test.ts`)
+- Scene graph CRUD, hit testing
+- Fig-import pipeline
+- Layout computation (Yoga)
+- MCP server edge cases
-### Writing Unit Tests
-
-```typescript
-import { describe, expect, it } from 'bun:test'
-import { SceneGraph } from '../../src/engine/scene-graph'
-
-describe('SceneGraph', () => {
- it('creates and retrieves a node', () => {
- const sg = new SceneGraph()
- const node = sg.createNode('RECTANGLE', sg.root, { name: 'Test' })
- expect(sg.getNode(node.guid)).toBeDefined()
- })
-})
-```
-
-## E2E Test Coverage
+## E2E-Testabdeckung
| Test file | Scope |
|-----------|-------|
-| `tests/e2e/layers-panel.spec.ts` | Layers panel tree structure, visibility toggles, selection sync |
-| `tests/e2e/visual.spec.ts` | Visual regression screenshots for shapes and rendering |
-
-## Test Helpers
-
-| File | Purpose |
-|------|---------|
-| `tests/helpers/canvas.ts` | Canvas setup and interaction utilities |
-| `tests/helpers/figma.ts` | Figma CDP connection helpers |
+| `tests/e2e/layers-panel.spec.ts` | Layers panel |
+| `tests/e2e/visual.spec.ts` | Visual regression |
-## Performance Targets
+## Leistungsziele
| Metric | Target |
|--------|--------|
-| E2E suite total | < 3s |
-| Unit test suite total | < 50ms |
-| Screenshot comparison | toMatchSnapshot (pixel-level) |
+| E2E suite | < 3s |
+| Unit tests | < 50ms |
diff --git a/packages/docs/de/eval-command.md b/packages/docs/de/eval-command.md
index 9f7c45018..5c4ef3d70 100644
--- a/packages/docs/de/eval-command.md
+++ b/packages/docs/de/eval-command.md
@@ -1,13 +1,13 @@
-# `open-pencil eval` — Figma-like Plugin API for Headless Scripting
+# `open-pencil eval` — Figma-ähnliche Plugin-API für Headless-Skripting
-## Overview
+## Übersicht
-`bun open-pencil eval <file> --code '<js>'` executes JavaScript against a `.fig` file with a Figma-compatible `figma` global object. This enables headless scripting, batch operations, AI tool execution, and testing — all without the GUI.
+`bun open-pencil eval <file> --code '<js>'` führt JavaScript gegen eine `.fig`-Datei mit einem Figma-kompatiblen `figma`-Globalobjekt aus. Dies ermöglicht Headless-Skripting, Batch-Operationen, KI-Werkzeug-Ausführung und Tests — alles ohne die GUI.
-The `figma` object mirrors Figma's Plugin API surface as closely as possible, so existing Figma plugin knowledge and code snippets transfer directly.
+Das `figma`-Objekt spiegelt Figmas Plugin-API-Oberfläche so nah wie möglich, sodass vorhandenes Figma-Plugin-Wissen und Code-Snippets direkt übertragbar sind.
```bash
-# Create a frame, set auto-layout, add children
+# Frame erstellen, Auto-Layout setzen, Kinder hinzufügen
bun open-pencil eval design.fig --code '
const frame = figma.createFrame()
frame.name = "Card"
@@ -26,21 +26,21 @@ bun open-pencil eval design.fig --code '
return { id: frame.id, name: frame.name }
'
-# Query nodes
+# Knoten abfragen
bun open-pencil eval design.fig --code '
const buttons = figma.currentPage.findAll(n => n.type === "FRAME" && n.name.includes("Button"))
return buttons.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
'
-# Read from stdin (for multiline scripts / piping)
+# Von stdin lesen (für mehrzeilige Skripte / Piping)
cat transform.js | bun open-pencil eval design.fig --stdin
-# Write changes back
+# Änderungen zurückschreiben
bun open-pencil eval design.fig --code '...' --write
bun open-pencil eval design.fig --code '...' -o modified.fig
```
-## Architecture
+## Architektur
```
┌──────────────────────────────────────────────────────┐
@@ -48,390 +48,93 @@ bun open-pencil eval design.fig --code '...' -o modified.fig
│ ↓ │
│ loadDocument(file) → SceneGraph │
│ ↓ │
-│ FigmaAPI(sceneGraph) → `figma` proxy object │
+│ FigmaAPI(sceneGraph) → `figma` Proxy-Objekt │
│ ↓ │
│ AsyncFunction('figma', wrappedCode)(figmaProxy) │
│ ↓ │
-│ print result as JSON / agentfmt │
-│ optionally: saveDocument(file) if --write │
+│ Ergebnis als JSON / agentfmt ausgeben │
+│ optional: saveDocument(file) bei --write │
└──────────────────────────────────────────────────────┘
```
-### Key classes
-
-| Class | Location | Role |
-|-------|----------|------|
-| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy object implementing `figma.*` methods against `SceneGraph` |
-| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy wrapping `SceneNode` with Figma-style property access (`.fills`, `.resize()`, `.appendChild()`, etc.) |
-| `eval` command | `packages/cli/src/commands/eval.ts` | CLI command that loads doc, creates API, executes code |
-
-### Why in `@open-pencil/core`?
-
-The `FigmaAPI` class lives in core (not CLI) because:
-- **AI tools reuse it** — the chat panel's `render` tool can execute JSX through the same API
-- **Test scripts** — unit tests can use the API to set up fixtures
-- **No DOM deps** — runs headless in Bun, no browser APIs needed
-
-## `FigmaAPI` — Phased Implementation
-
-### Phase 1: Core (MVP for eval command)
-
-These cover ~80% of real plugin scripts:
-
-#### Document & Page
-
-| Figma API | Our implementation | Notes |
-|-----------|--------------------|-------|
-| `figma.root` | Getter → proxy for root node | `.children` returns page proxies |
-| `figma.currentPage` | Getter/setter → first page by default | Settable to any page proxy |
-| `figma.currentPage.selection` | Get/set → tracked selection array | |
-| `figma.getNodeById(id)` | `graph.getNode(id)` wrapped in proxy | Sync, like Figma's deprecated version |
-
-#### Node Creation
-
-| Figma API | Maps to |
-|-----------|---------|
-| `figma.createFrame()` | `graph.createNode('FRAME', currentPageId)` |
-| `figma.createRectangle()` | `graph.createNode('RECTANGLE', ...)` |
-| `figma.createEllipse()` | `graph.createNode('ELLIPSE', ...)` |
-| `figma.createText()` | `graph.createNode('TEXT', ...)` |
-| `figma.createLine()` | `graph.createNode('LINE', ...)` |
-| `figma.createPolygon()` | `graph.createNode('POLYGON', ...)` |
-| `figma.createStar()` | `graph.createNode('STAR', ...)` |
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createPage()` | `graph.addPage(name)` |
-| `figma.createSection()` | `graph.createNode('SECTION', ...)` |
-
-#### Node Properties (via `FigmaNode` proxy)
-
-Read/write on any node proxy. Property access maps to `SceneNode` fields:
-
-```ts
-// Geometry
-node.x, node.y // direct
-node.width, node.height // read-only, use node.resize(w, h)
-node.rotation // direct
-node.resize(w, h) // updates width + height
-node.resizeWithoutConstraints(w, h) // same (no constraint engine yet)
-
-// Visual
-node.fills // get/set Fill[]
-node.strokes // get/set Stroke[]
-node.effects // get/set Effect[]
-node.opacity // get/set number
-node.visible // get/set boolean
-node.locked // get/set boolean
-node.blendMode // get/set BlendMode
-node.clipsContent // get/set boolean
-
-// Corner radius
-node.cornerRadius // get/set (number or figma.mixed)
-node.topLeftRadius // get/set
-node.topRightRadius // get/set
-node.bottomLeftRadius // get/set
-node.bottomRightRadius // get/set
-node.cornerSmoothing // get/set
-
-// Identity
-node.id // read-only
-node.name // get/set
-node.type // read-only
-node.parent // read-only → FigmaNode | null
-node.removed // read-only boolean
-```
+### Schlüsselklassen
-#### Tree Operations
+| Klasse | Ort | Rolle |
+|--------|-----|-------|
+| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy-Objekt, das `figma.*`-Methoden gegen `SceneGraph` implementiert |
+| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy, der `SceneNode` mit Figma-ähnlichem Eigenschaftszugriff umhüllt |
+| `eval`-Befehl | `packages/cli/src/commands/eval.ts` | CLI-Befehl: Dokument laden, API erstellen, Code ausführen |
-```ts
-node.children // read-only FigmaNode[]
-node.appendChild(child) // reparent to end
-node.insertChild(index, child) // reparent at index
-node.remove() // graph.deleteNode(id)
+### Warum in `@open-pencil/core`?
-// Traversal
-node.findAll(callback?) // recursive find
-node.findOne(callback) // first match
-node.findChild(callback) // direct children only
-node.findChildren(callback?) // direct children only
-```
+Die `FigmaAPI`-Klasse lebt in core (nicht CLI), weil:
+- **KI-Werkzeuge nutzen sie wieder** — das Chat-Panels `render`-Werkzeug kann JSX über dieselbe API ausführen
+- **Testskripte** — Unit-Tests können die API für Fixture-Setup verwenden
+- **Keine DOM-Abhängigkeiten** — läuft headless in Bun
-#### Auto-layout
-
-```ts
-node.layoutMode // 'NONE' | 'HORIZONTAL' | 'VERTICAL'
-node.primaryAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'
-node.counterAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'BASELINE'
-node.itemSpacing // number
-node.counterAxisSpacing // number | null
-node.paddingTop / Right / Bottom / Left // number
-node.layoutWrap // 'NO_WRAP' | 'WRAP'
-
-// Child sizing
-node.layoutPositioning // 'AUTO' | 'ABSOLUTE'
-node.layoutGrow // 0 | 1
-node.layoutSizingHorizontal // 'FIXED' | 'HUG' | 'FILL'
-node.layoutSizingVertical // 'FIXED' | 'HUG' | 'FILL'
-```
+## CLI-Befehl
-#### Text
-
-```ts
-node.characters // get/set (maps to node.text)
-node.fontSize // get/set
-node.fontName // get/set { family, style }
-node.fontWeight // get/set
-node.textAlignHorizontal // get/set
-node.textAlignVertical // get/set
-node.textAutoResize // get/set
-node.letterSpacing // get/set
-node.lineHeight // get/set
-node.maxLines // get/set
-node.textCase // get/set
-node.textDecoration // get/set
```
+bun open-pencil eval <file> [optionen]
-#### Stroke details
+Argumente:
+ file .fig-Datei zum Bearbeiten
-```ts
-node.strokeWeight // get/set (maps to strokes[0].weight)
-node.strokeAlign // get/set (maps to strokes[0].align)
-node.dashPattern // get/set
+Optionen:
+ --code, -c Auszuführender JavaScript-Code (hat Zugriff auf `figma`-Global)
+ --stdin Code von stdin statt --code lesen
+ --write, -w Änderungen in die Eingabedatei zurückschreiben
+ -o, --output In eine andere Datei schreiben
+ --json Ergebnis als JSON ausgeben (Standard für Nicht-TTY)
+ --quiet, -q Ausgabe unterdrücken, nur Datei schreiben
```
-#### Misc
+### Ausführungsmodell
-```ts
-figma.mixed // Symbol sentinel for mixed values
-figma.group(nodes, parent) // creates GROUP with given children
-figma.ungroup(node) // ungroups, reparents children
-figma.flatten(nodes) // NOT IMPLEMENTED YET — returns first node
-```
+1. `.fig` laden → `SceneGraph`
+2. `FigmaAPI(graph)` erstellen → `figma`-Proxy
+3. Benutzercode in async-Funktion verpacken: `return (async () => { <code> })()`
+4. Mit `figma` als einzigem Argument ausführen
+5. Rückgabewert ausgeben (JSON oder agentfmt)
+6. Bei `--write` oder `-o`: `SceneGraph` zurück in `.fig` serialisieren
-#### Export
+### Rückgabewert-Formatierung
-```ts
-node.exportAsync(settings?) // only works if CanvasKit is loaded
- // settings: { format: 'PNG'|'JPG'|'SVG', constraint? }
-```
+- `undefined` / `void` → keine Ausgabe
+- Primitive → direkt ausgeben
+- Objekte/Arrays → `JSON.stringify(result, null, 2)` oder agentfmt-Tabellen
+- `FigmaNode` → serialisiert als `{ id, type, name, x, y, width, height, fills, ... }`
+- Arrays von `FigmaNode` → als Liste serialisiert
-### Phase 2: Components & Instances
-
-| API | Maps to |
-|-----|---------|
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createComponentFromNode(node)` | Convert existing frame to component |
-| `figma.combineAsVariants(components, parent)` | Create COMPONENT_SET |
-| Node: `node.createInstance()` | `graph.createInstance(componentId, parentId)` |
-| Node: `node.detachInstance()` | `graph.detachInstance(id)` |
-| `figma.getNodeById(id).mainComponent` | `graph.getMainComponent(id)` |
-
-### Phase 3: Variables
-
-| API | Maps to |
-|-----|---------|
-| `figma.variables.getLocalVariables(type?)` | `graph.variables` filtered |
-| `figma.variables.getLocalVariableCollections()` | `graph.variableCollections` |
-| `figma.variables.createVariable(name, collection, type)` | `graph.addVariable(...)` |
-| `figma.variables.createVariableCollection(name)` | `graph.addCollection(...)` |
-| `figma.variables.getVariableById(id)` | `graph.variables.get(id)` |
-| `node.setBoundVariable(field, variable)` | `graph.bindVariable(...)` |
-| `node.boundVariables` | getter from SceneNode |
-
-### Phase 4: Styles & Advanced
-
-| API | Notes |
-|-----|-------|
-| `figma.createPaintStyle()` | Requires style storage in SceneGraph |
-| `figma.createTextStyle()` | Requires style storage in SceneGraph |
-| `figma.createEffectStyle()` | Requires style storage in SceneGraph |
-| `figma.loadFontAsync(fontName)` | No-op (we don't have font loading constraints) |
-| `figma.listAvailableFontsAsync()` | Return system fonts if available |
-| Boolean operations (`union`, `subtract`, `intersect`, `exclude`) | Requires path boolean engine |
-| `figma.createNodeFromJSXAsync(jsx)` | Port figma-use's JSX renderer |
-
-## `FigmaNode` Proxy Design
-
-The proxy wraps a `SceneNode` and translates Figma property names to our internal names. Key mappings:
-
-```ts
-const PROPERTY_MAP: Record<string, string> = {
- // Figma name → SceneNode field name (only where they differ)
- 'characters': 'text',
- 'strokeWeight': → computed from strokes[0].weight,
- 'strokeAlign': → computed from strokes[0].align,
- 'fontName': → computed from { family: fontFamily, style: ... },
- 'primaryAxisAlignItems': 'primaryAxisAlign',
- 'counterAxisAlignItems': 'counterAxisAlign',
- 'primaryAxisSizingMode': 'primaryAxisSizing', // value mapping: 'AUTO' → 'HUG', 'FIXED' → 'FIXED'
- 'counterAxisSizingMode': 'counterAxisSizing',
- 'layoutSizingHorizontal': → computed from primaryAxisSizing / counterAxisSizing depending on layoutMode
- 'layoutSizingVertical': → computed
-}
-```
+## `FigmaAPI` — Phasenweise Implementierung
-Methods on the proxy:
-
-```ts
-class FigmaNode {
- // The proxy is created via: new Proxy(target, handler)
- // where handler.get intercepts property reads and handler.set intercepts writes
-
- resize(width: number, height: number): void
- resizeWithoutConstraints(width: number, height: number): void
- remove(): void
- appendChild(child: FigmaNode): void
- insertChild(index: number, child: FigmaNode): void
- findAll(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- findOne(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChild(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChildren(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- exportAsync(settings?: ExportSettings): Promise<Uint8Array>
-
- // Components (Phase 2)
- createInstance(): FigmaNode
- detachInstance(): void
- get mainComponent(): FigmaNode | null
-}
-```
+Die vollständige API-Referenz mit Phasen (Core, Komponenten, Variablen, Stile) und Eigenschafts-Mapping finden Sie in der [englischen Version](/eval-command).
-## CLI Command
+### Phase 1: Core
-```
-bun open-pencil eval <file> [options]
-
-Arguments:
- file .fig file to operate on
-
-Options:
- --code, -c JavaScript code to execute (has access to `figma` global)
- --stdin Read code from stdin instead of --code
- --write, -w Write changes back to the input file
- -o, --output Write to a different file
- --json Output result as JSON (default for non-TTY)
- --quiet, -q Suppress output, only write file
-```
-
-### Execution model
+Deckt ~80% realer Plugin-Skripte ab. Enthält: Dokument & Seite, Knotenerstellung, Knoteneigenschaften, Baumoperationen, Auto-Layout, Text, Kontur und Export.
-1. Load `.fig` → `SceneGraph`
-2. Create `FigmaAPI(graph)` → `figma` proxy
-3. Wrap user code in async function: `return (async () => { <code> })()`
-4. Execute with `figma` as sole argument
-5. Print return value (JSON or agentfmt)
-6. If `--write` or `-o`: serialize `SceneGraph` back to `.fig`
+### Phase 2: Komponenten & Instanzen
-### Return value formatting
+`figma.createComponent()`, `combineAsVariants()`, `createInstance()`, `detachInstance()`, `mainComponent`.
-- `undefined` / `void` → no output
-- Primitives → printed directly
-- Objects/arrays → `JSON.stringify(result, null, 2)` or agentfmt tables
-- `FigmaNode` → serialized as `{ id, type, name, x, y, width, height, fills, ... }`
-- Arrays of `FigmaNode` → serialized as list
+### Phase 3: Variablen
-## Shared with AI Tools
+`figma.variables.getLocalVariables()`, `createVariable()`, `createVariableCollection()`, `setBoundVariable()`.
-The `FigmaAPI` class is the **same API surface** that AI tools use. Currently `src/ai/tools.ts` calls `store.createShape()`, `store.updateNodeWithUndo()`, etc. — these should be refactored to go through `FigmaAPI`:
+### Phase 4: Stile & Erweitert
-```ts
-// Before (current AI tools)
-execute: async ({ type, x, y, width, height }) => {
- const id = store.createShape(type, x, y, width, height)
- return { id }
-}
+Paint/Text/Effekt-Stile, Boolesche Operationen, JSX-Renderer.
-// After (using FigmaAPI)
-execute: async ({ type, x, y, width, height }) => {
- const frame = figma.createFrame()
- frame.resize(width, height)
- frame.x = x
- frame.y = y
- return { id: frame.id }
-}
-```
+## Gemeinsam mit KI-Werkzeugen
-This ensures CLI scripts and AI tools behave identically.
+Die `FigmaAPI`-Klasse ist **dieselbe API-Oberfläche**, die KI-Werkzeuge verwenden. Dies stellt sicher, dass CLI-Skripte und KI-Werkzeuge identisch funktionieren.
-## File Layout
+## Dateilayout
```
packages/core/src/
- figma-api.ts # FigmaAPI class + FigmaNode proxy (Phase 1–4)
- figma-api.test.ts # Unit tests against headless SceneGraph
-
+ figma-api.ts # FigmaAPI-Klasse + FigmaNode-Proxy
packages/cli/src/commands/
- eval.ts # CLI command
-
-packages/cli/src/commands/eval.test.ts # Integration tests
+ eval.ts # CLI-Befehl
```
-
-## Test Plan
-
-### Unit tests (`packages/core/src/figma-api.test.ts`)
-
-1. **Node creation** — each `createX()` creates correct type, added to current page
-2. **Property access** — `.fills`, `.x`, `.width`, `.name`, `.characters` read/write correctly
-3. **Resize** — `.resize(w, h)` updates width/height
-4. **Tree operations** — `.appendChild()`, `.insertChild()`, `.remove()`, `.parent`, `.children`
-5. **Traversal** — `.findAll()`, `.findOne()`, `.findChild()`, `.findChildren()` with callbacks
-6. **Auto-layout** — `.layoutMode`, `.itemSpacing`, `.paddingTop`, etc.
-7. **Text** — `.characters` maps to `.text`, `.fontName` maps to `{ family, style }`
-8. **Mixed values** — `.cornerRadius` returns `figma.mixed` when corners differ
-9. **Selection** — `figma.currentPage.selection` get/set
-10. **Page switching** — `figma.currentPage = page2` works
-11. **Group/ungroup** — `figma.group()` creates group, `figma.ungroup()` dissolves it
-12. **Clone** — node creation produces independent copies
-
-### CLI integration tests (`packages/cli/src/commands/eval.test.ts`)
-
-1. **Basic eval** — `eval test.fig --code 'return figma.currentPage.name'` → page name
-2. **Create + read** — create a frame, return its properties
-3. **Query nodes** — `findAll` returns correct nodes
-4. **Write back** — `--write` saves changes, reloading shows them
-5. **Stdin** — `echo 'return 42' | bun open-pencil eval test.fig --stdin` → `42`
-6. **JSON output** — `--json` returns valid JSON
-7. **Error handling** — syntax errors, runtime errors reported cleanly
-
-## Implementation Order
-
-1. **`FigmaNode` proxy** — property mapping, `.resize()`, `.remove()`, tree methods
-2. **`FigmaAPI` class** — `createFrame/Rectangle/...`, `.root`, `.currentPage`, `.getNodeById()`, `.mixed`, `.group()`
-3. **CLI `eval` command** — argument parsing, code wrapping, output formatting
-4. **Unit tests** — all 12 test groups above
-5. **CLI integration tests** — all 7 test groups above
-6. **Wire to AI tools** — refactor `src/ai/tools.ts` to use `FigmaAPI` where possible
-7. **Phase 2** — components & instances
-8. **Phase 3** — variables
-9. **Phase 4** — styles, boolean ops, JSX renderer
-
-## Property Mapping Reference
-
-| Figma Property | SceneNode Field | Type | Notes |
-|---------------|-----------------|------|-------|
-| `characters` | `text` | `string` | |
-| `fontName` | `fontFamily` + `fontWeight` + `italic` | `{ family, style }` | Computed: `style` = "Bold Italic" etc. |
-| `strokeWeight` | `strokes[0].weight` | `number` | Computed |
-| `strokeAlign` | `strokes[0].align` | `string` | Computed |
-| `primaryAxisAlignItems` | `primaryAxisAlign` | `string` | |
-| `counterAxisAlignItems` | `counterAxisAlign` | `string` | |
-| `layoutSizingHorizontal` | `primaryAxisSizing` or `counterAxisSizing` | `string` | Depends on `layoutMode` |
-| `layoutSizingVertical` | (opposite of horizontal) | `string` | |
-| `absoluteTransform` | computed from `x`, `y`, `rotation` | `Transform` | Read-only |
-| `absoluteBoundingBox` | `getAbsoluteBounds(id)` | `Rect` | Read-only |
-| All others | Same name | Same type | Direct passthrough |
-
-## Open Questions
-
-1. **Font loading**: `figma.loadFontAsync()` — should it be a no-op (we don't have font gating) or should we track loaded fonts?
- → **Decision: No-op that returns resolved Promise.** We don't gate text editing on font loading.
-
-2. **Export in headless mode**: `node.exportAsync()` requires CanvasKit. Should eval load CanvasKit?
- → **Decision: Optional.** If CanvasKit is available (via `--with-canvaskit` flag or env), enable export. Otherwise, throw "Export requires CanvasKit" error.
-
-3. **`figma.mixed` symbol**: Should we use the actual Figma symbol or our own?
- → **Decision: Our own `Symbol('mixed')`.** Exposed as `figma.mixed`.
-
-4. **Undo**: `figma.commitUndo()` / `figma.triggerUndo()` — relevant in headless?
- → **Decision: No-op in CLI.** Undo only matters in the live editor. The AI tools can add undo support separately via EditorStore.
-
-5. **Write format**: Should `--write` produce `.fig` (Kiwi binary) or also support `.json`?
- → **Decision: `.fig` only for now.** JSON export is a separate feature.
diff --git a/packages/docs/de/reference/file-format.md b/packages/docs/de/reference/file-format.md
index 0bd57ce9c..73becf3b8 100644
--- a/packages/docs/de/reference/file-format.md
+++ b/packages/docs/de/reference/file-format.md
@@ -1,6 +1,6 @@
# Dateiformat
-## .fig File Structure
+## .fig-Dateistruktur
```
┌─────────────────────────────────┐
@@ -14,7 +14,7 @@
└─────────────────────────────────┘
```
-## Import Pipeline
+## Import-Pipeline
```
.fig file → Parse header → Decompress Zstd → Decode Kiwi schema
@@ -22,7 +22,7 @@
→ Resolve blob refs → Render on canvas
```
-## Export Pipeline
+## Export-Pipeline
```
SceneGraph → NodeChange[] → Kiwi encode → Compress (Zstd/deflate)
diff --git a/packages/docs/de/reference/mcp-tools.md b/packages/docs/de/reference/mcp-tools.md
index b1f0fbcae..e5708d8f0 100644
--- a/packages/docs/de/reference/mcp-tools.md
+++ b/packages/docs/de/reference/mcp-tools.md
@@ -1,10 +1,10 @@
# MCP-Server
-OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
+OpenPencil enthält einen MCP-Server (Model Context Protocol), der KI-Coding-Tools — Claude Code, Cursor, Windsurf usw. — ermöglicht, .fig-Dateien headless zu lesen und zu bearbeiten.
-Two transports: **stdio** for MCP clients, **HTTP** for everything else.
+Zwei Transporte
-## Install
+## **stdio** für MCP-Clients, **HTTP** für alles andere.
```sh
bun add -g @open-pencil/mcp
@@ -24,7 +24,7 @@ Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json`):
}
```
-Or run from source without installing:
+Installation:Oder aus dem Quellcode ausführen:
::: code-group
```json [Bun]
diff --git a/packages/docs/de/reference/scene-graph.md b/packages/docs/de/reference/scene-graph.md
index c3aee6777..6b33b7283 100644
--- a/packages/docs/de/reference/scene-graph.md
+++ b/packages/docs/de/reference/scene-graph.md
@@ -1,8 +1,8 @@
# Szenengraph
-## In-Memory Representation
+## In-Memory-Darstellung
-Nodes live in a flat `Map<string, Node>` keyed by GUID string. The tree structure is maintained via `parentIndex` references. This gives O(1) lookup by ID and efficient traversal.
+Knoten leben in einer flachen `Map<string, Node>` keyed by GUID string. Baumstruktur wird über `parentIndex` references. This gives O(1)-Lookup by ID and efficient traversal.
```typescript
interface SceneGraph {
diff --git a/packages/docs/es/development/contributing.md b/packages/docs/es/development/contributing.md
index 08ca85e2d..9c07b8211 100644
--- a/packages/docs/es/development/contributing.md
+++ b/packages/docs/es/development/contributing.md
@@ -1,94 +1,65 @@
# Contribuir
-## Project Structure
+## Estructura del proyecto
```
packages/
- core/ @open-pencil/core — engine (zero DOM deps)
- src/ Scene graph, renderer, layout, codec, kiwi, types
- cli/ @open-pencil/cli — headless CLI for .fig operations
- src/commands/ info, tree, find, export
+ core/ @open-pencil/core — Engine
+ cli/ @open-pencil/cli — Headless CLI
+ mcp/ @open-pencil/mcp — MCP server
+ docs/ @open-pencil/docs — VitePress
src/
- components/ Vue SFCs (canvas, panels, toolbar, color picker)
- properties/ Property panel sections (Appearance, Fill, Stroke, etc.)
- composables/ Canvas input, keyboard shortcuts, rendering hooks
- stores/ Editor state (Vue reactivity)
- engine/ Re-export shims from @open-pencil/core
- kiwi/ Re-export shims from @open-pencil/core
- types.ts Shared types (re-exported from core)
- constants.ts UI colors, defaults, thresholds
-desktop/ Tauri v2 (Rust + config)
+ components/ Vue SFCs
+ composables/ Canvas input, shortcuts, rendering
+ stores/ Editor state
+desktop/ Tauri v2
tests/
- e2e/ Playwright visual regression
- engine/ Unit tests (bun:test)
-docs/ VitePress documentation site
-openspec/
- specs/ Capability specifications (source of truth)
- changes/ Active and archived changes
+ e2e/ Playwright
+ engine/ bun:test
+openspec/ Specs + changes
```
-## Development Setup
+## Entorno de desarrollo
```sh
bun install
-bun run dev # Editor at localhost:1420
-bun run docs:dev # Docs at localhost:5173
+bun run dev # Editor: localhost:1420
+bun run docs:dev # Docs: localhost:5173
```
-## Code Style
+## Estilo de código
-### Tooling
+### Herramientas
| Tool | Command | Purpose |
|------|---------|---------|
-| oxlint | `bun run lint` | Linting (Rust-based, fast) |
-| oxfmt | `bun run format` | Code formatting |
-| tsgo | `bun run typecheck` | Type checking (Go-based TypeScript checker) |
-
-Run all checks:
+| oxlint | `bun run lint` | Linting |
+| oxfmt | `bun run format` | Formatting |
+| tsgo | `bun run typecheck` | Type checking |
```sh
bun run check
```
-### Conventions
-
-- **File names** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
-- **Components** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
-- **Constants** — SCREAMING_SNAKE_CASE
-- **Functions/variables** — camelCase
-- **Types/interfaces** — PascalCase
-
-### AI Agent Conventions
-
-Developers and AI agents working on the codebase should read `AGENTS.md` in the repo root ([view on GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Covers rendering, scene graph, components & instances, layout, UI, file format, Tauri conventions, and known issues.
+### Convenciones
-## Making Changes
+- kebab-case (files), PascalCase (components/types), camelCase (functions), SCREAMING_SNAKE_CASE (constants)
+- AGENTS.md — [GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)
-1. Check existing [openspec specs](/development/openspec) for the capability you're modifying
-2. Create an openspec change if adding new behavior: `openspec new change "my-change"`
-3. Implement the change
-4. Run `bun run check` and `bun run test`
-5. Submit a pull request
+## Realizar cambios
-## Key Files
+1. [OpenSpec](./openspec) specs
+2. `openspec new change "name"`
+3. `bun run check && bun run test`
+4. Pull request
-Engine source lives in `packages/core/src/`. The app's `src/engine/` and `src/kiwi/` are re-export shims — edit the core package, not the shims.
+## Archivos clave
| File | Purpose |
|------|---------|
-| `packages/core/src/scene-graph.ts` | Scene graph: nodes, variables, instances, hit testing |
-| `packages/core/src/renderer.ts` | CanvasKit rendering pipeline |
-| `packages/core/src/layout.ts` | Yoga layout adapter |
-| `packages/core/src/undo.ts` | Undo/redo manager |
-| `packages/core/src/clipboard.ts` | Figma-compatible clipboard |
-| `packages/core/src/vector.ts` | Vector network model |
-| `packages/core/src/render-image.ts` | Offscreen image export (PNG/JPG/WEBP) |
-| `packages/core/src/kiwi/codec.ts` | Kiwi binary encoder/decoder |
-| `packages/core/src/kiwi/fig-import.ts` | .fig file import logic |
-| `packages/cli/src/index.ts` | CLI entry point |
-| `packages/cli/src/commands/` | CLI commands (info, tree, find, export) |
-| `src/stores/editor.ts` | Global editor state |
-| `src/composables/use-canvas.ts` | Canvas rendering composable |
-| `src/composables/use-canvas-input.ts` | Mouse/touch input handling |
-| `src/composables/use-keyboard.ts` | Keyboard shortcut handling |
+| `packages/core/src/scene-graph.ts` | Scene graph |
+| `packages/core/src/renderer.ts` | CanvasKit rendering |
+| `packages/core/src/layout.ts` | Yoga layout |
+| `packages/core/src/kiwi/codec.ts` | Kiwi codec |
+| `packages/cli/src/commands/` | CLI commands |
+| `src/stores/editor.ts` | Editor state |
diff --git a/packages/docs/es/development/openspec.md b/packages/docs/es/development/openspec.md
index de2d4da98..01a79bed5 100644
--- a/packages/docs/es/development/openspec.md
+++ b/packages/docs/es/development/openspec.md
@@ -1,107 +1,73 @@
# Flujo OpenSpec
-OpenPencil uses [OpenSpec](https://github.com/Fission-AI/OpenSpec) for spec-driven development. Specifications are the source of truth for what the system does.
+OpenPencil usa OpenSpec para desarrollo dirigido por especificaciones. Las especificaciones son la fuente de verdad.
-## Structure
+## Estructura
```
openspec/
-├── specs/ # Source of truth: how the system works now
+├── specs/ # Source of truth
│ ├── scene-graph/
-│ │ └── spec.md
│ ├── canvas-rendering/
-│ │ └── spec.md
│ ├── auto-layout/
-│ │ └── spec.md
-│ └── ... # 19 capability specs total
-├── changes/ # Proposed changes (one directory per change)
-│ └── archive/ # Completed changes
-└── config.yaml # Optional configuration
+│ └── ... # 19 capability specs
+├── changes/
+│ └── archive/
+└── config.yaml
```
-## Current Specs
+## Especificaciones actuales
| Capability | Description |
|-----------|-------------|
-| scene-graph | Flat Map storage, CRUD, hit testing |
-| canvas-rendering | CanvasKit WASM rendering pipeline |
-| canvas-navigation | Pan, zoom, hand tool |
-| selection-manipulation | Click/marquee select, move, resize, rotate |
-| undo-redo | Inverse-command pattern |
-| text-editing | Text tool, Paragraph API, font loading |
-| pen-tool | Vector network model, bezier curves |
-| auto-layout | Yoga WASM flexbox, Shift+A toggle |
-| figma-clipboard | Bidirectional Kiwi binary clipboard |
-| fig-import | .fig file import pipeline |
-| kiwi-codec | Kiwi binary codec, sparse field IDs |
-| editor-ui | Vue 3 panels, toolbar, color picker |
-| snap-guides | Edge/center snapping, rotation-aware |
-| rulers | Canvas rulers, selection highlight |
-| group-ungroup | ⌘G/⇧⌘G, position-based sort |
-| desktop-app | Tauri v2, macOS menu bar |
-| testing | Playwright E2E, bun:test unit |
-| scrub-input | Drag-to-scrub numeric inputs |
-| tooling | Vite 7, oxlint, oxfmt, tsgo, VitePress |
-
-## Workflow
-
-### 1. Propose a Change
+| scene-graph | Flat Map, CRUD, hit testing |
+| canvas-rendering | CanvasKit WASM rendering |
+| auto-layout | Yoga WASM flexbox |
+| fig-import | .fig file import |
+| kiwi-codec | Kiwi binary codec |
+| editor-ui | Vue 3 panels, toolbar |
+| desktop-app | Tauri v2 |
+| testing | Playwright + bun:test |
+| tooling | Vite, oxlint, tsgo |
+
+## Flujo de trabajo
+
+### 1. Proponer un cambio
```
-/opsx:propose add-dark-mode
+/opsx:propose change-name
```
-Creates `openspec/changes/add-dark-mode/` with:
-- `proposal.md` — why and what changes
-- `design.md` — technical approach
-- `specs/` — delta specifications (ADDED/MODIFIED/REMOVED requirements)
-- `tasks.md` — implementation checklist
+→ proposal.md, design.md, specs/, tasks.md
-### 2. Implement
+### 2. Implementar
```
/opsx:apply
```
-Execute tasks from tasks.md, checking off items as they're completed.
-
-### 3. Archive
+### 3. Archivar
```
/opsx:archive
```
-- Merges delta specs into `openspec/specs/` (the baseline)
-- Moves the change to `openspec/changes/archive/`
-
-## Spec Format
-
-Each spec file follows a consistent structure:
+## Formato de especificaciones
```markdown
# capability-name Specification
-
-## Purpose
-One-line description of what this capability does.
-
## Requirements
-
### Requirement: Name
-Description using SHALL/MUST for normative requirements.
-
#### Scenario: Name
- **WHEN** condition
- **THEN** expected outcome
```
-Every requirement has at least one scenario. Scenarios are potential test cases.
-
-## CLI Commands
+## Comandos CLI
```sh
-openspec list # List active changes
-openspec show <name> # Show change details
-openspec status --change <name> # Artifact status
-openspec archive <name> # Archive completed change
-openspec update # Regenerate skills/prompts
+openspec list
+openspec show <name>
+openspec status --change <name>
+openspec archive <name>
```
diff --git a/packages/docs/es/development/roadmap.md b/packages/docs/es/development/roadmap.md
index 372b9c142..1ea211a73 100644
--- a/packages/docs/es/development/roadmap.md
+++ b/packages/docs/es/development/roadmap.md
@@ -1,145 +1,32 @@
# Hoja de ruta
-## Phases
+## Fase 1 ✅
+SceneGraph, Skia rendering, shapes, selection, zoom/pan, undo/redo, snap guides.
-### Phase 1: Core Engine ✅
+## Motor Core ✅
+Vue 3 + Reka UI panels, properties, layers, toolbar, Yoga auto-layout, inline text editing, canvas rulers.
-SceneGraph, Skia rendering, basic shapes, selection, zoom/pan, undo/redo.
+## Fase 2 ✅
+.fig import/export, Kiwi codec, clipboard, pen tool, vector networks, groups, Tauri v2 desktop, sections, multi-page, hover highlight, Tier 1 rendering.
-**Delivered:**
-- Scene graph with flat Map storage and parent-child tree
-- CanvasKit WASM rendering for all shape types
-- Click/shift/marquee selection with resize handles and rotation
-- Zoom/pan with keyboard shortcuts and trackpad gestures
-- Undo/redo wired into all operations
-- Snap guides with edge and center snapping
+## UI Editor + Layout ✅
+Components, instances, overrides, component sets, variables (COLOR/FLOAT/STRING/BOOLEAN), collections, modes, image export, context menu, rich text formatting.
-### Phase 2: Editor UI + Layout ✅
+## Fase 3 🟡
+@open-pencil/core, CLI (12 commands), MCP server (29+ tools), AI chat (OpenRouter), JSX renderer, code panel.
-Properties panel, layers panel, toolbar, Yoga layout integration, text editing.
+**Planned:** port remaining figma-use tools, attached mode, design guidelines, screenshot verification loop.
-**Delivered:**
-- Vue 3 + Reka UI panels (properties, layers, toolbar)
-- Properties panel split into sections (Appearance, Fill, Stroke, Typography, Layout, Position)
-- ScrubInput component for all numeric inputs
-- Color picker (HSV, hex, opacity)
-- Layers panel with tree view, drag reorder, visibility toggle
-- Auto-layout with Yoga WASM (direction, gap, padding, justify, align)
-- Inline text editing with CanvasKit Paragraph API
-- System font loading via Local Font Access API
-- Canvas rulers with selection highlight
+## E/S Archivos + Funciones Visuales 🔲
+Prototyping, comments, PWA, Linux Tauri builds, performance optimization, full Figma compatibility test suite.
-### Phase 3: File I/O + Visual Features ✅
+## Fase 4
-.fig import/export, Kiwi codec, clipboard, sections, pages, advanced rendering.
-
-**Delivered:**
-- .fig file import via Kiwi binary codec
-- .fig file export with Kiwi encoding, Zstd compression, thumbnail generation
-- Save (⌘S) and Save As (⇧⌘S) with native OS dialogs
-- Zstd compression via Tauri Rust command (deflate fallback in browser)
-- Vendored kiwi-schema with ESM + sparse field ID patches
-- Figma-compatible clipboard (bidirectional Kiwi binary)
-- Pen tool with vector network model
-- vectorNetworkBlob binary encode/decode
-- Group/ungroup (⌘G/⇧⌘G)
-- Tauri v2 desktop app with native menu bar (macOS/Windows/Linux)
-- Sections (S key) with title pills, auto-adopt, luminance-adaptive text
-- Multi-page documents with pages panel, per-page viewport
-- Hover highlight with shape-aware outlines
-- Tier 1 rendering: gradients, image fills, effects, strokes (cap/join/dash), arcs
-- Fill type picker with solid/gradient/image tabs and gradient stop editing
-- Canvas background color per page
-- Fig-import unit tests, layout unit tests, layers-panel E2E tests
-
-### Phase 4: Components + Variables ✅
-
-Components, instances, overrides, variables, collections, modes, image export.
-
-**Delivered:**
-- Component creation from frame/group or multi-selection (⌥⌘K)
-- Component sets from multiple components (⇧⌘K) with dashed purple border
-- Instance creation from components with child cloning and componentId mapping
-- Live component-instance sync with override preservation
-- Detach instance back to frame (⌥⌘B)
-- Go to main component (cross-page navigation)
-- Always-visible purple component/instance labels with diamond icon
-- Opaque container hit testing (click selects component, double-click enters)
-- Right-click context menu with clipboard, z-order, grouping, component, visibility, lock, move-to-page actions
-- Z-order manipulation (] bring to front, [ send to back)
-- Toggle visibility (⇧⌘H) and lock (⇧⌘L)
-- Move nodes between pages via context menu
-- Viewport culling, Paint reuse, RAF render coalescing
-- Effects panel UI (drop shadow, inner shadow, layer/background/foreground blur)
-- Independent corner radius controls (per-corner toggle in Appearance section)
-- GitHub Actions CI/CD for Windows (x64, arm64) and macOS (x64, arm64) builds
-- Polygon and Star drawing tools with pointCount and starInnerRadius
-- Resizable left/right panels via reka-ui Splitter (persistent layout)
-- @/ import alias, shared types module (src/types.ts, src/global.d.ts)
-- Codebase lint-clean: 0 oxlint warnings, 0 tsgo type errors
-- Variables: COLOR type with collections, modes, bindings, FillSection variable picker, .fig import
-- Variables dialog: TanStack Table with resizable columns, mode columns, collection tabs with rename, search, demo collections (Primitives/Semantic/Spacing), undo/redo for all variable operations
-- Image export: PNG/JPG/WEBP with ExportSection (scale, format, live preview), ⇧⌘E shortcut, context menu
-- Canvas-native text editing: TextEditor class in core, phantom textarea, cursor/selection/word boundaries on canvas, caret blinking, selection highlights
-- System font enumeration via font-kit Rust crate, OnceLock cache, preload on startup
-- Font picker: virtual scroll (reka-ui ListboxVirtualizer), search filter, CSS font preview
-- ColorInput component extraction, ColorPicker alpha slider checkerboard fix
-- App identity: pencil icon, Cargo crate open_pencil, macOS Dock "OpenPencil"
-- Splash loader during WASM initialization
-- Rich text style runs: per-selection ⌘B/I/U, StyleRun model, ParagraphBuilder pushStyle/pop, .fig roundtrip
-- B/I/U/S toggle buttons in TypographySection
-- Double-click (word), triple-click (select all) text selection
-
-**Remaining (deferred to Phase 6):**
-- Variant switching
-- Variable types: FLOAT, STRING, BOOLEAN editing UI
-- Variable-driven theming
-
-### Phase 5: AI Integration & Tooling 🟡
-
-Core extraction, CLI, MCP server, design guidelines, screenshot verification loop.
-
-**Delivered:**
-- @open-pencil/core extracted to packages/core/ (zero DOM deps, Bun workspace)
-- @open-pencil/cli with headless .fig operations (info, tree, find, export, analyze, node, pages, variables), CanvasKit CPU rasterization, --json output
-- JSX renderer: TreeNode builders (Frame, Text, Rectangle, etc.), renderTreeNode/renderJsx, Tailwind-like shorthand props, 27 tests
-- jscpd copy-paste detection (15.6% → 0.62%), kiwi-serialize.ts consolidation
-- .fig roundtrip tests with LFS fixtures (material3.fig 87K nodes, nuxtui.fig 314K nodes)
-- .fig import O(n²) → O(n) fix (37s → 535ms on 87K nodes), ByteBuffer optimization
-- test:coverage script
-- AI chat: OpenRouter direct (no backend), Stronghold key storage, 26 tools (create_shape, set_fill, set_effects, set_constraints, components, groups, pages, variables, eval_code, etc.), model selector, ⌘J toggle, streaming markdown, Playwright tests with mock transport
-- Code panel: sceneNodeToJsx() export, Prism.js highlighting, line numbers, copy button, 14 tests
-- Properties panel restructured: Design | Code | AI tabs
-- npm publishing preparation for core and cli packages
-
-**Planned:**
-- Port remaining figma-use tools (118 total, 26 currently implemented)
-- Attached mode: WebSocket to running editor for eval, create, export, screenshot
-- Design guidelines system
-- AI-driven design workflow via MCP
-- Screenshot verification loop
-
-### Phase 6: Polish + Distribution 🔲
-
-Prototyping, comments, desktop distribution, documentation, public launch.
-
-**Planned:**
-- Prototyping (frame connections, transitions)
-- Comments (pin, threads, resolve)
-- Linux Tauri builds (macOS and Windows already covered by CI)
-- PWA support
-- Documentation site (VitePress)
-- Performance optimization (Lighthouse > 90)
-- Full Figma compatibility test suite
-- Deferred from Phase 4: variant switching, FLOAT/STRING/BOOLEAN variable UI, variable-driven theming
-
-## Timeline
-
-| Phase | Estimated Duration | Status |
-|-------|-------------------|--------|
-| Phase 1: Core Engine | 3 months | ✅ Complete |
-| Phase 2: Editor UI + Layout | 3 months | ✅ Complete |
-| Phase 3: File I/O + Visual Features | 2 months | ✅ Complete |
-| Phase 4: Components + Variables | 2 months | ✅ Complete |
-| Phase 5: AI Integration & Tooling | 2 months | 🟡 In Progress |
-| Phase 6: Polish + Distribution | 2 months | 🔲 Planned |
+| Phase | Componentes + Variables | Fase 5: Integración IA & Herramientas:Fase 6: Pulido + Distribución:Cronograma:Duración estimada:Estado |
+|-------|------|-----|
+| Fase 1 | 3 months | ✅ |
+| Motor Core | 3 months | ✅ |
+| Fase 2 | 2 months | ✅ |
+| UI Editor + Layout | 2 months | ✅ |
+| Fase 3 | 2 months | 🟡 |
+| E/S Archivos + Funciones Visuales | 2 months | 🔲 |
diff --git a/packages/docs/es/development/testing.md b/packages/docs/es/development/testing.md
index 3e7cd945c..7b40a0ee4 100644
--- a/packages/docs/es/development/testing.md
+++ b/packages/docs/es/development/testing.md
@@ -1,6 +1,6 @@
# Pruebas
-## Overview
+## Visión general
| Type | Framework | Command | Location |
|------|-----------|---------|----------|
@@ -8,84 +8,45 @@
| Figma CDP reference | Playwright | `bun run test:figma` | `tests/figma/` |
| Unit tests | bun:test | `bun run test:unit` | `tests/engine/` |
-## E2E Visual Regression
-
-Playwright creates shapes on the canvas and compares screenshots against baseline PNGs.
+## Regresión visual E2E
```sh
-bun run test # Run tests, compare against baselines
-bun run test:update # Regenerate baseline screenshots
+bun run test # Compare against baselines
+bun run test:update # Regenerate baselines
```
-### How It Works
-
-1. Tests load the editor in a headless browser
-2. The editor signals readiness via a `data-ready` HTML attribute
-3. Tests create shapes via the editor's API
-4. Screenshots are taken and compared against baselines using `toMatchSnapshot`
-5. Page is reused across test cases for speed (~2s total)
-
-### No-Chrome Test Mode
-
-The editor supports a test mode that hides UI chrome (toolbar, panels) for clean screenshot capture. Activated via URL parameter.
+1. Playwright → headless browser
+2. `data-ready` HTML attribute
+3. Create shapes → screenshot → `toMatchSnapshot`
-## Figma CDP Reference Tests
-
-A separate Playwright project connects to Figma via Chrome DevTools Protocol to capture reference screenshots for pixel-perfect comparison.
+## Tests de referencia Figma CDP
```sh
bun run figma:debug # Launch Figma with debugging port
-bun run test:figma # Connect to Figma, capture references
+bun run test:figma # Connect via CDP
```
-Requires Figma desktop app running with `--remote-debugging-port=9222`.
-
-## Unit Tests
-
-Engine unit tests use bun:test and target < 50ms execution:
+## Tests unitarios
```sh
bun run test:unit
```
-Tests cover:
-- Scene graph CRUD operations, parent-child relationships, z-ordering, hit testing
-- **Fig-import pipeline** — node type mapping, transforms, fills/strokes/effects, gradients, images, arcs, nested hierarchies (`tests/engine/fig-import.test.ts`)
-- **Layout computation** — Yoga auto-layout: direction, gap, padding, justify, align, child sizing (fixed/fill/hug), cross-axis sizing, wrap, nested layouts (`tests/engine/layout.test.ts`)
+- Scene graph CRUD, hit testing
+- Fig-import pipeline
+- Layout computation (Yoga)
+- MCP server edge cases
-### Writing Unit Tests
-
-```typescript
-import { describe, expect, it } from 'bun:test'
-import { SceneGraph } from '../../src/engine/scene-graph'
-
-describe('SceneGraph', () => {
- it('creates and retrieves a node', () => {
- const sg = new SceneGraph()
- const node = sg.createNode('RECTANGLE', sg.root, { name: 'Test' })
- expect(sg.getNode(node.guid)).toBeDefined()
- })
-})
-```
-
-## E2E Test Coverage
+## Cobertura de tests E2E
| Test file | Scope |
|-----------|-------|
-| `tests/e2e/layers-panel.spec.ts` | Layers panel tree structure, visibility toggles, selection sync |
-| `tests/e2e/visual.spec.ts` | Visual regression screenshots for shapes and rendering |
-
-## Test Helpers
-
-| File | Purpose |
-|------|---------|
-| `tests/helpers/canvas.ts` | Canvas setup and interaction utilities |
-| `tests/helpers/figma.ts` | Figma CDP connection helpers |
+| `tests/e2e/layers-panel.spec.ts` | Layers panel |
+| `tests/e2e/visual.spec.ts` | Visual regression |
-## Performance Targets
+## Objetivos de rendimiento
| Metric | Target |
|--------|--------|
-| E2E suite total | < 3s |
-| Unit test suite total | < 50ms |
-| Screenshot comparison | toMatchSnapshot (pixel-level) |
+| E2E suite | < 3s |
+| Unit tests | < 50ms |
diff --git a/packages/docs/es/eval-command.md b/packages/docs/es/eval-command.md
index 9f7c45018..f4d484cdd 100644
--- a/packages/docs/es/eval-command.md
+++ b/packages/docs/es/eval-command.md
@@ -1,437 +1,77 @@
-# `open-pencil eval` — Figma-like Plugin API for Headless Scripting
+# `open-pencil eval` — API de Plugin compatible con Figma para scripting headless
-## Overview
+## Visión general
-`bun open-pencil eval <file> --code '<js>'` executes JavaScript against a `.fig` file with a Figma-compatible `figma` global object. This enables headless scripting, batch operations, AI tool execution, and testing — all without the GUI.
+`bun open-pencil eval <file> --code '<js>'` ejecuta JavaScript contra un archivo `.fig` con un objeto global `figma` compatible con Figma. Esto permite scripting headless, operaciones por lotes, ejecución de herramientas IA y pruebas — todo sin interfaz gráfica.
-The `figma` object mirrors Figma's Plugin API surface as closely as possible, so existing Figma plugin knowledge and code snippets transfer directly.
+El objeto `figma` refleja la superficie de la API de Plugin de Figma lo más fielmente posible, por lo que el conocimiento existente sobre plugins de Figma y los fragmentos de código son directamente transferibles.
```bash
-# Create a frame, set auto-layout, add children
+# Crear un marco, configurar auto-layout, añadir hijos
bun open-pencil eval design.fig --code '
const frame = figma.createFrame()
frame.name = "Card"
frame.resize(300, 200)
frame.layoutMode = "VERTICAL"
frame.itemSpacing = 12
- frame.paddingTop = frame.paddingBottom = 16
- frame.paddingLeft = frame.paddingRight = 16
frame.fills = [{ type: "SOLID", color: { r: 1, g: 1, b: 1 } }]
-
- const title = figma.createText()
- title.characters = "Hello World"
- title.fontSize = 24
- frame.appendChild(title)
-
return { id: frame.id, name: frame.name }
'
-# Query nodes
+# Consultar nodos
bun open-pencil eval design.fig --code '
- const buttons = figma.currentPage.findAll(n => n.type === "FRAME" && n.name.includes("Button"))
- return buttons.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
+ const buttons = figma.currentPage.findAll(n => n.name.includes("Button"))
+ return buttons.map(b => ({ id: b.id, name: b.name }))
'
-# Read from stdin (for multiline scripts / piping)
-cat transform.js | bun open-pencil eval design.fig --stdin
-
-# Write changes back
+# Escribir los cambios
bun open-pencil eval design.fig --code '...' --write
-bun open-pencil eval design.fig --code '...' -o modified.fig
```
-## Architecture
+## Arquitectura
```
-┌──────────────────────────────────────────────────────┐
-│ CLI: `open-pencil eval <file> --code '...'` │
-│ ↓ │
-│ loadDocument(file) → SceneGraph │
-│ ↓ │
-│ FigmaAPI(sceneGraph) → `figma` proxy object │
-│ ↓ │
-│ AsyncFunction('figma', wrappedCode)(figmaProxy) │
-│ ↓ │
-│ print result as JSON / agentfmt │
-│ optionally: saveDocument(file) if --write │
-└──────────────────────────────────────────────────────┘
+CLI: open-pencil eval <file> --code '...'
+ → loadDocument(file) → SceneGraph
+ → FigmaAPI(sceneGraph) → proxy `figma`
+ → AsyncFunction('figma', code)(figmaProxy)
+ → imprimir resultado / guardar con --write
```
-### Key classes
-
-| Class | Location | Role |
-|-------|----------|------|
-| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy object implementing `figma.*` methods against `SceneGraph` |
-| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy wrapping `SceneNode` with Figma-style property access (`.fills`, `.resize()`, `.appendChild()`, etc.) |
-| `eval` command | `packages/cli/src/commands/eval.ts` | CLI command that loads doc, creates API, executes code |
-
-### Why in `@open-pencil/core`?
-
-The `FigmaAPI` class lives in core (not CLI) because:
-- **AI tools reuse it** — the chat panel's `render` tool can execute JSX through the same API
-- **Test scripts** — unit tests can use the API to set up fixtures
-- **No DOM deps** — runs headless in Bun, no browser APIs needed
-
-## `FigmaAPI` — Phased Implementation
-
-### Phase 1: Core (MVP for eval command)
-
-These cover ~80% of real plugin scripts:
-
-#### Document & Page
-
-| Figma API | Our implementation | Notes |
-|-----------|--------------------|-------|
-| `figma.root` | Getter → proxy for root node | `.children` returns page proxies |
-| `figma.currentPage` | Getter/setter → first page by default | Settable to any page proxy |
-| `figma.currentPage.selection` | Get/set → tracked selection array | |
-| `figma.getNodeById(id)` | `graph.getNode(id)` wrapped in proxy | Sync, like Figma's deprecated version |
+### Clases principales
-#### Node Creation
+| Clase | Ubicación | Rol |
+|-------|-----------|-----|
+| `FigmaAPI` | `packages/core/src/figma-api.ts` | Objeto proxy que implementa métodos `figma.*` |
+| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy que envuelve `SceneNode` con acceso a propiedades estilo Figma |
+| Comando `eval` | `packages/cli/src/commands/eval.ts` | Carga documento, crea API, ejecuta código |
-| Figma API | Maps to |
-|-----------|---------|
-| `figma.createFrame()` | `graph.createNode('FRAME', currentPageId)` |
-| `figma.createRectangle()` | `graph.createNode('RECTANGLE', ...)` |
-| `figma.createEllipse()` | `graph.createNode('ELLIPSE', ...)` |
-| `figma.createText()` | `graph.createNode('TEXT', ...)` |
-| `figma.createLine()` | `graph.createNode('LINE', ...)` |
-| `figma.createPolygon()` | `graph.createNode('POLYGON', ...)` |
-| `figma.createStar()` | `graph.createNode('STAR', ...)` |
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createPage()` | `graph.addPage(name)` |
-| `figma.createSection()` | `graph.createNode('SECTION', ...)` |
+### ¿Por qué en `@open-pencil/core`?
-#### Node Properties (via `FigmaNode` proxy)
+La clase `FigmaAPI` vive en core porque: las herramientas IA la reutilizan, los tests la usan y no tiene dependencias DOM.
-Read/write on any node proxy. Property access maps to `SceneNode` fields:
+## Comando CLI
-```ts
-// Geometry
-node.x, node.y // direct
-node.width, node.height // read-only, use node.resize(w, h)
-node.rotation // direct
-node.resize(w, h) // updates width + height
-node.resizeWithoutConstraints(w, h) // same (no constraint engine yet)
-
-// Visual
-node.fills // get/set Fill[]
-node.strokes // get/set Stroke[]
-node.effects // get/set Effect[]
-node.opacity // get/set number
-node.visible // get/set boolean
-node.locked // get/set boolean
-node.blendMode // get/set BlendMode
-node.clipsContent // get/set boolean
-
-// Corner radius
-node.cornerRadius // get/set (number or figma.mixed)
-node.topLeftRadius // get/set
-node.topRightRadius // get/set
-node.bottomLeftRadius // get/set
-node.bottomRightRadius // get/set
-node.cornerSmoothing // get/set
-
-// Identity
-node.id // read-only
-node.name // get/set
-node.type // read-only
-node.parent // read-only → FigmaNode | null
-node.removed // read-only boolean
-```
-
-#### Tree Operations
-
-```ts
-node.children // read-only FigmaNode[]
-node.appendChild(child) // reparent to end
-node.insertChild(index, child) // reparent at index
-node.remove() // graph.deleteNode(id)
-
-// Traversal
-node.findAll(callback?) // recursive find
-node.findOne(callback) // first match
-node.findChild(callback) // direct children only
-node.findChildren(callback?) // direct children only
```
+bun open-pencil eval <file> [opciones]
-#### Auto-layout
-
-```ts
-node.layoutMode // 'NONE' | 'HORIZONTAL' | 'VERTICAL'
-node.primaryAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'
-node.counterAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'BASELINE'
-node.itemSpacing // number
-node.counterAxisSpacing // number | null
-node.paddingTop / Right / Bottom / Left // number
-node.layoutWrap // 'NO_WRAP' | 'WRAP'
-
-// Child sizing
-node.layoutPositioning // 'AUTO' | 'ABSOLUTE'
-node.layoutGrow // 0 | 1
-node.layoutSizingHorizontal // 'FIXED' | 'HUG' | 'FILL'
-node.layoutSizingVertical // 'FIXED' | 'HUG' | 'FILL'
-```
-
-#### Text
-
-```ts
-node.characters // get/set (maps to node.text)
-node.fontSize // get/set
-node.fontName // get/set { family, style }
-node.fontWeight // get/set
-node.textAlignHorizontal // get/set
-node.textAlignVertical // get/set
-node.textAutoResize // get/set
-node.letterSpacing // get/set
-node.lineHeight // get/set
-node.maxLines // get/set
-node.textCase // get/set
-node.textDecoration // get/set
-```
-
-#### Stroke details
-
-```ts
-node.strokeWeight // get/set (maps to strokes[0].weight)
-node.strokeAlign // get/set (maps to strokes[0].align)
-node.dashPattern // get/set
-```
-
-#### Misc
-
-```ts
-figma.mixed // Symbol sentinel for mixed values
-figma.group(nodes, parent) // creates GROUP with given children
-figma.ungroup(node) // ungroups, reparents children
-figma.flatten(nodes) // NOT IMPLEMENTED YET — returns first node
-```
-
-#### Export
-
-```ts
-node.exportAsync(settings?) // only works if CanvasKit is loaded
- // settings: { format: 'PNG'|'JPG'|'SVG', constraint? }
-```
-
-### Phase 2: Components & Instances
-
-| API | Maps to |
-|-----|---------|
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createComponentFromNode(node)` | Convert existing frame to component |
-| `figma.combineAsVariants(components, parent)` | Create COMPONENT_SET |
-| Node: `node.createInstance()` | `graph.createInstance(componentId, parentId)` |
-| Node: `node.detachInstance()` | `graph.detachInstance(id)` |
-| `figma.getNodeById(id).mainComponent` | `graph.getMainComponent(id)` |
-
-### Phase 3: Variables
-
-| API | Maps to |
-|-----|---------|
-| `figma.variables.getLocalVariables(type?)` | `graph.variables` filtered |
-| `figma.variables.getLocalVariableCollections()` | `graph.variableCollections` |
-| `figma.variables.createVariable(name, collection, type)` | `graph.addVariable(...)` |
-| `figma.variables.createVariableCollection(name)` | `graph.addCollection(...)` |
-| `figma.variables.getVariableById(id)` | `graph.variables.get(id)` |
-| `node.setBoundVariable(field, variable)` | `graph.bindVariable(...)` |
-| `node.boundVariables` | getter from SceneNode |
-
-### Phase 4: Styles & Advanced
-
-| API | Notes |
-|-----|-------|
-| `figma.createPaintStyle()` | Requires style storage in SceneGraph |
-| `figma.createTextStyle()` | Requires style storage in SceneGraph |
-| `figma.createEffectStyle()` | Requires style storage in SceneGraph |
-| `figma.loadFontAsync(fontName)` | No-op (we don't have font loading constraints) |
-| `figma.listAvailableFontsAsync()` | Return system fonts if available |
-| Boolean operations (`union`, `subtract`, `intersect`, `exclude`) | Requires path boolean engine |
-| `figma.createNodeFromJSXAsync(jsx)` | Port figma-use's JSX renderer |
-
-## `FigmaNode` Proxy Design
-
-The proxy wraps a `SceneNode` and translates Figma property names to our internal names. Key mappings:
+Argumentos:
+ file Archivo .fig sobre el que operar
-```ts
-const PROPERTY_MAP: Record<string, string> = {
- // Figma name → SceneNode field name (only where they differ)
- 'characters': 'text',
- 'strokeWeight': → computed from strokes[0].weight,
- 'strokeAlign': → computed from strokes[0].align,
- 'fontName': → computed from { family: fontFamily, style: ... },
- 'primaryAxisAlignItems': 'primaryAxisAlign',
- 'counterAxisAlignItems': 'counterAxisAlign',
- 'primaryAxisSizingMode': 'primaryAxisSizing', // value mapping: 'AUTO' → 'HUG', 'FIXED' → 'FIXED'
- 'counterAxisSizingMode': 'counterAxisSizing',
- 'layoutSizingHorizontal': → computed from primaryAxisSizing / counterAxisSizing depending on layoutMode
- 'layoutSizingVertical': → computed
-}
+Opciones:
+ --code, -c Código JavaScript a ejecutar
+ --stdin Leer código desde stdin
+ --write, -w Escribir cambios en el archivo de entrada
+ -o, --output Escribir en un archivo diferente
+ --json Salida como JSON
+ --quiet, -q Suprimir la salida
```
-Methods on the proxy:
-
-```ts
-class FigmaNode {
- // The proxy is created via: new Proxy(target, handler)
- // where handler.get intercepts property reads and handler.set intercepts writes
-
- resize(width: number, height: number): void
- resizeWithoutConstraints(width: number, height: number): void
- remove(): void
- appendChild(child: FigmaNode): void
- insertChild(index: number, child: FigmaNode): void
- findAll(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- findOne(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChild(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChildren(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- exportAsync(settings?: ExportSettings): Promise<Uint8Array>
-
- // Components (Phase 2)
- createInstance(): FigmaNode
- detachInstance(): void
- get mainComponent(): FigmaNode | null
-}
-```
-
-## CLI Command
-
-```
-bun open-pencil eval <file> [options]
-
-Arguments:
- file .fig file to operate on
-
-Options:
- --code, -c JavaScript code to execute (has access to `figma` global)
- --stdin Read code from stdin instead of --code
- --write, -w Write changes back to the input file
- -o, --output Write to a different file
- --json Output result as JSON (default for non-TTY)
- --quiet, -q Suppress output, only write file
-```
-
-### Execution model
-
-1. Load `.fig` → `SceneGraph`
-2. Create `FigmaAPI(graph)` → `figma` proxy
-3. Wrap user code in async function: `return (async () => { <code> })()`
-4. Execute with `figma` as sole argument
-5. Print return value (JSON or agentfmt)
-6. If `--write` or `-o`: serialize `SceneGraph` back to `.fig`
-
-### Return value formatting
-
-- `undefined` / `void` → no output
-- Primitives → printed directly
-- Objects/arrays → `JSON.stringify(result, null, 2)` or agentfmt tables
-- `FigmaNode` → serialized as `{ id, type, name, x, y, width, height, fills, ... }`
-- Arrays of `FigmaNode` → serialized as list
-
-## Shared with AI Tools
-
-The `FigmaAPI` class is the **same API surface** that AI tools use. Currently `src/ai/tools.ts` calls `store.createShape()`, `store.updateNodeWithUndo()`, etc. — these should be refactored to go through `FigmaAPI`:
-
-```ts
-// Before (current AI tools)
-execute: async ({ type, x, y, width, height }) => {
- const id = store.createShape(type, x, y, width, height)
- return { id }
-}
-
-// After (using FigmaAPI)
-execute: async ({ type, x, y, width, height }) => {
- const frame = figma.createFrame()
- frame.resize(width, height)
- frame.x = x
- frame.y = y
- return { id: frame.id }
-}
-```
-
-This ensures CLI scripts and AI tools behave identically.
-
-## File Layout
-
-```
-packages/core/src/
- figma-api.ts # FigmaAPI class + FigmaNode proxy (Phase 1–4)
- figma-api.test.ts # Unit tests against headless SceneGraph
-
-packages/cli/src/commands/
- eval.ts # CLI command
-
-packages/cli/src/commands/eval.test.ts # Integration tests
-```
-
-## Test Plan
-
-### Unit tests (`packages/core/src/figma-api.test.ts`)
-
-1. **Node creation** — each `createX()` creates correct type, added to current page
-2. **Property access** — `.fills`, `.x`, `.width`, `.name`, `.characters` read/write correctly
-3. **Resize** — `.resize(w, h)` updates width/height
-4. **Tree operations** — `.appendChild()`, `.insertChild()`, `.remove()`, `.parent`, `.children`
-5. **Traversal** — `.findAll()`, `.findOne()`, `.findChild()`, `.findChildren()` with callbacks
-6. **Auto-layout** — `.layoutMode`, `.itemSpacing`, `.paddingTop`, etc.
-7. **Text** — `.characters` maps to `.text`, `.fontName` maps to `{ family, style }`
-8. **Mixed values** — `.cornerRadius` returns `figma.mixed` when corners differ
-9. **Selection** — `figma.currentPage.selection` get/set
-10. **Page switching** — `figma.currentPage = page2` works
-11. **Group/ungroup** — `figma.group()` creates group, `figma.ungroup()` dissolves it
-12. **Clone** — node creation produces independent copies
-
-### CLI integration tests (`packages/cli/src/commands/eval.test.ts`)
-
-1. **Basic eval** — `eval test.fig --code 'return figma.currentPage.name'` → page name
-2. **Create + read** — create a frame, return its properties
-3. **Query nodes** — `findAll` returns correct nodes
-4. **Write back** — `--write` saves changes, reloading shows them
-5. **Stdin** — `echo 'return 42' | bun open-pencil eval test.fig --stdin` → `42`
-6. **JSON output** — `--json` returns valid JSON
-7. **Error handling** — syntax errors, runtime errors reported cleanly
-
-## Implementation Order
-
-1. **`FigmaNode` proxy** — property mapping, `.resize()`, `.remove()`, tree methods
-2. **`FigmaAPI` class** — `createFrame/Rectangle/...`, `.root`, `.currentPage`, `.getNodeById()`, `.mixed`, `.group()`
-3. **CLI `eval` command** — argument parsing, code wrapping, output formatting
-4. **Unit tests** — all 12 test groups above
-5. **CLI integration tests** — all 7 test groups above
-6. **Wire to AI tools** — refactor `src/ai/tools.ts` to use `FigmaAPI` where possible
-7. **Phase 2** — components & instances
-8. **Phase 3** — variables
-9. **Phase 4** — styles, boolean ops, JSX renderer
-
-## Property Mapping Reference
-
-| Figma Property | SceneNode Field | Type | Notes |
-|---------------|-----------------|------|-------|
-| `characters` | `text` | `string` | |
-| `fontName` | `fontFamily` + `fontWeight` + `italic` | `{ family, style }` | Computed: `style` = "Bold Italic" etc. |
-| `strokeWeight` | `strokes[0].weight` | `number` | Computed |
-| `strokeAlign` | `strokes[0].align` | `string` | Computed |
-| `primaryAxisAlignItems` | `primaryAxisAlign` | `string` | |
-| `counterAxisAlignItems` | `counterAxisAlign` | `string` | |
-| `layoutSizingHorizontal` | `primaryAxisSizing` or `counterAxisSizing` | `string` | Depends on `layoutMode` |
-| `layoutSizingVertical` | (opposite of horizontal) | `string` | |
-| `absoluteTransform` | computed from `x`, `y`, `rotation` | `Transform` | Read-only |
-| `absoluteBoundingBox` | `getAbsoluteBounds(id)` | `Rect` | Read-only |
-| All others | Same name | Same type | Direct passthrough |
-
-## Open Questions
-
-1. **Font loading**: `figma.loadFontAsync()` — should it be a no-op (we don't have font gating) or should we track loaded fonts?
- → **Decision: No-op that returns resolved Promise.** We don't gate text editing on font loading.
-
-2. **Export in headless mode**: `node.exportAsync()` requires CanvasKit. Should eval load CanvasKit?
- → **Decision: Optional.** If CanvasKit is available (via `--with-canvaskit` flag or env), enable export. Otherwise, throw "Export requires CanvasKit" error.
-
-3. **`figma.mixed` symbol**: Should we use the actual Figma symbol or our own?
- → **Decision: Our own `Symbol('mixed')`.** Exposed as `figma.mixed`.
+## Implementación por fases
-4. **Undo**: `figma.commitUndo()` / `figma.triggerUndo()` — relevant in headless?
- → **Decision: No-op in CLI.** Undo only matters in the live editor. The AI tools can add undo support separately via EditorStore.
+- **Fase 1: Core** — creación de nodos, propiedades, operaciones de árbol, auto-layout, texto (~80% de scripts reales)
+- **Fase 2: Componentes e Instancias** — createComponent, createInstance, detachInstance
+- **Fase 3: Variables** — getLocalVariables, createVariable, setBoundVariable
+- **Fase 4: Estilos y Avanzado** — estilos paint/texto/efectos, operaciones booleanas
-5. **Write format**: Should `--write` produce `.fig` (Kiwi binary) or also support `.json`?
- → **Decision: `.fig` only for now.** JSON export is a separate feature.
+[Referencia API completa en inglés](/eval-command)
diff --git a/packages/docs/es/reference/file-format.md b/packages/docs/es/reference/file-format.md
index 5fd8620d3..fe3594464 100644
--- a/packages/docs/es/reference/file-format.md
+++ b/packages/docs/es/reference/file-format.md
@@ -1,6 +1,6 @@
# Formato de archivo
-## .fig File Structure
+## Estructura de archivos .fig
```
┌─────────────────────────────────┐
@@ -14,7 +14,7 @@
└─────────────────────────────────┘
```
-## Import Pipeline
+## Pipeline de importación
```
.fig file → Parse header → Decompress Zstd → Decode Kiwi schema
@@ -22,7 +22,7 @@
→ Resolve blob refs → Render on canvas
```
-## Export Pipeline
+## Pipeline de exportación
```
SceneGraph → NodeChange[] → Kiwi encode → Compress (Zstd/deflate)
diff --git a/packages/docs/es/reference/mcp-tools.md b/packages/docs/es/reference/mcp-tools.md
index 21f06a4e8..b2d555a2f 100644
--- a/packages/docs/es/reference/mcp-tools.md
+++ b/packages/docs/es/reference/mcp-tools.md
@@ -1,10 +1,10 @@
# Servidor MCP
-OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
+OpenPencil incluye un servidor MCP (Model Context Protocol) que permite a las herramientas de coding IA — Claude Code, Cursor, Windsurf etc. — leer y modificar archivos .fig headless.
-Two transports: **stdio** for MCP clients, **HTTP** for everything else.
+Dos transportes
-## Install
+## **stdio** para clientes MCP, **HTTP** para todo lo demás.
```sh
bun add -g @open-pencil/mcp
@@ -24,7 +24,7 @@ Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json`):
}
```
-Or run from source without installing:
+Instalación:O ejecutar desde el código fuente:
::: code-group
```json [Bun]
diff --git a/packages/docs/es/reference/scene-graph.md b/packages/docs/es/reference/scene-graph.md
index e4b5b9dfe..2f0f06eef 100644
--- a/packages/docs/es/reference/scene-graph.md
+++ b/packages/docs/es/reference/scene-graph.md
@@ -1,8 +1,8 @@
# Grafo de escena
-## In-Memory Representation
+## Representación en memoria
-Nodes live in a flat `Map<string, Node>` keyed by GUID string. The tree structure is maintained via `parentIndex` references. This gives O(1) lookup by ID and efficient traversal.
+Los nodos viven en un Map plano `Map<string, Node>` keyed by GUID string. La estructura de árbol se mantiene via `parentIndex` references. This gives Búsqueda O(1) by ID and efficient traversal.
```typescript
interface SceneGraph {
diff --git a/packages/docs/fr/development/contributing.md b/packages/docs/fr/development/contributing.md
index 772a05e5c..dd16eae7e 100644
--- a/packages/docs/fr/development/contributing.md
+++ b/packages/docs/fr/development/contributing.md
@@ -1,51 +1,41 @@
# Contribuer
-## Project Structure
+## Structure du projet
```
packages/
- core/ @open-pencil/core — engine (zero DOM deps)
- src/ Scene graph, renderer, layout, codec, kiwi, types
- cli/ @open-pencil/cli — headless CLI for .fig operations
- src/commands/ info, tree, find, export
+ core/ @open-pencil/core — Engine
+ cli/ @open-pencil/cli — Headless CLI
+ mcp/ @open-pencil/mcp — MCP server
+ docs/ @open-pencil/docs — VitePress
src/
- components/ Vue SFCs (canvas, panels, toolbar, color picker)
- properties/ Property panel sections (Appearance, Fill, Stroke, etc.)
- composables/ Canvas input, keyboard shortcuts, rendering hooks
- stores/ Editor state (Vue reactivity)
- engine/ Re-export shims from @open-pencil/core
- kiwi/ Re-export shims from @open-pencil/core
- types.ts Shared types (re-exported from core)
- constants.ts UI colors, defaults, thresholds
-desktop/ Tauri v2 (Rust + config)
+ components/ Vue SFCs
+ composables/ Canvas input, shortcuts, rendering
+ stores/ Editor state
+desktop/ Tauri v2
tests/
- e2e/ Playwright visual regression
- engine/ Unit tests (bun:test)
-docs/ VitePress documentation site
-openspec/
- specs/ Capability specifications (source of truth)
- changes/ Active and archived changes
+ e2e/ Playwright
+ engine/ bun:test
+openspec/ Specs + changes
```
-## Development Setup
+## Environnement de développement
```sh
bun install
-bun run dev # Editor at localhost:1420
-bun run docs:dev # Docs at localhost:5173
+bun run dev # Editor: localhost:1420
+bun run docs:dev # Docs: localhost:5173
```
-## Code Style
+## Style de code
-### Tooling
+### Outils
| Tool | Command | Purpose |
|------|---------|---------|
-| oxlint | `bun run lint` | Linting (Rust-based, fast) |
-| oxfmt | `bun run format` | Code formatting |
-| tsgo | `bun run typecheck` | Type checking (Go-based TypeScript checker) |
-
-Run all checks:
+| oxlint | `bun run lint` | Linting |
+| oxfmt | `bun run format` | Formatting |
+| tsgo | `bun run typecheck` | Type checking |
```sh
bun run check
@@ -53,42 +43,23 @@ bun run check
### Conventions
-- **File names** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
-- **Components** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
-- **Constants** — SCREAMING_SNAKE_CASE
-- **Functions/variables** — camelCase
-- **Types/interfaces** — PascalCase
-
-### AI Agent Conventions
-
-Developers and AI agents working on the codebase should read `AGENTS.md` in the repo root ([view on GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Covers rendering, scene graph, components & instances, layout, UI, file format, Tauri conventions, and known issues.
-
-## Making Changes
+- kebab-case (files), PascalCase (components/types), camelCase (functions), SCREAMING_SNAKE_CASE (constants)
+- AGENTS.md — [GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)
-1. Check existing [openspec specs](/development/openspec) for the capability you're modifying
-2. Create an openspec change if adding new behavior: `openspec new change "my-change"`
-3. Implement the change
-4. Run `bun run check` and `bun run test`
-5. Submit a pull request
+## Apporter des modifications
-## Key Files
+1. [OpenSpec](./openspec) specs
+2. `openspec new change "name"`
+3. `bun run check && bun run test`
+4. Pull request
-Engine source lives in `packages/core/src/`. The app's `src/engine/` and `src/kiwi/` are re-export shims — edit the core package, not the shims.
+## Fichiers clés
| File | Purpose |
|------|---------|
-| `packages/core/src/scene-graph.ts` | Scene graph: nodes, variables, instances, hit testing |
-| `packages/core/src/renderer.ts` | CanvasKit rendering pipeline |
-| `packages/core/src/layout.ts` | Yoga layout adapter |
-| `packages/core/src/undo.ts` | Undo/redo manager |
-| `packages/core/src/clipboard.ts` | Figma-compatible clipboard |
-| `packages/core/src/vector.ts` | Vector network model |
-| `packages/core/src/render-image.ts` | Offscreen image export (PNG/JPG/WEBP) |
-| `packages/core/src/kiwi/codec.ts` | Kiwi binary encoder/decoder |
-| `packages/core/src/kiwi/fig-import.ts` | .fig file import logic |
-| `packages/cli/src/index.ts` | CLI entry point |
-| `packages/cli/src/commands/` | CLI commands (info, tree, find, export) |
-| `src/stores/editor.ts` | Global editor state |
-| `src/composables/use-canvas.ts` | Canvas rendering composable |
-| `src/composables/use-canvas-input.ts` | Mouse/touch input handling |
-| `src/composables/use-keyboard.ts` | Keyboard shortcut handling |
+| `packages/core/src/scene-graph.ts` | Scene graph |
+| `packages/core/src/renderer.ts` | CanvasKit rendering |
+| `packages/core/src/layout.ts` | Yoga layout |
+| `packages/core/src/kiwi/codec.ts` | Kiwi codec |
+| `packages/cli/src/commands/` | CLI commands |
+| `src/stores/editor.ts` | Editor state |
diff --git a/packages/docs/fr/development/openspec.md b/packages/docs/fr/development/openspec.md
index 4907fe432..fb17f0c26 100644
--- a/packages/docs/fr/development/openspec.md
+++ b/packages/docs/fr/development/openspec.md
@@ -1,107 +1,73 @@
# Workflow OpenSpec
-OpenPencil uses [OpenSpec](https://github.com/Fission-AI/OpenSpec) for spec-driven development. Specifications are the source of truth for what the system does.
+OpenPencil utilise OpenSpec pour le développement piloté par les spécifications. Les spécifications sont la source de vérité.
## Structure
```
openspec/
-├── specs/ # Source of truth: how the system works now
+├── specs/ # Source of truth
│ ├── scene-graph/
-│ │ └── spec.md
│ ├── canvas-rendering/
-│ │ └── spec.md
│ ├── auto-layout/
-│ │ └── spec.md
-│ └── ... # 19 capability specs total
-├── changes/ # Proposed changes (one directory per change)
-│ └── archive/ # Completed changes
-└── config.yaml # Optional configuration
+│ └── ... # 19 capability specs
+├── changes/
+│ └── archive/
+└── config.yaml
```
-## Current Specs
+## Spécifications actuelles
| Capability | Description |
|-----------|-------------|
-| scene-graph | Flat Map storage, CRUD, hit testing |
-| canvas-rendering | CanvasKit WASM rendering pipeline |
-| canvas-navigation | Pan, zoom, hand tool |
-| selection-manipulation | Click/marquee select, move, resize, rotate |
-| undo-redo | Inverse-command pattern |
-| text-editing | Text tool, Paragraph API, font loading |
-| pen-tool | Vector network model, bezier curves |
-| auto-layout | Yoga WASM flexbox, Shift+A toggle |
-| figma-clipboard | Bidirectional Kiwi binary clipboard |
-| fig-import | .fig file import pipeline |
-| kiwi-codec | Kiwi binary codec, sparse field IDs |
-| editor-ui | Vue 3 panels, toolbar, color picker |
-| snap-guides | Edge/center snapping, rotation-aware |
-| rulers | Canvas rulers, selection highlight |
-| group-ungroup | ⌘G/⇧⌘G, position-based sort |
-| desktop-app | Tauri v2, macOS menu bar |
-| testing | Playwright E2E, bun:test unit |
-| scrub-input | Drag-to-scrub numeric inputs |
-| tooling | Vite 7, oxlint, oxfmt, tsgo, VitePress |
+| scene-graph | Flat Map, CRUD, hit testing |
+| canvas-rendering | CanvasKit WASM rendering |
+| auto-layout | Yoga WASM flexbox |
+| fig-import | .fig file import |
+| kiwi-codec | Kiwi binary codec |
+| editor-ui | Vue 3 panels, toolbar |
+| desktop-app | Tauri v2 |
+| testing | Playwright + bun:test |
+| tooling | Vite, oxlint, tsgo |
## Workflow
-### 1. Propose a Change
+### 1. Proposer une modification
```
-/opsx:propose add-dark-mode
+/opsx:propose change-name
```
-Creates `openspec/changes/add-dark-mode/` with:
-- `proposal.md` — why and what changes
-- `design.md` — technical approach
-- `specs/` — delta specifications (ADDED/MODIFIED/REMOVED requirements)
-- `tasks.md` — implementation checklist
+→ proposal.md, design.md, specs/, tasks.md
-### 2. Implement
+### 2. Implémenter
```
/opsx:apply
```
-Execute tasks from tasks.md, checking off items as they're completed.
-
-### 3. Archive
+### 3. Archiver
```
/opsx:archive
```
-- Merges delta specs into `openspec/specs/` (the baseline)
-- Moves the change to `openspec/changes/archive/`
-
-## Spec Format
-
-Each spec file follows a consistent structure:
+## Format des spécifications
```markdown
# capability-name Specification
-
-## Purpose
-One-line description of what this capability does.
-
## Requirements
-
### Requirement: Name
-Description using SHALL/MUST for normative requirements.
-
#### Scenario: Name
- **WHEN** condition
- **THEN** expected outcome
```
-Every requirement has at least one scenario. Scenarios are potential test cases.
-
-## CLI Commands
+## Commandes CLI
```sh
-openspec list # List active changes
-openspec show <name> # Show change details
-openspec status --change <name> # Artifact status
-openspec archive <name> # Archive completed change
-openspec update # Regenerate skills/prompts
+openspec list
+openspec show <name>
+openspec status --change <name>
+openspec archive <name>
```
diff --git a/packages/docs/fr/development/roadmap.md b/packages/docs/fr/development/roadmap.md
index 9d224ec36..237bbc24e 100644
--- a/packages/docs/fr/development/roadmap.md
+++ b/packages/docs/fr/development/roadmap.md
@@ -1,145 +1,32 @@
# Feuille de route
-## Phases
+## Phase 1 ✅
+SceneGraph, Skia rendering, shapes, selection, zoom/pan, undo/redo, snap guides.
-### Phase 1: Core Engine ✅
+## Moteur Core ✅
+Vue 3 + Reka UI panels, properties, layers, toolbar, Yoga auto-layout, inline text editing, canvas rulers.
-SceneGraph, Skia rendering, basic shapes, selection, zoom/pan, undo/redo.
+## Phase 2 ✅
+.fig import/export, Kiwi codec, clipboard, pen tool, vector networks, groups, Tauri v2 desktop, sections, multi-page, hover highlight, Tier 1 rendering.
-**Delivered:**
-- Scene graph with flat Map storage and parent-child tree
-- CanvasKit WASM rendering for all shape types
-- Click/shift/marquee selection with resize handles and rotation
-- Zoom/pan with keyboard shortcuts and trackpad gestures
-- Undo/redo wired into all operations
-- Snap guides with edge and center snapping
+## UI Éditeur + Layout ✅
+Components, instances, overrides, component sets, variables (COLOR/FLOAT/STRING/BOOLEAN), collections, modes, image export, context menu, rich text formatting.
-### Phase 2: Editor UI + Layout ✅
+## Phase 3 🟡
+@open-pencil/core, CLI (12 commands), MCP server (29+ tools), AI chat (OpenRouter), JSX renderer, code panel.
-Properties panel, layers panel, toolbar, Yoga layout integration, text editing.
+**Planned:** port remaining figma-use tools, attached mode, design guidelines, screenshot verification loop.
-**Delivered:**
-- Vue 3 + Reka UI panels (properties, layers, toolbar)
-- Properties panel split into sections (Appearance, Fill, Stroke, Typography, Layout, Position)
-- ScrubInput component for all numeric inputs
-- Color picker (HSV, hex, opacity)
-- Layers panel with tree view, drag reorder, visibility toggle
-- Auto-layout with Yoga WASM (direction, gap, padding, justify, align)
-- Inline text editing with CanvasKit Paragraph API
-- System font loading via Local Font Access API
-- Canvas rulers with selection highlight
+## E/S Fichiers + Fonctionnalités Visuelles 🔲
+Prototyping, comments, PWA, Linux Tauri builds, performance optimization, full Figma compatibility test suite.
-### Phase 3: File I/O + Visual Features ✅
+## Phase 4
-.fig import/export, Kiwi codec, clipboard, sections, pages, advanced rendering.
-
-**Delivered:**
-- .fig file import via Kiwi binary codec
-- .fig file export with Kiwi encoding, Zstd compression, thumbnail generation
-- Save (⌘S) and Save As (⇧⌘S) with native OS dialogs
-- Zstd compression via Tauri Rust command (deflate fallback in browser)
-- Vendored kiwi-schema with ESM + sparse field ID patches
-- Figma-compatible clipboard (bidirectional Kiwi binary)
-- Pen tool with vector network model
-- vectorNetworkBlob binary encode/decode
-- Group/ungroup (⌘G/⇧⌘G)
-- Tauri v2 desktop app with native menu bar (macOS/Windows/Linux)
-- Sections (S key) with title pills, auto-adopt, luminance-adaptive text
-- Multi-page documents with pages panel, per-page viewport
-- Hover highlight with shape-aware outlines
-- Tier 1 rendering: gradients, image fills, effects, strokes (cap/join/dash), arcs
-- Fill type picker with solid/gradient/image tabs and gradient stop editing
-- Canvas background color per page
-- Fig-import unit tests, layout unit tests, layers-panel E2E tests
-
-### Phase 4: Components + Variables ✅
-
-Components, instances, overrides, variables, collections, modes, image export.
-
-**Delivered:**
-- Component creation from frame/group or multi-selection (⌥⌘K)
-- Component sets from multiple components (⇧⌘K) with dashed purple border
-- Instance creation from components with child cloning and componentId mapping
-- Live component-instance sync with override preservation
-- Detach instance back to frame (⌥⌘B)
-- Go to main component (cross-page navigation)
-- Always-visible purple component/instance labels with diamond icon
-- Opaque container hit testing (click selects component, double-click enters)
-- Right-click context menu with clipboard, z-order, grouping, component, visibility, lock, move-to-page actions
-- Z-order manipulation (] bring to front, [ send to back)
-- Toggle visibility (⇧⌘H) and lock (⇧⌘L)
-- Move nodes between pages via context menu
-- Viewport culling, Paint reuse, RAF render coalescing
-- Effects panel UI (drop shadow, inner shadow, layer/background/foreground blur)
-- Independent corner radius controls (per-corner toggle in Appearance section)
-- GitHub Actions CI/CD for Windows (x64, arm64) and macOS (x64, arm64) builds
-- Polygon and Star drawing tools with pointCount and starInnerRadius
-- Resizable left/right panels via reka-ui Splitter (persistent layout)
-- @/ import alias, shared types module (src/types.ts, src/global.d.ts)
-- Codebase lint-clean: 0 oxlint warnings, 0 tsgo type errors
-- Variables: COLOR type with collections, modes, bindings, FillSection variable picker, .fig import
-- Variables dialog: TanStack Table with resizable columns, mode columns, collection tabs with rename, search, demo collections (Primitives/Semantic/Spacing), undo/redo for all variable operations
-- Image export: PNG/JPG/WEBP with ExportSection (scale, format, live preview), ⇧⌘E shortcut, context menu
-- Canvas-native text editing: TextEditor class in core, phantom textarea, cursor/selection/word boundaries on canvas, caret blinking, selection highlights
-- System font enumeration via font-kit Rust crate, OnceLock cache, preload on startup
-- Font picker: virtual scroll (reka-ui ListboxVirtualizer), search filter, CSS font preview
-- ColorInput component extraction, ColorPicker alpha slider checkerboard fix
-- App identity: pencil icon, Cargo crate open_pencil, macOS Dock "OpenPencil"
-- Splash loader during WASM initialization
-- Rich text style runs: per-selection ⌘B/I/U, StyleRun model, ParagraphBuilder pushStyle/pop, .fig roundtrip
-- B/I/U/S toggle buttons in TypographySection
-- Double-click (word), triple-click (select all) text selection
-
-**Remaining (deferred to Phase 6):**
-- Variant switching
-- Variable types: FLOAT, STRING, BOOLEAN editing UI
-- Variable-driven theming
-
-### Phase 5: AI Integration & Tooling 🟡
-
-Core extraction, CLI, MCP server, design guidelines, screenshot verification loop.
-
-**Delivered:**
-- @open-pencil/core extracted to packages/core/ (zero DOM deps, Bun workspace)
-- @open-pencil/cli with headless .fig operations (info, tree, find, export, analyze, node, pages, variables), CanvasKit CPU rasterization, --json output
-- JSX renderer: TreeNode builders (Frame, Text, Rectangle, etc.), renderTreeNode/renderJsx, Tailwind-like shorthand props, 27 tests
-- jscpd copy-paste detection (15.6% → 0.62%), kiwi-serialize.ts consolidation
-- .fig roundtrip tests with LFS fixtures (material3.fig 87K nodes, nuxtui.fig 314K nodes)
-- .fig import O(n²) → O(n) fix (37s → 535ms on 87K nodes), ByteBuffer optimization
-- test:coverage script
-- AI chat: OpenRouter direct (no backend), Stronghold key storage, 26 tools (create_shape, set_fill, set_effects, set_constraints, components, groups, pages, variables, eval_code, etc.), model selector, ⌘J toggle, streaming markdown, Playwright tests with mock transport
-- Code panel: sceneNodeToJsx() export, Prism.js highlighting, line numbers, copy button, 14 tests
-- Properties panel restructured: Design | Code | AI tabs
-- npm publishing preparation for core and cli packages
-
-**Planned:**
-- Port remaining figma-use tools (118 total, 26 currently implemented)
-- Attached mode: WebSocket to running editor for eval, create, export, screenshot
-- Design guidelines system
-- AI-driven design workflow via MCP
-- Screenshot verification loop
-
-### Phase 6: Polish + Distribution 🔲
-
-Prototyping, comments, desktop distribution, documentation, public launch.
-
-**Planned:**
-- Prototyping (frame connections, transitions)
-- Comments (pin, threads, resolve)
-- Linux Tauri builds (macOS and Windows already covered by CI)
-- PWA support
-- Documentation site (VitePress)
-- Performance optimization (Lighthouse > 90)
-- Full Figma compatibility test suite
-- Deferred from Phase 4: variant switching, FLOAT/STRING/BOOLEAN variable UI, variable-driven theming
-
-## Timeline
-
-| Phase | Estimated Duration | Status |
-|-------|-------------------|--------|
-| Phase 1: Core Engine | 3 months | ✅ Complete |
-| Phase 2: Editor UI + Layout | 3 months | ✅ Complete |
-| Phase 3: File I/O + Visual Features | 2 months | ✅ Complete |
-| Phase 4: Components + Variables | 2 months | ✅ Complete |
-| Phase 5: AI Integration & Tooling | 2 months | 🟡 In Progress |
-| Phase 6: Polish + Distribution | 2 months | 🔲 Planned |
+| Phase | Composants + Variables | Phase 5: Intégration IA & Outils:Phase 6: Polissage + Distribution:Calendrier:Durée estimée:Statut |
+|-------|------|-----|
+| Phase 1 | 3 months | ✅ |
+| Moteur Core | 3 months | ✅ |
+| Phase 2 | 2 months | ✅ |
+| UI Éditeur + Layout | 2 months | ✅ |
+| Phase 3 | 2 months | 🟡 |
+| E/S Fichiers + Fonctionnalités Visuelles | 2 months | 🔲 |
diff --git a/packages/docs/fr/development/testing.md b/packages/docs/fr/development/testing.md
index 9e0d7ce81..dfe989733 100644
--- a/packages/docs/fr/development/testing.md
+++ b/packages/docs/fr/development/testing.md
@@ -1,6 +1,6 @@
# Tests
-## Overview
+## Vue d'ensemble
| Type | Framework | Command | Location |
|------|-----------|---------|----------|
@@ -8,84 +8,45 @@
| Figma CDP reference | Playwright | `bun run test:figma` | `tests/figma/` |
| Unit tests | bun:test | `bun run test:unit` | `tests/engine/` |
-## E2E Visual Regression
-
-Playwright creates shapes on the canvas and compares screenshots against baseline PNGs.
+## Régression visuelle E2E
```sh
-bun run test # Run tests, compare against baselines
-bun run test:update # Regenerate baseline screenshots
+bun run test # Compare against baselines
+bun run test:update # Regenerate baselines
```
-### How It Works
-
-1. Tests load the editor in a headless browser
-2. The editor signals readiness via a `data-ready` HTML attribute
-3. Tests create shapes via the editor's API
-4. Screenshots are taken and compared against baselines using `toMatchSnapshot`
-5. Page is reused across test cases for speed (~2s total)
-
-### No-Chrome Test Mode
-
-The editor supports a test mode that hides UI chrome (toolbar, panels) for clean screenshot capture. Activated via URL parameter.
+1. Playwright → headless browser
+2. `data-ready` HTML attribute
+3. Create shapes → screenshot → `toMatchSnapshot`
-## Figma CDP Reference Tests
-
-A separate Playwright project connects to Figma via Chrome DevTools Protocol to capture reference screenshots for pixel-perfect comparison.
+## Tests de référence Figma CDP
```sh
bun run figma:debug # Launch Figma with debugging port
-bun run test:figma # Connect to Figma, capture references
+bun run test:figma # Connect via CDP
```
-Requires Figma desktop app running with `--remote-debugging-port=9222`.
-
-## Unit Tests
-
-Engine unit tests use bun:test and target < 50ms execution:
+## Tests unitaires
```sh
bun run test:unit
```
-Tests cover:
-- Scene graph CRUD operations, parent-child relationships, z-ordering, hit testing
-- **Fig-import pipeline** — node type mapping, transforms, fills/strokes/effects, gradients, images, arcs, nested hierarchies (`tests/engine/fig-import.test.ts`)
-- **Layout computation** — Yoga auto-layout: direction, gap, padding, justify, align, child sizing (fixed/fill/hug), cross-axis sizing, wrap, nested layouts (`tests/engine/layout.test.ts`)
+- Scene graph CRUD, hit testing
+- Fig-import pipeline
+- Layout computation (Yoga)
+- MCP server edge cases
-### Writing Unit Tests
-
-```typescript
-import { describe, expect, it } from 'bun:test'
-import { SceneGraph } from '../../src/engine/scene-graph'
-
-describe('SceneGraph', () => {
- it('creates and retrieves a node', () => {
- const sg = new SceneGraph()
- const node = sg.createNode('RECTANGLE', sg.root, { name: 'Test' })
- expect(sg.getNode(node.guid)).toBeDefined()
- })
-})
-```
-
-## E2E Test Coverage
+## Couverture des tests E2E
| Test file | Scope |
|-----------|-------|
-| `tests/e2e/layers-panel.spec.ts` | Layers panel tree structure, visibility toggles, selection sync |
-| `tests/e2e/visual.spec.ts` | Visual regression screenshots for shapes and rendering |
-
-## Test Helpers
-
-| File | Purpose |
-|------|---------|
-| `tests/helpers/canvas.ts` | Canvas setup and interaction utilities |
-| `tests/helpers/figma.ts` | Figma CDP connection helpers |
+| `tests/e2e/layers-panel.spec.ts` | Layers panel |
+| `tests/e2e/visual.spec.ts` | Visual regression |
-## Performance Targets
+## Objectifs de performance
| Metric | Target |
|--------|--------|
-| E2E suite total | < 3s |
-| Unit test suite total | < 50ms |
-| Screenshot comparison | toMatchSnapshot (pixel-level) |
+| E2E suite | < 3s |
+| Unit tests | < 50ms |
diff --git a/packages/docs/fr/eval-command.md b/packages/docs/fr/eval-command.md
index 9f7c45018..af7f3deb4 100644
--- a/packages/docs/fr/eval-command.md
+++ b/packages/docs/fr/eval-command.md
@@ -1,437 +1,77 @@
-# `open-pencil eval` — Figma-like Plugin API for Headless Scripting
+# `open-pencil eval` — API Plugin compatible Figma pour le scripting headless
-## Overview
+## Vue d'ensemble
-`bun open-pencil eval <file> --code '<js>'` executes JavaScript against a `.fig` file with a Figma-compatible `figma` global object. This enables headless scripting, batch operations, AI tool execution, and testing — all without the GUI.
+`bun open-pencil eval <file> --code '<js>'` exécute du JavaScript sur un fichier `.fig` avec un objet global `figma` compatible Figma. Cela permet le scripting headless, les opérations par lots, l'exécution d'outils IA et les tests — le tout sans interface graphique.
-The `figma` object mirrors Figma's Plugin API surface as closely as possible, so existing Figma plugin knowledge and code snippets transfer directly.
+L'objet `figma` reflète la surface de l'API Plugin de Figma aussi fidèlement que possible, de sorte que les connaissances existantes sur les plugins Figma et les extraits de code sont directement transférables.
```bash
-# Create a frame, set auto-layout, add children
+# Créer un cadre, définir l'auto-layout, ajouter des enfants
bun open-pencil eval design.fig --code '
const frame = figma.createFrame()
frame.name = "Card"
frame.resize(300, 200)
frame.layoutMode = "VERTICAL"
frame.itemSpacing = 12
- frame.paddingTop = frame.paddingBottom = 16
- frame.paddingLeft = frame.paddingRight = 16
frame.fills = [{ type: "SOLID", color: { r: 1, g: 1, b: 1 } }]
-
- const title = figma.createText()
- title.characters = "Hello World"
- title.fontSize = 24
- frame.appendChild(title)
-
return { id: frame.id, name: frame.name }
'
-# Query nodes
+# Interroger les nœuds
bun open-pencil eval design.fig --code '
- const buttons = figma.currentPage.findAll(n => n.type === "FRAME" && n.name.includes("Button"))
- return buttons.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
+ const buttons = figma.currentPage.findAll(n => n.name.includes("Button"))
+ return buttons.map(b => ({ id: b.id, name: b.name }))
'
-# Read from stdin (for multiline scripts / piping)
-cat transform.js | bun open-pencil eval design.fig --stdin
-
-# Write changes back
+# Écrire les modifications
bun open-pencil eval design.fig --code '...' --write
-bun open-pencil eval design.fig --code '...' -o modified.fig
```
## Architecture
```
-┌──────────────────────────────────────────────────────┐
-│ CLI: `open-pencil eval <file> --code '...'` │
-│ ↓ │
-│ loadDocument(file) → SceneGraph │
-│ ↓ │
-│ FigmaAPI(sceneGraph) → `figma` proxy object │
-│ ↓ │
-│ AsyncFunction('figma', wrappedCode)(figmaProxy) │
-│ ↓ │
-│ print result as JSON / agentfmt │
-│ optionally: saveDocument(file) if --write │
-└──────────────────────────────────────────────────────┘
+CLI: open-pencil eval <file> --code '...'
+ → loadDocument(file) → SceneGraph
+ → FigmaAPI(sceneGraph) → proxy `figma`
+ → AsyncFunction('figma', code)(figmaProxy)
+ → afficher résultat / sauvegarder avec --write
```
-### Key classes
-
-| Class | Location | Role |
-|-------|----------|------|
-| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy object implementing `figma.*` methods against `SceneGraph` |
-| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy wrapping `SceneNode` with Figma-style property access (`.fills`, `.resize()`, `.appendChild()`, etc.) |
-| `eval` command | `packages/cli/src/commands/eval.ts` | CLI command that loads doc, creates API, executes code |
-
-### Why in `@open-pencil/core`?
-
-The `FigmaAPI` class lives in core (not CLI) because:
-- **AI tools reuse it** — the chat panel's `render` tool can execute JSX through the same API
-- **Test scripts** — unit tests can use the API to set up fixtures
-- **No DOM deps** — runs headless in Bun, no browser APIs needed
-
-## `FigmaAPI` — Phased Implementation
-
-### Phase 1: Core (MVP for eval command)
-
-These cover ~80% of real plugin scripts:
-
-#### Document & Page
-
-| Figma API | Our implementation | Notes |
-|-----------|--------------------|-------|
-| `figma.root` | Getter → proxy for root node | `.children` returns page proxies |
-| `figma.currentPage` | Getter/setter → first page by default | Settable to any page proxy |
-| `figma.currentPage.selection` | Get/set → tracked selection array | |
-| `figma.getNodeById(id)` | `graph.getNode(id)` wrapped in proxy | Sync, like Figma's deprecated version |
+### Classes principales
-#### Node Creation
+| Classe | Emplacement | Rôle |
+|--------|-------------|------|
+| `FigmaAPI` | `packages/core/src/figma-api.ts` | Objet proxy implémentant les méthodes `figma.*` |
+| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy enveloppant `SceneNode` avec accès propriétés style Figma |
+| Commande `eval` | `packages/cli/src/commands/eval.ts` | Charge le document, crée l'API, exécute le code |
-| Figma API | Maps to |
-|-----------|---------|
-| `figma.createFrame()` | `graph.createNode('FRAME', currentPageId)` |
-| `figma.createRectangle()` | `graph.createNode('RECTANGLE', ...)` |
-| `figma.createEllipse()` | `graph.createNode('ELLIPSE', ...)` |
-| `figma.createText()` | `graph.createNode('TEXT', ...)` |
-| `figma.createLine()` | `graph.createNode('LINE', ...)` |
-| `figma.createPolygon()` | `graph.createNode('POLYGON', ...)` |
-| `figma.createStar()` | `graph.createNode('STAR', ...)` |
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createPage()` | `graph.addPage(name)` |
-| `figma.createSection()` | `graph.createNode('SECTION', ...)` |
+### Pourquoi dans `@open-pencil/core` ?
-#### Node Properties (via `FigmaNode` proxy)
+La classe `FigmaAPI` vit dans core car : les outils IA la réutilisent, les tests l'utilisent et elle n'a pas de dépendances DOM.
-Read/write on any node proxy. Property access maps to `SceneNode` fields:
-
-```ts
-// Geometry
-node.x, node.y // direct
-node.width, node.height // read-only, use node.resize(w, h)
-node.rotation // direct
-node.resize(w, h) // updates width + height
-node.resizeWithoutConstraints(w, h) // same (no constraint engine yet)
-
-// Visual
-node.fills // get/set Fill[]
-node.strokes // get/set Stroke[]
-node.effects // get/set Effect[]
-node.opacity // get/set number
-node.visible // get/set boolean
-node.locked // get/set boolean
-node.blendMode // get/set BlendMode
-node.clipsContent // get/set boolean
-
-// Corner radius
-node.cornerRadius // get/set (number or figma.mixed)
-node.topLeftRadius // get/set
-node.topRightRadius // get/set
-node.bottomLeftRadius // get/set
-node.bottomRightRadius // get/set
-node.cornerSmoothing // get/set
-
-// Identity
-node.id // read-only
-node.name // get/set
-node.type // read-only
-node.parent // read-only → FigmaNode | null
-node.removed // read-only boolean
-```
-
-#### Tree Operations
-
-```ts
-node.children // read-only FigmaNode[]
-node.appendChild(child) // reparent to end
-node.insertChild(index, child) // reparent at index
-node.remove() // graph.deleteNode(id)
-
-// Traversal
-node.findAll(callback?) // recursive find
-node.findOne(callback) // first match
-node.findChild(callback) // direct children only
-node.findChildren(callback?) // direct children only
-```
-
-#### Auto-layout
-
-```ts
-node.layoutMode // 'NONE' | 'HORIZONTAL' | 'VERTICAL'
-node.primaryAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'
-node.counterAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'BASELINE'
-node.itemSpacing // number
-node.counterAxisSpacing // number | null
-node.paddingTop / Right / Bottom / Left // number
-node.layoutWrap // 'NO_WRAP' | 'WRAP'
-
-// Child sizing
-node.layoutPositioning // 'AUTO' | 'ABSOLUTE'
-node.layoutGrow // 0 | 1
-node.layoutSizingHorizontal // 'FIXED' | 'HUG' | 'FILL'
-node.layoutSizingVertical // 'FIXED' | 'HUG' | 'FILL'
-```
-
-#### Text
-
-```ts
-node.characters // get/set (maps to node.text)
-node.fontSize // get/set
-node.fontName // get/set { family, style }
-node.fontWeight // get/set
-node.textAlignHorizontal // get/set
-node.textAlignVertical // get/set
-node.textAutoResize // get/set
-node.letterSpacing // get/set
-node.lineHeight // get/set
-node.maxLines // get/set
-node.textCase // get/set
-node.textDecoration // get/set
-```
-
-#### Stroke details
-
-```ts
-node.strokeWeight // get/set (maps to strokes[0].weight)
-node.strokeAlign // get/set (maps to strokes[0].align)
-node.dashPattern // get/set
-```
-
-#### Misc
-
-```ts
-figma.mixed // Symbol sentinel for mixed values
-figma.group(nodes, parent) // creates GROUP with given children
-figma.ungroup(node) // ungroups, reparents children
-figma.flatten(nodes) // NOT IMPLEMENTED YET — returns first node
-```
-
-#### Export
-
-```ts
-node.exportAsync(settings?) // only works if CanvasKit is loaded
- // settings: { format: 'PNG'|'JPG'|'SVG', constraint? }
-```
-
-### Phase 2: Components & Instances
-
-| API | Maps to |
-|-----|---------|
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createComponentFromNode(node)` | Convert existing frame to component |
-| `figma.combineAsVariants(components, parent)` | Create COMPONENT_SET |
-| Node: `node.createInstance()` | `graph.createInstance(componentId, parentId)` |
-| Node: `node.detachInstance()` | `graph.detachInstance(id)` |
-| `figma.getNodeById(id).mainComponent` | `graph.getMainComponent(id)` |
-
-### Phase 3: Variables
-
-| API | Maps to |
-|-----|---------|
-| `figma.variables.getLocalVariables(type?)` | `graph.variables` filtered |
-| `figma.variables.getLocalVariableCollections()` | `graph.variableCollections` |
-| `figma.variables.createVariable(name, collection, type)` | `graph.addVariable(...)` |
-| `figma.variables.createVariableCollection(name)` | `graph.addCollection(...)` |
-| `figma.variables.getVariableById(id)` | `graph.variables.get(id)` |
-| `node.setBoundVariable(field, variable)` | `graph.bindVariable(...)` |
-| `node.boundVariables` | getter from SceneNode |
-
-### Phase 4: Styles & Advanced
-
-| API | Notes |
-|-----|-------|
-| `figma.createPaintStyle()` | Requires style storage in SceneGraph |
-| `figma.createTextStyle()` | Requires style storage in SceneGraph |
-| `figma.createEffectStyle()` | Requires style storage in SceneGraph |
-| `figma.loadFontAsync(fontName)` | No-op (we don't have font loading constraints) |
-| `figma.listAvailableFontsAsync()` | Return system fonts if available |
-| Boolean operations (`union`, `subtract`, `intersect`, `exclude`) | Requires path boolean engine |
-| `figma.createNodeFromJSXAsync(jsx)` | Port figma-use's JSX renderer |
-
-## `FigmaNode` Proxy Design
-
-The proxy wraps a `SceneNode` and translates Figma property names to our internal names. Key mappings:
-
-```ts
-const PROPERTY_MAP: Record<string, string> = {
- // Figma name → SceneNode field name (only where they differ)
- 'characters': 'text',
- 'strokeWeight': → computed from strokes[0].weight,
- 'strokeAlign': → computed from strokes[0].align,
- 'fontName': → computed from { family: fontFamily, style: ... },
- 'primaryAxisAlignItems': 'primaryAxisAlign',
- 'counterAxisAlignItems': 'counterAxisAlign',
- 'primaryAxisSizingMode': 'primaryAxisSizing', // value mapping: 'AUTO' → 'HUG', 'FIXED' → 'FIXED'
- 'counterAxisSizingMode': 'counterAxisSizing',
- 'layoutSizingHorizontal': → computed from primaryAxisSizing / counterAxisSizing depending on layoutMode
- 'layoutSizingVertical': → computed
-}
-```
-
-Methods on the proxy:
-
-```ts
-class FigmaNode {
- // The proxy is created via: new Proxy(target, handler)
- // where handler.get intercepts property reads and handler.set intercepts writes
-
- resize(width: number, height: number): void
- resizeWithoutConstraints(width: number, height: number): void
- remove(): void
- appendChild(child: FigmaNode): void
- insertChild(index: number, child: FigmaNode): void
- findAll(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- findOne(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChild(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChildren(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- exportAsync(settings?: ExportSettings): Promise<Uint8Array>
-
- // Components (Phase 2)
- createInstance(): FigmaNode
- detachInstance(): void
- get mainComponent(): FigmaNode | null
-}
-```
-
-## CLI Command
+## Commande CLI
```
bun open-pencil eval <file> [options]
-Arguments:
- file .fig file to operate on
-
-Options:
- --code, -c JavaScript code to execute (has access to `figma` global)
- --stdin Read code from stdin instead of --code
- --write, -w Write changes back to the input file
- -o, --output Write to a different file
- --json Output result as JSON (default for non-TTY)
- --quiet, -q Suppress output, only write file
-```
-
-### Execution model
-
-1. Load `.fig` → `SceneGraph`
-2. Create `FigmaAPI(graph)` → `figma` proxy
-3. Wrap user code in async function: `return (async () => { <code> })()`
-4. Execute with `figma` as sole argument
-5. Print return value (JSON or agentfmt)
-6. If `--write` or `-o`: serialize `SceneGraph` back to `.fig`
-
-### Return value formatting
-
-- `undefined` / `void` → no output
-- Primitives → printed directly
-- Objects/arrays → `JSON.stringify(result, null, 2)` or agentfmt tables
-- `FigmaNode` → serialized as `{ id, type, name, x, y, width, height, fills, ... }`
-- Arrays of `FigmaNode` → serialized as list
-
-## Shared with AI Tools
-
-The `FigmaAPI` class is the **same API surface** that AI tools use. Currently `src/ai/tools.ts` calls `store.createShape()`, `store.updateNodeWithUndo()`, etc. — these should be refactored to go through `FigmaAPI`:
-
-```ts
-// Before (current AI tools)
-execute: async ({ type, x, y, width, height }) => {
- const id = store.createShape(type, x, y, width, height)
- return { id }
-}
-
-// After (using FigmaAPI)
-execute: async ({ type, x, y, width, height }) => {
- const frame = figma.createFrame()
- frame.resize(width, height)
- frame.x = x
- frame.y = y
- return { id: frame.id }
-}
-```
-
-This ensures CLI scripts and AI tools behave identically.
-
-## File Layout
+Arguments :
+ file Fichier .fig sur lequel opérer
+Options :
+ --code, -c Code JavaScript à exécuter
+ --stdin Lire le code depuis stdin
+ --write, -w Écrire les modifications dans le fichier d'entrée
+ -o, --output Écrire dans un fichier différent
+ --json Sortie en JSON
+ --quiet, -q Supprimer la sortie
```
-packages/core/src/
- figma-api.ts # FigmaAPI class + FigmaNode proxy (Phase 1–4)
- figma-api.test.ts # Unit tests against headless SceneGraph
-
-packages/cli/src/commands/
- eval.ts # CLI command
-
-packages/cli/src/commands/eval.test.ts # Integration tests
-```
-
-## Test Plan
-
-### Unit tests (`packages/core/src/figma-api.test.ts`)
-
-1. **Node creation** — each `createX()` creates correct type, added to current page
-2. **Property access** — `.fills`, `.x`, `.width`, `.name`, `.characters` read/write correctly
-3. **Resize** — `.resize(w, h)` updates width/height
-4. **Tree operations** — `.appendChild()`, `.insertChild()`, `.remove()`, `.parent`, `.children`
-5. **Traversal** — `.findAll()`, `.findOne()`, `.findChild()`, `.findChildren()` with callbacks
-6. **Auto-layout** — `.layoutMode`, `.itemSpacing`, `.paddingTop`, etc.
-7. **Text** — `.characters` maps to `.text`, `.fontName` maps to `{ family, style }`
-8. **Mixed values** — `.cornerRadius` returns `figma.mixed` when corners differ
-9. **Selection** — `figma.currentPage.selection` get/set
-10. **Page switching** — `figma.currentPage = page2` works
-11. **Group/ungroup** — `figma.group()` creates group, `figma.ungroup()` dissolves it
-12. **Clone** — node creation produces independent copies
-
-### CLI integration tests (`packages/cli/src/commands/eval.test.ts`)
-
-1. **Basic eval** — `eval test.fig --code 'return figma.currentPage.name'` → page name
-2. **Create + read** — create a frame, return its properties
-3. **Query nodes** — `findAll` returns correct nodes
-4. **Write back** — `--write` saves changes, reloading shows them
-5. **Stdin** — `echo 'return 42' | bun open-pencil eval test.fig --stdin` → `42`
-6. **JSON output** — `--json` returns valid JSON
-7. **Error handling** — syntax errors, runtime errors reported cleanly
-
-## Implementation Order
-
-1. **`FigmaNode` proxy** — property mapping, `.resize()`, `.remove()`, tree methods
-2. **`FigmaAPI` class** — `createFrame/Rectangle/...`, `.root`, `.currentPage`, `.getNodeById()`, `.mixed`, `.group()`
-3. **CLI `eval` command** — argument parsing, code wrapping, output formatting
-4. **Unit tests** — all 12 test groups above
-5. **CLI integration tests** — all 7 test groups above
-6. **Wire to AI tools** — refactor `src/ai/tools.ts` to use `FigmaAPI` where possible
-7. **Phase 2** — components & instances
-8. **Phase 3** — variables
-9. **Phase 4** — styles, boolean ops, JSX renderer
-
-## Property Mapping Reference
-
-| Figma Property | SceneNode Field | Type | Notes |
-|---------------|-----------------|------|-------|
-| `characters` | `text` | `string` | |
-| `fontName` | `fontFamily` + `fontWeight` + `italic` | `{ family, style }` | Computed: `style` = "Bold Italic" etc. |
-| `strokeWeight` | `strokes[0].weight` | `number` | Computed |
-| `strokeAlign` | `strokes[0].align` | `string` | Computed |
-| `primaryAxisAlignItems` | `primaryAxisAlign` | `string` | |
-| `counterAxisAlignItems` | `counterAxisAlign` | `string` | |
-| `layoutSizingHorizontal` | `primaryAxisSizing` or `counterAxisSizing` | `string` | Depends on `layoutMode` |
-| `layoutSizingVertical` | (opposite of horizontal) | `string` | |
-| `absoluteTransform` | computed from `x`, `y`, `rotation` | `Transform` | Read-only |
-| `absoluteBoundingBox` | `getAbsoluteBounds(id)` | `Rect` | Read-only |
-| All others | Same name | Same type | Direct passthrough |
-
-## Open Questions
-
-1. **Font loading**: `figma.loadFontAsync()` — should it be a no-op (we don't have font gating) or should we track loaded fonts?
- → **Decision: No-op that returns resolved Promise.** We don't gate text editing on font loading.
-
-2. **Export in headless mode**: `node.exportAsync()` requires CanvasKit. Should eval load CanvasKit?
- → **Decision: Optional.** If CanvasKit is available (via `--with-canvaskit` flag or env), enable export. Otherwise, throw "Export requires CanvasKit" error.
-3. **`figma.mixed` symbol**: Should we use the actual Figma symbol or our own?
- → **Decision: Our own `Symbol('mixed')`.** Exposed as `figma.mixed`.
+## Implémentation par phases
-4. **Undo**: `figma.commitUndo()` / `figma.triggerUndo()` — relevant in headless?
- → **Decision: No-op in CLI.** Undo only matters in the live editor. The AI tools can add undo support separately via EditorStore.
+- **Phase 1 : Core** — création de nœuds, propriétés, opérations d'arbre, auto-layout, texte (~80% des scripts réels)
+- **Phase 2 : Composants & Instances** — createComponent, createInstance, detachInstance
+- **Phase 3 : Variables** — getLocalVariables, createVariable, setBoundVariable
+- **Phase 4 : Styles & Avancé** — styles paint/texte/effets, opérations booléennes
-5. **Write format**: Should `--write` produce `.fig` (Kiwi binary) or also support `.json`?
- → **Decision: `.fig` only for now.** JSON export is a separate feature.
+[Référence API complète en anglais](/eval-command)
diff --git a/packages/docs/fr/reference/file-format.md b/packages/docs/fr/reference/file-format.md
index eff84db84..2b34f6680 100644
--- a/packages/docs/fr/reference/file-format.md
+++ b/packages/docs/fr/reference/file-format.md
@@ -1,6 +1,6 @@
# Format de fichier
-## .fig File Structure
+## Structure des fichiers .fig
```
┌─────────────────────────────────┐
@@ -14,7 +14,7 @@
└─────────────────────────────────┘
```
-## Import Pipeline
+## Pipeline d'importation
```
.fig file → Parse header → Decompress Zstd → Decode Kiwi schema
@@ -22,7 +22,7 @@
→ Resolve blob refs → Render on canvas
```
-## Export Pipeline
+## Pipeline d'exportation
```
SceneGraph → NodeChange[] → Kiwi encode → Compress (Zstd/deflate)
diff --git a/packages/docs/fr/reference/mcp-tools.md b/packages/docs/fr/reference/mcp-tools.md
index 372872cb4..a79eccb76 100644
--- a/packages/docs/fr/reference/mcp-tools.md
+++ b/packages/docs/fr/reference/mcp-tools.md
@@ -1,10 +1,10 @@
# Serveur MCP
-OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
+OpenPencil inclut un serveur MCP (Model Context Protocol) qui permet aux outils de coding IA — Claude Code, Cursor, Windsurf etc. — de lire et modifier des fichiers .fig en headless.
-Two transports: **stdio** for MCP clients, **HTTP** for everything else.
+Deux transports
-## Install
+## **stdio** pour les clients MCP, **HTTP** pour tout le reste.
```sh
bun add -g @open-pencil/mcp
@@ -24,7 +24,7 @@ Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json`):
}
```
-Or run from source without installing:
+Installation:Ou exécuter depuis les sources :
::: code-group
```json [Bun]
diff --git a/packages/docs/fr/reference/scene-graph.md b/packages/docs/fr/reference/scene-graph.md
index 667d41c56..17c302c4e 100644
--- a/packages/docs/fr/reference/scene-graph.md
+++ b/packages/docs/fr/reference/scene-graph.md
@@ -1,8 +1,8 @@
# Graphe de scène
-## In-Memory Representation
+## Représentation en mémoire
-Nodes live in a flat `Map<string, Node>` keyed by GUID string. The tree structure is maintained via `parentIndex` references. This gives O(1) lookup by ID and efficient traversal.
+Les nœuds vivent dans une Map plate `Map<string, Node>` keyed by GUID string. La structure arborescente est maintenue via `parentIndex` references. This gives Recherche O(1) by ID and efficient traversal.
```typescript
interface SceneGraph {
diff --git a/packages/docs/it/development/contributing.md b/packages/docs/it/development/contributing.md
index 5e26dfd1a..371bc27dc 100644
--- a/packages/docs/it/development/contributing.md
+++ b/packages/docs/it/development/contributing.md
@@ -1,94 +1,65 @@
# Contribuire
-## Project Structure
+## Struttura del progetto
```
packages/
- core/ @open-pencil/core — engine (zero DOM deps)
- src/ Scene graph, renderer, layout, codec, kiwi, types
- cli/ @open-pencil/cli — headless CLI for .fig operations
- src/commands/ info, tree, find, export
+ core/ @open-pencil/core — Engine
+ cli/ @open-pencil/cli — Headless CLI
+ mcp/ @open-pencil/mcp — MCP server
+ docs/ @open-pencil/docs — VitePress
src/
- components/ Vue SFCs (canvas, panels, toolbar, color picker)
- properties/ Property panel sections (Appearance, Fill, Stroke, etc.)
- composables/ Canvas input, keyboard shortcuts, rendering hooks
- stores/ Editor state (Vue reactivity)
- engine/ Re-export shims from @open-pencil/core
- kiwi/ Re-export shims from @open-pencil/core
- types.ts Shared types (re-exported from core)
- constants.ts UI colors, defaults, thresholds
-desktop/ Tauri v2 (Rust + config)
+ components/ Vue SFCs
+ composables/ Canvas input, shortcuts, rendering
+ stores/ Editor state
+desktop/ Tauri v2
tests/
- e2e/ Playwright visual regression
- engine/ Unit tests (bun:test)
-docs/ VitePress documentation site
-openspec/
- specs/ Capability specifications (source of truth)
- changes/ Active and archived changes
+ e2e/ Playwright
+ engine/ bun:test
+openspec/ Specs + changes
```
-## Development Setup
+## Ambiente di sviluppo
```sh
bun install
-bun run dev # Editor at localhost:1420
-bun run docs:dev # Docs at localhost:5173
+bun run dev # Editor: localhost:1420
+bun run docs:dev # Docs: localhost:5173
```
-## Code Style
+## Stile del codice
-### Tooling
+### Strumenti
| Tool | Command | Purpose |
|------|---------|---------|
-| oxlint | `bun run lint` | Linting (Rust-based, fast) |
-| oxfmt | `bun run format` | Code formatting |
-| tsgo | `bun run typecheck` | Type checking (Go-based TypeScript checker) |
-
-Run all checks:
+| oxlint | `bun run lint` | Linting |
+| oxfmt | `bun run format` | Formatting |
+| tsgo | `bun run typecheck` | Type checking |
```sh
bun run check
```
-### Conventions
-
-- **File names** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
-- **Components** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
-- **Constants** — SCREAMING_SNAKE_CASE
-- **Functions/variables** — camelCase
-- **Types/interfaces** — PascalCase
-
-### AI Agent Conventions
-
-Developers and AI agents working on the codebase should read `AGENTS.md` in the repo root ([view on GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Covers rendering, scene graph, components & instances, layout, UI, file format, Tauri conventions, and known issues.
+### Convenzioni
-## Making Changes
+- kebab-case (files), PascalCase (components/types), camelCase (functions), SCREAMING_SNAKE_CASE (constants)
+- AGENTS.md — [GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)
-1. Check existing [openspec specs](/development/openspec) for the capability you're modifying
-2. Create an openspec change if adding new behavior: `openspec new change "my-change"`
-3. Implement the change
-4. Run `bun run check` and `bun run test`
-5. Submit a pull request
+## Apportare modifiche
-## Key Files
+1. [OpenSpec](./openspec) specs
+2. `openspec new change "name"`
+3. `bun run check && bun run test`
+4. Pull request
-Engine source lives in `packages/core/src/`. The app's `src/engine/` and `src/kiwi/` are re-export shims — edit the core package, not the shims.
+## File principali
| File | Purpose |
|------|---------|
-| `packages/core/src/scene-graph.ts` | Scene graph: nodes, variables, instances, hit testing |
-| `packages/core/src/renderer.ts` | CanvasKit rendering pipeline |
-| `packages/core/src/layout.ts` | Yoga layout adapter |
-| `packages/core/src/undo.ts` | Undo/redo manager |
-| `packages/core/src/clipboard.ts` | Figma-compatible clipboard |
-| `packages/core/src/vector.ts` | Vector network model |
-| `packages/core/src/render-image.ts` | Offscreen image export (PNG/JPG/WEBP) |
-| `packages/core/src/kiwi/codec.ts` | Kiwi binary encoder/decoder |
-| `packages/core/src/kiwi/fig-import.ts` | .fig file import logic |
-| `packages/cli/src/index.ts` | CLI entry point |
-| `packages/cli/src/commands/` | CLI commands (info, tree, find, export) |
-| `src/stores/editor.ts` | Global editor state |
-| `src/composables/use-canvas.ts` | Canvas rendering composable |
-| `src/composables/use-canvas-input.ts` | Mouse/touch input handling |
-| `src/composables/use-keyboard.ts` | Keyboard shortcut handling |
+| `packages/core/src/scene-graph.ts` | Scene graph |
+| `packages/core/src/renderer.ts` | CanvasKit rendering |
+| `packages/core/src/layout.ts` | Yoga layout |
+| `packages/core/src/kiwi/codec.ts` | Kiwi codec |
+| `packages/cli/src/commands/` | CLI commands |
+| `src/stores/editor.ts` | Editor state |
diff --git a/packages/docs/it/development/openspec.md b/packages/docs/it/development/openspec.md
index 4907fe432..0045660ab 100644
--- a/packages/docs/it/development/openspec.md
+++ b/packages/docs/it/development/openspec.md
@@ -1,107 +1,73 @@
# Workflow OpenSpec
-OpenPencil uses [OpenSpec](https://github.com/Fission-AI/OpenSpec) for spec-driven development. Specifications are the source of truth for what the system does.
+OpenPencil usa OpenSpec per lo sviluppo guidato da specifiche. Le specifiche sono la fonte di verità.
-## Structure
+## Struttura
```
openspec/
-├── specs/ # Source of truth: how the system works now
+├── specs/ # Source of truth
│ ├── scene-graph/
-│ │ └── spec.md
│ ├── canvas-rendering/
-│ │ └── spec.md
│ ├── auto-layout/
-│ │ └── spec.md
-│ └── ... # 19 capability specs total
-├── changes/ # Proposed changes (one directory per change)
-│ └── archive/ # Completed changes
-└── config.yaml # Optional configuration
+│ └── ... # 19 capability specs
+├── changes/
+│ └── archive/
+└── config.yaml
```
-## Current Specs
+## Specifiche attuali
| Capability | Description |
|-----------|-------------|
-| scene-graph | Flat Map storage, CRUD, hit testing |
-| canvas-rendering | CanvasKit WASM rendering pipeline |
-| canvas-navigation | Pan, zoom, hand tool |
-| selection-manipulation | Click/marquee select, move, resize, rotate |
-| undo-redo | Inverse-command pattern |
-| text-editing | Text tool, Paragraph API, font loading |
-| pen-tool | Vector network model, bezier curves |
-| auto-layout | Yoga WASM flexbox, Shift+A toggle |
-| figma-clipboard | Bidirectional Kiwi binary clipboard |
-| fig-import | .fig file import pipeline |
-| kiwi-codec | Kiwi binary codec, sparse field IDs |
-| editor-ui | Vue 3 panels, toolbar, color picker |
-| snap-guides | Edge/center snapping, rotation-aware |
-| rulers | Canvas rulers, selection highlight |
-| group-ungroup | ⌘G/⇧⌘G, position-based sort |
-| desktop-app | Tauri v2, macOS menu bar |
-| testing | Playwright E2E, bun:test unit |
-| scrub-input | Drag-to-scrub numeric inputs |
-| tooling | Vite 7, oxlint, oxfmt, tsgo, VitePress |
+| scene-graph | Flat Map, CRUD, hit testing |
+| canvas-rendering | CanvasKit WASM rendering |
+| auto-layout | Yoga WASM flexbox |
+| fig-import | .fig file import |
+| kiwi-codec | Kiwi binary codec |
+| editor-ui | Vue 3 panels, toolbar |
+| desktop-app | Tauri v2 |
+| testing | Playwright + bun:test |
+| tooling | Vite, oxlint, tsgo |
## Workflow
-### 1. Propose a Change
+### 1. Proporre una modifica
```
-/opsx:propose add-dark-mode
+/opsx:propose change-name
```
-Creates `openspec/changes/add-dark-mode/` with:
-- `proposal.md` — why and what changes
-- `design.md` — technical approach
-- `specs/` — delta specifications (ADDED/MODIFIED/REMOVED requirements)
-- `tasks.md` — implementation checklist
+→ proposal.md, design.md, specs/, tasks.md
-### 2. Implement
+### 2. Implementare
```
/opsx:apply
```
-Execute tasks from tasks.md, checking off items as they're completed.
-
-### 3. Archive
+### 3. Archiviare
```
/opsx:archive
```
-- Merges delta specs into `openspec/specs/` (the baseline)
-- Moves the change to `openspec/changes/archive/`
-
-## Spec Format
-
-Each spec file follows a consistent structure:
+## Formato delle specifiche
```markdown
# capability-name Specification
-
-## Purpose
-One-line description of what this capability does.
-
## Requirements
-
### Requirement: Name
-Description using SHALL/MUST for normative requirements.
-
#### Scenario: Name
- **WHEN** condition
- **THEN** expected outcome
```
-Every requirement has at least one scenario. Scenarios are potential test cases.
-
-## CLI Commands
+## Comandi CLI
```sh
-openspec list # List active changes
-openspec show <name> # Show change details
-openspec status --change <name> # Artifact status
-openspec archive <name> # Archive completed change
-openspec update # Regenerate skills/prompts
+openspec list
+openspec show <name>
+openspec status --change <name>
+openspec archive <name>
```
diff --git a/packages/docs/it/development/roadmap.md b/packages/docs/it/development/roadmap.md
index 5c9d3753f..caa7f3cfc 100644
--- a/packages/docs/it/development/roadmap.md
+++ b/packages/docs/it/development/roadmap.md
@@ -1,145 +1,32 @@
# Roadmap
-## Phases
+## Fase 1 ✅
+SceneGraph, Skia rendering, shapes, selection, zoom/pan, undo/redo, snap guides.
-### Phase 1: Core Engine ✅
+## Motore Core ✅
+Vue 3 + Reka UI panels, properties, layers, toolbar, Yoga auto-layout, inline text editing, canvas rulers.
-SceneGraph, Skia rendering, basic shapes, selection, zoom/pan, undo/redo.
+## Fase 2 ✅
+.fig import/export, Kiwi codec, clipboard, pen tool, vector networks, groups, Tauri v2 desktop, sections, multi-page, hover highlight, Tier 1 rendering.
-**Delivered:**
-- Scene graph with flat Map storage and parent-child tree
-- CanvasKit WASM rendering for all shape types
-- Click/shift/marquee selection with resize handles and rotation
-- Zoom/pan with keyboard shortcuts and trackpad gestures
-- Undo/redo wired into all operations
-- Snap guides with edge and center snapping
+## UI Editor + Layout ✅
+Components, instances, overrides, component sets, variables (COLOR/FLOAT/STRING/BOOLEAN), collections, modes, image export, context menu, rich text formatting.
-### Phase 2: Editor UI + Layout ✅
+## Fase 3 🟡
+@open-pencil/core, CLI (12 commands), MCP server (29+ tools), AI chat (OpenRouter), JSX renderer, code panel.
-Properties panel, layers panel, toolbar, Yoga layout integration, text editing.
+**Planned:** port remaining figma-use tools, attached mode, design guidelines, screenshot verification loop.
-**Delivered:**
-- Vue 3 + Reka UI panels (properties, layers, toolbar)
-- Properties panel split into sections (Appearance, Fill, Stroke, Typography, Layout, Position)
-- ScrubInput component for all numeric inputs
-- Color picker (HSV, hex, opacity)
-- Layers panel with tree view, drag reorder, visibility toggle
-- Auto-layout with Yoga WASM (direction, gap, padding, justify, align)
-- Inline text editing with CanvasKit Paragraph API
-- System font loading via Local Font Access API
-- Canvas rulers with selection highlight
+## File I/O + Feature Visive 🔲
+Prototyping, comments, PWA, Linux Tauri builds, performance optimization, full Figma compatibility test suite.
-### Phase 3: File I/O + Visual Features ✅
+## Fase 4
-.fig import/export, Kiwi codec, clipboard, sections, pages, advanced rendering.
-
-**Delivered:**
-- .fig file import via Kiwi binary codec
-- .fig file export with Kiwi encoding, Zstd compression, thumbnail generation
-- Save (⌘S) and Save As (⇧⌘S) with native OS dialogs
-- Zstd compression via Tauri Rust command (deflate fallback in browser)
-- Vendored kiwi-schema with ESM + sparse field ID patches
-- Figma-compatible clipboard (bidirectional Kiwi binary)
-- Pen tool with vector network model
-- vectorNetworkBlob binary encode/decode
-- Group/ungroup (⌘G/⇧⌘G)
-- Tauri v2 desktop app with native menu bar (macOS/Windows/Linux)
-- Sections (S key) with title pills, auto-adopt, luminance-adaptive text
-- Multi-page documents with pages panel, per-page viewport
-- Hover highlight with shape-aware outlines
-- Tier 1 rendering: gradients, image fills, effects, strokes (cap/join/dash), arcs
-- Fill type picker with solid/gradient/image tabs and gradient stop editing
-- Canvas background color per page
-- Fig-import unit tests, layout unit tests, layers-panel E2E tests
-
-### Phase 4: Components + Variables ✅
-
-Components, instances, overrides, variables, collections, modes, image export.
-
-**Delivered:**
-- Component creation from frame/group or multi-selection (⌥⌘K)
-- Component sets from multiple components (⇧⌘K) with dashed purple border
-- Instance creation from components with child cloning and componentId mapping
-- Live component-instance sync with override preservation
-- Detach instance back to frame (⌥⌘B)
-- Go to main component (cross-page navigation)
-- Always-visible purple component/instance labels with diamond icon
-- Opaque container hit testing (click selects component, double-click enters)
-- Right-click context menu with clipboard, z-order, grouping, component, visibility, lock, move-to-page actions
-- Z-order manipulation (] bring to front, [ send to back)
-- Toggle visibility (⇧⌘H) and lock (⇧⌘L)
-- Move nodes between pages via context menu
-- Viewport culling, Paint reuse, RAF render coalescing
-- Effects panel UI (drop shadow, inner shadow, layer/background/foreground blur)
-- Independent corner radius controls (per-corner toggle in Appearance section)
-- GitHub Actions CI/CD for Windows (x64, arm64) and macOS (x64, arm64) builds
-- Polygon and Star drawing tools with pointCount and starInnerRadius
-- Resizable left/right panels via reka-ui Splitter (persistent layout)
-- @/ import alias, shared types module (src/types.ts, src/global.d.ts)
-- Codebase lint-clean: 0 oxlint warnings, 0 tsgo type errors
-- Variables: COLOR type with collections, modes, bindings, FillSection variable picker, .fig import
-- Variables dialog: TanStack Table with resizable columns, mode columns, collection tabs with rename, search, demo collections (Primitives/Semantic/Spacing), undo/redo for all variable operations
-- Image export: PNG/JPG/WEBP with ExportSection (scale, format, live preview), ⇧⌘E shortcut, context menu
-- Canvas-native text editing: TextEditor class in core, phantom textarea, cursor/selection/word boundaries on canvas, caret blinking, selection highlights
-- System font enumeration via font-kit Rust crate, OnceLock cache, preload on startup
-- Font picker: virtual scroll (reka-ui ListboxVirtualizer), search filter, CSS font preview
-- ColorInput component extraction, ColorPicker alpha slider checkerboard fix
-- App identity: pencil icon, Cargo crate open_pencil, macOS Dock "OpenPencil"
-- Splash loader during WASM initialization
-- Rich text style runs: per-selection ⌘B/I/U, StyleRun model, ParagraphBuilder pushStyle/pop, .fig roundtrip
-- B/I/U/S toggle buttons in TypographySection
-- Double-click (word), triple-click (select all) text selection
-
-**Remaining (deferred to Phase 6):**
-- Variant switching
-- Variable types: FLOAT, STRING, BOOLEAN editing UI
-- Variable-driven theming
-
-### Phase 5: AI Integration & Tooling 🟡
-
-Core extraction, CLI, MCP server, design guidelines, screenshot verification loop.
-
-**Delivered:**
-- @open-pencil/core extracted to packages/core/ (zero DOM deps, Bun workspace)
-- @open-pencil/cli with headless .fig operations (info, tree, find, export, analyze, node, pages, variables), CanvasKit CPU rasterization, --json output
-- JSX renderer: TreeNode builders (Frame, Text, Rectangle, etc.), renderTreeNode/renderJsx, Tailwind-like shorthand props, 27 tests
-- jscpd copy-paste detection (15.6% → 0.62%), kiwi-serialize.ts consolidation
-- .fig roundtrip tests with LFS fixtures (material3.fig 87K nodes, nuxtui.fig 314K nodes)
-- .fig import O(n²) → O(n) fix (37s → 535ms on 87K nodes), ByteBuffer optimization
-- test:coverage script
-- AI chat: OpenRouter direct (no backend), Stronghold key storage, 26 tools (create_shape, set_fill, set_effects, set_constraints, components, groups, pages, variables, eval_code, etc.), model selector, ⌘J toggle, streaming markdown, Playwright tests with mock transport
-- Code panel: sceneNodeToJsx() export, Prism.js highlighting, line numbers, copy button, 14 tests
-- Properties panel restructured: Design | Code | AI tabs
-- npm publishing preparation for core and cli packages
-
-**Planned:**
-- Port remaining figma-use tools (118 total, 26 currently implemented)
-- Attached mode: WebSocket to running editor for eval, create, export, screenshot
-- Design guidelines system
-- AI-driven design workflow via MCP
-- Screenshot verification loop
-
-### Phase 6: Polish + Distribution 🔲
-
-Prototyping, comments, desktop distribution, documentation, public launch.
-
-**Planned:**
-- Prototyping (frame connections, transitions)
-- Comments (pin, threads, resolve)
-- Linux Tauri builds (macOS and Windows already covered by CI)
-- PWA support
-- Documentation site (VitePress)
-- Performance optimization (Lighthouse > 90)
-- Full Figma compatibility test suite
-- Deferred from Phase 4: variant switching, FLOAT/STRING/BOOLEAN variable UI, variable-driven theming
-
-## Timeline
-
-| Phase | Estimated Duration | Status |
-|-------|-------------------|--------|
-| Phase 1: Core Engine | 3 months | ✅ Complete |
-| Phase 2: Editor UI + Layout | 3 months | ✅ Complete |
-| Phase 3: File I/O + Visual Features | 2 months | ✅ Complete |
-| Phase 4: Components + Variables | 2 months | ✅ Complete |
-| Phase 5: AI Integration & Tooling | 2 months | 🟡 In Progress |
-| Phase 6: Polish + Distribution | 2 months | 🔲 Planned |
+| Phase | Componenti + Variabili | Fase 5: Integrazione IA & Strumenti:Fase 6: Rifinitura + Distribuzione:Tempistica:Durata stimata:Stato |
+|-------|------|-----|
+| Fase 1 | 3 months | ✅ |
+| Motore Core | 3 months | ✅ |
+| Fase 2 | 2 months | ✅ |
+| UI Editor + Layout | 2 months | ✅ |
+| Fase 3 | 2 months | 🟡 |
+| File I/O + Feature Visive | 2 months | 🔲 |
diff --git a/packages/docs/it/development/testing.md b/packages/docs/it/development/testing.md
index efecd9257..5d1be2b1d 100644
--- a/packages/docs/it/development/testing.md
+++ b/packages/docs/it/development/testing.md
@@ -1,6 +1,6 @@
# Testing
-## Overview
+## Panoramica
| Type | Framework | Command | Location |
|------|-----------|---------|----------|
@@ -8,84 +8,45 @@
| Figma CDP reference | Playwright | `bun run test:figma` | `tests/figma/` |
| Unit tests | bun:test | `bun run test:unit` | `tests/engine/` |
-## E2E Visual Regression
-
-Playwright creates shapes on the canvas and compares screenshots against baseline PNGs.
+## Regressione visuale E2E
```sh
-bun run test # Run tests, compare against baselines
-bun run test:update # Regenerate baseline screenshots
+bun run test # Compare against baselines
+bun run test:update # Regenerate baselines
```
-### How It Works
-
-1. Tests load the editor in a headless browser
-2. The editor signals readiness via a `data-ready` HTML attribute
-3. Tests create shapes via the editor's API
-4. Screenshots are taken and compared against baselines using `toMatchSnapshot`
-5. Page is reused across test cases for speed (~2s total)
-
-### No-Chrome Test Mode
-
-The editor supports a test mode that hides UI chrome (toolbar, panels) for clean screenshot capture. Activated via URL parameter.
+1. Playwright → headless browser
+2. `data-ready` HTML attribute
+3. Create shapes → screenshot → `toMatchSnapshot`
-## Figma CDP Reference Tests
-
-A separate Playwright project connects to Figma via Chrome DevTools Protocol to capture reference screenshots for pixel-perfect comparison.
+## Test di riferimento Figma CDP
```sh
bun run figma:debug # Launch Figma with debugging port
-bun run test:figma # Connect to Figma, capture references
+bun run test:figma # Connect via CDP
```
-Requires Figma desktop app running with `--remote-debugging-port=9222`.
-
-## Unit Tests
-
-Engine unit tests use bun:test and target < 50ms execution:
+## Test unitari
```sh
bun run test:unit
```
-Tests cover:
-- Scene graph CRUD operations, parent-child relationships, z-ordering, hit testing
-- **Fig-import pipeline** — node type mapping, transforms, fills/strokes/effects, gradients, images, arcs, nested hierarchies (`tests/engine/fig-import.test.ts`)
-- **Layout computation** — Yoga auto-layout: direction, gap, padding, justify, align, child sizing (fixed/fill/hug), cross-axis sizing, wrap, nested layouts (`tests/engine/layout.test.ts`)
+- Scene graph CRUD, hit testing
+- Fig-import pipeline
+- Layout computation (Yoga)
+- MCP server edge cases
-### Writing Unit Tests
-
-```typescript
-import { describe, expect, it } from 'bun:test'
-import { SceneGraph } from '../../src/engine/scene-graph'
-
-describe('SceneGraph', () => {
- it('creates and retrieves a node', () => {
- const sg = new SceneGraph()
- const node = sg.createNode('RECTANGLE', sg.root, { name: 'Test' })
- expect(sg.getNode(node.guid)).toBeDefined()
- })
-})
-```
-
-## E2E Test Coverage
+## Copertura test E2E
| Test file | Scope |
|-----------|-------|
-| `tests/e2e/layers-panel.spec.ts` | Layers panel tree structure, visibility toggles, selection sync |
-| `tests/e2e/visual.spec.ts` | Visual regression screenshots for shapes and rendering |
-
-## Test Helpers
-
-| File | Purpose |
-|------|---------|
-| `tests/helpers/canvas.ts` | Canvas setup and interaction utilities |
-| `tests/helpers/figma.ts` | Figma CDP connection helpers |
+| `tests/e2e/layers-panel.spec.ts` | Layers panel |
+| `tests/e2e/visual.spec.ts` | Visual regression |
-## Performance Targets
+## Obiettivi di prestazione
| Metric | Target |
|--------|--------|
-| E2E suite total | < 3s |
-| Unit test suite total | < 50ms |
-| Screenshot comparison | toMatchSnapshot (pixel-level) |
+| E2E suite | < 3s |
+| Unit tests | < 50ms |
diff --git a/packages/docs/it/eval-command.md b/packages/docs/it/eval-command.md
index 9f7c45018..732cd6a35 100644
--- a/packages/docs/it/eval-command.md
+++ b/packages/docs/it/eval-command.md
@@ -1,437 +1,77 @@
-# `open-pencil eval` — Figma-like Plugin API for Headless Scripting
+# `open-pencil eval` — API Plugin Figma-compatibile per scripting headless
-## Overview
+## Panoramica
-`bun open-pencil eval <file> --code '<js>'` executes JavaScript against a `.fig` file with a Figma-compatible `figma` global object. This enables headless scripting, batch operations, AI tool execution, and testing — all without the GUI.
+`bun open-pencil eval <file> --code '<js>'` esegue JavaScript su un file `.fig` con un oggetto globale `figma` compatibile con Figma. Questo abilita scripting headless, operazioni batch, esecuzione di strumenti IA e test — tutto senza la GUI.
-The `figma` object mirrors Figma's Plugin API surface as closely as possible, so existing Figma plugin knowledge and code snippets transfer directly.
+L'oggetto `figma` rispecchia la superficie dell'API Plugin di Figma il più fedelmente possibile, così le conoscenze esistenti sui plugin Figma e gli snippet di codice sono direttamente trasferibili.
```bash
-# Create a frame, set auto-layout, add children
+# Creare un frame, impostare auto-layout, aggiungere figli
bun open-pencil eval design.fig --code '
const frame = figma.createFrame()
frame.name = "Card"
frame.resize(300, 200)
frame.layoutMode = "VERTICAL"
frame.itemSpacing = 12
- frame.paddingTop = frame.paddingBottom = 16
- frame.paddingLeft = frame.paddingRight = 16
frame.fills = [{ type: "SOLID", color: { r: 1, g: 1, b: 1 } }]
-
- const title = figma.createText()
- title.characters = "Hello World"
- title.fontSize = 24
- frame.appendChild(title)
-
return { id: frame.id, name: frame.name }
'
-# Query nodes
+# Interrogare nodi
bun open-pencil eval design.fig --code '
- const buttons = figma.currentPage.findAll(n => n.type === "FRAME" && n.name.includes("Button"))
- return buttons.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
+ const buttons = figma.currentPage.findAll(n => n.name.includes("Button"))
+ return buttons.map(b => ({ id: b.id, name: b.name }))
'
-# Read from stdin (for multiline scripts / piping)
-cat transform.js | bun open-pencil eval design.fig --stdin
-
-# Write changes back
+# Scrivere le modifiche
bun open-pencil eval design.fig --code '...' --write
-bun open-pencil eval design.fig --code '...' -o modified.fig
```
-## Architecture
+## Architettura
```
-┌──────────────────────────────────────────────────────┐
-│ CLI: `open-pencil eval <file> --code '...'` │
-│ ↓ │
-│ loadDocument(file) → SceneGraph │
-│ ↓ │
-│ FigmaAPI(sceneGraph) → `figma` proxy object │
-│ ↓ │
-│ AsyncFunction('figma', wrappedCode)(figmaProxy) │
-│ ↓ │
-│ print result as JSON / agentfmt │
-│ optionally: saveDocument(file) if --write │
-└──────────────────────────────────────────────────────┘
+CLI: open-pencil eval <file> --code '...'
+ → loadDocument(file) → SceneGraph
+ → FigmaAPI(sceneGraph) → proxy `figma`
+ → AsyncFunction('figma', code)(figmaProxy)
+ → stampa risultato / salva file con --write
```
-### Key classes
-
-| Class | Location | Role |
-|-------|----------|------|
-| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy object implementing `figma.*` methods against `SceneGraph` |
-| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy wrapping `SceneNode` with Figma-style property access (`.fills`, `.resize()`, `.appendChild()`, etc.) |
-| `eval` command | `packages/cli/src/commands/eval.ts` | CLI command that loads doc, creates API, executes code |
-
-### Why in `@open-pencil/core`?
-
-The `FigmaAPI` class lives in core (not CLI) because:
-- **AI tools reuse it** — the chat panel's `render` tool can execute JSX through the same API
-- **Test scripts** — unit tests can use the API to set up fixtures
-- **No DOM deps** — runs headless in Bun, no browser APIs needed
-
-## `FigmaAPI` — Phased Implementation
-
-### Phase 1: Core (MVP for eval command)
-
-These cover ~80% of real plugin scripts:
-
-#### Document & Page
-
-| Figma API | Our implementation | Notes |
-|-----------|--------------------|-------|
-| `figma.root` | Getter → proxy for root node | `.children` returns page proxies |
-| `figma.currentPage` | Getter/setter → first page by default | Settable to any page proxy |
-| `figma.currentPage.selection` | Get/set → tracked selection array | |
-| `figma.getNodeById(id)` | `graph.getNode(id)` wrapped in proxy | Sync, like Figma's deprecated version |
+### Classi principali
-#### Node Creation
+| Classe | Posizione | Ruolo |
+|--------|-----------|-------|
+| `FigmaAPI` | `packages/core/src/figma-api.ts` | Oggetto proxy che implementa metodi `figma.*` |
+| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy che avvolge `SceneNode` con accesso proprietà stile Figma |
+| Comando `eval` | `packages/cli/src/commands/eval.ts` | Carica documento, crea API, esegue codice |
-| Figma API | Maps to |
-|-----------|---------|
-| `figma.createFrame()` | `graph.createNode('FRAME', currentPageId)` |
-| `figma.createRectangle()` | `graph.createNode('RECTANGLE', ...)` |
-| `figma.createEllipse()` | `graph.createNode('ELLIPSE', ...)` |
-| `figma.createText()` | `graph.createNode('TEXT', ...)` |
-| `figma.createLine()` | `graph.createNode('LINE', ...)` |
-| `figma.createPolygon()` | `graph.createNode('POLYGON', ...)` |
-| `figma.createStar()` | `graph.createNode('STAR', ...)` |
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createPage()` | `graph.addPage(name)` |
-| `figma.createSection()` | `graph.createNode('SECTION', ...)` |
+### Perché in `@open-pencil/core`?
-#### Node Properties (via `FigmaNode` proxy)
+La classe `FigmaAPI` è nel core perché: gli strumenti IA la riutilizzano, i test possono usarla e non ha dipendenze DOM.
-Read/write on any node proxy. Property access maps to `SceneNode` fields:
+## Comando CLI
-```ts
-// Geometry
-node.x, node.y // direct
-node.width, node.height // read-only, use node.resize(w, h)
-node.rotation // direct
-node.resize(w, h) // updates width + height
-node.resizeWithoutConstraints(w, h) // same (no constraint engine yet)
-
-// Visual
-node.fills // get/set Fill[]
-node.strokes // get/set Stroke[]
-node.effects // get/set Effect[]
-node.opacity // get/set number
-node.visible // get/set boolean
-node.locked // get/set boolean
-node.blendMode // get/set BlendMode
-node.clipsContent // get/set boolean
-
-// Corner radius
-node.cornerRadius // get/set (number or figma.mixed)
-node.topLeftRadius // get/set
-node.topRightRadius // get/set
-node.bottomLeftRadius // get/set
-node.bottomRightRadius // get/set
-node.cornerSmoothing // get/set
-
-// Identity
-node.id // read-only
-node.name // get/set
-node.type // read-only
-node.parent // read-only → FigmaNode | null
-node.removed // read-only boolean
-```
-
-#### Tree Operations
-
-```ts
-node.children // read-only FigmaNode[]
-node.appendChild(child) // reparent to end
-node.insertChild(index, child) // reparent at index
-node.remove() // graph.deleteNode(id)
-
-// Traversal
-node.findAll(callback?) // recursive find
-node.findOne(callback) // first match
-node.findChild(callback) // direct children only
-node.findChildren(callback?) // direct children only
```
+bun open-pencil eval <file> [opzioni]
-#### Auto-layout
-
-```ts
-node.layoutMode // 'NONE' | 'HORIZONTAL' | 'VERTICAL'
-node.primaryAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'
-node.counterAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'BASELINE'
-node.itemSpacing // number
-node.counterAxisSpacing // number | null
-node.paddingTop / Right / Bottom / Left // number
-node.layoutWrap // 'NO_WRAP' | 'WRAP'
-
-// Child sizing
-node.layoutPositioning // 'AUTO' | 'ABSOLUTE'
-node.layoutGrow // 0 | 1
-node.layoutSizingHorizontal // 'FIXED' | 'HUG' | 'FILL'
-node.layoutSizingVertical // 'FIXED' | 'HUG' | 'FILL'
-```
-
-#### Text
-
-```ts
-node.characters // get/set (maps to node.text)
-node.fontSize // get/set
-node.fontName // get/set { family, style }
-node.fontWeight // get/set
-node.textAlignHorizontal // get/set
-node.textAlignVertical // get/set
-node.textAutoResize // get/set
-node.letterSpacing // get/set
-node.lineHeight // get/set
-node.maxLines // get/set
-node.textCase // get/set
-node.textDecoration // get/set
-```
-
-#### Stroke details
-
-```ts
-node.strokeWeight // get/set (maps to strokes[0].weight)
-node.strokeAlign // get/set (maps to strokes[0].align)
-node.dashPattern // get/set
-```
-
-#### Misc
-
-```ts
-figma.mixed // Symbol sentinel for mixed values
-figma.group(nodes, parent) // creates GROUP with given children
-figma.ungroup(node) // ungroups, reparents children
-figma.flatten(nodes) // NOT IMPLEMENTED YET — returns first node
-```
-
-#### Export
-
-```ts
-node.exportAsync(settings?) // only works if CanvasKit is loaded
- // settings: { format: 'PNG'|'JPG'|'SVG', constraint? }
-```
-
-### Phase 2: Components & Instances
-
-| API | Maps to |
-|-----|---------|
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createComponentFromNode(node)` | Convert existing frame to component |
-| `figma.combineAsVariants(components, parent)` | Create COMPONENT_SET |
-| Node: `node.createInstance()` | `graph.createInstance(componentId, parentId)` |
-| Node: `node.detachInstance()` | `graph.detachInstance(id)` |
-| `figma.getNodeById(id).mainComponent` | `graph.getMainComponent(id)` |
-
-### Phase 3: Variables
-
-| API | Maps to |
-|-----|---------|
-| `figma.variables.getLocalVariables(type?)` | `graph.variables` filtered |
-| `figma.variables.getLocalVariableCollections()` | `graph.variableCollections` |
-| `figma.variables.createVariable(name, collection, type)` | `graph.addVariable(...)` |
-| `figma.variables.createVariableCollection(name)` | `graph.addCollection(...)` |
-| `figma.variables.getVariableById(id)` | `graph.variables.get(id)` |
-| `node.setBoundVariable(field, variable)` | `graph.bindVariable(...)` |
-| `node.boundVariables` | getter from SceneNode |
-
-### Phase 4: Styles & Advanced
-
-| API | Notes |
-|-----|-------|
-| `figma.createPaintStyle()` | Requires style storage in SceneGraph |
-| `figma.createTextStyle()` | Requires style storage in SceneGraph |
-| `figma.createEffectStyle()` | Requires style storage in SceneGraph |
-| `figma.loadFontAsync(fontName)` | No-op (we don't have font loading constraints) |
-| `figma.listAvailableFontsAsync()` | Return system fonts if available |
-| Boolean operations (`union`, `subtract`, `intersect`, `exclude`) | Requires path boolean engine |
-| `figma.createNodeFromJSXAsync(jsx)` | Port figma-use's JSX renderer |
-
-## `FigmaNode` Proxy Design
-
-The proxy wraps a `SceneNode` and translates Figma property names to our internal names. Key mappings:
+Argomenti:
+ file File .fig su cui operare
-```ts
-const PROPERTY_MAP: Record<string, string> = {
- // Figma name → SceneNode field name (only where they differ)
- 'characters': 'text',
- 'strokeWeight': → computed from strokes[0].weight,
- 'strokeAlign': → computed from strokes[0].align,
- 'fontName': → computed from { family: fontFamily, style: ... },
- 'primaryAxisAlignItems': 'primaryAxisAlign',
- 'counterAxisAlignItems': 'counterAxisAlign',
- 'primaryAxisSizingMode': 'primaryAxisSizing', // value mapping: 'AUTO' → 'HUG', 'FIXED' → 'FIXED'
- 'counterAxisSizingMode': 'counterAxisSizing',
- 'layoutSizingHorizontal': → computed from primaryAxisSizing / counterAxisSizing depending on layoutMode
- 'layoutSizingVertical': → computed
-}
+Opzioni:
+ --code, -c Codice JavaScript da eseguire
+ --stdin Leggere codice da stdin
+ --write, -w Scrivere le modifiche nel file di input
+ -o, --output Scrivere in un file diverso
+ --json Output come JSON
+ --quiet, -q Sopprimere l'output
```
-Methods on the proxy:
-
-```ts
-class FigmaNode {
- // The proxy is created via: new Proxy(target, handler)
- // where handler.get intercepts property reads and handler.set intercepts writes
-
- resize(width: number, height: number): void
- resizeWithoutConstraints(width: number, height: number): void
- remove(): void
- appendChild(child: FigmaNode): void
- insertChild(index: number, child: FigmaNode): void
- findAll(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- findOne(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChild(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChildren(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- exportAsync(settings?: ExportSettings): Promise<Uint8Array>
-
- // Components (Phase 2)
- createInstance(): FigmaNode
- detachInstance(): void
- get mainComponent(): FigmaNode | null
-}
-```
-
-## CLI Command
-
-```
-bun open-pencil eval <file> [options]
-
-Arguments:
- file .fig file to operate on
-
-Options:
- --code, -c JavaScript code to execute (has access to `figma` global)
- --stdin Read code from stdin instead of --code
- --write, -w Write changes back to the input file
- -o, --output Write to a different file
- --json Output result as JSON (default for non-TTY)
- --quiet, -q Suppress output, only write file
-```
-
-### Execution model
-
-1. Load `.fig` → `SceneGraph`
-2. Create `FigmaAPI(graph)` → `figma` proxy
-3. Wrap user code in async function: `return (async () => { <code> })()`
-4. Execute with `figma` as sole argument
-5. Print return value (JSON or agentfmt)
-6. If `--write` or `-o`: serialize `SceneGraph` back to `.fig`
-
-### Return value formatting
-
-- `undefined` / `void` → no output
-- Primitives → printed directly
-- Objects/arrays → `JSON.stringify(result, null, 2)` or agentfmt tables
-- `FigmaNode` → serialized as `{ id, type, name, x, y, width, height, fills, ... }`
-- Arrays of `FigmaNode` → serialized as list
-
-## Shared with AI Tools
-
-The `FigmaAPI` class is the **same API surface** that AI tools use. Currently `src/ai/tools.ts` calls `store.createShape()`, `store.updateNodeWithUndo()`, etc. — these should be refactored to go through `FigmaAPI`:
-
-```ts
-// Before (current AI tools)
-execute: async ({ type, x, y, width, height }) => {
- const id = store.createShape(type, x, y, width, height)
- return { id }
-}
-
-// After (using FigmaAPI)
-execute: async ({ type, x, y, width, height }) => {
- const frame = figma.createFrame()
- frame.resize(width, height)
- frame.x = x
- frame.y = y
- return { id: frame.id }
-}
-```
-
-This ensures CLI scripts and AI tools behave identically.
-
-## File Layout
-
-```
-packages/core/src/
- figma-api.ts # FigmaAPI class + FigmaNode proxy (Phase 1–4)
- figma-api.test.ts # Unit tests against headless SceneGraph
-
-packages/cli/src/commands/
- eval.ts # CLI command
-
-packages/cli/src/commands/eval.test.ts # Integration tests
-```
-
-## Test Plan
-
-### Unit tests (`packages/core/src/figma-api.test.ts`)
-
-1. **Node creation** — each `createX()` creates correct type, added to current page
-2. **Property access** — `.fills`, `.x`, `.width`, `.name`, `.characters` read/write correctly
-3. **Resize** — `.resize(w, h)` updates width/height
-4. **Tree operations** — `.appendChild()`, `.insertChild()`, `.remove()`, `.parent`, `.children`
-5. **Traversal** — `.findAll()`, `.findOne()`, `.findChild()`, `.findChildren()` with callbacks
-6. **Auto-layout** — `.layoutMode`, `.itemSpacing`, `.paddingTop`, etc.
-7. **Text** — `.characters` maps to `.text`, `.fontName` maps to `{ family, style }`
-8. **Mixed values** — `.cornerRadius` returns `figma.mixed` when corners differ
-9. **Selection** — `figma.currentPage.selection` get/set
-10. **Page switching** — `figma.currentPage = page2` works
-11. **Group/ungroup** — `figma.group()` creates group, `figma.ungroup()` dissolves it
-12. **Clone** — node creation produces independent copies
-
-### CLI integration tests (`packages/cli/src/commands/eval.test.ts`)
-
-1. **Basic eval** — `eval test.fig --code 'return figma.currentPage.name'` → page name
-2. **Create + read** — create a frame, return its properties
-3. **Query nodes** — `findAll` returns correct nodes
-4. **Write back** — `--write` saves changes, reloading shows them
-5. **Stdin** — `echo 'return 42' | bun open-pencil eval test.fig --stdin` → `42`
-6. **JSON output** — `--json` returns valid JSON
-7. **Error handling** — syntax errors, runtime errors reported cleanly
-
-## Implementation Order
-
-1. **`FigmaNode` proxy** — property mapping, `.resize()`, `.remove()`, tree methods
-2. **`FigmaAPI` class** — `createFrame/Rectangle/...`, `.root`, `.currentPage`, `.getNodeById()`, `.mixed`, `.group()`
-3. **CLI `eval` command** — argument parsing, code wrapping, output formatting
-4. **Unit tests** — all 12 test groups above
-5. **CLI integration tests** — all 7 test groups above
-6. **Wire to AI tools** — refactor `src/ai/tools.ts` to use `FigmaAPI` where possible
-7. **Phase 2** — components & instances
-8. **Phase 3** — variables
-9. **Phase 4** — styles, boolean ops, JSX renderer
-
-## Property Mapping Reference
-
-| Figma Property | SceneNode Field | Type | Notes |
-|---------------|-----------------|------|-------|
-| `characters` | `text` | `string` | |
-| `fontName` | `fontFamily` + `fontWeight` + `italic` | `{ family, style }` | Computed: `style` = "Bold Italic" etc. |
-| `strokeWeight` | `strokes[0].weight` | `number` | Computed |
-| `strokeAlign` | `strokes[0].align` | `string` | Computed |
-| `primaryAxisAlignItems` | `primaryAxisAlign` | `string` | |
-| `counterAxisAlignItems` | `counterAxisAlign` | `string` | |
-| `layoutSizingHorizontal` | `primaryAxisSizing` or `counterAxisSizing` | `string` | Depends on `layoutMode` |
-| `layoutSizingVertical` | (opposite of horizontal) | `string` | |
-| `absoluteTransform` | computed from `x`, `y`, `rotation` | `Transform` | Read-only |
-| `absoluteBoundingBox` | `getAbsoluteBounds(id)` | `Rect` | Read-only |
-| All others | Same name | Same type | Direct passthrough |
-
-## Open Questions
-
-1. **Font loading**: `figma.loadFontAsync()` — should it be a no-op (we don't have font gating) or should we track loaded fonts?
- → **Decision: No-op that returns resolved Promise.** We don't gate text editing on font loading.
-
-2. **Export in headless mode**: `node.exportAsync()` requires CanvasKit. Should eval load CanvasKit?
- → **Decision: Optional.** If CanvasKit is available (via `--with-canvaskit` flag or env), enable export. Otherwise, throw "Export requires CanvasKit" error.
-
-3. **`figma.mixed` symbol**: Should we use the actual Figma symbol or our own?
- → **Decision: Our own `Symbol('mixed')`.** Exposed as `figma.mixed`.
+## Implementazione a fasi
-4. **Undo**: `figma.commitUndo()` / `figma.triggerUndo()` — relevant in headless?
- → **Decision: No-op in CLI.** Undo only matters in the live editor. The AI tools can add undo support separately via EditorStore.
+- **Fase 1: Core** — creazione nodi, proprietà, operazioni albero, auto-layout, testo (~80% degli script reali)
+- **Fase 2: Componenti & Istanze** — createComponent, createInstance, detachInstance
+- **Fase 3: Variabili** — getLocalVariables, createVariable, setBoundVariable
+- **Fase 4: Stili & Avanzato** — stili paint/testo/effetti, operazioni booleane
-5. **Write format**: Should `--write` produce `.fig` (Kiwi binary) or also support `.json`?
- → **Decision: `.fig` only for now.** JSON export is a separate feature.
+[Riferimento API completo in inglese](/eval-command)
diff --git a/packages/docs/it/reference/file-format.md b/packages/docs/it/reference/file-format.md
index 1318032e3..b49d41784 100644
--- a/packages/docs/it/reference/file-format.md
+++ b/packages/docs/it/reference/file-format.md
@@ -1,6 +1,6 @@
# Formato file
-## .fig File Structure
+## Struttura file .fig
```
┌─────────────────────────────────┐
@@ -14,7 +14,7 @@
└─────────────────────────────────┘
```
-## Import Pipeline
+## Pipeline di importazione
```
.fig file → Parse header → Decompress Zstd → Decode Kiwi schema
@@ -22,7 +22,7 @@
→ Resolve blob refs → Render on canvas
```
-## Export Pipeline
+## Pipeline di esportazione
```
SceneGraph → NodeChange[] → Kiwi encode → Compress (Zstd/deflate)
diff --git a/packages/docs/it/reference/mcp-tools.md b/packages/docs/it/reference/mcp-tools.md
index 56f059449..13cb35701 100644
--- a/packages/docs/it/reference/mcp-tools.md
+++ b/packages/docs/it/reference/mcp-tools.md
@@ -1,10 +1,10 @@
# Server MCP
-OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
+OpenPencil include un server MCP (Model Context Protocol) che permette agli strumenti di coding IA — Claude Code, Cursor, Windsurf ecc. — di leggere e modificare file .fig headless.
-Two transports: **stdio** for MCP clients, **HTTP** for everything else.
+Due trasporti
-## Install
+## **stdio** per client MCP, **HTTP** per tutto il resto.
```sh
bun add -g @open-pencil/mcp
@@ -24,7 +24,7 @@ Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json`):
}
```
-Or run from source without installing:
+Installazione:O eseguire dal codice sorgente:
::: code-group
```json [Bun]
diff --git a/packages/docs/it/reference/scene-graph.md b/packages/docs/it/reference/scene-graph.md
index ea9778529..a72146525 100644
--- a/packages/docs/it/reference/scene-graph.md
+++ b/packages/docs/it/reference/scene-graph.md
@@ -1,8 +1,8 @@
# Grafo della scena
-## In-Memory Representation
+## Rappresentazione in memoria
-Nodes live in a flat `Map<string, Node>` keyed by GUID string. The tree structure is maintained via `parentIndex` references. This gives O(1) lookup by ID and efficient traversal.
+I nodi vivono in una mappa piatta `Map<string, Node>` keyed by GUID string. La struttura ad albero è mantenuta via `parentIndex` references. This gives Lookup O(1) by ID and efficient traversal.
```typescript
interface SceneGraph {
diff --git a/packages/docs/pl/development/contributing.md b/packages/docs/pl/development/contributing.md
index 973ee6628..43a9b981d 100644
--- a/packages/docs/pl/development/contributing.md
+++ b/packages/docs/pl/development/contributing.md
@@ -1,94 +1,65 @@
# Współpraca
-## Project Structure
+## Struktura projektu
```
packages/
- core/ @open-pencil/core — engine (zero DOM deps)
- src/ Scene graph, renderer, layout, codec, kiwi, types
- cli/ @open-pencil/cli — headless CLI for .fig operations
- src/commands/ info, tree, find, export
+ core/ @open-pencil/core — Engine
+ cli/ @open-pencil/cli — Headless CLI
+ mcp/ @open-pencil/mcp — MCP server
+ docs/ @open-pencil/docs — VitePress
src/
- components/ Vue SFCs (canvas, panels, toolbar, color picker)
- properties/ Property panel sections (Appearance, Fill, Stroke, etc.)
- composables/ Canvas input, keyboard shortcuts, rendering hooks
- stores/ Editor state (Vue reactivity)
- engine/ Re-export shims from @open-pencil/core
- kiwi/ Re-export shims from @open-pencil/core
- types.ts Shared types (re-exported from core)
- constants.ts UI colors, defaults, thresholds
-desktop/ Tauri v2 (Rust + config)
+ components/ Vue SFCs
+ composables/ Canvas input, shortcuts, rendering
+ stores/ Editor state
+desktop/ Tauri v2
tests/
- e2e/ Playwright visual regression
- engine/ Unit tests (bun:test)
-docs/ VitePress documentation site
-openspec/
- specs/ Capability specifications (source of truth)
- changes/ Active and archived changes
+ e2e/ Playwright
+ engine/ bun:test
+openspec/ Specs + changes
```
-## Development Setup
+## Środowisko deweloperskie
```sh
bun install
-bun run dev # Editor at localhost:1420
-bun run docs:dev # Docs at localhost:5173
+bun run dev # Editor: localhost:1420
+bun run docs:dev # Docs: localhost:5173
```
-## Code Style
+## Styl kodu
-### Tooling
+### Narzędzia
| Tool | Command | Purpose |
|------|---------|---------|
-| oxlint | `bun run lint` | Linting (Rust-based, fast) |
-| oxfmt | `bun run format` | Code formatting |
-| tsgo | `bun run typecheck` | Type checking (Go-based TypeScript checker) |
-
-Run all checks:
+| oxlint | `bun run lint` | Linting |
+| oxfmt | `bun run format` | Formatting |
+| tsgo | `bun run typecheck` | Type checking |
```sh
bun run check
```
-### Conventions
-
-- **File names** — kebab-case (`scene-graph.ts`, `use-canvas-input.ts`)
-- **Components** — PascalCase Vue SFCs (`EditorCanvas.vue`, `ScrubInput.vue`)
-- **Constants** — SCREAMING_SNAKE_CASE
-- **Functions/variables** — camelCase
-- **Types/interfaces** — PascalCase
-
-### AI Agent Conventions
-
-Developers and AI agents working on the codebase should read `AGENTS.md` in the repo root ([view on GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)). Covers rendering, scene graph, components & instances, layout, UI, file format, Tauri conventions, and known issues.
+### Konwencje
-## Making Changes
+- kebab-case (files), PascalCase (components/types), camelCase (functions), SCREAMING_SNAKE_CASE (constants)
+- AGENTS.md — [GitHub](https://github.com/open-pencil/open-pencil/blob/master/AGENTS.md)
-1. Check existing [openspec specs](/development/openspec) for the capability you're modifying
-2. Create an openspec change if adding new behavior: `openspec new change "my-change"`
-3. Implement the change
-4. Run `bun run check` and `bun run test`
-5. Submit a pull request
+## Wprowadzanie zmian
-## Key Files
+1. [OpenSpec](./openspec) specs
+2. `openspec new change "name"`
+3. `bun run check && bun run test`
+4. Pull request
-Engine source lives in `packages/core/src/`. The app's `src/engine/` and `src/kiwi/` are re-export shims — edit the core package, not the shims.
+## Kluczowe pliki
| File | Purpose |
|------|---------|
-| `packages/core/src/scene-graph.ts` | Scene graph: nodes, variables, instances, hit testing |
-| `packages/core/src/renderer.ts` | CanvasKit rendering pipeline |
-| `packages/core/src/layout.ts` | Yoga layout adapter |
-| `packages/core/src/undo.ts` | Undo/redo manager |
-| `packages/core/src/clipboard.ts` | Figma-compatible clipboard |
-| `packages/core/src/vector.ts` | Vector network model |
-| `packages/core/src/render-image.ts` | Offscreen image export (PNG/JPG/WEBP) |
-| `packages/core/src/kiwi/codec.ts` | Kiwi binary encoder/decoder |
-| `packages/core/src/kiwi/fig-import.ts` | .fig file import logic |
-| `packages/cli/src/index.ts` | CLI entry point |
-| `packages/cli/src/commands/` | CLI commands (info, tree, find, export) |
-| `src/stores/editor.ts` | Global editor state |
-| `src/composables/use-canvas.ts` | Canvas rendering composable |
-| `src/composables/use-canvas-input.ts` | Mouse/touch input handling |
-| `src/composables/use-keyboard.ts` | Keyboard shortcut handling |
+| `packages/core/src/scene-graph.ts` | Scene graph |
+| `packages/core/src/renderer.ts` | CanvasKit rendering |
+| `packages/core/src/layout.ts` | Yoga layout |
+| `packages/core/src/kiwi/codec.ts` | Kiwi codec |
+| `packages/cli/src/commands/` | CLI commands |
+| `src/stores/editor.ts` | Editor state |
diff --git a/packages/docs/pl/development/openspec.md b/packages/docs/pl/development/openspec.md
index 4907fe432..de0472869 100644
--- a/packages/docs/pl/development/openspec.md
+++ b/packages/docs/pl/development/openspec.md
@@ -1,107 +1,73 @@
# Workflow OpenSpec
-OpenPencil uses [OpenSpec](https://github.com/Fission-AI/OpenSpec) for spec-driven development. Specifications are the source of truth for what the system does.
+OpenPencil używa OpenSpec do rozwoju opartego na specyfikacjach. Specyfikacje są źródłem prawdy.
-## Structure
+## Struktura
```
openspec/
-├── specs/ # Source of truth: how the system works now
+├── specs/ # Source of truth
│ ├── scene-graph/
-│ │ └── spec.md
│ ├── canvas-rendering/
-│ │ └── spec.md
│ ├── auto-layout/
-│ │ └── spec.md
-│ └── ... # 19 capability specs total
-├── changes/ # Proposed changes (one directory per change)
-│ └── archive/ # Completed changes
-└── config.yaml # Optional configuration
+│ └── ... # 19 capability specs
+├── changes/
+│ └── archive/
+└── config.yaml
```
-## Current Specs
+## Bieżące specyfikacje
| Capability | Description |
|-----------|-------------|
-| scene-graph | Flat Map storage, CRUD, hit testing |
-| canvas-rendering | CanvasKit WASM rendering pipeline |
-| canvas-navigation | Pan, zoom, hand tool |
-| selection-manipulation | Click/marquee select, move, resize, rotate |
-| undo-redo | Inverse-command pattern |
-| text-editing | Text tool, Paragraph API, font loading |
-| pen-tool | Vector network model, bezier curves |
-| auto-layout | Yoga WASM flexbox, Shift+A toggle |
-| figma-clipboard | Bidirectional Kiwi binary clipboard |
-| fig-import | .fig file import pipeline |
-| kiwi-codec | Kiwi binary codec, sparse field IDs |
-| editor-ui | Vue 3 panels, toolbar, color picker |
-| snap-guides | Edge/center snapping, rotation-aware |
-| rulers | Canvas rulers, selection highlight |
-| group-ungroup | ⌘G/⇧⌘G, position-based sort |
-| desktop-app | Tauri v2, macOS menu bar |
-| testing | Playwright E2E, bun:test unit |
-| scrub-input | Drag-to-scrub numeric inputs |
-| tooling | Vite 7, oxlint, oxfmt, tsgo, VitePress |
+| scene-graph | Flat Map, CRUD, hit testing |
+| canvas-rendering | CanvasKit WASM rendering |
+| auto-layout | Yoga WASM flexbox |
+| fig-import | .fig file import |
+| kiwi-codec | Kiwi binary codec |
+| editor-ui | Vue 3 panels, toolbar |
+| desktop-app | Tauri v2 |
+| testing | Playwright + bun:test |
+| tooling | Vite, oxlint, tsgo |
## Workflow
-### 1. Propose a Change
+### 1. Zaproponuj zmianę
```
-/opsx:propose add-dark-mode
+/opsx:propose change-name
```
-Creates `openspec/changes/add-dark-mode/` with:
-- `proposal.md` — why and what changes
-- `design.md` — technical approach
-- `specs/` — delta specifications (ADDED/MODIFIED/REMOVED requirements)
-- `tasks.md` — implementation checklist
+→ proposal.md, design.md, specs/, tasks.md
-### 2. Implement
+### 2. Implementuj
```
/opsx:apply
```
-Execute tasks from tasks.md, checking off items as they're completed.
-
-### 3. Archive
+### 3. Archiwizuj
```
/opsx:archive
```
-- Merges delta specs into `openspec/specs/` (the baseline)
-- Moves the change to `openspec/changes/archive/`
-
-## Spec Format
-
-Each spec file follows a consistent structure:
+## Format specyfikacji
```markdown
# capability-name Specification
-
-## Purpose
-One-line description of what this capability does.
-
## Requirements
-
### Requirement: Name
-Description using SHALL/MUST for normative requirements.
-
#### Scenario: Name
- **WHEN** condition
- **THEN** expected outcome
```
-Every requirement has at least one scenario. Scenarios are potential test cases.
-
-## CLI Commands
+## Polecenia CLI
```sh
-openspec list # List active changes
-openspec show <name> # Show change details
-openspec status --change <name> # Artifact status
-openspec archive <name> # Archive completed change
-openspec update # Regenerate skills/prompts
+openspec list
+openspec show <name>
+openspec status --change <name>
+openspec archive <name>
```
diff --git a/packages/docs/pl/development/roadmap.md b/packages/docs/pl/development/roadmap.md
index 59a244531..68d8b612c 100644
--- a/packages/docs/pl/development/roadmap.md
+++ b/packages/docs/pl/development/roadmap.md
@@ -1,145 +1,32 @@
# Plan rozwoju
-## Phases
+## Faza 1 ✅
+SceneGraph, Skia rendering, shapes, selection, zoom/pan, undo/redo, snap guides.
-### Phase 1: Core Engine ✅
+## Silnik Core ✅
+Vue 3 + Reka UI panels, properties, layers, toolbar, Yoga auto-layout, inline text editing, canvas rulers.
-SceneGraph, Skia rendering, basic shapes, selection, zoom/pan, undo/redo.
+## Faza 2 ✅
+.fig import/export, Kiwi codec, clipboard, pen tool, vector networks, groups, Tauri v2 desktop, sections, multi-page, hover highlight, Tier 1 rendering.
-**Delivered:**
-- Scene graph with flat Map storage and parent-child tree
-- CanvasKit WASM rendering for all shape types
-- Click/shift/marquee selection with resize handles and rotation
-- Zoom/pan with keyboard shortcuts and trackpad gestures
-- Undo/redo wired into all operations
-- Snap guides with edge and center snapping
+## UI Edytora + Layout ✅
+Components, instances, overrides, component sets, variables (COLOR/FLOAT/STRING/BOOLEAN), collections, modes, image export, context menu, rich text formatting.
-### Phase 2: Editor UI + Layout ✅
+## Faza 3 🟡
+@open-pencil/core, CLI (12 commands), MCP server (29+ tools), AI chat (OpenRouter), JSX renderer, code panel.
-Properties panel, layers panel, toolbar, Yoga layout integration, text editing.
+**Planned:** port remaining figma-use tools, attached mode, design guidelines, screenshot verification loop.
-**Delivered:**
-- Vue 3 + Reka UI panels (properties, layers, toolbar)
-- Properties panel split into sections (Appearance, Fill, Stroke, Typography, Layout, Position)
-- ScrubInput component for all numeric inputs
-- Color picker (HSV, hex, opacity)
-- Layers panel with tree view, drag reorder, visibility toggle
-- Auto-layout with Yoga WASM (direction, gap, padding, justify, align)
-- Inline text editing with CanvasKit Paragraph API
-- System font loading via Local Font Access API
-- Canvas rulers with selection highlight
+## I/O Plików + Funkcje Wizualne 🔲
+Prototyping, comments, PWA, Linux Tauri builds, performance optimization, full Figma compatibility test suite.
-### Phase 3: File I/O + Visual Features ✅
+## Faza 4
-.fig import/export, Kiwi codec, clipboard, sections, pages, advanced rendering.
-
-**Delivered:**
-- .fig file import via Kiwi binary codec
-- .fig file export with Kiwi encoding, Zstd compression, thumbnail generation
-- Save (⌘S) and Save As (⇧⌘S) with native OS dialogs
-- Zstd compression via Tauri Rust command (deflate fallback in browser)
-- Vendored kiwi-schema with ESM + sparse field ID patches
-- Figma-compatible clipboard (bidirectional Kiwi binary)
-- Pen tool with vector network model
-- vectorNetworkBlob binary encode/decode
-- Group/ungroup (⌘G/⇧⌘G)
-- Tauri v2 desktop app with native menu bar (macOS/Windows/Linux)
-- Sections (S key) with title pills, auto-adopt, luminance-adaptive text
-- Multi-page documents with pages panel, per-page viewport
-- Hover highlight with shape-aware outlines
-- Tier 1 rendering: gradients, image fills, effects, strokes (cap/join/dash), arcs
-- Fill type picker with solid/gradient/image tabs and gradient stop editing
-- Canvas background color per page
-- Fig-import unit tests, layout unit tests, layers-panel E2E tests
-
-### Phase 4: Components + Variables ✅
-
-Components, instances, overrides, variables, collections, modes, image export.
-
-**Delivered:**
-- Component creation from frame/group or multi-selection (⌥⌘K)
-- Component sets from multiple components (⇧⌘K) with dashed purple border
-- Instance creation from components with child cloning and componentId mapping
-- Live component-instance sync with override preservation
-- Detach instance back to frame (⌥⌘B)
-- Go to main component (cross-page navigation)
-- Always-visible purple component/instance labels with diamond icon
-- Opaque container hit testing (click selects component, double-click enters)
-- Right-click context menu with clipboard, z-order, grouping, component, visibility, lock, move-to-page actions
-- Z-order manipulation (] bring to front, [ send to back)
-- Toggle visibility (⇧⌘H) and lock (⇧⌘L)
-- Move nodes between pages via context menu
-- Viewport culling, Paint reuse, RAF render coalescing
-- Effects panel UI (drop shadow, inner shadow, layer/background/foreground blur)
-- Independent corner radius controls (per-corner toggle in Appearance section)
-- GitHub Actions CI/CD for Windows (x64, arm64) and macOS (x64, arm64) builds
-- Polygon and Star drawing tools with pointCount and starInnerRadius
-- Resizable left/right panels via reka-ui Splitter (persistent layout)
-- @/ import alias, shared types module (src/types.ts, src/global.d.ts)
-- Codebase lint-clean: 0 oxlint warnings, 0 tsgo type errors
-- Variables: COLOR type with collections, modes, bindings, FillSection variable picker, .fig import
-- Variables dialog: TanStack Table with resizable columns, mode columns, collection tabs with rename, search, demo collections (Primitives/Semantic/Spacing), undo/redo for all variable operations
-- Image export: PNG/JPG/WEBP with ExportSection (scale, format, live preview), ⇧⌘E shortcut, context menu
-- Canvas-native text editing: TextEditor class in core, phantom textarea, cursor/selection/word boundaries on canvas, caret blinking, selection highlights
-- System font enumeration via font-kit Rust crate, OnceLock cache, preload on startup
-- Font picker: virtual scroll (reka-ui ListboxVirtualizer), search filter, CSS font preview
-- ColorInput component extraction, ColorPicker alpha slider checkerboard fix
-- App identity: pencil icon, Cargo crate open_pencil, macOS Dock "OpenPencil"
-- Splash loader during WASM initialization
-- Rich text style runs: per-selection ⌘B/I/U, StyleRun model, ParagraphBuilder pushStyle/pop, .fig roundtrip
-- B/I/U/S toggle buttons in TypographySection
-- Double-click (word), triple-click (select all) text selection
-
-**Remaining (deferred to Phase 6):**
-- Variant switching
-- Variable types: FLOAT, STRING, BOOLEAN editing UI
-- Variable-driven theming
-
-### Phase 5: AI Integration & Tooling 🟡
-
-Core extraction, CLI, MCP server, design guidelines, screenshot verification loop.
-
-**Delivered:**
-- @open-pencil/core extracted to packages/core/ (zero DOM deps, Bun workspace)
-- @open-pencil/cli with headless .fig operations (info, tree, find, export, analyze, node, pages, variables), CanvasKit CPU rasterization, --json output
-- JSX renderer: TreeNode builders (Frame, Text, Rectangle, etc.), renderTreeNode/renderJsx, Tailwind-like shorthand props, 27 tests
-- jscpd copy-paste detection (15.6% → 0.62%), kiwi-serialize.ts consolidation
-- .fig roundtrip tests with LFS fixtures (material3.fig 87K nodes, nuxtui.fig 314K nodes)
-- .fig import O(n²) → O(n) fix (37s → 535ms on 87K nodes), ByteBuffer optimization
-- test:coverage script
-- AI chat: OpenRouter direct (no backend), Stronghold key storage, 26 tools (create_shape, set_fill, set_effects, set_constraints, components, groups, pages, variables, eval_code, etc.), model selector, ⌘J toggle, streaming markdown, Playwright tests with mock transport
-- Code panel: sceneNodeToJsx() export, Prism.js highlighting, line numbers, copy button, 14 tests
-- Properties panel restructured: Design | Code | AI tabs
-- npm publishing preparation for core and cli packages
-
-**Planned:**
-- Port remaining figma-use tools (118 total, 26 currently implemented)
-- Attached mode: WebSocket to running editor for eval, create, export, screenshot
-- Design guidelines system
-- AI-driven design workflow via MCP
-- Screenshot verification loop
-
-### Phase 6: Polish + Distribution 🔲
-
-Prototyping, comments, desktop distribution, documentation, public launch.
-
-**Planned:**
-- Prototyping (frame connections, transitions)
-- Comments (pin, threads, resolve)
-- Linux Tauri builds (macOS and Windows already covered by CI)
-- PWA support
-- Documentation site (VitePress)
-- Performance optimization (Lighthouse > 90)
-- Full Figma compatibility test suite
-- Deferred from Phase 4: variant switching, FLOAT/STRING/BOOLEAN variable UI, variable-driven theming
-
-## Timeline
-
-| Phase | Estimated Duration | Status |
-|-------|-------------------|--------|
-| Phase 1: Core Engine | 3 months | ✅ Complete |
-| Phase 2: Editor UI + Layout | 3 months | ✅ Complete |
-| Phase 3: File I/O + Visual Features | 2 months | ✅ Complete |
-| Phase 4: Components + Variables | 2 months | ✅ Complete |
-| Phase 5: AI Integration & Tooling | 2 months | 🟡 In Progress |
-| Phase 6: Polish + Distribution | 2 months | 🔲 Planned |
+| Phase | Komponenty + Zmienne | Faza 5: Integracja AI i Narzędzia:Faza 6: Dopracowanie + Dystrybucja:Harmonogram:Szacowany czas:Status |
+|-------|------|-----|
+| Faza 1 | 3 months | ✅ |
+| Silnik Core | 3 months | ✅ |
+| Faza 2 | 2 months | ✅ |
+| UI Edytora + Layout | 2 months | ✅ |
+| Faza 3 | 2 months | 🟡 |
+| I/O Plików + Funkcje Wizualne | 2 months | 🔲 |
diff --git a/packages/docs/pl/development/testing.md b/packages/docs/pl/development/testing.md
index 342a5c2a1..abd34c459 100644
--- a/packages/docs/pl/development/testing.md
+++ b/packages/docs/pl/development/testing.md
@@ -1,6 +1,6 @@
# Testowanie
-## Overview
+## Przegląd
| Type | Framework | Command | Location |
|------|-----------|---------|----------|
@@ -8,84 +8,45 @@
| Figma CDP reference | Playwright | `bun run test:figma` | `tests/figma/` |
| Unit tests | bun:test | `bun run test:unit` | `tests/engine/` |
-## E2E Visual Regression
-
-Playwright creates shapes on the canvas and compares screenshots against baseline PNGs.
+## Regresja wizualna E2E
```sh
-bun run test # Run tests, compare against baselines
-bun run test:update # Regenerate baseline screenshots
+bun run test # Compare against baselines
+bun run test:update # Regenerate baselines
```
-### How It Works
-
-1. Tests load the editor in a headless browser
-2. The editor signals readiness via a `data-ready` HTML attribute
-3. Tests create shapes via the editor's API
-4. Screenshots are taken and compared against baselines using `toMatchSnapshot`
-5. Page is reused across test cases for speed (~2s total)
-
-### No-Chrome Test Mode
-
-The editor supports a test mode that hides UI chrome (toolbar, panels) for clean screenshot capture. Activated via URL parameter.
+1. Playwright → headless browser
+2. `data-ready` HTML attribute
+3. Create shapes → screenshot → `toMatchSnapshot`
-## Figma CDP Reference Tests
-
-A separate Playwright project connects to Figma via Chrome DevTools Protocol to capture reference screenshots for pixel-perfect comparison.
+## Testy referencyjne Figma CDP
```sh
bun run figma:debug # Launch Figma with debugging port
-bun run test:figma # Connect to Figma, capture references
+bun run test:figma # Connect via CDP
```
-Requires Figma desktop app running with `--remote-debugging-port=9222`.
-
-## Unit Tests
-
-Engine unit tests use bun:test and target < 50ms execution:
+## Testy jednostkowe
```sh
bun run test:unit
```
-Tests cover:
-- Scene graph CRUD operations, parent-child relationships, z-ordering, hit testing
-- **Fig-import pipeline** — node type mapping, transforms, fills/strokes/effects, gradients, images, arcs, nested hierarchies (`tests/engine/fig-import.test.ts`)
-- **Layout computation** — Yoga auto-layout: direction, gap, padding, justify, align, child sizing (fixed/fill/hug), cross-axis sizing, wrap, nested layouts (`tests/engine/layout.test.ts`)
+- Scene graph CRUD, hit testing
+- Fig-import pipeline
+- Layout computation (Yoga)
+- MCP server edge cases
-### Writing Unit Tests
-
-```typescript
-import { describe, expect, it } from 'bun:test'
-import { SceneGraph } from '../../src/engine/scene-graph'
-
-describe('SceneGraph', () => {
- it('creates and retrieves a node', () => {
- const sg = new SceneGraph()
- const node = sg.createNode('RECTANGLE', sg.root, { name: 'Test' })
- expect(sg.getNode(node.guid)).toBeDefined()
- })
-})
-```
-
-## E2E Test Coverage
+## Pokrycie testów E2E
| Test file | Scope |
|-----------|-------|
-| `tests/e2e/layers-panel.spec.ts` | Layers panel tree structure, visibility toggles, selection sync |
-| `tests/e2e/visual.spec.ts` | Visual regression screenshots for shapes and rendering |
-
-## Test Helpers
-
-| File | Purpose |
-|------|---------|
-| `tests/helpers/canvas.ts` | Canvas setup and interaction utilities |
-| `tests/helpers/figma.ts` | Figma CDP connection helpers |
+| `tests/e2e/layers-panel.spec.ts` | Layers panel |
+| `tests/e2e/visual.spec.ts` | Visual regression |
-## Performance Targets
+## Cele wydajnościowe
| Metric | Target |
|--------|--------|
-| E2E suite total | < 3s |
-| Unit test suite total | < 50ms |
-| Screenshot comparison | toMatchSnapshot (pixel-level) |
+| E2E suite | < 3s |
+| Unit tests | < 50ms |
diff --git a/packages/docs/pl/eval-command.md b/packages/docs/pl/eval-command.md
index 9f7c45018..749d17feb 100644
--- a/packages/docs/pl/eval-command.md
+++ b/packages/docs/pl/eval-command.md
@@ -1,437 +1,77 @@
-# `open-pencil eval` — Figma-like Plugin API for Headless Scripting
+# `open-pencil eval` — API Pluginów kompatybilne z Figmą do skryptowania headless
-## Overview
+## Przegląd
-`bun open-pencil eval <file> --code '<js>'` executes JavaScript against a `.fig` file with a Figma-compatible `figma` global object. This enables headless scripting, batch operations, AI tool execution, and testing — all without the GUI.
+`bun open-pencil eval <file> --code '<js>'` wykonuje JavaScript na pliku `.fig` z globalnym obiektem `figma` kompatybilnym z Figmą. Umożliwia to skryptowanie headless, operacje wsadowe, wykonywanie narzędzi AI i testy — wszystko bez GUI.
-The `figma` object mirrors Figma's Plugin API surface as closely as possible, so existing Figma plugin knowledge and code snippets transfer directly.
+Obiekt `figma` odzwierciedla powierzchnię API Pluginów Figmy jak najdokładniej, więc istniejąca wiedza o pluginach Figmy i fragmenty kodu są bezpośrednio przenośne.
```bash
-# Create a frame, set auto-layout, add children
+# Utworzenie ramki, ustawienie auto-layout, dodanie dzieci
bun open-pencil eval design.fig --code '
const frame = figma.createFrame()
frame.name = "Card"
frame.resize(300, 200)
frame.layoutMode = "VERTICAL"
frame.itemSpacing = 12
- frame.paddingTop = frame.paddingBottom = 16
- frame.paddingLeft = frame.paddingRight = 16
frame.fills = [{ type: "SOLID", color: { r: 1, g: 1, b: 1 } }]
-
- const title = figma.createText()
- title.characters = "Hello World"
- title.fontSize = 24
- frame.appendChild(title)
-
return { id: frame.id, name: frame.name }
'
-# Query nodes
+# Zapytanie o węzły
bun open-pencil eval design.fig --code '
- const buttons = figma.currentPage.findAll(n => n.type === "FRAME" && n.name.includes("Button"))
- return buttons.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
+ const buttons = figma.currentPage.findAll(n => n.name.includes("Button"))
+ return buttons.map(b => ({ id: b.id, name: b.name }))
'
-# Read from stdin (for multiline scripts / piping)
-cat transform.js | bun open-pencil eval design.fig --stdin
-
-# Write changes back
+# Zapis zmian
bun open-pencil eval design.fig --code '...' --write
-bun open-pencil eval design.fig --code '...' -o modified.fig
```
-## Architecture
+## Architektura
```
-┌──────────────────────────────────────────────────────┐
-│ CLI: `open-pencil eval <file> --code '...'` │
-│ ↓ │
-│ loadDocument(file) → SceneGraph │
-│ ↓ │
-│ FigmaAPI(sceneGraph) → `figma` proxy object │
-│ ↓ │
-│ AsyncFunction('figma', wrappedCode)(figmaProxy) │
-│ ↓ │
-│ print result as JSON / agentfmt │
-│ optionally: saveDocument(file) if --write │
-└──────────────────────────────────────────────────────┘
+CLI: open-pencil eval <file> --code '...'
+ → loadDocument(file) → SceneGraph
+ → FigmaAPI(sceneGraph) → proxy `figma`
+ → AsyncFunction('figma', code)(figmaProxy)
+ → wydruk wyniku / zapis pliku z --write
```
-### Key classes
-
-| Class | Location | Role |
-|-------|----------|------|
-| `FigmaAPI` | `packages/core/src/figma-api.ts` | Proxy object implementing `figma.*` methods against `SceneGraph` |
-| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy wrapping `SceneNode` with Figma-style property access (`.fills`, `.resize()`, `.appendChild()`, etc.) |
-| `eval` command | `packages/cli/src/commands/eval.ts` | CLI command that loads doc, creates API, executes code |
-
-### Why in `@open-pencil/core`?
-
-The `FigmaAPI` class lives in core (not CLI) because:
-- **AI tools reuse it** — the chat panel's `render` tool can execute JSX through the same API
-- **Test scripts** — unit tests can use the API to set up fixtures
-- **No DOM deps** — runs headless in Bun, no browser APIs needed
-
-## `FigmaAPI` — Phased Implementation
-
-### Phase 1: Core (MVP for eval command)
-
-These cover ~80% of real plugin scripts:
-
-#### Document & Page
-
-| Figma API | Our implementation | Notes |
-|-----------|--------------------|-------|
-| `figma.root` | Getter → proxy for root node | `.children` returns page proxies |
-| `figma.currentPage` | Getter/setter → first page by default | Settable to any page proxy |
-| `figma.currentPage.selection` | Get/set → tracked selection array | |
-| `figma.getNodeById(id)` | `graph.getNode(id)` wrapped in proxy | Sync, like Figma's deprecated version |
+### Główne klasy
-#### Node Creation
+| Klasa | Lokalizacja | Rola |
+|-------|-------------|------|
+| `FigmaAPI` | `packages/core/src/figma-api.ts` | Obiekt proxy implementujący metody `figma.*` |
+| `FigmaNode` | `packages/core/src/figma-api.ts` | Proxy opakowujący `SceneNode` z dostępem do właściwości w stylu Figmy |
+| Polecenie `eval` | `packages/cli/src/commands/eval.ts` | Ładuje dokument, tworzy API, wykonuje kod |
-| Figma API | Maps to |
-|-----------|---------|
-| `figma.createFrame()` | `graph.createNode('FRAME', currentPageId)` |
-| `figma.createRectangle()` | `graph.createNode('RECTANGLE', ...)` |
-| `figma.createEllipse()` | `graph.createNode('ELLIPSE', ...)` |
-| `figma.createText()` | `graph.createNode('TEXT', ...)` |
-| `figma.createLine()` | `graph.createNode('LINE', ...)` |
-| `figma.createPolygon()` | `graph.createNode('POLYGON', ...)` |
-| `figma.createStar()` | `graph.createNode('STAR', ...)` |
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createPage()` | `graph.addPage(name)` |
-| `figma.createSection()` | `graph.createNode('SECTION', ...)` |
+### Dlaczego w `@open-pencil/core`?
-#### Node Properties (via `FigmaNode` proxy)
+Klasa `FigmaAPI` żyje w core, ponieważ: narzędzia AI ją reużywają, testy mogą jej używać i nie ma zależności DOM.
-Read/write on any node proxy. Property access maps to `SceneNode` fields:
+## Polecenie CLI
-```ts
-// Geometry
-node.x, node.y // direct
-node.width, node.height // read-only, use node.resize(w, h)
-node.rotation // direct
-node.resize(w, h) // updates width + height
-node.resizeWithoutConstraints(w, h) // same (no constraint engine yet)
-
-// Visual
-node.fills // get/set Fill[]
-node.strokes // get/set Stroke[]
-node.effects // get/set Effect[]
-node.opacity // get/set number
-node.visible // get/set boolean
-node.locked // get/set boolean
-node.blendMode // get/set BlendMode
-node.clipsContent // get/set boolean
-
-// Corner radius
-node.cornerRadius // get/set (number or figma.mixed)
-node.topLeftRadius // get/set
-node.topRightRadius // get/set
-node.bottomLeftRadius // get/set
-node.bottomRightRadius // get/set
-node.cornerSmoothing // get/set
-
-// Identity
-node.id // read-only
-node.name // get/set
-node.type // read-only
-node.parent // read-only → FigmaNode | null
-node.removed // read-only boolean
-```
-
-#### Tree Operations
-
-```ts
-node.children // read-only FigmaNode[]
-node.appendChild(child) // reparent to end
-node.insertChild(index, child) // reparent at index
-node.remove() // graph.deleteNode(id)
-
-// Traversal
-node.findAll(callback?) // recursive find
-node.findOne(callback) // first match
-node.findChild(callback) // direct children only
-node.findChildren(callback?) // direct children only
```
+bun open-pencil eval <file> [opcje]
-#### Auto-layout
-
-```ts
-node.layoutMode // 'NONE' | 'HORIZONTAL' | 'VERTICAL'
-node.primaryAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'
-node.counterAxisAlignItems // 'MIN' | 'CENTER' | 'MAX' | 'BASELINE'
-node.itemSpacing // number
-node.counterAxisSpacing // number | null
-node.paddingTop / Right / Bottom / Left // number
-node.layoutWrap // 'NO_WRAP' | 'WRAP'
-
-// Child sizing
-node.layoutPositioning // 'AUTO' | 'ABSOLUTE'
-node.layoutGrow // 0 | 1
-node.layoutSizingHorizontal // 'FIXED' | 'HUG' | 'FILL'
-node.layoutSizingVertical // 'FIXED' | 'HUG' | 'FILL'
-```
-
-#### Text
-
-```ts
-node.characters // get/set (maps to node.text)
-node.fontSize // get/set
-node.fontName // get/set { family, style }
-node.fontWeight // get/set
-node.textAlignHorizontal // get/set
-node.textAlignVertical // get/set
-node.textAutoResize // get/set
-node.letterSpacing // get/set
-node.lineHeight // get/set
-node.maxLines // get/set
-node.textCase // get/set
-node.textDecoration // get/set
-```
-
-#### Stroke details
-
-```ts
-node.strokeWeight // get/set (maps to strokes[0].weight)
-node.strokeAlign // get/set (maps to strokes[0].align)
-node.dashPattern // get/set
-```
-
-#### Misc
-
-```ts
-figma.mixed // Symbol sentinel for mixed values
-figma.group(nodes, parent) // creates GROUP with given children
-figma.ungroup(node) // ungroups, reparents children
-figma.flatten(nodes) // NOT IMPLEMENTED YET — returns first node
-```
-
-#### Export
-
-```ts
-node.exportAsync(settings?) // only works if CanvasKit is loaded
- // settings: { format: 'PNG'|'JPG'|'SVG', constraint? }
-```
-
-### Phase 2: Components & Instances
-
-| API | Maps to |
-|-----|---------|
-| `figma.createComponent()` | `graph.createNode('COMPONENT', ...)` |
-| `figma.createComponentFromNode(node)` | Convert existing frame to component |
-| `figma.combineAsVariants(components, parent)` | Create COMPONENT_SET |
-| Node: `node.createInstance()` | `graph.createInstance(componentId, parentId)` |
-| Node: `node.detachInstance()` | `graph.detachInstance(id)` |
-| `figma.getNodeById(id).mainComponent` | `graph.getMainComponent(id)` |
-
-### Phase 3: Variables
-
-| API | Maps to |
-|-----|---------|
-| `figma.variables.getLocalVariables(type?)` | `graph.variables` filtered |
-| `figma.variables.getLocalVariableCollections()` | `graph.variableCollections` |
-| `figma.variables.createVariable(name, collection, type)` | `graph.addVariable(...)` |
-| `figma.variables.createVariableCollection(name)` | `graph.addCollection(...)` |
-| `figma.variables.getVariableById(id)` | `graph.variables.get(id)` |
-| `node.setBoundVariable(field, variable)` | `graph.bindVariable(...)` |
-| `node.boundVariables` | getter from SceneNode |
-
-### Phase 4: Styles & Advanced
-
-| API | Notes |
-|-----|-------|
-| `figma.createPaintStyle()` | Requires style storage in SceneGraph |
-| `figma.createTextStyle()` | Requires style storage in SceneGraph |
-| `figma.createEffectStyle()` | Requires style storage in SceneGraph |
-| `figma.loadFontAsync(fontName)` | No-op (we don't have font loading constraints) |
-| `figma.listAvailableFontsAsync()` | Return system fonts if available |
-| Boolean operations (`union`, `subtract`, `intersect`, `exclude`) | Requires path boolean engine |
-| `figma.createNodeFromJSXAsync(jsx)` | Port figma-use's JSX renderer |
-
-## `FigmaNode` Proxy Design
-
-The proxy wraps a `SceneNode` and translates Figma property names to our internal names. Key mappings:
+Argumenty:
+ file Plik .fig do przetworzenia
-```ts
-const PROPERTY_MAP: Record<string, string> = {
- // Figma name → SceneNode field name (only where they differ)
- 'characters': 'text',
- 'strokeWeight': → computed from strokes[0].weight,
- 'strokeAlign': → computed from strokes[0].align,
- 'fontName': → computed from { family: fontFamily, style: ... },
- 'primaryAxisAlignItems': 'primaryAxisAlign',
- 'counterAxisAlignItems': 'counterAxisAlign',
- 'primaryAxisSizingMode': 'primaryAxisSizing', // value mapping: 'AUTO' → 'HUG', 'FIXED' → 'FIXED'
- 'counterAxisSizingMode': 'counterAxisSizing',
- 'layoutSizingHorizontal': → computed from primaryAxisSizing / counterAxisSizing depending on layoutMode
- 'layoutSizingVertical': → computed
-}
+Opcje:
+ --code, -c Kod JavaScript do wykonania
+ --stdin Odczyt kodu ze stdin
+ --write, -w Zapis zmian do pliku wejściowego
+ -o, --output Zapis do innego pliku
+ --json Wynik jako JSON
+ --quiet, -q Pomiń wydruk
```
-Methods on the proxy:
-
-```ts
-class FigmaNode {
- // The proxy is created via: new Proxy(target, handler)
- // where handler.get intercepts property reads and handler.set intercepts writes
-
- resize(width: number, height: number): void
- resizeWithoutConstraints(width: number, height: number): void
- remove(): void
- appendChild(child: FigmaNode): void
- insertChild(index: number, child: FigmaNode): void
- findAll(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- findOne(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChild(callback: (node: FigmaNode) => boolean): FigmaNode | null
- findChildren(callback?: (node: FigmaNode) => boolean): FigmaNode[]
- exportAsync(settings?: ExportSettings): Promise<Uint8Array>
-
- // Components (Phase 2)
- createInstance(): FigmaNode
- detachInstance(): void
- get mainComponent(): FigmaNode | null
-}
-```
-
-## CLI Command
-
-```
-bun open-pencil eval <file> [options]
-
-Arguments:
- file .fig file to operate on
-
-Options:
- --code, -c JavaScript code to execute (has access to `figma` global)
- --stdin Read code from stdin instead of --code
- --write, -w Write changes back to the input file
- -o, --output Write to a different file
- --json Output result as JSON (default for non-TTY)
- --quiet, -q Suppress output, only write file
-```
-
-### Execution model
-
-1. Load `.fig` → `SceneGraph`
-2. Create `FigmaAPI(graph)` → `figma` proxy
-3. Wrap user code in async function: `return (async () => { <code> })()`
-4. Execute with `figma` as sole argument
-5. Print return value (JSON or agentfmt)
-6. If `--write` or `-o`: serialize `SceneGraph` back to `.fig`
-
-### Return value formatting
-
-- `undefined` / `void` → no output
-- Primitives → printed directly
-- Objects/arrays → `JSON.stringify(result, null, 2)` or agentfmt tables
-- `FigmaNode` → serialized as `{ id, type, name, x, y, width, height, fills, ... }`
-- Arrays of `FigmaNode` → serialized as list
-
-## Shared with AI Tools
-
-The `FigmaAPI` class is the **same API surface** that AI tools use. Currently `src/ai/tools.ts` calls `store.createShape()`, `store.updateNodeWithUndo()`, etc. — these should be refactored to go through `FigmaAPI`:
-
-```ts
-// Before (current AI tools)
-execute: async ({ type, x, y, width, height }) => {
- const id = store.createShape(type, x, y, width, height)
- return { id }
-}
-
-// After (using FigmaAPI)
-execute: async ({ type, x, y, width, height }) => {
- const frame = figma.createFrame()
- frame.resize(width, height)
- frame.x = x
- frame.y = y
- return { id: frame.id }
-}
-```
-
-This ensures CLI scripts and AI tools behave identically.
-
-## File Layout
-
-```
-packages/core/src/
- figma-api.ts # FigmaAPI class + FigmaNode proxy (Phase 1–4)
- figma-api.test.ts # Unit tests against headless SceneGraph
-
-packages/cli/src/commands/
- eval.ts # CLI command
-
-packages/cli/src/commands/eval.test.ts # Integration tests
-```
-
-## Test Plan
-
-### Unit tests (`packages/core/src/figma-api.test.ts`)
-
-1. **Node creation** — each `createX()` creates correct type, added to current page
-2. **Property access** — `.fills`, `.x`, `.width`, `.name`, `.characters` read/write correctly
-3. **Resize** — `.resize(w, h)` updates width/height
-4. **Tree operations** — `.appendChild()`, `.insertChild()`, `.remove()`, `.parent`, `.children`
-5. **Traversal** — `.findAll()`, `.findOne()`, `.findChild()`, `.findChildren()` with callbacks
-6. **Auto-layout** — `.layoutMode`, `.itemSpacing`, `.paddingTop`, etc.
-7. **Text** — `.characters` maps to `.text`, `.fontName` maps to `{ family, style }`
-8. **Mixed values** — `.cornerRadius` returns `figma.mixed` when corners differ
-9. **Selection** — `figma.currentPage.selection` get/set
-10. **Page switching** — `figma.currentPage = page2` works
-11. **Group/ungroup** — `figma.group()` creates group, `figma.ungroup()` dissolves it
-12. **Clone** — node creation produces independent copies
-
-### CLI integration tests (`packages/cli/src/commands/eval.test.ts`)
-
-1. **Basic eval** — `eval test.fig --code 'return figma.currentPage.name'` → page name
-2. **Create + read** — create a frame, return its properties
-3. **Query nodes** — `findAll` returns correct nodes
-4. **Write back** — `--write` saves changes, reloading shows them
-5. **Stdin** — `echo 'return 42' | bun open-pencil eval test.fig --stdin` → `42`
-6. **JSON output** — `--json` returns valid JSON
-7. **Error handling** — syntax errors, runtime errors reported cleanly
-
-## Implementation Order
-
-1. **`FigmaNode` proxy** — property mapping, `.resize()`, `.remove()`, tree methods
-2. **`FigmaAPI` class** — `createFrame/Rectangle/...`, `.root`, `.currentPage`, `.getNodeById()`, `.mixed`, `.group()`
-3. **CLI `eval` command** — argument parsing, code wrapping, output formatting
-4. **Unit tests** — all 12 test groups above
-5. **CLI integration tests** — all 7 test groups above
-6. **Wire to AI tools** — refactor `src/ai/tools.ts` to use `FigmaAPI` where possible
-7. **Phase 2** — components & instances
-8. **Phase 3** — variables
-9. **Phase 4** — styles, boolean ops, JSX renderer
-
-## Property Mapping Reference
-
-| Figma Property | SceneNode Field | Type | Notes |
-|---------------|-----------------|------|-------|
-| `characters` | `text` | `string` | |
-| `fontName` | `fontFamily` + `fontWeight` + `italic` | `{ family, style }` | Computed: `style` = "Bold Italic" etc. |
-| `strokeWeight` | `strokes[0].weight` | `number` | Computed |
-| `strokeAlign` | `strokes[0].align` | `string` | Computed |
-| `primaryAxisAlignItems` | `primaryAxisAlign` | `string` | |
-| `counterAxisAlignItems` | `counterAxisAlign` | `string` | |
-| `layoutSizingHorizontal` | `primaryAxisSizing` or `counterAxisSizing` | `string` | Depends on `layoutMode` |
-| `layoutSizingVertical` | (opposite of horizontal) | `string` | |
-| `absoluteTransform` | computed from `x`, `y`, `rotation` | `Transform` | Read-only |
-| `absoluteBoundingBox` | `getAbsoluteBounds(id)` | `Rect` | Read-only |
-| All others | Same name | Same type | Direct passthrough |
-
-## Open Questions
-
-1. **Font loading**: `figma.loadFontAsync()` — should it be a no-op (we don't have font gating) or should we track loaded fonts?
- → **Decision: No-op that returns resolved Promise.** We don't gate text editing on font loading.
-
-2. **Export in headless mode**: `node.exportAsync()` requires CanvasKit. Should eval load CanvasKit?
- → **Decision: Optional.** If CanvasKit is available (via `--with-canvaskit` flag or env), enable export. Otherwise, throw "Export requires CanvasKit" error.
-
-3. **`figma.mixed` symbol**: Should we use the actual Figma symbol or our own?
- → **Decision: Our own `Symbol('mixed')`.** Exposed as `figma.mixed`.
+## Implementacja fazowa
-4. **Undo**: `figma.commitUndo()` / `figma.triggerUndo()` — relevant in headless?
- → **Decision: No-op in CLI.** Undo only matters in the live editor. The AI tools can add undo support separately via EditorStore.
+- **Faza 1: Core** — tworzenie węzłów, właściwości, operacje na drzewie, auto-layout, tekst (~80% realnych skryptów)
+- **Faza 2: Komponenty i Instancje** — createComponent, createInstance, detachInstance
+- **Faza 3: Zmienne** — getLocalVariables, createVariable, setBoundVariable
+- **Faza 4: Style i Zaawansowane** — style paint/tekst/efekty, operacje boolowskie
-5. **Write format**: Should `--write` produce `.fig` (Kiwi binary) or also support `.json`?
- → **Decision: `.fig` only for now.** JSON export is a separate feature.
+[Pełna referencja API po angielsku](/eval-command)
diff --git a/packages/docs/pl/reference/file-format.md b/packages/docs/pl/reference/file-format.md
index 220856b20..cb9dad7af 100644
--- a/packages/docs/pl/reference/file-format.md
+++ b/packages/docs/pl/reference/file-format.md
@@ -1,6 +1,6 @@
# Format pliku
-## .fig File Structure
+## Struktura pliku .fig
```
┌─────────────────────────────────┐
@@ -14,7 +14,7 @@
└─────────────────────────────────┘
```
-## Import Pipeline
+## Pipeline importu
```
.fig file → Parse header → Decompress Zstd → Decode Kiwi schema
@@ -22,7 +22,7 @@
→ Resolve blob refs → Render on canvas
```
-## Export Pipeline
+## Pipeline eksportu
```
SceneGraph → NodeChange[] → Kiwi encode → Compress (Zstd/deflate)
diff --git a/packages/docs/pl/reference/mcp-tools.md b/packages/docs/pl/reference/mcp-tools.md
index c0241f09a..33f8870cb 100644
--- a/packages/docs/pl/reference/mcp-tools.md
+++ b/packages/docs/pl/reference/mcp-tools.md
@@ -1,10 +1,10 @@
# Serwer MCP
-OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
+OpenPencil zawiera serwer MCP (Model Context Protocol), który umożliwia narzędziom kodowania AI — Claude Code, Cursor, Windsurf itp. — odczyt i modyfikację plików .fig headless.
-Two transports: **stdio** for MCP clients, **HTTP** for everything else.
+Dwa transporty
-## Install
+## **stdio** dla klientów MCP, **HTTP** dla reszty.
```sh
bun add -g @open-pencil/mcp
@@ -24,7 +24,7 @@ Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json`):
}
```
-Or run from source without installing:
+Instalacja:Lub uruchom ze źródeł:
::: code-group
```json [Bun]
diff --git a/packages/docs/pl/reference/scene-graph.md b/packages/docs/pl/reference/scene-graph.md
index c80d6a193..119b9849f 100644
--- a/packages/docs/pl/reference/scene-graph.md
+++ b/packages/docs/pl/reference/scene-graph.md
@@ -1,8 +1,8 @@
# Graf sceny
-## In-Memory Representation
+## Reprezentacja w pamięci
-Nodes live in a flat `Map<string, Node>` keyed by GUID string. The tree structure is maintained via `parentIndex` references. This gives O(1) lookup by ID and efficient traversal.
+Węzły żyją w płaskiej mapie `Map<string, Node>` keyed by GUID string. Struktura drzewa utrzymywana przez `parentIndex` references. This gives Wyszukiwanie O(1) by ID and efficient traversal.
```typescript
interface SceneGraph {