token-goat 2.9.1 → 2.9.3

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 (29) hide show
  1. package/README.md +38 -765
  2. package/SECURITY.md +1 -1
  3. package/dist/{token-goat-chunk-RRNRPCLX.mjs → token-goat-chunk-2VVXTAGD.mjs} +192 -16
  4. package/dist/{token-goat-chunk-CD6U5OD6.mjs → token-goat-chunk-3UBORD6Z.mjs} +9 -6
  5. package/dist/{token-goat-chunk-FDXINYK4.mjs → token-goat-chunk-3XVGPLDS.mjs} +3592 -63
  6. package/dist/{token-goat-chunk-SQSB5P5P.mjs → token-goat-chunk-6FQMEMWX.mjs} +583 -107
  7. package/dist/{token-goat-chunk-SXSWQMNP.mjs → token-goat-chunk-7A7SBE6R.mjs} +166 -72
  8. package/dist/token-goat-chunk-A37V4PBF.mjs +56 -0
  9. package/dist/{token-goat-chunk-MR7MNSDR.mjs → token-goat-chunk-A4VBNWSL.mjs} +20 -3
  10. package/dist/{token-goat-chunk-G6XLWJWI.mjs → token-goat-chunk-E3K3BTEQ.mjs} +5 -2
  11. package/dist/{token-goat-chunk-AO2QD2AG.mjs → token-goat-chunk-EEIDFMEM.mjs} +4 -0
  12. package/dist/{token-goat-chunk-324QOJYZ.mjs → token-goat-chunk-EVC4TOLE.mjs} +4 -1
  13. package/dist/{token-goat-chunk-WN5T5EW5.mjs → token-goat-chunk-FQD3OB5W.mjs} +98 -2
  14. package/dist/token-goat-chunk-HC5NMGPD.mjs +23 -0
  15. package/dist/{token-goat-chunk-4ZDRTNGV.mjs → token-goat-chunk-KKHKXUVS.mjs} +317 -32
  16. package/dist/{token-goat-chunk-4KD2N46D.mjs → token-goat-chunk-LLNA42NI.mjs} +10 -12
  17. package/dist/{token-goat-chunk-5CVKO3DA.mjs → token-goat-chunk-LYWIRYCF.mjs} +5 -2
  18. package/dist/{token-goat-chunk-LHMC5ENL.mjs → token-goat-chunk-OKJX2JWW.mjs} +6 -1
  19. package/dist/{token-goat-chunk-R4SR7MQY.mjs → token-goat-chunk-PXWBHSFB.mjs} +2 -2
  20. package/dist/{token-goat-chunk-V5T3YNYR.mjs → token-goat-chunk-XSSQFI4C.mjs} +7 -7
  21. package/dist/token-goat-hook.mjs +12 -7
  22. package/dist/token-goat.core.mjs +10 -7
  23. package/docs/C4_RUNTIME_ARCHITECTURE.md +303 -0
  24. package/docs/cli.md +392 -0
  25. package/docs/install.md +331 -0
  26. package/docs/security.md +106 -0
  27. package/package.json +14 -3
  28. package/dist/token-goat-chunk-AEX54RUZ.mjs +0 -11
  29. package/dist/token-goat-chunk-AUM22UQ2.mjs +0 -23
@@ -2,13 +2,17 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  registerReset
5
- } from "./token-goat-chunk-AO2QD2AG.mjs";
5
+ } from "./token-goat-chunk-EEIDFMEM.mjs";
6
+ import {
7
+ init_define_import_meta_env
8
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
9
 
7
10
  // src/version.ts
11
+ init_define_import_meta_env();
8
12
  import { createRequire } from "node:module";
9
13
  function resolveVersion() {
10
14
  if (true) {
11
- return "2.9.1";
15
+ return "2.9.3";
12
16
  }
13
17
  const require2 = createRequire(import.meta.url);
14
18
  const pkg = require2("../package.json");
@@ -17,6 +21,7 @@ function resolveVersion() {
17
21
  var VERSION = resolveVersion();
18
22
 
19
23
  // src/constants.ts
24
+ init_define_import_meta_env();
20
25
  import * as fs from "node:fs";
21
26
  import * as os from "node:os";
22
27
  import * as path from "node:path";
@@ -136,6 +141,7 @@ var ENV_KEYS = {
136
141
  var SYMBOL_BODY_CHAR_CAP = 128 * 1024;
137
142
 
138
143
  // src/bridges/registry.ts
144
+ init_define_import_meta_env();
139
145
  var KNOWN_HARNESS_NAMES = /* @__PURE__ */ new Set([
140
146
  "claudecode",
141
147
  "codex",
@@ -198,6 +204,7 @@ function resetHarnessCache() {
198
204
  registerReset(resetHarnessCache);
199
205
 
200
206
  // src/env.ts
207
+ init_define_import_meta_env();
201
208
  var FALSY_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
202
209
  var TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
203
210
  function envStr(key, defaultVal) {
@@ -236,6 +243,7 @@ function envStrList(key, defaultVal, delimiter2) {
236
243
  }
237
244
 
238
245
  // src/fingerprint.ts
246
+ init_define_import_meta_env();
239
247
  import { createHash } from "node:crypto";
240
248
  import * as fs2 from "node:fs";
241
249
  function fingerprintContent(content) {
@@ -264,6 +272,7 @@ function fileIsAbsent(filePath) {
264
272
  }
265
273
 
266
274
  // src/paths.ts
275
+ init_define_import_meta_env();
267
276
  import * as fs3 from "node:fs";
268
277
  import * as path2 from "node:path";
269
278
  var WSL_PATH_RE = /^\/mnt\/([a-zA-Z])\/(.*)$/s;
@@ -371,6 +380,7 @@ function displaySafePath(p) {
371
380
  }
372
381
 
373
382
  // src/util.ts
383
+ init_define_import_meta_env();
374
384
  import { spawn, spawnSync } from "node:child_process";
375
385
  import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, unlinkSync, writeFileSync, writeSync } from "node:fs";
376
386
  import * as path3 from "node:path";
@@ -1089,6 +1099,7 @@ function encodeUtf32(text, littleEndian) {
1089
1099
  }
1090
1100
 
1091
1101
  // src/project.ts
1102
+ init_define_import_meta_env();
1092
1103
  import * as fs4 from "node:fs";
1093
1104
  import * as os2 from "node:os";
1094
1105
  import * as path4 from "node:path";
@@ -1305,10 +1316,24 @@ function isInsideRoot(target, root) {
1305
1316
  }
1306
1317
 
1307
1318
  // src/config.ts
1319
+ init_define_import_meta_env();
1308
1320
  import * as fs5 from "node:fs";
1309
1321
  import * as path5 from "node:path";
1310
1322
 
1323
+ // node_modules/smol-toml/dist/index.js
1324
+ init_define_import_meta_env();
1325
+
1326
+ // node_modules/smol-toml/dist/parse.js
1327
+ init_define_import_meta_env();
1328
+
1329
+ // node_modules/smol-toml/dist/struct.js
1330
+ init_define_import_meta_env();
1331
+
1332
+ // node_modules/smol-toml/dist/primitive.js
1333
+ init_define_import_meta_env();
1334
+
1311
1335
  // node_modules/smol-toml/dist/date.js
1336
+ init_define_import_meta_env();
1312
1337
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
1313
1338
  var TomlDate = class _TomlDate extends Date {
1314
1339
  #hasDate = false;
@@ -1401,6 +1426,7 @@ var TomlDate = class _TomlDate extends Date {
1401
1426
  };
1402
1427
 
1403
1428
  // node_modules/smol-toml/dist/error.js
1429
+ init_define_import_meta_env();
1404
1430
  function getLineColFromPtr(string, ptr) {
1405
1431
  let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
1406
1432
  return [lines.length, lines.pop().length + 1];
@@ -1441,6 +1467,7 @@ ${codeblock}`, options);
1441
1467
  };
1442
1468
 
1443
1469
  // node_modules/smol-toml/dist/util.js
1470
+ init_define_import_meta_env();
1444
1471
  function indexOfNewline(str, start = 0) {
1445
1472
  let idx = str.indexOf("\n", start);
1446
1473
  if (str.charCodeAt(idx - 1) === 13)
@@ -1652,6 +1679,7 @@ function parseValue(ctx, integersAsBigInt, end) {
1652
1679
  }
1653
1680
 
1654
1681
  // node_modules/smol-toml/dist/extract.js
1682
+ init_define_import_meta_env();
1655
1683
  function extractValue(ctx, end, integersAsBigInt) {
1656
1684
  let ptr = ctx.p;
1657
1685
  let c = ctx.s.charCodeAt(ptr);
@@ -1954,6 +1982,7 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1954
1982
  }
1955
1983
 
1956
1984
  // node_modules/smol-toml/dist/stringify.js
1985
+ init_define_import_meta_env();
1957
1986
  var BARE_KEY = /^[a-z0-9-_]+$/i;
1958
1987
  function extendedTypeOf(obj) {
1959
1988
  let type = typeof obj;
@@ -2300,6 +2329,10 @@ var CONFIG_DEFAULTS = {
2300
2329
  gdrive: {
2301
2330
  enabled: true
2302
2331
  },
2332
+ redaction: {
2333
+ custom_patterns: [],
2334
+ strict: false
2335
+ },
2303
2336
  network: {
2304
2337
  offline: false
2305
2338
  },
@@ -2343,6 +2376,7 @@ function defaultConfig() {
2343
2376
  context: getDefaultConfig("context"),
2344
2377
  injection: getDefaultConfig("injection"),
2345
2378
  gdrive: getDefaultConfig("gdrive"),
2379
+ redaction: getDefaultConfig("redaction"),
2346
2380
  network: getDefaultConfig("network"),
2347
2381
  mcp: getDefaultConfig("mcp"),
2348
2382
  hint_stats: getDefaultConfig("hint_stats"),
@@ -2567,6 +2601,7 @@ var PROJECT_LOCKED_SECTIONS = [
2567
2601
  "injection",
2568
2602
  "webfetch",
2569
2603
  "gdrive",
2604
+ "redaction",
2570
2605
  "mcp",
2571
2606
  "network",
2572
2607
  "screenshot"
@@ -3075,6 +3110,12 @@ function _buildConfig(raw, projectRaw = {}) {
3075
3110
  const gd = getDefaultConfig("gdrive");
3076
3111
  gd.enabled = validatedBool(gd_raw["enabled"], gd.enabled);
3077
3112
  gd.enabled = envBool("TOKEN_GOAT_GDRIVE_ENABLED", gd.enabled);
3113
+ const red_raw = section(raw, "redaction");
3114
+ const red = getDefaultConfig("redaction");
3115
+ red.custom_patterns = validatedStrList(red_raw["custom_patterns"], red.custom_patterns);
3116
+ red.custom_patterns = envStrList("TOKEN_GOAT_REDACTION_CUSTOM_PATTERNS", red.custom_patterns, "\n");
3117
+ red.strict = validatedBool(red_raw["strict"], red.strict);
3118
+ red.strict = envBool("TOKEN_GOAT_REDACTION_STRICT", red.strict);
3078
3119
  const net_raw = section(raw, "network");
3079
3120
  const net = getDefaultConfig("network");
3080
3121
  net.offline = validatedBool(net_raw["offline"], net.offline);
@@ -3116,6 +3157,7 @@ function _buildConfig(raw, projectRaw = {}) {
3116
3157
  context: ctx,
3117
3158
  injection: inj,
3118
3159
  gdrive: gd,
3160
+ redaction: red,
3119
3161
  network: net,
3120
3162
  mcp,
3121
3163
  hint_stats: hs,
@@ -3187,6 +3229,8 @@ var CONFIG_KEY_ENV_OVERRIDES = {
3187
3229
  "indexing.cross_project_symbols": ["TOKEN_GOAT_CROSS_PROJECT_SYMBOLS"],
3188
3230
  "injection.enabled": ["TOKEN_GOAT_INJECTION_ENABLED"],
3189
3231
  "gdrive.enabled": ["TOKEN_GOAT_GDRIVE_ENABLED"],
3232
+ "redaction.custom_patterns": ["TOKEN_GOAT_REDACTION_CUSTOM_PATTERNS"],
3233
+ "redaction.strict": ["TOKEN_GOAT_REDACTION_STRICT"],
3190
3234
  "network.offline": ["TOKEN_GOAT_OFFLINE"],
3191
3235
  "mcp.confine_reads_to_project_root": ["TOKEN_GOAT_MCP_CONFINE_READS"],
3192
3236
  "mcp.allowed_roots": ["TOKEN_GOAT_MCP_ALLOWED_ROOTS"],
@@ -3355,6 +3399,10 @@ function saveConfig(config) {
3355
3399
  gdrive: {
3356
3400
  enabled: config.gdrive.enabled
3357
3401
  },
3402
+ redaction: {
3403
+ custom_patterns: config.redaction.custom_patterns,
3404
+ strict: config.redaction.strict
3405
+ },
3358
3406
  network: {
3359
3407
  offline: config.network.offline
3360
3408
  },
@@ -3376,6 +3424,7 @@ function saveConfig(config) {
3376
3424
  }
3377
3425
 
3378
3426
  // src/parser_types.ts
3427
+ init_define_import_meta_env();
3379
3428
  import * as path6 from "node:path";
3380
3429
  var EXTENSION_LANGUAGE = /* @__PURE__ */ new Map([
3381
3430
  [".py", "python"],
@@ -3532,7 +3581,17 @@ function unsupportedLanguageName(filePath) {
3532
3581
  return UNSUPPORTED_LANGUAGE_EXTENSIONS.get(ext);
3533
3582
  }
3534
3583
 
3584
+ // src/dotenv_redact.ts
3585
+ init_define_import_meta_env();
3586
+
3587
+ // src/languages/ini_idx.ts
3588
+ init_define_import_meta_env();
3589
+
3590
+ // src/languages/common.ts
3591
+ init_define_import_meta_env();
3592
+
3535
3593
  // src/doc_comment.ts
3594
+ init_define_import_meta_env();
3536
3595
  function precedingDocComment(lines, lineStart, style) {
3537
3596
  const aboveIdx = lineStart - 2;
3538
3597
  if (aboveIdx < 0 || aboveIdx >= lines.length) return "";
@@ -4701,11 +4760,13 @@ function redactIfDotenv(filePath, text) {
4701
4760
  }
4702
4761
 
4703
4762
  // src/db.ts
4763
+ init_define_import_meta_env();
4704
4764
  import * as fs7 from "node:fs";
4705
4765
  import { createRequire as createRequire3 } from "node:module";
4706
4766
  import * as path7 from "node:path";
4707
4767
 
4708
4768
  // src/sqlite_driver.ts
4769
+ init_define_import_meta_env();
4709
4770
  import * as fs6 from "node:fs";
4710
4771
  import { createRequire as createRequire2 } from "node:module";
4711
4772
  var _require = createRequire2(import.meta.url);
@@ -5447,6 +5508,7 @@ function closeAllDbs() {
5447
5508
  registerReset(closeAllDbs);
5448
5509
 
5449
5510
  // src/render/ansi.ts
5511
+ init_define_import_meta_env();
5450
5512
  function _colorStream(isatty) {
5451
5513
  if (process.env["NO_COLOR"]) return false;
5452
5514
  return isatty;
@@ -5521,9 +5583,11 @@ var C = {
5521
5583
  };
5522
5584
 
5523
5585
  // src/stats.ts
5586
+ init_define_import_meta_env();
5524
5587
  import * as path8 from "node:path";
5525
5588
 
5526
5589
  // src/render/stats_renderer.ts
5590
+ init_define_import_meta_env();
5527
5591
  var _STATS_MESSAGES_FALLBACK = {
5528
5592
  bytesModeOnlyNote: "tracks bytes, not vision tokens",
5529
5593
  sessionHintSplitNote: "session_hint shows realized savings; session_hint_overhead shows injected hint cost",
@@ -6906,7 +6970,14 @@ function renderStats2(opts) {
6906
6970
  process.stdout.write(renderStats(statsData) + "\n");
6907
6971
  }
6908
6972
 
6973
+ // src/hook_registry.ts
6974
+ init_define_import_meta_env();
6975
+
6976
+ // src/hooks_common.ts
6977
+ init_define_import_meta_env();
6978
+
6909
6979
  // src/secret_redact.ts
6980
+ init_define_import_meta_env();
6910
6981
  var SECRET_PATTERNS = [
6911
6982
  // Anthropic keys share OpenAI's "sk-" prefix but are more specific ("sk-ant-"), so they're matched first — the generic OpenAI pattern's negative lookahead below is defense in depth, not the sole guard.
6912
6983
  ["anthropic_api_key", /sk-ant-[A-Za-z0-9_-]{20,}/g],
@@ -6947,7 +7018,110 @@ var SECRET_PATTERNS = [
6947
7018
  function countRedactionPlaceholders(text) {
6948
7019
  return text.match(/\[REDACTED:[a-z0-9_]+\]/g)?.length ?? 0;
6949
7020
  }
6950
- function redactSecrets(text) {
7021
+ var MAX_CUSTOM_PATTERNS = 64;
7022
+ var MAX_CUSTOM_PATTERN_LENGTH = 512;
7023
+ var customCache = null;
7024
+ var GROUP_PREFIX = String.raw`\((?:\?(?::|<?[=!]|<\w+>|[a-z]*(?:-[a-z]*)?:))?`;
7025
+ var NESTED_QUANTIFIER = new RegExp(
7026
+ // a quantified group whose body itself repeats: (a+)+, (?:a*)*, (?<x>\d{2,})+
7027
+ GROUP_PREFIX + String.raw`[^()*+]*(?:[*+]|\{\d+,\d*\})[^()]*\)\s*(?:[*+]|\{\d+,\d*\})`
7028
+ );
7029
+ var PROBE_ALPHABETS = ["a", "0", "a0"];
7030
+ var PROBE_SHORT = 14;
7031
+ var PROBE_LONG = 20;
7032
+ var PROBE_GROWTH_FACTOR = 12;
7033
+ var PROBE_BUDGET_MS = 25;
7034
+ function timeMatch(re, input) {
7035
+ const probe = new RegExp(re.source, re.flags.replace("g", ""));
7036
+ const started = performance.now();
7037
+ probe.test(input);
7038
+ return performance.now() - started;
7039
+ }
7040
+ function growsExponentially(re) {
7041
+ for (const alphabet of PROBE_ALPHABETS) {
7042
+ const fill = (n) => alphabet.repeat(Math.ceil(n / alphabet.length)).slice(0, n) + "!";
7043
+ const short = timeMatch(re, fill(PROBE_SHORT));
7044
+ const long = timeMatch(re, fill(PROBE_LONG));
7045
+ if (long > PROBE_BUDGET_MS) return true;
7046
+ if (long > 1 && long > short * PROBE_GROWTH_FACTOR) return true;
7047
+ }
7048
+ return false;
7049
+ }
7050
+ function compileCustomPatterns(sources) {
7051
+ const key = JSON.stringify(sources);
7052
+ if (customCache !== null && customCache.key === key) {
7053
+ return { patterns: customCache.patterns, problems: customCache.problems };
7054
+ }
7055
+ const patterns = [];
7056
+ const problems = [];
7057
+ const written = sources.map((raw) => raw.trim()).filter((source) => source.length > 0);
7058
+ for (const source of written.slice(0, MAX_CUSTOM_PATTERNS)) {
7059
+ if (source.length > MAX_CUSTOM_PATTERN_LENGTH) {
7060
+ problems.push({ pattern: source.slice(0, 60), reason: `longer than ${MAX_CUSTOM_PATTERN_LENGTH} characters` });
7061
+ continue;
7062
+ }
7063
+ if (NESTED_QUANTIFIER.test(source)) {
7064
+ problems.push({
7065
+ pattern: source,
7066
+ reason: "repeats a group that already repeats, which can take exponential time to match"
7067
+ });
7068
+ continue;
7069
+ }
7070
+ let compiled;
7071
+ try {
7072
+ compiled = new RegExp(source, "g");
7073
+ } catch (e) {
7074
+ problems.push({ pattern: source, reason: e instanceof Error ? e.message : "is not a valid regular expression" });
7075
+ continue;
7076
+ }
7077
+ if (new RegExp(source).test("")) {
7078
+ problems.push({
7079
+ pattern: source,
7080
+ reason: "matches the empty string, so it would replace every position in the text"
7081
+ });
7082
+ continue;
7083
+ }
7084
+ if (growsExponentially(compiled)) {
7085
+ problems.push({
7086
+ pattern: source,
7087
+ reason: "its running time doubles as the text grows, which can stall the process on a short input"
7088
+ });
7089
+ continue;
7090
+ }
7091
+ patterns.push(compiled);
7092
+ }
7093
+ if (written.length > MAX_CUSTOM_PATTERNS) {
7094
+ problems.push({
7095
+ pattern: `(${written.length} entries)`,
7096
+ reason: `only the first ${MAX_CUSTOM_PATTERNS} custom patterns are used`
7097
+ });
7098
+ }
7099
+ customCache = { key, patterns, problems };
7100
+ return { patterns, problems };
7101
+ }
7102
+ var STRICT_CANDIDATE = /[A-Za-z0-9+/_-]{24,}={0,2}/g;
7103
+ function entropyBitsPerChar(s) {
7104
+ const counts = /* @__PURE__ */ new Map();
7105
+ for (const ch of s) counts.set(ch, (counts.get(ch) ?? 0) + 1);
7106
+ let bits = 0;
7107
+ for (const n of counts.values()) {
7108
+ const p = n / s.length;
7109
+ bits -= p * Math.log2(p);
7110
+ }
7111
+ return bits;
7112
+ }
7113
+ function characterClasses(s) {
7114
+ let n = 0;
7115
+ if (/[a-z]/.test(s)) n++;
7116
+ if (/[A-Z]/.test(s)) n++;
7117
+ if (/[0-9]/.test(s)) n++;
7118
+ if (/[+/=_-]/.test(s)) n++;
7119
+ return n;
7120
+ }
7121
+ function looksLikeCredential(s) {
7122
+ return characterClasses(s) >= 3 && entropyBitsPerChar(s) >= 3.5;
7123
+ }
7124
+ function redactSecrets(text, config = loadConfig()) {
6951
7125
  let count = 0;
6952
7126
  let out = text;
6953
7127
  for (const [kind, pattern] of SECRET_PATTERNS) {
@@ -6956,6 +7130,19 @@ function redactSecrets(text) {
6956
7130
  return `[REDACTED:${kind}]`;
6957
7131
  });
6958
7132
  }
7133
+ for (const pattern of compileCustomPatterns(config.redaction.custom_patterns).patterns) {
7134
+ out = out.replace(pattern, () => {
7135
+ count++;
7136
+ return "[REDACTED:custom]";
7137
+ });
7138
+ }
7139
+ if (config.redaction.strict) {
7140
+ out = out.replace(STRICT_CANDIDATE, (candidate) => {
7141
+ if (!looksLikeCredential(candidate)) return candidate;
7142
+ count++;
7143
+ return "[REDACTED:high_entropy]";
7144
+ });
7145
+ }
6959
7146
  return { text: out, count };
6960
7147
  }
6961
7148
 
@@ -7057,7 +7244,8 @@ function passOutput() {
7057
7244
  return { hookType: "pass" };
7058
7245
  }
7059
7246
  function denyOutput(message) {
7060
- return { hookType: "deny", message };
7247
+ const prefixed = message.startsWith("[tg]") ? message : `[tg] ${message}`;
7248
+ return { hookType: "deny", message: prefixed };
7061
7249
  }
7062
7250
  function contextOutput(context) {
7063
7251
  return { hookType: "context", context };
@@ -7269,11 +7457,16 @@ function serializeOutput(output, eventName, harness, event) {
7269
7457
  }
7270
7458
 
7271
7459
  // src/install.ts
7460
+ init_define_import_meta_env();
7272
7461
  import * as fs8 from "node:fs";
7273
7462
  import * as os3 from "node:os";
7274
7463
  import * as path9 from "node:path";
7275
7464
 
7465
+ // src/bridges/claudecode.ts
7466
+ init_define_import_meta_env();
7467
+
7276
7468
  // src/bridges/shim_common.ts
7469
+ init_define_import_meta_env();
7277
7470
  var SHIM_REQUIRES = `const { spawnSync } = require('node:child_process')
7278
7471
  const path = require('node:path')
7279
7472
  const { pathToFileURL } = require('node:url')`;
@@ -7393,6 +7586,7 @@ main().catch(() => {
7393
7586
  `;
7394
7587
 
7395
7588
  // src/bridges/guidance_block.ts
7589
+ init_define_import_meta_env();
7396
7590
  function buildGuidanceBody(fallbackToolClause, opts = {}) {
7397
7591
  const gdrive = opts.gdrive !== false;
7398
7592
  return [
@@ -7733,12 +7927,14 @@ function uninstallSkill() {
7733
7927
  }
7734
7928
 
7735
7929
  // src/bridges/codex_install.ts
7930
+ init_define_import_meta_env();
7736
7931
  import * as crypto from "node:crypto";
7737
7932
  import * as fs9 from "node:fs";
7738
7933
  import * as os4 from "node:os";
7739
7934
  import * as path10 from "node:path";
7740
7935
 
7741
7936
  // src/bridges/codex.ts
7937
+ init_define_import_meta_env();
7742
7938
  var CODEX_HOOK_SCRIPT = `#!/usr/bin/env node
7743
7939
  // token-goat Codex hook shim. Forwards the hook payload to \`token-goat hook <event>\`, then strips _tg_* keys and injects hookEventName so the response satisfies Codex's strict (additionalProperties:false) schema.
7744
7940
  'use strict'
@@ -7842,6 +8038,7 @@ main().catch(() => {
7842
8038
  `;
7843
8039
 
7844
8040
  // src/bridges/matcher_group.ts
8041
+ init_define_import_meta_env();
7845
8042
  function groupHasTokenGoat2(groups, matcher, predicate) {
7846
8043
  if (groups === void 0) return false;
7847
8044
  for (const group of groups) {
@@ -8127,11 +8324,16 @@ function stripAgentsBlock(p) {
8127
8324
  }
8128
8325
 
8129
8326
  // src/bridges/copilot_cli_install.ts
8327
+ init_define_import_meta_env();
8130
8328
  import * as fs10 from "node:fs";
8131
8329
  import * as os5 from "node:os";
8132
8330
  import * as path11 from "node:path";
8133
8331
 
8332
+ // src/bridges/copilot_cli.ts
8333
+ init_define_import_meta_env();
8334
+
8134
8335
  // src/bridges/shrink_block.ts
8336
+ init_define_import_meta_env();
8135
8337
  var MATERIALIZE_SHRUNK_IMAGE_JS = `// Best-effort sweep of previously materialized shrunk copies in the OS temp dir. The temp file only needs to outlive the single tool call whose path argument was rewritten to it, so anything older than an hour is finished with; the "token-goat-shrink-" prefix check confines the sweep to this mechanism's own files (same defense-in-depth rule as pruneShrinkCache in src/image_shrink.ts). Throttled per process; runs only when a shrink payload actually arrives, so the common no-image path never pays for it.
8136
8338
  const MATERIALIZED_SHRINK_MAX_AGE_MS = 60 * 60 * 1000
8137
8339
  let lastMaterializedShrinkSweepAtMs = 0
@@ -8166,7 +8368,7 @@ function materializeShrunkImage(context) {
8166
8368
  try {
8167
8369
  pruneMaterializedShrinks()
8168
8370
  const buf = Buffer.from(match[2], "base64")
8169
- const name = \`token-goat-shrink-\${process.pid}-\${Date.now()}-\${Math.random().toString(36).slice(2)}.\${match[1]}\`
8371
+ const name = \`token-goat-shrink-\${process.pid}-\${Date.now()}-\${globalThis.crypto.randomUUID()}.\${match[1]}\`
8170
8372
  const file = path.join(os.tmpdir(), name)
8171
8373
  fs.writeFileSync(file, buf)
8172
8374
  return file
@@ -8387,7 +8589,18 @@ async function tryInProcess(entryPath, tgEvent, canonical) {
8387
8589
  async function main() {
8388
8590
  const copilotEvent = process.argv[2] || ''
8389
8591
 
8390
- const tgEvent = COPILOT_TO_TG_EVENT[copilotEvent]
8592
+ // hasOwnProperty, not a bare lookup: the map is a plain object literal, so eight keys it never
8593
+ // declares ('constructor', 'toString', '__proto__' and the rest of Object.prototype) come back
8594
+ // truthy and sail past the check below. tgEvent is then a Function, and 'token-goat hook ' +
8595
+ // tgEvent is concatenated into a shell command string by the fallback at the bottom of this
8596
+ // shim. No member of Object.prototype stringifies with a shell metacharacter, so this was a
8597
+ // failed spawn rather than a second command -- but argv reaching a shell string through a gate
8598
+ // that reads like it stops it is the shape worth closing, not the payload that happened to be
8599
+ // harmless. The four shims built on shim_common.ts validate against a closed Set, which has no
8600
+ // equivalent hole.
8601
+ const tgEvent = Object.prototype.hasOwnProperty.call(COPILOT_TO_TG_EVENT, copilotEvent)
8602
+ ? COPILOT_TO_TG_EVENT[copilotEvent]
8603
+ : undefined
8391
8604
  if (!tgEvent) {
8392
8605
  process.stdout.write('{}')
8393
8606
  return
@@ -8880,11 +9093,13 @@ function isCopilotCliInstalled(opts = {}) {
8880
9093
  }
8881
9094
 
8882
9095
  // src/bridges/kimi_install.ts
9096
+ init_define_import_meta_env();
8883
9097
  import * as fs11 from "node:fs";
8884
9098
  import * as os6 from "node:os";
8885
9099
  import * as path12 from "node:path";
8886
9100
 
8887
9101
  // src/bridges/kimi.ts
9102
+ init_define_import_meta_env();
8888
9103
  var KIMI_HOOK_SCRIPT = `#!/usr/bin/env node
8889
9104
  // token-goat Kimi Code hook shim. Forwards the hook payload to \`token-goat hook <event>\`, then rewrites the response into Kimi's own contract: permissionDecision "deny" for a block, top-level "message" for a hint, empty stdout for a no-op.
8890
9105
  'use strict'
@@ -9136,11 +9351,13 @@ function isKimiInstalled() {
9136
9351
  }
9137
9352
 
9138
9353
  // src/bridges/grok_install.ts
9354
+ init_define_import_meta_env();
9139
9355
  import * as fs12 from "node:fs";
9140
9356
  import * as os7 from "node:os";
9141
9357
  import * as path13 from "node:path";
9142
9358
 
9143
9359
  // src/bridges/grok.ts
9360
+ init_define_import_meta_env();
9144
9361
  var GROK_HOOK_SCRIPT = `#!/usr/bin/env node
9145
9362
  // token-goat Grok CLI hook shim. Forwards the hook payload to \`token-goat hook <event>\`, then -- for pre_tool_use only -- translates token-goat's {"decision":"block",...} deny shape into Grok's documented {"decision":"deny",...} shape and sets exit code 2.
9146
9363
  'use strict'
@@ -9292,6 +9509,7 @@ function isGrokInstalled() {
9292
9509
  }
9293
9510
 
9294
9511
  // src/bridges/vscode_install.ts
9512
+ init_define_import_meta_env();
9295
9513
  import * as fs13 from "node:fs";
9296
9514
  import * as os8 from "node:os";
9297
9515
  import * as path14 from "node:path";
@@ -9457,11 +9675,19 @@ function uninstallVscode(opts = {}) {
9457
9675
  return removed;
9458
9676
  }
9459
9677
 
9678
+ // src/bridges/index.ts
9679
+ init_define_import_meta_env();
9680
+
9460
9681
  // src/tool_filters/helpers.ts
9682
+ init_define_import_meta_env();
9461
9683
  import * as fs14 from "node:fs";
9462
9684
  import * as path15 from "node:path";
9463
9685
 
9686
+ // src/bash_compress.ts
9687
+ init_define_import_meta_env();
9688
+
9464
9689
  // src/filters.ts
9690
+ init_define_import_meta_env();
9465
9691
  var DROP = () => null;
9466
9692
  var FILTERS = [
9467
9693
  {
@@ -9594,6 +9820,11 @@ function hasUnquotedOperator(cmd, ops) {
9594
9820
  return ops.some((op) => masked.includes(op));
9595
9821
  }
9596
9822
  var BYTES_ELIDED_MARKER_RE = /\n\.\.\. \[\d+ bytes elided by token-goat\]$/;
9823
+ var OWN_TRAILING_NOTICE_RE = /(?:\n(?:\[token-goat: output capped at ~\d+ tokens\]|\.\.\. \[\d+ bytes elided by token-goat\]))+$/;
9824
+ function splitOwnTrailingNotices(text) {
9825
+ const m = OWN_TRAILING_NOTICE_RE.exec(text);
9826
+ return m ? { body: text.slice(0, m.index), notices: m[0] } : { body: text, notices: "" };
9827
+ }
9597
9828
  var DIGITS_RE = /\d+/g;
9598
9829
  var CONTROL_CHAR_RE = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g;
9599
9830
  function utf8Len(s) {
@@ -10248,6 +10479,7 @@ function byteLength(s) {
10248
10479
  }
10249
10480
 
10250
10481
  // src/tool_filters/base.ts
10482
+ init_define_import_meta_env();
10251
10483
  var DEFAULT_MIN_NET_SAVINGS_BYTES = 100;
10252
10484
  function resolveMinNetSavingsBytes() {
10253
10485
  try {
@@ -10484,7 +10716,11 @@ ${body}`;
10484
10716
  }
10485
10717
  };
10486
10718
 
10719
+ // src/tool_filters/dispatch.ts
10720
+ init_define_import_meta_env();
10721
+
10487
10722
  // src/tool_filters/generic.ts
10723
+ init_define_import_meta_env();
10488
10724
  var GenericFilter = class extends ToolFilter {
10489
10725
  name = "generic";
10490
10726
  compress(stdout, stderr, _exitCode, _argv) {
@@ -10505,6 +10741,7 @@ ${errPart}` : errPart;
10505
10741
  };
10506
10742
 
10507
10743
  // src/tool_filters/go_test.ts
10744
+ init_define_import_meta_env();
10508
10745
  var TEST_RUN_RE = /^=== (RUN|PAUSE|CONT|NAME)\s/;
10509
10746
  var RACE_FENCE_RE = /^={10,}\s*$/;
10510
10747
  var RACE_WARNING_RE = /^WARNING: DATA RACE/;
@@ -10705,7 +10942,11 @@ var GoTestFilter = class extends ToolFilter {
10705
10942
  };
10706
10943
  var goTestFilter = new GoTestFilter();
10707
10944
 
10945
+ // src/tool_filters/ai_clis.ts
10946
+ init_define_import_meta_env();
10947
+
10708
10948
  // src/tool_filters/families.ts
10949
+ init_define_import_meta_env();
10709
10950
  function plural(n, suffix = "s") {
10710
10951
  return n === 1 ? "" : suffix;
10711
10952
  }
@@ -11082,10 +11323,10 @@ function makeLanguageFilter(cfg) {
11082
11323
  }
11083
11324
 
11084
11325
  // src/tool_filters/ai_clis.ts
11085
- var _GH_COPILOT_SPINNER_RE = /^\s*(?:Asking GitHub Copilot|Generating|Thinking|Fetching)\s*\.{0,3}\s*$/i;
11326
+ var _GH_COPILOT_SPINNER_RE = /^\s*(?:Asking GitHub Copilot|Generating|Thinking|Fetching)\s*(?:\.{1,3}\s*)?$/i;
11086
11327
  var _GH_COPILOT_BANNER_RE = /^\s*(?:Welcome to GitHub Copilot|Using GitHub Copilot|Authenticated as|GitHub Copilot\s+v\d+)/i;
11087
11328
  var _GH_COPILOT_DISCLAIMER_RE = /^\s*(?:Disclaimer:|This response was|GitHub Copilot|The commands?\s+(?:above|below)|Please review|Always review|Remember to|Note:|Tip:)/i;
11088
- var _AIDER_APPLYING_RE = /^\s*(?:Applying\s+edits?(?:\s+to\s+\S+)?|Applied\s+edit\s+to\s+\S+)\s*(?:\.{1,3})?\s*$/i;
11329
+ var _AIDER_APPLYING_RE = /^\s*(?:Applying\s+edits?(?:\s+to\s+\S+)?|Applied\s+edit\s+to\s+\S+)\s*(?:\.{1,3}\s*)?$/i;
11089
11330
  var _AIDER_TOKENS_RE = /^\s*Tokens:\s+\d[\d,]*\s+sent,\s+\d[\d,]*\s+received/i;
11090
11331
  var _AIDER_COST_RE = /^\s*Cost:\s+\$[\d.]+\s+message,\s+\$[\d.]+\s+session/i;
11091
11332
  var _AIDER_REPOMAP_RE = /^\s*(?:Repo-map:|Added\s+\S+\s+to\s+the\s+chat|Removed\s+\S+\s+from\s+the\s+chat|Loading\s+repo\s+map|Updating\s+repo\s+map|Scanning\s+repo\s+contents|Using\s+\d+\s+tokens\s+of\s+repo\s+map)/i;
@@ -11098,24 +11339,24 @@ var _GEMINI_BANNER_RE = /^\s*Gemini\s+CLI\s+v\d+/i;
11098
11339
  var _GEMINI_TOKEN_METER_RE = /^\s*(?:Token\s+usage|Context|Tokens):\s+[\d,]+\s*\/\s*[\d,]+/i;
11099
11340
  var _GEMINI_TOOL_SPINNER_RE = /^\s*[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏✓✗►✦]\s+(?:Call(?:ing|ed)|Execut(?:ing|ed)|Running)\s+\S+/;
11100
11341
  var _GEMINI_FOOTER_RE = /^\s*(?:Type\s+\/help|Press\s+Ctrl|Use\s+Ctrl|Tip:|Note:)/i;
11101
- var _GEMINI_THINKING_RE = /^\s*(?:Thinking|Generating|Processing)\s*\.{0,3}\s*$/i;
11342
+ var _GEMINI_THINKING_RE = /^\s*(?:Thinking|Generating|Processing)\s*(?:\.{1,3}\s*)?$/i;
11102
11343
  var _CLAUDE_CLI_MODEL_HDR_RE = /^\s*[◆◇►✦]\s+claude-/i;
11103
- var _CLAUDE_CLI_STATS_RE = /^\s*[↑↓⇑⇓]\s*\d[\d,]*\s*[↑↓⇑⇓]?\s*\d[\d,]*\s*tokens/i;
11344
+ var _CLAUDE_CLI_STATS_RE = /^\s*[↑↓⇑⇓]\s*\d[\d,]*(?:(?:\s*[↑↓⇑⇓]\s*|\s+)\d[\d,]*)?\s*tokens/i;
11104
11345
  var _CLAUDE_CLI_CONTEXT_RE = /^\s*(?:Context(?:\s+window)?|Token\s+limit):\s+[\d,]+\s*\/\s*[\d,]+/i;
11105
11346
  var _CLAUDE_CLI_FOOTER_RE = /^\s*(?:Press\s+Ctrl|Enter\s+\/|Type\s+\/|Use\s+Ctrl|Tip:|Note:)/i;
11106
- var _CLAUDE_CLI_SPINNER_RE = /^\s*[◎⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]\s+(?:Thinking|Generating|Processing|Running)\s*\.{0,3}\s*$/;
11347
+ var _CLAUDE_CLI_SPINNER_RE = /^\s*[◎⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]\s+(?:Thinking|Generating|Processing|Running)\s*(?:\.{1,3}\s*)?$/;
11107
11348
  var _CLAUDE_CLI_TOOL_LOG_RE = /^\s*(?:>\s+Using\s+tool:|✓\s+Tool\s+result:|◎\s+Tool:)/i;
11108
11349
  var _CLAUDE_CLI_SKIP_SUBCMDS = /* @__PURE__ */ new Set(["install", "update", "doctor", "config", "login", "logout"]);
11109
- var _CURSOR_STARTUP_RE = /^\s*(?:Extension\s+host\s+(?:started|starting)|Extension\s+'cursor[^']*'\s+activated|Starting\s+debug\s+adapter|Opening\s+folder\s*\.*\s*$|Restoring\s+(?:windows?|session)|Reusing\s+existing\s+extension\s+host|Connection\s+(?:established|to\s+remote)|Tunnel\s+(?:connected|connecting|status))/i;
11350
+ var _CURSOR_STARTUP_RE = /^\s*(?:Extension\s+host\s+(?:started|starting)|Extension\s+'cursor[^']*'\s+activated|Starting\s+debug\s+adapter|Opening\s+folder\s*(?:\.+\s*)?$|Restoring\s+(?:windows?|session)|Reusing\s+existing\s+extension\s+host|Connection\s+(?:established|to\s+remote)|Tunnel\s+(?:connected|connecting|status))/i;
11110
11351
  var _CURSOR_TELEMETRY_RE = /^\s*(?:Telemetry\s+is\s+(?:disabled|enabled)|Crash\s+reporter|Sending\s+telemetry|Analytics:)/i;
11111
11352
  var _CURSOR_BANNER_RE = /^\s*Cursor\s+v?\d+\.\d+/i;
11112
- var _WINDSURF_STARTUP_RE = /^\s*(?:Extension\s+host\s+(?:started|starting)|Extension\s+'\S+'\s+activated|Starting\s+debug\s+adapter|Opening\s+folder\s*\.*\s*$|Restoring\s+(?:windows?|session)|Reusing\s+existing\s+extension\s+host)/i;
11353
+ var _WINDSURF_STARTUP_RE = /^\s*(?:Extension\s+host\s+(?:started|starting)|Extension\s+'\S+'\s+activated|Starting\s+debug\s+adapter|Opening\s+folder\s*(?:\.+\s*)?$|Restoring\s+(?:windows?|session)|Reusing\s+existing\s+extension\s+host)/i;
11113
11354
  var _WINDSURF_CODEIUM_NOISE_RE = /^\s*(?:Codeium\s*(?::\s*)?(?:Activating|Activated|index(?:ing)?:?\s*loading|index\s+(?:loaded|ready)|Extension\s+loaded)|Connecting\s+to\s+Codeium\s+server|Authentication\s+status\s*:|Model\s+status\s*:|Codeium\s+(?:ready|connected|disconnected))/i;
11114
11355
  var _WINDSURF_BANNER_RE = /^\s*Windsurf\s+v?\d+\.\d+/i;
11115
11356
  var _WINDSURF_TELEMETRY_RE = /^\s*(?:Telemetry\s+is\s+(?:disabled|enabled)|Crash\s+reporter)/i;
11116
11357
  var _WINDSURF_CASCADE_STATUS_RE = /^\s*(?:Cascade\s*(?::\s*)?(?:connected|disconnected|ready|connecting|starting|model\s+loaded|indexing\s+workspace|context\s+limit|[a-z]+\.{3})|Cascade\s+v?\d+|AI\s+assistant\s+(?:ready|loaded|connecting))/i;
11117
11358
  var _WINDSURF_CASCADE_TOOL_RE = /^\s*Cascade\s+(?:is\s+)?(?:reading|writing|running|executed|modified|created|deleted)\s+/i;
11118
- var _WINDSURF_CASCADE_SPINNER_RE = /^\s*(?:Thinking|Generating|Cascade\s+is\s+thinking|Processing\s+request)\s*\.{0,3}\s*$/i;
11359
+ var _WINDSURF_CASCADE_SPINNER_RE = /^\s*(?:Thinking|Generating|Cascade\s+is\s+thinking|Processing\s+request)\s*(?:\.{1,3}\s*)?$/i;
11119
11360
  var _WINDSURF_CONTEXT_RE = /^\s*(?:Context(?:\s+window)?|Token\s+(?:usage|count))\s*:\s*[\d,]+\s*\/\s*[\d,]+/i;
11120
11361
  var _WINDSURF_WORKSPACE_RE = /^\s*(?:Loading\s+workspace|Indexing\s+workspace|Workspace\s+(?:indexed|ready|loading)|Scanning\s+files|File\s+watcher)/i;
11121
11362
  var _OPENCODE_BANNER_RE = /^\s*(?:Open[Cc]ode|opencode)\s+v?\d+\.\d+/i;
@@ -11136,10 +11377,10 @@ var _CLINE_BANNER_RE = /^\s*(?:Cline|claude-dev)\s+v\d+\.\d+/i;
11136
11377
  var _CLINE_TOKENS_RE = /^\s*Tokens\s*:\s*[\d,]+\s*\(/i;
11137
11378
  var _CLINE_COST_RE = /^\s*API\s+Cost\s*:\s*\$[\d.]+/i;
11138
11379
  var _CLINE_CONTEXT_RE = /^\s*Context\s+Window\s*:\s*[\d,]+\s*\/\s*[\d,]+\s+tokens/i;
11139
- var _CLINE_SPINNER_RE = /^\s*(?:Thinking|Processing|Streaming\s+response)\s*\.{0,3}\s*$/i;
11140
- var _CLINE_STARTUP_RE = /^\s*(?:Loading\s+workspace|Initializing\s+Cline|Starting\s+Cline)\s*\.{0,3}\s*$/i;
11380
+ var _CLINE_SPINNER_RE = /^\s*(?:Thinking|Processing|Streaming\s+response)\s*(?:\.{1,3}\s*)?$/i;
11381
+ var _CLINE_STARTUP_RE = /^\s*(?:Loading\s+workspace|Initializing\s+Cline|Starting\s+Cline)\s*(?:\.{1,3}\s*)?$/i;
11141
11382
  var _CLINE_MCP_STATUS_RE = /^\s*MCP\s+Server\s+['"]?\w/i;
11142
- var _CLINE_FILE_READ_RE = /^\s*Reading\s+file\s*:\s*\S+\s*\.{0,3}\s*$/i;
11383
+ var _CLINE_FILE_READ_RE = /^\s*Reading\s+file\s*:\s*\S+\s*(?:\.{1,3}\s*)?$/i;
11143
11384
  var _CLINE_WANTS_EXECUTE_RE = /^\s*Cline\s+wants\s+to\s+(?:execute|run|write|read|create|delete|use)\s*:/i;
11144
11385
  var _CODEX_SEPARATOR_RE = /^-{4,}$/;
11145
11386
  var _CODEX_MODEL_RE = /^model\s*:\s*(?<model>\S+)/i;
@@ -11402,6 +11643,7 @@ var AI_CLI_FILTERS = [
11402
11643
  ];
11403
11644
 
11404
11645
  // src/tool_filters/build.ts
11646
+ init_define_import_meta_env();
11405
11647
  var MAKE_RECURSE_RE = /^make\[\d+\]: (?:Entering|Leaving) directory/;
11406
11648
  var MAKE_PERCENT_RE = /^\[\s*\d+%\] (?:Building|Linking|Scanning|Generating|Installing|Compiling)\b/;
11407
11649
  var MAKE_ECHO_RE = /^\s*(?:echo|cc|gcc|clang|g\+\+)\b.*(?<![Ee]rror|[Ww]arning)/;
@@ -12887,6 +13129,7 @@ var BUILD_FILTERS = [
12887
13129
  ];
12888
13130
 
12889
13131
  // src/tool_filters/ci.ts
13132
+ init_define_import_meta_env();
12890
13133
  var _GH_RUN_PASS_STEP_RE = /^\s*[✓√]\s/;
12891
13134
  var _GH_RUN_FAIL_STEP_RE = /^\s*[X✗❌]\s|^\s*FAIL(:|ED|URE)\b|^\s*Error:\s/;
12892
13135
  var _GH_API_URL_SUFFIX = "_url";
@@ -13700,6 +13943,7 @@ var CI_FILTERS = [
13700
13943
  ];
13701
13944
 
13702
13945
  // src/tool_filters/cloud.ts
13946
+ init_define_import_meta_env();
13703
13947
  var _TF_REFRESH_RE = /^[a-z0-9_.[\]"-]+: (Refreshing state|Reading|Read complete|Still |Modifications complete)/;
13704
13948
  var _TF_PLAN_SUMMARY_RE = /^Plan: \d+ to (add|change|destroy|import)/;
13705
13949
  var _TF_NO_CHANGES_RE = /^No changes\.|^(?:This plan does nothing|Nothing to do\.)/i;
@@ -15124,6 +15368,7 @@ var CLOUD_FILTERS = [
15124
15368
  ];
15125
15369
 
15126
15370
  // src/tool_filters/shell_file.ts
15371
+ init_define_import_meta_env();
15127
15372
  var _GREP_COMPRESS_THRESHOLD = 30;
15128
15373
  var _GREP_MAX_FILE_LINES = 20;
15129
15374
  var GrepFilter = class extends ToolFilter {
@@ -16230,6 +16475,7 @@ var SHELL_FILE_FILTERS = [
16230
16475
  ];
16231
16476
 
16232
16477
  // src/tool_filters/languages.ts
16478
+ init_define_import_meta_env();
16233
16479
  var NODE_INTERNAL_FRAME_RE = /^\s{4}at\s+(?:node:|.+\s+\(node:)/;
16234
16480
  var NODE_MODULES_FRAME_RE = /^\s{4}at\s+.*[/\\]node_modules[/\\]/;
16235
16481
  var NodeFilter = class extends ToolFilter {
@@ -17212,7 +17458,7 @@ var erlangFilter = makeLanguageFilter({
17212
17458
  ]
17213
17459
  });
17214
17460
  var CRYSTAL_COMPILING_RE = /^\s*(?:Compiling\s+\S+|Linking\s+crystal\s+spec|crystal\s+spec\s+\S+\.cr\b)/i;
17215
- var CRYSTAL_SPEC_PASS_RE = /^\s*(?:\.\s*)+$|^\s*✓\s+.+\(\d+/i;
17461
+ var CRYSTAL_SPEC_PASS_RE = /^\s*(?:\.\s*)+$|^\s*✓\s+\S.*\(\d+/i;
17216
17462
  var CRYSTAL_DOT_PROGRESS_RE = /^\s*[.]+\s*$/;
17217
17463
  var CRYSTAL_SUMMARY_RE = /^\s*(?:Finished\s+in\s+[\d.]+\s+(?:second|millisecond)|\d+\s+example[s]?[,\s]|Pending:\s+\d+|\d+\s+failure[s]?|(?:All\s+)?\d+\s+spec[s]?\s+(?:passed|failed))/i;
17218
17464
  var CRYSTAL_FAILURE_HEADER_RE = /^\s*(?:Failures:|Errors:|\d+\)\s+\S)/i;
@@ -17255,7 +17501,7 @@ var crystalFilter = makeLanguageFilter({
17255
17501
  ]
17256
17502
  });
17257
17503
  var HASKELL_RESOLVING_RE = /^\s*(?:Resolving\s+dependencies|Downloading\s+\S+\s+from\s+Hackage|Downloading\s+\S+\s+\.\.\.|Fetching\s+package|Configuring\s+\S+\.\.\.|Preprocessing\s+\S+\s+for|Starting\s+to\s+install)/i;
17258
- var HASKELL_COMPILING_RE = /^\s*(?:\[\s*\d+\s+of\s+\d+\]\s+Compiling\s+\S+|Compiling\s+\S+(?:\s+\(\s*\S+,\s*\S+\))?\.\.\.?)/;
17504
+ var HASKELL_COMPILING_RE = /^\s*(?:\[\s*\d+\s+of\s+\d+\]\s+Compiling\s+\S+|Compiling\s+\S+(?:\s+\(\s*[^,\s]+,\s*\S+\))?\.\.\.?)/;
17259
17505
  var HASKELL_LINKING_RE = /^\s*(?:Linking\s+\S+|Building\s+all\s+executables|Building\s+library\s+for\s+|Building\s+executable|Installed\s+\S+(?:\s+\d+\.\d+)?)/i;
17260
17506
  var HASKELL_INSTALLING_RE = /^\s*(?:Installing\s+(?:library|executable)\s+in|Registering\s+library|Updating\s+package\s+list|Reading\s+available\s+packages)/i;
17261
17507
  var HASKELL_SUCCESS_RE = /^\s*(?:Completed\s+\d+\s+action|Build\s+completed|Finished\s+building\s+package|All\s+\d+\s+tests\s+passed|Test\s+suite\s+\S+:\s+PASS|\d+\s+out\s+of\s+\d+\s+test\s+suites\s+\(|Tests\s+complete\b)/i;
@@ -17307,7 +17553,7 @@ var ELM_DOT_PROGRESS_RE = /^\s*[.]+\s*$/;
17307
17553
  var ELM_DEPS_PROGRESS_RE = /^\s*(?:Building dependencies|Verifying\s+(?:dependencies|packages)|Updating\s+package\s+catalog|Solving\s+dependencies)/i;
17308
17554
  var ELM_COMPILING_RE = /^\s*(?:Compiling\s+\S+\.elm|Starting\s+compilation)/i;
17309
17555
  var ELM_SUCCESS_RE = /^\s*(?:Success!|Successfully\s+generated|Compilation\s+complete|Done!\s+Compiled\s+\d+)/i;
17310
- var ELM_ERROR_HEADER_RE = /^\s*--\s+[A-Z][A-Z0-9 _]+[A-Z0-9]\s*(?:-+|in\s+\S+)?\s*$/;
17556
+ var ELM_ERROR_HEADER_RE = /^\s*--\s+[A-Z][A-Z0-9 _]+[A-Z0-9]\s*(?:(?:-+|in\s+\S+)\s*)?$/;
17311
17557
  var ELM_ERROR_SUMMARY_RE = /^\s*(?:Detected\s+\d+\s+error|I\s+ran\s+into\s+\d+\s+problem|\d+\s+error[s]?\s+found)/i;
17312
17558
  var elmFilter = makeLanguageFilter({
17313
17559
  name: "elm",
@@ -17340,24 +17586,24 @@ var elmFilter = makeLanguageFilter({
17340
17586
  });
17341
17587
  var JULIA_PKG_RESOLVING_RE = (
17342
17588
  // eslint-disable-next-line no-control-regex
17343
- /^\s*(?:\x1b\[[0-9;]*m)?\s*(?:Resolving|Updating|Fetching|Precompiling|Downgrading|Upgrading|Cloning|Archiving)\s+/i
17589
+ /^\s*(?:\x1b\[[0-9;]*m\s*)?(?:Resolving|Updating|Fetching|Precompiling|Downgrading|Upgrading|Cloning|Archiving)\s+/i
17344
17590
  );
17345
17591
  var JULIA_PKG_DEP_LINE_RE = (
17346
17592
  // eslint-disable-next-line no-control-regex
17347
- /^\s*(?:\x1b\[[0-9;]*m)?\s*\[[0-9a-f]{8}\]\s+(?:[+\-↑↓~→⇒✓]|\w)/
17593
+ /^\s*(?:\x1b\[[0-9;]*m\s*)?\[[0-9a-f]{8}\]\s+(?:[+\-↑↓~→⇒✓]|\w)/
17348
17594
  );
17349
- var JULIA_PKG_INSTALLED_RE = /^\s*(?:\x1b\[[0-9;]*m)?\s*Installed\s+\S+\s+/i;
17595
+ var JULIA_PKG_INSTALLED_RE = /^\s*(?:\x1b\[[0-9;]*m\s*)?Installed\s+\S+\s+/i;
17350
17596
  var JULIA_PKG_BUILDING_RE = (
17351
17597
  // eslint-disable-next-line no-control-regex
17352
- /^\s*(?:\x1b\[[0-9;]*m)?\s*Building\s+\S+\s*(?:→|->|─+)?\s*/i
17598
+ /^\s*(?:\x1b\[[0-9;]*m\s*)?Building\s+\S+\s*(?:→|->|─+)?\s*/i
17353
17599
  );
17354
- var JULIA_PKG_STATUS_RE = /^\s*(?:\x1b\[[0-9;]*m)?\s*Status\s+`/i;
17600
+ var JULIA_PKG_STATUS_RE = /^\s*(?:\x1b\[[0-9;]*m\s*)?Status\s+`/i;
17355
17601
  var JULIA_TEST_SUMMARY_RE = /^\s*(?:Test\s+Summary:|Tests\s+run:|\d+\s+test[s]?\s+(?:passed|failed)|ALL_TESTS_PASS|Testing\s+\S+\s+done|No\s+tests\s+failed)/i;
17356
17602
  var JULIA_TEST_PASS_RE = /^\s*(?:✓|PASS:|Test\s+Passed)\s+/i;
17357
- var JULIA_TESTING_HEADER_RE = /^\s*(?:\x1b\[[0-9;]*m)?\s*Testing\s+\S+/i;
17603
+ var JULIA_TESTING_HEADER_RE = /^\s*(?:\x1b\[[0-9;]*m\s*)?Testing\s+\S+/i;
17358
17604
  var JULIA_PRECOMPILE_RE = (
17359
17605
  // eslint-disable-next-line no-control-regex
17360
- /^\s*(?:\x1b\[[0-9;]*m)?\s*\d+\s+(?:package[s]?\s+being\s+precompiled|dependency\s+precompil)/i
17606
+ /^\s*(?:\x1b\[[0-9;]*m\s*)?\d+\s+(?:package[s]?\s+being\s+precompiled|dependency\s+precompil)/i
17361
17607
  );
17362
17608
  var juliaFilter = makeLanguageFilter({
17363
17609
  name: "julia",
@@ -17454,6 +17700,7 @@ var LANGUAGE_FILTERS = [
17454
17700
  ];
17455
17701
 
17456
17702
  // src/tool_filters/misc.ts
17703
+ init_define_import_meta_env();
17457
17704
  var PW_PASS_RE = /^\s+[✓✔]\s/;
17458
17705
  var PW_DOWNLOAD_RE = /^\s*(Downloading|Downloaded|Installing)\s+\w|^\s*[\d.]+\s+[KMG]b\s+\[/i;
17459
17706
  var PlaywrightFilter = class _PlaywrightFilter extends ToolFilter {
@@ -18860,6 +19107,7 @@ var MISC_FILTERS = [
18860
19107
  ];
18861
19108
 
18862
19109
  // src/tool_filters/containers.ts
19110
+ init_define_import_meta_env();
18863
19111
  var _DOCKER_DIGEST_RE = /^\s*#\d+\s+(sha256:[a-f0-9]{8,}|resolve\s)/;
18864
19112
  var _DOCKER_PROGRESS_RE = /^\s*#\d+\s+\d+(?:\.\d+)?(?:MB|kB|GB)\s+\//;
18865
19113
  var _DOCKER_STEP_RE = /^\s*=>\s|^\s*#\d+\s+\[(internal|build|stage)/;
@@ -19530,6 +19778,7 @@ var CONTAINER_FILTERS = [
19530
19778
  ];
19531
19779
 
19532
19780
  // src/tool_filters/git.ts
19781
+ init_define_import_meta_env();
19533
19782
  var _GIT_VALUE_FLAGS = /* @__PURE__ */ new Set([
19534
19783
  "-m",
19535
19784
  "--message",
@@ -20571,6 +20820,7 @@ var GIT_FILTERS = [
20571
20820
  ];
20572
20821
 
20573
20822
  // src/tool_filters/linters.ts
20823
+ init_define_import_meta_env();
20574
20824
  var _ESLINT_LOC_RE = /^\s+\d+:\d+\s+(error|warning|info)\s/;
20575
20825
  var _ESLINT_FILE_RE = /^(?:\/|[A-Za-z]:|[a-zA-Z0-9_./-]+\.(?:js|jsx|ts|tsx|mjs|cjs|vue))/;
20576
20826
  var _ESLINT_SUMMARY_RE = /^[✖✗✘x×]\s+\d+\s+problem/;
@@ -21984,6 +22234,7 @@ var LINTER_FILTERS = [
21984
22234
  ];
21985
22235
 
21986
22236
  // src/tool_filters/package_managers.ts
22237
+ init_define_import_meta_env();
21987
22238
  function dedupLines(lines, maxPerKey = 1, keyFn = (l) => l.trim()) {
21988
22239
  const seen = /* @__PURE__ */ new Map();
21989
22240
  const out = [];
@@ -23055,6 +23306,7 @@ var PACKAGE_MANAGER_FILTERS = [
23055
23306
  ];
23056
23307
 
23057
23308
  // src/tool_filters/pytest.ts
23309
+ init_define_import_meta_env();
23058
23310
  var XDIST_PREFIX_RE = /^\[gw\d+\]\s*(?:\[\s*\d+%\]\s*)?/;
23059
23311
  var DOTS_RE = /^[.FxXEsS]+\s*(\[\s*\d+%\])?\s*$/;
23060
23312
  var BANNER_RE = /^(?:platform\s|cachedir:\s|rootdir:\s|plugins:\s|configfile:\s|bringing up\s|cacheprovider-)/;
@@ -23241,6 +23493,7 @@ var PytestFilter = class extends ToolFilter {
23241
23493
  var pytestFilter = new PytestFilter();
23242
23494
 
23243
23495
  // src/tool_filters/test_runners.ts
23496
+ init_define_import_meta_env();
23244
23497
  var jestFilter = makeNodeTestRunnerFilter({
23245
23498
  name: "jest",
23246
23499
  binaries: ["jest", "mocha", "ava", "tap"],
@@ -23258,12 +23511,26 @@ var jestFilter = makeNodeTestRunnerFilter({
23258
23511
  var vitestFilter = makeNodeTestRunnerFilter({
23259
23512
  name: "vitest",
23260
23513
  binaries: ["vitest"],
23261
- // File-level pass header carries a duration: `✓ src/x.test.ts (12ms)`.
23262
- passFileRe: /^\s*✓\s+\S.*\([\d.]+\s*\w+\)/,
23514
+ // File-level pass header carries a duration: `✓ src/x.test.ts (12ms)`. The ` > ` exclusion is
23515
+ // not decoration: a verbose per-test line whose test NAME happens to end in something shaped
23516
+ // like a duration (`... to the documented min (100ms) 1ms`) is otherwise claimed here, and gets
23517
+ // counted as a passing FILE. Both branches drop the line, so nothing is lost -- but the reported
23518
+ // count is wrong, and wrong in a way that depends on which reporter produced the run.
23519
+ passFileRe: /^\s*✓(?!.*\s>\s)\s+\S.*\([\d.]+\s*[a-zA-Z]\w*\)/,
23263
23520
  failFileRe: /^\s*(?:×|FAIL|✗|✘)\s+\S/,
23264
- summaryRe: /^(Test Files|Tests|Modules|Duration|Start at)[\s:]+\d/,
23265
- // Per-test tick is indented ≥2 spaces: ` ✓ should pass`.
23266
- testTickRe: /^\s{2,}✓\s/,
23521
+ // Real vitest right-aligns its summary labels, so every one of these arrives indented:
23522
+ // ` Tests 140 passed (140)`. Anchoring at `^` matched none of them. They survived only
23523
+ // by falling through to the keep-verbatim branch, which is not the same rule -- a summary line
23524
+ // reached while a fail block is open was swallowed into that block instead of ending it.
23525
+ summaryRe: /^\s*(Test Files|Tests|Modules|Duration|Start at)[\s:]+\d/,
23526
+ // Two shapes, because the reporter decides which one a passing test prints. The default
23527
+ // reporter indents a per-test tick under its file header (` ✓ should pass`). `--reporter=
23528
+ // verbose` prints one line per test at a single leading space, carrying the full
23529
+ // `file > describe > name` path instead: ` ✓ tests/x.test.ts > safeJoin > joins normally 28ms`.
23530
+ // Those lines match no rule at all today, so a verbose run compresses by nothing. The ` > `
23531
+ // is what separates them from a file-level header, which passFileRe claims first and which
23532
+ // never contains one.
23533
+ testTickRe: /^\s{2,}✓\s|^\s*✓\s.*\s>\s/,
23267
23534
  outputHdrRe: /^\s*stdout\s*\|/,
23268
23535
  outputNoun: "stdout",
23269
23536
  passFileNoun: "passing file"
@@ -23375,12 +23642,23 @@ function compressOutput(filter, stdout, stderr, exitCode, argv, opts = {}) {
23375
23642
  if (opts.maxBytes !== void 0) applyOpts.maxBytes = opts.maxBytes;
23376
23643
  return filter.apply(stdout, stderr, exitCode, argv, applyOpts);
23377
23644
  }
23645
+ function deliverCompressed(filter, stdout, stderr, exitCode, argv, opts = {}) {
23646
+ const compressed = compressOutput(filter, stdout, stderr, exitCode, argv, opts);
23647
+ const minNet = resolveMinNetSavingsBytes();
23648
+ const applied = compressed.worthApplying(minNet);
23649
+ const text = applied ? compressed.text : combineStreams(stdout, stderr);
23650
+ const marker = applied ? compressed.withMarker(minNet).slice(compressed.text.length) : "";
23651
+ return { applied, text, marker, compressed };
23652
+ }
23378
23653
  function filterByName(name) {
23379
23654
  if (name === "generic") return new GenericFilter();
23380
23655
  for (const f of TOOL_FILTERS) if (f.name === name) return f;
23381
23656
  return null;
23382
23657
  }
23383
23658
 
23659
+ // src/tool_filters/index.ts
23660
+ init_define_import_meta_env();
23661
+
23384
23662
  export {
23385
23663
  VERSION,
23386
23664
  dataDir,
@@ -23471,6 +23749,8 @@ export {
23471
23749
  validateEnumField,
23472
23750
  getLastConfigParseError,
23473
23751
  getLastProjectConfigParseError,
23752
+ PROJECT_LOCKED_SECTIONS,
23753
+ PROJECT_LOCKED_KEYS,
23474
23754
  lastProjectConfigLockedKeys,
23475
23755
  getProjectConfigInfo,
23476
23756
  resolveConfigKeyLayer,
@@ -23529,6 +23809,7 @@ export {
23529
23809
  _useRichStats,
23530
23810
  renderShortStats,
23531
23811
  renderStats2 as renderStats,
23812
+ compileCustomPatterns,
23532
23813
  redactSecrets,
23533
23814
  getToolName,
23534
23815
  getToolInput,
@@ -23584,17 +23865,21 @@ export {
23584
23865
  stripAnsiCodes,
23585
23866
  combineStreams,
23586
23867
  hasBareBackgroundOrNewline,
23868
+ splitOwnTrailingNotices,
23587
23869
  dedupeConsecutive,
23588
23870
  capTokens,
23589
23871
  shlexSplit,
23590
23872
  resolveMinNetSavingsBytes,
23591
23873
  isRewriteWorthwhile,
23592
23874
  compressedTokensSaved,
23875
+ CompressedOutput,
23593
23876
  ToolFilter,
23877
+ TOOL_FILTERS,
23594
23878
  dispatchArgv,
23595
23879
  selectFilter,
23596
23880
  detectFromCommand,
23597
23881
  compressOutput,
23882
+ deliverCompressed,
23598
23883
  filterByName
23599
23884
  };
23600
23885
  /*! Bundled license information: