easel-canvas 0.1.1 → 0.2.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/README.md +103 -34
- package/bin/mcp.mjs +146 -40
- package/bin/server.mjs +67 -5
- package/dist/assets/index-BZFSkKqU.css +1 -0
- package/dist/assets/index-BwyrrnkP.js +65 -0
- package/dist/index.html +3 -3
- package/dist/viewer/viewer.css +1 -0
- package/dist/viewer/viewer.js +49 -0
- package/examples/demo/CLAUDE.md +8 -0
- package/examples/demo/assets/fonts/OFL-Anton.txt +93 -0
- package/examples/demo/assets/fonts/OFL-JetBrainsMono.txt +93 -0
- package/examples/demo/assets/fonts/anton-latin-400.woff2 +0 -0
- package/examples/demo/assets/fonts/jetbrains-mono-latin-400.woff2 +0 -0
- package/examples/demo/assets/ticket-qr.svg +5 -0
- package/examples/demo/board.json +47 -20
- package/examples/demo/comments.json +27 -7
- package/examples/demo/screens/brand.html +155 -0
- package/examples/demo/screens/clash.html +94 -0
- package/examples/demo/screens/empty-day.html +114 -0
- package/examples/demo/screens/film.html +98 -0
- package/examples/demo/screens/home-daylight.html +144 -0
- package/examples/demo/screens/home.html +132 -38
- package/examples/demo/screens/poster.html +77 -0
- package/examples/demo/screens/programme.html +125 -0
- package/examples/demo/screens/site.html +118 -0
- package/examples/demo/screens/square.html +71 -0
- package/examples/demo/screens/ticket.html +107 -0
- package/examples/demo/screens/timetable.html +192 -0
- package/examples/demo/tokens.json +54 -22
- package/package.json +4 -3
- package/server/activity.mjs +370 -0
- package/server/agents.mjs +20 -0
- package/server/args.mjs +23 -2
- package/server/board.mjs +4 -16
- package/server/boards.mjs +46 -21
- package/server/browser.mjs +68 -0
- package/server/chat.mjs +376 -56
- package/server/connect.mjs +94 -0
- package/server/copies.mjs +105 -0
- package/server/custom.mjs +101 -0
- package/server/export.mjs +627 -0
- package/server/forks.mjs +214 -0
- package/server/fsutil.mjs +8 -0
- package/server/history.mjs +152 -24
- package/server/html.mjs +11 -1
- package/server/index.mjs +153 -16
- package/server/occupancy.mjs +183 -0
- package/server/permissions.mjs +141 -0
- package/server/place.mjs +87 -0
- package/server/registry.mjs +110 -0
- package/server/routes.mjs +23 -54
- package/server/runs.mjs +167 -0
- package/server/snapshot.mjs +21 -9
- package/server/tokens.mjs +4 -1
- package/server/update.mjs +63 -0
- package/server/watch.mjs +12 -1
- package/dist/assets/index-DXUYTbPc.js +0 -55
- package/dist/assets/index-lfQlW-DC.css +0 -1
- package/examples/demo/screens/empty.html +0 -43
- package/examples/demo/screens/habit.html +0 -55
- package/examples/demo/screens/landing.html +0 -44
- package/examples/demo/screens/new-habit.html +0 -47
- package/examples/demo/screens/settings.html +0 -43
- package/examples/demo/screens/stats.html +0 -50
package/README.md
CHANGED
|
@@ -2,29 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Easel
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**A design canvas where your coding agents and you work on the same real HTML.**
|
|
6
|
+
|
|
7
|
+
No export, no hand-off, no design file: screens are HTML files in your repo, and Claude Code, Codex, Cursor and Gemini edit them on the same canvas you do.
|
|
6
8
|
|
|
7
9
|
[](https://www.npmjs.com/package/easel-canvas)
|
|
8
10
|
[](LICENSE)
|
|
9
11
|
[](package.json)
|
|
10
|
-
[](#connect-your-ai-agent)
|
|
12
|
+
[](#connect-your-ai-agent)
|
|
13
|
+
[](#connect-your-ai-agent)
|
|
12
14
|
|
|
13
|
-
<img src="docs/screenshots/demo.gif" alt="Demo:
|
|
15
|
+
<img src="docs/screenshots/demo.gif" alt="Demo: the Intercut No.14 film festival identity on one canvas, then a zoom to its phone app; retyping the spliced title on My cut in place and taking it back, changing the ticket bar's fill to a token, asking Claude Code in the AI tab to turn the home screen into the ticket while the board redraws red with the QR code and the chat lists its tool calls, check_tokens among them; undoing and redoing that whole run, then exporting a view-only copy from Share" width="100%">
|
|
14
16
|
|
|
15
|
-
<sub>A real Claude Code run on the bundled demo
|
|
17
|
+
<sub>A real Claude Code run on the bundled demo. The agent's working time is sped up 16× (about 93 seconds shown in 6); everything else plays at real speed.</sub>
|
|
16
18
|
|
|
17
19
|
</div>
|
|
18
20
|
|
|
19
|
-
Easel turns a folder of plain HTML files into a design canvas.
|
|
21
|
+
Easel turns a folder of plain HTML files into a design canvas. Your agent 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**. Your designs stay in your repo as HTML and merge with git like any other code.
|
|
20
22
|
|
|
21
23
|
## Try it in 30 seconds
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
npx easel-canvas --demo
|
|
26
|
+
npx easel-canvas@latest --demo
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
That copies the
|
|
29
|
+
That copies the demo to `./easel-demo` and opens it at http://localhost:4317: Intercut No.14, a film festival identity with a phone app, a desktop timetable and campaign pieces, 12 boards set in bundled open-licence fonts. Click anything on a screen and start editing, or open the **AI** tab (⌘J) and ask your agent for a change. (`@latest` makes npx fetch the newest version instead of reusing a copy it cached; see [Updates](#updates).)
|
|
28
30
|
|
|
29
31
|
Already have HTML screens? Run it in your project:
|
|
30
32
|
|
|
@@ -36,28 +38,41 @@ npx easel-canvas --dir ./designs # any folder of screens/*.html
|
|
|
36
38
|
|
|
37
39
|
## Why Easel
|
|
38
40
|
|
|
39
|
-
- **HTML is the source of truth.** Each `screens/*.html` file is one board. What you see is
|
|
40
|
-
- **Built for AI agents.** An MCP server with
|
|
41
|
-
- **
|
|
42
|
-
- **
|
|
43
|
-
- **
|
|
41
|
+
- **HTML is the source of truth.** Each `screens/*.html` file is one board. What you see is what ships to the browser, with nothing to export or keep in sync.
|
|
42
|
+
- **Built for AI agents.** An MCP server with 22 tools lets agents see the boards, read your selection, comment, check tokens and arrange the canvas. The in-app chat runs Claude Code, Codex, Cursor Agent, Gemini CLI or your own command with your selection as context. A Claude Code run started there carries Easel's tools for that canvas without `connect`, and its permission requests come up as cards you answer there.
|
|
43
|
+
- **Several agents and people, no overwrites.** One writer per board: a second agent gets a fork beside it, not your file. Every change is tagged with who made it, and an agent's whole run undoes in one step.
|
|
44
|
+
- **Surgical edits.** Changes are patched into the exact source range (parse5 locations), so formatting, comments and the rest of the file stay as they were. If an agent changed the same element first, your edit is refused instead of overwriting it.
|
|
45
|
+
- **A copy anyone can open.** Share exports a view-only canvas you can host anywhere, or one `.html` file to attach to a message or a PR.
|
|
46
|
+
- **Git-friendly.** Layout, notes and comments live in small JSON files, one entry per line, so branches that move different boards merge without conflicts.
|
|
47
|
+
- **Local-first.** It runs on `127.0.0.1` against the files in your repo. No account, no cloud, no lock-in.
|
|
44
48
|
|
|
45
49
|
## Features
|
|
46
50
|
|
|
47
51
|
<table>
|
|
48
52
|
<tr>
|
|
49
|
-
<td colspan="2"><img src="docs/screenshots/overview.png" alt="Easel showing
|
|
53
|
+
<td colspan="2"><img src="docs/screenshots/overview.png" alt="Easel showing the Intercut No.14 film festival identity: the brand sheet and the site's first screen, the phone app's seven screens joined by flow arrows, the desktop timetable and sticky notes on one canvas, the board list card at the left and the inspector card at the right with the Brand sheet's position, options, token check and accessibility check"></td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr>
|
|
56
|
+
<td colspan="2"><b>See every screen at once.</b> Each HTML file in <code>screens/</code> is a board on one canvas, next to notes and arrows, with token and accessibility checks for the one you pick.</td>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td width="50%"><img src="docs/screenshots/select.png" alt="The Show ticket bar selected inside the My cut phone screen, its element toolbar (Text, Fill, Radius, Spacing, Ask AI, Comment) in the line above the dock, and the inspector with the breadcrumb, Fill set to the Safelight token with its contrast, Text, Corner radius, Padding and Gap"></td>
|
|
60
|
+
<td width="50%"><img src="docs/screenshots/ai-chat.png" alt="AI chat in the inspector card after a real Claude Code run: its reply about turning My cut into the ticket with a larger scannable QR code, Changed 1 board with Undo this run and Compare, and the My cut screen redrawn red with the QR code next to the Film and Ticket screens, under a Claude Code activity tag"></td>
|
|
61
|
+
</tr>
|
|
62
|
+
<tr>
|
|
63
|
+
<td><b>Edit the real screen.</b> Click any element to drag, resize, align, retype or restyle it; only that part of the HTML changes. Layers, wrap in flex or grid, copy and paste across boards.</td>
|
|
64
|
+
<td><b>Ask your agent.</b> Claude Code, Codex, Cursor Agent or Gemini CLI get your selection, boards and comments as context. Watch the board redraw, ask for variants side by side, and undo the whole run in one step.</td>
|
|
50
65
|
</tr>
|
|
51
66
|
<tr>
|
|
52
|
-
<td width="50%"><img src="docs/screenshots/
|
|
53
|
-
<td width="50%"><img src="docs/screenshots/
|
|
67
|
+
<td width="50%"><img src="docs/screenshots/agents.png" alt="Two agents on one canvas: the Social square held by Claude Code (Claude Code is editing…) and Codex working on a fork beside it, Social square · Codex (Codex is editing…), with a dashed arrow back, the note Forked — Codex started while Claude Code was editing, and Use this one on both"></td>
|
|
68
|
+
<td width="50%"><img src="docs/screenshots/share.png" alt="The Share popover under the inspector header with Selected boards (2): Web folder exported to intercut/easel-export/ with Reveal and Copy deploy command, One .html file, PDF and PNG, and the matching npx easel-canvas export --boards home.html,ticket.html command"></td>
|
|
54
69
|
</tr>
|
|
55
70
|
<tr>
|
|
56
|
-
<td><b>
|
|
57
|
-
<td><b>
|
|
71
|
+
<td><b>Work alongside several agents.</b> One writer per board: a second agent works on a fork beside it, every change is tagged with who made it, and Use this one keeps the version you want.</td>
|
|
72
|
+
<td><b>Share a view-only copy.</b> Export the canvas, a page or the selected boards as a static site to host anywhere, or as one <code>.html</code> file to attach; PDF and PNG too.</td>
|
|
58
73
|
</tr>
|
|
59
74
|
<tr>
|
|
60
|
-
<td width="50%"><img src="docs/screenshots/dark-mode.png" alt="Dark mode with
|
|
75
|
+
<td width="50%"><img src="docs/screenshots/dark-mode.png" alt="Dark mode on the film festival's phone screens with the Ticket board's context menu: Select inside, Ask AI for a review, Focus view, Ask AI, Go to board, Rename, Rename file, Duplicate, Bring to front, Send to back, Delete"></td>
|
|
61
76
|
<td width="50%">
|
|
62
77
|
<b>Everything a canvas should do.</b>
|
|
63
78
|
<ul>
|
|
@@ -74,33 +89,67 @@ npx easel-canvas --dir ./designs # any folder of screens/*.html
|
|
|
74
89
|
|
|
75
90
|
## Connect your AI agent
|
|
76
91
|
|
|
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`).
|
|
92
|
+
Keep the canvas running (`npx easel-canvas`). Agents write HTML files directly, and what they change shows up in the canvas's undo history (one step per in-app AI request, or per burst of edits from an outside agent); 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`). When several agents share a canvas, `claim_board` (before editing a file with their own tools) or `write_board` (a whole board through Easel) keeps one writer per board: a second agent on a busy board is given a fork next to it and told which file it is on.
|
|
93
|
+
|
|
94
|
+
Then, in your project folder:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx easel-canvas connect
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The in-app chat does not need this for Claude Code: each run it starts gets its own copy of these tools, bound to that canvas and that run, and a project's `easel` server is set aside for the run so the agent sees one set. Codex, Cursor Agent and Gemini CLI runs from the chat use the tools only once the project is connected.
|
|
101
|
+
|
|
102
|
+
It adds the Easel MCP server to your agents' configs and leaves everything else in those files as it was: `.mcp.json` (Claude Code), `.cursor/mcp.json` (Cursor) and `.gemini/settings.json` (Gemini CLI) in the project, and `[mcp_servers.easel]` in `~/.codex/config.toml` (Codex). Cursor, Gemini CLI and Codex are written only when they are found on your machine; pick agents with `--agents claude,cursor,gemini,codex`, or preview with `--dry-run`. Restart your agent afterwards.
|
|
103
|
+
|
|
104
|
+
There is no port to set: the MCP server finds the canvas running for the folder your agent works in (each canvas registers itself in `~/.easel/servers/`), and a busy port 4317 simply moves the canvas to the next free one. With several canvases open outside any of their projects, pass `--port <n>` to `easel-mcp` to pick one.
|
|
105
|
+
|
|
106
|
+
<details>
|
|
107
|
+
<summary>Manual setup</summary>
|
|
78
108
|
|
|
79
|
-
**Claude Code
|
|
109
|
+
**Claude Code** (`.mcp.json` in the project root), **Cursor** (`.cursor/mcp.json`), **Gemini CLI** (`.gemini/settings.json`):
|
|
80
110
|
|
|
81
111
|
```json
|
|
82
|
-
{ "mcpServers": { "easel": { "
|
|
112
|
+
{ "mcpServers": { "easel": { "command": "npx", "args": ["-y", "-p", "easel-canvas", "easel-mcp"] } } }
|
|
83
113
|
```
|
|
84
114
|
|
|
85
|
-
**Codex
|
|
115
|
+
**Codex** (`~/.codex/config.toml`):
|
|
86
116
|
|
|
87
117
|
```toml
|
|
88
118
|
[mcp_servers.easel]
|
|
89
119
|
command = "npx"
|
|
90
|
-
args = ["-y", "-p", "easel-canvas", "easel-mcp"
|
|
120
|
+
args = ["-y", "-p", "easel-canvas", "easel-mcp"]
|
|
91
121
|
default_tools_approval_mode = "approve" # the tools only view, comment and arrange
|
|
92
122
|
```
|
|
93
123
|
|
|
124
|
+
Add `"--port", "4317"` to `args` to pin one canvas instead of finding it by folder.
|
|
125
|
+
|
|
126
|
+
</details>
|
|
127
|
+
|
|
94
128
|
Using Easel as a submodule (below)? Point `args` at `tools/easel/bin/mcp.mjs` with `"command": "node"` instead.
|
|
95
129
|
|
|
96
130
|
Then try:
|
|
97
131
|
|
|
98
132
|
> "Fix what I selected on the canvas: make the button text shorter."
|
|
99
|
-
> "Make three variants of the
|
|
100
|
-
> "Create an onboarding screen at 390×844 and put it next to
|
|
133
|
+
> "Make three variants of the sign-up screen."
|
|
134
|
+
> "Create an onboarding screen at 390×844 and put it next to Home."
|
|
101
135
|
|
|
102
136
|
New files with `<meta name="board-size" content="390x844">` are placed on the canvas automatically at that size.
|
|
103
137
|
|
|
138
|
+
## Share a view-only copy
|
|
139
|
+
|
|
140
|
+
**Share** (at the top of the right card) writes a static, read-only copy of the whole canvas, the current page or the selected boards to `<project>/easel-export/`: boards with their pages, notes and comments, Play, and a stamp with the export time and `repo@commit`. Nothing in it calls back to Easel, so any static host works (Vercel, GitHub Pages, a PR preview, under any sub-path), and `index.html` also opens straight from disk (comment pins then stack in their board's corner, because browsers keep `file://` frames apart). **Copy deploy command** gives you `npx vercel deploy easel-export`. Turn on **One .html file** for a single self-contained file to attach to Slack, email or a PR; its size shows before you save. **PDF** (one board per page) and **PNG** (one 2× image per board) need Playwright's Chromium.
|
|
141
|
+
|
|
142
|
+
The same from the terminal, with no canvas running (it works in CI):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npx easel-canvas export # web folder in ./easel-export
|
|
146
|
+
npx easel-canvas export --single-file # one self-contained .html
|
|
147
|
+
npx easel-canvas export --page Onboarding --pdf --png
|
|
148
|
+
npx easel-canvas export --boards home.html,ticket.html --out dist/design-preview
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Exporting again replaces what the previous export of the same kind wrote there (a small `.easel-export.json` lists it) and leaves anything else in the folder alone; a non-empty folder Easel did not create is never cleared. Dot folders (`.easel/`, `.thumbs/`…) and files outside the design folder are never copied. A single file inlines the screens' images, fonts, CSS and scripts but not HTML embedded with `<iframe>`; the export lists what it skipped.
|
|
152
|
+
|
|
104
153
|
## Pin it in your project
|
|
105
154
|
|
|
106
155
|
`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/`:
|
|
@@ -127,6 +176,10 @@ npm run design # http://localhost:4317
|
|
|
127
176
|
- 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
177
|
- 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
178
|
|
|
179
|
+
## Updates
|
|
180
|
+
|
|
181
|
+
`npx` keeps the copy it downloaded first, so run `npx easel-canvas@latest` to get a new version (and `npm i -D easel-canvas@latest` if you pinned it). To tell you when one is out, the canvas asks the npm registry once a day which version is the latest: one request to `registry.npmjs.org`, nothing about your project. When a newer one exists, the terminal says so at start and a toast at launch shows the update command for how you installed Easel; Copy command or × puts it away until the next version. Set `EASEL_NO_UPDATE_CHECK=1` to turn the check off; it is also off in CI and when Easel runs from a git checkout.
|
|
182
|
+
|
|
130
183
|
|
|
131
184
|
<details>
|
|
132
185
|
<summary><b>Keyboard shortcuts and how-tos</b></summary>
|
|
@@ -140,13 +193,20 @@ npm run design # http://localhost:4317
|
|
|
140
193
|
| 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
194
|
| View | Focus view (F, ←→), Play in place (P or ▶, Esc), Play full screen (right-click) |
|
|
142
195
|
| 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
|
-
|
|
|
144
|
-
| Direct editing |
|
|
145
|
-
| Undo | ⌘Z / ⌘⇧Z. Canvas actions, HTML edits and board create/delete share one history (100 entries) |
|
|
146
|
-
|
|
|
196
|
+
| Select elements | No mode to enter: click anything on a board (drag the board to move it). Shift-click or Shift-drag for several, Esc lets go (then of the board), ↑ parent, ↓ or Enter first child, ←→ siblings, Option+↑↓ to reorder, ⌘A for all siblings, ⌘G Wrap in flex, Tab into the element toolbar |
|
|
197
|
+
| Direct editing | The element toolbar, in the line above the dock: Text (size, weight), Fill (your tokens first, written as a CSS variable, then Custom), Radius, Spacing (padding, gap), Ask AI, Comment. Double-click text to edit it (Shift+Enter for a line break). Move with handles (Alt drops inside a box) and resize, 6 align options, Properties panel in design words with the breadcrumb (CSS names on hover, everything else under More (CSS), ⚠, contrast), Replace image, ⌘C/⌘V to paste into another board |
|
|
198
|
+
| Undo | ⌘Z / ⌘⇧Z. Canvas actions, HTML edits and board create/delete share one history (100 entries). The ▾ next to Undo lists it newest first (who, what, when; Now marks where you are): Go back to here undoes or redoes step by step to that entry, and Redo brings the rest back. The history lasts until Easel restarts |
|
|
199
|
+
| Who changed what | A board changed by someone else (an agent over MCP or the in-app chat, a file edited outside Easel, another browser) gets a tag above its title, e.g. "Codex · 2m · 1 change", with a person or agent mark and the name, and the changed element is outlined. Click the tag: the change ("Get started" → "Start free"), Before / After, and Undo (only that change; asks first if one of its boards changed since). Tags fade once you open them or select the board, and clear a day later |
|
|
200
|
+
| Design system | Register tokens (`tokens.json`) and themes in the left "Tokens" tab, Theme in the View menu (⋯ at the top of the right card), Token check and Accessibility lists on the right |
|
|
147
201
|
| Collaboration | Comments (Reply, Resolve, author), Snapshot menu (git-commits only the design folder) |
|
|
148
|
-
|
|
|
149
|
-
|
|
|
202
|
+
| Share | "Share" at the top of the right card: whole canvas, this page or the selected boards as a web folder or one .html file, PDF or PNG; Reveal, Copy deploy command, and the matching `npx easel-canvas export` line |
|
|
203
|
+
| Who is on which board | A board someone is editing says so above its title with a mark and the name: "Claude Code is editing…", "You · editing", then "Claude Code · done 13:52"; the board list shows a dot (blue for you, ink for anyone else). An agent holds a board from its first write until its in-app run ends, or 45 s after its last write over MCP (or when it disconnects). A second agent writing a board another agent holds works on a fork beside it ("Welcome · Codex"), with an arrow back that says when and why; you are never forked. When both are done, Use this one on either keeps that version under the original's name, title, position and comments, and sends the other to trash; one Undo brings both back |
|
|
204
|
+
| Pick a variant | Variants from the AI tab land in the first free row (never on notes or boards) and each gets Use this: Apply makes it the original board and sends the other variants to trash (toast with Undo), Keep all leaves them as ordinary boards |
|
|
205
|
+
| AI | Right "AI" tab (⌘J): Claude Code, Codex, Cursor Agent, Gemini CLI, or your own command; selection, boards, visible boards, comments and references go along as context; N variants; Ask AI for a review |
|
|
206
|
+
| AI permissions | When Claude Code wants to run a command or edit outside what it may, the chat shows the exact request: Allow once, Always allow (that tool, or a command's first two words, until Easel restarts; never for file edits, for commands with `;` `&&` `\|` `>` and the like, or for `sh -c`-style wrappers), or Deny |
|
|
207
|
+
| Undo an AI run | Each run that changed files ends with the boards it changed and added: Undo this run (one step, ⌘Z brings it back; asks first if you changed one of them since), Redo, Compare before and after. After a restart: Restore the copy from before this run (the newest 10 are kept) |
|
|
208
|
+
| Custom agent | Agent menu › Custom command…: a name and a command with `{prompt}`, e.g. `aider --message {prompt} --yes`. Saved in `~/.easel/agents.json` (not in the project), run without a shell, output shown as plain text |
|
|
209
|
+
| Screen | F6 to move between regions, Tab to move between boards, ⌘\\ to fold both cards away and back, Appearance (System · Light · Dark) |
|
|
150
210
|
|
|
151
211
|
</details>
|
|
152
212
|
|
|
@@ -163,6 +223,11 @@ your-project/docs/design/
|
|
|
163
223
|
- 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
224
|
- Element paths and hashes are computed from the source with parse5. Every edit is a minimal string patch into that range, written atomically.
|
|
165
225
|
- 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.
|
|
226
|
+
- The server listens on 127.0.0.1 only and refuses changes (and the live connection) from other web pages open in your browser: only requests with no `Origin` (the CLI, the MCP server) or from the canvas page itself, on a local host name, get through. Boards are your project's own HTML and run inside the canvas page, with the same access to it as you have, so open only design folders you trust.
|
|
227
|
+
|
|
228
|
+
## Easel and Claude Design
|
|
229
|
+
|
|
230
|
+
Claude Design makes designs inside Claude, as artifacts. Easel keeps them as HTML files in your repo, edited by whichever agent you use, and exports a static copy when you want to show them. A feature-by-feature comparison is in [PARITY.md](PARITY.md) (last checked on 2026-10-09, before 0.2.0).
|
|
166
231
|
|
|
167
232
|
## Development
|
|
168
233
|
|
|
@@ -171,10 +236,11 @@ npm test # unit tests (source patching, board format, chat parsing,
|
|
|
171
236
|
npm run test:e2e # Playwright end-to-end tests against test/fixtures/design
|
|
172
237
|
npm run typecheck
|
|
173
238
|
npm run demo # run the repo's demo from source
|
|
239
|
+
npm run design:css # rebuild docs/design/assets/easel.css after changing app/src/style.css, so the boards in docs/design keep matching the app
|
|
174
240
|
```
|
|
175
241
|
|
|
176
242
|
- `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
|
|
243
|
+
- `examples/demo/` is Intercut No.14, the project `--demo` copies and the one in the demo video and the screenshots above. Its two fonts are bundled under the SIL Open Font License (see [License](#license)).
|
|
178
244
|
|
|
179
245
|
| Folder | Contents |
|
|
180
246
|
| --- | --- |
|
|
@@ -182,11 +248,14 @@ npm run demo # run the repo's demo from source
|
|
|
182
248
|
| `server/` | API and routes, board.json, file watching, element paths and hashes, source patching, history, chat runner, tokens |
|
|
183
249
|
| `app/` | Canvas UI (Vite + React + TypeScript); all UI text lives in `app/src/strings.ts` |
|
|
184
250
|
| `test/` | `node --test` unit tests and Playwright e2e tests |
|
|
251
|
+
| `tools/` | Repo maintenance scripts, not shipped: `mkcss.mjs` builds the design boards' stylesheet from the app's |
|
|
185
252
|
|
|
186
|
-
Background reading: the original plan is in [PLAN.md](PLAN.md)
|
|
253
|
+
Background reading: the original plan is in [PLAN.md](PLAN.md) and the work log is in [tasks.md](tasks.md).
|
|
187
254
|
|
|
188
255
|
Contributions are welcome: open an issue or a pull request.
|
|
189
256
|
|
|
190
257
|
## License
|
|
191
258
|
|
|
192
259
|
[MIT](LICENSE) © Hyun Park
|
|
260
|
+
|
|
261
|
+
The demo bundles two fonts in `examples/demo/assets/fonts/`, each under the [SIL Open Font License 1.1](https://openfontlicense.org) with its licence text beside it: [Anton](https://github.com/googlefonts/AntonFont) (`OFL-Anton.txt`) and [JetBrains Mono](https://github.com/JetBrains/JetBrainsMono) (`OFL-JetBrainsMono.txt`), both taken from the Fontsource 5.3.0 packages.
|
package/bin/mcp.mjs
CHANGED
|
@@ -2,25 +2,58 @@
|
|
|
2
2
|
// AI-generated with Claude Code, 2026-10-09, reviewed by Hyun Park
|
|
3
3
|
// MCP server (stdio): exposes boards, selection, screenshots, comments and placement through the app server API (http://localhost:<port>). PLAN.md ch. 6.
|
|
4
4
|
// The agent creates and edits HTML by writing files directly. This server only observes, points at things, and places boards.
|
|
5
|
+
// With --chat (an in-app Claude Code run) it also carries the run's permission prompt, answered in the Easel chat, under the name easel-chat;
|
|
6
|
+
// --permission (older) carries only that permission tool.
|
|
7
|
+
// No port needed: the canvas for the folder the agent runs in is found through the registry (server/registry.mjs) on each call.
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import fs from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
5
12
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
13
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
14
|
import { z } from "zod";
|
|
8
15
|
|
|
9
|
-
import {
|
|
16
|
+
import { agentLabel } from "../server/agents.mjs";
|
|
17
|
+
import { parseArgs, TOOL_ROOT } from "../server/args.mjs";
|
|
18
|
+
import { discoverPort } from "../server/registry.mjs";
|
|
19
|
+
|
|
20
|
+
const args = parseArgs();
|
|
21
|
+
const pkg = JSON.parse(readFileSync(path.join(TOOL_ROOT, "package.json"), "utf8"));
|
|
22
|
+
// --port wins; an in-app chat run passes the canvas it was started from
|
|
23
|
+
const explicit = args.portGiven ? args.port : Number(process.env.DESIGN_CANVAS_PORT) || null;
|
|
24
|
+
const IMAGE_LIMIT = 4 * 1024 * 1024;
|
|
10
25
|
|
|
11
|
-
|
|
12
|
-
const
|
|
26
|
+
let port = null;
|
|
27
|
+
const resolvePort = async (fresh = false) => (port = !fresh && port ? port : await discoverPort({ port: explicit }));
|
|
28
|
+
|
|
29
|
+
/** This MCP server's id at the canvas: the boards it writes are released when its client disconnects */
|
|
30
|
+
const CLIENT = `mcp-${process.pid.toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
31
|
+
/** Header values for the app server: who made a change (undo history, comments), which in-app run it belongs to, and this client */
|
|
32
|
+
const agentHeaders = () => ({ "X-Easel-Agent": agent(), "X-Easel-Client": CLIENT, ...(process.env.EASEL_RUN_ID ? { "X-Easel-Run": process.env.EASEL_RUN_ID } : {}) });
|
|
33
|
+
const agent = () => agentLabel(server.server.getClientVersion()?.name);
|
|
13
34
|
|
|
14
35
|
async function call(method, path, body) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
res = await fetch(BASE + path, {
|
|
36
|
+
const send = async () =>
|
|
37
|
+
fetch(`http://127.0.0.1:${port}${path}`, {
|
|
18
38
|
method,
|
|
19
|
-
headers: body ? { "Content-Type": "application/json" } :
|
|
39
|
+
headers: { ...agentHeaders(), ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
20
40
|
body: body ? JSON.stringify(body) : undefined,
|
|
21
41
|
});
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
let res;
|
|
43
|
+
try {
|
|
44
|
+
await resolvePort();
|
|
45
|
+
res = await send();
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e.message?.startsWith("Several Easel canvases")) throw e;
|
|
48
|
+
// Nothing was sent: the canvas may have restarted on another port, or started after this server
|
|
49
|
+
try {
|
|
50
|
+
if (explicit) throw e;
|
|
51
|
+
await resolvePort(true);
|
|
52
|
+
res = await send();
|
|
53
|
+
} catch (e2) {
|
|
54
|
+
if (e2.message?.startsWith("Several Easel canvases")) throw e2;
|
|
55
|
+
throw new Error(`Easel is not running for this project (tried http://localhost:${port}). Start it in the project with \`npx easel-canvas\` (add --dir <design folder> when the screens are not in ./docs/design or the current folder), then try again.`);
|
|
56
|
+
}
|
|
24
57
|
}
|
|
25
58
|
const text = await res.text();
|
|
26
59
|
if (!res.ok) {
|
|
@@ -37,36 +70,85 @@ async function call(method, path, body) {
|
|
|
37
70
|
const callJson = async (m, p, b) => JSON.parse(await call(m, p, b));
|
|
38
71
|
const ok = (data) => ({ content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] });
|
|
39
72
|
|
|
40
|
-
|
|
73
|
+
// --chat: started by an in-app Claude Code run (inline --mcp-config), bound to its canvas and run: the canvas tools and the permission tool,
|
|
74
|
+
// under a name of its own (the run denies any other easel server, so the model sees one set). --permission: the permission tool only
|
|
75
|
+
const permissionOnly = args.permission && !args.chat;
|
|
76
|
+
const server = new McpServer({ name: args.chat || args.permission ? "easel-chat" : "easel", version: pkg.version });
|
|
77
|
+
/** The canvas tools; none of them in --permission mode */
|
|
78
|
+
const tool = permissionOnly ? () => {} : (...a) => server.registerTool(...a);
|
|
41
79
|
|
|
42
|
-
|
|
80
|
+
if (args.chat || args.permission)
|
|
81
|
+
server.registerTool(
|
|
82
|
+
"permission",
|
|
83
|
+
{
|
|
84
|
+
description: "Asks the user in the Easel chat whether a tool call may run (Claude Code --permission-prompt-tool). Returns allow or deny.",
|
|
85
|
+
inputSchema: { tool_name: z.string(), input: z.record(z.string(), z.unknown()), tool_use_id: z.string().optional() },
|
|
86
|
+
},
|
|
87
|
+
async ({ tool_name, input, tool_use_id }) => {
|
|
88
|
+
let answer;
|
|
89
|
+
try {
|
|
90
|
+
let r = await callJson("POST", "/api/chat/permission", { tool_name, input, tool_use_id });
|
|
91
|
+
// The user may take a while: poll until the card is answered (or the run is cancelled, which denies it)
|
|
92
|
+
while (r.pending) r = await callJson("GET", `/api/chat/permission?id=${encodeURIComponent(r.id)}`);
|
|
93
|
+
answer = r.behavior === "allow" ? { behavior: "allow", updatedInput: r.updatedInput ?? input } : { behavior: "deny", message: String(r.message ?? "Denied") };
|
|
94
|
+
} catch (e) {
|
|
95
|
+
answer = { behavior: "deny", message: `Easel could not ask the user: ${e.message}` };
|
|
96
|
+
}
|
|
97
|
+
return { content: [{ type: "text", text: JSON.stringify(answer) }] };
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
tool(
|
|
43
102
|
"list_boards",
|
|
44
103
|
{
|
|
45
|
-
description:
|
|
104
|
+
description:
|
|
105
|
+
"List the boards on the design canvas (each board is an .html file in the screens folder, returned as dir) with file, title, size, position and page, who is editing it right now (editing), and origin for a variant or fork of another board. Use it to find which file to read or edit.",
|
|
46
106
|
inputSchema: { page: z.string().optional().describe("Only return boards on this page id") },
|
|
47
107
|
},
|
|
48
108
|
async ({ page }) => {
|
|
49
|
-
const { board, missing } = await callJson("GET", "/api/board");
|
|
109
|
+
const { board, missing, screens } = await callJson("GET", "/api/board");
|
|
110
|
+
const occ = (await callJson("GET", "/api/boards/occupancy").catch(() => null))?.boards ?? {};
|
|
50
111
|
const first = board.pages[0]?.id;
|
|
112
|
+
const editing = (f) => (occ[f] ?? []).filter((h) => h.state === "editing").map((h) => h.by ?? h.person ?? "someone");
|
|
51
113
|
const rows = board.order
|
|
52
114
|
.filter((f) => board.boards[f])
|
|
53
|
-
.map((f) => ({ file: f, ...board.boards[f], page: board.boards[f].page ?? first }))
|
|
115
|
+
.map((f) => ({ file: f, ...board.boards[f], page: board.boards[f].page ?? first, ...(editing(f).length ? { editing: editing(f) } : {}) }))
|
|
54
116
|
.filter((b) => !page || b.page === page);
|
|
55
|
-
return ok({ dir: "
|
|
117
|
+
return ok({ dir: screens ?? "screens", pages: board.pages, boards: rows, missingFiles: missing });
|
|
56
118
|
},
|
|
57
119
|
);
|
|
58
120
|
|
|
59
|
-
|
|
121
|
+
tool(
|
|
60
122
|
"read_board",
|
|
61
123
|
{ 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
124
|
async ({ file }) => ok(await call("GET", `/api/file?f=${encodeURIComponent(file)}`)),
|
|
63
125
|
);
|
|
64
126
|
|
|
65
|
-
|
|
127
|
+
tool(
|
|
128
|
+
"claim_board",
|
|
129
|
+
{
|
|
130
|
+
description:
|
|
131
|
+
"Call before you edit a board's file with your own file tools, so people and other agents see you are editing it. Returns the file to edit: the board itself, or, when another agent is editing that board right now, a fork next to it (a copy) so you do not overwrite each other. Edit the returned file. Reading never needs this.",
|
|
132
|
+
inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html") },
|
|
133
|
+
},
|
|
134
|
+
async ({ file }) => ok(await callJson("POST", "/api/boards/claim", { file })),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
tool(
|
|
138
|
+
"write_board",
|
|
139
|
+
{
|
|
140
|
+
description:
|
|
141
|
+
"Write a board's whole HTML through Easel (instead of writing the file yourself). If another agent is editing that board right now, your version goes to a fork next to it, and the reply says which file you are on; keep writing to that file.",
|
|
142
|
+
inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html"), html: z.string().describe("The complete HTML of the board") },
|
|
143
|
+
},
|
|
144
|
+
async ({ file, html }) => ok(await callJson("POST", "/api/boards/write", { file, html })),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
tool(
|
|
66
148
|
"get_selection",
|
|
67
149
|
{
|
|
68
150
|
description:
|
|
69
|
-
"What the user is looking at right now: selection (the element clicked
|
|
151
|
+
"What the user is looking at right now: selection (the element the user clicked on a board: 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 = an element is selected, 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
152
|
inputSchema: {},
|
|
71
153
|
},
|
|
72
154
|
async () => {
|
|
@@ -74,16 +156,24 @@ server.registerTool(
|
|
|
74
156
|
},
|
|
75
157
|
);
|
|
76
158
|
|
|
77
|
-
|
|
159
|
+
tool(
|
|
78
160
|
"screenshot",
|
|
79
161
|
{
|
|
80
|
-
description:
|
|
162
|
+
description:
|
|
163
|
+
"Take a PNG screenshot of a board, or of an element inside it, and return the image (plus the path it was saved to, in the design folder's .easel/screenshots/). Use it to check how a change looks (requires playwright).",
|
|
81
164
|
inputSchema: { file: z.string(), path: z.string().optional().describe("Element path, e.g. 0/2/1; omit for the whole board") },
|
|
82
165
|
},
|
|
83
|
-
async ({ file, path }) =>
|
|
166
|
+
async ({ file, path: elPath }) => {
|
|
167
|
+
const r = await callJson("POST", "/api/screenshot", { file, path: elPath });
|
|
168
|
+
const png = await fs.readFile(r.path).catch(() => null);
|
|
169
|
+
const where = `Saved to ${r.relPath ?? r.path}`;
|
|
170
|
+
if (!png) return ok(where);
|
|
171
|
+
if (png.length > IMAGE_LIMIT) return ok(`${where} (${(png.length / 1048576).toFixed(1)} MB, too large to return inline; open the file or screenshot an element by path)`);
|
|
172
|
+
return { content: [{ type: "image", data: png.toString("base64"), mimeType: "image/png" }, { type: "text", text: where }] };
|
|
173
|
+
},
|
|
84
174
|
);
|
|
85
175
|
|
|
86
|
-
|
|
176
|
+
tool(
|
|
87
177
|
"list_comments",
|
|
88
178
|
{
|
|
89
179
|
description: "List board comments (docs/design/comments.json), optionally for one file or only unresolved ones.",
|
|
@@ -97,22 +187,22 @@ server.registerTool(
|
|
|
97
187
|
},
|
|
98
188
|
);
|
|
99
189
|
|
|
100
|
-
|
|
190
|
+
tool(
|
|
101
191
|
"add_comment",
|
|
102
192
|
{
|
|
103
193
|
description: "Add a comment to a board, or to an element inside it when path is given.",
|
|
104
194
|
inputSchema: { file: z.string(), path: z.string().optional(), text: z.string(), author: z.string().optional() },
|
|
105
195
|
},
|
|
106
|
-
async (args) => ok(await callJson("POST", "/api/comments", { ...args, author: args.author ??
|
|
196
|
+
async (args) => ok(await callJson("POST", "/api/comments", { ...args, author: args.author ?? agent() })),
|
|
107
197
|
);
|
|
108
198
|
|
|
109
|
-
|
|
199
|
+
tool(
|
|
110
200
|
"resolve_comment",
|
|
111
201
|
{ 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
202
|
async ({ id, resolved }) => ok(await callJson("POST", "/api/comments", { action: "resolve", id, resolved: resolved ?? true })),
|
|
113
203
|
);
|
|
114
204
|
|
|
115
|
-
|
|
205
|
+
tool(
|
|
116
206
|
"place_board",
|
|
117
207
|
{
|
|
118
208
|
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.",
|
|
@@ -127,7 +217,7 @@ server.registerTool(
|
|
|
127
217
|
async (args) => ok(await callJson("POST", "/api/place", args)),
|
|
128
218
|
);
|
|
129
219
|
|
|
130
|
-
|
|
220
|
+
tool(
|
|
131
221
|
"list_errors",
|
|
132
222
|
{ 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
223
|
async () => {
|
|
@@ -137,7 +227,7 @@ server.registerTool(
|
|
|
137
227
|
},
|
|
138
228
|
);
|
|
139
229
|
|
|
140
|
-
|
|
230
|
+
tool(
|
|
141
231
|
"create_board",
|
|
142
232
|
{
|
|
143
233
|
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.",
|
|
@@ -155,7 +245,7 @@ server.registerTool(
|
|
|
155
245
|
async (args) => ok(await callJson("POST", "/api/boards/create", args)),
|
|
156
246
|
);
|
|
157
247
|
|
|
158
|
-
|
|
248
|
+
tool(
|
|
159
249
|
"list_notes",
|
|
160
250
|
{ description: "List canvas notes (titles and sticky notes), optionally for one page.", inputSchema: { page: z.string().optional() } },
|
|
161
251
|
async ({ page }) => {
|
|
@@ -165,7 +255,7 @@ server.registerTool(
|
|
|
165
255
|
},
|
|
166
256
|
);
|
|
167
257
|
|
|
168
|
-
|
|
258
|
+
tool(
|
|
169
259
|
"add_note",
|
|
170
260
|
{
|
|
171
261
|
description: "Add a note to the canvas. kind=title (large heading) or sticky (sticky note).",
|
|
@@ -174,7 +264,7 @@ server.registerTool(
|
|
|
174
264
|
async (args) => ok(await callJson("POST", "/api/notes", { action: "add", ...args })),
|
|
175
265
|
);
|
|
176
266
|
|
|
177
|
-
|
|
267
|
+
tool(
|
|
178
268
|
"update_note",
|
|
179
269
|
{
|
|
180
270
|
description: "Edit a note (text, position, width, page, color, size, bold, italic).",
|
|
@@ -194,19 +284,19 @@ server.registerTool(
|
|
|
194
284
|
async (args) => ok(await callJson("POST", "/api/notes", { action: "update", ...args })),
|
|
195
285
|
);
|
|
196
286
|
|
|
197
|
-
|
|
287
|
+
tool(
|
|
198
288
|
"delete_note",
|
|
199
289
|
{ description: "Delete a note (the user can undo it in the app).", inputSchema: { id: z.string() } },
|
|
200
290
|
async ({ id }) => ok(await callJson("POST", "/api/notes", { action: "delete", id })),
|
|
201
291
|
);
|
|
202
292
|
|
|
203
|
-
|
|
293
|
+
tool(
|
|
204
294
|
"list_pages",
|
|
205
295
|
{ description: "List canvas pages (the first page is the default).", inputSchema: {} },
|
|
206
296
|
async () => ok((await callJson("GET", "/api/board")).board.pages),
|
|
207
297
|
);
|
|
208
298
|
|
|
209
|
-
|
|
299
|
+
tool(
|
|
210
300
|
"manage_page",
|
|
211
301
|
{
|
|
212
302
|
description: "Manage pages: add (name), rename (id, name), delete (id; its items move to the first page), move (id, index).",
|
|
@@ -215,7 +305,7 @@ server.registerTool(
|
|
|
215
305
|
async (args) => ok(await callJson("POST", "/api/pages", args)),
|
|
216
306
|
);
|
|
217
307
|
|
|
218
|
-
|
|
308
|
+
tool(
|
|
219
309
|
"get_tokens",
|
|
220
310
|
{
|
|
221
311
|
description:
|
|
@@ -225,7 +315,7 @@ server.registerTool(
|
|
|
225
315
|
async () => ok(await callJson("GET", "/api/tokens?agent=1")),
|
|
226
316
|
);
|
|
227
317
|
|
|
228
|
-
|
|
318
|
+
tool(
|
|
229
319
|
"check_tokens",
|
|
230
320
|
{
|
|
231
321
|
description:
|
|
@@ -235,16 +325,32 @@ server.registerTool(
|
|
|
235
325
|
async ({ file }) => ok(await callJson("GET", `/api/lint${file ? `?f=${encodeURIComponent(file)}` : ""}`)),
|
|
236
326
|
);
|
|
237
327
|
|
|
238
|
-
|
|
328
|
+
tool(
|
|
239
329
|
"reply_comment",
|
|
240
330
|
{ 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 ??
|
|
331
|
+
async (args) => ok(await callJson("POST", "/api/comments", { action: "reply", ...args, author: args.author ?? agent() })),
|
|
242
332
|
);
|
|
243
333
|
|
|
244
|
-
|
|
334
|
+
tool(
|
|
245
335
|
"save_snapshot",
|
|
246
|
-
{
|
|
336
|
+
{
|
|
337
|
+
description: "Save a snapshot (a saved version): commits only the design folder to git, or outside a git repository copies it to .easel/snapshots/. Use only when the user explicitly asks to save.",
|
|
338
|
+
inputSchema: { message: z.string().optional() },
|
|
339
|
+
},
|
|
247
340
|
async ({ message }) => ok(await callJson("POST", "/api/snapshot", { message })),
|
|
248
341
|
);
|
|
249
342
|
|
|
250
343
|
await server.connect(new StdioServerTransport());
|
|
344
|
+
|
|
345
|
+
// The client went away (stdin closed, or we are told to stop): the boards this client was editing are released, then exit
|
|
346
|
+
let leaving = false;
|
|
347
|
+
const leave = async () => {
|
|
348
|
+
if (leaving) return;
|
|
349
|
+
leaving = true;
|
|
350
|
+
if (!permissionOnly && port)
|
|
351
|
+
await fetch(`http://127.0.0.1:${port}/api/boards/release`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client: CLIENT }), signal: AbortSignal.timeout(1000) }).catch(() => {});
|
|
352
|
+
process.exit(0);
|
|
353
|
+
};
|
|
354
|
+
process.stdin.on("end", leave);
|
|
355
|
+
process.stdin.on("close", leave);
|
|
356
|
+
for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"]) process.on(sig, leave);
|