token-goat 2.9.26 → 2.9.28

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 (57) hide show
  1. package/README.md +28 -88
  2. package/SECURITY.md +14 -0
  3. package/dist/{token-goat-chunk-CQHY4SL7.mjs → token-goat-chunk-4JJBFT7V.mjs} +3 -3
  4. package/dist/token-goat-chunk-4JMWPWCS.mjs +96 -0
  5. package/dist/token-goat-chunk-4RN64ZND.mjs +954 -0
  6. package/dist/{token-goat-chunk-5M3NRJD2.mjs → token-goat-chunk-4STDIGYC.mjs} +2 -2
  7. package/dist/{token-goat-chunk-BH4ZVRB2.mjs → token-goat-chunk-5NNYIUGV.mjs} +2 -2
  8. package/dist/{token-goat-chunk-LHUP4DXZ.mjs → token-goat-chunk-66LODAUT.mjs} +1 -1
  9. package/dist/{token-goat-chunk-M6CVNHTW.mjs → token-goat-chunk-6CCQDAYY.mjs} +69 -566
  10. package/dist/{token-goat-chunk-62IHOU6L.mjs → token-goat-chunk-6DQNNFJ6.mjs} +5 -3
  11. package/dist/{token-goat-chunk-H2CPLEMP.mjs → token-goat-chunk-6SGLIPQB.mjs} +40 -20
  12. package/dist/{token-goat-chunk-MBDJR6HU.mjs → token-goat-chunk-6Z5ULNE5.mjs} +3570 -3970
  13. package/dist/token-goat-chunk-7MAFDRVR.mjs +47 -0
  14. package/dist/{token-goat-chunk-POOI26O6.mjs → token-goat-chunk-7R2XYKC5.mjs} +6 -5
  15. package/dist/{token-goat-chunk-E6B2UFDF.mjs → token-goat-chunk-BCN2YQC6.mjs} +10 -8
  16. package/dist/token-goat-chunk-BJBRGPBX.mjs +244 -0
  17. package/dist/{token-goat-chunk-TG5ZPD6B.mjs → token-goat-chunk-CBMY2FGI.mjs} +479 -544
  18. package/dist/{token-goat-chunk-LRIZ7K3F.mjs → token-goat-chunk-CC2PYJM7.mjs} +2 -1
  19. package/dist/{token-goat-chunk-7EPYB34H.mjs → token-goat-chunk-D5ICEPSB.mjs} +14 -14
  20. package/dist/token-goat-chunk-D7GHQKQD.mjs +30 -0
  21. package/dist/{token-goat-chunk-JALB3KWJ.mjs → token-goat-chunk-EL7M26WP.mjs} +7623 -8462
  22. package/dist/{token-goat-chunk-ZZT6PVB3.mjs → token-goat-chunk-F7QZRIWM.mjs} +69 -20
  23. package/dist/{token-goat-chunk-FLEYOCAS.mjs → token-goat-chunk-FSTWAOW6.mjs} +3 -3
  24. package/dist/token-goat-chunk-GGLEE35R.mjs +564 -0
  25. package/dist/{token-goat-chunk-IKZLSRII.mjs → token-goat-chunk-HUDC5GS5.mjs} +2 -2
  26. package/dist/{token-goat-chunk-43JFN26X.mjs → token-goat-chunk-HXNAC4ZF.mjs} +22 -964
  27. package/dist/token-goat-chunk-I7CB3X4K.mjs +1379 -0
  28. package/dist/{token-goat-chunk-GKZ2US5B.mjs → token-goat-chunk-IFORDBGC.mjs} +32 -27
  29. package/dist/{token-goat-chunk-CXBOFPF4.mjs → token-goat-chunk-IHKZ3QNA.mjs} +26 -15
  30. package/dist/token-goat-chunk-IZXKVT4A.mjs +711 -0
  31. package/dist/{token-goat-chunk-PAV6NNY7.mjs → token-goat-chunk-JXK2HQXS.mjs} +22 -8
  32. package/dist/{token-goat-chunk-6E2IDLHF.mjs → token-goat-chunk-L45ZQRT7.mjs} +1 -1
  33. package/dist/{token-goat-chunk-MDV5VWF4.mjs → token-goat-chunk-L7SDVGBT.mjs} +196 -14
  34. package/dist/token-goat-chunk-LEG3JNJ6.mjs +139 -0
  35. package/dist/{token-goat-chunk-7SXPJOSZ.mjs → token-goat-chunk-M56BWPBN.mjs} +1 -1
  36. package/dist/{token-goat-chunk-G6EYO5CD.mjs → token-goat-chunk-MAMQPC43.mjs} +2 -87
  37. package/dist/{token-goat-chunk-VVROQBQJ.mjs → token-goat-chunk-MMLMALWK.mjs} +5 -3
  38. package/dist/{token-goat-chunk-D2X7XN5M.mjs → token-goat-chunk-MVSWBNMD.mjs} +7 -231
  39. package/dist/{token-goat-chunk-C2PG4K5D.mjs → token-goat-chunk-NILVK7XM.mjs} +4 -4
  40. package/dist/{token-goat-chunk-BAWKGODL.mjs → token-goat-chunk-Q4S3UQGO.mjs} +1 -1
  41. package/dist/{token-goat-chunk-MWID3YOY.mjs → token-goat-chunk-QM76S6YS.mjs} +3 -3
  42. package/dist/{token-goat-chunk-4GEDH2WU.mjs → token-goat-chunk-RJH64KQH.mjs} +81 -70
  43. package/dist/{token-goat-chunk-STYRLQIW.mjs → token-goat-chunk-RSS3TLXU.mjs} +2 -2
  44. package/dist/{token-goat-chunk-5BQ7W7D7.mjs → token-goat-chunk-SJEKA7Y2.mjs} +21 -16
  45. package/dist/{token-goat-chunk-RIB6XY2V.mjs → token-goat-chunk-UBUKHVYW.mjs} +1 -1
  46. package/dist/{token-goat-chunk-7Y6GWTII.mjs → token-goat-chunk-VE27HPIF.mjs} +14 -10
  47. package/dist/{token-goat-chunk-RH27ZSPF.mjs → token-goat-chunk-VWZKZPSR.mjs} +100 -23
  48. package/dist/{token-goat-chunk-L45IWWMC.mjs → token-goat-chunk-XI2VFAV6.mjs} +6 -6
  49. package/dist/{token-goat-chunk-WNBSCSAI.mjs → token-goat-chunk-XKY4VKJ4.mjs} +1 -1
  50. package/dist/{token-goat-chunk-L43RKNHA.mjs → token-goat-chunk-YWSP6IU7.mjs} +1 -1
  51. package/dist/token-goat-hook.mjs +23 -17
  52. package/dist/token-goat.core.mjs +32 -27
  53. package/docs/cli.md +32 -21
  54. package/docs/install.md +2 -0
  55. package/package.json +1 -1
  56. package/dist/token-goat-chunk-ADMR3QVF.mjs +0 -41
  57. package/dist/token-goat-chunk-MZTO4FXH.mjs +0 -26
@@ -2,11 +2,11 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  getDb
5
- } from "./token-goat-chunk-7SXPJOSZ.mjs";
5
+ } from "./token-goat-chunk-M56BWPBN.mjs";
6
6
  import {
7
7
  getHarnessName,
8
8
  loadConfig
9
- } from "./token-goat-chunk-LRIZ7K3F.mjs";
9
+ } from "./token-goat-chunk-CC2PYJM7.mjs";
10
10
  import {
11
11
  registerReset
12
12
  } from "./token-goat-chunk-EEIDFMEM.mjs";
@@ -15,15 +15,12 @@ import {
15
15
  } from "./token-goat-chunk-OSUFN2FV.mjs";
16
16
  import {
17
17
  VERSION,
18
- atomicWriteText,
19
18
  countNoun,
20
19
  dataDir,
21
20
  dataDirForHome,
22
21
  ensureDirSync,
23
- extractErrorMessage,
24
- sanitizeIdForFilename,
25
- tokenGoatHome
26
- } from "./token-goat-chunk-6E2IDLHF.mjs";
22
+ extractErrorMessage
23
+ } from "./token-goat-chunk-L45ZQRT7.mjs";
27
24
  import {
28
25
  displaySafeText
29
26
  } from "./token-goat-chunk-NMTKNYGF.mjs";
@@ -1007,6 +1004,8 @@ var KIND_TO_SOURCE = {
1007
1004
  reconcile_note_failed: SOURCE_OTHER,
1008
1005
  // Measurement of what a compaction produced (hooks_compact.ts postCompactHandler): summary size and how many manifest paths survived into it. SOURCE_OTHER and always recorded at (0, 0) -- the summary was written whether or not token-goat was watching, so there is no counterfactual in which those bytes were saved. Filing it anywhere with a savings total would credit token-goat for the whole summary, which is the accounting mistake this registry exists to prevent.
1009
1006
  compact_summary: SOURCE_OTHER,
1007
+ // One row per failed tool call the post_tool_use_failure hook sees (hooks_tool_failure.ts), with its tool_error_class.ts verdict in `detail` so failure rates by reason accumulate going forward. A measurement at (0, 0): a failure saves nothing.
1008
+ tool_failure: SOURCE_OTHER,
1010
1009
  // Envelope compaction of an oversized subagent report (hooks_agent_spawn.ts). SOURCE_CONTENT, not SOURCE_HINT: the handler's sibling session_hint entry is advisory (it only appends a recall pointer and genuinely saves nothing), whereas this kind records a real rewrite with real bytes removed, so filing it under the advisory bucket would understate the compaction and repeat the zero-savings desync this registry keeps getting bitten by.
1011
1010
  agent_report_compact: SOURCE_CONTENT,
1012
1011
  // Decline counterpart to agent_report_compact: the fence-collapse net-benefit gate ran and found at least one over-long fence, but declined to rewrite because net savings did not clear the notice cost. Always recorded at (0, 0) -- see the recordStat call site -- so it never contributes to any savings total; it exists purely to make gate hit-rate and near-misses visible instead of the decline being invisible.
@@ -1955,220 +1954,6 @@ function redactSecrets(text, config = loadConfig()) {
1955
1954
  return { text: out, count };
1956
1955
  }
1957
1956
 
1958
- // src/disk_cache.ts
1959
- init_define_import_meta_env();
1960
- import * as fs2 from "node:fs";
1961
- import * as path2 from "node:path";
1962
- var DEFAULT_MAX_COUNT = 200;
1963
- var DEFAULT_MAX_AGE_MS = 24 * 3600 * 1e3;
1964
- function sanitizeId(id) {
1965
- return sanitizeIdForFilename(id, 64);
1966
- }
1967
- function blobDir(subdir) {
1968
- return path2.join(tokenGoatHome(), subdir);
1969
- }
1970
- function blobPath(subdir, id) {
1971
- const safe = sanitizeId(id);
1972
- if (!safe) return null;
1973
- const dir = blobDir(subdir);
1974
- const candidate = path2.join(dir, `${safe}.json`);
1975
- try {
1976
- const rel = path2.relative(dir, candidate);
1977
- if (rel.startsWith("..")) return null;
1978
- } catch {
1979
- return null;
1980
- }
1981
- return candidate;
1982
- }
1983
- function isBlobStale(subdir, id) {
1984
- const p = blobPath(subdir, id);
1985
- if (p === null) return false;
1986
- try {
1987
- const stat = fs2.statSync(p);
1988
- return Date.now() - stat.mtimeMs > DEFAULT_MAX_AGE_MS;
1989
- } catch {
1990
- return false;
1991
- }
1992
- }
1993
- function subdirCacheDefaults(subdir) {
1994
- try {
1995
- if (subdir === "bash_outputs") {
1996
- const bc = loadConfig().bash_compress;
1997
- return { maxCount: bc.cache_max_file_count, maxBytes: bc.cache_max_bytes, maxBytesPerItem: bc.cache_max_bytes_per_output };
1998
- }
1999
- if (subdir === "web_outputs") {
2000
- const wf = loadConfig().webfetch;
2001
- return { maxCount: wf.max_file_count, maxBytes: wf.max_bytes, maxBytesPerItem: Number.POSITIVE_INFINITY };
2002
- }
2003
- } catch {
2004
- }
2005
- return { maxCount: DEFAULT_MAX_COUNT, maxBytes: Number.POSITIVE_INFINITY, maxBytesPerItem: Number.POSITIVE_INFINITY };
2006
- }
2007
- function storeBlob(subdir, id, value, opts = {}) {
2008
- const p = blobPath(subdir, id);
2009
- if (!p) return false;
2010
- const defaults = subdirCacheDefaults(subdir);
2011
- const maxBytesPerItem = opts.maxBytesPerItem ?? defaults.maxBytesPerItem;
2012
- let rawJson;
2013
- try {
2014
- rawJson = JSON.stringify(value);
2015
- } catch {
2016
- return false;
2017
- }
2018
- let json;
2019
- try {
2020
- const result = redactSecrets(rawJson);
2021
- json = result.text;
2022
- if (result.count > 0) recordStat("secret_redacted", 0, result.count, void 0, subdir);
2023
- } catch {
2024
- return false;
2025
- }
2026
- if (Number.isFinite(maxBytesPerItem) && Buffer.byteLength(json, "utf-8") > maxBytesPerItem) return false;
2027
- try {
2028
- const dir = path2.dirname(p);
2029
- if (!fs2.existsSync(dir)) ensureDirSync(dir);
2030
- atomicWriteText(p, json);
2031
- } catch {
2032
- return false;
2033
- }
2034
- pruneBlobs(
2035
- subdir,
2036
- opts.maxCount ?? defaults.maxCount,
2037
- opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS,
2038
- opts.maxBytes ?? defaults.maxBytes,
2039
- p
2040
- );
2041
- return true;
2042
- }
2043
- function loadBlob(subdir, id) {
2044
- const p = blobPath(subdir, id);
2045
- if (!p) return null;
2046
- try {
2047
- if (!fs2.existsSync(p)) return null;
2048
- return JSON.parse(fs2.readFileSync(p, "utf8"));
2049
- } catch {
2050
- return null;
2051
- }
2052
- }
2053
- function listBlobs(subdir) {
2054
- const dir = blobDir(subdir);
2055
- const out = [];
2056
- try {
2057
- if (!fs2.existsSync(dir)) return out;
2058
- for (const file of fs2.readdirSync(dir)) {
2059
- if (!file.endsWith(".json")) continue;
2060
- const id = file.slice(0, -5);
2061
- let mtime = 0;
2062
- try {
2063
- mtime = fs2.statSync(path2.join(dir, file)).mtimeMs;
2064
- } catch {
2065
- }
2066
- const value = loadBlob(subdir, id);
2067
- if (value !== null) out.push({ id, mtime, value });
2068
- }
2069
- } catch {
2070
- return out;
2071
- }
2072
- return out;
2073
- }
2074
- function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX_AGE_MS, maxBytes = Number.POSITIVE_INFINITY, protectedPath) {
2075
- return pruneBlobDir(blobDir(subdir), maxCount, maxAgeMs, maxBytes, protectedPath);
2076
- }
2077
- function pruneBlobDir(dir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX_AGE_MS, maxBytes = Number.POSITIVE_INFINITY, protectedPath) {
2078
- let removed = 0;
2079
- try {
2080
- if (!fs2.existsSync(dir)) return 0;
2081
- const cutoff = Date.now() - maxAgeMs;
2082
- let kept = [];
2083
- let protectedEntry;
2084
- for (const file of fs2.readdirSync(dir)) {
2085
- const full = path2.join(dir, file);
2086
- let stat;
2087
- try {
2088
- stat = fs2.statSync(full);
2089
- } catch {
2090
- continue;
2091
- }
2092
- if (!stat.isFile()) continue;
2093
- if (protectedPath !== void 0 && full === protectedPath) {
2094
- protectedEntry = [full, stat.mtimeMs, stat.size];
2095
- continue;
2096
- }
2097
- if (stat.mtimeMs < cutoff) {
2098
- try {
2099
- fs2.unlinkSync(full);
2100
- removed++;
2101
- } catch {
2102
- continue;
2103
- }
2104
- } else if (file.endsWith(".json")) {
2105
- kept.push([full, stat.mtimeMs, stat.size]);
2106
- }
2107
- }
2108
- const countBudget = protectedEntry ? Math.max(0, maxCount - 1) : maxCount;
2109
- if (kept.length > countBudget) {
2110
- kept.sort((a, b) => a[1] - b[1]);
2111
- const excess = kept.slice(0, kept.length - countBudget);
2112
- kept = kept.slice(kept.length - countBudget);
2113
- for (const [full] of excess) {
2114
- try {
2115
- fs2.unlinkSync(full);
2116
- removed++;
2117
- } catch {
2118
- continue;
2119
- }
2120
- }
2121
- }
2122
- if (Number.isFinite(maxBytes)) {
2123
- kept.sort((a, b) => a[1] - b[1]);
2124
- let total = kept.reduce((sum, [, , size]) => sum + size, 0) + (protectedEntry ? protectedEntry[2] : 0);
2125
- while (total > maxBytes && kept.length > 0) {
2126
- const oldest = kept.shift();
2127
- if (!oldest) break;
2128
- const [full, , size] = oldest;
2129
- try {
2130
- fs2.unlinkSync(full);
2131
- removed++;
2132
- total -= size;
2133
- } catch {
2134
- break;
2135
- }
2136
- }
2137
- }
2138
- } catch {
2139
- return removed;
2140
- }
2141
- return removed;
2142
- }
2143
- var SWEEPABLE_CACHE_SUBDIRS = [
2144
- { subdir: "bash_outputs", countCapped: true },
2145
- { subdir: "web_outputs", countCapped: true },
2146
- { subdir: "mcp_outputs", countCapped: true },
2147
- { subdir: "sessions", countCapped: false }
2148
- ];
2149
- function sweepCacheRoots(extraRoots = []) {
2150
- let removed = 0;
2151
- const roots = [tokenGoatHome(), ...extraRoots];
2152
- const seen = /* @__PURE__ */ new Set();
2153
- for (const root of roots) {
2154
- if (!root || seen.has(root)) continue;
2155
- seen.add(root);
2156
- for (const { subdir, countCapped } of SWEEPABLE_CACHE_SUBDIRS) {
2157
- try {
2158
- const defaults = subdirCacheDefaults(subdir);
2159
- removed += pruneBlobDir(
2160
- path2.join(root, subdir),
2161
- countCapped ? defaults.maxCount : Number.POSITIVE_INFINITY,
2162
- DEFAULT_MAX_AGE_MS,
2163
- countCapped ? defaults.maxBytes : Number.POSITIVE_INFINITY
2164
- );
2165
- } catch {
2166
- }
2167
- }
2168
- }
2169
- return removed;
2170
- }
2171
-
2172
1957
  export {
2173
1958
  BYTES_PER_TOKEN,
2174
1959
  guardDivisor,
@@ -2196,14 +1981,5 @@ export {
2196
1981
  countRedactionPlaceholders,
2197
1982
  compileCustomPatterns,
2198
1983
  hasPreciseSecret,
2199
- redactSecrets,
2200
- DEFAULT_MAX_COUNT,
2201
- DEFAULT_MAX_AGE_MS,
2202
- blobPath,
2203
- isBlobStale,
2204
- storeBlob,
2205
- loadBlob,
2206
- listBlobs,
2207
- pruneBlobs,
2208
- sweepCacheRoots
1984
+ redactSecrets
2209
1985
  };
@@ -10,13 +10,13 @@ import {
10
10
  querySheet,
11
11
  rangeSheet,
12
12
  xlsxColumns
13
- } from "./token-goat-chunk-STYRLQIW.mjs";
14
- import "./token-goat-chunk-L43RKNHA.mjs";
13
+ } from "./token-goat-chunk-RSS3TLXU.mjs";
14
+ import "./token-goat-chunk-YWSP6IU7.mjs";
15
15
  import "./token-goat-chunk-3BTK54F3.mjs";
16
- import "./token-goat-chunk-RIB6XY2V.mjs";
16
+ import "./token-goat-chunk-UBUKHVYW.mjs";
17
17
  import "./token-goat-chunk-XTQAOTSO.mjs";
18
18
  import "./token-goat-chunk-AH6QILZM.mjs";
19
- import "./token-goat-chunk-6E2IDLHF.mjs";
19
+ import "./token-goat-chunk-L45ZQRT7.mjs";
20
20
  import "./token-goat-chunk-NMTKNYGF.mjs";
21
21
  import "./token-goat-chunk-Y4AFKTHK.mjs";
22
22
  import "./token-goat-chunk-GMOUBOX4.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  parseOoxmlPart,
13
13
  readOoxmlZip,
14
14
  sortNumberedParts
15
- } from "./token-goat-chunk-RIB6XY2V.mjs";
15
+ } from "./token-goat-chunk-UBUKHVYW.mjs";
16
16
  import {
17
17
  compileGuardedRegex
18
18
  } from "./token-goat-chunk-GMOUBOX4.mjs";
@@ -5,11 +5,11 @@ import {
5
5
  docxTables,
6
6
  docxText,
7
7
  formatDocxTables
8
- } from "./token-goat-chunk-WNBSCSAI.mjs";
9
- import "./token-goat-chunk-RIB6XY2V.mjs";
8
+ } from "./token-goat-chunk-XKY4VKJ4.mjs";
9
+ import "./token-goat-chunk-UBUKHVYW.mjs";
10
10
  import "./token-goat-chunk-XTQAOTSO.mjs";
11
11
  import "./token-goat-chunk-AH6QILZM.mjs";
12
- import "./token-goat-chunk-6E2IDLHF.mjs";
12
+ import "./token-goat-chunk-L45ZQRT7.mjs";
13
13
  import "./token-goat-chunk-NMTKNYGF.mjs";
14
14
  import "./token-goat-chunk-Y4AFKTHK.mjs";
15
15
  import "./token-goat-chunk-GMOUBOX4.mjs";
@@ -44,15 +44,15 @@ import {
44
44
  trimRepeatedPrefix,
45
45
  truncateMiddleSmart,
46
46
  truncateTableRows
47
- } from "./token-goat-chunk-43JFN26X.mjs";
47
+ } from "./token-goat-chunk-4RN64ZND.mjs";
48
48
  import {
49
49
  redactSecrets,
50
50
  savedTokensFromBytes,
51
51
  stripAnsiEscapes
52
- } from "./token-goat-chunk-D2X7XN5M.mjs";
52
+ } from "./token-goat-chunk-MVSWBNMD.mjs";
53
53
  import {
54
54
  loadConfig
55
- } from "./token-goat-chunk-LRIZ7K3F.mjs";
55
+ } from "./token-goat-chunk-CC2PYJM7.mjs";
56
56
  import {
57
57
  resolveIndexPath
58
58
  } from "./token-goat-chunk-NMTKNYGF.mjs";
@@ -281,11 +281,11 @@ ${body}`;
281
281
  }
282
282
  };
283
283
 
284
- // src/tool_filters/dispatch.ts
285
- init_define_import_meta_env();
286
-
287
284
  // src/tool_filters/generic.ts
288
285
  init_define_import_meta_env();
286
+ var PassthroughFilter = class extends ToolFilter {
287
+ name = "passthrough";
288
+ };
289
289
  var GenericFilter = class extends ToolFilter {
290
290
  name = "generic";
291
291
  compress(stdout, stderr, _exitCode, _argv) {
@@ -305,6 +305,9 @@ ${errPart}` : errPart;
305
305
  }
306
306
  };
307
307
 
308
+ // src/tool_filters/dispatch.ts
309
+ init_define_import_meta_env();
310
+
308
311
  // src/tool_filters/go_test.ts
309
312
  init_define_import_meta_env();
310
313
  var TEST_RUN_RE = /^=== (RUN|PAUSE|CONT|NAME)\s/;
@@ -717,6 +720,43 @@ function makeNodeTestRunnerFilter(cfg) {
717
720
  }
718
721
  }();
719
722
  }
723
+ function initCountedRules(rules) {
724
+ return rules.map(() => ({ count: 0, lastLine: void 0 }));
725
+ }
726
+ function countedRuleMatches(rule, line) {
727
+ return rule.res ? rule.res.some((r) => r.test(line)) : rule.re?.test(line) ?? false;
728
+ }
729
+ function applyCountedRules(rules, counts, line) {
730
+ for (let i = 0; i < rules.length; i++) {
731
+ if (countedRuleMatches(rules[i], line)) {
732
+ counts[i].count++;
733
+ if (rules[i].keepLast) counts[i].lastLine = line.trim();
734
+ return i;
735
+ }
736
+ }
737
+ return -1;
738
+ }
739
+ function assembleCountedOutput(rules, counts, kept) {
740
+ const out = [];
741
+ for (let i = 0; i < rules.length; i++) {
742
+ if (rules[i].position === "prepend" && counts[i].count > 0)
743
+ out.push(rules[i].note(counts[i].count, counts[i].lastLine));
744
+ }
745
+ out.push(...kept);
746
+ for (let i = 0; i < rules.length; i++) {
747
+ if (rules[i].position === "append" && counts[i].count > 0)
748
+ out.push(rules[i].note(counts[i].count, counts[i].lastLine));
749
+ }
750
+ return out;
751
+ }
752
+ function countedRuleNotes(rules, counts) {
753
+ const notes = [];
754
+ for (let i = 0; i < rules.length; i++) {
755
+ if (rules[i].position === "note" && counts[i].count > 0)
756
+ notes.push(rules[i].note(counts[i].count, counts[i].lastLine));
757
+ }
758
+ return notes;
759
+ }
720
760
  function makeAiCliFilter(cfg) {
721
761
  return new class extends ToolFilter {
722
762
  name = cfg.name;
@@ -732,7 +772,7 @@ function makeAiCliFilter(cfg) {
732
772
  const kept = [];
733
773
  let droppedNoise = 0;
734
774
  const rules = cfg.countedRules ?? [];
735
- const counts = rules.map(() => ({ count: 0, lastLine: void 0 }));
775
+ const counts = initCountedRules(rules);
736
776
  const klRules = cfg.keepLastRules ?? [];
737
777
  const klValues = klRules.map(() => void 0);
738
778
  for (const line of lines) {
@@ -753,18 +793,7 @@ function makeAiCliFilter(cfg) {
753
793
  }
754
794
  }
755
795
  if (dropped) continue;
756
- let counted = false;
757
- for (let i = 0; i < rules.length; i++) {
758
- const rule = rules[i];
759
- const matched = rule.res ? rule.res.some((r) => r.test(line)) : rule.re.test(line);
760
- if (matched) {
761
- counts[i].count++;
762
- if (rule.keepLast) counts[i].lastLine = line.trim();
763
- counted = true;
764
- break;
765
- }
766
- }
767
- if (counted) continue;
796
+ if (applyCountedRules(rules, counts, line) >= 0) continue;
768
797
  let kl = false;
769
798
  for (let i = 0; i < klRules.length; i++) {
770
799
  if (klRules[i].re.test(line)) {
@@ -776,24 +805,8 @@ function makeAiCliFilter(cfg) {
776
805
  if (kl) continue;
777
806
  kept.push(line);
778
807
  }
779
- const out = [];
780
- for (let i = 0; i < rules.length; i++) {
781
- if (rules[i].position === "prepend" && counts[i].count > 0) {
782
- out.push(rules[i].note(counts[i].count, counts[i].lastLine));
783
- }
784
- }
785
- out.push(...kept);
786
- for (let i = 0; i < rules.length; i++) {
787
- if (rules[i].position === "append" && counts[i].count > 0) {
788
- out.push(rules[i].note(counts[i].count, counts[i].lastLine));
789
- }
790
- }
791
- const notes = [];
792
- for (let i = 0; i < rules.length; i++) {
793
- if (rules[i].position === "note" && counts[i].count > 0) {
794
- notes.push(rules[i].note(counts[i].count, counts[i].lastLine));
795
- }
796
- }
808
+ const out = assembleCountedOutput(rules, counts, kept);
809
+ const notes = countedRuleNotes(rules, counts);
797
810
  for (let i = 0; i < klRules.length; i++) {
798
811
  const v = klValues[i];
799
812
  if (v !== void 0) notes.push(klRules[i].note(v));
@@ -822,7 +835,7 @@ function makeLanguageFilter(cfg) {
822
835
  const kept = [];
823
836
  let droppedNoise = 0;
824
837
  const rules = cfg.countedRules ?? [];
825
- const counts = rules.map(() => ({ count: 0, lastLine: void 0 }));
838
+ const counts = initCountedRules(rules);
826
839
  const dRules = cfg.dedupeRules ?? [];
827
840
  const dState = dRules.map(() => ({ elided: 0, seen: /* @__PURE__ */ new Map() }));
828
841
  for (const line of lines) {
@@ -830,18 +843,7 @@ function makeLanguageFilter(cfg) {
830
843
  kept.push(line);
831
844
  continue;
832
845
  }
833
- let counted = false;
834
- for (let i = 0; i < rules.length; i++) {
835
- const rule = rules[i];
836
- const hit = rule.res ? rule.res.some((r) => r.test(line)) : rule.re?.test(line) ?? false;
837
- if (hit) {
838
- counts[i].count++;
839
- if (rule.keepLast) counts[i].lastLine = line.trim();
840
- counted = true;
841
- break;
842
- }
843
- }
844
- if (counted) continue;
846
+ if (applyCountedRules(rules, counts, line) >= 0) continue;
845
847
  let deduped = false;
846
848
  for (let i = 0; i < dRules.length; i++) {
847
849
  if (dRules[i].re.test(line)) {
@@ -862,21 +864,8 @@ function makeLanguageFilter(cfg) {
862
864
  }
863
865
  kept.push(line);
864
866
  }
865
- const out = [];
866
- for (let i = 0; i < rules.length; i++) {
867
- if (rules[i].position === "prepend" && counts[i].count > 0)
868
- out.push(rules[i].note(counts[i].count, counts[i].lastLine));
869
- }
870
- out.push(...kept);
871
- for (let i = 0; i < rules.length; i++) {
872
- if (rules[i].position === "append" && counts[i].count > 0)
873
- out.push(rules[i].note(counts[i].count, counts[i].lastLine));
874
- }
875
- const notes = [];
876
- for (let i = 0; i < rules.length; i++) {
877
- if (rules[i].position === "note" && counts[i].count > 0)
878
- notes.push(rules[i].note(counts[i].count, counts[i].lastLine));
879
- }
867
+ const out = assembleCountedOutput(rules, counts, kept);
868
+ const notes = countedRuleNotes(rules, counts);
880
869
  for (let i = 0; i < dRules.length; i++) {
881
870
  if (dState[i].elided > 0) notes.push(dRules[i].note(dState[i].elided));
882
871
  }
@@ -5063,13 +5052,19 @@ function grepFlagInCluster(argv, short, long) {
5063
5052
  var _GREP_GLUED_VALUE_SHORT_FLAGS = "ABCDdefgm";
5064
5053
  var _RG_GLUED_VALUE_SHORT_FLAGS = "ABCEMTdefgjmrt";
5065
5054
  function gluedValueShortFlags(argv) {
5066
- return pathStem(argv[0] ?? "").toLowerCase() === "rg" ? _RG_GLUED_VALUE_SHORT_FLAGS : _GREP_GLUED_VALUE_SHORT_FLAGS;
5055
+ return isRgCommand(argv) ? _RG_GLUED_VALUE_SHORT_FLAGS : _GREP_GLUED_VALUE_SHORT_FLAGS;
5056
+ }
5057
+ function isRgCommand(argv) {
5058
+ return pathStem(argv[0] ?? "").toLowerCase() === "rg";
5067
5059
  }
5068
5060
  function isFilesOnlySearch(argv) {
5069
- return grepFlagInCluster(argv, "l", "--files-with-matches");
5061
+ if (grepFlagInCluster(argv, "l", "--files-with-matches")) return true;
5062
+ if (argv.includes("--files")) return true;
5063
+ if (isRgCommand(argv)) return argv.includes("--files-without-match");
5064
+ return grepFlagInCluster(argv, "L", "--files-without-match");
5070
5065
  }
5071
5066
  function isCountOnlySearch(argv) {
5072
- return grepFlagInCluster(argv, "c", "--count");
5067
+ return grepFlagInCluster(argv, "c", "--count") || argv.includes("--count-matches");
5073
5068
  }
5074
5069
  function isStructuredOutputSearch(argv) {
5075
5070
  return argv.includes("--json");
@@ -7371,7 +7366,7 @@ var PWSH_PROGRESS_RECORD_RE = /^(?:Processing record\s+\d+\s+of\s+\d+|PROGRESS:\
7371
7366
  var PS_CNF_ERROR_RE = /^(\S.*?) : (?:The term '.*?' is|.*? is) not recognized as the name of a cmdlet, function, script file, or operable program\.\r?\n(?:.*\r?\n)*?[ \t]*\+ CategoryInfo\s*:\s*ObjectNotFound:\s*\(([^:]*):String\)\s*\[\],\s*CommandNotFoundException\r?\n[ \t]*\+ FullyQualifiedErrorId\s*:\s*CommandNotFoundException\r?\n?/gm;
7372
7367
  var PowerShellErrorFilter = class extends ToolFilter {
7373
7368
  name = "powershell";
7374
- binaries = /* @__PURE__ */ new Set(["pwsh", "powershell", "powershell.exe"]);
7369
+ binaries = /* @__PURE__ */ new Set(["pwsh", "powershell", "powershell.exe", "invoke-pester", "pester"]);
7375
7370
  compress(stdout, stderr, _exitCode, _argv) {
7376
7371
  const merged = this.combineOutput(stdout, stderr);
7377
7372
  const collapsed = this._collapseCommandNotFound(merged);
@@ -9230,6 +9225,20 @@ var KUBECTL_GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set([
9230
9225
  "--as-group",
9231
9226
  "--request-timeout"
9232
9227
  ]);
9228
+ var _KUBECTL_STRUCTURED_OUTPUT = /^(json|yaml|go-template|template)/;
9229
+ function kubectlOutputFormat(argv) {
9230
+ for (let i = 1; i < argv.length; i++) {
9231
+ const a = argv[i];
9232
+ if (a === "-o" || a === "--output") return (argv[i + 1] ?? "").toLowerCase();
9233
+ if (a.startsWith("--output=")) return a.slice("--output=".length).toLowerCase();
9234
+ if (a.startsWith("-o=")) return a.slice("-o=".length).toLowerCase();
9235
+ if (a.startsWith("-o") && !a.startsWith("--") && a.length > 2) return a.slice(2).toLowerCase();
9236
+ }
9237
+ return "";
9238
+ }
9239
+ function isKubectlStructuredOutput(argv) {
9240
+ return _KUBECTL_STRUCTURED_OUTPUT.test(kubectlOutputFormat(argv));
9241
+ }
9233
9242
  var KubectlFilter = class extends ToolFilter {
9234
9243
  name = "kubectl";
9235
9244
  binaries = /* @__PURE__ */ new Set(["kubectl", "k", "k9s", "oc"]);
@@ -9238,7 +9247,7 @@ var KubectlFilter = class extends ToolFilter {
9238
9247
  const pos = positionalArgs(argv.slice(1), KUBECTL_GLOBAL_VALUE_FLAGS);
9239
9248
  const subcommand = pos[0] ?? "";
9240
9249
  let text = stdout;
9241
- if (subcommand === "get" || subcommand === "top") {
9250
+ if ((subcommand === "get" || subcommand === "top") && !isKubectlStructuredOutput(argv)) {
9242
9251
  if (text.includes("\n")) {
9243
9252
  const resource = pos[1] ?? "";
9244
9253
  if (resource === "events" || resource === "ev" || resource === "event") {
@@ -13443,6 +13452,7 @@ function deliverCompressed(filter, stdout, stderr, exitCode, argv, opts = {}) {
13443
13452
  }
13444
13453
  function filterByName(name) {
13445
13454
  if (name === "generic") return new GenericFilter();
13455
+ if (name === "passthrough") return new PassthroughFilter();
13446
13456
  for (const f of TOOL_FILTERS) if (f.name === name) return f;
13447
13457
  return null;
13448
13458
  }
@@ -13456,6 +13466,7 @@ export {
13456
13466
  compressedTokensSaved,
13457
13467
  CompressedOutput,
13458
13468
  ToolFilter,
13469
+ PassthroughFilter,
13459
13470
  pytestFilter,
13460
13471
  looksLikePytestOutput,
13461
13472
  TOOL_FILTERS,
@@ -3,7 +3,7 @@ const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  queryCsv,
5
5
  quoteCsvCell
6
- } from "./token-goat-chunk-L43RKNHA.mjs";
6
+ } from "./token-goat-chunk-YWSP6IU7.mjs";
7
7
  import {
8
8
  NotAnOfficeDocumentError,
9
9
  assertOoxmlWithinDeadline,
@@ -12,7 +12,7 @@ import {
12
12
  ooxmlWorkDeadline,
13
13
  parseOoxmlPart,
14
14
  readOoxmlZip
15
- } from "./token-goat-chunk-RIB6XY2V.mjs";
15
+ } from "./token-goat-chunk-UBUKHVYW.mjs";
16
16
  import {
17
17
  displaySafeText
18
18
  } from "./token-goat-chunk-NMTKNYGF.mjs";
@@ -26,8 +26,8 @@ import {
26
26
  runSkeleton,
27
27
  runSymbol,
28
28
  withPinnedReads
29
- } from "./token-goat-chunk-RH27ZSPF.mjs";
30
- import "./token-goat-chunk-5M3NRJD2.mjs";
29
+ } from "./token-goat-chunk-VWZKZPSR.mjs";
30
+ import "./token-goat-chunk-4STDIGYC.mjs";
31
31
  import "./token-goat-chunk-DA43OE7L.mjs";
32
32
  import {
33
33
  buildProjectMap,
@@ -37,37 +37,42 @@ import {
37
37
  getProjectIndexCounts,
38
38
  isWorkerRunning,
39
39
  mapLookupBytesSaved
40
- } from "./token-goat-chunk-MBDJR6HU.mjs";
41
- import "./token-goat-chunk-4GEDH2WU.mjs";
42
- import "./token-goat-chunk-VVROQBQJ.mjs";
43
- import "./token-goat-chunk-M6CVNHTW.mjs";
40
+ } from "./token-goat-chunk-6Z5ULNE5.mjs";
41
+ import "./token-goat-chunk-IZXKVT4A.mjs";
42
+ import "./token-goat-chunk-RJH64KQH.mjs";
43
+ import "./token-goat-chunk-MMLMALWK.mjs";
44
+ import "./token-goat-chunk-6CCQDAYY.mjs";
45
+ import "./token-goat-chunk-GGLEE35R.mjs";
44
46
  import {
45
47
  claudeConfigDir
46
- } from "./token-goat-chunk-G6EYO5CD.mjs";
47
- import "./token-goat-chunk-43JFN26X.mjs";
48
+ } from "./token-goat-chunk-MAMQPC43.mjs";
49
+ import "./token-goat-chunk-HXNAC4ZF.mjs";
50
+ import "./token-goat-chunk-BJBRGPBX.mjs";
51
+ import "./token-goat-chunk-4JMWPWCS.mjs";
52
+ import "./token-goat-chunk-4RN64ZND.mjs";
48
53
  import {
49
54
  recordStat,
50
55
  savedTokensFromBytes
51
- } from "./token-goat-chunk-D2X7XN5M.mjs";
56
+ } from "./token-goat-chunk-MVSWBNMD.mjs";
52
57
  import "./token-goat-chunk-LKSXAMJB.mjs";
53
- import "./token-goat-chunk-L43RKNHA.mjs";
58
+ import "./token-goat-chunk-YWSP6IU7.mjs";
54
59
  import "./token-goat-chunk-3BTK54F3.mjs";
55
60
  import "./token-goat-chunk-XTQAOTSO.mjs";
56
61
  import "./token-goat-chunk-AH6QILZM.mjs";
57
- import "./token-goat-chunk-LHUP4DXZ.mjs";
62
+ import "./token-goat-chunk-66LODAUT.mjs";
58
63
  import {
59
64
  checkEmbeddingPreflight,
60
65
  embeddingsDepsAvailable
61
- } from "./token-goat-chunk-7EPYB34H.mjs";
62
- import "./token-goat-chunk-IKZLSRII.mjs";
66
+ } from "./token-goat-chunk-D5ICEPSB.mjs";
67
+ import "./token-goat-chunk-HUDC5GS5.mjs";
63
68
  import {
64
69
  getDb
65
- } from "./token-goat-chunk-7SXPJOSZ.mjs";
70
+ } from "./token-goat-chunk-M56BWPBN.mjs";
66
71
  import {
67
72
  envStrList,
68
73
  loadConfig,
69
74
  resolveProjectRoot
70
- } from "./token-goat-chunk-LRIZ7K3F.mjs";
75
+ } from "./token-goat-chunk-CC2PYJM7.mjs";
71
76
  import "./token-goat-chunk-EEIDFMEM.mjs";
72
77
  import "./token-goat-chunk-OSUFN2FV.mjs";
73
78
  import {
@@ -77,7 +82,7 @@ import {
77
82
  extractErrorMessage,
78
83
  foldCaseForContainment,
79
84
  globalDbPath
80
- } from "./token-goat-chunk-6E2IDLHF.mjs";
85
+ } from "./token-goat-chunk-L45ZQRT7.mjs";
81
86
  import {
82
87
  displaySafeJson,
83
88
  normalizePath