token-goat 2.9.29 → 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 (131) hide show
  1. package/README.md +34 -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-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
  11. package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
  12. package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
  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-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
  19. package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -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-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
  24. package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
  25. package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
  26. package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
  27. package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
  28. package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
  29. package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
  30. package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -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-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
  34. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  35. package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
  36. package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
  37. package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
  38. package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
  39. package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
  40. package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
  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-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
  47. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  48. package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
  49. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  50. package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
  51. package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
  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-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
  57. package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
  58. package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
  59. package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
  60. package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
  61. package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
  62. package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
  63. package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
  64. package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
  65. package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
  66. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  67. package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
  68. package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
  69. package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
  70. package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
  71. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  72. package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
  73. package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
  74. package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
  75. package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
  76. package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
  77. package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
  78. package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
  79. package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
  80. package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
  81. package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
  82. package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
  83. package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
  84. package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
  85. package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
  86. package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
  87. package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
  88. package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
  89. package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
  90. package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
  91. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  92. package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
  93. package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
  94. package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
  95. package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
  96. package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
  97. package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
  98. package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
  99. package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
  100. package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
  101. package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
  102. package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
  103. package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
  104. package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
  105. package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
  106. package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
  107. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  108. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  109. package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
  110. package/dist/token-goat-hook-client.cjs +87 -23
  111. package/dist/token-goat-hook-client.mjs +3 -3
  112. package/dist/token-goat-hook.mjs +46 -30
  113. package/dist/token-goat.core.mjs +6 -6
  114. package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
  115. package/docs/cli.md +80 -46
  116. package/docs/install.md +47 -14
  117. package/docs/security.md +7 -7
  118. package/package.json +17 -7
  119. package/scripts/verify-native-dist.mjs +386 -0
  120. package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
  121. package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
  122. package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
  123. package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
  124. package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
  125. package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
  126. package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
  127. package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
  128. package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
  129. package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
  130. package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
  131. package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
@@ -1,39 +1,42 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ sanitizeFtsQuery
5
+ } from "./token-goat-chunk-HYBFA5X3.mjs";
3
6
  import {
4
7
  DEFAULT_MAX_AGE_MS,
5
8
  blobPath,
6
9
  isBlobStale,
7
10
  loadBlob,
8
11
  storeBlob
9
- } from "./token-goat-chunk-D4ETHJD6.mjs";
12
+ } from "./token-goat-chunk-ARDNEC2U.mjs";
10
13
  import {
11
- hasUnquotedOperator
12
- } from "./token-goat-chunk-2WOUYWLM.mjs";
14
+ getDb
15
+ } from "./token-goat-chunk-VL3YIFHZ.mjs";
13
16
  import {
14
17
  redactSecrets
15
- } from "./token-goat-chunk-CIQ2FTY3.mjs";
16
- import {
17
- sanitizeFtsQuery
18
- } from "./token-goat-chunk-435UQTKD.mjs";
19
- import {
20
- getDb
21
- } from "./token-goat-chunk-7CPMDFGB.mjs";
18
+ } from "./token-goat-chunk-4FVIAHSI.mjs";
22
19
  import {
23
20
  shortFingerprint
24
- } from "./token-goat-chunk-TGOXNAHW.mjs";
21
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
25
22
  import {
26
23
  registerReset
27
24
  } from "./token-goat-chunk-YZAAZU2S.mjs";
28
25
  import {
29
26
  runGit
30
- } from "./token-goat-chunk-XYWPOSCN.mjs";
27
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
31
28
  import {
32
29
  normalizePath
33
- } from "./token-goat-chunk-NMTKNYGF.mjs";
30
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
34
31
  import {
35
32
  globalDbPath
36
- } from "./token-goat-chunk-MELOKFDJ.mjs";
33
+ } from "./token-goat-chunk-VES7EL7O.mjs";
34
+ import {
35
+ hasUnquotedOperator
36
+ } from "./token-goat-chunk-KWPNJBDH.mjs";
37
+ import {
38
+ stripAnsiEscapes
39
+ } from "./token-goat-chunk-HAVAOB3S.mjs";
37
40
  import {
38
41
  init_define_import_meta_env
39
42
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -140,7 +143,7 @@ var BUILD_COMMAND_PATTERNS = [
140
143
  /^\s*(?:gradle|\.\/gradlew|gradlew)\b/i,
141
144
  // Python / pip
142
145
  /^\s*pip\s+(install|freeze)\b/i,
143
- // npm audit / npm outdated — read-only reporting commands with no side effects, safe to cache/recall. Each resolves a `lockfile`-scoped fingerprint via bash_output_cache.ts's isNpmAuditCommand/isNpmOutdatedCommand, but that fingerprinting never actually ran outside their own unit tests until this entry, since neither subcommand was recognized by isBuildCommand (the generic cache-reachability gate in hooks_bash.ts). `npm install`/`npm ci`/`npm list`/`npm ls` are deliberately left out — see the negative-case test in lang_patterns.test.ts.
146
+ // npm audit / npm outdated — read-only reporting commands with no side effects, safe to cache/recall. Each resolves a `lockfile`-scoped fingerprint via bash_output_cache.ts's isNpmAuditCommand/isNpmOutdatedCommand, but that fingerprinting never actually ran outside their own unit tests until this entry, since neither subcommand was recognized by isBuildCommand (the generic cache-reachability gate in hooks_bash.ts and hooks_bash_post.ts). `npm install`/`npm ci`/`npm list`/`npm ls` are deliberately left out — see the negative-case test in lang_patterns.test.ts.
144
147
  /^\s*npm\s+(audit|outdated)\b/i,
145
148
  // Poetry
146
149
  /^\s*poetry\s+(install|update)\b/i,
@@ -225,6 +228,8 @@ var TEST_RUNNER_COMMAND_PATTERNS = [
225
228
  /^go test(?:\s|$)/i,
226
229
  // Rust / Cargo
227
230
  /^cargo test(?:\s|$)/i,
231
+ // dotnet test
232
+ /^\s*dotnet\s+test(?:\s|$)/i,
228
233
  // npm test / npm run test
229
234
  /^npm (?:test|run test)(?:\s|$)/i,
230
235
  // yarn test / yarn run test / pnpm test / pnpm run test
@@ -233,6 +238,20 @@ var TEST_RUNNER_COMMAND_PATTERNS = [
233
238
  function isTestRunnerCommand(cmd) {
234
239
  return TEST_RUNNER_COMMAND_PATTERNS.some((re) => re.test(cmd));
235
240
  }
241
+ var DEV_SERVER_COMMAND_PATTERNS = [
242
+ { pattern: /^(?:npx\s+)?next dev/, recallHint: '--tail 30 --grep "error|warn|ready|compiled"' },
243
+ { pattern: /^(?:npx\s+)?next build/, recallHint: '--grep "error|warn|Failed|\u2713"' },
244
+ // vite ends at whitespace or the end of the command, not at a word boundary, which a hyphen satisfies: vite-node is another tool, so it is neither recalled nor fingerprinted as a dev server.
245
+ { pattern: /^(?:npx\s+)?vite(?:\s|$)/, recallHint: '--tail 20 --grep "error|warn|ready"' },
246
+ // nuxt dev ends the same way: `nuxt devtools enable` is another nuxt command.
247
+ { pattern: /^(?:npx\s+)?nuxt dev(?:\s|$)/, recallHint: '--tail 30 --grep "error|warn|ready"' },
248
+ { pattern: /^(?:npx\s+)?remix dev/, recallHint: '--tail 20 --grep "error|warn|ready"' },
249
+ { pattern: /^(?:npx\s+)?astro dev/, recallHint: '--tail 20 --grep "error|warn|ready"' }
250
+ ];
251
+ function isDevServerCommand(cmd) {
252
+ const trimmed = cmd.trim();
253
+ return DEV_SERVER_COMMAND_PATTERNS.some(({ pattern }) => pattern.test(trimmed));
254
+ }
236
255
  var MONITORING_COMMAND_PATTERNS = [
237
256
  // GitHub CI
238
257
  { pattern: /^gh run (?:watch|view|list)/, recallHint: '--grep "fail|error|pass|\u2713|\u2717|conclusion"' },
@@ -242,16 +261,10 @@ var MONITORING_COMMAND_PATTERNS = [
242
261
  { pattern: /^gh pr list/, recallHint: '--grep "OPEN|DRAFT|MERGED|#"' },
243
262
  { pattern: /^gh issue view/, recallHint: '--grep "state|title|label|OPEN|CLOSED"' },
244
263
  { pattern: /^gh workflow (?:run|list|view)/, recallHint: '--grep "completed|failed|in_progress"' },
245
- // Dev servers (Next, Vite, Nuxt, Remix, Astro)
246
- { pattern: /^(?:npx\s+)?next dev/, recallHint: '--tail 30 --grep "error|warn|ready|compiled"' },
247
- { pattern: /^(?:npx\s+)?next build/, recallHint: '--grep "error|warn|Failed|\u2713"' },
248
- { pattern: /^(?:npx\s+)?vite\b(?:\s+dev|\s+build|\s+preview)?/, recallHint: '--tail 20 --grep "error|warn|ready"' },
249
- { pattern: /^(?:npx\s+)?nuxt dev/, recallHint: '--tail 30 --grep "error|warn|ready"' },
250
- { pattern: /^(?:npx\s+)?remix dev/, recallHint: '--tail 20 --grep "error|warn|ready"' },
251
- { pattern: /^(?:npx\s+)?astro dev/, recallHint: '--tail 20 --grep "error|warn|ready"' },
252
- // Test watchers
253
- { pattern: /^(?:npx\s+)?vitest(?:\s+run|\s+watch)?/, recallHint: '--grep "FAIL|PASS|Error|\u2713|\u2717"' },
254
- { pattern: /^(?:npx\s+)?jest(?:\s+--watch)?/, recallHint: '--grep "FAIL|PASS|Error|Tests:"' },
264
+ ...DEV_SERVER_COMMAND_PATTERNS,
265
+ // Test watchers. jest and vitest must be followed by whitespace or the end of the command, as in TEST_RUNNER_COMMAND_PATTERNS, not merely by a word boundary: a cached run goes stale only through the git fingerprint isTestRunnerCommand grants, and a longer name (jest-codemods, vitest-preview) is another tool that predicate rejects.
266
+ { pattern: /^(?:npx\s+)?vitest(?:\s|$)/, recallHint: '--grep "FAIL|PASS|Error|\u2713|\u2717"' },
267
+ { pattern: /^(?:npx\s+)?jest(?:\s|$)/, recallHint: '--grep "FAIL|PASS|Error|Tests:"' },
255
268
  { pattern: /^pytest(?:\s|$)/, recallHint: '--grep "FAILED|PASSED|ERROR|passed|failed"' },
256
269
  { pattern: /^(?:cargo\s+test|cargo\s+watch)/, recallHint: '--grep "FAILED|ok|error\\["' },
257
270
  { pattern: /^go test/, recallHint: '--grep "FAIL|ok|---"' },
@@ -268,7 +281,8 @@ var MONITORING_COMMAND_PATTERNS = [
268
281
  { pattern: /^(?:npx\s+)?prettier(?:\s|$)/, recallHint: '--grep "unchanged|reformatted|error"' },
269
282
  { pattern: /^npx\s+tsc(?:\s|$)/, recallHint: '--grep "error TS|Cannot find|Type "' },
270
283
  { pattern: /^ruff(?:\s|$)/, recallHint: '--grep "error|warning|Found"' },
271
- { pattern: /^(?:cargo\s+)?clippy/, recallHint: '--grep "error\\[|warning\\["' },
284
+ // Ends the same way: clippy-driver is clippy's rustc wrapper, run without cargo, so isBuildCommand gives it no fingerprint to go stale by.
285
+ { pattern: /^(?:cargo\s+)?clippy(?:\s|$)/, recallHint: '--grep "error\\[|warning\\["' },
272
286
  // git diff (full diff output — can be very large; excludes --stat which is small)
273
287
  { pattern: /^git diff(?!\s+--stat)(?:\s+HEAD)?(?:\s|$)/, recallHint: '--grep "@@|\\+\\+\\+|---|diff --git"' },
274
288
  { pattern: /^git diff\s+--cached(?!\s+--stat)/, recallHint: '--grep "@@|\\+\\+\\+|---|diff --git"' },
@@ -347,7 +361,8 @@ function indexRecallEntry(cacheType, id, label, content, storedAt) {
347
361
  label = excluded.label,
348
362
  content = excluded.content,
349
363
  stored_at = excluded.stored_at`
350
- ).run({ cacheType, id, label, content, storedAt });
364
+ // Stripped so a query spanning a colour boundary matches the text a reader sees; the cached blob itself stays raw.
365
+ ).run({ cacheType, id, label: stripAnsiEscapes(label), content: stripAnsiEscapes(content), storedAt });
351
366
  } catch {
352
367
  }
353
368
  pruneCacheRecallRows();
@@ -373,7 +388,7 @@ function hasFtsTable() {
373
388
  return _ftsAvailable;
374
389
  }
375
390
  function buildSnippet(content, query, maxLen = 160) {
376
- const flat = content.replace(/\s+/g, " ").trim();
391
+ const flat = stripAnsiEscapes(content).replace(/\s+/g, " ").trim();
377
392
  const tokens = query.split(/\s+/).filter(Boolean);
378
393
  let idx = -1;
379
394
  const lowerFlat = flat.toLowerCase();
@@ -491,7 +506,6 @@ var COMMAND_PATTERNS = {
491
506
  envProbe: /^\s*(?:node\s+(?:-v|--version)|npm\s+(?:-v|--version)|python3?\s+(?:(?:-V)\b|--?version)|git\s+--version|uv\s+--version|go\s+version|rustc\s+--version|cargo\s+--version|java\s+--version|ruby\s+--version|gem\s+--version|php\s+--version|which\b|where\b)/i,
492
507
  npx: /^(?!.*\b(?:install|add|remove|uninstall|i|rm|update|upgrade|set|get|publish|link|ci|audit|shrinkwrap|dedupe|prune|rebuild)\b)\s*npx\s+(?:--?yes\s+)?/i,
493
508
  gitPush: /^\s*git\s+push\b/i,
494
- testRunner: /^\s*(?:npx\s+)?(?:pytest|vitest|jest|go\s+test)\b/i,
495
509
  lintCommand: /^\s*(?:(?:npx\s+)?eslint|(?:uv\s+run\s+)?ruff)\b/i,
496
510
  npmRunScript: /^\s*npm\s+run(?:-script)?\b/i,
497
511
  catCommand: /^\s*cat\b/i
@@ -517,7 +531,6 @@ var isNpmInstallCommand = (cmd) => isCommandOfType(cmd, "npmInstall");
517
531
  var isNpmAuditCommand = (cmd) => isCommandOfType(cmd, "npmAudit");
518
532
  var isNpmOutdatedCommand = (cmd) => isCommandOfType(cmd, "npmOutdated");
519
533
  var isGitPushCommand = (cmd) => isCommandOfType(cmd, "gitPush");
520
- var isTestRunnerCommand2 = (cmd) => isCommandOfType(cmd, "testRunner");
521
534
  var isLintCommand = (cmd) => isCommandOfType(cmd, "lintCommand");
522
535
  var isNpmRunScriptCommand = (cmd) => isCommandOfType(cmd, "npmRunScript");
523
536
  var isCatCommand = (cmd) => isCommandOfType(cmd, "catCommand");
@@ -663,7 +676,7 @@ function bashOutputIdSync(command, output, cwd = null) {
663
676
  }
664
677
  function computeBashFingerprints(command, cwd) {
665
678
  const fingerprints = {};
666
- if (cwd && (isGitMutableCommand(command) || isGitPushCommand(command) || isTestRunnerCommand2(command) || isLintCommand(command) || isBuildCommand(command) || isNpmRunScriptCommand(command))) {
679
+ if (cwd && (isGitMutableCommand(command) || isGitPushCommand(command) || isTestRunnerCommand(command) || isLintCommand(command) || isBuildCommand(command) || isDevServerCommand(command) || isNpmRunScriptCommand(command))) {
667
680
  const fp = gitStateFingerprintSync(cwd);
668
681
  if (fp) fingerprints.git = fp;
669
682
  }
@@ -7,7 +7,7 @@ import {
7
7
  isUncOrDevicePath,
8
8
  lowercaseDriveLetter,
9
9
  normalizeDarwinSystemAlias
10
- } from "./token-goat-chunk-NMTKNYGF.mjs";
10
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
11
11
  import {
12
12
  init_define_import_meta_env
13
13
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -209,6 +209,7 @@ function sameDirectory(a, b, platform = process.platform) {
209
209
 
210
210
  // src/process_util.ts
211
211
  init_define_import_meta_env();
212
+ import { spawnSync } from "node:child_process";
212
213
  import { existsSync, realpathSync as realpathSync2, statSync } from "node:fs";
213
214
  import * as path2 from "node:path";
214
215
  function sleepSync(ms) {
@@ -283,9 +284,16 @@ function quoteShellPath(value) {
283
284
  if (process.platform === "win32") return `"${value}"`;
284
285
  return `"${value.replace(/[\\$`"]/g, "\\$&")}"`;
285
286
  }
287
+ function quotePosixShellWord(value) {
288
+ return `'${value.replace(/'/g, "'\\''")}'`;
289
+ }
286
290
  function quotePowershellPath(value) {
287
291
  return `'${value.replace(/'/g, "''")}'`;
288
292
  }
293
+ var POWERSHELL_EXIT_SUFFIX = "; if (Get-Variable LASTEXITCODE -ErrorAction Ignore) { exit (Get-Variable LASTEXITCODE -ValueOnly) }; exit 1";
294
+ function powershellHookLine(call) {
295
+ return `& ${call}${POWERSHELL_EXIT_SUFFIX}`;
296
+ }
289
297
  function resolveOnPath(label) {
290
298
  if (path2.isAbsolute(label)) return existsSync(label) ? label : null;
291
299
  if (label.includes("/") || label.includes("\\")) return null;
@@ -317,6 +325,12 @@ function resolveOnPath(label) {
317
325
  }
318
326
  return null;
319
327
  }
328
+ function spawnResolvedSync(resolved, args, options) {
329
+ if (!isWindows() || !/\.(?:cmd|bat)$/i.test(resolved)) return spawnSync(resolved, args, options);
330
+ const comspec = path2.join(process.env["SystemRoot"] ?? process.env["windir"] ?? "C:\\Windows", "System32", "cmd.exe");
331
+ const line = [resolved, ...args].map(windowsCmdQuoteArg).join(" ");
332
+ return spawnSync(existsSync(comspec) ? comspec : "cmd.exe", ["/d", "/s", "/c", `"${line}"`], { ...options, windowsVerbatimArguments: true });
333
+ }
320
334
  function installEpipeGuard(streams) {
321
335
  const targets = (streams ?? [process.stdout, process.stderr]).filter((s) => s !== void 0);
322
336
  for (const stream of targets) {
@@ -343,9 +357,11 @@ export {
343
357
  isInsideRoot,
344
358
  sleepSync,
345
359
  isWindows,
346
- windowsCmdQuoteArg,
347
360
  quoteShellPath,
361
+ quotePosixShellWord,
348
362
  quotePowershellPath,
363
+ powershellHookLine,
349
364
  resolveOnPath,
365
+ spawnResolvedSync,
350
366
  installEpipeGuard
351
367
  };
@@ -1,40 +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-E5TK5DNO.mjs";
8
+ } from "./token-goat-chunk-ATCPY7EQ.mjs";
8
9
  import {
9
10
  getFileLineRanges
10
- } from "./token-goat-chunk-TDUT2CL6.mjs";
11
- import {
12
- hasBareBackgroundOrNewline,
13
- hasUnquotedOperator,
14
- isRedirectAmpersand
15
- } from "./token-goat-chunk-2WOUYWLM.mjs";
11
+ } from "./token-goat-chunk-C63JQV5K.mjs";
16
12
  import {
17
13
  isUnderSystemTemp
18
- } from "./token-goat-chunk-TGOXNAHW.mjs";
14
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
19
15
  import {
20
16
  FALSY_ENV_VALUES
21
17
  } from "./token-goat-chunk-IVE6U7KV.mjs";
22
18
  import {
23
- escapeRegExp,
24
- safeSlice
25
- } from "./token-goat-chunk-XYWPOSCN.mjs";
19
+ escapeRegExp
20
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
26
21
  import {
27
22
  TOOL_RESULTS_ID_CHARS,
23
+ hostPathOfIndexKey,
28
24
  normalizePath,
29
25
  resolveIndexPath
30
- } 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";
31
32
  import {
32
33
  init_define_import_meta_env
33
34
  } from "./token-goat-chunk-A37V4PBF.mjs";
34
35
 
35
- // src/tool_error_class.ts
36
- init_define_import_meta_env();
37
-
38
36
  // src/bash_extractors.ts
39
37
  init_define_import_meta_env();
40
38
  import { statSync, openSync, readSync, closeSync } from "node:fs";
@@ -60,12 +58,15 @@ function surgicalHintFor(hintPath, isEnv, isConfig, isDoc, isXml, target, reason
60
58
  const outline = outlineCommand(hintPath);
61
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);
62
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
+ }
63
64
  if (isConfig) {
64
65
  const structured = structuredDataHint(hintPath, target.real ? target.name : null, reason);
65
66
  if (structured !== null) return structured;
66
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);
67
68
  }
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
+ if (isDoc) return docSectionHint(hintPath, target.name, reason);
69
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);
70
71
  }
71
72
  function surgicalHintForConfigDoc(filePath, isConfig, isDoc, isSql, isXml, target, reason = "") {
@@ -148,7 +149,7 @@ function classifyCatPath(filePath, cmd0) {
148
149
  return { filePath, ...flags, cmd0 };
149
150
  }
150
151
  function extractCatFile(cmd) {
151
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
152
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(cmd)) return null;
152
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);
153
154
  if (!m) return null;
154
155
  const cmd0 = m[1];
@@ -190,7 +191,7 @@ function extractPowerShellWrappedGetContent(cmd, event) {
190
191
  if (!w) return null;
191
192
  const inner = (w[1] ?? w[2] ?? "").trim();
192
193
  if (!inner) return null;
193
- if (/-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
194
+ if (/(?:^|\s)-(?:TotalCount|Head|First|Tail)\b/i.test(inner)) return null;
194
195
  const m = PS_GETCONTENT_INNER_RE.exec(inner);
195
196
  if (!m) return null;
196
197
  const filePath = m[1] ?? m[2] ?? m[3];
@@ -225,9 +226,12 @@ function extractPowerShellFileMethodRead(cmd, event) {
225
226
  }
226
227
  return { filePath, isDoc: flags.isDoc, isEnv: flags.isEnv, isConfig: flags.isConfig, isSql: flags.isSql, isXml: flags.isXml };
227
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
+ }
228
232
  function extractRgSymbolSearch(cmd) {
229
233
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
230
- if (!/-n\b/.test(cmd)) return null;
234
+ if (!hasLineNumberFlag(cmd)) return null;
231
235
  const patternMatch = /["']([^"']+)["']/.exec(cmd);
232
236
  const pattern = patternMatch?.[1];
233
237
  if (!pattern) return null;
@@ -673,9 +677,6 @@ function extractNodeFileRead(cmd) {
673
677
  return null;
674
678
  }
675
679
  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
680
  const direct = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
680
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;
681
682
  if (direct === null && piped === null) return null;
@@ -696,7 +697,7 @@ function extractGetContentTail(cmd) {
696
697
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
697
698
  if (!getnMatch) return null;
698
699
  const afterCmd = cmd.slice(getnMatch[0].length).replace(/-Path\s+/i, "");
699
- const beforeTail = afterCmd.split(/-Tail/i)[0]?.trim() ?? "";
700
+ const beforeTail = afterCmd.split(/(?:^|\s)-Tail\b/i)[0]?.trim() ?? "";
700
701
  const afterTail = afterCmd.split(/-Tail\s+\d+/i)[1]?.trim() ?? "";
701
702
  const filePath = (beforeTail || afterTail).replace(/^["']|["']$/g, "");
702
703
  if (!filePath) return null;
@@ -718,17 +719,16 @@ function extractGetContentSelectFirst(cmd) {
718
719
  return { filePath, isDoc, isConfig, isSql, isXml, n };
719
720
  }
720
721
  function extractGetContentHead(cmd) {
721
- const headMatch = /-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
722
+ const headMatch = /(?:^|\s)-(?:TotalCount|Head|First)\s+(\d+)/i.exec(cmd);
722
723
  if (!headMatch) return null;
723
724
  const n = parseInt(headMatch[1], 10);
724
725
  if (n <= 10) return null;
725
726
  const getnMatch = /^(Get-Content|gc)\s+/i.exec(cmd);
726
727
  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();
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();
732
732
  const filePath = (cleanedBefore || cleanedAfter).replace(/^["']|["']$/g, "");
733
733
  if (!filePath) return null;
734
734
  if (isTempPath(filePath)) return null;
@@ -740,7 +740,7 @@ var JSONL_TRANSCRIPT_HEAD_RE = /^\{\s*"(?:(?:parentUuid|isSidechain)"\s*:|type"\
740
740
  function taskOutputIsJsonlTranscript(outPath) {
741
741
  let fd = null;
742
742
  try {
743
- fd = openSync(normalizePath(outPath), "r");
743
+ fd = openSync(hostPathOfIndexKey(normalizePath(outPath)), "r");
744
744
  const buf = Buffer.alloc(64);
745
745
  const read = readSync(fd, buf, 0, buf.length, 0);
746
746
  return JSONL_TRANSCRIPT_HEAD_RE.test(buf.subarray(0, read).toString("utf-8").trim());
@@ -765,7 +765,7 @@ function extractTasksOutput(cmd) {
765
765
  if (m) return { id: m[1], path: fp };
766
766
  }
767
767
  }
768
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
768
+ {
769
769
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
770
770
  if (tailM) {
771
771
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -799,7 +799,7 @@ function extractToolResultsFile(cmd) {
799
799
  if (m) return { path: fp };
800
800
  }
801
801
  }
802
- if (!/-f\b/.test(cmd) && !/-n\s*\+/.test(cmd)) {
802
+ {
803
803
  const tailM = /^tail(?:\s+-n\s+(\d+)|\s+-(\d+))?\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(cmd);
804
804
  if (tailM) {
805
805
  const fp = tailM[3] ?? tailM[4] ?? tailM[5];
@@ -834,7 +834,7 @@ function extractFindCommand(cmd) {
834
834
  }
835
835
  function extractMarkdownHeadingGrep(cmd) {
836
836
  if (!/^(?:rg|grep)\s+/.test(cmd)) return null;
837
- if (!/-n\b/.test(cmd)) return null;
837
+ if (!hasLineNumberFlag(cmd)) return null;
838
838
  const hasHeadingPattern = /["']?\^#{1,6}["']?/.test(cmd) || /["']?\^#\+["']?/.test(cmd) || /["']?\^#\\+["']?/.test(cmd);
839
839
  if (!hasHeadingPattern) return null;
840
840
  const fileMatch = /(?:^|\s)(?:"([^"]+\.(?:md|markdown))"|'([^']+\.(?:md|markdown))'|([^\s"'|<>]+\.(?:md|markdown)))\s*(?:\||$)/.exec(cmd);
@@ -970,6 +970,9 @@ function commandOptsOutOfCompression(cmd) {
970
970
  }
971
971
  return false;
972
972
  }
973
+ function compressionOptedOut(rawCmd) {
974
+ return process.env["TOKEN_GOAT_BASH_COMPRESS"] === "0" || commandOptsOutOfCompression(rawCmd);
975
+ }
973
976
  var CURL_VALUE_FLAGS = /* @__PURE__ */ new Set([
974
977
  "-H",
975
978
  "--header",
@@ -1217,112 +1220,6 @@ function extractTerminalXmlParsing(cmd) {
1217
1220
  return null;
1218
1221
  }
1219
1222
 
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
1223
  export {
1327
1224
  sqlTableHint,
1328
1225
  surgicalHintFor,
@@ -1361,7 +1258,7 @@ export {
1361
1258
  extractRgStructuralSearch,
1362
1259
  extractGrepPipeChain,
1363
1260
  stripLeadingAssignments,
1364
- commandOptsOutOfCompression,
1261
+ compressionOptedOut,
1365
1262
  extractCurlUrl,
1366
1263
  extractTgSurgicalRead,
1367
1264
  isCurlGetCommand,
@@ -1374,9 +1271,5 @@ export {
1374
1271
  buildRecallHint,
1375
1272
  shellQuoteSingle,
1376
1273
  isCompressibleSingleCommand,
1377
- extractTerminalXmlParsing,
1378
- CONTENT_DELIVERED_REASON,
1379
- SEARCH_COMMAND_RE,
1380
- classifyToolError,
1381
- errorPrefix
1274
+ extractTerminalXmlParsing
1382
1275
  };
@@ -1,20 +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-CIQ2FTY3.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-TGOXNAHW.mjs";
11
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
10
12
  import {
11
13
  atomicWriteText,
12
14
  ensureDirSync,
13
15
  sanitizeIdForFilename
14
- } from "./token-goat-chunk-XYWPOSCN.mjs";
16
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
15
17
  import {
16
18
  tokenGoatHome
17
- } from "./token-goat-chunk-MELOKFDJ.mjs";
19
+ } from "./token-goat-chunk-VES7EL7O.mjs";
18
20
  import {
19
21
  init_define_import_meta_env
20
22
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -81,7 +83,7 @@ function storeBlob(subdir, id, value, opts = {}) {
81
83
  }
82
84
  let json;
83
85
  try {
84
- const result = redactSecrets(rawJson);
86
+ const result = redactSerializedJson(rawJson);
85
87
  json = result.text;
86
88
  if (result.count > 0) recordStat("secret_redacted", 0, result.count, void 0, subdir);
87
89
  } catch {