{"_id":"nostics@1.3.0","bugs":"https://github.com/vercel-labs/nostics/issues","dist":{"shasum":"e1d538463acb0207f9a0ef9ec551b075930559c4","tarball":"http://registry-npm.ywwl.com/nostics/download/nostics-1.3.0.tgz","fileCount":26,"integrity":"sha512-wzRsrJwNlFbqIRQt8aCeL2WE8USip/uuvGSOZV1D02CxX8ABTMbw8IywKjH7yWHETMXbWJI4OBpihg9rmz2Vyg==","signatures":[{"sig":"MEUCIGodvT87loATLpYPfTgXX7unU8akG5Y6++dxWWps8vfbAiEAyU8Wxzt0/enI2jaXK49EFL0Yrjyr+XCsaOrl+ak6mG4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD6vhOY1GkjvI//BG1/tI3IV0eaoPSQm/CDTMHK0W4wGQIhAN6AuNadJDPBzfDpXthzaUWqUMDx+zViXAEQOl3Jnyz7"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/nostics@1.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":97176,"size":29825,"noattachment":false,"key":"/nostics/-/nostics-1.3.0.tgz"},"name":"nostics","type":"module","types":"./dist/index.d.mts","author":"Anthony Fu <anthonyfu117@hotmail.com>","exports":{".":"./dist/index.mjs","./package.json":"./package.json","./reporters/dev":"./dist/reporters/dev.mjs","./reporters/node":"./dist/reporters/node.mjs","./formatters/ansi":"./dist/formatters/ansi.mjs","./formatters/json":"./dist/formatters/json.mjs","./reporters/fetch":"./dist/reporters/fetch.mjs"},"license":"MIT","scripts":{"dev":"vitest","fmt":"oxfmt","docs":"pnpm -C docs run dev","lint":"oxlint ${CI:+--deny-warnings} . && oxfmt --check .","play":"pnpm -C playground run dev","size":"size-limit","test":"pnpm run build && pnpm run \"/^test:/\"","build":"tsdown && pnpm --filter \"./packages/*\" run build","release":"node scripts/release.ts","lint:fix":"oxfmt && oxlint --fix .","test:demo":"pnpm -C demo-lib run build && pnpm -C demo-lib run test && pnpm -C playground run build","test:lint":"pnpm run lint","test:unit":"vitest run --coverage","typecheck":"tsc && pnpm --filter \"./packages/*\" run typecheck","docs:build":"pnpm -C docs run build","test:types":"pnpm run typecheck"},"version":"1.3.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:08a188d8-6b90-4672-9c0a-2c9e74fb75b3"}},"homepage":"https://github.com/vercel-labs/nostics#readme","keywords":[],"repository":{"url":"git+https://github.com/vercel-labs/nostics.git","type":"git"},"size-limit":[{"name":"defineDiagnostics from source","path":"src/index.ts","import":"{ defineDiagnostics }"},{"name":"defineDiagnostics","path":"dist/index.mjs","import":"{ defineDiagnostics }"},{"name":"defineProdDiagnostics","path":"dist/index.mjs","import":"{ defineProdDiagnostics }"},{"name":"defineDiagnostics + createConsoleReporter","path":"dist/index.mjs","import":"{ defineDiagnostics, createConsoleReporter }"},{"name":"defineProdDiagnostics + createConsoleReporter","path":"dist/index.mjs","import":"{ defineProdDiagnostics, createConsoleReporter }"},{"name":"formatDiagnostic","path":"dist/index.mjs","import":"{ formatDiagnostic }"},{"name":"full root","path":"dist/index.mjs","import":"*"},{"name":"ansi formatter","path":"dist/formatters/ansi.mjs","import":"*"}],"description":"Structured diagnostic code library","directories":{},"lint-staged":{"*":["oxfmt --no-error-on-unmatched-pattern","oxlint --no-error-on-unmatched-pattern --fix"]},"maintainers":[{"name":"danielroe","email":"daniel@roe.dev"},{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"sideEffects":false,"contributors":["Eduardo San Martin Morote <posva13@gmail.com>","Daniel Roe <daniel@roe.dev>"],"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.3.0","oxfmt":"^0.68.0","oxlint":"^1.80.0","semver":"^7.8.5","tsdown":"^0.23.0","tsnapi":"^1.5.0","vitest":"^5.0.1","publint":"^0.3.24","size-limit":"^14.0.0","typescript":"^6.0.0","@types/node":"^26.6.2","lint-staged":"^17.5.1","@types/semver":"^7.8.0","@posva/prompts":"^2.4.4","simple-git-hooks":"^2.14.0","@vitest/coverage-v8":"5.0.1","oxlint-plugin-posva":"^0.0.2","conventional-changelog":"^8.1.3","@size-limit/esbuild-why":"^14.0.0","@size-limit/preset-small-lib":"^14.0.0","conventional-changelog-angular":"^9.4.0"},"simple-git-hooks":{"pre-commit":"pnpm i --frozen-lockfile --ignore-scripts --offline && pnpm lint-staged"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nostics_1.3.0_1790001318937_0.2817097703710323"},"readme":"<p align=\"center\">\n  <img src=\"./docs/public/nostics.svg\" alt=\"nostics\" width=\"320\">\n</p>\n\n# nostics\n\n[![npm version](https://img.shields.io/npm/v/nostics?color=blue)](https://npmx.dev/nostics)\n[![npm downloads](https://img.shields.io/npm/dw/nostics?color=blue)](https://npmx.dev/nostics)\n[![CI](https://img.shields.io/github/actions/workflow/status/vercel-labs/nostics/ci.yml?branch=main&label=CI)](https://github.com/vercel-labs/nostics/actions/workflows/ci.yml)\n[![bundle size](https://deno.bundlejs.com/badge?q=nostics&treeshake=[{+defineDiagnostics+}])](https://bundlejs.com/?q=nostics&treeshake=%5B%7B+defineDiagnostics+%7D%5D)\n\nErrors worth reading.\n\n`nostics` helps you replace ad hoc error strings with stable diagnostic codes, actionable fixes, source locations, and docs links.\n\n```txt\n[NUXT_B2011] Plugin `./runtime/analytics.server.ts` is server-only but was registered with mode `client`.\n├▶ fix: Rename the file or register it with mode `server`.\n├▶ sources: modules/analytics.ts:18:5\n╰▶ see: https://nuxt.com/e/b2011\n```\n\n## Install\n\n```bash\npnpm add nostics\n```\n\n## Quick start\n\n```ts\nimport { createConsoleReporter, defineDiagnostics } from 'nostics'\n\nexport const diagnostics = defineDiagnostics({\n  docsBase: (code) => `https://nuxt.com/e/${code.replace('NUXT_', '').toLowerCase()}`,\n  reporters: [createConsoleReporter()],\n  codes: {\n    NUXT_B2011: {\n      why: (p: { src: string; mode: 'client' | 'server' }) => {\n        const expected = p.mode === 'client' ? 'server' : 'client'\n        return `Plugin \"${p.src}\" is ${expected}-only but was registered with mode \"${p.mode}\".`\n      },\n      fix: (p: { mode: 'client' | 'server' }) => {\n        const expected = p.mode === 'client' ? 'server' : 'client'\n        return `Rename the file or register it with mode \"${expected}\".`\n      },\n    },\n    NUXT_B5001: {\n      why: (p: { value: string; configPath: string }) =>\n        `Invalid compatibilityDate \"${p.value}\" in ${p.configPath}.`,\n      fix: (p: { example: string }) => `Use an ISO date like \"${p.example}\", or \"latest\".`,\n    },\n  },\n})\n```\n\nUse the generated handles where the problem happens:\n\n```ts\nconst plugin = resolvePlugin()\nconst source = locatePluginCall(plugin)\nconst config = loadNuxtConfig()\n\ndiagnostics.NUXT_B2011({\n  src: plugin.src,\n  mode: plugin.mode,\n  sources: [source],\n})\n\nthrow diagnostics.NUXT_B5001({\n  configPath: config.filepath,\n  value: config.compatibilityDate,\n  example: '2024-04-03',\n})\n```\n\nCalling a handle reports the diagnostic and returns a `Diagnostic`. Throwing the return value raises it. The params are inferred from your `why` and `fix` functions.\n\n## Claude Code plugin\n\nInstall the plugin to give Claude skills for your diagnostic catalog:\n\n```bash\nclaude plugin add https://github.com/vercel-labs/nostics\n```\n\nClaude will automatically pick up the `nostics` API reference and an `add-diagnostic` skill that finds the right catalog, chooses the next free code, and wires the call site.\n\n## Agent skills\n\nPrefer just the skills, without the plugin? Install them with [`npx skills`](https://github.com/vercel-labs/skills) into any supported agent (Claude Code, Codex, Cursor, opencode, and more):\n\n```bash\nnpx skills add vercel-labs/nostics\n```\n\n## Why use it\n\n- Stable codes that users can search and docs can link to.\n- Typed params at the call site.\n- `Diagnostic` instances that extend `Error`.\n- Built-in console, file, fetch, and Vite dev reporters.\n- Plain, ANSI, and JSON formatters.\n- A build plugin that strips report-only diagnostics from production bundles.\n\nThe structured shape also makes diagnostics easier for tools and coding agents to read, without making that the main workflow.\n\n## Vite plugins\n\nBuild-time plugins live in the separate [`@nostics/unplugin`](./packages/unplugin) package:\n\n```bash\npnpm add -D @nostics/unplugin\n```\n\nFor library builds, use the strip plugin:\n\n```ts\nimport { nosticsStrip } from '@nostics/unplugin/strip-transform'\n\nexport default defineConfig({\n  plugins: [nosticsStrip.vite()],\n})\n```\n\nFor browser diagnostics during Vite dev, use `createDevReporter()` in the browser and `nosticsCollector` in the consuming app:\n\n```ts\nimport { nosticsCollector } from '@nostics/unplugin/dev-server-collector'\n\nexport default defineConfig({\n  plugins: [nosticsCollector.vite()],\n})\n```\n\n## Docs\n\nSee the docs site for the guide, production build notes, dev collector setup, and API reference.\n\n## License\n\n[MIT](./LICENSE)\n","publish_time":1790001319107,"_cnpm_publish_time":1790001319107,"dist-tags":{"latest":"1.4.0"}}