You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`packages/rpc`|`@vitejs/devtools-rpc`|Typed RPC wrapper over `birpc` with WS presets|
11
+
|`packages/devframe`|`devframe`|Framework-neutral foundation — RPC layer (birpc + valibot + WS presets), host classes, createHostContext, six adapters at `devframe/adapters/*` (cli/build/spa/vite/kit/embedded), connectDevtool client |
12
+
|`packages/core`|`@vitejs/devtools`|Vite plugin, CLI, standalone/webcomponents client. Wraps devframe's createHostContext with the Vite plugin scan|
13
+
|`packages/kit`|`@vitejs/devtools-kit`|Vite-specific superset of devframe — adds PluginWithDevTools, ViteDevToolsNodeContext, and re-exports devframe's public types|
14
14
|`packages/ui`|`@vitejs/devtools-ui`| Shared UI components, composables, and UnoCSS preset (`presetDevToolsUI`). Private, not published |
15
15
|`packages/rolldown`|`@vitejs/devtools-rolldown`| Nuxt UI for Rolldown build data. Serves at `/.devtools-rolldown/`|
16
16
|`packages/vite`|`@vitejs/devtools-vite`| Nuxt UI for Vite DevTools (WIP). Serves at `/.devtools-vite/`|
@@ -23,20 +23,25 @@ Other top-level directories:
23
23
24
24
```mermaid
25
25
flowchart TD
26
-
core["core"] --> kit & rpc
26
+
kit --> devframe
27
+
core --> kit
27
28
core --> rolldown & vite & self-inspect
28
-
rolldown --> kit & rpc & ui
29
-
vite --> kit & rpc & ui
30
-
self-inspect --> kit & rpc
29
+
rolldown --> kit & ui
30
+
vite --> kit & ui
31
+
self-inspect --> kit
31
32
webext --> core
32
33
```
33
34
35
+
## Dep Boundary
36
+
37
+
`packages/devframe` is the lowest-level package in this monorepo and is positioned to be extracted into its own repo. It MUST NOT import from `vite` or any `@vitejs/*` package — not as a `dependencies` entry, not as an inlined dep, not as a source import. `packages/kit` and above build on top of devframe, never the reverse.
38
+
34
39
## Architecture
35
40
36
41
-**Entry**: `createDevToolsContext` (`packages/core/src/node/context.ts`) builds `DevToolsNodeContext` with hosts for RPC, docks, views, terminals. Invokes `plugin.devtools.setup` hooks.
37
42
-**Node context**: server-side (cwd, vite config, mode, hosts, auth storage at `node_modules/.vite/devtools/auth.json`).
38
43
-**Client context**: webcomponents/Nuxt UI state (`packages/core/src/client/webcomponents/state/*`) — dock entries, panels, RPC client. Two modes: `embedded` (overlay in host app) and `standalone` (independent page).
39
-
-**WS server** (`packages/core/src/node/ws.ts`): RPC via `@vitejs/devtools-rpc/presets/ws`. Auth skipped in build mode or when `devtools.clientAuth` is `false`.
44
+
-**WS server** (`packages/core/src/node/ws.ts`): RPC via `devframe/rpc/transports/ws-server`. Auth skipped in build mode or when `devtools.clientAuth` is `false`.
40
45
-**Nuxt UI plugins** (rolldown, vite, self-inspect): each registers RPC functions and hosts static Nuxt SPA at its own base path.
41
46
42
47
## Development
@@ -57,11 +62,21 @@ pnpm -C docs run docs # docs dev server
57
62
58
63
- Use workspace aliases from `alias.ts`.
59
64
- RPC functions must use `defineRpcFunction` from kit; always namespace IDs (`my-plugin:fn-name`).
60
-
- Shared state via `@vitejs/devtools-kit/utils/shared-state`; keep values serializable.
65
+
- Shared state via `devframe/utils/shared-state`; keep values serializable.
61
66
- Nuxt UI base paths: `/.devtools-rolldown/`, `/.devtools-vite/`, `/.devtools-self-inspect/`.
62
67
- Shared UI components/preset in `packages/ui`; use `presetDevToolsUI` from `@vitejs/devtools-ui/unocss`.
63
68
- Currently focused on Rolldown build-mode analysis; dev-mode support is deferred.
64
69
70
+
### Devframe design principles
71
+
72
+
These apply to everything inside `packages/devframe` and to how host packages (`kit`, `core`, etc.) layer on top. When in doubt, err on the side of "devframe provides hooks, the app decides UX".
73
+
74
+
-**Headless by default.** No default startup banners, no opinionated logging to stdout, no default styling. Provide hooks (`onReady`, `cli.configure`, etc.); let the application print its own branding. Structured diagnostics via `logs-sdk` are fine — ad-hoc `console.log`s baked into adapters are not.
75
+
-**File watching is the app's job, not devframe's.** Don't add a generic watcher primitive. Authors wire chokidar / fs.watch / watchman themselves and signal change via `ctx.rpc.sharedState.set(...)` or event-type RPCs. devframe stays out of the filesystem-observation business.
76
+
-**Mount path depends on adapter context.** Given `id: 'foo'`, the default mount path is `/.foo/` for *hosted* adapters (`vite`, `kit`, `embedded`) and `/` for *standalone* adapters (`cli`, `spa`, `build`). Authors override via `DevtoolDefinition.basePath`. Don't hardcode `DEVTOOLS_MOUNT_PATH` in adapter code paths that may run standalone.
77
+
-**SPAs own their basePath at runtime.** Build SPAs with relative asset paths (`vite.base: './'`); discover the effective base in the browser from the executing script's location / `document.baseURI`. `createBuild` / `createSpa` copy SPA output verbatim — no HTML rewriting, no build-time `--base` injection. The client (`connectDevtool`) resolves `.connection.json` relative to the runtime base automatically.
78
+
-**CLI flags compose from both sides.** The `cac` instance backing `createCli` is exposed both to the `DevtoolDefinition` (`cli.configure(cli)`) — for capabilities contributed by the tool itself — and to the `createCli` caller — for flags added at the final assembly stage. Parsed flag values are forwarded to `setup(ctx, { flags })`. Never hardcode domain-specific flags into `createCli`.
79
+
65
80
## Structured Diagnostics (Error Codes)
66
81
67
82
All node-side warnings and errors use structured diagnostics via [`logs-sdk`](https://github.com/vercel-labs/logs-sdk). Never use raw `console.warn`, `console.error`, or `throw new Error` with ad-hoc messages in node-side code — always define a coded diagnostic.
@@ -70,7 +85,8 @@ All node-side warnings and errors use structured diagnostics via [`logs-sdk`](ht
Framework-neutral foundation for building generic DevTools — an RPC layer (birpc + valibot + WS presets), runtime hosts (RPC / docks / views / terminals / logs / commands / agent), and adapters that deploy a single devtool definition to seven targets: `cli`, `build`, `vite`, `kit`, `embedded`, `mcp`, plus the `spa` mode.
4
+
5
+
## Layout
6
+
7
+
This directory is staged for extraction into a standalone repository. Until then it lives inside the [`vitejs/devtools`](https://github.com/vitejs/devtools) monorepo.
8
+
9
+
| Path | Description |
10
+
|------|-------------|
11
+
|[`packages/devframe`](./packages/devframe)| The published [`devframe`](https://www.npmjs.com/package/devframe) npm package. |
12
+
|[`docs`](./docs)| VitePress documentation site, deployed at https://devtools.vite.dev/devframe/.|
13
+
|[`examples`](./examples)| End-to-end demos: [`devframe-counter`](./examples/devframe-counter) (smallest cross-adapter demo) and [`devframe-files-inspector`](./examples/devframe-files-inspector) (CLI dev/build/spa + Vite DevTools dock). |
14
+
|[`tests`](./tests)| Public-API snapshot tests via [`tsnapi`](https://github.com/posva/tsnapi). |
15
+
16
+
## Install
17
+
18
+
```sh
19
+
pnpm add devframe
20
+
```
21
+
22
+
## Documentation
23
+
24
+
See [https://devtools.vite.dev/devframe/](https://devtools.vite.dev/devframe/) for the full guide and API reference.
0 commit comments