token-goat 2.9.29 → 2.9.30
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 +34 -40
- package/SECURITY.md +28 -10
- package/THIRD_PARTY_NOTICES.md +40 -3
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
- package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
- package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
- package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
- package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
- package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -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-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -15
- package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
- package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
- package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
- package/dist/{token-goat-chunk-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
- package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
- package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
- package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
- package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
- package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
- package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
- package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
- package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
- package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
- package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
- package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
- package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
- package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
- package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -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-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +46 -30
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +80 -46
- package/docs/install.md +47 -14
- package/docs/security.md +7 -7
- package/package.json +17 -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-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- 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,26 +4,30 @@ import {
|
|
|
4
4
|
CONTENT_DELIVERED_REASON,
|
|
5
5
|
classifyToolError,
|
|
6
6
|
errorPrefix
|
|
7
|
-
} from "./token-goat-chunk-
|
|
8
|
-
import "./token-goat-chunk-
|
|
9
|
-
import "./token-goat-chunk-
|
|
10
|
-
import "./token-goat-chunk-
|
|
11
|
-
import "./token-goat-chunk-
|
|
12
|
-
import "./token-goat-chunk-
|
|
13
|
-
import "./token-goat-chunk-
|
|
14
|
-
import "./token-goat-chunk-
|
|
15
|
-
import "./token-goat-chunk-
|
|
16
|
-
import "./token-goat-chunk-
|
|
7
|
+
} from "./token-goat-chunk-PEPTHRFF.mjs";
|
|
8
|
+
import "./token-goat-chunk-MNWKPRAL.mjs";
|
|
9
|
+
import "./token-goat-chunk-APGZXSPS.mjs";
|
|
10
|
+
import "./token-goat-chunk-COBQGL5S.mjs";
|
|
11
|
+
import "./token-goat-chunk-ATCPY7EQ.mjs";
|
|
12
|
+
import "./token-goat-chunk-VPBBTSJR.mjs";
|
|
13
|
+
import "./token-goat-chunk-C63JQV5K.mjs";
|
|
14
|
+
import "./token-goat-chunk-JB6QN6VF.mjs";
|
|
15
|
+
import "./token-goat-chunk-3Z5S4KGM.mjs";
|
|
16
|
+
import "./token-goat-chunk-VL3YIFHZ.mjs";
|
|
17
17
|
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
18
|
+
import "./token-goat-chunk-4FVIAHSI.mjs";
|
|
19
|
+
import "./token-goat-chunk-7IN2MKDS.mjs";
|
|
20
|
+
import "./token-goat-chunk-U4N3BN2W.mjs";
|
|
18
21
|
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
19
22
|
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
20
|
-
import "./token-goat-chunk-
|
|
21
|
-
import "./token-goat-chunk-
|
|
23
|
+
import "./token-goat-chunk-GOLEOXZP.mjs";
|
|
24
|
+
import "./token-goat-chunk-AM5V6GSX.mjs";
|
|
22
25
|
import {
|
|
23
26
|
displaySafeText
|
|
24
|
-
} from "./token-goat-chunk-
|
|
25
|
-
import "./token-goat-chunk-
|
|
26
|
-
import "./token-goat-chunk-
|
|
27
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
28
|
+
import "./token-goat-chunk-VES7EL7O.mjs";
|
|
29
|
+
import "./token-goat-chunk-KWPNJBDH.mjs";
|
|
30
|
+
import "./token-goat-chunk-HAVAOB3S.mjs";
|
|
27
31
|
import {
|
|
28
32
|
init_define_import_meta_env
|
|
29
33
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -78,6 +82,15 @@ function newToolErrorAccumulator() {
|
|
|
78
82
|
finish() {
|
|
79
83
|
const topUnknown = [...unknownPrefixes.values()].sort((a, b) => b.count - a.count || byCodeUnit(a.tool, b.tool) || byCodeUnit(a.prefix, b.prefix)).slice(0, UNKNOWN_PREFIX_LIMIT);
|
|
80
84
|
return { byTool: sortTallies(tools), byModel: sortTallies(models), unknownPrefixes: topUnknown };
|
|
85
|
+
},
|
|
86
|
+
checkpoint() {
|
|
87
|
+
const saved = structuredClone([[...tools], [...models], [...unknownPrefixes]]);
|
|
88
|
+
return () => {
|
|
89
|
+
for (const [live, copy] of [[tools, saved[0]], [models, saved[1]], [unknownPrefixes, saved[2]]]) {
|
|
90
|
+
live.clear();
|
|
91
|
+
for (const [k, v] of copy) live.set(k, v);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
81
94
|
}
|
|
82
95
|
};
|
|
83
96
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
recordStat
|
|
5
|
+
} from "./token-goat-chunk-3Z5S4KGM.mjs";
|
|
6
|
+
import {
|
|
7
|
+
loadConfig
|
|
8
|
+
} from "./token-goat-chunk-7IN2MKDS.mjs";
|
|
9
|
+
import {
|
|
10
|
+
fenceUntrustedContent,
|
|
11
|
+
scanForInjectionPatterns
|
|
12
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
13
|
+
import {
|
|
14
|
+
init_define_import_meta_env
|
|
15
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
16
|
+
|
|
17
|
+
// src/untrusted_fence.ts
|
|
18
|
+
init_define_import_meta_env();
|
|
19
|
+
function injectionFencingEnabled() {
|
|
20
|
+
try {
|
|
21
|
+
return loadConfig().injection.enabled;
|
|
22
|
+
} catch {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function fenceUntrusted(text, tag) {
|
|
27
|
+
if (!injectionFencingEnabled()) return text;
|
|
28
|
+
return fenceUntrustedContent(text, scanAndRecord(text), tag);
|
|
29
|
+
}
|
|
30
|
+
function fenceUntrustedSpans(spans, tag) {
|
|
31
|
+
const joined = spans.map((s) => s.text).join("");
|
|
32
|
+
if (!injectionFencingEnabled()) return joined;
|
|
33
|
+
return fenceUntrustedContent(spans, scanAndRecord(spans.filter((s) => s.own !== true).map((s) => s.text).join("")), tag);
|
|
34
|
+
}
|
|
35
|
+
function fenceWithMatches(text, matches, tag) {
|
|
36
|
+
if (!injectionFencingEnabled()) return text;
|
|
37
|
+
return tag === void 0 ? fenceUntrustedContent(text, matches) : fenceUntrustedContent(text, matches, tag);
|
|
38
|
+
}
|
|
39
|
+
function scanAndRecord(text) {
|
|
40
|
+
if (!injectionFencingEnabled()) return [];
|
|
41
|
+
let matches;
|
|
42
|
+
try {
|
|
43
|
+
matches = scanForInjectionPatterns(text);
|
|
44
|
+
} catch {
|
|
45
|
+
matches = [];
|
|
46
|
+
}
|
|
47
|
+
if (matches.length > 0) recordStat("injection_detected", 0, 0, void 0, matches.join(","));
|
|
48
|
+
return matches;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
injectionFencingEnabled,
|
|
53
|
+
fenceUntrusted,
|
|
54
|
+
fenceUntrustedSpans,
|
|
55
|
+
fenceWithMatches,
|
|
56
|
+
scanAndRecord
|
|
57
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
5
|
+
DEFAULT_TIMEOUT_SECONDS,
|
|
6
|
+
MAX_CAPTURE_BYTES,
|
|
7
|
+
resolveFilter,
|
|
8
|
+
run,
|
|
9
|
+
runRaw,
|
|
10
|
+
spawnTarget,
|
|
11
|
+
unknownFilterNotice
|
|
12
|
+
} from "./token-goat-chunk-7F2UBPD3.mjs";
|
|
13
|
+
import "./token-goat-chunk-54K3EUV3.mjs";
|
|
14
|
+
import "./token-goat-chunk-COBQGL5S.mjs";
|
|
15
|
+
import "./token-goat-chunk-AFLYLHDH.mjs";
|
|
16
|
+
import "./token-goat-chunk-HYBFA5X3.mjs";
|
|
17
|
+
import "./token-goat-chunk-ARDNEC2U.mjs";
|
|
18
|
+
import "./token-goat-chunk-3Z5S4KGM.mjs";
|
|
19
|
+
import "./token-goat-chunk-VL3YIFHZ.mjs";
|
|
20
|
+
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
21
|
+
import "./token-goat-chunk-4FVIAHSI.mjs";
|
|
22
|
+
import "./token-goat-chunk-7IN2MKDS.mjs";
|
|
23
|
+
import "./token-goat-chunk-U4N3BN2W.mjs";
|
|
24
|
+
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
25
|
+
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
26
|
+
import "./token-goat-chunk-GOLEOXZP.mjs";
|
|
27
|
+
import "./token-goat-chunk-AM5V6GSX.mjs";
|
|
28
|
+
import "./token-goat-chunk-FNFBKLRD.mjs";
|
|
29
|
+
import "./token-goat-chunk-VES7EL7O.mjs";
|
|
30
|
+
import "./token-goat-chunk-KWPNJBDH.mjs";
|
|
31
|
+
import "./token-goat-chunk-HAVAOB3S.mjs";
|
|
32
|
+
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
33
|
+
export {
|
|
34
|
+
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
35
|
+
DEFAULT_TIMEOUT_SECONDS,
|
|
36
|
+
MAX_CAPTURE_BYTES,
|
|
37
|
+
resolveFilter,
|
|
38
|
+
run,
|
|
39
|
+
runRaw,
|
|
40
|
+
spawnTarget,
|
|
41
|
+
unknownFilterNotice
|
|
42
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
getTrackedFiles
|
|
5
|
+
} from "./token-goat-chunk-FBNQNSJK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
enqueueDirtyPathsSafe
|
|
8
|
+
} from "./token-goat-chunk-H2PHHGM5.mjs";
|
|
9
|
+
import {
|
|
10
|
+
indexedPathSpellingIsStale,
|
|
11
|
+
parserFingerprintForLanguage
|
|
12
|
+
} from "./token-goat-chunk-RHXKCZX3.mjs";
|
|
13
|
+
import {
|
|
14
|
+
getProjectFileEntries,
|
|
15
|
+
projectScopeClause
|
|
16
|
+
} from "./token-goat-chunk-HYBFA5X3.mjs";
|
|
17
|
+
import {
|
|
18
|
+
getDb
|
|
19
|
+
} from "./token-goat-chunk-VL3YIFHZ.mjs";
|
|
20
|
+
import {
|
|
21
|
+
fingerprintFile,
|
|
22
|
+
getDisplayRoot,
|
|
23
|
+
indexedFileIsGone
|
|
24
|
+
} from "./token-goat-chunk-7IN2MKDS.mjs";
|
|
25
|
+
import {
|
|
26
|
+
countNoun
|
|
27
|
+
} from "./token-goat-chunk-GOLEOXZP.mjs";
|
|
28
|
+
import {
|
|
29
|
+
foldPath
|
|
30
|
+
} from "./token-goat-chunk-AM5V6GSX.mjs";
|
|
31
|
+
import {
|
|
32
|
+
displaySafeJson,
|
|
33
|
+
normalizePath,
|
|
34
|
+
resolveIndexPath,
|
|
35
|
+
toDisplayPath
|
|
36
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
37
|
+
import {
|
|
38
|
+
globalDbPath
|
|
39
|
+
} from "./token-goat-chunk-VES7EL7O.mjs";
|
|
40
|
+
import {
|
|
41
|
+
init_define_import_meta_env
|
|
42
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
43
|
+
|
|
44
|
+
// src/reconcile.ts
|
|
45
|
+
init_define_import_meta_env();
|
|
46
|
+
import * as fs from "node:fs";
|
|
47
|
+
var DEFAULT_RECONCILE_BUDGET_MS = 1500;
|
|
48
|
+
function readReconcileCursor(dbPath, root) {
|
|
49
|
+
try {
|
|
50
|
+
const row = getDb(dbPath).prepare("SELECT last_scanned_path FROM reconcile_cursor WHERE root = ?").get(root);
|
|
51
|
+
return row?.last_scanned_path ?? null;
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function writeReconcileCursor(dbPath, root, lastScannedPath) {
|
|
57
|
+
try {
|
|
58
|
+
getDb(dbPath).prepare(
|
|
59
|
+
"INSERT INTO reconcile_cursor (root, last_scanned_path, updated_at) VALUES (?, ?, ?) ON CONFLICT(root) DO UPDATE SET last_scanned_path = excluded.last_scanned_path, updated_at = excluded.updated_at"
|
|
60
|
+
).run(root, lastScannedPath, Date.now());
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function clearReconcileCursor(dbPath, root) {
|
|
65
|
+
try {
|
|
66
|
+
getDb(dbPath).prepare("DELETE FROM reconcile_cursor WHERE root = ?").run(root);
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function runReconcile(opts = {}) {
|
|
71
|
+
const raw = reconcileProject(opts);
|
|
72
|
+
const root = getDisplayRoot(opts.cwd ?? process.cwd());
|
|
73
|
+
const display = (paths) => paths.map((p) => toDisplayPath(root, p)).sort();
|
|
74
|
+
const result = {
|
|
75
|
+
...raw,
|
|
76
|
+
changed: display(raw.changed),
|
|
77
|
+
added: display(raw.added),
|
|
78
|
+
removed: display(raw.removed)
|
|
79
|
+
};
|
|
80
|
+
if (opts.json === true) {
|
|
81
|
+
process.stdout.write(`${displaySafeJson(result)}
|
|
82
|
+
`);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
const unqueued = opts.dryRun === true ? 0 : result.changed.length + result.added.length + result.removed.length - result.enqueued;
|
|
86
|
+
const noneQueued = unqueued > 0 && result.enqueued === 0;
|
|
87
|
+
const lines = [];
|
|
88
|
+
if (isReconcileClean(result)) {
|
|
89
|
+
if (!result.trackedUnavailable) {
|
|
90
|
+
lines.push(`Index matches disk: ${countNoun(result.scanned, "file")} checked in ${result.elapsedMs}ms.`);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
const verb = opts.dryRun === true ? "would reindex" : noneQueued ? "not queued" : "queued for reindexing";
|
|
94
|
+
const dropVerb = opts.dryRun === true ? "would drop from the index" : noneQueued ? "not queued" : "queued for removal";
|
|
95
|
+
if (result.changed.length > 0) lines.push(`${countNoun(result.changed.length, "file")} changed since indexing (${verb}):`);
|
|
96
|
+
for (const f of result.changed) lines.push(` ~ ${f}`);
|
|
97
|
+
if (result.added.length > 0) lines.push(`${countNoun(result.added.length, "file")} not in the index (${verb}):`);
|
|
98
|
+
for (const f of result.added) lines.push(` + ${f}`);
|
|
99
|
+
if (result.removed.length > 0) lines.push(`${countNoun(result.removed.length, "file")} indexed but gone from disk (${dropVerb}):`);
|
|
100
|
+
for (const f of result.removed) lines.push(` - ${f}`);
|
|
101
|
+
lines.push(`Checked ${countNoun(result.scanned, "file")} in ${result.elapsedMs}ms.`);
|
|
102
|
+
}
|
|
103
|
+
if (result.mtimeOnly > 0) {
|
|
104
|
+
lines.push(`${countNoun(result.mtimeOnly, "file")} had a newer timestamp but identical content, so ${result.mtimeOnly === 1 ? "it was" : "they were"} left alone.`);
|
|
105
|
+
}
|
|
106
|
+
if (result.parserStale > 0) {
|
|
107
|
+
const reparseVerb = opts.dryRun === true ? "would reparse" : noneQueued ? "not queued" : "queued for reparse";
|
|
108
|
+
lines.push(`${countNoun(result.parserStale, "file")} of the above ${result.parserStale === 1 ? "was" : "were"} unchanged on disk but indexed by an older parser (${reparseVerb}).`);
|
|
109
|
+
}
|
|
110
|
+
if (result.embedStale > 0) {
|
|
111
|
+
const reembedVerb = opts.dryRun === true ? "would re-embed" : noneQueued ? "not queued" : "queued for re-embedding";
|
|
112
|
+
lines.push(`${countNoun(result.embedStale, "file")} of the above ${result.embedStale === 1 ? "was" : "were"} unchanged on disk but held out-of-date embeddings (${reembedVerb}).`);
|
|
113
|
+
}
|
|
114
|
+
if (unqueued > 0) {
|
|
115
|
+
lines.push(`${countNoun(unqueued, "file")} of the above could not be queued for reindexing: the queue takes nothing under the OS temp dir, and nothing at all when it cannot be written. Run token-goat index here to bring the index up to date.`);
|
|
116
|
+
}
|
|
117
|
+
if (result.trackedUnavailable) {
|
|
118
|
+
lines.push("This project has an index but git listed no files in it, so nothing on disk was compared against it and changed or new files could not be found. Files gone from disk were still detected. Run token-goat inside the repository, or reindex with --walk if this directory is deliberately not under git.");
|
|
119
|
+
}
|
|
120
|
+
if (result.budgetExhausted) {
|
|
121
|
+
lines.push(`Stopped at the ${result.elapsedMs}ms budget with ${countNoun(result.unscanned, "file")} unchecked, so there may be more drift; deletions were not computed at all, because an unchecked file is indistinguishable from a deleted one. Raise --budget-ms for a complete sweep.`);
|
|
122
|
+
}
|
|
123
|
+
process.stdout.write(`${lines.join("\n")}
|
|
124
|
+
`);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
function isReconcileClean(r) {
|
|
128
|
+
return r.changed.length === 0 && r.added.length === 0 && r.removed.length === 0;
|
|
129
|
+
}
|
|
130
|
+
function reconcileProject(opts = {}) {
|
|
131
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
132
|
+
const budgetMs = opts.budgetMs ?? DEFAULT_RECONCILE_BUDGET_MS;
|
|
133
|
+
const calledAt = Date.now();
|
|
134
|
+
const dbPath = opts.dbPath ?? globalDbPath();
|
|
135
|
+
const tracked = getTrackedFiles(cwd);
|
|
136
|
+
const projectRoot = resolveIndexPath(".", cwd);
|
|
137
|
+
const indexed = getProjectFileEntries(projectRoot, dbPath);
|
|
138
|
+
const chunkScope = projectScopeClause("file_path");
|
|
139
|
+
const chunked = new Set(
|
|
140
|
+
getDb(dbPath).prepare(`SELECT DISTINCT file_path FROM chunks WHERE ${chunkScope.clause}`).pluck().all(...chunkScope.params(projectRoot)).map((p) => foldPath(normalizePath(p)))
|
|
141
|
+
);
|
|
142
|
+
const startedAt = Date.now();
|
|
143
|
+
let scanOrder = tracked;
|
|
144
|
+
const cursorPath = tracked.length > 0 ? readReconcileCursor(dbPath, projectRoot) : null;
|
|
145
|
+
if (cursorPath !== null) {
|
|
146
|
+
const cursorFolded = foldPath(normalizePath(cursorPath));
|
|
147
|
+
const cursorIdx = tracked.findIndex((f) => foldPath(normalizePath(f)) === cursorFolded);
|
|
148
|
+
if (cursorIdx !== -1) {
|
|
149
|
+
scanOrder = [...tracked.slice(cursorIdx + 1), ...tracked.slice(0, cursorIdx + 1)];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const changed = [];
|
|
153
|
+
const added = [];
|
|
154
|
+
const seenOnDisk = /* @__PURE__ */ new Set();
|
|
155
|
+
let mtimeOnly = 0;
|
|
156
|
+
let parserStale = 0;
|
|
157
|
+
let embedStale = 0;
|
|
158
|
+
let scanned = 0;
|
|
159
|
+
let budgetExhausted = false;
|
|
160
|
+
let lastScanned = null;
|
|
161
|
+
for (const file of scanOrder) {
|
|
162
|
+
if (Date.now() - startedAt >= budgetMs) {
|
|
163
|
+
budgetExhausted = true;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
scanned++;
|
|
167
|
+
lastScanned = file;
|
|
168
|
+
const normalized = normalizePath(file);
|
|
169
|
+
const folded = foldPath(normalized);
|
|
170
|
+
seenOnDisk.add(folded);
|
|
171
|
+
const entry = indexed.get(folded);
|
|
172
|
+
if (entry === void 0) {
|
|
173
|
+
added.push(file);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (entry.parserSha !== parserFingerprintForLanguage(entry.language)) {
|
|
177
|
+
changed.push(file);
|
|
178
|
+
parserStale++;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (entry.embedSha === "" && chunked.has(folded)) {
|
|
182
|
+
changed.push(file);
|
|
183
|
+
embedStale++;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (normalizePath(entry.filePath).slice(projectRoot.length) !== normalized.slice(projectRoot.length) && indexedPathSpellingIsStale(entry.filePath, file)) {
|
|
187
|
+
changed.push(file);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
let mtimeMs;
|
|
191
|
+
try {
|
|
192
|
+
mtimeMs = fs.statSync(file).mtimeMs;
|
|
193
|
+
} catch {
|
|
194
|
+
changed.push(file);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (entry.mtime !== 0 && mtimeMs / 1e3 === entry.mtime) continue;
|
|
198
|
+
const diskSha = fingerprintFile(file);
|
|
199
|
+
if (diskSha === null) {
|
|
200
|
+
changed.push(file);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (diskSha === entry.sha) {
|
|
204
|
+
mtimeOnly++;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
changed.push(file);
|
|
208
|
+
}
|
|
209
|
+
const trackedUnavailable = tracked.length === 0 && indexed.size > 0;
|
|
210
|
+
const removed = [];
|
|
211
|
+
if (!budgetExhausted) {
|
|
212
|
+
for (const [folded, entry] of indexed) {
|
|
213
|
+
if (seenOnDisk.has(folded)) continue;
|
|
214
|
+
if (Date.now() - startedAt >= budgetMs) {
|
|
215
|
+
budgetExhausted = true;
|
|
216
|
+
removed.length = 0;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (indexedFileIsGone(entry.filePath)) removed.push(entry.filePath);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let enqueued = 0;
|
|
223
|
+
if (opts.dryRun !== true) {
|
|
224
|
+
const toEnqueue = [...changed, ...added, ...removed].map((p) => resolveIndexPath(p, cwd));
|
|
225
|
+
enqueued = enqueueDirtyPathsSafe(toEnqueue, { alreadyResolved: true });
|
|
226
|
+
if (budgetExhausted) {
|
|
227
|
+
if (lastScanned !== null) writeReconcileCursor(dbPath, projectRoot, lastScanned);
|
|
228
|
+
} else if (tracked.length > 0) {
|
|
229
|
+
clearReconcileCursor(dbPath, projectRoot);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
scanned,
|
|
234
|
+
changed,
|
|
235
|
+
added,
|
|
236
|
+
removed,
|
|
237
|
+
mtimeOnly,
|
|
238
|
+
parserStale,
|
|
239
|
+
embedStale,
|
|
240
|
+
budgetExhausted,
|
|
241
|
+
trackedUnavailable,
|
|
242
|
+
unscanned: Math.max(0, tracked.length - scanned),
|
|
243
|
+
enqueued,
|
|
244
|
+
elapsedMs: Date.now() - calledAt
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export {
|
|
249
|
+
DEFAULT_RECONCILE_BUDGET_MS,
|
|
250
|
+
runReconcile,
|
|
251
|
+
isReconcileClean,
|
|
252
|
+
reconcileProject
|
|
253
|
+
};
|
|
@@ -2,28 +2,32 @@ import { createRequire as __cjsRequire } from 'node:module';
|
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
deliveredOutputBytes
|
|
5
|
-
} from "./token-goat-chunk-
|
|
5
|
+
} from "./token-goat-chunk-54K3EUV3.mjs";
|
|
6
6
|
import {
|
|
7
7
|
PassthroughFilter,
|
|
8
|
+
TOOL_FILTERS,
|
|
8
9
|
compressedTokensSaved,
|
|
9
10
|
deliverCompressed,
|
|
10
11
|
dispatchArgv,
|
|
11
12
|
filterByName,
|
|
12
13
|
selectFilter
|
|
13
|
-
} from "./token-goat-chunk-
|
|
14
|
+
} from "./token-goat-chunk-COBQGL5S.mjs";
|
|
14
15
|
import {
|
|
15
16
|
storeBashOutputSync
|
|
16
|
-
} from "./token-goat-chunk-
|
|
17
|
-
import {
|
|
18
|
-
capTokens,
|
|
19
|
-
shlexSplit
|
|
20
|
-
} from "./token-goat-chunk-2WOUYWLM.mjs";
|
|
17
|
+
} from "./token-goat-chunk-AFLYLHDH.mjs";
|
|
21
18
|
import {
|
|
22
19
|
recordStat
|
|
23
|
-
} from "./token-goat-chunk-
|
|
20
|
+
} from "./token-goat-chunk-3Z5S4KGM.mjs";
|
|
24
21
|
import {
|
|
25
22
|
loadConfig
|
|
26
|
-
} from "./token-goat-chunk-
|
|
23
|
+
} from "./token-goat-chunk-7IN2MKDS.mjs";
|
|
24
|
+
import {
|
|
25
|
+
displaySafeText
|
|
26
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
27
|
+
import {
|
|
28
|
+
capTokens,
|
|
29
|
+
shlexSplit
|
|
30
|
+
} from "./token-goat-chunk-KWPNJBDH.mjs";
|
|
27
31
|
import {
|
|
28
32
|
init_define_import_meta_env
|
|
29
33
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -185,6 +189,8 @@ function resolveFilter(command, filterName, cwd) {
|
|
|
185
189
|
if (filterName) {
|
|
186
190
|
const named = filterByName(filterName);
|
|
187
191
|
if (named !== null) return { filter: named, argv };
|
|
192
|
+
const filter = split === null ? null : selectFilter(split, effectiveCwd);
|
|
193
|
+
return { filter, argv, unknownFilter: filterName };
|
|
188
194
|
}
|
|
189
195
|
if (split === null) return { filter: null, argv };
|
|
190
196
|
return { filter: selectFilter(split, effectiveCwd), argv };
|
|
@@ -201,7 +207,7 @@ function spawnTarget(command, nativeShell, shellType) {
|
|
|
201
207
|
"-NoProfile",
|
|
202
208
|
"-NonInteractive",
|
|
203
209
|
"-Command",
|
|
204
|
-
|
|
210
|
+
`$TgC = $env:TG_CMD; Remove-Item Env:TG_CMD -ErrorAction SilentlyContinue; $global:TgOk = $true; $TgN = [Environment]::NewLine; $TgK = 'if ($global:TgOk = $?) { }'; $TgT = $null; $TgE = $null; $TgA = [System.Management.Automation.Language.Parser]::ParseInput($TgC, [ref]$TgT, [ref]$TgE); $TgX = [System.Collections.Generic.List[object]]::new(); $TgL = [System.Collections.Generic.List[string]]::new(); $TgTop = { param($n) $p = $n.Parent; while ($p -isnot [System.Management.Automation.Language.ScriptBlockAst]) { $p = $p.Parent }; [object]::ReferenceEquals($p, $TgA) }; if ($TgE.Count -eq 0) { if ($TgA.EndBlock.Unnamed) { $TgX.Add([pscustomobject]@{ P = $TgC.Length; O = 0; L = 0; T = ($TgN + $TgK) }) }; foreach ($TgB in @($TgA.BeginBlock, $TgA.ProcessBlock, $TgA.EndBlock, $TgA.CleanBlock)) { if ($TgB -and -not $TgB.Unnamed) { $TgX.Add([pscustomobject]@{ P = ($TgB.Extent.EndOffset - 1); O = 0; L = 0; T = ($TgN + $TgK + $TgN) }) } }; foreach ($TgR in $TgA.FindAll({ param($n) $n -is [System.Management.Automation.Language.ReturnStatementAst] -and (& $TgTop $n) }, $true)) { if ($TgR.Pipeline -and $TgR.Pipeline.GetPureExpression()) { $TgX.Add([pscustomobject]@{ P = $TgR.Extent.StartOffset; O = 1; L = 6; T = '$TgW = (' }); $TgX.Add([pscustomobject]@{ P = $TgR.Extent.EndOffset; O = 1; L = 0; T = '), $?; $global:TgOk = $TgW[1]; return $TgW[0]' }) } else { $TgX.Add([pscustomobject]@{ P = $TgR.Extent.StartOffset; O = 1; L = 6; T = 'return $(' }); $TgX.Add([pscustomobject]@{ P = $TgR.Extent.EndOffset; O = 1; L = 0; T = $(if ($TgR.Pipeline) { '; ' + $TgK + ')' } else { $TgK + ')' }) }) } }; $TgD = @($TgA.FindAll({ param($n) $n -is [System.Management.Automation.Language.LabeledStatementAst] -and $n.Label }, $true) | ForEach-Object { $_.Label } | Select-Object -Unique); foreach ($TgR in $TgA.FindAll({ param($n) ($n -is [System.Management.Automation.Language.BreakStatementAst] -or $n -is [System.Management.Automation.Language.ContinueStatementAst]) -and (& $TgTop $n) }, $true)) { $TgX.Add([pscustomobject]@{ P = $TgR.Extent.StartOffset; O = 0; L = 0; T = ($TgK + '; ') }); if ($TgR.Label -is [System.Management.Automation.Language.StringConstantExpressionAst]) { if ($TgR.Label.Value -eq '') { } elseif ($TgD -contains $TgR.Label.Value) { $TgL.Add($TgR.Label.Value) } else { $TgX.Add([pscustomobject]@{ P = $TgR.Label.Extent.StartOffset; O = 1; L = $TgR.Label.Extent.Text.Length; T = 'TgEsc' }); $TgL.Add('TgEsc') } } elseif ($TgR.Label) { $TgX.Add([pscustomobject]@{ P = $TgR.Label.Extent.StartOffset; O = 1; L = $TgR.Label.Extent.Text.Length; T = ('$(if ((-not [string]($TgV = (' + $TgR.Label.Extent.Text + '))) -or (@(' + (($TgD | ForEach-Object { "'" + $_ + "'" }) -join ',') + ') -contains $TgV)) { $TgV } else { ''TgEsc'' }; if (-not $global:TgOk) { Microsoft.PowerShell.Utility\\Write-Error TgRestore -ErrorAction Ignore })') }); foreach ($TgI in $TgD) { $TgL.Add($TgI) }; $TgL.Add('TgEsc') } }; foreach ($TgR in $TgA.FindAll({ param($n) $n -is [System.Management.Automation.Language.TryStatementAst] -and $n.Finally -and $n.Finally.Statements.Count -gt 0 -and (& $TgTop $n) }, $true)) { $TgX.Add([pscustomobject]@{ P = ($TgR.Finally.Extent.EndOffset - 1); O = 0; L = 0; T = ($TgN + $TgK + $TgN) }) } } else { throw [System.Management.Automation.ParseException]::new($TgE) }; $TgS = $TgC; foreach ($TgI in ($TgX | Sort-Object -Property @{ Expression = 'P'; Descending = $true }, @{ Expression = 'O'; Descending = $false })) { $TgS = $TgS.Substring(0, $TgI.P) + $TgI.T + $TgS.Substring($TgI.P + $TgI.L) }; $TgO = $(if ($PSVersionTable.PSVersion.Major -lt 6) { 'do { @() | & ([scriptblock]::Create($TgS)) } while ($false)' } else { 'do { & ([scriptblock]::Create($TgS)) } while ($false)' }); foreach ($TgI in ($TgL | Select-Object -Unique)) { $TgO = ':' + $TgI + ' do { ' + $TgO + ' } while ($false)' }; . ([scriptblock]::Create($TgO)); if ($global:TgOk) { exit 0 } else { exit 1 }`
|
|
205
211
|
],
|
|
206
212
|
shell: false,
|
|
207
213
|
cmdEnv: { TG_CMD: command }
|
|
@@ -235,9 +241,19 @@ function resolveCompressLimits() {
|
|
|
235
241
|
return { maxLines: 1e3, maxBytes: 64 * 1024 };
|
|
236
242
|
}
|
|
237
243
|
}
|
|
244
|
+
function unknownFilterNotice(name, fallback) {
|
|
245
|
+
const typed = name.toLowerCase();
|
|
246
|
+
const names = ["generic", "passthrough", ...new Set(TOOL_FILTERS.map((f) => f.name))];
|
|
247
|
+
const near = names.filter((n) => n.split("-").some((word) => word.startsWith(typed)) || typed.startsWith(n)).slice(0, 5);
|
|
248
|
+
const instead = fallback === null ? "running it uncompressed" : `auto-detected ${fallback.name}`;
|
|
249
|
+
const hint = near.length > 0 ? `; did you mean ${near.join(", ")}?` : "";
|
|
250
|
+
return `[token-goat: no filter named "${displaySafeText(name)}", ${instead}${hint}]
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
238
253
|
async function run(command, opts = {}) {
|
|
239
254
|
const timeout = opts.timeout ?? DEFAULT_TIMEOUT_SECONDS;
|
|
240
|
-
const { filter, argv } = resolveFilter(command, opts.filterName, opts.cwd);
|
|
255
|
+
const { filter, argv, unknownFilter } = resolveFilter(command, opts.filterName, opts.cwd);
|
|
256
|
+
if (unknownFilter !== void 0) (opts.writeStderr ?? ((s) => process.stderr.write(s)))(unknownFilterNotice(unknownFilter, filter));
|
|
241
257
|
if (filter === null) {
|
|
242
258
|
if ((opts.maxTokens ?? 0) > 0 || opts.quietSuccess) {
|
|
243
259
|
return wrapAndCompress(command, argv, new PassthroughFilter(), timeout, resolveProfile(opts.compressionProfile), opts);
|
|
@@ -258,6 +274,11 @@ function passthrough(command, timeout, cwd, env, nativeShell, shellType) {
|
|
|
258
274
|
stdio: "inherit"
|
|
259
275
|
});
|
|
260
276
|
if (isTimeout(result.error)) return 124;
|
|
277
|
+
if (result.error) {
|
|
278
|
+
process.stderr.write(`[token-goat: ${displaySafeText(result.error.message)}]
|
|
279
|
+
`);
|
|
280
|
+
return 127;
|
|
281
|
+
}
|
|
261
282
|
if (result.status !== null) return result.status;
|
|
262
283
|
if (result.signal) return signalExitCode(result.signal);
|
|
263
284
|
return 0;
|
|
@@ -297,7 +318,12 @@ async function wrapAndCompress(command, argv, filter, timeout, profile, opts) {
|
|
|
297
318
|
};
|
|
298
319
|
child.stdout?.on("data", onData(stdoutSink));
|
|
299
320
|
child.stderr?.on("data", onData(stderrSink));
|
|
321
|
+
let spawnError = null;
|
|
300
322
|
const { code, signal } = await new Promise((resolve) => {
|
|
323
|
+
child.on("error", (e) => {
|
|
324
|
+
spawnError = e;
|
|
325
|
+
resolve({ code: 127, signal: null });
|
|
326
|
+
});
|
|
301
327
|
child.on("close", (code2, signal2) => resolve({ code: code2, signal: signal2 }));
|
|
302
328
|
});
|
|
303
329
|
heartbeat.stop();
|
|
@@ -308,6 +334,7 @@ async function wrapAndCompress(command, argv, filter, timeout, profile, opts) {
|
|
|
308
334
|
stdoutText += `
|
|
309
335
|
[token-goat: capture capped at ${MAX_CAPTURE_BYTES / (1024 * 1024)} MiB]`;
|
|
310
336
|
}
|
|
337
|
+
if (spawnError !== null) stderrText = (stderrText ? stderrText + "\n" : "") + `[token-goat: ${displaySafeText(spawnError.message)}]`;
|
|
311
338
|
let exitCode;
|
|
312
339
|
if (timedOut) {
|
|
313
340
|
exitCode = 124;
|
|
@@ -363,6 +390,8 @@ export {
|
|
|
363
390
|
MAX_CAPTURE_BYTES,
|
|
364
391
|
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
365
392
|
resolveFilter,
|
|
393
|
+
spawnTarget,
|
|
394
|
+
unknownFilterNotice,
|
|
366
395
|
run,
|
|
367
396
|
runRaw
|
|
368
397
|
};
|