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.
- package/README.md +24 -1
- package/dist/{token-goat-chunk-5EXIMDHA.mjs → token-goat-chunk-7FWBSPCT.mjs} +1573 -386
- package/dist/token-goat-chunk-AEX54RUZ.mjs +11 -0
- package/dist/{token-goat-chunk-3KW5C2KQ.mjs → token-goat-chunk-AO2QD2AG.mjs} +0 -4
- package/dist/{token-goat-chunk-TBCLQTPG.mjs → token-goat-chunk-CKRATWCJ.mjs} +7 -7
- package/dist/{token-goat-chunk-X5OPORR4.mjs → token-goat-chunk-CN7GUPX6.mjs} +1258 -1769
- package/dist/{token-goat-hook-chunk-TKXOXN4J.mjs → token-goat-chunk-DG53MVNJ.mjs} +2 -98
- package/dist/{token-goat-chunk-DFBD2FFU.mjs → token-goat-chunk-FRMEOIRU.mjs} +365 -139
- package/dist/{token-goat-chunk-YWYITDOS.mjs → token-goat-chunk-G6XLWJWI.mjs} +2 -5
- package/dist/{token-goat-chunk-RD6O3PJU.mjs → token-goat-chunk-GXBPEQR2.mjs} +3699 -3341
- package/dist/{token-goat-chunk-DNEPSN3P.mjs → token-goat-chunk-I6EQH27G.mjs} +4 -7
- package/dist/{token-goat-hook-chunk-Q5URQRIF.mjs → token-goat-chunk-IYYQOPY4.mjs} +811 -79
- package/dist/{token-goat-chunk-W3MX4LQV.mjs → token-goat-chunk-L7QLEVO7.mjs} +6 -9
- package/dist/{token-goat-chunk-O7TGKV5I.mjs → token-goat-chunk-OA3GFKP2.mjs} +23 -24
- package/dist/{token-goat-chunk-GWZJ5SI2.mjs → token-goat-chunk-WA2ER6TZ.mjs} +7 -32
- package/dist/{token-goat-hook-chunk-VHZECEQD.mjs → token-goat-hook-chunk-2ISZ4AZR.mjs} +7 -32
- package/dist/{token-goat-chunk-4M7PSAO3.mjs → token-goat-hook-chunk-3QYSN4QV.mjs} +2 -98
- package/dist/{token-goat-hook-chunk-LFYT4DLB.mjs → token-goat-hook-chunk-6C5RN3CM.mjs} +23 -24
- package/dist/{token-goat-hook-chunk-WBTHUYJP.mjs → token-goat-hook-chunk-6QTWMSRO.mjs} +1221 -1730
- package/dist/token-goat-hook-chunk-ATEGFQAU.mjs +23 -0
- package/dist/{token-goat-hook-chunk-DJZGX27J.mjs → token-goat-hook-chunk-BU5OFDGQ.mjs} +363 -138
- package/dist/{token-goat-hook-chunk-J2ZK2FYW.mjs → token-goat-hook-chunk-BUOCULAM.mjs} +0 -4
- package/dist/{token-goat-hook-chunk-DHW6SRHR.mjs → token-goat-hook-chunk-CNLMPHXT.mjs} +1569 -382
- package/dist/{token-goat-hook-chunk-6NF4WM2U.mjs → token-goat-hook-chunk-I5VM5PO5.mjs} +3700 -3342
- package/dist/{token-goat-chunk-N53GXI2Z.mjs → token-goat-hook-chunk-KGLMNOGD.mjs} +811 -79
- package/dist/{token-goat-hook-chunk-TBJ5PUPQ.mjs → token-goat-hook-chunk-OQML5EMA.mjs} +6 -9
- package/dist/{token-goat-hook-chunk-UXD3B4OY.mjs → token-goat-hook-chunk-QTZ6YUMQ.mjs} +4 -7
- package/dist/token-goat-hook-chunk-RFRLWOQH.mjs +11 -0
- package/dist/{token-goat-hook-chunk-PCP4W65Z.mjs → token-goat-hook-chunk-XUMIVYEN.mjs} +2 -5
- package/dist/token-goat-hook.mjs +7 -12
- package/dist/token-goat.core.mjs +7 -10
- package/package.json +20 -40
- package/dist/token-goat-chunk-3UOG7PSZ.mjs +0 -63
- package/dist/token-goat-hook-chunk-ANFXTEQO.mjs +0 -23
- 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-chunk-
|
|
6
|
-
import {
|
|
7
|
-
init_define_import_meta_env
|
|
8
|
-
} from "./token-goat-chunk-3UOG7PSZ.mjs";
|
|
5
|
+
} from "./token-goat-chunk-AO2QD2AG.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.
|
|
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/fingerprint.ts
|
|
202
|
-
init_define_import_meta_env();
|
|
203
197
|
import { createHash } from "node:crypto";
|
|
204
198
|
import * as fs2 from "node:fs";
|
|
205
199
|
function fingerprintContent(content) {
|
|
@@ -219,9 +213,15 @@ function fingerprintFile(filePath) {
|
|
|
219
213
|
}
|
|
220
214
|
return fingerprintContent(data);
|
|
221
215
|
}
|
|
216
|
+
function fileIsAbsent(filePath) {
|
|
217
|
+
try {
|
|
218
|
+
return fs2.statSync(filePath, { throwIfNoEntry: false }) === void 0;
|
|
219
|
+
} catch {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
222
223
|
|
|
223
224
|
// src/paths.ts
|
|
224
|
-
init_define_import_meta_env();
|
|
225
225
|
import * as fs3 from "node:fs";
|
|
226
226
|
import * as path2 from "node:path";
|
|
227
227
|
var WSL_PATH_RE = /^\/mnt\/([a-zA-Z])\/(.*)$/s;
|
|
@@ -316,11 +316,22 @@ function safeJoin(base, ...parts) {
|
|
|
316
316
|
}
|
|
317
317
|
return path2.join(base, ...parts);
|
|
318
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
|
+
}
|
|
319
331
|
|
|
320
332
|
// src/util.ts
|
|
321
|
-
init_define_import_meta_env();
|
|
322
333
|
import { spawn, spawnSync } from "node:child_process";
|
|
323
|
-
import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as
|
|
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";
|
|
324
335
|
import * as path3 from "node:path";
|
|
325
336
|
function sleepSync(ms) {
|
|
326
337
|
if (ms <= 0) return;
|
|
@@ -340,7 +351,7 @@ function foldPath(p) {
|
|
|
340
351
|
}
|
|
341
352
|
function statSize(absPath) {
|
|
342
353
|
try {
|
|
343
|
-
const st =
|
|
354
|
+
const st = statSync3(absPath);
|
|
344
355
|
return st.isFile() ? st.size : null;
|
|
345
356
|
} catch {
|
|
346
357
|
return null;
|
|
@@ -434,7 +445,7 @@ function atomicWriteCore(dest, content) {
|
|
|
434
445
|
closeSync(fd);
|
|
435
446
|
}
|
|
436
447
|
try {
|
|
437
|
-
const destMode =
|
|
448
|
+
const destMode = statSync3(dest).mode;
|
|
438
449
|
chmodSync2(tmp, destMode);
|
|
439
450
|
} catch (e) {
|
|
440
451
|
if (e.code !== "ENOENT") throw e;
|
|
@@ -558,7 +569,7 @@ function withFileLock(lockPath, fn, opts = {}) {
|
|
|
558
569
|
}
|
|
559
570
|
let stale;
|
|
560
571
|
try {
|
|
561
|
-
const st =
|
|
572
|
+
const st = statSync3(lockPath);
|
|
562
573
|
stale = Date.now() - st.mtimeMs > staleMs;
|
|
563
574
|
} catch {
|
|
564
575
|
stale = true;
|
|
@@ -754,6 +765,11 @@ function countNoun(count, singular, plural = `${singular}s`) {
|
|
|
754
765
|
function excludeTestsHiddenNote(count) {
|
|
755
766
|
return `${count} in test ${count === 1 ? "file" : "files"} hidden by --exclude-tests`;
|
|
756
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
|
+
}
|
|
757
773
|
function escapeRegExp(s) {
|
|
758
774
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
759
775
|
}
|
|
@@ -943,9 +959,74 @@ function packageNameDistance(a, b, cap = 3) {
|
|
|
943
959
|
function suggestPackageNames(query, names) {
|
|
944
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);
|
|
945
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
|
+
}
|
|
946
1028
|
|
|
947
1029
|
// src/project.ts
|
|
948
|
-
init_define_import_meta_env();
|
|
949
1030
|
import * as fs4 from "node:fs";
|
|
950
1031
|
import * as os2 from "node:os";
|
|
951
1032
|
import * as path4 from "node:path";
|
|
@@ -1159,24 +1240,10 @@ function isInsideRoot(target, root) {
|
|
|
1159
1240
|
}
|
|
1160
1241
|
|
|
1161
1242
|
// src/config.ts
|
|
1162
|
-
init_define_import_meta_env();
|
|
1163
1243
|
import * as fs5 from "node:fs";
|
|
1164
1244
|
import * as path5 from "node:path";
|
|
1165
1245
|
|
|
1166
|
-
// node_modules/smol-toml/dist/index.js
|
|
1167
|
-
init_define_import_meta_env();
|
|
1168
|
-
|
|
1169
|
-
// node_modules/smol-toml/dist/parse.js
|
|
1170
|
-
init_define_import_meta_env();
|
|
1171
|
-
|
|
1172
|
-
// node_modules/smol-toml/dist/struct.js
|
|
1173
|
-
init_define_import_meta_env();
|
|
1174
|
-
|
|
1175
|
-
// node_modules/smol-toml/dist/primitive.js
|
|
1176
|
-
init_define_import_meta_env();
|
|
1177
|
-
|
|
1178
1246
|
// node_modules/smol-toml/dist/date.js
|
|
1179
|
-
init_define_import_meta_env();
|
|
1180
1247
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
1181
1248
|
var TomlDate = class _TomlDate extends Date {
|
|
1182
1249
|
#hasDate = false;
|
|
@@ -1269,7 +1336,6 @@ var TomlDate = class _TomlDate extends Date {
|
|
|
1269
1336
|
};
|
|
1270
1337
|
|
|
1271
1338
|
// node_modules/smol-toml/dist/error.js
|
|
1272
|
-
init_define_import_meta_env();
|
|
1273
1339
|
function getLineColFromPtr(string, ptr) {
|
|
1274
1340
|
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1275
1341
|
return [lines.length, lines.pop().length + 1];
|
|
@@ -1309,57 +1375,111 @@ ${codeblock}`, options);
|
|
|
1309
1375
|
}
|
|
1310
1376
|
};
|
|
1311
1377
|
|
|
1378
|
+
// node_modules/smol-toml/dist/util.js
|
|
1379
|
+
function indexOfNewline(str, start = 0) {
|
|
1380
|
+
let idx = str.indexOf("\n", start);
|
|
1381
|
+
if (str.charCodeAt(idx - 1) === 13)
|
|
1382
|
+
idx--;
|
|
1383
|
+
return idx;
|
|
1384
|
+
}
|
|
1385
|
+
function skipComment(ctx) {
|
|
1386
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1387
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1388
|
+
if (c === 10)
|
|
1389
|
+
break;
|
|
1390
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
1391
|
+
ctx.p++;
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
1395
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
1396
|
+
toml: ctx.s,
|
|
1397
|
+
ptr: ctx.p
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
1403
|
+
let c;
|
|
1404
|
+
while (1) {
|
|
1405
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
1406
|
+
ctx.p++;
|
|
1407
|
+
if (banComments || c !== 35)
|
|
1408
|
+
break;
|
|
1409
|
+
skipComment(ctx);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
function skipUntil(ctx, sep, end) {
|
|
1413
|
+
let ptr = ctx.p;
|
|
1414
|
+
if (!end) {
|
|
1415
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
1416
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1420
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1421
|
+
if (c === 35) {
|
|
1422
|
+
skipComment(ctx);
|
|
1423
|
+
} else if (c === end || c === sep) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
throw new TomlError("cannot find end of structure", {
|
|
1428
|
+
toml: ctx.s,
|
|
1429
|
+
ptr
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1312
1433
|
// node_modules/smol-toml/dist/primitive.js
|
|
1313
1434
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
1314
1435
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
1315
1436
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
1316
|
-
function parseString(
|
|
1317
|
-
let
|
|
1437
|
+
function parseString(ctx) {
|
|
1438
|
+
let start = ctx.p;
|
|
1439
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
1318
1440
|
let first = c;
|
|
1319
|
-
let isLiteral = c ===
|
|
1320
|
-
let isMultiline = c ===
|
|
1441
|
+
let isLiteral = c === 39;
|
|
1442
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
1321
1443
|
if (isMultiline) {
|
|
1322
|
-
if (
|
|
1323
|
-
|
|
1324
|
-
else if (
|
|
1325
|
-
|
|
1444
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
1445
|
+
ctx.p++;
|
|
1446
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
1447
|
+
ctx.p += 2;
|
|
1326
1448
|
}
|
|
1327
1449
|
let parsed = "";
|
|
1328
|
-
let sliceStart =
|
|
1450
|
+
let sliceStart = ctx.p;
|
|
1329
1451
|
let state = 0;
|
|
1330
|
-
for (
|
|
1331
|
-
c =
|
|
1332
|
-
if (isMultiline && (c ===
|
|
1452
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1453
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
1454
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
1333
1455
|
state = state && 3;
|
|
1334
|
-
} else if (c <
|
|
1456
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
1335
1457
|
throw new TomlError("control characters are not allowed in strings", {
|
|
1336
|
-
toml:
|
|
1337
|
-
ptr:
|
|
1458
|
+
toml: ctx.s,
|
|
1459
|
+
ptr: ctx.p
|
|
1338
1460
|
});
|
|
1339
|
-
} else if ((!state || state === 3) && c === first && (!isMultiline ||
|
|
1461
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
1340
1462
|
if (isMultiline) {
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
if (
|
|
1344
|
-
|
|
1463
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1464
|
+
ctx.p++;
|
|
1465
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1466
|
+
ctx.p++;
|
|
1345
1467
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
i + (isMultiline ? 3 : 1)
|
|
1351
|
-
];
|
|
1468
|
+
if (!state)
|
|
1469
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
1470
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
1471
|
+
return parsed;
|
|
1352
1472
|
} else if (!state) {
|
|
1353
|
-
if (!isLiteral && c ===
|
|
1354
|
-
parsed +=
|
|
1473
|
+
if (!isLiteral && c === 92) {
|
|
1474
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
1355
1475
|
state = 1;
|
|
1356
1476
|
}
|
|
1357
1477
|
} else if (state === 1) {
|
|
1358
|
-
if (c ===
|
|
1478
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
1359
1479
|
let value = 0;
|
|
1360
|
-
let len = c ===
|
|
1361
|
-
for (let j = 0; j < len; j++,
|
|
1362
|
-
let hex =
|
|
1480
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
1481
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
1482
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
1363
1483
|
let digit = (
|
|
1364
1484
|
/* 0-9 */
|
|
1365
1485
|
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
@@ -1371,57 +1491,68 @@ function parseString(str, ptr) {
|
|
|
1371
1491
|
)
|
|
1372
1492
|
);
|
|
1373
1493
|
if (digit < 0)
|
|
1374
|
-
throw new TomlError("invalid non-hex character in unicode escape", { toml:
|
|
1494
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
1375
1495
|
value = value << 4 | digit;
|
|
1376
1496
|
}
|
|
1377
1497
|
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
1378
|
-
throw new TomlError("invalid unicode escape", { toml:
|
|
1498
|
+
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
1379
1499
|
}
|
|
1380
1500
|
parsed += String.fromCodePoint(value);
|
|
1381
|
-
sliceStart =
|
|
1501
|
+
sliceStart = ctx.p + 1;
|
|
1382
1502
|
state = 0;
|
|
1383
|
-
} else if (c ===
|
|
1503
|
+
} else if (c === 32 || c === 9) {
|
|
1384
1504
|
state = 2;
|
|
1385
1505
|
} else {
|
|
1386
|
-
if (c ===
|
|
1506
|
+
if (c === 98)
|
|
1387
1507
|
parsed += "\b";
|
|
1388
|
-
else if (c ===
|
|
1508
|
+
else if (c === 116)
|
|
1389
1509
|
parsed += " ";
|
|
1390
|
-
else if (c ===
|
|
1510
|
+
else if (c === 110)
|
|
1391
1511
|
parsed += "\n";
|
|
1392
|
-
else if (c ===
|
|
1512
|
+
else if (c === 102)
|
|
1393
1513
|
parsed += "\f";
|
|
1394
|
-
else if (c ===
|
|
1514
|
+
else if (c === 114)
|
|
1395
1515
|
parsed += "\r";
|
|
1396
|
-
else if (c ===
|
|
1516
|
+
else if (c === 101)
|
|
1397
1517
|
parsed += "\x1B";
|
|
1398
|
-
else if (c ===
|
|
1518
|
+
else if (c === 34)
|
|
1399
1519
|
parsed += '"';
|
|
1400
|
-
else if (c ===
|
|
1520
|
+
else if (c === 92)
|
|
1401
1521
|
parsed += "\\";
|
|
1402
1522
|
else
|
|
1403
|
-
throw new TomlError("unrecognized escape sequence", { toml:
|
|
1404
|
-
sliceStart =
|
|
1523
|
+
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
1524
|
+
sliceStart = ctx.p + 1;
|
|
1405
1525
|
state = 0;
|
|
1406
1526
|
}
|
|
1407
|
-
} else if (c !==
|
|
1527
|
+
} else if (c !== 32 && c !== 9) {
|
|
1408
1528
|
if (state === 2) {
|
|
1409
1529
|
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
1410
|
-
toml:
|
|
1530
|
+
toml: ctx.s,
|
|
1411
1531
|
ptr: sliceStart
|
|
1412
1532
|
});
|
|
1413
1533
|
}
|
|
1414
|
-
state = !isLiteral && c ===
|
|
1415
|
-
sliceStart =
|
|
1534
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
1535
|
+
sliceStart = ctx.p;
|
|
1416
1536
|
}
|
|
1417
1537
|
}
|
|
1418
|
-
throw new TomlError("unfinished string", { toml:
|
|
1538
|
+
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
1419
1539
|
}
|
|
1420
|
-
function
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
if (
|
|
1424
|
-
|
|
1540
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
1541
|
+
let value = ctx.s.slice(start, end);
|
|
1542
|
+
let commentIdx = value.indexOf("#");
|
|
1543
|
+
if (commentIdx > 0) {
|
|
1544
|
+
skipComment({ s: value, p: commentIdx, d: 0 });
|
|
1545
|
+
value = value.slice(0, commentIdx);
|
|
1546
|
+
}
|
|
1547
|
+
return value.trimEnd();
|
|
1548
|
+
}
|
|
1549
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
1550
|
+
let ptr = ctx.p;
|
|
1551
|
+
let err = { toml: ctx.s, ptr };
|
|
1552
|
+
skipUntil(ctx, 44, end);
|
|
1553
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
1554
|
+
if (!value)
|
|
1555
|
+
throw new TomlError("incomplete declaration: value expected", err);
|
|
1425
1556
|
if (value === "-inf")
|
|
1426
1557
|
return -Infinity;
|
|
1427
1558
|
if (value === "inf" || value === "+inf")
|
|
@@ -1433,25 +1564,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1433
1564
|
let isInt = INT_REGEX.test(value);
|
|
1434
1565
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
1435
1566
|
if (LEADING_ZERO.test(value)) {
|
|
1436
|
-
throw new TomlError("leading zeroes are not allowed",
|
|
1437
|
-
toml,
|
|
1438
|
-
ptr
|
|
1439
|
-
});
|
|
1567
|
+
throw new TomlError("leading zeroes are not allowed", err);
|
|
1440
1568
|
}
|
|
1441
1569
|
value = value.replace(/_/g, "");
|
|
1442
1570
|
let numeric = +value;
|
|
1443
1571
|
if (isNaN(numeric)) {
|
|
1444
|
-
throw new TomlError("invalid number",
|
|
1445
|
-
toml,
|
|
1446
|
-
ptr
|
|
1447
|
-
});
|
|
1572
|
+
throw new TomlError("invalid number", err);
|
|
1448
1573
|
}
|
|
1449
1574
|
if (isInt) {
|
|
1450
1575
|
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
1451
|
-
throw new TomlError("integer value cannot be represented losslessly",
|
|
1452
|
-
toml,
|
|
1453
|
-
ptr
|
|
1454
|
-
});
|
|
1576
|
+
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
1455
1577
|
}
|
|
1456
1578
|
if (isInt || integersAsBigInt === true)
|
|
1457
1579
|
numeric = BigInt(value);
|
|
@@ -1459,281 +1581,184 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1459
1581
|
return numeric;
|
|
1460
1582
|
}
|
|
1461
1583
|
const date = new TomlDate(value);
|
|
1462
|
-
if (!date.isValid())
|
|
1463
|
-
throw new TomlError("invalid value",
|
|
1464
|
-
toml,
|
|
1465
|
-
ptr
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1584
|
+
if (!date.isValid())
|
|
1585
|
+
throw new TomlError("invalid value", err);
|
|
1468
1586
|
return date;
|
|
1469
1587
|
}
|
|
1470
1588
|
|
|
1471
1589
|
// node_modules/smol-toml/dist/extract.js
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
idx--;
|
|
1480
|
-
return idx <= end ? idx : -1;
|
|
1481
|
-
}
|
|
1482
|
-
function skipComment(str, ptr) {
|
|
1483
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1484
|
-
let c = str[i];
|
|
1485
|
-
if (c === "\n")
|
|
1486
|
-
return i;
|
|
1487
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
1488
|
-
return i + 1;
|
|
1489
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
1490
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
1491
|
-
toml: str,
|
|
1590
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
1591
|
+
let ptr = ctx.p;
|
|
1592
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
1593
|
+
if (c === 91 || c === 123) {
|
|
1594
|
+
if (!ctx.d--) {
|
|
1595
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
1596
|
+
toml: ctx.s,
|
|
1492
1597
|
ptr
|
|
1493
1598
|
});
|
|
1494
1599
|
}
|
|
1600
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
1601
|
+
ctx.d++;
|
|
1602
|
+
return value;
|
|
1495
1603
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
1499
|
-
let c;
|
|
1500
|
-
while (1) {
|
|
1501
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
1502
|
-
ptr++;
|
|
1503
|
-
if (banComments || c !== "#")
|
|
1504
|
-
break;
|
|
1505
|
-
ptr = skipComment(str, ptr);
|
|
1506
|
-
}
|
|
1507
|
-
return ptr;
|
|
1508
|
-
}
|
|
1509
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
1510
|
-
if (!end) {
|
|
1511
|
-
ptr = indexOfNewline(str, ptr);
|
|
1512
|
-
return ptr < 0 ? str.length : ptr;
|
|
1513
|
-
}
|
|
1514
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1515
|
-
let c = str[i];
|
|
1516
|
-
if (c === "#") {
|
|
1517
|
-
i = indexOfNewline(str, i);
|
|
1518
|
-
} else if (c === sep) {
|
|
1519
|
-
return i + 1;
|
|
1520
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
1521
|
-
return i;
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
throw new TomlError("cannot find end of structure", {
|
|
1525
|
-
toml: str,
|
|
1526
|
-
ptr
|
|
1527
|
-
});
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
// node_modules/smol-toml/dist/extract.js
|
|
1531
|
-
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
1532
|
-
let value = str.slice(startPtr, endPtr);
|
|
1533
|
-
let commentIdx = value.indexOf("#");
|
|
1534
|
-
if (commentIdx > -1) {
|
|
1535
|
-
skipComment(str, commentIdx);
|
|
1536
|
-
value = value.slice(0, commentIdx);
|
|
1604
|
+
if (c === 34 || c === 39) {
|
|
1605
|
+
return parseString(ctx);
|
|
1537
1606
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
toml: str,
|
|
1544
|
-
ptr
|
|
1545
|
-
});
|
|
1546
|
-
}
|
|
1547
|
-
let c = str[ptr];
|
|
1548
|
-
if (c === "[" || c === "{") {
|
|
1549
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
1550
|
-
if (end) {
|
|
1551
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1552
|
-
if (str[endPtr2] === ",")
|
|
1553
|
-
endPtr2++;
|
|
1554
|
-
else if (str[endPtr2] !== end) {
|
|
1555
|
-
throw new TomlError("expected comma or end of structure", {
|
|
1556
|
-
toml: str,
|
|
1557
|
-
ptr: endPtr2
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
return [value, endPtr2];
|
|
1562
|
-
}
|
|
1563
|
-
if (c === '"' || c === "'") {
|
|
1564
|
-
let [parsed, endPtr2] = parseString(str, ptr);
|
|
1565
|
-
if (end) {
|
|
1566
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1567
|
-
if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
|
|
1568
|
-
throw new TomlError("unexpected character encountered", {
|
|
1569
|
-
toml: str,
|
|
1570
|
-
ptr: endPtr2
|
|
1571
|
-
});
|
|
1572
|
-
}
|
|
1573
|
-
if (str[endPtr2] === ",")
|
|
1574
|
-
endPtr2++;
|
|
1575
|
-
}
|
|
1576
|
-
return [parsed, endPtr2];
|
|
1577
|
-
}
|
|
1578
|
-
let endPtr = skipUntil(str, ptr, ",", end);
|
|
1579
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
|
|
1580
|
-
if (!slice[0]) {
|
|
1581
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
1582
|
-
toml: str,
|
|
1583
|
-
ptr
|
|
1584
|
-
});
|
|
1607
|
+
if (c === 116) {
|
|
1608
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1609
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1610
|
+
ctx.p++;
|
|
1611
|
+
return true;
|
|
1585
1612
|
}
|
|
1586
|
-
if (
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1613
|
+
if (c === 102) {
|
|
1614
|
+
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)
|
|
1615
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1616
|
+
ctx.p++;
|
|
1617
|
+
return false;
|
|
1590
1618
|
}
|
|
1591
|
-
return
|
|
1592
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
1593
|
-
endPtr
|
|
1594
|
-
];
|
|
1619
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
1595
1620
|
}
|
|
1596
1621
|
|
|
1597
1622
|
// node_modules/smol-toml/dist/struct.js
|
|
1598
1623
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1599
|
-
function parseKey(
|
|
1600
|
-
let
|
|
1624
|
+
function parseKey(ctx, end = "=") {
|
|
1625
|
+
let start = ctx.p;
|
|
1626
|
+
let dot = start - 1;
|
|
1601
1627
|
let parsed = [];
|
|
1602
|
-
let endPtr =
|
|
1628
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
1603
1629
|
if (endPtr < 0) {
|
|
1604
1630
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1605
|
-
toml:
|
|
1606
|
-
ptr
|
|
1631
|
+
toml: ctx.s,
|
|
1632
|
+
ptr: start
|
|
1607
1633
|
});
|
|
1608
1634
|
}
|
|
1609
1635
|
do {
|
|
1610
|
-
let c =
|
|
1611
|
-
if (c !==
|
|
1612
|
-
if (c ===
|
|
1613
|
-
if (c ===
|
|
1636
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
1637
|
+
if (c !== 32 && c !== 9) {
|
|
1638
|
+
if (c === 34 || c === 39) {
|
|
1639
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
1614
1640
|
throw new TomlError("multiline strings are not allowed in keys", {
|
|
1615
|
-
toml:
|
|
1616
|
-
ptr
|
|
1641
|
+
toml: ctx.s,
|
|
1642
|
+
ptr: ctx.p
|
|
1617
1643
|
});
|
|
1618
1644
|
}
|
|
1619
|
-
let
|
|
1620
|
-
dot =
|
|
1621
|
-
let strEnd =
|
|
1645
|
+
let part = parseString(ctx);
|
|
1646
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1647
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1622
1648
|
let newLine = indexOfNewline(strEnd);
|
|
1623
1649
|
if (newLine > -1) {
|
|
1624
1650
|
throw new TomlError("newlines are not allowed in keys", {
|
|
1625
|
-
toml:
|
|
1626
|
-
ptr:
|
|
1651
|
+
toml: ctx.s,
|
|
1652
|
+
ptr: newLine
|
|
1627
1653
|
});
|
|
1628
1654
|
}
|
|
1629
1655
|
if (strEnd.trimStart()) {
|
|
1630
1656
|
throw new TomlError("found extra tokens after the string part", {
|
|
1631
|
-
toml:
|
|
1632
|
-
ptr:
|
|
1657
|
+
toml: ctx.s,
|
|
1658
|
+
ptr: ctx.p
|
|
1633
1659
|
});
|
|
1634
1660
|
}
|
|
1635
|
-
if (endPtr <
|
|
1636
|
-
endPtr =
|
|
1661
|
+
if (endPtr < ctx.p) {
|
|
1662
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
1637
1663
|
if (endPtr < 0) {
|
|
1638
1664
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1639
|
-
toml:
|
|
1640
|
-
ptr
|
|
1665
|
+
toml: ctx.s,
|
|
1666
|
+
ptr: start
|
|
1641
1667
|
});
|
|
1642
1668
|
}
|
|
1643
1669
|
}
|
|
1644
1670
|
parsed.push(part);
|
|
1645
1671
|
} else {
|
|
1646
|
-
dot =
|
|
1647
|
-
let part =
|
|
1672
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1673
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1648
1674
|
if (!KEY_PART_RE.test(part)) {
|
|
1649
1675
|
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1650
|
-
toml:
|
|
1651
|
-
ptr
|
|
1676
|
+
toml: ctx.s,
|
|
1677
|
+
ptr: ctx.p
|
|
1652
1678
|
});
|
|
1653
1679
|
}
|
|
1654
1680
|
parsed.push(part.trimEnd());
|
|
1655
1681
|
}
|
|
1656
1682
|
}
|
|
1657
1683
|
} while (dot + 1 && dot < endPtr);
|
|
1658
|
-
|
|
1684
|
+
ctx.p = endPtr + 1;
|
|
1685
|
+
skipVoid(ctx, true, true);
|
|
1686
|
+
return parsed;
|
|
1659
1687
|
}
|
|
1660
|
-
function parseInlineTable(
|
|
1688
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
1661
1689
|
let res = {};
|
|
1662
1690
|
let seen = /* @__PURE__ */ new Set();
|
|
1663
1691
|
let c;
|
|
1664
|
-
|
|
1665
|
-
while (
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
k = key[i];
|
|
1682
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1683
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
1684
|
-
toml: str,
|
|
1685
|
-
ptr
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
if (!hasOwn && k === "__proto__") {
|
|
1689
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
if (hasOwn) {
|
|
1692
|
+
ctx.p++;
|
|
1693
|
+
while (ctx.p < ctx.s.length) {
|
|
1694
|
+
skipVoid(ctx);
|
|
1695
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
1696
|
+
ctx.p++;
|
|
1697
|
+
return res;
|
|
1698
|
+
}
|
|
1699
|
+
let k;
|
|
1700
|
+
let t = res;
|
|
1701
|
+
let hasOwn = false;
|
|
1702
|
+
let p = ctx.p;
|
|
1703
|
+
let key = parseKey(ctx);
|
|
1704
|
+
for (let i = 0; i < key.length; i++) {
|
|
1705
|
+
if (i)
|
|
1706
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1707
|
+
k = key[i];
|
|
1708
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1693
1709
|
throw new TomlError("trying to redefine an already defined value", {
|
|
1694
|
-
toml:
|
|
1695
|
-
ptr
|
|
1710
|
+
toml: ctx.s,
|
|
1711
|
+
ptr: p
|
|
1696
1712
|
});
|
|
1697
1713
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1714
|
+
if (!hasOwn && k === "__proto__") {
|
|
1715
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (hasOwn) {
|
|
1719
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
1720
|
+
toml: ctx.s,
|
|
1721
|
+
ptr: ctx.p
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
1725
|
+
seen.add(t[k] = value);
|
|
1726
|
+
skipVoid(ctx);
|
|
1727
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
1728
|
+
return res;
|
|
1729
|
+
}
|
|
1730
|
+
if (c !== 44) {
|
|
1731
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1702
1732
|
}
|
|
1703
1733
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
return [res, ptr];
|
|
1734
|
+
throw new TomlError("unfinished table encountered", {
|
|
1735
|
+
toml: ctx.s,
|
|
1736
|
+
ptr: ctx.p
|
|
1737
|
+
});
|
|
1711
1738
|
}
|
|
1712
|
-
function parseArray(
|
|
1739
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
1713
1740
|
let res = [];
|
|
1714
1741
|
let c;
|
|
1715
|
-
|
|
1716
|
-
while (
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (!c) {
|
|
1731
|
-
throw new TomlError("unfinished array encountered", {
|
|
1732
|
-
toml: str,
|
|
1733
|
-
ptr
|
|
1734
|
-
});
|
|
1742
|
+
ctx.p++;
|
|
1743
|
+
while (ctx.p < ctx.s.length) {
|
|
1744
|
+
skipVoid(ctx);
|
|
1745
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
1746
|
+
ctx.p++;
|
|
1747
|
+
return res;
|
|
1748
|
+
}
|
|
1749
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
1750
|
+
skipVoid(ctx);
|
|
1751
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
1752
|
+
return res;
|
|
1753
|
+
}
|
|
1754
|
+
if (c !== 44) {
|
|
1755
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1756
|
+
}
|
|
1735
1757
|
}
|
|
1736
|
-
|
|
1758
|
+
throw new TomlError("unfinished array encountered", {
|
|
1759
|
+
toml: ctx.s,
|
|
1760
|
+
ptr: ctx.p
|
|
1761
|
+
});
|
|
1737
1762
|
}
|
|
1738
1763
|
|
|
1739
1764
|
// node_modules/smol-toml/dist/parse.js
|
|
@@ -1797,25 +1822,29 @@ function peekTable(key, table, meta, type) {
|
|
|
1797
1822
|
return [k, t, state.c];
|
|
1798
1823
|
}
|
|
1799
1824
|
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
1825
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
1800
1826
|
let res = {};
|
|
1801
1827
|
let meta = {};
|
|
1828
|
+
let tmp;
|
|
1802
1829
|
let tbl = res;
|
|
1803
1830
|
let m = meta;
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
let
|
|
1831
|
+
skipVoid(ctx);
|
|
1832
|
+
while (ctx.p < toml.length) {
|
|
1833
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
1834
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
1835
|
+
tmp = ctx.p += +isTableArray;
|
|
1836
|
+
let k = parseKey(ctx, "]");
|
|
1808
1837
|
if (isTableArray) {
|
|
1809
|
-
if (toml
|
|
1838
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
1810
1839
|
throw new TomlError("expected end of table declaration", {
|
|
1811
1840
|
toml,
|
|
1812
|
-
ptr:
|
|
1841
|
+
ptr: ctx.p - 1
|
|
1813
1842
|
});
|
|
1814
1843
|
}
|
|
1815
|
-
|
|
1844
|
+
ctx.p++;
|
|
1816
1845
|
}
|
|
1817
1846
|
let p = peekTable(
|
|
1818
|
-
k
|
|
1847
|
+
k,
|
|
1819
1848
|
res,
|
|
1820
1849
|
meta,
|
|
1821
1850
|
isTableArray ? 2 : 1
|
|
@@ -1824,16 +1853,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1824
1853
|
if (!p) {
|
|
1825
1854
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1826
1855
|
toml,
|
|
1827
|
-
ptr
|
|
1856
|
+
ptr: tmp
|
|
1828
1857
|
});
|
|
1829
1858
|
}
|
|
1830
1859
|
m = p[2];
|
|
1831
1860
|
tbl = p[1];
|
|
1832
|
-
ptr = k[1];
|
|
1833
1861
|
} else {
|
|
1834
|
-
|
|
1862
|
+
tmp = ctx.p;
|
|
1863
|
+
let k = parseKey(ctx);
|
|
1835
1864
|
let p = peekTable(
|
|
1836
|
-
k
|
|
1865
|
+
k,
|
|
1837
1866
|
tbl,
|
|
1838
1867
|
m,
|
|
1839
1868
|
0
|
|
@@ -1842,35 +1871,36 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1842
1871
|
if (!p) {
|
|
1843
1872
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1844
1873
|
toml,
|
|
1845
|
-
ptr
|
|
1874
|
+
ptr: tmp
|
|
1846
1875
|
});
|
|
1847
1876
|
}
|
|
1848
|
-
|
|
1849
|
-
p[1][p[0]] = v[0];
|
|
1850
|
-
ptr = v[1];
|
|
1877
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
1851
1878
|
}
|
|
1852
|
-
|
|
1853
|
-
if (toml
|
|
1879
|
+
skipVoid(ctx, true);
|
|
1880
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
1854
1881
|
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
1855
1882
|
toml,
|
|
1856
|
-
ptr
|
|
1883
|
+
ptr: ctx.p
|
|
1857
1884
|
});
|
|
1858
1885
|
}
|
|
1859
|
-
|
|
1886
|
+
skipVoid(ctx);
|
|
1860
1887
|
}
|
|
1861
1888
|
return res;
|
|
1862
1889
|
}
|
|
1863
1890
|
|
|
1864
1891
|
// node_modules/smol-toml/dist/stringify.js
|
|
1865
|
-
init_define_import_meta_env();
|
|
1866
1892
|
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
1867
1893
|
function extendedTypeOf(obj) {
|
|
1868
1894
|
let type = typeof obj;
|
|
1869
1895
|
if (type === "object") {
|
|
1870
1896
|
if (Array.isArray(obj))
|
|
1871
1897
|
return "array";
|
|
1872
|
-
if (obj instanceof Date)
|
|
1898
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
|
|
1873
1899
|
return "date";
|
|
1900
|
+
if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
1901
|
+
typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
|
|
1902
|
+
return "temporal";
|
|
1903
|
+
}
|
|
1874
1904
|
}
|
|
1875
1905
|
return type;
|
|
1876
1906
|
}
|
|
@@ -1884,38 +1914,42 @@ function isArrayOfTables(obj) {
|
|
|
1884
1914
|
function formatString(s) {
|
|
1885
1915
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
1886
1916
|
}
|
|
1917
|
+
function stringifyTemporal(temporal) {
|
|
1918
|
+
return temporal.toString({
|
|
1919
|
+
calendarName: "never",
|
|
1920
|
+
timeZoneName: "never"
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1887
1923
|
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
1888
1924
|
if (depth === 0) {
|
|
1889
1925
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
1890
1926
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
if (type === "array") {
|
|
1918
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
1927
|
+
switch (type) {
|
|
1928
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
1929
|
+
case "number":
|
|
1930
|
+
if (isNaN(val))
|
|
1931
|
+
return "nan";
|
|
1932
|
+
if (val === Infinity)
|
|
1933
|
+
return "inf";
|
|
1934
|
+
if (val === -Infinity)
|
|
1935
|
+
return "-inf";
|
|
1936
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
1937
|
+
return val.toFixed(1);
|
|
1938
|
+
case "bigint":
|
|
1939
|
+
case "boolean":
|
|
1940
|
+
return val.toString();
|
|
1941
|
+
case "string":
|
|
1942
|
+
return formatString(val);
|
|
1943
|
+
case "date":
|
|
1944
|
+
if (isNaN(val.getTime()))
|
|
1945
|
+
throw new TypeError("cannot serialize invalid date");
|
|
1946
|
+
return val.toISOString();
|
|
1947
|
+
case "object":
|
|
1948
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
1949
|
+
case "array":
|
|
1950
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
1951
|
+
case "temporal":
|
|
1952
|
+
return stringifyTemporal(val);
|
|
1919
1953
|
}
|
|
1920
1954
|
}
|
|
1921
1955
|
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
@@ -2004,7 +2038,6 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
2004
2038
|
}
|
|
2005
2039
|
|
|
2006
2040
|
// src/env.ts
|
|
2007
|
-
init_define_import_meta_env();
|
|
2008
2041
|
var FALSY_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
2009
2042
|
var TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
2010
2043
|
function envStr(key, defaultVal) {
|
|
@@ -3248,11 +3281,1055 @@ function saveConfig(config) {
|
|
|
3248
3281
|
_cached2 = null;
|
|
3249
3282
|
}
|
|
3250
3283
|
|
|
3284
|
+
// src/parser_types.ts
|
|
3285
|
+
import * as path6 from "node:path";
|
|
3286
|
+
var EXTENSION_LANGUAGE = /* @__PURE__ */ new Map([
|
|
3287
|
+
[".py", "python"],
|
|
3288
|
+
[".pyi", "python"],
|
|
3289
|
+
[".ts", "typescript"],
|
|
3290
|
+
[".tsx", "typescript"],
|
|
3291
|
+
[".mts", "typescript"],
|
|
3292
|
+
[".cts", "typescript"],
|
|
3293
|
+
[".js", "javascript"],
|
|
3294
|
+
[".jsx", "javascript"],
|
|
3295
|
+
[".mjs", "javascript"],
|
|
3296
|
+
[".cjs", "javascript"],
|
|
3297
|
+
[".rs", "rust"],
|
|
3298
|
+
[".go", "go"],
|
|
3299
|
+
[".c", "c"],
|
|
3300
|
+
[".h", "c"],
|
|
3301
|
+
[".cpp", "cpp"],
|
|
3302
|
+
[".cc", "cpp"],
|
|
3303
|
+
[".cxx", "cpp"],
|
|
3304
|
+
[".hpp", "cpp"],
|
|
3305
|
+
[".hxx", "cpp"],
|
|
3306
|
+
[".rb", "ruby"],
|
|
3307
|
+
[".ruby", "ruby"],
|
|
3308
|
+
// Rake task files (lib/tasks/foo.rake) are plain Ruby syntax (`task :foo do ... end`),
|
|
3309
|
+
// parsed identically by the ruby tree-sitter grammar. Without this entry a `.rake` file
|
|
3310
|
+
// fell through to 'unknown' and indexed zero symbols despite the grammar handling its
|
|
3311
|
+
// content exactly like any other .rb file -- the same has-extractor-but-no-extension gap
|
|
3312
|
+
// previously fixed for `.mk` (Makefile fragments).
|
|
3313
|
+
[".rake", "ruby"],
|
|
3314
|
+
[".java", "java"],
|
|
3315
|
+
[".sh", "bash"],
|
|
3316
|
+
[".bash", "bash"],
|
|
3317
|
+
[".md", "markdown"],
|
|
3318
|
+
[".markdown", "markdown"],
|
|
3319
|
+
// MDX heading syntax is plain ATX and works with the existing markdown extractor as-is,
|
|
3320
|
+
// unlike .rst which genuinely needs an underline-style heading parser this extractor doesn't
|
|
3321
|
+
// implement (left as 'unknown' deliberately).
|
|
3322
|
+
[".mdx", "markdown"],
|
|
3323
|
+
[".toml", "toml"],
|
|
3324
|
+
[".json", "json"],
|
|
3325
|
+
[".yaml", "yaml"],
|
|
3326
|
+
[".yml", "yaml"],
|
|
3327
|
+
[".css", "css"],
|
|
3328
|
+
[".scss", "css"],
|
|
3329
|
+
[".sass", "css"],
|
|
3330
|
+
[".less", "css"],
|
|
3331
|
+
[".cs", "csharp"],
|
|
3332
|
+
[".php", "php"],
|
|
3333
|
+
[".html", "html"],
|
|
3334
|
+
[".htm", "html"],
|
|
3335
|
+
[".liquid", "liquid"],
|
|
3336
|
+
[".kt", "kotlin"],
|
|
3337
|
+
[".kts", "kotlin"],
|
|
3338
|
+
[".swift", "swift"],
|
|
3339
|
+
[".scala", "scala"],
|
|
3340
|
+
[".sc", "scala"],
|
|
3341
|
+
[".lua", "lua"],
|
|
3342
|
+
[".ex", "elixir"],
|
|
3343
|
+
[".exs", "elixir"],
|
|
3344
|
+
[".dart", "dart"],
|
|
3345
|
+
[".zig", "zig"],
|
|
3346
|
+
[".r", "r"],
|
|
3347
|
+
[".graphql", "graphql"],
|
|
3348
|
+
[".gql", "graphql"],
|
|
3349
|
+
[".sql", "sql"],
|
|
3350
|
+
[".ini", "ini"],
|
|
3351
|
+
[".cfg", "ini"],
|
|
3352
|
+
[".conf", "ini"],
|
|
3353
|
+
[".proto", "proto"],
|
|
3354
|
+
// `.mk` is the idiomatic extension for included Makefile fragments (config.mk, rules.mk,
|
|
3355
|
+
// common.mk); their syntax is identical to a bare `Makefile`, which FILENAME_LANGUAGE already
|
|
3356
|
+
// maps. Without this entry a `.mk` fragment fell through to 'unknown' and was indexed with zero
|
|
3357
|
+
// symbols despite extractMakefile handling its content fine -- the same has-extractor-but-no-
|
|
3358
|
+
// extension gap previously seen for other adapters. (importsExtensionFor already treats bare
|
|
3359
|
+
// Makefile basenames as `.mk` for the imports command, so extractImports' `.mk` branch was
|
|
3360
|
+
// reachable while symbol indexing was not.)
|
|
3361
|
+
[".mk", "makefile"],
|
|
3362
|
+
[".tf", "terraform"],
|
|
3363
|
+
[".tfvars", "terraform"],
|
|
3364
|
+
[".hcl", "terraform"],
|
|
3365
|
+
[".ps1", "powershell"],
|
|
3366
|
+
[".psm1", "powershell"],
|
|
3367
|
+
[".env", "env_file"],
|
|
3368
|
+
[".cls", "apex"],
|
|
3369
|
+
[".trigger", "apex"],
|
|
3370
|
+
[".cmp", "salesforce_markup"],
|
|
3371
|
+
[".app", "salesforce_markup"],
|
|
3372
|
+
[".evt", "salesforce_markup"],
|
|
3373
|
+
[".intf", "salesforce_markup"],
|
|
3374
|
+
[".design", "salesforce_markup"],
|
|
3375
|
+
[".auradoc", "salesforce_markup"],
|
|
3376
|
+
[".tokens", "salesforce_markup"],
|
|
3377
|
+
[".page", "salesforce_markup"],
|
|
3378
|
+
[".component", "salesforce_markup"],
|
|
3379
|
+
[".email", "salesforce_markup"],
|
|
3380
|
+
[".vue", "vue"],
|
|
3381
|
+
[".svelte", "svelte"],
|
|
3382
|
+
[".astro", "astro"],
|
|
3383
|
+
[".ipynb", "ipynb"]
|
|
3384
|
+
]);
|
|
3385
|
+
var FILENAME_LANGUAGE = /* @__PURE__ */ new Map([
|
|
3386
|
+
["dockerfile", "dockerfile"],
|
|
3387
|
+
["makefile", "makefile"],
|
|
3388
|
+
["gnumakefile", "makefile"],
|
|
3389
|
+
["bsdmakefile", "makefile"],
|
|
3390
|
+
["cargo.toml", "toml"],
|
|
3391
|
+
["pyproject.toml", "toml"],
|
|
3392
|
+
["package.json", "json"],
|
|
3393
|
+
["tsconfig.json", "json"],
|
|
3394
|
+
[".envrc", "env_file"],
|
|
3395
|
+
// Gemfile and Rakefile are plain Ruby syntax with no extension -- the dominant, idiomatic
|
|
3396
|
+
// dependency-manifest and task-runner files in virtually every real Ruby project (analogous to
|
|
3397
|
+
// package.json for Node or a bare Makefile). Without these entries both fell through to
|
|
3398
|
+
// 'unknown' and indexed zero symbols despite the ruby tree-sitter grammar handling their
|
|
3399
|
+
// content exactly like any other .rb file -- the same has-extractor-but-no-dispatch-entry gap
|
|
3400
|
+
// already fixed for bare `Makefile` / `.mk` fragments above.
|
|
3401
|
+
["gemfile", "ruby"],
|
|
3402
|
+
["rakefile", "ruby"],
|
|
3403
|
+
// Vagrantfile, Guardfile, Podfile, Capfile, Fastfile: same idiomatic extensionless-Ruby-DSL
|
|
3404
|
+
// pattern as Gemfile/Rakefile above -- `Vagrant.configure(...) do ... end`, Guard's `guard
|
|
3405
|
+
// 'rspec' do ... end`, CocoaPods' `Pod::Spec.new do |s| ... end`, Capistrano's `set :application`,
|
|
3406
|
+
// and fastlane's `lane :build do ... end` are all plain Ruby, parsed identically by the ruby
|
|
3407
|
+
// tree-sitter grammar. Without these entries each fell through to 'unknown' and indexed zero
|
|
3408
|
+
// symbols despite the grammar handling their content exactly like any other .rb file.
|
|
3409
|
+
["vagrantfile", "ruby"],
|
|
3410
|
+
["guardfile", "ruby"],
|
|
3411
|
+
["podfile", "ruby"],
|
|
3412
|
+
["capfile", "ruby"],
|
|
3413
|
+
["fastfile", "ruby"],
|
|
3414
|
+
// Brewfile: Homebrew Bundle's dependency manifest (`brew "wget"`, `cask "..."`, `tap "..."`)
|
|
3415
|
+
// is ordinary Ruby method-call syntax, evaluated by Homebrew's own Ruby DSL -- the extensionless
|
|
3416
|
+
// macOS-dev-environment analogue of Gemfile/package.json, and near-universal in dotfiles repos
|
|
3417
|
+
// that use `brew bundle dump`/`brew bundle install`. Same has-extractor-but-no-dispatch-entry
|
|
3418
|
+
// gap as the other extensionless Ruby DSL files above: without this entry it fell through to
|
|
3419
|
+
// 'unknown' and indexed zero symbols despite the ruby tree-sitter grammar handling its content
|
|
3420
|
+
// exactly like any other .rb file.
|
|
3421
|
+
["brewfile", "ruby"]
|
|
3422
|
+
]);
|
|
3423
|
+
var DOTENV_VARIANT_RE = /^\.env(\..+)?$/;
|
|
3424
|
+
function detectLanguage(filePath) {
|
|
3425
|
+
const base = path6.basename(filePath).toLowerCase();
|
|
3426
|
+
if (DOTENV_VARIANT_RE.test(base)) return "env_file";
|
|
3427
|
+
const byName = FILENAME_LANGUAGE.get(base);
|
|
3428
|
+
if (byName !== void 0) return byName;
|
|
3429
|
+
if (base.endsWith("-meta.xml")) {
|
|
3430
|
+
return "salesforce_metadata";
|
|
3431
|
+
}
|
|
3432
|
+
const ext = path6.extname(base).toLowerCase();
|
|
3433
|
+
return EXTENSION_LANGUAGE.get(ext) ?? "unknown";
|
|
3434
|
+
}
|
|
3435
|
+
var UNSUPPORTED_LANGUAGE_EXTENSIONS = /* @__PURE__ */ new Map([]);
|
|
3436
|
+
function unsupportedLanguageName(filePath) {
|
|
3437
|
+
const ext = path6.extname(filePath).toLowerCase();
|
|
3438
|
+
return UNSUPPORTED_LANGUAGE_EXTENSIONS.get(ext);
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
// src/doc_comment.ts
|
|
3442
|
+
function precedingDocComment(lines, lineStart, style) {
|
|
3443
|
+
const aboveIdx = lineStart - 2;
|
|
3444
|
+
if (aboveIdx < 0 || aboveIdx >= lines.length) return "";
|
|
3445
|
+
const aboveLine = lines[aboveIdx];
|
|
3446
|
+
if (aboveLine === void 0) return "";
|
|
3447
|
+
const aboveTrimmed = aboveLine.trim();
|
|
3448
|
+
if (style === "hash") {
|
|
3449
|
+
if (!aboveTrimmed.startsWith("#")) return "";
|
|
3450
|
+
const collected = [];
|
|
3451
|
+
let i = aboveIdx;
|
|
3452
|
+
while (i >= 0) {
|
|
3453
|
+
const line = lines[i];
|
|
3454
|
+
if (line === void 0) break;
|
|
3455
|
+
const trimmed = line.trim();
|
|
3456
|
+
if (!trimmed.startsWith("#")) break;
|
|
3457
|
+
collected.unshift(trimmed.replace(/^#+\s?/, ""));
|
|
3458
|
+
i--;
|
|
3459
|
+
}
|
|
3460
|
+
return collected.join("\n").trim();
|
|
3461
|
+
}
|
|
3462
|
+
if (aboveTrimmed.endsWith("*/")) {
|
|
3463
|
+
let blockStart = aboveIdx;
|
|
3464
|
+
while (blockStart >= 0) {
|
|
3465
|
+
const l = lines[blockStart];
|
|
3466
|
+
if (l === void 0) break;
|
|
3467
|
+
if (l.trim().startsWith("/*")) break;
|
|
3468
|
+
blockStart--;
|
|
3469
|
+
}
|
|
3470
|
+
if (blockStart < 0) return "";
|
|
3471
|
+
const opener = lines[blockStart];
|
|
3472
|
+
if (opener === void 0 || !opener.trim().startsWith("/*")) return "";
|
|
3473
|
+
const region = lines.slice(blockStart, aboveIdx + 1);
|
|
3474
|
+
const joined = region.join("\n").trimEnd();
|
|
3475
|
+
if (joined.indexOf("*/") !== joined.length - 2) return "";
|
|
3476
|
+
return region.map(
|
|
3477
|
+
(l) => l.trim().replace(/^\/\*+/, "").replace(/\*+\/$/, "").replace(/^\*\s?/, "").trim()
|
|
3478
|
+
).filter((l) => l !== "").join("\n");
|
|
3479
|
+
}
|
|
3480
|
+
if (aboveTrimmed.startsWith("//")) {
|
|
3481
|
+
const collected = [];
|
|
3482
|
+
let i = aboveIdx;
|
|
3483
|
+
while (i >= 0) {
|
|
3484
|
+
const line = lines[i];
|
|
3485
|
+
if (line === void 0) break;
|
|
3486
|
+
const trimmed = line.trim();
|
|
3487
|
+
if (!trimmed.startsWith("//")) break;
|
|
3488
|
+
collected.unshift(trimmed.replace(/^\/\/[/!]?\s?/, ""));
|
|
3489
|
+
i--;
|
|
3490
|
+
}
|
|
3491
|
+
return collected.join("\n").trim();
|
|
3492
|
+
}
|
|
3493
|
+
return "";
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
// src/languages/common.ts
|
|
3497
|
+
function buildLineIndex(text) {
|
|
3498
|
+
const idx = [0];
|
|
3499
|
+
for (let i = 0; i < text.length; i++) {
|
|
3500
|
+
if (text[i] === "\n") idx.push(i + 1);
|
|
3501
|
+
}
|
|
3502
|
+
return idx;
|
|
3503
|
+
}
|
|
3504
|
+
function offsetToLine(lineIndex, offset) {
|
|
3505
|
+
let lo = 0;
|
|
3506
|
+
let hi = lineIndex.length - 1;
|
|
3507
|
+
while (lo < hi) {
|
|
3508
|
+
const mid = lo + hi + 1 >> 1;
|
|
3509
|
+
const lineStart = lineIndex[mid];
|
|
3510
|
+
if (lineStart === void 0 || lineStart > offset) {
|
|
3511
|
+
hi = mid - 1;
|
|
3512
|
+
} else {
|
|
3513
|
+
lo = mid;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
return lo + 1;
|
|
3517
|
+
}
|
|
3518
|
+
function stripCstyleComments(text, lineCommentRe) {
|
|
3519
|
+
const lines = text.split("\n");
|
|
3520
|
+
let inComment = false;
|
|
3521
|
+
const outLines = [];
|
|
3522
|
+
for (const line of lines) {
|
|
3523
|
+
const { code, inComment: nextInComment } = stripBlockCommentSpan(line, inComment);
|
|
3524
|
+
outLines.push(code);
|
|
3525
|
+
inComment = nextInComment;
|
|
3526
|
+
}
|
|
3527
|
+
let out = outLines.join("\n");
|
|
3528
|
+
if (lineCommentRe !== void 0) {
|
|
3529
|
+
out = out.replace(lineCommentRe, (m) => " ".repeat(m.length));
|
|
3530
|
+
}
|
|
3531
|
+
return out;
|
|
3532
|
+
}
|
|
3533
|
+
function stripXmlComments(text) {
|
|
3534
|
+
const lines = text.split("\n");
|
|
3535
|
+
let inComment = false;
|
|
3536
|
+
const outLines = [];
|
|
3537
|
+
for (const line of lines) {
|
|
3538
|
+
let result = "";
|
|
3539
|
+
let j = 0;
|
|
3540
|
+
while (j < line.length) {
|
|
3541
|
+
if (!inComment) {
|
|
3542
|
+
const open = line.indexOf("<!--", j);
|
|
3543
|
+
if (open === -1) {
|
|
3544
|
+
result += line.slice(j);
|
|
3545
|
+
break;
|
|
3546
|
+
}
|
|
3547
|
+
result += line.slice(j, open);
|
|
3548
|
+
const close = line.indexOf("-->", open + 4);
|
|
3549
|
+
if (close === -1) {
|
|
3550
|
+
result += " ".repeat(line.length - open);
|
|
3551
|
+
inComment = true;
|
|
3552
|
+
break;
|
|
3553
|
+
}
|
|
3554
|
+
result += " ".repeat(close + 3 - open);
|
|
3555
|
+
j = close + 3;
|
|
3556
|
+
inComment = false;
|
|
3557
|
+
} else {
|
|
3558
|
+
const close = line.indexOf("-->", j);
|
|
3559
|
+
if (close === -1) {
|
|
3560
|
+
result += " ".repeat(line.length - j);
|
|
3561
|
+
break;
|
|
3562
|
+
}
|
|
3563
|
+
result += " ".repeat(close + 3 - j);
|
|
3564
|
+
j = close + 3;
|
|
3565
|
+
inComment = false;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
outLines.push(result);
|
|
3569
|
+
}
|
|
3570
|
+
return outLines.join("\n");
|
|
3571
|
+
}
|
|
3572
|
+
function scanQuotedStringEnd(content, start) {
|
|
3573
|
+
const quote = content[start];
|
|
3574
|
+
const n = content.length;
|
|
3575
|
+
let j = start + 1;
|
|
3576
|
+
while (j < n) {
|
|
3577
|
+
if (content[j] === "\\" && j + 1 < n) {
|
|
3578
|
+
j += 2;
|
|
3579
|
+
continue;
|
|
3580
|
+
}
|
|
3581
|
+
if (content[j] === quote) {
|
|
3582
|
+
j++;
|
|
3583
|
+
break;
|
|
3584
|
+
}
|
|
3585
|
+
if (quote !== "`" && content[j] === "\n") {
|
|
3586
|
+
j++;
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
j++;
|
|
3590
|
+
}
|
|
3591
|
+
return j;
|
|
3592
|
+
}
|
|
3593
|
+
function stripJsComments(content) {
|
|
3594
|
+
let out = "";
|
|
3595
|
+
let i = 0;
|
|
3596
|
+
const n = content.length;
|
|
3597
|
+
while (i < n) {
|
|
3598
|
+
const ch = content[i];
|
|
3599
|
+
if (ch === "/" && content[i + 1] === "/") {
|
|
3600
|
+
let j = i;
|
|
3601
|
+
while (j < n && content[j] !== "\n") j++;
|
|
3602
|
+
out += " ".repeat(j - i);
|
|
3603
|
+
i = j;
|
|
3604
|
+
continue;
|
|
3605
|
+
}
|
|
3606
|
+
if (ch === "/" && content[i + 1] === "*") {
|
|
3607
|
+
let j = i + 2;
|
|
3608
|
+
while (j < n && !(content[j] === "*" && content[j + 1] === "/")) j++;
|
|
3609
|
+
const end = j < n ? j + 2 : n;
|
|
3610
|
+
out += content.slice(i, end).replace(/[^\n]/g, " ");
|
|
3611
|
+
i = end;
|
|
3612
|
+
continue;
|
|
3613
|
+
}
|
|
3614
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
3615
|
+
const j = scanQuotedStringEnd(content, i);
|
|
3616
|
+
out += content.slice(i, j);
|
|
3617
|
+
i = j;
|
|
3618
|
+
continue;
|
|
3619
|
+
}
|
|
3620
|
+
out += ch;
|
|
3621
|
+
i++;
|
|
3622
|
+
}
|
|
3623
|
+
return out;
|
|
3624
|
+
}
|
|
3625
|
+
function stripHashComments(text) {
|
|
3626
|
+
return text.split("\n").map((line) => {
|
|
3627
|
+
for (let i = 0; i < line.length; i++) {
|
|
3628
|
+
if (line[i] === "#" && !isInsideStringLiteral(line, i)) {
|
|
3629
|
+
return line.slice(0, i) + " ".repeat(line.length - i);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
return line;
|
|
3633
|
+
}).join("\n");
|
|
3634
|
+
}
|
|
3635
|
+
var HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
3636
|
+
var HTML_SCRIPT_BODY_RE = /(<script\b[^>]*>)([\s\S]*?)(<\/script\s*>)/gi;
|
|
3637
|
+
var HTML_CDATA_RE = /<!\[CDATA\[[\s\S]*?\]\]>/g;
|
|
3638
|
+
var LIQUID_COMMENT_RE = /{%-?\s*comment\s*-?%}[\s\S]*?{%-?\s*endcomment\s*-?%}/gi;
|
|
3639
|
+
function maskHtmlNoise(text) {
|
|
3640
|
+
let out = text.replace(
|
|
3641
|
+
HTML_SCRIPT_BODY_RE,
|
|
3642
|
+
(_m, open, body, close) => open + body.replace(/[^\n]/g, " ") + close
|
|
3643
|
+
);
|
|
3644
|
+
out = out.replace(HTML_COMMENT_RE, (m) => m.replace(/[^\n]/g, " "));
|
|
3645
|
+
out = out.replace(LIQUID_COMMENT_RE, (m) => m.replace(/[^\n]/g, " "));
|
|
3646
|
+
out = out.replace(HTML_CDATA_RE, (m) => m.replace(/[^\n]/g, " "));
|
|
3647
|
+
return out;
|
|
3648
|
+
}
|
|
3649
|
+
var HTML_HEADING_RE = /<h([1-6])[^>]*>(.*?)<\/h\1>/gis;
|
|
3650
|
+
var HTML_HEADING_TAG_STRIP_RE = /<[^>]+>/g;
|
|
3651
|
+
function findHtmlHeadingMatches(content) {
|
|
3652
|
+
const masked = maskHtmlNoise(content);
|
|
3653
|
+
const matches = [];
|
|
3654
|
+
for (const m of masked.matchAll(HTML_HEADING_RE)) {
|
|
3655
|
+
const level = parseInt(m[1] ?? "1", 10);
|
|
3656
|
+
const raw = m[2] ?? "";
|
|
3657
|
+
const heading = raw.replace(HTML_HEADING_TAG_STRIP_RE, "").trim();
|
|
3658
|
+
matches.push({ level, heading, offset: m.index ?? 0, tag: m[0] ?? "" });
|
|
3659
|
+
}
|
|
3660
|
+
return matches;
|
|
3661
|
+
}
|
|
3662
|
+
function isInsideStringLiteral(line, index, from = 0) {
|
|
3663
|
+
let openQuote = null;
|
|
3664
|
+
let i = from;
|
|
3665
|
+
while (i < index) {
|
|
3666
|
+
const ch = line[i];
|
|
3667
|
+
if (openQuote !== null && ch === "\\" && i + 1 < line.length) {
|
|
3668
|
+
i += 2;
|
|
3669
|
+
continue;
|
|
3670
|
+
}
|
|
3671
|
+
if (ch === '"' || ch === "'") {
|
|
3672
|
+
if (openQuote === null) {
|
|
3673
|
+
openQuote = ch;
|
|
3674
|
+
} else if (openQuote === ch) {
|
|
3675
|
+
openQuote = null;
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
i++;
|
|
3679
|
+
}
|
|
3680
|
+
return openQuote !== null;
|
|
3681
|
+
}
|
|
3682
|
+
function stripBlockCommentSpan(line, inComment) {
|
|
3683
|
+
let code = "";
|
|
3684
|
+
let j = 0;
|
|
3685
|
+
let comment = inComment;
|
|
3686
|
+
while (j < line.length) {
|
|
3687
|
+
if (!comment) {
|
|
3688
|
+
const lineCommentIdx = lineCommentStartIndex(line, ["//"], j);
|
|
3689
|
+
let open = line.indexOf("/*", j);
|
|
3690
|
+
while (open !== -1 && (isInsideStringLiteral(line, open, j) || lineCommentIdx !== -1 && open >= lineCommentIdx)) {
|
|
3691
|
+
open = line.indexOf("/*", open + 1);
|
|
3692
|
+
}
|
|
3693
|
+
if (open === -1) {
|
|
3694
|
+
code += line.slice(j);
|
|
3695
|
+
break;
|
|
3696
|
+
}
|
|
3697
|
+
code += line.slice(j, open);
|
|
3698
|
+
const close = line.indexOf("*/", open + 2);
|
|
3699
|
+
if (close === -1) {
|
|
3700
|
+
code += " ".repeat(line.length - open);
|
|
3701
|
+
comment = true;
|
|
3702
|
+
break;
|
|
3703
|
+
}
|
|
3704
|
+
code += " ".repeat(close + 2 - open);
|
|
3705
|
+
j = close + 2;
|
|
3706
|
+
comment = false;
|
|
3707
|
+
} else {
|
|
3708
|
+
const close = line.indexOf("*/", j);
|
|
3709
|
+
if (close === -1) {
|
|
3710
|
+
code += " ".repeat(line.length - j);
|
|
3711
|
+
break;
|
|
3712
|
+
}
|
|
3713
|
+
code += " ".repeat(close + 2 - j);
|
|
3714
|
+
j = close + 2;
|
|
3715
|
+
comment = false;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
return { code, inComment: comment };
|
|
3719
|
+
}
|
|
3720
|
+
function stripNestedBlockCommentSpan(line, depth) {
|
|
3721
|
+
let code = "";
|
|
3722
|
+
let j = 0;
|
|
3723
|
+
let d = depth;
|
|
3724
|
+
while (j < line.length) {
|
|
3725
|
+
if (d === 0) {
|
|
3726
|
+
const lineCommentIdx = lineCommentStartIndex(line, ["//"], j);
|
|
3727
|
+
let open = line.indexOf("/*", j);
|
|
3728
|
+
while (open !== -1 && (isInsideStringLiteral(line, open, j) || lineCommentIdx !== -1 && open >= lineCommentIdx)) {
|
|
3729
|
+
open = line.indexOf("/*", open + 1);
|
|
3730
|
+
}
|
|
3731
|
+
if (open === -1) {
|
|
3732
|
+
code += line.slice(j);
|
|
3733
|
+
break;
|
|
3734
|
+
}
|
|
3735
|
+
code += line.slice(j, open);
|
|
3736
|
+
code += " ";
|
|
3737
|
+
j = open + 2;
|
|
3738
|
+
d = 1;
|
|
3739
|
+
} else {
|
|
3740
|
+
const open = line.indexOf("/*", j);
|
|
3741
|
+
const close = line.indexOf("*/", j);
|
|
3742
|
+
if (close === -1 && open === -1) {
|
|
3743
|
+
code += " ".repeat(line.length - j);
|
|
3744
|
+
break;
|
|
3745
|
+
}
|
|
3746
|
+
const next = close === -1 ? open : open === -1 ? close : Math.min(open, close);
|
|
3747
|
+
code += " ".repeat(next + 2 - j);
|
|
3748
|
+
d = Math.max(0, d + (next === open ? 1 : -1));
|
|
3749
|
+
j = next + 2;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
return { code, depth: d };
|
|
3753
|
+
}
|
|
3754
|
+
function stripLineComment(line, markers = ["//"]) {
|
|
3755
|
+
const cutIdx = lineCommentStartIndex(line, markers);
|
|
3756
|
+
return cutIdx === -1 ? line : line.slice(0, cutIdx);
|
|
3757
|
+
}
|
|
3758
|
+
function lineCommentStartIndex(line, markers, from = 0) {
|
|
3759
|
+
let cutIdx = -1;
|
|
3760
|
+
for (const marker of markers) {
|
|
3761
|
+
let idx = line.indexOf(marker, from);
|
|
3762
|
+
while (idx !== -1 && isInsideStringLiteral(line, idx, from)) {
|
|
3763
|
+
idx = line.indexOf(marker, idx + 1);
|
|
3764
|
+
}
|
|
3765
|
+
if (idx !== -1 && (cutIdx === -1 || idx < cutIdx)) cutIdx = idx;
|
|
3766
|
+
}
|
|
3767
|
+
return cutIdx;
|
|
3768
|
+
}
|
|
3769
|
+
function stripStringLiterals(line) {
|
|
3770
|
+
let out = "";
|
|
3771
|
+
let i = 0;
|
|
3772
|
+
const stack = [];
|
|
3773
|
+
while (i < line.length) {
|
|
3774
|
+
const ch = line[i];
|
|
3775
|
+
if (ch === "\n") {
|
|
3776
|
+
out += ch;
|
|
3777
|
+
i++;
|
|
3778
|
+
stack.length = 0;
|
|
3779
|
+
continue;
|
|
3780
|
+
}
|
|
3781
|
+
const top = stack[stack.length - 1];
|
|
3782
|
+
if (top === void 0) {
|
|
3783
|
+
if (ch === '"' || ch === "'") {
|
|
3784
|
+
const bareBraceHole = ch === '"' && i > 0 && line[i - 1] === "$";
|
|
3785
|
+
stack.push({ kind: "string", quote: ch, bareBraceHole });
|
|
3786
|
+
out += ch;
|
|
3787
|
+
i++;
|
|
3788
|
+
continue;
|
|
3789
|
+
}
|
|
3790
|
+
out += ch;
|
|
3791
|
+
i++;
|
|
3792
|
+
continue;
|
|
3793
|
+
}
|
|
3794
|
+
if (top.kind === "hole") {
|
|
3795
|
+
if (ch === '"' || ch === "'") {
|
|
3796
|
+
const bareBraceHole = ch === '"' && i > 0 && line[i - 1] === "$";
|
|
3797
|
+
stack.push({ kind: "string", quote: ch, bareBraceHole });
|
|
3798
|
+
out += ch;
|
|
3799
|
+
i++;
|
|
3800
|
+
continue;
|
|
3801
|
+
}
|
|
3802
|
+
if (ch === "{") {
|
|
3803
|
+
top.depth++;
|
|
3804
|
+
out += ch;
|
|
3805
|
+
i++;
|
|
3806
|
+
continue;
|
|
3807
|
+
}
|
|
3808
|
+
if (ch === "}") {
|
|
3809
|
+
if (top.depth > 0) {
|
|
3810
|
+
top.depth--;
|
|
3811
|
+
} else {
|
|
3812
|
+
stack.pop();
|
|
3813
|
+
}
|
|
3814
|
+
out += ch;
|
|
3815
|
+
i++;
|
|
3816
|
+
continue;
|
|
3817
|
+
}
|
|
3818
|
+
out += ch;
|
|
3819
|
+
i++;
|
|
3820
|
+
continue;
|
|
3821
|
+
}
|
|
3822
|
+
if (ch === "\\" && i + 1 < line.length) {
|
|
3823
|
+
out += " ";
|
|
3824
|
+
i += 2;
|
|
3825
|
+
continue;
|
|
3826
|
+
}
|
|
3827
|
+
if (ch === top.quote) {
|
|
3828
|
+
stack.pop();
|
|
3829
|
+
out += ch;
|
|
3830
|
+
i++;
|
|
3831
|
+
continue;
|
|
3832
|
+
}
|
|
3833
|
+
if (top.quote === '"') {
|
|
3834
|
+
if (top.bareBraceHole && ch === "{") {
|
|
3835
|
+
if (line[i + 1] === "{") {
|
|
3836
|
+
out += " ";
|
|
3837
|
+
i += 2;
|
|
3838
|
+
continue;
|
|
3839
|
+
}
|
|
3840
|
+
stack.push({ kind: "hole", depth: 0 });
|
|
3841
|
+
out += ch;
|
|
3842
|
+
i++;
|
|
3843
|
+
continue;
|
|
3844
|
+
}
|
|
3845
|
+
if (!top.bareBraceHole && ch === "$" && line[i + 1] === "{") {
|
|
3846
|
+
stack.push({ kind: "hole", depth: 0 });
|
|
3847
|
+
out += line.slice(i, i + 2);
|
|
3848
|
+
i += 2;
|
|
3849
|
+
continue;
|
|
3850
|
+
}
|
|
3851
|
+
if (!top.bareBraceHole && ch === "{" && line[i + 1] === "$") {
|
|
3852
|
+
stack.push({ kind: "hole", depth: 0 });
|
|
3853
|
+
out += ch;
|
|
3854
|
+
i++;
|
|
3855
|
+
continue;
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
out += " ";
|
|
3859
|
+
i++;
|
|
3860
|
+
}
|
|
3861
|
+
return out;
|
|
3862
|
+
}
|
|
3863
|
+
function findMultilineCloser(line, from, state) {
|
|
3864
|
+
switch (state.kind) {
|
|
3865
|
+
case "heredoc":
|
|
3866
|
+
case "nowdoc": {
|
|
3867
|
+
const re = new RegExp(`^[ \\t]*${escapeRegExp(state.identifier)}\\b`);
|
|
3868
|
+
const m = re.exec(line);
|
|
3869
|
+
return m ? { maskEnd: m[0].length } : null;
|
|
3870
|
+
}
|
|
3871
|
+
case "tripleSingleQuote": {
|
|
3872
|
+
const m = /'{3,}/.exec(line.slice(from));
|
|
3873
|
+
return m === null ? null : { maskEnd: from + m.index + m[0].length };
|
|
3874
|
+
}
|
|
3875
|
+
case "tripleQuote": {
|
|
3876
|
+
const n = state.identifier !== "" ? parseInt(state.identifier, 10) : 3;
|
|
3877
|
+
const re = new RegExp(`"{${n},}`);
|
|
3878
|
+
const m = re.exec(line.slice(from));
|
|
3879
|
+
return m === null ? null : { maskEnd: from + m.index + m[0].length };
|
|
3880
|
+
}
|
|
3881
|
+
case "verbatim": {
|
|
3882
|
+
if (!state.interpolated) {
|
|
3883
|
+
let j2 = from;
|
|
3884
|
+
while (j2 < line.length) {
|
|
3885
|
+
if (line[j2] === '"') {
|
|
3886
|
+
if (line[j2 + 1] === '"') {
|
|
3887
|
+
j2 += 2;
|
|
3888
|
+
continue;
|
|
3889
|
+
}
|
|
3890
|
+
return { maskEnd: j2 + 1 };
|
|
3891
|
+
}
|
|
3892
|
+
j2++;
|
|
3893
|
+
}
|
|
3894
|
+
return null;
|
|
3895
|
+
}
|
|
3896
|
+
let j = from;
|
|
3897
|
+
let holeDepth = 0;
|
|
3898
|
+
let nestedQuote = null;
|
|
3899
|
+
while (j < line.length) {
|
|
3900
|
+
const c = line[j];
|
|
3901
|
+
if (nestedQuote !== null) {
|
|
3902
|
+
if (c === "\\" && j + 1 < line.length) {
|
|
3903
|
+
j += 2;
|
|
3904
|
+
continue;
|
|
3905
|
+
}
|
|
3906
|
+
if (c === nestedQuote) {
|
|
3907
|
+
nestedQuote = null;
|
|
3908
|
+
}
|
|
3909
|
+
j++;
|
|
3910
|
+
continue;
|
|
3911
|
+
}
|
|
3912
|
+
if (holeDepth > 0) {
|
|
3913
|
+
if (c === '"' || c === "'") {
|
|
3914
|
+
nestedQuote = c;
|
|
3915
|
+
j++;
|
|
3916
|
+
continue;
|
|
3917
|
+
}
|
|
3918
|
+
if (c === "{") holeDepth++;
|
|
3919
|
+
else if (c === "}") holeDepth--;
|
|
3920
|
+
j++;
|
|
3921
|
+
continue;
|
|
3922
|
+
}
|
|
3923
|
+
if (c === "{") {
|
|
3924
|
+
holeDepth = 1;
|
|
3925
|
+
j++;
|
|
3926
|
+
continue;
|
|
3927
|
+
}
|
|
3928
|
+
if (c === '"') {
|
|
3929
|
+
if (line[j + 1] === '"') {
|
|
3930
|
+
j += 2;
|
|
3931
|
+
continue;
|
|
3932
|
+
}
|
|
3933
|
+
return { maskEnd: j + 1 };
|
|
3934
|
+
}
|
|
3935
|
+
j++;
|
|
3936
|
+
}
|
|
3937
|
+
return null;
|
|
3938
|
+
}
|
|
3939
|
+
case "psHereDouble":
|
|
3940
|
+
return line.startsWith('"@', from) ? { maskEnd: from + 2 } : null;
|
|
3941
|
+
case "psHereSingle":
|
|
3942
|
+
return line.startsWith("'@", from) ? { maskEnd: from + 2 } : null;
|
|
3943
|
+
default:
|
|
3944
|
+
return null;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
var MULTILINE_OPENER_COMMENT_MARKERS = {
|
|
3948
|
+
php: ["//", "#"],
|
|
3949
|
+
kotlin: ["//"],
|
|
3950
|
+
csharp: ["//"],
|
|
3951
|
+
powershell: ["#"],
|
|
3952
|
+
swift: ["//"],
|
|
3953
|
+
elixir: ["#"]
|
|
3954
|
+
};
|
|
3955
|
+
var MULTILINE_OPENER_BLOCK_COMMENT_LANGS = /* @__PURE__ */ new Set(["php", "kotlin", "csharp", "swift"]);
|
|
3956
|
+
function isInsideSameLineBlockComment(line, idx, from = 0) {
|
|
3957
|
+
let comment = false;
|
|
3958
|
+
let j = from;
|
|
3959
|
+
while (j < idx) {
|
|
3960
|
+
if (!comment) {
|
|
3961
|
+
const open = line.indexOf("/*", j);
|
|
3962
|
+
if (open === -1 || open >= idx) return false;
|
|
3963
|
+
if (isInsideStringLiteral(line, open, from)) {
|
|
3964
|
+
j = open + 2;
|
|
3965
|
+
continue;
|
|
3966
|
+
}
|
|
3967
|
+
comment = true;
|
|
3968
|
+
j = open + 2;
|
|
3969
|
+
} else {
|
|
3970
|
+
const close = line.indexOf("*/", j);
|
|
3971
|
+
if (close === -1 || close >= idx) return true;
|
|
3972
|
+
comment = false;
|
|
3973
|
+
j = close + 2;
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
return comment;
|
|
3977
|
+
}
|
|
3978
|
+
function findMultilineOpener(line, from, lang) {
|
|
3979
|
+
const commentIdx = lineCommentStartIndex(line, MULTILINE_OPENER_COMMENT_MARKERS[lang], from);
|
|
3980
|
+
const isCommented = (idx) => commentIdx !== -1 && idx >= commentIdx || MULTILINE_OPENER_BLOCK_COMMENT_LANGS.has(lang) && isInsideSameLineBlockComment(line, idx, from);
|
|
3981
|
+
if (lang === "php") {
|
|
3982
|
+
const re = /<<<\s*(['"]?)([A-Za-z_]\w*)\1/g;
|
|
3983
|
+
re.lastIndex = from;
|
|
3984
|
+
const m = re.exec(line);
|
|
3985
|
+
if (!m || isInsideStringLiteral(line, m.index, from) || isCommented(m.index)) return null;
|
|
3986
|
+
const identifier = m[2] ?? "";
|
|
3987
|
+
const kind = m[1] === "'" ? "nowdoc" : "heredoc";
|
|
3988
|
+
return { openStart: m.index, closesSameLine: null, state: { kind, identifier } };
|
|
3989
|
+
}
|
|
3990
|
+
if (lang === "kotlin") {
|
|
3991
|
+
const idx = line.indexOf('"""', from);
|
|
3992
|
+
if (idx === -1 || isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
|
|
3993
|
+
const closeIdx = line.indexOf('"""', idx + 3);
|
|
3994
|
+
if (closeIdx !== -1) {
|
|
3995
|
+
return { openStart: idx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "3" } };
|
|
3996
|
+
}
|
|
3997
|
+
return { openStart: idx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "3" } };
|
|
3998
|
+
}
|
|
3999
|
+
if (lang === "swift") {
|
|
4000
|
+
const idx = line.indexOf('"""', from);
|
|
4001
|
+
if (idx === -1 || isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
|
|
4002
|
+
const closeIdx = line.indexOf('"""', idx + 3);
|
|
4003
|
+
if (closeIdx !== -1) {
|
|
4004
|
+
return { openStart: idx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "3" } };
|
|
4005
|
+
}
|
|
4006
|
+
return { openStart: idx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "3" } };
|
|
4007
|
+
}
|
|
4008
|
+
if (lang === "elixir") {
|
|
4009
|
+
const candidates = [];
|
|
4010
|
+
const dq = line.indexOf('"""', from);
|
|
4011
|
+
if (dq !== -1) candidates.push([dq, "tripleQuote", '"""']);
|
|
4012
|
+
const sq = line.indexOf("'''", from);
|
|
4013
|
+
if (sq !== -1) candidates.push([sq, "tripleSingleQuote", "'''"]);
|
|
4014
|
+
candidates.sort((a, b) => a[0] - b[0]);
|
|
4015
|
+
const first = candidates[0];
|
|
4016
|
+
if (first === void 0) return null;
|
|
4017
|
+
const [idx, kind, delim] = first;
|
|
4018
|
+
if (isInsideStringLiteral(line, idx, from) || isCommented(idx)) return null;
|
|
4019
|
+
const closeIdx = line.indexOf(delim, idx + 3);
|
|
4020
|
+
const state = { kind, identifier: "3" };
|
|
4021
|
+
if (closeIdx !== -1) return { openStart: idx, closesSameLine: closeIdx + 3, state };
|
|
4022
|
+
return { openStart: idx, closesSameLine: null, state };
|
|
4023
|
+
}
|
|
4024
|
+
if (lang === "csharp") {
|
|
4025
|
+
const tripleRe = /"{3,}/g;
|
|
4026
|
+
tripleRe.lastIndex = from;
|
|
4027
|
+
const tripleM = tripleRe.exec(line);
|
|
4028
|
+
let tripleIdx = tripleM ? tripleM.index : -1;
|
|
4029
|
+
const tripleLen = tripleM ? tripleM[0].length : 0;
|
|
4030
|
+
if (tripleIdx !== -1 && (isInsideStringLiteral(line, tripleIdx, from) || isCommented(tripleIdx))) tripleIdx = -1;
|
|
4031
|
+
const verbRe = /\$?@\$?"/g;
|
|
4032
|
+
verbRe.lastIndex = from;
|
|
4033
|
+
const verbM = verbRe.exec(line);
|
|
4034
|
+
let verbIdx = verbM ? verbM.index : -1;
|
|
4035
|
+
if (verbIdx !== -1 && isCommented(verbIdx)) verbIdx = -1;
|
|
4036
|
+
if (verbIdx !== -1 && isInsideStringLiteral(line, verbIdx, from)) verbIdx = -1;
|
|
4037
|
+
if (tripleIdx === -1 && verbIdx === -1) return null;
|
|
4038
|
+
const useTriple = tripleIdx !== -1 && (verbIdx === -1 || tripleIdx < verbIdx);
|
|
4039
|
+
if (useTriple) {
|
|
4040
|
+
const closeRe = new RegExp(`"{${tripleLen},}`);
|
|
4041
|
+
const closeM = closeRe.exec(line.slice(tripleIdx + tripleLen));
|
|
4042
|
+
if (closeM !== null) {
|
|
4043
|
+
const closeIdx = tripleIdx + tripleLen + closeM.index;
|
|
4044
|
+
return { openStart: tripleIdx, closesSameLine: closeIdx + closeM[0].length, state: { kind: "tripleQuote", identifier: String(tripleLen) } };
|
|
4045
|
+
}
|
|
4046
|
+
return { openStart: tripleIdx, closesSameLine: null, state: { kind: "tripleQuote", identifier: String(tripleLen) } };
|
|
4047
|
+
}
|
|
4048
|
+
const quoteIdx = verbIdx + (verbM?.[0].length ?? 1) - 1;
|
|
4049
|
+
const interpolated = (verbM?.[0] ?? "").includes("$");
|
|
4050
|
+
const closer = findMultilineCloser(line, quoteIdx + 1, { kind: "verbatim", identifier: "", interpolated });
|
|
4051
|
+
if (closer !== null) {
|
|
4052
|
+
return { openStart: verbIdx, closesSameLine: closer.maskEnd, state: { kind: "verbatim", identifier: "", interpolated } };
|
|
4053
|
+
}
|
|
4054
|
+
return { openStart: verbIdx, closesSameLine: null, state: { kind: "verbatim", identifier: "", interpolated } };
|
|
4055
|
+
}
|
|
4056
|
+
if (lang === "powershell") {
|
|
4057
|
+
const re = /@("|')\s*$/;
|
|
4058
|
+
const tail = line.slice(from);
|
|
4059
|
+
const m = re.exec(tail);
|
|
4060
|
+
if (!m) return null;
|
|
4061
|
+
const openStart = from + m.index;
|
|
4062
|
+
if (isCommented(openStart)) return null;
|
|
4063
|
+
if (isInsideStringLiteral(line, openStart, from)) return null;
|
|
4064
|
+
const kind = m[1] === '"' ? "psHereDouble" : "psHereSingle";
|
|
4065
|
+
return { openStart, closesSameLine: null, state: { kind, identifier: "" } };
|
|
4066
|
+
}
|
|
4067
|
+
return null;
|
|
4068
|
+
}
|
|
4069
|
+
function stripMultilineStringSpan(line, state, lang) {
|
|
4070
|
+
let code = "";
|
|
4071
|
+
let i = 0;
|
|
4072
|
+
let cur = state;
|
|
4073
|
+
while (i < line.length) {
|
|
4074
|
+
if (cur !== null) {
|
|
4075
|
+
const closed = findMultilineCloser(line, i, cur);
|
|
4076
|
+
if (closed === null) {
|
|
4077
|
+
code += " ".repeat(line.length - i);
|
|
4078
|
+
i = line.length;
|
|
4079
|
+
continue;
|
|
4080
|
+
}
|
|
4081
|
+
code += " ".repeat(closed.maskEnd - i);
|
|
4082
|
+
i = closed.maskEnd;
|
|
4083
|
+
cur = null;
|
|
4084
|
+
continue;
|
|
4085
|
+
}
|
|
4086
|
+
const opened = findMultilineOpener(line, i, lang);
|
|
4087
|
+
if (opened === null) {
|
|
4088
|
+
code += line.slice(i);
|
|
4089
|
+
break;
|
|
4090
|
+
}
|
|
4091
|
+
code += line.slice(i, opened.openStart);
|
|
4092
|
+
if (opened.closesSameLine !== null) {
|
|
4093
|
+
code += " ".repeat(opened.closesSameLine - opened.openStart);
|
|
4094
|
+
i = opened.closesSameLine;
|
|
4095
|
+
cur = null;
|
|
4096
|
+
} else {
|
|
4097
|
+
code += " ".repeat(line.length - opened.openStart);
|
|
4098
|
+
i = line.length;
|
|
4099
|
+
cur = opened.state;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
return { code, state: cur };
|
|
4103
|
+
}
|
|
4104
|
+
function makeSpanSymbol(filePath, name, kind, span, parent = "", lines, style) {
|
|
4105
|
+
return {
|
|
4106
|
+
filePath,
|
|
4107
|
+
name,
|
|
4108
|
+
kind,
|
|
4109
|
+
lineStart: span.startLine,
|
|
4110
|
+
lineEnd: span.endLine,
|
|
4111
|
+
body: span.body,
|
|
4112
|
+
docstring: lines !== void 0 && style !== void 0 ? precedingDocComment(lines, span.startLine, style) : "",
|
|
4113
|
+
parent
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
function makeLineSymbol(filePath, name, kind, line, sig, parent, lines, style) {
|
|
4117
|
+
return {
|
|
4118
|
+
filePath,
|
|
4119
|
+
name,
|
|
4120
|
+
kind,
|
|
4121
|
+
lineStart: line,
|
|
4122
|
+
lineEnd: line,
|
|
4123
|
+
body: sig ?? "",
|
|
4124
|
+
docstring: lines !== void 0 && style !== void 0 ? precedingDocComment(lines, line, style) : "",
|
|
4125
|
+
parent: parent ?? ""
|
|
4126
|
+
};
|
|
4127
|
+
}
|
|
4128
|
+
function makeSymbolEmitter(symbols, sections, seen, filePath, maxSymbols = 500, maxHeadingLen = 120) {
|
|
4129
|
+
return function emit(name, kind, line) {
|
|
4130
|
+
if (!name || name.length > maxHeadingLen) return;
|
|
4131
|
+
if (symbols.length >= maxSymbols) return;
|
|
4132
|
+
const key = `${name}\0${kind}\0${line}`;
|
|
4133
|
+
if (seen.has(key)) return;
|
|
4134
|
+
seen.add(key);
|
|
4135
|
+
symbols.push({
|
|
4136
|
+
filePath,
|
|
4137
|
+
name,
|
|
4138
|
+
kind,
|
|
4139
|
+
lineStart: line,
|
|
4140
|
+
lineEnd: line,
|
|
4141
|
+
body: "",
|
|
4142
|
+
docstring: "",
|
|
4143
|
+
parent: ""
|
|
4144
|
+
});
|
|
4145
|
+
sections.push({ heading: name, level: 1, line, endLine: line });
|
|
4146
|
+
};
|
|
4147
|
+
}
|
|
4148
|
+
function assignFlatEndLines(sections, totalLines) {
|
|
4149
|
+
for (let i = 0; i < sections.length; i++) {
|
|
4150
|
+
const next = sections[i + 1];
|
|
4151
|
+
const s = sections[i];
|
|
4152
|
+
if (s === void 0) continue;
|
|
4153
|
+
const end = next !== void 0 ? next.line - 1 : totalLines;
|
|
4154
|
+
s.endLine = end < s.line ? s.line : end;
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
function propagateEndLinesToSymbols(symbols, sections) {
|
|
4158
|
+
const sectionMap = /* @__PURE__ */ new Map();
|
|
4159
|
+
for (const sec of sections) {
|
|
4160
|
+
const key = `${sec.heading}\0${sec.line}`;
|
|
4161
|
+
const queue = sectionMap.get(key);
|
|
4162
|
+
if (queue !== void 0) queue.push(sec.endLine);
|
|
4163
|
+
else sectionMap.set(key, [sec.endLine]);
|
|
4164
|
+
}
|
|
4165
|
+
return symbols.map((sym) => {
|
|
4166
|
+
const key = `${sym.name}\0${sym.lineStart}`;
|
|
4167
|
+
const endLine = sectionMap.get(key)?.shift();
|
|
4168
|
+
if (endLine !== void 0 && endLine !== sym.lineEnd) {
|
|
4169
|
+
return { ...sym, lineEnd: endLine };
|
|
4170
|
+
}
|
|
4171
|
+
return sym;
|
|
4172
|
+
});
|
|
4173
|
+
}
|
|
4174
|
+
function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex, lineCommentPrefix) {
|
|
4175
|
+
let depth = 0;
|
|
4176
|
+
let quote = null;
|
|
4177
|
+
for (let i = openBraceIndex; i < content.length; i++) {
|
|
4178
|
+
const ch = content[i];
|
|
4179
|
+
if (quote !== null) {
|
|
4180
|
+
if (ch === "\\") {
|
|
4181
|
+
i++;
|
|
4182
|
+
continue;
|
|
4183
|
+
}
|
|
4184
|
+
if (ch === quote) quote = null;
|
|
4185
|
+
continue;
|
|
4186
|
+
}
|
|
4187
|
+
if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
|
|
4188
|
+
while (i < content.length && content[i] !== "\n") i++;
|
|
4189
|
+
continue;
|
|
4190
|
+
}
|
|
4191
|
+
if (ch === '"' || ch === "'") {
|
|
4192
|
+
quote = ch;
|
|
4193
|
+
continue;
|
|
4194
|
+
}
|
|
4195
|
+
if (ch === "{") depth++;
|
|
4196
|
+
else if (ch === "}") {
|
|
4197
|
+
depth--;
|
|
4198
|
+
if (depth === 0) {
|
|
4199
|
+
return offsetToLine(lineIndex, i);
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
return totalLines;
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
// src/languages/ini_idx.ts
|
|
4207
|
+
var MAX_SECTIONS = 200;
|
|
4208
|
+
var MAX_HEADING_LEN = 200;
|
|
4209
|
+
var MAX_ENV_KEYS = 200;
|
|
4210
|
+
var HEADER_RE = /^\[([^\]\r\n]+)\]\s*(?:[;#].*)?$/;
|
|
4211
|
+
var ENV_KEY_RE = /^(?:export\s+)?([A-Za-z_][\w.-]*)\s*(?:=|:(?!\/\/))/;
|
|
4212
|
+
function extractIni(content, filePath) {
|
|
4213
|
+
const symbols = [];
|
|
4214
|
+
const sections = [];
|
|
4215
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4216
|
+
const lines = content.split(/\r?\n/);
|
|
4217
|
+
const totalLines = countContentLines(content);
|
|
4218
|
+
for (let i = 0; i < lines.length; i++) {
|
|
4219
|
+
if (symbols.length >= MAX_SECTIONS) break;
|
|
4220
|
+
const line = lines[i] ?? "";
|
|
4221
|
+
if (!line || line[0] !== "[") continue;
|
|
4222
|
+
const m = HEADER_RE.exec(line);
|
|
4223
|
+
if (m === null) continue;
|
|
4224
|
+
const name = m[1]?.trim() ?? "";
|
|
4225
|
+
if (!name || name.length > MAX_HEADING_LEN) continue;
|
|
4226
|
+
const key = `${name}\0${i + 1}`;
|
|
4227
|
+
if (seen.has(key)) continue;
|
|
4228
|
+
seen.add(key);
|
|
4229
|
+
symbols.push(makeLineSymbol(filePath, name, "ini_section", i + 1));
|
|
4230
|
+
sections.push({ heading: name, level: 1, line: i + 1, endLine: i + 1 });
|
|
4231
|
+
}
|
|
4232
|
+
sections.sort((a, b) => a.line - b.line);
|
|
4233
|
+
assignFlatEndLines(sections, totalLines);
|
|
4234
|
+
return propagateEndLinesToSymbols(symbols, sections);
|
|
4235
|
+
}
|
|
4236
|
+
function _isEscapedQuote(line, i, q) {
|
|
4237
|
+
if (q === "'") return false;
|
|
4238
|
+
let backslashes = 0;
|
|
4239
|
+
let j = i - 1;
|
|
4240
|
+
while (j >= 0 && line[j] === "\\") {
|
|
4241
|
+
backslashes++;
|
|
4242
|
+
j--;
|
|
4243
|
+
}
|
|
4244
|
+
return backslashes % 2 === 1;
|
|
4245
|
+
}
|
|
4246
|
+
function _lineClosesQuote(line, q) {
|
|
4247
|
+
for (let i = 0; i < line.length; i++) {
|
|
4248
|
+
if (line[i] === q && !_isEscapedQuote(line, i, q)) return true;
|
|
4249
|
+
}
|
|
4250
|
+
return false;
|
|
4251
|
+
}
|
|
4252
|
+
function _detectOpenQuote(value) {
|
|
4253
|
+
const trimmed = value.replace(/^\s+/, "");
|
|
4254
|
+
const q = trimmed[0];
|
|
4255
|
+
if (q !== '"' && q !== "'") return null;
|
|
4256
|
+
for (let i = 1; i < trimmed.length; i++) {
|
|
4257
|
+
if (trimmed[i] === q && !_isEscapedQuote(trimmed, i, q)) return null;
|
|
4258
|
+
}
|
|
4259
|
+
return q;
|
|
4260
|
+
}
|
|
4261
|
+
function extractEnv(content, filePath) {
|
|
4262
|
+
const symbols = [];
|
|
4263
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4264
|
+
const lines = content.split(/\r?\n/);
|
|
4265
|
+
let openQuote = null;
|
|
4266
|
+
for (let i = 0; i < lines.length; i++) {
|
|
4267
|
+
if (symbols.length >= MAX_ENV_KEYS) break;
|
|
4268
|
+
const line = lines[i] ?? "";
|
|
4269
|
+
if (openQuote !== null) {
|
|
4270
|
+
if (_lineClosesQuote(line, openQuote)) openQuote = null;
|
|
4271
|
+
continue;
|
|
4272
|
+
}
|
|
4273
|
+
if (!line || line[0] === "#" || line[0] === ";" || line[0] === " " || line[0] === " ") continue;
|
|
4274
|
+
const m = ENV_KEY_RE.exec(line);
|
|
4275
|
+
if (m === null) continue;
|
|
4276
|
+
const name = m[1]?.trim() ?? "";
|
|
4277
|
+
if (!name || name.length > MAX_HEADING_LEN) continue;
|
|
4278
|
+
const key = `${name}\0${i + 1}`;
|
|
4279
|
+
if (seen.has(key)) continue;
|
|
4280
|
+
seen.add(key);
|
|
4281
|
+
symbols.push(makeLineSymbol(filePath, name, "env_key", i + 1));
|
|
4282
|
+
openQuote = _detectOpenQuote(line.slice(m[0].length));
|
|
4283
|
+
}
|
|
4284
|
+
return symbols;
|
|
4285
|
+
}
|
|
4286
|
+
|
|
4287
|
+
// src/dotenv_redact.ts
|
|
4288
|
+
var DOTENV_VALUE_PLACEHOLDER = "[REDACTED:dotenv_value]";
|
|
4289
|
+
var ASSIGNMENT_RE = /^(\s*(?:export\s+)?[A-Za-z_][\w.-]*\s*(?:\+?=|:(?!\/\/)))/;
|
|
4290
|
+
var SAFE_LINE_RE = /^\s*(?:[#;].*)?$/;
|
|
4291
|
+
function isDotenvPath(filePath) {
|
|
4292
|
+
return detectLanguage(filePath) === "env_file";
|
|
4293
|
+
}
|
|
4294
|
+
function redactDotenvValues(text) {
|
|
4295
|
+
const lines = text.split("\n");
|
|
4296
|
+
const out = [];
|
|
4297
|
+
let openQuote = null;
|
|
4298
|
+
for (const raw of lines) {
|
|
4299
|
+
const hasCr = raw.endsWith("\r");
|
|
4300
|
+
const line = hasCr ? raw.slice(0, -1) : raw;
|
|
4301
|
+
const eol = hasCr ? "\r" : "";
|
|
4302
|
+
const emit = (s) => {
|
|
4303
|
+
out.push(`${s}${eol}`);
|
|
4304
|
+
};
|
|
4305
|
+
if (openQuote !== null) {
|
|
4306
|
+
if (_lineClosesQuote(line, openQuote)) openQuote = null;
|
|
4307
|
+
emit(DOTENV_VALUE_PLACEHOLDER);
|
|
4308
|
+
continue;
|
|
4309
|
+
}
|
|
4310
|
+
if (SAFE_LINE_RE.test(line)) {
|
|
4311
|
+
emit(line);
|
|
4312
|
+
continue;
|
|
4313
|
+
}
|
|
4314
|
+
const m = ASSIGNMENT_RE.exec(line);
|
|
4315
|
+
if (m === null || m[1] === void 0) {
|
|
4316
|
+
emit(DOTENV_VALUE_PLACEHOLDER);
|
|
4317
|
+
continue;
|
|
4318
|
+
}
|
|
4319
|
+
const prefix = m[1];
|
|
4320
|
+
openQuote = _detectOpenQuote(line.slice(prefix.length));
|
|
4321
|
+
emit(`${prefix}${DOTENV_VALUE_PLACEHOLDER}`);
|
|
4322
|
+
}
|
|
4323
|
+
return out.join("\n");
|
|
4324
|
+
}
|
|
4325
|
+
function redactIfDotenv(filePath, text) {
|
|
4326
|
+
return isDotenvPath(filePath) ? redactDotenvValues(text) : text;
|
|
4327
|
+
}
|
|
4328
|
+
|
|
3251
4329
|
// src/db.ts
|
|
3252
|
-
init_define_import_meta_env();
|
|
3253
4330
|
import * as fs6 from "node:fs";
|
|
3254
4331
|
import { createRequire as createRequire2 } from "node:module";
|
|
3255
|
-
import * as
|
|
4332
|
+
import * as path7 from "node:path";
|
|
3256
4333
|
import Database from "better-sqlite3";
|
|
3257
4334
|
var _require = createRequire2(import.meta.url);
|
|
3258
4335
|
var _connections = /* @__PURE__ */ new Map();
|
|
@@ -3504,7 +4581,7 @@ CREATE TRIGGER IF NOT EXISTS cache_recall_au AFTER UPDATE ON cache_recall BEGIN
|
|
|
3504
4581
|
VALUES (new.row_id, new.label, new.content);
|
|
3505
4582
|
END;
|
|
3506
4583
|
`;
|
|
3507
|
-
var SCHEMA_VERSION =
|
|
4584
|
+
var SCHEMA_VERSION = 11;
|
|
3508
4585
|
function alterTableIdempotent(conn, sql) {
|
|
3509
4586
|
try {
|
|
3510
4587
|
conn.exec(sql);
|
|
@@ -3512,6 +4589,26 @@ function alterTableIdempotent(conn, sql) {
|
|
|
3512
4589
|
if (!(err instanceof Error) || !/duplicate column/i.test(err.message)) throw err;
|
|
3513
4590
|
}
|
|
3514
4591
|
}
|
|
4592
|
+
function purgeDotenvEmbeddings(conn) {
|
|
4593
|
+
let paths;
|
|
4594
|
+
try {
|
|
4595
|
+
paths = conn.prepare("SELECT DISTINCT file_path FROM chunks").all().map((r) => r.file_path).filter(isDotenvPath);
|
|
4596
|
+
} catch {
|
|
4597
|
+
return;
|
|
4598
|
+
}
|
|
4599
|
+
if (paths.length === 0) return;
|
|
4600
|
+
for (const p of paths) {
|
|
4601
|
+
try {
|
|
4602
|
+
conn.prepare("DELETE FROM chunk_vectors WHERE rowid IN (SELECT id FROM chunks WHERE file_path = ?)").run(p);
|
|
4603
|
+
} catch {
|
|
4604
|
+
}
|
|
4605
|
+
conn.prepare("DELETE FROM chunks WHERE file_path = ?").run(p);
|
|
4606
|
+
try {
|
|
4607
|
+
conn.prepare("UPDATE files SET embed_sha = NULL WHERE path = ?").run(p);
|
|
4608
|
+
} catch {
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
3515
4612
|
var MIGRATIONS = {
|
|
3516
4613
|
// 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.
|
|
3517
4614
|
1: (conn) => alterTableIdempotent(conn, "ALTER TABLE files ADD COLUMN embed_sha TEXT"),
|
|
@@ -3520,7 +4617,15 @@ var MIGRATIONS = {
|
|
|
3520
4617
|
// 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.
|
|
3521
4618
|
8: (conn) => alterTableIdempotent(conn, "ALTER TABLE symbols ADD COLUMN parent TEXT NOT NULL DEFAULT ''"),
|
|
3522
4619
|
// 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.
|
|
3523
|
-
9: (conn) => alterTableIdempotent(conn, "ALTER TABLE hint_emissions ADD COLUMN bytes_emitted INTEGER")
|
|
4620
|
+
9: (conn) => alterTableIdempotent(conn, "ALTER TABLE hint_emissions ADD COLUMN bytes_emitted INTEGER"),
|
|
4621
|
+
// v10 -> v11: purge chunks (and their vectors) for dotenv files. Until this version, a tracked
|
|
4622
|
+
// `.env` was chunked and embedded verbatim on the git path, so `semantic` returned its values --
|
|
4623
|
+
// see dotenv_redact.ts. Redacting from now on is not enough on its own: the embed-freshness gate
|
|
4624
|
+
// (isEmbedFresh in parser.ts) skips a file whose bytes have not changed, so an already-indexed
|
|
4625
|
+
// .env would have kept serving its pre-fix chunks indefinitely. Deleting the rows here both
|
|
4626
|
+
// removes the stored secrets and, by clearing embed_sha, makes the next drain re-embed the file
|
|
4627
|
+
// through the redacting path.
|
|
4628
|
+
10: purgeDotenvEmbeddings
|
|
3524
4629
|
};
|
|
3525
4630
|
function runMigrations(conn, fromVersion, toVersion) {
|
|
3526
4631
|
for (let v = fromVersion; v < toVersion; v++) {
|
|
@@ -3566,8 +4671,8 @@ function initConnection(conn) {
|
|
|
3566
4671
|
}
|
|
3567
4672
|
}
|
|
3568
4673
|
function resolveDbPath(dbPath) {
|
|
3569
|
-
if (
|
|
3570
|
-
if (dbPath.includes("/") || dbPath.includes("\\")) return
|
|
4674
|
+
if (path7.isAbsolute(dbPath)) return dbPath;
|
|
4675
|
+
if (dbPath.includes("/") || dbPath.includes("\\")) return path7.resolve(dbPath);
|
|
3571
4676
|
return safeJoin(dataDir(), dbPath);
|
|
3572
4677
|
}
|
|
3573
4678
|
function connectionKey(dbPath) {
|
|
@@ -3578,7 +4683,7 @@ function getDb(dbPath) {
|
|
|
3578
4683
|
const { resolved, key } = connectionKey(dbPath);
|
|
3579
4684
|
const existing = _connections.get(key);
|
|
3580
4685
|
if (existing !== void 0) return existing;
|
|
3581
|
-
const dir =
|
|
4686
|
+
const dir = path7.dirname(resolved);
|
|
3582
4687
|
try {
|
|
3583
4688
|
ensureDirSync(dir);
|
|
3584
4689
|
} catch (e) {
|
|
@@ -3609,7 +4714,6 @@ function closeAllDbs() {
|
|
|
3609
4714
|
registerReset(closeAllDbs);
|
|
3610
4715
|
|
|
3611
4716
|
// src/render/ansi.ts
|
|
3612
|
-
init_define_import_meta_env();
|
|
3613
4717
|
function _colorStream(isatty) {
|
|
3614
4718
|
if (process.env["NO_COLOR"]) return false;
|
|
3615
4719
|
return isatty;
|
|
@@ -3684,11 +4788,9 @@ var C = {
|
|
|
3684
4788
|
};
|
|
3685
4789
|
|
|
3686
4790
|
// src/stats.ts
|
|
3687
|
-
|
|
3688
|
-
import * as path7 from "node:path";
|
|
4791
|
+
import * as path8 from "node:path";
|
|
3689
4792
|
|
|
3690
4793
|
// src/render/stats_renderer.ts
|
|
3691
|
-
init_define_import_meta_env();
|
|
3692
4794
|
var _STATS_MESSAGES_FALLBACK = {
|
|
3693
4795
|
bytesModeOnlyNote: "tracks bytes, not vision tokens",
|
|
3694
4796
|
sessionHintSplitNote: "session_hint shows realized savings; session_hint_overhead shows injected hint cost",
|
|
@@ -4414,6 +5516,8 @@ var KIND_TO_SOURCE = {
|
|
|
4414
5516
|
json_outline: SOURCE_READ,
|
|
4415
5517
|
yaml_query: SOURCE_READ,
|
|
4416
5518
|
yaml_outline: SOURCE_READ,
|
|
5519
|
+
xml_query: SOURCE_READ,
|
|
5520
|
+
xml_outline: SOURCE_READ,
|
|
4417
5521
|
openapi_op: SOURCE_READ,
|
|
4418
5522
|
openapi_outline: SOURCE_READ,
|
|
4419
5523
|
zip_list: SOURCE_READ,
|
|
@@ -4499,6 +5603,8 @@ var COMMAND_KINDS = {
|
|
|
4499
5603
|
"json-outline": /* @__PURE__ */ new Set(["json_outline"]),
|
|
4500
5604
|
"yaml-query": /* @__PURE__ */ new Set(["yaml_query"]),
|
|
4501
5605
|
"yaml-outline": /* @__PURE__ */ new Set(["yaml_outline"]),
|
|
5606
|
+
"xml-query": /* @__PURE__ */ new Set(["xml_query"]),
|
|
5607
|
+
"xml-outline": /* @__PURE__ */ new Set(["xml_outline"]),
|
|
4502
5608
|
"openapi-op": /* @__PURE__ */ new Set(["openapi_op"]),
|
|
4503
5609
|
"openapi-outline": /* @__PURE__ */ new Set(["openapi_outline"]),
|
|
4504
5610
|
"zip-list": /* @__PURE__ */ new Set(["zip_list"]),
|
|
@@ -4578,7 +5684,7 @@ var _globalSchemaApplied = /* @__PURE__ */ new Set();
|
|
|
4578
5684
|
registerReset(() => _globalSchemaApplied.clear());
|
|
4579
5685
|
function getGlobalDb(homeDir) {
|
|
4580
5686
|
const basePath = homeDir ? dataDirForHome(homeDir) : dataDir();
|
|
4581
|
-
const dbPath =
|
|
5687
|
+
const dbPath = path8.join(basePath, "global.db");
|
|
4582
5688
|
const db = getDb(dbPath);
|
|
4583
5689
|
if (!_globalSchemaApplied.has(dbPath)) {
|
|
4584
5690
|
db.exec(GLOBAL_SCHEMA_SQL);
|
|
@@ -4816,7 +5922,6 @@ function renderStats2(opts) {
|
|
|
4816
5922
|
}
|
|
4817
5923
|
|
|
4818
5924
|
// src/secret_redact.ts
|
|
4819
|
-
init_define_import_meta_env();
|
|
4820
5925
|
var SECRET_PATTERNS = [
|
|
4821
5926
|
// Anthropic keys share OpenAI's "sk-" prefix but are more specific
|
|
4822
5927
|
// ("sk-ant-"), so they're matched first — the generic OpenAI pattern's
|
|
@@ -4834,18 +5939,52 @@ var SECRET_PATTERNS = [
|
|
|
4834
5939
|
// contain '_' and could otherwise partially match the classic pattern.
|
|
4835
5940
|
["github_token", /github_pat_[A-Za-z0-9_]{22,}/g],
|
|
4836
5941
|
["github_token", /gh[oprsu]_[A-Za-z0-9]{36,}/g],
|
|
5942
|
+
// xapp- is Slack's app-level token (Socket Mode), a bearer credential in its own right that
|
|
5943
|
+
// the xox[baprs]- prefix does not cover. It gets its own entry rather than joining the
|
|
5944
|
+
// alternation above because it needs the full segmented shape (xapp-<ver>-<app id>-<digits>-
|
|
5945
|
+
// <hex>) to be safe: a bare /xapp-[A-Za-z0-9-]+/ redacted ordinary identifiers like
|
|
5946
|
+
// "xapp-config" and the css class "xapp-container", mangling normal source. The xox* prefixes
|
|
5947
|
+
// are distinctive enough on their own; "xapp-" is not.
|
|
4837
5948
|
["slack_token", /xox[baprs]-[A-Za-z0-9-]+/g],
|
|
5949
|
+
["slack_token", /xapp-\d-[A-Za-z0-9]{6,}-\d{8,}-[A-Za-z0-9]{16,}/g],
|
|
4838
5950
|
// Matches the full block (BEGIN marker through its matching END marker), not just the
|
|
4839
5951
|
// header -- the actual secret material is the base64 body between them, so redacting only
|
|
4840
5952
|
// the header line would leave the key bytes themselves fully readable in the cached blob.
|
|
4841
|
-
// The
|
|
4842
|
-
//
|
|
4843
|
-
|
|
5953
|
+
// The body is lazy and additionally refuses to cross a following BEGIN marker. Both halves
|
|
5954
|
+
// matter. The laziness bounds a successful match at the very next END marker; the negative
|
|
5955
|
+
// lookahead bounds a *failing* one, because a BEGIN with no END of its own would otherwise
|
|
5956
|
+
// scan to end-of-input, and a blob full of such markers made the pass quadratic -- 6 ms, 20 ms
|
|
5957
|
+
// and 78 ms for 2000, 4000 and 8000 of them, four times the work for twice the input, the same
|
|
5958
|
+
// shape as the lookbehind incident described above. Private key blocks do not nest, so
|
|
5959
|
+
// refusing to cross a BEGIN costs nothing in correctness.
|
|
5960
|
+
// The algorithm and ` BLOCK` groups are backreferenced in the END marker rather than repeated,
|
|
5961
|
+
// so a BEGIN only ever pairs with its own END spelling. Written as two independent optional
|
|
5962
|
+
// groups, `BEGIN PGP PRIVATE KEY` would happily close on a distant `END RSA PRIVATE KEY BLOCK`
|
|
5963
|
+
// and redact everything in between. A non-participating group backreferences as the empty
|
|
5964
|
+
// string in JS, which is exactly what the unprefixed `BEGIN PRIVATE KEY` form needs.
|
|
5965
|
+
// The algorithm list covers every armored private-key header openssl, ssh-keygen and gpg
|
|
5966
|
+
// actually emit, not just the ones a first draft happened to think of. ENCRYPTED is the
|
|
5967
|
+
// PKCS#8 passphrase-protected form (`openssl genpkey -aes256`, `ssh-keygen -m PKCS8`) and is
|
|
5968
|
+
// the most common shape of all; DSA is legacy but still written verbatim; PGP carries the
|
|
5969
|
+
// ` BLOCK` suffix, which is why that suffix is optional here. All three used to fall through
|
|
5970
|
+
// to disk in full. An encrypted key is still key material: the passphrase can be attacked
|
|
5971
|
+
// offline once the bytes are cached, so it is redacted like any other.
|
|
5972
|
+
// PuTTY `.ppk` files are deliberately not matched. They have no END marker -- the private
|
|
5973
|
+
// section is a `Private-Lines: N` count followed by exactly N base64 lines -- so bounding a
|
|
5974
|
+
// match would take a stateful parse rather than a regex, on a path that runs over every
|
|
5975
|
+
// command output. A regex guess at where the body ends is exactly the over-eager match this
|
|
5976
|
+
// module's header warns against.
|
|
5977
|
+
["private_key_block", /-----BEGIN (RSA |DSA |EC |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY( BLOCK)?-----(?:(?!-----BEGIN )[\s\S])*?-----END \1PRIVATE KEY\2-----/g],
|
|
4844
5978
|
// Redacts only the token itself, not the "Authorization: Bearer " prefix -- the lookbehind
|
|
4845
5979
|
// anchors on the header name and scheme so the surrounding request-log line stays readable,
|
|
4846
5980
|
// matching how AWS_ACCESS_KEY_ID=... above keeps its own prefix intact.
|
|
4847
|
-
|
|
4848
|
-
|
|
5981
|
+
// The optional quotes on either side of the colon are what let this see a header carried in
|
|
5982
|
+
// JSON rather than in raw wire format. Without them the lookbehind demanded the colon sit
|
|
5983
|
+
// directly against the header name and the scheme directly against the space, so a body like
|
|
5984
|
+
// {"Authorization": "Bearer <token>"} -- the shape any logged fetch or MCP result arrives in
|
|
5985
|
+
// -- matched nothing and the token was cached verbatim.
|
|
5986
|
+
["auth_bearer_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Bearer[ \t])[A-Za-z0-9\-._~+/]{10,}=*/gi],
|
|
5987
|
+
["auth_basic_token", /(?<=Authorization["']?[ \t]{0,8}:[ \t]{0,8}["']?[ \t]{0,8}Basic[ \t])[A-Za-z0-9+/]{6,}=*/gi],
|
|
4849
5988
|
// JWTs have no distinctive prefix of their own, but the base64url encoding of the smallest
|
|
4850
5989
|
// realistic header ('{"alg":' or similar) always starts with "eyJ", so that's the practical
|
|
4851
5990
|
// anchor here -- each of the three dot-separated segments requires a minimum length to avoid
|
|
@@ -4864,6 +6003,13 @@ var SECRET_PATTERNS = [
|
|
|
4864
6003
|
// are what make the short, generic 'sig' name safe to key on: a prose or code mention of "sig"
|
|
4865
6004
|
// never sits directly after a query separator followed by that much opaque token.
|
|
4866
6005
|
["presigned_signature", /(?<=[?&](?:X-Amz-Signature|X-Goog-Signature|sig)=)[A-Za-z0-9%+/=_-]{16,}/gi],
|
|
6006
|
+
// A password inside a connection url. `postgres://user:hunter2@db.internal` carries the
|
|
6007
|
+
// credential in the authority section, where there is no `key=value` separator for the
|
|
6008
|
+
// generic pattern below to anchor on, so a DATABASE_URL echoed by a failing migration or a
|
|
6009
|
+
// psql error went through untouched. The anchors are what keep this narrow: a scheme's `://`,
|
|
6010
|
+
// a userinfo segment, the colon, and a following `@`. `http://host:8080/path` has no `@` and
|
|
6011
|
+
// is left alone; so is any url without credentials.
|
|
6012
|
+
["url_credentials", /(?<=:\/\/[^\s:@/]{1,64}:)[^\s:@/]{1,256}(?=@)/g],
|
|
4867
6013
|
// Generic key=value assignments in .env-file and connection-string/query-string shape. The
|
|
4868
6014
|
// lookbehind again redacts only the value, and the value's character class deliberately
|
|
4869
6015
|
// excludes whitespace, '&', ';', '#', quote characters, and '[' ']' ':' -- that exclusion is
|
|
@@ -4879,13 +6025,19 @@ var SECRET_PATTERNS = [
|
|
|
4879
6025
|
// this cannot backtrack catastrophically -- there is no nested or overlapping quantifier for
|
|
4880
6026
|
// the engine to explore multiple ways of matching, so removing the upper bound does not
|
|
4881
6027
|
// introduce a ReDoS risk.
|
|
6028
|
+
// Quotes are permitted around the separator, but never inside the value class. A quoted value
|
|
6029
|
+
// is the ordinary way secrets are written -- .env files, JSON, YAML, TOML all quote by default
|
|
6030
|
+
// -- and the lookbehind used to stop dead at the opening quote, so `API_KEY="..."` passed
|
|
6031
|
+
// through in full while the bare `API_KEY=...` was caught. The closing quote of the key name
|
|
6032
|
+
// blocked it from the other side too, which is what kept every JSON body unredacted. Keeping
|
|
6033
|
+
// quotes out of the value class is still what stops the match running past the closing quote.
|
|
4882
6034
|
// The keyword may be a prefix of a longer key name rather than the whole of it, so the
|
|
4883
6035
|
// trailing identifier class below is load-bearing: without it the lookbehind required the
|
|
4884
6036
|
// keyword to sit immediately before the separator, and AWS_SECRET_ACCESS_KEY=,
|
|
4885
6037
|
// SECRET_KEY=, and DB_PASSWORD_HASH= all passed through in full. That class matches
|
|
4886
6038
|
// identifier characters only, so prose that merely mentions a keyword still never reaches
|
|
4887
6039
|
// a separator and stays unredacted. api[_-]?key covers the apikey and api-key spellings too.
|
|
4888
|
-
["generic_secret_assignment", /(?<=(?:password|passwd|secret|api[_-]?key)[a-z0-9_-]
|
|
6040
|
+
["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]
|
|
4889
6041
|
];
|
|
4890
6042
|
function redactSecrets(text) {
|
|
4891
6043
|
let count = 0;
|
|
@@ -4900,7 +6052,6 @@ function redactSecrets(text) {
|
|
|
4900
6052
|
}
|
|
4901
6053
|
|
|
4902
6054
|
// src/filters.ts
|
|
4903
|
-
init_define_import_meta_env();
|
|
4904
6055
|
var DROP = () => null;
|
|
4905
6056
|
var FILTERS = [
|
|
4906
6057
|
{
|
|
@@ -4961,7 +6112,6 @@ var FILTERS = [
|
|
|
4961
6112
|
];
|
|
4962
6113
|
|
|
4963
6114
|
// src/bash_compress.ts
|
|
4964
|
-
init_define_import_meta_env();
|
|
4965
6115
|
function stripAnsiCodes(text) {
|
|
4966
6116
|
return stripAnsiEscapes(text);
|
|
4967
6117
|
}
|
|
@@ -4980,10 +6130,13 @@ export {
|
|
|
4980
6130
|
fingerprintContent,
|
|
4981
6131
|
shortFingerprint,
|
|
4982
6132
|
fingerprintFile,
|
|
6133
|
+
fileIsAbsent,
|
|
4983
6134
|
normalizePath,
|
|
4984
6135
|
normalizeDarwinSystemAlias,
|
|
4985
6136
|
resolveIndexPath,
|
|
4986
6137
|
toDisplayPath,
|
|
6138
|
+
displaySafeText,
|
|
6139
|
+
displaySafePath,
|
|
4987
6140
|
sleepSync,
|
|
4988
6141
|
isWindows,
|
|
4989
6142
|
isCaseInsensitiveFs,
|
|
@@ -5015,6 +6168,7 @@ export {
|
|
|
5015
6168
|
grepFilteredToEmptyNotice,
|
|
5016
6169
|
countNoun,
|
|
5017
6170
|
excludeTestsHiddenNote,
|
|
6171
|
+
countContentLines,
|
|
5018
6172
|
escapeRegExp,
|
|
5019
6173
|
windowsCmdQuoteArg,
|
|
5020
6174
|
redactUrlQuery,
|
|
@@ -5034,6 +6188,9 @@ export {
|
|
|
5034
6188
|
isWithinQuietHours,
|
|
5035
6189
|
hookCommandFor,
|
|
5036
6190
|
suggestPackageNames,
|
|
6191
|
+
detectSourceEncoding,
|
|
6192
|
+
decodeSource,
|
|
6193
|
+
encodeSource,
|
|
5037
6194
|
canonicalize,
|
|
5038
6195
|
makeProjectAt,
|
|
5039
6196
|
findProject,
|
|
@@ -5055,6 +6212,36 @@ export {
|
|
|
5055
6212
|
loadPersistedConfig,
|
|
5056
6213
|
CONFIG_KEY_ENV_OVERRIDES,
|
|
5057
6214
|
saveConfig,
|
|
6215
|
+
precedingDocComment,
|
|
6216
|
+
buildLineIndex,
|
|
6217
|
+
offsetToLine,
|
|
6218
|
+
stripCstyleComments,
|
|
6219
|
+
stripXmlComments,
|
|
6220
|
+
scanQuotedStringEnd,
|
|
6221
|
+
stripJsComments,
|
|
6222
|
+
stripHashComments,
|
|
6223
|
+
maskHtmlNoise,
|
|
6224
|
+
findHtmlHeadingMatches,
|
|
6225
|
+
isInsideStringLiteral,
|
|
6226
|
+
stripBlockCommentSpan,
|
|
6227
|
+
stripNestedBlockCommentSpan,
|
|
6228
|
+
stripLineComment,
|
|
6229
|
+
stripStringLiterals,
|
|
6230
|
+
stripMultilineStringSpan,
|
|
6231
|
+
makeSpanSymbol,
|
|
6232
|
+
makeLineSymbol,
|
|
6233
|
+
makeSymbolEmitter,
|
|
6234
|
+
assignFlatEndLines,
|
|
6235
|
+
propagateEndLinesToSymbols,
|
|
6236
|
+
findMatchingBraceEndLine,
|
|
6237
|
+
extractIni,
|
|
6238
|
+
_lineClosesQuote,
|
|
6239
|
+
_detectOpenQuote,
|
|
6240
|
+
extractEnv,
|
|
6241
|
+
detectLanguage,
|
|
6242
|
+
unsupportedLanguageName,
|
|
6243
|
+
isDotenvPath,
|
|
6244
|
+
redactIfDotenv,
|
|
5058
6245
|
getDb,
|
|
5059
6246
|
colorStdout,
|
|
5060
6247
|
RESET,
|
|
@@ -5076,8 +6263,8 @@ export {
|
|
|
5076
6263
|
|
|
5077
6264
|
smol-toml/dist/date.js:
|
|
5078
6265
|
smol-toml/dist/error.js:
|
|
5079
|
-
smol-toml/dist/primitive.js:
|
|
5080
6266
|
smol-toml/dist/util.js:
|
|
6267
|
+
smol-toml/dist/primitive.js:
|
|
5081
6268
|
smol-toml/dist/extract.js:
|
|
5082
6269
|
smol-toml/dist/struct.js:
|
|
5083
6270
|
smol-toml/dist/parse.js:
|