Skip to content

feat!: migrate logs-sdk to nostics, bump devframe to v0.3#350

Merged
antfu merged 4 commits into
mainfrom
antfu/devframe-v0.3
May 18, 2026
Merged

feat!: migrate logs-sdk to nostics, bump devframe to v0.3#350
antfu merged 4 commits into
mainfrom
antfu/devframe-v0.3

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented May 15, 2026

Description

logs-sdk has been renamed and rewritten as nostics. Devframe v0.3.0 is the first release that consumes the new dep, so this PR bumps both together to keep ctx.diagnostics (re-exported from devframe) and the in-repo diagnostics files backed by the same library and emission API.

API delta (also applies to plugin-facing ctx.diagnostics):

  • defineDiagnostics({ docsBase, codes }) + separate createLogger()defineDiagnostics({ docsBase, reporters, codes }) (no more createLogger).
  • Code fields message / hint / levelwhy / fix (no level).
  • Emission logger.CODE(params).throw() / .log()diagnostics.CODE.throw(params) / .report(params) (and ctx.diagnostics.logger.CODE is now a proxy that resolves directly to the nostics handle).
  • cause moves from a 2nd arg into the params object.

Convention docs (AGENTS.md/CLAUDE.md), plugin-author docs (docs/kit/diagnostics.md, docs/errors/index.md), and the vite-devtools-kit skill have been rewritten to teach the new API.

Linked Issues

Additional context

Verification: pnpm sync --check ✓ (devframe at v0.3.0), pnpm lint ✓, pnpm test ✓ (190/190), pnpm build ✓. The remaining pnpm typecheck errors are pre-existing RPC-type registration issues unrelated to this migration.

antfu added 2 commits May 15, 2026 13:35
`logs-sdk` has been renamed and rewritten as `nostics`. Devframe v0.3.0
is the first release on the new dep. Doing both together keeps
`ctx.diagnostics` (re-exported from devframe) and our internal
diagnostics backed by the same library.

API delta:
- `defineDiagnostics({ docsBase, codes })` + separate `createLogger()`
  → `defineDiagnostics({ docsBase, reporters, codes })`
- Code fields `message`/`hint`/`level` → `why`/`fix` (no `level`)
- `logger.CODE(params).throw() / .log()` → `diagnostics.CODE.throw(params) / .report(params)`
- `cause` moves from a 2nd arg to inside the params object

For plugin authors, `ctx.diagnostics.logger.CODE` is now a proxy that
resolves directly to a `nostics` handle, so emission is
`ctx.diagnostics.logger.CODE.throw(params)` instead of the old
`logger.CODE(params).throw()` shape.
# Conflicts:
#	devframe
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@350
npm i https://pkg.pr.new/@vitejs/devtools-kit@350
npm i https://pkg.pr.new/@vitejs/devtools-rolldown@350
npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@350

commit: 456e302

`tsdown`'s client/server split in devframe v0.2.3+ emits the
`DevToolsRpc{Server,Client}Functions` and `DevToolsRpcSharedStates`
interfaces twice — once in the canonical `devframe-*.d.mts` chunk and
again in the `index-*.d.mts` chunk consumed by `devframe/client`. The
duplicate declarations are seen by TypeScript as separate identities,
so `declare module '@vitejs/devtools-kit'` augmentations applied to
the canonical interface don't reach client-side consumers.

The patch replaces the duplicate declarations in the client chunk with
type imports from the canonical chunk, so both sides resolve to the
same interface. Remove the patch once devframe ships a fix upstream.
@antfu antfu changed the title feat: migrate logs-sdk to nostics, bump devframe to v0.3 feat!: migrate logs-sdk to nostics, bump devframe to v0.3 May 15, 2026
# Conflicts:
#	packages/rolldown/src/node/diagnostics.ts
#	packages/rolldown/src/node/utils/json-parse-stream.ts
#	pnpm-lock.yaml
@antfu antfu merged commit d1bc706 into main May 18, 2026
10 checks passed
@antfu antfu deleted the antfu/devframe-v0.3 branch May 18, 2026 07:08
Comment thread docs/kit/diagnostics.md

// Log without throwing
ctx.diagnostics.logger.MYP0002().log()
throw ctx.diagnostics.logger.MYP0001.throw({ name: 'foo' })
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm realizing, after much trial and error, that it's not possible to type the .throw() call to have never. In TS, only an explicit root-lever const fn: () => never = ... works. Maybe we should just remove it and tell people to use throw diagnostics.X.report() (already works)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, do you think we should just have throw diagnostics.X()?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that yeah, no need to have an object and we could always add methods to it if we need in the future. The only thing I can think about is being able to create the Diagnostic without reporting but we currently don't support it and seems exactly like what we want to avoid

Initially I thought of report() and throw() because I wanted to avoid a side effect on the constructor: new diags.X.() -> eslint would complain. But now that we got rid of the new, it's a function invocation, so side effects are okay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants