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
|
@@ -4,29 +4,62 @@ import {
|
|
|
4
4
|
parse
|
|
5
5
|
} from "./token-goat-chunk-3BTK54F3.mjs";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
compileGuardedRegexCached,
|
|
8
|
+
countNoun
|
|
9
|
+
} from "./token-goat-chunk-HU4TORC5.mjs";
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
} from "./token-goat-chunk-
|
|
11
|
+
echoedValue
|
|
12
|
+
} from "./token-goat-chunk-GGGG7RWB.mjs";
|
|
12
13
|
import {
|
|
13
|
-
|
|
14
|
-
} from "./token-goat-chunk-
|
|
14
|
+
displaySafeText
|
|
15
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
15
16
|
import {
|
|
16
17
|
init_define_import_meta_env
|
|
17
18
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
18
19
|
|
|
19
20
|
// src/csv_query.ts
|
|
20
21
|
init_define_import_meta_env();
|
|
22
|
+
|
|
23
|
+
// src/query_notices.ts
|
|
24
|
+
init_define_import_meta_env();
|
|
25
|
+
function headElidedNotice(hidden, noun) {
|
|
26
|
+
return `...(${countNoun(hidden, `more ${noun}`)} elided; use --head to see more)`;
|
|
27
|
+
}
|
|
28
|
+
function traversalLimitNotice(matched) {
|
|
29
|
+
if (matched === 0) return "...(no matches: the search stopped at this tool's traversal limit before finding any, so the part of the document it did not reach may still hold some. Narrow the path to search less of the document.)";
|
|
30
|
+
return "...(the search stopped early at this tool's traversal limit; these are not necessarily all the matches. Narrow the path to search less of the document.)";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/filter_notice.ts
|
|
34
|
+
init_define_import_meta_env();
|
|
35
|
+
function allOfCount(count, singular, plural = `${singular}s`) {
|
|
36
|
+
return count === 1 ? `the only ${singular}` : `all ${count} ${plural}`;
|
|
37
|
+
}
|
|
38
|
+
function filteredSubject(count, singular, plural) {
|
|
39
|
+
const one = count === 1;
|
|
40
|
+
return { subject: `${allOfCount(count, singular, plural)} ${one ? "was" : "were"}`, pronoun: one ? "it" : "them" };
|
|
41
|
+
}
|
|
42
|
+
function grepFilteredToEmptyNotice(preFilterCount, grep, nounSingular, nounPlural) {
|
|
43
|
+
const { subject, pronoun } = filteredSubject(preFilterCount, nounSingular, nounPlural);
|
|
44
|
+
return ` (${subject} filtered out by --grep ${displaySafeText(grep)} -- widen or drop the filter to see ${pronoun})`;
|
|
45
|
+
}
|
|
46
|
+
function filtersFilteredToEmptyNotice(preFilterCount, activeFilters, nounSingular, nounPlural, reassurance) {
|
|
47
|
+
const { subject, pronoun } = filteredSubject(preFilterCount, nounSingular, nounPlural);
|
|
48
|
+
const cause = activeFilters.length === 0 ? "the active filter" : activeFilters.map(displaySafeText).join(" + ");
|
|
49
|
+
const knob = activeFilters.length > 1 ? "filters" : "filter";
|
|
50
|
+
const tail = reassurance === void 0 ? "" : `; ${reassurance}`;
|
|
51
|
+
return ` (${subject} filtered out by ${cause}${tail} -- widen or drop the ${knob} to see ${pronoun})`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/csv_query.ts
|
|
21
55
|
var DELIMITER_CANDIDATES = [",", " ", ";", "|"];
|
|
22
56
|
var DELIMITER_SAMPLE_ROWS = 5;
|
|
23
57
|
function detectDelimiter(content) {
|
|
24
|
-
|
|
25
|
-
if (slice.trim() === "") return ",";
|
|
58
|
+
if (content.trim() === "") return ",";
|
|
26
59
|
for (const cand of DELIMITER_CANDIDATES) {
|
|
27
60
|
let rows;
|
|
28
61
|
try {
|
|
29
|
-
rows = parse(
|
|
62
|
+
rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter: cand, bom: true, relax_quotes: true, to: DELIMITER_SAMPLE_ROWS });
|
|
30
63
|
} catch {
|
|
31
64
|
continue;
|
|
32
65
|
}
|
|
@@ -39,7 +72,9 @@ function parseRecords(content, opts) {
|
|
|
39
72
|
const delimiter = opts.delimiter ?? detectDelimiter(content);
|
|
40
73
|
if (opts.noHeader === true) {
|
|
41
74
|
const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
|
|
42
|
-
|
|
75
|
+
const width = rows.reduce((max, row) => Math.max(max, row.length), 0);
|
|
76
|
+
const columns = Array.from({ length: width }, (_, i) => `col${i + 1}`);
|
|
77
|
+
return { records: rows.map((row) => Object.fromEntries(columns.map((name, i) => [name, row[i] ?? ""]))), columns };
|
|
43
78
|
}
|
|
44
79
|
const header = csvHeader(content, { ...opts, delimiter });
|
|
45
80
|
const dupes = header.filter((name, i) => name !== "" && header.indexOf(name) !== i);
|
|
@@ -49,14 +84,25 @@ function parseRecords(content, opts) {
|
|
|
49
84
|
`duplicate column ${unique.length === 1 ? "name" : "names"} in header: ${unique.join(", ")} \u2014 rename the duplicates or pass --no-header to address columns positionally as col1, col2, \u2026`
|
|
50
85
|
);
|
|
51
86
|
}
|
|
52
|
-
|
|
87
|
+
const records = parse(content, { columns: () => header, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
|
|
88
|
+
return { records, columns: header };
|
|
89
|
+
}
|
|
90
|
+
function nameBlankHeaders(raw) {
|
|
91
|
+
const taken = new Set(raw.filter((name) => name !== ""));
|
|
92
|
+
return raw.map((name, i) => {
|
|
93
|
+
if (name !== "") return name;
|
|
94
|
+
let synth = `col${i + 1}`;
|
|
95
|
+
while (taken.has(synth)) synth += "_";
|
|
96
|
+
taken.add(synth);
|
|
97
|
+
return synth;
|
|
98
|
+
});
|
|
53
99
|
}
|
|
54
100
|
function csvHeader(content, opts) {
|
|
55
101
|
if (opts.noHeader === true) return [];
|
|
56
102
|
const delimiter = opts.delimiter ?? detectDelimiter(content);
|
|
57
103
|
try {
|
|
58
104
|
const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, to: 1, relax_quotes: true });
|
|
59
|
-
return rows[0] ?? [];
|
|
105
|
+
return nameBlankHeaders(rows[0] ?? []);
|
|
60
106
|
} catch {
|
|
61
107
|
return [];
|
|
62
108
|
}
|
|
@@ -70,7 +116,7 @@ function parseWhereSpecs(specs) {
|
|
|
70
116
|
const op = m[2];
|
|
71
117
|
const value = m[3];
|
|
72
118
|
if ((op === ">" || op === "<" || op === ">=" || op === "<=") && value.trim() === "") {
|
|
73
|
-
throw new Error(`invalid --where spec: ${spec} (missing comparison value after
|
|
119
|
+
throw new Error(`invalid --where spec: ${spec} (missing comparison value after ${echoedValue(op)})`);
|
|
74
120
|
}
|
|
75
121
|
if (op === "~=") {
|
|
76
122
|
const guarded = compileGuardedRegexCached(value);
|
|
@@ -128,8 +174,8 @@ function matchesWhere(row, where) {
|
|
|
128
174
|
}
|
|
129
175
|
}
|
|
130
176
|
function queryCsv(content, opts) {
|
|
131
|
-
const records = parseRecords(content, opts);
|
|
132
|
-
const allColumns = records.length > 0 ?
|
|
177
|
+
const { records, columns: allHeader } = parseRecords(content, opts);
|
|
178
|
+
const allColumns = records.length > 0 ? allHeader : [];
|
|
133
179
|
const realHeader = records.length > 0 ? allColumns : csvHeader(content, opts);
|
|
134
180
|
const columns = opts.columns && opts.columns.length > 0 ? opts.columns : allColumns;
|
|
135
181
|
for (const c of columns) {
|
|
@@ -164,7 +210,7 @@ function formatCsvTable(result, activeFilters = []) {
|
|
|
164
210
|
...result.rows.map((r) => r.map(quoteCsvCell).join(","))
|
|
165
211
|
];
|
|
166
212
|
if (result.totalRows > result.rows.length) {
|
|
167
|
-
lines.push(
|
|
213
|
+
lines.push(headElidedNotice(result.totalRows - result.rows.length, "row"));
|
|
168
214
|
}
|
|
169
215
|
if (result.totalRows === 0 && result.preFilterRows > 0) {
|
|
170
216
|
lines.push(filtersFilteredToEmptyNotice(result.preFilterRows, activeFilters, "data row", "data rows"));
|
|
@@ -172,8 +218,8 @@ function formatCsvTable(result, activeFilters = []) {
|
|
|
172
218
|
return lines.join("\n");
|
|
173
219
|
}
|
|
174
220
|
function profileCsv(content, opts = {}) {
|
|
175
|
-
const records = parseRecords(content, opts);
|
|
176
|
-
const columns = records.length > 0 ?
|
|
221
|
+
const { records, columns: allHeader } = parseRecords(content, opts);
|
|
222
|
+
const columns = records.length > 0 ? allHeader : [];
|
|
177
223
|
return columns.map((col) => {
|
|
178
224
|
const values = records.map((r) => r[col] ?? "");
|
|
179
225
|
const nullCount = values.filter((v) => v.trim() === "").length;
|
|
@@ -219,6 +265,12 @@ function formatCsvProfile(profiles) {
|
|
|
219
265
|
}
|
|
220
266
|
|
|
221
267
|
export {
|
|
268
|
+
headElidedNotice,
|
|
269
|
+
traversalLimitNotice,
|
|
270
|
+
allOfCount,
|
|
271
|
+
filteredSubject,
|
|
272
|
+
grepFilteredToEmptyNotice,
|
|
273
|
+
filtersFilteredToEmptyNotice,
|
|
222
274
|
parseWhereSpecs,
|
|
223
275
|
queryCsv,
|
|
224
276
|
quoteCsvCell,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
init_define_import_meta_env();
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
function readManifest() {
|
|
11
|
-
if (true) return JSON.parse('{"version":"2.9.
|
|
11
|
+
if (true) return JSON.parse('{"version":"2.9.31","name":"token-goat","bugs":{"url":"https://github.com/DFKHelper/token-goat/issues"}}');
|
|
12
12
|
try {
|
|
13
13
|
return createRequire(import.meta.url)("../package.json");
|
|
14
14
|
} catch {
|
|
@@ -132,6 +132,11 @@ function ensureStorageRootPrivate(dir) {
|
|
|
132
132
|
if (isUnderRoot(dir, DATA_DIR)) ensureDataDirPrivate();
|
|
133
133
|
if (isUnderRoot(dir, tokenGoatHome())) ensureHomeDirPrivate();
|
|
134
134
|
}
|
|
135
|
+
function _resetDataDirCacheForTesting() {
|
|
136
|
+
DATA_DIR = defaultDataDir();
|
|
137
|
+
dataDirHardened = false;
|
|
138
|
+
hardenedHomes.clear();
|
|
139
|
+
}
|
|
135
140
|
function globalDbPath() {
|
|
136
141
|
return path.join(DATA_DIR, "global.db");
|
|
137
142
|
}
|
|
@@ -190,6 +195,7 @@ export {
|
|
|
190
195
|
tokenGoatHome,
|
|
191
196
|
isTokenGoatStorage,
|
|
192
197
|
ensureStorageRootPrivate,
|
|
198
|
+
_resetDataDirCacheForTesting,
|
|
193
199
|
globalDbPath,
|
|
194
200
|
configPath,
|
|
195
201
|
projectConfigPath,
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
FIND_SCAN_LIMIT,
|
|
5
|
+
findParentName,
|
|
6
|
+
findSymbolCandidates
|
|
7
|
+
} from "./token-goat-chunk-4SC7UJYV.mjs";
|
|
8
|
+
import {
|
|
9
|
+
indexedSourceText
|
|
10
|
+
} from "./token-goat-chunk-QH7YVYOY.mjs";
|
|
11
|
+
import {
|
|
12
|
+
querySymbols
|
|
13
|
+
} from "./token-goat-chunk-IK2DRMFX.mjs";
|
|
14
|
+
import {
|
|
15
|
+
getDb,
|
|
16
|
+
pathEqClause
|
|
17
|
+
} from "./token-goat-chunk-GVB2MUST.mjs";
|
|
18
|
+
import {
|
|
19
|
+
fingerprintContent
|
|
20
|
+
} from "./token-goat-chunk-4GBVPH3D.mjs";
|
|
21
|
+
import {
|
|
22
|
+
foldPath
|
|
23
|
+
} from "./token-goat-chunk-AM5V6GSX.mjs";
|
|
24
|
+
import {
|
|
25
|
+
globalDbPath
|
|
26
|
+
} from "./token-goat-chunk-CO3UYX6G.mjs";
|
|
27
|
+
import {
|
|
28
|
+
init_define_import_meta_env
|
|
29
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
30
|
+
|
|
31
|
+
// src/notes.ts
|
|
32
|
+
init_define_import_meta_env();
|
|
33
|
+
import * as fs from "node:fs";
|
|
34
|
+
var WHOLE_FILE_NOTE_SYMBOL = "";
|
|
35
|
+
function toNoteRow(row) {
|
|
36
|
+
return {
|
|
37
|
+
id: row.id,
|
|
38
|
+
filePath: row.file_path,
|
|
39
|
+
symbol: row.symbol,
|
|
40
|
+
content: row.content,
|
|
41
|
+
fingerprint: row.fingerprint,
|
|
42
|
+
createdAt: row.created_at,
|
|
43
|
+
updatedAt: row.updated_at
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function declarationGroups(rows, dbPath) {
|
|
47
|
+
const fileSymbols = /* @__PURE__ */ new Map();
|
|
48
|
+
const groups = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const row of rows) {
|
|
50
|
+
let siblings = fileSymbols.get(row.filePath);
|
|
51
|
+
if (siblings === void 0) {
|
|
52
|
+
siblings = querySymbols({ filePath: row.filePath, limit: FIND_SCAN_LIMIT }, dbPath);
|
|
53
|
+
fileSymbols.set(row.filePath, siblings);
|
|
54
|
+
}
|
|
55
|
+
const parent = findParentName(row, siblings);
|
|
56
|
+
const key = JSON.stringify([row.filePath, parent]);
|
|
57
|
+
const group = groups.get(key);
|
|
58
|
+
if (group === void 0) groups.set(key, { parent, rows: [row] });
|
|
59
|
+
else group.rows.push(row);
|
|
60
|
+
}
|
|
61
|
+
return [...groups.values()];
|
|
62
|
+
}
|
|
63
|
+
function groupEntry(group) {
|
|
64
|
+
const rows = [...group].sort((x, y) => x.lineStart - y.lineStart);
|
|
65
|
+
const first = rows[0];
|
|
66
|
+
if (rows.length === 1 && first.body !== "") return first;
|
|
67
|
+
const body = rows.map((r) => r.body !== "" ? r.body : bodyFromSource(r)).join("\n");
|
|
68
|
+
return { ...first, lineEnd: Math.max(...rows.map((r) => r.lineEnd)), body };
|
|
69
|
+
}
|
|
70
|
+
function resolveSymbolMatch(filePath, symbolName, dbPath = globalDbPath()) {
|
|
71
|
+
const { candidates, displaySymbol } = findSymbolCandidates(filePath, filePath, symbolName, void 0, dbPath);
|
|
72
|
+
const seen = /* @__PURE__ */ new Set();
|
|
73
|
+
const distinct = candidates.filter((c) => {
|
|
74
|
+
const key = `${c.filePath}|${c.lineStart}|${c.lineEnd}`;
|
|
75
|
+
if (seen.has(key)) return false;
|
|
76
|
+
seen.add(key);
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
if (distinct.length === 0) return { kind: "none" };
|
|
80
|
+
if (distinct.length === 1) return { kind: "ok", entry: groupEntry(distinct) };
|
|
81
|
+
const groups = declarationGroups(distinct, dbPath);
|
|
82
|
+
if (groups.length === 1) return { kind: "ok", entry: groupEntry(groups[0].rows) };
|
|
83
|
+
const fileLevel = groups.find((g) => g.parent === null);
|
|
84
|
+
if (fileLevel !== void 0 && !symbolName.includes(".")) return { kind: "ok", entry: groupEntry(fileLevel.rows) };
|
|
85
|
+
const declarations = groups.map((g) => ({ entry: groupEntry(g.rows), qualifiedName: g.parent === null ? displaySymbol : `${g.parent}.${displaySymbol}` })).sort((x, y) => x.entry.lineStart - y.entry.lineStart);
|
|
86
|
+
return { kind: "ambiguous", symbol: displaySymbol, candidates: declarations };
|
|
87
|
+
}
|
|
88
|
+
function bodyFromSource(entry) {
|
|
89
|
+
try {
|
|
90
|
+
return indexedSourceText(entry.filePath, fs.readFileSync(entry.filePath, "utf8")).split(/\r?\n/).slice(Math.max(0, entry.lineStart - 1), entry.lineEnd).join("\n");
|
|
91
|
+
} catch {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function symbolNamesInFile(filePath, dbPath = globalDbPath()) {
|
|
96
|
+
const symbols = querySymbols({ filePath, limit: -1 }, dbPath);
|
|
97
|
+
return [...new Set(symbols.map((s) => s.name))].sort();
|
|
98
|
+
}
|
|
99
|
+
function computeFileFingerprint(filePath, dbPath = globalDbPath()) {
|
|
100
|
+
const symbols = querySymbols({ filePath, limit: -1 }, dbPath);
|
|
101
|
+
const manifest = symbols.map((s) => `${s.name}:${s.kind}:${s.lineStart}-${s.lineEnd}`).sort().join("\n");
|
|
102
|
+
return fingerprintContent(manifest);
|
|
103
|
+
}
|
|
104
|
+
function computeSymbolFingerprints(filePath, symbolName, dbPath = globalDbPath()) {
|
|
105
|
+
const match = resolveSymbolMatch(filePath, symbolName, dbPath);
|
|
106
|
+
if (match.kind === "none") return [];
|
|
107
|
+
return (match.kind === "ok" ? [match.entry] : match.candidates.map((c) => c.entry)).map((e) => fingerprintContent(e.body));
|
|
108
|
+
}
|
|
109
|
+
function upsertNote(filePath, symbol, content, fingerprint, dbPath = globalDbPath()) {
|
|
110
|
+
const db = getDb(dbPath);
|
|
111
|
+
const now = Date.now() / 1e3;
|
|
112
|
+
db.transaction(() => {
|
|
113
|
+
const updated = db.prepare(`UPDATE notes SET content = ?, fingerprint = ?, updated_at = ? WHERE ${pathEqClause("file_path")} AND symbol = ?`).run(content, fingerprint, now, foldPath(filePath), symbol);
|
|
114
|
+
if (updated.changes > 0) return;
|
|
115
|
+
db.prepare("INSERT INTO notes (file_path, symbol, content, fingerprint, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(
|
|
116
|
+
filePath,
|
|
117
|
+
symbol,
|
|
118
|
+
content,
|
|
119
|
+
fingerprint,
|
|
120
|
+
now,
|
|
121
|
+
now
|
|
122
|
+
);
|
|
123
|
+
}).immediate();
|
|
124
|
+
}
|
|
125
|
+
function getNote(filePath, symbol, dbPath = globalDbPath()) {
|
|
126
|
+
const db = getDb(dbPath);
|
|
127
|
+
const row = db.prepare(
|
|
128
|
+
`SELECT id, file_path, symbol, content, fingerprint, created_at, updated_at FROM notes WHERE ${pathEqClause("file_path")} AND symbol = ?`
|
|
129
|
+
).get(foldPath(filePath), symbol);
|
|
130
|
+
return row === void 0 ? null : toNoteRow(row);
|
|
131
|
+
}
|
|
132
|
+
function listNotes(dbPath = globalDbPath()) {
|
|
133
|
+
const db = getDb(dbPath);
|
|
134
|
+
const rows = db.prepare(
|
|
135
|
+
"SELECT id, file_path, symbol, content, fingerprint, created_at, updated_at FROM notes ORDER BY file_path, symbol"
|
|
136
|
+
).all();
|
|
137
|
+
return rows.map(toNoteRow);
|
|
138
|
+
}
|
|
139
|
+
function isNoteStale(note, dbPath = globalDbPath()) {
|
|
140
|
+
if (note.symbol !== WHOLE_FILE_NOTE_SYMBOL) return !computeSymbolFingerprints(note.filePath, note.symbol, dbPath).includes(note.fingerprint);
|
|
141
|
+
return computeFileFingerprint(note.filePath, dbPath) !== note.fingerprint;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
WHOLE_FILE_NOTE_SYMBOL,
|
|
146
|
+
resolveSymbolMatch,
|
|
147
|
+
symbolNamesInFile,
|
|
148
|
+
computeFileFingerprint,
|
|
149
|
+
computeSymbolFingerprints,
|
|
150
|
+
upsertNote,
|
|
151
|
+
getNote,
|
|
152
|
+
listNotes,
|
|
153
|
+
isNoteStale
|
|
154
|
+
};
|