nuxt-agent-md 0.2.0 → 0.3.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 +16 -24
- package/dist/cli.js +20 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# nuxt-agent-md
|
|
2
2
|
|
|
3
|
-
Generate `AGENTS.md` with Nuxt documentation for AI coding agents.
|
|
3
|
+
Generate `AGENTS.md` with Nuxt documentation for AI coding agents (Cursor, Copilot, Claude, etc.).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Gives your AI assistant instant access to accurate Nuxt API references, reducing hallucinations and improving code quality.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
@@ -18,9 +18,15 @@ 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
|
|
22
|
-
3. Generates a minified index of all documentation files
|
|
23
|
-
4. Creates/updates `AGENTS.md` with the index
|
|
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
|
|
24
|
+
|
|
25
|
+
The index format is pipe-delimited for minimal token usage:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
CATEGORY|path/to/file.md|keyword1,keyword2,keyword3
|
|
29
|
+
```
|
|
24
30
|
|
|
25
31
|
## Options
|
|
26
32
|
|
|
@@ -48,36 +54,22 @@ nuxt-agent-md --no-minify
|
|
|
48
54
|
|
|
49
55
|
# Custom output paths
|
|
50
56
|
nuxt-agent-md -d .docs -o CLAUDE.md
|
|
51
|
-
|
|
52
|
-
# Preview changes without writing
|
|
53
|
-
nuxt-agent-md --dry-run
|
|
54
57
|
```
|
|
55
58
|
|
|
56
59
|
## Output
|
|
57
60
|
|
|
58
61
|
The tool generates:
|
|
59
62
|
|
|
60
|
-
1. `.nuxt-docs/` - Directory containing
|
|
63
|
+
1. `.nuxt-docs/` - Directory containing markdown documentation (auto-added to `.gitignore`)
|
|
61
64
|
2. `AGENTS.md` - File with minified index pointing to the docs
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
CATEGORY|path/to/file.md|keyword1,keyword2,keyword3
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Why this approach?
|
|
66
|
+
## Why?
|
|
70
67
|
|
|
71
|
-
|
|
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.
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|----------|--------------|
|
|
75
|
-
| Baseline (no docs) | 53% |
|
|
76
|
-
| Skills | 53% |
|
|
77
|
-
| Skills with explicit instructions | 79% |
|
|
78
|
-
| **AGENTS.md with docs index** | **100%** |
|
|
70
|
+
## Credits
|
|
79
71
|
|
|
80
|
-
|
|
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.
|
|
81
73
|
|
|
82
74
|
## License
|
|
83
75
|
|
package/dist/cli.js
CHANGED
|
@@ -38,8 +38,10 @@ function mapToDocsVersion(nuxtVersion) {
|
|
|
38
38
|
|
|
39
39
|
// src/download.ts
|
|
40
40
|
import { spawnSync } from "node:child_process";
|
|
41
|
-
import { existsSync as existsSync2, mkdirSync, rmSync, renameSync } from "node:fs";
|
|
41
|
+
import { existsSync as existsSync2, mkdirSync, rmSync, renameSync, readdirSync } from "node:fs";
|
|
42
42
|
import { join as join2 } from "node:path";
|
|
43
|
+
var CLEANUP_FILES = ["LICENSE", "README.md", "package.json", ".navigation.yml"];
|
|
44
|
+
var CLEANUP_DIRS = ["bridge", "community", "migration"];
|
|
43
45
|
async function downloadDocs(version, targetDir) {
|
|
44
46
|
const tempDir = ".nuxt-docs-temp";
|
|
45
47
|
if (existsSync2(targetDir))
|
|
@@ -63,6 +65,17 @@ async function downloadDocs(version, targetDir) {
|
|
|
63
65
|
if (extract.status !== 0)
|
|
64
66
|
throw new Error(extract.stderr);
|
|
65
67
|
renameSync(join2(tempDir, "package"), targetDir);
|
|
68
|
+
for (const file of CLEANUP_FILES) {
|
|
69
|
+
const path = join2(targetDir, file);
|
|
70
|
+
if (existsSync2(path))
|
|
71
|
+
rmSync(path);
|
|
72
|
+
}
|
|
73
|
+
for (const item of readdirSync(targetDir)) {
|
|
74
|
+
const dirName = item.replace(/^\d+\./, "");
|
|
75
|
+
if (CLEANUP_DIRS.includes(dirName)) {
|
|
76
|
+
rmSync(join2(targetDir, item), { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
66
79
|
} finally {
|
|
67
80
|
if (existsSync2(tempDir))
|
|
68
81
|
rmSync(tempDir, { recursive: true });
|
|
@@ -70,7 +83,7 @@ async function downloadDocs(version, targetDir) {
|
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
// src/generate.ts
|
|
73
|
-
import { readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
86
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
74
87
|
import { join as join3, relative } from "node:path";
|
|
75
88
|
async function generateIndex(docsDir) {
|
|
76
89
|
const entries = [];
|
|
@@ -81,10 +94,11 @@ async function generateIndex(docsDir) {
|
|
|
81
94
|
full: generateFullIndex(entries, docsDir)
|
|
82
95
|
};
|
|
83
96
|
}
|
|
97
|
+
var EXCLUDED_DIRS = ["bridge", "community"];
|
|
84
98
|
function walkDir(dir, baseDir, entries) {
|
|
85
99
|
let items;
|
|
86
100
|
try {
|
|
87
|
-
items =
|
|
101
|
+
items = readdirSync2(dir);
|
|
88
102
|
} catch {
|
|
89
103
|
return;
|
|
90
104
|
}
|
|
@@ -97,7 +111,8 @@ function walkDir(dir, baseDir, entries) {
|
|
|
97
111
|
continue;
|
|
98
112
|
}
|
|
99
113
|
if (stat.isDirectory()) {
|
|
100
|
-
|
|
114
|
+
const dirName = item.replace(/^\d+\./, "");
|
|
115
|
+
if (!item.startsWith(".") && item !== "node_modules" && !EXCLUDED_DIRS.includes(dirName)) {
|
|
101
116
|
walkDir(fullPath, baseDir, entries);
|
|
102
117
|
}
|
|
103
118
|
} else if (item.endsWith(".md") && !item.startsWith(".")) {
|
|
@@ -186,7 +201,7 @@ function generateMinifiedIndex(entries, docsDir) {
|
|
|
186
201
|
});
|
|
187
202
|
const lines = [];
|
|
188
203
|
for (const entry of sorted) {
|
|
189
|
-
const keywords = entry.keywords.slice(0,
|
|
204
|
+
const keywords = entry.keywords.slice(0, 5).join(",");
|
|
190
205
|
lines.push(`${entry.category}|${docsDir}/${entry.path}|${keywords}`);
|
|
191
206
|
}
|
|
192
207
|
return lines.join(`
|