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,52 +1,56 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
- DELIVERS_CONTENT_RE,
5
- commandPathIsTouchable,
6
- leadWithCommand
7
- } from "./token-goat-chunk-E5TK5DNO.mjs";
4
+ commandPathIsTouchable
5
+ } from "./token-goat-chunk-P6VGNTQT.mjs";
8
6
  import {
7
+ dropFileLineRangesIfChanged,
9
8
  getFileLineRanges
10
- } from "./token-goat-chunk-TDUT2CL6.mjs";
9
+ } from "./token-goat-chunk-GL3ETKSC.mjs";
11
10
  import {
12
11
  hasBareBackgroundOrNewline,
13
12
  hasUnquotedOperator,
14
13
  isRedirectAmpersand
15
- } from "./token-goat-chunk-2WOUYWLM.mjs";
14
+ } from "./token-goat-chunk-4GILLLWY.mjs";
16
15
  import {
17
16
  isUnderSystemTemp
18
- } from "./token-goat-chunk-TGOXNAHW.mjs";
17
+ } from "./token-goat-chunk-4GBVPH3D.mjs";
19
18
  import {
20
19
  FALSY_ENV_VALUES
21
20
  } from "./token-goat-chunk-IVE6U7KV.mjs";
22
21
  import {
23
- escapeRegExp,
24
- safeSlice
25
- } from "./token-goat-chunk-XYWPOSCN.mjs";
22
+ escapeRegExp
23
+ } from "./token-goat-chunk-HU4TORC5.mjs";
24
+ import {
25
+ configGetCommand,
26
+ docSectionHint,
27
+ grepLinesHint,
28
+ leadWithCommand,
29
+ quotedArg,
30
+ quotedArgs
31
+ } from "./token-goat-chunk-GGGG7RWB.mjs";
26
32
  import {
27
33
  TOOL_RESULTS_ID_CHARS,
34
+ hostPathOfIndexKey,
28
35
  normalizePath,
29
36
  resolveIndexPath
30
- } from "./token-goat-chunk-NMTKNYGF.mjs";
37
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
31
38
  import {
32
39
  init_define_import_meta_env
33
40
  } from "./token-goat-chunk-A37V4PBF.mjs";
34
41
 
35
- // src/tool_error_class.ts
36
- init_define_import_meta_env();
37
-
38
42
  // src/bash_extractors.ts
39
43
  init_define_import_meta_env();
40
44
  import { statSync, openSync, readSync, closeSync } from "node:fs";
41
45
  function outlineCommand(shown) {
42
- return 'token-goat outline "' + shown + '"';
46
+ return "token-goat outline " + quotedArg(shown);
43
47
  }
44
48
  function structuredDataHint(hintPath, target, reason = "") {
45
49
  const ext = /\.(json|ya?ml)$/i.exec(hintPath)?.[1];
46
50
  if (ext === void 0) return null;
47
51
  const fmt = ext.toLowerCase() === "json" ? "json" : "yaml";
48
- const outline = "token-goat " + fmt + '-outline "' + hintPath + '"';
49
- const query = (path2) => "token-goat " + fmt + '-query "' + hintPath + '" "' + path2 + '"';
52
+ const outline = "token-goat " + fmt + "-outline " + quotedArg(hintPath);
53
+ const query = (path2) => "token-goat " + fmt + "-query " + quotedArgs(hintPath, path2).join(" ");
50
54
  if (target === null || /["'`$\\]/.test(target)) {
51
55
  return leadWithCommand(outline, "to list the top-level keys with their type and size (`--filter TEXT` narrows a large one), then `" + query("KEY") + "` to read one value (`\"['a.b']\"` for a key holding a dot)", reason);
52
56
  }
@@ -54,24 +58,27 @@ function structuredDataHint(hintPath, target, reason = "") {
54
58
  return leadWithCommand(query(path), "to read that value, or `" + outline + "` for every top-level key with its type and size", reason);
55
59
  }
56
60
  function sqlTableHint(hintPath, target, reason = "") {
57
- return leadWithCommand('token-goat read "' + hintPath + "::" + target.name + '"', "to pull one CREATE TABLE / CREATE TYPE block", reason);
61
+ return leadWithCommand("token-goat read " + quotedArg(hintPath + "::" + target.name), "to pull one CREATE TABLE / CREATE TYPE block", reason);
58
62
  }
59
63
  function surgicalHintFor(hintPath, isEnv, isConfig, isDoc, isXml, target, reason = "") {
60
64
  const outline = outlineCommand(hintPath);
61
- if (isXml) return leadWithCommand('token-goat xml-outline "' + hintPath + '"', 'to inspect structure, or `token-goat xml-query "' + hintPath + '" "<selector>"` to query specific nodes', reason);
62
- if (isEnv) return leadWithCommand('token-goat config-get "' + hintPath + '" ' + target.name, "to read a specific variable", reason);
65
+ if (isXml) return leadWithCommand("token-goat xml-outline " + quotedArg(hintPath), "to inspect structure, or `token-goat xml-query " + quotedArgs(hintPath, "<selector>").join(" ") + "` to query specific nodes", reason);
66
+ if (isEnv) return leadWithCommand(configGetCommand(hintPath, target.name), "to read a specific variable", reason);
67
+ if (isConfig && /\.properties$/i.test(hintPath)) {
68
+ return target.real ? leadWithCommand(configGetCommand(hintPath, target.name), "to read a specific value", reason) : grepLinesHint("<key>", hintPath, reason);
69
+ }
63
70
  if (isConfig) {
64
71
  const structured = structuredDataHint(hintPath, target.real ? target.name : null, reason);
65
72
  if (structured !== null) return structured;
66
- return target.slice === "key" ? leadWithCommand('token-goat config-get "' + hintPath + '" ' + target.name, "to read a specific value, or `" + outline + "` for every key with line ranges", reason) : leadWithCommand('token-goat section "' + hintPath + "::" + target.name + '"', "to read one table, or `" + outline + "` for every key with line ranges", reason);
73
+ return target.slice === "key" ? leadWithCommand(configGetCommand(hintPath, target.name), "to read a specific value, or `" + outline + "` for every key with line ranges", reason) : leadWithCommand("token-goat section " + quotedArg(hintPath + "::" + target.name), "to read one table, or `" + outline + "` for every key with line ranges", reason);
67
74
  }
68
- if (isDoc) return leadWithCommand('token-goat section "' + hintPath + "::" + target.name + '"', "to read one section, or `" + outline + "` for every heading with line ranges", reason);
69
- return target.real ? leadWithCommand('token-goat read "' + hintPath + "::" + target.name + '"', "to read one function or class, or `" + outline + "` for all of them", reason) : leadWithCommand(outline, "to list every function and class with its line range", reason);
75
+ if (isDoc) return docSectionHint(hintPath, target.name, reason);
76
+ return target.real ? leadWithCommand("token-goat read " + quotedArg(hintPath + "::" + target.name), "to read one function or class, or `" + outline + "` for all of them", reason) : leadWithCommand(outline, "to list every function and class with its line range", reason);
70
77
  }
71
78
  function surgicalHintForConfigDoc(filePath, isConfig, isDoc, isSql, isXml, target, reason = "") {
72
79
  if (isXml || isConfig || isDoc) return surgicalHintFor(filePath, false, isConfig, isDoc, isXml, target, reason);
73
80
  if (isSql) return sqlTableHint(filePath, target, reason);
74
- return leadWithCommand(outlineCommand(filePath), 'or `token-goat skeleton "' + filePath + '"` to see the file structure', reason);
81
+ return leadWithCommand(outlineCommand(filePath), "or `token-goat skeleton " + quotedArg(filePath) + "` to see the file structure", reason);
75
82
  }
76
83
  function splitShellSegments(cmd) {
77
84
  const segments = [];
@@ -148,7 +155,7 @@ function classifyCatPath(filePath, cmd0) {
148
155
  return { filePath, ...flags, cmd0 };
149
156
  }
150
157
  function extractCatFile(cmd) {
151
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
158
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
152
159
  const m = /^(cat|bat|type|Get-Content|gc)(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+?))(?:\s+-[a-zA-Z].*?)?(?:\s+2>(&1|\/dev\/null))?\s*$/i.exec(cmd);
153
160
  if (!m) return null;
154
161
  const cmd0 = m[1];
@@ -190,7 +197,7 @@ function extractPowerShellWrappedGetContent(cmd, event) {
190
197
  if (!w) return null;
191
198
  const inner = (w[1] ?? w[2] ?? "").trim();
192
199
  if (!inner) return null;
193
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
200
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
194
201
  const m = PS_GETCONTENT_INNER_RE.exec(inner);
195
202
  if (!m) return null;
196
203
  const filePath = m[1] ?? m[2] ?? m[3];
@@ -225,9 +232,12 @@ function extractPowerShellFileMethodRead(cmd, event) {
225
232
  }
226
233
  return { filePath, isDoc: flags.isDoc, isEnv: flags.isEnv, isConfig: flags.isConfig, isSql: flags.isSql, isXml: flags.isXml };
227
234
  }
235
+ function hasLineNumberFlag(cmd) {
236
+ return /(?:^|\s)-[a-mo-zA-Z]*n[a-zA-Z]*(?=\s|$)/.test(cmd) || /(?:^|\s)--line-number(?=\s|$)/.test(cmd);
237
+ }
228
238
  function extractRgSymbolSearch(cmd) {
229
239
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
230
- if (!/-n\b/.test(cmd)) return null;
240
+ if (!hasLineNumberFlag(cmd)) return null;
231
241
  const patternMatch = /["']([^"']+)["']/.exec(cmd);
232
242
  const pattern = patternMatch?.[1];
233
243
  if (!pattern) return null;
@@ -620,8 +630,9 @@ function substituteSentence(filePath, ranges, sub) {
620
630
  const allReads = reads.length === 2 ? reads.join(" and ") : reads.length >= 3 ? reads.slice(0, -1).join(", ") + ", and " + reads[reads.length - 1] : reads[0];
621
631
  return "Lines " + spans + " of " + filePath + " cost " + sub.requestedBytes + " bytes; " + allReads + " returns the same content as " + sub.replacementBytes + " bytes, resolved to whole regions and robust to line shifts.";
622
632
  }
623
- function leadingLinesHint(lead, hintPath, start, end, preHookCwd, substitute) {
633
+ function leadingLinesHint(lead, hintPath, start, end, preHookCwd, substitute, event) {
624
634
  const key = resolveIndexPath(hintPath, preHookCwd ?? process.cwd());
635
+ if (commandPathIsTouchable(hintPath, event)) dropFileLineRangesIfChanged(key);
625
636
  const prior = findRangeOverlap(getFileLineRanges(key), start, end);
626
637
  if (prior !== null) return sedOverlapHint(hintPath, prior, start, end);
627
638
  if (substitute === null) return null;
@@ -647,7 +658,7 @@ function sedOverlapHint(filePath, prior, start, end) {
647
658
  if (segments.length === 0) {
648
659
  return base + "These lines were already served - recall them from your earlier output instead of re-reading.";
649
660
  }
650
- const reads = segments.map(([s, e]) => '`token-goat read "' + filePath + "@" + s + "-" + e + '"`').join(" and ");
661
+ const reads = segments.map(([s, e]) => "`token-goat read " + quotedArg(filePath + "@" + s + "-" + e) + "`").join(" and ");
651
662
  return base + "For only the new lines, " + reads + ".";
652
663
  }
653
664
  function extractNodeFileRead(cmd) {
@@ -673,9 +684,6 @@ function extractNodeFileRead(cmd) {
673
684
  return null;
674
685
  }
675
686
  function extractTailFile(cmd) {
676
- if (/-f\b/.test(cmd)) return null;
677
- if (/-c\b/.test(cmd)) return null;
678
- if (/-n\s*\+/.test(cmd)) return null;
679
687
  const direct = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
680
688
  const piped = direct === null ? /^cat(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+?))(?:\s+2>(?:&1|\/dev\/null))?\s*\|\s*tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s*$/.exec(cmd) : null;
681
689
  if (direct === null && piped === null) return null;
@@ -696,7 +704,7 @@ function extractGetContentTail(cmd) {
696
704
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
697
705
  if (!getnMatch) return null;
698
706
  const afterCmd = cmd.slice(getnMatch[0].length).replace(/-Path\s+/i, "");
699
- const beforeTail = afterCmd.split(/-Tail/i)[0]?.trim() ?? "";
707
+ const beforeTail = afterCmd.split(/(?:^|\s)-Tail\b/i)[0]?.trim() ?? "";
700
708
  const afterTail = afterCmd.split(/-Tail\s+\d+/i)[1]?.trim() ?? "";
701
709
  const filePath = (beforeTail || afterTail).replace(/^["']|["']$/g, "");
702
710
  if (!filePath) return null;
@@ -718,17 +726,16 @@ function extractGetContentSelectFirst(cmd) {
718
726
  return { filePath, isDoc, isConfig, isSql, isXml, n };
719
727
  }
720
728
  function extractGetContentHead(cmd) {
721
- const headMatch = /-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
729
+ const headMatch = /(?:^|\s)-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
722
730
  if (!headMatch) return null;
723
731
  const n = parseInt(headMatch[1], 10);
724
732
  if (n <= 10) return null;
725
733
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
726
734
  if (!getnMatch) return null;
727
- const afterCmd = cmd.slice(getnMatch[0].length).replace(/-Path\s+/i, "");
728
- const beforeHead = afterCmd.split(/-(?:TotalCount|Head|First)/i)[0]?.trim() ?? "";
729
- const afterHead = afterCmd.split(/-(?:TotalCount|Head|First)\s+\d+/i)[1]?.trim() ?? "";
730
- const cleanedBefore = beforeHead.replace(/-(?:Encoding|Delimiter|Wait)\s+\S+/gi, "").replace(/-[a-zA-Z]+/g, "").trim();
731
- const cleanedAfter = afterHead.replace(/-(?:Encoding|Delimiter|Wait)\s+\S+/gi, "").replace(/-[a-zA-Z]+/g, "").trim();
735
+ const afterCmd = cmd.slice(getnMatch[0].length).replace(/(?:^|\s)-Path\s+/i, " ");
736
+ const [beforeHead = "", afterHead = ""] = afterCmd.split(/(?:^|\s)-(?:TotalCount|Head|First)\s+\d+/i, 2);
737
+ const cleanedBefore = beforeHead.replace(/(?:^|\s)-(?:Encoding|Delimiter|Wait)\s+\S+/gi, " ").replace(/(?:^|\s)-[a-zA-Z]+(?=\s|$)/g, " ").trim();
738
+ const cleanedAfter = afterHead.replace(/(?:^|\s)-(?:Encoding|Delimiter|Wait)\s+\S+/gi, " ").replace(/(?:^|\s)-[a-zA-Z]+(?=\s|$)/g, " ").trim();
732
739
  const filePath = (cleanedBefore || cleanedAfter).replace(/^["']|["']$/g, "");
733
740
  if (!filePath) return null;
734
741
  if (isTempPath(filePath)) return null;
@@ -740,7 +747,7 @@ var JSONL_TRANSCRIPT_HEAD_RE = /^\{\s*"(?:(?:parentUuid|isSidechain)"\s*:|type"\
740
747
  function taskOutputIsJsonlTranscript(outPath) {
741
748
  let fd = null;
742
749
  try {
743
- fd = openSync(normalizePath(outPath), "r");
750
+ fd = openSync(hostPathOfIndexKey(normalizePath(outPath)), "r");
744
751
  const buf = Buffer.alloc(64);
745
752
  const read = readSync(fd, buf, 0, buf.length, 0);
746
753
  return JSONL_TRANSCRIPT_HEAD_RE.test(buf.subarray(0, read).toString("utf-8").trim());
@@ -765,7 +772,7 @@ function extractTasksOutput(cmd) {
765
772
  if (m) return { id: m[1], path: fp };
766
773
  }
767
774
  }
768
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
775
+ {
769
776
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
770
777
  if (tailM) {
771
778
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -799,7 +806,7 @@ function extractToolResultsFile(cmd) {
799
806
  if (m) return { path: fp };
800
807
  }
801
808
  }
802
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
809
+ {
803
810
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
804
811
  if (tailM) {
805
812
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -834,7 +841,7 @@ function extractFindCommand(cmd) {
834
841
  }
835
842
  function extractMarkdownHeadingGrep(cmd) {
836
843
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
837
- if (!/-n\b/.test(cmd)) return null;
844
+ if (!hasLineNumberFlag(cmd)) return null;
838
845
  const hasHeadingPattern = /["']?\^#{1,6}["']?/.test(cmd) || /["']?\^#\+["']?/.test(cmd) || /["']?\^#\\+["']?/.test(cmd);
839
846
  if (!hasHeadingPattern) return null;
840
847
  const fileMatch = /(?:^|\s)(?:"([^"]+\.(?:md|markdown))"|'([^']+\.(?:md|markdown))'|([^\s"'|<>]+\.(?:md|markdown)))\s*(?:\||$)/.exec(cmd);
@@ -926,16 +933,18 @@ function stripHeredocBodies(cmd) {
926
933
  }
927
934
  var ASSIGNMENT_PREFIX_WORDS = /* @__PURE__ */ new Set(["env", "export", "time", "command", "nohup", "exec", "!", "{", "do", "then", "else"]);
928
935
  var ENV_VALUE_FLAGS = /* @__PURE__ */ new Set(["-u", "--unset", "-C", "--chdir"]);
936
+ var ENV_CHDIR_FLAG = /^(?:--c|-[A-BD-Za-z]*C)/;
929
937
  var ENV_PREFIX_WORDS = /* @__PURE__ */ new Set(["env"]);
930
938
  function walkCommandPrefix(words, prefixWords) {
931
939
  const assignments = [];
932
940
  let prefixed = false;
941
+ let chdir = false;
933
942
  for (let i = 0; i < words.length; i++) {
934
943
  const word = words[i];
935
944
  const pwsh = /^\$env:([A-Za-z_]\w*)(?:=(.*))?$/i.exec(word);
936
945
  if (pwsh !== null) {
937
946
  assignments.push({ name: pwsh[1].toUpperCase(), value: pwsh[2] ?? (words[i + 1] === "=" ? words[i + 2] : void 0) });
938
- return { command: i, assignments };
947
+ return { command: i, assignments, chdir };
939
948
  }
940
949
  const posix = /^([A-Za-z_]\w*)=(.*)$/.exec(word);
941
950
  if (posix !== null) {
@@ -947,17 +956,24 @@ function walkCommandPrefix(words, prefixWords) {
947
956
  continue;
948
957
  }
949
958
  if (prefixed && word.startsWith("-")) {
950
- if (ENV_VALUE_FLAGS.has(word)) i++;
959
+ if (ENV_CHDIR_FLAG.test(word)) chdir = true;
960
+ if (ENV_VALUE_FLAGS.has(word) || /^-[A-Za-z]+C$/.test(word)) i++;
951
961
  continue;
952
962
  }
953
- return { command: i, assignments };
963
+ return { command: i, assignments, chdir };
954
964
  }
955
- return { command: words.length, assignments };
965
+ return { command: words.length, assignments, chdir };
956
966
  }
967
+ var caseless = (literal) => literal.replace(/[A-Za-z]/g, (c) => `[${c.toUpperCase()}${c.toLowerCase()}]`);
968
+ var CHANGES_WHAT_RUNS_NAMES = ["PATH", "BASH_ENV", "ENV", "CDPATH", "HOME", "SHELL", "IFS", "PROMPT_COMMAND", "USERPROFILE", "APPDATA", "LOCALAPPDATA"].map(caseless).join("|") + `|(?:${caseless("LD_")}|${caseless("DYLD_")}|${caseless("XDG_")}|${caseless("GIT_")}|${caseless("NPM_CONFIG_")}|${caseless("PIP_")}|${caseless("UV_")}|${caseless("PERL")}|${caseless("RUBY")})\\w*|${caseless("NODE_")}(?!${caseless("ENV")}\\b)\\w*|${caseless("PYTHON")}(?!${["IOENCODING", "UTF8", "UNBUFFERED", "DONTWRITEBYTECODE"].map(caseless).join("|")}\\b)\\w*|${caseless("TOKEN_GOAT_")}(?!${caseless("BASH_COMPRESS")}\\b)\\w*`;
969
+ var CHANGES_WHAT_RUNS = new RegExp(`^(?:${CHANGES_WHAT_RUNS_NAMES})$`);
957
970
  function stripLeadingAssignments(cmd) {
958
971
  const { words, starts } = splitCommandWordsAt(cmd);
959
- const at = starts[walkCommandPrefix(words, ENV_PREFIX_WORDS).command];
972
+ const { command, assignments, chdir } = walkCommandPrefix(words, ENV_PREFIX_WORDS);
973
+ const at = starts[command];
960
974
  if (at === void 0 || at === 0) return cmd;
975
+ if (chdir) return cmd;
976
+ if (assignments.some(({ name }) => CHANGES_WHAT_RUNS.test(name))) return cmd;
961
977
  return isCompressibleSingleCommand(cmd.slice(0, at + 1)) ? cmd.slice(at) : cmd;
962
978
  }
963
979
  function commandOptsOutOfCompression(cmd) {
@@ -970,6 +986,9 @@ function commandOptsOutOfCompression(cmd) {
970
986
  }
971
987
  return false;
972
988
  }
989
+ function compressionOptedOut(rawCmd) {
990
+ return process.env["TOKEN_GOAT_BASH_COMPRESS"] === "0" || commandOptsOutOfCompression(rawCmd);
991
+ }
973
992
  var CURL_VALUE_FLAGS = /* @__PURE__ */ new Set([
974
993
  "-H",
975
994
  "--header",
@@ -1217,112 +1236,6 @@ function extractTerminalXmlParsing(cmd) {
1217
1236
  return null;
1218
1237
  }
1219
1238
 
1220
- // src/tool_error_class.ts
1221
- var UNKNOWN_REASON = "unclassified";
1222
- var DENIAL_KIND_REASONS = {
1223
- "permission-rule": "hook_deny",
1224
- // 73 in the census: the user declined an approval prompt.
1225
- "user-rejected": "user_rejected",
1226
- // 1 in the census; kept because it is an enumerated harness value, not a text guess.
1227
- "automode-blocked": "auto_mode_blocked"
1228
- };
1229
- var TG_DENY_RE = /\[tg\]|token-goat/;
1230
- var CONTENT_DELIVERED_REASON = "tg_content_delivered";
1231
- function tgDenyReason(text) {
1232
- return DELIVERS_CONTENT_RE.test(text) ? CONTENT_DELIVERED_REASON : "tg_deny";
1233
- }
1234
- var HOOK_DENY_TEXT_RE = /^PreToolUse:\S+ hook error: /;
1235
- var TEST_OR_BUILD_COMMAND_RE = /^(?:npm\s+(?:test|run\s+(?:test|build|lint|typecheck))|npx\s+(?:vitest|tsc|eslint|jest|playwright)|vitest|jest|pytest|tsc|eslint|cargo\s+(?:test|build|check|clippy)|go\s+(?:test|build|vet)|make|gradle|mvn|dotnet\s+(?:test|build)|ruff|mypy|python3?\s+-m\s+(?:pytest|unittest))\b/;
1236
- var SEARCH_COMMAND_RE = /^(?:grep|egrep|fgrep|rg|findstr)\b/;
1237
- function runsCommand(command, head) {
1238
- return splitShellSegments(command).some((segment) => head.test(stripLeadingAssignments(segment)));
1239
- }
1240
- var EXPECTED_PATTERNS = [
1241
- // 176: the Bash tool's own timeout, reported as SIGTERM's 143 plus this line.
1242
- { reason: "command_timeout", tools: ["Bash"], re: /^Exit code \d+\s+Command timed out after / },
1243
- // 289: exit 1 with no output from a search command, which is how grep and rg report zero hits.
1244
- { reason: "search_no_match", tools: ["Bash"], re: /^Exit code 1\s*$/, command: SEARCH_COMMAND_RE },
1245
- // 252: a test, build, lint or typecheck run reporting failures, which is the tool doing its job.
1246
- { reason: "test_or_build_failed", tools: ["Bash"], re: /^Exit code \d+/, command: TEST_OR_BUILD_COMMAND_RE },
1247
- // 302: an unbalanced quote or bracket in the command itself.
1248
- { reason: "shell_syntax_error", tools: ["Bash"], re: /unexpected EOF while looking for matching|syntax error near unexpected token/ },
1249
- // 29: a binary missing from PATH.
1250
- { reason: "command_not_found", tools: ["Bash"], re: /command not found/ },
1251
- // 272: the harness refusing a bare or leading `sleep` and pointing at Monitor instead.
1252
- { reason: "sleep_blocked", tools: ["Bash"], re: /^Blocked: (?:sleep \d+ followed by|standalone sleep)/ },
1253
- // 114: old_string absent from the file.
1254
- { reason: "edit_string_not_found", tools: ["Edit", "MultiEdit"], re: /^String to replace not found in file/ },
1255
- // 37: old_string present more than once with replace_all false.
1256
- { reason: "edit_multiple_matches", tools: ["Edit", "MultiEdit"], re: /^Found \d+ matches of the string to replace/ },
1257
- // 37: the harness's read-before-write guard.
1258
- { reason: "file_not_read_yet", tools: ["Edit", "MultiEdit", "Write"], re: /^File has not been read yet/ },
1259
- // 16: the file changed on disk after the last read.
1260
- { reason: "file_modified_since_read", tools: ["Edit", "MultiEdit", "Write"], re: /^File has been modified since read/ },
1261
- // 643 (578 Bash, 53 Read, 11 Grep, 1 Edit): a path that does not exist, in each tool's own wording.
1262
- { reason: "path_not_found", re: /No such file or directory|^File does not exist\.|^Path does not exist:/ },
1263
- // 1,171: an interpreter raising: a Python traceback header, the `Node.js vN.N.N` line Node prints under every uncaught error, or a named error line (`SyntaxError: ...`). After path_not_found, so a missing file stays a missing file whichever language reported it.
1264
- { reason: "script_exception", tools: ["Bash"], re: /^(?:Traceback \(most recent call last\):|Node\.js v\d+\.\d+\.\d+\b|[A-Z]\w*(?:Error|Exception)(?: \[\w+\])?: )/m },
1265
- // 14: a Read over the harness's size ceiling.
1266
- { reason: "file_too_large", tools: ["Read"], re: /^File content \([^)]*\) exceeds maximum allowed/ },
1267
- // 85: arguments the tool's schema rejected before it ran.
1268
- { reason: "input_validation", re: /^InputValidationError/ },
1269
- // 68: a StructuredOutput call that did not match the requested schema.
1270
- { reason: "schema_mismatch", tools: ["StructuredOutput"], re: /^Output does not match required schema/ },
1271
- // 35: the harness's concurrent-subagent ceiling.
1272
- { reason: "subagent_limit", tools: ["Agent", "Task"], re: /^Concurrent subagent limit reached/ },
1273
- // 37: a tool disabled for this session or a misspelled tool name.
1274
- { reason: "tool_unavailable", re: /^Error: No such tool available/ }
1275
- ];
1276
- var EXPECTED_REASONS = [
1277
- "interrupted",
1278
- "tg_deny",
1279
- CONTENT_DELIVERED_REASON,
1280
- ...new Set(Object.values(DENIAL_KIND_REASONS)),
1281
- ...EXPECTED_PATTERNS.map((p) => p.reason)
1282
- ];
1283
- var TOOL_USE_ERROR_OPEN = "<tool_use_error>";
1284
- var TOOL_USE_ERROR_CLOSE = "</tool_use_error>";
1285
- function unwrapToolError(errorText) {
1286
- let text = errorText.trim();
1287
- if (text.startsWith(TOOL_USE_ERROR_OPEN)) text = text.slice(TOOL_USE_ERROR_OPEN.length);
1288
- if (text.endsWith(TOOL_USE_ERROR_CLOSE)) text = text.slice(0, text.length - TOOL_USE_ERROR_CLOSE.length);
1289
- return text.trim();
1290
- }
1291
- function expected(reason) {
1292
- return { kind: "expected", reason };
1293
- }
1294
- function classifyToolError(tool, errorText, flags = {}) {
1295
- if (flags.isInterrupt === true) return expected("interrupted");
1296
- const text = unwrapToolError(errorText);
1297
- const denial = flags.denialKind;
1298
- if (denial !== void 0 && denial !== "") {
1299
- const reason = DENIAL_KIND_REASONS[denial] ?? "hook_deny";
1300
- return expected(reason === "hook_deny" && TG_DENY_RE.test(text) ? tgDenyReason(text) : reason);
1301
- }
1302
- if (HOOK_DENY_TEXT_RE.test(text)) return expected(TG_DENY_RE.test(text) ? tgDenyReason(text) : "hook_deny");
1303
- for (const p of EXPECTED_PATTERNS) {
1304
- if (p.tools !== void 0 && (tool === void 0 || !p.tools.includes(tool))) continue;
1305
- if (!p.re.test(text)) continue;
1306
- if (p.command !== void 0 && (flags.command === void 0 || !runsCommand(flags.command, p.command))) continue;
1307
- return expected(p.reason);
1308
- }
1309
- return { kind: "unknown", reason: UNKNOWN_REASON };
1310
- }
1311
- var ERROR_PREFIX_CHARS = 60;
1312
- var EXIT_CODE_HEADER_RE = /^Exit code (\d+)\s*/;
1313
- function errorPrefix(errorText) {
1314
- let text = unwrapToolError(errorText);
1315
- let lead = "";
1316
- const exit = EXIT_CODE_HEADER_RE.exec(text);
1317
- if (exit !== null) {
1318
- lead = `exit ${exit[1] ?? ""}: `;
1319
- text = text.slice(exit[0].length);
1320
- }
1321
- const line = text.split("\n").find((l) => l.trim() !== "") ?? "";
1322
- const masked = line.trim().replace(/\b[A-Za-z]:[\\/]\S*|~?\/[\w.~-]+(?:\/[\w.~-]*)+/g, "<path>").replace(/'[^'\n]*'|"[^"\n]*"|`[^`\n]*`/g, "<q>").replace(/\d+/g, "N");
1323
- return safeSlice(`${lead}${masked === "" ? "(empty)" : masked}`, ERROR_PREFIX_CHARS);
1324
- }
1325
-
1326
1239
  export {
1327
1240
  sqlTableHint,
1328
1241
  surgicalHintFor,
@@ -1360,8 +1273,9 @@ export {
1360
1273
  extractMarkdownHeadingGrep,
1361
1274
  extractRgStructuralSearch,
1362
1275
  extractGrepPipeChain,
1276
+ CHANGES_WHAT_RUNS_NAMES,
1363
1277
  stripLeadingAssignments,
1364
- commandOptsOutOfCompression,
1278
+ compressionOptedOut,
1365
1279
  extractCurlUrl,
1366
1280
  extractTgSurgicalRead,
1367
1281
  isCurlGetCommand,
@@ -1374,9 +1288,5 @@ export {
1374
1288
  buildRecallHint,
1375
1289
  shellQuoteSingle,
1376
1290
  isCompressibleSingleCommand,
1377
- extractTerminalXmlParsing,
1378
- CONTENT_DELIVERED_REASON,
1379
- SEARCH_COMMAND_RE,
1380
- classifyToolError,
1381
- errorPrefix
1291
+ extractTerminalXmlParsing
1382
1292
  };
@@ -2,7 +2,7 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  detectHarness
5
- } from "./token-goat-chunk-TGOXNAHW.mjs";
5
+ } from "./token-goat-chunk-QYHO5CPH.mjs";
6
6
  import {
7
7
  init_define_import_meta_env
8
8
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -0,0 +1,71 @@
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/languages/markup_scan.ts
8
+ init_define_import_meta_env();
9
+ function charFinder(text, ch) {
10
+ let cached = -2;
11
+ return (from) => {
12
+ if (cached === -1) return -1;
13
+ if (cached >= from) return cached;
14
+ cached = text.indexOf(ch, from);
15
+ return cached;
16
+ };
17
+ }
18
+ function gtFinder(text) {
19
+ return charFinder(text, ">");
20
+ }
21
+ function findOpenTags(text, open) {
22
+ const out = [];
23
+ open.lastIndex = 0;
24
+ let m;
25
+ while ((m = open.exec(text)) !== null) {
26
+ const nameEnd = m.index + m[0].length;
27
+ const gt = text.indexOf(">", nameEnd);
28
+ if (gt < 0) break;
29
+ out.push({ start: m.index, nameEnd, end: gt + 1 });
30
+ open.lastIndex = gt + 1;
31
+ }
32
+ return out;
33
+ }
34
+ function findElements(text, open, close, limit = Infinity) {
35
+ const out = [];
36
+ const next = elementCursor(text, open, close);
37
+ let el;
38
+ while (out.length < limit && (el = next()) !== null) out.push(el);
39
+ return out;
40
+ }
41
+ function elementCursor(text, open, close) {
42
+ open.lastIndex = 0;
43
+ let done = false;
44
+ return () => {
45
+ if (done) return null;
46
+ const m = open.exec(text);
47
+ if (m !== null) {
48
+ const nameEnd = m.index + m[0].length;
49
+ const gt = text.indexOf(">", nameEnd);
50
+ if (gt >= 0) {
51
+ close.lastIndex = gt + 1;
52
+ const c = close.exec(text);
53
+ if (c !== null) {
54
+ const end = c.index + c[0].length;
55
+ open.lastIndex = end;
56
+ return { start: m.index, nameEnd, end, attrs: text.slice(nameEnd, gt), body: text.slice(gt + 1, c.index), bodyEnd: c.index };
57
+ }
58
+ }
59
+ }
60
+ done = true;
61
+ return null;
62
+ };
63
+ }
64
+
65
+ export {
66
+ charFinder,
67
+ gtFinder,
68
+ findOpenTags,
69
+ findElements,
70
+ elementCursor
71
+ };