token-goat 2.6.32 → 2.6.34

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 (35) hide show
  1. package/README.md +24 -1
  2. package/dist/{token-goat-chunk-5EXIMDHA.mjs → token-goat-chunk-7FWBSPCT.mjs} +1573 -386
  3. package/dist/token-goat-chunk-AEX54RUZ.mjs +11 -0
  4. package/dist/{token-goat-chunk-3KW5C2KQ.mjs → token-goat-chunk-AO2QD2AG.mjs} +0 -4
  5. package/dist/{token-goat-chunk-TBCLQTPG.mjs → token-goat-chunk-CKRATWCJ.mjs} +7 -7
  6. package/dist/{token-goat-chunk-X5OPORR4.mjs → token-goat-chunk-CN7GUPX6.mjs} +1258 -1769
  7. package/dist/{token-goat-hook-chunk-TKXOXN4J.mjs → token-goat-chunk-DG53MVNJ.mjs} +2 -98
  8. package/dist/{token-goat-chunk-DFBD2FFU.mjs → token-goat-chunk-FRMEOIRU.mjs} +365 -139
  9. package/dist/{token-goat-chunk-YWYITDOS.mjs → token-goat-chunk-G6XLWJWI.mjs} +2 -5
  10. package/dist/{token-goat-chunk-RD6O3PJU.mjs → token-goat-chunk-GXBPEQR2.mjs} +3699 -3341
  11. package/dist/{token-goat-chunk-DNEPSN3P.mjs → token-goat-chunk-I6EQH27G.mjs} +4 -7
  12. package/dist/{token-goat-hook-chunk-Q5URQRIF.mjs → token-goat-chunk-IYYQOPY4.mjs} +811 -79
  13. package/dist/{token-goat-chunk-W3MX4LQV.mjs → token-goat-chunk-L7QLEVO7.mjs} +6 -9
  14. package/dist/{token-goat-chunk-O7TGKV5I.mjs → token-goat-chunk-OA3GFKP2.mjs} +23 -24
  15. package/dist/{token-goat-chunk-GWZJ5SI2.mjs → token-goat-chunk-WA2ER6TZ.mjs} +7 -32
  16. package/dist/{token-goat-hook-chunk-VHZECEQD.mjs → token-goat-hook-chunk-2ISZ4AZR.mjs} +7 -32
  17. package/dist/{token-goat-chunk-4M7PSAO3.mjs → token-goat-hook-chunk-3QYSN4QV.mjs} +2 -98
  18. package/dist/{token-goat-hook-chunk-LFYT4DLB.mjs → token-goat-hook-chunk-6C5RN3CM.mjs} +23 -24
  19. package/dist/{token-goat-hook-chunk-WBTHUYJP.mjs → token-goat-hook-chunk-6QTWMSRO.mjs} +1221 -1730
  20. package/dist/token-goat-hook-chunk-ATEGFQAU.mjs +23 -0
  21. package/dist/{token-goat-hook-chunk-DJZGX27J.mjs → token-goat-hook-chunk-BU5OFDGQ.mjs} +363 -138
  22. package/dist/{token-goat-hook-chunk-J2ZK2FYW.mjs → token-goat-hook-chunk-BUOCULAM.mjs} +0 -4
  23. package/dist/{token-goat-hook-chunk-DHW6SRHR.mjs → token-goat-hook-chunk-CNLMPHXT.mjs} +1569 -382
  24. package/dist/{token-goat-hook-chunk-6NF4WM2U.mjs → token-goat-hook-chunk-I5VM5PO5.mjs} +3700 -3342
  25. package/dist/{token-goat-chunk-N53GXI2Z.mjs → token-goat-hook-chunk-KGLMNOGD.mjs} +811 -79
  26. package/dist/{token-goat-hook-chunk-TBJ5PUPQ.mjs → token-goat-hook-chunk-OQML5EMA.mjs} +6 -9
  27. package/dist/{token-goat-hook-chunk-UXD3B4OY.mjs → token-goat-hook-chunk-QTZ6YUMQ.mjs} +4 -7
  28. package/dist/token-goat-hook-chunk-RFRLWOQH.mjs +11 -0
  29. package/dist/{token-goat-hook-chunk-PCP4W65Z.mjs → token-goat-hook-chunk-XUMIVYEN.mjs} +2 -5
  30. package/dist/token-goat-hook.mjs +7 -12
  31. package/dist/token-goat.core.mjs +7 -10
  32. package/package.json +20 -40
  33. package/dist/token-goat-chunk-3UOG7PSZ.mjs +0 -63
  34. package/dist/token-goat-hook-chunk-ANFXTEQO.mjs +0 -23
  35. package/dist/token-goat-hook-chunk-K33JMLL7.mjs +0 -63
@@ -2,17 +2,13 @@ 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-hook-chunk-J2ZK2FYW.mjs";
6
- import {
7
- init_define_import_meta_env
8
- } from "./token-goat-hook-chunk-K33JMLL7.mjs";
5
+ } from "./token-goat-hook-chunk-BUOCULAM.mjs";
9
6
 
10
7
  // src/version.ts
11
- init_define_import_meta_env();
12
8
  import { createRequire } from "node:module";
13
9
  function resolveVersion() {
14
10
  if (true) {
15
- return "2.6.32";
11
+ return "2.6.34";
16
12
  }
17
13
  const require2 = createRequire(import.meta.url);
18
14
  const pkg = require2("../package.json");
@@ -21,7 +17,6 @@ function resolveVersion() {
21
17
  var VERSION = resolveVersion();
22
18
 
23
19
  // src/constants.ts
24
- init_define_import_meta_env();
25
20
  import * as fs from "node:fs";
26
21
  import * as os from "node:os";
27
22
  import * as path from "node:path";
@@ -137,7 +132,6 @@ var ENV_KEYS = {
137
132
  var SYMBOL_BODY_CHAR_CAP = 128 * 1024;
138
133
 
139
134
  // src/bridges/registry.ts
140
- init_define_import_meta_env();
141
135
  var KNOWN_HARNESS_NAMES = /* @__PURE__ */ new Set([
142
136
  "claudecode",
143
137
  "codex",
@@ -149,6 +143,7 @@ var KNOWN_HARNESS_NAMES = /* @__PURE__ */ new Set([
149
143
  "copilot_cli",
150
144
  "grok",
151
145
  "qwen",
146
+ "kimi",
152
147
  "generic"
153
148
  ]);
154
149
  function detectHarness() {
@@ -199,7 +194,6 @@ function resetHarnessCache() {
199
194
  registerReset(resetHarnessCache);
200
195
 
201
196
  // src/paths.ts
202
- init_define_import_meta_env();
203
197
  import * as fs2 from "node:fs";
204
198
  import * as path2 from "node:path";
205
199
  var WSL_PATH_RE = /^\/mnt\/([a-zA-Z])\/(.*)$/s;
@@ -294,9 +288,20 @@ function safeJoin(base, ...parts) {
294
288
  }
295
289
  return path2.join(base, ...parts);
296
290
  }
291
+ function displaySafeText(text) {
292
+ return text.replace(new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cf}", "gu"), (ch) => {
293
+ if (ch === "\n") return "\\n";
294
+ if (ch === "\r") return "\\r";
295
+ if (ch === " ") return "\\t";
296
+ const code = ch.codePointAt(0) ?? 0;
297
+ return code <= 255 ? "\\x" + code.toString(16).padStart(2, "0") : "\\u" + code.toString(16).padStart(4, "0");
298
+ });
299
+ }
300
+ function displaySafePath(p) {
301
+ return displaySafeText(p);
302
+ }
297
303
 
298
304
  // src/util.ts
299
- init_define_import_meta_env();
300
305
  import { spawn, spawnSync } from "node:child_process";
301
306
  import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync, renameSync, statSync as statSync2, unlinkSync, writeFileSync, writeSync } from "node:fs";
302
307
  import * as path3 from "node:path";
@@ -732,6 +737,11 @@ function countNoun(count, singular, plural = `${singular}s`) {
732
737
  function excludeTestsHiddenNote(count) {
733
738
  return `${count} in test ${count === 1 ? "file" : "files"} hidden by --exclude-tests`;
734
739
  }
740
+ function countContentLines(content) {
741
+ if (content === "") return 0;
742
+ const n = content.split("\n").length;
743
+ return content.endsWith("\n") ? n - 1 : n;
744
+ }
735
745
  function escapeRegExp(s) {
736
746
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
737
747
  }
@@ -908,9 +918,74 @@ function packageNameDistance(a, b, cap = 3) {
908
918
  function suggestPackageNames(query, names) {
909
919
  return [...new Set(names)].map((n) => ({ n, d: packageNameDistance(query.toLowerCase(), n.toLowerCase()) })).filter((x) => x.d <= 3).sort((a, b) => a.d - b.d).slice(0, 5).map((x) => x.n);
910
920
  }
921
+ function detectSourceEncoding(buf) {
922
+ if (buf.length >= 4) {
923
+ if (buf[0] === 255 && buf[1] === 254 && buf[2] === 0 && buf[3] === 0) return "utf32le";
924
+ if (buf[0] === 0 && buf[1] === 0 && buf[2] === 254 && buf[3] === 255) return "utf32be";
925
+ }
926
+ if (buf.length >= 2) {
927
+ if (buf[0] === 255 && buf[1] === 254) return "utf16le";
928
+ if (buf[0] === 254 && buf[1] === 255) return "utf16be";
929
+ }
930
+ if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) return "utf8-bom";
931
+ return "utf8";
932
+ }
933
+ function decodeSource(buf) {
934
+ switch (detectSourceEncoding(buf)) {
935
+ case "utf32le":
936
+ return decodeUtf32(buf.subarray(4), true);
937
+ case "utf32be":
938
+ return decodeUtf32(buf.subarray(4), false);
939
+ case "utf16le":
940
+ return buf.subarray(2).toString("utf16le");
941
+ case "utf16be":
942
+ return swap16(buf.subarray(2)).toString("utf16le");
943
+ case "utf8-bom":
944
+ return buf.subarray(3).toString("utf8");
945
+ default:
946
+ return buf.toString("utf8");
947
+ }
948
+ }
949
+ function encodeSource(text, encoding) {
950
+ switch (encoding) {
951
+ case "utf32le":
952
+ return Buffer.concat([Buffer.from([255, 254, 0, 0]), encodeUtf32(text, true)]);
953
+ case "utf32be":
954
+ return Buffer.concat([Buffer.from([0, 0, 254, 255]), encodeUtf32(text, false)]);
955
+ case "utf16le":
956
+ return Buffer.concat([Buffer.from([255, 254]), Buffer.from(text, "utf16le")]);
957
+ case "utf16be":
958
+ return Buffer.concat([Buffer.from([254, 255]), swap16(Buffer.from(text, "utf16le"))]);
959
+ case "utf8-bom":
960
+ return Buffer.concat([Buffer.from([239, 187, 191]), Buffer.from(text, "utf8")]);
961
+ default:
962
+ return Buffer.from(text, "utf8");
963
+ }
964
+ }
965
+ function swap16(buf) {
966
+ const out = Buffer.from(buf);
967
+ return out.subarray(0, out.length - out.length % 2).swap16();
968
+ }
969
+ function decodeUtf32(buf, littleEndian) {
970
+ const points = [];
971
+ for (let i = 0; i + 4 <= buf.length; i += 4) {
972
+ const cp = littleEndian ? buf.readUInt32LE(i) : buf.readUInt32BE(i);
973
+ points.push(cp > 1114111 || cp >= 55296 && cp <= 57343 ? 65533 : cp);
974
+ }
975
+ return String.fromCodePoint(...points);
976
+ }
977
+ function encodeUtf32(text, littleEndian) {
978
+ const points = [...text];
979
+ const out = Buffer.alloc(points.length * 4);
980
+ points.forEach((ch, i) => {
981
+ const cp = ch.codePointAt(0) ?? 65533;
982
+ if (littleEndian) out.writeUInt32LE(cp, i * 4);
983
+ else out.writeUInt32BE(cp, i * 4);
984
+ });
985
+ return out;
986
+ }
911
987
 
912
988
  // src/fingerprint.ts
913
- init_define_import_meta_env();
914
989
  import { createHash } from "node:crypto";
915
990
  import * as fs3 from "node:fs";
916
991
  function fingerprintContent(content) {
@@ -930,9 +1005,15 @@ function fingerprintFile(filePath) {
930
1005
  }
931
1006
  return fingerprintContent(data);
932
1007
  }
1008
+ function fileIsAbsent(filePath) {
1009
+ try {
1010
+ return fs3.statSync(filePath, { throwIfNoEntry: false }) === void 0;
1011
+ } catch {
1012
+ return false;
1013
+ }
1014
+ }
933
1015
 
934
1016
  // src/project.ts
935
- init_define_import_meta_env();
936
1017
  import * as fs4 from "node:fs";
937
1018
  import * as os2 from "node:os";
938
1019
  import * as path4 from "node:path";
@@ -1146,24 +1227,10 @@ function isInsideRoot(target, root) {
1146
1227
  }
1147
1228
 
1148
1229
  // src/config.ts
1149
- init_define_import_meta_env();
1150
1230
  import * as fs5 from "node:fs";
1151
1231
  import * as path5 from "node:path";
1152
1232
 
1153
- // node_modules/smol-toml/dist/index.js
1154
- init_define_import_meta_env();
1155
-
1156
- // node_modules/smol-toml/dist/parse.js
1157
- init_define_import_meta_env();
1158
-
1159
- // node_modules/smol-toml/dist/struct.js
1160
- init_define_import_meta_env();
1161
-
1162
- // node_modules/smol-toml/dist/primitive.js
1163
- init_define_import_meta_env();
1164
-
1165
1233
  // node_modules/smol-toml/dist/date.js
1166
- init_define_import_meta_env();
1167
1234
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
1168
1235
  var TomlDate = class _TomlDate extends Date {
1169
1236
  #hasDate = false;
@@ -1256,7 +1323,6 @@ var TomlDate = class _TomlDate extends Date {
1256
1323
  };
1257
1324
 
1258
1325
  // node_modules/smol-toml/dist/error.js
1259
- init_define_import_meta_env();
1260
1326
  function getLineColFromPtr(string, ptr) {
1261
1327
  let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
1262
1328
  return [lines.length, lines.pop().length + 1];
@@ -1296,57 +1362,111 @@ ${codeblock}`, options);
1296
1362
  }
1297
1363
  };
1298
1364
 
1365
+ // node_modules/smol-toml/dist/util.js
1366
+ function indexOfNewline(str, start = 0) {
1367
+ let idx = str.indexOf("\n", start);
1368
+ if (str.charCodeAt(idx - 1) === 13)
1369
+ idx--;
1370
+ return idx;
1371
+ }
1372
+ function skipComment(ctx) {
1373
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1374
+ let c = ctx.s.charCodeAt(ctx.p);
1375
+ if (c === 10)
1376
+ break;
1377
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
1378
+ ctx.p++;
1379
+ break;
1380
+ }
1381
+ if (c < 32 && c !== 9 || c === 127) {
1382
+ throw new TomlError("control characters are not allowed in comments", {
1383
+ toml: ctx.s,
1384
+ ptr: ctx.p
1385
+ });
1386
+ }
1387
+ }
1388
+ }
1389
+ function skipVoid(ctx, banNewLines, banComments) {
1390
+ let c;
1391
+ while (1) {
1392
+ while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
1393
+ ctx.p++;
1394
+ if (banComments || c !== 35)
1395
+ break;
1396
+ skipComment(ctx);
1397
+ }
1398
+ }
1399
+ function skipUntil(ctx, sep, end) {
1400
+ let ptr = ctx.p;
1401
+ if (!end) {
1402
+ ptr = indexOfNewline(ctx.s, ptr);
1403
+ ctx.p = ptr < 0 ? ctx.s.length : ptr;
1404
+ return;
1405
+ }
1406
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1407
+ let c = ctx.s.charCodeAt(ctx.p);
1408
+ if (c === 35) {
1409
+ skipComment(ctx);
1410
+ } else if (c === end || c === sep) {
1411
+ return;
1412
+ }
1413
+ }
1414
+ throw new TomlError("cannot find end of structure", {
1415
+ toml: ctx.s,
1416
+ ptr
1417
+ });
1418
+ }
1419
+
1299
1420
  // node_modules/smol-toml/dist/primitive.js
1300
1421
  var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
1301
1422
  var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
1302
1423
  var LEADING_ZERO = /^[+-]?0[0-9_]/;
1303
- function parseString(str, ptr) {
1304
- let c = str[ptr++];
1424
+ function parseString(ctx) {
1425
+ let start = ctx.p;
1426
+ let c = ctx.s.charCodeAt(ctx.p++);
1305
1427
  let first = c;
1306
- let isLiteral = c === "'";
1307
- let isMultiline = c === str[ptr] && c === str[ptr + 1];
1428
+ let isLiteral = c === 39;
1429
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
1308
1430
  if (isMultiline) {
1309
- if (str[ptr += 2] === "\n")
1310
- ptr++;
1311
- else if (str[ptr] === "\r" && str[ptr + 1] === "\n")
1312
- ptr += 2;
1431
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
1432
+ ctx.p++;
1433
+ else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
1434
+ ctx.p += 2;
1313
1435
  }
1314
1436
  let parsed = "";
1315
- let sliceStart = ptr;
1437
+ let sliceStart = ctx.p;
1316
1438
  let state = 0;
1317
- for (let i = ptr; i < str.length; i++) {
1318
- c = str[i];
1319
- if (isMultiline && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
1439
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1440
+ c = ctx.s.charCodeAt(ctx.p);
1441
+ if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
1320
1442
  state = state && 3;
1321
- } else if (c < " " && c !== " " || c === "\x7F") {
1443
+ } else if (c < 32 && c !== 9 || c === 127) {
1322
1444
  throw new TomlError("control characters are not allowed in strings", {
1323
- toml: str,
1324
- ptr: i
1445
+ toml: ctx.s,
1446
+ ptr: ctx.p
1325
1447
  });
1326
- } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
1448
+ } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
1327
1449
  if (isMultiline) {
1328
- if (str[i + 3] === first)
1329
- i++;
1330
- if (str[i + 3] === first)
1331
- i++;
1450
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
1451
+ ctx.p++;
1452
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
1453
+ ctx.p++;
1332
1454
  }
1333
- return [
1334
- // If we're in a newline escape still, then there's nothing to add.
1335
- // Also try to avoid concat if there's nothing to add to parsed, or nothing has been added to parsed.
1336
- state ? parsed : parsed + str.slice(sliceStart, i),
1337
- i + (isMultiline ? 3 : 1)
1338
- ];
1455
+ if (!state)
1456
+ parsed += ctx.s.slice(sliceStart, ctx.p);
1457
+ ctx.p += isMultiline ? 3 : 1;
1458
+ return parsed;
1339
1459
  } else if (!state) {
1340
- if (!isLiteral && c === "\\") {
1341
- parsed += str.slice(sliceStart, sliceStart = i);
1460
+ if (!isLiteral && c === 92) {
1461
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
1342
1462
  state = 1;
1343
1463
  }
1344
1464
  } else if (state === 1) {
1345
- if (c === "x" || c === "u" || c === "U") {
1465
+ if (c === 120 || c === 117 || c === 85) {
1346
1466
  let value = 0;
1347
- let len = c === "x" ? 2 : c === "u" ? 4 : 8;
1348
- for (let j = 0; j < len; j++, i++) {
1349
- let hex = str.charCodeAt(i + 1);
1467
+ let len = c === 120 ? 2 : c === 117 ? 4 : 8;
1468
+ for (let j = 0; j < len; j++, ctx.p++) {
1469
+ let hex = ctx.s.charCodeAt(ctx.p + 1);
1350
1470
  let digit = (
1351
1471
  /* 0-9 */
1352
1472
  hex >= 48 && hex <= 57 ? hex - 48 : (
@@ -1358,57 +1478,68 @@ function parseString(str, ptr) {
1358
1478
  )
1359
1479
  );
1360
1480
  if (digit < 0)
1361
- throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
1481
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
1362
1482
  value = value << 4 | digit;
1363
1483
  }
1364
1484
  if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
1365
- throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
1485
+ throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
1366
1486
  }
1367
1487
  parsed += String.fromCodePoint(value);
1368
- sliceStart = i + 1;
1488
+ sliceStart = ctx.p + 1;
1369
1489
  state = 0;
1370
- } else if (c === " " || c === " ") {
1490
+ } else if (c === 32 || c === 9) {
1371
1491
  state = 2;
1372
1492
  } else {
1373
- if (c === "b")
1493
+ if (c === 98)
1374
1494
  parsed += "\b";
1375
- else if (c === "t")
1495
+ else if (c === 116)
1376
1496
  parsed += " ";
1377
- else if (c === "n")
1497
+ else if (c === 110)
1378
1498
  parsed += "\n";
1379
- else if (c === "f")
1499
+ else if (c === 102)
1380
1500
  parsed += "\f";
1381
- else if (c === "r")
1501
+ else if (c === 114)
1382
1502
  parsed += "\r";
1383
- else if (c === "e")
1503
+ else if (c === 101)
1384
1504
  parsed += "\x1B";
1385
- else if (c === '"')
1505
+ else if (c === 34)
1386
1506
  parsed += '"';
1387
- else if (c === "\\")
1507
+ else if (c === 92)
1388
1508
  parsed += "\\";
1389
1509
  else
1390
- throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
1391
- sliceStart = i + 1;
1510
+ throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
1511
+ sliceStart = ctx.p + 1;
1392
1512
  state = 0;
1393
1513
  }
1394
- } else if (c !== " " && c !== " ") {
1514
+ } else if (c !== 32 && c !== 9) {
1395
1515
  if (state === 2) {
1396
1516
  throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
1397
- toml: str,
1517
+ toml: ctx.s,
1398
1518
  ptr: sliceStart
1399
1519
  });
1400
1520
  }
1401
- state = !isLiteral && c === "\\" ? 1 : 0;
1402
- sliceStart = i;
1521
+ state = !isLiteral && c === 92 ? 1 : 0;
1522
+ sliceStart = ctx.p;
1403
1523
  }
1404
1524
  }
1405
- throw new TomlError("unfinished string", { toml: str, ptr });
1525
+ throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
1406
1526
  }
1407
- function parseValue(value, toml, ptr, integersAsBigInt) {
1408
- if (value === "true")
1409
- return true;
1410
- if (value === "false")
1411
- return false;
1527
+ function sliceAndTrimEndOf(ctx, start, end) {
1528
+ let value = ctx.s.slice(start, end);
1529
+ let commentIdx = value.indexOf("#");
1530
+ if (commentIdx > 0) {
1531
+ skipComment({ s: value, p: commentIdx, d: 0 });
1532
+ value = value.slice(0, commentIdx);
1533
+ }
1534
+ return value.trimEnd();
1535
+ }
1536
+ function parseValue(ctx, integersAsBigInt, end) {
1537
+ let ptr = ctx.p;
1538
+ let err = { toml: ctx.s, ptr };
1539
+ skipUntil(ctx, 44, end);
1540
+ let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
1541
+ if (!value)
1542
+ throw new TomlError("incomplete declaration: value expected", err);
1412
1543
  if (value === "-inf")
1413
1544
  return -Infinity;
1414
1545
  if (value === "inf" || value === "+inf")
@@ -1420,25 +1551,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
1420
1551
  let isInt = INT_REGEX.test(value);
1421
1552
  if (isInt || FLOAT_REGEX.test(value)) {
1422
1553
  if (LEADING_ZERO.test(value)) {
1423
- throw new TomlError("leading zeroes are not allowed", {
1424
- toml,
1425
- ptr
1426
- });
1554
+ throw new TomlError("leading zeroes are not allowed", err);
1427
1555
  }
1428
1556
  value = value.replace(/_/g, "");
1429
1557
  let numeric = +value;
1430
1558
  if (isNaN(numeric)) {
1431
- throw new TomlError("invalid number", {
1432
- toml,
1433
- ptr
1434
- });
1559
+ throw new TomlError("invalid number", err);
1435
1560
  }
1436
1561
  if (isInt) {
1437
1562
  if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
1438
- throw new TomlError("integer value cannot be represented losslessly", {
1439
- toml,
1440
- ptr
1441
- });
1563
+ throw new TomlError("integer value cannot be represented losslessly", err);
1442
1564
  }
1443
1565
  if (isInt || integersAsBigInt === true)
1444
1566
  numeric = BigInt(value);
@@ -1446,281 +1568,184 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
1446
1568
  return numeric;
1447
1569
  }
1448
1570
  const date = new TomlDate(value);
1449
- if (!date.isValid()) {
1450
- throw new TomlError("invalid value", {
1451
- toml,
1452
- ptr
1453
- });
1454
- }
1571
+ if (!date.isValid())
1572
+ throw new TomlError("invalid value", err);
1455
1573
  return date;
1456
1574
  }
1457
1575
 
1458
1576
  // node_modules/smol-toml/dist/extract.js
1459
- init_define_import_meta_env();
1460
-
1461
- // node_modules/smol-toml/dist/util.js
1462
- init_define_import_meta_env();
1463
- function indexOfNewline(str, start = 0, end = str.length) {
1464
- let idx = str.indexOf("\n", start);
1465
- if (str[idx - 1] === "\r")
1466
- idx--;
1467
- return idx <= end ? idx : -1;
1468
- }
1469
- function skipComment(str, ptr) {
1470
- for (let i = ptr; i < str.length; i++) {
1471
- let c = str[i];
1472
- if (c === "\n")
1473
- return i;
1474
- if (c === "\r" && str[i + 1] === "\n")
1475
- return i + 1;
1476
- if (c < " " && c !== " " || c === "\x7F") {
1477
- throw new TomlError("control characters are not allowed in comments", {
1478
- toml: str,
1577
+ function extractValue(ctx, end, integersAsBigInt) {
1578
+ let ptr = ctx.p;
1579
+ let c = ctx.s.charCodeAt(ptr);
1580
+ if (c === 91 || c === 123) {
1581
+ if (!ctx.d--) {
1582
+ throw new TomlError("document contains excessively nested structures. aborting.", {
1583
+ toml: ctx.s,
1479
1584
  ptr
1480
1585
  });
1481
1586
  }
1587
+ let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
1588
+ ctx.d++;
1589
+ return value;
1482
1590
  }
1483
- return str.length;
1484
- }
1485
- function skipVoid(str, ptr, banNewLines, banComments) {
1486
- let c;
1487
- while (1) {
1488
- while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
1489
- ptr++;
1490
- if (banComments || c !== "#")
1491
- break;
1492
- ptr = skipComment(str, ptr);
1493
- }
1494
- return ptr;
1495
- }
1496
- function skipUntil(str, ptr, sep, end, banNewLines = false) {
1497
- if (!end) {
1498
- ptr = indexOfNewline(str, ptr);
1499
- return ptr < 0 ? str.length : ptr;
1500
- }
1501
- for (let i = ptr; i < str.length; i++) {
1502
- let c = str[i];
1503
- if (c === "#") {
1504
- i = indexOfNewline(str, i);
1505
- } else if (c === sep) {
1506
- return i + 1;
1507
- } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
1508
- return i;
1509
- }
1510
- }
1511
- throw new TomlError("cannot find end of structure", {
1512
- toml: str,
1513
- ptr
1514
- });
1515
- }
1516
-
1517
- // node_modules/smol-toml/dist/extract.js
1518
- function sliceAndTrimEndOf(str, startPtr, endPtr) {
1519
- let value = str.slice(startPtr, endPtr);
1520
- let commentIdx = value.indexOf("#");
1521
- if (commentIdx > -1) {
1522
- skipComment(str, commentIdx);
1523
- value = value.slice(0, commentIdx);
1591
+ if (c === 34 || c === 39) {
1592
+ return parseString(ctx);
1524
1593
  }
1525
- return [value.trimEnd(), commentIdx];
1526
- }
1527
- function extractValue(str, ptr, end, depth, integersAsBigInt) {
1528
- if (depth === 0) {
1529
- throw new TomlError("document contains excessively nested structures. aborting.", {
1530
- toml: str,
1531
- ptr
1532
- });
1533
- }
1534
- let c = str[ptr];
1535
- if (c === "[" || c === "{") {
1536
- let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
1537
- if (end) {
1538
- endPtr2 = skipVoid(str, endPtr2);
1539
- if (str[endPtr2] === ",")
1540
- endPtr2++;
1541
- else if (str[endPtr2] !== end) {
1542
- throw new TomlError("expected comma or end of structure", {
1543
- toml: str,
1544
- ptr: endPtr2
1545
- });
1546
- }
1547
- }
1548
- return [value, endPtr2];
1549
- }
1550
- if (c === '"' || c === "'") {
1551
- let [parsed, endPtr2] = parseString(str, ptr);
1552
- if (end) {
1553
- endPtr2 = skipVoid(str, endPtr2);
1554
- if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
1555
- throw new TomlError("unexpected character encountered", {
1556
- toml: str,
1557
- ptr: endPtr2
1558
- });
1559
- }
1560
- if (str[endPtr2] === ",")
1561
- endPtr2++;
1562
- }
1563
- return [parsed, endPtr2];
1564
- }
1565
- let endPtr = skipUntil(str, ptr, ",", end);
1566
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
1567
- if (!slice[0]) {
1568
- throw new TomlError("incomplete key-value declaration: no value specified", {
1569
- toml: str,
1570
- ptr
1571
- });
1594
+ if (c === 116) {
1595
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
1596
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
1597
+ ctx.p++;
1598
+ return true;
1572
1599
  }
1573
- if (end && slice[1] > -1) {
1574
- endPtr = skipVoid(str, ptr + slice[1]);
1575
- if (str[endPtr] === ",")
1576
- endPtr++;
1600
+ if (c === 102) {
1601
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
1602
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
1603
+ ctx.p++;
1604
+ return false;
1577
1605
  }
1578
- return [
1579
- parseValue(slice[0], str, ptr, integersAsBigInt),
1580
- endPtr
1581
- ];
1606
+ return parseValue(ctx, integersAsBigInt, end);
1582
1607
  }
1583
1608
 
1584
1609
  // node_modules/smol-toml/dist/struct.js
1585
1610
  var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
1586
- function parseKey(str, ptr, end = "=") {
1587
- let dot = ptr - 1;
1611
+ function parseKey(ctx, end = "=") {
1612
+ let start = ctx.p;
1613
+ let dot = start - 1;
1588
1614
  let parsed = [];
1589
- let endPtr = str.indexOf(end, ptr);
1615
+ let endPtr = ctx.s.indexOf(end, start);
1590
1616
  if (endPtr < 0) {
1591
1617
  throw new TomlError("incomplete key-value: cannot find end of key", {
1592
- toml: str,
1593
- ptr
1618
+ toml: ctx.s,
1619
+ ptr: start
1594
1620
  });
1595
1621
  }
1596
1622
  do {
1597
- let c = str[ptr = ++dot];
1598
- if (c !== " " && c !== " ") {
1599
- if (c === '"' || c === "'") {
1600
- if (c === str[ptr + 1] && c === str[ptr + 2]) {
1623
+ let c = ctx.s.charCodeAt(ctx.p = ++dot);
1624
+ if (c !== 32 && c !== 9) {
1625
+ if (c === 34 || c === 39) {
1626
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
1601
1627
  throw new TomlError("multiline strings are not allowed in keys", {
1602
- toml: str,
1603
- ptr
1628
+ toml: ctx.s,
1629
+ ptr: ctx.p
1604
1630
  });
1605
1631
  }
1606
- let [part, eos] = parseString(str, ptr);
1607
- dot = str.indexOf(".", eos);
1608
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
1632
+ let part = parseString(ctx);
1633
+ dot = ctx.s.indexOf(".", ctx.p);
1634
+ let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1609
1635
  let newLine = indexOfNewline(strEnd);
1610
1636
  if (newLine > -1) {
1611
1637
  throw new TomlError("newlines are not allowed in keys", {
1612
- toml: str,
1613
- ptr: ptr + dot + newLine
1638
+ toml: ctx.s,
1639
+ ptr: newLine
1614
1640
  });
1615
1641
  }
1616
1642
  if (strEnd.trimStart()) {
1617
1643
  throw new TomlError("found extra tokens after the string part", {
1618
- toml: str,
1619
- ptr: eos
1644
+ toml: ctx.s,
1645
+ ptr: ctx.p
1620
1646
  });
1621
1647
  }
1622
- if (endPtr < eos) {
1623
- endPtr = str.indexOf(end, eos);
1648
+ if (endPtr < ctx.p) {
1649
+ endPtr = ctx.s.indexOf(end, ctx.p);
1624
1650
  if (endPtr < 0) {
1625
1651
  throw new TomlError("incomplete key-value: cannot find end of key", {
1626
- toml: str,
1627
- ptr
1652
+ toml: ctx.s,
1653
+ ptr: start
1628
1654
  });
1629
1655
  }
1630
1656
  }
1631
1657
  parsed.push(part);
1632
1658
  } else {
1633
- dot = str.indexOf(".", ptr);
1634
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
1659
+ dot = ctx.s.indexOf(".", ctx.p);
1660
+ let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1635
1661
  if (!KEY_PART_RE.test(part)) {
1636
1662
  throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
1637
- toml: str,
1638
- ptr
1663
+ toml: ctx.s,
1664
+ ptr: ctx.p
1639
1665
  });
1640
1666
  }
1641
1667
  parsed.push(part.trimEnd());
1642
1668
  }
1643
1669
  }
1644
1670
  } while (dot + 1 && dot < endPtr);
1645
- return [parsed, skipVoid(str, endPtr + 1, true, true)];
1671
+ ctx.p = endPtr + 1;
1672
+ skipVoid(ctx, true, true);
1673
+ return parsed;
1646
1674
  }
1647
- function parseInlineTable(str, ptr, depth, integersAsBigInt) {
1675
+ function parseInlineTable(ctx, integersAsBigInt) {
1648
1676
  let res = {};
1649
1677
  let seen = /* @__PURE__ */ new Set();
1650
1678
  let c;
1651
- ptr++;
1652
- while ((c = str[ptr++]) !== "}" && c) {
1653
- if (c === ",") {
1654
- throw new TomlError("expected value, found comma", {
1655
- toml: str,
1656
- ptr: ptr - 1
1657
- });
1658
- } else if (c === "#")
1659
- ptr = skipComment(str, ptr);
1660
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
1661
- let k;
1662
- let t = res;
1663
- let hasOwn = false;
1664
- let [key, keyEndPtr] = parseKey(str, ptr - 1);
1665
- for (let i = 0; i < key.length; i++) {
1666
- if (i)
1667
- t = hasOwn ? t[k] : t[k] = {};
1668
- k = key[i];
1669
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
1670
- throw new TomlError("trying to redefine an already defined value", {
1671
- toml: str,
1672
- ptr
1673
- });
1674
- }
1675
- if (!hasOwn && k === "__proto__") {
1676
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1677
- }
1678
- }
1679
- if (hasOwn) {
1679
+ ctx.p++;
1680
+ while (ctx.p < ctx.s.length) {
1681
+ skipVoid(ctx);
1682
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
1683
+ ctx.p++;
1684
+ return res;
1685
+ }
1686
+ let k;
1687
+ let t = res;
1688
+ let hasOwn = false;
1689
+ let p = ctx.p;
1690
+ let key = parseKey(ctx);
1691
+ for (let i = 0; i < key.length; i++) {
1692
+ if (i)
1693
+ t = hasOwn ? t[k] : t[k] = {};
1694
+ k = key[i];
1695
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
1680
1696
  throw new TomlError("trying to redefine an already defined value", {
1681
- toml: str,
1682
- ptr
1697
+ toml: ctx.s,
1698
+ ptr: p
1683
1699
  });
1684
1700
  }
1685
- let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
1686
- seen.add(value);
1687
- t[k] = value;
1688
- ptr = valueEndPtr;
1701
+ if (!hasOwn && k === "__proto__") {
1702
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1703
+ }
1704
+ }
1705
+ if (hasOwn) {
1706
+ throw new TomlError("trying to redefine an already defined value", {
1707
+ toml: ctx.s,
1708
+ ptr: ctx.p
1709
+ });
1710
+ }
1711
+ let value = extractValue(ctx, 125, integersAsBigInt);
1712
+ seen.add(t[k] = value);
1713
+ skipVoid(ctx);
1714
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
1715
+ return res;
1716
+ }
1717
+ if (c !== 44) {
1718
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1689
1719
  }
1690
1720
  }
1691
- if (!c) {
1692
- throw new TomlError("unfinished table encountered", {
1693
- toml: str,
1694
- ptr
1695
- });
1696
- }
1697
- return [res, ptr];
1721
+ throw new TomlError("unfinished table encountered", {
1722
+ toml: ctx.s,
1723
+ ptr: ctx.p
1724
+ });
1698
1725
  }
1699
- function parseArray(str, ptr, depth, integersAsBigInt) {
1726
+ function parseArray(ctx, integersAsBigInt) {
1700
1727
  let res = [];
1701
1728
  let c;
1702
- ptr++;
1703
- while ((c = str[ptr++]) !== "]" && c) {
1704
- if (c === ",") {
1705
- throw new TomlError("expected value, found comma", {
1706
- toml: str,
1707
- ptr: ptr - 1
1708
- });
1709
- } else if (c === "#")
1710
- ptr = skipComment(str, ptr);
1711
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
1712
- let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
1713
- res.push(e[0]);
1714
- ptr = e[1];
1715
- }
1716
- }
1717
- if (!c) {
1718
- throw new TomlError("unfinished array encountered", {
1719
- toml: str,
1720
- ptr
1721
- });
1729
+ ctx.p++;
1730
+ while (ctx.p < ctx.s.length) {
1731
+ skipVoid(ctx);
1732
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
1733
+ ctx.p++;
1734
+ return res;
1735
+ }
1736
+ res.push(extractValue(ctx, 93, integersAsBigInt));
1737
+ skipVoid(ctx);
1738
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
1739
+ return res;
1740
+ }
1741
+ if (c !== 44) {
1742
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1743
+ }
1722
1744
  }
1723
- return [res, ptr];
1745
+ throw new TomlError("unfinished array encountered", {
1746
+ toml: ctx.s,
1747
+ ptr: ctx.p
1748
+ });
1724
1749
  }
1725
1750
 
1726
1751
  // node_modules/smol-toml/dist/parse.js
@@ -1784,25 +1809,29 @@ function peekTable(key, table, meta, type) {
1784
1809
  return [k, t, state.c];
1785
1810
  }
1786
1811
  function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1812
+ let ctx = { s: toml, p: 0, d: maxDepth };
1787
1813
  let res = {};
1788
1814
  let meta = {};
1815
+ let tmp;
1789
1816
  let tbl = res;
1790
1817
  let m = meta;
1791
- for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
1792
- if (toml[ptr] === "[") {
1793
- let isTableArray = toml[++ptr] === "[";
1794
- let k = parseKey(toml, ptr += +isTableArray, "]");
1818
+ skipVoid(ctx);
1819
+ while (ctx.p < toml.length) {
1820
+ if (toml.charCodeAt(ctx.p) === 91) {
1821
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1822
+ tmp = ctx.p += +isTableArray;
1823
+ let k = parseKey(ctx, "]");
1795
1824
  if (isTableArray) {
1796
- if (toml[k[1] - 1] !== "]") {
1825
+ if (toml.charCodeAt(ctx.p - 1) !== 93) {
1797
1826
  throw new TomlError("expected end of table declaration", {
1798
1827
  toml,
1799
- ptr: k[1] - 1
1828
+ ptr: ctx.p - 1
1800
1829
  });
1801
1830
  }
1802
- k[1]++;
1831
+ ctx.p++;
1803
1832
  }
1804
1833
  let p = peekTable(
1805
- k[0],
1834
+ k,
1806
1835
  res,
1807
1836
  meta,
1808
1837
  isTableArray ? 2 : 1
@@ -1811,16 +1840,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1811
1840
  if (!p) {
1812
1841
  throw new TomlError("trying to redefine an already defined table or value", {
1813
1842
  toml,
1814
- ptr
1843
+ ptr: tmp
1815
1844
  });
1816
1845
  }
1817
1846
  m = p[2];
1818
1847
  tbl = p[1];
1819
- ptr = k[1];
1820
1848
  } else {
1821
- let k = parseKey(toml, ptr);
1849
+ tmp = ctx.p;
1850
+ let k = parseKey(ctx);
1822
1851
  let p = peekTable(
1823
- k[0],
1852
+ k,
1824
1853
  tbl,
1825
1854
  m,
1826
1855
  0
@@ -1829,35 +1858,36 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1829
1858
  if (!p) {
1830
1859
  throw new TomlError("trying to redefine an already defined table or value", {
1831
1860
  toml,
1832
- ptr
1861
+ ptr: tmp
1833
1862
  });
1834
1863
  }
1835
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
1836
- p[1][p[0]] = v[0];
1837
- ptr = v[1];
1864
+ p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
1838
1865
  }
1839
- ptr = skipVoid(toml, ptr, true);
1840
- if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
1866
+ skipVoid(ctx, true);
1867
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
1841
1868
  throw new TomlError("each key-value declaration must be followed by an end-of-line", {
1842
1869
  toml,
1843
- ptr
1870
+ ptr: ctx.p
1844
1871
  });
1845
1872
  }
1846
- ptr = skipVoid(toml, ptr);
1873
+ skipVoid(ctx);
1847
1874
  }
1848
1875
  return res;
1849
1876
  }
1850
1877
 
1851
1878
  // node_modules/smol-toml/dist/stringify.js
1852
- init_define_import_meta_env();
1853
1879
  var BARE_KEY = /^[a-z0-9-_]+$/i;
1854
1880
  function extendedTypeOf(obj) {
1855
1881
  let type = typeof obj;
1856
1882
  if (type === "object") {
1857
1883
  if (Array.isArray(obj))
1858
1884
  return "array";
1859
- if (obj instanceof Date)
1885
+ if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
1860
1886
  return "date";
1887
+ if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
1888
+ typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
1889
+ return "temporal";
1890
+ }
1861
1891
  }
1862
1892
  return type;
1863
1893
  }
@@ -1871,38 +1901,42 @@ function isArrayOfTables(obj) {
1871
1901
  function formatString(s) {
1872
1902
  return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
1873
1903
  }
1904
+ function stringifyTemporal(temporal) {
1905
+ return temporal.toString({
1906
+ calendarName: "never",
1907
+ timeZoneName: "never"
1908
+ });
1909
+ }
1874
1910
  function stringifyValue(val, type, depth, numberAsFloat) {
1875
1911
  if (depth === 0) {
1876
1912
  throw new Error("Could not stringify the object: maximum object depth exceeded");
1877
1913
  }
1878
- if (type === "number") {
1879
- if (isNaN(val))
1880
- return "nan";
1881
- if (val === Infinity)
1882
- return "inf";
1883
- if (val === -Infinity)
1884
- return "-inf";
1885
- if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
1886
- return val.toFixed(1);
1887
- return val.toString();
1888
- }
1889
- if (type === "bigint" || type === "boolean") {
1890
- return val.toString();
1891
- }
1892
- if (type === "string") {
1893
- return formatString(val);
1894
- }
1895
- if (type === "date") {
1896
- if (isNaN(val.getTime())) {
1897
- throw new TypeError("cannot serialize invalid date");
1898
- }
1899
- return val.toISOString();
1900
- }
1901
- if (type === "object") {
1902
- return stringifyInlineTable(val, depth, numberAsFloat);
1903
- }
1904
- if (type === "array") {
1905
- return stringifyArray(val, depth, numberAsFloat);
1914
+ switch (type) {
1915
+ // @ts-expect-error -- intentional fallthrough case
1916
+ case "number":
1917
+ if (isNaN(val))
1918
+ return "nan";
1919
+ if (val === Infinity)
1920
+ return "inf";
1921
+ if (val === -Infinity)
1922
+ return "-inf";
1923
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
1924
+ return val.toFixed(1);
1925
+ case "bigint":
1926
+ case "boolean":
1927
+ return val.toString();
1928
+ case "string":
1929
+ return formatString(val);
1930
+ case "date":
1931
+ if (isNaN(val.getTime()))
1932
+ throw new TypeError("cannot serialize invalid date");
1933
+ return val.toISOString();
1934
+ case "object":
1935
+ return stringifyInlineTable(val, depth, numberAsFloat);
1936
+ case "array":
1937
+ return stringifyArray(val, depth, numberAsFloat);
1938
+ case "temporal":
1939
+ return stringifyTemporal(val);
1906
1940
  }
1907
1941
  }
1908
1942
  function stringifyInlineTable(obj, depth, numberAsFloat) {
@@ -1991,7 +2025,6 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
1991
2025
  }
1992
2026
 
1993
2027
  // src/env.ts
1994
- init_define_import_meta_env();
1995
2028
  var FALSY_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
1996
2029
  var TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
1997
2030
  function envStr(key, defaultVal) {
@@ -3235,11 +3268,1055 @@ function saveConfig(config) {
3235
3268
  _cached2 = null;
3236
3269
  }
3237
3270
 
3271
+ // src/parser_types.ts
3272
+ import * as path6 from "node:path";
3273
+ var EXTENSION_LANGUAGE = /* @__PURE__ */ new Map([
3274
+ [".py", "python"],
3275
+ [".pyi", "python"],
3276
+ [".ts", "typescript"],
3277
+ [".tsx", "typescript"],
3278
+ [".mts", "typescript"],
3279
+ [".cts", "typescript"],
3280
+ [".js", "javascript"],
3281
+ [".jsx", "javascript"],
3282
+ [".mjs", "javascript"],
3283
+ [".cjs", "javascript"],
3284
+ [".rs", "rust"],
3285
+ [".go", "go"],
3286
+ [".c", "c"],
3287
+ [".h", "c"],
3288
+ [".cpp", "cpp"],
3289
+ [".cc", "cpp"],
3290
+ [".cxx", "cpp"],
3291
+ [".hpp", "cpp"],
3292
+ [".hxx", "cpp"],
3293
+ [".rb", "ruby"],
3294
+ [".ruby", "ruby"],
3295
+ // Rake task files (lib/tasks/foo.rake) are plain Ruby syntax (`task :foo do ... end`),
3296
+ // parsed identically by the ruby tree-sitter grammar. Without this entry a `.rake` file
3297
+ // fell through to 'unknown' and indexed zero symbols despite the grammar handling its
3298
+ // content exactly like any other .rb file -- the same has-extractor-but-no-extension gap
3299
+ // previously fixed for `.mk` (Makefile fragments).
3300
+ [".rake", "ruby"],
3301
+ [".java", "java"],
3302
+ [".sh", "bash"],
3303
+ [".bash", "bash"],
3304
+ [".md", "markdown"],
3305
+ [".markdown", "markdown"],
3306
+ // MDX heading syntax is plain ATX and works with the existing markdown extractor as-is,
3307
+ // unlike .rst which genuinely needs an underline-style heading parser this extractor doesn't
3308
+ // implement (left as 'unknown' deliberately).
3309
+ [".mdx", "markdown"],
3310
+ [".toml", "toml"],
3311
+ [".json", "json"],
3312
+ [".yaml", "yaml"],
3313
+ [".yml", "yaml"],
3314
+ [".css", "css"],
3315
+ [".scss", "css"],
3316
+ [".sass", "css"],
3317
+ [".less", "css"],
3318
+ [".cs", "csharp"],
3319
+ [".php", "php"],
3320
+ [".html", "html"],
3321
+ [".htm", "html"],
3322
+ [".liquid", "liquid"],
3323
+ [".kt", "kotlin"],
3324
+ [".kts", "kotlin"],
3325
+ [".swift", "swift"],
3326
+ [".scala", "scala"],
3327
+ [".sc", "scala"],
3328
+ [".lua", "lua"],
3329
+ [".ex", "elixir"],
3330
+ [".exs", "elixir"],
3331
+ [".dart", "dart"],
3332
+ [".zig", "zig"],
3333
+ [".r", "r"],
3334
+ [".graphql", "graphql"],
3335
+ [".gql", "graphql"],
3336
+ [".sql", "sql"],
3337
+ [".ini", "ini"],
3338
+ [".cfg", "ini"],
3339
+ [".conf", "ini"],
3340
+ [".proto", "proto"],
3341
+ // `.mk` is the idiomatic extension for included Makefile fragments (config.mk, rules.mk,
3342
+ // common.mk); their syntax is identical to a bare `Makefile`, which FILENAME_LANGUAGE already
3343
+ // maps. Without this entry a `.mk` fragment fell through to 'unknown' and was indexed with zero
3344
+ // symbols despite extractMakefile handling its content fine -- the same has-extractor-but-no-
3345
+ // extension gap previously seen for other adapters. (importsExtensionFor already treats bare
3346
+ // Makefile basenames as `.mk` for the imports command, so extractImports' `.mk` branch was
3347
+ // reachable while symbol indexing was not.)
3348
+ [".mk", "makefile"],
3349
+ [".tf", "terraform"],
3350
+ [".tfvars", "terraform"],
3351
+ [".hcl", "terraform"],
3352
+ [".ps1", "powershell"],
3353
+ [".psm1", "powershell"],
3354
+ [".env", "env_file"],
3355
+ [".cls", "apex"],
3356
+ [".trigger", "apex"],
3357
+ [".cmp", "salesforce_markup"],
3358
+ [".app", "salesforce_markup"],
3359
+ [".evt", "salesforce_markup"],
3360
+ [".intf", "salesforce_markup"],
3361
+ [".design", "salesforce_markup"],
3362
+ [".auradoc", "salesforce_markup"],
3363
+ [".tokens", "salesforce_markup"],
3364
+ [".page", "salesforce_markup"],
3365
+ [".component", "salesforce_markup"],
3366
+ [".email", "salesforce_markup"],
3367
+ [".vue", "vue"],
3368
+ [".svelte", "svelte"],
3369
+ [".astro", "astro"],
3370
+ [".ipynb", "ipynb"]
3371
+ ]);
3372
+ var FILENAME_LANGUAGE = /* @__PURE__ */ new Map([
3373
+ ["dockerfile", "dockerfile"],
3374
+ ["makefile", "makefile"],
3375
+ ["gnumakefile", "makefile"],
3376
+ ["bsdmakefile", "makefile"],
3377
+ ["cargo.toml", "toml"],
3378
+ ["pyproject.toml", "toml"],
3379
+ ["package.json", "json"],
3380
+ ["tsconfig.json", "json"],
3381
+ [".envrc", "env_file"],
3382
+ // Gemfile and Rakefile are plain Ruby syntax with no extension -- the dominant, idiomatic
3383
+ // dependency-manifest and task-runner files in virtually every real Ruby project (analogous to
3384
+ // package.json for Node or a bare Makefile). Without these entries both fell through to
3385
+ // 'unknown' and indexed zero symbols despite the ruby tree-sitter grammar handling their
3386
+ // content exactly like any other .rb file -- the same has-extractor-but-no-dispatch-entry gap
3387
+ // already fixed for bare `Makefile` / `.mk` fragments above.
3388
+ ["gemfile", "ruby"],
3389
+ ["rakefile", "ruby"],
3390
+ // Vagrantfile, Guardfile, Podfile, Capfile, Fastfile: same idiomatic extensionless-Ruby-DSL
3391
+ // pattern as Gemfile/Rakefile above -- `Vagrant.configure(...) do ... end`, Guard's `guard
3392
+ // 'rspec' do ... end`, CocoaPods' `Pod::Spec.new do |s| ... end`, Capistrano's `set :application`,
3393
+ // and fastlane's `lane :build do ... end` are all plain Ruby, parsed identically by the ruby
3394
+ // tree-sitter grammar. Without these entries each fell through to 'unknown' and indexed zero
3395
+ // symbols despite the grammar handling their content exactly like any other .rb file.
3396
+ ["vagrantfile", "ruby"],
3397
+ ["guardfile", "ruby"],
3398
+ ["podfile", "ruby"],
3399
+ ["capfile", "ruby"],
3400
+ ["fastfile", "ruby"],
3401
+ // Brewfile: Homebrew Bundle's dependency manifest (`brew "wget"`, `cask "..."`, `tap "..."`)
3402
+ // is ordinary Ruby method-call syntax, evaluated by Homebrew's own Ruby DSL -- the extensionless
3403
+ // macOS-dev-environment analogue of Gemfile/package.json, and near-universal in dotfiles repos
3404
+ // that use `brew bundle dump`/`brew bundle install`. Same has-extractor-but-no-dispatch-entry
3405
+ // gap as the other extensionless Ruby DSL files above: without this entry it fell through to
3406
+ // 'unknown' and indexed zero symbols despite the ruby tree-sitter grammar handling its content
3407
+ // exactly like any other .rb file.
3408
+ ["brewfile", "ruby"]
3409
+ ]);
3410
+ var DOTENV_VARIANT_RE = /^\.env(\..+)?$/;
3411
+ function detectLanguage(filePath) {
3412
+ const base = path6.basename(filePath).toLowerCase();
3413
+ if (DOTENV_VARIANT_RE.test(base)) return "env_file";
3414
+ const byName = FILENAME_LANGUAGE.get(base);
3415
+ if (byName !== void 0) return byName;
3416
+ if (base.endsWith("-meta.xml")) {
3417
+ return "salesforce_metadata";
3418
+ }
3419
+ const ext = path6.extname(base).toLowerCase();
3420
+ return EXTENSION_LANGUAGE.get(ext) ?? "unknown";
3421
+ }
3422
+ var UNSUPPORTED_LANGUAGE_EXTENSIONS = /* @__PURE__ */ new Map([]);
3423
+ function unsupportedLanguageName(filePath) {
3424
+ const ext = path6.extname(filePath).toLowerCase();
3425
+ return UNSUPPORTED_LANGUAGE_EXTENSIONS.get(ext);
3426
+ }
3427
+
3428
+ // src/doc_comment.ts
3429
+ function precedingDocComment(lines, lineStart, style) {
3430
+ const aboveIdx = lineStart - 2;
3431
+ if (aboveIdx < 0 || aboveIdx >= lines.length) return "";
3432
+ const aboveLine = lines[aboveIdx];
3433
+ if (aboveLine === void 0) return "";
3434
+ const aboveTrimmed = aboveLine.trim();
3435
+ if (style === "hash") {
3436
+ if (!aboveTrimmed.startsWith("#")) return "";
3437
+ const collected = [];
3438
+ let i = aboveIdx;
3439
+ while (i >= 0) {
3440
+ const line = lines[i];
3441
+ if (line === void 0) break;
3442
+ const trimmed = line.trim();
3443
+ if (!trimmed.startsWith("#")) break;
3444
+ collected.unshift(trimmed.replace(/^#+\s?/, ""));
3445
+ i--;
3446
+ }
3447
+ return collected.join("\n").trim();
3448
+ }
3449
+ if (aboveTrimmed.endsWith("*/")) {
3450
+ let blockStart = aboveIdx;
3451
+ while (blockStart >= 0) {
3452
+ const l = lines[blockStart];
3453
+ if (l === void 0) break;
3454
+ if (l.trim().startsWith("/*")) break;
3455
+ blockStart--;
3456
+ }
3457
+ if (blockStart < 0) return "";
3458
+ const opener = lines[blockStart];
3459
+ if (opener === void 0 || !opener.trim().startsWith("/*")) return "";
3460
+ const region = lines.slice(blockStart, aboveIdx + 1);
3461
+ const joined = region.join("\n").trimEnd();
3462
+ if (joined.indexOf("*/") !== joined.length - 2) return "";
3463
+ return region.map(
3464
+ (l) => l.trim().replace(/^\/\*+/, "").replace(/\*+\/$/, "").replace(/^\*\s?/, "").trim()
3465
+ ).filter((l) => l !== "").join("\n");
3466
+ }
3467
+ if (aboveTrimmed.startsWith("//")) {
3468
+ const collected = [];
3469
+ let i = aboveIdx;
3470
+ while (i >= 0) {
3471
+ const line = lines[i];
3472
+ if (line === void 0) break;
3473
+ const trimmed = line.trim();
3474
+ if (!trimmed.startsWith("//")) break;
3475
+ collected.unshift(trimmed.replace(/^\/\/[/!]?\s?/, ""));
3476
+ i--;
3477
+ }
3478
+ return collected.join("\n").trim();
3479
+ }
3480
+ return "";
3481
+ }
3482
+
3483
+ // src/languages/common.ts
3484
+ function buildLineIndex(text) {
3485
+ const idx = [0];
3486
+ for (let i = 0; i < text.length; i++) {
3487
+ if (text[i] === "\n") idx.push(i + 1);
3488
+ }
3489
+ return idx;
3490
+ }
3491
+ function offsetToLine(lineIndex, offset) {
3492
+ let lo = 0;
3493
+ let hi = lineIndex.length - 1;
3494
+ while (lo < hi) {
3495
+ const mid = lo + hi + 1 >> 1;
3496
+ const lineStart = lineIndex[mid];
3497
+ if (lineStart === void 0 || lineStart > offset) {
3498
+ hi = mid - 1;
3499
+ } else {
3500
+ lo = mid;
3501
+ }
3502
+ }
3503
+ return lo + 1;
3504
+ }
3505
+ function stripCstyleComments(text, lineCommentRe) {
3506
+ const lines = text.split("\n");
3507
+ let inComment = false;
3508
+ const outLines = [];
3509
+ for (const line of lines) {
3510
+ const { code, inComment: nextInComment } = stripBlockCommentSpan(line, inComment);
3511
+ outLines.push(code);
3512
+ inComment = nextInComment;
3513
+ }
3514
+ let out = outLines.join("\n");
3515
+ if (lineCommentRe !== void 0) {
3516
+ out = out.replace(lineCommentRe, (m) => " ".repeat(m.length));
3517
+ }
3518
+ return out;
3519
+ }
3520
+ function stripXmlComments(text) {
3521
+ const lines = text.split("\n");
3522
+ let inComment = false;
3523
+ const outLines = [];
3524
+ for (const line of lines) {
3525
+ let result = "";
3526
+ let j = 0;
3527
+ while (j < line.length) {
3528
+ if (!inComment) {
3529
+ const open = line.indexOf("<!--", j);
3530
+ if (open === -1) {
3531
+ result += line.slice(j);
3532
+ break;
3533
+ }
3534
+ result += line.slice(j, open);
3535
+ const close = line.indexOf("-->", open + 4);
3536
+ if (close === -1) {
3537
+ result += " ".repeat(line.length - open);
3538
+ inComment = true;
3539
+ break;
3540
+ }
3541
+ result += " ".repeat(close + 3 - open);
3542
+ j = close + 3;
3543
+ inComment = false;
3544
+ } else {
3545
+ const close = line.indexOf("-->", j);
3546
+ if (close === -1) {
3547
+ result += " ".repeat(line.length - j);
3548
+ break;
3549
+ }
3550
+ result += " ".repeat(close + 3 - j);
3551
+ j = close + 3;
3552
+ inComment = false;
3553
+ }
3554
+ }
3555
+ outLines.push(result);
3556
+ }
3557
+ return outLines.join("\n");
3558
+ }
3559
+ function scanQuotedStringEnd(content, start) {
3560
+ const quote = content[start];
3561
+ const n = content.length;
3562
+ let j = start + 1;
3563
+ while (j < n) {
3564
+ if (content[j] === "\\" && j + 1 < n) {
3565
+ j += 2;
3566
+ continue;
3567
+ }
3568
+ if (content[j] === quote) {
3569
+ j++;
3570
+ break;
3571
+ }
3572
+ if (quote !== "`" && content[j] === "\n") {
3573
+ j++;
3574
+ break;
3575
+ }
3576
+ j++;
3577
+ }
3578
+ return j;
3579
+ }
3580
+ function stripJsComments(content) {
3581
+ let out = "";
3582
+ let i = 0;
3583
+ const n = content.length;
3584
+ while (i < n) {
3585
+ const ch = content[i];
3586
+ if (ch === "/" && content[i + 1] === "/") {
3587
+ let j = i;
3588
+ while (j < n && content[j] !== "\n") j++;
3589
+ out += " ".repeat(j - i);
3590
+ i = j;
3591
+ continue;
3592
+ }
3593
+ if (ch === "/" && content[i + 1] === "*") {
3594
+ let j = i + 2;
3595
+ while (j < n && !(content[j] === "*" && content[j + 1] === "/")) j++;
3596
+ const end = j < n ? j + 2 : n;
3597
+ out += content.slice(i, end).replace(/[^\n]/g, " ");
3598
+ i = end;
3599
+ continue;
3600
+ }
3601
+ if (ch === '"' || ch === "'" || ch === "`") {
3602
+ const j = scanQuotedStringEnd(content, i);
3603
+ out += content.slice(i, j);
3604
+ i = j;
3605
+ continue;
3606
+ }
3607
+ out += ch;
3608
+ i++;
3609
+ }
3610
+ return out;
3611
+ }
3612
+ function stripHashComments(text) {
3613
+ return text.split("\n").map((line) => {
3614
+ for (let i = 0; i < line.length; i++) {
3615
+ if (line[i] === "#" && !isInsideStringLiteral(line, i)) {
3616
+ return line.slice(0, i) + " ".repeat(line.length - i);
3617
+ }
3618
+ }
3619
+ return line;
3620
+ }).join("\n");
3621
+ }
3622
+ var HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
3623
+ var HTML_SCRIPT_BODY_RE = /(<script\b[^>]*>)([\s\S]*?)(<\/script\s*>)/gi;
3624
+ var HTML_CDATA_RE = /<!\[CDATA\[[\s\S]*?\]\]>/g;
3625
+ var LIQUID_COMMENT_RE = /{%-?\s*comment\s*-?%}[\s\S]*?{%-?\s*endcomment\s*-?%}/gi;
3626
+ function maskHtmlNoise(text) {
3627
+ let out = text.replace(
3628
+ HTML_SCRIPT_BODY_RE,
3629
+ (_m, open, body, close) => open + body.replace(/[^\n]/g, " ") + close
3630
+ );
3631
+ out = out.replace(HTML_COMMENT_RE, (m) => m.replace(/[^\n]/g, " "));
3632
+ out = out.replace(LIQUID_COMMENT_RE, (m) => m.replace(/[^\n]/g, " "));
3633
+ out = out.replace(HTML_CDATA_RE, (m) => m.replace(/[^\n]/g, " "));
3634
+ return out;
3635
+ }
3636
+ var HTML_HEADING_RE = /<h([1-6])[^>]*>(.*?)<\/h\1>/gis;
3637
+ var HTML_HEADING_TAG_STRIP_RE = /<[^>]+>/g;
3638
+ function findHtmlHeadingMatches(content) {
3639
+ const masked = maskHtmlNoise(content);
3640
+ const matches = [];
3641
+ for (const m of masked.matchAll(HTML_HEADING_RE)) {
3642
+ const level = parseInt(m[1] ?? "1", 10);
3643
+ const raw = m[2] ?? "";
3644
+ const heading = raw.replace(HTML_HEADING_TAG_STRIP_RE, "").trim();
3645
+ matches.push({ level, heading, offset: m.index ?? 0, tag: m[0] ?? "" });
3646
+ }
3647
+ return matches;
3648
+ }
3649
+ function isInsideStringLiteral(line, index, from = 0) {
3650
+ let openQuote = null;
3651
+ let i = from;
3652
+ while (i < index) {
3653
+ const ch = line[i];
3654
+ if (openQuote !== null && ch === "\\" && i + 1 < line.length) {
3655
+ i += 2;
3656
+ continue;
3657
+ }
3658
+ if (ch === '"' || ch === "'") {
3659
+ if (openQuote === null) {
3660
+ openQuote = ch;
3661
+ } else if (openQuote === ch) {
3662
+ openQuote = null;
3663
+ }
3664
+ }
3665
+ i++;
3666
+ }
3667
+ return openQuote !== null;
3668
+ }
3669
+ function stripBlockCommentSpan(line, inComment) {
3670
+ let code = "";
3671
+ let j = 0;
3672
+ let comment = inComment;
3673
+ while (j < line.length) {
3674
+ if (!comment) {
3675
+ const lineCommentIdx = lineCommentStartIndex(line, ["//"], j);
3676
+ let open = line.indexOf("/*", j);
3677
+ while (open !== -1 && (isInsideStringLiteral(line, open, j) || lineCommentIdx !== -1 && open >= lineCommentIdx)) {
3678
+ open = line.indexOf("/*", open + 1);
3679
+ }
3680
+ if (open === -1) {
3681
+ code += line.slice(j);
3682
+ break;
3683
+ }
3684
+ code += line.slice(j, open);
3685
+ const close = line.indexOf("*/", open + 2);
3686
+ if (close === -1) {
3687
+ code += " ".repeat(line.length - open);
3688
+ comment = true;
3689
+ break;
3690
+ }
3691
+ code += " ".repeat(close + 2 - open);
3692
+ j = close + 2;
3693
+ comment = false;
3694
+ } else {
3695
+ const close = line.indexOf("*/", j);
3696
+ if (close === -1) {
3697
+ code += " ".repeat(line.length - j);
3698
+ break;
3699
+ }
3700
+ code += " ".repeat(close + 2 - j);
3701
+ j = close + 2;
3702
+ comment = false;
3703
+ }
3704
+ }
3705
+ return { code, inComment: comment };
3706
+ }
3707
+ function stripNestedBlockCommentSpan(line, depth) {
3708
+ let code = "";
3709
+ let j = 0;
3710
+ let d = depth;
3711
+ while (j < line.length) {
3712
+ if (d === 0) {
3713
+ const lineCommentIdx = lineCommentStartIndex(line, ["//"], j);
3714
+ let open = line.indexOf("/*", j);
3715
+ while (open !== -1 && (isInsideStringLiteral(line, open, j) || lineCommentIdx !== -1 && open >= lineCommentIdx)) {
3716
+ open = line.indexOf("/*", open + 1);
3717
+ }
3718
+ if (open === -1) {
3719
+ code += line.slice(j);
3720
+ break;
3721
+ }
3722
+ code += line.slice(j, open);
3723
+ code += " ";
3724
+ j = open + 2;
3725
+ d = 1;
3726
+ } else {
3727
+ const open = line.indexOf("/*", j);
3728
+ const close = line.indexOf("*/", j);
3729
+ if (close === -1 && open === -1) {
3730
+ code += " ".repeat(line.length - j);
3731
+ break;
3732
+ }
3733
+ const next = close === -1 ? open : open === -1 ? close : Math.min(open, close);
3734
+ code += " ".repeat(next + 2 - j);
3735
+ d = Math.max(0, d + (next === open ? 1 : -1));
3736
+ j = next + 2;
3737
+ }
3738
+ }
3739
+ return { code, depth: d };
3740
+ }
3741
+ function stripLineComment(line, markers = ["//"]) {
3742
+ const cutIdx = lineCommentStartIndex(line, markers);
3743
+ return cutIdx === -1 ? line : line.slice(0, cutIdx);
3744
+ }
3745
+ function lineCommentStartIndex(line, markers, from = 0) {
3746
+ let cutIdx = -1;
3747
+ for (const marker of markers) {
3748
+ let idx = line.indexOf(marker, from);
3749
+ while (idx !== -1 && isInsideStringLiteral(line, idx, from)) {
3750
+ idx = line.indexOf(marker, idx + 1);
3751
+ }
3752
+ if (idx !== -1 && (cutIdx === -1 || idx < cutIdx)) cutIdx = idx;
3753
+ }
3754
+ return cutIdx;
3755
+ }
3756
+ function stripStringLiterals(line) {
3757
+ let out = "";
3758
+ let i = 0;
3759
+ const stack = [];
3760
+ while (i < line.length) {
3761
+ const ch = line[i];
3762
+ if (ch === "\n") {
3763
+ out += ch;
3764
+ i++;
3765
+ stack.length = 0;
3766
+ continue;
3767
+ }
3768
+ const top = stack[stack.length - 1];
3769
+ if (top === void 0) {
3770
+ if (ch === '"' || ch === "'") {
3771
+ const bareBraceHole = ch === '"' && i > 0 && line[i - 1] === "$";
3772
+ stack.push({ kind: "string", quote: ch, bareBraceHole });
3773
+ out += ch;
3774
+ i++;
3775
+ continue;
3776
+ }
3777
+ out += ch;
3778
+ i++;
3779
+ continue;
3780
+ }
3781
+ if (top.kind === "hole") {
3782
+ if (ch === '"' || ch === "'") {
3783
+ const bareBraceHole = ch === '"' && i > 0 && line[i - 1] === "$";
3784
+ stack.push({ kind: "string", quote: ch, bareBraceHole });
3785
+ out += ch;
3786
+ i++;
3787
+ continue;
3788
+ }
3789
+ if (ch === "{") {
3790
+ top.depth++;
3791
+ out += ch;
3792
+ i++;
3793
+ continue;
3794
+ }
3795
+ if (ch === "}") {
3796
+ if (top.depth > 0) {
3797
+ top.depth--;
3798
+ } else {
3799
+ stack.pop();
3800
+ }
3801
+ out += ch;
3802
+ i++;
3803
+ continue;
3804
+ }
3805
+ out += ch;
3806
+ i++;
3807
+ continue;
3808
+ }
3809
+ if (ch === "\\" && i + 1 < line.length) {
3810
+ out += " ";
3811
+ i += 2;
3812
+ continue;
3813
+ }
3814
+ if (ch === top.quote) {
3815
+ stack.pop();
3816
+ out += ch;
3817
+ i++;
3818
+ continue;
3819
+ }
3820
+ if (top.quote === '"') {
3821
+ if (top.bareBraceHole && ch === "{") {
3822
+ if (line[i + 1] === "{") {
3823
+ out += " ";
3824
+ i += 2;
3825
+ continue;
3826
+ }
3827
+ stack.push({ kind: "hole", depth: 0 });
3828
+ out += ch;
3829
+ i++;
3830
+ continue;
3831
+ }
3832
+ if (!top.bareBraceHole && ch === "$" && line[i + 1] === "{") {
3833
+ stack.push({ kind: "hole", depth: 0 });
3834
+ out += line.slice(i, i + 2);
3835
+ i += 2;
3836
+ continue;
3837
+ }
3838
+ if (!top.bareBraceHole && ch === "{" && line[i + 1] === "$") {
3839
+ stack.push({ kind: "hole", depth: 0 });
3840
+ out += ch;
3841
+ i++;
3842
+ continue;
3843
+ }
3844
+ }
3845
+ out += " ";
3846
+ i++;
3847
+ }
3848
+ return out;
3849
+ }
3850
+ function findMultilineCloser(line, from, state) {
3851
+ switch (state.kind) {
3852
+ case "heredoc":
3853
+ case "nowdoc": {
3854
+ const re = new RegExp(`^[ \\t]*${escapeRegExp(state.identifier)}\\b`);
3855
+ const m = re.exec(line);
3856
+ return m ? { maskEnd: m[0].length } : null;
3857
+ }
3858
+ case "tripleSingleQuote": {
3859
+ const m = /'{3,}/.exec(line.slice(from));
3860
+ return m === null ? null : { maskEnd: from + m.index + m[0].length };
3861
+ }
3862
+ case "tripleQuote": {
3863
+ const n = state.identifier !== "" ? parseInt(state.identifier, 10) : 3;
3864
+ const re = new RegExp(`"{${n},}`);
3865
+ const m = re.exec(line.slice(from));
3866
+ return m === null ? null : { maskEnd: from + m.index + m[0].length };
3867
+ }
3868
+ case "verbatim": {
3869
+ if (!state.interpolated) {
3870
+ let j2 = from;
3871
+ while (j2 < line.length) {
3872
+ if (line[j2] === '"') {
3873
+ if (line[j2 + 1] === '"') {
3874
+ j2 += 2;
3875
+ continue;
3876
+ }
3877
+ return { maskEnd: j2 + 1 };
3878
+ }
3879
+ j2++;
3880
+ }
3881
+ return null;
3882
+ }
3883
+ let j = from;
3884
+ let holeDepth = 0;
3885
+ let nestedQuote = null;
3886
+ while (j < line.length) {
3887
+ const c = line[j];
3888
+ if (nestedQuote !== null) {
3889
+ if (c === "\\" && j + 1 < line.length) {
3890
+ j += 2;
3891
+ continue;
3892
+ }
3893
+ if (c === nestedQuote) {
3894
+ nestedQuote = null;
3895
+ }
3896
+ j++;
3897
+ continue;
3898
+ }
3899
+ if (holeDepth > 0) {
3900
+ if (c === '"' || c === "'") {
3901
+ nestedQuote = c;
3902
+ j++;
3903
+ continue;
3904
+ }
3905
+ if (c === "{") holeDepth++;
3906
+ else if (c === "}") holeDepth--;
3907
+ j++;
3908
+ continue;
3909
+ }
3910
+ if (c === "{") {
3911
+ holeDepth = 1;
3912
+ j++;
3913
+ continue;
3914
+ }
3915
+ if (c === '"') {
3916
+ if (line[j + 1] === '"') {
3917
+ j += 2;
3918
+ continue;
3919
+ }
3920
+ return { maskEnd: j + 1 };
3921
+ }
3922
+ j++;
3923
+ }
3924
+ return null;
3925
+ }
3926
+ case "psHereDouble":
3927
+ return line.startsWith('"@', from) ? { maskEnd: from + 2 } : null;
3928
+ case "psHereSingle":
3929
+ return line.startsWith("'@", from) ? { maskEnd: from + 2 } : null;
3930
+ default:
3931
+ return null;
3932
+ }
3933
+ }
3934
+ var MULTILINE_OPENER_COMMENT_MARKERS = {
3935
+ php: ["//", "#"],
3936
+ kotlin: ["//"],
3937
+ csharp: ["//"],
3938
+ powershell: ["#"],
3939
+ swift: ["//"],
3940
+ elixir: ["#"]
3941
+ };
3942
+ var MULTILINE_OPENER_BLOCK_COMMENT_LANGS = /* @__PURE__ */ new Set(["php", "kotlin", "csharp", "swift"]);
3943
+ function isInsideSameLineBlockComment(line, idx, from = 0) {
3944
+ let comment = false;
3945
+ let j = from;
3946
+ while (j < idx) {
3947
+ if (!comment) {
3948
+ const open = line.indexOf("/*", j);
3949
+ if (open === -1 || open >= idx) return false;
3950
+ if (isInsideStringLiteral(line, open, from)) {
3951
+ j = open + 2;
3952
+ continue;
3953
+ }
3954
+ comment = true;
3955
+ j = open + 2;
3956
+ } else {
3957
+ const close = line.indexOf("*/", j);
3958
+ if (close === -1 || close >= idx) return true;
3959
+ comment = false;
3960
+ j = close + 2;
3961
+ }
3962
+ }
3963
+ return comment;
3964
+ }
3965
+ function findMultilineOpener(line, from, lang) {
3966
+ const commentIdx = lineCommentStartIndex(line, MULTILINE_OPENER_COMMENT_MARKERS[lang], from);
3967
+ const isCommented = (idx) => commentIdx !== -1 && idx >= commentIdx || MULTILINE_OPENER_BLOCK_COMMENT_LANGS.has(lang) && isInsideSameLineBlockComment(line, idx, from);
3968
+ if (lang === "php") {
3969
+ const re = /<<<\s*(['"]?)([A-Za-z_]\w*)\1/g;
3970
+ re.lastIndex = from;
3971
+ const m = re.exec(line);
3972
+ if (!m || isInsideStringLiteral(line, m.index, from) || isCommented(m.index)) return null;
3973
+ const identifier = m[2] ?? "";
3974
+ const kind = m[1] === "'" ? "nowdoc" : "heredoc";
3975
+ return { openStart: m.index, closesSameLine: null, state: { kind, identifier } };
3976
+ }
3977
+ if (lang === "kotlin") {
3978
+ const idx = line.indexOf('"""', from);
3979
+ if (idx === -1 || isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
3980
+ const closeIdx = line.indexOf('"""', idx + 3);
3981
+ if (closeIdx !== -1) {
3982
+ return { openStart: idx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "3" } };
3983
+ }
3984
+ return { openStart: idx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "3" } };
3985
+ }
3986
+ if (lang === "swift") {
3987
+ const idx = line.indexOf('"""', from);
3988
+ if (idx === -1 || isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
3989
+ const closeIdx = line.indexOf('"""', idx + 3);
3990
+ if (closeIdx !== -1) {
3991
+ return { openStart: idx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "3" } };
3992
+ }
3993
+ return { openStart: idx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "3" } };
3994
+ }
3995
+ if (lang === "elixir") {
3996
+ const candidates = [];
3997
+ const dq = line.indexOf('"""', from);
3998
+ if (dq !== -1) candidates.push([dq, "tripleQuote", '"""']);
3999
+ const sq = line.indexOf("'''", from);
4000
+ if (sq !== -1) candidates.push([sq, "tripleSingleQuote", "'''"]);
4001
+ candidates.sort((a, b) => a[0] - b[0]);
4002
+ const first = candidates[0];
4003
+ if (first === void 0) return null;
4004
+ const [idx, kind, delim] = first;
4005
+ if (isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
4006
+ const closeIdx = line.indexOf(delim, idx + 3);
4007
+ const state = { kind, identifier: "3" };
4008
+ if (closeIdx !== -1) return { openStart: idx, closesSameLine: closeIdx + 3, state };
4009
+ return { openStart: idx, closesSameLine: null, state };
4010
+ }
4011
+ if (lang === "csharp") {
4012
+ const tripleRe = /"{3,}/g;
4013
+ tripleRe.lastIndex = from;
4014
+ const tripleM = tripleRe.exec(line);
4015
+ let tripleIdx = tripleM ? tripleM.index : -1;
4016
+ const tripleLen = tripleM ? tripleM[0].length : 0;
4017
+ if (tripleIdx !== -1 && (isInsideStringLiteral(line, tripleIdx, from) || isCommented(tripleIdx))) tripleIdx = -1;
4018
+ const verbRe = /\$?@\$?"/g;
4019
+ verbRe.lastIndex = from;
4020
+ const verbM = verbRe.exec(line);
4021
+ let verbIdx = verbM ? verbM.index : -1;
4022
+ if (verbIdx !== -1 && isCommented(verbIdx)) verbIdx = -1;
4023
+ if (verbIdx !== -1 && isInsideStringLiteral(line, verbIdx, from)) verbIdx = -1;
4024
+ if (tripleIdx === -1 && verbIdx === -1) return null;
4025
+ const useTriple = tripleIdx !== -1 && (verbIdx === -1 || tripleIdx < verbIdx);
4026
+ if (useTriple) {
4027
+ const closeRe = new RegExp(`"{${tripleLen},}`);
4028
+ const closeM = closeRe.exec(line.slice(tripleIdx + tripleLen));
4029
+ if (closeM !== null) {
4030
+ const closeIdx = tripleIdx + tripleLen + closeM.index;
4031
+ return { openStart: tripleIdx, closesSameLine: closeIdx + closeM[0].length, state: { kind: "tripleQuote", identifier: String(tripleLen) } };
4032
+ }
4033
+ return { openStart: tripleIdx, closesSameLine: null, state: { kind: "tripleQuote", identifier: String(tripleLen) } };
4034
+ }
4035
+ const quoteIdx = verbIdx + (verbM?.[0].length ?? 1) - 1;
4036
+ const interpolated = (verbM?.[0] ?? "").includes("$");
4037
+ const closer = findMultilineCloser(line, quoteIdx + 1, { kind: "verbatim", identifier: "", interpolated });
4038
+ if (closer !== null) {
4039
+ return { openStart: verbIdx, closesSameLine: closer.maskEnd, state: { kind: "verbatim", identifier: "", interpolated } };
4040
+ }
4041
+ return { openStart: verbIdx, closesSameLine: null, state: { kind: "verbatim", identifier: "", interpolated } };
4042
+ }
4043
+ if (lang === "powershell") {
4044
+ const re = /@("|')\s*$/;
4045
+ const tail = line.slice(from);
4046
+ const m = re.exec(tail);
4047
+ if (!m) return null;
4048
+ const openStart = from + m.index;
4049
+ if (isCommented(openStart)) return null;
4050
+ if (isInsideStringLiteral(line, openStart, from)) return null;
4051
+ const kind = m[1] === '"' ? "psHereDouble" : "psHereSingle";
4052
+ return { openStart, closesSameLine: null, state: { kind, identifier: "" } };
4053
+ }
4054
+ return null;
4055
+ }
4056
+ function stripMultilineStringSpan(line, state, lang) {
4057
+ let code = "";
4058
+ let i = 0;
4059
+ let cur = state;
4060
+ while (i < line.length) {
4061
+ if (cur !== null) {
4062
+ const closed = findMultilineCloser(line, i, cur);
4063
+ if (closed === null) {
4064
+ code += " ".repeat(line.length - i);
4065
+ i = line.length;
4066
+ continue;
4067
+ }
4068
+ code += " ".repeat(closed.maskEnd - i);
4069
+ i = closed.maskEnd;
4070
+ cur = null;
4071
+ continue;
4072
+ }
4073
+ const opened = findMultilineOpener(line, i, lang);
4074
+ if (opened === null) {
4075
+ code += line.slice(i);
4076
+ break;
4077
+ }
4078
+ code += line.slice(i, opened.openStart);
4079
+ if (opened.closesSameLine !== null) {
4080
+ code += " ".repeat(opened.closesSameLine - opened.openStart);
4081
+ i = opened.closesSameLine;
4082
+ cur = null;
4083
+ } else {
4084
+ code += " ".repeat(line.length - opened.openStart);
4085
+ i = line.length;
4086
+ cur = opened.state;
4087
+ }
4088
+ }
4089
+ return { code, state: cur };
4090
+ }
4091
+ function makeSpanSymbol(filePath, name, kind, span, parent = "", lines, style) {
4092
+ return {
4093
+ filePath,
4094
+ name,
4095
+ kind,
4096
+ lineStart: span.startLine,
4097
+ lineEnd: span.endLine,
4098
+ body: span.body,
4099
+ docstring: lines !== void 0 && style !== void 0 ? precedingDocComment(lines, span.startLine, style) : "",
4100
+ parent
4101
+ };
4102
+ }
4103
+ function makeLineSymbol(filePath, name, kind, line, sig, parent, lines, style) {
4104
+ return {
4105
+ filePath,
4106
+ name,
4107
+ kind,
4108
+ lineStart: line,
4109
+ lineEnd: line,
4110
+ body: sig ?? "",
4111
+ docstring: lines !== void 0 && style !== void 0 ? precedingDocComment(lines, line, style) : "",
4112
+ parent: parent ?? ""
4113
+ };
4114
+ }
4115
+ function makeSymbolEmitter(symbols, sections, seen, filePath, maxSymbols = 500, maxHeadingLen = 120) {
4116
+ return function emit(name, kind, line) {
4117
+ if (!name || name.length > maxHeadingLen) return;
4118
+ if (symbols.length >= maxSymbols) return;
4119
+ const key = `${name}\0${kind}\0${line}`;
4120
+ if (seen.has(key)) return;
4121
+ seen.add(key);
4122
+ symbols.push({
4123
+ filePath,
4124
+ name,
4125
+ kind,
4126
+ lineStart: line,
4127
+ lineEnd: line,
4128
+ body: "",
4129
+ docstring: "",
4130
+ parent: ""
4131
+ });
4132
+ sections.push({ heading: name, level: 1, line, endLine: line });
4133
+ };
4134
+ }
4135
+ function assignFlatEndLines(sections, totalLines) {
4136
+ for (let i = 0; i < sections.length; i++) {
4137
+ const next = sections[i + 1];
4138
+ const s = sections[i];
4139
+ if (s === void 0) continue;
4140
+ const end = next !== void 0 ? next.line - 1 : totalLines;
4141
+ s.endLine = end < s.line ? s.line : end;
4142
+ }
4143
+ }
4144
+ function propagateEndLinesToSymbols(symbols, sections) {
4145
+ const sectionMap = /* @__PURE__ */ new Map();
4146
+ for (const sec of sections) {
4147
+ const key = `${sec.heading}\0${sec.line}`;
4148
+ const queue = sectionMap.get(key);
4149
+ if (queue !== void 0) queue.push(sec.endLine);
4150
+ else sectionMap.set(key, [sec.endLine]);
4151
+ }
4152
+ return symbols.map((sym) => {
4153
+ const key = `${sym.name}\0${sym.lineStart}`;
4154
+ const endLine = sectionMap.get(key)?.shift();
4155
+ if (endLine !== void 0 && endLine !== sym.lineEnd) {
4156
+ return { ...sym, lineEnd: endLine };
4157
+ }
4158
+ return sym;
4159
+ });
4160
+ }
4161
+ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex, lineCommentPrefix) {
4162
+ let depth = 0;
4163
+ let quote = null;
4164
+ for (let i = openBraceIndex; i < content.length; i++) {
4165
+ const ch = content[i];
4166
+ if (quote !== null) {
4167
+ if (ch === "\\") {
4168
+ i++;
4169
+ continue;
4170
+ }
4171
+ if (ch === quote) quote = null;
4172
+ continue;
4173
+ }
4174
+ if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
4175
+ while (i < content.length && content[i] !== "\n") i++;
4176
+ continue;
4177
+ }
4178
+ if (ch === '"' || ch === "'") {
4179
+ quote = ch;
4180
+ continue;
4181
+ }
4182
+ if (ch === "{") depth++;
4183
+ else if (ch === "}") {
4184
+ depth--;
4185
+ if (depth === 0) {
4186
+ return offsetToLine(lineIndex, i);
4187
+ }
4188
+ }
4189
+ }
4190
+ return totalLines;
4191
+ }
4192
+
4193
+ // src/languages/ini_idx.ts
4194
+ var MAX_SECTIONS = 200;
4195
+ var MAX_HEADING_LEN = 200;
4196
+ var MAX_ENV_KEYS = 200;
4197
+ var HEADER_RE = /^\[([^\]\r\n]+)\]\s*(?:[;#].*)?$/;
4198
+ var ENV_KEY_RE = /^(?:export\s+)?([A-Za-z_][\w.-]*)\s*(?:=|:(?!\/\/))/;
4199
+ function extractIni(content, filePath) {
4200
+ const symbols = [];
4201
+ const sections = [];
4202
+ const seen = /* @__PURE__ */ new Set();
4203
+ const lines = content.split(/\r?\n/);
4204
+ const totalLines = countContentLines(content);
4205
+ for (let i = 0; i < lines.length; i++) {
4206
+ if (symbols.length >= MAX_SECTIONS) break;
4207
+ const line = lines[i] ?? "";
4208
+ if (!line || line[0] !== "[") continue;
4209
+ const m = HEADER_RE.exec(line);
4210
+ if (m === null) continue;
4211
+ const name = m[1]?.trim() ?? "";
4212
+ if (!name || name.length > MAX_HEADING_LEN) continue;
4213
+ const key = `${name}\0${i + 1}`;
4214
+ if (seen.has(key)) continue;
4215
+ seen.add(key);
4216
+ symbols.push(makeLineSymbol(filePath, name, "ini_section", i + 1));
4217
+ sections.push({ heading: name, level: 1, line: i + 1, endLine: i + 1 });
4218
+ }
4219
+ sections.sort((a, b) => a.line - b.line);
4220
+ assignFlatEndLines(sections, totalLines);
4221
+ return propagateEndLinesToSymbols(symbols, sections);
4222
+ }
4223
+ function _isEscapedQuote(line, i, q) {
4224
+ if (q === "'") return false;
4225
+ let backslashes = 0;
4226
+ let j = i - 1;
4227
+ while (j >= 0 && line[j] === "\\") {
4228
+ backslashes++;
4229
+ j--;
4230
+ }
4231
+ return backslashes % 2 === 1;
4232
+ }
4233
+ function _lineClosesQuote(line, q) {
4234
+ for (let i = 0; i < line.length; i++) {
4235
+ if (line[i] === q && !_isEscapedQuote(line, i, q)) return true;
4236
+ }
4237
+ return false;
4238
+ }
4239
+ function _detectOpenQuote(value) {
4240
+ const trimmed = value.replace(/^\s+/, "");
4241
+ const q = trimmed[0];
4242
+ if (q !== '"' && q !== "'") return null;
4243
+ for (let i = 1; i < trimmed.length; i++) {
4244
+ if (trimmed[i] === q && !_isEscapedQuote(trimmed, i, q)) return null;
4245
+ }
4246
+ return q;
4247
+ }
4248
+ function extractEnv(content, filePath) {
4249
+ const symbols = [];
4250
+ const seen = /* @__PURE__ */ new Set();
4251
+ const lines = content.split(/\r?\n/);
4252
+ let openQuote = null;
4253
+ for (let i = 0; i < lines.length; i++) {
4254
+ if (symbols.length >= MAX_ENV_KEYS) break;
4255
+ const line = lines[i] ?? "";
4256
+ if (openQuote !== null) {
4257
+ if (_lineClosesQuote(line, openQuote)) openQuote = null;
4258
+ continue;
4259
+ }
4260
+ if (!line || line[0] === "#" || line[0] === ";" || line[0] === " " || line[0] === " ") continue;
4261
+ const m = ENV_KEY_RE.exec(line);
4262
+ if (m === null) continue;
4263
+ const name = m[1]?.trim() ?? "";
4264
+ if (!name || name.length > MAX_HEADING_LEN) continue;
4265
+ const key = `${name}\0${i + 1}`;
4266
+ if (seen.has(key)) continue;
4267
+ seen.add(key);
4268
+ symbols.push(makeLineSymbol(filePath, name, "env_key", i + 1));
4269
+ openQuote = _detectOpenQuote(line.slice(m[0].length));
4270
+ }
4271
+ return symbols;
4272
+ }
4273
+
4274
+ // src/dotenv_redact.ts
4275
+ var DOTENV_VALUE_PLACEHOLDER = "[REDACTED:dotenv_value]";
4276
+ var ASSIGNMENT_RE = /^(\s*(?:export\s+)?[A-Za-z_][\w.-]*\s*(?:\+?=|:(?!\/\/)))/;
4277
+ var SAFE_LINE_RE = /^\s*(?:[#;].*)?$/;
4278
+ function isDotenvPath(filePath) {
4279
+ return detectLanguage(filePath) === "env_file";
4280
+ }
4281
+ function redactDotenvValues(text) {
4282
+ const lines = text.split("\n");
4283
+ const out = [];
4284
+ let openQuote = null;
4285
+ for (const raw of lines) {
4286
+ const hasCr = raw.endsWith("\r");
4287
+ const line = hasCr ? raw.slice(0, -1) : raw;
4288
+ const eol = hasCr ? "\r" : "";
4289
+ const emit = (s) => {
4290
+ out.push(`${s}${eol}`);
4291
+ };
4292
+ if (openQuote !== null) {
4293
+ if (_lineClosesQuote(line, openQuote)) openQuote = null;
4294
+ emit(DOTENV_VALUE_PLACEHOLDER);
4295
+ continue;
4296
+ }
4297
+ if (SAFE_LINE_RE.test(line)) {
4298
+ emit(line);
4299
+ continue;
4300
+ }
4301
+ const m = ASSIGNMENT_RE.exec(line);
4302
+ if (m === null || m[1] === void 0) {
4303
+ emit(DOTENV_VALUE_PLACEHOLDER);
4304
+ continue;
4305
+ }
4306
+ const prefix = m[1];
4307
+ openQuote = _detectOpenQuote(line.slice(prefix.length));
4308
+ emit(`${prefix}${DOTENV_VALUE_PLACEHOLDER}`);
4309
+ }
4310
+ return out.join("\n");
4311
+ }
4312
+ function redactIfDotenv(filePath, text) {
4313
+ return isDotenvPath(filePath) ? redactDotenvValues(text) : text;
4314
+ }
4315
+
3238
4316
  // src/db.ts
3239
- init_define_import_meta_env();
3240
4317
  import * as fs6 from "node:fs";
3241
4318
  import { createRequire as createRequire2 } from "node:module";
3242
- import * as path6 from "node:path";
4319
+ import * as path7 from "node:path";
3243
4320
  import Database from "better-sqlite3";
3244
4321
  var _require = createRequire2(import.meta.url);
3245
4322
  var _connections = /* @__PURE__ */ new Map();
@@ -3491,7 +4568,7 @@ CREATE TRIGGER IF NOT EXISTS cache_recall_au AFTER UPDATE ON cache_recall BEGIN
3491
4568
  VALUES (new.row_id, new.label, new.content);
3492
4569
  END;
3493
4570
  `;
3494
- var SCHEMA_VERSION = 10;
4571
+ var SCHEMA_VERSION = 11;
3495
4572
  function alterTableIdempotent(conn, sql) {
3496
4573
  try {
3497
4574
  conn.exec(sql);
@@ -3499,6 +4576,26 @@ function alterTableIdempotent(conn, sql) {
3499
4576
  if (!(err instanceof Error) || !/duplicate column/i.test(err.message)) throw err;
3500
4577
  }
3501
4578
  }
4579
+ function purgeDotenvEmbeddings(conn) {
4580
+ let paths;
4581
+ try {
4582
+ paths = conn.prepare("SELECT DISTINCT file_path FROM chunks").all().map((r) => r.file_path).filter(isDotenvPath);
4583
+ } catch {
4584
+ return;
4585
+ }
4586
+ if (paths.length === 0) return;
4587
+ for (const p of paths) {
4588
+ try {
4589
+ conn.prepare("DELETE FROM chunk_vectors WHERE rowid IN (SELECT id FROM chunks WHERE file_path = ?)").run(p);
4590
+ } catch {
4591
+ }
4592
+ conn.prepare("DELETE FROM chunks WHERE file_path = ?").run(p);
4593
+ try {
4594
+ conn.prepare("UPDATE files SET embed_sha = NULL WHERE path = ?").run(p);
4595
+ } catch {
4596
+ }
4597
+ }
4598
+ }
3502
4599
  var MIGRATIONS = {
3503
4600
  // v1 -> v2: adds files.embed_sha, tracked separately from files.sha so embedding freshness can be gated independently of parse freshness (see makeIndexer in worker.ts). A pre-existing v1 database's `files` table predates the column, so it needs an explicit ALTER TABLE here; a brand-new database already has the column from SCHEMA_SQL's CREATE TABLE above, so the ALTER TABLE would fail with "duplicate column name" there -- swallow exactly that error and rethrow anything else, so a genuine ALTER TABLE failure is never silently lost.
3504
4601
  1: (conn) => alterTableIdempotent(conn, "ALTER TABLE files ADD COLUMN embed_sha TEXT"),
@@ -3507,7 +4604,15 @@ var MIGRATIONS = {
3507
4604
  // v8 -> v9: adds symbols.parent (see SCHEMA_VERSION comment above for why). A pre-existing v8 database's `symbols` table predates the column, so it needs an explicit ALTER TABLE here; a brand-new database already has the column from SCHEMA_SQL's CREATE TABLE above, so the ALTER TABLE would fail with "duplicate column name" there -- swallow exactly that error and rethrow anything else, same pattern as v1 -> v2 / v2 -> v3 above.
3508
4605
  8: (conn) => alterTableIdempotent(conn, "ALTER TABLE symbols ADD COLUMN parent TEXT NOT NULL DEFAULT ''"),
3509
4606
  // v9 -> v10: adds hint_emissions.bytes_emitted (see SCHEMA_VERSION comment above for why). A pre-existing v9 database's `hint_emissions` table predates the column, so it needs an explicit ALTER TABLE here; a brand-new database already has the column from SCHEMA_SQL's CREATE TABLE above, so the ALTER TABLE would fail with "duplicate column name" there -- swallow exactly that error and rethrow anything else, same pattern as v1 -> v2 / v2 -> v3 / v8 -> v9 above.
3510
- 9: (conn) => alterTableIdempotent(conn, "ALTER TABLE hint_emissions ADD COLUMN bytes_emitted INTEGER")
4607
+ 9: (conn) => alterTableIdempotent(conn, "ALTER TABLE hint_emissions ADD COLUMN bytes_emitted INTEGER"),
4608
+ // v10 -> v11: purge chunks (and their vectors) for dotenv files. Until this version, a tracked
4609
+ // `.env` was chunked and embedded verbatim on the git path, so `semantic` returned its values --
4610
+ // see dotenv_redact.ts. Redacting from now on is not enough on its own: the embed-freshness gate
4611
+ // (isEmbedFresh in parser.ts) skips a file whose bytes have not changed, so an already-indexed
4612
+ // .env would have kept serving its pre-fix chunks indefinitely. Deleting the rows here both
4613
+ // removes the stored secrets and, by clearing embed_sha, makes the next drain re-embed the file
4614
+ // through the redacting path.
4615
+ 10: purgeDotenvEmbeddings
3511
4616
  };
3512
4617
  function runMigrations(conn, fromVersion, toVersion) {
3513
4618
  for (let v = fromVersion; v < toVersion; v++) {
@@ -3553,8 +4658,8 @@ function initConnection(conn) {
3553
4658
  }
3554
4659
  }
3555
4660
  function resolveDbPath(dbPath) {
3556
- if (path6.isAbsolute(dbPath)) return dbPath;
3557
- if (dbPath.includes("/") || dbPath.includes("\\")) return path6.resolve(dbPath);
4661
+ if (path7.isAbsolute(dbPath)) return dbPath;
4662
+ if (dbPath.includes("/") || dbPath.includes("\\")) return path7.resolve(dbPath);
3558
4663
  return safeJoin(dataDir(), dbPath);
3559
4664
  }
3560
4665
  function connectionKey(dbPath) {
@@ -3565,7 +4670,7 @@ function getDb(dbPath) {
3565
4670
  const { resolved, key } = connectionKey(dbPath);
3566
4671
  const existing = _connections.get(key);
3567
4672
  if (existing !== void 0) return existing;
3568
- const dir = path6.dirname(resolved);
4673
+ const dir = path7.dirname(resolved);
3569
4674
  try {
3570
4675
  ensureDirSync(dir);
3571
4676
  } catch (e) {
@@ -3596,7 +4701,6 @@ function closeAllDbs() {
3596
4701
  registerReset(closeAllDbs);
3597
4702
 
3598
4703
  // src/render/ansi.ts
3599
- init_define_import_meta_env();
3600
4704
  function _colorStream(isatty) {
3601
4705
  if (process.env["NO_COLOR"]) return false;
3602
4706
  return isatty;
@@ -3671,11 +4775,9 @@ var C = {
3671
4775
  };
3672
4776
 
3673
4777
  // src/stats.ts
3674
- init_define_import_meta_env();
3675
- import * as path7 from "node:path";
4778
+ import * as path8 from "node:path";
3676
4779
 
3677
4780
  // src/render/stats_renderer.ts
3678
- init_define_import_meta_env();
3679
4781
  var _STATS_MESSAGES_FALLBACK = {
3680
4782
  bytesModeOnlyNote: "tracks bytes, not vision tokens",
3681
4783
  sessionHintSplitNote: "session_hint shows realized savings; session_hint_overhead shows injected hint cost",
@@ -4401,6 +5503,8 @@ var KIND_TO_SOURCE = {
4401
5503
  json_outline: SOURCE_READ,
4402
5504
  yaml_query: SOURCE_READ,
4403
5505
  yaml_outline: SOURCE_READ,
5506
+ xml_query: SOURCE_READ,
5507
+ xml_outline: SOURCE_READ,
4404
5508
  openapi_op: SOURCE_READ,
4405
5509
  openapi_outline: SOURCE_READ,
4406
5510
  zip_list: SOURCE_READ,
@@ -4486,6 +5590,8 @@ var COMMAND_KINDS = {
4486
5590
  "json-outline": /* @__PURE__ */ new Set(["json_outline"]),
4487
5591
  "yaml-query": /* @__PURE__ */ new Set(["yaml_query"]),
4488
5592
  "yaml-outline": /* @__PURE__ */ new Set(["yaml_outline"]),
5593
+ "xml-query": /* @__PURE__ */ new Set(["xml_query"]),
5594
+ "xml-outline": /* @__PURE__ */ new Set(["xml_outline"]),
4489
5595
  "openapi-op": /* @__PURE__ */ new Set(["openapi_op"]),
4490
5596
  "openapi-outline": /* @__PURE__ */ new Set(["openapi_outline"]),
4491
5597
  "zip-list": /* @__PURE__ */ new Set(["zip_list"]),
@@ -4565,7 +5671,7 @@ var _globalSchemaApplied = /* @__PURE__ */ new Set();
4565
5671
  registerReset(() => _globalSchemaApplied.clear());
4566
5672
  function getGlobalDb(homeDir) {
4567
5673
  const basePath = homeDir ? dataDirForHome(homeDir) : dataDir();
4568
- const dbPath = path7.join(basePath, "global.db");
5674
+ const dbPath = path8.join(basePath, "global.db");
4569
5675
  const db = getDb(dbPath);
4570
5676
  if (!_globalSchemaApplied.has(dbPath)) {
4571
5677
  db.exec(GLOBAL_SCHEMA_SQL);
@@ -4803,7 +5909,6 @@ function renderStats2(opts) {
4803
5909
  }
4804
5910
 
4805
5911
  // src/secret_redact.ts
4806
- init_define_import_meta_env();
4807
5912
  var SECRET_PATTERNS = [
4808
5913
  // Anthropic keys share OpenAI's "sk-" prefix but are more specific
4809
5914
  // ("sk-ant-"), so they're matched first — the generic OpenAI pattern's
@@ -4821,18 +5926,52 @@ var SECRET_PATTERNS = [
4821
5926
  // contain '_' and could otherwise partially match the classic pattern.
4822
5927
  ["github_token", /github_pat_[A-Za-z0-9_]{22,}/g],
4823
5928
  ["github_token", /gh[oprsu]_[A-Za-z0-9]{36,}/g],
5929
+ // xapp- is Slack's app-level token (Socket Mode), a bearer credential in its own right that
5930
+ // the xox[baprs]- prefix does not cover. It gets its own entry rather than joining the
5931
+ // alternation above because it needs the full segmented shape (xapp-<ver>-<app id>-<digits>-
5932
+ // <hex>) to be safe: a bare /xapp-[A-Za-z0-9-]+/ redacted ordinary identifiers like
5933
+ // "xapp-config" and the css class "xapp-container", mangling normal source. The xox* prefixes
5934
+ // are distinctive enough on their own; "xapp-" is not.
4824
5935
  ["slack_token", /xox[baprs]-[A-Za-z0-9-]+/g],
5936
+ ["slack_token", /xapp-\d-[A-Za-z0-9]{6,}-\d{8,}-[A-Za-z0-9]{16,}/g],
4825
5937
  // Matches the full block (BEGIN marker through its matching END marker), not just the
4826
5938
  // header -- the actual secret material is the base64 body between them, so redacting only
4827
5939
  // the header line would leave the key bytes themselves fully readable in the cached blob.
4828
- // The lazy [\s\S]*? is bounded by the very next END marker (private key blocks don't nest),
4829
- // so this stays linear in practice despite the lazy quantifier.
4830
- ["private_key_block", /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/g],
5940
+ // The body is lazy and additionally refuses to cross a following BEGIN marker. Both halves
5941
+ // matter. The laziness bounds a successful match at the very next END marker; the negative
5942
+ // lookahead bounds a *failing* one, because a BEGIN with no END of its own would otherwise
5943
+ // scan to end-of-input, and a blob full of such markers made the pass quadratic -- 6 ms, 20 ms
5944
+ // and 78 ms for 2000, 4000 and 8000 of them, four times the work for twice the input, the same
5945
+ // shape as the lookbehind incident described above. Private key blocks do not nest, so
5946
+ // refusing to cross a BEGIN costs nothing in correctness.
5947
+ // The algorithm and ` BLOCK` groups are backreferenced in the END marker rather than repeated,
5948
+ // so a BEGIN only ever pairs with its own END spelling. Written as two independent optional
5949
+ // groups, `BEGIN PGP PRIVATE KEY` would happily close on a distant `END RSA PRIVATE KEY BLOCK`
5950
+ // and redact everything in between. A non-participating group backreferences as the empty
5951
+ // string in JS, which is exactly what the unprefixed `BEGIN PRIVATE KEY` form needs.
5952
+ // The algorithm list covers every armored private-key header openssl, ssh-keygen and gpg
5953
+ // actually emit, not just the ones a first draft happened to think of. ENCRYPTED is the
5954
+ // PKCS#8 passphrase-protected form (`openssl genpkey -aes256`, `ssh-keygen -m PKCS8`) and is
5955
+ // the most common shape of all; DSA is legacy but still written verbatim; PGP carries the
5956
+ // ` BLOCK` suffix, which is why that suffix is optional here. All three used to fall through
5957
+ // to disk in full. An encrypted key is still key material: the passphrase can be attacked
5958
+ // offline once the bytes are cached, so it is redacted like any other.
5959
+ // PuTTY `.ppk` files are deliberately not matched. They have no END marker -- the private
5960
+ // section is a `Private-Lines: N` count followed by exactly N base64 lines -- so bounding a
5961
+ // match would take a stateful parse rather than a regex, on a path that runs over every
5962
+ // command output. A regex guess at where the body ends is exactly the over-eager match this
5963
+ // module's header warns against.
5964
+ ["private_key_block", /-----BEGIN (RSA |DSA |EC |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY( BLOCK)?-----(?:(?!-----BEGIN )[\s\S])*?-----END \1PRIVATE KEY\2-----/g],
4831
5965
  // Redacts only the token itself, not the "Authorization: Bearer " prefix -- the lookbehind
4832
5966
  // anchors on the header name and scheme so the surrounding request-log line stays readable,
4833
5967
  // matching how AWS_ACCESS_KEY_ID=... above keeps its own prefix intact.
4834
- ["auth_bearer_token", /(?<=Authorization:\s*Bearer\s)[A-Za-z0-9\-._~+/]{10,}=*/gi],
4835
- ["auth_basic_token", /(?<=Authorization:\s*Basic\s)[A-Za-z0-9+/]{6,}=*/gi],
5968
+ // The optional quotes on either side of the colon are what let this see a header carried in
5969
+ // JSON rather than in raw wire format. Without them the lookbehind demanded the colon sit
5970
+ // directly against the header name and the scheme directly against the space, so a body like
5971
+ // {"Authorization": "Bearer <token>"} -- the shape any logged fetch or MCP result arrives in
5972
+ // -- matched nothing and the token was cached verbatim.
5973
+ ["auth_bearer_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Bearer[ \t])[A-Za-z0-9\-._~+/]{10,}=*/gi],
5974
+ ["auth_basic_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Basic[ \t])[A-Za-z0-9+/]{6,}=*/gi],
4836
5975
  // JWTs have no distinctive prefix of their own, but the base64url encoding of the smallest
4837
5976
  // realistic header ('{"alg":' or similar) always starts with "eyJ", so that's the practical
4838
5977
  // anchor here -- each of the three dot-separated segments requires a minimum length to avoid
@@ -4851,6 +5990,13 @@ var SECRET_PATTERNS = [
4851
5990
  // are what make the short, generic 'sig' name safe to key on: a prose or code mention of "sig"
4852
5991
  // never sits directly after a query separator followed by that much opaque token.
4853
5992
  ["presigned_signature", /(?<=[?&](?:X-Amz-Signature|X-Goog-Signature|sig)=)[A-Za-z0-9%+/=_-]{16,}/gi],
5993
+ // A password inside a connection url. `postgres://user:hunter2@db.internal` carries the
5994
+ // credential in the authority section, where there is no `key=value` separator for the
5995
+ // generic pattern below to anchor on, so a DATABASE_URL echoed by a failing migration or a
5996
+ // psql error went through untouched. The anchors are what keep this narrow: a scheme's `://`,
5997
+ // a userinfo segment, the colon, and a following `@`. `http://host:8080/path` has no `@` and
5998
+ // is left alone; so is any url without credentials.
5999
+ ["url_credentials", /(?<=:\/\/[^\s:@/]{1,64}:)[^\s:@/]{1,256}(?=@)/g],
4854
6000
  // Generic key=value assignments in .env-file and connection-string/query-string shape. The
4855
6001
  // lookbehind again redacts only the value, and the value's character class deliberately
4856
6002
  // excludes whitespace, '&', ';', '#', quote characters, and '[' ']' ':' -- that exclusion is
@@ -4866,13 +6012,19 @@ var SECRET_PATTERNS = [
4866
6012
  // this cannot backtrack catastrophically -- there is no nested or overlapping quantifier for
4867
6013
  // the engine to explore multiple ways of matching, so removing the upper bound does not
4868
6014
  // introduce a ReDoS risk.
6015
+ // Quotes are permitted around the separator, but never inside the value class. A quoted value
6016
+ // is the ordinary way secrets are written -- .env files, JSON, YAML, TOML all quote by default
6017
+ // -- and the lookbehind used to stop dead at the opening quote, so `API_KEY="..."` passed
6018
+ // through in full while the bare `API_KEY=...` was caught. The closing quote of the key name
6019
+ // blocked it from the other side too, which is what kept every JSON body unredacted. Keeping
6020
+ // quotes out of the value class is still what stops the match running past the closing quote.
4869
6021
  // The keyword may be a prefix of a longer key name rather than the whole of it, so the
4870
6022
  // trailing identifier class below is load-bearing: without it the lookbehind required the
4871
6023
  // keyword to sit immediately before the separator, and AWS_SECRET_ACCESS_KEY=,
4872
6024
  // SECRET_KEY=, and DB_PASSWORD_HASH= all passed through in full. That class matches
4873
6025
  // identifier characters only, so prose that merely mentions a keyword still never reaches
4874
6026
  // a separator and stays unredacted. api[_-]?key covers the apikey and api-key spellings too.
4875
- ["generic_secret_assignment", /(?<=(?:password|passwd|secret|api[_-]?key)[a-z0-9_-]*\s*[:=]\s*)[^\s&;#'"[\]:]{4,}/gi]
6027
+ ["generic_secret_assignment", /(?<=(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token)[a-z0-9_-]{0,64}["']?[ \t]{0,8}[:=][ \t]{0,8}["']?)(?:\\[^\n]|[^\s\\&;#'"[\],{}:]){4,}/gi]
4876
6028
  ];
4877
6029
  function redactSecrets(text) {
4878
6030
  let count = 0;
@@ -4887,7 +6039,6 @@ function redactSecrets(text) {
4887
6039
  }
4888
6040
 
4889
6041
  // src/filters.ts
4890
- init_define_import_meta_env();
4891
6042
  var DROP = () => null;
4892
6043
  var FILTERS = [
4893
6044
  {
@@ -4948,7 +6099,6 @@ var FILTERS = [
4948
6099
  ];
4949
6100
 
4950
6101
  // src/bash_compress.ts
4951
- init_define_import_meta_env();
4952
6102
  function stripAnsiCodes(text) {
4953
6103
  return stripAnsiEscapes(text);
4954
6104
  }
@@ -4968,6 +6118,8 @@ export {
4968
6118
  normalizeDarwinSystemAlias,
4969
6119
  resolveIndexPath,
4970
6120
  toDisplayPath,
6121
+ displaySafeText,
6122
+ displaySafePath,
4971
6123
  sleepSync,
4972
6124
  isWindows,
4973
6125
  isCaseInsensitiveFs,
@@ -4999,6 +6151,7 @@ export {
4999
6151
  grepFilteredToEmptyNotice,
5000
6152
  countNoun,
5001
6153
  excludeTestsHiddenNote,
6154
+ countContentLines,
5002
6155
  escapeRegExp,
5003
6156
  windowsCmdQuoteArg,
5004
6157
  redactUrlQuery,
@@ -5017,9 +6170,13 @@ export {
5017
6170
  isWithinQuietHours,
5018
6171
  hookCommandFor,
5019
6172
  suggestPackageNames,
6173
+ detectSourceEncoding,
6174
+ decodeSource,
6175
+ encodeSource,
5020
6176
  fingerprintContent,
5021
6177
  shortFingerprint,
5022
6178
  fingerprintFile,
6179
+ fileIsAbsent,
5023
6180
  canonicalize,
5024
6181
  makeProjectAt,
5025
6182
  findProject,
@@ -5042,6 +6199,36 @@ export {
5042
6199
  CONFIG_KEY_ENV_OVERRIDES,
5043
6200
  saveConfig,
5044
6201
  redactSecrets,
6202
+ precedingDocComment,
6203
+ buildLineIndex,
6204
+ offsetToLine,
6205
+ stripCstyleComments,
6206
+ stripXmlComments,
6207
+ scanQuotedStringEnd,
6208
+ stripJsComments,
6209
+ stripHashComments,
6210
+ maskHtmlNoise,
6211
+ findHtmlHeadingMatches,
6212
+ isInsideStringLiteral,
6213
+ stripBlockCommentSpan,
6214
+ stripNestedBlockCommentSpan,
6215
+ stripLineComment,
6216
+ stripStringLiterals,
6217
+ stripMultilineStringSpan,
6218
+ makeSpanSymbol,
6219
+ makeLineSymbol,
6220
+ makeSymbolEmitter,
6221
+ assignFlatEndLines,
6222
+ propagateEndLinesToSymbols,
6223
+ findMatchingBraceEndLine,
6224
+ extractIni,
6225
+ _lineClosesQuote,
6226
+ _detectOpenQuote,
6227
+ extractEnv,
6228
+ detectLanguage,
6229
+ unsupportedLanguageName,
6230
+ isDotenvPath,
6231
+ redactIfDotenv,
5045
6232
  getDb,
5046
6233
  colorStdout,
5047
6234
  RESET,
@@ -5062,8 +6249,8 @@ export {
5062
6249
 
5063
6250
  smol-toml/dist/date.js:
5064
6251
  smol-toml/dist/error.js:
5065
- smol-toml/dist/primitive.js:
5066
6252
  smol-toml/dist/util.js:
6253
+ smol-toml/dist/primitive.js:
5067
6254
  smol-toml/dist/extract.js:
5068
6255
  smol-toml/dist/struct.js:
5069
6256
  smol-toml/dist/parse.js: