agdex 0.7.0 → 0.8.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.
@@ -1,11 +1,78 @@
1
1
  import {
2
- __require
3
- } from "./index-dtcewfnz.js";
2
+ __require,
3
+ __toESM
4
+ } from "./index-pyanjjwn.js";
4
5
 
5
- // src/lib/agents-md.ts
6
- import { execSync } from "child_process";
6
+ // src/lib/lockfile.ts
7
7
  import fs from "fs";
8
8
  import path from "path";
9
+ var LOCKFILE_SCHEMA_VERSION = 1;
10
+ var LOCKFILE_RELATIVE_PATH = path.join(".agdex", "agdex.lock");
11
+ function getLockfilePath(cwd) {
12
+ return path.join(cwd, LOCKFILE_RELATIVE_PATH);
13
+ }
14
+ function createIndexId(kind, sourceName, targetFile) {
15
+ return `${kind}:${sourceName}:${normalizeRelativePath(targetFile)}`;
16
+ }
17
+ function normalizeRelativePath(filePath) {
18
+ return filePath.split(path.sep).join("/");
19
+ }
20
+ function toStoredPath(cwd, filePath) {
21
+ if (!path.isAbsolute(filePath)) {
22
+ return normalizeRelativePath(filePath);
23
+ }
24
+ const relative = path.relative(cwd, filePath);
25
+ if (relative && !relative.startsWith("..") && !path.isAbsolute(relative)) {
26
+ return normalizeRelativePath(relative);
27
+ }
28
+ return filePath;
29
+ }
30
+ function resolveStoredPath(cwd, storedPath) {
31
+ return path.isAbsolute(storedPath) ? storedPath : path.join(cwd, storedPath);
32
+ }
33
+ function readIndexLockfile(cwd) {
34
+ const lockfilePath = getLockfilePath(cwd);
35
+ if (!fs.existsSync(lockfilePath)) {
36
+ return { schemaVersion: LOCKFILE_SCHEMA_VERSION, indexes: [] };
37
+ }
38
+ const parsed = JSON.parse(fs.readFileSync(lockfilePath, "utf-8"));
39
+ return {
40
+ schemaVersion: parsed.schemaVersion || LOCKFILE_SCHEMA_VERSION,
41
+ indexes: Array.isArray(parsed.indexes) ? parsed.indexes : []
42
+ };
43
+ }
44
+ function writeIndexLockfile(cwd, lockfile) {
45
+ const lockfilePath = getLockfilePath(cwd);
46
+ fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });
47
+ const normalized = {
48
+ schemaVersion: LOCKFILE_SCHEMA_VERSION,
49
+ indexes: [...lockfile.indexes].sort((a, b) => a.id.localeCompare(b.id))
50
+ };
51
+ fs.writeFileSync(lockfilePath, `${JSON.stringify(normalized, null, 2)}
52
+ `, "utf-8");
53
+ }
54
+ function upsertIndexLockEntry(cwd, entry) {
55
+ const lockfile = readIndexLockfile(cwd);
56
+ const nextEntry = {
57
+ ...entry,
58
+ targetFile: normalizeRelativePath(entry.targetFile),
59
+ cachePath: toStoredPath(cwd, entry.cachePath),
60
+ updatedAt: new Date().toISOString()
61
+ };
62
+ const existingIndex = lockfile.indexes.findIndex((candidate) => candidate.id === nextEntry.id);
63
+ if (existingIndex === -1) {
64
+ lockfile.indexes.push(nextEntry);
65
+ } else {
66
+ lockfile.indexes[existingIndex] = nextEntry;
67
+ }
68
+ writeIndexLockfile(cwd, lockfile);
69
+ return nextEntry;
70
+ }
71
+
72
+ // src/lib/agents-md.ts
73
+ import { execSync } from "child_process";
74
+ import fs2 from "fs";
75
+ import path2 from "path";
9
76
  import os from "os";
10
77
  var START_MARKER_PREFIX = "<!-- AGENTS-MD-EMBED-START";
11
78
  var END_MARKER_PREFIX = "<!-- AGENTS-MD-EMBED-END";
@@ -18,8 +85,8 @@ function getEndMarker(providerName) {
18
85
  }
19
86
  async function pullDocs(provider, options) {
20
87
  if (provider.urlConfig) {
21
- const { pullDocsFromUrl } = await import("./url-scraper-5sj8c56t.js");
22
- const docsPath2 = options.docsDir ?? fs.mkdtempSync(path.join(os.tmpdir(), "agdex-"));
88
+ const { pullDocsFromUrl } = await import("./url-scraper-axfs3dz7.js");
89
+ const docsPath2 = options.docsDir ?? fs2.mkdtempSync(path2.join(os.tmpdir(), "agdex-"));
23
90
  return pullDocsFromUrl(provider.urlConfig, docsPath2, { onProgress: options.onProgress });
24
91
  }
25
92
  const { cwd, version: versionOverride, docsDir } = options;
@@ -36,11 +103,11 @@ async function pullDocs(provider, options) {
36
103
  } else {
37
104
  version = provider.defaultBranch || "main";
38
105
  }
39
- const docsPath = docsDir ?? fs.mkdtempSync(path.join(os.tmpdir(), "agdex-"));
106
+ const docsPath = docsDir ?? fs2.mkdtempSync(path2.join(os.tmpdir(), "agdex-"));
40
107
  const useTempDir = !docsDir;
41
108
  try {
42
- if (fs.existsSync(docsPath)) {
43
- fs.rmSync(docsPath, { recursive: true });
109
+ if (fs2.existsSync(docsPath)) {
110
+ fs2.rmSync(docsPath, { recursive: true });
44
111
  }
45
112
  const defaultVersionToTag = (v) => {
46
113
  if (v.startsWith("v") || /^\d/.test(v)) {
@@ -56,8 +123,8 @@ async function pullDocs(provider, options) {
56
123
  version
57
124
  };
58
125
  } catch (error) {
59
- if (useTempDir && fs.existsSync(docsPath)) {
60
- fs.rmSync(docsPath, { recursive: true });
126
+ if (useTempDir && fs2.existsSync(docsPath)) {
127
+ fs2.rmSync(docsPath, { recursive: true });
61
128
  }
62
129
  return {
63
130
  success: false,
@@ -66,7 +133,7 @@ async function pullDocs(provider, options) {
66
133
  }
67
134
  }
68
135
  async function cloneDocsFolder(repo, docsFolder, tag, destDir) {
69
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "agdex-clone-"));
136
+ const tempDir = fs2.mkdtempSync(path2.join(os.tmpdir(), "agdex-clone-"));
70
137
  try {
71
138
  try {
72
139
  execSync(`git clone --depth 1 --filter=blob:none --sparse --branch ${tag} https://github.com/${repo}.git .`, { cwd: tempDir, stdio: "pipe" });
@@ -78,25 +145,25 @@ async function cloneDocsFolder(repo, docsFolder, tag, destDir) {
78
145
  throw error;
79
146
  }
80
147
  execSync(`git sparse-checkout set ${docsFolder}`, { cwd: tempDir, stdio: "pipe" });
81
- const sourceDocsDir = path.join(tempDir, docsFolder);
82
- if (!fs.existsSync(sourceDocsDir)) {
148
+ const sourceDocsDir = path2.join(tempDir, docsFolder);
149
+ if (!fs2.existsSync(sourceDocsDir)) {
83
150
  throw new Error(`${docsFolder} folder not found in cloned repository`);
84
151
  }
85
- if (fs.existsSync(destDir)) {
86
- fs.rmSync(destDir, { recursive: true });
152
+ if (fs2.existsSync(destDir)) {
153
+ fs2.rmSync(destDir, { recursive: true });
87
154
  }
88
- fs.mkdirSync(destDir, { recursive: true });
89
- fs.cpSync(sourceDocsDir, destDir, { recursive: true });
155
+ fs2.mkdirSync(destDir, { recursive: true });
156
+ fs2.cpSync(sourceDocsDir, destDir, { recursive: true });
90
157
  } finally {
91
- if (fs.existsSync(tempDir)) {
92
- fs.rmSync(tempDir, { recursive: true });
158
+ if (fs2.existsSync(tempDir)) {
159
+ fs2.rmSync(tempDir, { recursive: true });
93
160
  }
94
161
  }
95
162
  }
96
163
  function collectDocFiles(dir, options) {
97
164
  const extensions = options?.extensions || [".mdx", ".md"];
98
165
  const excludePatterns = options?.excludePatterns || [];
99
- const files = fs.readdirSync(dir, { recursive: true });
166
+ const files = fs2.readdirSync(dir, { recursive: true });
100
167
  return files.filter((f) => {
101
168
  const hasValidExtension = extensions.some((ext) => f.endsWith(ext));
102
169
  if (!hasValidExtension)
@@ -310,12 +377,12 @@ function injectIndex(existingContent, indexContent, providerName) {
310
377
  `;
311
378
  }
312
379
  function ensureGitignoreEntry(cwd, docsDir) {
313
- const gitignorePath = path.join(cwd, ".gitignore");
380
+ const gitignorePath = path2.join(cwd, ".gitignore");
314
381
  const entry = docsDir.endsWith("/") ? docsDir : `${docsDir}/`;
315
382
  const entryRegex = new RegExp(`^\\s*${docsDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:/.*)?$`);
316
383
  let content = "";
317
- if (fs.existsSync(gitignorePath)) {
318
- content = fs.readFileSync(gitignorePath, "utf-8");
384
+ if (fs2.existsSync(gitignorePath)) {
385
+ content = fs2.readFileSync(gitignorePath, "utf-8");
319
386
  }
320
387
  const hasEntry = content.split(/\r?\n/).some((line) => entryRegex.test(line));
321
388
  if (hasEntry) {
@@ -328,23 +395,24 @@ function ensureGitignoreEntry(cwd, docsDir) {
328
395
  const newContent = content + (needsNewline ? `
329
396
  ` : "") + header + `${entry}
330
397
  `;
331
- fs.writeFileSync(gitignorePath, newContent, "utf-8");
398
+ fs2.writeFileSync(gitignorePath, newContent, "utf-8");
332
399
  return { path: gitignorePath, updated: true, alreadyPresent: false };
333
400
  }
334
401
  function getGlobalCacheDir() {
335
- return path.join(os.homedir(), ".cache", "agdex");
402
+ return path2.join(os.homedir(), ".cache", "agdex");
336
403
  }
337
404
  function getLocalCacheDir(cwd) {
338
- return path.join(cwd, ".agdex");
405
+ return path2.join(cwd, ".agdex");
339
406
  }
340
407
  async function embed(options) {
341
408
  const {
342
409
  cwd,
343
410
  provider,
344
411
  version,
345
- output = "AGENTS.md",
412
+ versionMode,
413
+ output = "CLAUDE.local.md",
346
414
  docsDir: customDocsDir,
347
- globalCache = true,
415
+ globalCache = false,
348
416
  description
349
417
  } = options;
350
418
  let docsPath;
@@ -352,28 +420,28 @@ async function embed(options) {
352
420
  let docsDir;
353
421
  if (customDocsDir) {
354
422
  docsDir = customDocsDir;
355
- docsPath = path.isAbsolute(customDocsDir) ? customDocsDir : path.join(cwd, customDocsDir);
356
- docsLinkPath = path.isAbsolute(customDocsDir) ? customDocsDir : `./${customDocsDir}`;
423
+ docsPath = path2.isAbsolute(customDocsDir) ? customDocsDir : path2.join(cwd, customDocsDir);
424
+ docsLinkPath = path2.isAbsolute(customDocsDir) ? customDocsDir : `./${customDocsDir}`;
357
425
  } else if (globalCache) {
358
426
  const cacheBase = getGlobalCacheDir();
359
- docsDir = path.join(cacheBase, provider.name);
427
+ docsDir = path2.join(cacheBase, provider.name);
360
428
  docsPath = docsDir;
361
429
  docsLinkPath = docsPath;
362
430
  } else {
363
431
  docsDir = `.agdex/${provider.name}`;
364
- docsPath = path.join(cwd, docsDir);
432
+ docsPath = path2.join(cwd, docsDir);
365
433
  docsLinkPath = `./${docsDir}`;
366
434
  }
367
- const targetPath = path.join(cwd, output);
435
+ const targetPath = path2.join(cwd, output);
368
436
  let sizeBefore = 0;
369
437
  let isNewFile = true;
370
438
  let existingContent = "";
371
- if (fs.existsSync(targetPath)) {
372
- existingContent = fs.readFileSync(targetPath, "utf-8");
439
+ if (fs2.existsSync(targetPath)) {
440
+ existingContent = fs2.readFileSync(targetPath, "utf-8");
373
441
  sizeBefore = Buffer.byteLength(existingContent, "utf-8");
374
442
  isNewFile = false;
375
443
  }
376
- const cacheHit = fs.existsSync(docsPath) && fs.readdirSync(docsPath).length > 0;
444
+ const cacheHit = fs2.existsSync(docsPath) && fs2.readdirSync(docsPath).length > 0;
377
445
  let pullResult;
378
446
  if (cacheHit) {
379
447
  let resolvedVersion = version;
@@ -404,8 +472,8 @@ async function embed(options) {
404
472
  excludePatterns: provider.excludePatterns
405
473
  });
406
474
  const sections = buildDocTree(docFiles);
407
- const localFlag = !globalCache ? " --local" : "";
408
- const regenerateCommand = `npx agdex --provider ${provider.name} --output ${output}${localFlag}`;
475
+ const cacheFlag = globalCache ? " --global" : "";
476
+ const regenerateCommand = `npx agdex --provider ${provider.name} --output ${output}${cacheFlag}`;
409
477
  const indexContent = generateIndex({
410
478
  docsPath: docsLinkPath,
411
479
  sections,
@@ -416,16 +484,34 @@ async function embed(options) {
416
484
  regenerateCommand
417
485
  });
418
486
  const newContent = injectIndex(existingContent, indexContent, provider.name);
419
- fs.writeFileSync(targetPath, newContent, "utf-8");
487
+ fs2.writeFileSync(targetPath, newContent, "utf-8");
420
488
  const sizeAfter = Buffer.byteLength(newContent, "utf-8");
421
489
  let gitignoreUpdated = false;
422
490
  if (!globalCache && !customDocsDir) {
423
491
  const gitignoreResult = ensureGitignoreEntry(cwd, ".agdex");
424
492
  gitignoreUpdated = gitignoreResult.updated;
425
- } else if (!globalCache && customDocsDir && !path.isAbsolute(customDocsDir)) {
493
+ } else if (!globalCache && customDocsDir && !path2.isAbsolute(customDocsDir)) {
426
494
  const gitignoreResult = ensureGitignoreEntry(cwd, customDocsDir);
427
495
  gitignoreUpdated = gitignoreResult.updated;
428
496
  }
497
+ upsertIndexLockEntry(cwd, {
498
+ id: createIndexId("docs", provider.name, output),
499
+ kind: "docs",
500
+ source: {
501
+ type: provider.urlConfig ? "url-docs" : provider.name === "custom" ? "github-docs" : "builtin-provider",
502
+ name: provider.name,
503
+ displayName: provider.displayName,
504
+ repo: provider.repo || undefined,
505
+ docsPath: provider.docsPath || undefined,
506
+ url: provider.urlConfig?.baseUrl,
507
+ version: pullResult.version,
508
+ versionMode: versionMode || (version ? "pinned" : pullResult.version ? "auto" : "unknown")
509
+ },
510
+ targetFile: output,
511
+ marker: provider.name,
512
+ cachePath: docsPath,
513
+ command: regenerateCommand
514
+ });
429
515
  return {
430
516
  success: true,
431
517
  targetFile: output,
@@ -440,18 +526,18 @@ async function embed(options) {
440
526
  }
441
527
 
442
528
  // src/lib/providers/nextjs.ts
443
- import fs2 from "fs";
444
- import path2 from "path";
529
+ import fs3 from "fs";
530
+ import path3 from "path";
445
531
  function detectWorkspace(cwd) {
446
- const packageJsonPath = path2.join(cwd, "package.json");
447
- const pnpmWorkspacePath = path2.join(cwd, "pnpm-workspace.yaml");
448
- if (fs2.existsSync(pnpmWorkspacePath)) {
532
+ const packageJsonPath = path3.join(cwd, "package.json");
533
+ const pnpmWorkspacePath = path3.join(cwd, "pnpm-workspace.yaml");
534
+ if (fs3.existsSync(pnpmWorkspacePath)) {
449
535
  const packages = parsePnpmWorkspace(pnpmWorkspacePath);
450
536
  if (packages.length > 0) {
451
537
  return { isMonorepo: true, type: "pnpm", packages };
452
538
  }
453
539
  }
454
- if (fs2.existsSync(packageJsonPath)) {
540
+ if (fs3.existsSync(packageJsonPath)) {
455
541
  const packages = parsePackageJsonWorkspaces(packageJsonPath);
456
542
  if (packages.length > 0) {
457
543
  return { isMonorepo: true, type: "npm", packages };
@@ -461,7 +547,7 @@ function detectWorkspace(cwd) {
461
547
  }
462
548
  function parsePnpmWorkspace(filePath) {
463
549
  try {
464
- const content = fs2.readFileSync(filePath, "utf-8");
550
+ const content = fs3.readFileSync(filePath, "utf-8");
465
551
  const lines = content.split(`
466
552
  `);
467
553
  const packages = [];
@@ -489,7 +575,7 @@ function parsePnpmWorkspace(filePath) {
489
575
  }
490
576
  function parsePackageJsonWorkspaces(filePath) {
491
577
  try {
492
- const content = fs2.readFileSync(filePath, "utf-8");
578
+ const content = fs3.readFileSync(filePath, "utf-8");
493
579
  const pkg = JSON.parse(content);
494
580
  if (Array.isArray(pkg.workspaces)) {
495
581
  return pkg.workspaces;
@@ -508,21 +594,21 @@ function expandWorkspacePatterns(cwd, patterns) {
508
594
  if (pattern.startsWith("!"))
509
595
  continue;
510
596
  if (pattern.includes("*")) {
511
- const basePath = path2.join(cwd, pattern.replace("/*", "").replace("/**", ""));
512
- if (fs2.existsSync(basePath)) {
597
+ const basePath = path3.join(cwd, pattern.replace("/*", "").replace("/**", ""));
598
+ if (fs3.existsSync(basePath)) {
513
599
  try {
514
- const entries = fs2.readdirSync(basePath);
600
+ const entries = fs3.readdirSync(basePath);
515
601
  for (const entry of entries) {
516
- const fullPath = path2.join(basePath, entry);
517
- if (fs2.statSync(fullPath).isDirectory()) {
602
+ const fullPath = path3.join(basePath, entry);
603
+ if (fs3.statSync(fullPath).isDirectory()) {
518
604
  packagePaths.push(fullPath);
519
605
  }
520
606
  }
521
607
  } catch {}
522
608
  }
523
609
  } else {
524
- const fullPath = path2.join(cwd, pattern);
525
- if (fs2.existsSync(fullPath)) {
610
+ const fullPath = path3.join(cwd, pattern);
611
+ if (fs3.existsSync(fullPath)) {
526
612
  packagePaths.push(fullPath);
527
613
  }
528
614
  }
@@ -548,11 +634,11 @@ function findNextjsInWorkspace(cwd, patterns) {
548
634
  const packagePaths = expandWorkspacePatterns(cwd, patterns);
549
635
  const versions = [];
550
636
  for (const pkgPath of packagePaths) {
551
- const packageJsonPath = path2.join(pkgPath, "package.json");
552
- if (!fs2.existsSync(packageJsonPath))
637
+ const packageJsonPath = path3.join(pkgPath, "package.json");
638
+ if (!fs3.existsSync(packageJsonPath))
553
639
  continue;
554
640
  try {
555
- const content = fs2.readFileSync(packageJsonPath, "utf-8");
641
+ const content = fs3.readFileSync(packageJsonPath, "utf-8");
556
642
  const pkg = JSON.parse(content);
557
643
  const nextVersion = pkg.dependencies?.next || pkg.devDependencies?.next;
558
644
  if (nextVersion) {
@@ -569,15 +655,15 @@ function findNextjsInWorkspace(cwd, patterns) {
569
655
  });
570
656
  }
571
657
  function detectVersion(cwd) {
572
- const packageJsonPath = path2.join(cwd, "package.json");
573
- if (!fs2.existsSync(packageJsonPath)) {
658
+ const packageJsonPath = path3.join(cwd, "package.json");
659
+ if (!fs3.existsSync(packageJsonPath)) {
574
660
  return {
575
661
  version: null,
576
662
  error: "No package.json found in the current directory"
577
663
  };
578
664
  }
579
665
  try {
580
- const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
666
+ const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
581
667
  const dependencies = packageJson.dependencies || {};
582
668
  const devDependencies = packageJson.devDependencies || {};
583
669
  const nextVersion = dependencies.next || devDependencies.next;
@@ -621,18 +707,18 @@ var nextjsProvider = {
621
707
  };
622
708
 
623
709
  // src/lib/providers/react.ts
624
- import fs3 from "fs";
625
- import path3 from "path";
710
+ import fs4 from "fs";
711
+ import path4 from "path";
626
712
  function detectVersion2(cwd) {
627
- const packageJsonPath = path3.join(cwd, "package.json");
628
- if (!fs3.existsSync(packageJsonPath)) {
713
+ const packageJsonPath = path4.join(cwd, "package.json");
714
+ if (!fs4.existsSync(packageJsonPath)) {
629
715
  return {
630
716
  version: null,
631
717
  error: "No package.json found in the current directory"
632
718
  };
633
719
  }
634
720
  try {
635
- const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
721
+ const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf-8"));
636
722
  const dependencies = packageJson.dependencies || {};
637
723
  const devDependencies = packageJson.devDependencies || {};
638
724
  const reactVersion = dependencies.react || devDependencies.react;
@@ -664,8 +750,8 @@ var reactProvider = {
664
750
  };
665
751
 
666
752
  // src/lib/providers/pixi.ts
667
- import fs4 from "fs";
668
- import path4 from "path";
753
+ import fs5 from "fs";
754
+ import path5 from "path";
669
755
  function parsePixiVersion(content) {
670
756
  const requiresPixiMatch = content.match(/requires-pixi\s*=\s*["']([^"']+)["']/);
671
757
  if (requiresPixiMatch) {
@@ -677,20 +763,20 @@ function parsePixiVersion(content) {
677
763
  return null;
678
764
  }
679
765
  function detectVersion3(cwd) {
680
- const pixiTomlPath = path4.join(cwd, "pixi.toml");
681
- if (fs4.existsSync(pixiTomlPath)) {
766
+ const pixiTomlPath = path5.join(cwd, "pixi.toml");
767
+ if (fs5.existsSync(pixiTomlPath)) {
682
768
  try {
683
- const content = fs4.readFileSync(pixiTomlPath, "utf-8");
769
+ const content = fs5.readFileSync(pixiTomlPath, "utf-8");
684
770
  const version = parsePixiVersion(content);
685
771
  if (version) {
686
772
  return { version };
687
773
  }
688
774
  } catch {}
689
775
  }
690
- const pyprojectPath = path4.join(cwd, "pyproject.toml");
691
- if (fs4.existsSync(pyprojectPath)) {
776
+ const pyprojectPath = path5.join(cwd, "pyproject.toml");
777
+ if (fs5.existsSync(pyprojectPath)) {
692
778
  try {
693
- const content = fs4.readFileSync(pyprojectPath, "utf-8");
779
+ const content = fs5.readFileSync(pyprojectPath, "utf-8");
694
780
  if (content.includes("[tool.pixi")) {
695
781
  const version = parsePixiVersion(content);
696
782
  if (version) {
@@ -734,13 +820,13 @@ var pixiProvider = {
734
820
  };
735
821
 
736
822
  // src/lib/providers/rattler-build.ts
737
- import fs5 from "fs";
738
- import path5 from "path";
823
+ import fs6 from "fs";
824
+ import path6 from "path";
739
825
  function detectVersion4(cwd) {
740
- const pixiTomlPath = path5.join(cwd, "pixi.toml");
741
- if (fs5.existsSync(pixiTomlPath)) {
826
+ const pixiTomlPath = path6.join(cwd, "pixi.toml");
827
+ if (fs6.existsSync(pixiTomlPath)) {
742
828
  try {
743
- const content = fs5.readFileSync(pixiTomlPath, "utf-8");
829
+ const content = fs6.readFileSync(pixiTomlPath, "utf-8");
744
830
  const match = content.match(/rattler-build\s*=\s*["']([^"']+)["']/);
745
831
  if (match) {
746
832
  const versionMatch = match[1].match(/[\d]+\.[\d]+\.[\d]+/);
@@ -750,10 +836,10 @@ function detectVersion4(cwd) {
750
836
  }
751
837
  } catch {}
752
838
  }
753
- const pyprojectPath = path5.join(cwd, "pyproject.toml");
754
- if (fs5.existsSync(pyprojectPath)) {
839
+ const pyprojectPath = path6.join(cwd, "pyproject.toml");
840
+ if (fs6.existsSync(pyprojectPath)) {
755
841
  try {
756
- const content = fs5.readFileSync(pyprojectPath, "utf-8");
842
+ const content = fs6.readFileSync(pyprojectPath, "utf-8");
757
843
  const match = content.match(/rattler-build\s*=\s*["']([^"']+)["']/);
758
844
  if (match) {
759
845
  const versionMatch = match[1].match(/[\d]+\.[\d]+\.[\d]+/);
@@ -799,13 +885,13 @@ var rattlerBuildProvider = {
799
885
  };
800
886
 
801
887
  // src/lib/providers/tauri.ts
802
- import fs6 from "fs";
803
- import path6 from "path";
888
+ import fs7 from "fs";
889
+ import path7 from "path";
804
890
  function detectVersion5(cwd) {
805
- const packageJsonPath = path6.join(cwd, "package.json");
806
- if (fs6.existsSync(packageJsonPath)) {
891
+ const packageJsonPath = path7.join(cwd, "package.json");
892
+ if (fs7.existsSync(packageJsonPath)) {
807
893
  try {
808
- const content = fs6.readFileSync(packageJsonPath, "utf-8");
894
+ const content = fs7.readFileSync(packageJsonPath, "utf-8");
809
895
  const pkg = JSON.parse(content);
810
896
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
811
897
  const tauriApi = deps["@tauri-apps/api"];
@@ -821,14 +907,14 @@ function detectVersion5(cwd) {
821
907
  }
822
908
  } catch {}
823
909
  }
824
- const tauriConfPath = path6.join(cwd, "src-tauri", "tauri.conf.json");
825
- if (fs6.existsSync(tauriConfPath)) {
910
+ const tauriConfPath = path7.join(cwd, "src-tauri", "tauri.conf.json");
911
+ if (fs7.existsSync(tauriConfPath)) {
826
912
  return { version: "v2" };
827
913
  }
828
- const cargoTomlPath = path6.join(cwd, "src-tauri", "Cargo.toml");
829
- if (fs6.existsSync(cargoTomlPath)) {
914
+ const cargoTomlPath = path7.join(cwd, "src-tauri", "Cargo.toml");
915
+ if (fs7.existsSync(cargoTomlPath)) {
830
916
  try {
831
- const content = fs6.readFileSync(cargoTomlPath, "utf-8");
917
+ const content = fs7.readFileSync(cargoTomlPath, "utf-8");
832
918
  const match = content.match(/tauri\s*=\s*.*?"(\d+)\./);
833
919
  if (match) {
834
920
  const major = parseInt(match[1]);
@@ -889,14 +975,14 @@ var condaForgeProvider = {
889
975
  };
890
976
 
891
977
  // src/lib/providers/bun.ts
892
- import fs7 from "fs";
893
- import path7 from "path";
978
+ import fs8 from "fs";
979
+ import path8 from "path";
894
980
  import { execSync as execSync2 } from "child_process";
895
981
  function detectVersion7(cwd) {
896
- const bunLockPath = path7.join(cwd, "bun.lockb");
897
- const hasBunLock = fs7.existsSync(bunLockPath);
898
- const bunfigPath = path7.join(cwd, "bunfig.toml");
899
- const hasBunfig = fs7.existsSync(bunfigPath);
982
+ const bunLockPath = path8.join(cwd, "bun.lockb");
983
+ const hasBunLock = fs8.existsSync(bunLockPath);
984
+ const bunfigPath = path8.join(cwd, "bunfig.toml");
985
+ const hasBunfig = fs8.existsSync(bunfigPath);
900
986
  if (!hasBunLock && !hasBunfig) {
901
987
  return {
902
988
  version: null,
@@ -928,18 +1014,18 @@ var bunProvider = {
928
1014
  };
929
1015
 
930
1016
  // src/lib/providers/svelte.ts
931
- import fs8 from "fs";
932
- import path8 from "path";
1017
+ import fs9 from "fs";
1018
+ import path9 from "path";
933
1019
  function detectVersion8(cwd) {
934
- const packageJsonPath = path8.join(cwd, "package.json");
935
- if (!fs8.existsSync(packageJsonPath)) {
1020
+ const packageJsonPath = path9.join(cwd, "package.json");
1021
+ if (!fs9.existsSync(packageJsonPath)) {
936
1022
  return {
937
1023
  version: null,
938
1024
  error: "No package.json found in the current directory"
939
1025
  };
940
1026
  }
941
1027
  try {
942
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
1028
+ const packageJson = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8"));
943
1029
  const dependencies = packageJson.dependencies || {};
944
1030
  const devDependencies = packageJson.devDependencies || {};
945
1031
  const svelteVersion = dependencies.svelte || devDependencies.svelte;
@@ -977,18 +1063,18 @@ var svelteProvider = {
977
1063
  };
978
1064
 
979
1065
  // src/lib/providers/tailwind.ts
980
- import fs9 from "fs";
981
- import path9 from "path";
1066
+ import fs10 from "fs";
1067
+ import path10 from "path";
982
1068
  function detectVersion9(cwd) {
983
- const packageJsonPath = path9.join(cwd, "package.json");
984
- if (!fs9.existsSync(packageJsonPath)) {
1069
+ const packageJsonPath = path10.join(cwd, "package.json");
1070
+ if (!fs10.existsSync(packageJsonPath)) {
985
1071
  return {
986
1072
  version: null,
987
1073
  error: "No package.json found in the current directory"
988
1074
  };
989
1075
  }
990
1076
  try {
991
- const packageJson = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8"));
1077
+ const packageJson = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
992
1078
  const dependencies = packageJson.dependencies || {};
993
1079
  const devDependencies = packageJson.devDependencies || {};
994
1080
  const tailwindVersion = dependencies.tailwindcss || devDependencies.tailwindcss;
@@ -1020,8 +1106,8 @@ var tailwindProvider = {
1020
1106
  };
1021
1107
 
1022
1108
  // src/lib/providers/ruff.ts
1023
- import fs10 from "fs";
1024
- import path10 from "path";
1109
+ import fs11 from "fs";
1110
+ import path11 from "path";
1025
1111
  function parseRuffVersion(content) {
1026
1112
  const patterns = [
1027
1113
  /ruff\s*=\s*["']([^"']+)["']/,
@@ -1040,10 +1126,10 @@ function parseRuffVersion(content) {
1040
1126
  return null;
1041
1127
  }
1042
1128
  function detectVersion10(cwd) {
1043
- const pyprojectPath = path10.join(cwd, "pyproject.toml");
1044
- if (fs10.existsSync(pyprojectPath)) {
1129
+ const pyprojectPath = path11.join(cwd, "pyproject.toml");
1130
+ if (fs11.existsSync(pyprojectPath)) {
1045
1131
  try {
1046
- const content = fs10.readFileSync(pyprojectPath, "utf-8");
1132
+ const content = fs11.readFileSync(pyprojectPath, "utf-8");
1047
1133
  if (content.includes("ruff")) {
1048
1134
  const version = parseRuffVersion(content);
1049
1135
  if (version) {
@@ -1052,8 +1138,8 @@ function detectVersion10(cwd) {
1052
1138
  }
1053
1139
  } catch {}
1054
1140
  }
1055
- const ruffTomlPath = path10.join(cwd, "ruff.toml");
1056
- if (fs10.existsSync(ruffTomlPath)) {}
1141
+ const ruffTomlPath = path11.join(cwd, "ruff.toml");
1142
+ if (fs11.existsSync(ruffTomlPath)) {}
1057
1143
  try {
1058
1144
  const { execSync: execSync3 } = __require("child_process");
1059
1145
  const output = execSync3("ruff --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
@@ -1085,8 +1171,8 @@ var ruffProvider = {
1085
1171
  };
1086
1172
 
1087
1173
  // src/lib/providers/ty.ts
1088
- import fs11 from "fs";
1089
- import path11 from "path";
1174
+ import fs12 from "fs";
1175
+ import path12 from "path";
1090
1176
  function parseTyVersion(content) {
1091
1177
  const patterns = [
1092
1178
  /\bty\s*=\s*["']([^"']+)["']/,
@@ -1105,10 +1191,10 @@ function parseTyVersion(content) {
1105
1191
  return null;
1106
1192
  }
1107
1193
  function detectVersion11(cwd) {
1108
- const pyprojectPath = path11.join(cwd, "pyproject.toml");
1109
- if (fs11.existsSync(pyprojectPath)) {
1194
+ const pyprojectPath = path12.join(cwd, "pyproject.toml");
1195
+ if (fs12.existsSync(pyprojectPath)) {
1110
1196
  try {
1111
- const content = fs11.readFileSync(pyprojectPath, "utf-8");
1197
+ const content = fs12.readFileSync(pyprojectPath, "utf-8");
1112
1198
  if (content.includes("[tool.ty]") || /["']ty[>=<]/.test(content) || /\bty\s*=/.test(content)) {
1113
1199
  const version = parseTyVersion(content);
1114
1200
  if (version) {
@@ -1148,8 +1234,8 @@ var tyProvider = {
1148
1234
  };
1149
1235
 
1150
1236
  // src/lib/providers/basedpyright.ts
1151
- import fs12 from "fs";
1152
- import path12 from "path";
1237
+ import fs13 from "fs";
1238
+ import path13 from "path";
1153
1239
  function parseBasedpyrightVersion(content) {
1154
1240
  const patterns = [
1155
1241
  /basedpyright\s*=\s*["']([^"']+)["']/,
@@ -1168,10 +1254,10 @@ function parseBasedpyrightVersion(content) {
1168
1254
  return null;
1169
1255
  }
1170
1256
  function detectVersion12(cwd) {
1171
- const pyprojectPath = path12.join(cwd, "pyproject.toml");
1172
- if (fs12.existsSync(pyprojectPath)) {
1257
+ const pyprojectPath = path13.join(cwd, "pyproject.toml");
1258
+ if (fs13.existsSync(pyprojectPath)) {
1173
1259
  try {
1174
- const content = fs12.readFileSync(pyprojectPath, "utf-8");
1260
+ const content = fs13.readFileSync(pyprojectPath, "utf-8");
1175
1261
  if (content.includes("basedpyright")) {
1176
1262
  const version = parseBasedpyrightVersion(content);
1177
1263
  if (version) {
@@ -1211,18 +1297,18 @@ var basedpyrightProvider = {
1211
1297
  };
1212
1298
 
1213
1299
  // src/lib/providers/convex.ts
1214
- import fs13 from "fs";
1215
- import path13 from "path";
1300
+ import fs14 from "fs";
1301
+ import path14 from "path";
1216
1302
  function detectVersion13(cwd) {
1217
- const packageJsonPath = path13.join(cwd, "package.json");
1218
- if (!fs13.existsSync(packageJsonPath)) {
1303
+ const packageJsonPath = path14.join(cwd, "package.json");
1304
+ if (!fs14.existsSync(packageJsonPath)) {
1219
1305
  return {
1220
1306
  version: null,
1221
1307
  error: "No package.json found in the current directory"
1222
1308
  };
1223
1309
  }
1224
1310
  try {
1225
- const packageJson = JSON.parse(fs13.readFileSync(packageJsonPath, "utf-8"));
1311
+ const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
1226
1312
  const dependencies = packageJson.dependencies || {};
1227
1313
  const devDependencies = packageJson.devDependencies || {};
1228
1314
  const convexVersion = dependencies.convex || devDependencies.convex;
@@ -1254,8 +1340,8 @@ var convexProvider = {
1254
1340
  };
1255
1341
 
1256
1342
  // src/lib/providers/polars.ts
1257
- import fs14 from "fs";
1258
- import path14 from "path";
1343
+ import fs15 from "fs";
1344
+ import path15 from "path";
1259
1345
  function parsePolarsVersion(content) {
1260
1346
  const patterns = [
1261
1347
  /polars\s*=\s*["']([^"']+)["']/,
@@ -1281,10 +1367,10 @@ function parseRequirementsVersion(content) {
1281
1367
  return null;
1282
1368
  }
1283
1369
  function detectVersion14(cwd) {
1284
- const pyprojectPath = path14.join(cwd, "pyproject.toml");
1285
- if (fs14.existsSync(pyprojectPath)) {
1370
+ const pyprojectPath = path15.join(cwd, "pyproject.toml");
1371
+ if (fs15.existsSync(pyprojectPath)) {
1286
1372
  try {
1287
- const content = fs14.readFileSync(pyprojectPath, "utf-8");
1373
+ const content = fs15.readFileSync(pyprojectPath, "utf-8");
1288
1374
  if (content.includes("polars")) {
1289
1375
  const version = parsePolarsVersion(content);
1290
1376
  if (version) {
@@ -1293,10 +1379,10 @@ function detectVersion14(cwd) {
1293
1379
  }
1294
1380
  } catch {}
1295
1381
  }
1296
- const requirementsPath = path14.join(cwd, "requirements.txt");
1297
- if (fs14.existsSync(requirementsPath)) {
1382
+ const requirementsPath = path15.join(cwd, "requirements.txt");
1383
+ if (fs15.existsSync(requirementsPath)) {
1298
1384
  try {
1299
- const content = fs14.readFileSync(requirementsPath, "utf-8");
1385
+ const content = fs15.readFileSync(requirementsPath, "utf-8");
1300
1386
  if (content.includes("polars")) {
1301
1387
  const version = parseRequirementsVersion(content);
1302
1388
  if (version) {
@@ -1336,8 +1422,8 @@ var polarsProvider = {
1336
1422
  };
1337
1423
 
1338
1424
  // src/lib/providers/delta-rs.ts
1339
- import fs15 from "fs";
1340
- import path15 from "path";
1425
+ import fs16 from "fs";
1426
+ import path16 from "path";
1341
1427
  function parseDeltaLakeVersion(content) {
1342
1428
  const patterns = [
1343
1429
  /deltalake\s*=\s*["']([^"']+)["']/,
@@ -1363,10 +1449,10 @@ function parseRequirementsVersion2(content) {
1363
1449
  return null;
1364
1450
  }
1365
1451
  function detectVersion15(cwd) {
1366
- const pyprojectPath = path15.join(cwd, "pyproject.toml");
1367
- if (fs15.existsSync(pyprojectPath)) {
1452
+ const pyprojectPath = path16.join(cwd, "pyproject.toml");
1453
+ if (fs16.existsSync(pyprojectPath)) {
1368
1454
  try {
1369
- const content = fs15.readFileSync(pyprojectPath, "utf-8");
1455
+ const content = fs16.readFileSync(pyprojectPath, "utf-8");
1370
1456
  if (content.includes("deltalake")) {
1371
1457
  const version = parseDeltaLakeVersion(content);
1372
1458
  if (version) {
@@ -1375,10 +1461,10 @@ function detectVersion15(cwd) {
1375
1461
  }
1376
1462
  } catch {}
1377
1463
  }
1378
- const requirementsPath = path15.join(cwd, "requirements.txt");
1379
- if (fs15.existsSync(requirementsPath)) {
1464
+ const requirementsPath = path16.join(cwd, "requirements.txt");
1465
+ if (fs16.existsSync(requirementsPath)) {
1380
1466
  try {
1381
- const content = fs15.readFileSync(requirementsPath, "utf-8");
1467
+ const content = fs16.readFileSync(requirementsPath, "utf-8");
1382
1468
  if (content.includes("deltalake")) {
1383
1469
  const version = parseRequirementsVersion2(content);
1384
1470
  if (version) {
@@ -1418,18 +1504,18 @@ var deltaRsProvider = {
1418
1504
  };
1419
1505
 
1420
1506
  // src/lib/providers/obsidian.ts
1421
- import fs16 from "fs";
1422
- import path16 from "path";
1507
+ import fs17 from "fs";
1508
+ import path17 from "path";
1423
1509
  function detectVersion16(cwd) {
1424
- const packageJsonPath = path16.join(cwd, "package.json");
1425
- if (!fs16.existsSync(packageJsonPath)) {
1510
+ const packageJsonPath = path17.join(cwd, "package.json");
1511
+ if (!fs17.existsSync(packageJsonPath)) {
1426
1512
  return {
1427
1513
  version: null,
1428
1514
  error: "No package.json found in the current directory"
1429
1515
  };
1430
1516
  }
1431
1517
  try {
1432
- const packageJson = JSON.parse(fs16.readFileSync(packageJsonPath, "utf-8"));
1518
+ const packageJson = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
1433
1519
  const dependencies = packageJson.dependencies || {};
1434
1520
  const devDependencies = packageJson.devDependencies || {};
1435
1521
  const obsidianVersion = dependencies.obsidian || devDependencies.obsidian;
@@ -1461,13 +1547,13 @@ var obsidianProvider = {
1461
1547
  };
1462
1548
 
1463
1549
  // src/lib/providers/obsidian-excalidraw.ts
1464
- import fs17 from "fs";
1465
- import path17 from "path";
1550
+ import fs18 from "fs";
1551
+ import path18 from "path";
1466
1552
  function detectVersion17(cwd) {
1467
- const manifestPath = path17.join(cwd, "manifest.json");
1468
- if (fs17.existsSync(manifestPath)) {
1553
+ const manifestPath = path18.join(cwd, "manifest.json");
1554
+ if (fs18.existsSync(manifestPath)) {
1469
1555
  try {
1470
- const manifest = JSON.parse(fs17.readFileSync(manifestPath, "utf-8"));
1556
+ const manifest = JSON.parse(fs18.readFileSync(manifestPath, "utf-8"));
1471
1557
  if (manifest.id === "obsidian-excalidraw-plugin" && manifest.version) {
1472
1558
  return { version: manifest.version };
1473
1559
  }
@@ -1524,8 +1610,8 @@ var ffmpegProvider = {
1524
1610
  };
1525
1611
 
1526
1612
  // src/lib/providers/manim.ts
1527
- import fs18 from "fs";
1528
- import path18 from "path";
1613
+ import fs19 from "fs";
1614
+ import path19 from "path";
1529
1615
  function parseManimVersion(content) {
1530
1616
  const patterns = [
1531
1617
  /manim\s*=\s*["']([^"']+)["']/,
@@ -1551,10 +1637,10 @@ function parseRequirementsVersion3(content) {
1551
1637
  return null;
1552
1638
  }
1553
1639
  function detectVersion19(cwd) {
1554
- const pyprojectPath = path18.join(cwd, "pyproject.toml");
1555
- if (fs18.existsSync(pyprojectPath)) {
1640
+ const pyprojectPath = path19.join(cwd, "pyproject.toml");
1641
+ if (fs19.existsSync(pyprojectPath)) {
1556
1642
  try {
1557
- const content = fs18.readFileSync(pyprojectPath, "utf-8");
1643
+ const content = fs19.readFileSync(pyprojectPath, "utf-8");
1558
1644
  if (content.includes("manim")) {
1559
1645
  const version = parseManimVersion(content);
1560
1646
  if (version) {
@@ -1563,10 +1649,10 @@ function detectVersion19(cwd) {
1563
1649
  }
1564
1650
  } catch {}
1565
1651
  }
1566
- const requirementsPath = path18.join(cwd, "requirements.txt");
1567
- if (fs18.existsSync(requirementsPath)) {
1652
+ const requirementsPath = path19.join(cwd, "requirements.txt");
1653
+ if (fs19.existsSync(requirementsPath)) {
1568
1654
  try {
1569
- const content = fs18.readFileSync(requirementsPath, "utf-8");
1655
+ const content = fs19.readFileSync(requirementsPath, "utf-8");
1570
1656
  if (content.includes("manim")) {
1571
1657
  const version = parseRequirementsVersion3(content);
1572
1658
  if (version) {
@@ -1670,8 +1756,8 @@ var tensorrtProvider = {
1670
1756
  };
1671
1757
 
1672
1758
  // src/lib/providers/generic.ts
1673
- import fs19 from "fs";
1674
- import path19 from "path";
1759
+ import fs20 from "fs";
1760
+ import path20 from "path";
1675
1761
  function createProvider(options) {
1676
1762
  const {
1677
1763
  name,
@@ -1691,15 +1777,15 @@ function createProvider(options) {
1691
1777
  instruction
1692
1778
  } = options;
1693
1779
  const detectVersion20 = packageName ? (cwd) => {
1694
- const packageJsonPath = path19.join(cwd, "package.json");
1695
- if (!fs19.existsSync(packageJsonPath)) {
1780
+ const packageJsonPath = path20.join(cwd, "package.json");
1781
+ if (!fs20.existsSync(packageJsonPath)) {
1696
1782
  return {
1697
1783
  version: null,
1698
1784
  error: "No package.json found in the current directory"
1699
1785
  };
1700
1786
  }
1701
1787
  try {
1702
- const packageJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
1788
+ const packageJson = JSON.parse(fs20.readFileSync(packageJsonPath, "utf-8"));
1703
1789
  const dependencies = packageJson.dependencies || {};
1704
1790
  const devDependencies = packageJson.devDependencies || {};
1705
1791
  const version = dependencies[packageName] || devDependencies[packageName];
@@ -1742,19 +1828,31 @@ function createLocalProvider(options) {
1742
1828
  instruction: options.instruction || `IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any ${options.displayName} tasks.`
1743
1829
  };
1744
1830
  }
1831
+ function createUrlProvider(options) {
1832
+ return {
1833
+ name: options.name,
1834
+ displayName: options.displayName,
1835
+ repo: "",
1836
+ docsPath: "",
1837
+ extensions: options.extensions || [".md"],
1838
+ excludePatterns: options.excludePatterns || [],
1839
+ instruction: options.instruction || `IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any ${options.displayName} tasks.`,
1840
+ urlConfig: options.urlConfig
1841
+ };
1842
+ }
1745
1843
  // src/lib/providers/sveltekit.ts
1746
- import fs20 from "fs";
1747
- import path20 from "path";
1844
+ import fs21 from "fs";
1845
+ import path21 from "path";
1748
1846
  function detectVersion20(cwd) {
1749
- const packageJsonPath = path20.join(cwd, "package.json");
1750
- if (!fs20.existsSync(packageJsonPath)) {
1847
+ const packageJsonPath = path21.join(cwd, "package.json");
1848
+ if (!fs21.existsSync(packageJsonPath)) {
1751
1849
  return {
1752
1850
  version: null,
1753
1851
  error: "No package.json found in the current directory"
1754
1852
  };
1755
1853
  }
1756
1854
  try {
1757
- const packageJson = JSON.parse(fs20.readFileSync(packageJsonPath, "utf-8"));
1855
+ const packageJson = JSON.parse(fs21.readFileSync(packageJsonPath, "utf-8"));
1758
1856
  const dependencies = packageJson.dependencies || {};
1759
1857
  const devDependencies = packageJson.devDependencies || {};
1760
1858
  const kitVersion = dependencies["@sveltejs/kit"] || devDependencies["@sveltejs/kit"];
@@ -1785,18 +1883,18 @@ var sveltekitProvider = {
1785
1883
  instruction: "IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any SvelteKit tasks."
1786
1884
  };
1787
1885
  // src/lib/providers/shadcn-svelte.ts
1788
- import fs21 from "fs";
1789
- import path21 from "path";
1886
+ import fs22 from "fs";
1887
+ import path22 from "path";
1790
1888
  function detectVersion21(cwd) {
1791
- const packageJsonPath = path21.join(cwd, "package.json");
1792
- if (!fs21.existsSync(packageJsonPath)) {
1889
+ const packageJsonPath = path22.join(cwd, "package.json");
1890
+ if (!fs22.existsSync(packageJsonPath)) {
1793
1891
  return {
1794
1892
  version: null,
1795
1893
  error: "No package.json found in the current directory"
1796
1894
  };
1797
1895
  }
1798
1896
  try {
1799
- const packageJson = JSON.parse(fs21.readFileSync(packageJsonPath, "utf-8"));
1897
+ const packageJson = JSON.parse(fs22.readFileSync(packageJsonPath, "utf-8"));
1800
1898
  const dependencies = packageJson.dependencies || {};
1801
1899
  const devDependencies = packageJson.devDependencies || {};
1802
1900
  const version = dependencies["shadcn-svelte"] || devDependencies["shadcn-svelte"];
@@ -1905,8 +2003,8 @@ function isProviderAvailable(preset) {
1905
2003
  }
1906
2004
 
1907
2005
  // src/lib/skills.ts
1908
- import fs22 from "fs";
1909
- import path22 from "path";
2006
+ import fs23 from "fs";
2007
+ import path23 from "path";
1910
2008
  import os2 from "os";
1911
2009
  var SKILLS_START_MARKER = "<!-- AGENTS-MD-SKILLS-START -->";
1912
2010
  var SKILLS_END_MARKER = "<!-- AGENTS-MD-SKILLS-END -->";
@@ -1921,10 +2019,10 @@ async function fetchSkillsShSearch(query, limit = 20) {
1921
2019
  return data.skills;
1922
2020
  }
1923
2021
  function parseEnabledPlugins(settingsPath) {
1924
- if (!fs22.existsSync(settingsPath))
2022
+ if (!fs23.existsSync(settingsPath))
1925
2023
  return [];
1926
2024
  try {
1927
- const content = fs22.readFileSync(settingsPath, "utf-8");
2025
+ const content = fs23.readFileSync(settingsPath, "utf-8");
1928
2026
  const settings = JSON.parse(content);
1929
2027
  const enabledPlugins = settings.enabledPlugins || {};
1930
2028
  const plugins = [];
@@ -1945,17 +2043,17 @@ function parseEnabledPlugins(settingsPath) {
1945
2043
  }
1946
2044
  }
1947
2045
  function findPluginSkillsPath(pluginRepo, skillName) {
1948
- const cacheDir = path22.join(os2.homedir(), ".claude", "plugins", "cache", pluginRepo, skillName);
1949
- if (!fs22.existsSync(cacheDir))
2046
+ const cacheDir = path23.join(os2.homedir(), ".claude", "plugins", "cache", pluginRepo, skillName);
2047
+ if (!fs23.existsSync(cacheDir))
1950
2048
  return null;
1951
2049
  try {
1952
- const entries = fs22.readdirSync(cacheDir, { withFileTypes: true });
2050
+ const entries = fs23.readdirSync(cacheDir, { withFileTypes: true });
1953
2051
  const hashDirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith("."));
1954
2052
  if (hashDirs.length === 0)
1955
2053
  return null;
1956
2054
  const hashDir = hashDirs[0].name;
1957
- const skillsPath = path22.join(cacheDir, hashDir, "skills");
1958
- if (fs22.existsSync(skillsPath)) {
2055
+ const skillsPath = path23.join(cacheDir, hashDir, "skills");
2056
+ if (fs23.existsSync(skillsPath)) {
1959
2057
  return skillsPath;
1960
2058
  }
1961
2059
  return null;
@@ -1967,8 +2065,8 @@ function getEnabledPluginSources(cwd) {
1967
2065
  const sources = [];
1968
2066
  const seenPlugins = new Set;
1969
2067
  const settingsPaths = [
1970
- path22.join(os2.homedir(), ".claude", "settings.json"),
1971
- path22.join(cwd, ".claude", "settings.json")
2068
+ path23.join(os2.homedir(), ".claude", "settings.json"),
2069
+ path23.join(cwd, ".claude", "settings.json")
1972
2070
  ];
1973
2071
  for (const settingsPath of settingsPaths) {
1974
2072
  const plugins = parseEnabledPlugins(settingsPath);
@@ -2011,12 +2109,12 @@ function parseSkillFrontmatter(content) {
2011
2109
  function getFilesRecursively(dir, baseDir) {
2012
2110
  const files = [];
2013
2111
  try {
2014
- const entries = fs22.readdirSync(dir, { withFileTypes: true });
2112
+ const entries = fs23.readdirSync(dir, { withFileTypes: true });
2015
2113
  for (const entry of entries) {
2016
2114
  if (entry.name.startsWith(".") || entry.name === "SKILL.md")
2017
2115
  continue;
2018
- const fullPath = path22.join(dir, entry.name);
2019
- const relativePath = path22.relative(baseDir, fullPath);
2116
+ const fullPath = path23.join(dir, entry.name);
2117
+ const relativePath = path23.relative(baseDir, fullPath);
2020
2118
  if (entry.isDirectory()) {
2021
2119
  files.push(...getFilesRecursively(fullPath, baseDir));
2022
2120
  } else {
@@ -2027,29 +2125,29 @@ function getFilesRecursively(dir, baseDir) {
2027
2125
  return files;
2028
2126
  }
2029
2127
  function getSiblingFiles(skillMdPath) {
2030
- const dir = path22.dirname(skillMdPath);
2031
- if (!fs22.existsSync(dir))
2128
+ const dir = path23.dirname(skillMdPath);
2129
+ if (!fs23.existsSync(dir))
2032
2130
  return [];
2033
2131
  return getFilesRecursively(dir, dir).sort();
2034
2132
  }
2035
2133
  function discoverPluginSkills(pluginsPath, label) {
2036
2134
  const skills = [];
2037
- const pluginsDir = path22.join(pluginsPath, "plugins");
2038
- if (!fs22.existsSync(pluginsDir)) {
2135
+ const pluginsDir = path23.join(pluginsPath, "plugins");
2136
+ if (!fs23.existsSync(pluginsDir)) {
2039
2137
  return skills;
2040
2138
  }
2041
- const plugins = fs22.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory());
2139
+ const plugins = fs23.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory());
2042
2140
  for (const plugin of plugins) {
2043
- const skillsDir = path22.join(pluginsDir, plugin.name, "skills");
2044
- if (!fs22.existsSync(skillsDir))
2141
+ const skillsDir = path23.join(pluginsDir, plugin.name, "skills");
2142
+ if (!fs23.existsSync(skillsDir))
2045
2143
  continue;
2046
- const skillDirs = fs22.readdirSync(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory());
2144
+ const skillDirs = fs23.readdirSync(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory());
2047
2145
  for (const skillDir of skillDirs) {
2048
- const skillMdPath = path22.join(skillsDir, skillDir.name, "SKILL.md");
2049
- if (!fs22.existsSync(skillMdPath))
2146
+ const skillMdPath = path23.join(skillsDir, skillDir.name, "SKILL.md");
2147
+ if (!fs23.existsSync(skillMdPath))
2050
2148
  continue;
2051
2149
  try {
2052
- const content = fs22.readFileSync(skillMdPath, "utf-8");
2150
+ const content = fs23.readFileSync(skillMdPath, "utf-8");
2053
2151
  const frontmatter = parseSkillFrontmatter(content);
2054
2152
  if (!frontmatter)
2055
2153
  continue;
@@ -2068,16 +2166,16 @@ function discoverPluginSkills(pluginsPath, label) {
2068
2166
  }
2069
2167
  function discoverFlatSkills(skillsPath, source, label) {
2070
2168
  const skills = [];
2071
- if (!fs22.existsSync(skillsPath)) {
2169
+ if (!fs23.existsSync(skillsPath)) {
2072
2170
  return skills;
2073
2171
  }
2074
- const skillDirs = fs22.readdirSync(skillsPath, { withFileTypes: true }).filter((d) => d.isDirectory());
2172
+ const skillDirs = fs23.readdirSync(skillsPath, { withFileTypes: true }).filter((d) => d.isDirectory());
2075
2173
  for (const skillDir of skillDirs) {
2076
- const skillMdPath = path22.join(skillsPath, skillDir.name, "SKILL.md");
2077
- if (!fs22.existsSync(skillMdPath))
2174
+ const skillMdPath = path23.join(skillsPath, skillDir.name, "SKILL.md");
2175
+ if (!fs23.existsSync(skillMdPath))
2078
2176
  continue;
2079
2177
  try {
2080
- const content = fs22.readFileSync(skillMdPath, "utf-8");
2178
+ const content = fs23.readFileSync(skillMdPath, "utf-8");
2081
2179
  const frontmatter = parseSkillFrontmatter(content);
2082
2180
  if (!frontmatter)
2083
2181
  continue;
@@ -2102,10 +2200,10 @@ function discoverSkillsShRepo(repoDir, repoName) {
2102
2200
  "skills/.curated",
2103
2201
  "skills/.experimental"
2104
2202
  ];
2105
- const rootSkillMd = path22.join(repoDir, "SKILL.md");
2106
- if (fs22.existsSync(rootSkillMd)) {
2203
+ const rootSkillMd = path23.join(repoDir, "SKILL.md");
2204
+ if (fs23.existsSync(rootSkillMd)) {
2107
2205
  try {
2108
- const content = fs22.readFileSync(rootSkillMd, "utf-8");
2206
+ const content = fs23.readFileSync(rootSkillMd, "utf-8");
2109
2207
  const frontmatter = parseSkillFrontmatter(content);
2110
2208
  if (frontmatter) {
2111
2209
  seen.add(frontmatter.name);
@@ -2121,8 +2219,8 @@ function discoverSkillsShRepo(repoDir, repoName) {
2121
2219
  } catch {}
2122
2220
  }
2123
2221
  for (const dir of searchDirs) {
2124
- const fullDir = path22.join(repoDir, dir);
2125
- if (!fs22.existsSync(fullDir))
2222
+ const fullDir = path23.join(repoDir, dir);
2223
+ if (!fs23.existsSync(fullDir))
2126
2224
  continue;
2127
2225
  const discovered = discoverFlatSkills(fullDir, "skills-sh", repoName);
2128
2226
  for (const skill of discovered) {
@@ -2252,7 +2350,7 @@ function getDefaultSkillSources(cwd, options = {}) {
2252
2350
  sources.push({
2253
2351
  type: "plugin",
2254
2352
  path: pluginPath,
2255
- label: path22.basename(pluginPath)
2353
+ label: path23.basename(pluginPath)
2256
2354
  });
2257
2355
  }
2258
2356
  if (includeEnabledPlugins) {
@@ -2260,7 +2358,7 @@ function getDefaultSkillSources(cwd, options = {}) {
2260
2358
  sources.push(...enabledPluginSources);
2261
2359
  }
2262
2360
  if (includeUser) {
2263
- const userSkillsPath = path22.join(os2.homedir(), ".claude", "skills");
2361
+ const userSkillsPath = path23.join(os2.homedir(), ".claude", "skills");
2264
2362
  sources.push({
2265
2363
  type: "user",
2266
2364
  path: userSkillsPath,
@@ -2268,7 +2366,7 @@ function getDefaultSkillSources(cwd, options = {}) {
2268
2366
  });
2269
2367
  }
2270
2368
  if (includeProject) {
2271
- const projectSkillsPath = path22.join(cwd, ".claude", "skills");
2369
+ const projectSkillsPath = path23.join(cwd, ".claude", "skills");
2272
2370
  sources.push({
2273
2371
  type: "project",
2274
2372
  path: projectSkillsPath,
@@ -2279,12 +2377,12 @@ function getDefaultSkillSources(cwd, options = {}) {
2279
2377
  }
2280
2378
  async function embedSkills(options) {
2281
2379
  const { cwd, sources, output = "AGENTS.md" } = options;
2282
- const targetPath = path22.join(cwd, output);
2380
+ const targetPath = path23.join(cwd, output);
2283
2381
  let sizeBefore = 0;
2284
2382
  let isNewFile = true;
2285
2383
  let existingContent = "";
2286
- if (fs22.existsSync(targetPath)) {
2287
- existingContent = fs22.readFileSync(targetPath, "utf-8");
2384
+ if (fs23.existsSync(targetPath)) {
2385
+ existingContent = fs23.readFileSync(targetPath, "utf-8");
2288
2386
  sizeBefore = Buffer.byteLength(existingContent, "utf-8");
2289
2387
  isNewFile = false;
2290
2388
  }
@@ -2308,7 +2406,7 @@ async function embedSkills(options) {
2308
2406
  regenerateCommand: `npx agdex skills embed`
2309
2407
  });
2310
2408
  const newContent = injectSkillsIndex(existingContent, indexContent);
2311
- fs22.writeFileSync(targetPath, newContent, "utf-8");
2409
+ fs23.writeFileSync(targetPath, newContent, "utf-8");
2312
2410
  const sizeAfter = Buffer.byteLength(newContent, "utf-8");
2313
2411
  return {
2314
2412
  success: true,
@@ -2322,24 +2420,24 @@ async function embedSkills(options) {
2322
2420
  }
2323
2421
 
2324
2422
  // src/lib/config.ts
2325
- import fs23 from "fs";
2326
- import path23 from "path";
2423
+ import fs24 from "fs";
2424
+ import path24 from "path";
2327
2425
  var DEFAULT_CONFIG = {
2328
2426
  output: "CLAUDE.local.md"
2329
2427
  };
2330
2428
  function loadConfig(cwd = process.cwd()) {
2331
- const rcPath = path23.join(cwd, ".agdexrc.json");
2332
- if (fs23.existsSync(rcPath)) {
2429
+ const rcPath = path24.join(cwd, ".agdexrc.json");
2430
+ if (fs24.existsSync(rcPath)) {
2333
2431
  try {
2334
- const content = fs23.readFileSync(rcPath, "utf-8");
2432
+ const content = fs24.readFileSync(rcPath, "utf-8");
2335
2433
  const config = JSON.parse(content);
2336
2434
  return { ...DEFAULT_CONFIG, ...config };
2337
2435
  } catch {}
2338
2436
  }
2339
- const packageJsonPath = path23.join(cwd, "package.json");
2340
- if (fs23.existsSync(packageJsonPath)) {
2437
+ const packageJsonPath = path24.join(cwd, "package.json");
2438
+ if (fs24.existsSync(packageJsonPath)) {
2341
2439
  try {
2342
- const content = fs23.readFileSync(packageJsonPath, "utf-8");
2440
+ const content = fs24.readFileSync(packageJsonPath, "utf-8");
2343
2441
  const packageJson = JSON.parse(content);
2344
2442
  if (packageJson.agdex && typeof packageJson.agdex === "object") {
2345
2443
  return { ...DEFAULT_CONFIG, ...packageJson.agdex };
@@ -2353,4 +2451,120 @@ function getDefaultOutput(cwd = process.cwd()) {
2353
2451
  return config.output || "CLAUDE.local.md";
2354
2452
  }
2355
2453
 
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 };
2454
+ // src/lib/index-maintenance.ts
2455
+ import fs25 from "fs";
2456
+ import path25 from "path";
2457
+ var DOCS_MARKER_REGEX = /<!-- AGENTS-MD-EMBED-START:(\S+?) -->/g;
2458
+ var SKILLS_START_MARKER2 = "<!-- AGENTS-MD-SKILLS-START -->";
2459
+ function getDefaultStatusTargets(cwd) {
2460
+ const targets = [
2461
+ getDefaultOutput(cwd),
2462
+ "AGENTS.md",
2463
+ "AGENTS.local.md",
2464
+ "CLAUDE.md",
2465
+ "CLAUDE.local.md"
2466
+ ];
2467
+ return [...new Set(targets)];
2468
+ }
2469
+ function readEmbeddedMarkers(cwd, targetFile) {
2470
+ const targetPath = path25.join(cwd, targetFile);
2471
+ if (!fs25.existsSync(targetPath))
2472
+ return [];
2473
+ const content = fs25.readFileSync(targetPath, "utf-8");
2474
+ const markers = [];
2475
+ let match;
2476
+ while ((match = DOCS_MARKER_REGEX.exec(content)) !== null) {
2477
+ markers.push({ kind: "docs", marker: match[1], targetFile });
2478
+ }
2479
+ if (content.includes(SKILLS_START_MARKER2)) {
2480
+ markers.push({ kind: "skills", marker: "skills", targetFile });
2481
+ }
2482
+ return markers;
2483
+ }
2484
+ function createStatusReport(options) {
2485
+ const { cwd } = options;
2486
+ const lockfile = readIndexLockfile(cwd);
2487
+ const scannedFiles = options.targetFile ? [options.targetFile] : getScannedFiles(cwd, lockfile);
2488
+ const markers = scannedFiles.flatMap((targetFile) => readEmbeddedMarkers(cwd, targetFile));
2489
+ const indexes = [];
2490
+ const seenMarkers = new Set;
2491
+ for (const entry of lockfile.indexes) {
2492
+ if (options.targetFile && entry.targetFile !== options.targetFile)
2493
+ continue;
2494
+ const markerKey = getMarkerKey(entry.kind, entry.marker, entry.targetFile);
2495
+ const marker = markers.find((candidate) => candidate.kind === entry.kind && candidate.marker === entry.marker && candidate.targetFile === entry.targetFile);
2496
+ if (marker)
2497
+ seenMarkers.add(markerKey);
2498
+ indexes.push(analyzeLockfileEntry(cwd, entry, Boolean(marker)));
2499
+ }
2500
+ for (const marker of markers) {
2501
+ const markerKey = getMarkerKey(marker.kind, marker.marker, marker.targetFile);
2502
+ if (seenMarkers.has(markerKey))
2503
+ continue;
2504
+ indexes.push({
2505
+ id: `untracked:${marker.kind}:${marker.marker}:${marker.targetFile}`,
2506
+ kind: marker.kind,
2507
+ health: "untracked-marker",
2508
+ targetFile: marker.targetFile,
2509
+ marker: marker.marker,
2510
+ suggestedAction: "Run `agdex migrate` or rerun the embed command to create a lockfile entry."
2511
+ });
2512
+ }
2513
+ return {
2514
+ cwd,
2515
+ lockfilePath: path25.join(cwd, ".agdex", "agdex.lock"),
2516
+ scannedFiles,
2517
+ indexes: indexes.sort((a, b) => a.id.localeCompare(b.id))
2518
+ };
2519
+ }
2520
+ function getScannedFiles(cwd, lockfile) {
2521
+ const targets = [
2522
+ ...lockfile.indexes.map((entry) => entry.targetFile),
2523
+ ...getDefaultStatusTargets(cwd)
2524
+ ];
2525
+ return [...new Set(targets)].filter((target) => fs25.existsSync(path25.join(cwd, target)));
2526
+ }
2527
+ function analyzeLockfileEntry(cwd, entry, hasMarker) {
2528
+ const targetExists = fs25.existsSync(path25.join(cwd, entry.targetFile));
2529
+ const cachePath = resolveStoredPath(cwd, entry.cachePath);
2530
+ const cacheExists = fs25.existsSync(cachePath);
2531
+ let health = "ok";
2532
+ let suggestedAction = "No action needed.";
2533
+ if (!targetExists) {
2534
+ health = "missing-target";
2535
+ suggestedAction = "Rerun the original embed command or remove this stale lockfile entry.";
2536
+ } else if (!hasMarker) {
2537
+ health = "missing-marker";
2538
+ suggestedAction = "Run `agdex refresh --repair` or rerun the original embed command.";
2539
+ } else if (!cacheExists) {
2540
+ health = "missing-cache";
2541
+ suggestedAction = "Run `agdex refresh` to rebuild the documentation cache.";
2542
+ } else if (entry.kind === "docs" && !hasReadableCache(cachePath)) {
2543
+ health = "stale-lockfile-entry";
2544
+ suggestedAction = "Run `agdex refresh --force` or remove this stale lockfile entry.";
2545
+ }
2546
+ return {
2547
+ id: entry.id,
2548
+ kind: entry.kind,
2549
+ health,
2550
+ targetFile: entry.targetFile,
2551
+ marker: entry.marker,
2552
+ cachePath: entry.cachePath,
2553
+ source: entry.source,
2554
+ command: entry.command,
2555
+ suggestedAction,
2556
+ lockfileEntry: entry
2557
+ };
2558
+ }
2559
+ function hasReadableCache(cachePath) {
2560
+ try {
2561
+ return fs25.readdirSync(cachePath).length > 0;
2562
+ } catch {
2563
+ return false;
2564
+ }
2565
+ }
2566
+ function getMarkerKey(kind, marker, targetFile) {
2567
+ return `${kind}:${marker}:${targetFile}`;
2568
+ }
2569
+
2570
+ export { getLockfilePath, createIndexId, readIndexLockfile, writeIndexLockfile, upsertIndexLockEntry, 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, createUrlProvider, getProvider, listProviders, isProviderAvailable, fetchSkillsShSearch, getEnabledPluginSources, parseSkillFrontmatter, discoverPluginSkills, discoverFlatSkills, discoverSkillsShRepo, collectAllSkills, generateSkillsIndex, hasExistingSkillsIndex, removeSkillsIndex, injectSkillsIndex, getDefaultSkillSources, embedSkills, loadConfig, getDefaultOutput, getDefaultStatusTargets, readEmbeddedMarkers, createStatusReport };