@useonsite/vite 0.1.1 → 0.1.2

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
@@ -69,7 +69,42 @@ The chat is one round box. Its buttons show only an icon: takes, **Pin as commen
69
69
 
70
70
  The quick chat sits just under the element, or above it when there is no room below. With two or more elements, or a comment you added to the ask, their chips ride on a tab that joins the element's outline. Choose × on a chip to leave it out.
71
71
 
72
- A frame on the element shows each step while the agent works. For more room, open the quick chat in the full chat with <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>⇧ Shift</kbd> + <kbd>Enter</kbd>, or tap <kbd>⌥</kbd> twice. Your draft and selection come along. <kbd>Esc</kbd> or a click outside closes the quick chat; the draft stays. With the panel open, <kbd>⌥</kbd>-click adds elements to the panel.
72
+ A frame on the element carries the ask's bar from the moment you send it (see [Look at each take as it lands](#look-at-each-take-as-it-lands)). For more room, open the quick chat in the full chat with <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>⇧ Shift</kbd> + <kbd>Enter</kbd>, or tap <kbd>⌥</kbd> twice. Your draft and selection come along. <kbd>Esc</kbd> or a click outside closes the quick chat; the draft stays. With the panel open, <kbd>⌥</kbd>-click adds elements to the panel.
73
+
74
+ ### The panel
75
+
76
+ The panel shows the thread: your asks, the agent's replies, and the take bar over the chat. Its header is one row of icons:
77
+
78
+ - **Select** (the cursor): click elements to mention them, as <kbd>⌥</kbd>-click does.
79
+ - **Changes** (the dashed square): outline what the takes changed, as holding <kbd>⌥</kbd> does.
80
+ - **⋯**: the Onsite menu, with **Changes** and **Export**. It opens over the panel; the panel stays open.
81
+ - **Close** (the arrow down).
82
+
83
+ The panel keeps one height, so its header stays in place while the thread grows and when you switch views. Point at an icon, or move to it with <kbd>Tab</kbd>, to see its name and keys. Drag the empty part of the header to move the panel. **Changes** and **Export** from the menu open over the thread; the back arrow or <kbd>Esc</kbd> goes back to it. The menu's **Changes** item shows how many files and comments there are. The scheme (Auto, Light or Dark), the working animation and the motion are in the menu, under **Settings** (see [While the agent works](#while-the-agent-works)).
84
+
85
+ ### Messages
86
+
87
+ Onsite tells you what it did in a short message, such as "Kept Take 1 · 1 file" with **Undo**. The Onsite button stretches into a pill that holds the message, with the logo at its end, and the pill folds back into the button after 4 seconds. The button stays where it is.
88
+
89
+ - Point at the message, or move the focus into it, and it stays until you leave it.
90
+ - A long message takes two lines at most and then ends with "…". A screen reader reads all of it.
91
+ - A new message replaces the one that shows, in the same pill.
92
+ - Drag the button, and the pill folds at once.
93
+ - With the icon hidden (**Hide icon** in the menu), the message shows at the bottom of the page.
94
+
95
+ ### While the agent works
96
+
97
+ While a run works, the four corners of the Onsite logo move round its square. Choose how in the Onsite menu, under **Settings** > **Working animation**:
98
+
99
+ - **Corner hops** (the default): the four corners slide to the next corner together, then rest there.
100
+ - **Relay**: one corner at a time runs to the next corner.
101
+ - **Pulse**: the corners stay, and the dot pulses.
102
+
103
+ When the run ends, the corners finish their move and stop in place.
104
+
105
+ **Settings** > **Motion** sets how much Onsite moves. **System** (the default) follows the reduced motion setting of your computer. **Full** always moves. **Reduced** turns off the slides and glides of Onsite. With reduced motion, the logo's dot pulses and its corners stay still.
106
+
107
+ Both settings are saved for your project in `.onsite/prefs.json`, with the scheme and the place of the Onsite button.
73
108
 
74
109
  ### What you can select
75
110
 
@@ -88,13 +123,44 @@ Ask while a run works, and the new ask waits in a queue: the Send button turns i
88
123
 
89
124
  - A waiting element shows a faint dashed frame and its place, such as "Queued · next". Choose × on the frame, or **Cancel** in the chat, to cancel it.
90
125
  - While a run works, you can still switch, keep and skip the takes of other asks. A keep waits only for a file that the working run has read or written.
126
+ - You can keep or skip a ready take of the run that works: a keep stops that run first, and the next ask in the queue starts after the keep.
91
127
  - **Stop** ends only the run that works. The next ask then starts.
92
128
 
129
+ ### Look at each take as it lands
130
+
131
+ The agent writes the takes of an ask one after the other. You do not have to wait for the last one. The frame's bar is there from the start, and it does not change size while the agent works:
132
+
133
+ `[O] | [1] [2] [3] ✕ ✓ | note`
134
+
135
+ - **[O]** is your code on disk: a round toggle over the takes, not one of them. It works once a take is ready, and it turns orange while the page shows the original.
136
+ - **[1] [2] [3]** are the takes, one tag for each take that you asked for. A dashed tag waits its turn. An orange tag with a small spinner on its corner is being written. A solid tag is ready: click it to show that take. The filled tag is the take that the page shows. A struck tag was skipped, or the run stopped before it. Point at a tag to read the take's name, or the agent's step while it is written.
137
+ - A take is **ready** when the agent leaves its note. When a take becomes ready, its tag pulses once. When the run ends, every take with a change is ready.
138
+ - Take 1 shows on the page from its first change. Later takes never take over the page: you switch when you want.
139
+ - **✕ Skip** and **✓ Keep** act on the take that the page shows, once it is ready. Until then, they are dim. While the agent works, ✓ keeps that take and stops the rest of the run. ✕ skips only that take: the run goes on, and the page shows the next ready take, or the original. The agent cannot write into a take that you skipped.
140
+ - Until the first take is ready, the bar shows the agent's step, such as "Reading ProjectCard.tsx", on a line of its own while the chat is open. The line sits on the side away from the element, so the tags do not move when it goes. When there is no room for it there, such as above a heading at the top of the window, the line hides: the chat shows the step.
141
+ - The bar sits above its element, else below it, else beside it. It keeps the side it opened on while that side has room, so a scroll or the chat does not move it to the other side for good. It keeps off the elements of your other asks when it can, and a new tag never pushes an open bar aside.
142
+ - With the chat closed, as after a quick chat, the bar has no step line: point at the spinning tag to read the step. The expand icon at the end opens the full chat on that ask: `[O] | [1] [2] ✕ ✓ | note expand`.
143
+ - The **note** icon opens and closes the take's card (see below). It is orange while the card shows.
144
+ - Press Escape on the bar to fold it into a small tag. Click the tag to open the bar again.
145
+
146
+ ### Read a take's card, tune it and refine it
147
+
148
+ The agent leaves a note on each take. It shows as a card outside the frame, next to the bar. The card opens on its own for the take that the page shows, once the take is ready, and it switches with the take.
149
+
150
+ - **The card** has a title for the idea, a muted line on why it helps, and two to four points on what changed. It names components by their short names, such as `ProjectCard`.
151
+ - **Options.** When your ask has a feel to tune, such as motion, speed, size, spacing or strength, the agent adds up to four options. A choice shows as small buttons, a range as a slider with its value. Move one, and Onsite writes that value into the take's own file: the page updates by hot reload, with no agent call. A moved option shows its value in orange. Most takes have no options.
152
+ - **Keep** writes the take with the values you chose. The export names each option and its value.
153
+ - **Refine** from the line at the bottom. It shows a chip for each option you moved. Type what else to change, or only send the chips: the ask reads "Refine take 2. Speed: 320 ms." and then your words. It builds on that take, shows in the chat like any ask, and waits in the queue while a run works.
154
+ - **Close** the card with ✕ in its corner, or press Escape in it. It stays closed for every bar, also after a reload in this tab, until you open a card again with the note icon on the bar.
155
+ - While **[O]** shows your code on disk, the card stays, but its options are off.
156
+ - The card sits right of the frame and its bar, else left of them, below them or above them. It keeps clear of the bars, the frames of your other asks and the chat. When only a narrow strip is left beside the frame, such as over a sidebar, the card narrows into it. It stays where it opened while there is room there, so an option that widens the element, [O] or the chat that opens does not move it. When nothing has room, it sits where it covers the least, off the chat and the bars, and never over its own frame while another place exists. A tall card scrolls inside.
157
+
93
158
  ### Compare, keep or skip
94
159
 
95
160
  - **Each ask shows one of its takes**, at the same time as your other asks. Ask about a card and then about a chart, and the page shows both changes.
96
161
  - **Switch** between the takes of an ask: each ask numbers its takes 1, 2, 3. **Original** is a toggle apart from them: press it to see that ask's part of your code as it is on disk, and press it again to go back to the take you chose. Your other asks keep what they show. When more than one ask has takes, ‹ and › in the chat's take bar move between asks. Your page keeps its state, such as text in a form.
97
- - **Read the idea** of a take: the agent leaves a short note on each take, the idea and why it helps. A speech bubble on the frame shows that the take has one; click it to read the note of the take that the frame shows. The note names components and files by their short names, such as `ProjectCard.tsx`. Point at a take's number to read its note too.
162
+ - **The chat's take bar** reads `[O] | [1] [2] ✕ ✓`. **O** is the original. The tags after the divider are the takes; the shown take is filled, and a skipped take stays in its place, struck through. **✕** skips and **✓** keeps the take you chose. Point at a tag or an icon to see what it is.
163
+ - **Read the idea** of a take in its card, next to the bar. Point at a take's number to read why it helps.
98
164
  - When two asks change the same file, the page shows the newer ask's version of that file. The older ask's bar says which ask holds the file, such as "Ask 2 holds styles.css".
99
165
  - **Show the original everywhere** in the Onsite menu shows your code on disk for every ask at once. Press it again, now named **Show the takes again**, to bring back the take that each ask showed.
100
166
  - **Hold ⌥** to see every element that a take changed. Click a label to switch versions right there. **Original** in that menu shows the original for every ask that changed those elements.
@@ -115,15 +181,15 @@ Click a pin to read the comment. Choose **Add to the ask** to send it with your
115
181
 
116
182
  ### See what changed
117
183
 
118
- The **Changes** view lists every file the open takes change, grouped into pages, components and styles, with lines added and removed. Open a file to see its diff.
184
+ Choose **Changes** in the Onsite menu. The view lists every file the open takes change, grouped into pages, components and styles, with lines added and removed. Open a file to see its diff.
119
185
 
120
186
  ### Export
121
187
 
122
- The **Export** view builds one Markdown prompt from the takes and comments you choose. It holds what you asked, the idea of each take, the diffs, your comments, the page context, and instructions to follow your repository's rules. Copy it to the clipboard or download it, then give it to your own coding agent.
188
+ Choose **Export** in the Onsite menu. The view builds one Markdown prompt from the takes and comments you choose. It holds what you asked, the idea of each take, the diffs, your comments, the page context, and instructions to follow your repository's rules. Copy it to the clipboard or download it, then give it to your own coding agent.
123
189
 
124
190
  ### Move Onsite
125
191
 
126
- You can drag the Onsite button or the panel's header to any corner or the top or bottom middle, and <kbd>⇧ Shift</kbd> + arrow keys move it too.
192
+ You can drag the Onsite button or the empty part of the panel's header to any corner or the top or bottom middle, and <kbd>⇧ Shift</kbd> + arrow keys move it too.
127
193
 
128
194
  ### Skills and presets
129
195
 
@@ -136,6 +202,21 @@ Turn each skill on or off in the Onsite menu. The agent sees the name and descri
136
202
 
137
203
  **Presets** are saved asks. Select elements, then pick a preset to run its ask on them. Onsite ships with a few, such as "Tighten spacing" and "Add realistic sample data". The presets you write are saved in `.onsite/presets.json` in your project.
138
204
 
205
+ ### Design base
206
+
207
+ A design base gives the agent a known baseline look when your app has little to build on. Choose it in the Onsite menu, under **Settings** > **Design base**:
208
+
209
+ - **Off** (the default): the agent follows your app's own look.
210
+ - **shadcn/ui + Lucide**
211
+ - **Radix Themes + Radix Icons**
212
+ - **Material 3 + Material Symbols**
213
+
214
+ With a base, the agent gets a short written guide for it: spacing, radius, type scale, colours, borders and shadows, buttons, inputs, cards, badges, tables, dialogs, the hover, focus and disabled states, and the icon set. Your words win over the base. Your app's brand colours and fonts stay. The base sets the rest.
215
+
216
+ Onsite adds no packages. It reads your `package.json` and tells the agent which of the base's packages you have, such as `lucide-react` or `@radix-ui/themes`. The agent imports from those. For the rest, it builds the look with your app's own styling and draws icons as inline SVG.
217
+
218
+ The base is saved for your project in `.onsite/prefs.json` and applies to every later ask. Each ask remembers the base it ran with, and the export names it.
219
+
139
220
  ## Keyboard
140
221
 
141
222
  | Key | Action |
@@ -145,15 +226,16 @@ Turn each skill on or off in the Onsite menu. The agent sees the name and descri
145
226
  | <kbd>↑</kbd> / <kbd>↓</kbd> while picking (hold <kbd>⌥</kbd>, or Select mode) | Move the highlight to the element around it, or back down. The next click selects the highlighted element. In a text field, hold <kbd>⌥</kbd> |
146
227
  | <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>⇧</kbd> + <kbd>Enter</kbd> | Open the quick chat in the full chat |
147
228
  | Hold <kbd>⌥</kbd> | Show what the takes changed |
148
- | <kbd>⇧</kbd> + arrow key | Move Onsite to the next corner or middle (Onsite button or panel header focused) |
229
+ | <kbd>⇧</kbd> + arrow key | Move Onsite to the next corner or middle (Onsite button, or a part of the panel's header, focused) |
149
230
  | Right-click the Onsite button, or **⋯** | Open the menu: Changes, Export, Show the original everywhere, Skills, Presets, Settings, Hide icon |
150
- | <kbd>←</kbd> / <kbd>→</kbd> on a frame's bar | Switch between the takes |
231
+ | <kbd>←</kbd> / <kbd>→</kbd> on a frame's bar | Switch between the ready takes |
151
232
  | <kbd>O</kbd> on a frame's bar | Show the original, or go back to the chosen take |
152
- | <kbd>Enter</kbd> on a frame's bar | Keep the chosen take |
233
+ | <kbd>⌥</kbd> + <kbd>O</kbd> | Show the original for the open bar's ask, or go back to its take. Works anywhere on the page and in Onsite's chat, but not in your app's own text fields, where it types as usual |
234
+ | <kbd>Enter</kbd> on a frame's bar | Keep the shown take, once it is ready |
153
235
  | <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>Enter</kbd> | Send, or Queue while a run works |
154
236
  | <kbd>⌥</kbd> + <kbd>Enter</kbd> | Pin the chat's text as a comment on the selected element |
155
- | <kbd>Tab</kbd> in the chat | Move to the chat's buttons; each one shows its name and keys |
156
- | <kbd>Esc</kbd> | Leave a mode, close the quick chat, or close the panel |
237
+ | <kbd>Tab</kbd> in the panel | Move to the panel's icons and the chat's buttons; each one shows its name and keys |
238
+ | <kbd>Esc</kbd> | Leave a mode, close the quick chat, go back from Changes or Export to the thread, or close the panel |
157
239
 
158
240
  ## API
159
241
 
@@ -240,9 +322,9 @@ Onsite is for local development.
240
322
  - It runs only in the Vite dev server, never in a build.
241
323
  - It answers only requests from your app's own origin.
242
324
  - The agent can write only inside the `src` folders you configure, and only through Onsite. It has no shell and no web access.
243
- - Its tools are Onsite's own: list, read, write and edit source files, and leave a note on a take. Onsite checks each note (60 to 320 characters, no code, short file names) and shows it as plain text.
325
+ - Its tools are Onsite's own: list, read, write and edit source files, and leave a note on a take. Onsite checks each note (a short title, a why line and two to four points, no code, short file names) and shows it as plain text. An option of a take must point at a value in the take's own files, marked with a comment such as `/* onsite:speed */`. Moving an option rewrites only that value in the take, never your files on disk and never your app's elements. Keep writes the take without the markers.
244
326
  - The agent can read the skills that you turn on, but it cannot run their scripts. A skill never widens what the agent may write.
245
- - Page text, props, comments, take notes and file contents are passed to the model as data, never as instructions.
327
+ - Page text, props, comments, take notes, their options and file contents are passed to the model as data, never as instructions.
246
328
 
247
329
  Your code and page content go to Claude through your own account when you ask for a change.
248
330
 
@@ -250,9 +332,11 @@ Your code and page content go to Claude through your own account when you ask fo
250
332
 
251
333
  - While a take shows, a hand edit to one of its files makes the take stale: its ask shows the original, with your edit. Ask again to redo the take on the new code. To show the stale take anyway, choose it: a small card says that it was made on older code, and **Show anyway** shows it. **Cancel**, <kbd>Esc</kbd> or a click outside the card keeps the original.
252
334
  - One agent run works at a time. Asks you send meanwhile wait in a queue of up to three, and start in order.
335
+ - A run may take 10 minutes and 40 tool calls for each take it asks for: 30 minutes and 120 calls for three takes. Then it ends with what it made so far. **Stop** ends it sooner.
253
336
  - Each ask shows one take. When two asks change the same file, only the newer ask's version of that file shows. Onsite does not merge them.
254
337
  - An ask builds on one take, not on every shown take. When you select elements of two asks, the new take carries the newer ask's change, not the older ask's. If it changes a file of the older ask, the page shows the new take's version of that file, without the older ask's change. To start a new ask from your files on disk, choose **Show the original everywhere** in the Onsite menu first.
255
338
  - An ask that waits in the queue never builds on a take of a run that is still working or waiting. It starts from your files on disk then.
339
+ - Outlines, bars, cards and the quick chat move with the page as you scroll the window. In a scroll area inside the page, such as a list or a wide table, they stay inside the area and follow its scroll one frame later. The same goes for an app that scrolls in an element and not in the window.
256
340
 
257
341
  ## Contributing
258
342
 
package/dist/index.d.mts CHANGED
@@ -37,6 +37,56 @@ interface Selection extends Stamp {
37
37
  props?: ComponentProps[];
38
38
  }
39
39
  type TakeState = "open" | "kept" | "skipped" | "aside";
40
+ /**
41
+ * The note card of a take (T-030): the idea in a few plain words, for a
42
+ * designer. The take_note tool checked and cleaned each field. Agent text:
43
+ * show it as text only. A point may hold `**bold**` for a lead word.
44
+ */
45
+ interface NoteCard {
46
+ /** A short name for the idea, at most NOTE_TITLE_MAX characters. */
47
+ title: string;
48
+ /** One sentence on why it helps, at most NOTE_WHY_MAX characters. */
49
+ why: string;
50
+ /** NOTE_POINTS_MIN to NOTE_POINTS_MAX short points on what changed. */
51
+ points: string[];
52
+ }
53
+ /** One value of a choice option: the text in the code, and its name in the card. */
54
+ interface ChoiceValue {
55
+ value: string;
56
+ label: string;
57
+ }
58
+ /**
59
+ * An option of a take (T-030, ADR 0012): one value in the take's own files
60
+ * that the person can move from the card. The value sits right before a
61
+ * marker comment, `/* onsite:<id> *\/`. A choice has 2 to 4 labelled
62
+ * values; a range has a min, a max, a step and a unit.
63
+ */
64
+ type OptionSpec = {
65
+ id: string;
66
+ label: string;
67
+ kind: "choice";
68
+ values: ChoiceValue[];
69
+ default: string;
70
+ } | {
71
+ id: string;
72
+ label: string;
73
+ kind: "range";
74
+ min: number;
75
+ max: number;
76
+ step: number;
77
+ unit: string;
78
+ default: number;
79
+ };
80
+ /** The value of an option: a choice's value, or a range's number. */
81
+ type OptionValue = string | number;
82
+ /** An option of a take, with the file that holds its marker. */
83
+ type TakeOption = OptionSpec & {
84
+ path: string;
85
+ };
86
+ /** An option as the overlay shows it: with the value in the take's file now. */
87
+ type OptionView = TakeOption & {
88
+ value: OptionValue;
89
+ };
40
90
  /** Lines added and removed in one file, as the overlay shows them. */
41
91
  interface FileStat {
42
92
  path: string;
@@ -79,6 +129,12 @@ interface Entry {
79
129
  take?: number;
80
130
  /** A run's reads and writes, on the person's entry. */
81
131
  steps?: StepView[];
132
+ /**
133
+ * The number of takes that the ask asked for, on the person's entry of
134
+ * an ask of 2 or more takes (T-028). The frame's bar shows one tag per
135
+ * take before the agent writes any. Absent for an ask of one take.
136
+ */
137
+ count?: number;
82
138
  /** The comments sent with an ask. */
83
139
  comments?: CommentId[];
84
140
  /** On the reply of a run that the person stopped. */
@@ -96,7 +152,9 @@ interface TakeView {
96
152
  /**
97
153
  * The agent's note on the take: its idea and why it helps, one to three
98
154
  * plain sentences (T-024). Untrusted text: show it as text only. Absent
99
- * when the agent left no note, such as in an old log.
155
+ * when the agent left no note, such as in an old log. While the run
156
+ * works, a take with a note is ready: the person can keep or skip it
157
+ * (T-028, ADR 0011).
100
158
  */
101
159
  note?: string;
102
160
  state: TakeState;
@@ -118,6 +176,13 @@ interface TakeView {
118
176
  path: string;
119
177
  by: TakeId;
120
178
  }>;
179
+ /**
180
+ * The note card (T-030). Absent for a note from a log before T-030: the
181
+ * overlay shows `note` as one paragraph, with the label as the title.
182
+ */
183
+ card?: NoteCard;
184
+ /** The take's options, with their values now (T-030). Absent when the take has none. */
185
+ options?: OptionView[];
121
186
  }
122
187
  /** One comment as the overlay shows it. */
123
188
  interface CommentView {
@@ -158,10 +223,17 @@ interface ThreadState {
158
223
  * a restart fails the asks that waited.
159
224
  */
160
225
  queue?: RunId[];
161
- /** The running run's reply so far. In memory only, so a reload during a run picks it up. */
226
+ /**
227
+ * The running run's reply so far. In memory only, so a reload during a
228
+ * run picks it up. `labels` holds the concept of each take from the
229
+ * reply's "Take N: …" lines so far, by take number from 1, "" for a take
230
+ * with no line yet; the bar names its tags with them before the run ends
231
+ * (T-028). Absent when the reply has no such line.
232
+ */
162
233
  live?: {
163
234
  run: RunId;
164
235
  text: string;
236
+ labels?: string[];
165
237
  };
166
238
  /** The seq of the log's last event. */
167
239
  seq: number;
@@ -200,6 +272,12 @@ interface OnsiteOptions {
200
272
  model?: string;
201
273
  /** Turn Onsite off without removing the plugin. Default true. */
202
274
  enabled?: boolean;
275
+ /**
276
+ * Stamp a component imported from a package, such as `<WaButton>` or
277
+ * `<Dialog.Root>`, at its usage site, so a click selects it on its own.
278
+ * Set to false when a library rejects unknown props. Default true.
279
+ */
280
+ stampPackages?: boolean;
203
281
  }
204
282
  declare module "vite" {
205
283
  interface CustomEventMap {