easel-canvas 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hyun Park
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,192 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Easel
4
+
5
+ **An infinite canvas for HTML screens. Your AI agent writes the designs; you see and tweak them live.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/easel-canvas.svg?color=black)](https://www.npmjs.com/package/easel-canvas)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-black.svg)](LICENSE)
9
+ [![Node](https://img.shields.io/badge/node-%E2%89%A520-black.svg)](package.json)
10
+ [![MCP](https://img.shields.io/badge/MCP-20%20tools-3E7BFA.svg)](#connect-your-ai-agent)
11
+ [![Works with](https://img.shields.io/badge/works%20with-Claude%20Code%20·%20Codex-3E7BFA.svg)](#connect-your-ai-agent)
12
+
13
+ <img src="docs/screenshots/demo.gif" alt="Demo: editing text in place on a mobile screen, then asking Claude Code in the AI tab to rename a heading and recolor a bar; the board redraws with the change" width="100%">
14
+
15
+ <sub>A real Claude Code run on the bundled demo (the agent's thinking time is sped up 4×).</sub>
16
+
17
+ </div>
18
+
19
+ Easel turns a folder of plain HTML files into a design canvas. Claude Code or Codex writes a screen, and it shows up on the canvas a moment later. Drag, resize, retype or restyle anything on the canvas, and **only that part of the source file changes**. There is no export step and no proprietary file format: your designs stay in your repo as HTML and merge with git like any other code.
20
+
21
+ ## Try it in 30 seconds
22
+
23
+ ```bash
24
+ npx easel-canvas --demo
25
+ ```
26
+
27
+ That copies the "Tidy" habit tracker demo to `./easel-demo` and opens it at http://localhost:4317. Open the **AI** tab (⌘J) and ask Claude Code or Codex for a change, or double-click a screen and start editing.
28
+
29
+ Already have HTML screens? Run it in your project:
30
+
31
+ ```bash
32
+ npx easel-canvas # opens ./docs/design (or the current folder if it has screens/)
33
+ npx easel-canvas --init # starts a new ./docs/design with one screen
34
+ npx easel-canvas --dir ./designs # any folder of screens/*.html
35
+ ```
36
+
37
+ ## Why Easel
38
+
39
+ - **HTML is the source of truth.** Each `screens/*.html` file is one board. What you see is exactly what ships to the browser, and there's nothing to export or keep in sync.
40
+ - **Built for AI agents.** An MCP server with 20 tools lets agents see the boards, read what you selected, leave comments, check tokens and arrange the canvas. An in-app chat runs `claude -p` or `codex exec` with your selection as context.
41
+ - **Surgical edits.** Changes are patched into the exact source range (parse5 locations), so formatting, comments and the rest of the file stay untouched. If an agent edits the same element first, your edit is rejected instead of overwriting it.
42
+ - **Git-friendly by design.** Layout, notes and comments live in small JSON files written one entry per line, so two branches moving different boards merge without conflicts.
43
+ - **Local-first.** It runs on `127.0.0.1` and works directly on the files in your repo. No account, no cloud, no lock-in.
44
+
45
+ ## Features
46
+
47
+ <table>
48
+ <tr>
49
+ <td colspan="2"><img src="docs/screenshots/overview.png" alt="Easel showing a habit tracker app: five mobile screens on an infinite canvas with notes, flow arrows, a board list and a properties panel with token and accessibility checks"></td>
50
+ </tr>
51
+ <tr>
52
+ <td width="50%"><img src="docs/screenshots/edit-mode.png" alt="Edit mode: an element selected inside a mobile screen with handles, and a properties panel with token chips"></td>
53
+ <td width="50%"><img src="docs/screenshots/ai-chat.png" alt="AI chat panel: a streamed reply from Claude Code with Read and Edit tool lines, and the edited Stats screen on the canvas"></td>
54
+ </tr>
55
+ <tr>
56
+ <td><b>Edit in place.</b> Select any element, drag it, resize it, align it, retype its text or change its styles. Layers, wrap in flex/grid, cross-board copy and paste.</td>
57
+ <td><b>Chat with your agent.</b> Pick Claude Code or Codex, send the selection, boards and comments as context, watch the edit stream in, ask for N variants side by side.</td>
58
+ </tr>
59
+ <tr>
60
+ <td width="50%"><img src="docs/screenshots/dark-mode.png" alt="Dark mode with a board context menu: Edit, Play in place, Ask AI for a review, Focus view, Rename, Duplicate, Bring to front, Delete"></td>
61
+ <td width="50%">
62
+ <b>Everything a canvas should do.</b>
63
+ <ul>
64
+ <li>Pan, zoom and minimap; thumbnails keep ~100 boards smooth (60 fps)</li>
65
+ <li>Notes, sticky notes, shapes, arrows and images</li>
66
+ <li>Pages, layout guides, focus view and Play in place</li>
67
+ <li>Design tokens with off-token warnings and an accessibility check</li>
68
+ <li>Comments with replies, git snapshots, and one undo history for canvas actions and HTML edits</li>
69
+ <li>Context menus and keyboard shortcuts for everything; light and dark themes</li>
70
+ </ul>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+
75
+ ## Connect your AI agent
76
+
77
+ Keep the canvas running (`npx easel-canvas`). Agents write HTML files directly; the MCP server lets them **see** (`list_boards`, `read_board`, `screenshot`, `list_errors`), **know what you mean** (`get_selection` with the selected element, visible boards and the current page), **talk** (comments and replies) and **arrange** (`place_board`, `create_board`, notes, pages, `check_tokens`, `save_snapshot`).
78
+
79
+ **Claude Code**: add `.mcp.json` to your project root:
80
+
81
+ ```json
82
+ { "mcpServers": { "easel": { "type": "stdio", "command": "npx", "args": ["-y", "-p", "easel-canvas", "easel-mcp", "--port", "4317"] } } }
83
+ ```
84
+
85
+ **Codex**: add to `~/.codex/config.toml`:
86
+
87
+ ```toml
88
+ [mcp_servers.easel]
89
+ command = "npx"
90
+ args = ["-y", "-p", "easel-canvas", "easel-mcp", "--port", "4317"]
91
+ default_tools_approval_mode = "approve" # the tools only view, comment and arrange
92
+ ```
93
+
94
+ Using Easel as a submodule (below)? Point `args` at `tools/easel/bin/mcp.mjs` with `"command": "node"` instead.
95
+
96
+ Then try:
97
+
98
+ > "Fix what I selected on the canvas: make the button text shorter."
99
+ > "Make three variants of the Stats screen."
100
+ > "Create an onboarding screen at 390×844 and put it next to Today."
101
+
102
+ New files with `<meta name="board-size" content="390x844">` are placed on the canvas automatically at that size.
103
+
104
+ ## Pin it in your project
105
+
106
+ `npx easel-canvas` is all most projects need. To pin an exact version for your team, add it as a dev dependency (`npm i -D easel-canvas`, then `"design": "easel-canvas"` in your scripts) or as a git submodule. With your designs in `<project>/docs/design/screens/`:
107
+
108
+ ```bash
109
+ git submodule add https://github.com/nemodleo/easel.git tools/easel
110
+ ```
111
+
112
+ ```json
113
+ {
114
+ "scripts": {
115
+ "design:install": "git submodule update --init tools/easel && npm --prefix tools/easel install",
116
+ "design": "npm --prefix tools/easel start"
117
+ }
118
+ }
119
+ ```
120
+
121
+ ```bash
122
+ npm run design:install # once: fetch the submodule and install
123
+ npm run design # http://localhost:4317
124
+ ```
125
+
126
+ - The default design folder is `../../docs/design` relative to the tool, so `tools/easel` opens your `docs/design` with no flags. Anywhere else: `npm --prefix tools/easel start -- --dir <design folder> --port <port>`.
127
+ - It installs separately from your app, so it never touches your app's dependencies, build or deploy, and CI that skips submodules (the `actions/checkout` default) is unaffected.
128
+ - To update: push to this repo, then run `git submodule update --remote tools/easel` in your project and commit the new pointer. Teammates run `npm run design:install` after `git pull`.
129
+
130
+
131
+ <details>
132
+ <summary><b>Keyboard shortcuts and how-tos</b></summary>
133
+
134
+ | To do this | How |
135
+ | --- | --- |
136
+ | Pan and zoom | Drag empty space, Space, or Hand (H); trackpad scroll; ⌘+wheel or pinch (4–400%). ⇧1 Fit all, ⇧2 selection, ⌘0 Zoom to 100%, Minimap (M) |
137
+ | Find | Left "Boards" tab: ⌘K search and list; pages (drag to reorder; right-click to rename, delete, or set the launch page) |
138
+ | Boards | Draw with the board tool (B), use a "New board" template (Blank · Mobile screen · Desktop screen · Document), or drop an HTML file on the canvas. Duplicate ⌘D, rename F2 (renaming the file offers to update references), Delete (confirm, trash, undo), Bring to front / Send to back ⌘] ⌘[ |
139
+ | Multiple items | Drag on empty space to marquee-select or use Shift; move together (snap guides, Alt to disable); arrow keys 1, Shift 10, Option 100 |
140
+ | Board options | Right "Properties": position, size, Radius, No frame, Interactive (Play), Stretch to window, Open as launch screen, Layout guides (Columns · Rows · Grid, up to 6, ⌃G), Adjustable values |
141
+ | View | Focus view (F, ←→), Play in place (P or ▶, Esc), Play full screen (right-click) |
142
+ | Notes and shapes | Title (T), sticky note (N, 8 colors, size, bold, italic), Rectangle (R), Oval (O), Line (L), Arrow (A), Pen (P when no board is selected), image (Assets or paste) |
143
+ | Edit mode | Double-click or E. Click or Shift, Esc for parent, Enter for child, ↑↓ for siblings, Option+↑↓ to reorder, ⌘A for all siblings, ⌘G Wrap in flex |
144
+ | Direct editing | Move with handles (Alt drops inside a box) and resize, 6 align options, double-click text (Shift+Enter for a line break), Properties panel (token chips, ⚠, contrast ratio), Replace image, ⌘C/⌘V to paste into another board |
145
+ | Undo | ⌘Z / ⌘⇧Z. Canvas actions, HTML edits and board create/delete share one history (100 entries) |
146
+ | Design system | Register tokens (`tokens.json`) and themes in the left "Tokens" tab, Theme menu in the toolbar, Token check and Accessibility lists on the right |
147
+ | Collaboration | Comments (Reply, Resolve, author), Snapshot menu (git-commits only the design folder) |
148
+ | AI | Right "AI" tab (⌘J): Claude Code or Codex; selection, boards, visible boards, comments and references go along as context; N variants; Ask AI for a review |
149
+ | Screen | F6 to move between regions, Tab to move between boards, ⌘\\ to hide panels, Appearance (System · Light · Dark) |
150
+
151
+ </details>
152
+
153
+ ## How it works
154
+
155
+ ```
156
+ your-project/docs/design/
157
+ ├── screens/*.html ← one board per file; agents and you both edit these
158
+ ├── board.json ← positions, titles, pages, notes, shapes (one line per entry)
159
+ ├── comments.json ← comment threads pinned to elements
160
+ └── tokens.json ← optional design tokens and themes
161
+ ```
162
+
163
+ - A small Node server watches the folder (chokidar) and tells the browser which board changed, so only that board reloads, keeping scroll and selection.
164
+ - Element paths and hashes are computed from the source with parse5. Every edit is a minimal string patch into that range, written atomically.
165
+ - The canvas is a Vite + React app. Each board is an iframe of the real HTML, so scripts, links and CSS behave exactly as in a browser.
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ npm test # unit tests (source patching, board format, chat parsing, tokens…)
171
+ npm run test:e2e # Playwright end-to-end tests against test/fixtures/design
172
+ npm run typecheck
173
+ npm run demo # run the repo's demo from source
174
+ ```
175
+
176
+ - `test/fixtures/design/` intentionally keeps Korean screen content and board titles: it mimics real user content and is needed to test Korean text input (IME) and rendering. Set `DESIGN_CANVAS_E2E_DIR=<folder>` to run the e2e tests against another design folder.
177
+ - `examples/demo/` is the "Tidy" demo used for the screenshots above.
178
+
179
+ | Folder | Contents |
180
+ | --- | --- |
181
+ | `bin/` | `server.mjs` (app server), `mcp.mjs` (MCP stdio server) |
182
+ | `server/` | API and routes, board.json, file watching, element paths and hashes, source patching, history, chat runner, tokens |
183
+ | `app/` | Canvas UI (Vite + React + TypeScript); all UI text lives in `app/src/strings.ts` |
184
+ | `test/` | `node --test` unit tests and Playwright e2e tests |
185
+
186
+ Background reading: the original plan is in [PLAN.md](PLAN.md), a feature-by-feature comparison with Claude Design is in [PARITY.md](PARITY.md), and the work log is in [tasks.md](tasks.md).
187
+
188
+ Contributions are welcome: open an issue or a pull request.
189
+
190
+ ## License
191
+
192
+ [MIT](LICENSE) © Hyun Park
package/bin/mcp.mjs ADDED
@@ -0,0 +1,250 @@
1
+ #!/usr/bin/env node
2
+ // AI-generated with Claude Code, 2026-10-09, reviewed by Hyun Park
3
+ // MCP server (stdio): exposes boards, selection, screenshots, comments and placement through the app server API (http://localhost:<port>). PLAN.md ch. 6.
4
+ // The agent creates and edits HTML by writing files directly. This server only observes, points at things, and places boards.
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import { z } from "zod";
8
+
9
+ import { parseArgs } from "../server/args.mjs";
10
+
11
+ const { port } = parseArgs();
12
+ const BASE = `http://127.0.0.1:${port}`;
13
+
14
+ async function call(method, path, body) {
15
+ let res;
16
+ try {
17
+ res = await fetch(BASE + path, {
18
+ method,
19
+ headers: body ? { "Content-Type": "application/json" } : undefined,
20
+ body: body ? JSON.stringify(body) : undefined,
21
+ });
22
+ } catch {
23
+ throw new Error(`Easel is not running. Start it with npm run design from the repo root (${BASE}).`);
24
+ }
25
+ const text = await res.text();
26
+ if (!res.ok) {
27
+ let msg = text;
28
+ try {
29
+ msg = JSON.parse(text).error ?? text;
30
+ } catch {
31
+ /* keep as is */
32
+ }
33
+ throw new Error(`${res.status} ${msg}`);
34
+ }
35
+ return text;
36
+ }
37
+ const callJson = async (m, p, b) => JSON.parse(await call(m, p, b));
38
+ const ok = (data) => ({ content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] });
39
+
40
+ const server = new McpServer({ name: "easel", version: "0.1.0" });
41
+
42
+ server.registerTool(
43
+ "list_boards",
44
+ {
45
+ description: "List the boards on the design canvas (each board is a docs/design/screens/*.html file) with file, title, size, position and page. Use it to find which file to read or edit.",
46
+ inputSchema: { page: z.string().optional().describe("Only return boards on this page id") },
47
+ },
48
+ async ({ page }) => {
49
+ const { board, missing } = await callJson("GET", "/api/board");
50
+ const first = board.pages[0]?.id;
51
+ const rows = board.order
52
+ .filter((f) => board.boards[f])
53
+ .map((f) => ({ file: f, ...board.boards[f], page: board.boards[f].page ?? first }))
54
+ .filter((b) => !page || b.page === page);
55
+ return ok({ dir: "docs/design/screens", pages: board.pages, boards: rows, missingFiles: missing });
56
+ },
57
+ );
58
+
59
+ server.registerTool(
60
+ "read_board",
61
+ { description: "Read a board's source HTML exactly as stored in the file. Use it before editing a board.", inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html") } },
62
+ async ({ file }) => ok(await call("GET", `/api/file?f=${encodeURIComponent(file)}`)),
63
+ );
64
+
65
+ server.registerTool(
66
+ "get_selection",
67
+ {
68
+ description:
69
+ "What the user is looking at right now: selection (the element clicked in edit mode: file, path as element indexes from the children of <body>, tag, kind and label, text, source outerHTML up to 4KB, hash, computed styles), mode (canvas, edit, focus, play), page and pageName, visibleArtboards (boards visible on screen), selectedArtboards, dirty (pending saves), edits (recent edit history), erroredArtboards and firstError (boards with errors). Use it for requests like 'fix the selected element' or 'this screen'.",
70
+ inputSchema: {},
71
+ },
72
+ async () => {
73
+ return ok(await callJson("GET", "/api/selection"));
74
+ },
75
+ );
76
+
77
+ server.registerTool(
78
+ "screenshot",
79
+ {
80
+ description: "Take a PNG screenshot of a board, or of an element inside it, and return the image file path. Use it to check how a change looks (requires playwright).",
81
+ inputSchema: { file: z.string(), path: z.string().optional().describe("Element path, e.g. 0/2/1; omit for the whole board") },
82
+ },
83
+ async ({ file, path }) => ok(await callJson("POST", "/api/screenshot", { file, path })),
84
+ );
85
+
86
+ server.registerTool(
87
+ "list_comments",
88
+ {
89
+ description: "List board comments (docs/design/comments.json), optionally for one file or only unresolved ones.",
90
+ inputSchema: { file: z.string().optional(), unresolved: z.boolean().optional() },
91
+ },
92
+ async ({ file, unresolved }) => {
93
+ const q = new URLSearchParams();
94
+ if (file) q.set("file", file);
95
+ if (unresolved) q.set("unresolved", "1");
96
+ return ok(await callJson("GET", `/api/comments?${q}`));
97
+ },
98
+ );
99
+
100
+ server.registerTool(
101
+ "add_comment",
102
+ {
103
+ description: "Add a comment to a board, or to an element inside it when path is given.",
104
+ inputSchema: { file: z.string(), path: z.string().optional(), text: z.string(), author: z.string().optional() },
105
+ },
106
+ async (args) => ok(await callJson("POST", "/api/comments", { ...args, author: args.author ?? "AI" })),
107
+ );
108
+
109
+ server.registerTool(
110
+ "resolve_comment",
111
+ { description: "Mark a comment as resolved (pass resolved=false to reopen it). Use it after fixing what a comment asked for.", inputSchema: { id: z.string(), resolved: z.boolean().optional() } },
112
+ async ({ id, resolved }) => ok(await callJson("POST", "/api/comments", { action: "resolve", id, resolved: resolved ?? true })),
113
+ );
114
+
115
+ server.registerTool(
116
+ "place_board",
117
+ {
118
+ description: "Record a board's canvas position, title and page in board.json. Use it after creating a new screen to set its name and position.",
119
+ inputSchema: {
120
+ file: z.string(),
121
+ x: z.number().optional(),
122
+ y: z.number().optional(),
123
+ title: z.string().optional(),
124
+ page: z.string().optional(),
125
+ },
126
+ },
127
+ async (args) => ok(await callJson("POST", "/api/place", args)),
128
+ );
129
+
130
+ server.registerTool(
131
+ "list_errors",
132
+ { description: "List boards with errors (script errors, images that failed to load, missing files) and the first error. Use it to check your edits did not break a board.", inputSchema: {} },
133
+ async () => {
134
+ const s = await callJson("GET", "/api/selection");
135
+ const { errors } = await callJson("GET", "/api/errors");
136
+ return ok({ erroredArtboards: s.erroredArtboards, firstError: s.firstError, errors });
137
+ },
138
+ );
139
+
140
+ server.registerTool(
141
+ "create_board",
142
+ {
143
+ description: "Create a new board (HTML file) from a template and place it on the canvas. Templates: blank (Blank), mobile (390×844 Mobile screen), desktop (1440×900 Desktop screen), doc (Document). Edit the created file directly afterwards.",
144
+ inputSchema: {
145
+ file: z.string().optional().describe("File name, e.g. scr-40.html; generated if omitted"),
146
+ title: z.string().optional(),
147
+ template: z.enum(["blank", "mobile", "desktop", "doc"]).optional(),
148
+ x: z.number().optional(),
149
+ y: z.number().optional(),
150
+ w: z.number().optional(),
151
+ h: z.number().optional(),
152
+ page: z.string().optional(),
153
+ },
154
+ },
155
+ async (args) => ok(await callJson("POST", "/api/boards/create", args)),
156
+ );
157
+
158
+ server.registerTool(
159
+ "list_notes",
160
+ { description: "List canvas notes (titles and sticky notes), optionally for one page.", inputSchema: { page: z.string().optional() } },
161
+ async ({ page }) => {
162
+ const { board } = await callJson("GET", "/api/board");
163
+ const first = board.pages[0]?.id;
164
+ return ok(Object.entries(board.notes).map(([id, n]) => ({ id, ...n, page: n.page ?? first })).filter((n) => !page || n.page === page));
165
+ },
166
+ );
167
+
168
+ server.registerTool(
169
+ "add_note",
170
+ {
171
+ description: "Add a note to the canvas. kind=title (large heading) or sticky (sticky note).",
172
+ inputSchema: { kind: z.enum(["title", "sticky"]), text: z.string(), x: z.number(), y: z.number(), w: z.number().optional(), page: z.string().optional() },
173
+ },
174
+ async (args) => ok(await callJson("POST", "/api/notes", { action: "add", ...args })),
175
+ );
176
+
177
+ server.registerTool(
178
+ "update_note",
179
+ {
180
+ description: "Edit a note (text, position, width, page, color, size, bold, italic).",
181
+ inputSchema: {
182
+ id: z.string(),
183
+ text: z.string().optional(),
184
+ x: z.number().optional(),
185
+ y: z.number().optional(),
186
+ w: z.number().optional(),
187
+ page: z.string().optional(),
188
+ color: z.string().optional(),
189
+ size: z.number().optional(),
190
+ bold: z.boolean().optional(),
191
+ italic: z.boolean().optional(),
192
+ },
193
+ },
194
+ async (args) => ok(await callJson("POST", "/api/notes", { action: "update", ...args })),
195
+ );
196
+
197
+ server.registerTool(
198
+ "delete_note",
199
+ { description: "Delete a note (the user can undo it in the app).", inputSchema: { id: z.string() } },
200
+ async ({ id }) => ok(await callJson("POST", "/api/notes", { action: "delete", id })),
201
+ );
202
+
203
+ server.registerTool(
204
+ "list_pages",
205
+ { description: "List canvas pages (the first page is the default).", inputSchema: {} },
206
+ async () => ok((await callJson("GET", "/api/board")).board.pages),
207
+ );
208
+
209
+ server.registerTool(
210
+ "manage_page",
211
+ {
212
+ description: "Manage pages: add (name), rename (id, name), delete (id; its items move to the first page), move (id, index).",
213
+ inputSchema: { action: z.enum(["add", "rename", "delete", "move"]), id: z.string().optional(), name: z.string().optional(), index: z.number().optional() },
214
+ },
215
+ async (args) => ok(await callJson("POST", "/api/pages", args)),
216
+ );
217
+
218
+ server.registerTool(
219
+ "get_tokens",
220
+ {
221
+ description:
222
+ "Get the design tokens (colors per theme, font sizes, weights, radii, spacing, fonts, minimum tap target) from tokens.json. Use only these values when creating or editing screens. If the project has no tokens.json it returns registered: false and no values; then keep to the styles already in the file.",
223
+ inputSchema: {},
224
+ },
225
+ async () => ok(await callJson("GET", "/api/tokens?agent=1")),
226
+ );
227
+
228
+ server.registerTool(
229
+ "check_tokens",
230
+ {
231
+ description:
232
+ "Find off-token values in screen HTML (colors, font sizes, weights, radii, spacing not a multiple of 4). Use it to verify your edits. Omit file to check all screens. If the project has no tokens.json it returns registered: false and no violations (nothing to check against).",
233
+ inputSchema: { file: z.string().optional() },
234
+ },
235
+ async ({ file }) => ok(await callJson("GET", `/api/lint${file ? `?f=${encodeURIComponent(file)}` : ""}`)),
236
+ );
237
+
238
+ server.registerTool(
239
+ "reply_comment",
240
+ { description: "Reply to a comment (resolve=true replies and marks it resolved).", inputSchema: { id: z.string(), text: z.string(), resolve: z.boolean().optional(), author: z.string().optional() } },
241
+ async (args) => ok(await callJson("POST", "/api/comments", { action: "reply", ...args, author: args.author ?? "AI" })),
242
+ );
243
+
244
+ server.registerTool(
245
+ "save_snapshot",
246
+ { description: "Save a snapshot by committing only the design folder to git (a saved version). Use only when the user explicitly asks to save.", inputSchema: { message: z.string().optional() } },
247
+ async ({ message }) => ok(await callJson("POST", "/api/snapshot", { message })),
248
+ );
249
+
250
+ await server.connect(new StdioServerTransport());
package/bin/server.mjs ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ // AI-generated with Claude Code, 2026-10-09, reviewed by Hyun Park
3
+ // Usage: easel-canvas [--dir <design folder>] [--port 4317] [--open] [--demo] [--init]
4
+ import { spawn } from "node:child_process";
5
+ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
+ import path from "node:path";
7
+
8
+ import { parseArgs, TOOL_ROOT } from "../server/args.mjs";
9
+
10
+ const args = parseArgs();
11
+ const pkg = JSON.parse(readFileSync(path.join(TOOL_ROOT, "package.json"), "utf8"));
12
+
13
+ if (args.version) {
14
+ console.log(pkg.version);
15
+ process.exit(0);
16
+ }
17
+ if (args.help) {
18
+ console.log(`Easel ${pkg.version} — an HTML design canvas for AI agents
19
+
20
+ Usage
21
+ npx easel-canvas open ./docs/design (or the current folder if it has screens/)
22
+ npx easel-canvas --demo copy the demo project to ./easel-demo and open it
23
+ npx easel-canvas --init create ./docs/design with a starter screen, then open it
24
+ npx easel-canvas --dir <folder> open a specific design folder
25
+
26
+ Options
27
+ --port <n> port to listen on (default 4317)
28
+ --open open the canvas in your browser (--demo and --init do this; --no-open to skip)
29
+ -h, --help show this help
30
+ -v, --version
31
+
32
+ A design folder holds screens/*.html (one board per file). Easel keeps board.json and
33
+ comments.json next to them. MCP for Claude Code / Codex: npx -y -p easel-canvas easel-mcp --port 4317
34
+ Docs: ${pkg.homepage}`);
35
+ process.exit(0);
36
+ }
37
+
38
+ let dir = args.dir;
39
+ let open = args.open;
40
+ if (args.demo) {
41
+ dir = path.resolve("easel-demo");
42
+ if (!existsSync(dir)) {
43
+ cpSync(path.join(TOOL_ROOT, "examples/demo"), dir, { recursive: true });
44
+ console.log(`Copied the demo project to ${dir}`);
45
+ }
46
+ open = true;
47
+ } else if (args.init) {
48
+ if (!existsSync(path.join(dir, "screens"))) {
49
+ const { newBoardHtml } = await import("../server/boards.mjs");
50
+ const { projectName } = await import("../server/fsutil.mjs");
51
+ mkdirSync(path.join(dir, "screens"), { recursive: true });
52
+ writeFileSync(path.join(dir, "screens/home.html"), newBoardHtml({ title: "Home", w: 390, h: 844, template: "mobile", brand: projectName(dir) }));
53
+ console.log(`Created ${path.join(dir, "screens/home.html")}`);
54
+ }
55
+ open = true;
56
+ }
57
+
58
+ if (!existsSync(dir)) {
59
+ console.error(`No design folder at ${dir}
60
+
61
+ Try one of:
62
+ npx easel-canvas --demo open the demo project
63
+ npx easel-canvas --init start a new design folder here (./docs/design)
64
+ npx easel-canvas --dir <folder> open an existing folder of screens/*.html`);
65
+ process.exit(1);
66
+ }
67
+
68
+ const { createServer } = await import("../server/index.mjs");
69
+ const { attach, closeBrowser, extraRoutes } = await import("../server/routes.mjs");
70
+ const app = await createServer({ dir, port: args.port, dev: !args.prod, extraRoutes });
71
+ await attach(app);
72
+ console.log(`Easel: ${app.url} (design folder ${dir})`);
73
+
74
+ if (open && !args.noOpen) {
75
+ const [cmd, cmdArgs] = process.platform === "darwin" ? ["open", [app.url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", app.url]] : ["xdg-open", [app.url]];
76
+ spawn(cmd, cmdArgs, { stdio: "ignore", detached: true, windowsHide: true }).on("error", () => {}).unref();
77
+ }
78
+
79
+ for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"])
80
+ process.on(sig, async () => {
81
+ await closeBrowser();
82
+ process.exit(0);
83
+ });