{"_id":"logs-sdk","_rev":"7-674adaa4a1fa46212a4fff196be0297e","name":"logs-sdk","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.0":{"name":"logs-sdk","version":"0.0.0","author":{"name":"Daniel Roe","email":"daniel@roe.dev"},"_id":"logs-sdk@0.0.0","maintainers":[{"name":"danielroe","email":"daniel@roe.dev"}],"dist":{"shasum":"745a3a9c9c9cea44c2fb1b172a7de90a2ee6dbe7","tarball":"https://registry.npmjs.org/logs-sdk/-/logs-sdk-0.0.0.tgz","fileCount":2,"integrity":"sha512-Ss919eyHiINvgjNe2/2QJIsE9wz7SNBxv+HJ9Nm0iiUvF++BTdvhbjMinffdOYalPrSWwn5D1NW/YQXsc+CHoA==","signatures":[{"sig":"MEYCIQDRLapjkr89ddNjUCdISJKH4NLSu96l/dKuTw8FPdXU6gIhAL2d2sZExP5hqlwe3IFtcf+Zxqiljdg32iS0kFic6Tap","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":119},"gitHead":"5709fcae6bbf3cef4678bc5320bcf68fac84590b","_npmUser":{"name":"danielroe","email":"daniel@roe.dev"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/logs-sdk_0.0.0_1774633488093_0.1449085501848857","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"logs-sdk","version":"0.0.5","keywords":[],"author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","_id":"logs-sdk@0.0.5","maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"danielroe","email":"daniel@roe.dev"}],"contributors":[{"name":"Eduardo San Martin Morote","email":"posva13@gmail.com"}],"homepage":"https://github.com/vercel-labs/logs-sdk#readme","bugs":{"url":"https://github.com/vercel-labs/logs-sdk/issues"},"dist":{"shasum":"883ecf2a5418bf15b04bd57828fb25442c04954b","tarball":"https://registry.npmjs.org/logs-sdk/-/logs-sdk-0.0.5.tgz","fileCount":28,"integrity":"sha512-R52wCMawYldP8Av4wwzbfJzCNWTy6hmBcB6RLj8Ki5fZsfRdBHeYO7hUM27ZkH7Vn8ea6i0JP6uP2DEgZRQwRA==","signatures":[{"sig":"MEQCIAO90uyAr/mQtNWzYkeJv8HlHr2DSV6R0KmKNi5wjLDbAiAfXS/Ff5juBucZhDsjkP71uC9HLw4IhQJnpVL+JboYhg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95296},"type":"module","_from":"file:logs-sdk-0.0.5.tgz","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs","./unplugin":"./dist/unplugin.mjs","./dev-reporter":"./dist/dev-reporter.mjs","./package.json":"./package.json","./node-reporter":"./dist/node-reporter.mjs","./formatters/ansi":"./dist/formatters/ansi.mjs","./formatters/json":"./dist/formatters/json.mjs"},"scripts":{"dev":"vitest","lint":"eslint","play":"pnpm -C playground run dev","test":"pnpm run build && pnpm -r run build && tsc && eslint && vitest run","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:7b161cdc-5188-410c-bc17-52c21ad0b992"}},"_resolved":"/tmp/b9bf86bcd59df3625e2a7291c0ba0063/logs-sdk-0.0.5.tgz","_integrity":"sha512-R52wCMawYldP8Av4wwzbfJzCNWTy6hmBcB6RLj8Ki5fZsfRdBHeYO7hUM27ZkH7Vn8ea6i0JP6uP2DEgZRQwRA==","repository":{"url":"git+https://github.com/vercel-labs/logs-sdk.git","type":"git"},"_npmVersion":"11.11.0","description":"Structured diagnostic code library","directories":{},"lint-staged":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"24.14.1","dependencies":{"unplugin":"^3.0.0","oxc-parser":"^0.124.0","magic-string":"^0.30.21"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.7","bumpp":"^11.0.1","eslint":"^10.2.0","semver":"^7.7.4","tsdown":"^0.21.7","tsnapi":"^0.1.1","vitest":"^4.1.3","esbuild":"^0.28.0","publint":"^0.3.18","logs-sdk":"0.0.5","@antfu/ni":"^30.0.0","typescript":"^6.0.2","@types/node":"^25.5.2","lint-staged":"^16.4.0","@antfu/utils":"^9.3.0","@types/semver":"^7.7.1","@posva/prompts":"^2.4.4","simple-git-hooks":"^2.13.1","@antfu/eslint-config":"^8.1.0","conventional-changelog":"^7.2.0","conventional-changelog-angular":"^8.3.1"},"peerDependencies":{"unplugin":">=2.0.0","oxc-parser":">=0.50.0","magic-string":">=0.30.0"},"simple-git-hooks":{"pre-commit":"pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"},"peerDependenciesMeta":{"unplugin":{"optional":true},"oxc-parser":{"optional":true},"magic-string":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/logs-sdk_0.0.5_1776241850755_0.03607708692495759","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"logs-sdk","type":"module","version":"0.0.6","description":"Structured diagnostic code library","author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"contributors":[{"name":"Eduardo San Martin Morote","email":"posva13@gmail.com"}],"license":"MIT","homepage":"https://github.com/vercel-labs/logs-sdk#readme","repository":{"type":"git","url":"git+https://github.com/vercel-labs/logs-sdk.git"},"bugs":{"url":"https://github.com/vercel-labs/logs-sdk/issues"},"keywords":[],"sideEffects":false,"exports":{".":"./dist/index.mjs","./formatters/ansi":"./dist/formatters/ansi.mjs","./formatters/json":"./dist/formatters/json.mjs","./reporters/dev":"./dist/reporters/dev.mjs","./reporters/node":"./dist/reporters/node.mjs","./unplugin":"./dist/unplugin.mjs","./package.json":"./package.json"},"types":"./dist/index.d.mts","dependencies":{"magic-string":"^0.30.21","oxc-parser":"^0.126.0","unplugin":"^3.0.0"},"devDependencies":{"@antfu/eslint-config":"^8.2.0","@antfu/ni":"^30.0.0","@antfu/utils":"^9.3.0","@posva/prompts":"^2.4.4","@types/node":"^25.6.0","@types/semver":"^7.7.1","bumpp":"^11.0.1","conventional-changelog":"^7.2.0","conventional-changelog-angular":"^8.3.1","esbuild":"^0.28.0","eslint":"^10.2.0","lint-staged":"^16.4.0","publint":"^0.3.18","semver":"^7.7.4","simple-git-hooks":"^2.13.1","tsdown":"^0.21.8","tsnapi":"^0.3.0","typescript":"^6.0.2","vite":"^8.0.8","vitest":"^4.1.4","logs-sdk":"0.0.6"},"simple-git-hooks":{"pre-commit":"pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"},"lint-staged":{"*":"eslint --fix"},"scripts":{"build":"tsdown","dev":"vitest","play":"pnpm -C playground run dev","lint":"eslint","release":"node scripts/release.ts","test":"pnpm run build && pnpm -r run build && tsc && eslint && vitest run","typecheck":"tsc"},"_id":"logs-sdk@0.0.6","_integrity":"sha512-G4M1C9aLLBOIWpmw/Lqk4zrap/T2IJsoUOuUDjRcVSLy6lHQqxr3wCqIT1FvvpYTUYpEwvu4utsMY42jTNvx8Q==","_resolved":"/tmp/0e46683d64fde911ac5a23abcaff55ad/logs-sdk-0.0.6.tgz","_from":"file:logs-sdk-0.0.6.tgz","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-G4M1C9aLLBOIWpmw/Lqk4zrap/T2IJsoUOuUDjRcVSLy6lHQqxr3wCqIT1FvvpYTUYpEwvu4utsMY42jTNvx8Q==","shasum":"8903bcf08f9f860a817be1108d112218d7a209c9","tarball":"https://registry.npmjs.org/logs-sdk/-/logs-sdk-0.0.6.tgz","fileCount":28,"unpackedSize":107885,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEmvY9RTaG2OvHvLKThKHaVP/A0ZLnqep0VEgCXXalNFAiBmdD+SbemT8+XAwTiZQISWT8crnM8oPSZjRDgCPJi+YQ=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:7b161cdc-5188-410c-bc17-52c21ad0b992"}},"directories":{},"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"danielroe","email":"daniel@roe.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logs-sdk_0.0.6_1776382664907_0.3187785149723612"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-27T17:44:48.000Z","modified":"2026-04-16T23:37:45.138Z","1.0.0":"2025-08-20T21:03:52.865Z","1.0.1":"2025-08-20T21:10:40.947Z","0.0.0":"2026-03-27T17:44:48.237Z","0.0.5":"2026-04-15T08:30:50.946Z","0.0.6":"2026-04-16T23:37:45.046Z"},"bugs":{"url":"https://github.com/vercel-labs/logs-sdk/issues"},"author":{"name":"Anthony Fu","email":"anthonyfu117@hotmail.com"},"license":"MIT","homepage":"https://github.com/vercel-labs/logs-sdk#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/vercel-labs/logs-sdk.git"},"description":"Structured diagnostic code library","contributors":[{"name":"Eduardo San Martin Morote","email":"posva13@gmail.com"}],"maintainers":[{"name":"posva","email":"posva13@gmail.com"},{"name":"danielroe","email":"daniel@roe.dev"}],"readme":"# logs-sdk\n\nStructured diagnostic codes for JavaScript/TypeScript libraries and frameworks.\n\n`logs-sdk` makes every error, warning, and suggestion a **structured, typed, machine-readable object** — with a stable code, a human explanation, and enough context for an agent to act on it precisely.\n\n## What it looks like\n\n```\n[NUXT_B2011] Invalid plugin `/plugins/bad.ts`. src option is required.\n├▶ fix: Pass a string path or an object with a `src` property to `addPlugin()`.\n├▶ hint: Check your module's addPlugin() calls\n╰▶ see: https://nuxt.com/e/b2011\n```\n\nEvery diagnostic has a **stable code**, a **human-readable explanation**, and structured fields — `fix`, `why`, `hint`, `docs` — that tell you what happened and how to resolve it. The `see` link points to a dedicated documentation page for that error code, with detailed explanations, examples, and common solutions. It should be visited only if more context is needed beyond the concise inline message.\n\nThese error messages are designed to be **actionable** — not just telling you what went wrong, but guiding you toward the fix.\n\n## For humans\n\nA code like `NUXT_B2011` is stable and searchable — look it up in docs, find it in source, share it in issues. The structured fields give you immediate guidance: you don't need to search for the error message to find the fix, it's right there. And when you need more detail, the docs link takes you to a dedicated page for that specific error code — with explanations and examples to understand the root cause and how to resolve it.\n\nWhen library authors define diagnostics in one place, messages stay consistent. Every occurrence of `NUXT_B2011` produces the same explanation, the same fix, the same docs link.\n\n## For AI agents\n\nStructured diagnostics enable a different kind of agent integration — **precise rather than probabilistic**.\n\nEvery diagnostic has a stable code an agent can dispatch on directly, instead of pattern-matching on message text. The object carries everything needed to act: what happened (`message`), why (`why`), how to fix it (`fix`), where to learn more (`docs`), and machine-readable details (`context`, `sources`). The per-code documentation pages are equally useful for agents — they can crawl or fetch them for deeper context when the inline fields aren't enough.\n\nAn agent can resolve the issue without asking the user for more information. Users don't need to configure anything — if a library uses `logs-sdk`, its diagnostics are already agent-ready. All codes are defined in a catalog, so an agent can enumerate the full error surface ahead of time. And when multiple libraries in a stack adopt it, agents get uniformly structured data from every layer.\n\n## Claude Code plugin\n\nlogs-sdk ships a [Claude Code plugin](https://docs.anthropic.com/en/docs/claude-code/skills) that gives agents full context on the diagnostics API.\n\nRun from your project root — the plugin is scoped to the current directory:\n\n```bash\n# temporary install because private repo, should be a claude code marketplace in the future\ngh api repos/vercel-labs/logs-sdk/contents/install.sh --jq '.content' | base64 -d | bash\n```\n\nThe plugin includes two skills:\n\n- **logs-sdk** — auto-triggered reference skill. Loaded automatically when Claude Code detects logs-sdk imports or API usage in your project, providing context on `defineDiagnostics`, `createLogger`, formatters, reporters, and best practices.\n- **`/add-diagnostic`** — user-invocable skill. Guides the agent through adding a new diagnostic code following the `PREFIX_XNNNN` convention, picking the right file, category, and sequence number.\n\n## Usage\n\n### Define diagnostics\n\n`defineDiagnostics()` declares the diagnostic codes for a domain — pure data, no side effects.\n\n`docsBase` can be a string (auto-appends `/${code.toLowerCase()}`) or a function for full control over the URL:\n\n```ts\nimport { defineDiagnostics } from 'logs-sdk'\n\n// Function form — strip the project prefix for cleaner URLs\nconst diagnostics = defineDiagnostics({\n  docsBase: code => `https://nuxt.com/e/${code.replace('NUXT_', '').toLowerCase()}`,\n  codes: {\n    NUXT_B2011: {\n      message: (p: { src: string }) => `Invalid plugin \\`${p.src}\\`. src option is required.`,\n      fix: 'Pass a string path or an object with a `src` property to `addPlugin()`.',\n    },\n    NUXT_B5001: {\n      message: 'Missing compatibilityDate in nuxt.config.',\n      fix: (p: { date: string }) => `Add \\`compatibilityDate: '${p.date}'\\` to your nuxt.config.`,\n      hint: 'This ensures consistent behavior across Nuxt versions.',\n      level: 'warn',\n    },\n  },\n})\n// diagnostics.NUXT_B2011({ src: '...' }).docs → 'https://nuxt.com/e/b2011'\n```\n\n```ts\n// String form — simple base URL, code appended automatically\nconst diagnostics = defineDiagnostics({\n  docsBase: 'https://example.com/errors',\n  codes: {\n    MY_E001: { message: 'Something went wrong.' },\n  },\n})\n// diagnostics.MY_E001().docs → 'https://example.com/errors/my_e001'\n```\n\n### Create a logger\n\n`createLogger()` binds diagnostics to output — formatting and reporting.\n\n```ts\nimport { createLogger } from 'logs-sdk'\n\nconst log = createLogger({\n  diagnostics: [diagnostics],\n})\n\nlog.NUXT_B2011({ src: pluginPath }).throw()\nlog.NUXT_B5001({ date: '2025-01-01' }).warn()\n```\n\n`log.NUXT_B2011` is cmd+clickable, TypeScript enforces params, and actions are chainable — `.throw()`, `.warn()`, `.error()`, `.log()`.\n\n### Multiple diagnostic sets\n\n```ts\nconst log = createLogger({\n  diagnostics: [nuxtDiagnostics, i18nDiagnostics],\n})\n\nlog.NUXT_B2011({ src: pluginPath }).throw() // [NUXT_B2011] ...\nlog.I18N_I001({ locale: 'fr' }).warn() // [I18N_I001] ...\n```\n\n### Custom reporters\n\nPass a single reporter function or an array:\n\n```ts\nconst log = createLogger({\n  diagnostics: [diagnostics],\n  reporters: [\n    consoleReporter,\n    (diagnostic, formatted) => {\n      sentry.captureMessage(formatted, { tags: { code: diagnostic.code } })\n    },\n  ],\n})\n```\n\n## Features\n\n- Typed diagnostic factories — cmd+clickable (go to definition), hover shows params, TypeScript enforces correctness\n- Structured `Diagnostic` objects — serializable, transportable across process boundaries\n- Chainable actions — `.throw()`, `.warn()`, `.error()`, `.log()`\n- Pluggable formatters — plain text, ANSI colors, JSON\n- Pluggable reporters — console, HTTP, custom\n- Multiple diagnostic sets — compose diagnostics from different libraries\n- Zero runtime dependencies\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md"}