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
Adopts nostics 0.1.0 (the renamed-and-redesigned logs-sdk):
`message`/`hint`/`level` become `why`/`fix`/per-call reporter method;
`createLogger`/`Logger` are gone (each `defineDiagnostics()` returns
its own callable handles); emit shape is `code.throw({...})` /
`code.report({...}, { method })` instead of `code({...}).method()`.
The `DevToolsDiagnosticsHost` keeps `register()` and `host.logger.CODE`
via a Proxy over an internal registry, and `host.defineDiagnostics()`
pre-wires the shared ANSI console reporter. `host.createLogger` is
dropped (no nostics equivalent — use the typed return of
`defineDiagnostics` directly).
Copy file name to clipboardExpand all lines: AGENTS.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,14 +39,14 @@ The `pnpm test` script intentionally runs `build` first so `tsnapi` snapshots co
39
39
These reinforce devframe's positioning as "the container for one devtool integration, portable to multiple viewers". When in doubt, err on the side of "devframe provides primitives, the hub provides UX".
40
40
41
41
-**Single-integration scope.** Devframe describes one tool. If a feature only makes sense when multiple tools share a UI — docking, a unified command palette, cross-tool toasts, terminal aggregation — it belongs in a hub package, not here.
42
-
-**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 `logs-sdk` are fine — ad-hoc `console.log`s baked into adapters are not.
42
+
-**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.
43
43
-**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.
44
44
-**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.
45
45
-**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`.
46
46
47
47
## Structured Diagnostics (Error Codes)
48
48
49
-
All node-side warnings and errors use structured diagnostics via [`logs-sdk`](https://github.com/vercel-labs/logs-sdk). Never use raw `console.warn`, `console.error`, or `throw new Error` with ad-hoc messages in node-side code — always define a coded diagnostic.
49
+
All node-side warnings and errors use structured diagnostics via [`nostics`](https://www.npmjs.com/package/nostics). Never use raw `console.warn`, `console.error`, or `throw new Error` with ad-hoc messages in node-side code — always define a coded diagnostic.
50
50
51
51
Prefix: **`DF`**. Codes are sequential 4-digit numbers (e.g. `DF0033`). Check the existing diagnostics file to find the next available number.
- Every error page includes the cause, recommended fix, and a reference to the source file that emits it.
13
-
- The diagnostics system is powered by [`logs-sdk`](https://github.com/vercel-labs/logs-sdk), which provides structured logging with docs URLs, ANSI-formatted console output, and level-based filtering.
13
+
- The diagnostics system is powered by [`nostics`](https://www.npmjs.com/package/nostics), which provides structured diagnostic codes with docs URLs, ANSI-formatted console output, and pluggable reporters.
Copy file name to clipboardExpand all lines: docs/guide/diagnostics.md
+27-47Lines changed: 27 additions & 47 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
# Structured Diagnostics
6
6
7
-
`ctx.diagnostics` is a thin layer over [`logs-sdk`](https://github.com/vercel-labs/logs-sdk) that lets integrations register coded errors and warnings into a shared logger without depending on `logs-sdk` directly. Use it for author-defined coded diagnostics — errors, warnings, deprecations — with a stable code, a documentation URL, and a structured payload. For free-form runtime output that should appear in the DevTools UI, use [`ctx.messages`](https://devtools.vite.dev/kit/messages).
7
+
`ctx.diagnostics` is a thin layer over [`nostics`](https://www.npmjs.com/package/nostics) that lets integrations register coded errors and warnings into a shared lookup without depending on `nostics` directly. Use it for author-defined coded diagnostics — errors, warnings, deprecations — with a stable code, a documentation URL, and a structured payload. For free-form runtime output that should appear in the DevTools UI, use [`ctx.messages`](https://devtools.vite.dev/kit/messages).
8
8
9
9
| Surface | Purpose | Example |
10
10
|---------|---------|---------|
@@ -15,17 +15,14 @@ outline: deep
15
15
16
16
```ts
17
17
interfaceDevToolsDiagnosticsHost {
18
-
/**Combined logs-sdk Logger across all registered diagnostics. */
19
-
readonly logger:Logger
18
+
/**Proxy-backed lookup over every registered code. */
//Now you can emit codes through the shared logger:
59
-
ctx.diagnostics.logger.MYP0002().log()
54
+
//Emit through the host's shared reporter:
55
+
myDiagnostics.MYP0002.report()
60
56
},
61
57
},
62
58
}
@@ -76,68 +72,52 @@ Prefixes already in use in this monorepo:
76
72
|`RDDT`|`@vitejs/devtools-rolldown`|
77
73
|`VDT`|`@vitejs/devtools-vite` (reserved) |
78
74
79
-
Each definition supports a `message` (string or function), an optional `hint`, an optional `level` (`'error'` / `'warn'` / `'suggestion'` / `'deprecation'` — defaults to `'error'`), and a `docsBase` for generating documentation URLs. See [`logs-sdk`](https://github.com/vercel-labs/logs-sdk) for the full schema.
75
+
Each definition supports a `why` (string or function — the message) and an optional `fix` (string or function — the suggested resolution). The `docsBase` on `defineDiagnostics({...})` auto-attaches the URL to every emitted diagnostic. See [`nostics`](https://www.npmjs.com/package/nostics) for the full schema.
80
76
81
77
## Emit a diagnostic
82
78
83
-
Each registered code becomes a callable factory on `ctx.diagnostics.logger`. The factory returns an object with `.throw()`, `.warn()`, `.error()`, `.log()`, and `.format()`.
79
+
Each registered code becomes a `DiagnosticHandle` on the typed result of `defineDiagnostics()` (and through the shared `ctx.diagnostics.logger` lookup). Handles expose `.report()` and `.throw()`.
`.throw()` is typed `never`, so TypeScript treats the line after as unreachable. Prefix the call with `throw` for control-flow narrowing:
100
96
101
97
```ts
102
-
throwctx.diagnostics.logger.MYP0001({ name }).throw()
98
+
throwmyDiagnostics.MYP0001.throw({ name })
103
99
```
104
100
105
-
## Typed logger reference
101
+
## Typed handle reference
106
102
107
-
`ctx.diagnostics.logger` is loosely typed — it covers an unbounded set of registered codes, beyond what TypeScript can narrow. For autocompletion on your plugin's specific codes, keep a typed reference returned from `createLogger`:
103
+
`ctx.diagnostics.logger` is loosely typed — it covers an unbounded set of registered codes, beyond what TypeScript can narrow. For autocompletion on your plugin's specific codes, keep the typed result of `defineDiagnostics()`:
Copy file name to clipboardExpand all lines: docs/guide/index.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
@@ -29,7 +29,7 @@ Devframe keeps its surface focused on one tool, so the same definition stays por
29
29
|**[Devframe Definition](./devframe-definition)**| One `defineDevframe` call describes your tool once; the adapters deploy it anywhere. |
30
30
|**[RPC](./rpc)**| Type-safe bidirectional calls built on birpc + valibot. Supports `query`, `static`, `action`, and `event` types. |
31
31
|**[Shared State](./shared-state)**| Observable, patch-synced state that survives reconnects and bridges server ↔ browser. |
32
-
|**[Diagnostics](./diagnostics)**| Coded warnings/errors via `logs-sdk` — registered into the host logger so adapters and consumers share the same surface. |
32
+
|**[Diagnostics](./diagnostics)**| Coded warnings/errors via `nostics` — registered into the host's shared lookup so adapters and consumers share the same surface. |
33
33
|**[Streaming](./streaming)**| One-way (RPC streaming) and two-way (uploads) channel primitives for long-running data. |
34
34
|**[When Clauses](./when-clauses)**| VS Code-style conditional expressions for docks, commands, and custom UI. |
35
35
|**[Utilities](/helpers/utilities)**| Bundled helpers under `devframe/utils/*` — terminal colors, hashing, editor launch, structured-clone serialization, and more. |
0 commit comments