agdex 0.5.1 → 0.6.1

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/cli/index.js CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- __commonJS,
4
- __require,
5
- __toESM,
6
3
  basedpyrightProvider,
7
4
  buildDocTree,
8
5
  bunProvider,
@@ -42,7 +39,12 @@ import {
42
39
  tailwindProvider,
43
40
  tauriProvider,
44
41
  tyProvider
45
- } from "../index-thmt54kg.js";
42
+ } from "../index-cm3qmz9v.js";
43
+ import {
44
+ __commonJS,
45
+ __require,
46
+ __toESM
47
+ } from "../index-dtcewfnz.js";
46
48
 
47
49
  // node_modules/commander/lib/error.js
48
50
  var require_error = __commonJS((exports) => {
@@ -2107,7 +2109,7 @@ var require_clear = __commonJS((exports, module) => {
2107
2109
  if (it)
2108
2110
  o = it;
2109
2111
  var i = 0;
2110
- var F = function F() {};
2112
+ var F = function F2() {};
2111
2113
  return { s: F, n: function n() {
2112
2114
  if (i >= o.length)
2113
2115
  return { done: true };
@@ -4439,7 +4441,7 @@ var require_dist = __commonJS((exports, module) => {
4439
4441
  if (it)
4440
4442
  o = it;
4441
4443
  var i = 0;
4442
- var F = function F() {};
4444
+ var F = function F2() {};
4443
4445
  return { s: F, n: function n() {
4444
4446
  if (i >= o.length)
4445
4447
  return { done: true };
@@ -4542,7 +4544,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4542
4544
  }
4543
4545
  return question2.format ? yield question2.format(answer2, answers) : answer2;
4544
4546
  });
4545
- return function getFormattedAnswer(_x, _x2) {
4547
+ return function getFormattedAnswer2(_x, _x2) {
4546
4548
  return _ref.apply(this, arguments);
4547
4549
  };
4548
4550
  }();
@@ -7048,6 +7050,13 @@ Cancelled.`));
7048
7050
  }
7049
7051
  async function runEmbed(options) {
7050
7052
  const cwd = process.cwd();
7053
+ if (options.url) {
7054
+ await runUrl(options.url, {
7055
+ output: options.output,
7056
+ name: options.description
7057
+ });
7058
+ return;
7059
+ }
7051
7060
  let provider;
7052
7061
  let version = options.fwVersion;
7053
7062
  let output;
@@ -7090,7 +7099,7 @@ async function runEmbed(options) {
7090
7099
  return;
7091
7100
  }
7092
7101
  output = options.output || getDefaultOutput();
7093
- if (!version && !provider.detectVersion) {
7102
+ if (!version && !provider.detectVersion && !provider.urlConfig) {
7094
7103
  console.error(import_picocolors2.default.red(`Provider ${provider.displayName} requires --version flag since auto-detection is not supported.`));
7095
7104
  process.exit(1);
7096
7105
  }
@@ -7100,7 +7109,10 @@ async function runEmbed(options) {
7100
7109
  async function executeEmbed(cwd, provider, version, output, globalCache, description) {
7101
7110
  let resolvedVersion = version;
7102
7111
  let usingDefaultBranch = false;
7103
- if (!resolvedVersion && provider.detectVersion) {
7112
+ if (!resolvedVersion && provider.urlConfig) {
7113
+ resolvedVersion = "latest";
7114
+ usingDefaultBranch = true;
7115
+ } else if (!resolvedVersion && provider.detectVersion) {
7104
7116
  const detected = provider.detectVersion(cwd);
7105
7117
  if (!detected.version) {
7106
7118
  const fallbackBranch = provider.defaultBranch || "main";
@@ -7555,6 +7567,68 @@ Building index from ${import_picocolors2.default.cyan(docsPath)}...`);
7555
7567
  console.log(`${import_picocolors2.default.green("✓")} ${action} ${import_picocolors2.default.bold(output)} (${sizeInfo})`);
7556
7568
  console.log("");
7557
7569
  }
7570
+ async function runUrl(url, options) {
7571
+ const cwd = process.cwd();
7572
+ const { createUrlProvider } = await import("../url-scraper-5sj8c56t.js");
7573
+ const { pullDocsFromUrl } = await import("../url-scraper-5sj8c56t.js");
7574
+ const name = options.name || new URL(url).hostname.replace(/^docs\./, "").replace(/\.\w+$/, "");
7575
+ const providerName = name.toLowerCase().replace(/\s+/g, "-");
7576
+ const output = options.output || getDefaultOutput();
7577
+ const cacheBase = path.join(os.homedir(), ".cache", "agdex");
7578
+ const docsPath = path.join(cacheBase, providerName);
7579
+ console.log(`
7580
+ Scraping documentation from ${import_picocolors2.default.cyan(url)}...`);
7581
+ const cacheHit = fs.existsSync(docsPath) && fs.readdirSync(docsPath).length > 0;
7582
+ if (cacheHit) {
7583
+ console.log(`${import_picocolors2.default.green("✓")} Using cached docs from ${import_picocolors2.default.bold(docsPath)}`);
7584
+ } else {
7585
+ const urlConfig = {
7586
+ baseUrl: url,
7587
+ contentSelector: options.selector || "main#main-content, main, article, .body",
7588
+ removeSelectors: [],
7589
+ concurrency: options.concurrency ? parseInt(options.concurrency, 10) : 5,
7590
+ fetchDelay: options.delay ? parseInt(options.delay, 10) : 200
7591
+ };
7592
+ const pullResult = await pullDocsFromUrl(urlConfig, docsPath, {
7593
+ onProgress: (current, total, page) => {
7594
+ process.stdout.write(`\r Fetching pages... ${current}/${total} (${page})`);
7595
+ }
7596
+ });
7597
+ if (!pullResult.success) {
7598
+ console.error(import_picocolors2.default.red(`
7599
+ Failed: ${pullResult.error}`));
7600
+ process.exit(1);
7601
+ }
7602
+ console.log(`
7603
+ ${import_picocolors2.default.green("✓")} Downloaded docs to ${import_picocolors2.default.bold(docsPath)}`);
7604
+ }
7605
+ const targetPath = path.join(cwd, output);
7606
+ let existingContent = "";
7607
+ let sizeBefore = 0;
7608
+ let isNewFile = true;
7609
+ if (fs.existsSync(targetPath)) {
7610
+ existingContent = fs.readFileSync(targetPath, "utf-8");
7611
+ sizeBefore = Buffer.byteLength(existingContent, "utf-8");
7612
+ isNewFile = false;
7613
+ }
7614
+ const docFiles = collectDocFiles(docsPath, { extensions: [".md"] });
7615
+ const sections = buildDocTree(docFiles);
7616
+ const indexContent = generateIndex({
7617
+ docsPath,
7618
+ sections,
7619
+ outputFile: output,
7620
+ providerName: name,
7621
+ instruction: `IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any ${name} tasks.`,
7622
+ regenerateCommand: `npx agdex url "${url}" --name "${name}" --output ${output}`
7623
+ });
7624
+ const newContent = injectIndex(existingContent, indexContent, providerName);
7625
+ fs.writeFileSync(targetPath, newContent, "utf-8");
7626
+ const sizeAfter = Buffer.byteLength(newContent, "utf-8");
7627
+ const action = isNewFile ? "Created" : "Updated";
7628
+ const sizeInfo = isNewFile ? formatSize(sizeAfter) : `${formatSize(sizeBefore)} → ${formatSize(sizeAfter)}`;
7629
+ console.log(`${import_picocolors2.default.green("✓")} ${action} ${import_picocolors2.default.bold(output)} (${sizeInfo})`);
7630
+ console.log("");
7631
+ }
7558
7632
  function runList() {
7559
7633
  console.log(import_picocolors2.default.cyan(`
7560
7634
  \uD83D\uDCDA Built-in Documentation Providers
@@ -7563,8 +7637,8 @@ function runList() {
7563
7637
  const provider = getProvider(preset);
7564
7638
  const status = provider ? import_picocolors2.default.green("✓") : import_picocolors2.default.gray("○");
7565
7639
  const name = provider?.displayName || preset;
7566
- const repo = provider?.repo || "not implemented";
7567
- console.log(` ${status} ${import_picocolors2.default.bold(preset)} - ${name} (${import_picocolors2.default.gray(repo)})`);
7640
+ const source = provider?.urlConfig ? provider.urlConfig.baseUrl : provider?.repo || "not implemented";
7641
+ console.log(` ${status} ${import_picocolors2.default.bold(preset)} - ${name} (${import_picocolors2.default.gray(source)})`);
7568
7642
  }
7569
7643
  console.log("");
7570
7644
  console.log(import_picocolors2.default.cyan(`\uD83D\uDCE6 Usage Examples
@@ -7579,6 +7653,9 @@ function runList() {
7579
7653
  console.log(` ${import_picocolors2.default.white("agdex")} ${import_picocolors2.default.gray("(interactive)")}`);
7580
7654
  console.log(` ${import_picocolors2.default.gray("→ then enter:")} ${import_picocolors2.default.white("https://github.com/anthropics/skills/tree/main/skills")}`);
7581
7655
  console.log("");
7656
+ console.log(import_picocolors2.default.gray(" Website URL:"));
7657
+ console.log(` ${import_picocolors2.default.white('agdex url https://docs.example.com/latest/index.html --name "My Docs"')}`);
7658
+ console.log("");
7582
7659
  console.log(import_picocolors2.default.gray(" Local documentation:"));
7583
7660
  console.log(` ${import_picocolors2.default.white('agdex local ./my-docs --name "My Docs"')}`);
7584
7661
  console.log("");
@@ -7591,14 +7668,16 @@ function runList() {
7591
7668
  program2.name("agdex").description(`Create compressed documentation indexes for AI coding agents.
7592
7669
 
7593
7670
  Sources you can index:
7594
- • Built-in providers (Next.js, React, Bun, Pixi, Tauri, etc.)
7671
+ • Built-in providers (Next.js, React, Bun, Pixi, Tauri, TensorRT, etc.)
7595
7672
  • Any GitHub repository URL or owner/repo
7673
+ • Any documentation website URL
7596
7674
  • Local documentation directories
7597
7675
  • Claude Code skills
7598
7676
 
7599
7677
  Run 'agdex' without arguments for interactive mode.`).version("0.4.2");
7600
- program2.command("embed", { isDefault: true }).description("Embed documentation index into AGENTS.md/CLAUDE.md").option("-p, --provider <name>", "Documentation provider (nextjs, react, etc.)").option("--fw-version <version>", "Framework version (auto-detected if not provided)").option("-o, --output <file>", "Target file (default: from config or CLAUDE.md)").option("--repo <owner/repo>", "Custom GitHub repository").option("--docs-path <path>", "Path to docs folder in repository").option("-g, --global", "Store docs in global cache (~/.cache/agdex/) (default)").option("-l, --local", "Store docs in local .agdex/ instead of global cache").option("-d, --description <text>", "Additional description to include in the index").action(runEmbed);
7678
+ program2.command("embed", { isDefault: true }).description("Embed documentation index into AGENTS.md/CLAUDE.md").option("-p, --provider <name>", "Documentation provider (nextjs, react, etc.)").option("--fw-version <version>", "Framework version (auto-detected if not provided)").option("-o, --output <file>", "Target file (default: from config or CLAUDE.md)").option("--repo <owner/repo>", "Custom GitHub repository").option("--docs-path <path>", "Path to docs folder in repository").option("-g, --global", "Store docs in global cache (~/.cache/agdex/) (default)").option("-l, --local", "Store docs in local .agdex/ instead of global cache").option("-d, --description <text>", "Additional description to include in the index").option("-u, --url <url>", "Scrape documentation from a website URL").action(runEmbed);
7601
7679
  program2.command("local <docs-path>").description("Build index from local documentation directory").option("-n, --name <name>", "Display name for the documentation").option("-o, --output <file>", "Target file (default: from config or CLAUDE.md)").option("-e, --extensions <exts>", "File extensions to include (comma-separated, default: .md,.mdx)").action(runLocal);
7680
+ program2.command("url <url>").description("Scrape documentation from a website URL and build index").option("-n, --name <name>", "Display name for the documentation (default: derived from URL)").option("-o, --output <file>", "Target file (default: from config or CLAUDE.md)").option("-s, --selector <css>", "CSS selector for main content (default: main#main-content, main, article)").option("-c, --concurrency <n>", "Max concurrent fetches (default: 5)").option("--delay <ms>", "Delay between fetch batches in ms (default: 200)").action(runUrl);
7602
7681
  program2.command("list").description("List available documentation providers").action(runList);
7603
7682
  async function runRemove(options) {
7604
7683
  const cwd = process.cwd();
@@ -1,22 +1,6 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
1
+ import {
2
+ __require
3
+ } from "./index-sh9kr6eq.js";
20
4
 
21
5
  // src/lib/agents-md.ts
22
6
  import { execSync } from "child_process";
@@ -33,6 +17,11 @@ function getEndMarker(providerName) {
33
17
  return providerName ? `${END_MARKER_PREFIX}:${providerName}${MARKER_SUFFIX}` : `${END_MARKER_PREFIX}${MARKER_SUFFIX}`;
34
18
  }
35
19
  async function pullDocs(provider, options) {
20
+ if (provider.urlConfig) {
21
+ const { pullDocsFromUrl } = await import("./url-scraper-9xq4d56t.js");
22
+ const docsPath2 = options.docsDir ?? fs.mkdtempSync(path.join(os.tmpdir(), "agdex-"));
23
+ return pullDocsFromUrl(provider.urlConfig, docsPath2, { onProgress: options.onProgress });
24
+ }
36
25
  const { cwd, version: versionOverride, docsDir } = options;
37
26
  let version;
38
27
  if (versionOverride) {
@@ -1617,6 +1606,69 @@ var manimProvider = {
1617
1606
  instruction: "IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any Manim tasks. Manim is a Python library for mathematical animations."
1618
1607
  };
1619
1608
 
1609
+ // src/lib/providers/tensorrt.ts
1610
+ var tensorrtProvider = {
1611
+ name: "tensorrt",
1612
+ displayName: "NVIDIA TensorRT",
1613
+ repo: "",
1614
+ docsPath: "",
1615
+ extensions: [".md"],
1616
+ excludePatterns: [],
1617
+ defaultBranch: "latest",
1618
+ instruction: "IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any NVIDIA TensorRT tasks. These docs cover TensorRT SDK for optimizing deep learning models for high-performance inference.",
1619
+ urlConfig: {
1620
+ baseUrl: "https://docs.nvidia.com/deeplearning/tensorrt/latest/index.html",
1621
+ contentSelector: "main#main-content, main, article, .body",
1622
+ removeSelectors: [
1623
+ ".headerlink",
1624
+ ".toctree-wrapper",
1625
+ ".breadcrumb",
1626
+ ".page-navigation",
1627
+ ".related-pages"
1628
+ ],
1629
+ pages: [
1630
+ "getting-started/release-notes.html",
1631
+ "getting-started/quick-start-guide.html",
1632
+ "getting-started/support-matrix.html",
1633
+ "installing-tensorrt/overview.html",
1634
+ "installing-tensorrt/prerequisites.html",
1635
+ "installing-tensorrt/installing.html",
1636
+ "installing-tensorrt/upgrading.html",
1637
+ "installing-tensorrt/uninstalling.html",
1638
+ "architecture/architecture-overview.html",
1639
+ "architecture/capabilities.html",
1640
+ "architecture/how-trt-works.html",
1641
+ "inference-library/c-api-docs.html",
1642
+ "inference-library/python-api-docs.html",
1643
+ "inference-library/sample-support-guide.html",
1644
+ "inference-library/advanced.html",
1645
+ "inference-library/work-quantized-types.html",
1646
+ "inference-library/accuracy-considerations.html",
1647
+ "inference-library/work-dynamic-shapes.html",
1648
+ "inference-library/extending-custom-layers.html",
1649
+ "inference-library/work-with-loops.html",
1650
+ "inference-library/work-with-conditionals.html",
1651
+ "inference-library/work-with-dla.html",
1652
+ "inference-library/capture-replay.html",
1653
+ "inference-library/work-with-transformers.html",
1654
+ "performance/best-practices.html",
1655
+ "api/c-api.html",
1656
+ "api/python-api.html",
1657
+ "api/migration-guide.html",
1658
+ "api/onnx-graphsurgeon-api.html",
1659
+ "api/polygraphy-api.html",
1660
+ "reference/troubleshooting.html",
1661
+ "reference/data-format-desc.html",
1662
+ "reference/command-line-programs.html",
1663
+ "reference/operators.html",
1664
+ "reference/additional-resources.html",
1665
+ "reference/glossary.html"
1666
+ ],
1667
+ concurrency: 3,
1668
+ fetchDelay: 300
1669
+ }
1670
+ };
1671
+
1620
1672
  // src/lib/providers/generic.ts
1621
1673
  import fs19 from "fs";
1622
1674
  import path19 from "path";
@@ -1836,6 +1888,8 @@ function getProvider(preset) {
1836
1888
  return manimProvider;
1837
1889
  case "cuda-feedstock":
1838
1890
  return cudaFeedstockProvider;
1891
+ case "tensorrt":
1892
+ return tensorrtProvider;
1839
1893
  case "vue":
1840
1894
  case "astro":
1841
1895
  return null;
@@ -1844,7 +1898,7 @@ function getProvider(preset) {
1844
1898
  }
1845
1899
  }
1846
1900
  function listProviders() {
1847
- return ["nextjs", "react", "pixi", "rattler-build", "tauri", "conda-forge", "bun", "vue", "svelte", "sveltekit", "shadcn-svelte", "astro", "tailwind", "ruff", "ty", "basedpyright", "convex", "polars", "delta-rs", "obsidian", "obsidian-excalidraw", "ffmpeg", "manim", "cuda-feedstock"];
1901
+ return ["nextjs", "react", "pixi", "rattler-build", "tauri", "conda-forge", "bun", "vue", "svelte", "sveltekit", "shadcn-svelte", "astro", "tailwind", "ruff", "ty", "basedpyright", "convex", "polars", "delta-rs", "obsidian", "obsidian-excalidraw", "ffmpeg", "manim", "cuda-feedstock", "tensorrt"];
1848
1902
  }
1849
1903
  function isProviderAvailable(preset) {
1850
1904
  return getProvider(preset) !== null;
@@ -2299,4 +2353,4 @@ function getDefaultOutput(cwd = process.cwd()) {
2299
2353
  return config.output || "AGENTS.md";
2300
2354
  }
2301
2355
 
2302
- export { __toESM, __commonJS, __require, pullDocs, collectDocFiles, buildDocTree, generateIndex, hasExistingIndex, getEmbeddedProviders, removeDocsIndex, injectIndex, ensureGitignoreEntry, getGlobalCacheDir, getLocalCacheDir, embed, nextjsProvider, reactProvider, pixiProvider, rattlerBuildProvider, tauriProvider, condaForgeProvider, bunProvider, svelteProvider, tailwindProvider, ruffProvider, tyProvider, basedpyrightProvider, convexProvider, polarsProvider, deltaRsProvider, obsidianProvider, obsidianExcalidrawProvider, ffmpegProvider, manimProvider, createProvider, createLocalProvider, getProvider, listProviders, isProviderAvailable, fetchSkillsShSearch, getEnabledPluginSources, parseSkillFrontmatter, discoverPluginSkills, discoverFlatSkills, discoverSkillsShRepo, collectAllSkills, generateSkillsIndex, hasExistingSkillsIndex, removeSkillsIndex, injectSkillsIndex, getDefaultSkillSources, embedSkills, loadConfig, getDefaultOutput };
2356
+ export { pullDocs, collectDocFiles, buildDocTree, generateIndex, hasExistingIndex, getEmbeddedProviders, removeDocsIndex, injectIndex, ensureGitignoreEntry, getGlobalCacheDir, getLocalCacheDir, embed, nextjsProvider, reactProvider, pixiProvider, rattlerBuildProvider, tauriProvider, condaForgeProvider, bunProvider, svelteProvider, tailwindProvider, ruffProvider, tyProvider, basedpyrightProvider, convexProvider, polarsProvider, deltaRsProvider, obsidianProvider, obsidianExcalidrawProvider, ffmpegProvider, manimProvider, tensorrtProvider, createProvider, createLocalProvider, getProvider, listProviders, isProviderAvailable, fetchSkillsShSearch, getEnabledPluginSources, parseSkillFrontmatter, discoverPluginSkills, discoverFlatSkills, discoverSkillsShRepo, collectAllSkills, generateSkillsIndex, hasExistingSkillsIndex, removeSkillsIndex, injectSkillsIndex, getDefaultSkillSources, embedSkills, loadConfig, getDefaultOutput };