nuxt-agent-md 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +19 -13
  2. package/dist/cli.js +26 -45
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nuxt-agent-md
2
2
 
3
- Generate `AGENTS.md` with Nuxt documentation for AI coding agents (Cursor, Copilot, Claude, etc.).
3
+ Generate `AGENTS.md` and `CLAUDE.md` with Nuxt documentation for AI coding agents (Cursor, Copilot, Claude Code, etc.).
4
4
 
5
5
  Gives your AI assistant instant access to accurate Nuxt API references, reducing hallucinations and improving code quality.
6
6
 
@@ -18,15 +18,14 @@ nuxt-agent-md
18
18
  ## What it does
19
19
 
20
20
  1. Detects your Nuxt version from `package.json`
21
- 2. Downloads the corresponding `@nuxt/docs` documentation (~1.5 MB)
22
- 3. Generates a minified index (~20 KB) of all documentation files
23
- 4. Creates/updates `AGENTS.md` with the index
21
+ 2. Downloads the corresponding `@nuxt/docs` documentation (~1.5 MB) to `.nuxt-docs/`
22
+ 3. Generates a compact pipe-delimited index pointing to the downloaded docs
23
+ 4. Creates/updates `AGENTS.md` with a directive instruction and the index
24
+ 5. Creates `CLAUDE.md` that references `@AGENTS.md`
24
25
 
25
- The index format is pipe-delimited for minimal token usage:
26
+ The generated `AGENTS.md` is intentionally minimal — a short directive telling the agent to read the docs, followed by a file index. No inline API summaries or pattern guides are included, so the agent is forced to consult the actual documentation files rather than relying on stale training data.
26
27
 
27
- ```
28
- CATEGORY|path/to/file.md|keyword1,keyword2,keyword3
29
- ```
28
+ This follows [Vercel's finding](https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals) that passive context with retrieval-led reasoning outperforms both skills and inline knowledge.
30
29
 
31
30
  ## Options
32
31
 
@@ -61,15 +60,22 @@ nuxt-agent-md -d .docs -o CLAUDE.md
61
60
  The tool generates:
62
61
 
63
62
  1. `.nuxt-docs/` - Directory containing markdown documentation (auto-added to `.gitignore`)
64
- 2. `AGENTS.md` - File with minified index pointing to the docs
63
+ 2. `AGENTS.md` - File with documentation index (wrapped in `<!-- BEGIN:nuxt-agent-rules -->` markers)
64
+ 3. `CLAUDE.md` - File that references `@AGENTS.md` for Claude Code/Cursor compatibility
65
65
 
66
- ## Why?
66
+ ## How it works
67
67
 
68
- AI coding agents work better when they have access to accurate documentation rather than relying on training data that may be outdated. By providing a compact index in `AGENTS.md`, the agent can quickly find and read the relevant documentation files for any Nuxt API.
68
+ The key insight from [Vercel's research](https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals) is that agents perform best when given a directive to read docs rather than inline knowledge they can use as a shortcut. The generated `AGENTS.md` contains:
69
69
 
70
- ## Credits
70
+ ```markdown
71
+ # Nuxt: ALWAYS read docs before coding
72
+
73
+ This project uses Nuxt v4.x.x. Before any Nuxt work, find and read
74
+ the relevant doc in `.nuxt-docs/`. Your training data may be outdated
75
+ — the docs are the source of truth.
76
+ ```
71
77
 
72
- Inspired by [Vercel's research](https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals) showing that documentation indexes in `AGENTS.md` significantly improve agent accuracy.
78
+ Followed by a compact index mapping categories to doc file paths. The agent sees the index, knows where to find specific docs, and reads the actual files when needed.
73
79
 
74
80
  ## License
75
81
 
package/dist/cli.js CHANGED
@@ -236,17 +236,23 @@ function generateFullIndex(entries, docsDir) {
236
236
  }
237
237
 
238
238
  // src/inject.ts
239
+ import { dirname, join as join4 } from "node:path";
239
240
  import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync } from "node:fs";
240
- var START_MARKER = "<!-- NUXT_DOCS_START -->";
241
- var END_MARKER = "<!-- NUXT_DOCS_END -->";
241
+ var START_MARKER = "<!-- BEGIN:nuxt-agent-rules -->";
242
+ var END_MARKER = "<!-- END:nuxt-agent-rules -->";
242
243
  async function injectAgentsMd(outputPath, index, nuxtVersion, docsDir, minify) {
243
244
  let content = "";
244
245
  if (existsSync3(outputPath)) {
245
246
  content = readFileSync3(outputPath, "utf-8");
246
247
  }
247
248
  const nuxtSection = generateNuxtSection(index, nuxtVersion, docsDir, minify);
249
+ const oldStartMarker = "<!-- NUXT_DOCS_START -->";
250
+ const oldEndMarker = "<!-- NUXT_DOCS_END -->";
248
251
  if (content.includes(START_MARKER) && content.includes(END_MARKER)) {
249
- const regex = new RegExp(`${START_MARKER}[\\s\\S]*${END_MARKER}`, "m");
252
+ const regex = new RegExp(`${escapeRegex(START_MARKER)}[\\s\\S]*${escapeRegex(END_MARKER)}`, "m");
253
+ content = content.replace(regex, nuxtSection);
254
+ } else if (content.includes(oldStartMarker) && content.includes(oldEndMarker)) {
255
+ const regex = new RegExp(`${escapeRegex(oldStartMarker)}[\\s\\S]*${escapeRegex(oldEndMarker)}`, "m");
250
256
  content = content.replace(regex, nuxtSection);
251
257
  } else if (content.length > 0) {
252
258
  content = content.trimEnd() + `
@@ -256,60 +262,34 @@ async function injectAgentsMd(outputPath, index, nuxtVersion, docsDir, minify) {
256
262
  content = generateFullAgentsMd(nuxtSection);
257
263
  }
258
264
  writeFileSync(outputPath, content);
265
+ generateClaudeMd(outputPath);
266
+ }
267
+ function escapeRegex(str) {
268
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
269
+ }
270
+ function generateClaudeMd(agentsMdPath) {
271
+ const dir = dirname(agentsMdPath);
272
+ const claudeMdPath = join4(dir, "CLAUDE.md");
273
+ const agentsMdFilename = agentsMdPath.split("/").pop() || "AGENTS.md";
274
+ const claudeMdContent = `@${agentsMdFilename}
275
+ `;
276
+ writeFileSync(claudeMdPath, claudeMdContent, "utf-8");
259
277
  }
260
278
  function generateNuxtSection(index, nuxtVersion, docsDir, minify) {
261
- const majorVersion = nuxtVersion.split(".")[0];
262
279
  return `${START_MARKER}
263
- ## Nuxt Documentation
264
280
 
265
- This project uses **Nuxt ${majorVersion}** (v${nuxtVersion}).
281
+ # Nuxt: ALWAYS read docs before coding
266
282
 
267
- When working with Nuxt APIs, ALWAYS read the referenced documentation files before making changes.
268
-
269
- ### Quick Reference Index
283
+ This project uses Nuxt v${nuxtVersion}. Before any Nuxt work, find and read the relevant doc in \`${docsDir}/\`. Your training data may be outdated — the docs are the source of truth.
270
284
 
271
285
  \`\`\`
272
286
  ${minify ? index.minified : index.full}
273
287
  \`\`\`
274
288
 
275
- ### Key Nuxt ${majorVersion} Patterns
276
-
277
- #### Data Fetching
278
- - Use \`useFetch\` for component-level data fetching (auto-deduped, SSR-safe)
279
- - Use \`useAsyncData\` when you need more control over the key/handler
280
- - Use \`$fetch\` in event handlers and server routes (NOT in setup for SSR)
281
- - Always handle \`pending\` and \`error\` states
282
-
283
- #### Server Routes
284
- - Files in \`server/api/\` become API endpoints
285
- - Use \`defineEventHandler\` for all handlers
286
- - Access body with \`readBody(event)\`
287
- - Access query with \`getQuery(event)\`
288
- - Access params with \`event.context.params\`
289
-
290
- #### State Management
291
- - Use \`useState\` for SSR-friendly reactive state
292
- - Use \`useCookie\` for cookie-based state
293
- - Use \`useRuntimeConfig\` for environment variables
294
-
295
- #### Routing & Navigation
296
- - Use \`definePageMeta\` for page-level config
297
- - Use \`navigateTo\` for programmatic navigation
298
- - Use \`useRoute\` and \`useRouter\` for route info
299
-
300
- #### Configuration
301
- - \`nuxt.config.ts\` for build-time config
302
- - \`runtimeConfig\` for environment variables (private/public)
303
- - \`app.config.ts\` for public runtime config
304
-
305
289
  ${END_MARKER}`;
306
290
  }
307
291
  function generateFullAgentsMd(nuxtSection) {
308
- return `# AGENTS.md
309
-
310
- This file provides documentation references for AI coding agents.
311
-
312
- ${nuxtSection}
292
+ return `${nuxtSection}
313
293
  `;
314
294
  }
315
295
 
@@ -354,7 +334,8 @@ async function generateAgentsMd(options = {}) {
354
334
  if (updateGitignore(docsDir)) {
355
335
  console.log(`Added ${docsDir} to .gitignore`);
356
336
  }
357
- console.log(`Generated ${outputPath}`);
337
+ const claudeMdPath = outputPath.replace(/[^/]+$/, "CLAUDE.md");
338
+ console.log(`Generated ${outputPath} and ${claudeMdPath}`);
358
339
  }
359
340
 
360
341
  // src/cli.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-agent-md",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Generate AGENTS.md with Nuxt documentation for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {