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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_define_import_meta_env
|
|
5
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
6
|
+
|
|
7
|
+
// src/types.ts
|
|
8
|
+
init_define_import_meta_env();
|
|
9
|
+
var HOOK_EVENTS = [
|
|
10
|
+
"pre_tool_use",
|
|
11
|
+
"post_tool_use",
|
|
12
|
+
"notification",
|
|
13
|
+
"stop",
|
|
14
|
+
"pre_compact",
|
|
15
|
+
"post_compact",
|
|
16
|
+
"user_prompt_submit",
|
|
17
|
+
"subagent_stop",
|
|
18
|
+
"subagent_start",
|
|
19
|
+
"session_start",
|
|
20
|
+
"post_tool_use_failure"
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
HOOK_EVENTS
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
WorkerAlreadyRunningError,
|
|
5
|
+
WorkerDataDirUnwritableError,
|
|
6
|
+
appendWorkerErrorLog,
|
|
7
|
+
claimWorkerPidFile,
|
|
8
|
+
currentDaemonStamp,
|
|
9
|
+
dataDirWriteRefusal,
|
|
10
|
+
drainHeartbeatPathFor,
|
|
11
|
+
ensureWorkerAlive,
|
|
12
|
+
isWorkerRunning,
|
|
13
|
+
oneLogLine,
|
|
14
|
+
readPidFile,
|
|
15
|
+
resolvePollIntervalMs,
|
|
16
|
+
startDetachedWorker,
|
|
17
|
+
stopWorker,
|
|
18
|
+
workerErrorLogPath,
|
|
19
|
+
workerPidPath,
|
|
20
|
+
workerStampPath,
|
|
21
|
+
writeDrainHeartbeat
|
|
22
|
+
} from "./token-goat-chunk-5KDMCMF2.mjs";
|
|
23
|
+
import "./token-goat-chunk-GOLEOXZP.mjs";
|
|
24
|
+
import "./token-goat-chunk-AM5V6GSX.mjs";
|
|
25
|
+
import "./token-goat-chunk-FNFBKLRD.mjs";
|
|
26
|
+
import "./token-goat-chunk-VES7EL7O.mjs";
|
|
27
|
+
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
28
|
+
export {
|
|
29
|
+
WorkerAlreadyRunningError,
|
|
30
|
+
WorkerDataDirUnwritableError,
|
|
31
|
+
appendWorkerErrorLog,
|
|
32
|
+
claimWorkerPidFile,
|
|
33
|
+
currentDaemonStamp,
|
|
34
|
+
dataDirWriteRefusal,
|
|
35
|
+
drainHeartbeatPathFor,
|
|
36
|
+
ensureWorkerAlive,
|
|
37
|
+
isWorkerRunning,
|
|
38
|
+
oneLogLine,
|
|
39
|
+
readPidFile,
|
|
40
|
+
resolvePollIntervalMs,
|
|
41
|
+
startDetachedWorker,
|
|
42
|
+
stopWorker,
|
|
43
|
+
workerErrorLogPath,
|
|
44
|
+
workerPidPath,
|
|
45
|
+
workerStampPath,
|
|
46
|
+
writeDrainHeartbeat
|
|
47
|
+
};
|
|
@@ -2,7 +2,7 @@ import { createRequire as __cjsRequire } from 'node:module';
|
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
stripAnsiEscapes
|
|
5
|
-
} from "./token-goat-chunk-
|
|
5
|
+
} from "./token-goat-chunk-HAVAOB3S.mjs";
|
|
6
6
|
import {
|
|
7
7
|
init_define_import_meta_env
|
|
8
8
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -36,12 +36,24 @@ function clipWideLines(text, maxChars = INPUT_MAX_LINE_CHARS) {
|
|
|
36
36
|
let clipped = 0;
|
|
37
37
|
const out = text.split("\n").map((line) => {
|
|
38
38
|
if (line.length <= maxChars) return line;
|
|
39
|
+
const marker = CLIPPED_MARKER_RE.exec(line);
|
|
40
|
+
if (marker && line.length - marker[0].length <= maxChars) return line;
|
|
39
41
|
clipped += 1;
|
|
40
42
|
const keep = Math.floor(maxChars / 2);
|
|
41
43
|
return line.slice(0, keep) + ` ... [${line.length - maxChars} chars clipped] ... ` + line.slice(line.length - (maxChars - keep));
|
|
42
44
|
});
|
|
43
45
|
return clipped === 0 ? text : out.join("\n");
|
|
44
46
|
}
|
|
47
|
+
function isWholeJsonDocument(text) {
|
|
48
|
+
const t = text.trim();
|
|
49
|
+
if (t[0] !== "{" && t[0] !== "[") return false;
|
|
50
|
+
try {
|
|
51
|
+
JSON.parse(t);
|
|
52
|
+
return true;
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
45
57
|
function clampKeepingEnds(text, maxBytes) {
|
|
46
58
|
const buf = Buffer.from(text, "utf8");
|
|
47
59
|
if (buf.length <= maxBytes) return null;
|
|
@@ -195,7 +207,7 @@ function dedupeConsecutive(lines, opts = {}) {
|
|
|
195
207
|
let count = 0;
|
|
196
208
|
const flush = () => {
|
|
197
209
|
if (prev === null) return;
|
|
198
|
-
if (count >= minRun) out.push(fmt(prev, count));
|
|
210
|
+
if (count >= minRun) out.push(prev.trim() === "" ? "" : fmt(prev, count));
|
|
199
211
|
else for (let i = 0; i < count; i++) out.push(prev);
|
|
200
212
|
};
|
|
201
213
|
for (const line of lines) {
|
|
@@ -206,7 +218,7 @@ function dedupeConsecutive(lines, opts = {}) {
|
|
|
206
218
|
out.push(line);
|
|
207
219
|
continue;
|
|
208
220
|
}
|
|
209
|
-
if (line === prev) {
|
|
221
|
+
if (line === prev || prev !== null && prev.trim() === "" && line.trim() === "") {
|
|
210
222
|
count += 1;
|
|
211
223
|
continue;
|
|
212
224
|
}
|
|
@@ -723,6 +735,7 @@ function shlexSplit(cmd) {
|
|
|
723
735
|
if (has) tokens.push(cur);
|
|
724
736
|
return tokens;
|
|
725
737
|
}
|
|
738
|
+
var CLIP_MIN_OVERFLOW = 64;
|
|
726
739
|
function capLongLines(lines, maxChars = FALLBACK_MAX_LINE_CHARS) {
|
|
727
740
|
return lines.map((line) => {
|
|
728
741
|
if (line.length <= maxChars) return line;
|
|
@@ -732,6 +745,7 @@ function capLongLines(lines, maxChars = FALLBACK_MAX_LINE_CHARS) {
|
|
|
732
745
|
const high = line.charCodeAt(cut - 1);
|
|
733
746
|
const low = line.charCodeAt(cut);
|
|
734
747
|
if (high >= 55296 && high <= 56319 && low >= 56320 && low <= 57343) cut -= 1;
|
|
748
|
+
if (line.length - cut <= CLIP_MIN_OVERFLOW) return line;
|
|
735
749
|
const carried = priorClip !== null && priorClip.index >= cut ? Number(priorClip[1]) - priorClip[0].length : 0;
|
|
736
750
|
return `${line.slice(0, cut)} \u2026 [${line.length - cut + carried} chars elided]`;
|
|
737
751
|
});
|
|
@@ -907,14 +921,18 @@ export {
|
|
|
907
921
|
DEFAULT_MAX_LINES,
|
|
908
922
|
DEFAULT_MAX_BYTES,
|
|
909
923
|
MAX_INSPECT_BYTES,
|
|
924
|
+
DEFAULT_MAX_INPUT_BYTES,
|
|
925
|
+
FALLBACK_MAX_LINE_CHARS,
|
|
910
926
|
LONG_LINE_MAX_CHARS,
|
|
911
927
|
getMaxInputBytes,
|
|
912
928
|
INPUT_MAX_LINE_CHARS,
|
|
913
929
|
clipWideLines,
|
|
930
|
+
isWholeJsonDocument,
|
|
914
931
|
clampKeepingEnds,
|
|
915
932
|
compressionMarker,
|
|
916
933
|
combineStreams,
|
|
917
934
|
ERROR_SIGNAL_RE,
|
|
935
|
+
TABLE_ROW_ANOMALY_RE,
|
|
918
936
|
TIMESTAMP_PREFIX_RE,
|
|
919
937
|
REDIRECT_TOKEN_RE,
|
|
920
938
|
maskQuotedSpans,
|
|
@@ -924,9 +942,13 @@ export {
|
|
|
924
942
|
hasUnquotedOperator,
|
|
925
943
|
splitOwnTrailingNotices,
|
|
926
944
|
safeDecode,
|
|
945
|
+
sanitizeControlChars,
|
|
946
|
+
stripProgress,
|
|
927
947
|
normalise,
|
|
928
948
|
hasHighEntropyToken,
|
|
929
949
|
dedupeConsecutive,
|
|
950
|
+
dedupeNumericRuns,
|
|
951
|
+
truncateMiddle,
|
|
930
952
|
truncateMiddleSmart,
|
|
931
953
|
capBytes,
|
|
932
954
|
capTokens,
|
|
@@ -945,6 +967,8 @@ export {
|
|
|
945
967
|
resolvePackageManagerScript,
|
|
946
968
|
shlexSplit,
|
|
947
969
|
capLongLines,
|
|
970
|
+
GREP_MAX_LINE_CHARS,
|
|
971
|
+
grepLiteralPattern,
|
|
948
972
|
clipLongMatchLine,
|
|
949
973
|
clipGrepLines,
|
|
950
974
|
fallbackTruncate,
|
|
@@ -3,7 +3,7 @@ const require = __cjsRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
configPath,
|
|
5
5
|
dataDir
|
|
6
|
-
} from "./token-goat-chunk-
|
|
6
|
+
} from "./token-goat-chunk-VES7EL7O.mjs";
|
|
7
7
|
import {
|
|
8
8
|
init_define_import_meta_env
|
|
9
9
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -19,20 +19,35 @@ var PROTOCOL_VERSION = 1;
|
|
|
19
19
|
var SERVER_SLOTS = 3;
|
|
20
20
|
var MAX_FRAME_BYTES = 64 * 1024 * 1024;
|
|
21
21
|
var KEY_BYTES = 32;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var HARNESS_PROTOCOL_VERSION = 2;
|
|
23
|
+
function challengeMacV2(key, nc, ns, harness, noop, noops) {
|
|
24
|
+
return mac(key, "S", nc, ns, harness, noop, ...noops.flat());
|
|
25
|
+
}
|
|
26
|
+
function requestMacV2(key, nc, ns, harness, body) {
|
|
27
|
+
return mac(key, "C", nc, ns, harness, body);
|
|
28
|
+
}
|
|
29
|
+
function outFrameMac(key, nc, ns, seq, data) {
|
|
30
|
+
return mac(key, "O", nc, ns, String(seq), data);
|
|
31
|
+
}
|
|
32
|
+
function doneFrameMac(key, nc, ns, stdout, exit, n) {
|
|
33
|
+
return mac(key, "D", nc, ns, stdout, String(exit), String(n));
|
|
34
|
+
}
|
|
35
|
+
function resolveBundleDir(dir) {
|
|
24
36
|
try {
|
|
25
37
|
return fs.realpathSync.native(dir);
|
|
26
38
|
} catch {
|
|
27
39
|
return dir;
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
|
-
function
|
|
42
|
+
function bundleDir() {
|
|
43
|
+
return resolveBundleDir(path.dirname(fileURLToPath(import.meta.url)));
|
|
44
|
+
}
|
|
45
|
+
function endpointId(dir, bundle) {
|
|
31
46
|
const fold = (p) => process.platform === "win32" ? p.toLowerCase() : p;
|
|
32
|
-
return crypto.createHash("sha256").update(`${fold(dir)}\0${fold(
|
|
47
|
+
return crypto.createHash("sha256").update(`${fold(dir)}\0${fold(bundle)}`).digest("hex").slice(0, 16);
|
|
33
48
|
}
|
|
34
|
-
function endpointFor(slot, dir = dataDir()) {
|
|
35
|
-
const id = `${endpointId(dir)}-${slot}`;
|
|
49
|
+
function endpointFor(slot, dir = dataDir(), bundle = bundleDir()) {
|
|
50
|
+
const id = `${endpointId(dir, bundle)}-${slot}`;
|
|
36
51
|
if (process.platform === "win32") return String.raw`\\.\pipe\token-goat-hooks-` + id;
|
|
37
52
|
const inData = path.join(dir, `hooks-${id}.sock`);
|
|
38
53
|
if (Buffer.byteLength(inData) < 100) return inData;
|
|
@@ -103,7 +118,9 @@ function mac(key, ...parts) {
|
|
|
103
118
|
}
|
|
104
119
|
function macMatches(expected, actual) {
|
|
105
120
|
if (typeof actual !== "string" || actual.length !== expected.length) return false;
|
|
106
|
-
|
|
121
|
+
const want = Buffer.from(expected);
|
|
122
|
+
const got = Buffer.from(actual);
|
|
123
|
+
return want.length === got.length && crypto.timingSafeEqual(want, got);
|
|
107
124
|
}
|
|
108
125
|
function writeFrame(socket, message) {
|
|
109
126
|
socket.write(encodeFrame(message));
|
|
@@ -198,6 +215,11 @@ function launcherPath() {
|
|
|
198
215
|
export {
|
|
199
216
|
PROTOCOL_VERSION,
|
|
200
217
|
SERVER_SLOTS,
|
|
218
|
+
HARNESS_PROTOCOL_VERSION,
|
|
219
|
+
challengeMacV2,
|
|
220
|
+
requestMacV2,
|
|
221
|
+
outFrameMac,
|
|
222
|
+
doneFrameMac,
|
|
201
223
|
endpointFor,
|
|
202
224
|
serverKeyPath,
|
|
203
225
|
readServerKey,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MAX_RESUME_CHARS,
|
|
5
|
+
MAX_RESUME_TOKENS,
|
|
6
|
+
buildResumePacket
|
|
7
|
+
} from "./token-goat-chunk-FZ3NEW5O.mjs";
|
|
8
|
+
import "./token-goat-chunk-Q5VTGRH7.mjs";
|
|
9
|
+
import "./token-goat-chunk-Y776AENC.mjs";
|
|
10
|
+
import "./token-goat-chunk-SJHWVNDQ.mjs";
|
|
11
|
+
import "./token-goat-chunk-AFLYLHDH.mjs";
|
|
12
|
+
import "./token-goat-chunk-BPGCUMR7.mjs";
|
|
13
|
+
import "./token-goat-chunk-C63JQV5K.mjs";
|
|
14
|
+
import "./token-goat-chunk-JB6QN6VF.mjs";
|
|
15
|
+
import "./token-goat-chunk-EVMZJ27Z.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
|
+
MAX_RESUME_CHARS,
|
|
35
|
+
MAX_RESUME_TOKENS,
|
|
36
|
+
buildResumePacket
|
|
37
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_define_import_meta_env
|
|
5
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
6
|
+
|
|
7
|
+
// src/delivering_deny.ts
|
|
8
|
+
init_define_import_meta_env();
|
|
9
|
+
var DELIVERS_CONTENT_RE = /is inlined below instead of the full body|headings below instead of the full body|in place of the full file/;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
DELIVERS_CONTENT_RE
|
|
13
|
+
};
|
|
@@ -4,14 +4,12 @@ import {
|
|
|
4
4
|
parse
|
|
5
5
|
} from "./token-goat-chunk-3BTK54F3.mjs";
|
|
6
6
|
import {
|
|
7
|
+
compileGuardedRegexCached,
|
|
7
8
|
filtersFilteredToEmptyNotice
|
|
8
|
-
} from "./token-goat-chunk-
|
|
9
|
+
} from "./token-goat-chunk-GOLEOXZP.mjs";
|
|
9
10
|
import {
|
|
10
11
|
displaySafeText
|
|
11
|
-
} from "./token-goat-chunk-
|
|
12
|
-
import {
|
|
13
|
-
compileGuardedRegexCached
|
|
14
|
-
} from "./token-goat-chunk-JTKCQMQA.mjs";
|
|
12
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
15
13
|
import {
|
|
16
14
|
init_define_import_meta_env
|
|
17
15
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -21,12 +19,11 @@ init_define_import_meta_env();
|
|
|
21
19
|
var DELIMITER_CANDIDATES = [",", " ", ";", "|"];
|
|
22
20
|
var DELIMITER_SAMPLE_ROWS = 5;
|
|
23
21
|
function detectDelimiter(content) {
|
|
24
|
-
|
|
25
|
-
if (slice.trim() === "") return ",";
|
|
22
|
+
if (content.trim() === "") return ",";
|
|
26
23
|
for (const cand of DELIMITER_CANDIDATES) {
|
|
27
24
|
let rows;
|
|
28
25
|
try {
|
|
29
|
-
rows = parse(
|
|
26
|
+
rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter: cand, bom: true, relax_quotes: true, to: DELIMITER_SAMPLE_ROWS });
|
|
30
27
|
} catch {
|
|
31
28
|
continue;
|
|
32
29
|
}
|
|
@@ -39,7 +36,9 @@ function parseRecords(content, opts) {
|
|
|
39
36
|
const delimiter = opts.delimiter ?? detectDelimiter(content);
|
|
40
37
|
if (opts.noHeader === true) {
|
|
41
38
|
const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
|
|
42
|
-
|
|
39
|
+
const width = rows.reduce((max, row) => Math.max(max, row.length), 0);
|
|
40
|
+
const columns = Array.from({ length: width }, (_, i) => `col${i + 1}`);
|
|
41
|
+
return { records: rows.map((row) => Object.fromEntries(columns.map((name, i) => [name, row[i] ?? ""]))), columns };
|
|
43
42
|
}
|
|
44
43
|
const header = csvHeader(content, { ...opts, delimiter });
|
|
45
44
|
const dupes = header.filter((name, i) => name !== "" && header.indexOf(name) !== i);
|
|
@@ -49,14 +48,25 @@ function parseRecords(content, opts) {
|
|
|
49
48
|
`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
49
|
);
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
const records = parse(content, { columns: () => header, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
|
|
52
|
+
return { records, columns: header };
|
|
53
|
+
}
|
|
54
|
+
function nameBlankHeaders(raw) {
|
|
55
|
+
const taken = new Set(raw.filter((name) => name !== ""));
|
|
56
|
+
return raw.map((name, i) => {
|
|
57
|
+
if (name !== "") return name;
|
|
58
|
+
let synth = `col${i + 1}`;
|
|
59
|
+
while (taken.has(synth)) synth += "_";
|
|
60
|
+
taken.add(synth);
|
|
61
|
+
return synth;
|
|
62
|
+
});
|
|
53
63
|
}
|
|
54
64
|
function csvHeader(content, opts) {
|
|
55
65
|
if (opts.noHeader === true) return [];
|
|
56
66
|
const delimiter = opts.delimiter ?? detectDelimiter(content);
|
|
57
67
|
try {
|
|
58
68
|
const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, to: 1, relax_quotes: true });
|
|
59
|
-
return rows[0] ?? [];
|
|
69
|
+
return nameBlankHeaders(rows[0] ?? []);
|
|
60
70
|
} catch {
|
|
61
71
|
return [];
|
|
62
72
|
}
|
|
@@ -128,8 +138,8 @@ function matchesWhere(row, where) {
|
|
|
128
138
|
}
|
|
129
139
|
}
|
|
130
140
|
function queryCsv(content, opts) {
|
|
131
|
-
const records = parseRecords(content, opts);
|
|
132
|
-
const allColumns = records.length > 0 ?
|
|
141
|
+
const { records, columns: allHeader } = parseRecords(content, opts);
|
|
142
|
+
const allColumns = records.length > 0 ? allHeader : [];
|
|
133
143
|
const realHeader = records.length > 0 ? allColumns : csvHeader(content, opts);
|
|
134
144
|
const columns = opts.columns && opts.columns.length > 0 ? opts.columns : allColumns;
|
|
135
145
|
for (const c of columns) {
|
|
@@ -172,8 +182,8 @@ function formatCsvTable(result, activeFilters = []) {
|
|
|
172
182
|
return lines.join("\n");
|
|
173
183
|
}
|
|
174
184
|
function profileCsv(content, opts = {}) {
|
|
175
|
-
const records = parseRecords(content, opts);
|
|
176
|
-
const columns = records.length > 0 ?
|
|
185
|
+
const { records, columns: allHeader } = parseRecords(content, opts);
|
|
186
|
+
const columns = records.length > 0 ? allHeader : [];
|
|
177
187
|
return columns.map((col) => {
|
|
178
188
|
const values = records.map((r) => r[col] ?? "");
|
|
179
189
|
const nullCount = values.filter((v) => v.trim() === "").length;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
buildGuidanceBlock,
|
|
5
|
+
claudeMdPath,
|
|
6
|
+
codexAgentsPath,
|
|
7
|
+
copilotCliInstructionsPath,
|
|
8
|
+
isCodexInstalled,
|
|
9
|
+
isCopilotCliInstalled,
|
|
10
|
+
isInstalled
|
|
11
|
+
} from "./token-goat-chunk-OJBNYTJP.mjs";
|
|
12
|
+
import {
|
|
13
|
+
loadConfig
|
|
14
|
+
} from "./token-goat-chunk-7IN2MKDS.mjs";
|
|
15
|
+
import {
|
|
16
|
+
recordCreatedBy,
|
|
17
|
+
upsertDelimitedBlock
|
|
18
|
+
} from "./token-goat-chunk-GOLEOXZP.mjs";
|
|
19
|
+
import {
|
|
20
|
+
init_define_import_meta_env
|
|
21
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
22
|
+
|
|
23
|
+
// src/cli_doctor_guidance.ts
|
|
24
|
+
init_define_import_meta_env();
|
|
25
|
+
import * as fs from "node:fs";
|
|
26
|
+
import * as path from "node:path";
|
|
27
|
+
var INSTRUCTION_GATE_BEGIN = "<!-- token-goat-begin -->";
|
|
28
|
+
var INSTRUCTION_GATE_END = "<!-- token-goat-end -->";
|
|
29
|
+
var CODEX_GATE_BEGIN = "<!-- token-goat-codex-begin -->";
|
|
30
|
+
var CODEX_GATE_END = "<!-- token-goat-codex-end -->";
|
|
31
|
+
function findInstructionGateCandidates(rootDir = process.cwd()) {
|
|
32
|
+
const candidates = [];
|
|
33
|
+
const claudeMdPath2 = path.join(rootDir, "CLAUDE.md");
|
|
34
|
+
const claudeMdExists = fs.existsSync(claudeMdPath2);
|
|
35
|
+
let claudeMdHasGate = false;
|
|
36
|
+
if (claudeMdExists) {
|
|
37
|
+
try {
|
|
38
|
+
const content = fs.readFileSync(claudeMdPath2, "utf8");
|
|
39
|
+
claudeMdHasGate = content.includes(INSTRUCTION_GATE_BEGIN) && content.includes(INSTRUCTION_GATE_END);
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
candidates.push({
|
|
44
|
+
filename: "CLAUDE.md",
|
|
45
|
+
relativePath: "CLAUDE.md",
|
|
46
|
+
fullPath: claudeMdPath2,
|
|
47
|
+
harnessName: "Claude Code",
|
|
48
|
+
exists: claudeMdExists,
|
|
49
|
+
hasGate: claudeMdHasGate,
|
|
50
|
+
beginMarker: INSTRUCTION_GATE_BEGIN,
|
|
51
|
+
endMarker: INSTRUCTION_GATE_END,
|
|
52
|
+
fallbackToolClause: "Claude Code's own Read, Grep, and Glob preference rules"
|
|
53
|
+
});
|
|
54
|
+
const agentsMdPath = path.join(rootDir, "AGENTS.md");
|
|
55
|
+
const agentsMdExists = fs.existsSync(agentsMdPath);
|
|
56
|
+
let agentsMdHasGate = false;
|
|
57
|
+
if (agentsMdExists) {
|
|
58
|
+
try {
|
|
59
|
+
const content = fs.readFileSync(agentsMdPath, "utf8");
|
|
60
|
+
agentsMdHasGate = content.includes(CODEX_GATE_BEGIN) && content.includes(CODEX_GATE_END) || content.includes(INSTRUCTION_GATE_BEGIN) && content.includes(INSTRUCTION_GATE_END);
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
candidates.push({
|
|
65
|
+
filename: "AGENTS.md",
|
|
66
|
+
relativePath: "AGENTS.md",
|
|
67
|
+
fullPath: agentsMdPath,
|
|
68
|
+
harnessName: "Codex / AGENTS.md",
|
|
69
|
+
exists: agentsMdExists,
|
|
70
|
+
hasGate: agentsMdHasGate,
|
|
71
|
+
beginMarker: CODEX_GATE_BEGIN,
|
|
72
|
+
endMarker: CODEX_GATE_END,
|
|
73
|
+
fallbackToolClause: "Codex's native `exec`, `apply_patch`, and `view_image` tools (shell commands like `cat`/`type` run inside `exec`)"
|
|
74
|
+
});
|
|
75
|
+
const copilotInstructionsPath = path.join(rootDir, ".github", "copilot-instructions.md");
|
|
76
|
+
const copilotInstructionsExists = fs.existsSync(copilotInstructionsPath);
|
|
77
|
+
let copilotInstructionsHasGate = false;
|
|
78
|
+
if (copilotInstructionsExists) {
|
|
79
|
+
try {
|
|
80
|
+
const content = fs.readFileSync(copilotInstructionsPath, "utf8");
|
|
81
|
+
copilotInstructionsHasGate = content.includes(INSTRUCTION_GATE_BEGIN) && content.includes(INSTRUCTION_GATE_END);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
candidates.push({
|
|
86
|
+
filename: "copilot-instructions.md",
|
|
87
|
+
relativePath: path.join(".github", "copilot-instructions.md"),
|
|
88
|
+
fullPath: copilotInstructionsPath,
|
|
89
|
+
harnessName: "GitHub Copilot CLI",
|
|
90
|
+
exists: copilotInstructionsExists,
|
|
91
|
+
hasGate: copilotInstructionsHasGate,
|
|
92
|
+
beginMarker: INSTRUCTION_GATE_BEGIN,
|
|
93
|
+
endMarker: INSTRUCTION_GATE_END,
|
|
94
|
+
fallbackToolClause: "Copilot CLI's native `view`, `grep`, and `glob` tools (with PowerShell commands `Get-Content`/`Select-String` as search fallbacks)"
|
|
95
|
+
});
|
|
96
|
+
return candidates;
|
|
97
|
+
}
|
|
98
|
+
function fileHasGate(fullPath, markers) {
|
|
99
|
+
let content;
|
|
100
|
+
try {
|
|
101
|
+
content = fs.readFileSync(fullPath, "utf8");
|
|
102
|
+
} catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return markers.some(([begin, end]) => content.includes(begin) && content.includes(end));
|
|
106
|
+
}
|
|
107
|
+
function findActiveGlobalGates() {
|
|
108
|
+
const globals = [
|
|
109
|
+
{ fullPath: claudeMdPath(), markers: [[INSTRUCTION_GATE_BEGIN, INSTRUCTION_GATE_END]] },
|
|
110
|
+
{ fullPath: codexAgentsPath(), markers: [[CODEX_GATE_BEGIN, CODEX_GATE_END], [INSTRUCTION_GATE_BEGIN, INSTRUCTION_GATE_END]] },
|
|
111
|
+
{ fullPath: copilotCliInstructionsPath(), markers: [[INSTRUCTION_GATE_BEGIN, INSTRUCTION_GATE_END]] }
|
|
112
|
+
];
|
|
113
|
+
return globals.filter((g) => fileHasGate(g.fullPath, g.markers)).map((g) => g.fullPath);
|
|
114
|
+
}
|
|
115
|
+
function checkInstructionGates(rootDir = process.cwd()) {
|
|
116
|
+
const candidates = findInstructionGateCandidates(rootDir);
|
|
117
|
+
const existingFiles = candidates.filter((c) => c.exists);
|
|
118
|
+
const gatedFiles = existingFiles.filter((c) => c.hasGate);
|
|
119
|
+
const activeGlobal = findActiveGlobalGates();
|
|
120
|
+
if (gatedFiles.length > 0 || activeGlobal.length > 0) {
|
|
121
|
+
const names = [...activeGlobal, ...gatedFiles.map((c) => c.relativePath)].join(", ");
|
|
122
|
+
return {
|
|
123
|
+
name: "Instruction gate",
|
|
124
|
+
status: "ok",
|
|
125
|
+
message: `active in ${names}`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (existingFiles.length > 0) {
|
|
129
|
+
const unGated = existingFiles.map((c) => c.relativePath).join(", ");
|
|
130
|
+
return {
|
|
131
|
+
name: "Instruction gate",
|
|
132
|
+
status: "warn",
|
|
133
|
+
message: `missing in ${unGated} and in the user-level instruction files 'token-goat install' writes (agents will bypass token-goat and read whole files). Run 'token-goat doctor --fix' to inject automatically.`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
name: "Instruction gate",
|
|
138
|
+
status: "warn",
|
|
139
|
+
message: "missing: no user-level instruction file carries it and no project instruction file was found (CLAUDE.md, AGENTS.md, or .github/copilot-instructions.md). Run 'token-goat install', or 'token-goat doctor --fix' to create CLAUDE.md with the routing gate."
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function repairInstructionGates(rootDir = process.cwd()) {
|
|
143
|
+
const repairs = [];
|
|
144
|
+
const errors = [];
|
|
145
|
+
const candidates = findInstructionGateCandidates(rootDir);
|
|
146
|
+
if (candidates.some((c) => c.hasGate) || findActiveGlobalGates().length > 0) return { repairs, errors };
|
|
147
|
+
const existingUngated = candidates.filter((c) => c.exists);
|
|
148
|
+
const fallback = candidates[0];
|
|
149
|
+
if (!fallback) return { repairs, errors };
|
|
150
|
+
const targets = existingUngated.length > 0 ? existingUngated : [fallback];
|
|
151
|
+
const cfg = loadConfig(rootDir);
|
|
152
|
+
const gdrive = cfg.gdrive?.enabled ?? true;
|
|
153
|
+
for (const target of targets) {
|
|
154
|
+
try {
|
|
155
|
+
const block = buildGuidanceBlock({
|
|
156
|
+
beginMarker: target.beginMarker,
|
|
157
|
+
endMarker: target.endMarker,
|
|
158
|
+
fallbackToolClause: target.fallbackToolClause,
|
|
159
|
+
gdrive
|
|
160
|
+
});
|
|
161
|
+
recordCreatedBy([target.fullPath], () => {
|
|
162
|
+
fs.mkdirSync(path.dirname(target.fullPath), { recursive: true });
|
|
163
|
+
upsertDelimitedBlock(target.fullPath, target.beginMarker, target.endMarker, block);
|
|
164
|
+
});
|
|
165
|
+
repairs.push(`Injected token-goat routing gate into ${target.relativePath}`);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
errors.push(`Failed to inject routing gate into ${target.relativePath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return { repairs, errors };
|
|
171
|
+
}
|
|
172
|
+
function checkHarnessCacheEfficiency(rootDir = process.cwd()) {
|
|
173
|
+
const hasVscode = fs.existsSync(path.join(rootDir, ".vscode"));
|
|
174
|
+
const hasIdea = fs.existsSync(path.join(rootDir, ".idea"));
|
|
175
|
+
const hasCursor = fs.existsSync(path.join(rootDir, ".cursor")) || fs.existsSync(path.join(rootDir, ".cursorrules"));
|
|
176
|
+
const hasVs = fs.existsSync(path.join(rootDir, ".vs"));
|
|
177
|
+
const ideDetected = [
|
|
178
|
+
hasVscode && "VS Code",
|
|
179
|
+
hasIdea && "JetBrains",
|
|
180
|
+
hasCursor && "Cursor",
|
|
181
|
+
hasVs && "Visual Studio"
|
|
182
|
+
].filter(Boolean);
|
|
183
|
+
const hasClaude = fs.existsSync(path.join(rootDir, ".claude")) || fs.existsSync(path.join(rootDir, "CLAUDE.md"));
|
|
184
|
+
const hasCopilot = fs.existsSync(path.join(rootDir, ".github", "hooks")) || fs.existsSync(path.join(rootDir, ".github", "copilot-instructions.md"));
|
|
185
|
+
const hasCodex = fs.existsSync(path.join(rootDir, ".codex")) || fs.existsSync(path.join(rootDir, "AGENTS.md"));
|
|
186
|
+
const cliDetected = [
|
|
187
|
+
(hasClaude || isInstalled("user")) && "Claude Code",
|
|
188
|
+
(hasCopilot || isCopilotCliInstalled()) && "Copilot CLI",
|
|
189
|
+
(hasCodex || isCodexInstalled()) && "Codex"
|
|
190
|
+
].filter(Boolean);
|
|
191
|
+
if (ideDetected.length > 0 && cliDetected.length === 0) {
|
|
192
|
+
return {
|
|
193
|
+
name: "Harness efficiency",
|
|
194
|
+
status: "warn",
|
|
195
|
+
message: `${ideDetected.join(", ")} workspace detected without CLI harness config. IDE hooks cannot fold/trim built-in reads. If you also use a CLI agent, run 'token-goat install' for Claude Code, or 'token-goat install --codex' or '--copilot' for those.`
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (cliDetected.length > 0) {
|
|
199
|
+
return {
|
|
200
|
+
name: "Harness efficiency",
|
|
201
|
+
status: "ok",
|
|
202
|
+
message: `CLI harness configured (${cliDetected.join(", ")})`
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
INSTRUCTION_GATE_BEGIN,
|
|
210
|
+
INSTRUCTION_GATE_END,
|
|
211
|
+
CODEX_GATE_BEGIN,
|
|
212
|
+
CODEX_GATE_END,
|
|
213
|
+
findInstructionGateCandidates,
|
|
214
|
+
findActiveGlobalGates,
|
|
215
|
+
checkInstructionGates,
|
|
216
|
+
repairInstructionGates,
|
|
217
|
+
checkHarnessCacheEfficiency
|
|
218
|
+
};
|