{"name":"nostics","version":"0.0.0","keywords":[],"author":{"url":"https://www.npmjs.com/~posva","name":"posva"},"license":"UNLICENSED","_id":"nostics@0.0.0","maintainers":[{"name":"posva","email":"posva13@gmail.com"}],"dist":{"shasum":"d4944c4c08c0b8fc59391ab831a7cfa07386d2b7","tarball":"http://registry-npm.ywwl.com/nostics/download/nostics-0.0.0.tgz","fileCount":2,"integrity":"sha512-X1skYFPPEzjj6CF+CCurgibABDety0T3GKtxUXGbcgu99h34T09T/R+Oia8gkFov5C1eFJNiP7m910IiYr34WQ==","signatures":[{"sig":"MEQCIHBkRel9GL8uJuuOvnZsGwoGe2oYdGlaMDon5/yDB7zWAiAM+njrpAJgYkCQvUZs85TD90Xm0OSynP2FW1611h+Veg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":260,"size":298,"noattachment":false,"key":"/nostics/-/nostics-0.0.0.tgz"},"main":"index.js","private":false,"scripts":{},"_npmUser":{"name":"posva","email":"posva13@gmail.com"},"_npmVersion":"11.11.1","description":"Placeholder for nostics","directories":{},"_nodeVersion":"25.8.2","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nostics_0.0.0_1775636432925_0.9978447167158289","host":"s3://npm-registry-packages-npm-production"},"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":1775636433110,"_cnpm_publish_time":1775636433110,"dist-tags":{"latest":"1.4.0"}}