@presto1314w/vite-devtools-browser 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,297 +1,319 @@
1
- # vite-browser
2
-
3
- `vite-browser` is a runtime diagnostics toolchain for Vite applications.
4
-
5
- It gives agents and developers structured access to:
6
-
7
- - Vue, React, and Svelte runtime state
8
- - Vite HMR activity and runtime health
9
- - event-window correlation between current errors and recent hot updates
10
- - rule-based HMR diagnosis with confidence levels
11
- - module graph snapshots and diffs
12
- - mapped error output with optional source snippets
13
- - network, logs, screenshots, and page evaluation
14
-
15
- It ships in two forms:
16
-
17
- - Agent Skill: scenario-based debugging workflows for coding assistants
18
- - CLI Runtime (`@presto1314w/vite-devtools-browser`): structured shell commands for local Vite debugging
19
-
20
- Current documented baseline: `v0.2.2`.
21
-
22
- ## What's New In v0.2
23
-
24
- `v0.2.x` moves `vite-browser` from snapshot-style inspection toward runtime diagnosis:
25
-
26
- - browser/runtime events are captured into a daemon-side event queue
27
- - `correlate errors` links the current error to recent HMR-updated modules
28
- - `diagnose hmr` turns runtime, trace, and error signals into structured findings
29
- - skills and CLI flows now route more directly to runtime triage instead of raw log inspection
30
-
31
- `v0.2.2` is the stabilization pass for this model:
32
-
33
- - tighter `diagnose hmr` wording around websocket evidence and runtime ambiguity
34
- - better test coverage for the four built-in diagnosis families
35
- - docs and release positioning aligned around the stable `v0.2.x` surface
36
-
37
- ## Built For Agents
38
-
39
- `vite-browser` is designed for agent workflows as much as local debugging.
40
-
41
- Models do not work well with a DevTools panel that has to be visually inspected step by step. They work much better when runtime signals are exposed as structured commands that can be queried, compared, and chained in a loop. `vite-browser` turns framework state, Vite runtime status, HMR activity, module graph changes, mapped errors, logs, and network activity into terminal output that an agent can actually reason about.
42
-
43
- Under the hood, each command is a one-shot request against a long-lived browser daemon. That keeps the CLI simple for users while letting agent loops inspect a running app repeatedly without having to manage browser lifecycle on every step.
44
-
45
- ## Why vite-browser
46
-
47
- Most browser CLIs are optimized for automation. Most framework devtools are optimized for humans in a GUI.
48
-
49
- `vite-browser` is optimized for structured Vite runtime debugging:
50
-
51
- - it can inspect framework state like a devtools bridge
52
- - it can explain Vite-specific behavior like HMR updates and module graph changes
53
- - it can correlate recent updates with current failures
54
- - it returns structured text that AI agents can consume directly in loops
55
-
56
- ## Positioning
57
-
58
- | Tool | Best for | Notable gap compared with `vite-browser` |
59
- | --- | --- | --- |
60
- | `agent-browser` | general browser automation | not focused on Vite runtime diagnostics |
61
- | `next-browser` | Next.js + React debugging | not designed as a Vite runtime tool |
62
- | `vite-plugin-vue-mcp` | Vue MCP integration inside Vite | plugin/MCP-first, not a standalone diagnostics CLI |
63
- | `vite-browser` | Vite runtime diagnostics for agents and developers | browser lifecycle coverage still being expanded |
64
-
65
- ## Install
66
-
67
- ### Install Skill
68
-
69
- ```bash
70
- npx skills add MapleCity1314/vite-browser
71
- ```
72
-
73
- ### Install CLI
74
-
75
- ```bash
76
- npm install -g @presto1314w/vite-devtools-browser
77
- npx playwright install chromium
78
- ```
79
-
80
- ## Quick Start
81
-
82
- ```bash
83
- # terminal A: start Vite app
84
- cd my-app
85
- npm run dev
86
-
87
- # terminal B: inspect runtime
88
- vite-browser open http://localhost:5173
89
- vite-browser detect
90
- vite-browser vite runtime
91
- vite-browser errors --mapped --inline-source
92
- vite-browser correlate errors --mapped --window 5000
93
- vite-browser diagnose hmr --limit 50
94
- vite-browser vite hmr trace --limit 20
95
- vite-browser vite module-graph trace --limit 50
96
- vite-browser network
97
- vite-browser close
98
- ```
99
-
100
- For component/state debugging, then branch into framework-specific commands:
101
-
102
- ```bash
103
- vite-browser vue tree
104
- vite-browser vue pinia
105
- vite-browser vue router
106
- vite-browser react tree
107
- vite-browser svelte tree
108
- ```
109
-
110
- ## What It Looks Like
111
-
112
- ```bash
113
- $ vite-browser vite runtime
114
- # Vite Runtime
115
- URL: http://localhost:5173/
116
- Framework: vue
117
- Vite Client: loaded
118
- HMR Socket: open
119
- Error Overlay: none
120
- Tracked HMR Events: 3
121
-
122
- $ vite-browser vite hmr trace --limit 5
123
- # HMR Trace
124
- [12:34:10] connected [vite] connected.
125
- [12:34:15] update /src/App.vue
126
-
127
- $ vite-browser errors --mapped --inline-source
128
- Failed to resolve import "./missing"
129
-
130
- # Mapped Stack
131
- - http://localhost:5173/src/main.ts:12:4 -> /src/main.ts:12:4
132
- 12 | import "./missing"
133
-
134
- $ vite-browser correlate errors --mapped --window 5000
135
- # Error Correlation
136
- ## Current Error
137
- TypeError: boom at /src/App.tsx:4:2
138
-
139
- ## Correlation
140
- Confidence: high
141
- HMR update observed within 5000ms of the current error
142
- Matching modules: /src/App.tsx
143
-
144
- $ vite-browser diagnose hmr --limit 50
145
- # HMR Diagnosis
146
- ## missing-module
147
- Status: fail
148
- Confidence: high
149
- A module import failed to resolve during HMR.
150
- Suggestion: Verify the import path, file extension, alias configuration, and whether the module exists on disk.
151
- ```
152
-
153
- ## Core Capabilities
154
-
155
- - Framework detection: Vue/React/Svelte best-effort detection and version hinting
156
- - Vue runtime inspection: component tree/details, Pinia stores/getters, Vue Router state
157
- - React runtime inspection: component tree/details (props/state/hooks/context/source)
158
- - Svelte runtime inspection: component tree/details when metadata is available
159
- - Vite runtime diagnostics:
160
- - runtime status summary
161
- - HMR summary/timeline/clear
162
- - module-graph snapshot/diff/clear
163
- - error/HMR correlation over recent event windows
164
- - rule-based HMR diagnosis with confidence levels
165
- - source-mapped errors with optional inline source snippet
166
- - Debug utilities: console logs, network tracing, screenshot, page `eval`
167
-
168
- ## Recommended Workflows
169
-
170
- ### Runtime/HMR triage
171
-
172
- ```bash
173
- vite-browser vite runtime
174
- vite-browser errors --mapped --inline-source
175
- vite-browser correlate errors --mapped --window 5000
176
- vite-browser diagnose hmr --limit 50
177
- vite-browser vite hmr trace --limit 50
178
- vite-browser vite module-graph trace --limit 200
179
- ```
180
-
181
- ### Data/API triage
182
-
183
- ```bash
184
- vite-browser errors --mapped
185
- vite-browser logs
186
- vite-browser network
187
- vite-browser network <idx>
188
- vite-browser eval '<state probe>'
189
- ```
190
-
191
- ### Component/state triage
192
-
193
- ```bash
194
- vite-browser detect
195
- vite-browser vue tree
196
- vite-browser vue pinia
197
- vite-browser vue router
198
- vite-browser react tree
199
- vite-browser svelte tree
200
- ```
201
-
202
- ## Current Boundaries
203
-
204
- `vite-browser` v0.2.2 is strong at:
205
-
1
+ # vite-browser
2
+
3
+ **Explain why your Vite app broke after a hot update.**
4
+
5
+ `vite-browser` is a runtime diagnostics toolchain for Vite apps. It connects current errors to recent HMR activity, traces store and module updates into rerender paths, and returns structured terminal output that both developers and AI agents can reason about directly.
6
+
7
+ No plugin installation. No GUI. Just connect to a running Vite dev server and start querying.
8
+
9
+ **CLI**
10
+ ```bash
11
+ npm install -g @presto1314w/vite-devtools-browser
12
+ npx playwright install chromium
13
+ ```
14
+
15
+ **Agent Skill**
16
+ ```bash
17
+ npx skills add MapleCity1314/vite-browser
18
+ ```
19
+
20
+ ---
21
+
22
+ ## The Problem It Solves
23
+
24
+ You save a file. Vite hot-updates. The page breaks.
25
+
26
+ The error overlay tells you *what* broke. It does not tell you *why the update caused it*.
27
+
28
+ You want to know:
29
+ - which module change triggered this error
30
+ - whether a store update propagated into a broken render path
31
+ - what the HMR timeline looked like before the failure
32
+
33
+ `vite-browser` answers these questions from the terminal, without touching your project config.
34
+
35
+ ---
36
+
37
+ ## Quickstart
38
+
39
+ ```bash
40
+ # terminal A - your app
41
+ cd my-app && npm run dev
42
+
43
+ # terminal B - diagnostics
44
+ vite-browser open http://localhost:5173
45
+ vite-browser vite runtime
46
+ vite-browser errors --mapped --inline-source
47
+ vite-browser correlate errors --mapped --window 5000
48
+ vite-browser close
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Example: Tracing a Broken HMR Update
54
+
55
+ You edit `src/store/cart.ts`. The page breaks with `TypeError: cannot read properties of undefined`.
56
+
57
+ ```bash
58
+ # 1. check what the error actually is
59
+ $ vite-browser errors --mapped --inline-source
60
+
61
+ TypeError: Cannot read properties of undefined (reading 'items')
62
+
63
+ # Mapped Stack
64
+ - /src/components/CartSummary.tsx:14:12
65
+ 14 | total = cart.items.reduce(...)
66
+ ```
67
+
68
+ ```bash
69
+ # 2. correlate with recent HMR activity
70
+ $ vite-browser correlate errors --mapped --window 5000
71
+
72
+ # Error Correlation
73
+ Confidence: high
74
+ HMR update observed within 5000ms of the current error
75
+ Matching modules: /src/store/cart.ts
76
+ ```
77
+
78
+ ```bash
79
+ # 3. trace how the update propagated
80
+ $ vite-browser correlate renders --window 5000
81
+
82
+ # Render Correlation
83
+ Confidence: high
84
+ Recent store update likely propagated through 1 render step(s).
85
+
86
+ ## Store Updates
87
+ - cart
88
+
89
+ ## Changed Keys
90
+ - items
91
+
92
+ ## Render Path
93
+ - AppShell > ShoppingCart > CartSummary
94
+ ```
95
+
96
+ ```bash
97
+ # 4. get a structured diagnosis
98
+ $ vite-browser diagnose propagation --window 5000
99
+
100
+ # Propagation Diagnosis
101
+ Status: fail
102
+ Confidence: high
103
+ A plausible store -> render -> error propagation path was found.
104
+ ```
105
+
106
+ Four commands. You know the store update broke the render path. You know where to fix it.
107
+
108
+ ---
109
+
110
+ ## Built For Agents
111
+
112
+ Models cannot visually inspect a DevTools panel. They work much better when runtime signals are structured commands that can be queried, compared, and chained in a loop.
113
+
114
+ `vite-browser` turns Vite runtime state, HMR activity, module graph changes, framework component trees, mapped errors, and network activity into terminal output an agent can consume directly.
115
+
116
+ Each command is a one-shot request against a long-lived browser daemon - no browser lifecycle management on every step, no GUI dependency, no project config changes required.
117
+
118
+ ```bash
119
+ # an agent debugging loop looks like this
120
+ vite-browser vite runtime
121
+ vite-browser errors --mapped --inline-source
122
+ vite-browser correlate errors --mapped --window 5000
123
+ vite-browser correlate renders --window 5000
124
+ vite-browser diagnose propagation --window 5000
125
+ vite-browser diagnose hmr --limit 50
126
+ ```
127
+
128
+ Agent Skill workflows are also available for scenario-based debugging in coding assistants:
129
+
130
+ ```bash
131
+ npx skills add MapleCity1314/vite-browser
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Core Capabilities
137
+
138
+ **Framework detection**
139
+ - Vue, React, Svelte best-effort detection with version hinting
140
+
141
+ **Vue runtime**
142
+ - component tree and details
143
+ - Pinia stores, getters, and changed keys
144
+ - Vue Router state
145
+
146
+ **React runtime**
147
+ - component tree with props, state, hooks, context, and source metadata
148
+
149
+ **Svelte runtime**
150
+ - component tree when metadata is available
151
+
152
+ **Vite runtime diagnostics**
153
+ - runtime status and HMR health
154
+ - HMR timeline, summary, and clear
155
+ - module graph snapshot, diff, trace, and clear
156
+ - error / HMR correlation over configurable time windows
157
+ - store and module update / render path correlation
158
+ - propagation diagnosis with store updates, changed keys, and render paths
159
+ - rule-based HMR diagnosis with confidence levels
160
+ - source-mapped errors with optional inline source snippets
161
+
162
+ **Debug utilities**
163
+ - console logs, network tracing, screenshot, page `eval`
164
+
165
+ ---
166
+
167
+ ## Positioning
168
+
169
+ | Tool | Best for | Gap vs `vite-browser` |
170
+ |---|---|---|
171
+ | `agent-browser` | general browser automation | no Vite runtime awareness |
172
+ | `next-browser` | Next.js + React debugging | not a Vite runtime tool |
173
+ | `vite-plugin-vue-mcp` | Vue MCP integration | requires plugin install, Vue only |
174
+ | `vite-browser` | Vite runtime diagnostics for agents and developers | browser lifecycle coverage still expanding |
175
+
176
+ `vite-browser` requires no changes to your project. It works against any running Vite dev server across Vue, React, and Svelte.
177
+
178
+ ---
179
+
180
+ ## Recommended Workflows
181
+
182
+ ### HMR / runtime triage
183
+ ```bash
184
+ vite-browser vite runtime
185
+ vite-browser errors --mapped --inline-source
186
+ vite-browser correlate errors --mapped --window 5000
187
+ vite-browser diagnose hmr --limit 50
188
+ vite-browser vite hmr trace --limit 50
189
+ vite-browser vite module-graph trace --limit 200
190
+ ```
191
+
192
+ ### Propagation / rerender triage
193
+ ```bash
194
+ vite-browser correlate renders --window 5000
195
+ vite-browser diagnose propagation --window 5000
196
+ vite-browser vue pinia
197
+ vite-browser vue tree
198
+ ```
199
+
200
+ ### Data / API triage
201
+ ```bash
202
+ vite-browser errors --mapped
203
+ vite-browser logs
204
+ vite-browser network
205
+ vite-browser network <idx>
206
+ vite-browser eval '<state probe>'
207
+ ```
208
+
209
+ ### Component / state triage
210
+ ```bash
211
+ vite-browser detect
212
+ vite-browser vue tree
213
+ vite-browser vue pinia
214
+ vite-browser vue router
215
+ vite-browser react tree
216
+ vite-browser svelte tree
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Command Reference
222
+
223
+ ### Browser
224
+ ```bash
225
+ vite-browser open <url> [--cookies-json <file>]
226
+ vite-browser close
227
+ vite-browser goto <url>
228
+ vite-browser back
229
+ vite-browser reload
230
+ ```
231
+
232
+ ### Framework
233
+ ```bash
234
+ vite-browser detect
235
+ vite-browser vue tree [id]
236
+ vite-browser vue pinia [store]
237
+ vite-browser vue router
238
+ vite-browser react tree [id]
239
+ vite-browser svelte tree [id]
240
+ ```
241
+
242
+ ### Vite Runtime
243
+ ```bash
244
+ vite-browser vite restart
245
+ vite-browser vite runtime
246
+ vite-browser vite hmr
247
+ vite-browser vite hmr trace [--limit <n>]
248
+ vite-browser vite hmr clear
249
+ vite-browser vite module-graph [--filter <txt>] [--limit <n>]
250
+ vite-browser vite module-graph trace [--filter <txt>] [--limit <n>]
251
+ vite-browser vite module-graph clear
252
+ vite-browser errors
253
+ vite-browser errors --mapped
254
+ vite-browser errors --mapped --inline-source
255
+ vite-browser correlate errors [--window <ms>]
256
+ vite-browser correlate renders [--window <ms>]
257
+ vite-browser correlate errors --mapped --inline-source
258
+ vite-browser diagnose hmr [--window <ms>] [--limit <n>]
259
+ vite-browser diagnose propagation [--window <ms>]
260
+ ```
261
+
262
+ ### Utilities
263
+ ```bash
264
+ vite-browser logs
265
+ vite-browser network [idx]
266
+ vite-browser screenshot
267
+ vite-browser eval <script>
268
+ ```
269
+
270
+ ---
271
+
272
+ ## Current Boundaries
273
+
274
+ `v0.3.1` is strong at:
206
275
  - surfacing runtime state as structured shell output
207
- - linking current errors to recent HMR/module activity
208
- - detecting several common HMR failure patterns quickly
209
-
210
- It is not yet a full propagation-trace engine. In particular, it does not reliably infer deep chains like `store -> component A -> component B -> error` across arbitrary component graphs.
211
-
212
- ## Command Reference
213
-
214
- ### Browser
215
-
216
- ```bash
217
- vite-browser open <url> [--cookies-json <file>]
218
- vite-browser close
219
- vite-browser goto <url>
220
- vite-browser back
221
- vite-browser reload
222
- ```
223
-
224
- ### Framework
225
-
226
- ```bash
227
- vite-browser detect
228
- vite-browser vue tree [id]
229
- vite-browser vue pinia [store]
230
- vite-browser vue router
231
- vite-browser react tree [id]
232
- vite-browser svelte tree [id]
233
- ```
234
-
235
- ### Vite Runtime
236
-
237
- ```bash
238
- vite-browser vite restart
239
- vite-browser vite runtime
240
- vite-browser vite hmr
241
- vite-browser vite hmr trace [--limit <n>]
242
- vite-browser vite hmr clear
243
- vite-browser vite module-graph [--filter <txt>] [--limit <n>]
244
- vite-browser vite module-graph trace [--filter <txt>] [--limit <n>]
245
- vite-browser vite module-graph clear
246
- vite-browser errors
247
- vite-browser errors --mapped
248
- vite-browser errors --mapped --inline-source
249
- vite-browser correlate errors [--window <ms>]
250
- vite-browser correlate errors --mapped --inline-source
251
- vite-browser diagnose hmr [--window <ms>] [--limit <n>]
252
- ```
253
-
254
- ### Utilities
255
-
256
- ```bash
257
- vite-browser logs
258
- vite-browser network [idx]
259
- vite-browser screenshot
260
- vite-browser eval <script>
261
- ```
262
-
263
- ## Skill Packs
264
-
265
- The entry skill routes to specialized workflows:
266
-
267
- - `skills/vite-browser-core-debug/SKILL.md`
268
- - `skills/vite-browser-runtime-diagnostics/SKILL.md`
269
- - `skills/vite-browser-network-regression/SKILL.md`
270
- - `skills/vite-browser-release-smoke/SKILL.md`
271
-
272
- Router definition: [skills/SKILL.md](./skills/SKILL.md)
273
-
274
- ## Local Development
275
-
276
- ```bash
277
- pnpm install
278
- pnpm build
279
- pnpm test
280
- pnpm test:coverage
281
- pnpm test:evals
282
- pnpm test:evals:e2e
283
- ```
284
-
285
- ## Discovery
286
-
287
- If you want to introduce the project to new users, start with the launch kit in [docs/launch-kit.md](./docs/launch-kit.md).
288
-
289
- ## Requirements
290
-
291
- - Node.js `>=20`
292
- - Chromium installed via Playwright
293
- - Running Vite dev server
294
-
295
- ## License
296
-
297
- MIT
276
+ - linking current errors to recent HMR and module activity
277
+ - detecting common HMR failure patterns with confidence levels
278
+ - narrowing likely store/module -> render paths in Vue-first flows
279
+ - capturing browser-side runtime errors even when the Vite overlay is absent
280
+
281
+ `correlate renders` and `diagnose propagation` are **high-confidence propagation clues**, not strict causal proof. They do not reliably trace deep chains like `store -> component A -> component B -> error` across arbitrary graphs, and intentionally fall back to conservative output when evidence is incomplete.
282
+
283
+ React store inspection (Zustand, Redux) and deeper cross-framework propagation tracing are on the roadmap.
284
+
285
+ ---
286
+
287
+ ## Skill Packs
288
+
289
+ ```
290
+ skills/vite-browser-core-debug/SKILL.md
291
+ skills/vite-browser-runtime-diagnostics/SKILL.md
292
+ skills/vite-browser-network-regression/SKILL.md
293
+ skills/vite-browser-release-smoke/SKILL.md
294
+ ```
295
+
296
+ Router: [skills/SKILL.md](./skills/SKILL.md)
297
+
298
+ ---
299
+
300
+ ## Local Development
301
+
302
+ ```bash
303
+ pnpm install
304
+ pnpm build
305
+ pnpm test
306
+ pnpm test:coverage
307
+ pnpm test:evals
308
+ pnpm test:evals:e2e
309
+ ```
310
+
311
+ ## Requirements
312
+
313
+ - Node.js `>=20`
314
+ - Chromium via Playwright
315
+ - Running Vite dev server
316
+
317
+ ## License
318
+
319
+ MIT
@@ -0,0 +1,3 @@
1
+ import type { VBEvent } from "./event-queue.js";
2
+ export declare function initBrowserEventCollector(): void;
3
+ export declare function readBrowserEvents(): VBEvent[];