token-goat 2.9.29 → 2.9.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +53 -42
  2. package/SECURITY.md +37 -11
  3. package/THIRD_PARTY_NOTICES.md +41 -4
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/native/win32-arm64/tg-hook.exe +0 -0
  7. package/dist/native/win32-x64/tg-hook.exe +0 -0
  8. package/dist/ort-wasm-simd-threaded.mjs +59 -0
  9. package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-25TRAWET.mjs} +23 -6
  10. package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
  11. package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-2M7E4PF7.mjs} +43 -14
  12. package/dist/token-goat-chunk-2UPZGKKY.mjs +188 -0
  13. package/dist/token-goat-chunk-2WLPWKHV.mjs +135 -0
  14. package/dist/token-goat-chunk-2XBMMDBD.mjs +126 -0
  15. package/dist/token-goat-chunk-32ZOY4N5.mjs +23 -0
  16. package/dist/token-goat-chunk-3EZRNKTK.mjs +188 -0
  17. package/dist/token-goat-chunk-4ADZHI7J.mjs +63 -0
  18. package/dist/token-goat-chunk-4GBVPH3D.mjs +242 -0
  19. package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-4GILLLWY.mjs} +34 -7
  20. package/dist/token-goat-chunk-4NAPX7BA.mjs +90 -0
  21. package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-4SC7UJYV.mjs} +9981 -11563
  22. package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
  23. package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-4ZBFWLXF.mjs} +310 -441
  24. package/dist/token-goat-chunk-57BIAXJL.mjs +286 -0
  25. package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
  26. package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
  27. package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
  28. package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
  29. package/dist/token-goat-chunk-646E6U44.mjs +398 -0
  30. package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
  31. package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-6DG6HWP3.mjs} +13 -3
  32. package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
  33. package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
  34. package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-76FGDLRO.mjs} +574 -340
  35. package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7EZTZOMC.mjs} +780 -767
  36. package/dist/token-goat-chunk-7MAOA6X4.mjs +3647 -0
  37. package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
  38. package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
  39. package/dist/token-goat-chunk-AUNGYYQX.mjs +184 -0
  40. package/dist/token-goat-chunk-AUQYRMMH.mjs +2985 -0
  41. package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
  42. package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-BA4HI6BW.mjs} +1910 -165
  43. package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-BFCWY73P.mjs} +58 -20
  44. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  45. package/dist/token-goat-chunk-BWGFUZZE.mjs +25 -0
  46. package/dist/token-goat-chunk-C75NA7PL.mjs +322 -0
  47. package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
  48. package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
  49. package/dist/token-goat-chunk-CIMQ2BB3.mjs +233 -0
  50. package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-CJLS3CDL.mjs} +70 -18
  51. package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-CO3UYX6G.mjs} +7 -1
  52. package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
  53. package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
  54. package/dist/token-goat-chunk-CVCEVUGK.mjs +315 -0
  55. package/dist/token-goat-chunk-CXHOFN7R.mjs +371 -0
  56. package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
  57. package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-DGS2LVNA.mjs} +70 -160
  58. package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-DOWRSMWO.mjs} +1 -1
  59. package/dist/token-goat-chunk-E45INMY3.mjs +71 -0
  60. package/dist/token-goat-chunk-EC5F37F4.mjs +244 -0
  61. package/dist/{token-goat-chunk-XTQAOTSO.mjs → token-goat-chunk-EDBDRVH5.mjs} +4 -1
  62. package/dist/token-goat-chunk-EELTBKDM.mjs +613 -0
  63. package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
  64. package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
  65. package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-F4HYL64R.mjs} +12 -2
  66. package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
  67. package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
  68. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  69. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  70. package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
  71. package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-GL3ETKSC.mjs} +276 -19
  72. package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-GVB2MUST.mjs} +265 -1567
  73. package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
  74. package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
  75. package/dist/token-goat-chunk-HLPW63A7.mjs +48 -0
  76. package/dist/token-goat-chunk-HU4TORC5.mjs +1377 -0
  77. package/dist/token-goat-chunk-I7VKZZAW.mjs +35 -0
  78. package/dist/token-goat-chunk-IA6XSPE3.mjs +218 -0
  79. package/dist/token-goat-chunk-IAGXMHIK.mjs +863 -0
  80. package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-IK2DRMFX.mjs} +129 -74
  81. package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-INNPTRUX.mjs} +2954 -2783
  82. package/dist/token-goat-chunk-JJ5BX4F4.mjs +129 -0
  83. package/dist/token-goat-chunk-JVFSHVFJ.mjs +129 -0
  84. package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
  85. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  86. package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
  87. package/dist/token-goat-chunk-LCNQ2CNN.mjs +497 -0
  88. package/dist/token-goat-chunk-M3LFJDPU.mjs +58 -0
  89. package/dist/token-goat-chunk-M52KPT3C.mjs +87 -0
  90. package/dist/token-goat-chunk-MBEG42H7.mjs +150 -0
  91. package/dist/{token-goat-chunk-EVC4TOLE.mjs → token-goat-chunk-METECDOH.mjs} +3 -12
  92. package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-MHX7XCC3.mjs} +3 -2
  93. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  94. package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
  95. package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-N5MMR2IW.mjs} +30 -8
  96. package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
  97. package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-NISNMD7T.mjs} +2545 -2953
  98. package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
  99. package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
  100. package/dist/token-goat-chunk-NSNSPPBG.mjs +69 -0
  101. package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
  102. package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
  103. package/dist/token-goat-chunk-ODBT2USM.mjs +800 -0
  104. package/dist/token-goat-chunk-OS5EM5PP.mjs +107 -0
  105. package/dist/token-goat-chunk-OUKDTVNU.mjs +1178 -0
  106. package/dist/token-goat-chunk-OXFMP75N.mjs +566 -0
  107. package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -1
  108. package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-P6HQSWQ3.mjs} +55 -47
  109. package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
  110. package/dist/token-goat-chunk-PFWIMH2E.mjs +261 -0
  111. package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
  112. package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
  113. package/dist/token-goat-chunk-PX5PQWTY.mjs +462 -0
  114. package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
  115. package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
  116. package/dist/token-goat-chunk-QH7YVYOY.mjs +3957 -0
  117. package/dist/token-goat-chunk-QLMUHEPB.mjs +43 -0
  118. package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-QQOJIHL3.mjs} +50 -14
  119. package/dist/token-goat-chunk-QQTWJY2O.mjs +85 -0
  120. package/dist/token-goat-chunk-QYHO5CPH.mjs +93 -0
  121. package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
  122. package/dist/token-goat-chunk-RSLPOBKQ.mjs +339 -0
  123. package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
  124. package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
  125. package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-SOAFZNNZ.mjs} +164 -40
  126. package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-SRTHT7KV.mjs} +33 -15
  127. package/dist/token-goat-chunk-T5P5ACNQ.mjs +212 -0
  128. package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
  129. package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
  130. package/dist/token-goat-chunk-TM6MC754.mjs +40 -0
  131. package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
  132. package/dist/token-goat-chunk-U2KSB4SG.mjs +56 -0
  133. package/dist/token-goat-chunk-U4WHMG6Y.mjs +898 -0
  134. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  135. package/dist/token-goat-chunk-UGJHGR5A.mjs +52 -0
  136. package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-UOUDVA5U.mjs} +76 -16
  137. package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-URRJ33GR.mjs} +22 -4
  138. package/dist/token-goat-chunk-UZOROKIS.mjs +165 -0
  139. package/dist/token-goat-chunk-VIHGGGEI.mjs +4234 -0
  140. package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
  141. package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
  142. package/dist/token-goat-chunk-VWZA2H4P.mjs +368 -0
  143. package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-VXEXMJDL.mjs} +2964 -3153
  144. package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
  145. package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-WDH44VAU.mjs} +19 -22
  146. package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
  147. package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
  148. package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-XLRBNZCC.mjs} +40 -21
  149. package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-XRKUX6CM.mjs} +4 -0
  150. package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
  151. package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
  152. package/dist/token-goat-chunk-Y2ZTQOCL.mjs +35 -0
  153. package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-YB4VMGK2.mjs} +15 -4
  154. package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
  155. package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-YHVDKQBR.mjs} +389 -221
  156. package/dist/token-goat-chunk-YJB5XLWI.mjs +26 -0
  157. package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-YKB6AQG3.mjs} +53 -31
  158. package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
  159. package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
  160. package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-YY6AVUFL.mjs} +13246 -12247
  161. package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
  162. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  163. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  164. package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
  165. package/dist/token-goat-hook-client.cjs +87 -23
  166. package/dist/token-goat-hook-client.mjs +3 -3
  167. package/dist/token-goat-hook.mjs +76 -31
  168. package/dist/token-goat.core.mjs +6 -6
  169. package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
  170. package/docs/cli.md +113 -60
  171. package/docs/install.md +63 -20
  172. package/docs/security.md +10 -8
  173. package/package.json +18 -7
  174. package/scripts/verify-native-dist.mjs +386 -0
  175. package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
  176. package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
  177. package/dist/token-goat-chunk-BGYOZ6DO.mjs +0 -24
  178. package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
  179. package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
  180. package/dist/token-goat-chunk-D4ETHJD6.mjs +0 -246
  181. package/dist/token-goat-chunk-DNRPXHYH.mjs +0 -1062
  182. package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
  183. package/dist/token-goat-chunk-FTP4U4QA.mjs +0 -64
  184. package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
  185. package/dist/token-goat-chunk-GLXRTTLE.mjs +0 -36
  186. package/dist/token-goat-chunk-H5J3C56Q.mjs +0 -1511
  187. package/dist/token-goat-chunk-IVWI2OCK.mjs +0 -368
  188. package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
  189. package/dist/token-goat-chunk-LZNBQTDK.mjs +0 -26
  190. package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
  191. package/dist/token-goat-chunk-RTMVLHWX.mjs +0 -7113
  192. package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
  193. package/dist/token-goat-chunk-VZQEWRVH.mjs +0 -312
  194. package/dist/token-goat-chunk-XYWPOSCN.mjs +0 -807
  195. package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
  196. package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
  197. package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
@@ -0,0 +1,286 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ GROK_HOOK_SCRIPT,
5
+ VSCODE_CLAUDE_HOOKS_TURNED_OFF_TEXT,
6
+ disableVscodeClaudeHooks,
7
+ grokConfigPath,
8
+ grokHookScriptPath,
9
+ installAntigravity,
10
+ installGemini,
11
+ installGrok,
12
+ installKimi,
13
+ installOpenclaw,
14
+ installOpencode,
15
+ installPi,
16
+ installQwen,
17
+ isAntigravityInstalled,
18
+ isGeminiInstalled,
19
+ isGrokInstalled,
20
+ isKimiInstalled,
21
+ isOpenclawInstalled,
22
+ isOpencodeInstalled,
23
+ isPiInstalled,
24
+ isQwenInstalled,
25
+ kimiConfigPath,
26
+ kimiHookScriptPath,
27
+ vscodeHooksInstalled,
28
+ vscodeRunsTokenGoatClaudeHooks,
29
+ wiredGrokHookWords,
30
+ wiredKimiHookWords
31
+ } from "./token-goat-chunk-AUQYRMMH.mjs";
32
+ import {
33
+ CLAUDECODE_HOOK_SCRIPT,
34
+ CODEX_HOOK_SCRIPT,
35
+ COPILOT_CLI_HOOK_SCRIPT,
36
+ claudeHookScriptPath,
37
+ codexConfigPath,
38
+ codexHookScriptPath,
39
+ copilotCliConfigPath,
40
+ copilotCliScriptPath,
41
+ hookEventGaps,
42
+ installCodex,
43
+ installHooks,
44
+ isCodexInstalled,
45
+ isCopilotCliInstalled,
46
+ isInstalled,
47
+ parseNativeInvocation,
48
+ repairCopilotCliHooks,
49
+ wiredCodexHookWords,
50
+ wiredCopilotHookWords
51
+ } from "./token-goat-chunk-7MAOA6X4.mjs";
52
+ import "./token-goat-chunk-CXHOFN7R.mjs";
53
+ import "./token-goat-chunk-QQTWJY2O.mjs";
54
+ import "./token-goat-chunk-G5PJ7AGM.mjs";
55
+ import "./token-goat-chunk-BPGCUMR7.mjs";
56
+ import "./token-goat-chunk-C75NA7PL.mjs";
57
+ import "./token-goat-chunk-CBIQ7WTD.mjs";
58
+ import "./token-goat-chunk-76FGDLRO.mjs";
59
+ import "./token-goat-chunk-U4WHMG6Y.mjs";
60
+ import "./token-goat-chunk-GVB2MUST.mjs";
61
+ import "./token-goat-chunk-XB5KKOCG.mjs";
62
+ import "./token-goat-chunk-OUKDTVNU.mjs";
63
+ import "./token-goat-chunk-BFCWY73P.mjs";
64
+ import "./token-goat-chunk-KGEFFSHD.mjs";
65
+ import "./token-goat-chunk-XX6O25RN.mjs";
66
+ import "./token-goat-chunk-HAVAOB3S.mjs";
67
+ import "./token-goat-chunk-T5P5ACNQ.mjs";
68
+ import "./token-goat-chunk-7EZTZOMC.mjs";
69
+ import "./token-goat-chunk-QYHO5CPH.mjs";
70
+ import "./token-goat-chunk-4GBVPH3D.mjs";
71
+ import "./token-goat-chunk-YZAAZU2S.mjs";
72
+ import "./token-goat-chunk-IVE6U7KV.mjs";
73
+ import {
74
+ extractErrorMessage,
75
+ hasCreatedConfig
76
+ } from "./token-goat-chunk-HU4TORC5.mjs";
77
+ import "./token-goat-chunk-GGGG7RWB.mjs";
78
+ import "./token-goat-chunk-AM5V6GSX.mjs";
79
+ import "./token-goat-chunk-FNFBKLRD.mjs";
80
+ import "./token-goat-chunk-CO3UYX6G.mjs";
81
+ import {
82
+ init_define_import_meta_env
83
+ } from "./token-goat-chunk-A37V4PBF.mjs";
84
+
85
+ // src/cli_doctor_hooks.ts
86
+ init_define_import_meta_env();
87
+ import * as fs from "node:fs";
88
+ import * as path from "node:path";
89
+ function shimIsCurrent(scriptPath, expected) {
90
+ try {
91
+ return fs.readFileSync(scriptPath, "utf-8").replace(/\r\n/g, "\n") === expected.replace(/\r\n/g, "\n");
92
+ } catch {
93
+ return false;
94
+ }
95
+ }
96
+ var SHIM_FILE_WORD = /(?:^|[\\/])token-goat-shim\.c?js$/;
97
+ function wiringPointsAtMissingFile(entries) {
98
+ return entries.some(({ words }) => {
99
+ const native = parseNativeInvocation(words);
100
+ if (native !== void 0 && !fs.existsSync(native.bin)) return true;
101
+ return words.some((word) => SHIM_FILE_WORD.test(word) && !fs.existsSync(word));
102
+ });
103
+ }
104
+ function hasHookEventGaps(gaps) {
105
+ return gaps !== null && (gaps.missing.length > 0 || gaps.outdated.length > 0 || gaps.broken.length > 0);
106
+ }
107
+ function repairHarnessHooks(rootDir = process.cwd()) {
108
+ const repairs = [];
109
+ const errors = [];
110
+ const projectRoot = path.resolve(rootDir ?? process.cwd());
111
+ try {
112
+ const userShim = claudeHookScriptPath();
113
+ const userGaps = hookEventGaps("user");
114
+ const userInstalled = isInstalled("user") || fs.existsSync(userShim) || userGaps !== null;
115
+ if (userInstalled) {
116
+ const isStaleShim = fs.existsSync(userShim) && !shimIsCurrent(userShim, CLAUDECODE_HOOK_SCRIPT);
117
+ if (isStaleShim || hasHookEventGaps(userGaps)) {
118
+ installHooks("user");
119
+ repairs.push("Repaired Claude Code (user) hooks and shim");
120
+ }
121
+ }
122
+ } catch (e) {
123
+ errors.push(`Failed to repair Claude Code (user) hooks: ${extractErrorMessage(e)}`);
124
+ }
125
+ try {
126
+ const projShim = claudeHookScriptPath();
127
+ const projGaps = hookEventGaps("project");
128
+ const projInstalled = isInstalled("project") || projGaps !== null;
129
+ if (projInstalled) {
130
+ const isStaleShim = fs.existsSync(projShim) && !shimIsCurrent(projShim, CLAUDECODE_HOOK_SCRIPT);
131
+ if (isStaleShim || hasHookEventGaps(projGaps)) {
132
+ installHooks("project");
133
+ repairs.push("Repaired Claude Code (project) hooks and shim");
134
+ }
135
+ }
136
+ } catch (e) {
137
+ errors.push(`Failed to repair Claude Code (project) hooks: ${extractErrorMessage(e)}`);
138
+ }
139
+ try {
140
+ const userShim = copilotCliScriptPath();
141
+ const userConfig = copilotCliConfigPath();
142
+ const userInstalled = isCopilotCliInstalled() || fs.existsSync(userConfig) || fs.existsSync(userShim);
143
+ if (userInstalled) {
144
+ const isStaleShim = fs.existsSync(userShim) && !shimIsCurrent(userShim, COPILOT_CLI_HOOK_SCRIPT);
145
+ const wired = wiredCopilotHookWords();
146
+ const hasOutdatedEntries = wired.some((e) => e.current === false);
147
+ if (isStaleShim || hasOutdatedEntries || wiringPointsAtMissingFile(wired)) {
148
+ repairCopilotCliHooks();
149
+ repairs.push("Repaired Copilot CLI (user) hooks and shim");
150
+ }
151
+ }
152
+ } catch (e) {
153
+ errors.push(`Failed to repair Copilot CLI (user) hooks: ${extractErrorMessage(e)}`);
154
+ }
155
+ try {
156
+ const copilotLocalOpts = { local: true, projectRoot };
157
+ const projShim = copilotCliScriptPath(copilotLocalOpts);
158
+ const projConfig = copilotCliConfigPath(copilotLocalOpts);
159
+ const projInstalled = isCopilotCliInstalled(copilotLocalOpts) || fs.existsSync(projConfig) || fs.existsSync(projShim);
160
+ if (projInstalled) {
161
+ const isStaleShim = fs.existsSync(projShim) && !shimIsCurrent(projShim, COPILOT_CLI_HOOK_SCRIPT);
162
+ const wired = wiredCopilotHookWords(copilotLocalOpts);
163
+ const hasOutdatedEntries = wired.some((e) => e.current === false);
164
+ const pointsAtMissing = hasCreatedConfig(projConfig) && wiringPointsAtMissingFile(wired);
165
+ if (isStaleShim || hasOutdatedEntries || pointsAtMissing) {
166
+ repairCopilotCliHooks(copilotLocalOpts);
167
+ repairs.push("Repaired Copilot CLI (project) hooks and shim");
168
+ }
169
+ }
170
+ } catch (e) {
171
+ errors.push(`Failed to repair Copilot CLI (project) hooks: ${extractErrorMessage(e)}`);
172
+ }
173
+ try {
174
+ const codexShim = codexHookScriptPath();
175
+ const codexCfg = codexConfigPath();
176
+ const codexInstalled = isCodexInstalled() || fs.existsSync(codexCfg) || fs.existsSync(codexShim);
177
+ if (codexInstalled) {
178
+ const isStaleShim = fs.existsSync(codexShim) && !shimIsCurrent(codexShim, CODEX_HOOK_SCRIPT);
179
+ const wired = wiredCodexHookWords();
180
+ const hasOutdatedEntries = wired.some((e) => e.current === false);
181
+ if (isStaleShim || hasOutdatedEntries || wiringPointsAtMissingFile(wired)) {
182
+ installCodex();
183
+ repairs.push("Repaired Codex CLI hooks and shim");
184
+ }
185
+ }
186
+ } catch (e) {
187
+ errors.push(`Failed to repair Codex CLI hooks: ${extractErrorMessage(e)}`);
188
+ }
189
+ try {
190
+ const grokShim = grokHookScriptPath();
191
+ const grokCfg = grokConfigPath();
192
+ const grokInstalled = isGrokInstalled() || fs.existsSync(grokCfg) || fs.existsSync(grokShim);
193
+ if (grokInstalled) {
194
+ const isStaleShim = fs.existsSync(grokShim) && !shimIsCurrent(grokShim, GROK_HOOK_SCRIPT);
195
+ const wired = wiredGrokHookWords();
196
+ const hasOutdatedEntries = wired.some((e) => e.current === false);
197
+ if (isStaleShim || hasOutdatedEntries || wiringPointsAtMissingFile(wired)) {
198
+ installGrok();
199
+ repairs.push("Repaired Grok CLI hooks and shim");
200
+ }
201
+ }
202
+ } catch (e) {
203
+ errors.push(`Failed to repair Grok CLI hooks: ${extractErrorMessage(e)}`);
204
+ }
205
+ try {
206
+ const kimiShim = kimiHookScriptPath();
207
+ const kimiCfg = kimiConfigPath();
208
+ const kimiInstalled = isKimiInstalled() || fs.existsSync(kimiCfg) || fs.existsSync(kimiShim);
209
+ if (kimiInstalled) {
210
+ const wired = wiredKimiHookWords();
211
+ const hasOutdatedEntries = wired.some((e) => e.current === false);
212
+ if (hasOutdatedEntries || wiringPointsAtMissingFile(wired) || fs.existsSync(kimiShim) && fs.statSync(kimiShim).size === 0) {
213
+ installKimi();
214
+ repairs.push("Repaired Kimi Code hooks and shim");
215
+ }
216
+ }
217
+ } catch (e) {
218
+ errors.push(`Failed to repair Kimi Code hooks: ${extractErrorMessage(e)}`);
219
+ }
220
+ try {
221
+ if (isGeminiInstalled()) {
222
+ const res = installGemini();
223
+ if (!res.alreadyInstalled) repairs.push("Repaired Gemini CLI hooks");
224
+ }
225
+ } catch (e) {
226
+ errors.push(`Failed to repair Gemini CLI hooks: ${extractErrorMessage(e)}`);
227
+ }
228
+ try {
229
+ if (isQwenInstalled()) {
230
+ const res = installQwen();
231
+ if (!res.alreadyInstalled) repairs.push("Repaired Qwen Code hooks");
232
+ }
233
+ } catch (e) {
234
+ errors.push(`Failed to repair Qwen Code hooks: ${extractErrorMessage(e)}`);
235
+ }
236
+ try {
237
+ if (isOpencodeInstalled()) {
238
+ const res = installOpencode();
239
+ if (!res.alreadyInstalled) repairs.push("Repaired opencode plugin");
240
+ }
241
+ } catch (e) {
242
+ errors.push(`Failed to repair opencode plugin: ${extractErrorMessage(e)}`);
243
+ }
244
+ try {
245
+ if (isOpenclawInstalled()) {
246
+ const res = installOpenclaw();
247
+ if (!res.alreadyInstalled) repairs.push("Repaired OpenClaw plugin");
248
+ }
249
+ } catch (e) {
250
+ errors.push(`Failed to repair OpenClaw plugin: ${extractErrorMessage(e)}`);
251
+ }
252
+ try {
253
+ if (isPiInstalled()) {
254
+ const res = installPi();
255
+ if (!res.alreadyInstalled) repairs.push("Repaired pi extension");
256
+ } else if (isPiInstalled({ local: true })) {
257
+ const res = installPi({ local: true });
258
+ if (!res.alreadyInstalled) repairs.push("Repaired pi (project) extension");
259
+ }
260
+ } catch (e) {
261
+ errors.push(`Failed to repair pi extension: ${extractErrorMessage(e)}`);
262
+ }
263
+ try {
264
+ if (isAntigravityInstalled()) {
265
+ const res = installAntigravity();
266
+ if (!res.alreadyInstalled) repairs.push("Repaired Antigravity CLI integration");
267
+ }
268
+ } catch (e) {
269
+ errors.push(`Failed to repair Antigravity CLI integration: ${extractErrorMessage(e)}`);
270
+ }
271
+ try {
272
+ if (vscodeRunsTokenGoatClaudeHooks() && vscodeHooksInstalled()) {
273
+ if (disableVscodeClaudeHooks()) {
274
+ repairs.push(VSCODE_CLAUDE_HOOKS_TURNED_OFF_TEXT);
275
+ }
276
+ }
277
+ } catch (e) {
278
+ errors.push(`Failed to repair VS Code chat.useClaudeHooks: ${extractErrorMessage(e)}`);
279
+ }
280
+ return { repairs, errors };
281
+ }
282
+ export {
283
+ repairHarnessHooks,
284
+ shimIsCurrent,
285
+ wiringPointsAtMissingFile
286
+ };
@@ -0,0 +1,115 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ sessionSidecarPath
5
+ } from "./token-goat-chunk-WBA5SKT4.mjs";
6
+ import {
7
+ ensureDirSync
8
+ } from "./token-goat-chunk-HU4TORC5.mjs";
9
+ import {
10
+ init_define_import_meta_env
11
+ } from "./token-goat-chunk-A37V4PBF.mjs";
12
+
13
+ // src/read_shape.ts
14
+ init_define_import_meta_env();
15
+ import { readFileSync, rmSync, writeFileSync } from "node:fs";
16
+ import { dirname } from "node:path";
17
+ var SHAPES = /* @__PURE__ */ new Set(["outline", "skeleton", "fold", "truncated", "partial"]);
18
+ var SHAPE_SUFFIX = ".read-shape";
19
+ var MAX_ENTRIES = 512;
20
+ function load(target) {
21
+ try {
22
+ const parsed = JSON.parse(readFileSync(target, "utf8"));
23
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
24
+ } catch {
25
+ return {};
26
+ }
27
+ }
28
+ function recordReadShape(stateKey, file, shape) {
29
+ const target = sessionSidecarPath(stateKey, SHAPE_SUFFIX);
30
+ if (target === null) return;
31
+ try {
32
+ const shapes = load(target);
33
+ if (shape === null) {
34
+ if (!Object.hasOwn(shapes, file)) return;
35
+ delete shapes[file];
36
+ } else {
37
+ delete shapes[file];
38
+ shapes[file] = shape;
39
+ }
40
+ const keys = Object.keys(shapes);
41
+ if (keys.length === 0) {
42
+ rmSync(target, { force: true });
43
+ return;
44
+ }
45
+ for (const k of keys.slice(0, Math.max(0, keys.length - MAX_ENTRIES))) delete shapes[k];
46
+ ensureDirSync(dirname(target));
47
+ writeFileSync(target, JSON.stringify(shapes), "utf8");
48
+ } catch {
49
+ }
50
+ }
51
+ function readShapeOf(stateKey, file) {
52
+ const target = sessionSidecarPath(stateKey, SHAPE_SUFFIX);
53
+ if (target === null) return null;
54
+ const shapes = load(target);
55
+ const shape = Object.hasOwn(shapes, file) ? shapes[file] : void 0;
56
+ return shape !== void 0 && SHAPES.has(shape) ? shape : null;
57
+ }
58
+
59
+ // src/line_diff.ts
60
+ init_define_import_meta_env();
61
+ function splitLines(text) {
62
+ const lines = text.split(/\r\n|\r|\n/);
63
+ if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
64
+ return lines;
65
+ }
66
+ function lcsLength(a, b) {
67
+ const [shortArr, longArr] = a.length <= b.length ? [a, b] : [b, a];
68
+ const n = shortArr.length;
69
+ let prev = new Array(n + 1).fill(0);
70
+ let curr = new Array(n + 1).fill(0);
71
+ for (let i = 1; i <= longArr.length; i++) {
72
+ for (let j = 1; j <= n; j++) {
73
+ curr[j] = shortArr[j - 1] === longArr[i - 1] ? (prev[j - 1] ?? 0) + 1 : Math.max(prev[j] ?? 0, curr[j - 1] ?? 0);
74
+ }
75
+ const swap = prev;
76
+ prev = curr;
77
+ curr = swap;
78
+ }
79
+ return prev[n] ?? 0;
80
+ }
81
+
82
+ // src/write_target.ts
83
+ init_define_import_meta_env();
84
+ import { readFileSync as readFileSync2, statSync } from "node:fs";
85
+ var MAX_LINES_FOR_DIFF = 4e3;
86
+ var MAX_OLD_FILE_BYTES_FOR_DIFF = 4 * 1024 * 1024;
87
+ function inspectFile(filePath) {
88
+ let stat;
89
+ try {
90
+ stat = statSync(filePath);
91
+ } catch {
92
+ return { state: "absent" };
93
+ }
94
+ if (!stat.isFile()) return { state: "unusable" };
95
+ if (stat.size > MAX_OLD_FILE_BYTES_FOR_DIFF) return { state: "unread" };
96
+ try {
97
+ return { state: "text", text: readFileSync2(filePath, "utf-8") };
98
+ } catch {
99
+ return { state: "unread" };
100
+ }
101
+ }
102
+ function readKnownText(filePath) {
103
+ const onDisk = inspectFile(filePath);
104
+ return onDisk.state === "text" ? onDisk.text : "";
105
+ }
106
+
107
+ export {
108
+ recordReadShape,
109
+ readShapeOf,
110
+ splitLines,
111
+ lcsLength,
112
+ MAX_LINES_FOR_DIFF,
113
+ inspectFile,
114
+ readKnownText
115
+ };
@@ -0,0 +1,145 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ isSecretFileName
5
+ } from "./token-goat-chunk-32ZOY4N5.mjs";
6
+ import {
7
+ fenceFileText
8
+ } from "./token-goat-chunk-4NAPX7BA.mjs";
9
+ import "./token-goat-chunk-U4WHMG6Y.mjs";
10
+ import "./token-goat-chunk-GVB2MUST.mjs";
11
+ import "./token-goat-chunk-XB5KKOCG.mjs";
12
+ import "./token-goat-chunk-OUKDTVNU.mjs";
13
+ import "./token-goat-chunk-XX6O25RN.mjs";
14
+ import {
15
+ redactSecrets
16
+ } from "./token-goat-chunk-T5P5ACNQ.mjs";
17
+ import "./token-goat-chunk-7EZTZOMC.mjs";
18
+ import "./token-goat-chunk-QYHO5CPH.mjs";
19
+ import "./token-goat-chunk-4GBVPH3D.mjs";
20
+ import "./token-goat-chunk-YZAAZU2S.mjs";
21
+ import "./token-goat-chunk-IVE6U7KV.mjs";
22
+ import "./token-goat-chunk-HU4TORC5.mjs";
23
+ import "./token-goat-chunk-GGGG7RWB.mjs";
24
+ import "./token-goat-chunk-AM5V6GSX.mjs";
25
+ import "./token-goat-chunk-FNFBKLRD.mjs";
26
+ import "./token-goat-chunk-CO3UYX6G.mjs";
27
+ import {
28
+ init_define_import_meta_env
29
+ } from "./token-goat-chunk-A37V4PBF.mjs";
30
+
31
+ // src/edit_near_miss.ts
32
+ init_define_import_meta_env();
33
+ var MAX_HITS = 20;
34
+ var MAX_OLD_LINES = 200;
35
+ var MAX_OLD_CHARS = 16384;
36
+ var MIN_LINE_COVERAGE = 0.5;
37
+ var FOLDS = [
38
+ [/[‘’‚‛′]/g, "'"],
39
+ [/[“”„‟″]/g, '"'],
40
+ [/[‐‑‒–—―−]/g, "-"]
41
+ ];
42
+ function foldPunctuation(line) {
43
+ let out = line.normalize("NFKC");
44
+ for (const [pattern, replacement] of FOLDS) out = out.replace(pattern, replacement);
45
+ return out;
46
+ }
47
+ function trimEndBlanks(line) {
48
+ let end = line.length;
49
+ while (end > 0 && " \r\f\v".includes(line[end - 1])) end--;
50
+ return line.slice(0, end);
51
+ }
52
+ var RUNGS = [
53
+ { rung: "trailing-whitespace", normalize: trimEndBlanks },
54
+ { rung: "unicode-punctuation", normalize: (line) => trimEndBlanks(foldPunctuation(line)) },
55
+ { rung: "indentation", normalize: (line) => foldPunctuation(line).trim() }
56
+ ];
57
+ function splitLines(text) {
58
+ const lines = [];
59
+ let start = 0;
60
+ while (start <= text.length) {
61
+ const nl = text.indexOf("\n", start);
62
+ const end = nl === -1 ? text.length : nl;
63
+ lines.push({ text: text.slice(start, end), start, end });
64
+ if (nl === -1) break;
65
+ start = nl + 1;
66
+ }
67
+ return lines;
68
+ }
69
+ function matchesAt(fileLines, oldLines, at, tailAnchored) {
70
+ const last = oldLines.length - 1;
71
+ if (last === 0) {
72
+ const line = fileLines[at];
73
+ const old = oldLines[0];
74
+ return tailAnchored ? line.endsWith(old) : old.length >= line.length * MIN_LINE_COVERAGE && line.includes(old);
75
+ }
76
+ if (!fileLines[at].endsWith(oldLines[0])) return false;
77
+ for (let i = 1; i < last; i++) {
78
+ if (fileLines[at + i] !== oldLines[i]) return false;
79
+ }
80
+ const tail = fileLines[at + last];
81
+ return tailAnchored ? tail === oldLines[last] : tail.startsWith(oldLines[last]);
82
+ }
83
+ function findNearMiss(fileText, oldString) {
84
+ if (oldString === "" || fileText.includes(oldString)) return null;
85
+ const lines = splitLines(fileText);
86
+ const rawOld = oldString.split("\n");
87
+ if (rawOld.length > 1 && rawOld[rawOld.length - 1] === "") rawOld.pop();
88
+ if (rawOld.length > lines.length || rawOld.length > MAX_OLD_LINES || oldString.length > MAX_OLD_CHARS) return null;
89
+ for (const { rung, normalize } of RUNGS) {
90
+ const oldLines = rawOld.map(normalize);
91
+ const tailAnchored = /[ \t\r\f\v]$/.test(rawOld[rawOld.length - 1]);
92
+ if (oldLines.every((line) => line === "")) return null;
93
+ const normalized = lines.map((line) => normalize(line.text));
94
+ const hits = [];
95
+ let truncated = false;
96
+ for (let at = 0; at + oldLines.length <= lines.length; at++) {
97
+ if (!matchesAt(normalized, oldLines, at, tailAnchored)) continue;
98
+ if (hits.length === MAX_HITS) {
99
+ truncated = true;
100
+ break;
101
+ }
102
+ const first = lines[at];
103
+ const final = lines[at + oldLines.length - 1];
104
+ hits.push({ startLine: at + 1, endLine: at + oldLines.length, start: first.start, end: final.end });
105
+ }
106
+ if (hits.length > 0) return { rung, hits, truncated };
107
+ }
108
+ return null;
109
+ }
110
+ var NEAR_MISS_RUNG_NOTE = {
111
+ "trailing-whitespace": "ignoring trailing whitespace",
112
+ "unicode-punctuation": "ignoring quote, dash and space-character differences",
113
+ indentation: "ignoring indentation"
114
+ };
115
+ var MAX_SPAN_LINES = 20;
116
+ var MAX_SPAN_BYTES = 1536;
117
+ function isNearMissAdvice(text) {
118
+ return /^\[token-goat\] Edit failed: string not found in [^\n]*?, but (?:line \d+ matches|lines \d+-\d+ match|\d+\+? places match),/.test(text);
119
+ }
120
+ function describeNearMiss(fileText, display, miss) {
121
+ const [only, ...rest] = miss.hits;
122
+ if (only === void 0) return null;
123
+ const note = NEAR_MISS_RUNG_NOTE[miss.rung];
124
+ const head = `[token-goat] Edit failed: string not found in ${display}`;
125
+ if (rest.length > 0) {
126
+ const where = miss.hits.slice(0, 5).map((hit) => hit.startLine === hit.endLine ? `${hit.startLine}` : `${hit.startLine}-${hit.endLine}`);
127
+ const count = `${miss.hits.length}${miss.truncated ? "+" : ""}`;
128
+ return `${head}, but ${count} places match, ${note} (lines ${where.join(", ")}). View one range and add surrounding context to old_string.`;
129
+ }
130
+ const range = only.startLine === only.endLine ? `line ${only.startLine} matches` : `lines ${only.startLine}-${only.endLine} match`;
131
+ const span = redactSecrets(fileText.slice(only.start, only.end)).text;
132
+ if (isSecretFileName(display) || only.endLine - only.startLine + 1 > MAX_SPAN_LINES || Buffer.byteLength(span, "utf8") > MAX_SPAN_BYTES) {
133
+ return `${head}, but ${range}, ${note}. View that range to copy the exact text.`;
134
+ }
135
+ return `${head}, but ${range}, ${note}. Copy the on-disk text below into old_string exactly:
136
+ ${fenceFileText(span)}`;
137
+ }
138
+ export {
139
+ MAX_SPAN_BYTES,
140
+ MAX_SPAN_LINES,
141
+ NEAR_MISS_RUNG_NOTE,
142
+ describeNearMiss,
143
+ findNearMiss,
144
+ isNearMissAdvice
145
+ };