token-goat 2.6.33 → 2.6.35

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 (25) hide show
  1. package/README.md +4 -0
  2. package/SECURITY.md +11 -10
  3. package/dist/{token-goat-chunk-FN6WLFIX.mjs → token-goat-chunk-D5IZEGN2.mjs} +817 -53
  4. package/dist/{token-goat-hook-chunk-HXHFLKEL.mjs → token-goat-chunk-DQIT5JIF.mjs} +7 -2
  5. package/dist/{token-goat-chunk-72R7M5H7.mjs → token-goat-chunk-DRAIYVUI.mjs} +16 -14
  6. package/dist/{token-goat-chunk-RPOXYJWK.mjs → token-goat-chunk-HW4VUKJ5.mjs} +77 -26
  7. package/dist/{token-goat-chunk-TDYTBCT4.mjs → token-goat-chunk-I2KCEGIP.mjs} +704 -138
  8. package/dist/{token-goat-chunk-WFRR2DBG.mjs → token-goat-chunk-K7W3P2TJ.mjs} +583 -343
  9. package/dist/{token-goat-chunk-OHQ7RBLL.mjs → token-goat-chunk-SIHYQCTM.mjs} +2 -2
  10. package/dist/{token-goat-chunk-77CX3MCN.mjs → token-goat-chunk-UIZVX3HN.mjs} +2 -2
  11. package/dist/{token-goat-chunk-L6FVTDPD.mjs → token-goat-chunk-Y2NH6DGZ.mjs} +564 -31
  12. package/dist/{token-goat-chunk-HPWPUBAK.mjs → token-goat-chunk-YF67EWRH.mjs} +5 -5
  13. package/dist/{token-goat-hook-chunk-E6AIPKNF.mjs → token-goat-hook-chunk-2O7P4Z6Q.mjs} +579 -339
  14. package/dist/{token-goat-hook-chunk-WBBHV6TZ.mjs → token-goat-hook-chunk-3AAH72SO.mjs} +77 -26
  15. package/dist/{token-goat-hook-chunk-QD2DX2U7.mjs → token-goat-hook-chunk-4POU6OHK.mjs} +564 -31
  16. package/dist/{token-goat-hook-chunk-ZT47M3IA.mjs → token-goat-hook-chunk-CRBMPT74.mjs} +2 -2
  17. package/dist/{token-goat-hook-chunk-26DLRODR.mjs → token-goat-hook-chunk-D6UJEFHX.mjs} +2 -2
  18. package/dist/{token-goat-hook-chunk-XBOWDNJB.mjs → token-goat-hook-chunk-J4HKWUWZ.mjs} +5 -5
  19. package/dist/{token-goat-chunk-RQQ4SY2P.mjs → token-goat-hook-chunk-NIPXIAPA.mjs} +7 -2
  20. package/dist/{token-goat-hook-chunk-VDXQXYJK.mjs → token-goat-hook-chunk-NXVT4F3S.mjs} +817 -53
  21. package/dist/{token-goat-hook-chunk-EKGDLI4D.mjs → token-goat-hook-chunk-VU6VGZBM.mjs} +16 -14
  22. package/dist/{token-goat-hook-chunk-UWV4MTYI.mjs → token-goat-hook-chunk-XM4W3WCO.mjs} +704 -138
  23. package/dist/token-goat-hook.mjs +5 -5
  24. package/dist/token-goat.core.mjs +5 -5
  25. package/package.json +11 -10
@@ -8,7 +8,7 @@ import {
8
8
  import { createRequire } from "node:module";
9
9
  function resolveVersion() {
10
10
  if (true) {
11
- return "2.6.33";
11
+ return "2.6.35";
12
12
  }
13
13
  const require2 = createRequire(import.meta.url);
14
14
  const pkg = require2("../package.json");
@@ -213,6 +213,13 @@ function fingerprintFile(filePath) {
213
213
  }
214
214
  return fingerprintContent(data);
215
215
  }
216
+ function fileIsAbsent(filePath) {
217
+ try {
218
+ return fs2.statSync(filePath, { throwIfNoEntry: false }) === void 0;
219
+ } catch {
220
+ return false;
221
+ }
222
+ }
216
223
 
217
224
  // src/paths.ts
218
225
  import * as fs3 from "node:fs";
@@ -309,10 +316,22 @@ function safeJoin(base, ...parts) {
309
316
  }
310
317
  return path2.join(base, ...parts);
311
318
  }
319
+ function displaySafeText(text) {
320
+ return text.replace(new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cf}", "gu"), (ch) => {
321
+ if (ch === "\n") return "\\n";
322
+ if (ch === "\r") return "\\r";
323
+ if (ch === " ") return "\\t";
324
+ const code = ch.codePointAt(0) ?? 0;
325
+ return code <= 255 ? "\\x" + code.toString(16).padStart(2, "0") : "\\u" + code.toString(16).padStart(4, "0");
326
+ });
327
+ }
328
+ function displaySafePath(p) {
329
+ return displaySafeText(p);
330
+ }
312
331
 
313
332
  // src/util.ts
314
333
  import { spawn, spawnSync } from "node:child_process";
315
- import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync2, unlinkSync, writeFileSync, writeSync } from "node:fs";
334
+ import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, unlinkSync, writeFileSync, writeSync } from "node:fs";
316
335
  import * as path3 from "node:path";
317
336
  function sleepSync(ms) {
318
337
  if (ms <= 0) return;
@@ -332,7 +351,7 @@ function foldPath(p) {
332
351
  }
333
352
  function statSize(absPath) {
334
353
  try {
335
- const st = statSync2(absPath);
354
+ const st = statSync3(absPath);
336
355
  return st.isFile() ? st.size : null;
337
356
  } catch {
338
357
  return null;
@@ -426,7 +445,7 @@ function atomicWriteCore(dest, content) {
426
445
  closeSync(fd);
427
446
  }
428
447
  try {
429
- const destMode = statSync2(dest).mode;
448
+ const destMode = statSync3(dest).mode;
430
449
  chmodSync2(tmp, destMode);
431
450
  } catch (e) {
432
451
  if (e.code !== "ENOENT") throw e;
@@ -550,7 +569,7 @@ function withFileLock(lockPath, fn, opts = {}) {
550
569
  }
551
570
  let stale;
552
571
  try {
553
- const st = statSync2(lockPath);
572
+ const st = statSync3(lockPath);
554
573
  stale = Date.now() - st.mtimeMs > staleMs;
555
574
  } catch {
556
575
  stale = true;
@@ -746,6 +765,11 @@ function countNoun(count, singular, plural = `${singular}s`) {
746
765
  function excludeTestsHiddenNote(count) {
747
766
  return `${count} in test ${count === 1 ? "file" : "files"} hidden by --exclude-tests`;
748
767
  }
768
+ function countContentLines(content) {
769
+ if (content === "") return 0;
770
+ const n = content.split("\n").length;
771
+ return content.endsWith("\n") ? n - 1 : n;
772
+ }
749
773
  function escapeRegExp(s) {
750
774
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
751
775
  }
@@ -935,6 +959,72 @@ function packageNameDistance(a, b, cap = 3) {
935
959
  function suggestPackageNames(query, names) {
936
960
  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);
937
961
  }
962
+ function detectSourceEncoding(buf) {
963
+ if (buf.length >= 4) {
964
+ if (buf[0] === 255 && buf[1] === 254 && buf[2] === 0 && buf[3] === 0) return "utf32le";
965
+ if (buf[0] === 0 && buf[1] === 0 && buf[2] === 254 && buf[3] === 255) return "utf32be";
966
+ }
967
+ if (buf.length >= 2) {
968
+ if (buf[0] === 255 && buf[1] === 254) return "utf16le";
969
+ if (buf[0] === 254 && buf[1] === 255) return "utf16be";
970
+ }
971
+ if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) return "utf8-bom";
972
+ return "utf8";
973
+ }
974
+ function decodeSource(buf) {
975
+ switch (detectSourceEncoding(buf)) {
976
+ case "utf32le":
977
+ return decodeUtf32(buf.subarray(4), true);
978
+ case "utf32be":
979
+ return decodeUtf32(buf.subarray(4), false);
980
+ case "utf16le":
981
+ return buf.subarray(2).toString("utf16le");
982
+ case "utf16be":
983
+ return swap16(buf.subarray(2)).toString("utf16le");
984
+ case "utf8-bom":
985
+ return buf.subarray(3).toString("utf8");
986
+ default:
987
+ return buf.toString("utf8");
988
+ }
989
+ }
990
+ function encodeSource(text, encoding) {
991
+ switch (encoding) {
992
+ case "utf32le":
993
+ return Buffer.concat([Buffer.from([255, 254, 0, 0]), encodeUtf32(text, true)]);
994
+ case "utf32be":
995
+ return Buffer.concat([Buffer.from([0, 0, 254, 255]), encodeUtf32(text, false)]);
996
+ case "utf16le":
997
+ return Buffer.concat([Buffer.from([255, 254]), Buffer.from(text, "utf16le")]);
998
+ case "utf16be":
999
+ return Buffer.concat([Buffer.from([254, 255]), swap16(Buffer.from(text, "utf16le"))]);
1000
+ case "utf8-bom":
1001
+ return Buffer.concat([Buffer.from([239, 187, 191]), Buffer.from(text, "utf8")]);
1002
+ default:
1003
+ return Buffer.from(text, "utf8");
1004
+ }
1005
+ }
1006
+ function swap16(buf) {
1007
+ const out = Buffer.from(buf);
1008
+ return out.subarray(0, out.length - out.length % 2).swap16();
1009
+ }
1010
+ function decodeUtf32(buf, littleEndian) {
1011
+ const points = [];
1012
+ for (let i = 0; i + 4 <= buf.length; i += 4) {
1013
+ const cp = littleEndian ? buf.readUInt32LE(i) : buf.readUInt32BE(i);
1014
+ points.push(cp > 1114111 || cp >= 55296 && cp <= 57343 ? 65533 : cp);
1015
+ }
1016
+ return String.fromCodePoint(...points);
1017
+ }
1018
+ function encodeUtf32(text, littleEndian) {
1019
+ const points = [...text];
1020
+ const out = Buffer.alloc(points.length * 4);
1021
+ points.forEach((ch, i) => {
1022
+ const cp = ch.codePointAt(0) ?? 65533;
1023
+ if (littleEndian) out.writeUInt32LE(cp, i * 4);
1024
+ else out.writeUInt32BE(cp, i * 4);
1025
+ });
1026
+ return out;
1027
+ }
938
1028
 
939
1029
  // src/project.ts
940
1030
  import * as fs4 from "node:fs";
@@ -1106,6 +1196,9 @@ function getDisplayRoot(explicitRoot) {
1106
1196
  _displayRootCache = { cwd, root };
1107
1197
  return root;
1108
1198
  }
1199
+ registerReset(() => {
1200
+ _displayRootCache = null;
1201
+ });
1109
1202
  function isUnderSystemTemp(filePath) {
1110
1203
  let sysTemp;
1111
1204
  try {
@@ -1285,57 +1378,111 @@ ${codeblock}`, options);
1285
1378
  }
1286
1379
  };
1287
1380
 
1381
+ // node_modules/smol-toml/dist/util.js
1382
+ function indexOfNewline(str, start = 0) {
1383
+ let idx = str.indexOf("\n", start);
1384
+ if (str.charCodeAt(idx - 1) === 13)
1385
+ idx--;
1386
+ return idx;
1387
+ }
1388
+ function skipComment(ctx) {
1389
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1390
+ let c = ctx.s.charCodeAt(ctx.p);
1391
+ if (c === 10)
1392
+ break;
1393
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
1394
+ ctx.p++;
1395
+ break;
1396
+ }
1397
+ if (c < 32 && c !== 9 || c === 127) {
1398
+ throw new TomlError("control characters are not allowed in comments", {
1399
+ toml: ctx.s,
1400
+ ptr: ctx.p
1401
+ });
1402
+ }
1403
+ }
1404
+ }
1405
+ function skipVoid(ctx, banNewLines, banComments) {
1406
+ let c;
1407
+ while (1) {
1408
+ while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
1409
+ ctx.p++;
1410
+ if (banComments || c !== 35)
1411
+ break;
1412
+ skipComment(ctx);
1413
+ }
1414
+ }
1415
+ function skipUntil(ctx, sep, end) {
1416
+ let ptr = ctx.p;
1417
+ if (!end) {
1418
+ ptr = indexOfNewline(ctx.s, ptr);
1419
+ ctx.p = ptr < 0 ? ctx.s.length : ptr;
1420
+ return;
1421
+ }
1422
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1423
+ let c = ctx.s.charCodeAt(ctx.p);
1424
+ if (c === 35) {
1425
+ skipComment(ctx);
1426
+ } else if (c === end || c === sep) {
1427
+ return;
1428
+ }
1429
+ }
1430
+ throw new TomlError("cannot find end of structure", {
1431
+ toml: ctx.s,
1432
+ ptr
1433
+ });
1434
+ }
1435
+
1288
1436
  // node_modules/smol-toml/dist/primitive.js
1289
1437
  var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
1290
1438
  var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
1291
1439
  var LEADING_ZERO = /^[+-]?0[0-9_]/;
1292
- function parseString(str, ptr) {
1293
- let c = str[ptr++];
1440
+ function parseString(ctx) {
1441
+ let start = ctx.p;
1442
+ let c = ctx.s.charCodeAt(ctx.p++);
1294
1443
  let first = c;
1295
- let isLiteral = c === "'";
1296
- let isMultiline = c === str[ptr] && c === str[ptr + 1];
1444
+ let isLiteral = c === 39;
1445
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
1297
1446
  if (isMultiline) {
1298
- if (str[ptr += 2] === "\n")
1299
- ptr++;
1300
- else if (str[ptr] === "\r" && str[ptr + 1] === "\n")
1301
- ptr += 2;
1447
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
1448
+ ctx.p++;
1449
+ else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
1450
+ ctx.p += 2;
1302
1451
  }
1303
1452
  let parsed = "";
1304
- let sliceStart = ptr;
1453
+ let sliceStart = ctx.p;
1305
1454
  let state = 0;
1306
- for (let i = ptr; i < str.length; i++) {
1307
- c = str[i];
1308
- if (isMultiline && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
1455
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1456
+ c = ctx.s.charCodeAt(ctx.p);
1457
+ if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
1309
1458
  state = state && 3;
1310
- } else if (c < " " && c !== " " || c === "\x7F") {
1459
+ } else if (c < 32 && c !== 9 || c === 127) {
1311
1460
  throw new TomlError("control characters are not allowed in strings", {
1312
- toml: str,
1313
- ptr: i
1461
+ toml: ctx.s,
1462
+ ptr: ctx.p
1314
1463
  });
1315
- } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
1464
+ } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
1316
1465
  if (isMultiline) {
1317
- if (str[i + 3] === first)
1318
- i++;
1319
- if (str[i + 3] === first)
1320
- i++;
1466
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
1467
+ ctx.p++;
1468
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
1469
+ ctx.p++;
1321
1470
  }
1322
- return [
1323
- // If we're in a newline escape still, then there's nothing to add.
1324
- // Also try to avoid concat if there's nothing to add to parsed, or nothing has been added to parsed.
1325
- state ? parsed : parsed + str.slice(sliceStart, i),
1326
- i + (isMultiline ? 3 : 1)
1327
- ];
1471
+ if (!state)
1472
+ parsed += ctx.s.slice(sliceStart, ctx.p);
1473
+ ctx.p += isMultiline ? 3 : 1;
1474
+ return parsed;
1328
1475
  } else if (!state) {
1329
- if (!isLiteral && c === "\\") {
1330
- parsed += str.slice(sliceStart, sliceStart = i);
1476
+ if (!isLiteral && c === 92) {
1477
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
1331
1478
  state = 1;
1332
1479
  }
1333
1480
  } else if (state === 1) {
1334
- if (c === "x" || c === "u" || c === "U") {
1481
+ if (c === 120 || c === 117 || c === 85) {
1335
1482
  let value = 0;
1336
- let len = c === "x" ? 2 : c === "u" ? 4 : 8;
1337
- for (let j = 0; j < len; j++, i++) {
1338
- let hex = str.charCodeAt(i + 1);
1483
+ let len = c === 120 ? 2 : c === 117 ? 4 : 8;
1484
+ for (let j = 0; j < len; j++, ctx.p++) {
1485
+ let hex = ctx.s.charCodeAt(ctx.p + 1);
1339
1486
  let digit = (
1340
1487
  /* 0-9 */
1341
1488
  hex >= 48 && hex <= 57 ? hex - 48 : (
@@ -1347,57 +1494,68 @@ function parseString(str, ptr) {
1347
1494
  )
1348
1495
  );
1349
1496
  if (digit < 0)
1350
- throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
1497
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
1351
1498
  value = value << 4 | digit;
1352
1499
  }
1353
1500
  if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
1354
- throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
1501
+ throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
1355
1502
  }
1356
1503
  parsed += String.fromCodePoint(value);
1357
- sliceStart = i + 1;
1504
+ sliceStart = ctx.p + 1;
1358
1505
  state = 0;
1359
- } else if (c === " " || c === " ") {
1506
+ } else if (c === 32 || c === 9) {
1360
1507
  state = 2;
1361
1508
  } else {
1362
- if (c === "b")
1509
+ if (c === 98)
1363
1510
  parsed += "\b";
1364
- else if (c === "t")
1511
+ else if (c === 116)
1365
1512
  parsed += " ";
1366
- else if (c === "n")
1513
+ else if (c === 110)
1367
1514
  parsed += "\n";
1368
- else if (c === "f")
1515
+ else if (c === 102)
1369
1516
  parsed += "\f";
1370
- else if (c === "r")
1517
+ else if (c === 114)
1371
1518
  parsed += "\r";
1372
- else if (c === "e")
1519
+ else if (c === 101)
1373
1520
  parsed += "\x1B";
1374
- else if (c === '"')
1521
+ else if (c === 34)
1375
1522
  parsed += '"';
1376
- else if (c === "\\")
1523
+ else if (c === 92)
1377
1524
  parsed += "\\";
1378
1525
  else
1379
- throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
1380
- sliceStart = i + 1;
1526
+ throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
1527
+ sliceStart = ctx.p + 1;
1381
1528
  state = 0;
1382
1529
  }
1383
- } else if (c !== " " && c !== " ") {
1530
+ } else if (c !== 32 && c !== 9) {
1384
1531
  if (state === 2) {
1385
1532
  throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
1386
- toml: str,
1533
+ toml: ctx.s,
1387
1534
  ptr: sliceStart
1388
1535
  });
1389
1536
  }
1390
- state = !isLiteral && c === "\\" ? 1 : 0;
1391
- sliceStart = i;
1537
+ state = !isLiteral && c === 92 ? 1 : 0;
1538
+ sliceStart = ctx.p;
1392
1539
  }
1393
1540
  }
1394
- throw new TomlError("unfinished string", { toml: str, ptr });
1541
+ throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
1395
1542
  }
1396
- function parseValue(value, toml, ptr, integersAsBigInt) {
1397
- if (value === "true")
1398
- return true;
1399
- if (value === "false")
1400
- return false;
1543
+ function sliceAndTrimEndOf(ctx, start, end) {
1544
+ let value = ctx.s.slice(start, end);
1545
+ let commentIdx = value.indexOf("#");
1546
+ if (commentIdx > 0) {
1547
+ skipComment({ s: value, p: commentIdx, d: 0 });
1548
+ value = value.slice(0, commentIdx);
1549
+ }
1550
+ return value.trimEnd();
1551
+ }
1552
+ function parseValue(ctx, integersAsBigInt, end) {
1553
+ let ptr = ctx.p;
1554
+ let err = { toml: ctx.s, ptr };
1555
+ skipUntil(ctx, 44, end);
1556
+ let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
1557
+ if (!value)
1558
+ throw new TomlError("incomplete declaration: value expected", err);
1401
1559
  if (value === "-inf")
1402
1560
  return -Infinity;
1403
1561
  if (value === "inf" || value === "+inf")
@@ -1409,25 +1567,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
1409
1567
  let isInt = INT_REGEX.test(value);
1410
1568
  if (isInt || FLOAT_REGEX.test(value)) {
1411
1569
  if (LEADING_ZERO.test(value)) {
1412
- throw new TomlError("leading zeroes are not allowed", {
1413
- toml,
1414
- ptr
1415
- });
1570
+ throw new TomlError("leading zeroes are not allowed", err);
1416
1571
  }
1417
1572
  value = value.replace(/_/g, "");
1418
1573
  let numeric = +value;
1419
1574
  if (isNaN(numeric)) {
1420
- throw new TomlError("invalid number", {
1421
- toml,
1422
- ptr
1423
- });
1575
+ throw new TomlError("invalid number", err);
1424
1576
  }
1425
1577
  if (isInt) {
1426
1578
  if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
1427
- throw new TomlError("integer value cannot be represented losslessly", {
1428
- toml,
1429
- ptr
1430
- });
1579
+ throw new TomlError("integer value cannot be represented losslessly", err);
1431
1580
  }
1432
1581
  if (isInt || integersAsBigInt === true)
1433
1582
  numeric = BigInt(value);
@@ -1435,277 +1584,184 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
1435
1584
  return numeric;
1436
1585
  }
1437
1586
  const date = new TomlDate(value);
1438
- if (!date.isValid()) {
1439
- throw new TomlError("invalid value", {
1440
- toml,
1441
- ptr
1442
- });
1443
- }
1587
+ if (!date.isValid())
1588
+ throw new TomlError("invalid value", err);
1444
1589
  return date;
1445
1590
  }
1446
1591
 
1447
- // node_modules/smol-toml/dist/util.js
1448
- function indexOfNewline(str, start = 0, end = str.length) {
1449
- let idx = str.indexOf("\n", start);
1450
- if (str[idx - 1] === "\r")
1451
- idx--;
1452
- return idx <= end ? idx : -1;
1453
- }
1454
- function skipComment(str, ptr) {
1455
- for (let i = ptr; i < str.length; i++) {
1456
- let c = str[i];
1457
- if (c === "\n")
1458
- return i;
1459
- if (c === "\r" && str[i + 1] === "\n")
1460
- return i + 1;
1461
- if (c < " " && c !== " " || c === "\x7F") {
1462
- throw new TomlError("control characters are not allowed in comments", {
1463
- toml: str,
1592
+ // node_modules/smol-toml/dist/extract.js
1593
+ function extractValue(ctx, end, integersAsBigInt) {
1594
+ let ptr = ctx.p;
1595
+ let c = ctx.s.charCodeAt(ptr);
1596
+ if (c === 91 || c === 123) {
1597
+ if (!ctx.d--) {
1598
+ throw new TomlError("document contains excessively nested structures. aborting.", {
1599
+ toml: ctx.s,
1464
1600
  ptr
1465
1601
  });
1466
1602
  }
1603
+ let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
1604
+ ctx.d++;
1605
+ return value;
1467
1606
  }
1468
- return str.length;
1469
- }
1470
- function skipVoid(str, ptr, banNewLines, banComments) {
1471
- let c;
1472
- while (1) {
1473
- while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
1474
- ptr++;
1475
- if (banComments || c !== "#")
1476
- break;
1477
- ptr = skipComment(str, ptr);
1478
- }
1479
- return ptr;
1480
- }
1481
- function skipUntil(str, ptr, sep, end, banNewLines = false) {
1482
- if (!end) {
1483
- ptr = indexOfNewline(str, ptr);
1484
- return ptr < 0 ? str.length : ptr;
1485
- }
1486
- for (let i = ptr; i < str.length; i++) {
1487
- let c = str[i];
1488
- if (c === "#") {
1489
- i = indexOfNewline(str, i);
1490
- } else if (c === sep) {
1491
- return i + 1;
1492
- } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
1493
- return i;
1494
- }
1495
- }
1496
- throw new TomlError("cannot find end of structure", {
1497
- toml: str,
1498
- ptr
1499
- });
1500
- }
1501
-
1502
- // node_modules/smol-toml/dist/extract.js
1503
- function sliceAndTrimEndOf(str, startPtr, endPtr) {
1504
- let value = str.slice(startPtr, endPtr);
1505
- let commentIdx = value.indexOf("#");
1506
- if (commentIdx > -1) {
1507
- skipComment(str, commentIdx);
1508
- value = value.slice(0, commentIdx);
1509
- }
1510
- return [value.trimEnd(), commentIdx];
1511
- }
1512
- function extractValue(str, ptr, end, depth, integersAsBigInt) {
1513
- if (depth === 0) {
1514
- throw new TomlError("document contains excessively nested structures. aborting.", {
1515
- toml: str,
1516
- ptr
1517
- });
1518
- }
1519
- let c = str[ptr];
1520
- if (c === "[" || c === "{") {
1521
- let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
1522
- if (end) {
1523
- endPtr2 = skipVoid(str, endPtr2);
1524
- if (str[endPtr2] === ",")
1525
- endPtr2++;
1526
- else if (str[endPtr2] !== end) {
1527
- throw new TomlError("expected comma or end of structure", {
1528
- toml: str,
1529
- ptr: endPtr2
1530
- });
1531
- }
1532
- }
1533
- return [value, endPtr2];
1534
- }
1535
- if (c === '"' || c === "'") {
1536
- let [parsed, endPtr2] = parseString(str, ptr);
1537
- if (end) {
1538
- endPtr2 = skipVoid(str, endPtr2);
1539
- if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
1540
- throw new TomlError("unexpected character encountered", {
1541
- toml: str,
1542
- ptr: endPtr2
1543
- });
1544
- }
1545
- if (str[endPtr2] === ",")
1546
- endPtr2++;
1547
- }
1548
- return [parsed, endPtr2];
1607
+ if (c === 34 || c === 39) {
1608
+ return parseString(ctx);
1549
1609
  }
1550
- let endPtr = skipUntil(str, ptr, ",", end);
1551
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
1552
- if (!slice[0]) {
1553
- throw new TomlError("incomplete key-value declaration: no value specified", {
1554
- toml: str,
1555
- ptr
1556
- });
1610
+ if (c === 116) {
1611
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
1612
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
1613
+ ctx.p++;
1614
+ return true;
1557
1615
  }
1558
- if (end && slice[1] > -1) {
1559
- endPtr = skipVoid(str, ptr + slice[1]);
1560
- if (str[endPtr] === ",")
1561
- endPtr++;
1616
+ if (c === 102) {
1617
+ 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)
1618
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
1619
+ ctx.p++;
1620
+ return false;
1562
1621
  }
1563
- return [
1564
- parseValue(slice[0], str, ptr, integersAsBigInt),
1565
- endPtr
1566
- ];
1622
+ return parseValue(ctx, integersAsBigInt, end);
1567
1623
  }
1568
1624
 
1569
1625
  // node_modules/smol-toml/dist/struct.js
1570
1626
  var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
1571
- function parseKey(str, ptr, end = "=") {
1572
- let dot = ptr - 1;
1627
+ function parseKey(ctx, end = "=") {
1628
+ let start = ctx.p;
1629
+ let dot = start - 1;
1573
1630
  let parsed = [];
1574
- let endPtr = str.indexOf(end, ptr);
1631
+ let endPtr = ctx.s.indexOf(end, start);
1575
1632
  if (endPtr < 0) {
1576
1633
  throw new TomlError("incomplete key-value: cannot find end of key", {
1577
- toml: str,
1578
- ptr
1634
+ toml: ctx.s,
1635
+ ptr: start
1579
1636
  });
1580
1637
  }
1581
1638
  do {
1582
- let c = str[ptr = ++dot];
1583
- if (c !== " " && c !== " ") {
1584
- if (c === '"' || c === "'") {
1585
- if (c === str[ptr + 1] && c === str[ptr + 2]) {
1639
+ let c = ctx.s.charCodeAt(ctx.p = ++dot);
1640
+ if (c !== 32 && c !== 9) {
1641
+ if (c === 34 || c === 39) {
1642
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
1586
1643
  throw new TomlError("multiline strings are not allowed in keys", {
1587
- toml: str,
1588
- ptr
1644
+ toml: ctx.s,
1645
+ ptr: ctx.p
1589
1646
  });
1590
1647
  }
1591
- let [part, eos] = parseString(str, ptr);
1592
- dot = str.indexOf(".", eos);
1593
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
1648
+ let part = parseString(ctx);
1649
+ dot = ctx.s.indexOf(".", ctx.p);
1650
+ let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1594
1651
  let newLine = indexOfNewline(strEnd);
1595
1652
  if (newLine > -1) {
1596
1653
  throw new TomlError("newlines are not allowed in keys", {
1597
- toml: str,
1598
- ptr: ptr + dot + newLine
1654
+ toml: ctx.s,
1655
+ ptr: newLine
1599
1656
  });
1600
1657
  }
1601
1658
  if (strEnd.trimStart()) {
1602
1659
  throw new TomlError("found extra tokens after the string part", {
1603
- toml: str,
1604
- ptr: eos
1660
+ toml: ctx.s,
1661
+ ptr: ctx.p
1605
1662
  });
1606
1663
  }
1607
- if (endPtr < eos) {
1608
- endPtr = str.indexOf(end, eos);
1664
+ if (endPtr < ctx.p) {
1665
+ endPtr = ctx.s.indexOf(end, ctx.p);
1609
1666
  if (endPtr < 0) {
1610
1667
  throw new TomlError("incomplete key-value: cannot find end of key", {
1611
- toml: str,
1612
- ptr
1668
+ toml: ctx.s,
1669
+ ptr: start
1613
1670
  });
1614
1671
  }
1615
1672
  }
1616
1673
  parsed.push(part);
1617
1674
  } else {
1618
- dot = str.indexOf(".", ptr);
1619
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
1675
+ dot = ctx.s.indexOf(".", ctx.p);
1676
+ let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1620
1677
  if (!KEY_PART_RE.test(part)) {
1621
1678
  throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
1622
- toml: str,
1623
- ptr
1679
+ toml: ctx.s,
1680
+ ptr: ctx.p
1624
1681
  });
1625
1682
  }
1626
1683
  parsed.push(part.trimEnd());
1627
1684
  }
1628
1685
  }
1629
1686
  } while (dot + 1 && dot < endPtr);
1630
- return [parsed, skipVoid(str, endPtr + 1, true, true)];
1687
+ ctx.p = endPtr + 1;
1688
+ skipVoid(ctx, true, true);
1689
+ return parsed;
1631
1690
  }
1632
- function parseInlineTable(str, ptr, depth, integersAsBigInt) {
1691
+ function parseInlineTable(ctx, integersAsBigInt) {
1633
1692
  let res = {};
1634
1693
  let seen = /* @__PURE__ */ new Set();
1635
1694
  let c;
1636
- ptr++;
1637
- while ((c = str[ptr++]) !== "}" && c) {
1638
- if (c === ",") {
1639
- throw new TomlError("expected value, found comma", {
1640
- toml: str,
1641
- ptr: ptr - 1
1642
- });
1643
- } else if (c === "#")
1644
- ptr = skipComment(str, ptr);
1645
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
1646
- let k;
1647
- let t = res;
1648
- let hasOwn = false;
1649
- let [key, keyEndPtr] = parseKey(str, ptr - 1);
1650
- for (let i = 0; i < key.length; i++) {
1651
- if (i)
1652
- t = hasOwn ? t[k] : t[k] = {};
1653
- k = key[i];
1654
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
1655
- throw new TomlError("trying to redefine an already defined value", {
1656
- toml: str,
1657
- ptr
1658
- });
1659
- }
1660
- if (!hasOwn && k === "__proto__") {
1661
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1662
- }
1663
- }
1664
- if (hasOwn) {
1695
+ ctx.p++;
1696
+ while (ctx.p < ctx.s.length) {
1697
+ skipVoid(ctx);
1698
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
1699
+ ctx.p++;
1700
+ return res;
1701
+ }
1702
+ let k;
1703
+ let t = res;
1704
+ let hasOwn = false;
1705
+ let p = ctx.p;
1706
+ let key = parseKey(ctx);
1707
+ for (let i = 0; i < key.length; i++) {
1708
+ if (i)
1709
+ t = hasOwn ? t[k] : t[k] = {};
1710
+ k = key[i];
1711
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
1665
1712
  throw new TomlError("trying to redefine an already defined value", {
1666
- toml: str,
1667
- ptr
1713
+ toml: ctx.s,
1714
+ ptr: p
1668
1715
  });
1669
1716
  }
1670
- let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
1671
- seen.add(value);
1672
- t[k] = value;
1673
- ptr = valueEndPtr;
1717
+ if (!hasOwn && k === "__proto__") {
1718
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1719
+ }
1720
+ }
1721
+ if (hasOwn) {
1722
+ throw new TomlError("trying to redefine an already defined value", {
1723
+ toml: ctx.s,
1724
+ ptr: ctx.p
1725
+ });
1726
+ }
1727
+ let value = extractValue(ctx, 125, integersAsBigInt);
1728
+ seen.add(t[k] = value);
1729
+ skipVoid(ctx);
1730
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
1731
+ return res;
1732
+ }
1733
+ if (c !== 44) {
1734
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1674
1735
  }
1675
1736
  }
1676
- if (!c) {
1677
- throw new TomlError("unfinished table encountered", {
1678
- toml: str,
1679
- ptr
1680
- });
1681
- }
1682
- return [res, ptr];
1737
+ throw new TomlError("unfinished table encountered", {
1738
+ toml: ctx.s,
1739
+ ptr: ctx.p
1740
+ });
1683
1741
  }
1684
- function parseArray(str, ptr, depth, integersAsBigInt) {
1742
+ function parseArray(ctx, integersAsBigInt) {
1685
1743
  let res = [];
1686
1744
  let c;
1687
- ptr++;
1688
- while ((c = str[ptr++]) !== "]" && c) {
1689
- if (c === ",") {
1690
- throw new TomlError("expected value, found comma", {
1691
- toml: str,
1692
- ptr: ptr - 1
1693
- });
1694
- } else if (c === "#")
1695
- ptr = skipComment(str, ptr);
1696
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
1697
- let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
1698
- res.push(e[0]);
1699
- ptr = e[1];
1700
- }
1701
- }
1702
- if (!c) {
1703
- throw new TomlError("unfinished array encountered", {
1704
- toml: str,
1705
- ptr
1706
- });
1745
+ ctx.p++;
1746
+ while (ctx.p < ctx.s.length) {
1747
+ skipVoid(ctx);
1748
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
1749
+ ctx.p++;
1750
+ return res;
1751
+ }
1752
+ res.push(extractValue(ctx, 93, integersAsBigInt));
1753
+ skipVoid(ctx);
1754
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
1755
+ return res;
1756
+ }
1757
+ if (c !== 44) {
1758
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1759
+ }
1707
1760
  }
1708
- return [res, ptr];
1761
+ throw new TomlError("unfinished array encountered", {
1762
+ toml: ctx.s,
1763
+ ptr: ctx.p
1764
+ });
1709
1765
  }
1710
1766
 
1711
1767
  // node_modules/smol-toml/dist/parse.js
@@ -1769,25 +1825,29 @@ function peekTable(key, table, meta, type) {
1769
1825
  return [k, t, state.c];
1770
1826
  }
1771
1827
  function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1828
+ let ctx = { s: toml, p: 0, d: maxDepth };
1772
1829
  let res = {};
1773
1830
  let meta = {};
1831
+ let tmp;
1774
1832
  let tbl = res;
1775
1833
  let m = meta;
1776
- for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
1777
- if (toml[ptr] === "[") {
1778
- let isTableArray = toml[++ptr] === "[";
1779
- let k = parseKey(toml, ptr += +isTableArray, "]");
1834
+ skipVoid(ctx);
1835
+ while (ctx.p < toml.length) {
1836
+ if (toml.charCodeAt(ctx.p) === 91) {
1837
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1838
+ tmp = ctx.p += +isTableArray;
1839
+ let k = parseKey(ctx, "]");
1780
1840
  if (isTableArray) {
1781
- if (toml[k[1] - 1] !== "]") {
1841
+ if (toml.charCodeAt(ctx.p - 1) !== 93) {
1782
1842
  throw new TomlError("expected end of table declaration", {
1783
1843
  toml,
1784
- ptr: k[1] - 1
1844
+ ptr: ctx.p - 1
1785
1845
  });
1786
1846
  }
1787
- k[1]++;
1847
+ ctx.p++;
1788
1848
  }
1789
1849
  let p = peekTable(
1790
- k[0],
1850
+ k,
1791
1851
  res,
1792
1852
  meta,
1793
1853
  isTableArray ? 2 : 1
@@ -1796,16 +1856,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1796
1856
  if (!p) {
1797
1857
  throw new TomlError("trying to redefine an already defined table or value", {
1798
1858
  toml,
1799
- ptr
1859
+ ptr: tmp
1800
1860
  });
1801
1861
  }
1802
1862
  m = p[2];
1803
1863
  tbl = p[1];
1804
- ptr = k[1];
1805
1864
  } else {
1806
- let k = parseKey(toml, ptr);
1865
+ tmp = ctx.p;
1866
+ let k = parseKey(ctx);
1807
1867
  let p = peekTable(
1808
- k[0],
1868
+ k,
1809
1869
  tbl,
1810
1870
  m,
1811
1871
  0
@@ -1814,21 +1874,19 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1814
1874
  if (!p) {
1815
1875
  throw new TomlError("trying to redefine an already defined table or value", {
1816
1876
  toml,
1817
- ptr
1877
+ ptr: tmp
1818
1878
  });
1819
1879
  }
1820
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
1821
- p[1][p[0]] = v[0];
1822
- ptr = v[1];
1880
+ p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
1823
1881
  }
1824
- ptr = skipVoid(toml, ptr, true);
1825
- if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
1882
+ skipVoid(ctx, true);
1883
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
1826
1884
  throw new TomlError("each key-value declaration must be followed by an end-of-line", {
1827
1885
  toml,
1828
- ptr
1886
+ ptr: ctx.p
1829
1887
  });
1830
1888
  }
1831
- ptr = skipVoid(toml, ptr);
1889
+ skipVoid(ctx);
1832
1890
  }
1833
1891
  return res;
1834
1892
  }
@@ -1840,8 +1898,12 @@ function extendedTypeOf(obj) {
1840
1898
  if (type === "object") {
1841
1899
  if (Array.isArray(obj))
1842
1900
  return "array";
1843
- if (obj instanceof Date)
1901
+ if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
1844
1902
  return "date";
1903
+ if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
1904
+ typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
1905
+ return "temporal";
1906
+ }
1845
1907
  }
1846
1908
  return type;
1847
1909
  }
@@ -1855,38 +1917,42 @@ function isArrayOfTables(obj) {
1855
1917
  function formatString(s) {
1856
1918
  return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
1857
1919
  }
1920
+ function stringifyTemporal(temporal) {
1921
+ return temporal.toString({
1922
+ calendarName: "never",
1923
+ timeZoneName: "never"
1924
+ });
1925
+ }
1858
1926
  function stringifyValue(val, type, depth, numberAsFloat) {
1859
1927
  if (depth === 0) {
1860
1928
  throw new Error("Could not stringify the object: maximum object depth exceeded");
1861
1929
  }
1862
- if (type === "number") {
1863
- if (isNaN(val))
1864
- return "nan";
1865
- if (val === Infinity)
1866
- return "inf";
1867
- if (val === -Infinity)
1868
- return "-inf";
1869
- if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
1870
- return val.toFixed(1);
1871
- return val.toString();
1872
- }
1873
- if (type === "bigint" || type === "boolean") {
1874
- return val.toString();
1875
- }
1876
- if (type === "string") {
1877
- return formatString(val);
1878
- }
1879
- if (type === "date") {
1880
- if (isNaN(val.getTime())) {
1881
- throw new TypeError("cannot serialize invalid date");
1882
- }
1883
- return val.toISOString();
1884
- }
1885
- if (type === "object") {
1886
- return stringifyInlineTable(val, depth, numberAsFloat);
1887
- }
1888
- if (type === "array") {
1889
- return stringifyArray(val, depth, numberAsFloat);
1930
+ switch (type) {
1931
+ // @ts-expect-error -- intentional fallthrough case
1932
+ case "number":
1933
+ if (isNaN(val))
1934
+ return "nan";
1935
+ if (val === Infinity)
1936
+ return "inf";
1937
+ if (val === -Infinity)
1938
+ return "-inf";
1939
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
1940
+ return val.toFixed(1);
1941
+ case "bigint":
1942
+ case "boolean":
1943
+ return val.toString();
1944
+ case "string":
1945
+ return formatString(val);
1946
+ case "date":
1947
+ if (isNaN(val.getTime()))
1948
+ throw new TypeError("cannot serialize invalid date");
1949
+ return val.toISOString();
1950
+ case "object":
1951
+ return stringifyInlineTable(val, depth, numberAsFloat);
1952
+ case "array":
1953
+ return stringifyArray(val, depth, numberAsFloat);
1954
+ case "temporal":
1955
+ return stringifyTemporal(val);
1890
1956
  }
1891
1957
  }
1892
1958
  function stringifyInlineTable(obj, depth, numberAsFloat) {
@@ -2445,7 +2511,7 @@ function getLastProjectConfigParseError() {
2445
2511
  return _lastProjectConfigParseError;
2446
2512
  }
2447
2513
  var PROJECT_LOCKED_SECTIONS = ["injection", "webfetch", "gdrive", "mcp", "network"];
2448
- var PROJECT_LOCKED_KEYS = ["indexing.cross_project_symbols"];
2514
+ var PROJECT_LOCKED_KEYS = ["indexing.cross_project_symbols", "worker.blocked_roots"];
2449
2515
  var _lastProjectConfigLockedKeys = [];
2450
2516
  function stripLockedProjectKeys(projectRaw) {
2451
2517
  const cleaned = {};
@@ -2617,6 +2683,9 @@ function resolveConfigProjectRoot() {
2617
2683
  _projectRootCache = { cwd, root };
2618
2684
  return root;
2619
2685
  }
2686
+ registerReset(() => {
2687
+ _projectRootCache = null;
2688
+ });
2620
2689
  function isAutoTriggerMultiplierExplicit() {
2621
2690
  const setsMultiplier = (text) => {
2622
2691
  const raw = parse(text);
@@ -4108,7 +4177,8 @@ function propagateEndLinesToSymbols(symbols, sections) {
4108
4177
  return sym;
4109
4178
  });
4110
4179
  }
4111
- function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex) {
4180
+ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex, lineCommentPrefix, opts) {
4181
+ const block = opts?.blockComment;
4112
4182
  let depth = 0;
4113
4183
  let quote = null;
4114
4184
  for (let i = openBraceIndex; i < content.length; i++) {
@@ -4121,6 +4191,15 @@ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex
4121
4191
  if (ch === quote) quote = null;
4122
4192
  continue;
4123
4193
  }
4194
+ if (block !== void 0 && content.startsWith(block[0], i)) {
4195
+ const close = content.indexOf(block[1], i + block[0].length);
4196
+ i = close === -1 ? content.length : close + block[1].length - 1;
4197
+ continue;
4198
+ }
4199
+ if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
4200
+ while (i < content.length && content[i] !== "\n") i++;
4201
+ continue;
4202
+ }
4124
4203
  if (ch === '"' || ch === "'") {
4125
4204
  quote = ch;
4126
4205
  continue;
@@ -4133,7 +4212,106 @@ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex
4133
4212
  }
4134
4213
  }
4135
4214
  }
4136
- return totalLines;
4215
+ return opts?.noMatchValue ?? totalLines;
4216
+ }
4217
+ function assignBraceBlockSpans(symbols, content, lineCommentPrefix) {
4218
+ if (symbols.length === 0) return [...symbols];
4219
+ const lines = content.split("\n");
4220
+ const totalLines = lines.length;
4221
+ const lineIndex = buildLineIndex(content);
4222
+ const starts = [...new Set(symbols.map((s) => s.lineStart))].sort((a, b) => a - b);
4223
+ const blockComment = lineCommentPrefix === "//" ? ["/*", "*/"] : lineCommentPrefix === "#" ? ["<#", "#>"] : void 0;
4224
+ return symbols.map((sym) => {
4225
+ if (sym.lineEnd !== sym.lineStart) return sym;
4226
+ const nextStart = starts.find((s) => s > sym.lineStart);
4227
+ const lastSearchLine = Math.min(nextStart !== void 0 ? nextStart - 1 : totalLines, sym.lineStart + BRACE_SEARCH_MAX_LINES);
4228
+ const openIndex = findBlockOpenBrace(content, lineIndex, sym.lineStart, lastSearchLine, lineCommentPrefix, blockComment);
4229
+ if (openIndex === null) return sym;
4230
+ const endLine = findMatchingBraceEndLine(
4231
+ content,
4232
+ openIndex,
4233
+ totalLines,
4234
+ lineIndex,
4235
+ lineCommentPrefix,
4236
+ blockComment === void 0 ? { noMatchValue: -1 } : { blockComment, noMatchValue: -1 }
4237
+ );
4238
+ if (endLine <= sym.lineStart) return sym;
4239
+ return { ...sym, lineEnd: endLine, body: lines.slice(sym.lineStart - 1, endLine).join("\n") };
4240
+ });
4241
+ }
4242
+ var BRACE_SEARCH_MAX_LINES = 10;
4243
+ function findBlockOpenBrace(content, lineIndex, startLine, lastSearchLine, lineCommentPrefix, blockComment) {
4244
+ const from = lineIndex[startLine - 1];
4245
+ if (from === void 0) return null;
4246
+ const to = lineIndex[lastSearchLine] ?? content.length;
4247
+ let quote = null;
4248
+ let parenDepth = 0;
4249
+ let linesSeen = 0;
4250
+ let atLineStart = false;
4251
+ for (let i = from; i < to; i++) {
4252
+ const ch = content[i];
4253
+ if (ch === void 0) break;
4254
+ if (quote !== null) {
4255
+ if (ch === "\\") {
4256
+ i++;
4257
+ continue;
4258
+ }
4259
+ if (ch === quote) quote = null;
4260
+ continue;
4261
+ }
4262
+ if (ch === "\n") {
4263
+ linesSeen++;
4264
+ atLineStart = true;
4265
+ continue;
4266
+ }
4267
+ if (blockComment !== void 0 && content.startsWith(blockComment[0], i)) {
4268
+ const close = content.indexOf(blockComment[1], i + blockComment[0].length);
4269
+ if (close === -1) return null;
4270
+ i = close + blockComment[1].length - 1;
4271
+ continue;
4272
+ }
4273
+ if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
4274
+ while (i + 1 < to && content[i + 1] !== "\n") i++;
4275
+ continue;
4276
+ }
4277
+ if (atLineStart && !/\s/.test(ch)) {
4278
+ atLineStart = false;
4279
+ if (parenDepth === 0 && linesSeen >= 1 && startsWithBlockKeyword(content, i, to)) return null;
4280
+ }
4281
+ if (ch === '"' || ch === "'") {
4282
+ quote = ch;
4283
+ continue;
4284
+ }
4285
+ if (ch === "(" || ch === "[") parenDepth++;
4286
+ else if (ch === ")" || ch === "]") {
4287
+ if (parenDepth > 0) parenDepth--;
4288
+ } else if (ch === ";") return null;
4289
+ else if (ch === "{") return i;
4290
+ }
4291
+ return null;
4292
+ }
4293
+ var BLOCK_OPENING_KEYWORDS = /* @__PURE__ */ new Set([
4294
+ "if",
4295
+ "for",
4296
+ "while",
4297
+ "do",
4298
+ "switch",
4299
+ "when",
4300
+ "match",
4301
+ "try",
4302
+ "foreach",
4303
+ "loop",
4304
+ "guard",
4305
+ "repeat",
4306
+ "unless",
4307
+ "until"
4308
+ ]);
4309
+ function startsWithBlockKeyword(content, i, to) {
4310
+ const first = content[i];
4311
+ if (first === void 0 || !/[A-Za-z_]/.test(first)) return false;
4312
+ let j = i + 1;
4313
+ while (j < to && /[A-Za-z0-9_]/.test(content[j])) j++;
4314
+ return BLOCK_OPENING_KEYWORDS.has(content.slice(i, j));
4137
4315
  }
4138
4316
 
4139
4317
  // src/languages/ini_idx.ts
@@ -4147,7 +4325,7 @@ function extractIni(content, filePath) {
4147
4325
  const sections = [];
4148
4326
  const seen = /* @__PURE__ */ new Set();
4149
4327
  const lines = content.split(/\r?\n/);
4150
- const totalLines = lines.length;
4328
+ const totalLines = countContentLines(content);
4151
4329
  for (let i = 0; i < lines.length; i++) {
4152
4330
  if (symbols.length >= MAX_SECTIONS) break;
4153
4331
  const line = lines[i] ?? "";
@@ -5449,6 +5627,8 @@ var KIND_TO_SOURCE = {
5449
5627
  json_outline: SOURCE_READ,
5450
5628
  yaml_query: SOURCE_READ,
5451
5629
  yaml_outline: SOURCE_READ,
5630
+ xml_query: SOURCE_READ,
5631
+ xml_outline: SOURCE_READ,
5452
5632
  openapi_op: SOURCE_READ,
5453
5633
  openapi_outline: SOURCE_READ,
5454
5634
  zip_list: SOURCE_READ,
@@ -5534,6 +5714,8 @@ var COMMAND_KINDS = {
5534
5714
  "json-outline": /* @__PURE__ */ new Set(["json_outline"]),
5535
5715
  "yaml-query": /* @__PURE__ */ new Set(["yaml_query"]),
5536
5716
  "yaml-outline": /* @__PURE__ */ new Set(["yaml_outline"]),
5717
+ "xml-query": /* @__PURE__ */ new Set(["xml_query"]),
5718
+ "xml-outline": /* @__PURE__ */ new Set(["xml_outline"]),
5537
5719
  "openapi-op": /* @__PURE__ */ new Set(["openapi_op"]),
5538
5720
  "openapi-outline": /* @__PURE__ */ new Set(["openapi_outline"]),
5539
5721
  "zip-list": /* @__PURE__ */ new Set(["zip_list"]),
@@ -5868,13 +6050,42 @@ var SECRET_PATTERNS = [
5868
6050
  // contain '_' and could otherwise partially match the classic pattern.
5869
6051
  ["github_token", /github_pat_[A-Za-z0-9_]{22,}/g],
5870
6052
  ["github_token", /gh[oprsu]_[A-Za-z0-9]{36,}/g],
6053
+ // xapp- is Slack's app-level token (Socket Mode), a bearer credential in its own right that
6054
+ // the xox[baprs]- prefix does not cover. It gets its own entry rather than joining the
6055
+ // alternation above because it needs the full segmented shape (xapp-<ver>-<app id>-<digits>-
6056
+ // <hex>) to be safe: a bare /xapp-[A-Za-z0-9-]+/ redacted ordinary identifiers like
6057
+ // "xapp-config" and the css class "xapp-container", mangling normal source. The xox* prefixes
6058
+ // are distinctive enough on their own; "xapp-" is not.
5871
6059
  ["slack_token", /xox[baprs]-[A-Za-z0-9-]+/g],
6060
+ ["slack_token", /xapp-\d-[A-Za-z0-9]{6,}-\d{8,}-[A-Za-z0-9]{16,}/g],
5872
6061
  // Matches the full block (BEGIN marker through its matching END marker), not just the
5873
6062
  // header -- the actual secret material is the base64 body between them, so redacting only
5874
6063
  // the header line would leave the key bytes themselves fully readable in the cached blob.
5875
- // The lazy [\s\S]*? is bounded by the very next END marker (private key blocks don't nest),
5876
- // so this stays linear in practice despite the lazy quantifier.
5877
- ["private_key_block", /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/g],
6064
+ // The body is lazy and additionally refuses to cross a following BEGIN marker. Both halves
6065
+ // matter. The laziness bounds a successful match at the very next END marker; the negative
6066
+ // lookahead bounds a *failing* one, because a BEGIN with no END of its own would otherwise
6067
+ // scan to end-of-input, and a blob full of such markers made the pass quadratic -- 6 ms, 20 ms
6068
+ // and 78 ms for 2000, 4000 and 8000 of them, four times the work for twice the input, the same
6069
+ // shape as the lookbehind incident described above. Private key blocks do not nest, so
6070
+ // refusing to cross a BEGIN costs nothing in correctness.
6071
+ // The algorithm and ` BLOCK` groups are backreferenced in the END marker rather than repeated,
6072
+ // so a BEGIN only ever pairs with its own END spelling. Written as two independent optional
6073
+ // groups, `BEGIN PGP PRIVATE KEY` would happily close on a distant `END RSA PRIVATE KEY BLOCK`
6074
+ // and redact everything in between. A non-participating group backreferences as the empty
6075
+ // string in JS, which is exactly what the unprefixed `BEGIN PRIVATE KEY` form needs.
6076
+ // The algorithm list covers every armored private-key header openssl, ssh-keygen and gpg
6077
+ // actually emit, not just the ones a first draft happened to think of. ENCRYPTED is the
6078
+ // PKCS#8 passphrase-protected form (`openssl genpkey -aes256`, `ssh-keygen -m PKCS8`) and is
6079
+ // the most common shape of all; DSA is legacy but still written verbatim; PGP carries the
6080
+ // ` BLOCK` suffix, which is why that suffix is optional here. All three used to fall through
6081
+ // to disk in full. An encrypted key is still key material: the passphrase can be attacked
6082
+ // offline once the bytes are cached, so it is redacted like any other.
6083
+ // PuTTY `.ppk` files are deliberately not matched. They have no END marker -- the private
6084
+ // section is a `Private-Lines: N` count followed by exactly N base64 lines -- so bounding a
6085
+ // match would take a stateful parse rather than a regex, on a path that runs over every
6086
+ // command output. A regex guess at where the body ends is exactly the over-eager match this
6087
+ // module's header warns against.
6088
+ ["private_key_block", /-----BEGIN (RSA |DSA |EC |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY( BLOCK)?-----(?:(?!-----BEGIN )[\s\S])*?-----END \1PRIVATE KEY\2-----/g],
5878
6089
  // Redacts only the token itself, not the "Authorization: Bearer " prefix -- the lookbehind
5879
6090
  // anchors on the header name and scheme so the surrounding request-log line stays readable,
5880
6091
  // matching how AWS_ACCESS_KEY_ID=... above keeps its own prefix intact.
@@ -5883,7 +6094,13 @@ var SECRET_PATTERNS = [
5883
6094
  // directly against the header name and the scheme directly against the space, so a body like
5884
6095
  // {"Authorization": "Bearer <token>"} -- the shape any logged fetch or MCP result arrives in
5885
6096
  // -- matched nothing and the token was cached verbatim.
5886
- ["auth_bearer_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Bearer[ \t])[A-Za-z0-9\-._~+/]{10,}=*/gi],
6097
+ // `token` is the second scheme spelling in wide use -- it is what curl and gh examples pass for
6098
+ // GitHub and many other APIs -- and an opaque value behind it carries exactly the same authority
6099
+ // as one behind `Bearer`. The trailing gap is `{1,8}` rather than a single space for the same
6100
+ // reason every other gap in this lookbehind already is: a hand-aligned or reformatted header
6101
+ // ("Authorization: Bearer <token>") is ordinary, and demanding exactly one space there made
6102
+ // this the one position in the pattern that a second space defeated.
6103
+ ["auth_bearer_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}(?:Bearer|token)[ \t]{1,8})[A-Za-z0-9\-._~+/]{10,}=*/gi],
5887
6104
  ["auth_basic_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Basic[ \t])[A-Za-z0-9+/]{6,}=*/gi],
5888
6105
  // JWTs have no distinctive prefix of their own, but the base64url encoding of the smallest
5889
6106
  // realistic header ('{"alg":' or similar) always starts with "eyJ", so that's the practical
@@ -5937,7 +6154,22 @@ var SECRET_PATTERNS = [
5937
6154
  // SECRET_KEY=, and DB_PASSWORD_HASH= all passed through in full. That class matches
5938
6155
  // identifier characters only, so prose that merely mentions a keyword still never reaches
5939
6156
  // a separator and stays unredacted. api[_-]?key covers the apikey and api-key spellings too.
5940
- ["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]
6157
+ // `& ; # , :` play two incompatible roles. They separate one field from the next (a query
6158
+ // string, a cookie header, an inline env list), and they are also perfectly ordinary password
6159
+ // characters. Rejecting them outright got the first role right and the second badly wrong: the
6160
+ // match stopped at the first one and left everything after it in plain text, so
6161
+ // `password=corr&horse&battery` redacted four characters and printed the rest, and
6162
+ // `DB_PASSWORD=Aa1:xyz` matched nothing at all because the run before the `:` was under the
6163
+ // four-character floor. A tail left sitting in the open is the outcome this module's header
6164
+ // calls worse than no redaction, because it reads as handled.
6165
+ //
6166
+ // So the separator role is decided by what follows rather than assumed: one of these characters
6167
+ // ends the value only when the next thing along is another `name=` / `name:` pair, which is what
6168
+ // an actual field separator is always followed by. `,OTHER=public` and `; other=1` still end it;
6169
+ // the `&` in the middle of a passphrase does not. Whitespace, quotes and brackets are unchanged
6170
+ // -- they end a value unconditionally, which is also what keeps this pattern from re-matching
6171
+ // the `[REDACTED:...]` placeholder it just wrote.
6172
+ ["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\\&;#,:'"[\]{}]|[&;#,:](?![ \t]*[A-Za-z_][A-Za-z0-9_.-]*[ \t]*[:=])){4,}/gi]
5941
6173
  ];
5942
6174
  function redactSecrets(text) {
5943
6175
  let count = 0;
@@ -6030,10 +6262,13 @@ export {
6030
6262
  fingerprintContent,
6031
6263
  shortFingerprint,
6032
6264
  fingerprintFile,
6265
+ fileIsAbsent,
6033
6266
  normalizePath,
6034
6267
  normalizeDarwinSystemAlias,
6035
6268
  resolveIndexPath,
6036
6269
  toDisplayPath,
6270
+ displaySafeText,
6271
+ displaySafePath,
6037
6272
  sleepSync,
6038
6273
  isWindows,
6039
6274
  isCaseInsensitiveFs,
@@ -6065,6 +6300,7 @@ export {
6065
6300
  grepFilteredToEmptyNotice,
6066
6301
  countNoun,
6067
6302
  excludeTestsHiddenNote,
6303
+ countContentLines,
6068
6304
  escapeRegExp,
6069
6305
  windowsCmdQuoteArg,
6070
6306
  redactUrlQuery,
@@ -6084,6 +6320,9 @@ export {
6084
6320
  isWithinQuietHours,
6085
6321
  hookCommandFor,
6086
6322
  suggestPackageNames,
6323
+ detectSourceEncoding,
6324
+ decodeSource,
6325
+ encodeSource,
6087
6326
  canonicalize,
6088
6327
  makeProjectAt,
6089
6328
  findProject,
@@ -6127,6 +6366,7 @@ export {
6127
6366
  assignFlatEndLines,
6128
6367
  propagateEndLinesToSymbols,
6129
6368
  findMatchingBraceEndLine,
6369
+ assignBraceBlockSpans,
6130
6370
  extractIni,
6131
6371
  _lineClosesQuote,
6132
6372
  _detectOpenQuote,
@@ -6156,8 +6396,8 @@ export {
6156
6396
 
6157
6397
  smol-toml/dist/date.js:
6158
6398
  smol-toml/dist/error.js:
6159
- smol-toml/dist/primitive.js:
6160
6399
  smol-toml/dist/util.js:
6400
+ smol-toml/dist/primitive.js:
6161
6401
  smol-toml/dist/extract.js:
6162
6402
  smol-toml/dist/struct.js:
6163
6403
  smol-toml/dist/parse.js: