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,398 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MAX_LINES_FOR_DIFF,
|
|
5
|
+
lcsLength,
|
|
6
|
+
readKnownText,
|
|
7
|
+
readShapeOf,
|
|
8
|
+
splitLines
|
|
9
|
+
} from "./token-goat-chunk-5AC66HNP.mjs";
|
|
10
|
+
import "./token-goat-chunk-WBA5SKT4.mjs";
|
|
11
|
+
import {
|
|
12
|
+
sessionStateKey
|
|
13
|
+
} from "./token-goat-chunk-C75NA7PL.mjs";
|
|
14
|
+
import {
|
|
15
|
+
preToolPathDeclined
|
|
16
|
+
} from "./token-goat-chunk-P6VGNTQT.mjs";
|
|
17
|
+
import {
|
|
18
|
+
contextOutput,
|
|
19
|
+
denyOutput,
|
|
20
|
+
getCwd,
|
|
21
|
+
getFilePath,
|
|
22
|
+
getToolInput,
|
|
23
|
+
getToolName,
|
|
24
|
+
passOutput,
|
|
25
|
+
resolveEventPath
|
|
26
|
+
} from "./token-goat-chunk-76FGDLRO.mjs";
|
|
27
|
+
import {
|
|
28
|
+
dropFileLineRangesIfChanged,
|
|
29
|
+
getFileLineRanges,
|
|
30
|
+
markHintShown,
|
|
31
|
+
wasFileFullyReadThisSession,
|
|
32
|
+
wasHintShown
|
|
33
|
+
} from "./token-goat-chunk-GL3ETKSC.mjs";
|
|
34
|
+
import {
|
|
35
|
+
recordStat
|
|
36
|
+
} from "./token-goat-chunk-U4WHMG6Y.mjs";
|
|
37
|
+
import "./token-goat-chunk-GVB2MUST.mjs";
|
|
38
|
+
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
39
|
+
import "./token-goat-chunk-OUKDTVNU.mjs";
|
|
40
|
+
import "./token-goat-chunk-BFCWY73P.mjs";
|
|
41
|
+
import "./token-goat-chunk-KGEFFSHD.mjs";
|
|
42
|
+
import "./token-goat-chunk-XX6O25RN.mjs";
|
|
43
|
+
import "./token-goat-chunk-HAVAOB3S.mjs";
|
|
44
|
+
import "./token-goat-chunk-T5P5ACNQ.mjs";
|
|
45
|
+
import {
|
|
46
|
+
loadConfig
|
|
47
|
+
} from "./token-goat-chunk-7EZTZOMC.mjs";
|
|
48
|
+
import "./token-goat-chunk-QYHO5CPH.mjs";
|
|
49
|
+
import {
|
|
50
|
+
fingerprintContent,
|
|
51
|
+
resolveProjectRoot
|
|
52
|
+
} from "./token-goat-chunk-4GBVPH3D.mjs";
|
|
53
|
+
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
54
|
+
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
55
|
+
import {
|
|
56
|
+
isWithinQuietHours
|
|
57
|
+
} from "./token-goat-chunk-HU4TORC5.mjs";
|
|
58
|
+
import {
|
|
59
|
+
canQuoteArg,
|
|
60
|
+
echoedValue,
|
|
61
|
+
fencedCommand,
|
|
62
|
+
fileSubject,
|
|
63
|
+
quotedArg
|
|
64
|
+
} from "./token-goat-chunk-GGGG7RWB.mjs";
|
|
65
|
+
import {
|
|
66
|
+
canonicalize
|
|
67
|
+
} from "./token-goat-chunk-AM5V6GSX.mjs";
|
|
68
|
+
import {
|
|
69
|
+
displaySafePath,
|
|
70
|
+
normalizePath
|
|
71
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
72
|
+
import "./token-goat-chunk-CO3UYX6G.mjs";
|
|
73
|
+
import {
|
|
74
|
+
init_define_import_meta_env
|
|
75
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
76
|
+
|
|
77
|
+
// src/write_guard_hooks.ts
|
|
78
|
+
init_define_import_meta_env();
|
|
79
|
+
|
|
80
|
+
// src/sibling_copy.ts
|
|
81
|
+
init_define_import_meta_env();
|
|
82
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
83
|
+
var BACKUP_EXTENSIONS = /* @__PURE__ */ new Set([".bak", ".orig", ".new"]);
|
|
84
|
+
var VERSIONED_STEM = /^(.*\D)[_.-]?v\d+$/i;
|
|
85
|
+
var COPY_SUFFIX_STEM = /^(.+?)(?:[_.-](?:new|fixed|copy|old|orig|backup|bak)| copy| - copy| \(\d+\))$/i;
|
|
86
|
+
var SERIES_DIRECTORIES = /* @__PURE__ */ new Set(["migrations", "versions", "fixtures", "__snapshots__"]);
|
|
87
|
+
var VERSION_DIRECTORY = /^v\d+$/i;
|
|
88
|
+
function siblingCandidates(filePath) {
|
|
89
|
+
const dir = dirname(filePath);
|
|
90
|
+
const base = basename(filePath);
|
|
91
|
+
const ext = extname(base);
|
|
92
|
+
const stem = ext === "" ? base : base.slice(0, -ext.length);
|
|
93
|
+
const names = [];
|
|
94
|
+
if (BACKUP_EXTENSIONS.has(ext.toLowerCase()) && extname(stem) !== "") names.push(stem);
|
|
95
|
+
const versioned = VERSIONED_STEM.exec(stem);
|
|
96
|
+
if (versioned !== null) names.push(versioned[1].replace(/[_.-]+$/, "") + ext);
|
|
97
|
+
const copied = COPY_SUFFIX_STEM.exec(stem);
|
|
98
|
+
if (copied !== null) names.push(copied[1] + ext);
|
|
99
|
+
return names.filter((name, i) => name !== "" && name !== ext && name !== base && names.indexOf(name) === i).map((name) => join(dir, name));
|
|
100
|
+
}
|
|
101
|
+
function globToRegExp(glob) {
|
|
102
|
+
let source = "";
|
|
103
|
+
for (let i = 0; i < glob.length; i++) {
|
|
104
|
+
const c = glob[i];
|
|
105
|
+
if (c === "*" && glob[i + 1] === "*") {
|
|
106
|
+
source += ".*";
|
|
107
|
+
i++;
|
|
108
|
+
} else if (c === "*") {
|
|
109
|
+
source += "[^/]*";
|
|
110
|
+
} else if (c === "?") {
|
|
111
|
+
source += "[^/]";
|
|
112
|
+
} else {
|
|
113
|
+
source += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return new RegExp("(?:^|/)" + source + "$", "i");
|
|
117
|
+
}
|
|
118
|
+
function directorySegments(normalized, projectRoot) {
|
|
119
|
+
const root = projectRoot === null ? "" : projectRoot.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
120
|
+
if (root !== "" && normalized.toLowerCase().startsWith(root.toLowerCase() + "/")) return normalized.slice(root.length + 1).split("/").slice(0, -1).map((s) => s.toLowerCase());
|
|
121
|
+
if (root === "") return normalized.split("/").slice(0, -1).map((s) => s.toLowerCase());
|
|
122
|
+
return normalized.split("/").slice(-2, -1).map((s) => s.toLowerCase());
|
|
123
|
+
}
|
|
124
|
+
function siblingCopyExcluded(filePath, allow, projectRoot) {
|
|
125
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
126
|
+
const segments = directorySegments(normalized, projectRoot);
|
|
127
|
+
if (segments.some((s) => SERIES_DIRECTORIES.has(s) || VERSION_DIRECTORY.test(s))) return true;
|
|
128
|
+
return allow.some((glob) => glob !== "" && globToRegExp(glob.replace(/\\/g, "/")).test(normalized));
|
|
129
|
+
}
|
|
130
|
+
function siblingCopyMessage(original, unchangedPct) {
|
|
131
|
+
const shown = displaySafePath(original);
|
|
132
|
+
const outline = canQuoteArg(shown) ? `, or run ${fencedCommand("token-goat outline " + quotedArg(shown))} to find the part to change` : "";
|
|
133
|
+
return `This new file repeats about ${Math.round(unchangedPct)}% of an existing file in the same directory. Edit the original with \`Edit\` or \`token-goat replace\` instead of writing a second copy of it${outline}. If a separate copy is intended, carry on.`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/write_guards.ts
|
|
137
|
+
init_define_import_meta_env();
|
|
138
|
+
var ELLIPSIS = String.raw`(?:\.{3}|…)`;
|
|
139
|
+
var COMMENT_LEAD = String.raw`(?:/{2,}|#+|/\*+|\*+|<!--|--|;+|%+|"""|''')`;
|
|
140
|
+
var COMMENT_CLOSE = String.raw`(?:\*+/|-->|"""|''')`;
|
|
141
|
+
var KEYWORD = String.raw`(?:rest|remainder|remaining|existing|unchanged|omitted|truncated|previous|same as|other)`;
|
|
142
|
+
var SUBJECT = String.raw`(?:rest of (?:the )?(?:file|code|content|function|class|module|implementation|method)|existing (?:code|content|implementation)|remaining (?:code|content|lines|implementation)|previous (?:code|content))`;
|
|
143
|
+
var REST_SUBJECT = String.raw`(?:rest of (?:the )?(?:file|code|content|function|class|module|implementation|method)|remaining (?:code|content|lines|implementation))`;
|
|
144
|
+
var TRAILER = String.raw`(?:(?:is |remains |stays |goes )?(?:unchanged|here|omitted|as[- ]is|the same|same as before|as before|above|below))`;
|
|
145
|
+
var MAX_ELISION_LINE_CHARS = 120;
|
|
146
|
+
var LEADING_COMMENT = new RegExp(`^${COMMENT_LEAD}`);
|
|
147
|
+
var TRAILING_COMMENT = new RegExp(`${COMMENT_CLOSE}$`);
|
|
148
|
+
var ANY_ELLIPSIS = new RegExp(ELLIPSIS, "g");
|
|
149
|
+
var HAS_ELLIPSIS = new RegExp(ELLIPSIS);
|
|
150
|
+
var STARTS_WITH_ELLIPSIS = new RegExp(`^${ELLIPSIS}`);
|
|
151
|
+
var ENDS_WITH_ELLIPSIS = new RegExp(`${ELLIPSIS}$`);
|
|
152
|
+
var LEAD_THEN_TRAILER = new RegExp(`^(?:keep )?(?:the )?${KEYWORD}(?: \\S+){0,4}? (?:unchanged|here|omitted|truncated|as[- ]is|the same|as before|above|below)$`, "i");
|
|
153
|
+
var WRAPPED_MARKER = new RegExp(`^(?:the )?${KEYWORD}(?: \\S+){0,3}$`, "i");
|
|
154
|
+
var SUBJECT_ONLY = new RegExp(`^${SUBJECT}(?: ${TRAILER})?$`, "i");
|
|
155
|
+
var SUBJECT_QUALIFIED = new RegExp(`^${SUBJECT} (?:(?:is |are |remains? |stays? )?(?:unchanged|omitted|truncated|not shown|as[- ]is|as before|same as before)|(?:remains?|stays?|is|are) (?:the )?same)$`, "i");
|
|
156
|
+
var REST_PLACED = new RegExp(`^(?:${REST_SUBJECT} (?:(?:goes |is |comes )?(?:here|above|below)|follows)|rest of (?:the )?implementation)$`, "i");
|
|
157
|
+
var ELLIPSIS_QUALIFIER = new RegExp(`^(?:(?:the )?(?:same as before|as before|unchanged|omitted|truncated|not shown)|\\d+ (?:more )?\\S+ (?:omitted|truncated|not shown|unchanged|hidden|elided))$`, "i");
|
|
158
|
+
var BRACKET_NOTE = new RegExp(`^(?:truncated|omitted|content (?:truncated|omitted)|(?:remaining|rest of)[^\\]]{0,60}(?:omitted|truncated|unchanged)|\\d+ (?:more )?lines? (?:omitted|truncated|folded))$`, "i");
|
|
159
|
+
var FOLD_MARKER = new RegExp(`^${ELLIPSIS}\\s*\\d+\\s+(?:more\\s+)?lines?\\b.*\\bfolded\\b`, "i");
|
|
160
|
+
var TOKEN_GOAT_NOTICE = /^\[token-goat[: ].{0,200}\]$/;
|
|
161
|
+
function spaced(text) {
|
|
162
|
+
return text.replace(ANY_ELLIPSIS, " ").replace(/\s+/g, " ").trim();
|
|
163
|
+
}
|
|
164
|
+
function isElisionLine(trimmed) {
|
|
165
|
+
if (trimmed === "" || trimmed.length > MAX_ELISION_LINE_CHARS) return false;
|
|
166
|
+
if (TOKEN_GOAT_NOTICE.test(trimmed) || FOLD_MARKER.test(trimmed)) return true;
|
|
167
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) return BRACKET_NOTE.test(spaced(trimmed.slice(1, -1)));
|
|
168
|
+
const led = LEADING_COMMENT.test(trimmed);
|
|
169
|
+
if (!led && !STARTS_WITH_ELLIPSIS.test(trimmed)) return false;
|
|
170
|
+
const body = led ? trimmed.replace(LEADING_COMMENT, "").replace(TRAILING_COMMENT, "").trim() : trimmed;
|
|
171
|
+
const payload = spaced(body).replace(/^[([](.*)[)\]]$/, "$1").trim();
|
|
172
|
+
const hasEllipsis = HAS_ELLIPSIS.test(body);
|
|
173
|
+
if (!hasEllipsis) return SUBJECT_QUALIFIED.test(payload) || REST_PLACED.test(payload);
|
|
174
|
+
if (SUBJECT_ONLY.test(payload) || ELLIPSIS_QUALIFIER.test(payload)) return true;
|
|
175
|
+
return LEAD_THEN_TRAILER.test(payload) || STARTS_WITH_ELLIPSIS.test(body) && ENDS_WITH_ELLIPSIS.test(body) && WRAPPED_MARKER.test(payload);
|
|
176
|
+
}
|
|
177
|
+
function findNewElisionLine(newText, knownText) {
|
|
178
|
+
let known;
|
|
179
|
+
for (const raw of splitLines(newText)) {
|
|
180
|
+
const trimmed = raw.trim();
|
|
181
|
+
if (!isElisionLine(trimmed)) continue;
|
|
182
|
+
known ??= new Set(splitLines(typeof knownText === "function" ? knownText() : knownText).map((l) => l.trim()));
|
|
183
|
+
if (!known.has(trimmed)) return trimmed;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
function patchAddedLines(patch) {
|
|
188
|
+
const files = [];
|
|
189
|
+
let current;
|
|
190
|
+
for (const line of patch.split(/\r\n|\r|\n/)) {
|
|
191
|
+
const header = /^\*\*\* (?:Add|Update) File: (.+)$/.exec(line);
|
|
192
|
+
const moved = /^\*\*\* Move to: (.+)$/.exec(line);
|
|
193
|
+
if (header !== null) {
|
|
194
|
+
current = { path: header[1].trim(), added: [] };
|
|
195
|
+
files.push(current);
|
|
196
|
+
} else if (moved !== null && current !== void 0) {
|
|
197
|
+
current.path = moved[1].trim();
|
|
198
|
+
} else if (line.startsWith("*** ")) {
|
|
199
|
+
current = void 0;
|
|
200
|
+
} else if (current !== void 0 && line.startsWith("+")) {
|
|
201
|
+
current.added.push(line.slice(1));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return files;
|
|
205
|
+
}
|
|
206
|
+
var MAX_DIFF_SPAN = 2e3;
|
|
207
|
+
function removedLineIndexes(oldLines, newLines) {
|
|
208
|
+
let head = 0;
|
|
209
|
+
while (head < oldLines.length && head < newLines.length && oldLines[head] === newLines[head]) head++;
|
|
210
|
+
let tail = 0;
|
|
211
|
+
while (tail < oldLines.length - head && tail < newLines.length - head && oldLines[oldLines.length - 1 - tail] === newLines[newLines.length - 1 - tail]) tail++;
|
|
212
|
+
const n = oldLines.length - head - tail;
|
|
213
|
+
const m = newLines.length - head - tail;
|
|
214
|
+
const removed = [];
|
|
215
|
+
if (m === 0 || n > MAX_DIFF_SPAN || m > MAX_DIFF_SPAN) {
|
|
216
|
+
for (let i2 = 0; i2 < n; i2++) removed.push(head + i2);
|
|
217
|
+
return removed;
|
|
218
|
+
}
|
|
219
|
+
const width = m + 1;
|
|
220
|
+
const goesLeft = new Uint8Array(Math.ceil((n + 1) * width / 8));
|
|
221
|
+
let above = new Uint16Array(width);
|
|
222
|
+
let row = new Uint16Array(width);
|
|
223
|
+
for (let i2 = 1; i2 <= n; i2++) {
|
|
224
|
+
for (let j2 = 1; j2 <= m; j2++) {
|
|
225
|
+
if (oldLines[head + i2 - 1] === newLines[head + j2 - 1]) {
|
|
226
|
+
row[j2] = (above[j2 - 1] ?? 0) + 1;
|
|
227
|
+
} else {
|
|
228
|
+
const left = row[j2 - 1] ?? 0;
|
|
229
|
+
const up = above[j2] ?? 0;
|
|
230
|
+
row[j2] = Math.max(left, up);
|
|
231
|
+
if (left >= up) goesLeft[i2 * width + j2 >> 3] |= 1 << (i2 * width + j2 & 7);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
;
|
|
235
|
+
[above, row] = [row, above];
|
|
236
|
+
}
|
|
237
|
+
let i = n;
|
|
238
|
+
let j = m;
|
|
239
|
+
while (i > 0) {
|
|
240
|
+
if (j > 0 && oldLines[head + i - 1] === newLines[head + j - 1]) {
|
|
241
|
+
i--;
|
|
242
|
+
j--;
|
|
243
|
+
} else if (j > 0 && ((goesLeft[i * width + j >> 3] ?? 0) & 1 << (i * width + j & 7)) !== 0) {
|
|
244
|
+
j--;
|
|
245
|
+
} else {
|
|
246
|
+
removed.push(head + i - 1);
|
|
247
|
+
i--;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return removed.reverse();
|
|
251
|
+
}
|
|
252
|
+
function unseenRemovedRuns(oldLines, newLines, served) {
|
|
253
|
+
const unseen = removedLineIndexes(oldLines, newLines).map((i) => i + 1).filter((line) => !served.some(([s, e]) => line >= s && line <= e));
|
|
254
|
+
const runs = [];
|
|
255
|
+
for (const line of unseen) {
|
|
256
|
+
const last = runs[runs.length - 1];
|
|
257
|
+
if (last !== void 0 && last[1] === line - 1) last[1] = line;
|
|
258
|
+
else runs.push([line, line]);
|
|
259
|
+
}
|
|
260
|
+
return runs;
|
|
261
|
+
}
|
|
262
|
+
var BLIND_DROP_MIN_LINES = 5;
|
|
263
|
+
function countRunLines(runs) {
|
|
264
|
+
return runs.reduce((sum, [s, e]) => sum + (e - s + 1), 0);
|
|
265
|
+
}
|
|
266
|
+
var ELISION_ADVICE = "Write the real content, or change only the part you mean to with `Edit` or `token-goat replace`. If this exact text is intended, repeat the identical call and it goes through.";
|
|
267
|
+
function placeholderMessage(line) {
|
|
268
|
+
const shown = echoedValue(line.length > 100 ? line.slice(0, 100) + "..." : line);
|
|
269
|
+
return `This call writes a placeholder line (${shown}) that is not in the file now. Written as it stands, that line replaces whatever it stands for. ${ELISION_ADVICE}`;
|
|
270
|
+
}
|
|
271
|
+
var MAX_QUOTED_PLACEHOLDERS = 3;
|
|
272
|
+
function placeholdersMessage(found) {
|
|
273
|
+
if (found.length === 1) return placeholderMessage(found[0]);
|
|
274
|
+
const quoted = found.slice(0, MAX_QUOTED_PLACEHOLDERS).map((line) => echoedValue(line.length > 100 ? line.slice(0, 100) + "..." : line));
|
|
275
|
+
const more = found.length > quoted.length ? ` and ${found.length - quoted.length} more` : "";
|
|
276
|
+
return `This call writes ${found.length} placeholder lines (${quoted.join(", ")}${more}) that are not in the files now. Written as they stand, each replaces whatever it stands for. ${ELISION_ADVICE}`;
|
|
277
|
+
}
|
|
278
|
+
function blindDropMessage(filePath, runs) {
|
|
279
|
+
const total = countRunLines(runs);
|
|
280
|
+
const named = [...runs].sort((a, b) => b[1] - b[0] - (a[1] - a[0])).slice(0, 3).sort((a, b) => a[0] - b[0]);
|
|
281
|
+
const shownPath = displaySafePath(filePath);
|
|
282
|
+
const commands = named.map(([s, e]) => fencedCommand("token-goat read " + quotedArg(`${shownPath}@${s}-${e}`)));
|
|
283
|
+
return `This Write would delete ${total} lines of ${fileSubject(commands.join(" "), shownPath, filePath)} that this session never read in full (lines ${named.map(([s, e]) => s === e ? String(s) : `${s}-${e}`).join(", ")}). Read them first with ${commands.join(" or ")}, or change only what you mean to with \`Edit\` or \`token-goat replace\`. If dropping them is intended, repeat the identical call and it goes through.`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/write_guard_hooks.ts
|
|
287
|
+
function guardVerdict(key, message, detail) {
|
|
288
|
+
const hints = loadConfig().hints;
|
|
289
|
+
const policy = hints.write_blind_drop;
|
|
290
|
+
if (policy === "off" || wasHintShown(key)) return passOutput();
|
|
291
|
+
if (policy === "warn" && isWithinQuietHours(hints.quiet_hours)) return passOutput();
|
|
292
|
+
markHintShown(key);
|
|
293
|
+
recordStat("write_blind_drop", 0, 0, void 0, detail);
|
|
294
|
+
return policy === "deny" ? denyOutput(message) : contextOutput(message);
|
|
295
|
+
}
|
|
296
|
+
function guardKey(kind, file, text) {
|
|
297
|
+
return "write_blind_drop:" + kind + ":" + fingerprintContent(file + "\0" + text);
|
|
298
|
+
}
|
|
299
|
+
function placeholderGuard(event, filePath, newText, knownText) {
|
|
300
|
+
if (loadConfig().hints.write_blind_drop === "off") return passOutput();
|
|
301
|
+
const line = findNewElisionLine(newText, knownText);
|
|
302
|
+
if (line === null) return passOutput();
|
|
303
|
+
return guardVerdict(guardKey("placeholder", filePath, newText), placeholderMessage(line), "kind=placeholder tool=" + (getToolName(event) ?? "unknown"));
|
|
304
|
+
}
|
|
305
|
+
function blindDropGuard(event, filePath, newContent, oldLines, newLines) {
|
|
306
|
+
if (loadConfig().hints.write_blind_drop === "off") return passOutput();
|
|
307
|
+
const normalized = normalizePath(filePath);
|
|
308
|
+
const shape = readShapeOf(sessionStateKey(event), normalized);
|
|
309
|
+
if (shape === null || shape === "fold" || shape === "truncated") return passOutput();
|
|
310
|
+
if (wasFileFullyReadThisSession(normalized)) return passOutput();
|
|
311
|
+
dropFileLineRangesIfChanged(normalized);
|
|
312
|
+
const served = getFileLineRanges(normalized);
|
|
313
|
+
if (shape === "partial" && served.length === 0) return passOutput();
|
|
314
|
+
const runs = unseenRemovedRuns(oldLines, newLines, served);
|
|
315
|
+
if (countRunLines(runs) < BLIND_DROP_MIN_LINES) return passOutput();
|
|
316
|
+
return guardVerdict(guardKey("blind", filePath, newContent), blindDropMessage(filePath, runs), "kind=blind_drop last_read=" + shape + " lines=" + countRunLines(runs));
|
|
317
|
+
}
|
|
318
|
+
function siblingCopyGuard(event, filePath, newContent) {
|
|
319
|
+
const cfg = loadConfig().hints;
|
|
320
|
+
if (!cfg.write_sibling_copy) return passOutput();
|
|
321
|
+
const candidates = siblingCandidates(filePath);
|
|
322
|
+
if (candidates.length === 0) return passOutput();
|
|
323
|
+
const cwd = getCwd(event);
|
|
324
|
+
if (siblingCopyExcluded(canonicalize(filePath, cwd), cfg.write_sibling_copy_allow, cwd === void 0 ? null : resolveProjectRoot({ project: cwd }))) return passOutput();
|
|
325
|
+
const newLines = splitLines(newContent);
|
|
326
|
+
if (newLines.length > MAX_LINES_FOR_DIFF) return passOutput();
|
|
327
|
+
for (const original of candidates) {
|
|
328
|
+
const oldLines = splitLines(readKnownText(original));
|
|
329
|
+
if (oldLines.length < cfg.write_rewrite_min_lines || oldLines.length > MAX_LINES_FOR_DIFF) continue;
|
|
330
|
+
const unchangedPct = lcsLength(oldLines, newLines) / oldLines.length * 100;
|
|
331
|
+
if (unchangedPct < cfg.write_rewrite_unchanged_pct) continue;
|
|
332
|
+
const key = "write_sibling_copy:" + fingerprintContent(original);
|
|
333
|
+
if (wasHintShown(key)) return passOutput();
|
|
334
|
+
markHintShown(key);
|
|
335
|
+
const shownPct = Math.round(unchangedPct);
|
|
336
|
+
recordStat("write_sibling_copy", 0, 0, void 0, "unchanged_pct=" + shownPct);
|
|
337
|
+
return contextOutput(siblingCopyMessage(original, unchangedPct));
|
|
338
|
+
}
|
|
339
|
+
return passOutput();
|
|
340
|
+
}
|
|
341
|
+
var MAX_EDIT_FILES_CHECKED = 20;
|
|
342
|
+
function preEditPlaceholderGuard(event) {
|
|
343
|
+
if (loadConfig().hints.write_blind_drop === "off") return passOutput();
|
|
344
|
+
const input = getToolInput(event);
|
|
345
|
+
const patch = typeof input["command"] === "string" ? input["command"] : input["input"];
|
|
346
|
+
if (typeof patch === "string" && input["new_string"] === void 0 && input["edits"] === void 0 && input["replacements"] === void 0) {
|
|
347
|
+
for (const file of patchAddedLines(patch)) {
|
|
348
|
+
const target = resolveEventPath(event, file.path);
|
|
349
|
+
if (preToolPathDeclined(event, target)) continue;
|
|
350
|
+
const verdict2 = placeholderGuard(event, target, file.added.join("\n"), () => readKnownText(target));
|
|
351
|
+
if (verdict2.hookType !== "pass") return verdict2;
|
|
352
|
+
}
|
|
353
|
+
return passOutput();
|
|
354
|
+
}
|
|
355
|
+
const known = /* @__PURE__ */ new Map();
|
|
356
|
+
const fileText = (path) => {
|
|
357
|
+
let text = known.get(path);
|
|
358
|
+
if (text === void 0) known.set(path, text = readKnownText(path));
|
|
359
|
+
return text;
|
|
360
|
+
};
|
|
361
|
+
const edits = [];
|
|
362
|
+
if (Array.isArray(input["replacements"])) {
|
|
363
|
+
for (const raw of input["replacements"]) {
|
|
364
|
+
const named = raw !== null && typeof raw === "object" ? raw["filePath"] : void 0;
|
|
365
|
+
edits.push({ path: typeof named === "string" && named !== "" ? resolveEventPath(event, named) : void 0, raw });
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
const filePath = getFilePath(event);
|
|
369
|
+
for (const raw of Array.isArray(input["edits"]) ? input["edits"] : [input]) edits.push({ path: filePath, raw });
|
|
370
|
+
}
|
|
371
|
+
const flagged = [];
|
|
372
|
+
const examined = /* @__PURE__ */ new Set();
|
|
373
|
+
for (const { path, raw } of edits) {
|
|
374
|
+
if (path === void 0 || raw === null || typeof raw !== "object" || preToolPathDeclined(event, path)) continue;
|
|
375
|
+
const edit = raw;
|
|
376
|
+
const newString = edit["new_string"] ?? edit["newString"];
|
|
377
|
+
if (typeof newString !== "string") continue;
|
|
378
|
+
if (!examined.has(path)) {
|
|
379
|
+
if (examined.size >= MAX_EDIT_FILES_CHECKED) continue;
|
|
380
|
+
examined.add(path);
|
|
381
|
+
}
|
|
382
|
+
const oldString = edit["old_string"] ?? edit["oldString"];
|
|
383
|
+
const replaced = typeof oldString === "string" ? oldString : "";
|
|
384
|
+
const line = findNewElisionLine(newString, () => fileText(path) + "\n" + replaced);
|
|
385
|
+
const key = guardKey("placeholder", path, newString);
|
|
386
|
+
if (line !== null && !wasHintShown(key)) flagged.push({ line, key });
|
|
387
|
+
}
|
|
388
|
+
if (flagged.length === 0) return passOutput();
|
|
389
|
+
const verdict = guardVerdict(flagged[0].key, placeholdersMessage(flagged.map((f) => f.line)), "kind=placeholder tool=" + (getToolName(event) ?? "unknown") + " entries=" + flagged.length);
|
|
390
|
+
if (verdict.hookType !== "pass") for (const { key } of flagged) markHintShown(key);
|
|
391
|
+
return verdict;
|
|
392
|
+
}
|
|
393
|
+
export {
|
|
394
|
+
blindDropGuard,
|
|
395
|
+
placeholderGuard,
|
|
396
|
+
preEditPlaceholderGuard,
|
|
397
|
+
siblingCopyGuard
|
|
398
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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/windows_powershell.ts
|
|
8
|
+
init_define_import_meta_env();
|
|
9
|
+
|
|
10
|
+
// src/windows_system32.ts
|
|
11
|
+
init_define_import_meta_env();
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
var DEFAULT_WINDOWS_DIR = "C:\\Windows";
|
|
15
|
+
function windowsSystem32Exe(...rel) {
|
|
16
|
+
const missing = path.join(DEFAULT_WINDOWS_DIR, "System32", ...rel);
|
|
17
|
+
for (const root of [process.env["SystemRoot"], process.env["windir"], DEFAULT_WINDOWS_DIR]) {
|
|
18
|
+
if (root === void 0 || !path.win32.isAbsolute(root)) continue;
|
|
19
|
+
const exe = path.join(root, "System32", ...rel);
|
|
20
|
+
if (fs.existsSync(exe)) return exe;
|
|
21
|
+
}
|
|
22
|
+
return missing;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/windows_powershell.ts
|
|
26
|
+
function windowsPowerShellPath() {
|
|
27
|
+
return windowsSystem32Exe("WindowsPowerShell", "v1.0", "powershell.exe");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
windowsSystem32Exe,
|
|
32
|
+
windowsPowerShellPath
|
|
33
|
+
};
|
|
@@ -3,6 +3,12 @@ const require = __cjsRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
external_exports
|
|
5
5
|
} from "./token-goat-chunk-3U6ZYVX5.mjs";
|
|
6
|
+
import {
|
|
7
|
+
answeringMcpToolCall
|
|
8
|
+
} from "./token-goat-chunk-KGEFFSHD.mjs";
|
|
9
|
+
import {
|
|
10
|
+
displaySafeText
|
|
11
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
6
12
|
import {
|
|
7
13
|
init_define_import_meta_env
|
|
8
14
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -113,7 +119,7 @@ var McpServer = class {
|
|
|
113
119
|
await this.send({ jsonrpc: "2.0", id, result: await this.callTool(params) });
|
|
114
120
|
return;
|
|
115
121
|
default:
|
|
116
|
-
await this.sendError(id, JSONRPC_METHOD_NOT_FOUND, `Method not found: ${method}`);
|
|
122
|
+
await this.sendError(id, JSONRPC_METHOD_NOT_FOUND, `Method not found: ${displaySafeText(method)}`);
|
|
117
123
|
return;
|
|
118
124
|
}
|
|
119
125
|
} catch (err) {
|
|
@@ -157,7 +163,7 @@ var McpServer = class {
|
|
|
157
163
|
);
|
|
158
164
|
}
|
|
159
165
|
try {
|
|
160
|
-
return await handler(parsed.data);
|
|
166
|
+
return await answeringMcpToolCall(() => handler(parsed.data), new Set(this.tools.keys()));
|
|
161
167
|
} catch (err) {
|
|
162
168
|
return errorText(err instanceof Error ? err.message : String(err));
|
|
163
169
|
}
|