# Figpea > Figpea is a scriptable, browser-based design tool for viewing and editing PSD, Adobe XD, Figma, SVG, and PDF files. Open the editor with `?agent=1` to attach `window.figpea`, a versioned, JSON-serializable command surface agents can use to author, inspect, and export designs programmatically. ## Agent API - [Agent API docs](https://figpea.com/docs/agent-api) — window.figpea contract version 6.7.3: the activation flag, the Tier-1 recipe, the full method reference (including layer query via `find`, gradient fill authoring with full round-trip read-back, image-fill mode control, interaction authoring, component conversion and instance placement with state authoring and management including removeState and renameState plus optional position placement via `figpea.component.placeInstance(componentId, position?)` on the active page centred at drop, one undo, layer-level text case control, a widened style surface covering HSL blend modes, stroke controls, effects including gradient overlay, pattern overlay, outer glow, inner glow, bevel/emboss, and satin, text-frame sizing and vertical alignment (with `lineHeight` as absolute px leading and never a multiplier, `letterSpacing` as thousandths of an em, and `fixWidth` as a px wrap width), declared mask verbs `setMask`/`clearMask`, layer constraints, project image library, strict schema validation — entry-time validation returns structured `invalid_params` errors naming method, parameter, expected and received types, and an unrecognised key inside a nested object param is refused naming it (`() received unknown parameter ""`) — diagnostics with per-format detection wiring (SVG, XD, PSD, Figma), live-canvas screenshot capture (which settles in-flight image decoding before it captures, so an attached photograph is decoded in the PNG — and reports `settled: false` when it could not settle in time), camera/viewport control, contact-sheet and flow-poster PDF exports, an ungated project-health/copy-deck/font-manifest report, font-alias read/write via `figpea.font.*` (`listAliases`/`getAlias`/`setAlias`/`clearAlias` over the stored missing→replacement map, with `unknown_font` on unresolvable replacements), original-image recovery, per-region fills on path layers (fill individual closed regions, including overlaps, via getRegionFills/setRegionFill/clearRegionFill), `session.renameProject({ name })`, group stack layout via layer.setAutoLayout — mode/padding/gap/alignment/sizing with one-undo patching and validation, relative selection via session.selectRelative — parent/child/nextSibling/previousSibling in panel order with wrapping and composite handling, point-based layer lookup via session.layersAtPoint — every layer containing a world-space point, in panel order, locked included, and matching-layer bulk select via session.findMatching — every layer on the seed's page matching the Select-matching rule (same component-master instance, or same type + name + size/offset ±1 + same relative path), panel order, seed included, plus Figma-parity same-property search via session.find's reference-id keys (sameFillAs/sameStrokeAs/sameEffectAs/sameTextPropertiesAs/sameFontAs/sameComponentMasterAs/samePropertiesAs — every layer sharing a property with a reference layer, same comparators and exclusions as the Edit ▸ Select All with Same commands)). The active document names itself, and a mutation aimed at the wrong one refuses: every node returned by `session.layerTree()`/`session.find()` carries `documentId`/`documentName`, `session.document()` reads that identity in O(1), and `session.expectDocument(id?)` arms it so that a mutation against a different active document is refused with `document_mismatch` and nothing is created, moved or deleted in either design. A project is captured automatically into this browser's local storage, and the address bar names the one you have open (`?projectId=`), so a reload reopens it while a plain launch lands on the welcome screen where the project is listed (a hard kill can drop the last second of edits), so an exported `.fp` checkpoint is the *portable* form rather than the only durable one; the library is local to one browser and one device and is never a cloud sync, and Figpea never writes back to the `.psd`/`.xd`/`.fig`/`.svg`/`.pdf` you opened. Every contract call carries one published budget: `figpea.describe().limits.argsChars` (also `describe("limits")`) is the total serialized size of a call's args in UTF-16 code units, and an over-budget call is refused with `arg_size_exceeded` and nothing applied — so size a `layer.batch` against it and chunk at about two-thirds rather than discovering the wall. Ten newer facts are part of the same frozen contract. `style.fontFamily` is ONE installed family name, never a CSS stack: a comma-separated stack is accepted, stored verbatim and rendered as the fallback face while every call still returns `ok:true`, so pass a single family. `report.measureText` now waits for the font it is measuring and names the face behind its numbers — `requestedFamily`, `measuredFamily`, `substituted`, and a `warning` present only when `substituted` is true — so never trust a width without reading `substituted`. When the width differs from an explicit fallback measurement the face is reported as unverified — `measuredFamily: null`, `verified: false`, no family named, no fallback warning — so treat the label, not the number, as unproven. `canvas.screenshot({id})` is viewport-independent in density as well as region (omitting `pixelRatio`, or passing `1`, draws at 1x), and `export.project` takes an opt-in `verifyGeometry` on a `format: "figpea"` export that compares a canonicalised geometry fingerprint across the round trip and returns `geometryWarning` on the success result when it mismatches. The read side of a layer's geometry names its coordinate space: `session.layerTree()`, `session.layerById(id)` and `session.find(sel)` report `bounds` in **world** coordinates — the same basis `canvas.getViewport()`, `canvas.layerRect()` and `session.layersAtPoint()` use — while every placement input except `setPosition` with `space` omitted is **parent-local** (`setLocalPosition`, `setPosition` with `space:"local"`, `create`'s `x`/`y`, a transform's `e,f`), so a child at page-local `x: 110` on a page whose world origin is `x 2580` reads back `bounds.left` 2690 and handing 2690 to `setLocalPosition` throws it 2580px off the page while returning `ok: true`. All three reads take an optional trailing `space`: `"world"` (the default, unchanged in output and cost) or `"local"`, which returns the very parent-local rect `setLocalPosition` consumes, so read-then-write needs no arithmetic, except inside a rotated or mirrored parent, where the parent-local placement calls are refused with `invalid_position` naming the parent (use the world-space round trip of `bounds` with `setPosition` there); on a tree read `"local"` resolves **each node against its own parent**, so a folder nested in a page is a third basis rather than page-local, and inside a rotated or mirrored parent only `"local"` is exact. `create("path", …)` renders the `d` it is given — absolute and relative SVG commands alike — authored in the layer's own local space and never rebased: `x`/`y` place the path's box top-left in parent-local coordinates and the reported `bounds` are the drawn shape in world coordinates, so baking the placement into the `d` puts the mark in the wrong place. A path that cannot be rendered is rejected with `invalid_geometry` naming `"path"` before anything is created — until this version, three such cases were accepted with `ok: true` and either drew nothing or drew in the wrong place, catchable only by reading `bounds` back. A path layer is re-pathed in place with `layer.setPath(id, d)` — delete-and-recreate is no longer needed; the same layer id, parent, transform and style survive, and its `regionFills` are invalidated. `window.figpea.SKILL(selector?)` additionally provides zero-drift runtime reference guidance — the craft guidance for using the API well, read live from the runtime itself so it can never go stale. Arc progress-ring authoring via `layer.create("arc")` ring mode (`{rx, ry, startAngle, sweep}` as fractions of a turn, 0 = 12 o'clock clockwise, `sweep: 1` closed ring; absent `sweep` keeps the legacy degree donut) with normalized `{mode: "ring" | "donut", rx, ry, startAngle, sweep}` read-back on `layerTree()`/`layerById()`. Prop placement: `create(kind, {x, y})` places the new layer parent-local in the same call — `x`/`y` are per-kind schema props, not common ones — while every visual prop belongs inside `style{}` and a top-level visual prop is rejected with `invalid_transform` naming `style.`, creating nothing. Text layers report their content on the read side: `session.layerById(id)` always returns the `rawText` string plus the `textRuns` payload (string slices with resolved fonts and sizes), and `session.layerTree()` returns the same runs behind the explicit opt-in flag `includeText` (omitted, no runs); a deleted id reads `not_found` like any other unknown id. The layer tree is rooted at the **active sheet**: `session.layerTree()` returns that sheet as its root node (`layerType: "sheet"`) with the sheet’s top-level layers as its children, a layer id from any sheet still resolves through `layerById`, `find` and every mutation, and a `create` with no `parentId` lands in the active sheet. A text edit settles the stack it lives in: `layer.setText`, and the text-style keys that reshape a text box's measured extent (font size, family, weight, letter spacing, line height, wrap width, box height). Either one settles the enclosing auto layout group and every auto layout group above it in the same call and the same undo step, so one read-back describes settled geometry and no second mutation is needed. - [Download the Agent Skill](https://figpea.com/figpea-agent/SKILL.md) — a transport-only pointer rather than a copy: it names `GET https://editor.figpea.com/agent/skill.md` as the always-current body and the three ways to fetch it (`figpea.SKILL()`, the `figpea_skill` MCP tool, or a plain HTTP GET), so nothing here can drift out of date. - [figpea-mcp on npm](https://www.npmjs.com/package/figpea-mcp) — connect any MCP client with `npx -y figpea-mcp` (fetches the live contract from the editor origin, so it never goes stale); source at [github.com/figpea/figpea-mcp](https://github.com/figpea/figpea-mcp). - [Off-band binary returns](https://figpea.com/docs/agent-api) — via `figpea-mcp`, `returnAs: "path"` works on any binary export, including a native `.fp` from `export.project` and the image exports `canvas.screenshot` / `export.layer` / `export.artboard`: the bytes are written to a per-session file and come back as `{ok, path, mime, width, height, bytes, filename?, url}` text instead of inline base64, so a deliverable never crosses the wire as base64; for >1 MB results this saves ~1.3 tokens/raw byte. - [canvas.screenshot and camera zoom](https://figpea.com/docs/agent-api#screenshot) — `figpea.canvas.screenshot()` **without** `options.id` captures at the region's *on-screen* size (world × camera zoom) × `pixelRatio`, so a zoomed-out camera returns a far smaller PNG with `ok: true` and no warning (a 3543 × 5002 artboard at `pixelRatio 0.42` came back 219 × 310 instead of 1488 × 2100). **Always pass `options.id`** for a capture you intend to judge or measure; the no-id form is only correct when you want what the user currently sees. ## Product - [Documentation](https://figpea.com/docs) — guides for opening files, layer operations, exporting, and the Agent API. - [Your projects & restore](https://figpea.com/docs/your-projects) — projects are captured automatically into this browser's local storage and listed on the welcome screen; list, open, rename, duplicate or delete them, and the address bar names the open project so a reload keeps you in it; after a crash what was flushed is still in the list; and a storage readout in the Your projects heading row shows how much room Figpea is using in this browser against what the browser allows — it covers the whole site in this browser, not just the projects listed. Local to one browser and device, never a cloud sync. - [Pricing](https://figpea.com/pricing) — plans and entitlements (authoring is free; some export formats and scales require a paid plan), including the one-time Rescue Pass: 7 days of full Pro for a single payment, no subscription and nothing to cancel. ## AI agents - [AI agents page](https://figpea.com/ai-agents) — Overview and setup guide for connecting Claude Code, Codex, Cursor, or any MCP agent to Figpea. ## Supported formats - [PSD viewer](https://figpea.com/psd-viewer) - [Adobe XD viewer](https://figpea.com/xd-viewer) - [Figma (.fig) viewer](https://figpea.com/figma-viewer) - [SVG viewer](https://figpea.com/svg-viewer) The live editor itself runs at a separate origin (editor.figpea.com) and is described here in prose only, not as a link -- reach it via the docs and product links above.