Skip to content

Commit 42ce866

Browse files
antfuclaude
andcommitted
refactor(devframe): namespace adapters and invert client dep from kit
Move the six adapters (cli/build/spa/vite/kit/embedded) into `devframe/adapters/*` so they're clearly grouped and no longer share the top-level subpath namespace. Relocate the framework-neutral RPC client surface from `@vitejs/devtools-kit/client` into `devframe/client`, including `rpc`, `rpc-shared-state`, `rpc-static`, `rpc-ws`, `static-rpc`, `docks`, and `context`. Kit now re-exports `devframe/client` plus its kit-only `remote` + `client-script` helpers, establishing that devframe must never depend on vite or any `@vitejs/*` package. Add a Dep Boundary section to AGENTS.md documenting the rule. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ca7cb67 commit 42ce866

49 files changed

Lines changed: 207 additions & 253 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Monorepo (`pnpm` workspaces + `turbo`). ESM TypeScript; bundled with `tsdown`. P
88

99
| Package | npm | Description |
1010
|---------|-----|-------------|
11-
| `packages/devframe` | `devframe` | Framework-neutral foundation — RPC layer (birpc + valibot + WS presets), host classes, createHostContext, six adapters (cli/build/spa/vite/kit/embedded), connectDevtool client |
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 |
1212
| `packages/core` | `@vitejs/devtools` | Vite plugin, CLI, standalone/webcomponents client. Wraps devframe's createHostContext with the Vite plugin scan |
1313
| `packages/kit` | `@vitejs/devtools-kit` | Vite-specific superset of devframe — adds PluginWithDevTools, ViteDevToolsNodeContext, and re-exports devframe's public types |
1414
| `packages/ui` | `@vitejs/devtools-ui` | Shared UI components, composables, and UnoCSS preset (`presetDevToolsUI`). Private, not published |
@@ -32,6 +32,10 @@ flowchart TD
3232
webext --> core
3333
```
3434

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+
3539
## Architecture
3640

3741
- **Entry**: `createDevToolsContext` (`packages/core/src/node/context.ts`) builds `DevToolsNodeContext` with hosts for RPC, docks, views, terminals. Invokes `plugin.devtools.setup` hooks.

alias.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export const alias = {
2121
'devframe/utils/shared-state': r('devframe/src/utils/shared-state.ts'),
2222
'devframe/utils/state': r('devframe/src/utils/state.ts'),
2323
'devframe/utils/when': r('devframe/src/utils/when.ts'),
24-
'devframe/cli': r('devframe/src/cli.ts'),
25-
'devframe/build': r('devframe/src/build.ts'),
26-
'devframe/spa': r('devframe/src/spa.ts'),
27-
'devframe/vite': r('devframe/src/vite.ts'),
28-
'devframe/kit': r('devframe/src/kit.ts'),
29-
'devframe/embedded': r('devframe/src/embedded.ts'),
30-
'devframe/client': r('devframe/src/client.ts'),
24+
'devframe/adapters/cli': r('devframe/src/adapters/cli.ts'),
25+
'devframe/adapters/build': r('devframe/src/adapters/build.ts'),
26+
'devframe/adapters/spa': r('devframe/src/adapters/spa.ts'),
27+
'devframe/adapters/vite': r('devframe/src/adapters/vite.ts'),
28+
'devframe/adapters/kit': r('devframe/src/adapters/kit.ts'),
29+
'devframe/adapters/embedded': r('devframe/src/adapters/embedded.ts'),
30+
'devframe/client': r('devframe/src/client/index.ts'),
3131
'devframe': r('devframe/src'),
3232
'@vitejs/devtools-kit/node': r('kit/src/node/index.ts'),
3333
'@vitejs/devtools-kit/client': r('kit/src/client/index.ts'),

examples/devframe-counter/bin.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import process from 'node:process'
3-
import { createCli } from 'devframe/cli'
3+
import { createCli } from 'devframe/adapters/cli'
44
import devtool from './src/devtool.ts'
55

66
async function main() {

packages/devframe/package.json

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
"sideEffects": false,
2121
"exports": {
2222
".": "./dist/index.mjs",
23-
"./build": "./dist/build.mjs",
24-
"./cli": "./dist/cli.mjs",
25-
"./client": "./dist/client.mjs",
23+
"./adapters/build": "./dist/adapters/build.mjs",
24+
"./adapters/cli": "./dist/adapters/cli.mjs",
25+
"./adapters/embedded": "./dist/adapters/embedded.mjs",
26+
"./adapters/kit": "./dist/adapters/kit.mjs",
27+
"./adapters/spa": "./dist/adapters/spa.mjs",
28+
"./adapters/vite": "./dist/adapters/vite.mjs",
29+
"./client": "./dist/client/index.mjs",
2630
"./constants": "./dist/constants.mjs",
27-
"./embedded": "./dist/embedded.mjs",
28-
"./kit": "./dist/kit.mjs",
2931
"./node": "./dist/node/index.mjs",
3032
"./rpc": "./dist/rpc/index.mjs",
3133
"./rpc/client": "./dist/rpc/client.mjs",
3234
"./rpc/server": "./dist/rpc/server.mjs",
3335
"./rpc/transports/ws-client": "./dist/rpc/transports/ws-client.mjs",
3436
"./rpc/transports/ws-server": "./dist/rpc/transports/ws-server.mjs",
35-
"./spa": "./dist/spa.mjs",
3637
"./types": "./dist/types/index.mjs",
3738
"./utils/events": "./dist/utils/events.mjs",
3839
"./utils/human-id": "./dist/utils/human-id.mjs",
@@ -41,7 +42,6 @@
4142
"./utils/shared-state": "./dist/utils/shared-state.mjs",
4243
"./utils/state": "./dist/utils/state.mjs",
4344
"./utils/when": "./dist/utils/when.mjs",
44-
"./vite": "./dist/vite.mjs",
4545
"./package.json": "./package.json"
4646
},
4747
"types": "./dist/index.d.ts",
@@ -72,21 +72,13 @@
7272
"tsdown": "catalog:build"
7373
},
7474
"inlinedDependencies": {
75-
"@jridgewell/trace-mapping": "0.3.31",
76-
"@oxc-project/types": "0.126.0",
77-
"@rolldown/pluginutils": "1.0.0-rc.16",
7875
"acorn": "8.16.0",
79-
"esbuild": "0.28.0",
8076
"human-id": "4.1.3",
8177
"immer": "11.1.4",
8278
"mlly": "1.8.2",
8379
"obug": "2.1.1",
8480
"perfect-debounce": "2.1.0",
85-
"postcss": "8.5.10",
86-
"rolldown": "1.0.0-rc.16",
87-
"terser": "5.44.1",
8881
"tinyexec": "1.1.1",
89-
"ua-parser-modern": "0.1.1",
90-
"vite": "8.0.9"
82+
"ua-parser-modern": "0.1.1"
9183
}
9284
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import type { DevtoolDefinition } from './types/devtool'
2+
import type { DevtoolDefinition } from '../types/devtool'
33
import { existsSync } from 'node:fs'
44
import fs from 'node:fs/promises'
55
import process from 'node:process'
@@ -10,10 +10,10 @@ import {
1010
DEVTOOLS_DIRNAME,
1111
DEVTOOLS_RPC_DUMP_DIRNAME,
1212
DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME,
13-
} from './constants'
14-
import { createHostContext } from './node/context'
15-
import { createH3DevToolsHost } from './node/host-h3'
16-
import { collectStaticRpcDump } from './node/static-dump'
13+
} from '../constants'
14+
import { createHostContext } from '../node/context'
15+
import { createH3DevToolsHost } from '../node/host-h3'
16+
import { collectStaticRpcDump } from '../node/static-dump'
1717

1818
export interface BuildStaticOptions {
1919
outDir: string
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import type { DevtoolDefinition } from './types/devtool'
1+
import type { DevtoolDefinition } from '../types/devtool'
22
import process from 'node:process'
33
import c from 'ansis'
44
import cac from 'cac'
55
import { getPort } from 'get-port-please'
66
import { createApp } from 'h3'
77
import { resolve } from 'pathe'
88
import sirv from 'sirv'
9+
import { DEVTOOLS_MOUNT_PATH } from '../constants'
10+
import { createHostContext } from '../node/context'
11+
import { createH3DevToolsHost } from '../node/host-h3'
12+
import { startHttpAndWs } from '../node/server'
913
import { buildStatic } from './build'
10-
import { DEVTOOLS_MOUNT_PATH } from './constants'
11-
import { createHostContext } from './node/context'
12-
import { createH3DevToolsHost } from './node/host-h3'
13-
import { startHttpAndWs } from './node/server'
1414
import { buildSpa } from './spa'
1515

1616
export interface CreateCliOptions {

packages/devframe/src/embedded.ts renamed to packages/devframe/src/adapters/embedded.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { DevToolsNodeContext } from './types/context'
2-
import type { DevtoolDefinition } from './types/devtool'
1+
import type { DevToolsNodeContext } from '../types/context'
2+
import type { DevtoolDefinition } from '../types/devtool'
33

44
/**
55
* Register a devtool into an already-running devframe/Kit context at
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DevtoolDefinition } from './types/devtool'
1+
import type { DevtoolDefinition } from '../types/devtool'
22

33
export interface KitPlugin {
44
name: string
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import type { DevtoolDefinition } from './types/devtool'
2+
import type { DevtoolDefinition } from '../types/devtool'
33
import fs from 'node:fs/promises'
44
import c from 'ansis'
55
import { resolve } from 'pathe'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DevtoolDefinition } from './types/devtool'
1+
import type { DevtoolDefinition } from '../types/devtool'
22
import { resolve } from 'pathe'
33
import sirv from 'sirv'
44

0 commit comments

Comments
 (0)