docs-to-agent 0.1.0 → 0.2.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/dist/bin/cli.mjs +65 -44
- package/package.json +4 -4
package/dist/bin/cli.mjs
CHANGED
|
@@ -3,51 +3,72 @@ import { c as parseGitHubUrl, i as DOCS_BASE_DIR, l as pullDocs, n as generateIn
|
|
|
3
3
|
import "../index.mjs";
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
import { defineCommand, runMain } from "citty";
|
|
7
|
+
import { consola } from "consola";
|
|
8
|
+
import { colors } from "consola/utils";
|
|
9
|
+
runMain(defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "docs-to-agent",
|
|
12
|
+
version: "0.1.0",
|
|
13
|
+
description: "Download docs from a GitHub repo and generate a compact index for AI coding agents"
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
url: {
|
|
17
|
+
type: "positional",
|
|
18
|
+
description: "GitHub URL with docs path (e.g. https://github.com/nuxt/nuxt/tree/main/docs)",
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
output: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Target file",
|
|
24
|
+
alias: "o",
|
|
25
|
+
default: "AGENTS.md"
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Project name override (defaults to repo name)"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
run({ args }) {
|
|
33
|
+
try {
|
|
34
|
+
consola.start("Parsing GitHub URL...");
|
|
35
|
+
const parsed = parseGitHubUrl(args.url);
|
|
36
|
+
const projectName = args.name || parsed.repo;
|
|
37
|
+
const key = repoKey(parsed.owner, parsed.repo);
|
|
38
|
+
consola.info(colors.dim(`repo: ${parsed.owner}/${parsed.repo}, branch: ${parsed.branch}, path: ${parsed.docsPath}`));
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
consola.start("Downloading documentation...");
|
|
41
|
+
const result = pullDocs({
|
|
42
|
+
owner: parsed.owner,
|
|
43
|
+
repo: parsed.repo,
|
|
44
|
+
branch: parsed.branch,
|
|
45
|
+
docsPath: parsed.docsPath,
|
|
46
|
+
cwd
|
|
47
|
+
});
|
|
48
|
+
consola.success(`Downloaded ${result.fileCount} doc files → ${result.localDocsDir}/`);
|
|
49
|
+
const files = collectDocFiles(join(cwd, result.localDocsDir));
|
|
50
|
+
if (files.length === 0) {
|
|
51
|
+
consola.warn("No .md/.mdx files found in docs folder.");
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
const sections = buildDocTree(files);
|
|
55
|
+
const indexContent = generateIndex({
|
|
56
|
+
name: projectName,
|
|
57
|
+
docsDir: result.localDocsDir,
|
|
58
|
+
sections
|
|
59
|
+
});
|
|
60
|
+
const outputPath = resolve(cwd, args.output);
|
|
61
|
+
let existingContent = "";
|
|
62
|
+
if (existsSync(outputPath)) existingContent = readFileSync(outputPath, "utf-8");
|
|
63
|
+
writeFileSync(outputPath, injectIntoFile(existingContent, indexContent, key));
|
|
64
|
+
consola.success(`Updated ${args.output}`);
|
|
65
|
+
if (ensureGitignoreEntry(cwd, DOCS_BASE_DIR).updated) consola.info(colors.dim(`Added ${DOCS_BASE_DIR}/ to .gitignore`));
|
|
66
|
+
consola.box(`Done! ${files.length} docs indexed → ${args.output} [${key}]`);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
69
|
+
consola.error(msg);
|
|
29
70
|
process.exit(1);
|
|
30
71
|
}
|
|
31
|
-
const sections = buildDocTree(files);
|
|
32
|
-
const indexContent = generateIndex({
|
|
33
|
-
name: projectName,
|
|
34
|
-
docsDir: result.localDocsDir,
|
|
35
|
-
sections
|
|
36
|
-
});
|
|
37
|
-
const outputPath = resolve(cwd, opts.output);
|
|
38
|
-
let existingContent = "";
|
|
39
|
-
if (existsSync(outputPath)) existingContent = readFileSync(outputPath, "utf-8");
|
|
40
|
-
writeFileSync(outputPath, injectIntoFile(existingContent, indexContent, key));
|
|
41
|
-
console.log(pc.green(` Updated ${opts.output}`));
|
|
42
|
-
if (ensureGitignoreEntry(cwd, DOCS_BASE_DIR).updated) console.log(pc.dim(` Added ${DOCS_BASE_DIR}/ to .gitignore`));
|
|
43
|
-
console.log();
|
|
44
|
-
console.log(pc.green(pc.bold("Done!")));
|
|
45
|
-
console.log(pc.dim(` ${files.length} docs indexed → ${opts.output} [${key}]`));
|
|
46
|
-
} catch (err) {
|
|
47
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
48
|
-
console.error(pc.red(`Error: ${msg}`));
|
|
49
|
-
process.exit(1);
|
|
50
72
|
}
|
|
51
|
-
});
|
|
52
|
-
program.parse();
|
|
73
|
+
}));
|
|
53
74
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docs-to-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Download docs from any GitHub repo and generate a compact index for AI coding agents",
|
|
5
5
|
"homepage": "https://github.com/angelorc/docs-to-agent",
|
|
6
6
|
"bugs": "https://github.com/angelorc/docs-to-agent/issues",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"citty": "^0.2.0",
|
|
29
|
+
"consola": "^3.4.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@changesets/cli": "^2.29.4",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"typecheck": "tsc --noEmit",
|
|
53
53
|
"changeset": "changeset",
|
|
54
54
|
"version": "changeset version",
|
|
55
|
-
"release": "changeset
|
|
55
|
+
"release": "changeset publish"
|
|
56
56
|
}
|
|
57
57
|
}
|