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.
Files changed (2) hide show
  1. package/dist/bin/cli.mjs +65 -44
  2. 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 { Command } from "commander";
7
- import pc from "picocolors";
8
- const program = new Command();
9
- program.name("docs-to-agent").description("Download docs from a GitHub repo and generate a compact index for AI coding agents").argument("<github-url>", "GitHub URL with docs path (e.g. https://github.com/nuxt/nuxt/tree/main/docs)").option("-o, --output <file>", "Target file", "AGENTS.md").option("--name <name>", "Project name override (defaults to repo name)").action(async (url, opts) => {
10
- try {
11
- console.log(pc.cyan("Parsing GitHub URL..."));
12
- const parsed = parseGitHubUrl(url);
13
- const projectName = opts.name || parsed.repo;
14
- const key = repoKey(parsed.owner, parsed.repo);
15
- console.log(pc.dim(` repo: ${parsed.owner}/${parsed.repo}, branch: ${parsed.branch}, path: ${parsed.docsPath}`));
16
- const cwd = process.cwd();
17
- console.log(pc.cyan("Downloading documentation..."));
18
- const result = pullDocs({
19
- owner: parsed.owner,
20
- repo: parsed.repo,
21
- branch: parsed.branch,
22
- docsPath: parsed.docsPath,
23
- cwd
24
- });
25
- console.log(pc.green(` Downloaded ${result.fileCount} doc files → ${result.localDocsDir}/`));
26
- const files = collectDocFiles(join(cwd, result.localDocsDir));
27
- if (files.length === 0) {
28
- console.log(pc.yellow("No .md/.mdx files found in docs folder."));
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.1.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
- "commander": "^14.0.3",
29
- "picocolors": "^1.1.1"
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 version && git add . && git commit -m 'chore(release): version packages' && changeset publish && git push --follow-tags"
55
+ "release": "changeset publish"
56
56
  }
57
57
  }