devframe 0.1.20 → 0.1.21

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.
Files changed (61) hide show
  1. package/dist/{_shared-S-Ujqz_L.mjs → _shared-iZy45oG3.mjs} +2 -2
  2. package/dist/adapters/build.d.mts +3 -3
  3. package/dist/adapters/build.mjs +7 -7
  4. package/dist/adapters/cli.d.mts +1 -1
  5. package/dist/adapters/cli.mjs +2 -2
  6. package/dist/adapters/dev.d.mts +2 -2
  7. package/dist/adapters/dev.mjs +1 -1
  8. package/dist/adapters/embedded.d.mts +2 -2
  9. package/dist/adapters/embedded.mjs +1 -1
  10. package/dist/adapters/mcp.d.mts +1 -1
  11. package/dist/adapters/mcp.mjs +4 -3
  12. package/dist/adapters/vite.d.mts +5 -4
  13. package/dist/adapters/vite.mjs +4 -3
  14. package/dist/client/index.d.mts +15 -145
  15. package/dist/client/index.mjs +3 -12
  16. package/dist/constants.d.mts +12 -15
  17. package/dist/constants.mjs +12 -29
  18. package/dist/context-BJ4r2SmR.mjs +1051 -0
  19. package/dist/context-internal-Dx_NoSv1.mjs +199 -0
  20. package/dist/context-internal-saIAfNVw.d.mts +51 -0
  21. package/dist/{dev-B8i_CBlQ.mjs → dev-CdAy400a.mjs} +6 -6
  22. package/dist/{devtool-Bm6zZAw5.d.mts → devtool-CNvLs2_Y.d.mts} +37 -538
  23. package/dist/diagnostics-DxPnRoXO.mjs +51 -0
  24. package/dist/{human-id-CHS0s28X.mjs → human-id-BLoGo_e5.mjs} +0 -1
  25. package/dist/{index-BCo03GEF.d.mts → index-CuLRIMto.d.mts} +1 -1
  26. package/dist/index.d.mts +4 -5
  27. package/dist/index.mjs +1 -4
  28. package/dist/internal/index.d.mts +16 -0
  29. package/dist/internal/index.mjs +3 -0
  30. package/dist/node/index.d.mts +14 -146
  31. package/dist/node/index.mjs +7 -6
  32. package/dist/recipes/open-helpers.d.mts +1 -1
  33. package/dist/recipes/open-helpers.mjs +1 -1
  34. package/dist/rpc/index.d.mts +2 -2
  35. package/dist/rpc/transports/ws-client.d.mts +1 -1
  36. package/dist/rpc/transports/ws-server.d.mts +1 -1
  37. package/dist/{server-DksyT-um.d.mts → server-BAqOajx_.d.mts} +1 -1
  38. package/dist/types/index.d.mts +4 -4
  39. package/dist/utils/events.d.mts +1 -1
  40. package/dist/utils/human-id.mjs +1 -1
  41. package/dist/utils/shared-state.d.mts +1 -1
  42. package/dist/utils/state.d.mts +1 -1
  43. package/dist/utils/streaming-channel.d.mts +1 -1
  44. package/dist/utils/when.d.mts +401 -2
  45. package/dist/{ws-client-DQySVfF_.d.mts → ws-client-CjPuPFbA.d.mts} +1 -1
  46. package/dist/{ws-server-VQqESKAs.d.mts → ws-server-C7LnhOHi.d.mts} +1 -1
  47. package/package.json +2 -5
  48. package/skills/devframe/SKILL.md +54 -100
  49. package/skills/devframe/templates/counter-devtool.ts +3 -8
  50. package/skills/devframe/templates/spa-devtool.ts +2 -7
  51. package/dist/adapters/kit.d.mts +0 -23
  52. package/dist/adapters/kit.mjs +0 -16
  53. package/dist/context-BfvbAyGk.mjs +0 -7215
  54. package/dist/main-DpINGndA.mjs +0 -601
  55. package/dist/when-aBBXAEh5.d.mts +0 -401
  56. package/dist/{host-h3-BMvrFzIJ.mjs → host-h3-9jeHcltx.mjs} +1 -1
  57. package/dist/{open-BtOOEldu.mjs → open-Dede_w9r.mjs} +4 -4
  58. /package/dist/{server-qRRM8t3v.mjs → server-CBsxXIH5.mjs} +0 -0
  59. /package/dist/{static-dump-C1aVSwxY.mjs → static-dump-D5VH8Iqk.mjs} +0 -0
  60. /package/dist/{transports-BPUzHhI2.mjs → transports-DSV5_5QM.mjs} +0 -0
  61. /package/dist/{types-ag029cAe.d.mts → types-C5OVe4AC.d.mts} +0 -0
@@ -1,20 +1,25 @@
1
1
  ---
2
2
  name: devframe
3
3
  description: >
4
- Use when building devtools with devframe — the framework-neutral
5
- foundation that powers Vite DevTools. Covers DevtoolDefinition,
6
- picking the right adapter (cli / build / spa / vite / kit / embedded /
7
- mcp), designing RPC contracts, registering docks / commands / logs /
8
- terminals, exposing an agent-native surface over MCP, and wiring the
9
- author's SPA client. Triggers on `devframe` imports, `defineDevtool`,
10
- `createCli`, `createMcpServer`, `connectDevtool`, and on migrations of
11
- existing inspectors (eslint-config-inspector, unocss-inspector,
12
- node-modules-inspector-style tools) to devframe.
4
+ Use when building one devtool integration with devframe — the
5
+ portable, framework-neutral container for a single tool. Covers
6
+ DevtoolDefinition, picking the right deployment adapter
7
+ (cli / build / spa / vite / embedded / mcp), designing RPC
8
+ contracts, exposing an agent-native surface over MCP, and wiring
9
+ the author's SPA client. Hub-only concerns (docks, terminals,
10
+ commands, the unified messages dock) belong to
11
+ `@vitejs/devtools-kit` see the `vite-devtools-kit` skill for
12
+ those. Triggers on `devframe` imports, `defineDevtool`,
13
+ `createCli`, `createMcpServer`, `connectDevtool`, and on
14
+ migrations of existing inspectors (eslint-config-inspector,
15
+ unocss-inspector, node-modules-inspector-style tools) to devframe.
13
16
  ---
14
17
 
15
18
  # devframe skill
16
19
 
17
- A devtool built on devframe is a **single `DevtoolDefinition`** plus an author-provided SPA. Use one of seven adapters to ship it. `devframe` must not depend on Vite or any `@vitejs/*` package it's the lowest-level layer in the monorepo, and the Kit / core packages build on top.
20
+ **Devframe is the container for one devtool integration, portable across viewers.** A devtool built on devframe is a single `DevtoolDefinition` plus an author-provided SPA the same definition deploys as a standalone CLI, a static report, an embedded SPA, an MCP server, or as a dock entry inside the Vite DevTools hub via `createPluginFromDevframe`.
21
+
22
+ Devframe deliberately stops at the boundary of one tool. Anything that only matters across multiple integrations — docks, terminals, command palette, cross-tool toasts — lives in `@vitejs/devtools-kit`, the hub layer. `devframe` must not depend on Vite, any `@vitejs/*` package, or hub-only concepts; it's the lowest-level layer in the monorepo.
18
23
 
19
24
  Full reference: [devfra.me/](https://devfra.me/).
20
25
 
@@ -28,7 +33,7 @@ All adapter factories share the shape `createXxx(devtoolDef, options?)`.
28
33
  | Run the dev server programmatically (any CLI framework) | `createDevServer(def, options?)` | `devframe/adapters/dev` |
29
34
  | Mount a SPA in an existing Vite dev server | `createVitePlugin(def, options?)` | `devframe/adapters/vite` |
30
35
  | Self-contained static deploy with baked data | `createBuild(def, options?)` | `devframe/adapters/build` |
31
- | Integrate into Vite DevTools | `createKitPlugin(def, options?)` | `devframe/adapters/kit` |
36
+ | Integrate into Vite DevTools | `createPluginFromDevframe(def, options?)` | `@vitejs/devtools-kit/node` |
32
37
  | Register dynamically at runtime | `createEmbedded(def, { ctx })` | `devframe/adapters/embedded` |
33
38
  | Expose to coding agents (MCP) | `createMcpServer(def, options?)` | `devframe/adapters/mcp` *(experimental)* |
34
39
 
@@ -50,17 +55,12 @@ export default defineDevtool({
50
55
  type: 'static',
51
56
  handler: () => ({ count: 42 }),
52
57
  }))
53
- ctx.docks.register({
54
- id: 'my-inspector',
55
- title: 'My Inspector',
56
- icon: 'ph:magnifying-glass-duotone',
57
- type: 'iframe',
58
- url: '/.devtools/',
59
- })
60
58
  },
61
59
  })
62
60
  ```
63
61
 
62
+ `setup(ctx)` registers RPC functions, shared state, diagnostics, and any other devframe-level wiring. It does **not** receive `docks` / `terminals` / `messages` / `commands` — those are hub features. When mounted into Vite DevTools via `createPluginFromDevframe(d)`, the kit auto-derives an iframe dock entry from `id` / `name` / `icon` / `basePath`; for richer hub-side behaviour (custom-render, terminals, palette commands) pass `options.setup` to `createPluginFromDevframe`.
63
+
64
64
  See `templates/counter-devtool.ts` for a runnable counter example, `templates/spa-devtool.ts` for an SPA-ready shape, and `templates/vite-client.ts` for the author's client entry.
65
65
 
66
66
  ## Namespacing
@@ -75,21 +75,19 @@ See `templates/counter-devtool.ts` for a runnable counter example, `templates/sp
75
75
 
76
76
  ## DevToolsNodeContext at a glance
77
77
 
78
- `setup(ctx)` receives the full server-side surface. Each host corresponds to a [docs](https://devfra.me/) page:
78
+ `setup(ctx)` receives the framework-neutral server-side surface. Each host corresponds to a [docs](https://devfra.me/) page:
79
79
 
80
80
  | Host | Purpose |
81
81
  |------|---------|
82
- | `ctx.rpc` | Register RPC functions, broadcast, shared state |
83
- | `ctx.docks` | Dock entries (iframe / action / custom-render / launcher / json-render) |
82
+ | `ctx.rpc` | Register RPC functions, broadcast, shared state, streaming channels |
84
83
  | `ctx.views` | Serve static files via `hostStatic(base, distDir)` |
85
- | `ctx.commands` | Command palette entries with keybindings + `when` gating |
86
- | `ctx.messages` | Structured message entries, toasts, file / element positions |
87
84
  | `ctx.diagnostics` | Structured diagnostics host (logs-sdk) — register custom error codes |
88
- | `ctx.terminals` | Spawn and stream child processes |
89
85
  | `ctx.agent` | Expose tools + resources to coding agents (experimental) |
90
86
  | `ctx.host` | Runtime abstraction — `mountStatic`, `resolveOrigin`, `getStorageDir` |
91
87
  | `ctx.mode` | `'dev'` or `'build'` — gate setup work per runtime |
92
88
 
89
+ > Hub-only hosts (`ctx.docks`, `ctx.terminals`, `ctx.messages`, `ctx.commands`) only exist when the devtool is mounted into Vite DevTools via `createPluginFromDevframe`. See the [`vite-devtools-kit` skill](../../skills/vite-devtools-kit) for those.
90
+
93
91
  ## RPC contracts
94
92
 
95
93
  ```ts
@@ -240,84 +238,36 @@ Readable.fromWeb(reader.readable).pipe(targetNodeWritable)
240
238
 
241
239
  For chat-style UIs that combine both: keep the **conversation log** in shared state (survives reconnects), and use a streaming channel for **active responses**. The action that starts a response appends a placeholder to shared state; on producer close, commit the joined content back to shared state. Working example: [`devframe/examples/devframe-streaming-chat`](https://github.com/vitejs/devtools/tree/main/devframe/examples/devframe-streaming-chat).
242
240
 
243
- ## Dock entries
241
+ ## Mounting into Vite DevTools
244
242
 
245
- Five entry types: `iframe` (full panel), `action` (client script on click), `custom-render` (mount into panel DOM), `launcher` (setup card + server callback), `json-render` (UI from a JSON spec, zero client code).
243
+ A portable devframe definition is dropped into the Vite DevTools hub via `createPluginFromDevframe`:
246
244
 
247
245
  ```ts
248
- // Iframe — most common:
249
- ctx.docks.register({
250
- id: 'my-inspector',
251
- title: 'My Inspector',
252
- icon: 'ph:magnifying-glass-duotone',
253
- type: 'iframe',
254
- url: '/.my-inspector/',
255
- })
256
-
257
- ctx.views.hostStatic('/.my-inspector/', clientDist)
258
- ```
259
-
260
- All entries accept `when` for conditional visibility and `badge` for short indicator text. See `/devframe/dock-system` for the full type reference.
261
-
262
- ### Remote docks
263
-
264
- Set `remote: true` on an iframe dock to turn a hosted URL into a live DevFrame client. DevFrame injects an auth-approved connection descriptor into the iframe URL; on the hosted page, `connectDevtool()` parses it and returns a fully connected client — no extra wiring. Dev-mode only.
265
-
266
- ## Commands
267
-
268
- ```ts
269
- import { defineCommand } from 'devframe'
270
-
271
- ctx.commands.register(defineCommand({
272
- id: 'my-inspector:clear-cache',
273
- title: 'Clear Cache',
274
- icon: 'ph:trash-duotone',
275
- keybindings: [{ key: 'Mod+Shift+C' }],
276
- when: 'clientType == embedded',
277
- handler: async () => clearCache(),
278
- }))
246
+ // vite.config.ts
247
+ import { createPluginFromDevframe } from '@vitejs/devtools-kit/node'
248
+ import myInspector from './my-inspector'
249
+
250
+ export default {
251
+ plugins: [
252
+ createPluginFromDevframe(myInspector, {
253
+ // Optional kit-only setup — runs after the auto-derived dock entry.
254
+ setup(kitCtx) {
255
+ kitCtx.commands.register({
256
+ id: 'my-inspector:clear-cache',
257
+ title: 'Clear Cache',
258
+ handler: () => { /* ... */ },
259
+ })
260
+ },
261
+ }),
262
+ ],
263
+ }
279
264
  ```
280
265
 
281
- - Two-level hierarchy (parent + `children`) max.
282
- - Use `Mod` for platform-aware modifier (Cmd on macOS, Ctrl elsewhere).
283
- - `ctx.commands.execute(id, ...args)` runs a command programmatically.
284
- - `when` is a whenexpr expression — see below.
285
-
286
- ## Logs & notifications
287
-
288
- ```ts
289
- // Fire-and-forget
290
- ctx.messages.add({ message: 'Scan complete', level: 'success', notify: true })
291
-
292
- // With handle for in-place updates
293
- const handle = await ctx.messages.add({
294
- id: 'my-inspector:build',
295
- message: 'Building…',
296
- level: 'info',
297
- status: 'loading',
298
- })
299
- await handle.update({ message: 'Built', level: 'success', status: 'idle' })
300
- ```
301
-
302
- `notify: true` also renders a toast. `filePosition: { file, line, column }` makes the entry click-to-editor. `elementPosition: { selector, boundingBox }` highlights a DOM element. Re-adding with the same `id` updates the existing entry (deduplication pattern).
303
-
304
- ## Terminals
305
-
306
- ```ts
307
- const session = await ctx.terminals.startChildProcess(
308
- { command: 'vite', args: ['build', '--watch'], cwd: process.cwd() },
309
- { id: 'my-inspector:build', title: 'Build', icon: 'ph:terminal-duotone' },
310
- )
311
-
312
- await session.terminate()
313
- await session.restart()
314
- ```
315
-
316
- Color is enabled automatically (`FORCE_COLOR=true`). Output streams into the built-in Terminals panel and is buffered for late-joining clients.
266
+ The kit auto-derives an iframe dock entry from `id` / `name` / `icon` / `basePath`. For dock variations (custom-render, launcher, action, json-render), terminals, palette commands, and toasts, use the `options.setup` hook — those APIs live on the kit-augmented context, not on the devframe-level `setup`. See the [`vite-devtools-kit` skill](../../skills/vite-devtools-kit) for the hub-side reference.
317
267
 
318
268
  ## When clauses
319
269
 
320
- Gate dock / command visibility with VS Code-style expressions (evaluated by the external `whenexpr` package):
270
+ Gate kit-side dock / command visibility with VS Code-style expressions evaluated by the external `whenexpr` package. The runtime + types ship from `devframe/utils/when`, but the consumers (`when` field on docks and commands) live in the kit:
321
271
 
322
272
  ```ts
323
273
  when: 'clientType == embedded'
@@ -435,18 +385,22 @@ At runtime, static clients look up the argument hash in the dump; misses resolve
435
385
 
436
386
  ## Further reading
437
387
 
438
- All of the above has a dedicated page at [devfra.me](https://devfra.me/):
388
+ Devframe-level pages (one-tool, portable surface):
439
389
 
440
390
  - [Devtool Definition](https://devfra.me/devtool-definition) — fields, runtime flags, multi-adapter wiring
441
- - [Adapters](https://devfra.me/adapters) — full reference for all seven adapters
391
+ - [Adapters](https://devfra.me/adapters) — full reference for all deployment adapters
442
392
  - [RPC](https://devfra.me/rpc) — types, schema, broadcasts, dumps
443
393
  - [Shared State](https://devfra.me/shared-state) — patches, events, client-side mutation
444
394
  - [Streaming](https://devfra.me/streaming) — chunked feeds, uploads, replay, Web/Node Streams interop
445
- - [Dock System](https://devfra.me/dock-system) — every entry type + remote docks
446
- - [Commands](https://devfra.me/commands) — palette, keybindings, sub-commands
447
395
  - [When Clauses](https://devfra.me/when-clauses) — syntax, context, type-safe wrappers
448
- - [Messages & Notifications](https://devfra.me/messages) — entry fields, positional hints
449
396
  - [Structured Diagnostics](https://devfra.me/diagnostics) — coded errors via `ctx.diagnostics`, register custom codes
450
- - [Terminals](https://devfra.me/terminals) — child processes, external sessions
451
397
  - [Client](https://devfra.me/client) — auth handshake, modes, discovery
452
398
  - [Agent-Native](https://devfra.me/agent-native) — agent field, tools/resources, MCP + Claude Desktop
399
+
400
+ Hub-only surfaces (Vite DevTools Kit — only available when mounted into the hub):
401
+
402
+ - [Vite DevTools Kit overview](https://devtools.vite.dev/kit/)
403
+ - [Dock System](https://devtools.vite.dev/kit/dock-system) — every entry type + remote docks
404
+ - [Commands](https://devtools.vite.dev/kit/commands) — palette, keybindings, sub-commands
405
+ - [Messages & Notifications](https://devtools.vite.dev/kit/messages) — entry fields, positional hints
406
+ - [Terminals](https://devtools.vite.dev/kit/terminals) — child processes, external sessions
@@ -1,4 +1,6 @@
1
- // Smallest possible devtool.
1
+ // Smallest possible devtool. The dock entry is auto-derived from
2
+ // `id` / `name` / `icon` when this definition is mounted into Vite
3
+ // DevTools via `createPluginFromDevframe(devtool)`.
2
4
  import { defineDevtool, defineRpcFunction } from 'devframe'
3
5
 
4
6
  let counter = 0
@@ -18,12 +20,5 @@ export default defineDevtool({
18
20
  type: 'action',
19
21
  handler: () => ({ count: ++counter }),
20
22
  }))
21
- ctx.docks.register({
22
- id: 'counter',
23
- title: 'Counter',
24
- icon: 'ph:counter-duotone',
25
- type: 'iframe',
26
- url: '/counter/',
27
- })
28
23
  },
29
24
  })
@@ -1,4 +1,6 @@
1
1
  // Devtool with setupBrowser + SPA query-loader — deployable as a static site.
2
+ // When mounted into Vite DevTools via `createPluginFromDevframe`, the kit
3
+ // auto-derives an iframe dock from `id` / `name` / `icon`.
2
4
  import { defineDevtool, defineRpcFunction } from 'devframe'
3
5
  import * as v from 'valibot'
4
6
 
@@ -16,13 +18,6 @@ export default defineDevtool({
16
18
  return { url, verdict: 'ok' as const }
17
19
  },
18
20
  }))
19
- ctx.docks.register({
20
- id: 'my-inspector',
21
- title: 'My Inspector',
22
- icon: 'ph:magnifying-glass-duotone',
23
- type: 'iframe',
24
- url: '/my-inspector/',
25
- })
26
21
  },
27
22
  setupBrowser() {
28
23
  // Browser-side implementation — used by the SPA adapter so the
@@ -1,23 +0,0 @@
1
- import { r as DevtoolDefinition } from "../devtool-Bm6zZAw5.mjs";
2
-
3
- //#region src/adapters/kit.d.ts
4
- interface CreateKitPluginOptions {
5
- /**
6
- * Optional plugin name override. Defaults to `devframe:<devtool-id>`.
7
- */
8
- name?: string;
9
- }
10
- interface KitPlugin {
11
- name: string;
12
- devtools: {
13
- setup: DevtoolDefinition['setup'];
14
- capabilities?: DevtoolDefinition['capabilities'];
15
- };
16
- }
17
- /**
18
- * Produce a Vite plugin object that Kit's plugin-scan picks up via
19
- * `Plugin.devtools`.
20
- */
21
- declare function createKitPlugin(d: DevtoolDefinition, options?: CreateKitPluginOptions): KitPlugin;
22
- //#endregion
23
- export { CreateKitPluginOptions, KitPlugin, createKitPlugin };
@@ -1,16 +0,0 @@
1
- //#region src/adapters/kit.ts
2
- /**
3
- * Produce a Vite plugin object that Kit's plugin-scan picks up via
4
- * `Plugin.devtools`.
5
- */
6
- function createKitPlugin(d, options = {}) {
7
- return {
8
- name: options.name ?? `devframe:${d.id}`,
9
- devtools: {
10
- setup: d.setup,
11
- capabilities: d.capabilities
12
- }
13
- };
14
- }
15
- //#endregion
16
- export { createKitPlugin };