Skip to content

Commit 97bc45b

Browse files
authored
refactor: consolidate MCP and dump trees, standardize util imports (#11)
1 parent e963e8f commit 97bc45b

40 files changed

Lines changed: 57 additions & 70 deletions

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ The `pnpm test` script intentionally runs `build` first so `tsnapi` snapshots co
3030
## Conventions
3131

3232
- RPC functions must use `defineRpcFunction`; always namespace IDs (`my-plugin:fn-name`).
33-
- Shared state via `utils/shared-state`; keep values serializable.
33+
- Shared state via `devframe/utils/shared-state`; keep values serializable.
34+
- Utility imports use the package-path form `devframe/utils/*`, never relative `../utils/*`.
3435
- Dependencies go through the pnpm catalogs in `pnpm-workspace.yaml` (`cli`, `inlined`, `testing`, `types`) — add to a catalog and reference as `catalog:<name>`, don't pin versions in `package.json`.
3536

3637
### Devframe design principles

alias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const alias = {
3434
'devframe/adapters/build': r('devframe/src/adapters/build.ts'),
3535
'devframe/helpers/vite': r('devframe/src/helpers/vite.ts'),
3636
'devframe/adapters/embedded': r('devframe/src/adapters/embedded.ts'),
37-
'devframe/adapters/mcp': r('devframe/src/adapters/mcp.ts'),
37+
'devframe/adapters/mcp': r('devframe/src/adapters/mcp/index.ts'),
3838
'@devframes/nuxt/runtime/plugin.client': r('nuxt/src/runtime/plugin.client.ts'),
3939
'@devframes/nuxt': r('nuxt/src/index.ts'),
4040
'devframe/recipes/open-helpers': r('devframe/src/recipes/open-helpers.ts'),

docs/errors/DF0017.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ The agent-native surface is experimental and may change without a major version
2828

2929
## Source
3030

31-
- [`packages/devframe/src/node/mcp/build-server.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/node/mcp/build-server.ts)`createMcpServer()` throws `DF0017` when the requested transport is unsupported or when the underlying transport fails to `connect()`.
31+
- [`packages/devframe/src/adapters/mcp/build-server.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/adapters/mcp/build-server.ts)`createMcpServer()` throws `DF0017` when the requested transport is unsupported or when the underlying transport fails to `connect()`.

docs/errors/DF0024.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Add either `handler: ...` directly on the definition, or `setup: ctx => ({ handl
1919
## Source
2020

2121
- [`packages/devframe/src/rpc/handler.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/handler.ts) — invocation throws `DF0024` when neither `handler` nor a `setup` returning `{ handler }` is provided.
22-
- [`packages/devframe/src/rpc/dumps.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dumps.ts) — dump generation also requires a handler and throws `DF0024` if the definition is incomplete.
22+
- [`packages/devframe/src/rpc/dump/index.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dump/index.ts) — dump generation also requires a handler and throws `DF0024` if the definition is incomplete.

docs/errors/DF0025.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Re-run `createBuild` to regenerate the dump, or check that the call site uses th
1818

1919
## Source
2020

21-
- [`packages/devframe/src/rpc/dumps.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dumps.ts) — the static-mode dump resolver throws `DF0025` when a client calls a function name that is not present in the baked dump store.
21+
- [`packages/devframe/src/rpc/dump/index.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dump/index.ts) — the static-mode dump resolver throws `DF0025` when a client calls a function name that is not present in the baked dump store.

docs/errors/DF0026.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ defineRpcFunction({
2828

2929
## Source
3030

31-
- [`packages/devframe/src/rpc/dumps.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dumps.ts) — the static-mode dump resolver throws `DF0026` when none of the pre-computed inputs matches the call's args and no `fallback` was configured.
31+
- [`packages/devframe/src/rpc/dump/index.ts`](https://github.com/vitejs/devtools/blob/main/devframe/packages/devframe/src/rpc/dump/index.ts) — the static-mode dump resolver throws `DF0026` when none of the pre-computed inputs matches the call's args and no `fallback` was configured.

packages/devframe/src/adapters/build.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { DevframeDefinition } from '../types/devframe'
33
import { existsSync } from 'node:fs'
44
import fs from 'node:fs/promises'
55
import process from 'node:process'
6+
import { colors as c } from 'devframe/utils/colors'
7+
import { structuredCloneStringify } from 'devframe/utils/structured-clone'
68
import { dirname, resolve } from 'pathe'
79
import {
810
DEVTOOLS_CONNECTION_META_FILENAME,
@@ -11,10 +13,8 @@ import {
1113
} from '../constants'
1214
import { createHostContext } from '../node/context'
1315
import { createH3DevToolsHost } from '../node/host-h3'
14-
import { collectStaticRpcDump } from '../node/static-dump'
16+
import { collectStaticRpcDump } from '../rpc/dump/static'
1517
import { strictJsonStringify } from '../rpc/serialization'
16-
import { colors as c } from '../utils/colors'
17-
import { structuredCloneStringify } from '../utils/structured-clone'
1818
import { resolveBasePath } from './_shared'
1919

2020
export interface CreateBuildOptions {

packages/devframe/src/adapters/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { H3 } from 'h3'
33
import type { DevframeDefinition } from '../types/devframe'
44
import process from 'node:process'
55
import cac from 'cac'
6-
import { colors as c } from '../utils/colors'
6+
import { colors as c } from 'devframe/utils/colors'
77
import { createBuild } from './build'
88
import { createDevServer, resolveDevServerPort } from './dev'
99
import { flagKeyToOption, isBooleanFlag, parseCliFlags } from './flags'

packages/devframe/src/adapters/dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { StartedServer } from '../node/server'
22
import type { DevframeDefinition, DevframeSetupInfo } from '../types/devframe'
33
import process from 'node:process'
4+
import { open } from 'devframe/utils/open'
5+
import { mountStaticHandler } from 'devframe/utils/serve-static'
46
import { getPort } from 'get-port-please'
57
import { H3 } from 'h3'
68
import { resolve } from 'pathe'
79
import { DEVTOOLS_CONNECTION_META_FILENAME } from '../constants'
810
import { createHostContext } from '../node/context'
911
import { createH3DevToolsHost } from '../node/host-h3'
1012
import { startHttpAndWs } from '../node/server'
11-
import { open } from '../utils/open'
12-
import { mountStaticHandler } from '../utils/serve-static'
1313
import { normalizeBasePath, resolveBasePath } from './_shared'
1414

1515
const DEFAULT_PORT = 9999

packages/devframe/src/node/mcp/__tests__/mcp-server.test.ts renamed to packages/devframe/src/adapters/mcp/__tests__/mcp-server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { DevToolsHost } from '../../../types/host'
22
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
33
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js'
4+
import { createHostContext } from 'devframe/node'
45
import { describe, expect, it } from 'vitest'
5-
import { createHostContext } from '../../context'
66
import { buildMcpServerFromContext } from '../build-server'
77

88
function nullHost(): DevToolsHost {

0 commit comments

Comments
 (0)