nuxt-agent-md 0.3.0 → 0.4.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.
- package/README.md +4 -2
- package/dist/cli.js +23 -4
- 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
|
|
|
@@ -21,6 +21,7 @@ nuxt-agent-md
|
|
|
21
21
|
2. Downloads the corresponding `@nuxt/docs` documentation (~1.5 MB)
|
|
22
22
|
3. Generates a minified index (~20 KB) of all documentation files
|
|
23
23
|
4. Creates/updates `AGENTS.md` with the index
|
|
24
|
+
5. Creates `CLAUDE.md` that references `@AGENTS.md`
|
|
24
25
|
|
|
25
26
|
The index format is pipe-delimited for minimal token usage:
|
|
26
27
|
|
|
@@ -61,7 +62,8 @@ nuxt-agent-md -d .docs -o CLAUDE.md
|
|
|
61
62
|
The tool generates:
|
|
62
63
|
|
|
63
64
|
1. `.nuxt-docs/` - Directory containing markdown documentation (auto-added to `.gitignore`)
|
|
64
|
-
2. `AGENTS.md` - File with
|
|
65
|
+
2. `AGENTS.md` - File with documentation index (wrapped in `<!-- BEGIN:nuxt-agent-rules -->` markers)
|
|
66
|
+
3. `CLAUDE.md` - File that references `@AGENTS.md` for Claude Code/Cursor compatibility
|
|
65
67
|
|
|
66
68
|
## Why?
|
|
67
69
|
|
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 = "<!--
|
|
241
|
-
var END_MARKER = "<!--
|
|
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,6 +262,18 @@ 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
279
|
const majorVersion = nuxtVersion.split(".")[0];
|
|
@@ -354,7 +372,8 @@ async function generateAgentsMd(options = {}) {
|
|
|
354
372
|
if (updateGitignore(docsDir)) {
|
|
355
373
|
console.log(`Added ${docsDir} to .gitignore`);
|
|
356
374
|
}
|
|
357
|
-
|
|
375
|
+
const claudeMdPath = outputPath.replace(/[^/]+$/, "CLAUDE.md");
|
|
376
|
+
console.log(`Generated ${outputPath} and ${claudeMdPath}`);
|
|
358
377
|
}
|
|
359
378
|
|
|
360
379
|
// src/cli.ts
|