token-goat 2.9.18 → 2.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/token-goat-chunk-2CLWWRFR.mjs +26 -0
- package/dist/{token-goat-chunk-LTYWLKAG.mjs → token-goat-chunk-2Q3N5KUQ.mjs} +1283 -1012
- package/dist/{token-goat-chunk-6LGVCCMY.mjs → token-goat-chunk-3OGZOFLS.mjs} +26 -16
- package/dist/{token-goat-chunk-QML7ITHJ.mjs → token-goat-chunk-3VTJC7KU.mjs} +693 -438
- package/dist/{token-goat-chunk-QIDLJGXZ.mjs → token-goat-chunk-6LJNM4ZZ.mjs} +29 -5
- package/dist/{token-goat-chunk-CA6V36KW.mjs → token-goat-chunk-74ADIZZX.mjs} +68 -50
- package/dist/{token-goat-chunk-52IMXJ2L.mjs → token-goat-chunk-ASTBLE2R.mjs} +4 -4
- package/dist/token-goat-chunk-AU2K2QHR.mjs +20 -0
- package/dist/token-goat-chunk-BQIC3AVL.mjs +292 -0
- package/dist/token-goat-chunk-CBXLE54Q.mjs +30 -0
- package/dist/{token-goat-chunk-LMFO66YD.mjs → token-goat-chunk-DA43OE7L.mjs} +1 -1
- package/dist/{token-goat-chunk-ARNRFR6M.mjs → token-goat-chunk-DNAF26L4.mjs} +1 -1
- package/dist/{token-goat-chunk-BFEWOMA3.mjs → token-goat-chunk-DPHJU3P7.mjs} +1186 -4573
- package/dist/{token-goat-chunk-OWSJJY5R.mjs → token-goat-chunk-DW4VKU7D.mjs} +5 -5
- package/dist/token-goat-chunk-DYUBZZNP.mjs +198 -0
- package/dist/{token-goat-chunk-W3E65QOW.mjs → token-goat-chunk-ERGHDBC6.mjs} +310 -47
- package/dist/token-goat-chunk-EUZKG7ZO.mjs +304 -0
- package/dist/{token-goat-chunk-5MMJAJF3.mjs → token-goat-chunk-FWYZVS3E.mjs} +324 -31
- package/dist/token-goat-chunk-G6SYQQO7.mjs +41 -0
- package/dist/{token-goat-chunk-YQZE5NS6.mjs → token-goat-chunk-GIPMOGOI.mjs} +6 -6
- package/dist/{token-goat-chunk-BWCRC23L.mjs → token-goat-chunk-H4VC5TR6.mjs} +29 -20
- package/dist/{token-goat-chunk-V3ZWBEHM.mjs → token-goat-chunk-I5PQRHFE.mjs} +103 -24
- package/dist/token-goat-chunk-ITWYDOKP.mjs +341 -0
- package/dist/{token-goat-chunk-I67CPTDD.mjs → token-goat-chunk-K3ZNBN4U.mjs} +19 -14
- package/dist/{token-goat-chunk-HPOFR6QX.mjs → token-goat-chunk-K5XPIUVB.mjs} +222 -61
- package/dist/token-goat-chunk-KT75DZK4.mjs +1989 -0
- package/dist/{token-goat-chunk-H3FONFBO.mjs → token-goat-chunk-MNJWG2ZO.mjs} +3 -3
- package/dist/{token-goat-chunk-GRI6HWX3.mjs → token-goat-chunk-MUJV7BR3.mjs} +1 -1
- package/dist/{token-goat-chunk-ERTXEKB6.mjs → token-goat-chunk-NMTKNYGF.mjs} +2 -0
- package/dist/{token-goat-chunk-LA3O4JGD.mjs → token-goat-chunk-ODF7H7WS.mjs} +3 -3
- package/dist/{token-goat-chunk-K4DG6EEF.mjs → token-goat-chunk-ONMU7BON.mjs} +7 -8
- package/dist/{token-goat-chunk-4EXFN2AW.mjs → token-goat-chunk-OZRSREKR.mjs} +2 -2
- package/dist/{token-goat-chunk-EPXNOKIV.mjs → token-goat-chunk-P4XBHZXU.mjs} +2 -2
- package/dist/{token-goat-chunk-CTOYJ232.mjs → token-goat-chunk-PAVWB4L4.mjs} +173 -1840
- package/dist/{token-goat-chunk-UENEL6KX.mjs → token-goat-chunk-PTW22MRC.mjs} +2 -2
- package/dist/token-goat-chunk-SL454EN5.mjs +1816 -0
- package/dist/token-goat-chunk-SP5QR2HN.mjs +1379 -0
- package/dist/{token-goat-chunk-7VLWNQDQ.mjs → token-goat-chunk-T46UKRFM.mjs} +1 -1
- package/dist/{token-goat-chunk-L7VCX33I.mjs → token-goat-chunk-T63VHOL3.mjs} +40 -10
- package/dist/token-goat-chunk-VSJGPEBB.mjs +248 -0
- package/dist/{token-goat-chunk-HIZXQVNU.mjs → token-goat-chunk-VYXGHGUY.mjs} +4 -4
- package/dist/token-goat-chunk-W6QYCWAT.mjs +128 -0
- package/dist/{token-goat-chunk-WFX2V3OF.mjs → token-goat-chunk-Z4ALQADF.mjs} +579 -422
- package/dist/token-goat-chunk-ZHFM4DHJ.mjs +324 -0
- package/dist/token-goat-hook.mjs +18 -12
- package/dist/token-goat.core.mjs +29 -20
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +15 -13
- package/docs/install.md +1 -1
- package/docs/security.md +2 -2
- package/package.json +3 -2
- package/dist/token-goat-chunk-2KTZ6J7T.mjs +0 -173
- package/dist/token-goat-chunk-34OUJ2IE.mjs +0 -35
- package/dist/token-goat-chunk-RHHFEXKF.mjs +0 -93
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
pathEqClause,
|
|
5
5
|
projectScopeClause,
|
|
6
6
|
querySymbols
|
|
7
|
-
} from "./token-goat-chunk-
|
|
7
|
+
} from "./token-goat-chunk-K3ZNBN4U.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-
|
|
24
|
+
} from "./token-goat-chunk-T63VHOL3.mjs";
|
|
25
25
|
import {
|
|
26
26
|
fingerprintContent,
|
|
27
27
|
loadConfig
|
|
28
|
-
} from "./token-goat-chunk-
|
|
28
|
+
} from "./token-goat-chunk-74ADIZZX.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-
|
|
42
|
+
} from "./token-goat-chunk-6LJNM4ZZ.mjs";
|
|
43
43
|
import {
|
|
44
44
|
displaySafeText,
|
|
45
45
|
normalizePath
|
|
46
|
-
} from "./token-goat-chunk-
|
|
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-
|
|
77
|
+
return await (await import("./token-goat-chunk-VYXGHGUY.mjs")).docxText(filePath);
|
|
78
78
|
case ".pptx":
|
|
79
|
-
return await (await import("./token-goat-chunk-
|
|
79
|
+
return await (await import("./token-goat-chunk-ASTBLE2R.mjs")).pptxAllSlidesText(filePath, true);
|
|
80
80
|
case ".xlsx":
|
|
81
|
-
return await (await import("./token-goat-chunk-
|
|
81
|
+
return await (await import("./token-goat-chunk-DW4VKU7D.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,
|
|
108
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) fail(`${
|
|
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,
|
|
112
|
-
if (typeof value !== "string") fail(`${
|
|
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,
|
|
116
|
-
if (!Array.isArray(value)) fail(`${
|
|
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,
|
|
120
|
-
if (actual !== wanted) fail(`${
|
|
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;
|
|
@@ -309,7 +309,7 @@ var BertWordPiece = class _BertWordPiece {
|
|
|
309
309
|
var _require = createRequire(import.meta.url);
|
|
310
310
|
var DEFAULT_MODEL = "Xenova/bge-small-en-v1.5";
|
|
311
311
|
var DEFAULT_DIM = 384;
|
|
312
|
-
var DEFAULT_EMBED_THREADS =
|
|
312
|
+
var DEFAULT_EMBED_THREADS = 4;
|
|
313
313
|
var PINNED_MODEL_REVISION = "ea104dacec62c0de699686887e3f920caeb4f3e3";
|
|
314
314
|
var MODEL_FILES = [
|
|
315
315
|
{
|
|
@@ -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 = "
|
|
700
|
+
var EMBED_FINGERPRINT = "702c126bffd8439e";
|
|
701
|
+
var EMBED_KIND_FINGERPRINTS = /* @__PURE__ */ new Map([
|
|
702
|
+
["docx", "a39e82e795d46ed1"],
|
|
703
|
+
["markdown", "c65dd62705244608"],
|
|
704
|
+
["pdf", "9a0ea76d66dfd358"],
|
|
705
|
+
["pptx", "b60b30cb38a801e2"],
|
|
706
|
+
["xlsx", "e5b358c460b6507f"]
|
|
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
|
-
|
|
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,
|
|
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,154 @@ 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 = "
|
|
1472
|
+
var PARSER_FINGERPRINT = "486e443a693e6cdc";
|
|
1473
|
+
var LANGUAGE_PARSER_FINGERPRINTS = /* @__PURE__ */ new Map([
|
|
1474
|
+
["abap", "3477b349e26ff486"],
|
|
1475
|
+
["abl", "e79dac17ec1be23e"],
|
|
1476
|
+
["apache", "d6aa0ead3f7d8936"],
|
|
1477
|
+
["apex", "140d8f5601f95126"],
|
|
1478
|
+
["asm", "3e9aa7923f56286d"],
|
|
1479
|
+
["bash", "5906a50cadf9dc24"],
|
|
1480
|
+
["batch", "01e9923196d3d66b"],
|
|
1481
|
+
["caddy", "6aa41b340b3acb36"],
|
|
1482
|
+
["clojure", "bc2547b735ff453b"],
|
|
1483
|
+
["cmake", "c30e973a5b0b9628"],
|
|
1484
|
+
["common_lisp", "74c3d80a715b7507"],
|
|
1485
|
+
["csharp", "f5f7307d4575fc32"],
|
|
1486
|
+
["dart", "6657a5eeb20b7b2c"],
|
|
1487
|
+
["elixir", "88c5ce992a32ad21"],
|
|
1488
|
+
["emacs_lisp", "b3d8e903be32f3bd"],
|
|
1489
|
+
["erlang", "2bc6ed62806ffc74"],
|
|
1490
|
+
["fortran", "56658a0f6d3d9a27"],
|
|
1491
|
+
["fsharp", "df4c61b50c49aabe"],
|
|
1492
|
+
["graphql", "f4a0c9155c9649ee"],
|
|
1493
|
+
["groovy", "b3facf1b9460df44"],
|
|
1494
|
+
["haskell", "75f0794252047696"],
|
|
1495
|
+
["jcl", "06199551a218e69d"],
|
|
1496
|
+
["kotlin", "a99a84e9ae3a1362"],
|
|
1497
|
+
["liquid", "387d4f7973ef74dd"],
|
|
1498
|
+
["lua", "3a36b15e74558aa0"],
|
|
1499
|
+
["makefile", "dd470fdea2050de2"],
|
|
1500
|
+
["matlab", "65bccffd6a80ddd0"],
|
|
1501
|
+
["nginx", "0c24489a62c74032"],
|
|
1502
|
+
["nix", "7a261153f741c56b"],
|
|
1503
|
+
["objc", "e85cfa09f698e42a"],
|
|
1504
|
+
["ocaml", "643e216c28a48324"],
|
|
1505
|
+
["pascal", "4e4ae4aa127e7c4e"],
|
|
1506
|
+
["perl", "12dff36e9dab0700"],
|
|
1507
|
+
["php", "6b56ace5008da841"],
|
|
1508
|
+
["pli", "46626c331cc8c5ed"],
|
|
1509
|
+
["powershell", "e460d7974d112d63"],
|
|
1510
|
+
["proto", "a721e303a321bc4c"],
|
|
1511
|
+
["r", "7d52c82fe21bc414"],
|
|
1512
|
+
["racket", "d039be035fd8dcb1"],
|
|
1513
|
+
["rpg", "003b932e718fd3ec"],
|
|
1514
|
+
["salesforce_metadata", "0d2d649f0825c2b4"],
|
|
1515
|
+
["sas", "5a5518274e5bf88d"],
|
|
1516
|
+
["scala", "580d772168d7ec04"],
|
|
1517
|
+
["scheme", "9008af85ddce7593"],
|
|
1518
|
+
["solidity", "13e09d7acfc45176"],
|
|
1519
|
+
["sql", "e7a658d83f5ed705"],
|
|
1520
|
+
["swift", "bf3fbf0617f7dafd"],
|
|
1521
|
+
["terraform", "bb7ba075971caf67"],
|
|
1522
|
+
["thrift", "d39f3c5a82bb5b0b"],
|
|
1523
|
+
["vb", "4ddc4f794b061bfe"],
|
|
1524
|
+
["vhdl", "6d9e0f47264942fb"],
|
|
1525
|
+
["zig", "94d64036a1ad42b0"]
|
|
1526
|
+
]);
|
|
1527
|
+
|
|
1528
|
+
// src/parser_stamp.ts
|
|
1529
|
+
function parserFingerprintForLanguage(language) {
|
|
1530
|
+
return LANGUAGE_PARSER_FINGERPRINTS.get(language) ?? PARSER_FINGERPRINT;
|
|
1531
|
+
}
|
|
1417
1532
|
|
|
1418
1533
|
// src/parser.ts
|
|
1419
1534
|
init_define_import_meta_env();
|
|
1420
1535
|
import * as fs2 from "node:fs";
|
|
1421
1536
|
import { createRequire as createRequire2 } from "node:module";
|
|
1537
|
+
import * as path6 from "node:path";
|
|
1538
|
+
|
|
1539
|
+
// src/asset_extensions.ts
|
|
1540
|
+
init_define_import_meta_env();
|
|
1422
1541
|
import * as path4 from "node:path";
|
|
1542
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1543
|
+
".png",
|
|
1544
|
+
".jpg",
|
|
1545
|
+
".jpeg",
|
|
1546
|
+
".gif",
|
|
1547
|
+
".webp",
|
|
1548
|
+
".bmp",
|
|
1549
|
+
".tif",
|
|
1550
|
+
".tiff",
|
|
1551
|
+
".avif",
|
|
1552
|
+
".heic",
|
|
1553
|
+
".heif"
|
|
1554
|
+
]);
|
|
1555
|
+
function isImagePath(p) {
|
|
1556
|
+
return IMAGE_EXTENSIONS.has(path4.extname(p).toLowerCase());
|
|
1557
|
+
}
|
|
1558
|
+
var NON_TEXT_ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1559
|
+
...IMAGE_EXTENSIONS,
|
|
1560
|
+
".ico",
|
|
1561
|
+
".icns",
|
|
1562
|
+
".psd",
|
|
1563
|
+
".woff",
|
|
1564
|
+
".woff2",
|
|
1565
|
+
".ttf",
|
|
1566
|
+
".otf",
|
|
1567
|
+
".eot",
|
|
1568
|
+
".zip",
|
|
1569
|
+
".gz",
|
|
1570
|
+
".tgz",
|
|
1571
|
+
".bz2",
|
|
1572
|
+
".xz",
|
|
1573
|
+
".7z",
|
|
1574
|
+
".rar",
|
|
1575
|
+
".jar",
|
|
1576
|
+
".mp3",
|
|
1577
|
+
".wav",
|
|
1578
|
+
".flac",
|
|
1579
|
+
".ogg",
|
|
1580
|
+
".m4a",
|
|
1581
|
+
".aac",
|
|
1582
|
+
".mp4",
|
|
1583
|
+
".m4v",
|
|
1584
|
+
".mov",
|
|
1585
|
+
".avi",
|
|
1586
|
+
".mkv",
|
|
1587
|
+
".webm",
|
|
1588
|
+
".wasm",
|
|
1589
|
+
".exe",
|
|
1590
|
+
".dll",
|
|
1591
|
+
".so",
|
|
1592
|
+
".dylib",
|
|
1593
|
+
".node",
|
|
1594
|
+
".class",
|
|
1595
|
+
".pyc",
|
|
1596
|
+
".pdb",
|
|
1597
|
+
".bin",
|
|
1598
|
+
".dat",
|
|
1599
|
+
".db",
|
|
1600
|
+
".sqlite",
|
|
1601
|
+
".sqlite3"
|
|
1602
|
+
]);
|
|
1603
|
+
function isNonTextAsset(p) {
|
|
1604
|
+
return NON_TEXT_ASSET_EXTENSIONS.has(path4.extname(p).toLowerCase());
|
|
1605
|
+
}
|
|
1606
|
+
var NON_TEXT_ASSET_SET_ID = (() => {
|
|
1607
|
+
const joined = [...NON_TEXT_ASSET_EXTENSIONS].sort().join(",");
|
|
1608
|
+
let h = 2166136261;
|
|
1609
|
+
for (let i = 0; i < joined.length; i++) {
|
|
1610
|
+
h ^= joined.charCodeAt(i);
|
|
1611
|
+
h = Math.imul(h, 16777619);
|
|
1612
|
+
}
|
|
1613
|
+
return (h >>> 0).toString(16).padStart(8, "0");
|
|
1614
|
+
})();
|
|
1423
1615
|
|
|
1424
1616
|
// src/embedding_boundaries.ts
|
|
1425
1617
|
init_define_import_meta_env();
|
|
@@ -1586,14 +1778,14 @@ function buildEmbeddingBoundaries(filePath, content, dbPath) {
|
|
|
1586
1778
|
|
|
1587
1779
|
// src/languages/salesforce_frontend.ts
|
|
1588
1780
|
init_define_import_meta_env();
|
|
1589
|
-
import * as
|
|
1781
|
+
import * as path5 from "node:path";
|
|
1590
1782
|
function lines(content) {
|
|
1591
1783
|
return content.split("\n");
|
|
1592
1784
|
}
|
|
1593
1785
|
function bundleName(filePath) {
|
|
1594
1786
|
const normalized = filePath.replaceAll("\\", "/");
|
|
1595
|
-
const parent =
|
|
1596
|
-
const base =
|
|
1787
|
+
const parent = path5.posix.basename(path5.posix.dirname(normalized));
|
|
1788
|
+
const base = path5.posix.basename(normalized).replace(/\.[^.]+$/, "");
|
|
1597
1789
|
return parent === "lwc" || parent === "aura" ? base : parent;
|
|
1598
1790
|
}
|
|
1599
1791
|
function lwcTagAlias(name) {
|
|
@@ -1697,7 +1889,7 @@ var MARKUP_KIND = {
|
|
|
1697
1889
|
};
|
|
1698
1890
|
function markupArtifactName(filePath, extension) {
|
|
1699
1891
|
if (extension === ".page" || extension === ".component" || extension === ".email") {
|
|
1700
|
-
return
|
|
1892
|
+
return path5.posix.basename(filePath.replaceAll("\\", "/")).replace(new RegExp(`${extension.replace(".", "\\.")}$`, "i"), "");
|
|
1701
1893
|
}
|
|
1702
1894
|
return bundleName(filePath);
|
|
1703
1895
|
}
|
|
@@ -1717,7 +1909,7 @@ function attributeRefs(refs, content, filePath, attribute, split = false) {
|
|
|
1717
1909
|
}
|
|
1718
1910
|
function extractSalesforceMarkup(content, filePath) {
|
|
1719
1911
|
const normalized = filePath.replaceAll("\\", "/");
|
|
1720
|
-
const extension =
|
|
1912
|
+
const extension = path5.posix.extname(normalized).toLowerCase();
|
|
1721
1913
|
const kind = MARKUP_KIND[extension] ?? "salesforce_markup";
|
|
1722
1914
|
const symbols = [
|
|
1723
1915
|
symbol(filePath, markupArtifactName(normalized, extension), kind, 1, countContentLines(content))
|
|
@@ -1933,6 +2125,41 @@ var TSJS_FN_SCOPE_TYPES = /* @__PURE__ */ new Set([
|
|
|
1933
2125
|
"generator_function",
|
|
1934
2126
|
"generator_function_declaration"
|
|
1935
2127
|
]);
|
|
2128
|
+
function sameNode(a, b) {
|
|
2129
|
+
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;
|
|
2130
|
+
}
|
|
2131
|
+
function isIifeCallee(node) {
|
|
2132
|
+
let cur = node;
|
|
2133
|
+
let parent = cur.parent;
|
|
2134
|
+
while (parent !== null && parent.type === "parenthesized_expression") {
|
|
2135
|
+
cur = parent;
|
|
2136
|
+
parent = cur.parent;
|
|
2137
|
+
}
|
|
2138
|
+
if (parent === null || parent.type !== "call_expression" || !sameNode(parent.childForFieldName("function"), cur)) return false;
|
|
2139
|
+
let stmt = parent.parent;
|
|
2140
|
+
while (stmt !== null && stmt.type === "parenthesized_expression") stmt = stmt.parent;
|
|
2141
|
+
if (stmt !== null && stmt.type === "unary_expression" && ["!", "void", "+"].includes(stmt.childForFieldName("operator")?.text ?? "")) {
|
|
2142
|
+
stmt = stmt.parent;
|
|
2143
|
+
while (stmt !== null && stmt.type === "parenthesized_expression") stmt = stmt.parent;
|
|
2144
|
+
}
|
|
2145
|
+
return stmt !== null && stmt.type === "expression_statement";
|
|
2146
|
+
}
|
|
2147
|
+
function isModuleWrapperCallback(node) {
|
|
2148
|
+
const argsNode = node.parent;
|
|
2149
|
+
if (argsNode === null || argsNode.type !== "arguments") return false;
|
|
2150
|
+
const call = argsNode.parent;
|
|
2151
|
+
if (call === null || call.type !== "call_expression" || call.parent === null || call.parent.type !== "expression_statement") return false;
|
|
2152
|
+
const callee = call.childForFieldName("function");
|
|
2153
|
+
if (callee === null) return false;
|
|
2154
|
+
if (callee.type === "identifier" && (callee.text === "$" || callee.text === "define" || callee.text === "require")) return true;
|
|
2155
|
+
if (callee.type === "member_expression") {
|
|
2156
|
+
const object = callee.childForFieldName("object");
|
|
2157
|
+
const property = callee.childForFieldName("property");
|
|
2158
|
+
const first = argsNode.namedChildren[0];
|
|
2159
|
+
return object?.type === "identifier" && object.text === "document" && property?.text === "addEventListener" && first?.type === "string" && first.text.includes("DOMContentLoaded");
|
|
2160
|
+
}
|
|
2161
|
+
return false;
|
|
2162
|
+
}
|
|
1936
2163
|
function extractTsJsSymbols(root, filePath, lines2) {
|
|
1937
2164
|
const out = [];
|
|
1938
2165
|
const visit = (node, insideFunction) => {
|
|
@@ -1996,12 +2223,6 @@ function extractTsJsSymbols(root, filePath, lines2) {
|
|
|
1996
2223
|
out.push(makeSymbol(filePath, fieldName.text, "method", node, lines2, "c"));
|
|
1997
2224
|
}
|
|
1998
2225
|
}
|
|
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
2226
|
if (node.type === "pair" && node.parent?.type === "object") {
|
|
2006
2227
|
const key = node.childForFieldName("key");
|
|
2007
2228
|
const value = node.childForFieldName("value");
|
|
@@ -2018,7 +2239,9 @@ function extractTsJsSymbols(root, filePath, lines2) {
|
|
|
2018
2239
|
}
|
|
2019
2240
|
}
|
|
2020
2241
|
}
|
|
2021
|
-
const
|
|
2242
|
+
const isAnonymousFn = node.type === "function_expression" || node.type === "arrow_function";
|
|
2243
|
+
const isTransparentWrapper = !insideFunction && isAnonymousFn && (isIifeCallee(node) || isModuleWrapperCallback(node));
|
|
2244
|
+
const childInside = insideFunction || TSJS_FN_SCOPE_TYPES.has(node.type) && !isTransparentWrapper;
|
|
2022
2245
|
for (const child of node.namedChildren) {
|
|
2023
2246
|
visit(child, childInside);
|
|
2024
2247
|
}
|
|
@@ -3557,8 +3780,8 @@ function boundSymbolDocstring(docstring) {
|
|
|
3557
3780
|
return docstring.slice(0, Math.max(0, end)) + DOCSTRING_TRUNCATION_MARKER;
|
|
3558
3781
|
}
|
|
3559
3782
|
function loadGrammar(lang, filePath, content) {
|
|
3560
|
-
const useTsx = lang === "typescript" && filePath !== void 0 &&
|
|
3561
|
-
const useCppHeader = lang === "c" && filePath !== void 0 &&
|
|
3783
|
+
const useTsx = lang === "typescript" && filePath !== void 0 && path6.extname(filePath).toLowerCase() === ".tsx";
|
|
3784
|
+
const useCppHeader = lang === "c" && filePath !== void 0 && path6.extname(filePath).toLowerCase() === ".h" && content !== void 0 && CPP_HEADER_SNIFF_RE.test(content);
|
|
3562
3785
|
const cacheKey = useTsx ? "typescript:tsx" : useCppHeader ? "c:cpp-header" : lang;
|
|
3563
3786
|
const cached = _grammarCache.get(cacheKey);
|
|
3564
3787
|
if (cached !== void 0) return cached;
|
|
@@ -3694,7 +3917,7 @@ function parseSourceSymbolsTreeSitterOnly(content, filePath, language) {
|
|
|
3694
3917
|
var REGEX_ADAPTERS_SLOT = /* @__PURE__ */ Symbol.for("token-goat.regex-adapters");
|
|
3695
3918
|
var adapterSlot = globalThis;
|
|
3696
3919
|
async function loadRegexExtractors() {
|
|
3697
|
-
adapterSlot[REGEX_ADAPTERS_SLOT] ??= await import("./token-goat-chunk-
|
|
3920
|
+
adapterSlot[REGEX_ADAPTERS_SLOT] ??= await import("./token-goat-chunk-FWYZVS3E.mjs");
|
|
3698
3921
|
}
|
|
3699
3922
|
function regexAdapters() {
|
|
3700
3923
|
const loaded = adapterSlot[REGEX_ADAPTERS_SLOT];
|
|
@@ -3756,7 +3979,7 @@ function isUnderSkipDir(filePath, skipDirs) {
|
|
|
3756
3979
|
}
|
|
3757
3980
|
function isParseSkipEligible(filePath, cfg) {
|
|
3758
3981
|
if (isUnderSkipDir(filePath, cfg.skip_dirs)) return true;
|
|
3759
|
-
if (cfg.skip_files.includes(
|
|
3982
|
+
if (cfg.skip_files.includes(path6.basename(filePath))) return true;
|
|
3760
3983
|
try {
|
|
3761
3984
|
const stat = fs2.statSync(filePath);
|
|
3762
3985
|
if (stat.size > cfg.large_file_skip_kb * 1024) return true;
|
|
@@ -3764,18 +3987,30 @@ function isParseSkipEligible(filePath, cfg) {
|
|
|
3764
3987
|
}
|
|
3765
3988
|
return false;
|
|
3766
3989
|
}
|
|
3990
|
+
function boundarySpanKey(spans) {
|
|
3991
|
+
return spans.map((s) => `${s.start}-${s.end}`).sort().join(",");
|
|
3992
|
+
}
|
|
3993
|
+
function embeddingBoundariesMoved(db, filePath, result) {
|
|
3994
|
+
const priorSpans = db.prepare(`SELECT line_start, line_end FROM symbols WHERE ${pathEqClause("file_path")}`).all(foldPath(filePath));
|
|
3995
|
+
const prior = boundarySpanKey(priorSpans.map((r) => ({ start: r.line_start, end: r.line_end })));
|
|
3996
|
+
const next = boundarySpanKey(
|
|
3997
|
+
result.symbols.filter((s) => s.name !== "" && s.kind !== "").map((s) => ({ start: s.lineStart, end: s.lineEnd }))
|
|
3998
|
+
);
|
|
3999
|
+
return prior !== next;
|
|
4000
|
+
}
|
|
3767
4001
|
function writeParseResult(filePath, content, result, dbPath) {
|
|
3768
4002
|
const db = getDb(dbPath);
|
|
3769
4003
|
const sha = fingerprintContent(content);
|
|
3770
4004
|
const mtime = safeMtime(filePath);
|
|
3771
4005
|
const now = Date.now() / 1e3;
|
|
3772
4006
|
const priorRow = db.prepare(`SELECT sha, embed_sha FROM files WHERE ${pathEqClause("path")}`).get(foldPath(filePath));
|
|
3773
|
-
const
|
|
4007
|
+
const carriedEmbedSha = priorRow !== void 0 && priorRow.sha === sha ? priorRow.embed_sha : null;
|
|
4008
|
+
const embedShaToCarry = carriedEmbedSha !== null && carriedEmbedSha === sha && detectLanguage(filePath) !== "markdown" && embeddingBoundariesMoved(db, filePath, result) ? null : carriedEmbedSha;
|
|
3774
4009
|
const writeAll = db.transaction(() => {
|
|
3775
4010
|
deleteFileRows(db, filePath);
|
|
3776
4011
|
db.prepare(
|
|
3777
4012
|
"INSERT INTO files (path, sha, mtime, language, indexed_at, parser_sha, embed_sha) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
|
3778
|
-
).run(filePath, sha, mtime, result.language, now,
|
|
4013
|
+
).run(filePath, sha, mtime, result.language, now, parserFingerprintForLanguage(result.language), embedShaToCarry);
|
|
3779
4014
|
const insSym = db.prepare(
|
|
3780
4015
|
"INSERT INTO symbols (file_path, name, kind, line_start, line_end, body, docstring, parent) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
|
|
3781
4016
|
);
|
|
@@ -3844,7 +4079,16 @@ var TIMEOUT_EMBED_SHA_PREFIX = "timeout:";
|
|
|
3844
4079
|
function timeoutEmbedSha(sha, workMillis) {
|
|
3845
4080
|
return `${TIMEOUT_EMBED_SHA_PREFIX}${workMillis}:${sha}`;
|
|
3846
4081
|
}
|
|
3847
|
-
|
|
4082
|
+
var ASSET_EMBED_SHA_PREFIX = "asset:";
|
|
4083
|
+
function assetEmbedSha(sha) {
|
|
4084
|
+
return `${ASSET_EMBED_SHA_PREFIX}${NON_TEXT_ASSET_SET_ID}:${sha}`;
|
|
4085
|
+
}
|
|
4086
|
+
var MAX_CHUNKS_EMBED_SHA_PREFIX = "maxchunks:";
|
|
4087
|
+
function maxChunksEmbedSha(sha, maxChunks) {
|
|
4088
|
+
return `${MAX_CHUNKS_EMBED_SHA_PREFIX}${maxChunks}:${sha}`;
|
|
4089
|
+
}
|
|
4090
|
+
function canonicalizeIndexPath(rawPath) {
|
|
4091
|
+
const absPath = normalizePath(rawPath);
|
|
3848
4092
|
if (!isCaseInsensitiveFs()) return absPath;
|
|
3849
4093
|
let real;
|
|
3850
4094
|
try {
|
|
@@ -3855,17 +4099,17 @@ function canonicalizeIndexPath(absPath) {
|
|
|
3855
4099
|
const cut = Math.max(absPath.lastIndexOf("/"), absPath.lastIndexOf("\\"));
|
|
3856
4100
|
const base = absPath.slice(cut + 1);
|
|
3857
4101
|
const realNorm = normalizePath(real);
|
|
3858
|
-
const realBase =
|
|
4102
|
+
const realBase = path6.basename(realNorm);
|
|
3859
4103
|
if (base === realBase) return absPath;
|
|
3860
4104
|
if (foldPath(base) !== foldPath(realBase)) return absPath;
|
|
3861
|
-
const callerDir = cut < 0 ? normalizePath(
|
|
3862
|
-
if (foldPath(callerDir) !== foldPath(
|
|
4105
|
+
const callerDir = cut < 0 ? normalizePath(path6.resolve(".")) : normalizePath(absPath.slice(0, cut));
|
|
4106
|
+
if (foldPath(callerDir) !== foldPath(path6.dirname(realNorm))) return absPath;
|
|
3863
4107
|
return absPath.slice(0, cut + 1) + realBase;
|
|
3864
4108
|
}
|
|
3865
4109
|
function indexedPathSpellingIsStale(storedPath, absPath) {
|
|
3866
4110
|
if (!isCaseInsensitiveFs()) return false;
|
|
3867
4111
|
const stored = normalizePath(storedPath);
|
|
3868
|
-
const candidate = normalizePath(
|
|
4112
|
+
const candidate = normalizePath(path6.resolve(absPath));
|
|
3869
4113
|
if (foldPath(stored) !== foldPath(candidate)) return false;
|
|
3870
4114
|
let real;
|
|
3871
4115
|
try {
|
|
@@ -3891,12 +4135,14 @@ function indexedPathSpellingIsStale(storedPath, absPath) {
|
|
|
3891
4135
|
}
|
|
3892
4136
|
return false;
|
|
3893
4137
|
}
|
|
3894
|
-
function isEmbedFresh(storedEmbedSha, sha, embeddingsEnabled, depsAvailable, symbolOnlyKb) {
|
|
4138
|
+
function isEmbedFresh(storedEmbedSha, sha, embeddingsEnabled, depsAvailable, symbolOnlyKb, maxChunksPerFile = 0) {
|
|
3895
4139
|
if (storedEmbedSha === void 0) return false;
|
|
3896
4140
|
if (!embeddingsEnabled) return storedEmbedSha === disabledEmbedSha(sha);
|
|
3897
4141
|
if (storedEmbedSha === sha) return true;
|
|
3898
4142
|
if (!depsAvailable && storedEmbedSha === unavailableEmbedSha(sha)) return true;
|
|
3899
4143
|
if (storedEmbedSha === oversizeEmbedSha(sha, symbolOnlyKb)) return true;
|
|
4144
|
+
if (maxChunksPerFile > 0 && storedEmbedSha === maxChunksEmbedSha(sha, maxChunksPerFile)) return true;
|
|
4145
|
+
if (storedEmbedSha === assetEmbedSha(sha)) return true;
|
|
3900
4146
|
if (storedEmbedSha === timeoutEmbedSha(sha, MAX_DOCUMENT_WORK_MILLIS)) return true;
|
|
3901
4147
|
return false;
|
|
3902
4148
|
}
|
|
@@ -3913,6 +4159,12 @@ async function indexFileEmbeddings(rawPath, dbPath = globalDbPath(), sha, onErro
|
|
|
3913
4159
|
stampEmbedSha(db, filePath, sha, (s) => s);
|
|
3914
4160
|
return;
|
|
3915
4161
|
}
|
|
4162
|
+
if (isNonTextAsset(filePath)) {
|
|
4163
|
+
const db = getDb(dbPath);
|
|
4164
|
+
deleteFileEmbeddings(db, filePath);
|
|
4165
|
+
stampEmbedSha(db, filePath, sha, assetEmbedSha);
|
|
4166
|
+
return;
|
|
4167
|
+
}
|
|
3916
4168
|
if (isEmbeddableDocument(filePath)) {
|
|
3917
4169
|
let extracted;
|
|
3918
4170
|
let refusedOnTheClock = false;
|
|
@@ -3976,9 +4228,16 @@ async function indexFileEmbeddings(rawPath, dbPath = globalDbPath(), sha, onErro
|
|
|
3976
4228
|
stampEmbedSha(db, filePath, sha, (s) => s);
|
|
3977
4229
|
return;
|
|
3978
4230
|
}
|
|
4231
|
+
const boundaries = buildEmbeddingBoundaries(filePath, content, dbPath);
|
|
4232
|
+
const chunkCount = chunkFile(filePath, content, void 0, void 0, boundaries).length;
|
|
4233
|
+
if (chunkCount > ixCfg.max_chunks_per_file) {
|
|
4234
|
+
const db = getDb(dbPath);
|
|
4235
|
+
deleteFileEmbeddings(db, filePath);
|
|
4236
|
+
stampEmbedSha(db, filePath, sha, (s) => maxChunksEmbedSha(s, ixCfg.max_chunks_per_file));
|
|
4237
|
+
return;
|
|
4238
|
+
}
|
|
3979
4239
|
try {
|
|
3980
4240
|
const db = getDb(dbPath);
|
|
3981
|
-
const boundaries = buildEmbeddingBoundaries(filePath, content, dbPath);
|
|
3982
4241
|
const outcome = await indexFile(db, filePath, content, boundaries);
|
|
3983
4242
|
stampEmbedSha(db, filePath, sha, (s) => outcome === "unavailable" ? unavailableEmbedSha(s) : s);
|
|
3984
4243
|
} catch (err) {
|
|
@@ -4530,6 +4789,8 @@ export {
|
|
|
4530
4789
|
isEmbeddableDocument,
|
|
4531
4790
|
ipynbToVirtualSource,
|
|
4532
4791
|
eachUnfencedLine,
|
|
4792
|
+
isImagePath,
|
|
4793
|
+
isNonTextAsset,
|
|
4533
4794
|
modelFilesPresent,
|
|
4534
4795
|
ensureModelFiles,
|
|
4535
4796
|
checkEmbeddingPreflight,
|
|
@@ -4548,7 +4809,7 @@ export {
|
|
|
4548
4809
|
formatHeadingTreeParts,
|
|
4549
4810
|
getWellKnownSections,
|
|
4550
4811
|
extractChangelogVersionHint,
|
|
4551
|
-
|
|
4812
|
+
parserFingerprintForLanguage,
|
|
4552
4813
|
treeSitterCoreAvailable,
|
|
4553
4814
|
treeSitterCoreLoadError,
|
|
4554
4815
|
isTreeSitterAvailable,
|
|
@@ -4558,6 +4819,8 @@ export {
|
|
|
4558
4819
|
deleteFileRows,
|
|
4559
4820
|
isParseSkipEligible,
|
|
4560
4821
|
indexFileSync,
|
|
4822
|
+
assetEmbedSha,
|
|
4823
|
+
maxChunksEmbedSha,
|
|
4561
4824
|
indexedPathSpellingIsStale,
|
|
4562
4825
|
isEmbedFresh,
|
|
4563
4826
|
indexFileEmbeddings,
|