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
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ These reinforce devframe's positioning as "the container for one devtool integra
62
62
-**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 `nostics` are fine — ad-hoc `console.log`s baked into adapters are not.
63
63
-**Mount path depends on adapter context.** Given `id: 'foo'`, the default mount path is `/__foo/` for *hosted* adapters (`vite`, `embedded`) and `/` for *standalone* adapters (`cli`, `spa`, `build`). Authors override via `DevframeDefinition.basePath`. Don't hardcode mount paths in adapter code paths that may run standalone.
64
64
-**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 (`connectDevframe`) resolves `.connection.json` relative to the runtime base automatically.
65
-
-**CLI flags compose from both sides.** The `cac` instance backing `createCli` is exposed both to the `DevframeDefinition` (`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`.
65
+
-**CLI flags compose from both sides.** The `cac` instance backing `createCac` is exposed both to the `DevframeDefinition` (`cli.configure(cli)`) — for capabilities contributed by the tool itself — and to the `createCac` caller — for flags added at the final assembly stage. Parsed flag values are forwarded to `setup(ctx, { flags })`. Never hardcode domain-specific flags into `createCac`.
Copy file name to clipboardExpand all lines: docs/adapters/cac.md
+21-11Lines changed: 21 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,21 @@
2
2
outline: deep
3
3
---
4
4
5
-
# CLI
5
+
# CLI (cac)
6
6
7
-
The CLI adapter wraps a `DevframeDefinition` in a `cac`-powered command-line interface. From one entry it spins up an `h3` dev server with WebSocket RPC, builds static snapshots, builds SPA bundles, or starts an MCP server.
7
+
The cac adapter wraps a `DevframeDefinition` in a [`cac`](https://github.com/cacjs/cac)-powered command-line interface. From one entry it spins up an `h3` dev server with WebSocket RPC, builds static snapshots, builds SPA bundles, or starts an MCP server.
8
+
9
+
`cac` is an optional peer dependency, pulled in only through this adapter — install it alongside `devframe` to opt into `createCac`:
10
+
11
+
```sh
12
+
npm install devframe cac
13
+
```
14
+
15
+
Tools that assemble their own command-line shell from the [lower-level factories](#use-your-own-cli-framework) never import this adapter, so they run without `cac`.
The `devframe/adapters/cli` entry (`createCli`) remains as a deprecated alias for this module — new code should import `createCac` from `devframe/adapters/cac`.
32
+
23
33
Running the resulting binary:
24
34
25
35
```sh
@@ -34,18 +44,18 @@ Standalone CLI serves the SPA at `/` by default. The `/__devframe/` prefix is fo
34
44
35
45
## Options
36
46
37
-
`createCli(def, options?)` accepts:
47
+
`createCac(def, options?)` accepts:
38
48
39
49
| Option | Default | Description |
40
50
|--------|---------|-------------|
41
51
|`defaultPort`|`9999` (or `def.cli?.port`) | Port used by the dev command when `--port` isn't provided. |
42
52
|`configureCli`| — |`(cli: CAC) => void` — final hook to add commands/flags at the assembly stage, after the definition's `cli.configure` runs. |
43
53
|`onReady`| — |`(info: { origin, port, app }) => void \| Promise<void>` — called once the dev server is listening. Use this to print your own startup banner. |
44
54
45
-
`createCli` returns a `CliHandle`:
55
+
`createCac` returns a `CacHandle`:
46
56
47
57
```ts
48
-
interfaceCliHandle {
58
+
interfaceCacHandle {
49
59
cli:CAC// raw cac instance — mutate before calling parse()
50
60
parse: (argv?:string[]) =>Promise<void>
51
61
}
@@ -80,14 +90,14 @@ defineDevframe({
80
90
})
81
91
```
82
92
83
-
`distDir` is the only required field; everything else has sensible defaults. The `configure` hook runs *before* the `configureCli` option passed to `createCli`, so the final tool author always has the last word on flags.
93
+
`distDir` is the only required field; everything else has sensible defaults. The `configure` hook runs *before* the `configureCli` option passed to `createCac`, so the final tool author always has the last word on flags.
84
94
85
95
## Headless logging
86
96
87
97
Devframe leaves startup output to the application. Wire `onReady` to print your own banner:
88
98
89
99
```ts
90
-
awaitcreateCli(devframe, {
100
+
awaitcreateCac(devframe, {
91
101
onReady({ origin }) {
92
102
console.log(`ESLint Config Inspector ready at ${origin}`)
93
103
},
@@ -98,13 +108,13 @@ Structured diagnostics (via `nostics`) continue to surface through their normal
98
108
99
109
## Use your own CLI framework
100
110
101
-
To integrate devframe into an existing commander / yargs program — or to expose a different command structure than `createCli`'s `dev` / `build` / `mcp` triplet — drop down to the peer factories. Same `DevframeDefinition`, different shell:
111
+
To integrate devframe into an existing commander / yargs program — or to expose a different command structure than `createCac`'s `dev` / `build` / `mcp` triplet — drop down to the peer factories. Same `DevframeDefinition`, different shell:
102
112
103
113
| Building block | Entry | Purpose |
104
114
|----------------|-------|---------|
105
115
|[`createDevServer(def, opts?)`](./dev)|`devframe/adapters/dev`| h3 + WebSocket RPC + SPA mount |
Copy file name to clipboardExpand all lines: docs/adapters/dev.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ outline: deep
4
4
5
5
# Dev
6
6
7
-
The `dev` adapter is the building block `createCli` uses internally — h3 + WebSocket RPC + the author's SPA mounted at the resolved base path. Reach for it directly to mount the dev server inside an existing CLI program (commander, yargs, hand-rolled CAC) or to attach custom middleware to the underlying h3 app.
7
+
The `dev` adapter is the building block `createCac` uses internally — h3 + WebSocket RPC + the author's SPA mounted at the resolved base path. Reach for it directly to mount the dev server inside an existing CLI program (commander, yargs, hand-rolled CAC) or to attach custom middleware to the underlying h3 app.
Copy file name to clipboardExpand all lines: docs/adapters/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ outline: deep
6
6
7
7
An adapter takes a `DevframeDefinition` and deploys it into a specific runtime — a standalone CLI, a Vite plugin, a static snapshot, an embedded host, or an MCP server. Each adapter ships at its own entry point (`devframe/adapters/<name>`); the bundler pulls in only the ones you use.
8
8
9
-
Every adapter factory has the shape `createXxx(devframeDef, options?)`.
9
+
Every adapter factory has the shape `createXxx(devframeDef, options?)`. Some adapters draw on an optional peer dependency, installed only when you opt into that adapter: `cac` pulls in [`cac`](https://github.com/cacjs/cac), and `mcp` pulls in [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk).
10
10
11
11
## Comparison
12
12
13
13
| Adapter | Entry | Factory | Best for |
14
14
|---------|-------|---------|----------|
15
-
|[`cli`](./cli)|`devframe/adapters/cli`|`createCli(def, options?)`| Standalone tools run via `node ./my-tool.js`|
15
+
|[`cac`](./cac)|`devframe/adapters/cac`|`createCac(def, options?)`| Standalone tools run via `node ./my-tool.js`|
16
16
|[`dev`](./dev)|`devframe/adapters/dev`|`createDevServer(def, options?)`| Run the dev server programmatically — drive it from any CLI framework |
17
17
|[`build`](./build)|`devframe/adapters/build`|`createBuild(def, options?)`| Offline reports, CI artifacts, deployable SPA snapshots |
18
18
|[`vite`](./vite)|`@vitejs/devtools-kit/node`|`createPluginFromDevframe(def, options?)`| Mount the definition into Vite DevTools (or any compatible host) |
Copy file name to clipboardExpand all lines: docs/guide/devframe-definition.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ outline: deep
4
4
5
5
# Devframe Definition
6
6
7
-
Every Devframe tool starts with a single `defineDevframe` call. The returned `DevframeDefinition` is a portable value that any of the [adapters](/adapters/) can consume — the same definition runs under `createCli`, `createBuild`, `createMcpServer`, the `vite` adapter's `createPluginFromDevframe`, and so on.
7
+
Every Devframe tool starts with a single `defineDevframe` call. The returned `DevframeDefinition` is a portable value that any of the [adapters](/adapters/) can consume — the same definition runs under `createCac`, `createBuild`, `createMcpServer`, the `vite` adapter's `createPluginFromDevframe`, and so on.
8
8
9
9
## Minimal definition
10
10
@@ -51,7 +51,7 @@ export default defineDevframe({
51
51
|`basePath`|`string`| Optional mount path override. Defaults depend on the adapter: `/` for standalone (`cli` / `spa` / `build`), `/.<id>/` for hosted (`vite` / `embedded`). |
52
52
|`duplicationStrategy`|`'warn' \| 'silent' \| 'throw' \| 'duplicate'`| How a hub reacts when another devframe sharing this `id` is mounted onto the same hub. Defaults to `'warn'`. See [Hub](./hub). Hub adapters consult it; standalone adapters ignore it. |
53
53
|`capabilities`|`{ dev?, build?, spa? }`| Per-runtime feature flags. A `boolean` applies to the runtime as a whole; an object enables individual features. |
54
-
|`setup`|`(ctx, info?) => void \| Promise<void>`|**Required.** Server-side entry point. Runs in every runtime. The optional second argument carries runtime metadata — most notably the parsed CLI `flags` when running under `createCli`. |
54
+
|`setup`|`(ctx, info?) => void \| Promise<void>`|**Required.** Server-side entry point. Runs in every runtime. The optional second argument carries runtime metadata — most notably the parsed CLI `flags` when running under `createCac`. |
55
55
|`setupBrowser`|`(ctx) => void \| Promise<void>`| Browser-only entry used by the SPA adapter. |
56
56
|`cli`|`DevframeCliOptions`| Defaults for the CLI adapter. See [CLI options](#cli-options) below. |
57
57
|`spa`|`DevframeSpaOptions`| Defaults for the SPA adapter (`base`, `loader`). |
@@ -185,7 +185,7 @@ defineDevframe({
185
185
|`host`|`string`| Default bind host. |
186
186
|`open`|`boolean \| string`|`true` opens the origin, a string opens a specific path, `false` disables. Matches the `--open` / `--no-open` flags. |
187
187
|`auth`|`boolean`| Disable the WS trust flow when the tool is localhost-only and single-user. Default `true`. |
188
-
|`configure`|`(cli: CAC) => void`| Contribute capability flags/commands. Runs before `createCli`'s `configureCli` option so the final tool author always has the last word. |
188
+
|`configure`|`(cli: CAC) => void`| Contribute capability flags/commands. Runs before `createCac`'s `configureCli` option so the final tool author always has the last word. |
189
189
190
190
`setup(ctx, info)` receives `info.flags` populated from both devframe's built-in flags and any you declared via `configure` — saves duplicating flag parsing.
191
191
@@ -210,12 +210,12 @@ The definition is a plain value, so wire it into multiple adapters from the same
Copy file name to clipboardExpand all lines: docs/guide/index.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Devframe keeps its surface focused on one tool, so the same definition stays por
17
17
-**App-owned file watching.** Wire your own watcher (chokidar, fs.watch, …) and signal change via `ctx.rpc.sharedState.set(...)` or event-typed RPCs.
18
18
-**Context-aware mount paths.** Standalone adapters (`cli`, `spa`, `build`) serve at `/` by default; hosted adapters (`vite`, `embedded`) serve at `/.<id>/`. Override via `DevframeDefinition.basePath`.
19
19
-**SPAs own their base at runtime.** Build with relative asset paths (`vite.base: './'`); `connectDevframe` discovers the effective base from the executing script's location.
20
-
-**CLI flags compose.** The `cac` instance is exposed to both the devframe (`cli.configure`) and the caller of `createCli`, so capability flags and app flags merge cleanly.
20
+
-**CLI flags compose.** The `cac` instance is exposed to both the devframe (`cli.configure`) and the caller of `createCac`, so capability flags and app flags merge cleanly.
21
21
22
22
## What Devframe provides
23
23
@@ -47,7 +47,7 @@ A minimal devframe with a CLI entry point:
The same definition can also be deployed through any of the other adapters — for example, mounted into Vite DevTools via the [`vite` adapter](/adapters/vite).
@@ -91,7 +91,7 @@ Devframe deploys the same `DevframeDefinition` through one of these adapters:
91
91
92
92
| Adapter | Entry | Target |
93
93
|---------|-------|--------|
94
-
|`cli`|`createCli(d).parse()`| Standalone CLI with dev / build / mcp subcommands |
94
+
|`cli`|`createCac(d).parse()`| Standalone CLI with dev / build / mcp subcommands |
95
95
|`vite`|`createPluginFromDevframe(d, opts?)`*(from `@vitejs/devtools-kit/node`)*| Mount the devframe into Vite DevTools (or another compatible host) |
96
96
|`build`|`createBuild(d, opts?)`| Self-contained static deploy with baked RPC dumps |
97
97
|`embedded`|`createEmbedded(d, { ctx })`| Runtime registration into an existing host |
0 commit comments