Skip to content

Commit 78ce8d7

Browse files
committed
docs: update
1 parent 81fd1be commit 78ce8d7

26 files changed

Lines changed: 128 additions & 123 deletions

docs/app/assets/css/devframe.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@
4545
.mermaid svg {
4646
width: 100%;
4747
}
48+
49+
/* Do not render "description" slot */
50+
[data-slot="description"] {
51+
display: none;
52+
}

docs/content/1.guide/10.standalone-cli.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { resolve } from 'pathe'
3232

3333
const clientAssets = resolve(import.meta.dirname, '../dist/public')
3434

35-
const devframe = defineDevframe({
35+
const myDevframe = defineDevframe({
3636
id: 'my-tool',
3737
name: 'My Tool',
3838
clientAssets,
@@ -62,7 +62,7 @@ const devframe = defineDevframe({
6262
},
6363
})
6464

65-
await createCac(devframe, {
65+
await createCac(myDevframe, {
6666
onReady({ origin }) {
6767
console.log(c.green`My Tool ready at ${origin}`)
6868
},
@@ -292,7 +292,7 @@ import { defineDevframe } from 'devframe'
292292
import { createBuild } from 'devframe/adapters/build'
293293
import { createDevServer } from 'devframe/adapters/dev'
294294

295-
const devframe = defineDevframe({
295+
const myDevframe = defineDevframe({
296296
id: 'my-tool',
297297
name: 'My Tool',
298298
clientAssets: './dist/public',
@@ -307,7 +307,7 @@ program
307307
.option('-p, --port <port>', 'Port', '7777')
308308
.option('--config <file>', 'Config file path')
309309
.action(async (opts) => {
310-
const handle = await createDevServer(devframe, {
310+
const handle = await createDevServer(myDevframe, {
311311
port: Number(opts.port),
312312
flags: { config: opts.config },
313313
onReady: ({ origin }) => console.log(`Ready at ${origin}`),
@@ -318,7 +318,7 @@ program
318318
program
319319
.command('build')
320320
.option('--out-dir <dir>', 'Output directory', 'dist-static')
321-
.action(opts => createBuild(devframe, { outDir: opts.outDir }))
321+
.action(opts => createBuild(myDevframe, { outDir: opts.outDir }))
322322

323323
await program.parseAsync()
324324
```

docs/content/1.guide/11.client.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { connectDevframe } from 'devframe/client'
1414

1515
const rpc = await connectDevframe()
1616

17-
const modules = await rpc.call('my-devframe:get-modules', { limit: 10 })
17+
const modules = await rpc.call('my-tool:get-modules', { limit: 10 })
1818
```
1919

2020
At the default mount path, `connectDevframe` needs no arguments — it auto-detects the backend via `__devframe/__connection.json`.
@@ -120,7 +120,7 @@ const ok = await rpc.requestTrustWithToken('a1b2c3…')
120120
Derive a [scoped client](/guide/scoped-context) for namespaced ids:
121121

122122
```ts
123-
const my = (await connectDevframe()).scope('my-devframe')
123+
const my = (await connectDevframe()).scope('my-tool')
124124

125125
// Standard call — awaits a response or throws.
126126
const modules = await my.rpc.call('get-modules', { limit: 10 })
@@ -142,7 +142,7 @@ Register functions the node side calls via `rpc.broadcast`:
142142
import { defineRpcFunction } from 'devframe'
143143

144144
my.rpc.register(defineRpcFunction({
145-
name: 'on-file-changed', // -> my-devframe:on-file-changed
145+
name: 'on-file-changed', // -> my-tool:on-file-changed
146146
type: 'event',
147147
setup: () => ({
148148
handler: async ({ file }: { file: string }) => {
@@ -155,7 +155,7 @@ my.rpc.register(defineRpcFunction({
155155
## Shared state
156156

157157
```ts
158-
const state = await my.rpc.sharedState('state') // -> my-devframe:state
158+
const state = await my.rpc.sharedState('state') // -> my-tool:state
159159

160160
console.log(state.value())
161161

@@ -329,7 +329,7 @@ render()
329329
// 2. Handle a failing call.
330330
async function loadModules() {
331331
try {
332-
return await rpc.call('my-devframe:get-modules', { limit: 10 })
332+
return await rpc.call('my-tool:get-modules', { limit: 10 })
333333
}
334334
catch (error) {
335335
if (error instanceof DevframeConnectionError) {

docs/content/1.guide/14.agent-native.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ Programmatically:
111111
import { defineDevframe } from 'devframe'
112112
import { createMcpServer } from 'devframe/adapters/mcp'
113113

114-
const devframe = defineDevframe({ /**/ })
114+
const myDevframe = defineDevframe({ /**/ })
115115

116-
await createMcpServer(devframe, { transport: 'stdio' })
116+
await createMcpServer(myDevframe, { transport: 'stdio' })
117117
```
118118

119119
`@modelcontextprotocol/server` is a peer dependency.
@@ -125,9 +125,9 @@ In `claude_desktop_config.json`:
125125
```json
126126
{
127127
"mcpServers": {
128-
"my-devframe": {
128+
"my-tool": {
129129
"command": "pnpm",
130-
"args": ["--filter", "my-devframe", "exec", "devframe", "mcp"]
130+
"args": ["--filter", "my-tool", "exec", "devframe", "mcp"]
131131
}
132132
}
133133
}

docs/content/1.guide/2.devframe-definition.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ import { defineDevframe, defineRpcFunction } from 'devframe'
1212
import * as v from 'valibot' // npm i valibot
1313
1414
export default defineDevframe({
15-
id: 'my-devframe',
16-
name: 'My Devframe',
15+
id: 'my-tool',
16+
name: 'My Tool',
1717
version: '1.0.0',
18-
packageName: 'my-devframe',
18+
packageName: 'my-tool',
1919
importMetaUrl: import.meta.url,
20-
homepage: 'https://github.com/me/my-devframe',
20+
homepage: 'https://github.com/me/my-tool',
2121
description: 'A one-line summary of what the tool does.',
2222
icon: 'ph:gauge-duotone',
2323
setup(ctx) {
2424
// A scoped context auto-namespaces ids with your devframe `id`.
25-
const my = ctx.scope('my-devframe')
25+
const my = ctx.scope('my-tool')
2626

2727
// Register your RPC functions, shared state, etc. here.
2828
my.rpc.register(defineRpcFunction({
29-
name: 'hello', // stored as `my-devframe:hello`
29+
name: 'hello', // stored as `my-tool:hello`
3030
type: 'static',
3131
jsonSerializable: true,
3232
handler: () => ({ message: 'hello' }),
@@ -64,8 +64,8 @@ Import metadata from `package.json` (`name` → `packageName`; devframe `name` i
6464
import pkg from '../package.json' with { type: 'json' }
6565

6666
export default defineDevframe({
67-
id: 'my-devframe',
68-
name: 'My Devframe', // display label
67+
id: 'my-tool',
68+
name: 'My Tool', // display label
6969
version: pkg.version,
7070
packageName: pkg.name,
7171
importMetaUrl: import.meta.url,
@@ -83,10 +83,10 @@ export default defineDevframe({
8383
export default defineDevframe({
8484
// …metadata as above
8585
importMetaUrl: import.meta.url,
86-
// Served from the locally installed `my-devframe--assets`, resolved via
86+
// Served from the locally installed `my-tool--assets`, resolved via
8787
// `importMetaUrl` — works under pnpm's strict layout with zero network.
8888
clientAssets: { package: `${pkg.name}--assets`, version: pkg.version },
89-
// Imported from `my-devframe`'s own dependency graph.
89+
// Imported from `my-tool`'s own dependency graph.
9090
services: [{ package: '@scope/my-service', version: pkg.version }],
9191
setup(ctx) { /**/ },
9292
})
@@ -117,8 +117,8 @@ For assets you host yourself, call `ctx.views.hostStatic` in `setup` — [Client
117117

118118
```ts
119119
defineDevframe({
120-
id: 'my-devframe',
121-
name: 'My Devframe',
120+
id: 'my-tool',
121+
name: 'My Tool',
122122
setup(ctx) {
123123
if (ctx.mode === 'build') {
124124
// Static-only work — baked into the RPC dump.
@@ -200,11 +200,11 @@ Hosted adapters can augment `ctx` — e.g. the [`vite` adapter](/adapters/vite)'
200200

201201
```ts
202202
defineDevframe({
203-
id: 'my-devframe',
204-
name: 'My Devframe',
203+
id: 'my-tool',
204+
name: 'My Tool',
205205
clientAssets: './client/dist', // built SPA served as the UI
206206
cli: {
207-
command: 'my-devframe', // binary name; default: the `id`
207+
command: 'my-tool', // binary name; default: the `id`
208208
port: 9876, // preferred port; default: 9999
209209
portRange: [9876, 10000], // forwarded to get-port-please
210210
random: false, // forwarded to get-port-please
@@ -243,16 +243,16 @@ import { createPluginFromDevframe } from '@vitejs/devtools-kit/node'
243243
import { createBuild } from 'devframe/adapters/build'
244244
import { createCac } from 'devframe/adapters/cac'
245245

246-
const devframe = defineDevframe({ id: 'my-devframe', name: 'My Devframe', setup() {} })
246+
const myDevframe = defineDevframe({ id: 'my-tool', name: 'My Tool', setup() {} })
247247

248248
// 1. Standalone CLI:
249-
await createCac(devframe).parse()
249+
await createCac(myDevframe).parse()
250250

251251
// 2. Offline snapshot:
252-
await createBuild(devframe, { outDir: 'dist-static' })
252+
await createBuild(myDevframe, { outDir: 'dist-static' })
253253

254254
// 3. Mount into a host framework (Vite DevTools shown — others can implement equivalents):
255-
export const myPlugin = () => createPluginFromDevframe(devframe)
255+
export const myPlugin = () => createPluginFromDevframe(myDevframe)
256256
```
257257

258258
## What's next

docs/content/1.guide/3.rpc.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { defineRpcFunction } from 'devframe'
1212
import * as v from 'valibot' // npm i valibot (or use zod / arktype)
1313
1414
export const getModules = defineRpcFunction({
15-
name: 'get-modules', // bare — the scope namespaces it to `my-devframe:get-modules`
15+
name: 'get-modules', // bare — the scope namespaces it to `my-tool:get-modules`
1616
type: 'query',
1717
args: [v.object({ limit: v.number() })],
1818
returns: v.array(v.object({ id: v.string(), size: v.number() })),
@@ -32,18 +32,18 @@ import { defineDevframe } from 'devframe'
3232
import { getModules } from './rpc/functions/get-modules'
3333

3434
export default defineDevframe({
35-
id: 'my-devframe',
36-
name: 'My Devframe',
35+
id: 'my-tool',
36+
name: 'My Tool',
3737
setup(ctx) {
38-
const my = ctx.scope('my-devframe')
38+
const my = ctx.scope('my-tool')
3939
my.rpc.register(getModules)
4040
},
4141
})
4242
```
4343

4444
### Naming convention
4545

46-
Scope with your devframe id, then a kebab-case action: `my-devframe:get-modules`.
46+
Scope with your devframe id, then a kebab-case action: `my-tool:get-modules`.
4747

4848
### Function types
4949

@@ -68,13 +68,13 @@ Use `setup(ctx)` (returns `{ handler, dump? }`) when the handler needs `Devframe
6868

6969
```ts
7070
defineDevframe({
71-
id: 'my-devframe',
72-
name: 'My Devframe',
71+
id: 'my-tool',
72+
name: 'My Tool',
7373
setup(ctx) {
74-
const my = ctx.scope('my-devframe')
74+
const my = ctx.scope('my-tool')
7575
watcher.on('change', (file) => {
7676
void my.rpc.broadcast({
77-
method: 'on-file-changed', // -> my-devframe:on-file-changed
77+
method: 'on-file-changed', // -> my-tool:on-file-changed
7878
args: [{ file }],
7979
})
8080
})
@@ -95,7 +95,7 @@ defineDevframe({
9595
For node-side→browser-side chunk feeds, use [streaming channels](/guide/streaming):
9696

9797
```ts
98-
const channel = ctx.rpc.streaming.create<string>('my-devframe:chat', {
98+
const channel = ctx.rpc.streaming.create<string>('my-tool:chat', {
9999
replayWindow: 256,
100100
})
101101
const stream = channel.start()
@@ -107,7 +107,7 @@ sourceReadable.pipeTo(stream.writable)
107107
A scoped `rpc.call` invokes a node-side function directly, skipping the transport:
108108

109109
```ts
110-
const my = ctx.scope('my-devframe')
110+
const my = ctx.scope('my-tool')
111111
const modules = await my.rpc.call('get-modules', { limit: 10 })
112112
```
113113

@@ -122,7 +122,7 @@ From the browser, [`connectDevframe`](/guide/client) (or `getDevframeRpcClient`)
122122
import { connectDevframe } from 'devframe/client'
123123

124124
const client = await connectDevframe()
125-
const my = client.scope('my-devframe')
125+
const my = client.scope('my-tool')
126126

127127
const modules = await my.rpc.call('get-modules', { limit: 10 })
128128
```
@@ -141,7 +141,7 @@ const serverFunctions = [getModules, getFile] as const
141141

142142
declare module 'devframe' {
143143
interface DevframeRpcServerFunctions
144-
extends RpcDefinitionsToFunctionsWithNamespace<'my-devframe', typeof serverFunctions> {}
144+
extends RpcDefinitionsToFunctionsWithNamespace<'my-tool', typeof serverFunctions> {}
145145
}
146146
```
147147

docs/content/1.guide/4.shared-state.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ A [scoped context](/guide/scoped-context)'s `rpc.sharedState(key, options)` name
3030
import { defineDevframe } from 'devframe'
3131

3232
export default defineDevframe({
33-
id: 'my-devframe',
34-
name: 'My Devframe',
33+
id: 'my-tool',
34+
name: 'My Tool',
3535
async setup(ctx) {
36-
const my = ctx.scope('my-devframe')
36+
const my = ctx.scope('my-tool')
3737

38-
const state = await my.rpc.sharedState('state', { // -> my-devframe:state
38+
const state = await my.rpc.sharedState('state', { // -> my-tool:state
3939
initialValue: {
4040
count: 0,
4141
items: [] as { id: string, name: string }[],
@@ -77,7 +77,7 @@ Devframe applies the recipe to a draft, emits `updated` (with `SharedStatePatch[
7777
Enable patches for minimal network diffs; `updated` then carries `Patch[]`:
7878

7979
```ts
80-
const state = await ctx.rpc.sharedState.get('my-devframe:big-state', {
80+
const state = await ctx.rpc.sharedState.get('my-tool:big-state', {
8181
initialValue: largeTree,
8282
// sharedState-level enablePatches is opt-in:
8383
sharedState: createSharedState({ initialValue: largeTree, enablePatches: true }),
@@ -99,9 +99,9 @@ The same key is on the browser RPC client, scoped identically; browser-side muta
9999
```ts
100100
import { connectDevframe } from 'devframe/client'
101101

102-
const my = (await connectDevframe()).scope('my-devframe')
102+
const my = (await connectDevframe()).scope('my-tool')
103103

104-
const state = await my.rpc.sharedState('state') // -> my-devframe:state
104+
const state = await my.rpc.sharedState('state') // -> my-tool:state
105105

106106
console.log(state.value().count)
107107

@@ -133,7 +133,7 @@ Augment `DevframeRpcSharedStates` to type each key once; lookups stay typed:
133133
```ts
134134
declare module 'devframe' {
135135
interface DevframeRpcSharedStates {
136-
'my-devframe:state': {
136+
'my-tool:state': {
137137
count: number
138138
items: { id: string, name: string }[]
139139
}

0 commit comments

Comments
 (0)