leglas 0.9.0 → 1.0.0

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 CHANGED
@@ -44,7 +44,7 @@ Your app doesn't change to make any of this work. Leglas proxies the same
44
44
  dev server in your project: one config file to delete when you're done
45
45
  and sessions that clean up after themselves.
46
46
 
47
- ## What you can do with Leglas
47
+ ## What it does
48
48
 
49
49
  <p align="center">
50
50
  <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/compare-artboards.jpg" width="900" alt="The Leglas interface: the rail on the left, and two directions running side by side as the real app, each labelled with its name and the width it is drawn at." />
@@ -52,66 +52,30 @@ and sessions that clean up after themselves.
52
52
 
53
53
  <p align="center"><i>Two directions for the same page, running side by side as the actual app.</i></p>
54
54
 
55
- - Pick any two variations for side-by-side comparison when it gets hard to choose.
56
- - Name each direction, drag to reorder and organise your variants, set aside the ones that
57
- don't feel right. Your actions on every idea survive a long exploration.
58
- - Send a teammate the link to a direction. They open the live version instead of a screenshot and a paragraph of explanation.
59
- - Compare things no design tool can hold: 3 git branches, a local
60
- build against production, yesterday's direction against today's, or even 7 different worktrees.
61
- - `leglas init` teaches any coding agent the workflow, and
62
- `leglas explore` briefs an exploration. Five directions can be five
63
- separate ideas, or five variants of the one you already like: you choose
64
- the spread, your agent supplies the taste.
65
- - Ask for changes without leaving the comparison: describe what you
66
- want on the direction you're looking at, and Leglas turns it into a
67
- precise request for your agent, file path included. The composer
68
- carries its own agent picker, the way every chat you already use
69
- carries a model picker: the CLIs found on your machine (Claude Code,
70
- Codex, Cursor) are one click away next to the send button. Leglas checks
71
- your shell path and the conventional per-user install locations, then asks
72
- each CLI for its login status so a signed-out agent says so before a run
73
- instead of failing one. Claude Code and Codex can optionally override effort
74
- for this project, remembered separately for each agent; `Agent default`
75
- leaves the CLI's own setting untouched. To
76
- work from an IDE panel or chat host, choose
77
- "Connect agent via MCP" for the exact setup and a live confirmation
78
- once the agent uses a Leglas tool. Each run
79
- reports in a card above the field: who is working, what file they
80
- are touching, how long it has been, a stop button while it runs and
81
- retry when it fails. Your agent, your subscription, no keys. Claude
82
- Code, Codex and Cursor pick the conversation back up between
83
- requests, so a run after the first goes straight to the change
84
- instead of reading the project again. Claude Code and Codex warm up
85
- while you type and let their process go once you have left Leglas
86
- alone for a few minutes, so an open window is not holding one.
87
- Prefer a terminal? `npx leglas watch` is the same loop with the
88
- agent's own output scrolling by. In Claude Code, the Leglas MCP
89
- server can also push each request straight into your open session as
90
- a channel event (channels are a research preview: start Claude Code
91
- with `--dangerously-load-development-channels
92
- server:<your leglas server name>`).
93
- - A change makes a variant, not a rewrite. Ask for something on the
94
- direction you are looking at and the result registers under it in the
95
- rail, with the original still there to compare against. A chip beside
96
- the send button switches to changing the direction itself, for when a
97
- change really is a fix. Hover any direction to see what it was built
98
- from and the change that was asked for, in the words that were typed.
99
- - Your agent sees what you see. Every change you send carries a screenshot
100
- of the direction at the width you are looking at, a crop of whatever you
101
- pointed at with a note, the other pane when you are comparing, and any
102
- image you pasted into the composer as a reference. Leglas renders them
103
- with a Chrome, Chromium, Brave or Edge already on your machine, nothing
104
- to install; with none found, the request says so and goes anyway. Agents
105
- can look for themselves too: `npx leglas show "Aurora" --screenshot`
106
- writes a PNG of a direction (`--width 390` for the phone layout) and the
107
- MCP `show` tool returns the image. The instructions Leglas writes for
108
- agents ask for one look after each change, so a broken layout gets fixed
109
- before you see it.
110
- - Keep the winner with one command. Leglas moves it into your source
111
- tree and clears the exploration away.
112
- - No app yet or want plain HTML comparisons? Some people want exactly that, and it works fine. Same comparison, no dev server.
113
-
114
- ## Quick start
55
+ - Put any two directions side by side when it gets hard to choose.
56
+ - Name each direction, drag to reorder, set aside the ones that don't feel
57
+ right. Your opinion of every idea survives a long exploration.
58
+ - Share the rail with someone who has no repo: a client, a cofounder, a
59
+ teammate on another machine. They get the real app, in your order, and
60
+ cannot change anything. See [Sharing](#sharing).
61
+ - Compare things no design tool can hold: three git branches, a local build
62
+ against production, yesterday's direction against today's.
63
+ - Hand the workflow to your coding agent. `leglas init` teaches it, and
64
+ `leglas explore` briefs an exploration: five separate ideas, or five
65
+ variants of the one you already like. You choose the spread; your agent
66
+ supplies the taste.
67
+ - Ask for changes without leaving the comparison. Describe what you want on
68
+ the direction you are looking at, or point at it, and Leglas turns that
69
+ into a precise request for your agent, file path and screenshots
70
+ included. The agents on your machine are one click away next to the send
71
+ button. Your agent, your subscription, no keys.
72
+ - A change makes a variant, not a rewrite. The result registers under the
73
+ direction it came from, with the original still there to compare against.
74
+ - Keep the winner with one command. Leglas moves it into your source tree,
75
+ writes down what the exploration decided and clears the rest away.
76
+ - No app yet? Plain HTML files compare the same way, no dev server needed.
77
+
78
+ ## Get started
115
79
 
116
80
  Start your dev server, then run Leglas from the project directory:
117
81
 
@@ -119,194 +83,162 @@ Start your dev server, then run Leglas from the project directory:
119
83
  npx leglas
120
84
  ```
121
85
 
122
- Leglas starts on port 4100, proxies your app, and opens
86
+ Leglas starts on port 4100, proxies your app and opens
123
87
  `http://localhost:4100/leglas`. With no configuration you get a single
124
- preview of your app root. Add a config file to compare more than one thing.
125
- If that port turns out to be served from outside your project, Leglas
126
- says so and points at `devServer` and `--user-port` rather than quietly
127
- proxying the wrong app.
88
+ preview of your app root; a config file, described under
89
+ [Configuration](#configuration), is how you get more than one thing to
90
+ compare.
91
+ If that port turns out to be served from outside your project, Leglas says
92
+ so and points at `devServer` and `--user-port` rather than quietly proxying
93
+ the wrong app.
94
+
95
+ It works with whatever you are building in. Leglas never imports or
96
+ executes your framework, so the target can be Next, Vite, Remix, SvelteKit,
97
+ Astro or a folder of static files. It needs Node 24 or newer, and nothing
98
+ else: `npx` fetches the CLI on first use and starts from the cache after
99
+ that. To pin a version for a project, `npm install -D leglas`; to type
100
+ `leglas` without the prefix, `npm install -g leglas`.
101
+
102
+ ## Using Leglas
103
+
104
+ ### The rail and the stage
105
+
106
+ Directions live in a rail on the left. The stage shows the active one in a
107
+ framed viewport at Full, 1440, 834 or 390 wide. Rename, reorder, hide and
108
+ tag directions from the rail; open the removed list to restore one, delete
109
+ it for good or clear the list. Your layout is saved per project and
110
+ survives restarts.
128
111
 
129
- It works with whatever you're building in. Leglas never imports or
130
- executes your framework, so the target can be Next, Vite, Remix,
131
- SvelteKit, Astro, or a folder of static files.
112
+ A small tools widget floats over the stage and can be dragged to any
113
+ corner. Its popover holds the viewport presets and a few preferences,
114
+ including hiding the dev badge your framework paints over the corner of
115
+ the app when it lands on the part you are judging.
132
116
 
133
- ## Install
117
+ ### Comparing
134
118
 
135
- There is nothing you have to install: `npx leglas` fetches the CLI on
136
- first use and starts from npm's cache after that, and every instruction
137
- Leglas writes for agents uses the same form, so a fresh clone works
138
- with no setup at all. Requires Node 24 or newer.
119
+ Flipping shows a difference over time. A split shows it at once, which is
120
+ what you want for the last two in contention: press `C`, or hover a
121
+ direction and press its compare button, and it becomes the right pane
122
+ while the active direction holds the left.
123
+
124
+ Each side is drawn at the width it had on its own and scaled to fit, so
125
+ nothing reflows and flipping and splitting agree about what the design is.
126
+ An app given half the room would cross its own breakpoints and draw a
127
+ different design. If the narrow rendering is what you want, the tools
128
+ popover's "Scale each side to fit" switch is for that.
129
+
130
+ ### Asking for a change
131
+
132
+ Type what you want into the field under the rail, or press `R`, and Leglas
133
+ composes a request naming the direction and the file behind it, copies it
134
+ to your clipboard and queues it. The direction it means is the one
135
+ highlighted directly above the field. By default the request asks for a
136
+ new variant beside that direction; the chip next to the send button
137
+ switches it to a change in place, for when a change really is a fix.
138
+
139
+ Pick an agent once from the picker beside the send button and the card
140
+ above the field shows it working: which file it is editing, how long it
141
+ has been, a stop if you change your mind, a retry when a run goes wrong.
142
+ Every request carries a screenshot of the direction at the width you are
143
+ looking at, a crop of anything you pointed at, the other pane when you are
144
+ comparing and any image you pasted in as a reference. Leglas runs no model
145
+ of its own; your agent already knows your conventions and your taste.
139
146
 
140
- Two optional upgrades:
147
+ <p align="center">
148
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-idle.png" width="290" alt="The change field, empty, with its agent picker reading Choose an agent" />
149
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-queued.png" width="290" alt="A card above the change field reading: Change queued, pick who runs your changes" />
150
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-pickedup.png" width="290" alt="A card above the change field reading: Codex is on it, editing .leglas/variants/hero/poster.tsx, 56s, with a stop button" />
151
+ </p>
141
152
 
142
- - `npm install -D leglas` pins the version in a project. Teammates and
143
- CI get the same Leglas from their normal install, and `npx` resolves
144
- the local copy from then on.
145
- - `npm install -g leglas` is for typing `leglas` without the prefix.
153
+ <p align="center"><i>Nothing waiting, then a request queued, then an agent that has taken it.</i></p>
146
154
 
147
- ## Working with coding agents
155
+ Hover any direction to see what it was built from and the change that was
156
+ asked for, in the words that were typed.
148
157
 
149
- The fastest way in is the agent skill:
158
+ ### Pointing at the problem
150
159
 
151
- ```sh
152
- npx skills add FredAmartey/leglas
153
- ```
160
+ Most of what you would type is the part describing where the problem is,
161
+ so point at it instead. Press `A` and the preview becomes a picker:
162
+ hovering outlines the element under the pointer, clicking drops a numbered
163
+ pin that takes a note, and dragging marks an area and names every element
164
+ inside it. Click a pin again to reread it, reword it or drop it. The page
165
+ still scrolls, so the thing three screens down is as easy to mark as the
166
+ headline.
154
167
 
155
- One install, and your agent recognises "give me a few directions for the
156
- pricing page" as a Leglas exploration in any project, including ones
157
- that have never seen Leglas. It sets the project up itself and gets to
158
- work.
159
-
160
- In a project, run `npx leglas init` once. It writes a section into your
161
- project's `AGENTS.md`, creates a starter config, and gitignores Leglas's
162
- working directory. That section travels with the repo, so Claude Code,
163
- Cursor, Codex, or whatever you switch to next opens the project already
164
- knowing how to add design directions to it. Every command accepts
165
- `--json` and prints a single machine-readable envelope, so agents drive
166
- the same CLI you do.
168
+ Annotations are a request on their own, so the field can stay empty: leave
169
+ three and send once. Each carries the element's own words, its tag and
170
+ classes, a path and the box it filled, and tells your agent which of those
171
+ to trust first, because the design moves under them by design. A pin whose
172
+ element has since gone turns amber rather than pointing confidently at the
173
+ wrong thing.
167
174
 
168
- The instructions center on one rule: add beside what exists, never
169
- rewrite it. Two directions that rewrite the same file cannot render from
170
- one server, and asking an agent to "make the hero calmer" tempts it to
171
- edit the hero. The supporting commands:
172
-
173
- - `npx leglas explore hero --count 6` briefs the exploration: what the set
174
- is for, why it only works if the six genuinely disagree, and how each
175
- direction registers. Unbriefed, six requests come back as six variants
176
- of one idea. With `--based-on "Aurora"` the goal flips: six deliberate
177
- variants of a direction you already like, and drifting into a new
178
- direction is the failure. The designs themselves are the agent's;
179
- Leglas prescribes none.
180
- - `npx leglas new hero --from src/Hero.tsx` scaffolds a switcher under
181
- `.leglas/variants/hero/`. With `--from`, the baseline re-exports your
182
- real component, so you never compare against a stale copy. Leglas
183
- prints the one line to add in your component and does not edit it,
184
- because rewriting a file it does not understand is how a tool breaks a
185
- codebase. Scaffolded branch points return the fallback in production
186
- builds, so a committed one cannot expose an unreleased direction.
187
- - `npx leglas classify --change package.json --rewrite src/theme.css` answers
188
- where a direction should live before it is written. Changing
189
- dependencies, build configuration, or an existing file's behaviour
190
- cannot be additive, so those directions build on their own git branch
191
- and register with `leglas add --branch`. Everything else stays in-app,
192
- where switching is instant.
193
- - `npx leglas show "Aurora" --json` answers for one direction: its entry, the
194
- source file behind it, the variants based on it, what it is being compared
195
- against, and anything still pending on it. Add `--screenshot` and it
196
- renders the direction too, so an agent can look at what it built. Copying
197
- a direction from the rail hands over a block that ends in this command, so
198
- an agent given the block can go and get the rest.
199
- - `npx leglas keep "Aurora" --to src/components/hero.tsx` moves the winner
200
- into real source and ends the exploration. It also writes down what the
201
- exploration was, into `design-log/`: every direction with its note, the words
202
- you typed at each of them, the captures the agent was sent, and which one
203
- won. Plain markdown and PNGs, committed, so a pull request can link it and
204
- somebody can read it in three months without this tool. Exploring is
205
- episodic, and the archive is what makes coming back to a surface cheaper than
206
- starting over. `npx leglas log` lists what is there. Set `logDir` if you want
207
- it somewhere else.
208
-
209
- Asking for a change works from the interface too. Type what you want
210
- changed into the field under the rail (or press `R`) and Leglas composes a
211
- prompt naming the direction and the file behind it, copies it to your
212
- clipboard, and queues it. The direction it means is the one highlighted
213
- directly above the field. By default the request asks for a new variant
214
- beside that direction; the chip next to the send button switches it to a
215
- change in place. Your agent drains the queue with `npx leglas requests --json` and clears
216
- it with `--clear`. Leglas runs no model of its own; your agent already
217
- knows your conventions and your taste.
218
-
219
- Most of what you would type into that field is the part describing where
220
- the problem is, so you can point at it instead. Press `A` and the preview
221
- becomes a picker: hovering outlines the element under the pointer,
222
- clicking drops a numbered pin that takes a note, and dragging marks an
223
- area and names every element inside it. Click a pin again to reread what
224
- it says, reword it or drop it. The page still scrolls, so the thing three
225
- screens down is as easy to mark as the headline. Annotations
226
- are a request on their own, so the field can stay empty; leave three and
227
- send once. Each one carries the element's own words, its tag and classes,
228
- a path and the box it filled, and the request tells your agent which of
229
- those to trust first, because the design moves under them by design. One
230
- whose element has since gone turns amber rather than pointing confidently
231
- at the wrong thing, and one already sent with a change takes a ring until
232
- that change settles.
233
-
234
- The card above the field is the whole status: what you have queued, who
235
- has taken it and for how long, and what went wrong when a run fails.
175
+ ### Sharing
176
+
177
+ The rail is local, and the person who most needs to see it often has no
178
+ repo. The share control in the rail's header fixes that: pick the whole rail
179
+ as you see it, or what is on stage (one direction, or the pair being
180
+ compared), and start sharing. Leglas opens a second listener on your
181
+ machine, points a tunnel at it and copies the link once it answers.
236
182
 
237
183
  <p align="center">
238
- <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-idle.png" width="290" alt="The change field, empty, with its agent picker reading Choose an agent" />
239
- <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-queued.png" width="290" alt="A card above the change field reading: Change queued, pick who runs your changes" />
240
- <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/field-pickedup.png" width="290" alt="A card above the change field reading: Codex is on it, editing .leglas/variants/hero/poster.tsx, 56s, with a stop button" />
184
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/share-links.png" width="426" alt="The share panel under the rail's header while sharing: the tunnel address, two links named Link 1 and Client review each with 24h left, the hovered row showing copy, extend and turn off, Another link, the scope line reading The whole rail, 6 directions, only what you shared, then Replace all and Stop" />
185
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/share-viewer.png" width="426" alt="The same rail as a viewer sees it: a strip reading Shared with you, the whole rail, then the directions in the sharer's order with no composer" />
241
186
  </p>
242
187
 
243
- <p align="center"><i>Nothing waiting, then a request queued, then an agent that has taken it.</i></p>
244
-
245
- Pick an agent once and the same card shows it working: which file it is
246
- editing, a stop if you change your mind, a retry when a run goes
247
- wrong. `npx leglas watch` in another terminal is the same loop with the
248
- agent's own output in view, and it needs no flag once an agent has been
249
- picked in the interface.
250
-
251
- To use a CLI that is not in the picker, keep the custom command explicit
252
- in the terminal:
188
+ <p align="center"><i>Sharing, and what the person on the other end gets.</i></p>
189
+
190
+ Whoever opens the link gets the real app, running, with your order, your
191
+ names, your folded families and your viewport. They can flip, compare,
192
+ search and change the width. They cannot change anything: the share
193
+ listener refuses every write, whoever the caller is, and answers every path
194
+ with 403 without the cookie the link sets, so your dev server never faces
195
+ the internet bare. Viewers do not get hot reload either, since an app's
196
+ live-reload socket is a way in; they refresh to see a change.
197
+
198
+ What a viewer can do is read what your dev server serves, and you choose
199
+ how much of it. **Anywhere in the app** is the whole dev server over GET,
200
+ source included, because Leglas proxies it faithfully and that is the
201
+ point; it suits a demo. **Only what you shared** serves the pages you shared
202
+ and the files they load, refuses the rest before the dev server hears of it
203
+ and holds against a console or curl as well as a browser. The list is read
204
+ off what your own directions loaded while you looked at them, not written
205
+ by hand, and anything it did not predict shows up in the panel with one
206
+ click to let that path or its folder through. Bounded still means a viewer
207
+ sees everything your shared pages themselves load. Either way Leglas
208
+ refuses the routes a dev server mounts to act on your machine, Vite's
209
+ editor launcher among them, hidden files like `.env` however the path is
210
+ spelled and a service worker that would outlive the share.
253
211
 
254
- ```sh
255
- npx leglas watch --run "my-agent {prompt}"
256
- ```
212
+ <p align="center">
213
+ <img src="https://raw.githubusercontent.com/FredAmartey/leglas/main/.github/assets/screenshots/share-reach.png" width="426" alt="The share panel before starting: The whole rail, 6 directions, 2 on branches left out; The direction on stage, Table; How far they can go: Anywhere in the app, Your whole dev server over GET; Only what you shared, These pages and the 22 files they loaded; a Start sharing button" />
214
+ </p>
257
215
 
258
- ### MCP server
216
+ <p align="center"><i>Choosing what to share, and how far a viewer goes.</i></p>
259
217
 
260
- For agent hosts that cannot run shell commands, `leglas-mcp` exposes the
261
- same operations as MCP tools over stdio: `start`, `add`, `list`, `show`,
262
- `classify`, `explore`, `scaffold`, `keep`, `requests`, and `init`. Each
263
- tool calls exactly what the CLI calls and returns the same envelope.
264
- `watch` is the one command with no tool behind it: it is a loop that
265
- holds a terminal open, and on a host that speaks channels the server
266
- already pushes each request into the session as it arrives.
218
+ A share hands out links rather than a link. Name one for each person, up
219
+ to sixteen; each lasts a day, extends by another with one click and turns
220
+ off on its own without touching the others. The panel shows which links
221
+ are answering and how many sessions are on each. When your rail has moved
222
+ since you shared, it offers to push what you see now; stop the share from
223
+ the same place, and it stops with Leglas either way.
267
224
 
268
- ```sh
269
- claude mcp add leglas -- npx -y leglas-mcp
270
- ```
225
+ The tunnel is borrowed, not shipped. Leglas looks for `cloudflared` or
226
+ `ngrok` on your machine and runs whichever it finds; with neither, the link
227
+ only works on this machine and the panel says so. Branch directions run on
228
+ their own port and are left out of a share for now.
271
229
 
272
- Or in `.mcp.json`:
230
+ ### Keys
273
231
 
274
- ```json
275
- { "mcpServers": { "leglas": { "command": "npx", "args": ["-y", "leglas-mcp"] } } }
276
- ```
232
+ Arrows move between directions and `1` to `9` jump straight to one. `R`
233
+ asks for a change, `A` annotates, `C` compares, `Cmd K` (`Ctrl K`
234
+ elsewhere) searches, `T` opens the tools popover and `B` collapses the
235
+ rail. Press `?` for the whole keymap.
277
236
 
278
- The host's working directory names the project, the same contract as the
279
- CLI. A host that starts the server somewhere else is asked where the
280
- project is, over MCP roots. The `start` tool boots the viewer and returns
281
- its URL, and anything it started stops when the session ends.
237
+ ## Setting up a project
282
238
 
283
- ### As an Agent Plugin
239
+ ### Configuration
284
240
 
285
- The repository is also an [Agent Plugin](https://agent-plugins.org), the
286
- open standard for shipping Agent Skills and MCP server configuration in
287
- one format. Clients that implement it install the skill and the server
288
- together, instead of the two steps above. It is a layout rather than a
289
- build: `plugin.json` and `mcp.json` at the root, the skill in
290
- `skills/leglas/`, nothing generated.
291
-
292
- An Agent Plugins client starts a plugin's server in the plugin's own
293
- install directory rather than the project, so on that path the working
294
- directory names a copy of Leglas and nothing else. The server therefore
295
- takes the project from the workspace the host declares over MCP roots,
296
- and the working directory only when it sits inside one. If a host offers
297
- neither, `LEGLAS_PROJECT_DIR` names the project outright; without it the
298
- tools report that there is no project rather than writing into a plugin
299
- cache. `mcp.json` passes `${PLUGIN_ROOT}` for exactly that check, and
300
- nothing else.
301
-
302
- The plugin's version covers the skill and the configuration, not the
303
- server it launches: `npx` fetches the current `leglas-mcp` the same way
304
- every `npx leglas` in these instructions fetches the current CLI, which
305
- keeps both faces of Leglas on one version in a project they share.
306
-
307
- ## Configuration
308
-
309
- Create `leglas.config.ts` at the project root. `.js`, `.mjs`, and `.json`
241
+ Create `leglas.config.ts` at the project root. `.js`, `.mjs` and `.json`
310
242
  work too. Resolution walks upward from the working directory, so in a
311
243
  monorepo the nearest file wins. Node reads the TypeScript config natively;
312
244
  there is no compiler or extra dependency involved.
@@ -346,129 +278,18 @@ A broken config never stops the server. Leglas starts anyway and the
346
278
  interface reports what to fix, so you are not hunting through a stack
347
279
  trace.
348
280
 
349
- ## The interface
350
-
351
- Directions live in a rail on the left. The stage shows the active one in
352
- a framed viewport at Full, 1440, 834 or 390 wide. Rename, reorder, hide
353
- and tag directions from the rail. Open the removed list to restore a
354
- direction, delete one permanently or clear the full list. Machine-local
355
- directions are removed from `.leglas/previews.json`; shared project config
356
- and preview source files stay untouched. Layout is saved per project and
357
- survives restarts and port changes.
358
-
359
- Flipping shows a difference over time. A split shows it at once, which is
360
- what you want for the last two directions in contention: press `C`, or
361
- hover a direction and press its compare button, and it becomes the right
362
- pane while the active direction holds the left.
363
-
364
- A split does not hand each side half the room. An app given half the room
365
- crosses its own breakpoints and draws a different design, so you would be
366
- choosing between two narrow renderings of directions meant for the wide
367
- one. Instead each side is drawn at the width it had on its own and scaled
368
- to fit, keeping the same proportions, so nothing reflows and flipping and
369
- splitting agree about what the design is. Each pane says the width it is
370
- drawn at and the scale it is shown at. If you want the narrow rendering,
371
- that is what the tools popover's "Scale each side to fit" switch is for.
372
-
373
- Arrows move between directions, `1` to `9` jump straight to one, `R` asks
374
- for a change to the one you are on, `A` annotates the design itself,
375
- `Cmd K` (`Ctrl K` elsewhere) searches, `T` opens the tools popover and `B`
376
- collapses the rail. Press `?` for the whole keymap.
377
-
378
- A small tools widget floats over the stage and can be dragged to any
379
- corner, because a floating control has a habit of sitting exactly where
380
- you need to look. Its popover holds the viewport presets and a few
381
- preferences.
382
-
383
- Frameworks paint a dev badge over the corner of the running app. It
384
- belongs to your app, so Leglas leaves it alone; when it lands on the part
385
- you are judging, the popover hides it, and does that by styling inside
386
- the preview frame, never by altering what the proxy forwards.
387
-
388
- ## Command line
389
-
390
- ```text
391
- Usage
392
- leglas init Prepare a project and teach its agents
393
- leglas [options] Start the server and open the interface
394
- leglas new <surface> Scaffold a branch point for a surface
395
- leglas explore <surface> Brief an agent's exploration of a surface
396
- leglas classify Decide where a direction should live
397
- leglas add --title T --url U Register a preview on this machine
398
- leglas list Show every preview, shared and local
399
- leglas log [entry] What past explorations decided
400
- leglas show <title> Everything Leglas knows about one direction
401
- leglas requests Show change requests made from the interface
402
- leglas watch --run "<cmd>" Hand each request to your agent as it arrives
403
- leglas keep <title> --to <path> Keep a winner and end the exploration
404
-
405
- Options
406
- --user-port <port> Port your dev server is on (default: from config, or 3000)
407
- --port <port> Port for Leglas itself (default: 4100, next free if taken)
408
- --config <path> Config file to use instead of searching upward
409
- --no-open Do not open the browser
410
- --json Print a single machine-readable envelope
411
- -h, --help Show this
412
- -v, --version Show the version
413
-
414
- Options for new
415
- --print Print the scaffold instead of writing it
416
- --from <path> Use an existing component as the baseline
417
-
418
- Options for explore
419
- --count <n> How many directions (default 3)
420
- --based-on <title> Variants of an existing direction instead of new ones
421
-
422
- Options for watch
423
- --run <command> Your agent, with {prompt} where the request goes, for
424
- example "claude -p {prompt}". Remembered after first use
425
- --port <port> Port Leglas itself is on (default: 4100)
426
-
427
- Options for classify
428
- --change <path> A file the direction creates or wires up (repeatable)
429
- --rewrite <path> An existing file whose behaviour it must change (repeatable)
430
-
431
- Options for add
432
- --note <text> Second line under the title
433
- --tag <text> Repeatable
434
- --branch <name> Back the preview with a checkout of this git branch
435
- --file <path> Preview a plain HTML file served by Leglas itself
436
- --based-on <title> The direction this is a variant of; groups the family
437
- --asked-for <text> The change that was asked for, in the words that were typed
438
-
439
- Options for show
440
- --screenshot Render the direction and write a PNG
441
- --width <n> Capture width from 320 to 3840 (needs --screenshot)
442
- --port <port> Running Leglas port (needs --screenshot)
443
- ```
444
-
445
- `leglas.config.ts` is the shared description of a project: commit it and a
281
+ The config is the shared description of a project: commit it and a
446
282
  teammate gets the same directions on clone. `leglas add` registers a
447
283
  preview on your machine only, in `.leglas/previews.json`, because
448
- exploration is short-lived and its code lives in a gitignored directory.
449
- `leglas list` shows both and marks which are local.
450
-
451
- Renaming a direction in the rail is local in the same way, recorded in
452
- `.leglas/renames.json`. Leglas will not edit your config to rename
453
- something you only renamed for yourself, so the config title stays the
454
- one a teammate sees, and `leglas show` and `leglas keep` take either
455
- name.
456
-
457
- ## Comparing branches
458
-
459
- A preview with a `branch` field is served from its own checkout: Leglas
460
- creates a worktree, installs, starts the app with your `devCommand` on a
461
- free port, and tears it all down when you quit. In the interface it looks
462
- like any other direction, so a branch against your working tree, or three
463
- branches against each other, compares the same way two query parameters
464
- do.
465
-
466
- ## Without a dev server
284
+ exploration is short-lived and its code lives in a gitignored directory;
285
+ `leglas list` shows both and marks which are local. Renaming a direction
286
+ in the rail is local in the same way, so the config title stays the one a
287
+ teammate sees, and `leglas show` and `leglas keep` take either name.
467
288
 
468
- Leglas does not require a running app.
289
+ ### Without a dev server
469
290
 
470
291
  If the project exists but nothing is listening, set `devCommand` and
471
- Leglas starts your app itself, proxies it, and stops it on exit. When
292
+ Leglas starts your app itself, proxies it and stops it on exit. When
472
293
  `--user-port` names a server explicitly, Leglas never starts a different
473
294
  one behind that flag.
474
295
 
@@ -489,7 +310,16 @@ the lone file, so stylesheets and images beside it resolve. When the real
489
310
  app arrives, directions graduate to app code and nothing about the
490
311
  interface changes.
491
312
 
492
- ## How it works
313
+ ### Comparing branches
314
+
315
+ A preview with a `branch` field is served from its own checkout: Leglas
316
+ creates a worktree, installs, starts the app with your `devCommand` on a
317
+ free port and tears it all down when you quit. In the interface it looks
318
+ like any other direction, so a branch against your working tree, or three
319
+ branches against each other, compares the same way two query parameters
320
+ do.
321
+
322
+ ### How it works
493
323
 
494
324
  Leglas runs one local server that serves the interface at `/leglas` and
495
325
  forwards every other request to your dev server. Previews load through
@@ -503,7 +333,7 @@ app behaves differently through Leglas than on its own port, that is a
503
333
  bug.
504
334
 
505
335
  Because a preview is a URL, the same interface compares two routes, two
506
- implementations behind a query parameter, or a local server against a
336
+ implementations behind a query parameter or a local server against a
507
337
  deployed one. Absolute URLs load directly rather than through the proxy,
508
338
  so a site that refuses to be framed will not preview; the interface says
509
339
  so instead of showing an empty pane.
@@ -511,10 +341,10 @@ so instead of showing an empty pane.
511
341
  Leglas also compares what each preview actually draws and warns when two
512
342
  are identical. This catches a typo like `?v-hero=wavee` that your app
513
343
  silently ignores while the rail implies a comparison. The check reads the
514
- rendered page, runs only on previews you have opened, and skips
344
+ rendered page, runs only on previews you have opened and skips
515
345
  cross-origin previews, which the browser will not let it read.
516
346
 
517
- ## Limitations
347
+ ### Limitations
518
348
 
519
349
  - Leglas runs no model of its own. Comparing existing routes costs
520
350
  nothing, but a new direction is still code your agent writes; Leglas
@@ -526,43 +356,125 @@ cross-origin previews, which the browser will not let it read.
526
356
  - The interface is built for desktop widths.
527
357
  - Leglas is a development tool. Nothing in it ships to production.
528
358
 
529
- ## Development
359
+ ## Working with agents
360
+
361
+ The fastest way in is the agent skill:
362
+
363
+ ```sh
364
+ npx skills add FredAmartey/leglas
365
+ ```
366
+
367
+ One install, and your agent recognises "give me a few directions for the
368
+ pricing page" as a Leglas exploration in any project, including ones that
369
+ have never seen Leglas. It sets the project up itself and gets to work.
370
+
371
+ In a project, `npx leglas init` writes a section into `AGENTS.md`, creates
372
+ a starter config and gitignores Leglas's working directory. That section
373
+ is the agent's whole workflow, and it travels with the repo, so Claude
374
+ Code, Cursor, Codex or whatever you switch to next opens the project
375
+ already knowing how to add design directions to it. Every command accepts
376
+ `--json` and prints a single machine-readable envelope, so agents drive
377
+ the same CLI you do.
378
+
379
+ ### Add beside, never rewrite
380
+
381
+ The instructions center on one rule. Two directions that rewrite the same
382
+ file cannot render from one server, and asking an agent to "make the hero
383
+ calmer" tempts it to edit the hero. So a direction is added next to what
384
+ exists: a switcher scaffolded beside your component, a query parameter
385
+ that selects it, and your real component untouched as the baseline.
386
+ Anything that cannot be additive, a dependency, a build change, an
387
+ existing file's behaviour, builds on its own git branch instead.
388
+
389
+ ### What an agent runs
390
+
391
+ | Command | What it does |
392
+ | --- | --- |
393
+ | `leglas explore <surface> --count 6` | Briefs the exploration: what the set is for, and why it only works if the six genuinely disagree. `--based-on "Aurora"` flips it to six deliberate variants of one you like. The designs are the agent's; Leglas prescribes none. |
394
+ | `leglas new <surface> --from src/Hero.tsx` | Scaffolds a switcher under `.leglas/variants/`, with the baseline re-exporting your real component. Prints the one line to add and does not edit your file. Scaffolded branch points return the fallback in production builds. |
395
+ | `leglas classify --change … --rewrite …` | Says where a direction should live before it is written: in-app, where switching is instant, or on its own branch. |
396
+ | `leglas add --title … --url …` | Registers a direction on this machine. |
397
+ | `leglas show "Aurora" --json` | Everything about one direction: its entry, the file behind it, its variants, what it is compared against, what is pending. `--screenshot` renders it too, so an agent can look at what it built. |
398
+ | `leglas requests --json` | The change requests queued from the interface; `--clear` acknowledges them. |
399
+ | `leglas keep "Aurora" --to src/components/hero.tsx` | Moves the winner into real source and ends the exploration, writing what it decided into `design-log/` as markdown and PNGs. `leglas log` lists what is there. |
400
+
401
+ ### Running requests
402
+
403
+ Requests made from the interface wait in a queue. An agent picked in the
404
+ interface drains it on its own. In a terminal, `npx leglas watch` is the
405
+ same loop with the agent's own output in view, and needs no flag once an
406
+ agent has been picked; for a CLI that is not in the picker, keep the
407
+ command explicit:
408
+
409
+ ```sh
410
+ npx leglas watch --run "my-agent {prompt}"
411
+ ```
412
+
413
+ ### MCP server
530
414
 
531
- This repository is a pnpm workspace.
415
+ For agent hosts that cannot run shell commands, `leglas-mcp` exposes the
416
+ same operations as MCP tools over stdio: `start`, `add`, `list`, `show`,
417
+ `classify`, `explore`, `scaffold`, `keep`, `requests` and `init`. Each
418
+ tool calls exactly what the CLI calls and returns the same envelope. The
419
+ `start` tool boots the viewer and returns its URL, and anything it started
420
+ stops when the session ends.
532
421
 
533
422
  ```sh
534
- pnpm install
535
- pnpm build # build every package
536
- pnpm test # run the test suite
537
- pnpm typecheck # type check every package
538
- pnpm site # build the site, homepage and changelog, into dist/site
423
+ claude mcp add leglas -- npx -y leglas-mcp
539
424
  ```
540
425
 
541
- | Package | Contents |
542
- | ----------------- | -------------------------------------------------- |
543
- | `packages/server` | Config loading, the proxy, and the local server |
544
- | `packages/shell` | The interface, a React application built with Vite |
545
- | `packages/cli` | The `leglas` binary |
546
- | `packages/mcp` | The `leglas-mcp` stdio server for agent hosts |
547
-
548
- To work on the interface with live reload, run a Leglas server in one
549
- terminal and `pnpm --filter @leglas/shell dev` in another.
550
-
551
- Two packages are published, both unscoped: `leglas`, which bundles the
552
- server and the built interface, and `leglas-mcp`. Releases are
553
- tag-driven: set the same version in both packages and `plugin.json`, turn
554
- the changelog's Unreleased section into that version with a title for what
555
- the release was about, push a `v<version>` tag, and CI runs the suite and
556
- publishes through npm trusted publishing. A tag that disagrees with the
557
- manifests is refused, and so is a patch tag when `api-surface.txt` has
558
- moved since the previous one. No npm token exists anywhere in the project.
559
-
560
- The [site](https://leglas.vercel.app/) is two pages, the homepage and the
561
- [changelog](https://leglas.vercel.app/changelog/), written by `site.ts`. The
562
- changelog page is made from `CHANGELOG.md` and nothing else, so describing a
563
- release in the changelog is the whole job. Vercel builds it from
564
- `vercel.json` on every push, so main is the live site and every pull request
565
- gets a preview.
426
+ Or in `.mcp.json`:
427
+
428
+ ```json
429
+ { "mcpServers": { "leglas": { "command": "npx", "args": ["-y", "leglas-mcp"] } } }
430
+ ```
431
+
432
+ The host's working directory names the project, the same contract as the
433
+ CLI. A host that starts the server somewhere else is asked where the
434
+ project is, over MCP roots. On a host that speaks channels, the server
435
+ pushes each request into the session as it arrives.
436
+
437
+ ### Agent Plugin
438
+
439
+ The repository is also an [Agent Plugin](https://agent-plugins.org), the
440
+ open standard for shipping a skill and MCP configuration together, so a
441
+ client that implements it installs both in one step. It is a layout, not a
442
+ build: `plugin.json` and `mcp.json` at the root, the skill in
443
+ `skills/leglas/`. Such a client starts the server in the plugin's own
444
+ directory, so the project is taken from the workspace the host declares
445
+ over MCP roots, or from `LEGLAS_PROJECT_DIR` when it declares none. The
446
+ plugin's version covers the skill and the configuration; the server it
447
+ launches is whatever `npx` fetches, the same as every command above.
448
+
449
+ ## Command line
450
+
451
+ ```text
452
+ leglas init Prepare a project and teach its agents
453
+ leglas [options] Start the server and open the interface
454
+ leglas new <surface> Scaffold a branch point for a surface
455
+ leglas explore <surface> Brief an agent's exploration of a surface
456
+ leglas classify Decide where a direction should live
457
+ leglas add --title T --url U Register a preview on this machine
458
+ leglas list Show every preview, shared and local
459
+ leglas log [entry] What past explorations decided
460
+ leglas show <title> Everything Leglas knows about one direction
461
+ leglas requests Show change requests made from the interface
462
+ leglas watch --run "<cmd>" Hand each request to your agent as it arrives
463
+ leglas keep <title> --to <path> Keep a winner and end the exploration
464
+ ```
465
+
466
+ `--json` on any command prints a single machine-readable envelope.
467
+ `--port` chooses Leglas's own port and `--user-port` your dev server's;
468
+ `--config` names a config file instead of searching upward. Every
469
+ command's options are under `leglas <command> --help`.
470
+
471
+ ## Development
472
+
473
+ This repository is a pnpm workspace: `pnpm install`, then `pnpm build`,
474
+ `pnpm test` and `pnpm typecheck`. Two packages are published, `leglas` and
475
+ `leglas-mcp`, and the repository is also the Agent Plugin. How to work on
476
+ it, what a pull request needs and how a release is cut are in
477
+ [CONTRIBUTING.md](CONTRIBUTING.md).
566
478
 
567
479
  ## License
568
480