token-goat 2.9.17 → 2.9.19

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 (42) hide show
  1. package/README.md +2 -0
  2. package/dist/{token-goat-chunk-HRUGS6CO.mjs → token-goat-chunk-2GTB5RBZ.mjs} +365 -26
  3. package/dist/{token-goat-chunk-W2GUUQAQ.mjs → token-goat-chunk-3W5P673V.mjs} +1 -1
  4. package/dist/{token-goat-chunk-5WB7GDH4.mjs → token-goat-chunk-62VJ47WN.mjs} +6 -6
  5. package/dist/{token-goat-chunk-C26ZBGBC.mjs → token-goat-chunk-7DGTVBWP.mjs} +58 -44
  6. package/dist/{token-goat-chunk-GPCCYQSS.mjs → token-goat-chunk-AVRD7SBO.mjs} +60 -8
  7. package/dist/{token-goat-chunk-66224KCZ.mjs → token-goat-chunk-BTKDZW7F.mjs} +1 -1
  8. package/dist/{token-goat-chunk-LMFO66YD.mjs → token-goat-chunk-DA43OE7L.mjs} +1 -1
  9. package/dist/{token-goat-chunk-YFGEUIEO.mjs → token-goat-chunk-DA6TIDLI.mjs} +21 -16
  10. package/dist/{token-goat-chunk-CPHVXKNU.mjs → token-goat-chunk-DHIXE6GV.mjs} +2 -2
  11. package/dist/{token-goat-chunk-73GXYYZR.mjs → token-goat-chunk-EP7TCWHM.mjs} +304 -46
  12. package/dist/{token-goat-chunk-EKGVCAES.mjs → token-goat-chunk-EXLLLIC3.mjs} +4 -4
  13. package/dist/{token-goat-chunk-CICJFVIH.mjs → token-goat-chunk-F24NE3FO.mjs} +3 -3
  14. package/dist/{token-goat-chunk-THBLW56G.mjs → token-goat-chunk-FJZ5MZK7.mjs} +3 -3
  15. package/dist/{token-goat-chunk-PKNOHVWP.mjs → token-goat-chunk-FQYMZASI.mjs} +632 -350
  16. package/dist/{token-goat-chunk-RFFUCQK7.mjs → token-goat-chunk-FX5DHKGF.mjs} +5 -5
  17. package/dist/{token-goat-chunk-RB24DBBS.mjs → token-goat-chunk-GYC34EGE.mjs} +7 -8
  18. package/dist/{token-goat-chunk-2M33Q3O4.mjs → token-goat-chunk-HPMMLV37.mjs} +369 -120
  19. package/dist/{token-goat-chunk-BK3RPPTK.mjs → token-goat-chunk-IBTFGZBX.mjs} +19 -14
  20. package/dist/{token-goat-chunk-MWSVUKVV.mjs → token-goat-chunk-JNIFSVWM.mjs} +36 -10
  21. package/dist/{token-goat-chunk-KZPO4DWC.mjs → token-goat-chunk-KWM6KBPA.mjs} +2 -2
  22. package/dist/{token-goat-chunk-G75WIVFM.mjs → token-goat-chunk-L2UOJBV4.mjs} +21 -20
  23. package/dist/{token-goat-chunk-2XA5ZW4T.mjs → token-goat-chunk-LACH3WKS.mjs} +4 -4
  24. package/dist/token-goat-chunk-MU6I4IDI.mjs +337 -0
  25. package/dist/{token-goat-chunk-SWRKVA3J.mjs → token-goat-chunk-NJKNAC37.mjs} +1 -1
  26. package/dist/{token-goat-chunk-ERTXEKB6.mjs → token-goat-chunk-NMTKNYGF.mjs} +2 -0
  27. package/dist/{token-goat-chunk-CKIJWTRQ.mjs → token-goat-chunk-NYFYIRG3.mjs} +12 -12
  28. package/dist/{token-goat-chunk-4EXFN2AW.mjs → token-goat-chunk-OZRSREKR.mjs} +2 -2
  29. package/dist/token-goat-chunk-P46RTOAQ.mjs +27 -0
  30. package/dist/{token-goat-chunk-IDHWKNKZ.mjs → token-goat-chunk-PIAESKVU.mjs} +139 -23
  31. package/dist/{token-goat-chunk-26YUO7MP.mjs → token-goat-chunk-S7RFIX4Y.mjs} +180 -50
  32. package/dist/{token-goat-chunk-2VASS5VR.mjs → token-goat-chunk-SOKAPOOC.mjs} +23 -4
  33. package/dist/token-goat-chunk-VJQBYSXG.mjs +20 -0
  34. package/dist/{token-goat-chunk-7VQMOBPQ.mjs → token-goat-chunk-WKO5TVNA.mjs} +948 -618
  35. package/dist/{token-goat-chunk-UBZCON6N.mjs → token-goat-chunk-ZGQXRYKE.mjs} +29 -5
  36. package/dist/token-goat-hook.mjs +12 -12
  37. package/dist/token-goat.core.mjs +21 -20
  38. package/docs/cli.md +4 -3
  39. package/docs/security.md +1 -1
  40. package/package.json +1 -1
  41. package/dist/token-goat-chunk-7EGKXBWT.mjs +0 -173
  42. package/dist/token-goat-chunk-GLOM5W5C.mjs +0 -93
@@ -4,7 +4,7 @@ import {
4
4
  pathEqClause,
5
5
  projectScopeClause,
6
6
  querySymbols
7
- } from "./token-goat-chunk-BK3RPPTK.mjs";
7
+ } from "./token-goat-chunk-IBTFGZBX.mjs";
8
8
  import {
9
9
  TREE_SITTER_LANGUAGES,
10
10
  _detectOpenQuote,
@@ -21,11 +21,11 @@ import {
21
21
  stripJsComments,
22
22
  stripStringLiterals,
23
23
  stripXmlComments
24
- } from "./token-goat-chunk-MWSVUKVV.mjs";
24
+ } from "./token-goat-chunk-JNIFSVWM.mjs";
25
25
  import {
26
26
  fingerprintContent,
27
27
  loadConfig
28
- } from "./token-goat-chunk-2VASS5VR.mjs";
28
+ } from "./token-goat-chunk-SOKAPOOC.mjs";
29
29
  import {
30
30
  registerReset
31
31
  } from "./token-goat-chunk-EEIDFMEM.mjs";
@@ -39,11 +39,11 @@ import {
39
39
  foldPath,
40
40
  globalDbPath,
41
41
  isCaseInsensitiveFs
42
- } from "./token-goat-chunk-UBZCON6N.mjs";
42
+ } from "./token-goat-chunk-ZGQXRYKE.mjs";
43
43
  import {
44
44
  displaySafeText,
45
45
  normalizePath
46
- } from "./token-goat-chunk-ERTXEKB6.mjs";
46
+ } from "./token-goat-chunk-NMTKNYGF.mjs";
47
47
  import {
48
48
  DocumentRefusedError,
49
49
  MAX_DOCUMENT_WORK_MILLIS
@@ -74,11 +74,11 @@ async function extractEmbeddableDocumentText(filePath) {
74
74
  return text;
75
75
  }
76
76
  case ".docx":
77
- return await (await import("./token-goat-chunk-EKGVCAES.mjs")).docxText(filePath);
77
+ return await (await import("./token-goat-chunk-EXLLLIC3.mjs")).docxText(filePath);
78
78
  case ".pptx":
79
- return await (await import("./token-goat-chunk-2XA5ZW4T.mjs")).pptxAllSlidesText(filePath, true);
79
+ return await (await import("./token-goat-chunk-LACH3WKS.mjs")).pptxAllSlidesText(filePath, true);
80
80
  case ".xlsx":
81
- return await (await import("./token-goat-chunk-RFFUCQK7.mjs")).allSheetsHeadText(filePath, XLSX_SHEET_ROW_CAP);
81
+ return await (await import("./token-goat-chunk-FX5DHKGF.mjs")).allSheetsHeadText(filePath, XLSX_SHEET_ROW_CAP);
82
82
  default:
83
83
  return null;
84
84
  }
@@ -104,20 +104,20 @@ var UnsupportedTokenizerError = class extends Error {
104
104
  function fail(message) {
105
105
  throw new UnsupportedTokenizerError(message);
106
106
  }
107
- function asRecord(value, path5) {
108
- if (typeof value !== "object" || value === null || Array.isArray(value)) fail(`${path5} is not an object`);
107
+ function asRecord(value, path7) {
108
+ if (typeof value !== "object" || value === null || Array.isArray(value)) fail(`${path7} is not an object`);
109
109
  return value;
110
110
  }
111
- function asString(value, path5) {
112
- if (typeof value !== "string") fail(`${path5} is not a string`);
111
+ function asString(value, path7) {
112
+ if (typeof value !== "string") fail(`${path7} is not a string`);
113
113
  return value;
114
114
  }
115
- function asArray(value, path5) {
116
- if (!Array.isArray(value)) fail(`${path5} is not an array`);
115
+ function asArray(value, path7) {
116
+ if (!Array.isArray(value)) fail(`${path7} is not an array`);
117
117
  return value;
118
118
  }
119
- function expectValue(actual, wanted, path5) {
120
- if (actual !== wanted) fail(`${path5} is ${JSON.stringify(actual)}, expected ${JSON.stringify(wanted)}`);
119
+ function expectValue(actual, wanted, path7) {
120
+ if (actual !== wanted) fail(`${path7} is ${JSON.stringify(actual)}, expected ${JSON.stringify(wanted)}`);
121
121
  }
122
122
  function isChinese(cp) {
123
123
  return cp >= 19968 && cp <= 40959 || cp >= 13312 && cp <= 19903 || cp >= 131072 && cp <= 173791 || cp >= 173824 && cp <= 177983 || cp >= 177984 && cp <= 178207 || cp >= 178208 && cp <= 183983 || cp >= 63744 && cp <= 64255 || cp >= 194560 && cp <= 195103;
@@ -697,7 +697,25 @@ init_define_import_meta_env();
697
697
 
698
698
  // src/embed_fingerprint.ts
699
699
  init_define_import_meta_env();
700
- var EMBED_FINGERPRINT = "b7b2ff71de288d13";
700
+ var EMBED_FINGERPRINT = "09d9e67fa7a822f0";
701
+ var EMBED_KIND_FINGERPRINTS = /* @__PURE__ */ new Map([
702
+ ["docx", "cfbf232abfe8b972"],
703
+ ["markdown", "ed197b9b0c1124d9"],
704
+ ["pdf", "34e7e695b086e47b"],
705
+ ["pptx", "808203b7f6f26822"],
706
+ ["xlsx", "87d97745a0dc6b85"]
707
+ ]);
708
+ var PRE_KIND_EMBED_FINGERPRINT = "b7b2ff71de288d13";
709
+ var SPLIT_EMBED_FINGERPRINT = "2310db32d9bc8a2b";
710
+
711
+ // src/embed_stamp.ts
712
+ init_define_import_meta_env();
713
+ import * as path3 from "node:path";
714
+ function embedKindForPath(filePath) {
715
+ if (isEmbeddableDocument(filePath)) return path3.extname(filePath).toLowerCase().slice(1);
716
+ if (detectLanguage(filePath) === "markdown") return "markdown";
717
+ return null;
718
+ }
701
719
 
702
720
  // src/embeddings.ts
703
721
  var QUERY_INSTRUCTION_PREFIX = "Represent this sentence for searching relevant passages: ";
@@ -1345,7 +1363,42 @@ function resetAllEmbeddings(db, keepVectors = false) {
1345
1363
  }
1346
1364
  function embeddingProvenance(modelName = DEFAULT_MODEL) {
1347
1365
  const revision = modelName === DEFAULT_MODEL ? PINNED_MODEL_REVISION.slice(0, 12) : "unpinned";
1348
- return `${modelName}@${revision}/${backendId()}/embed-${EMBED_FINGERPRINT}`;
1366
+ const kinds = [...EMBED_KIND_FINGERPRINTS].map(([kind, digest]) => `+${kind}-${digest}`).join("");
1367
+ return `${modelName}@${revision}/${backendId()}/embed-${EMBED_FINGERPRINT}${kinds}`;
1368
+ }
1369
+ function chunkStampsOf(provenance) {
1370
+ const at = provenance.lastIndexOf("/embed-");
1371
+ const kinds = /* @__PURE__ */ new Map();
1372
+ if (at === -1) return { globalDigest: "", kinds };
1373
+ const [globalDigest = "", ...kindParts] = provenance.slice(at + "/embed-".length).split("+");
1374
+ for (const part of kindParts) {
1375
+ const dash = part.lastIndexOf("-");
1376
+ if (dash !== -1) kinds.set(part.slice(0, dash), part.slice(dash + 1));
1377
+ }
1378
+ return { globalDigest, kinds };
1379
+ }
1380
+ function resetStaleChunking(db, stored, current) {
1381
+ const before = chunkStampsOf(stored);
1382
+ const now = chunkStampsOf(current);
1383
+ if (before.kinds.size === 0 && before.globalDigest === PRE_KIND_EMBED_FINGERPRINT && now.globalDigest === SPLIT_EMBED_FINGERPRINT) return 0;
1384
+ if (before.globalDigest !== now.globalDigest) return resetAllEmbeddings(db, true);
1385
+ const changed = /* @__PURE__ */ new Set();
1386
+ for (const kind of /* @__PURE__ */ new Set([...before.kinds.keys(), ...now.kinds.keys()])) {
1387
+ if (before.kinds.get(kind) !== now.kinds.get(kind)) changed.add(kind);
1388
+ }
1389
+ return changed.size === 0 ? 0 : resetEmbeddingsForKinds(db, changed);
1390
+ }
1391
+ function resetEmbeddingsForKinds(db, kinds) {
1392
+ const paths = db.prepare("SELECT DISTINCT file_path FROM chunks").pluck().all().filter((p) => {
1393
+ const kind = embedKindForPath(p);
1394
+ return kind !== null && kinds.has(kind);
1395
+ });
1396
+ const clearEmbedSha = db.prepare(`UPDATE files SET embed_sha = NULL WHERE ${pathEqClause("path")}`);
1397
+ const tx = db.transaction(() => {
1398
+ for (const p of paths) clearEmbedSha.run(foldPath(p));
1399
+ });
1400
+ tx.immediate();
1401
+ return paths.length;
1349
1402
  }
1350
1403
  function backendId() {
1351
1404
  return `onnxruntime-node@${majorMinor(runtimeVersion())}`;
@@ -1366,7 +1419,7 @@ function ensureEmbeddingProvenance(db, modelName = DEFAULT_MODEL) {
1366
1419
  const stored = db.prepare("SELECT provenance FROM embedding_provenance WHERE id = 1").pluck().get();
1367
1420
  if (stored === current) return;
1368
1421
  const keepVectors = stored !== void 0 && vectorSpaceOf(stored) === vectorSpaceOf(current);
1369
- const cleared = resetAllEmbeddings(db, keepVectors);
1422
+ const cleared = stored !== void 0 && keepVectors ? resetStaleChunking(db, stored, current) : resetAllEmbeddings(db, false);
1370
1423
  db.prepare(
1371
1424
  "INSERT INTO embedding_provenance (id, provenance) VALUES (1, ?) ON CONFLICT(id) DO UPDATE SET provenance = excluded.provenance"
1372
1425
  ).run(current);
@@ -1411,15 +1464,151 @@ function _pathPriorityPenalty(filePath) {
1411
1464
  return 0;
1412
1465
  }
1413
1466
 
1467
+ // src/parser_stamp.ts
1468
+ init_define_import_meta_env();
1469
+
1414
1470
  // src/parser_fingerprint.ts
1415
1471
  init_define_import_meta_env();
1416
- var PARSER_FINGERPRINT = "0d80572d3abdfb19";
1472
+ var PARSER_FINGERPRINT = "50e28a938598adc3";
1473
+ var LANGUAGE_PARSER_FINGERPRINTS = /* @__PURE__ */ new Map([
1474
+ ["abap", "c27b615fd1e3d0ae"],
1475
+ ["abl", "8e8b45045f728f85"],
1476
+ ["apex", "546947e386330fa7"],
1477
+ ["asm", "8af853e890aabc4d"],
1478
+ ["bash", "7c5de1432ec76aaa"],
1479
+ ["batch", "23cd0210524383a9"],
1480
+ ["clojure", "19e80acd48cb3845"],
1481
+ ["cmake", "87ee9ef26bcb3404"],
1482
+ ["common_lisp", "61e24d550e8110cf"],
1483
+ ["csharp", "564c98ab9df034a1"],
1484
+ ["dart", "d0fa0a6695c18a75"],
1485
+ ["elixir", "7ac1b17ec1512657"],
1486
+ ["emacs_lisp", "c70f99530c1e4f75"],
1487
+ ["erlang", "65a4f827d0bfd3dc"],
1488
+ ["fortran", "2568582b68b70e7b"],
1489
+ ["fsharp", "050c93e745f27ccb"],
1490
+ ["graphql", "4c32faeccc16c581"],
1491
+ ["groovy", "ac99c133c972726a"],
1492
+ ["haskell", "0b379a28adab818c"],
1493
+ ["jcl", "304cdefba0bf1a8f"],
1494
+ ["kotlin", "e599a308cbfa4e5e"],
1495
+ ["liquid", "4eb183a9e3516a51"],
1496
+ ["lua", "0428840b251971b4"],
1497
+ ["makefile", "543fa6d789911d63"],
1498
+ ["matlab", "a5264af40b3262a7"],
1499
+ ["nix", "9bf6bdb2ded8f8fc"],
1500
+ ["objc", "41ec1e0eb7bf9008"],
1501
+ ["ocaml", "540c7a46253af516"],
1502
+ ["pascal", "da41a90998923f24"],
1503
+ ["perl", "1deb223827bcafc9"],
1504
+ ["php", "1686c9fffae2fbd2"],
1505
+ ["pli", "96a0719e3b4d45f1"],
1506
+ ["powershell", "fe3d53d563d25807"],
1507
+ ["proto", "d3759b07cb8e6ec6"],
1508
+ ["r", "e761fe84bc60a181"],
1509
+ ["racket", "07f032b125b60118"],
1510
+ ["rpg", "fbc46fd9aa1e7ed0"],
1511
+ ["salesforce_metadata", "c072823a101fc371"],
1512
+ ["sas", "2b42c5afda0f795b"],
1513
+ ["scala", "71617a1a856545fe"],
1514
+ ["scheme", "13c8c817daa4fe4b"],
1515
+ ["solidity", "376397d925ea1bf6"],
1516
+ ["sql", "ebd22cedc1ce7e09"],
1517
+ ["swift", "86645b284e98e21b"],
1518
+ ["terraform", "d188afbf616c4f2c"],
1519
+ ["thrift", "7761f38e67391431"],
1520
+ ["vb", "b63f7a33e68a2a69"],
1521
+ ["vhdl", "526c52e2a0ab75ae"],
1522
+ ["zig", "8c6199f1727a0684"]
1523
+ ]);
1524
+
1525
+ // src/parser_stamp.ts
1526
+ function parserFingerprintForLanguage(language) {
1527
+ return LANGUAGE_PARSER_FINGERPRINTS.get(language) ?? PARSER_FINGERPRINT;
1528
+ }
1417
1529
 
1418
1530
  // src/parser.ts
1419
1531
  init_define_import_meta_env();
1420
1532
  import * as fs2 from "node:fs";
1421
1533
  import { createRequire as createRequire2 } from "node:module";
1534
+ import * as path6 from "node:path";
1535
+
1536
+ // src/asset_extensions.ts
1537
+ init_define_import_meta_env();
1422
1538
  import * as path4 from "node:path";
1539
+ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
1540
+ ".png",
1541
+ ".jpg",
1542
+ ".jpeg",
1543
+ ".gif",
1544
+ ".webp",
1545
+ ".bmp",
1546
+ ".tif",
1547
+ ".tiff",
1548
+ ".avif",
1549
+ ".heic",
1550
+ ".heif"
1551
+ ]);
1552
+ function isImagePath(p) {
1553
+ return IMAGE_EXTENSIONS.has(path4.extname(p).toLowerCase());
1554
+ }
1555
+ var NON_TEXT_ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
1556
+ ...IMAGE_EXTENSIONS,
1557
+ ".ico",
1558
+ ".icns",
1559
+ ".psd",
1560
+ ".woff",
1561
+ ".woff2",
1562
+ ".ttf",
1563
+ ".otf",
1564
+ ".eot",
1565
+ ".zip",
1566
+ ".gz",
1567
+ ".tgz",
1568
+ ".bz2",
1569
+ ".xz",
1570
+ ".7z",
1571
+ ".rar",
1572
+ ".jar",
1573
+ ".mp3",
1574
+ ".wav",
1575
+ ".flac",
1576
+ ".ogg",
1577
+ ".m4a",
1578
+ ".aac",
1579
+ ".mp4",
1580
+ ".m4v",
1581
+ ".mov",
1582
+ ".avi",
1583
+ ".mkv",
1584
+ ".webm",
1585
+ ".wasm",
1586
+ ".exe",
1587
+ ".dll",
1588
+ ".so",
1589
+ ".dylib",
1590
+ ".node",
1591
+ ".class",
1592
+ ".pyc",
1593
+ ".pdb",
1594
+ ".bin",
1595
+ ".dat",
1596
+ ".db",
1597
+ ".sqlite",
1598
+ ".sqlite3"
1599
+ ]);
1600
+ function isNonTextAsset(p) {
1601
+ return NON_TEXT_ASSET_EXTENSIONS.has(path4.extname(p).toLowerCase());
1602
+ }
1603
+ var NON_TEXT_ASSET_SET_ID = (() => {
1604
+ const joined = [...NON_TEXT_ASSET_EXTENSIONS].sort().join(",");
1605
+ let h = 2166136261;
1606
+ for (let i = 0; i < joined.length; i++) {
1607
+ h ^= joined.charCodeAt(i);
1608
+ h = Math.imul(h, 16777619);
1609
+ }
1610
+ return (h >>> 0).toString(16).padStart(8, "0");
1611
+ })();
1423
1612
 
1424
1613
  // src/embedding_boundaries.ts
1425
1614
  init_define_import_meta_env();
@@ -1586,14 +1775,14 @@ function buildEmbeddingBoundaries(filePath, content, dbPath) {
1586
1775
 
1587
1776
  // src/languages/salesforce_frontend.ts
1588
1777
  init_define_import_meta_env();
1589
- import * as path3 from "node:path";
1778
+ import * as path5 from "node:path";
1590
1779
  function lines(content) {
1591
1780
  return content.split("\n");
1592
1781
  }
1593
1782
  function bundleName(filePath) {
1594
1783
  const normalized = filePath.replaceAll("\\", "/");
1595
- const parent = path3.posix.basename(path3.posix.dirname(normalized));
1596
- const base = path3.posix.basename(normalized).replace(/\.[^.]+$/, "");
1784
+ const parent = path5.posix.basename(path5.posix.dirname(normalized));
1785
+ const base = path5.posix.basename(normalized).replace(/\.[^.]+$/, "");
1597
1786
  return parent === "lwc" || parent === "aura" ? base : parent;
1598
1787
  }
1599
1788
  function lwcTagAlias(name) {
@@ -1697,7 +1886,7 @@ var MARKUP_KIND = {
1697
1886
  };
1698
1887
  function markupArtifactName(filePath, extension) {
1699
1888
  if (extension === ".page" || extension === ".component" || extension === ".email") {
1700
- return path3.posix.basename(filePath.replaceAll("\\", "/")).replace(new RegExp(`${extension.replace(".", "\\.")}$`, "i"), "");
1889
+ return path5.posix.basename(filePath.replaceAll("\\", "/")).replace(new RegExp(`${extension.replace(".", "\\.")}$`, "i"), "");
1701
1890
  }
1702
1891
  return bundleName(filePath);
1703
1892
  }
@@ -1717,7 +1906,7 @@ function attributeRefs(refs, content, filePath, attribute, split = false) {
1717
1906
  }
1718
1907
  function extractSalesforceMarkup(content, filePath) {
1719
1908
  const normalized = filePath.replaceAll("\\", "/");
1720
- const extension = path3.posix.extname(normalized).toLowerCase();
1909
+ const extension = path5.posix.extname(normalized).toLowerCase();
1721
1910
  const kind = MARKUP_KIND[extension] ?? "salesforce_markup";
1722
1911
  const symbols = [
1723
1912
  symbol(filePath, markupArtifactName(normalized, extension), kind, 1, countContentLines(content))
@@ -1933,6 +2122,41 @@ var TSJS_FN_SCOPE_TYPES = /* @__PURE__ */ new Set([
1933
2122
  "generator_function",
1934
2123
  "generator_function_declaration"
1935
2124
  ]);
2125
+ function sameNode(a, b) {
2126
+ return a !== null && b !== null && a.type === b.type && a.startPosition.row === b.startPosition.row && a.startPosition.column === b.startPosition.column && a.endPosition.row === b.endPosition.row && a.endPosition.column === b.endPosition.column;
2127
+ }
2128
+ function isIifeCallee(node) {
2129
+ let cur = node;
2130
+ let parent = cur.parent;
2131
+ while (parent !== null && parent.type === "parenthesized_expression") {
2132
+ cur = parent;
2133
+ parent = cur.parent;
2134
+ }
2135
+ if (parent === null || parent.type !== "call_expression" || !sameNode(parent.childForFieldName("function"), cur)) return false;
2136
+ let stmt = parent.parent;
2137
+ while (stmt !== null && stmt.type === "parenthesized_expression") stmt = stmt.parent;
2138
+ if (stmt !== null && stmt.type === "unary_expression" && ["!", "void", "+"].includes(stmt.childForFieldName("operator")?.text ?? "")) {
2139
+ stmt = stmt.parent;
2140
+ while (stmt !== null && stmt.type === "parenthesized_expression") stmt = stmt.parent;
2141
+ }
2142
+ return stmt !== null && stmt.type === "expression_statement";
2143
+ }
2144
+ function isModuleWrapperCallback(node) {
2145
+ const argsNode = node.parent;
2146
+ if (argsNode === null || argsNode.type !== "arguments") return false;
2147
+ const call = argsNode.parent;
2148
+ if (call === null || call.type !== "call_expression" || call.parent === null || call.parent.type !== "expression_statement") return false;
2149
+ const callee = call.childForFieldName("function");
2150
+ if (callee === null) return false;
2151
+ if (callee.type === "identifier" && (callee.text === "$" || callee.text === "define" || callee.text === "require")) return true;
2152
+ if (callee.type === "member_expression") {
2153
+ const object = callee.childForFieldName("object");
2154
+ const property = callee.childForFieldName("property");
2155
+ const first = argsNode.namedChildren[0];
2156
+ return object?.type === "identifier" && object.text === "document" && property?.text === "addEventListener" && first?.type === "string" && first.text.includes("DOMContentLoaded");
2157
+ }
2158
+ return false;
2159
+ }
1936
2160
  function extractTsJsSymbols(root, filePath, lines2) {
1937
2161
  const out = [];
1938
2162
  const visit = (node, insideFunction) => {
@@ -1996,12 +2220,6 @@ function extractTsJsSymbols(root, filePath, lines2) {
1996
2220
  out.push(makeSymbol(filePath, fieldName.text, "method", node, lines2, "c"));
1997
2221
  }
1998
2222
  }
1999
- if (node.type === "method_definition" && node.parent?.type === "object") {
2000
- const name = nodeName(node);
2001
- if (name !== null && name !== "") {
2002
- out.push(makeSymbol(filePath, name, "method", node, lines2, "c"));
2003
- }
2004
- }
2005
2223
  if (node.type === "pair" && node.parent?.type === "object") {
2006
2224
  const key = node.childForFieldName("key");
2007
2225
  const value = node.childForFieldName("value");
@@ -2018,7 +2236,9 @@ function extractTsJsSymbols(root, filePath, lines2) {
2018
2236
  }
2019
2237
  }
2020
2238
  }
2021
- const childInside = insideFunction || TSJS_FN_SCOPE_TYPES.has(node.type);
2239
+ const isAnonymousFn = node.type === "function_expression" || node.type === "arrow_function";
2240
+ const isTransparentWrapper = !insideFunction && isAnonymousFn && (isIifeCallee(node) || isModuleWrapperCallback(node));
2241
+ const childInside = insideFunction || TSJS_FN_SCOPE_TYPES.has(node.type) && !isTransparentWrapper;
2022
2242
  for (const child of node.namedChildren) {
2023
2243
  visit(child, childInside);
2024
2244
  }
@@ -3557,8 +3777,8 @@ function boundSymbolDocstring(docstring) {
3557
3777
  return docstring.slice(0, Math.max(0, end)) + DOCSTRING_TRUNCATION_MARKER;
3558
3778
  }
3559
3779
  function loadGrammar(lang, filePath, content) {
3560
- const useTsx = lang === "typescript" && filePath !== void 0 && path4.extname(filePath).toLowerCase() === ".tsx";
3561
- const useCppHeader = lang === "c" && filePath !== void 0 && path4.extname(filePath).toLowerCase() === ".h" && content !== void 0 && CPP_HEADER_SNIFF_RE.test(content);
3780
+ const useTsx = lang === "typescript" && filePath !== void 0 && path6.extname(filePath).toLowerCase() === ".tsx";
3781
+ const useCppHeader = lang === "c" && filePath !== void 0 && path6.extname(filePath).toLowerCase() === ".h" && content !== void 0 && CPP_HEADER_SNIFF_RE.test(content);
3562
3782
  const cacheKey = useTsx ? "typescript:tsx" : useCppHeader ? "c:cpp-header" : lang;
3563
3783
  const cached = _grammarCache.get(cacheKey);
3564
3784
  if (cached !== void 0) return cached;
@@ -3694,7 +3914,7 @@ function parseSourceSymbolsTreeSitterOnly(content, filePath, language) {
3694
3914
  var REGEX_ADAPTERS_SLOT = /* @__PURE__ */ Symbol.for("token-goat.regex-adapters");
3695
3915
  var adapterSlot = globalThis;
3696
3916
  async function loadRegexExtractors() {
3697
- adapterSlot[REGEX_ADAPTERS_SLOT] ??= await import("./token-goat-chunk-GPCCYQSS.mjs");
3917
+ adapterSlot[REGEX_ADAPTERS_SLOT] ??= await import("./token-goat-chunk-AVRD7SBO.mjs");
3698
3918
  }
3699
3919
  function regexAdapters() {
3700
3920
  const loaded = adapterSlot[REGEX_ADAPTERS_SLOT];
@@ -3756,7 +3976,7 @@ function isUnderSkipDir(filePath, skipDirs) {
3756
3976
  }
3757
3977
  function isParseSkipEligible(filePath, cfg) {
3758
3978
  if (isUnderSkipDir(filePath, cfg.skip_dirs)) return true;
3759
- if (cfg.skip_files.includes(path4.basename(filePath))) return true;
3979
+ if (cfg.skip_files.includes(path6.basename(filePath))) return true;
3760
3980
  try {
3761
3981
  const stat = fs2.statSync(filePath);
3762
3982
  if (stat.size > cfg.large_file_skip_kb * 1024) return true;
@@ -3764,18 +3984,30 @@ function isParseSkipEligible(filePath, cfg) {
3764
3984
  }
3765
3985
  return false;
3766
3986
  }
3987
+ function boundarySpanKey(spans) {
3988
+ return spans.map((s) => `${s.start}-${s.end}`).sort().join(",");
3989
+ }
3990
+ function embeddingBoundariesMoved(db, filePath, result) {
3991
+ const priorSpans = db.prepare(`SELECT line_start, line_end FROM symbols WHERE ${pathEqClause("file_path")}`).all(foldPath(filePath));
3992
+ const prior = boundarySpanKey(priorSpans.map((r) => ({ start: r.line_start, end: r.line_end })));
3993
+ const next = boundarySpanKey(
3994
+ result.symbols.filter((s) => s.name !== "" && s.kind !== "").map((s) => ({ start: s.lineStart, end: s.lineEnd }))
3995
+ );
3996
+ return prior !== next;
3997
+ }
3767
3998
  function writeParseResult(filePath, content, result, dbPath) {
3768
3999
  const db = getDb(dbPath);
3769
4000
  const sha = fingerprintContent(content);
3770
4001
  const mtime = safeMtime(filePath);
3771
4002
  const now = Date.now() / 1e3;
3772
4003
  const priorRow = db.prepare(`SELECT sha, embed_sha FROM files WHERE ${pathEqClause("path")}`).get(foldPath(filePath));
3773
- const embedShaToCarry = priorRow !== void 0 && priorRow.sha === sha ? priorRow.embed_sha : null;
4004
+ const carriedEmbedSha = priorRow !== void 0 && priorRow.sha === sha ? priorRow.embed_sha : null;
4005
+ const embedShaToCarry = carriedEmbedSha !== null && carriedEmbedSha === sha && detectLanguage(filePath) !== "markdown" && embeddingBoundariesMoved(db, filePath, result) ? null : carriedEmbedSha;
3774
4006
  const writeAll = db.transaction(() => {
3775
4007
  deleteFileRows(db, filePath);
3776
4008
  db.prepare(
3777
4009
  "INSERT INTO files (path, sha, mtime, language, indexed_at, parser_sha, embed_sha) VALUES (?, ?, ?, ?, ?, ?, ?)"
3778
- ).run(filePath, sha, mtime, result.language, now, PARSER_FINGERPRINT, embedShaToCarry);
4010
+ ).run(filePath, sha, mtime, result.language, now, parserFingerprintForLanguage(result.language), embedShaToCarry);
3779
4011
  const insSym = db.prepare(
3780
4012
  "INSERT INTO symbols (file_path, name, kind, line_start, line_end, body, docstring, parent) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
3781
4013
  );
@@ -3844,7 +4076,16 @@ var TIMEOUT_EMBED_SHA_PREFIX = "timeout:";
3844
4076
  function timeoutEmbedSha(sha, workMillis) {
3845
4077
  return `${TIMEOUT_EMBED_SHA_PREFIX}${workMillis}:${sha}`;
3846
4078
  }
3847
- function canonicalizeIndexPath(absPath) {
4079
+ var ASSET_EMBED_SHA_PREFIX = "asset:";
4080
+ function assetEmbedSha(sha) {
4081
+ return `${ASSET_EMBED_SHA_PREFIX}${NON_TEXT_ASSET_SET_ID}:${sha}`;
4082
+ }
4083
+ var MAX_CHUNKS_EMBED_SHA_PREFIX = "maxchunks:";
4084
+ function maxChunksEmbedSha(sha, maxChunks) {
4085
+ return `${MAX_CHUNKS_EMBED_SHA_PREFIX}${maxChunks}:${sha}`;
4086
+ }
4087
+ function canonicalizeIndexPath(rawPath) {
4088
+ const absPath = normalizePath(rawPath);
3848
4089
  if (!isCaseInsensitiveFs()) return absPath;
3849
4090
  let real;
3850
4091
  try {
@@ -3855,17 +4096,17 @@ function canonicalizeIndexPath(absPath) {
3855
4096
  const cut = Math.max(absPath.lastIndexOf("/"), absPath.lastIndexOf("\\"));
3856
4097
  const base = absPath.slice(cut + 1);
3857
4098
  const realNorm = normalizePath(real);
3858
- const realBase = path4.basename(realNorm);
4099
+ const realBase = path6.basename(realNorm);
3859
4100
  if (base === realBase) return absPath;
3860
4101
  if (foldPath(base) !== foldPath(realBase)) return absPath;
3861
- const callerDir = cut < 0 ? normalizePath(path4.resolve(".")) : normalizePath(absPath.slice(0, cut));
3862
- if (foldPath(callerDir) !== foldPath(path4.dirname(realNorm))) return absPath;
4102
+ const callerDir = cut < 0 ? normalizePath(path6.resolve(".")) : normalizePath(absPath.slice(0, cut));
4103
+ if (foldPath(callerDir) !== foldPath(path6.dirname(realNorm))) return absPath;
3863
4104
  return absPath.slice(0, cut + 1) + realBase;
3864
4105
  }
3865
4106
  function indexedPathSpellingIsStale(storedPath, absPath) {
3866
4107
  if (!isCaseInsensitiveFs()) return false;
3867
4108
  const stored = normalizePath(storedPath);
3868
- const candidate = normalizePath(path4.resolve(absPath));
4109
+ const candidate = normalizePath(path6.resolve(absPath));
3869
4110
  if (foldPath(stored) !== foldPath(candidate)) return false;
3870
4111
  let real;
3871
4112
  try {
@@ -3891,12 +4132,14 @@ function indexedPathSpellingIsStale(storedPath, absPath) {
3891
4132
  }
3892
4133
  return false;
3893
4134
  }
3894
- function isEmbedFresh(storedEmbedSha, sha, embeddingsEnabled, depsAvailable, symbolOnlyKb) {
4135
+ function isEmbedFresh(storedEmbedSha, sha, embeddingsEnabled, depsAvailable, symbolOnlyKb, maxChunksPerFile = 0) {
3895
4136
  if (storedEmbedSha === void 0) return false;
3896
4137
  if (!embeddingsEnabled) return storedEmbedSha === disabledEmbedSha(sha);
3897
4138
  if (storedEmbedSha === sha) return true;
3898
4139
  if (!depsAvailable && storedEmbedSha === unavailableEmbedSha(sha)) return true;
3899
4140
  if (storedEmbedSha === oversizeEmbedSha(sha, symbolOnlyKb)) return true;
4141
+ if (maxChunksPerFile > 0 && storedEmbedSha === maxChunksEmbedSha(sha, maxChunksPerFile)) return true;
4142
+ if (storedEmbedSha === assetEmbedSha(sha)) return true;
3900
4143
  if (storedEmbedSha === timeoutEmbedSha(sha, MAX_DOCUMENT_WORK_MILLIS)) return true;
3901
4144
  return false;
3902
4145
  }
@@ -3913,6 +4156,12 @@ async function indexFileEmbeddings(rawPath, dbPath = globalDbPath(), sha, onErro
3913
4156
  stampEmbedSha(db, filePath, sha, (s) => s);
3914
4157
  return;
3915
4158
  }
4159
+ if (isNonTextAsset(filePath)) {
4160
+ const db = getDb(dbPath);
4161
+ deleteFileEmbeddings(db, filePath);
4162
+ stampEmbedSha(db, filePath, sha, assetEmbedSha);
4163
+ return;
4164
+ }
3916
4165
  if (isEmbeddableDocument(filePath)) {
3917
4166
  let extracted;
3918
4167
  let refusedOnTheClock = false;
@@ -3976,9 +4225,16 @@ async function indexFileEmbeddings(rawPath, dbPath = globalDbPath(), sha, onErro
3976
4225
  stampEmbedSha(db, filePath, sha, (s) => s);
3977
4226
  return;
3978
4227
  }
4228
+ const boundaries = buildEmbeddingBoundaries(filePath, content, dbPath);
4229
+ const chunkCount = chunkFile(filePath, content, void 0, void 0, boundaries).length;
4230
+ if (chunkCount > ixCfg.max_chunks_per_file) {
4231
+ const db = getDb(dbPath);
4232
+ deleteFileEmbeddings(db, filePath);
4233
+ stampEmbedSha(db, filePath, sha, (s) => maxChunksEmbedSha(s, ixCfg.max_chunks_per_file));
4234
+ return;
4235
+ }
3979
4236
  try {
3980
4237
  const db = getDb(dbPath);
3981
- const boundaries = buildEmbeddingBoundaries(filePath, content, dbPath);
3982
4238
  const outcome = await indexFile(db, filePath, content, boundaries);
3983
4239
  stampEmbedSha(db, filePath, sha, (s) => outcome === "unavailable" ? unavailableEmbedSha(s) : s);
3984
4240
  } catch (err) {
@@ -4530,6 +4786,8 @@ export {
4530
4786
  isEmbeddableDocument,
4531
4787
  ipynbToVirtualSource,
4532
4788
  eachUnfencedLine,
4789
+ isImagePath,
4790
+ isNonTextAsset,
4533
4791
  modelFilesPresent,
4534
4792
  ensureModelFiles,
4535
4793
  checkEmbeddingPreflight,
@@ -4548,7 +4806,7 @@ export {
4548
4806
  formatHeadingTreeParts,
4549
4807
  getWellKnownSections,
4550
4808
  extractChangelogVersionHint,
4551
- PARSER_FINGERPRINT,
4809
+ parserFingerprintForLanguage,
4552
4810
  treeSitterCoreAvailable,
4553
4811
  treeSitterCoreLoadError,
4554
4812
  isTreeSitterAvailable,
@@ -5,12 +5,12 @@ import {
5
5
  docxTables,
6
6
  docxText,
7
7
  formatDocxTables
8
- } from "./token-goat-chunk-CPHVXKNU.mjs";
9
- import "./token-goat-chunk-66224KCZ.mjs";
8
+ } from "./token-goat-chunk-DHIXE6GV.mjs";
9
+ import "./token-goat-chunk-BTKDZW7F.mjs";
10
10
  import "./token-goat-chunk-XTQAOTSO.mjs";
11
11
  import "./token-goat-chunk-AH6QILZM.mjs";
12
- import "./token-goat-chunk-UBZCON6N.mjs";
13
- import "./token-goat-chunk-ERTXEKB6.mjs";
12
+ import "./token-goat-chunk-ZGQXRYKE.mjs";
13
+ import "./token-goat-chunk-NMTKNYGF.mjs";
14
14
  import "./token-goat-chunk-Y4AFKTHK.mjs";
15
15
  import "./token-goat-chunk-GMOUBOX4.mjs";
16
16
  import "./token-goat-chunk-A37V4PBF.mjs";
@@ -5,14 +5,14 @@ import {
5
5
  isSupportedOcrLang,
6
6
  loadConfig,
7
7
  resolveOcrLangs
8
- } from "./token-goat-chunk-2VASS5VR.mjs";
8
+ } from "./token-goat-chunk-SOKAPOOC.mjs";
9
9
  import {
10
10
  ensureDirSync,
11
11
  tokenGoatHome
12
- } from "./token-goat-chunk-UBZCON6N.mjs";
12
+ } from "./token-goat-chunk-ZGQXRYKE.mjs";
13
13
  import {
14
14
  fenceUntrustedOcrText
15
- } from "./token-goat-chunk-ERTXEKB6.mjs";
15
+ } from "./token-goat-chunk-NMTKNYGF.mjs";
16
16
  import {
17
17
  init_define_import_meta_env
18
18
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -3,7 +3,7 @@ const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  queryCsv,
5
5
  quoteCsvCell
6
- } from "./token-goat-chunk-KZPO4DWC.mjs";
6
+ } from "./token-goat-chunk-KWM6KBPA.mjs";
7
7
  import {
8
8
  NotAnOfficeDocumentError,
9
9
  assertOoxmlWithinDeadline,
@@ -12,10 +12,10 @@ import {
12
12
  ooxmlWorkDeadline,
13
13
  parseOoxmlPart,
14
14
  readOoxmlZip
15
- } from "./token-goat-chunk-66224KCZ.mjs";
15
+ } from "./token-goat-chunk-BTKDZW7F.mjs";
16
16
  import {
17
17
  displaySafeText
18
- } from "./token-goat-chunk-ERTXEKB6.mjs";
18
+ } from "./token-goat-chunk-NMTKNYGF.mjs";
19
19
  import {
20
20
  DocumentRefusedError
21
21
  } from "./token-goat-chunk-Y4AFKTHK.mjs";