{"name":"nostics","version":"1.1.2","keywords":[],"author":"Anthony Fu <anthonyfu117@hotmail.com>","license":"MIT","_id":"nostics@1.1.2","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":"353efdf5fe588b4ec8c73dea88f4dfc38c04e695","tarball":"http://registry-npm.ywwl.com/nostics/download/nostics-1.1.2.tgz","fileCount":26,"integrity":"sha512-LwDyl2h5K2tTSm0j62FytRWmhtTRppjpkG6sDSCDz5XuJxsoNf4JIs/GqPwiq+GBxe2LIN5bdjFxvy5MImCbqQ==","signatures":[{"sig":"MEQCIFf+EFA7CiSMMbyLeRgWY/95GvAndJwx6f1RpGJfEM+nAiA15n7CDkIX6piBctumyHlV/r29wL0h8zynzTbQp3aY9w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/nostics@1.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":91434,"size":28068,"noattachment":false,"key":"/nostics/-/nostics-1.1.2.tgz"},"type":"module","types":"./dist/index.d.mts","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"},"scripts":{"dev":"vitest","docs":"pnpm -C docs run dev","lint":"eslint","play":"pnpm -C playground run dev","size":"size-limit","test":"pnpm run build && vitest run --coverage && pnpm -C demo-lib run build && pnpm -C playground run build && pnpm run typecheck && pnpm run lint","build":"tsdown && pnpm --filter \"./packages/*\" run build","release":"node scripts/release.ts","typecheck":"tsc && pnpm --filter \"./packages/*\" run typecheck","docs:build":"pnpm -C docs run build"},"_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"},"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":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.16","oxfmt":"^0.54.0","eslint":"^10.5.0","semver":"^7.8.4","tsdown":"^0.22.2","tsnapi":"^0.3.3","vitest":"^4.1.8","nostics":"1.1.2","publint":"^0.3.21","@antfu/ni":"^30.1.0","@vitest/ui":"4.1.8","size-limit":"^12.1.0","typescript":"^6.0.3","@types/node":"^25.9.3","lint-staged":"^17.0.7","@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.8","@antfu/eslint-config":"^9.0.0","conventional-changelog":"^7.2.0","@size-limit/esbuild-why":"^12.1.0","@size-limit/preset-small-lib":"^12.1.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_1.1.2_1781708124939_0.1331075439758409","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":1781708125174,"_cnpm_publish_time":1781708125174,"dist-tags":{"latest":"1.4.0"}}