token-goat 2.9.30 → 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 +24 -7
- package/SECURITY.md +10 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- 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/{token-goat-chunk-QSBRTGM2.mjs → token-goat-chunk-25TRAWET.mjs} +17 -7
- package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
- package/dist/{token-goat-chunk-IVKIZWAB.mjs → token-goat-chunk-2M7E4PF7.mjs} +41 -12
- package/dist/{token-goat-chunk-SMVRN2HU.mjs → token-goat-chunk-2UPZGKKY.mjs} +2 -2
- 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-KWPNJBDH.mjs → token-goat-chunk-4GILLLWY.mjs} +7 -4
- package/dist/{token-goat-chunk-67TQJ76B.mjs → token-goat-chunk-4NAPX7BA.mjs} +36 -3
- package/dist/{token-goat-chunk-PU7V3FD6.mjs → token-goat-chunk-4SC7UJYV.mjs} +3354 -2553
- package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
- package/dist/{token-goat-chunk-AFLYLHDH.mjs → token-goat-chunk-4ZBFWLXF.mjs} +283 -427
- package/dist/{token-goat-chunk-JDWCRD6M.mjs → token-goat-chunk-57BIAXJL.mjs} +73 -40
- package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
- package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
- package/dist/token-goat-chunk-646E6U44.mjs +398 -0
- package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
- package/dist/{token-goat-chunk-JN4XMLSD.mjs → token-goat-chunk-6DG6HWP3.mjs} +8 -2
- package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
- package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
- package/dist/{token-goat-chunk-VPBBTSJR.mjs → token-goat-chunk-76FGDLRO.mjs} +262 -255
- package/dist/{token-goat-chunk-7IN2MKDS.mjs → token-goat-chunk-7EZTZOMC.mjs} +121 -289
- package/dist/{token-goat-chunk-OJBNYTJP.mjs → token-goat-chunk-7MAOA6X4.mjs} +640 -80
- package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
- package/dist/{token-goat-chunk-PD5VKH46.mjs → token-goat-chunk-AUNGYYQX.mjs} +2 -2
- package/dist/{token-goat-chunk-HG45AF2B.mjs → token-goat-chunk-AUQYRMMH.mjs} +794 -37
- package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
- package/dist/{token-goat-chunk-A3CK6N5Z.mjs → token-goat-chunk-BA4HI6BW.mjs} +1309 -110
- package/dist/{token-goat-chunk-JB6QN6VF.mjs → token-goat-chunk-BFCWY73P.mjs} +59 -23
- package/dist/{token-goat-chunk-B45VMIIH.mjs → token-goat-chunk-BWGFUZZE.mjs} +7 -5
- package/dist/{token-goat-chunk-P4QMM4WK.mjs → token-goat-chunk-C75NA7PL.mjs} +50 -23
- package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
- package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
- package/dist/{token-goat-chunk-H2PHHGM5.mjs → token-goat-chunk-CIMQ2BB3.mjs} +57 -12
- package/dist/{token-goat-chunk-N2NMER56.mjs → token-goat-chunk-CJLS3CDL.mjs} +46 -4
- package/dist/{token-goat-chunk-VES7EL7O.mjs → token-goat-chunk-CO3UYX6G.mjs} +1 -1
- package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
- package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
- package/dist/{token-goat-chunk-4LCCNRTG.mjs → token-goat-chunk-CVCEVUGK.mjs} +8 -6
- package/dist/{token-goat-chunk-B2RZZCSS.mjs → token-goat-chunk-CXHOFN7R.mjs} +37 -20
- package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
- package/dist/{token-goat-chunk-APGZXSPS.mjs → token-goat-chunk-DGS2LVNA.mjs} +47 -30
- package/dist/{token-goat-chunk-54K3EUV3.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-5BCIJXMO.mjs → token-goat-chunk-EELTBKDM.mjs} +14 -10
- package/dist/{token-goat-chunk-W3QCJS6G.mjs → token-goat-chunk-F4HYL64R.mjs} +8 -6
- package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
- package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
- package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
- package/dist/{token-goat-chunk-C63JQV5K.mjs → token-goat-chunk-GL3ETKSC.mjs} +233 -15
- package/dist/token-goat-chunk-GVB2MUST.mjs +1298 -0
- package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
- package/dist/{token-goat-chunk-ZEJVMUQH.mjs → token-goat-chunk-HLPW63A7.mjs} +2 -2
- package/dist/{token-goat-chunk-GOLEOXZP.mjs → token-goat-chunk-HU4TORC5.mjs} +44 -26
- package/dist/{token-goat-chunk-Z57YODA2.mjs → token-goat-chunk-I7VKZZAW.mjs} +2 -2
- package/dist/{token-goat-chunk-NYKZLXMK.mjs → token-goat-chunk-IA6XSPE3.mjs} +6 -6
- package/dist/{token-goat-chunk-E3OQX2XT.mjs → token-goat-chunk-IAGXMHIK.mjs} +81 -42
- package/dist/{token-goat-chunk-HYBFA5X3.mjs → token-goat-chunk-IK2DRMFX.mjs} +24 -68
- package/dist/{token-goat-chunk-COBQGL5S.mjs → token-goat-chunk-INNPTRUX.mjs} +249 -299
- package/dist/{token-goat-chunk-7NADEDKJ.mjs → token-goat-chunk-JJ5BX4F4.mjs} +6 -1
- package/dist/{token-goat-chunk-PEPTHRFF.mjs → token-goat-chunk-JVFSHVFJ.mjs} +6 -6
- package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
- package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
- package/dist/{token-goat-chunk-Q5VTGRH7.mjs → token-goat-chunk-LCNQ2CNN.mjs} +55 -319
- 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-T4FK7VOV.mjs → token-goat-chunk-MHX7XCC3.mjs} +2 -1
- package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
- package/dist/{token-goat-chunk-LOBGHXPB.mjs → token-goat-chunk-N5MMR2IW.mjs} +1 -1
- package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
- package/dist/{token-goat-chunk-RHXKCZX3.mjs → token-goat-chunk-NISNMD7T.mjs} +2182 -2959
- package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
- package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
- package/dist/{token-goat-chunk-KQNZDCBD.mjs → token-goat-chunk-NSNSPPBG.mjs} +25 -3
- package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
- package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
- package/dist/{token-goat-chunk-JTQQGXZH.mjs → token-goat-chunk-ODBT2USM.mjs} +124 -57
- 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-DZX2YDPT.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -2
- package/dist/{token-goat-chunk-QCLDAQTS.mjs → token-goat-chunk-P6HQSWQ3.mjs} +50 -53
- package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
- package/dist/{token-goat-chunk-7BXSNBY5.mjs → token-goat-chunk-PFWIMH2E.mjs} +23 -15
- package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
- package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
- package/dist/{token-goat-chunk-GFBSN7BD.mjs → token-goat-chunk-PX5PQWTY.mjs} +22 -250
- package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
- package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
- package/dist/{token-goat-chunk-FBNQNSJK.mjs → token-goat-chunk-QH7YVYOY.mjs} +2198 -2782
- package/dist/{token-goat-chunk-64FBPDTK.mjs → token-goat-chunk-QLMUHEPB.mjs} +12 -9
- package/dist/{token-goat-chunk-RZRTDST7.mjs → token-goat-chunk-QQOJIHL3.mjs} +37 -11
- package/dist/{token-goat-chunk-XKI4SEMX.mjs → token-goat-chunk-QQTWJY2O.mjs} +19 -0
- package/dist/{token-goat-chunk-U4N3BN2W.mjs → token-goat-chunk-QYHO5CPH.mjs} +3 -2
- package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
- package/dist/{token-goat-chunk-ETBHVDB6.mjs → token-goat-chunk-RSLPOBKQ.mjs} +22 -11
- package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
- package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
- package/dist/{token-goat-chunk-4JJS54TR.mjs → token-goat-chunk-SOAFZNNZ.mjs} +161 -38
- package/dist/{token-goat-chunk-664RTTUV.mjs → token-goat-chunk-SRTHT7KV.mjs} +21 -16
- package/dist/{token-goat-chunk-4FVIAHSI.mjs → token-goat-chunk-T5P5ACNQ.mjs} +7 -6
- package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
- package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
- package/dist/{token-goat-chunk-COTXZHTS.mjs → token-goat-chunk-TM6MC754.mjs} +4 -3
- package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
- package/dist/{token-goat-chunk-3CHUNJ2O.mjs → token-goat-chunk-U2KSB4SG.mjs} +8 -5
- package/dist/{token-goat-chunk-3Z5S4KGM.mjs → token-goat-chunk-U4WHMG6Y.mjs} +29 -49
- package/dist/{token-goat-chunk-PY533T7F.mjs → token-goat-chunk-UGJHGR5A.mjs} +21 -15
- package/dist/{token-goat-chunk-CYCEYAEO.mjs → token-goat-chunk-UOUDVA5U.mjs} +1 -1
- package/dist/{token-goat-chunk-JDHE26RP.mjs → token-goat-chunk-URRJ33GR.mjs} +16 -5
- package/dist/{token-goat-chunk-56EIMS3E.mjs → token-goat-chunk-UZOROKIS.mjs} +23 -17
- package/dist/{token-goat-chunk-CZ3LUXYZ.mjs → token-goat-chunk-VIHGGGEI.mjs} +427 -308
- package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
- package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
- package/dist/{token-goat-chunk-YARZFCZS.mjs → token-goat-chunk-VWZA2H4P.mjs} +62 -53
- package/dist/{token-goat-chunk-SQSSNQPE.mjs → token-goat-chunk-VXEXMJDL.mjs} +3979 -4745
- package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
- package/dist/{token-goat-chunk-SJHWVNDQ.mjs → token-goat-chunk-WDH44VAU.mjs} +7 -4
- package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
- package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
- package/dist/{token-goat-chunk-FZ3NEW5O.mjs → token-goat-chunk-XLRBNZCC.mjs} +13 -8
- package/dist/{token-goat-chunk-Z44YO3QZ.mjs → token-goat-chunk-XRKUX6CM.mjs} +1 -1
- package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
- package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
- package/dist/{token-goat-chunk-WY3L4DVT.mjs → token-goat-chunk-Y2ZTQOCL.mjs} +13 -8
- package/dist/{token-goat-chunk-UQ5UK2T7.mjs → token-goat-chunk-YB4VMGK2.mjs} +1 -1
- package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
- package/dist/{token-goat-chunk-ZQSJMO2R.mjs → token-goat-chunk-YHVDKQBR.mjs} +105 -105
- package/dist/{token-goat-chunk-H2K3QP6H.mjs → token-goat-chunk-YJB5XLWI.mjs} +8 -6
- package/dist/{token-goat-chunk-ZCDTCVIS.mjs → token-goat-chunk-YKB6AQG3.mjs} +5 -2
- package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
- package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
- package/dist/{token-goat-chunk-HOJLCGDP.mjs → token-goat-chunk-YY6AVUFL.mjs} +2033 -2251
- package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
- package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
- package/dist/token-goat-hook-client.cjs +1 -1
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +67 -38
- package/dist/token-goat.core.mjs +4 -4
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +40 -21
- package/docs/install.md +19 -9
- package/docs/security.md +5 -3
- package/package.json +2 -1
- package/dist/token-goat-chunk-5KDMCMF2.mjs +0 -362
- package/dist/token-goat-chunk-6QMAS7AB.mjs +0 -42
- package/dist/token-goat-chunk-7F2UBPD3.mjs +0 -397
- package/dist/token-goat-chunk-ARDNEC2U.mjs +0 -248
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +0 -134
- package/dist/token-goat-chunk-EFHMMIGP.mjs +0 -68
- package/dist/token-goat-chunk-IVALLT3S.mjs +0 -48
- package/dist/token-goat-chunk-JDU3EXSU.mjs +0 -65
- package/dist/token-goat-chunk-MKPF4CL5.mjs +0 -37
- package/dist/token-goat-chunk-RC35RBUL.mjs +0 -312
- package/dist/token-goat-chunk-USILZ3T3.mjs +0 -53
- package/dist/token-goat-chunk-VL3YIFHZ.mjs +0 -2975
- package/dist/token-goat-chunk-XU4P6Z24.mjs +0 -133
- package/dist/token-goat-chunk-Y776AENC.mjs +0 -1597
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
registerReset
|
|
5
|
+
} from "./token-goat-chunk-YZAAZU2S.mjs";
|
|
6
|
+
import {
|
|
7
|
+
extractErrorMessage,
|
|
8
|
+
runGit
|
|
9
|
+
} from "./token-goat-chunk-HU4TORC5.mjs";
|
|
10
|
+
import {
|
|
11
|
+
canonicalize,
|
|
12
|
+
foldPath
|
|
13
|
+
} from "./token-goat-chunk-AM5V6GSX.mjs";
|
|
14
|
+
import {
|
|
15
|
+
normalizeDarwinSystemAlias
|
|
16
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
17
|
+
import {
|
|
18
|
+
init_define_import_meta_env
|
|
19
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
20
|
+
|
|
21
|
+
// src/fingerprint.ts
|
|
22
|
+
init_define_import_meta_env();
|
|
23
|
+
import { createHash } from "node:crypto";
|
|
24
|
+
import * as fs from "node:fs";
|
|
25
|
+
function fingerprintContent(content) {
|
|
26
|
+
const hash = createHash("sha256");
|
|
27
|
+
hash.update(typeof content === "string" ? Buffer.from(content, "utf-8") : content);
|
|
28
|
+
return hash.digest("hex");
|
|
29
|
+
}
|
|
30
|
+
function shortFingerprint(content) {
|
|
31
|
+
return fingerprintContent(content).slice(0, 16);
|
|
32
|
+
}
|
|
33
|
+
function indexedFileIsGone(filePath) {
|
|
34
|
+
return statIndexedFile(filePath) === "gone";
|
|
35
|
+
}
|
|
36
|
+
function statIndexedFile(filePath) {
|
|
37
|
+
try {
|
|
38
|
+
const st = fs.statSync(filePath);
|
|
39
|
+
return st.isFile() ? st : "gone";
|
|
40
|
+
} catch (err) {
|
|
41
|
+
const code = err?.code;
|
|
42
|
+
return code === "ENOENT" || code === "ENOTDIR" ? "gone" : null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function fingerprintFile(filePath) {
|
|
46
|
+
let data;
|
|
47
|
+
try {
|
|
48
|
+
data = fs.readFileSync(filePath);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return fingerprintContent(data);
|
|
53
|
+
}
|
|
54
|
+
function fileIsAbsent(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
return fs.statSync(filePath, { throwIfNoEntry: false }) === void 0;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/project.ts
|
|
63
|
+
init_define_import_meta_env();
|
|
64
|
+
import * as fs2 from "node:fs";
|
|
65
|
+
import * as os from "node:os";
|
|
66
|
+
import * as path from "node:path";
|
|
67
|
+
var PROJECT_MARKERS = [
|
|
68
|
+
".git",
|
|
69
|
+
"package.json",
|
|
70
|
+
"pyproject.toml",
|
|
71
|
+
"Cargo.toml",
|
|
72
|
+
"go.mod",
|
|
73
|
+
"shopify.app.toml",
|
|
74
|
+
"_config.yml",
|
|
75
|
+
"deno.json",
|
|
76
|
+
"deno.jsonc"
|
|
77
|
+
];
|
|
78
|
+
var REPO_CONTAINER_THRESHOLD = 3;
|
|
79
|
+
function projectHash(canonicalRoot) {
|
|
80
|
+
return shortFingerprint(foldPath(canonicalRoot));
|
|
81
|
+
}
|
|
82
|
+
function makeProjectAt(root) {
|
|
83
|
+
let canonical;
|
|
84
|
+
try {
|
|
85
|
+
canonical = canonicalize(root);
|
|
86
|
+
} catch (exc) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`makeProjectAt: could not resolve path: ${extractErrorMessage(exc)}`,
|
|
89
|
+
{ cause: exc }
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const stat = fs2.statSync(canonical);
|
|
94
|
+
if (!stat.isDirectory()) {
|
|
95
|
+
throw new Error(`makeProjectAt: path is not a directory: ${canonical}`);
|
|
96
|
+
}
|
|
97
|
+
} catch (exc) {
|
|
98
|
+
if (exc instanceof Error && exc.message.includes("ENOENT")) {
|
|
99
|
+
throw new Error(`makeProjectAt: path does not exist: ${canonical}`, { cause: exc });
|
|
100
|
+
}
|
|
101
|
+
throw exc;
|
|
102
|
+
}
|
|
103
|
+
const hash = projectHash(canonical);
|
|
104
|
+
return { root: canonical, hash, marker: "manual" };
|
|
105
|
+
}
|
|
106
|
+
function isRepoContainer(pathStr) {
|
|
107
|
+
let nestedRepos = 0;
|
|
108
|
+
try {
|
|
109
|
+
const entries = fs2.readdirSync(pathStr, { withFileTypes: true });
|
|
110
|
+
for (const entry of entries) {
|
|
111
|
+
if (entry.isDirectory()) {
|
|
112
|
+
const gitPath = path.join(pathStr, entry.name, ".git");
|
|
113
|
+
if (fs2.existsSync(gitPath)) {
|
|
114
|
+
let isGitDir = false;
|
|
115
|
+
try {
|
|
116
|
+
isGitDir = fs2.statSync(gitPath).isDirectory();
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
if (isGitDir) {
|
|
120
|
+
nestedRepos++;
|
|
121
|
+
if (nestedRepos >= REPO_CONTAINER_THRESHOLD) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
function markerExists(current, marker) {
|
|
134
|
+
const markerPath = path.join(current, marker);
|
|
135
|
+
try {
|
|
136
|
+
if (!fs2.existsSync(markerPath)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const stat = fs2.lstatSync(markerPath);
|
|
140
|
+
if (!stat.isSymbolicLink()) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const resolved = fs2.realpathSync(markerPath);
|
|
144
|
+
const rel = path.relative(path.resolve(current), path.resolve(resolved));
|
|
145
|
+
return !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function findProject(cwd) {
|
|
151
|
+
let p;
|
|
152
|
+
try {
|
|
153
|
+
p = canonicalize(cwd);
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
let sysTemp = null;
|
|
158
|
+
try {
|
|
159
|
+
sysTemp = canonicalize(os.tmpdir());
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
let current = p;
|
|
163
|
+
while (true) {
|
|
164
|
+
if (sysTemp && normalizeDarwinSystemAlias(foldPath(current)) === normalizeDarwinSystemAlias(foldPath(sysTemp))) {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
for (const marker of PROJECT_MARKERS) {
|
|
168
|
+
if (markerExists(current, marker)) {
|
|
169
|
+
if (!isRepoContainer(current)) {
|
|
170
|
+
return {
|
|
171
|
+
root: current,
|
|
172
|
+
hash: projectHash(current),
|
|
173
|
+
marker
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const parent = path.dirname(current);
|
|
180
|
+
if (parent === current) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
current = parent;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
var _displayRootCache = null;
|
|
188
|
+
function getDisplayRoot(explicitRoot) {
|
|
189
|
+
if (explicitRoot !== void 0) return explicitRoot;
|
|
190
|
+
const cwd = process.cwd();
|
|
191
|
+
if (_displayRootCache !== null && _displayRootCache.cwd === cwd) return _displayRootCache.root;
|
|
192
|
+
const project = findProject(cwd);
|
|
193
|
+
const root = project !== null ? project.root : void 0;
|
|
194
|
+
_displayRootCache = { cwd, root };
|
|
195
|
+
return root;
|
|
196
|
+
}
|
|
197
|
+
registerReset(() => {
|
|
198
|
+
_displayRootCache = null;
|
|
199
|
+
}, { perRequest: true });
|
|
200
|
+
function isUnderSystemTemp(filePath) {
|
|
201
|
+
let sysTemp;
|
|
202
|
+
try {
|
|
203
|
+
sysTemp = canonicalize(os.tmpdir());
|
|
204
|
+
} catch {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
let target;
|
|
208
|
+
try {
|
|
209
|
+
target = canonicalize(filePath);
|
|
210
|
+
} catch {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const foldedTemp = normalizeDarwinSystemAlias(foldPath(sysTemp));
|
|
214
|
+
const foldedTarget = normalizeDarwinSystemAlias(foldPath(target));
|
|
215
|
+
return foldedTarget === foldedTemp || foldedTarget.startsWith(`${foldedTemp}/`);
|
|
216
|
+
}
|
|
217
|
+
function resolveProjectRoot(opts) {
|
|
218
|
+
const base = opts?.project !== void 0 ? path.resolve(opts.project) : process.cwd();
|
|
219
|
+
const toplevel = runGit(["rev-parse", "--show-toplevel"], { cwd: base });
|
|
220
|
+
if (toplevel.exitCode === 0) {
|
|
221
|
+
const trimmed = toplevel.stdout.trim();
|
|
222
|
+
if (trimmed.length > 0) return canonicalize(trimmed);
|
|
223
|
+
}
|
|
224
|
+
const project = findProject(base);
|
|
225
|
+
if (project !== null) return project.root;
|
|
226
|
+
return canonicalize(base);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
fingerprintContent,
|
|
231
|
+
shortFingerprint,
|
|
232
|
+
indexedFileIsGone,
|
|
233
|
+
statIndexedFile,
|
|
234
|
+
fingerprintFile,
|
|
235
|
+
fileIsAbsent,
|
|
236
|
+
projectHash,
|
|
237
|
+
makeProjectAt,
|
|
238
|
+
findProject,
|
|
239
|
+
getDisplayRoot,
|
|
240
|
+
isUnderSystemTemp,
|
|
241
|
+
resolveProjectRoot
|
|
242
|
+
};
|
|
@@ -3,6 +3,9 @@ const require = __cjsRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
stripAnsiEscapes
|
|
5
5
|
} from "./token-goat-chunk-HAVAOB3S.mjs";
|
|
6
|
+
import {
|
|
7
|
+
countNoun
|
|
8
|
+
} from "./token-goat-chunk-HU4TORC5.mjs";
|
|
6
9
|
import {
|
|
7
10
|
init_define_import_meta_env
|
|
8
11
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -343,11 +346,11 @@ function capTokens(text, maxTokens) {
|
|
|
343
346
|
}
|
|
344
347
|
return truncated;
|
|
345
348
|
}
|
|
346
|
-
function headTailCompress(lines, head, tail,
|
|
349
|
+
function headTailCompress(lines, head, tail, noun = "item", plural = `${noun}s`) {
|
|
347
350
|
const total = lines.length;
|
|
348
351
|
if (total <= head + tail) return lines.join("\n");
|
|
349
352
|
const elided = total - head - tail;
|
|
350
|
-
return [...lines.slice(0, head), `... [${elided} more ${
|
|
353
|
+
return [...lines.slice(0, head), `... [${countNoun(elided, `more ${noun}`, `more ${plural}`)} elided by token-goat]`, ...lines.slice(total - tail)].join(
|
|
351
354
|
"\n"
|
|
352
355
|
);
|
|
353
356
|
}
|
|
@@ -365,7 +368,7 @@ function truncateTableRows(text, maxRows, hint) {
|
|
|
365
368
|
for (let i = 0; i < rows.length && wanted.size < maxRows; i++) wanted.add(i);
|
|
366
369
|
const kept = [...wanted].sort((a, b) => a - b);
|
|
367
370
|
const elided = rows.length - kept.length;
|
|
368
|
-
const note = anomalies ? `[token-goat: ${elided
|
|
371
|
+
const note = anomalies ? `[token-goat: ${countNoun(elided, "more row")}; ${countNoun(anomalies, "row")} kept for a not-ready status, the rest from the top; ${hint}]` : `[token-goat: ${countNoun(elided, "more row")}; ${hint}]`;
|
|
369
372
|
return `${[header, ...kept.map((i) => rows[i])].join("\n")}
|
|
370
373
|
${note}`;
|
|
371
374
|
}
|
|
@@ -382,7 +385,7 @@ function trimRepeatedPrefix(lines, pattern, keep) {
|
|
|
382
385
|
out.push(line);
|
|
383
386
|
}
|
|
384
387
|
}
|
|
385
|
-
if (dropped) out.push(`[token-goat: +${dropped
|
|
388
|
+
if (dropped) out.push(`[token-goat: +${countNoun(dropped, "more line")} matching ${pattern.source}]`);
|
|
386
389
|
return out;
|
|
387
390
|
}
|
|
388
391
|
function stripTimestamps(lines) {
|
|
@@ -2,11 +2,16 @@ import { createRequire as __cjsRequire } from 'node:module';
|
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
recordStat
|
|
5
|
-
} from "./token-goat-chunk-
|
|
5
|
+
} from "./token-goat-chunk-U4WHMG6Y.mjs";
|
|
6
|
+
import {
|
|
7
|
+
redactSecrets
|
|
8
|
+
} from "./token-goat-chunk-T5P5ACNQ.mjs";
|
|
6
9
|
import {
|
|
7
10
|
loadConfig
|
|
8
|
-
} from "./token-goat-chunk-
|
|
11
|
+
} from "./token-goat-chunk-7EZTZOMC.mjs";
|
|
9
12
|
import {
|
|
13
|
+
UNTRUSTED_FILE_TAG,
|
|
14
|
+
displaySafeText,
|
|
10
15
|
fenceUntrustedContent,
|
|
11
16
|
scanForInjectionPatterns
|
|
12
17
|
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
@@ -47,11 +52,39 @@ function scanAndRecord(text) {
|
|
|
47
52
|
if (matches.length > 0) recordStat("injection_detected", 0, 0, void 0, matches.join(","));
|
|
48
53
|
return matches;
|
|
49
54
|
}
|
|
55
|
+
function fenceFileText(text) {
|
|
56
|
+
return fenceUntrusted(redactSecrets(text).text, UNTRUSTED_FILE_TAG);
|
|
57
|
+
}
|
|
58
|
+
function fenceIfScanMatched(text, tag) {
|
|
59
|
+
const matches = scanAndRecord(text);
|
|
60
|
+
if (matches.length === 0) return text;
|
|
61
|
+
return fenceUntrustedContent(text, matches, tag);
|
|
62
|
+
}
|
|
63
|
+
function fenceFieldIfMatched(text, tag) {
|
|
64
|
+
const redacted = redactSecrets(text).text;
|
|
65
|
+
const fenced = fenceIfScanMatched(redacted, tag);
|
|
66
|
+
return fenced === redacted ? displaySafeText(redacted) : fenced;
|
|
67
|
+
}
|
|
68
|
+
function fenceFileFieldIfMatched(text) {
|
|
69
|
+
return fenceFieldIfMatched(text, UNTRUSTED_FILE_TAG);
|
|
70
|
+
}
|
|
71
|
+
function fenceJsonStrings(value, field) {
|
|
72
|
+
if (typeof value === "string") return field(value);
|
|
73
|
+
if (Array.isArray(value)) return value.map((v) => fenceJsonStrings(v, field));
|
|
74
|
+
if (value === null || typeof value !== "object") return value;
|
|
75
|
+
if (typeof value.toJSON === "function") return value;
|
|
76
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [field(k), fenceJsonStrings(v, field)]));
|
|
77
|
+
}
|
|
50
78
|
|
|
51
79
|
export {
|
|
52
80
|
injectionFencingEnabled,
|
|
53
81
|
fenceUntrusted,
|
|
54
82
|
fenceUntrustedSpans,
|
|
55
83
|
fenceWithMatches,
|
|
56
|
-
scanAndRecord
|
|
84
|
+
scanAndRecord,
|
|
85
|
+
fenceFileText,
|
|
86
|
+
fenceIfScanMatched,
|
|
87
|
+
fenceFieldIfMatched,
|
|
88
|
+
fenceFileFieldIfMatched,
|
|
89
|
+
fenceJsonStrings
|
|
57
90
|
};
|