token-goat 2.9.28 → 2.9.29

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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-2AWQ2R5X.mjs} +2 -2
  3. package/dist/{token-goat-chunk-5NNYIUGV.mjs → token-goat-chunk-2NNUA2LR.mjs} +4 -4
  4. package/dist/{token-goat-chunk-4RN64ZND.mjs → token-goat-chunk-2WOUYWLM.mjs} +2 -1
  5. package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-435UQTKD.mjs} +5 -3
  6. package/dist/{token-goat-chunk-6DQNNFJ6.mjs → token-goat-chunk-44BM7DDQ.mjs} +3 -3
  7. package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-52NSDWYY.mjs} +2 -2
  8. package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-67BNIKKO.mjs} +19 -16
  9. package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-6AK46ZT7.mjs} +2 -3
  10. package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-7CPMDFGB.mjs} +166 -40
  11. package/dist/token-goat-chunk-ASLWOQ3I.mjs +14 -0
  12. package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-BGYOZ6DO.mjs} +6 -4
  13. package/dist/{token-goat-chunk-JXK2HQXS.mjs → token-goat-chunk-C5YPNZKQ.mjs} +3 -3
  14. package/dist/{token-goat-chunk-MVSWBNMD.mjs → token-goat-chunk-CIQ2FTY3.mjs} +19 -14
  15. package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-D4ETHJD6.mjs} +6 -4
  16. package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-DNRPXHYH.mjs} +21 -17
  17. package/dist/{token-goat-chunk-YWSP6IU7.mjs → token-goat-chunk-DNSPXQXQ.mjs} +2 -2
  18. package/dist/token-goat-chunk-DPNLUJWB.mjs +220 -0
  19. package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-E4ZOJIZK.mjs} +10 -7
  20. package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-E5TK5DNO.mjs} +11 -4
  21. package/dist/{token-goat-chunk-MMLMALWK.mjs → token-goat-chunk-EUSDXRXU.mjs} +60 -12
  22. package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-FTP4U4QA.mjs} +12 -9
  23. package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-G23DWHV4.mjs} +17 -14
  24. package/dist/{token-goat-chunk-L7SDVGBT.mjs → token-goat-chunk-G7IWXCFF.mjs} +49 -23
  25. package/dist/{token-goat-chunk-NILVK7XM.mjs → token-goat-chunk-GLXRTTLE.mjs} +7 -5
  26. package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-H5J3C56Q.mjs} +35 -16
  27. package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-HNFZZHFW.mjs} +2 -2
  28. package/dist/{token-goat-chunk-CBMY2FGI.mjs → token-goat-chunk-HUYUHODZ.mjs} +572 -230
  29. package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
  30. package/dist/{token-goat-chunk-F7QZRIWM.mjs → token-goat-chunk-IVWI2OCK.mjs} +8 -30
  31. package/dist/{token-goat-chunk-GMOUBOX4.mjs → token-goat-chunk-JTKCQMQA.mjs} +37 -5
  32. package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-KOPIR3KZ.mjs} +12 -9
  33. package/dist/token-goat-chunk-L7H3U27L.mjs +35 -0
  34. package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-LZNBQTDK.mjs} +6 -4
  35. package/dist/token-goat-chunk-MELOKFDJ.mjs +199 -0
  36. package/dist/{token-goat-chunk-VWZKZPSR.mjs → token-goat-chunk-NMBWLRHW.mjs} +76 -39
  37. package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-O6I2XU4P.mjs} +12 -10
  38. package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-ONXH6NZ5.mjs} +1 -1
  39. package/dist/token-goat-chunk-ORNFMIER.mjs +295 -0
  40. package/dist/{token-goat-chunk-66LODAUT.mjs → token-goat-chunk-PGTH2U4C.mjs} +1 -1
  41. package/dist/{token-goat-chunk-SJEKA7Y2.mjs → token-goat-chunk-PKRWMHVP.mjs} +76 -64
  42. package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-PQ53BSCF.mjs} +1 -1
  43. package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-PYSUADX4.mjs} +2 -2
  44. package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-QO3LXVVR.mjs} +185 -104
  45. package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-RLP6J7WR.mjs} +6 -6
  46. package/dist/token-goat-chunk-RQGGMPCR.mjs +205 -0
  47. package/dist/{token-goat-chunk-6Z5ULNE5.mjs → token-goat-chunk-RTMVLHWX.mjs} +165 -60
  48. package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-S4VSXURL.mjs} +8 -6
  49. package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-SE6E4BKJ.mjs} +1 -1
  50. package/dist/token-goat-chunk-TCQANXYC.mjs +351 -0
  51. package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-TDUT2CL6.mjs} +7 -7
  52. package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-TGOXNAHW.mjs} +54 -112
  53. package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UA5BKWWQ.mjs} +1 -1
  54. package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-UXSXQQIY.mjs} +1 -1
  55. package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-VMFWNHGR.mjs} +79 -68
  56. package/dist/token-goat-chunk-VQ6F6T7X.mjs +36 -0
  57. package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-VZQEWRVH.mjs} +6 -4
  58. package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
  59. package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-XYWPOSCN.mjs} +57 -615
  60. package/dist/{token-goat-chunk-4JJBFT7V.mjs → token-goat-chunk-YAGLESS3.mjs} +8 -5
  61. package/dist/token-goat-chunk-YKSRAWUU.mjs +33 -0
  62. package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-YOOVFPTP.mjs} +2 -2
  63. package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
  64. package/dist/token-goat-chunk-Z6KBMOBI.mjs +53 -0
  65. package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-ZER6EAXZ.mjs} +3 -3
  66. package/dist/token-goat-hook-client.cjs +475 -0
  67. package/dist/token-goat-hook-client.mjs +26 -0
  68. package/dist/token-goat-hook.mjs +31 -27
  69. package/dist/token-goat.core.mjs +9 -44
  70. package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
  71. package/docs/cli.md +3 -2
  72. package/docs/install.md +16 -14
  73. package/package.json +1 -1
  74. package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
  75. package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
  76. package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
  77. package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
@@ -0,0 +1,53 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ init_define_import_meta_env
5
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
+
7
+ // src/env.ts
8
+ init_define_import_meta_env();
9
+ var FALSY_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
10
+ var TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
11
+ function envStr(key, defaultVal) {
12
+ const raw = process.env[key];
13
+ if (raw === void 0) return defaultVal;
14
+ const trimmed = raw.trim();
15
+ return trimmed === "" ? defaultVal : trimmed;
16
+ }
17
+ function envBool(key, defaultVal) {
18
+ const raw = process.env[key];
19
+ if (raw === void 0) return defaultVal;
20
+ const norm = raw.trim().toLowerCase();
21
+ if (norm === "") return defaultVal;
22
+ if (TRUTHY_ENV_VALUES.has(norm)) return true;
23
+ if (FALSY_ENV_VALUES.has(norm)) return false;
24
+ return defaultVal;
25
+ }
26
+ function envInt(key, defaultVal, min, max) {
27
+ const raw = process.env[key];
28
+ if (raw === void 0) return defaultVal;
29
+ const norm = raw.trim();
30
+ if (norm === "") return defaultVal;
31
+ if (!/^[+-]?\d+$/.test(norm)) return defaultVal;
32
+ const val = parseInt(norm, 10);
33
+ if (!Number.isFinite(val)) return defaultVal;
34
+ let clamped = val;
35
+ if (min !== void 0) clamped = Math.max(min, clamped);
36
+ if (max !== void 0) clamped = Math.min(max, clamped);
37
+ return clamped;
38
+ }
39
+ function envStrList(key, defaultVal, delimiter) {
40
+ const raw = process.env[key];
41
+ if (raw === void 0) return defaultVal;
42
+ const entries = raw.split(delimiter).map((s) => s.trim()).filter((s) => s !== "");
43
+ return entries.length > 0 ? entries : defaultVal;
44
+ }
45
+
46
+ export {
47
+ FALSY_ENV_VALUES,
48
+ TRUTHY_ENV_VALUES,
49
+ envStr,
50
+ envBool,
51
+ envInt,
52
+ envStrList
53
+ };
@@ -1,5 +1,8 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ deliveredOutputBytes
5
+ } from "./token-goat-chunk-L7H3U27L.mjs";
3
6
  import {
4
7
  PassthroughFilter,
5
8
  compressedTokensSaved,
@@ -7,21 +10,20 @@ import {
7
10
  dispatchArgv,
8
11
  filterByName,
9
12
  selectFilter
10
- } from "./token-goat-chunk-RJH64KQH.mjs";
13
+ } from "./token-goat-chunk-ZER6EAXZ.mjs";
11
14
  import {
12
15
  storeBashOutputSync
13
- } from "./token-goat-chunk-HXNAC4ZF.mjs";
16
+ } from "./token-goat-chunk-O6I2XU4P.mjs";
14
17
  import {
15
18
  capTokens,
16
19
  shlexSplit
17
- } from "./token-goat-chunk-4RN64ZND.mjs";
20
+ } from "./token-goat-chunk-2WOUYWLM.mjs";
18
21
  import {
19
22
  recordStat
20
- } from "./token-goat-chunk-MVSWBNMD.mjs";
23
+ } from "./token-goat-chunk-CIQ2FTY3.mjs";
21
24
  import {
22
- detectHarness,
23
25
  loadConfig
24
- } from "./token-goat-chunk-CC2PYJM7.mjs";
26
+ } from "./token-goat-chunk-TGOXNAHW.mjs";
25
27
  import {
26
28
  init_define_import_meta_env
27
29
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -31,28 +33,6 @@ init_define_import_meta_env();
31
33
  import { spawn, spawnSync } from "node:child_process";
32
34
  import * as os from "node:os";
33
35
 
34
- // src/delivery_cap.ts
35
- init_define_import_meta_env();
36
- var CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES = 2e4;
37
- var CLAUDE_CODE_PERSISTED_PREVIEW_BYTES = 2048;
38
- function bashOutputCapBytes(harness = detectHarness()) {
39
- return harness === "claudecode" ? CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES : null;
40
- }
41
- function clipToDeliveryCap(text, reserveBytes) {
42
- const cap = bashOutputCapBytes();
43
- const room = cap === null ? null : cap - reserveBytes;
44
- if (room === null || room <= 0 || Buffer.byteLength(text, "utf-8") <= room) return { text, clipped: false };
45
- const sliced = Buffer.from(text, "utf-8").subarray(0, room).toString("utf-8");
46
- const lastNewline = sliced.lastIndexOf("\n");
47
- return { text: lastNewline > 0 ? sliced.slice(0, lastNewline) : sliced, clipped: true };
48
- }
49
- function deliveredOutputBytes(originalBytes, harness) {
50
- const cap = bashOutputCapBytes(harness);
51
- if (cap === null) return Math.max(0, originalBytes);
52
- if (originalBytes <= cap) return Math.max(0, originalBytes);
53
- return CLAUDE_CODE_PERSISTED_PREVIEW_BYTES;
54
- }
55
-
56
36
  // src/shell.ts
57
37
  init_define_import_meta_env();
58
38
  import * as fs from "node:fs";
@@ -377,8 +357,6 @@ function recordSavings(result) {
377
357
  }
378
358
 
379
359
  export {
380
- clipToDeliveryCap,
381
- deliveredOutputBytes,
382
360
  canRunWrappedShell,
383
361
  canRunPowerShell,
384
362
  DEFAULT_TIMEOUT_SECONDS,
@@ -24,6 +24,7 @@ function climbsBetweenRungs(previous, elapsed) {
24
24
  }
25
25
  var PROBE_TERMINATORS = ["!", "a", "0", " ", "\uFFFF", "\n", "\u2028"];
26
26
  var PROBE_BUDGET_MS = 25;
27
+ var LINEAR_BY_CONSTRUCTION_EXCLUDES = /[*+?{|]/;
27
28
  var MAX_COUNTED_REPEAT = 8;
28
29
  var LITERAL_RUN_ATOM = /[^\\()[\]{}|^$*+?]/;
29
30
  var QUANTIFIER_AT = /^[*+?{]/;
@@ -38,6 +39,22 @@ function timeMatch(re, input) {
38
39
  again.test(input);
39
40
  return { ms: Math.min(first, performance.now() - restarted), matched };
40
41
  }
42
+ function confirmed(re, input, first) {
43
+ const again = timeMatch(re, input);
44
+ return again.ms < first.ms ? { ms: again.ms, matched: first.matched } : first;
45
+ }
46
+ function remeasuredForProjection(re, timings, inputs) {
47
+ const hi = timings.length - 1;
48
+ const hiLength = PROBE_LENGTHS[hi];
49
+ const lo = hiLength === void 0 ? -1 : PROBE_LENGTHS.findIndex((l) => l * 2 >= hiLength);
50
+ const out = [...timings];
51
+ for (const i of /* @__PURE__ */ new Set([lo, hi])) {
52
+ const input = inputs[i];
53
+ const ms = out[i];
54
+ if (input !== void 0 && ms !== void 0) out[i] = Math.min(ms, timeMatch(re, input).ms);
55
+ }
56
+ return out;
57
+ }
41
58
  var ESCAPE_SAMPLES = {
42
59
  s: " ",
43
60
  S: "a",
@@ -207,15 +224,24 @@ function climbsPastBudget(re) {
207
224
  const candidates = [tail, ...PROBE_TERMINATORS.filter((t) => t !== tail)];
208
225
  let swept;
209
226
  const timings = [];
227
+ const inputs = [];
210
228
  let previous;
211
229
  for (const length of PROBE_LENGTHS) {
212
230
  let failing;
213
231
  let last;
232
+ let failingInput = "";
233
+ let lastInput = "";
214
234
  const attempt = (candidate) => {
215
- const m = timeMatch(re, body(length) + candidate);
235
+ const input = body(length) + candidate;
236
+ let m = timeMatch(re, input);
237
+ if (m.ms > PROBE_BUDGET_MS) m = confirmed(re, input, m);
216
238
  last = m;
239
+ lastInput = input;
217
240
  if (m.ms > PROBE_BUDGET_MS) return "over-budget";
218
- if (!m.matched) failing = m;
241
+ if (!m.matched) {
242
+ failing = m;
243
+ failingInput = input;
244
+ }
219
245
  return m;
220
246
  };
221
247
  for (const candidate of swept === void 0 ? candidates : [swept, ...candidates]) {
@@ -235,12 +261,17 @@ function climbsPastBudget(re) {
235
261
  sweptMs += Date.now() - sweepStarted;
236
262
  }
237
263
  if (failing !== void 0) falsified = true;
238
- const elapsed = (failing ?? last).ms;
239
- if (climbsBetweenRungs(previous, elapsed)) return "ratio";
264
+ let elapsed = (failing ?? last).ms;
265
+ const rungInput = failing !== void 0 ? failingInput : lastInput;
266
+ if (climbsBetweenRungs(previous, elapsed)) {
267
+ elapsed = confirmed(re, rungInput, { ms: elapsed, matched: false }).ms;
268
+ if (climbsBetweenRungs(previous, elapsed)) return "ratio";
269
+ }
240
270
  previous = elapsed;
241
271
  timings.push(elapsed);
272
+ inputs.push(rungInput);
242
273
  }
243
- if (projectsPastBudget(timings)) return "projection";
274
+ if (projectsPastBudget(timings) && projectsPastBudget(remeasuredForProjection(re, timings, inputs))) return "projection";
244
275
  }
245
276
  if (!falsified && QUANTIFIED_GROUP.test(re.source)) return "unfalsifiable";
246
277
  return null;
@@ -353,6 +384,7 @@ function compileGuardedRegex(pattern, flags = "") {
353
384
  } catch (e) {
354
385
  return { ok: false, reason: e instanceof Error ? e.message : "is not a valid regular expression" };
355
386
  }
387
+ if (!LINEAR_BY_CONSTRUCTION_EXCLUDES.test(pattern)) return { ok: true, re };
356
388
  const cause = growsExponentially(re);
357
389
  if (cause !== null) {
358
390
  return {
@@ -25,11 +25,11 @@ import {
25
25
  extractSwift,
26
26
  extractThrift,
27
27
  extractWgsl
28
- } from "./token-goat-chunk-66LODAUT.mjs";
28
+ } from "./token-goat-chunk-PGTH2U4C.mjs";
29
29
  import {
30
30
  extractShellBannerHeading
31
- } from "./token-goat-chunk-D5ICEPSB.mjs";
32
- import "./token-goat-chunk-HUDC5GS5.mjs";
31
+ } from "./token-goat-chunk-VMFWNHGR.mjs";
32
+ import "./token-goat-chunk-435UQTKD.mjs";
33
33
  import {
34
34
  GENERIC_CLAUSE,
35
35
  assignBraceBlockSpans,
@@ -59,18 +59,21 @@ import {
59
59
  stripMultilineStringSpan,
60
60
  stripStringLiterals,
61
61
  stripXmlComments
62
- } from "./token-goat-chunk-M56BWPBN.mjs";
63
- import "./token-goat-chunk-CC2PYJM7.mjs";
64
- import "./token-goat-chunk-EEIDFMEM.mjs";
65
- import "./token-goat-chunk-OSUFN2FV.mjs";
62
+ } from "./token-goat-chunk-7CPMDFGB.mjs";
63
+ import "./token-goat-chunk-TGOXNAHW.mjs";
64
+ import "./token-goat-chunk-XB5KKOCG.mjs";
65
+ import "./token-goat-chunk-YZAAZU2S.mjs";
66
+ import "./token-goat-chunk-IVE6U7KV.mjs";
66
67
  import {
67
68
  countContentLines,
68
69
  escapeRegExp,
69
70
  pushAll
70
- } from "./token-goat-chunk-L45ZQRT7.mjs";
71
+ } from "./token-goat-chunk-XYWPOSCN.mjs";
72
+ import "./token-goat-chunk-TCQANXYC.mjs";
71
73
  import "./token-goat-chunk-NMTKNYGF.mjs";
74
+ import "./token-goat-chunk-MELOKFDJ.mjs";
72
75
  import "./token-goat-chunk-Y4AFKTHK.mjs";
73
- import "./token-goat-chunk-GMOUBOX4.mjs";
76
+ import "./token-goat-chunk-JTKCQMQA.mjs";
74
77
  import {
75
78
  init_define_import_meta_env
76
79
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -0,0 +1,35 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ detectHarness
5
+ } from "./token-goat-chunk-TGOXNAHW.mjs";
6
+ import {
7
+ init_define_import_meta_env
8
+ } from "./token-goat-chunk-A37V4PBF.mjs";
9
+
10
+ // src/delivery_cap.ts
11
+ init_define_import_meta_env();
12
+ var CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES = 2e4;
13
+ var CLAUDE_CODE_PERSISTED_PREVIEW_BYTES = 2048;
14
+ function bashOutputCapBytes(harness = detectHarness()) {
15
+ return harness === "claudecode" ? CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES : null;
16
+ }
17
+ function clipToDeliveryCap(text, reserveBytes) {
18
+ const cap = bashOutputCapBytes();
19
+ const room = cap === null ? null : cap - reserveBytes;
20
+ if (room === null || room <= 0 || Buffer.byteLength(text, "utf-8") <= room) return { text, clipped: false };
21
+ const sliced = Buffer.from(text, "utf-8").subarray(0, room).toString("utf-8");
22
+ const lastNewline = sliced.lastIndexOf("\n");
23
+ return { text: lastNewline > 0 ? sliced.slice(0, lastNewline) : sliced, clipped: true };
24
+ }
25
+ function deliveredOutputBytes(originalBytes, harness) {
26
+ const cap = bashOutputCapBytes(harness);
27
+ if (cap === null) return Math.max(0, originalBytes);
28
+ if (originalBytes <= cap) return Math.max(0, originalBytes);
29
+ return CLAUDE_CODE_PERSISTED_PREVIEW_BYTES;
30
+ }
31
+
32
+ export {
33
+ clipToDeliveryCap,
34
+ deliveredOutputBytes
35
+ };
@@ -6,14 +6,16 @@ import {
6
6
  pptxOutline,
7
7
  pptxSlideText,
8
8
  pptxTextGrep
9
- } from "./token-goat-chunk-Q4S3UQGO.mjs";
10
- import "./token-goat-chunk-UBUKHVYW.mjs";
9
+ } from "./token-goat-chunk-HNFZZHFW.mjs";
10
+ import "./token-goat-chunk-UXSXQQIY.mjs";
11
11
  import "./token-goat-chunk-XTQAOTSO.mjs";
12
12
  import "./token-goat-chunk-AH6QILZM.mjs";
13
- import "./token-goat-chunk-L45ZQRT7.mjs";
13
+ import "./token-goat-chunk-XYWPOSCN.mjs";
14
+ import "./token-goat-chunk-TCQANXYC.mjs";
14
15
  import "./token-goat-chunk-NMTKNYGF.mjs";
16
+ import "./token-goat-chunk-MELOKFDJ.mjs";
15
17
  import "./token-goat-chunk-Y4AFKTHK.mjs";
16
- import "./token-goat-chunk-GMOUBOX4.mjs";
18
+ import "./token-goat-chunk-JTKCQMQA.mjs";
17
19
  import "./token-goat-chunk-A37V4PBF.mjs";
18
20
  export {
19
21
  pptxAllSlidesText,
@@ -0,0 +1,199 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ init_define_import_meta_env
5
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
+
7
+ // src/version.ts
8
+ init_define_import_meta_env();
9
+ import { createRequire } from "node:module";
10
+ function readManifest() {
11
+ if (true) return JSON.parse('{"version":"2.9.29","name":"token-goat","bugs":{"url":"https://github.com/DFKHelper/token-goat/issues"}}');
12
+ try {
13
+ return createRequire(import.meta.url)("../package.json");
14
+ } catch {
15
+ return {};
16
+ }
17
+ }
18
+ var manifest = readManifest();
19
+ var VERSION = manifest.version ?? "0.0.0";
20
+ var PACKAGE_NAME = manifest.name !== void 0 && manifest.name !== "" ? manifest.name : "token-goat";
21
+ var ISSUES_URL = manifest.bugs?.url !== void 0 && manifest.bugs.url !== "" ? manifest.bugs.url : "https://github.com/DFKHelper/token-goat/issues";
22
+ var SUPPORT_EMAIL = "token-goat@dfkhelper.com";
23
+ function supportRequestLine(what) {
24
+ return `To ask for ${what} support, open an issue at ${ISSUES_URL} or email ${SUPPORT_EMAIL}.`;
25
+ }
26
+
27
+ // src/constants.ts
28
+ init_define_import_meta_env();
29
+ import * as fs from "node:fs";
30
+ import * as os from "node:os";
31
+ import * as path from "node:path";
32
+ function safeEnvDir(value) {
33
+ const stripped = value.trim();
34
+ if (stripped === "") return void 0;
35
+ if (!path.isAbsolute(stripped)) return void 0;
36
+ if (process.platform === "win32") {
37
+ const root = path.parse(stripped).root;
38
+ if (root === "" || root === "\\" || root === "/") return void 0;
39
+ }
40
+ return stripped;
41
+ }
42
+ function dataDirForHome(homeDir) {
43
+ const platform = process.platform;
44
+ if (platform === "win32") {
45
+ return path.join(homeDir, "AppData", "Local", "dfk-helper", "token-goat");
46
+ }
47
+ if (platform === "darwin") {
48
+ return path.join(homeDir, "Library", "Application Support", "token-goat");
49
+ }
50
+ return path.join(homeDir, ".local", "share", "token-goat");
51
+ }
52
+ function homeFallbackOrGuard() {
53
+ const inVitest = process.env["VITEST_WORKER_ID"] !== void 0 || process.env["VITEST"] === "true";
54
+ if (inVitest && process.env["VITEST_ALLOW_REAL_DATA_DIR"] !== "1") {
55
+ throw new Error(
56
+ "token-goat: refusing to resolve DATA_DIR against the real home directory inside a Vitest worker (LOCALAPPDATA/XDG_DATA_HOME is unset). This would read or write the developer's real global.db/config.toml. Set LOCALAPPDATA/XDG_DATA_HOME explicitly for this process, or VITEST_ALLOW_REAL_DATA_DIR=1 if this is an intentional mocked-home test."
57
+ );
58
+ }
59
+ return dataDirForHome(os.homedir());
60
+ }
61
+ function defaultDataDir() {
62
+ const platform = process.platform;
63
+ if (platform === "win32") {
64
+ const raw = process.env["LOCALAPPDATA"] ?? "";
65
+ const base2 = raw ? safeEnvDir(raw) : void 0;
66
+ if (base2 !== void 0) {
67
+ return path.join(base2, "dfk-helper", "token-goat");
68
+ }
69
+ return homeFallbackOrGuard();
70
+ }
71
+ if (platform === "darwin") {
72
+ const raw = process.env["XDG_DATA_HOME"] ?? "";
73
+ const base2 = raw ? safeEnvDir(raw) : void 0;
74
+ if (base2 !== void 0) {
75
+ return path.join(base2, "token-goat");
76
+ }
77
+ return homeFallbackOrGuard();
78
+ }
79
+ const xdg = process.env["XDG_DATA_HOME"] ?? "";
80
+ const base = xdg ? safeEnvDir(xdg) : void 0;
81
+ if (base !== void 0) {
82
+ return path.join(base, "token-goat");
83
+ }
84
+ return homeFallbackOrGuard();
85
+ }
86
+ var DATA_DIR = defaultDataDir();
87
+ function dataDir() {
88
+ return DATA_DIR;
89
+ }
90
+ var dataDirHardened = false;
91
+ function ensureDataDirPrivate() {
92
+ if (dataDirHardened) return;
93
+ try {
94
+ fs.mkdirSync(path.dirname(DATA_DIR), { recursive: true });
95
+ fs.mkdirSync(DATA_DIR, { recursive: true, mode: 448 });
96
+ if (process.platform !== "win32") {
97
+ const current = fs.statSync(DATA_DIR).mode & 511;
98
+ if ((current & 63) !== 0) fs.chmodSync(DATA_DIR, current & 448);
99
+ }
100
+ dataDirHardened = true;
101
+ } catch {
102
+ }
103
+ }
104
+ function tokenGoatHome() {
105
+ const override = safeEnvDir(process.env["TOKEN_GOAT_HOME"] ?? "");
106
+ if (override !== void 0) return override;
107
+ return path.join(os.homedir(), ".token-goat");
108
+ }
109
+ var hardenedHomes = /* @__PURE__ */ new Set();
110
+ function ensureHomeDirPrivate() {
111
+ const home = tokenGoatHome();
112
+ if (hardenedHomes.has(home)) return;
113
+ try {
114
+ fs.mkdirSync(path.dirname(home), { recursive: true });
115
+ fs.mkdirSync(home, { recursive: true, mode: 448 });
116
+ if (process.platform !== "win32") {
117
+ const current = fs.statSync(home).mode & 511;
118
+ if ((current & 63) !== 0) fs.chmodSync(home, current & 448);
119
+ }
120
+ hardenedHomes.add(home);
121
+ } catch {
122
+ }
123
+ }
124
+ function isUnderRoot(child, parent) {
125
+ const rel = path.relative(parent, child);
126
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
127
+ }
128
+ function isTokenGoatStorage(p) {
129
+ return isUnderRoot(p, DATA_DIR) || isUnderRoot(p, tokenGoatHome());
130
+ }
131
+ function ensureStorageRootPrivate(dir) {
132
+ if (isUnderRoot(dir, DATA_DIR)) ensureDataDirPrivate();
133
+ if (isUnderRoot(dir, tokenGoatHome())) ensureHomeDirPrivate();
134
+ }
135
+ function globalDbPath() {
136
+ return path.join(DATA_DIR, "global.db");
137
+ }
138
+ function configPath() {
139
+ return path.join(DATA_DIR, "config.toml");
140
+ }
141
+ var PROJECT_CONFIG_FILENAME = ".token-goat.toml";
142
+ function projectConfigPath(projectRoot) {
143
+ return path.join(projectRoot, PROJECT_CONFIG_FILENAME);
144
+ }
145
+ var ENV_KEYS = {
146
+ COMPACT_ASSIST: "TOKEN_GOAT_COMPACT_ASSIST",
147
+ COMPACT_ASSIST_LEGACY: "TOKENWISE_COMPACT_ASSIST",
148
+ BASH_COMPRESS: "TOKEN_GOAT_BASH_COMPRESS",
149
+ SESSION_BRIEF: "TOKEN_GOAT_SESSION_BRIEF",
150
+ SKILL_PRESERVATION: "TOKEN_GOAT_SKILL_PRESERVATION",
151
+ ORPHAN_SWEEP: "TOKEN_GOAT_ORPHAN_SWEEP",
152
+ HINT_BUDGET: "TOKEN_GOAT_HINT_BUDGET",
153
+ HINT_JSON_SIDECAR: "TOKEN_GOAT_HINT_JSON_SIDECAR",
154
+ BASH_DEDUP_MIN_BYTES: "TOKEN_GOAT_BASH_DEDUP_MIN_BYTES",
155
+ WEB_DEDUP_MIN_BYTES: "TOKEN_GOAT_WEB_DEDUP_MIN_BYTES",
156
+ GREP_DEDUP_MIN_MATCHES: "TOKEN_GOAT_GREP_DEDUP_MIN_MATCHES",
157
+ GLOB_DEDUP_MIN_MATCHES: "TOKEN_GOAT_GLOB_DEDUP_MIN_MATCHES",
158
+ LARGE_READ_BYTES: "TOKEN_GOAT_LARGE_READ_BYTES",
159
+ REPOMAP_COMPACT_THRESHOLD: "TOKEN_GOAT_REPOMAP_COMPACT_THRESHOLD",
160
+ WEB_CACHE_MAX_FILES: "TOKEN_GOAT_WEB_CACHE_MAX_FILES",
161
+ WEB_CACHE_MAX_BYTES: "TOKEN_GOAT_WEB_CACHE_MAX_BYTES",
162
+ WEB_COMPRESS: "TOKEN_GOAT_WEB_COMPRESS",
163
+ BASH_CACHE_MIN_BYTES: "TOKEN_GOAT_BASH_CACHE_MIN_BYTES",
164
+ BASH_CACHE_MAX_FILES: "TOKEN_GOAT_BASH_CACHE_MAX_FILES",
165
+ BASH_CACHE_MAX_BYTES: "TOKEN_GOAT_BASH_CACHE_MAX_BYTES",
166
+ BASH_CACHE_MAX_BYTES_PER_OUTPUT: "TOKEN_GOAT_BASH_CACHE_MAX_BYTES_PER_OUTPUT",
167
+ WORKER_WATCHDOG: "TOKEN_GOAT_WORKER_WATCHDOG",
168
+ WORKER_MAX_POOL: "TOKEN_GOAT_WORKER_MAX_POOL",
169
+ COMPRESS_PROFILE: "TOKEN_GOAT_COMPRESS_PROFILE",
170
+ SKILL_COMPRESS: "TOKEN_GOAT_SKILL_COMPRESS",
171
+ SERVE_DIFF_ON_REREAD: "TOKEN_GOAT_SERVE_DIFF_ON_REREAD",
172
+ ELIDE_SERVED_LINES: "TOKEN_GOAT_ELIDE_SERVED_LINES",
173
+ OVERFLOW_GUARD: "TOKEN_GOAT_OVERFLOW_GUARD",
174
+ OVERFLOW_MAX_TOKENS: "TOKEN_GOAT_OVERFLOW_MAX_TOKENS",
175
+ HARNESS_OVERRIDE: "TOKEN_GOAT_HARNESS_OVERRIDE",
176
+ RECONCILE: "TOKEN_GOAT_RECONCILE",
177
+ RECONCILE_BUDGET_MS: "TOKEN_GOAT_RECONCILE_BUDGET_MS",
178
+ MCP_TOOLS: "TOKEN_GOAT_MCP_TOOLS"
179
+ };
180
+ var SYMBOL_BODY_CHAR_CAP = 128 * 1024;
181
+ var SKELETON_SYMBOL_CAP = 5e3;
182
+
183
+ export {
184
+ VERSION,
185
+ PACKAGE_NAME,
186
+ supportRequestLine,
187
+ dataDirForHome,
188
+ dataDir,
189
+ ensureDataDirPrivate,
190
+ tokenGoatHome,
191
+ isTokenGoatStorage,
192
+ ensureStorageRootPrivate,
193
+ globalDbPath,
194
+ configPath,
195
+ projectConfigPath,
196
+ ENV_KEYS,
197
+ SYMBOL_BODY_CHAR_CAP,
198
+ SKELETON_SYMBOL_CAP
199
+ };