{"name":"nostics","version":"0.2.0","keywords":[],"author":"Anthony Fu <anthonyfu117@hotmail.com>","license":"MIT","_id":"nostics@0.2.0","maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"contributors":["Eduardo San Martin Morote <posva13@gmail.com>"],"homepage":"https://github.com/vercel-labs/nostics#readme","bugs":"https://github.com/vercel-labs/nostics/issues","dist":{"shasum":"8c9274d7352bf9c6c556d2b63e179431c88a1a6d","tarball":"http://registry-npm.ywwl.com/nostics/download/nostics-0.2.0.tgz","fileCount":28,"integrity":"sha512-/WQpI46UMbqvy1okYb+V+9wW3J8/m6GJ33wm691n/tyi6YtJiZ6ssJjENAU7y4evfYrrgYN9HllKDzPvffil1w==","signatures":[{"sig":"MEUCIQDwQwgZoLjJ1Kyb9HLfJCZ47FNiL7/V9kp3AFnuXHoG1AIgG5EElK/DzEyvsndOFzmPmBHJwPRTPTozBnV4XSVHd+k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":102653,"size":30681,"noattachment":false,"key":"/nostics/-/nostics-0.2.0.tgz"},"type":"module","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs","./unplugin":"./dist/unplugin.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"},"scripts":{"dev":"vitest","lint":"eslint","play":"pnpm -C playground run dev","test":"pnpm run build && pnpm -r run build && tsc && eslint && vitest run --coverage","build":"tsdown","release":"node scripts/release.ts","typecheck":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:08a188d8-6b90-4672-9c0a-2c9e74fb75b3"}},"repository":{"url":"git+https://github.com/vercel-labs/nostics.git","type":"git"},"description":"Structured diagnostic code library","directories":{},"lint-staged":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"24.15.0","dependencies":{"unplugin":"^3.0.0","oxc-parser":"^0.132.0","magic-string":"^0.30.21"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.12","oxfmt":"^0.50.0","eslint":"^10.3.0","semver":"^7.8.0","tsdown":"^0.22.0","tsnapi":"^0.3.3","vitest":"^4.1.6","esbuild":"^0.28.0","nostics":"0.2.0","publint":"^0.3.21","@antfu/ni":"^30.1.0","@vitest/ui":"4.1.6","typescript":"^6.0.3","@types/node":"^25.7.0","lint-staged":"^17.0.4","@antfu/utils":"^9.3.0","@types/semver":"^7.7.1","@posva/prompts":"^2.4.4","simple-git-hooks":"^2.13.1","@vitest/coverage-v8":"4.1.6","@antfu/eslint-config":"^9.0.0","conventional-changelog":"^7.2.0","conventional-changelog-angular":"^8.3.1"},"simple-git-hooks":{"pre-commit":"pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"},"_npmOperationalInternal":{"tmp":"tmp/nostics_0.2.0_1779252576114_0.9332206588809169","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":1779252576273,"_cnpm_publish_time":1779252576273,"dist-tags":{"latest":"1.4.0"}}