@useonsite/vite 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Victor Frederik Nielsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,252 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="design/brand/mark-dark.svg">
4
+ <img src="design/brand/mark-light.svg" width="72" height="72" alt="Onsite">
5
+ </picture>
6
+ </p>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ <h1 align="center">onsite</h1>
9
+
10
+ <p align="center"><strong>Design in your running app.</strong></p>
11
+
12
+ Onsite is a Vite plugin that puts a design agent inside your app while you develop it. Point at anything on the page, say what you want, and watch the change land in your real components, with your real data. Every change arrives as a **take** that you can compare, keep or skip. Nothing touches your files until you keep one.
13
+
14
+ When you like the result, keep it, or **export** a prompt that your own coding agent uses to build it properly.
15
+
16
+ ```bash
17
+ npm i -D @useonsite/vite
18
+ ```
19
+
20
+ > **Status:** early development, not published to npm yet.
21
+
22
+ ## Why Onsite
23
+
24
+ - **Your app, not a mock-up.** Changes happen in your components, with your routes, state, data and login.
25
+ - **Takes, not edits.** Ask for one take or three. Switch between them with hot reload; the page keeps its state.
26
+ - **Safe by default.** Takes live outside your source tree until you keep one. Undo puts back the last keep.
27
+ - **Fits your workflow.** Export a prompt with the diffs, your comments and the page context, and hand it to Claude Code, Cursor or any other agent.
28
+ - **Never in your way.** The overlay draws in its own layer and never changes your app's layout. It runs in `vite dev` only and is gone from your build.
29
+
30
+ ## Quick start
31
+
32
+ 1. Install the plugin:
33
+
34
+ ```bash
35
+ npm i -D @useonsite/vite
36
+ ```
37
+
38
+ 2. Add it to `vite.config.ts`, before your framework plugin:
39
+
40
+ ```ts
41
+ import { defineConfig } from "vite";
42
+ import react from "@vitejs/plugin-react";
43
+ import onsite from "@useonsite/vite";
44
+
45
+ export default defineConfig({
46
+ plugins: [onsite(), react()],
47
+ });
48
+ ```
49
+
50
+ 3. Make sure Claude can run. Log in once with the [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI (`claude`), or set `ANTHROPIC_API_KEY`.
51
+
52
+ 4. Start your dev server as usual:
53
+
54
+ ```bash
55
+ npm run dev
56
+ ```
57
+
58
+ 5. Open your app. The Onsite button sits in the corner of the page.
59
+
60
+ ## Using Onsite
61
+
62
+ ### Ask for a change
63
+
64
+ 1. Hold <kbd>⌥ Option</kbd> (<kbd>Alt</kbd>) and click an element to select it. A quick chat opens beside it. <kbd>⌥</kbd>-click more elements to give more context.
65
+ 2. Type what you want, such as "make the budget easier to read at a glance".
66
+ 3. Press <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>Enter</kbd>, or choose the arrow. For two or three different options, choose the takes button (the stack with ×1) first: each click steps 1, 2, 3.
67
+
68
+ The chat is one round box. Its buttons show only an icon: takes, **Pin as comment**, **Stop** while a run works, and **Send** (the arrow) or **Queue**. Point at a button, or move to it with <kbd>Tab</kbd>, to see its name, its keys, and what it acts on, such as the take your ask builds on.
69
+
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
+
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.
73
+
74
+ ### Ask again while the agent works
75
+
76
+ Ask while a run works, and the new ask waits in a queue: the Send button turns into **Queue** (a list with a plus). When three asks wait, Queue is off, and its tooltip says why. Up to three asks wait, first in, first out. Each one starts when the run before it ends. It builds on the take of the elements you selected (see [Compare, keep or skip](#compare-keep-or-skip)), if that take's run had finished; else it starts from the files on disk. That take stays open until the ask starts: keep or skip it after.
77
+
78
+ - 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.
79
+ - 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.
80
+ - **Stop** ends only the run that works. The next ask then starts.
81
+
82
+ ### Compare, keep or skip
83
+
84
+ - **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.
85
+ - **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.
86
+ - **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.
87
+ - 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".
88
+ - **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.
89
+ - **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.
90
+ - **Keep** writes the take to your files. **Skip** drops it. **Undo** puts back your last keep or skip. A keep ends its own ask; your other asks keep their takes. A take of another ask that changes a kept file was made on the old code, so its ask shows the original.
91
+ - Ask again while takes show, and the next take builds on the take of the elements you selected: the take that the page shows for their files. When you select elements of two asks, it builds on the newer ask's take, and the Send button's tooltip says so, such as "On Take 1 of ask 2, the newer ask". When no shown take changes the selected elements' files, it builds on the take that showed last.
92
+
93
+ ### Comment
94
+
95
+ A comment is a note that you pin on an element for later. It starts no run.
96
+
97
+ 1. <kbd>⌥</kbd>-click the element. The quick chat opens beside it.
98
+ 2. Type the note.
99
+ 3. Choose **Pin as comment**, or press <kbd>⌥</kbd> + <kbd>Enter</kbd>. The quick chat closes, and a numbered pin stays on the element.
100
+
101
+ The panel's chat has **Pin as comment** too. With more than one element selected, the comment pins on the first one, and the button's tooltip says which. A comment works while a run works: it never waits in the queue.
102
+
103
+ Click a pin to read the comment. Choose **Add to the ask** to send it with your next ask, or **Resolve** when it is done. Comments stay across reloads. The **Changes** view lists them, and you can put them in an export.
104
+
105
+ ### See what changed
106
+
107
+ 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.
108
+
109
+ ### Export
110
+
111
+ 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.
112
+
113
+ ### Move Onsite
114
+
115
+ 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.
116
+
117
+ ### Skills and presets
118
+
119
+ **Skills** are Claude skills: folders with a `SKILL.md`. Onsite finds them in two places:
120
+
121
+ - **Project skills** in your project's `.claude/skills/`. Onsite looks in the Vite root and in each folder above it, up to your repository root. Project skills are on by default.
122
+ - **Your own skills** in `~/.claude/skills/`. They are off by default, because they are not part of this project.
123
+
124
+ Turn each skill on or off in the Onsite menu. The agent sees the name and description of each skill that is on, and reads a skill when your ask matches it. It follows the skill with its own tools only: Onsite never runs a skill's scripts.
125
+
126
+ **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.
127
+
128
+ ## Keyboard
129
+
130
+ | Key | Action |
131
+ |---|---|
132
+ | <kbd>⌥</kbd> <kbd>⌥</kbd> (tap twice) | Open or close Onsite |
133
+ | <kbd>⌥</kbd> + click | Select an element and open the quick chat beside it |
134
+ | <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>⇧</kbd> + <kbd>Enter</kbd> | Open the quick chat in the full chat |
135
+ | Hold <kbd>⌥</kbd> | Show what the takes changed |
136
+ | <kbd>⇧</kbd> + arrow key | Move Onsite to the next corner or middle (Onsite button or panel header focused) |
137
+ | Right-click the Onsite button, or **⋯** | Open the menu: Changes, Export, Show the original everywhere, Skills, Presets, Settings, Hide icon |
138
+ | <kbd>←</kbd> / <kbd>→</kbd> on a frame's bar | Switch between the takes |
139
+ | <kbd>O</kbd> on a frame's bar | Show the original, or go back to the chosen take |
140
+ | <kbd>Enter</kbd> on a frame's bar | Keep the chosen take |
141
+ | <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>Enter</kbd> | Send, or Queue while a run works |
142
+ | <kbd>⌥</kbd> + <kbd>Enter</kbd> | Pin the chat's text as a comment on the selected element |
143
+ | <kbd>Tab</kbd> in the chat | Move to the chat's buttons; each one shows its name and keys |
144
+ | <kbd>Esc</kbd> | Leave a mode, close the quick chat, or close the panel |
145
+
146
+ ## API
147
+
148
+ ### `onsite(options?)`
149
+
150
+ Returns the Vite plugin. Every option is optional.
151
+
152
+ | Option | Type | Default | Description |
153
+ |---|---|---|---|
154
+ | `src` | `string[]` | `["src"]` | The source folders, relative to the Vite root. The agent reads and writes only here. |
155
+ | `model` | `string` | Claude's default | The Claude model the agent uses, such as `"claude-sonnet-5-5"`. |
156
+ | `enabled` | `boolean` | `true` | Set to `false` to turn Onsite off without removing the plugin. |
157
+
158
+ ```ts
159
+ onsite({
160
+ src: ["src", "packages/ui/src"],
161
+ model: "claude-sonnet-5-5",
162
+ enabled: process.env.ONSITE !== "0",
163
+ });
164
+ ```
165
+
166
+ The plugin is active in `vite dev` only. `vite build` ignores it.
167
+
168
+ A model that you choose in the Onsite menu is saved for your project in `.onsite/prefs.json`. It is used over the `model` option.
169
+
170
+ ## Requirements
171
+
172
+ - Vite 6 or later
173
+ - React with `@vitejs/plugin-react` (see below)
174
+ - Node.js `^22.18.0` or `>=24.11.0`
175
+ - A Claude login (`claude`) or an `ANTHROPIC_API_KEY`
176
+
177
+ ## Supported technologies
178
+
179
+ ### Supported and tested
180
+
181
+ | Area | Supported |
182
+ |---|---|
183
+ | Build tool | Vite 6 and Vite 8 |
184
+ | Framework | React 19, single-page apps with an `index.html` |
185
+ | React plugin | `@vitejs/plugin-react` 5 and 6 |
186
+ | Compiler | React Compiler (`babel-plugin-react-compiler`) |
187
+ | Languages | TypeScript and JavaScript (`.tsx`, `.jsx`, `.ts`, `.js`) |
188
+ | Styles | Plain CSS files, Tailwind and inline styles. Changed elements flash and show in the ⌥ view. |
189
+ | Dev server | HTTP, HTTPS and HTTP/2 (mkcert or `@vitejs/plugin-basic-ssl` setups) |
190
+ | Browser | Chrome and other Chromium browsers |
191
+ | OS | macOS |
192
+
193
+ ### Should work, not tested yet
194
+
195
+ | Area | What to expect |
196
+ |---|---|
197
+ | Vite 7 | Between two tested versions; no known issue. |
198
+ | React 18 | The source stamps and the props reader rely on nothing React 19-only. |
199
+ | `@vitejs/plugin-react-swc` | Onsite stamps JSX before any React plugin runs, so the compiler should not matter. |
200
+ | Sass, Less | The agent can change `.scss`, `.sass` and `.less` files, but changed elements do not flash or show in the ⌥ view yet. |
201
+ | CSS Modules, CSS-in-JS | Changes work. The flash and the ⌥ view mark elements only through changed JSX, not through changed class names. |
202
+ | Firefox, Safari | The overlay uses standard DOM APIs, but no test runs in them. |
203
+ | Linux, Windows | Expected to work. On Windows and Linux, the ⌥ key is <kbd>Alt</kbd>. |
204
+
205
+ ### Not supported yet
206
+
207
+ | Area | Status |
208
+ |---|---|
209
+ | Vue, Svelte, Solid, Preact, Angular | Onsite stamps React JSX only. |
210
+ | Server-rendered React frameworks: Next.js, React Router framework mode, Remix, TanStack Start, Astro | Onsite needs an app that Vite serves from `index.html`. Next.js does not run on Vite. |
211
+ | webpack, Turbopack, Rspack, Parcel | Onsite is a Vite plugin. |
212
+ | Storybook | Planned: takes judged in every story. |
213
+ | React Native | Not planned. |
214
+ | Deleting files in a take | The agent can add and change files, not delete them. |
215
+ | Screenshots for the agent | Planned: the agent sees the page before and after its change. Today it gets a text snapshot of the page and the props of the selected components. |
216
+
217
+ ## Your project and Onsite
218
+
219
+ - **Your rules count.** The agent reads `AGENTS.md` and `CLAUDE.md` in your project, uses your component library and follows your import rules.
220
+ - **Its state lives in `.onsite/`.** That folder holds the history of your asks and takes, so it survives a restart of the dev server. Onsite adds `.onsite/` to your `.gitignore`.
221
+ - **It is crash-safe.** If the dev server stops in the middle of a run or a keep, Onsite picks up where it left off on the next start.
222
+
223
+ ## Security
224
+
225
+ Onsite is for local development.
226
+
227
+ - It runs only in the Vite dev server, never in a build.
228
+ - It answers only requests from your app's own origin.
229
+ - The agent can write only inside the `src` folders you configure, and only through Onsite. It has no shell and no web access.
230
+ - 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.
231
+ - 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.
232
+ - Page text, props, comments, take notes and file contents are passed to the model as data, never as instructions.
233
+
234
+ Your code and page content go to Claude through your own account when you ask for a change.
235
+
236
+ ## Limits
237
+
238
+ - 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.
239
+ - One agent run works at a time. Asks you send meanwhile wait in a queue of up to three, and start in order.
240
+ - 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.
241
+ - 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.
242
+ - 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.
243
+
244
+ ## Contributing
245
+
246
+ See [`AGENTS.md`](AGENTS.md) for how the repository works, and [`docs/adr/`](docs/adr/) for the design decisions. Run `npm ci`, then `npm run check` before every commit. `npm run dev` starts the example app with Onsite.
247
+
248
+ The example app is a playground: `npm run reset`, or **Reset playground** in its sidebar, puts it back to the version in git (see [`examples/react-app/README.md`](examples/react-app/README.md)).
249
+
250
+ ## License
251
+
252
+ [MIT](LICENSE)
@@ -0,0 +1,213 @@
1
+ import { Plugin } from "vite";
2
+ /** The ID of a run: one ask of the person and the agent's work on it. */
3
+ type RunId = string;
4
+ /** The ID of a take: `${RunId}-${n}`, known when the run starts. */
5
+ type TakeId = string;
6
+ /** The ID of a keep, a skip or an undo. */
7
+ type ChangeId = string;
8
+ /** The ID of a comment. */
9
+ type CommentId = string;
10
+ /** A stamped element: where its opening tag is in the source. */
11
+ interface Stamp {
12
+ /** `"<file>:<line>:<col>"`, such as `"src/components/Card.tsx:12:5"`. */
13
+ src: string;
14
+ /** The nearest enclosing component, such as `"Card"`. */
15
+ comp?: string;
16
+ }
17
+ /** The props of one component around a selected element, read from the React fiber. */
18
+ interface ComponentProps {
19
+ comp: string;
20
+ /** The component's source stamp, when React knows it. */
21
+ src?: string;
22
+ /** JSON of the props: no functions, no elements, no cycles. At most PROPS_CAP bytes. */
23
+ json: string;
24
+ /** True when the JSON was cut to the cap. */
25
+ cut: boolean;
26
+ }
27
+ /** One element that the person selected in the page. */
28
+ interface Selection extends Stamp {
29
+ /** The tag name, lower case, such as `"button"`. */
30
+ tag?: string;
31
+ /** The element's outer HTML, cut to SELECTION_HTML_CAP characters. */
32
+ html?: string;
33
+ /** The element's size in CSS pixels. */
34
+ w?: number;
35
+ h?: number;
36
+ /** The props of its nearest components, innermost first. */
37
+ props?: ComponentProps[];
38
+ }
39
+ type TakeState = "open" | "kept" | "skipped" | "aside";
40
+ /** Lines added and removed in one file, as the overlay shows them. */
41
+ interface FileStat {
42
+ path: string;
43
+ status: "added" | "changed" | "deleted";
44
+ added: number;
45
+ removed: number;
46
+ }
47
+ /** The kind of an ask: one take, or 2 or 3 takes. */
48
+ type AskKind = "ask" | "takes";
49
+ /** The kind of a change. */
50
+ type ChangeKind = "keep" | "skip" | "undo";
51
+ /** One step of a run as the overlay shows it: a read, a list, or a write with its lines. */
52
+ interface StepView {
53
+ tool: "src_list" | "src_read" | "src_write" | "src_edit";
54
+ path: string;
55
+ /** The run's number of the take a write went into, from 1. */
56
+ take?: number;
57
+ from?: number;
58
+ to?: number;
59
+ }
60
+ /** One line of the thread. */
61
+ interface Entry {
62
+ /** The run's or the change's ID. */
63
+ id: string;
64
+ at: string;
65
+ who: "person" | "agent" | "error";
66
+ kind?: AskKind | ChangeKind;
67
+ /** Plain text; the overlay never renders it as HTML. */
68
+ text: string;
69
+ selection?: Selection[];
70
+ files?: FileStat[];
71
+ costUSD?: number;
72
+ /** The change that this undo undid. */
73
+ undoes?: ChangeId;
74
+ /** A later undo undid this change. */
75
+ undone?: boolean;
76
+ /** The numbers of the takes that a run made, from 1 in each run. */
77
+ takes?: number[];
78
+ /** The number, within its run, of the take that a keep or a skip acted on. */
79
+ take?: number;
80
+ /** A run's reads and writes, on the person's entry. */
81
+ steps?: StepView[];
82
+ /** The comments sent with an ask. */
83
+ comments?: CommentId[];
84
+ /** On the reply of a run that the person stopped. */
85
+ stopped?: boolean;
86
+ }
87
+ /** One take as the overlay shows it. */
88
+ interface TakeView {
89
+ id: TakeId;
90
+ /** Each run numbers its takes from 1: the run's frame and bar say 1, 2, 3. */
91
+ no: number;
92
+ /** The run that made it. */
93
+ of: RunId;
94
+ /** The take's concept, from a takes reply ("Take 2: a progress ring"). */
95
+ label?: string;
96
+ /**
97
+ * The agent's note on the take: its idea and why it helps, one to three
98
+ * 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.
100
+ */
101
+ note?: string;
102
+ state: TakeState;
103
+ files: FileStat[];
104
+ stopped?: boolean;
105
+ /**
106
+ * The take's files that changed on disk after the take was made: the
107
+ * disk version is not the take's `before` (T-014). The core reads the
108
+ * disk for it, so it is current. Absent when no file moved.
109
+ */
110
+ stale?: string[];
111
+ /**
112
+ * The files of a shown take that a newer run's shown take also holds
113
+ * (T-019). The app serves the newer take's version of such a file; `by`
114
+ * names that take. Absent when the take does not show, or no file of it
115
+ * is covered.
116
+ */
117
+ covered?: Array<{
118
+ path: string;
119
+ by: TakeId;
120
+ }>;
121
+ }
122
+ /** One comment as the overlay shows it. */
123
+ interface CommentView {
124
+ id: CommentId;
125
+ at: string;
126
+ text: string;
127
+ stamp: Stamp;
128
+ /** The file and line of the stamp, split for the changes view. */
129
+ file: string;
130
+ line: number;
131
+ take: TakeId | "";
132
+ /** The number of that take within its run. */
133
+ takeNo?: number;
134
+ resolved: boolean;
135
+ }
136
+ /** The folded thread: everything the overlay draws, without file contents. */
137
+ interface ThreadState {
138
+ entries: Entry[];
139
+ takes: TakeView[];
140
+ comments: CommentView[];
141
+ /**
142
+ * The open take that the person or a run showed last, or "" when every
143
+ * run shows the original. A new ask refines it by default when no shown
144
+ * take holds a selected element's file (T-022).
145
+ */
146
+ shown: TakeId | "";
147
+ /**
148
+ * Every take that the app shows: at most one per run, in run order
149
+ * (T-019). When two of them hold one file, the newer run's version shows.
150
+ * Empty when every run shows the original.
151
+ */
152
+ showing: TakeId[];
153
+ /** The run that works now, or "". */
154
+ running: RunId | "";
155
+ /**
156
+ * The asks that wait for the running run, first in, first out. Each
157
+ * starts when the run before it ends. Absent when none waits. In memory:
158
+ * a restart fails the asks that waited.
159
+ */
160
+ queue?: RunId[];
161
+ /** The running run's reply so far. In memory only, so a reload during a run picks it up. */
162
+ live?: {
163
+ run: RunId;
164
+ text: string;
165
+ };
166
+ /** The seq of the log's last event. */
167
+ seq: number;
168
+ }
169
+ /** An element mark: the stamps of host elements and the CSS selectors of style rules. */
170
+ interface Marks {
171
+ stamps: string[];
172
+ selectors: string[];
173
+ }
174
+ /** A write of the shown take landed by HMR: flash the elements it changed. */
175
+ interface FlashEvent {
176
+ take: TakeId;
177
+ path: string;
178
+ from: number;
179
+ to: number;
180
+ marks: Marks;
181
+ }
182
+ /** The reply so far of the running run. */
183
+ interface TextEvent {
184
+ run: RunId;
185
+ text: string;
186
+ }
187
+ interface WsEvents {
188
+ /** The whole folded state, after every logged event. */
189
+ "onsite:state": ThreadState;
190
+ /** The agent's reply so far, as it grows. */
191
+ "onsite:text": TextEvent;
192
+ /** Sent after Vite has sent the HMR update of a write into the shown take. The overlay waits for `vite:afterUpdate`, then flashes. */
193
+ "onsite:flash": FlashEvent;
194
+ }
195
+ /** The plugin's options, in the app's own vite.config.ts: `onsite({ src: ["src"] })`. */
196
+ interface OnsiteOptions {
197
+ /** Source folders, relative to the Vite root. The agent reads and writes only here. Default ["src"]. */
198
+ src?: string[];
199
+ /** The model for the agent. Default: the Agent SDK's default. */
200
+ model?: string;
201
+ /** Turn Onsite off without removing the plugin. Default true. */
202
+ enabled?: boolean;
203
+ }
204
+ declare module "vite" {
205
+ interface CustomEventMap {
206
+ "onsite:state": WsEvents["onsite:state"];
207
+ "onsite:text": WsEvents["onsite:text"];
208
+ "onsite:flash": WsEvents["onsite:flash"];
209
+ }
210
+ }
211
+ /** The Onsite plugin. It works in `vite serve` only. Put it before the React plugin. */
212
+ export default function onsite(opts?: OnsiteOptions): Plugin;
213
+ export type { OnsiteOptions };