token-goat 2.9.28 → 2.9.30

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 (134) hide show
  1. package/README.md +36 -40
  2. package/SECURITY.md +28 -10
  3. package/THIRD_PARTY_NOTICES.md +40 -3
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/ort-wasm-simd-threaded.mjs +59 -0
  7. package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
  8. package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
  9. package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
  10. package/dist/{token-goat-chunk-66LODAUT.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
  11. package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
  12. package/dist/token-goat-chunk-54K3EUV3.mjs +35 -0
  13. package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
  14. package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
  15. package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -0
  16. package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
  17. package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
  18. package/dist/{token-goat-chunk-NILVK7XM.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -6
  19. package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-664RTTUV.mjs} +31 -15
  20. package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
  21. package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
  22. package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
  23. package/dist/{token-goat-chunk-F7QZRIWM.mjs → token-goat-chunk-7F2UBPD3.mjs} +42 -35
  24. package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-7IN2MKDS.mjs} +718 -595
  25. package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
  26. package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-A3CK6N5Z.mjs} +621 -72
  27. package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-AFLYLHDH.mjs} +48 -33
  28. package/dist/token-goat-chunk-AM5V6GSX.mjs +367 -0
  29. package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-APGZXSPS.mjs} +44 -148
  30. package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-ARDNEC2U.mjs} +11 -7
  31. package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
  32. package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
  33. package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -5
  34. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  35. package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-C63JQV5K.mjs} +49 -10
  36. package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
  37. package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
  38. package/dist/token-goat-chunk-CYCEYAEO.mjs +265 -0
  39. package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
  40. package/dist/token-goat-chunk-DZX2YDPT.mjs +15 -0
  41. package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
  42. package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
  43. package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
  44. package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
  45. package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
  46. package/dist/{token-goat-chunk-6Z5ULNE5.mjs → token-goat-chunk-FBNQNSJK.mjs} +2490 -4957
  47. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  48. package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
  49. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  50. package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-GFBSN7BD.mjs} +30 -398
  51. package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-GOLEOXZP.mjs} +780 -786
  52. package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
  53. package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
  54. package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
  55. package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
  56. package/dist/{token-goat-chunk-CBMY2FGI.mjs → token-goat-chunk-HOJLCGDP.mjs} +17113 -15554
  57. package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-HYBFA5X3.mjs} +120 -19
  58. package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
  59. package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
  60. package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
  61. package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
  62. package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
  63. package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-JDU3EXSU.mjs} +14 -10
  64. package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
  65. package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-JN4XMLSD.mjs} +7 -4
  66. package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
  67. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  68. package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
  69. package/dist/{token-goat-chunk-4RN64ZND.mjs → token-goat-chunk-KWPNJBDH.mjs} +28 -3
  70. package/dist/token-goat-chunk-LOBGHXPB.mjs +242 -0
  71. package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
  72. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  73. package/dist/{token-goat-chunk-YWSP6IU7.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
  74. package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
  75. package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
  76. package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
  77. package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
  78. package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
  79. package/dist/{token-goat-chunk-VWZKZPSR.mjs → token-goat-chunk-PU7V3FD6.mjs} +8752 -11098
  80. package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
  81. package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
  82. package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-QCLDAQTS.mjs} +33 -19
  83. package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
  84. package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-RC35RBUL.mjs} +7 -5
  85. package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-RHXKCZX3.mjs} +887 -507
  86. package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
  87. package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
  88. package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
  89. package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-SQSSNQPE.mjs} +2100 -1442
  90. package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-T4FK7VOV.mjs} +3 -3
  91. package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
  92. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  93. package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
  94. package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
  95. package/dist/token-goat-chunk-VES7EL7O.mjs +205 -0
  96. package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-VL3YIFHZ.mjs} +550 -49
  97. package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-VPBBTSJR.mjs} +362 -128
  98. package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
  99. package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -5
  100. package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
  101. package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
  102. package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
  103. package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-Y776AENC.mjs} +138 -33
  104. package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
  105. package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
  106. package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-Z44YO3QZ.mjs} +12 -6
  107. package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
  108. package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-ZCDTCVIS.mjs} +49 -30
  109. package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
  110. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  111. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  112. package/dist/{token-goat-chunk-SJEKA7Y2.mjs → token-goat-chunk-ZQSJMO2R.mjs} +381 -201
  113. package/dist/token-goat-hook-client.cjs +539 -0
  114. package/dist/token-goat-hook-client.mjs +26 -0
  115. package/dist/token-goat-hook.mjs +48 -28
  116. package/dist/token-goat.core.mjs +10 -45
  117. package/docs/C4_RUNTIME_ARCHITECTURE.md +3 -3
  118. package/docs/cli.md +82 -47
  119. package/docs/install.md +58 -23
  120. package/docs/security.md +7 -7
  121. package/package.json +17 -7
  122. package/scripts/verify-native-dist.mjs +386 -0
  123. package/dist/token-goat-chunk-4JJBFT7V.mjs +0 -20
  124. package/dist/token-goat-chunk-5NNYIUGV.mjs +0 -143
  125. package/dist/token-goat-chunk-6DQNNFJ6.mjs +0 -294
  126. package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
  127. package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
  128. package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
  129. package/dist/token-goat-chunk-GMOUBOX4.mjs +0 -386
  130. package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
  131. package/dist/token-goat-chunk-JXK2HQXS.mjs +0 -318
  132. package/dist/token-goat-chunk-L7SDVGBT.mjs +0 -430
  133. package/dist/token-goat-chunk-MMLMALWK.mjs +0 -1381
  134. package/dist/token-goat-chunk-MVSWBNMD.mjs +0 -1985
@@ -1,38 +1,38 @@
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
4
  commandPathIsTouchable,
5
+ docSectionHint,
6
+ grepLinesHint,
6
7
  leadWithCommand
7
- } from "./token-goat-chunk-IZXKVT4A.mjs";
8
+ } from "./token-goat-chunk-ATCPY7EQ.mjs";
8
9
  import {
9
10
  getFileLineRanges
10
- } from "./token-goat-chunk-GGLEE35R.mjs";
11
+ } from "./token-goat-chunk-C63JQV5K.mjs";
11
12
  import {
12
- hasBareBackgroundOrNewline,
13
- hasUnquotedOperator,
14
- isRedirectAmpersand
15
- } from "./token-goat-chunk-4RN64ZND.mjs";
16
- import {
17
- FALSY_ENV_VALUES,
18
13
  isUnderSystemTemp
19
- } from "./token-goat-chunk-CC2PYJM7.mjs";
14
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
15
+ import {
16
+ FALSY_ENV_VALUES
17
+ } from "./token-goat-chunk-IVE6U7KV.mjs";
20
18
  import {
21
- escapeRegExp,
22
- safeSlice
23
- } from "./token-goat-chunk-L45ZQRT7.mjs";
19
+ escapeRegExp
20
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
24
21
  import {
25
22
  TOOL_RESULTS_ID_CHARS,
23
+ hostPathOfIndexKey,
26
24
  normalizePath,
27
25
  resolveIndexPath
28
- } from "./token-goat-chunk-NMTKNYGF.mjs";
26
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
27
+ import {
28
+ hasBareBackgroundOrNewline,
29
+ hasUnquotedOperator,
30
+ isRedirectAmpersand
31
+ } from "./token-goat-chunk-KWPNJBDH.mjs";
29
32
  import {
30
33
  init_define_import_meta_env
31
34
  } from "./token-goat-chunk-A37V4PBF.mjs";
32
35
 
33
- // src/tool_error_class.ts
34
- init_define_import_meta_env();
35
-
36
36
  // src/bash_extractors.ts
37
37
  init_define_import_meta_env();
38
38
  import { statSync, openSync, readSync, closeSync } from "node:fs";
@@ -58,12 +58,15 @@ function surgicalHintFor(hintPath, isEnv, isConfig, isDoc, isXml, target, reason
58
58
  const outline = outlineCommand(hintPath);
59
59
  if (isXml) return leadWithCommand('token-goat xml-outline "' + hintPath + '"', 'to inspect structure, or `token-goat xml-query "' + hintPath + '" "<selector>"` to query specific nodes', reason);
60
60
  if (isEnv) return leadWithCommand('token-goat config-get "' + hintPath + '" ' + target.name, "to read a specific variable", reason);
61
+ if (isConfig && /\.properties$/i.test(hintPath)) {
62
+ return target.real ? leadWithCommand('token-goat config-get "' + hintPath + '" ' + target.name, "to read a specific value", reason) : grepLinesHint("<key>", hintPath, reason);
63
+ }
61
64
  if (isConfig) {
62
65
  const structured = structuredDataHint(hintPath, target.real ? target.name : null, reason);
63
66
  if (structured !== null) return structured;
64
67
  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);
65
68
  }
66
- if (isDoc) return leadWithCommand('token-goat section "' + hintPath + "::" + target.name + '"', "to read one section, or `" + outline + "` for every heading with line ranges", reason);
69
+ if (isDoc) return docSectionHint(hintPath, target.name, reason);
67
70
  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);
68
71
  }
69
72
  function surgicalHintForConfigDoc(filePath, isConfig, isDoc, isSql, isXml, target, reason = "") {
@@ -146,7 +149,7 @@ function classifyCatPath(filePath, cmd0) {
146
149
  return { filePath, ...flags, cmd0 };
147
150
  }
148
151
  function extractCatFile(cmd) {
149
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
152
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
150
153
  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);
151
154
  if (!m) return null;
152
155
  const cmd0 = m[1];
@@ -188,7 +191,7 @@ function extractPowerShellWrappedGetContent(cmd, event) {
188
191
  if (!w) return null;
189
192
  const inner = (w[1] ?? w[2] ?? "").trim();
190
193
  if (!inner) return null;
191
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
194
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
192
195
  const m = PS_GETCONTENT_INNER_RE.exec(inner);
193
196
  if (!m) return null;
194
197
  const filePath = m[1] ?? m[2] ?? m[3];
@@ -223,9 +226,12 @@ function extractPowerShellFileMethodRead(cmd, event) {
223
226
  }
224
227
  return { filePath, isDoc: flags.isDoc, isEnv: flags.isEnv, isConfig: flags.isConfig, isSql: flags.isSql, isXml: flags.isXml };
225
228
  }
229
+ function hasLineNumberFlag(cmd) {
230
+ return /(?:^|\s)-[a-mo-zA-Z]*n[a-zA-Z]*(?=\s|$)/.test(cmd) || /(?:^|\s)--line-number(?=\s|$)/.test(cmd);
231
+ }
226
232
  function extractRgSymbolSearch(cmd) {
227
233
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
228
- if (!/-n\b/.test(cmd)) return null;
234
+ if (!hasLineNumberFlag(cmd)) return null;
229
235
  const patternMatch = /["']([^"']+)["']/.exec(cmd);
230
236
  const pattern = patternMatch?.[1];
231
237
  if (!pattern) return null;
@@ -671,9 +677,6 @@ function extractNodeFileRead(cmd) {
671
677
  return null;
672
678
  }
673
679
  function extractTailFile(cmd) {
674
- if (/-f\b/.test(cmd)) return null;
675
- if (/-c\b/.test(cmd)) return null;
676
- if (/-n\s*\+/.test(cmd)) return null;
677
680
  const direct = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
678
681
  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;
679
682
  if (direct === null && piped === null) return null;
@@ -694,7 +697,7 @@ function extractGetContentTail(cmd) {
694
697
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
695
698
  if (!getnMatch) return null;
696
699
  const afterCmd = cmd.slice(getnMatch[0].length).replace(/-Path\s+/i, "");
697
- const beforeTail = afterCmd.split(/-Tail/i)[0]?.trim() ?? "";
700
+ const beforeTail = afterCmd.split(/(?:^|\s)-Tail\b/i)[0]?.trim() ?? "";
698
701
  const afterTail = afterCmd.split(/-Tail\s+\d+/i)[1]?.trim() ?? "";
699
702
  const filePath = (beforeTail || afterTail).replace(/^["']|["']$/g, "");
700
703
  if (!filePath) return null;
@@ -716,17 +719,16 @@ function extractGetContentSelectFirst(cmd) {
716
719
  return { filePath, isDoc, isConfig, isSql, isXml, n };
717
720
  }
718
721
  function extractGetContentHead(cmd) {
719
- const headMatch = /-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
722
+ const headMatch = /(?:^|\s)-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
720
723
  if (!headMatch) return null;
721
724
  const n = parseInt(headMatch[1], 10);
722
725
  if (n <= 10) return null;
723
726
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
724
727
  if (!getnMatch) return null;
725
- const afterCmd = cmd.slice(getnMatch[0].length).replace(/-Path\s+/i, "");
726
- const beforeHead = afterCmd.split(/-(?:TotalCount|Head|First)/i)[0]?.trim() ?? "";
727
- const afterHead = afterCmd.split(/-(?:TotalCount|Head|First)\s+\d+/i)[1]?.trim() ?? "";
728
- const cleanedBefore = beforeHead.replace(/-(?:Encoding|Delimiter|Wait)\s+\S+/gi, "").replace(/-[a-zA-Z]+/g, "").trim();
729
- const cleanedAfter = afterHead.replace(/-(?:Encoding|Delimiter|Wait)\s+\S+/gi, "").replace(/-[a-zA-Z]+/g, "").trim();
728
+ const afterCmd = cmd.slice(getnMatch[0].length).replace(/(?:^|\s)-Path\s+/i, " ");
729
+ const [beforeHead = "", afterHead = ""] = afterCmd.split(/(?:^|\s)-(?:TotalCount|Head|First)\s+\d+/i, 2);
730
+ const cleanedBefore = beforeHead.replace(/(?:^|\s)-(?:Encoding|Delimiter|Wait)\s+\S+/gi, " ").replace(/(?:^|\s)-[a-zA-Z]+(?=\s|$)/g, " ").trim();
731
+ const cleanedAfter = afterHead.replace(/(?:^|\s)-(?:Encoding|Delimiter|Wait)\s+\S+/gi, " ").replace(/(?:^|\s)-[a-zA-Z]+(?=\s|$)/g, " ").trim();
730
732
  const filePath = (cleanedBefore || cleanedAfter).replace(/^["']|["']$/g, "");
731
733
  if (!filePath) return null;
732
734
  if (isTempPath(filePath)) return null;
@@ -738,7 +740,7 @@ var JSONL_TRANSCRIPT_HEAD_RE = /^\{\s*"(?:(?:parentUuid|isSidechain)"\s*:|type"\
738
740
  function taskOutputIsJsonlTranscript(outPath) {
739
741
  let fd = null;
740
742
  try {
741
- fd = openSync(normalizePath(outPath), "r");
743
+ fd = openSync(hostPathOfIndexKey(normalizePath(outPath)), "r");
742
744
  const buf = Buffer.alloc(64);
743
745
  const read = readSync(fd, buf, 0, buf.length, 0);
744
746
  return JSONL_TRANSCRIPT_HEAD_RE.test(buf.subarray(0, read).toString("utf-8").trim());
@@ -754,7 +756,7 @@ function taskOutputIsJsonlTranscript(outPath) {
754
756
  }
755
757
  }
756
758
  function extractTasksOutput(cmd) {
757
- const taskOutputRe = /[/\\]tasks[/\\]([a-z0-9]+)\.output$/;
759
+ const taskOutputRe = /(?:^|[/\\])tasks[/\\]([a-z0-9]+)\.output$/;
758
760
  const catM = /^cat(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
759
761
  if (catM) {
760
762
  const fp = catM[1] ?? catM[2] ?? catM[3];
@@ -763,7 +765,7 @@ function extractTasksOutput(cmd) {
763
765
  if (m) return { id: m[1], path: fp };
764
766
  }
765
767
  }
766
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
768
+ {
767
769
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
768
770
  if (tailM) {
769
771
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -797,7 +799,7 @@ function extractToolResultsFile(cmd) {
797
799
  if (m) return { path: fp };
798
800
  }
799
801
  }
800
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
802
+ {
801
803
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
802
804
  if (tailM) {
803
805
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -832,7 +834,7 @@ function extractFindCommand(cmd) {
832
834
  }
833
835
  function extractMarkdownHeadingGrep(cmd) {
834
836
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
835
- if (!/-n\b/.test(cmd)) return null;
837
+ if (!hasLineNumberFlag(cmd)) return null;
836
838
  const hasHeadingPattern = /["']?\^#{1,6}["']?/.test(cmd) || /["']?\^#\+["']?/.test(cmd) || /["']?\^#\\+["']?/.test(cmd);
837
839
  if (!hasHeadingPattern) return null;
838
840
  const fileMatch = /(?:^|\s)(?:"([^"]+\.(?:md|markdown))"|'([^']+\.(?:md|markdown))'|([^\s"'|<>]+\.(?:md|markdown)))\s*(?:\||$)/.exec(cmd);
@@ -968,6 +970,9 @@ function commandOptsOutOfCompression(cmd) {
968
970
  }
969
971
  return false;
970
972
  }
973
+ function compressionOptedOut(rawCmd) {
974
+ return process.env["TOKEN_GOAT_BASH_COMPRESS"] === "0" || commandOptsOutOfCompression(rawCmd);
975
+ }
971
976
  var CURL_VALUE_FLAGS = /* @__PURE__ */ new Set([
972
977
  "-H",
973
978
  "--header",
@@ -1215,118 +1220,13 @@ function extractTerminalXmlParsing(cmd) {
1215
1220
  return null;
1216
1221
  }
1217
1222
 
1218
- // src/tool_error_class.ts
1219
- var UNKNOWN_REASON = "unclassified";
1220
- var DENIAL_KIND_REASONS = {
1221
- "permission-rule": "hook_deny",
1222
- // 73 in the census: the user declined an approval prompt.
1223
- "user-rejected": "user_rejected",
1224
- // 1 in the census; kept because it is an enumerated harness value, not a text guess.
1225
- "automode-blocked": "auto_mode_blocked"
1226
- };
1227
- var TG_DENY_RE = /\[tg\]|token-goat/;
1228
- var CONTENT_DELIVERED_REASON = "tg_content_delivered";
1229
- function tgDenyReason(text) {
1230
- return DELIVERS_CONTENT_RE.test(text) ? CONTENT_DELIVERED_REASON : "tg_deny";
1231
- }
1232
- var HOOK_DENY_TEXT_RE = /^PreToolUse:\S+ hook error: /;
1233
- 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/;
1234
- var SEARCH_COMMAND_RE = /^(?:grep|egrep|fgrep|rg|findstr)\b/;
1235
- function runsCommand(command, head) {
1236
- return splitShellSegments(command).some((segment) => head.test(stripLeadingAssignments(segment)));
1237
- }
1238
- var EXPECTED_PATTERNS = [
1239
- // 176: the Bash tool's own timeout, reported as SIGTERM's 143 plus this line.
1240
- { reason: "command_timeout", tools: ["Bash"], re: /^Exit code \d+\s+Command timed out after / },
1241
- // 289: exit 1 with no output from a search command, which is how grep and rg report zero hits.
1242
- { reason: "search_no_match", tools: ["Bash"], re: /^Exit code 1\s*$/, command: SEARCH_COMMAND_RE },
1243
- // 252: a test, build, lint or typecheck run reporting failures, which is the tool doing its job.
1244
- { reason: "test_or_build_failed", tools: ["Bash"], re: /^Exit code \d+/, command: TEST_OR_BUILD_COMMAND_RE },
1245
- // 302: an unbalanced quote or bracket in the command itself.
1246
- { reason: "shell_syntax_error", tools: ["Bash"], re: /unexpected EOF while looking for matching|syntax error near unexpected token/ },
1247
- // 29: a binary missing from PATH.
1248
- { reason: "command_not_found", tools: ["Bash"], re: /command not found/ },
1249
- // 272: the harness refusing a bare or leading `sleep` and pointing at Monitor instead.
1250
- { reason: "sleep_blocked", tools: ["Bash"], re: /^Blocked: (?:sleep \d+ followed by|standalone sleep)/ },
1251
- // 114: old_string absent from the file.
1252
- { reason: "edit_string_not_found", tools: ["Edit", "MultiEdit"], re: /^String to replace not found in file/ },
1253
- // 37: old_string present more than once with replace_all false.
1254
- { reason: "edit_multiple_matches", tools: ["Edit", "MultiEdit"], re: /^Found \d+ matches of the string to replace/ },
1255
- // 37: the harness's read-before-write guard.
1256
- { reason: "file_not_read_yet", tools: ["Edit", "MultiEdit", "Write"], re: /^File has not been read yet/ },
1257
- // 16: the file changed on disk after the last read.
1258
- { reason: "file_modified_since_read", tools: ["Edit", "MultiEdit", "Write"], re: /^File has been modified since read/ },
1259
- // 643 (578 Bash, 53 Read, 11 Grep, 1 Edit): a path that does not exist, in each tool's own wording.
1260
- { reason: "path_not_found", re: /No such file or directory|^File does not exist\.|^Path does not exist:/ },
1261
- // 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.
1262
- { 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 },
1263
- // 14: a Read over the harness's size ceiling.
1264
- { reason: "file_too_large", tools: ["Read"], re: /^File content \([^)]*\) exceeds maximum allowed/ },
1265
- // 85: arguments the tool's schema rejected before it ran.
1266
- { reason: "input_validation", re: /^InputValidationError/ },
1267
- // 68: a StructuredOutput call that did not match the requested schema.
1268
- { reason: "schema_mismatch", tools: ["StructuredOutput"], re: /^Output does not match required schema/ },
1269
- // 35: the harness's concurrent-subagent ceiling.
1270
- { reason: "subagent_limit", tools: ["Agent", "Task"], re: /^Concurrent subagent limit reached/ },
1271
- // 37: a tool disabled for this session or a misspelled tool name.
1272
- { reason: "tool_unavailable", re: /^Error: No such tool available/ }
1273
- ];
1274
- var EXPECTED_REASONS = [
1275
- "interrupted",
1276
- "tg_deny",
1277
- CONTENT_DELIVERED_REASON,
1278
- ...new Set(Object.values(DENIAL_KIND_REASONS)),
1279
- ...EXPECTED_PATTERNS.map((p) => p.reason)
1280
- ];
1281
- var TOOL_USE_ERROR_OPEN = "<tool_use_error>";
1282
- var TOOL_USE_ERROR_CLOSE = "</tool_use_error>";
1283
- function unwrapToolError(errorText) {
1284
- let text = errorText.trim();
1285
- if (text.startsWith(TOOL_USE_ERROR_OPEN)) text = text.slice(TOOL_USE_ERROR_OPEN.length);
1286
- if (text.endsWith(TOOL_USE_ERROR_CLOSE)) text = text.slice(0, text.length - TOOL_USE_ERROR_CLOSE.length);
1287
- return text.trim();
1288
- }
1289
- function expected(reason) {
1290
- return { kind: "expected", reason };
1291
- }
1292
- function classifyToolError(tool, errorText, flags = {}) {
1293
- if (flags.isInterrupt === true) return expected("interrupted");
1294
- const text = unwrapToolError(errorText);
1295
- const denial = flags.denialKind;
1296
- if (denial !== void 0 && denial !== "") {
1297
- const reason = DENIAL_KIND_REASONS[denial] ?? "hook_deny";
1298
- return expected(reason === "hook_deny" && TG_DENY_RE.test(text) ? tgDenyReason(text) : reason);
1299
- }
1300
- if (HOOK_DENY_TEXT_RE.test(text)) return expected(TG_DENY_RE.test(text) ? tgDenyReason(text) : "hook_deny");
1301
- for (const p of EXPECTED_PATTERNS) {
1302
- if (p.tools !== void 0 && (tool === void 0 || !p.tools.includes(tool))) continue;
1303
- if (!p.re.test(text)) continue;
1304
- if (p.command !== void 0 && (flags.command === void 0 || !runsCommand(flags.command, p.command))) continue;
1305
- return expected(p.reason);
1306
- }
1307
- return { kind: "unknown", reason: UNKNOWN_REASON };
1308
- }
1309
- var ERROR_PREFIX_CHARS = 60;
1310
- var EXIT_CODE_HEADER_RE = /^Exit code (\d+)\s*/;
1311
- function errorPrefix(errorText) {
1312
- let text = unwrapToolError(errorText);
1313
- let lead = "";
1314
- const exit = EXIT_CODE_HEADER_RE.exec(text);
1315
- if (exit !== null) {
1316
- lead = `exit ${exit[1] ?? ""}: `;
1317
- text = text.slice(exit[0].length);
1318
- }
1319
- const line = text.split("\n").find((l) => l.trim() !== "") ?? "";
1320
- const masked = line.trim().replace(/\b[A-Za-z]:[\\/]\S*|~?\/[\w.~-]+(?:\/[\w.~-]*)+/g, "<path>").replace(/'[^'\n]*'|"[^"\n]*"|`[^`\n]*`/g, "<q>").replace(/\d+/g, "N");
1321
- return safeSlice(`${lead}${masked === "" ? "(empty)" : masked}`, ERROR_PREFIX_CHARS);
1322
- }
1323
-
1324
1223
  export {
1325
1224
  sqlTableHint,
1326
1225
  surgicalHintFor,
1327
1226
  surgicalHintForConfigDoc,
1328
1227
  splitShellSegments,
1329
1228
  extractCatSourceFile,
1229
+ classifyCatPath,
1330
1230
  extractCatFile,
1331
1231
  extractCatFilesMulti,
1332
1232
  extractPowerShellWrappedGetContent,
@@ -1358,7 +1258,7 @@ export {
1358
1258
  extractRgStructuralSearch,
1359
1259
  extractGrepPipeChain,
1360
1260
  stripLeadingAssignments,
1361
- commandOptsOutOfCompression,
1261
+ compressionOptedOut,
1362
1262
  extractCurlUrl,
1363
1263
  extractTgSurgicalRead,
1364
1264
  isCurlGetCommand,
@@ -1371,9 +1271,5 @@ export {
1371
1271
  buildRecallHint,
1372
1272
  shellQuoteSingle,
1373
1273
  isCompressibleSingleCommand,
1374
- extractTerminalXmlParsing,
1375
- CONTENT_DELIVERED_REASON,
1376
- SEARCH_COMMAND_RE,
1377
- classifyToolError,
1378
- errorPrefix
1274
+ extractTerminalXmlParsing
1379
1275
  };
@@ -1,18 +1,22 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
- recordStat,
5
- redactSecrets
6
- } from "./token-goat-chunk-MVSWBNMD.mjs";
4
+ recordStat
5
+ } from "./token-goat-chunk-3Z5S4KGM.mjs";
6
+ import {
7
+ redactSerializedJson
8
+ } from "./token-goat-chunk-4FVIAHSI.mjs";
7
9
  import {
8
10
  loadConfig
9
- } from "./token-goat-chunk-CC2PYJM7.mjs";
11
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
10
12
  import {
11
13
  atomicWriteText,
12
14
  ensureDirSync,
13
- sanitizeIdForFilename,
15
+ sanitizeIdForFilename
16
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
17
+ import {
14
18
  tokenGoatHome
15
- } from "./token-goat-chunk-L45ZQRT7.mjs";
19
+ } from "./token-goat-chunk-VES7EL7O.mjs";
16
20
  import {
17
21
  init_define_import_meta_env
18
22
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -79,7 +83,7 @@ function storeBlob(subdir, id, value, opts = {}) {
79
83
  }
80
84
  let json;
81
85
  try {
82
- const result = redactSecrets(rawJson);
86
+ const result = redactSerializedJson(rawJson);
83
87
  json = result.text;
84
88
  if (result.count > 0) recordStat("secret_redacted", 0, result.count, void 0, subdir);
85
89
  } catch {
@@ -0,0 +1,134 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ VSCODE_TOOL_NAME_KEY,
5
+ getCwd
6
+ } from "./token-goat-chunk-VPBBTSJR.mjs";
7
+ import {
8
+ escapesOntoNetworkThroughLinks,
9
+ foldPathForContainment,
10
+ isInsideRoot
11
+ } from "./token-goat-chunk-AM5V6GSX.mjs";
12
+ import {
13
+ isUncOrDevicePath,
14
+ resolveIndexPath,
15
+ wslMountOfIndexKey
16
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
17
+ import {
18
+ init_define_import_meta_env
19
+ } from "./token-goat-chunk-A37V4PBF.mjs";
20
+
21
+ // src/hint_suggestion_guard.ts
22
+ init_define_import_meta_env();
23
+ function looksLikeSuggestion(slice) {
24
+ return slice.includes('"');
25
+ }
26
+ var SAFE_OUTSIDE_QUOTES = /^[A-Za-z0-9 \t_./=:,@+-]*$/;
27
+ var CONTROL_OR_BIDI = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\u061C\u200B-\u200D\u2028\u2029\uFE00-\uFE0F]|[\u{E0000}-\u{E007F}]/u;
28
+ function suggestionIsUnsafe(slice) {
29
+ if (slice.includes("$") || slice.includes("\n") || slice.includes("\r") || slice.includes("`")) return true;
30
+ if (CONTROL_OR_BIDI.test(slice)) return true;
31
+ const regions = slice.split('"');
32
+ if (regions.length % 2 === 0) return true;
33
+ for (let i = 2; i < regions.length; i += 2) {
34
+ if (!SAFE_OUTSIDE_QUOTES.test(regions[i] ?? "")) return true;
35
+ }
36
+ return false;
37
+ }
38
+ var OMITTED = "token-goat (command omitted: the path contains shell metacharacters)";
39
+ function stripUnsafeSuggestions(text) {
40
+ if (!text.includes("token-goat ")) return text;
41
+ let out = "";
42
+ let at = 0;
43
+ for (; ; ) {
44
+ const start = text.indexOf("token-goat ", at);
45
+ if (start === -1) return out + text.slice(at);
46
+ const lineBreak = text.slice(start).search(/[\r\n]/);
47
+ const line = lineBreak === -1 ? text.slice(start) : text.slice(start, start + lineBreak);
48
+ const firstTick = line.indexOf("`");
49
+ const narrow = firstTick === -1 ? line : line.slice(0, firstTick);
50
+ out += text.slice(at, start);
51
+ if (!looksLikeSuggestion(narrow) || !suggestionIsUnsafe(narrow)) {
52
+ out += narrow;
53
+ at = start + narrow.length;
54
+ continue;
55
+ }
56
+ const lastTick = line.lastIndexOf("`");
57
+ const wide = lastTick === -1 ? line : line.slice(0, lastTick);
58
+ out += OMITTED;
59
+ at = start + wide.length;
60
+ }
61
+ }
62
+ function leadWithCommand(command, purpose = "", reason = "") {
63
+ const tail = reason.trim();
64
+ return "Run `" + command + "`" + (purpose === "" ? "" : " " + purpose) + "." + (tail === "" ? "" : (tail.includes("`") ? "\n" : " ") + tail);
65
+ }
66
+ function docNavigation(filePath) {
67
+ const ext = /\.(txt|rst)$/i.exec(filePath)?.[1]?.toLowerCase();
68
+ return { section: ext !== "txt", outline: ext === void 0 };
69
+ }
70
+ function grepLinesHint(pattern, shownPath, reason = "") {
71
+ return leadWithCommand('token-goat grep "' + pattern + '" "' + shownPath + '" -C 3', "to read the matching lines", reason);
72
+ }
73
+ function docSectionHint(shownPath, heading, reason = "") {
74
+ const nav = docNavigation(shownPath);
75
+ if (!nav.section) return grepLinesHint("<pattern>", shownPath, reason);
76
+ return leadWithCommand('token-goat section "' + shownPath + "::" + heading + '"', "to read one section" + (nav.outline ? ', or `token-goat outline "' + shownPath + '"` for every heading with line ranges' : ""), reason);
77
+ }
78
+
79
+ // src/vscode_path_gate.ts
80
+ init_define_import_meta_env();
81
+ import * as path from "node:path";
82
+ function resolvesToUncPath(target, cwd) {
83
+ try {
84
+ return isUncOrDevicePath(path.resolve(cwd ?? process.cwd(), target));
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+ function vscodePathAllowed(filePath, workspace) {
90
+ if (isUncOrDevicePath(filePath)) return false;
91
+ if (workspace === void 0 || isUncOrDevicePath(workspace)) return false;
92
+ const resolvedRoot = path.resolve(workspace);
93
+ const resolvedTarget = path.resolve(workspace, filePath);
94
+ const root = foldPathForContainment(resolvedRoot.replace(/\\/g, "/"));
95
+ const target = foldPathForContainment(resolvedTarget.replace(/\\/g, "/"));
96
+ if (target !== root && !target.startsWith(root.endsWith("/") ? root : root + "/")) return false;
97
+ return isInsideRoot(resolvedTarget, resolvedRoot);
98
+ }
99
+ function isVscodeEvent(event) {
100
+ return event.raw["_tg_harness"] === "vscode" || event.raw[VSCODE_TOOL_NAME_KEY] !== void 0;
101
+ }
102
+ function preToolPathDeclined(event, target) {
103
+ if (target === void 0) return false;
104
+ const cwd = getCwd(event);
105
+ if (spellingDeclined(event, target, cwd)) return true;
106
+ const mount = secondSpellingAtMount(target, cwd);
107
+ return mount !== null && spellingDeclined(event, mount, cwd);
108
+ }
109
+ function spellingDeclined(event, target, cwd) {
110
+ if (isUncOrDevicePath(target) || resolvesToUncPath(target, cwd)) return true;
111
+ if (isVscodeEvent(event)) return !vscodePathAllowed(target, cwd);
112
+ return escapesOntoNetworkThroughLinks(target, cwd);
113
+ }
114
+ function secondSpellingAtMount(target, cwd) {
115
+ if (process.platform === "win32") return null;
116
+ const base = cwd ?? "/";
117
+ const mount = wslMountOfIndexKey(resolveIndexPath(target, base));
118
+ return mount !== null && mount !== path.resolve(base, target) ? mount : null;
119
+ }
120
+ function commandPathIsTouchable(filePath, event) {
121
+ if (event === void 0) return !escapesOntoNetworkThroughLinks(filePath);
122
+ return !preToolPathDeclined(event, filePath);
123
+ }
124
+
125
+ export {
126
+ stripUnsafeSuggestions,
127
+ leadWithCommand,
128
+ docNavigation,
129
+ grepLinesHint,
130
+ docSectionHint,
131
+ vscodePathAllowed,
132
+ preToolPathDeclined,
133
+ commandPathIsTouchable
134
+ };