token-goat 2.9.29 → 2.9.31
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 +53 -42
- package/SECURITY.md +37 -11
- package/THIRD_PARTY_NOTICES.md +41 -4
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/native/win32-arm64/tg-hook.exe +0 -0
- package/dist/native/win32-x64/tg-hook.exe +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-25TRAWET.mjs} +23 -6
- package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-2M7E4PF7.mjs} +43 -14
- package/dist/token-goat-chunk-2UPZGKKY.mjs +188 -0
- package/dist/token-goat-chunk-2WLPWKHV.mjs +135 -0
- package/dist/token-goat-chunk-2XBMMDBD.mjs +126 -0
- package/dist/token-goat-chunk-32ZOY4N5.mjs +23 -0
- package/dist/token-goat-chunk-3EZRNKTK.mjs +188 -0
- package/dist/token-goat-chunk-4ADZHI7J.mjs +63 -0
- package/dist/token-goat-chunk-4GBVPH3D.mjs +242 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-4GILLLWY.mjs} +34 -7
- package/dist/token-goat-chunk-4NAPX7BA.mjs +90 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-4SC7UJYV.mjs} +9981 -11563
- package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-4ZBFWLXF.mjs} +310 -441
- package/dist/token-goat-chunk-57BIAXJL.mjs +286 -0
- package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
- package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
- package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
- package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
- package/dist/token-goat-chunk-646E6U44.mjs +398 -0
- package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-6DG6HWP3.mjs} +13 -3
- package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
- package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-76FGDLRO.mjs} +574 -340
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7EZTZOMC.mjs} +780 -767
- package/dist/token-goat-chunk-7MAOA6X4.mjs +3647 -0
- package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/token-goat-chunk-AUNGYYQX.mjs +184 -0
- package/dist/token-goat-chunk-AUQYRMMH.mjs +2985 -0
- package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-BA4HI6BW.mjs} +1910 -165
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-BFCWY73P.mjs} +58 -20
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/token-goat-chunk-BWGFUZZE.mjs +25 -0
- package/dist/token-goat-chunk-C75NA7PL.mjs +322 -0
- package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
- package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
- package/dist/token-goat-chunk-CIMQ2BB3.mjs +233 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-CJLS3CDL.mjs} +70 -18
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-CO3UYX6G.mjs} +7 -1
- package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
- package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
- package/dist/token-goat-chunk-CVCEVUGK.mjs +315 -0
- package/dist/token-goat-chunk-CXHOFN7R.mjs +371 -0
- package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-DGS2LVNA.mjs} +70 -160
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-DOWRSMWO.mjs} +1 -1
- package/dist/token-goat-chunk-E45INMY3.mjs +71 -0
- package/dist/token-goat-chunk-EC5F37F4.mjs +244 -0
- package/dist/{token-goat-chunk-XTQAOTSO.mjs → token-goat-chunk-EDBDRVH5.mjs} +4 -1
- package/dist/token-goat-chunk-EELTBKDM.mjs +613 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-F4HYL64R.mjs} +12 -2
- package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
- package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-GL3ETKSC.mjs} +276 -19
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-GVB2MUST.mjs} +265 -1567
- package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HLPW63A7.mjs +48 -0
- package/dist/token-goat-chunk-HU4TORC5.mjs +1377 -0
- package/dist/token-goat-chunk-I7VKZZAW.mjs +35 -0
- package/dist/token-goat-chunk-IA6XSPE3.mjs +218 -0
- package/dist/token-goat-chunk-IAGXMHIK.mjs +863 -0
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-IK2DRMFX.mjs} +129 -74
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-INNPTRUX.mjs} +2954 -2783
- package/dist/token-goat-chunk-JJ5BX4F4.mjs +129 -0
- package/dist/token-goat-chunk-JVFSHVFJ.mjs +129 -0
- package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
- package/dist/token-goat-chunk-LCNQ2CNN.mjs +497 -0
- package/dist/token-goat-chunk-M3LFJDPU.mjs +58 -0
- package/dist/token-goat-chunk-M52KPT3C.mjs +87 -0
- package/dist/token-goat-chunk-MBEG42H7.mjs +150 -0
- package/dist/{token-goat-chunk-EVC4TOLE.mjs → token-goat-chunk-METECDOH.mjs} +3 -12
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-MHX7XCC3.mjs} +3 -2
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-N5MMR2IW.mjs} +30 -8
- package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-NISNMD7T.mjs} +2545 -2953
- package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
- package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
- package/dist/token-goat-chunk-NSNSPPBG.mjs +69 -0
- package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
- package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
- package/dist/token-goat-chunk-ODBT2USM.mjs +800 -0
- package/dist/token-goat-chunk-OS5EM5PP.mjs +107 -0
- package/dist/token-goat-chunk-OUKDTVNU.mjs +1178 -0
- package/dist/token-goat-chunk-OXFMP75N.mjs +566 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -1
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-P6HQSWQ3.mjs} +55 -47
- package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
- package/dist/token-goat-chunk-PFWIMH2E.mjs +261 -0
- package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
- package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
- package/dist/token-goat-chunk-PX5PQWTY.mjs +462 -0
- package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
- package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
- package/dist/token-goat-chunk-QH7YVYOY.mjs +3957 -0
- package/dist/token-goat-chunk-QLMUHEPB.mjs +43 -0
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-QQOJIHL3.mjs} +50 -14
- package/dist/token-goat-chunk-QQTWJY2O.mjs +85 -0
- package/dist/token-goat-chunk-QYHO5CPH.mjs +93 -0
- package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
- package/dist/token-goat-chunk-RSLPOBKQ.mjs +339 -0
- package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
- package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-SOAFZNNZ.mjs} +164 -40
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-SRTHT7KV.mjs} +33 -15
- package/dist/token-goat-chunk-T5P5ACNQ.mjs +212 -0
- package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
- package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
- package/dist/token-goat-chunk-TM6MC754.mjs +40 -0
- package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
- package/dist/token-goat-chunk-U2KSB4SG.mjs +56 -0
- package/dist/token-goat-chunk-U4WHMG6Y.mjs +898 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/token-goat-chunk-UGJHGR5A.mjs +52 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-UOUDVA5U.mjs} +76 -16
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-URRJ33GR.mjs} +22 -4
- package/dist/token-goat-chunk-UZOROKIS.mjs +165 -0
- package/dist/token-goat-chunk-VIHGGGEI.mjs +4234 -0
- package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
- package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
- package/dist/token-goat-chunk-VWZA2H4P.mjs +368 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-VXEXMJDL.mjs} +2964 -3153
- package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-WDH44VAU.mjs} +19 -22
- package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
- package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-XLRBNZCC.mjs} +40 -21
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-XRKUX6CM.mjs} +4 -0
- package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
- package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
- package/dist/token-goat-chunk-Y2ZTQOCL.mjs +35 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-YB4VMGK2.mjs} +15 -4
- package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
- package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-YHVDKQBR.mjs} +389 -221
- package/dist/token-goat-chunk-YJB5XLWI.mjs +26 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-YKB6AQG3.mjs} +53 -31
- package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
- package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-YY6AVUFL.mjs} +13246 -12247
- package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
- package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
- package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
- package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +76 -31
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
- package/docs/cli.md +113 -60
- package/docs/install.md +63 -20
- package/docs/security.md +10 -8
- package/package.json +18 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
- package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
- package/dist/token-goat-chunk-BGYOZ6DO.mjs +0 -24
- package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-D4ETHJD6.mjs +0 -246
- package/dist/token-goat-chunk-DNRPXHYH.mjs +0 -1062
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-FTP4U4QA.mjs +0 -64
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-GLXRTTLE.mjs +0 -36
- package/dist/token-goat-chunk-H5J3C56Q.mjs +0 -1511
- package/dist/token-goat-chunk-IVWI2OCK.mjs +0 -368
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-LZNBQTDK.mjs +0 -26
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-RTMVLHWX.mjs +0 -7113
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- package/dist/token-goat-chunk-VZQEWRVH.mjs +0 -312
- package/dist/token-goat-chunk-XYWPOSCN.mjs +0 -807
- package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
- package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
- package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
filePathSpellingsClause,
|
|
5
|
+
fileRowByIndexKey,
|
|
6
|
+
getReadDb,
|
|
7
|
+
pathEqClause,
|
|
8
|
+
pathSuffixClause,
|
|
9
|
+
projectScopeClause
|
|
10
|
+
} from "./token-goat-chunk-GVB2MUST.mjs";
|
|
6
11
|
import {
|
|
7
|
-
foldPath
|
|
8
|
-
|
|
9
|
-
} from "./token-goat-chunk-TCQANXYC.mjs";
|
|
12
|
+
foldPath
|
|
13
|
+
} from "./token-goat-chunk-AM5V6GSX.mjs";
|
|
10
14
|
import {
|
|
11
15
|
normalizePath
|
|
12
|
-
} from "./token-goat-chunk-
|
|
16
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
13
17
|
import {
|
|
14
18
|
globalDbPath
|
|
15
|
-
} from "./token-goat-chunk-
|
|
19
|
+
} from "./token-goat-chunk-CO3UYX6G.mjs";
|
|
16
20
|
import {
|
|
17
21
|
init_define_import_meta_env
|
|
18
22
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -20,35 +24,95 @@ import {
|
|
|
20
24
|
// src/index_reader.ts
|
|
21
25
|
init_define_import_meta_env();
|
|
22
26
|
|
|
23
|
-
// src/
|
|
27
|
+
// src/nested_worktrees.ts
|
|
24
28
|
init_define_import_meta_env();
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
import fs from "node:fs";
|
|
30
|
+
import path from "node:path";
|
|
31
|
+
var cache = /* @__PURE__ */ new Map();
|
|
32
|
+
function commonGitDir(root) {
|
|
33
|
+
const dotGit = path.join(root, ".git");
|
|
34
|
+
let st;
|
|
35
|
+
try {
|
|
36
|
+
st = fs.statSync(dotGit);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (st.isDirectory()) return dotGit;
|
|
41
|
+
if (!st.isFile()) return null;
|
|
42
|
+
try {
|
|
43
|
+
const m = /^gitdir:(.*)$/m.exec(fs.readFileSync(dotGit, "utf8"));
|
|
44
|
+
const target = m?.[1]?.trim();
|
|
45
|
+
if (target === void 0 || target === "") return null;
|
|
46
|
+
const gitDir = path.resolve(root, target);
|
|
47
|
+
const common = fs.readFileSync(path.join(gitDir, "commondir"), "utf8").trim();
|
|
48
|
+
return path.resolve(gitDir, common);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
27
52
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
// Both separators are accepted because not every writer into `symbols` stores a normalizePath'd (forward-slash) file_path, and the JS-side path-boundary test this narrowing feeds treats `/` and `\` alike.
|
|
32
|
-
clause: `(${col} = ? OR substr(${col}, -length(?)) = ? OR substr(${col}, -length(?)) = ?)`,
|
|
33
|
-
params: (baseName) => {
|
|
34
|
-
const folded = foldPath(baseName);
|
|
35
|
-
return [folded, `/${folded}`, `/${folded}`, `\\${folded}`, `\\${folded}`];
|
|
36
|
-
}
|
|
37
|
-
};
|
|
53
|
+
function strictlyInside(child, parent) {
|
|
54
|
+
const base = parent.endsWith("/") ? parent : `${parent}/`;
|
|
55
|
+
return child.startsWith(base) && child.length > base.length;
|
|
38
56
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
function nestedWorktreeRoots(root) {
|
|
58
|
+
const common = commonGitDir(root);
|
|
59
|
+
if (common === null) return [];
|
|
60
|
+
const listDir = path.join(common, "worktrees");
|
|
61
|
+
let listMtimeMs;
|
|
62
|
+
try {
|
|
63
|
+
listMtimeMs = fs.statSync(listDir).mtimeMs;
|
|
64
|
+
} catch {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const hit = cache.get(root);
|
|
68
|
+
if (hit?.listMtimeMs === listMtimeMs) return hit.roots;
|
|
69
|
+
const rootPath = normalizePath(root);
|
|
70
|
+
const rootKey = foldPath(rootPath);
|
|
71
|
+
let realPath;
|
|
72
|
+
try {
|
|
73
|
+
realPath = normalizePath(fs.realpathSync.native(root));
|
|
74
|
+
} catch {
|
|
75
|
+
realPath = null;
|
|
76
|
+
}
|
|
77
|
+
const roots = [];
|
|
78
|
+
let names;
|
|
79
|
+
try {
|
|
80
|
+
names = fs.readdirSync(listDir);
|
|
81
|
+
} catch {
|
|
82
|
+
names = [];
|
|
83
|
+
}
|
|
84
|
+
for (const name of names) {
|
|
85
|
+
const entryDir = path.join(listDir, name);
|
|
86
|
+
let target;
|
|
87
|
+
try {
|
|
88
|
+
target = fs.readFileSync(path.join(entryDir, "gitdir"), "utf8").trim();
|
|
89
|
+
} catch {
|
|
90
|
+
continue;
|
|
50
91
|
}
|
|
51
|
-
|
|
92
|
+
if (target === "") continue;
|
|
93
|
+
const wtRoot = normalizePath(path.dirname(path.resolve(entryDir, target)));
|
|
94
|
+
if (strictlyInside(foldPath(wtRoot), rootKey)) roots.push(wtRoot);
|
|
95
|
+
else if (realPath !== null && strictlyInside(foldPath(wtRoot), foldPath(realPath))) roots.push(rootPath.replace(/\/+$/, "") + wtRoot.slice(realPath.replace(/\/+$/, "").length));
|
|
96
|
+
}
|
|
97
|
+
roots.sort();
|
|
98
|
+
cache.set(root, { listMtimeMs, roots });
|
|
99
|
+
return roots;
|
|
100
|
+
}
|
|
101
|
+
function ownProjectScope(column, root) {
|
|
102
|
+
const scope = projectScopeClause(column);
|
|
103
|
+
const excluded = nestedWorktreeExclusions(column, root);
|
|
104
|
+
if (excluded.clauses.length === 0) return { clause: scope.clause, params: scope.params(root) };
|
|
105
|
+
return { clause: `(${[scope.clause, ...excluded.clauses].join(" AND ")})`, params: [...scope.params(root), ...excluded.params] };
|
|
106
|
+
}
|
|
107
|
+
function nestedWorktreeExclusions(column, root) {
|
|
108
|
+
const scope = projectScopeClause(column);
|
|
109
|
+
const clauses = [];
|
|
110
|
+
const params = [];
|
|
111
|
+
for (const wt of nestedWorktreeRoots(root)) {
|
|
112
|
+
clauses.push(`NOT ${scope.clause}`);
|
|
113
|
+
params.push(...scope.params(wt));
|
|
114
|
+
}
|
|
115
|
+
return { clauses, params };
|
|
52
116
|
}
|
|
53
117
|
|
|
54
118
|
// src/index_reader.ts
|
|
@@ -78,9 +142,9 @@ function toRefEntry(row) {
|
|
|
78
142
|
}
|
|
79
143
|
function applyRootDirScope(rootDir, column, where, params) {
|
|
80
144
|
if (rootDir === void 0) return;
|
|
81
|
-
const
|
|
82
|
-
where.push(clause);
|
|
83
|
-
params.push(...
|
|
145
|
+
const scope = ownProjectScope(column, indexKey(rootDir));
|
|
146
|
+
where.push(scope.clause);
|
|
147
|
+
params.push(...scope.params);
|
|
84
148
|
}
|
|
85
149
|
function buildSymbolWhere(opts) {
|
|
86
150
|
const where = [];
|
|
@@ -90,15 +154,9 @@ function buildSymbolWhere(opts) {
|
|
|
90
154
|
params.push(opts.name);
|
|
91
155
|
}
|
|
92
156
|
if (opts.filePath !== void 0) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
where.push(`(${pathEqClause("file_path")} OR ${pathEqClause("file_path")})`);
|
|
97
|
-
params.push(foldPath(key), foldPath(alt));
|
|
98
|
-
} else {
|
|
99
|
-
where.push(pathEqClause("file_path"));
|
|
100
|
-
params.push(foldPath(key));
|
|
101
|
-
}
|
|
157
|
+
const spellings = filePathSpellingsClause("file_path", opts.filePath);
|
|
158
|
+
where.push(spellings.clause);
|
|
159
|
+
params.push(...spellings.params);
|
|
102
160
|
}
|
|
103
161
|
if (opts.kind !== void 0) {
|
|
104
162
|
where.push("kind = ?");
|
|
@@ -122,7 +180,7 @@ function querySymbols(opts = {}, dbPath = globalDbPath()) {
|
|
|
122
180
|
const limit = opts.limit ?? DEFAULT_QUERY_LIMIT;
|
|
123
181
|
const offset = opts.offset ?? 0;
|
|
124
182
|
const sql = `SELECT file_path, name, kind, line_start, line_end, body, docstring, parent FROM symbols ${clause} ORDER BY file_path, line_start, rowid LIMIT ? OFFSET ?`;
|
|
125
|
-
const db =
|
|
183
|
+
const db = getReadDb(dbPath);
|
|
126
184
|
const rows = db.prepare(sql).all(...params, limit, offset);
|
|
127
185
|
return rows.map(toSymbolEntry);
|
|
128
186
|
}
|
|
@@ -131,14 +189,14 @@ function distinctSymbolKinds(rootDir, dbPath = globalDbPath()) {
|
|
|
131
189
|
const params = [];
|
|
132
190
|
applyRootDirScope(rootDir, "file_path", where, params);
|
|
133
191
|
const clause = where.length > 0 ? `WHERE ${where.join(" AND ")}` : "";
|
|
134
|
-
const db =
|
|
192
|
+
const db = getReadDb(dbPath);
|
|
135
193
|
const rows = db.prepare(`SELECT DISTINCT kind FROM symbols ${clause} ORDER BY kind`).all(...params);
|
|
136
194
|
return rows.map((r) => r.kind);
|
|
137
195
|
}
|
|
138
196
|
function countSymbols(opts = {}, dbPath = globalDbPath()) {
|
|
139
197
|
const { clause, params } = buildSymbolWhere(opts);
|
|
140
198
|
const sql = `SELECT COUNT(*) as cnt FROM symbols ${clause}`;
|
|
141
|
-
const db =
|
|
199
|
+
const db = getReadDb(dbPath);
|
|
142
200
|
const row = db.prepare(sql).get(...params);
|
|
143
201
|
return row.cnt;
|
|
144
202
|
}
|
|
@@ -156,20 +214,20 @@ function queryRefs(opts, dbPath = globalDbPath()) {
|
|
|
156
214
|
const { clause, params } = buildRefsWhere(opts);
|
|
157
215
|
const limit = opts.limit ?? DEFAULT_QUERY_LIMIT;
|
|
158
216
|
const sql = `SELECT file_path, name, line, col, context FROM refs ${clause} ORDER BY file_path, line LIMIT ?`;
|
|
159
|
-
const db =
|
|
217
|
+
const db = getReadDb(dbPath);
|
|
160
218
|
const rows = db.prepare(sql).all(...params, limit);
|
|
161
219
|
return rows.map(toRefEntry);
|
|
162
220
|
}
|
|
163
221
|
function countRefs(opts, dbPath = globalDbPath()) {
|
|
164
222
|
const { clause, params } = buildRefsWhere(opts);
|
|
165
223
|
const sql = `SELECT COUNT(*) as cnt FROM refs ${clause}`;
|
|
166
|
-
const db =
|
|
224
|
+
const db = getReadDb(dbPath);
|
|
167
225
|
const row = db.prepare(sql).get(...params);
|
|
168
226
|
return row.cnt;
|
|
169
227
|
}
|
|
170
228
|
function queryRefsByContext(context, filePath, dbPath = globalDbPath()) {
|
|
171
229
|
const sql = `SELECT file_path, name, line, col, context FROM refs WHERE context = ? AND ${pathEqClause("file_path")} ORDER BY line LIMIT 20`;
|
|
172
|
-
const db =
|
|
230
|
+
const db = getReadDb(dbPath);
|
|
173
231
|
const rows = db.prepare(sql).all(context, foldPath(indexKey(filePath)));
|
|
174
232
|
return rows.map(toRefEntry);
|
|
175
233
|
}
|
|
@@ -177,7 +235,7 @@ var REF_COUNT_BATCH = 900;
|
|
|
177
235
|
function queryRefCounts(names, dbPath = globalDbPath(), rootDir) {
|
|
178
236
|
const counts = /* @__PURE__ */ new Map();
|
|
179
237
|
if (names.length === 0) return counts;
|
|
180
|
-
const db =
|
|
238
|
+
const db = getReadDb(dbPath);
|
|
181
239
|
const scopeWhere = [];
|
|
182
240
|
const scopeParams = [];
|
|
183
241
|
applyRootDirScope(rootDir, "file_path", scopeWhere, scopeParams);
|
|
@@ -196,9 +254,15 @@ function queryRefCounts(names, dbPath = globalDbPath(), rootDir) {
|
|
|
196
254
|
return counts;
|
|
197
255
|
}
|
|
198
256
|
function getProjectFileEntries(rootDir, dbPath = globalDbPath()) {
|
|
199
|
-
const db = getDb(dbPath);
|
|
200
257
|
const { clause, params } = projectScopeClause("path");
|
|
201
|
-
|
|
258
|
+
return fileEntriesWhere(clause, params(indexKey(rootDir)), dbPath);
|
|
259
|
+
}
|
|
260
|
+
function getOwnProjectFileEntries(rootDir, dbPath = globalDbPath()) {
|
|
261
|
+
const { clause, params } = ownProjectScope("path", indexKey(rootDir));
|
|
262
|
+
return fileEntriesWhere(clause, params, dbPath);
|
|
263
|
+
}
|
|
264
|
+
function fileEntriesWhere(clause, params, dbPath) {
|
|
265
|
+
const rows = getReadDb(dbPath).prepare(`SELECT path, sha, mtime, language, indexed_at, embed_sha, parser_sha FROM files WHERE ${clause}`).all(...params);
|
|
202
266
|
const out = /* @__PURE__ */ new Map();
|
|
203
267
|
for (const row of rows) {
|
|
204
268
|
out.set(foldPath(row.path), {
|
|
@@ -214,17 +278,8 @@ function getProjectFileEntries(rootDir, dbPath = globalDbPath()) {
|
|
|
214
278
|
return out;
|
|
215
279
|
}
|
|
216
280
|
function getFileEntry(filePath, dbPath = globalDbPath()) {
|
|
217
|
-
const db =
|
|
218
|
-
const
|
|
219
|
-
let row = db.prepare(
|
|
220
|
-
`SELECT path, sha, mtime, language, indexed_at, embed_sha, parser_sha FROM files WHERE ${pathEqClause("path")}`
|
|
221
|
-
).get(foldPath(key));
|
|
222
|
-
if (row === void 0 && (key.includes("/") || key.includes("\\"))) {
|
|
223
|
-
const altPath = key.includes("/") ? key.replace(/\//g, "\\") : key.replace(/\\/g, "/");
|
|
224
|
-
row = db.prepare(
|
|
225
|
-
`SELECT path, sha, mtime, language, indexed_at, embed_sha, parser_sha FROM files WHERE ${pathEqClause("path")}`
|
|
226
|
-
).get(foldPath(altPath));
|
|
227
|
-
}
|
|
281
|
+
const db = getReadDb(dbPath);
|
|
282
|
+
const row = fileRowByIndexKey(db, filePath, "path, sha, mtime, language, indexed_at, embed_sha, parser_sha");
|
|
228
283
|
if (row === void 0) return null;
|
|
229
284
|
return {
|
|
230
285
|
filePath: row.path,
|
|
@@ -240,12 +295,10 @@ function sanitizeFtsQuery(query, join = "AND") {
|
|
|
240
295
|
const terms = query.split(/\s+/).filter((t) => t.length > 0).map((t) => '"' + t.replace(/"/g, '""') + '"');
|
|
241
296
|
return terms.join(join === "OR" ? " OR " : " ");
|
|
242
297
|
}
|
|
243
|
-
function runFtsQuery(db, match, limit, scope
|
|
298
|
+
function runFtsQuery(db, match, limit, scope) {
|
|
244
299
|
const sql = `SELECT s.file_path, s.name, s.kind, s.line_start, s.line_end, s.body, s.docstring, s.parent FROM symbols_fts JOIN symbols s ON s.id = symbols_fts.rowid WHERE symbols_fts MATCH ?${scope !== void 0 ? ` AND ${scope.clause}` : ""} ORDER BY bm25(symbols_fts) LIMIT ?`;
|
|
245
300
|
const params = [match];
|
|
246
|
-
if (scope !== void 0
|
|
247
|
-
params.push(...scope.params(rootDir));
|
|
248
|
-
}
|
|
301
|
+
if (scope !== void 0) params.push(...scope.params);
|
|
249
302
|
params.push(limit);
|
|
250
303
|
const rows = db.prepare(sql).all(...params);
|
|
251
304
|
return rows.map(toSymbolEntry);
|
|
@@ -253,22 +306,23 @@ function runFtsQuery(db, match, limit, scope, rootDir) {
|
|
|
253
306
|
function searchSymbolsFts(query, limit = 50, dbPath = globalDbPath(), rootDir) {
|
|
254
307
|
const andMatch = sanitizeFtsQuery(query, "AND");
|
|
255
308
|
if (andMatch === "") return [];
|
|
256
|
-
const db =
|
|
257
|
-
const scope = rootDir !== void 0 ?
|
|
309
|
+
const db = getReadDb(dbPath);
|
|
310
|
+
const scope = rootDir !== void 0 ? ownProjectScope("s.file_path", indexKey(rootDir)) : void 0;
|
|
258
311
|
try {
|
|
259
|
-
const andResults = runFtsQuery(db, andMatch, limit, scope
|
|
312
|
+
const andResults = runFtsQuery(db, andMatch, limit, scope);
|
|
260
313
|
if (andResults.length > 0) return andResults;
|
|
261
314
|
const orMatch = sanitizeFtsQuery(query, "OR");
|
|
262
315
|
if (orMatch === andMatch) return andResults;
|
|
263
|
-
return runFtsQuery(db, orMatch, limit, scope
|
|
316
|
+
return runFtsQuery(db, orMatch, limit, scope);
|
|
264
317
|
} catch {
|
|
265
318
|
return [];
|
|
266
319
|
}
|
|
267
320
|
}
|
|
268
321
|
|
|
269
322
|
export {
|
|
270
|
-
|
|
271
|
-
|
|
323
|
+
commonGitDir,
|
|
324
|
+
ownProjectScope,
|
|
325
|
+
nestedWorktreeExclusions,
|
|
272
326
|
DEFAULT_QUERY_LIMIT,
|
|
273
327
|
querySymbols,
|
|
274
328
|
distinctSymbolKinds,
|
|
@@ -278,6 +332,7 @@ export {
|
|
|
278
332
|
queryRefsByContext,
|
|
279
333
|
queryRefCounts,
|
|
280
334
|
getProjectFileEntries,
|
|
335
|
+
getOwnProjectFileEntries,
|
|
281
336
|
getFileEntry,
|
|
282
337
|
sanitizeFtsQuery,
|
|
283
338
|
searchSymbolsFts
|