agdex 0.4.1 → 0.5.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 (46) hide show
  1. package/README.md +42 -5
  2. package/dist/cli/configurable-select.d.ts +15 -0
  3. package/dist/cli/configurable-select.d.ts.map +1 -0
  4. package/dist/cli/index.js +444 -106
  5. package/dist/{index-9gy9s47s.js → index-974mhezm.js} +919 -61
  6. package/dist/index-g5x6jpyb.js +2304 -0
  7. package/dist/{index-pkx4s2ef.js → index-nn4xptha.js} +42 -15
  8. package/dist/index-pfdh6eyh.js +2241 -0
  9. package/dist/{index-4shp3mqh.js → index-vf9nfyjb.js} +369 -60
  10. package/dist/{index-zrmn6fd2.js → index-wsqyam11.js} +301 -68
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -1
  14. package/dist/lib/agents-md.d.ts +5 -0
  15. package/dist/lib/agents-md.d.ts.map +1 -1
  16. package/dist/lib/providers/cuda-feedstock.d.ts +6 -0
  17. package/dist/lib/providers/cuda-feedstock.d.ts.map +1 -0
  18. package/dist/lib/providers/generic.d.ts.map +1 -1
  19. package/dist/lib/providers/index.d.ts +3 -0
  20. package/dist/lib/providers/index.d.ts.map +1 -1
  21. package/dist/lib/providers/shadcn-svelte.d.ts +3 -0
  22. package/dist/lib/providers/shadcn-svelte.d.ts.map +1 -0
  23. package/dist/lib/providers/sveltekit.d.ts +3 -0
  24. package/dist/lib/providers/sveltekit.d.ts.map +1 -0
  25. package/dist/lib/skills.d.ts +13 -2
  26. package/dist/lib/skills.d.ts.map +1 -1
  27. package/dist/lib/types.d.ts +18 -3
  28. package/dist/lib/types.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/index-57bfejpe.js +0 -1357
  31. package/dist/index-5h59833k.js +0 -1270
  32. package/dist/index-6dj5che8.js +0 -859
  33. package/dist/index-6e18afd7.js +0 -1229
  34. package/dist/index-7adbtddf.js +0 -1123
  35. package/dist/index-cfpc7eqp.js +0 -1265
  36. package/dist/index-db6kreh4.js +0 -1188
  37. package/dist/index-exr11by8.js +0 -708
  38. package/dist/index-fxmpwsct.js +0 -779
  39. package/dist/index-gtzz9131.js +0 -708
  40. package/dist/index-hr5jh9yq.js +0 -712
  41. package/dist/index-k299aha0.js +0 -1229
  42. package/dist/index-ntpyfcve.js +0 -1154
  43. package/dist/index-p0xjkwcp.js +0 -1283
  44. package/dist/index-pry8ssn1.js +0 -636
  45. package/dist/index-wgnqr8g3.js +0 -882
  46. package/dist/index-y6zqcrbh.js +0 -788
@@ -58,7 +58,13 @@ async function pullDocs(provider, options) {
58
58
  if (fs.existsSync(docsPath)) {
59
59
  fs.rmSync(docsPath, { recursive: true });
60
60
  }
61
- const tag = provider.versionToTag ? provider.versionToTag(version) : `v${version}`;
61
+ const defaultVersionToTag = (v) => {
62
+ if (v.startsWith("v") || /^\d/.test(v)) {
63
+ return v.startsWith("v") ? v : `v${v}`;
64
+ }
65
+ return v;
66
+ };
67
+ const tag = provider.versionToTag ? provider.versionToTag(version) : defaultVersionToTag(version);
62
68
  await cloneDocsFolder(provider.repo, provider.docsPath, tag, docsPath);
63
69
  return {
64
70
  success: true,
@@ -345,7 +351,7 @@ async function embed(options) {
345
351
  version,
346
352
  output = "AGENTS.md",
347
353
  docsDir: customDocsDir,
348
- globalCache = false,
354
+ globalCache = true,
349
355
  description
350
356
  } = options;
351
357
  let docsPath;
@@ -374,24 +380,39 @@ async function embed(options) {
374
380
  sizeBefore = Buffer.byteLength(existingContent, "utf-8");
375
381
  isNewFile = false;
376
382
  }
377
- const pullResult = await pullDocs(provider, {
378
- cwd,
379
- version,
380
- docsDir: docsPath
381
- });
382
- if (!pullResult.success) {
383
- return {
384
- success: false,
385
- error: pullResult.error
383
+ const cacheHit = fs.existsSync(docsPath) && fs.readdirSync(docsPath).length > 0;
384
+ let pullResult;
385
+ if (cacheHit) {
386
+ let resolvedVersion = version;
387
+ if (!resolvedVersion && provider.detectVersion) {
388
+ const detected = provider.detectVersion(cwd);
389
+ resolvedVersion = detected.version || undefined;
390
+ }
391
+ pullResult = {
392
+ success: true,
393
+ docsPath,
394
+ version: resolvedVersion
386
395
  };
396
+ } else {
397
+ pullResult = await pullDocs(provider, {
398
+ cwd,
399
+ version,
400
+ docsDir: docsPath
401
+ });
402
+ if (!pullResult.success) {
403
+ return {
404
+ success: false,
405
+ error: pullResult.error
406
+ };
407
+ }
387
408
  }
388
409
  const docFiles = collectDocFiles(docsPath, {
389
410
  extensions: provider.extensions,
390
411
  excludePatterns: provider.excludePatterns
391
412
  });
392
413
  const sections = buildDocTree(docFiles);
393
- const globalFlag = globalCache ? " --global" : "";
394
- const regenerateCommand = `npx agdex --provider ${provider.name} --output ${output}${globalFlag}`;
414
+ const localFlag = !globalCache ? " --local" : "";
415
+ const regenerateCommand = `npx agdex --provider ${provider.name} --output ${output}${localFlag}`;
395
416
  const indexContent = generateIndex({
396
417
  docsPath: docsLinkPath,
397
418
  sections,
@@ -420,7 +441,8 @@ async function embed(options) {
420
441
  sizeBefore,
421
442
  sizeAfter,
422
443
  isNewFile,
423
- gitignoreUpdated
444
+ gitignoreUpdated,
445
+ cacheHit
424
446
  };
425
447
  }
426
448
 
@@ -1601,7 +1623,12 @@ function createProvider(options) {
1601
1623
  docsPath,
1602
1624
  extensions = [".mdx", ".md"],
1603
1625
  packageName,
1604
- versionToTag = (v) => v.startsWith("v") ? v : `v${v}`,
1626
+ versionToTag = (v) => {
1627
+ if (v.startsWith("v") || /^\d/.test(v)) {
1628
+ return v.startsWith("v") ? v : `v${v}`;
1629
+ }
1630
+ return v;
1631
+ },
1605
1632
  excludePatterns = ["**/index.mdx", "**/index.md"],
1606
1633
  instruction
1607
1634
  } = options;