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
@@ -1,64 +0,0 @@
1
- import { createRequire as __cjsRequire } from 'node:module';
2
- const require = __cjsRequire(import.meta.url);
3
- import {
4
- OCR_LANG_FILE,
5
- OCR_LANG_PATH,
6
- OCR_LANG_SHA256,
7
- SUPPORTED_OCR_LANGS,
8
- buildChildScript,
9
- formatOcrSummary,
10
- getActiveOcrLangs,
11
- getOcrLangSpec,
12
- isOcrEngineAvailable,
13
- isTextHeavy,
14
- ocrBlockedOffline,
15
- ocrImage,
16
- ocrIntegrityFailed,
17
- quarantineOcrLangCache,
18
- resetOcrStateForTesting,
19
- resolveOcrLang,
20
- setOcrTimeoutForTesting,
21
- setTesseractEntryForTesting,
22
- verifyOcrLangCache
23
- } from "./token-goat-chunk-VZQEWRVH.mjs";
24
- import "./token-goat-chunk-D4ETHJD6.mjs";
25
- import "./token-goat-chunk-CIQ2FTY3.mjs";
26
- import "./token-goat-chunk-7CPMDFGB.mjs";
27
- import {
28
- DEFAULT_OCR_LANG,
29
- isSupportedOcrLang,
30
- resolveOcrLangs
31
- } from "./token-goat-chunk-TGOXNAHW.mjs";
32
- import "./token-goat-chunk-XB5KKOCG.mjs";
33
- import "./token-goat-chunk-YZAAZU2S.mjs";
34
- import "./token-goat-chunk-IVE6U7KV.mjs";
35
- import "./token-goat-chunk-XYWPOSCN.mjs";
36
- import "./token-goat-chunk-TCQANXYC.mjs";
37
- import "./token-goat-chunk-NMTKNYGF.mjs";
38
- import "./token-goat-chunk-MELOKFDJ.mjs";
39
- import "./token-goat-chunk-JTKCQMQA.mjs";
40
- import "./token-goat-chunk-A37V4PBF.mjs";
41
- export {
42
- DEFAULT_OCR_LANG,
43
- OCR_LANG_FILE,
44
- OCR_LANG_PATH,
45
- OCR_LANG_SHA256,
46
- SUPPORTED_OCR_LANGS,
47
- buildChildScript,
48
- formatOcrSummary,
49
- getActiveOcrLangs,
50
- getOcrLangSpec,
51
- isOcrEngineAvailable,
52
- isSupportedOcrLang,
53
- isTextHeavy,
54
- ocrBlockedOffline,
55
- ocrImage,
56
- ocrIntegrityFailed,
57
- quarantineOcrLangCache,
58
- resetOcrStateForTesting,
59
- resolveOcrLang,
60
- resolveOcrLangs,
61
- setOcrTimeoutForTesting,
62
- setTesseractEntryForTesting,
63
- verifyOcrLangCache
64
- };
@@ -1,456 +0,0 @@
1
- import { createRequire as __cjsRequire } from 'node:module';
2
- const require = __cjsRequire(import.meta.url);
3
- import {
4
- computeAdaptiveBudget,
5
- getContextPressure,
6
- isNoisePath,
7
- listSiblingSessionStates,
8
- loadSessionCache
9
- } from "./token-goat-chunk-H5J3C56Q.mjs";
10
- import {
11
- WEB_FETCH_KEY_SEP,
12
- getSessionBashOutputs,
13
- getSessionBashReruns,
14
- getSessionFiles,
15
- getSessionWebFetches
16
- } from "./token-goat-chunk-TDUT2CL6.mjs";
17
- import {
18
- getBashOutput
19
- } from "./token-goat-chunk-O6I2XU4P.mjs";
20
- import {
21
- findProject,
22
- loadConfig
23
- } from "./token-goat-chunk-TGOXNAHW.mjs";
24
- import {
25
- LOCK_WAIT_MS_HARDENED,
26
- atomicWriteText,
27
- ensureDirSync,
28
- runGit,
29
- toKB,
30
- withFileLock,
31
- withRetryOnLock
32
- } from "./token-goat-chunk-XYWPOSCN.mjs";
33
- import {
34
- foldPath,
35
- sleepSync
36
- } from "./token-goat-chunk-TCQANXYC.mjs";
37
- import {
38
- displaySafePath,
39
- displaySafeText,
40
- neutralizeSpokenMarkers
41
- } from "./token-goat-chunk-NMTKNYGF.mjs";
42
- import {
43
- dataDir
44
- } from "./token-goat-chunk-MELOKFDJ.mjs";
45
- import {
46
- init_define_import_meta_env
47
- } from "./token-goat-chunk-A37V4PBF.mjs";
48
-
49
- // src/manifest.ts
50
- init_define_import_meta_env();
51
- import { spawnSync } from "node:child_process";
52
-
53
- // src/project_memory.ts
54
- init_define_import_meta_env();
55
- import * as fs from "node:fs";
56
- import * as path from "node:path";
57
- var MAX_ENTRIES = 30;
58
- var MAX_VALUE_LEN = 300;
59
- var MAX_TOTAL_CHARS = 4e3;
60
- var KEY_RE = /^[A-Za-z0-9_-]{1,80}$/;
61
- function ordinal(a, b) {
62
- return a < b ? -1 : a > b ? 1 : 0;
63
- }
64
- function memoryPath(projectHash) {
65
- return path.join(dataDir(), "projects", `${projectHash}_memory.toml`);
66
- }
67
- function validateKey(key) {
68
- if (!KEY_RE.test(key)) {
69
- throw new Error(
70
- `Invalid memory key ${JSON.stringify(key)}: use only letters, digits, hyphens, underscores (max 80 chars)`
71
- );
72
- }
73
- }
74
- function parseTOML(content, unparsed = []) {
75
- const result = {};
76
- for (const [i, line] of content.split("\n").entries()) {
77
- const trimmed = line.trim();
78
- if (!trimmed || trimmed.startsWith("#")) {
79
- continue;
80
- }
81
- const match = trimmed.match(/^([A-Za-z0-9_-]+)\s*=\s*"(.*)"\s*$/);
82
- if (match) {
83
- const [, key, value] = match;
84
- if (key && value !== void 0) {
85
- const unescaped = value.replace(/\\([\\nrt"])/g, (_, c) => {
86
- switch (c) {
87
- case "\\":
88
- return "\\";
89
- case "n":
90
- return "\n";
91
- case "r":
92
- return "\r";
93
- case '"':
94
- return '"';
95
- default:
96
- return _;
97
- }
98
- });
99
- result[key] = unescaped;
100
- }
101
- } else {
102
- unparsed.push(i + 1);
103
- }
104
- }
105
- return result;
106
- }
107
- function loadRaw(filePath, forUpdate = false) {
108
- let content = "";
109
- try {
110
- withRetryOnLock(() => {
111
- content = fs.readFileSync(filePath, "utf-8");
112
- });
113
- } catch (err) {
114
- if (err.code === "ENOENT") return {};
115
- throw err;
116
- }
117
- const unparsed = [];
118
- const entries = parseTOML(content, unparsed);
119
- if (forUpdate && unparsed.length > 0) {
120
- const one = unparsed.length === 1;
121
- throw new Error(`Not updating ${filePath}: ${one ? "line" : "lines"} ${unparsed.join(", ")} ${one ? "is" : "are"} not in the key = "value" form, and saving would drop ${one ? "it" : "them"}. Fix or remove ${one ? "it" : "them"}, then try again.`);
122
- }
123
- return entries;
124
- }
125
- function save(filePath, entries) {
126
- const lines = [];
127
- const sorted = Object.entries(entries).sort(([a], [b]) => ordinal(a, b));
128
- for (const [k, v] of sorted) {
129
- const escaped = v.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\r/g, "\\r").replace(/\n/g, "\\n");
130
- lines.push(`${k} = "${escaped}"`);
131
- }
132
- const content = lines.length > 0 ? lines.join("\n") + "\n" : "";
133
- const dir = path.dirname(filePath);
134
- ensureDirSync(dir);
135
- atomicWriteText(filePath, content);
136
- }
137
- function loadEntries(projectHash) {
138
- return loadRaw(memoryPath(projectHash));
139
- }
140
- function setEntry(projectHash, key, value) {
141
- validateKey(key);
142
- const p = memoryPath(projectHash);
143
- const dir = path.dirname(p);
144
- ensureDirSync(dir);
145
- const doSet = () => {
146
- const entries = loadRaw(p, true);
147
- const isNewKey = !(key in entries);
148
- if (isNewKey && Object.keys(entries).length >= MAX_ENTRIES) {
149
- const keysToKeep = MAX_ENTRIES - 1;
150
- const allKeys = Object.keys(entries).sort((a, b) => ordinal(a, b));
151
- for (const k of allKeys.slice(keysToKeep)) {
152
- delete entries[k];
153
- }
154
- }
155
- entries[key] = value;
156
- save(p, entries);
157
- return true;
158
- };
159
- underNotesLock(p, doSet);
160
- }
161
- function underNotesLock(p, update) {
162
- const lockPath = `${p}.lock`;
163
- ensureDirSync(path.dirname(p));
164
- for (let attempt = 1; attempt <= 3; attempt++) {
165
- if (withFileLock(lockPath, update, { waitMs: LOCK_WAIT_MS_HARDENED }) !== void 0) return;
166
- if (fs.existsSync(lockPath)) break;
167
- if (attempt < 3) sleepSync(50 * attempt);
168
- }
169
- throw new Error(`Could not lock ${p} for writing; no note was changed. Another token-goat process may be writing notes: try again.`);
170
- }
171
- function unsetEntry(projectHash, key) {
172
- validateKey(key);
173
- const p = memoryPath(projectHash);
174
- const doUnset = () => {
175
- const entries = loadRaw(p, true);
176
- if (key in entries) {
177
- delete entries[key];
178
- save(p, entries);
179
- }
180
- return true;
181
- };
182
- underNotesLock(p, doUnset);
183
- }
184
- function clearAll(projectHash) {
185
- const p = memoryPath(projectHash);
186
- const doClear = () => {
187
- if (fs.existsSync(p)) {
188
- save(p, {});
189
- }
190
- return true;
191
- };
192
- underNotesLock(p, doClear);
193
- }
194
- function buildInjection(projectHash) {
195
- try {
196
- const entries = loadEntries(projectHash);
197
- if (Object.keys(entries).length === 0) {
198
- return null;
199
- }
200
- const header = '### Project notes (`token-goat note set <key> "<finding>"`)';
201
- const lines = [header];
202
- let total = header.length;
203
- let skipped = 0;
204
- const entries_list = Object.entries(entries).sort(([a], [b]) => ordinal(a, b)).slice(0, MAX_ENTRIES);
205
- for (const [key, val] of entries_list) {
206
- const display = val.length <= MAX_VALUE_LEN ? val : val.slice(0, MAX_VALUE_LEN) + "\u2026";
207
- const line = `- **${key}**: ${display}`;
208
- if (total + line.length + 1 > MAX_TOTAL_CHARS) {
209
- skipped++;
210
- continue;
211
- }
212
- lines.push(line);
213
- total += line.length + 1;
214
- }
215
- if (skipped > 0) {
216
- while (lines.length > 1 && total + `- (+${skipped} more memory entries omitted -- total size limit reached)`.length + 1 > MAX_TOTAL_CHARS) {
217
- const popped = lines.pop();
218
- total -= popped.length + 1;
219
- skipped++;
220
- }
221
- lines.push(`- (+${skipped} more memory entries omitted -- total size limit reached)`);
222
- }
223
- return lines.join("\n");
224
- } catch {
225
- return null;
226
- }
227
- }
228
- function projectNotesFor(cwd) {
229
- if (cwd === void 0) return null;
230
- try {
231
- const project = findProject(cwd);
232
- return project === null ? null : buildInjection(project.hash);
233
- } catch {
234
- return null;
235
- }
236
- }
237
-
238
- // src/manifest.ts
239
- var MEM_EPOCH_TIMEOUT_MS = 800;
240
- var MAX_ROWS = 40;
241
- function appendCappedSection(lines, header, rows, cap) {
242
- if (rows.length === 0) return;
243
- lines.push("");
244
- lines.push(header);
245
- for (const row of rows.slice(0, cap)) lines.push(row);
246
- if (rows.length > cap) lines.push(`- ...and ${rows.length - cap} more`);
247
- }
248
- function renderReadRow(entry) {
249
- const kb = Math.max(1, toKB(entry.sizeBytes));
250
- const plural = entry.readCount === 1 ? "read" : "reads";
251
- const edited = entry.wasEdited ? ", edited" : "";
252
- return `- ${displaySafePath(entry.path)} (${kb}kb, ${entry.readCount} ${plural}${edited})`;
253
- }
254
- function renderSymbolReadRow(entry) {
255
- return `- ${displaySafePath(entry.path)} (symbols: ${(entry.symbols_read ?? []).map(displaySafeText).join(", ")})`;
256
- }
257
- function mergeManifestFiles(parent, siblingFiles) {
258
- const byPath = /* @__PURE__ */ new Map();
259
- for (const f of parent) byPath.set(foldPath(f.path), f);
260
- for (const f of siblingFiles) {
261
- const key = foldPath(f.path);
262
- const prev = byPath.get(key);
263
- if (prev === void 0) {
264
- byPath.set(key, f);
265
- continue;
266
- }
267
- const mergedSymbols = [.../* @__PURE__ */ new Set([...prev.symbols_read ?? [], ...f.symbols_read ?? []])];
268
- byPath.set(key, {
269
- path: prev.path,
270
- readCount: Math.max(prev.readCount, f.readCount),
271
- lastReadAt: Math.max(prev.lastReadAt, f.lastReadAt),
272
- wasEdited: prev.wasEdited || f.wasEdited,
273
- sizeBytes: f.lastReadAt >= prev.lastReadAt ? f.sizeBytes : prev.sizeBytes,
274
- ...prev.wasTruncated || f.wasTruncated ? { wasTruncated: true } : {},
275
- ...mergedSymbols.length > 0 ? { symbols_read: mergedSymbols } : {}
276
- });
277
- }
278
- return Array.from(byPath.values());
279
- }
280
- function renderWebFetchRow(key, cacheId) {
281
- const [url = key, prompt = ""] = key.split(WEB_FETCH_KEY_SEP);
282
- const promptSuffix = prompt ? `, prompt: ${neutralizeSpokenMarkers(JSON.stringify(prompt))}` : "";
283
- return `- ${displaySafeText(url)} (cacheId: ${cacheId}${promptSuffix})`;
284
- }
285
- function selectManifestFiles(siblings) {
286
- const ownFiles = [...getSessionFiles().values()];
287
- const siblingFiles = siblings.flatMap((s) => s.files);
288
- const files = siblingFiles.length > 0 ? mergeManifestFiles(ownFiles, siblingFiles) : ownFiles;
289
- const editedFiles = files.filter((f) => f.wasEdited);
290
- const readFiles = files.filter((f) => f.readCount > 0 && !f.wasEdited && !isNoisePath(f.path));
291
- const symbolOnlyFiles = files.filter((f) => f.readCount === 0 && !f.wasEdited && (f.symbols_read?.length ?? 0) > 0);
292
- return { files, readFiles, editedFiles, symbolOnlyFiles };
293
- }
294
- function selectManifestWebFetches(siblings) {
295
- const merged = /* @__PURE__ */ new Map();
296
- for (const sibling of siblings) for (const [key, cacheId] of sibling.webFetches) merged.set(key, cacheId);
297
- for (const [key, cacheId] of getSessionWebFetches()) merged.set(key, cacheId);
298
- return [...merged.entries()];
299
- }
300
- function manifestPrintedPaths(sessionId, limit, cwd, transcriptPath) {
301
- const { printed } = buildManifestParts(sessionId, cwd, transcriptPath);
302
- return printed.slice(0, limit);
303
- }
304
- function buildManifestParts(sessionId, cwd, transcriptPath) {
305
- const siblings = sessionId !== void 0 ? listSiblingSessionStates(sessionId) : [];
306
- const { files, readFiles, editedFiles, symbolOnlyFiles } = selectManifestFiles(siblings);
307
- const webFetches = selectManifestWebFetches(siblings);
308
- const lines = [];
309
- lines.push("## Session context");
310
- lines.push(`Files read: ${readFiles.length}`);
311
- lines.push(`Files edited: ${editedFiles.length}`);
312
- const fileRows = [];
313
- const appendFileSection = (header, entries, render) => {
314
- const rows = entries.map(render);
315
- appendCappedSection(lines, header, rows, MAX_ROWS);
316
- for (let i = 0; i < Math.min(rows.length, MAX_ROWS); i++) fileRows.push({ path: displaySafePath(entries[i].path), row: rows[i] });
317
- };
318
- appendFileSection("### Edited files", editedFiles, (entry) => `- ${displaySafePath(entry.path)}`);
319
- const notes = projectNotesFor(cwd);
320
- if (notes !== null) lines.push("", notes);
321
- appendFileSection("### Surgically read files (symbol/section reads, never read whole)", symbolOnlyFiles, renderSymbolReadRow);
322
- appendFileSection("### Read files", readFiles, renderReadRow);
323
- appendCappedSection(lines, "### Web URLs fetched", webFetches.map(([key, cacheId]) => renderWebFetchRow(key, cacheId)), MAX_ROWS);
324
- lines.push(...buildSafeToDiscardSection(files));
325
- lines.push(...buildMemEpochSection());
326
- const text = capManifestChars(lines.join("\n"), sessionId, cwd, transcriptPath);
327
- const seen = /* @__PURE__ */ new Set();
328
- const printed = [];
329
- for (const { path: path2, row } of fileRows) {
330
- if (seen.has(path2) || !(text.includes(row + "\n") || text.endsWith(row))) continue;
331
- seen.add(path2);
332
- printed.push(path2);
333
- }
334
- return { text, printed };
335
- }
336
- function buildManifest(sessionId, cwd, transcriptPath) {
337
- return buildManifestParts(sessionId, cwd, transcriptPath).text;
338
- }
339
- function gitDirtySignals(cwd) {
340
- const timeoutMs = loadConfig().hints.git_hint_max_ms;
341
- let hasPendingDiff = false;
342
- try {
343
- const diffResult = runGit(["diff", "--no-color", "--stat", "HEAD"], { cwd, timeoutMs });
344
- hasPendingDiff = diffResult.exitCode === 0 && diffResult.stdout.trim() !== "";
345
- } catch {
346
- }
347
- let hasUncommittedChanges = false;
348
- try {
349
- const statusResult = runGit(["status", "--porcelain"], { cwd, timeoutMs });
350
- hasUncommittedChanges = statusResult.exitCode === 0 && statusResult.stdout.trim() !== "";
351
- } catch {
352
- }
353
- return { hasPendingDiff, hasUncommittedChanges };
354
- }
355
- function adaptiveCharBonus(sessionId, cwd, transcriptPath) {
356
- if (!cwd) return 0;
357
- const cache = loadSessionCache(sessionId ?? "") ?? {};
358
- const ageSecs = cache.created_ts !== void 0 ? Math.max(0, Date.now() / 1e3 - cache.created_ts) : 0;
359
- const contextPressure = getContextPressure(cache, transcriptPath);
360
- const { hasPendingDiff, hasUncommittedChanges } = gitDirtySignals(cwd);
361
- if (!hasPendingDiff && !hasUncommittedChanges) return 0;
362
- const baseline = computeAdaptiveBudget(cache, ageSecs, { contextPressure });
363
- const withGitSignal = computeAdaptiveBudget(cache, ageSecs, { hasPendingDiff, hasUncommittedChanges, contextPressure });
364
- const deltaTokens = Math.max(0, withGitSignal - baseline);
365
- return deltaTokens * 3;
366
- }
367
- function capManifestChars(manifest, sessionId, cwd, transcriptPath) {
368
- const cap = loadConfig().compact_assist.max_manifest_chars;
369
- if (cap <= 0) return manifest;
370
- if (manifest.length <= cap) return manifest;
371
- const effectiveCap = cap + adaptiveCharBonus(sessionId, cwd, transcriptPath);
372
- if (manifest.length <= effectiveCap) return manifest;
373
- const omitted = manifest.length - effectiveCap;
374
- return manifest.slice(0, effectiveCap) + `
375
- ...(manifest truncated at ${effectiveCap} chars; ${omitted} chars omitted)`;
376
- }
377
- function buildSafeToDiscardSection(files) {
378
- const rerunHashes = getSessionBashReruns();
379
- const bashOutputs = getSessionBashOutputs();
380
- const rerunHashSet = new Set(rerunHashes);
381
- const rerunRows = [];
382
- for (const hash of rerunHashes) {
383
- const id = bashOutputs.find(([h]) => h === hash)?.[1];
384
- if (id === void 0) continue;
385
- const entry = getBashOutput(id);
386
- if (entry === null) continue;
387
- const flatCommand = neutralizeSpokenMarkers(entry.command.replace(/[\t\r\n]+/g, " "));
388
- rerunRows.push("- `" + flatCommand + "` \u2014 an older run of this exact command was superseded; recall the surviving copy with `bash-output " + id + " --full`");
389
- }
390
- const supersededReadRows = [];
391
- for (const f of files) {
392
- if (f.readCount > 1 || f.wasEdited) {
393
- const reason = f.wasEdited ? "edited after being read" : "re-read " + f.readCount + "x";
394
- supersededReadRows.push("- " + displaySafePath(f.path) + " (" + reason + " \u2014 only the latest content already in context is current)");
395
- }
396
- }
397
- const cachedOutputRows = [];
398
- for (const [hash, id] of bashOutputs) {
399
- if (rerunHashSet.has(hash)) continue;
400
- const entry = getBashOutput(id);
401
- if (entry === null) continue;
402
- const flatCommand = neutralizeSpokenMarkers(entry.command.replace(/[\t\r\n]+/g, " "));
403
- cachedOutputRows.push("- `" + flatCommand + "` \u2014 recallable via `bash-output " + id + " --full`");
404
- }
405
- const total = rerunRows.length + supersededReadRows.length + cachedOutputRows.length;
406
- if (total === 0) return [];
407
- const lines = [];
408
- lines.push("");
409
- lines.push("### SAFE_TO_DISCARD (" + total + " items \u2014 provably inert; each is recallable, not gone)");
410
- appendCappedSection(lines, "Superseded reruns (" + rerunRows.length + "):", rerunRows, MAX_ROWS);
411
- appendCappedSection(lines, "Superseded file reads (" + supersededReadRows.length + "):", supersededReadRows, MAX_ROWS);
412
- appendCappedSection(lines, "Other cached bash outputs (" + cachedOutputRows.length + "):", cachedOutputRows, MAX_ROWS);
413
- return lines;
414
- }
415
- function buildMemEpochSection() {
416
- let result;
417
- try {
418
- result = spawnSync("mem", ["epoch"], {
419
- encoding: "utf-8",
420
- timeout: MEM_EPOCH_TIMEOUT_MS,
421
- windowsHide: true
422
- });
423
- } catch {
424
- return [];
425
- }
426
- if (result.error !== void 0 || result.status !== 0) return [];
427
- const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
428
- if (!/^\d+$/.test(stdout)) return [];
429
- return [
430
- "",
431
- "### mem epoch",
432
- `mem epoch: ${stdout} (no live TGMEM block is tracked in this session -- only the epoch counter is folded in; see buildMemEpochSection's doc comment)`
433
- ];
434
- }
435
- var MANIFEST_PREAMBLE = "When summarizing this session, keep the file paths and symbol names below exactly as written -- they are the handles the next turn needs to resume work. Do not paraphrase them into prose.";
436
- var MANIFEST_RECOVERY_PREAMBLE = "The conversation was just compacted. Below is what this session touched, recovered from token-goat's own ledger rather than from the summary -- use it to re-establish paths and symbol names the summary may have dropped.";
437
- var BUDGET_ESCALATION_MARKER = "TG-BUDGET-ESCALATION:";
438
- function summaryBudgetDirective(budgetChars) {
439
- if (budgetChars <= 0) return "";
440
- return ` Aim for at most ${budgetChars} characters. Prefer a shorter summary that keeps every path, symbol, command and decision over a longer one that reproduces tool output verbatim: cite the recall id (\`token-goat bash-output <id> --full\`) rather than quoting the output again. If this session genuinely cannot be summarized within that target without losing state the next turn needs, exceed it and open the summary with a single line reading \`${BUDGET_ESCALATION_MARKER} <one-sentence reason>\`.`;
441
- }
442
-
443
- export {
444
- loadEntries,
445
- setEntry,
446
- unsetEntry,
447
- clearAll,
448
- projectNotesFor,
449
- renderWebFetchRow,
450
- manifestPrintedPaths,
451
- buildManifest,
452
- MANIFEST_PREAMBLE,
453
- MANIFEST_RECOVERY_PREAMBLE,
454
- BUDGET_ESCALATION_MARKER,
455
- summaryBudgetDirective
456
- };
@@ -1,36 +0,0 @@
1
- import { createRequire as __cjsRequire } from 'node:module';
2
- const require = __cjsRequire(import.meta.url);
3
- import {
4
- XlsxScanTooLargeError,
5
- allSheetsHeadText,
6
- formatXlsxColumns,
7
- formatXlsxRange,
8
- headSheet,
9
- listSheets,
10
- querySheet,
11
- rangeSheet,
12
- xlsxColumns
13
- } from "./token-goat-chunk-PYSUADX4.mjs";
14
- import "./token-goat-chunk-DNSPXQXQ.mjs";
15
- import "./token-goat-chunk-3BTK54F3.mjs";
16
- import "./token-goat-chunk-UXSXQQIY.mjs";
17
- import "./token-goat-chunk-XTQAOTSO.mjs";
18
- import "./token-goat-chunk-AH6QILZM.mjs";
19
- import "./token-goat-chunk-XYWPOSCN.mjs";
20
- import "./token-goat-chunk-TCQANXYC.mjs";
21
- import "./token-goat-chunk-NMTKNYGF.mjs";
22
- import "./token-goat-chunk-MELOKFDJ.mjs";
23
- import "./token-goat-chunk-Y4AFKTHK.mjs";
24
- import "./token-goat-chunk-JTKCQMQA.mjs";
25
- import "./token-goat-chunk-A37V4PBF.mjs";
26
- export {
27
- XlsxScanTooLargeError,
28
- allSheetsHeadText,
29
- formatXlsxColumns,
30
- formatXlsxRange,
31
- headSheet,
32
- listSheets,
33
- querySheet,
34
- rangeSheet,
35
- xlsxColumns
36
- };