overlane 0.1.139 → 0.1.141
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/dist/overlane.mjs +1931 -414
- package/package.json +1 -1
- package/plugins/claude/plugins/mvrx-harness/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-codemap.mjs +25 -24
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-context.mjs +19 -19
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-guard.mjs +12 -12
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-intake.mjs +19 -19
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-quota.mjs +17 -17
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-statusline.mjs +13 -13
- package/plugins/claude/plugins/mvrx-harness/scripts/harness-stop.mjs +17 -17
- package/plugins/codex/plugins/mvrx-harness/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-codemap.mjs +25 -24
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-context.mjs +19 -19
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-guard.mjs +12 -12
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-intake.mjs +19 -19
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-quota.mjs +17 -17
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-statusline.mjs +13 -13
- package/plugins/codex/plugins/mvrx-harness/scripts/harness-stop.mjs +17 -17
- package/plugins/release-manifest.json +22 -22
package/dist/overlane.mjs
CHANGED
|
@@ -288,14 +288,14 @@ function promiseAllObject(promisesObj) {
|
|
|
288
288
|
}
|
|
289
289
|
function randomString(length = 10) {
|
|
290
290
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
291
|
-
let
|
|
291
|
+
let str2 = "";
|
|
292
292
|
for (let i2 = 0; i2 < length; i2++) {
|
|
293
|
-
|
|
293
|
+
str2 += chars[Math.floor(Math.random() * chars.length)];
|
|
294
294
|
}
|
|
295
|
-
return
|
|
295
|
+
return str2;
|
|
296
296
|
}
|
|
297
|
-
function esc(
|
|
298
|
-
return JSON.stringify(
|
|
297
|
+
function esc(str2) {
|
|
298
|
+
return JSON.stringify(str2);
|
|
299
299
|
}
|
|
300
300
|
function slugify(input2) {
|
|
301
301
|
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -339,8 +339,8 @@ function numKeys(data) {
|
|
|
339
339
|
}
|
|
340
340
|
return keyCount;
|
|
341
341
|
}
|
|
342
|
-
function escapeRegex(
|
|
343
|
-
return
|
|
342
|
+
function escapeRegex(str2) {
|
|
343
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
344
344
|
}
|
|
345
345
|
function clone(inst, def, params) {
|
|
346
346
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -582,13 +582,13 @@ function getSizableOrigin(input2) {
|
|
|
582
582
|
return "file";
|
|
583
583
|
return "unknown";
|
|
584
584
|
}
|
|
585
|
-
function codePointLength(
|
|
586
|
-
const units =
|
|
587
|
-
if (!highSurrogate.test(
|
|
585
|
+
function codePointLength(str2) {
|
|
586
|
+
const units = str2.length;
|
|
587
|
+
if (!highSurrogate.test(str2))
|
|
588
588
|
return units;
|
|
589
589
|
let count = units;
|
|
590
590
|
for (let i2 = 0; i2 < units - 1; i2++) {
|
|
591
|
-
if ((
|
|
591
|
+
if ((str2.charCodeAt(i2) & 64512) === 55296 && (str2.charCodeAt(i2 + 1) & 64512) === 56320) {
|
|
592
592
|
count--;
|
|
593
593
|
i2++;
|
|
594
594
|
}
|
|
@@ -4545,7 +4545,7 @@ function isRef(value) {
|
|
|
4545
4545
|
function cloneIssues(issues) {
|
|
4546
4546
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4547
4547
|
}
|
|
4548
|
-
function isRecursive(inst, stack,
|
|
4548
|
+
function isRecursive(inst, stack, resolve20) {
|
|
4549
4549
|
const cached2 = recursive.get(inst);
|
|
4550
4550
|
if (cached2 !== void 0)
|
|
4551
4551
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4555,7 +4555,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4555
4555
|
let result = NONE;
|
|
4556
4556
|
const check2 = (child) => {
|
|
4557
4557
|
if (result !== PROVEN && child?._zod) {
|
|
4558
|
-
const answer = isRecursive(child, stack,
|
|
4558
|
+
const answer = isRecursive(child, stack, resolve20);
|
|
4559
4559
|
if (answer > result)
|
|
4560
4560
|
result = answer;
|
|
4561
4561
|
}
|
|
@@ -4566,7 +4566,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4566
4566
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
4567
4567
|
if (spread && !desc.enumerable)
|
|
4568
4568
|
continue;
|
|
4569
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4569
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve20) : NONE;
|
|
4570
4570
|
if (child > answer)
|
|
4571
4571
|
answer = child;
|
|
4572
4572
|
}
|
|
@@ -4630,7 +4630,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4630
4630
|
break;
|
|
4631
4631
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4632
4632
|
case "lazy": {
|
|
4633
|
-
const inner = def._cachedInner ?? (
|
|
4633
|
+
const inner = def._cachedInner ?? (resolve20 ? inst._zod.innerType : void 0);
|
|
4634
4634
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4635
4635
|
break;
|
|
4636
4636
|
}
|
|
@@ -24440,13 +24440,13 @@ var init_git = __esm({
|
|
|
24440
24440
|
|
|
24441
24441
|
// ../contracts/src/ci.ts
|
|
24442
24442
|
function stripComment(text) {
|
|
24443
|
-
let
|
|
24443
|
+
let quote4 = null;
|
|
24444
24444
|
for (let i2 = 0; i2 < text.length; i2 += 1) {
|
|
24445
24445
|
const ch = text[i2];
|
|
24446
|
-
if (
|
|
24447
|
-
if (ch ===
|
|
24446
|
+
if (quote4 !== null) {
|
|
24447
|
+
if (ch === quote4) quote4 = null;
|
|
24448
24448
|
} else if (ch === '"' || ch === "'") {
|
|
24449
|
-
if (i2 === 0 || /[\s[,{:]/.test(text[i2 - 1] ?? " "))
|
|
24449
|
+
if (i2 === 0 || /[\s[,{:]/.test(text[i2 - 1] ?? " ")) quote4 = ch;
|
|
24450
24450
|
} else if (ch === "#" && (i2 === 0 || /\s/.test(text[i2 - 1] ?? ""))) {
|
|
24451
24451
|
return text.slice(0, i2);
|
|
24452
24452
|
}
|
|
@@ -24478,13 +24478,13 @@ function parseScalar(raw, line3) {
|
|
|
24478
24478
|
const inner = text.slice(1, -1);
|
|
24479
24479
|
const items = [];
|
|
24480
24480
|
let current2 = "";
|
|
24481
|
-
let
|
|
24481
|
+
let quote4 = null;
|
|
24482
24482
|
for (const ch of inner) {
|
|
24483
|
-
if (
|
|
24483
|
+
if (quote4 !== null) {
|
|
24484
24484
|
current2 += ch;
|
|
24485
|
-
if (ch ===
|
|
24485
|
+
if (ch === quote4) quote4 = null;
|
|
24486
24486
|
} else if (ch === '"' || ch === "'") {
|
|
24487
|
-
|
|
24487
|
+
quote4 = ch;
|
|
24488
24488
|
current2 += ch;
|
|
24489
24489
|
} else if (ch === ",") {
|
|
24490
24490
|
items.push(parseScalar(current2, line3));
|
|
@@ -27154,6 +27154,67 @@ var init_observability = __esm({
|
|
|
27154
27154
|
}
|
|
27155
27155
|
});
|
|
27156
27156
|
|
|
27157
|
+
// ../contracts/src/code-nav.ts
|
|
27158
|
+
var CodeNavFreshness, CodeNavMeta, CodeNavSymbol, CodeNavTextHit, CodeFindAnswer, CodeOutlineAnswer, CodeRefsAnswer, CodeSpanAnswer;
|
|
27159
|
+
var init_code_nav = __esm({
|
|
27160
|
+
"../contracts/src/code-nav.ts"() {
|
|
27161
|
+
"use strict";
|
|
27162
|
+
init_zod();
|
|
27163
|
+
CodeNavFreshness = external_exports.enum(["fresh", "partial", "stale", "unavailable"]);
|
|
27164
|
+
CodeNavMeta = external_exports.object({
|
|
27165
|
+
/** The commit the index describes; null with no index. */
|
|
27166
|
+
indexedCommit: external_exports.string().nullable(),
|
|
27167
|
+
/** The commit the caller asked about (the checkout's HEAD for the local source); null when unknown. */
|
|
27168
|
+
requestedCommit: external_exports.string().nullable(),
|
|
27169
|
+
coverage: external_exports.object({
|
|
27170
|
+
/** Files the index parsed. */
|
|
27171
|
+
files: external_exports.number().int().nonnegative(),
|
|
27172
|
+
symbols: external_exports.number().int().nonnegative(),
|
|
27173
|
+
/** Files that could not be parsed (unsupported language, too large). */
|
|
27174
|
+
uncovered: external_exports.number().int().nonnegative(),
|
|
27175
|
+
/** Files that differ between the indexed and the requested commit; their answers come from a pattern scan or are missing. */
|
|
27176
|
+
changedSinceIndex: external_exports.number().int().nonnegative()
|
|
27177
|
+
}).strict(),
|
|
27178
|
+
freshness: CodeNavFreshness,
|
|
27179
|
+
/** True when an empty or short answer may be missing results (stale, partial or uncovered files), as opposed to a certain "no match". */
|
|
27180
|
+
incomplete: external_exports.boolean(),
|
|
27181
|
+
notice: external_exports.string().optional()
|
|
27182
|
+
}).strict();
|
|
27183
|
+
CodeNavSymbol = external_exports.object({ kind: external_exports.string(), qualified: external_exports.string(), path: external_exports.string(), line: external_exports.number().int().positive(), endLine: external_exports.number().int().positive().optional() }).strict();
|
|
27184
|
+
CodeNavTextHit = external_exports.object({ path: external_exports.string(), line: external_exports.number().int().positive(), text: external_exports.string() }).strict();
|
|
27185
|
+
CodeFindAnswer = CodeNavMeta.extend({
|
|
27186
|
+
source: external_exports.enum(["index", "search"]),
|
|
27187
|
+
matches: external_exports.array(CodeNavSymbol),
|
|
27188
|
+
more: external_exports.boolean(),
|
|
27189
|
+
/** Literal-search lines, when the index could not answer. */
|
|
27190
|
+
lines: external_exports.array(CodeNavTextHit).optional()
|
|
27191
|
+
}).strict();
|
|
27192
|
+
CodeOutlineAnswer = CodeNavMeta.extend({
|
|
27193
|
+
path: external_exports.string(),
|
|
27194
|
+
source: external_exports.enum(["index", "pattern"]),
|
|
27195
|
+
symbols: external_exports.array(external_exports.object({ line: external_exports.number().int().positive(), kind: external_exports.string(), name: external_exports.string() }).strict())
|
|
27196
|
+
}).strict();
|
|
27197
|
+
CodeRefsAnswer = CodeNavMeta.extend({
|
|
27198
|
+
name: external_exports.string(),
|
|
27199
|
+
source: external_exports.enum(["index", "search"]),
|
|
27200
|
+
callers: external_exports.array(CodeNavSymbol),
|
|
27201
|
+
matches: external_exports.array(CodeNavTextHit),
|
|
27202
|
+
skippedImports: external_exports.number().int().nonnegative(),
|
|
27203
|
+
more: external_exports.number().int().nonnegative()
|
|
27204
|
+
}).strict();
|
|
27205
|
+
CodeSpanAnswer = CodeNavMeta.extend({
|
|
27206
|
+
found: external_exports.boolean(),
|
|
27207
|
+
path: external_exports.string(),
|
|
27208
|
+
kind: external_exports.string(),
|
|
27209
|
+
qualified: external_exports.string(),
|
|
27210
|
+
start: external_exports.number().int().nonnegative(),
|
|
27211
|
+
end: external_exports.number().int().nonnegative(),
|
|
27212
|
+
/** Other definitions of the same name, best first. */
|
|
27213
|
+
also: external_exports.array(CodeNavSymbol)
|
|
27214
|
+
}).strict();
|
|
27215
|
+
}
|
|
27216
|
+
});
|
|
27217
|
+
|
|
27157
27218
|
// ../contracts/src/index.ts
|
|
27158
27219
|
var init_src = __esm({
|
|
27159
27220
|
"../contracts/src/index.ts"() {
|
|
@@ -27205,6 +27266,7 @@ var init_src = __esm({
|
|
|
27205
27266
|
init_egress();
|
|
27206
27267
|
init_enterprise();
|
|
27207
27268
|
init_observability();
|
|
27269
|
+
init_code_nav();
|
|
27208
27270
|
}
|
|
27209
27271
|
});
|
|
27210
27272
|
|
|
@@ -28155,13 +28217,13 @@ var require_Collection = __commonJS({
|
|
|
28155
28217
|
var require_stringifyComment = __commonJS({
|
|
28156
28218
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
|
|
28157
28219
|
"use strict";
|
|
28158
|
-
var stringifyComment = (
|
|
28220
|
+
var stringifyComment = (str2) => str2.replace(/^(?!$)(?: $)?/gm, "#");
|
|
28159
28221
|
function indentComment(comment, indent) {
|
|
28160
28222
|
if (/^\n+$/.test(comment))
|
|
28161
28223
|
return comment.substring(1);
|
|
28162
28224
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
28163
28225
|
}
|
|
28164
|
-
var lineComment = (
|
|
28226
|
+
var lineComment = (str2, indent, comment) => str2.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str2.endsWith(" ") ? "" : " ") + comment;
|
|
28165
28227
|
exports.indentComment = indentComment;
|
|
28166
28228
|
exports.lineComment = lineComment;
|
|
28167
28229
|
exports.stringifyComment = stringifyComment;
|
|
@@ -28315,16 +28377,16 @@ var require_stringifyString = __commonJS({
|
|
|
28315
28377
|
lineWidth: ctx.options.lineWidth,
|
|
28316
28378
|
minContentWidth: ctx.options.minContentWidth
|
|
28317
28379
|
});
|
|
28318
|
-
var containsDocumentMarker = (
|
|
28319
|
-
function lineLengthOverLimit(
|
|
28380
|
+
var containsDocumentMarker = (str2) => /^(%|---|\.\.\.)/m.test(str2);
|
|
28381
|
+
function lineLengthOverLimit(str2, lineWidth, indentLength) {
|
|
28320
28382
|
if (!lineWidth || lineWidth < 0)
|
|
28321
28383
|
return false;
|
|
28322
28384
|
const limit = lineWidth - indentLength;
|
|
28323
|
-
const strLen =
|
|
28385
|
+
const strLen = str2.length;
|
|
28324
28386
|
if (strLen <= limit)
|
|
28325
28387
|
return false;
|
|
28326
28388
|
for (let i2 = 0, start2 = 0; i2 < strLen; ++i2) {
|
|
28327
|
-
if (
|
|
28389
|
+
if (str2[i2] === "\n") {
|
|
28328
28390
|
if (i2 - start2 > limit)
|
|
28329
28391
|
return true;
|
|
28330
28392
|
start2 = i2 + 1;
|
|
@@ -28341,11 +28403,11 @@ var require_stringifyString = __commonJS({
|
|
|
28341
28403
|
const { implicitKey } = ctx;
|
|
28342
28404
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
28343
28405
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
28344
|
-
let
|
|
28406
|
+
let str2 = "";
|
|
28345
28407
|
let start2 = 0;
|
|
28346
28408
|
for (let i2 = 0, ch = json2[i2]; ch; ch = json2[++i2]) {
|
|
28347
28409
|
if (ch === " " && json2[i2 + 1] === "\\" && json2[i2 + 2] === "n") {
|
|
28348
|
-
|
|
28410
|
+
str2 += json2.slice(start2, i2) + "\\ ";
|
|
28349
28411
|
i2 += 1;
|
|
28350
28412
|
start2 = i2;
|
|
28351
28413
|
ch = "\\";
|
|
@@ -28354,38 +28416,38 @@ var require_stringifyString = __commonJS({
|
|
|
28354
28416
|
switch (json2[i2 + 1]) {
|
|
28355
28417
|
case "u":
|
|
28356
28418
|
{
|
|
28357
|
-
|
|
28419
|
+
str2 += json2.slice(start2, i2);
|
|
28358
28420
|
const code2 = json2.substr(i2 + 2, 4);
|
|
28359
28421
|
switch (code2) {
|
|
28360
28422
|
case "0000":
|
|
28361
|
-
|
|
28423
|
+
str2 += "\\0";
|
|
28362
28424
|
break;
|
|
28363
28425
|
case "0007":
|
|
28364
|
-
|
|
28426
|
+
str2 += "\\a";
|
|
28365
28427
|
break;
|
|
28366
28428
|
case "000b":
|
|
28367
|
-
|
|
28429
|
+
str2 += "\\v";
|
|
28368
28430
|
break;
|
|
28369
28431
|
case "001b":
|
|
28370
|
-
|
|
28432
|
+
str2 += "\\e";
|
|
28371
28433
|
break;
|
|
28372
28434
|
case "0085":
|
|
28373
|
-
|
|
28435
|
+
str2 += "\\N";
|
|
28374
28436
|
break;
|
|
28375
28437
|
case "00a0":
|
|
28376
|
-
|
|
28438
|
+
str2 += "\\_";
|
|
28377
28439
|
break;
|
|
28378
28440
|
case "2028":
|
|
28379
|
-
|
|
28441
|
+
str2 += "\\L";
|
|
28380
28442
|
break;
|
|
28381
28443
|
case "2029":
|
|
28382
|
-
|
|
28444
|
+
str2 += "\\P";
|
|
28383
28445
|
break;
|
|
28384
28446
|
default:
|
|
28385
28447
|
if (code2.substr(0, 2) === "00")
|
|
28386
|
-
|
|
28448
|
+
str2 += "\\x" + code2.substr(2);
|
|
28387
28449
|
else
|
|
28388
|
-
|
|
28450
|
+
str2 += json2.substr(i2, 6);
|
|
28389
28451
|
}
|
|
28390
28452
|
i2 += 5;
|
|
28391
28453
|
start2 = i2 + 1;
|
|
@@ -28395,14 +28457,14 @@ var require_stringifyString = __commonJS({
|
|
|
28395
28457
|
if (implicitKey || json2[i2 + 2] === '"' || json2.length < minMultiLineLength) {
|
|
28396
28458
|
i2 += 1;
|
|
28397
28459
|
} else {
|
|
28398
|
-
|
|
28460
|
+
str2 += json2.slice(start2, i2) + "\n\n";
|
|
28399
28461
|
while (json2[i2 + 2] === "\\" && json2[i2 + 3] === "n" && json2[i2 + 4] !== '"') {
|
|
28400
|
-
|
|
28462
|
+
str2 += "\n";
|
|
28401
28463
|
i2 += 2;
|
|
28402
28464
|
}
|
|
28403
|
-
|
|
28465
|
+
str2 += indent;
|
|
28404
28466
|
if (json2[i2 + 2] === " ")
|
|
28405
|
-
|
|
28467
|
+
str2 += "\\";
|
|
28406
28468
|
i2 += 1;
|
|
28407
28469
|
start2 = i2 + 1;
|
|
28408
28470
|
}
|
|
@@ -28411,8 +28473,8 @@ var require_stringifyString = __commonJS({
|
|
|
28411
28473
|
i2 += 1;
|
|
28412
28474
|
}
|
|
28413
28475
|
}
|
|
28414
|
-
|
|
28415
|
-
return implicitKey ?
|
|
28476
|
+
str2 = start2 ? str2 + json2.slice(start2) : json2;
|
|
28477
|
+
return implicitKey ? str2 : foldFlowLines.foldFlowLines(str2, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
28416
28478
|
}
|
|
28417
28479
|
function singleQuotedString(value, ctx) {
|
|
28418
28480
|
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
|
|
@@ -28540,15 +28602,15 @@ ${indent}${start2}${value}${end}`;
|
|
|
28540
28602
|
return quotedString(value, ctx);
|
|
28541
28603
|
}
|
|
28542
28604
|
}
|
|
28543
|
-
const
|
|
28605
|
+
const str2 = value.replace(/\n+/g, `$&
|
|
28544
28606
|
${indent}`);
|
|
28545
28607
|
if (actualString) {
|
|
28546
|
-
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(
|
|
28608
|
+
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str2);
|
|
28547
28609
|
const { compat, tags } = ctx.doc.schema;
|
|
28548
28610
|
if (tags.some(test) || compat?.some(test))
|
|
28549
28611
|
return quotedString(value, ctx);
|
|
28550
28612
|
}
|
|
28551
|
-
return implicitKey ?
|
|
28613
|
+
return implicitKey ? str2 : foldFlowLines.foldFlowLines(str2, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
28552
28614
|
}
|
|
28553
28615
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
28554
28616
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -28700,11 +28762,11 @@ var require_stringify = __commonJS({
|
|
|
28700
28762
|
const props = stringifyProps(node2, tagObj, ctx);
|
|
28701
28763
|
if (props.length > 0)
|
|
28702
28764
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
28703
|
-
const
|
|
28765
|
+
const str2 = typeof tagObj.stringify === "function" ? tagObj.stringify(node2, ctx, onComment, onChompKeep) : identity.isScalar(node2) ? stringifyString.stringifyString(node2, ctx, onComment, onChompKeep) : node2.toString(ctx, onComment, onChompKeep);
|
|
28704
28766
|
if (!props)
|
|
28705
|
-
return
|
|
28706
|
-
return identity.isScalar(node2) ||
|
|
28707
|
-
${ctx.indent}${
|
|
28767
|
+
return str2;
|
|
28768
|
+
return identity.isScalar(node2) || str2[0] === "{" || str2[0] === "[" ? `${props} ${str2}` : `${props}
|
|
28769
|
+
${ctx.indent}${str2}`;
|
|
28708
28770
|
}
|
|
28709
28771
|
exports.createStringifyContext = createStringifyContext;
|
|
28710
28772
|
exports.stringify = stringify2;
|
|
@@ -28739,8 +28801,8 @@ var require_stringifyPair = __commonJS({
|
|
|
28739
28801
|
});
|
|
28740
28802
|
let keyCommentDone = false;
|
|
28741
28803
|
let chompKeep = false;
|
|
28742
|
-
let
|
|
28743
|
-
if (!explicitKey && !ctx.inFlow &&
|
|
28804
|
+
let str2 = stringify2.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
28805
|
+
if (!explicitKey && !ctx.inFlow && str2.length > 1024) {
|
|
28744
28806
|
if (simpleKeys)
|
|
28745
28807
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
28746
28808
|
explicitKey = true;
|
|
@@ -28749,27 +28811,27 @@ var require_stringifyPair = __commonJS({
|
|
|
28749
28811
|
if (allNullValues || value == null) {
|
|
28750
28812
|
if (keyCommentDone && onComment)
|
|
28751
28813
|
onComment();
|
|
28752
|
-
return
|
|
28814
|
+
return str2 === "" ? "?" : explicitKey ? `? ${str2}` : str2;
|
|
28753
28815
|
}
|
|
28754
28816
|
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
|
|
28755
|
-
|
|
28817
|
+
str2 = `? ${str2}`;
|
|
28756
28818
|
if (keyComment && !keyCommentDone) {
|
|
28757
|
-
|
|
28819
|
+
str2 += stringifyComment.lineComment(str2, ctx.indent, commentString(keyComment));
|
|
28758
28820
|
} else if (chompKeep && onChompKeep)
|
|
28759
28821
|
onChompKeep();
|
|
28760
|
-
return
|
|
28822
|
+
return str2;
|
|
28761
28823
|
}
|
|
28762
28824
|
if (keyCommentDone)
|
|
28763
28825
|
keyComment = null;
|
|
28764
28826
|
if (explicitKey) {
|
|
28765
28827
|
if (keyComment)
|
|
28766
|
-
|
|
28767
|
-
|
|
28828
|
+
str2 += stringifyComment.lineComment(str2, ctx.indent, commentString(keyComment));
|
|
28829
|
+
str2 = `? ${str2}
|
|
28768
28830
|
${indent}:`;
|
|
28769
28831
|
} else {
|
|
28770
|
-
|
|
28832
|
+
str2 = `${str2}:`;
|
|
28771
28833
|
if (keyComment)
|
|
28772
|
-
|
|
28834
|
+
str2 += stringifyComment.lineComment(str2, ctx.indent, commentString(keyComment));
|
|
28773
28835
|
}
|
|
28774
28836
|
let vsb, vcb, valueComment;
|
|
28775
28837
|
if (identity.isNode(value)) {
|
|
@@ -28785,7 +28847,7 @@ ${indent}:`;
|
|
|
28785
28847
|
}
|
|
28786
28848
|
ctx.implicitKey = false;
|
|
28787
28849
|
if (!explicitKey && !keyComment && identity.isScalar(value))
|
|
28788
|
-
ctx.indentAtStart =
|
|
28850
|
+
ctx.indentAtStart = str2.length + 1;
|
|
28789
28851
|
chompKeep = false;
|
|
28790
28852
|
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
28791
28853
|
ctx.indent = ctx.indent.substring(2);
|
|
@@ -28829,16 +28891,16 @@ ${ctx.indent}`;
|
|
|
28829
28891
|
} else if (valueStr === "" || valueStr[0] === "\n") {
|
|
28830
28892
|
ws = "";
|
|
28831
28893
|
}
|
|
28832
|
-
|
|
28894
|
+
str2 += ws + valueStr;
|
|
28833
28895
|
if (ctx.inFlow) {
|
|
28834
28896
|
if (valueCommentDone && onComment)
|
|
28835
28897
|
onComment();
|
|
28836
28898
|
} else if (valueComment && !valueCommentDone) {
|
|
28837
|
-
|
|
28899
|
+
str2 += stringifyComment.lineComment(str2, ctx.indent, commentString(valueComment));
|
|
28838
28900
|
} else if (chompKeep && onChompKeep) {
|
|
28839
28901
|
onChompKeep();
|
|
28840
28902
|
}
|
|
28841
|
-
return
|
|
28903
|
+
return str2;
|
|
28842
28904
|
}
|
|
28843
28905
|
exports.stringifyPair = stringifyPair;
|
|
28844
28906
|
}
|
|
@@ -29065,31 +29127,31 @@ var require_stringifyCollection = __commonJS({
|
|
|
29065
29127
|
}
|
|
29066
29128
|
}
|
|
29067
29129
|
chompKeep = false;
|
|
29068
|
-
let
|
|
29130
|
+
let str3 = stringify2.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
29069
29131
|
if (comment2)
|
|
29070
|
-
|
|
29132
|
+
str3 += stringifyComment.lineComment(str3, itemIndent, commentString(comment2));
|
|
29071
29133
|
if (chompKeep && comment2)
|
|
29072
29134
|
chompKeep = false;
|
|
29073
|
-
lines.push(blockItemPrefix +
|
|
29135
|
+
lines.push(blockItemPrefix + str3);
|
|
29074
29136
|
}
|
|
29075
|
-
let
|
|
29137
|
+
let str2;
|
|
29076
29138
|
if (lines.length === 0) {
|
|
29077
|
-
|
|
29139
|
+
str2 = flowChars.start + flowChars.end;
|
|
29078
29140
|
} else {
|
|
29079
|
-
|
|
29141
|
+
str2 = lines[0];
|
|
29080
29142
|
for (let i2 = 1; i2 < lines.length; ++i2) {
|
|
29081
29143
|
const line3 = lines[i2];
|
|
29082
|
-
|
|
29144
|
+
str2 += line3 ? `
|
|
29083
29145
|
${indent}${line3}` : "\n";
|
|
29084
29146
|
}
|
|
29085
29147
|
}
|
|
29086
29148
|
if (comment) {
|
|
29087
|
-
|
|
29149
|
+
str2 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
|
|
29088
29150
|
if (onComment)
|
|
29089
29151
|
onComment();
|
|
29090
29152
|
} else if (chompKeep && onChompKeep)
|
|
29091
29153
|
onChompKeep();
|
|
29092
|
-
return
|
|
29154
|
+
return str2;
|
|
29093
29155
|
}
|
|
29094
29156
|
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
29095
29157
|
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
@@ -29132,21 +29194,21 @@ ${indent}${line3}` : "\n";
|
|
|
29132
29194
|
}
|
|
29133
29195
|
if (comment)
|
|
29134
29196
|
reqNewline = true;
|
|
29135
|
-
let
|
|
29136
|
-
reqNewline || (reqNewline = lines.length > linesAtValue ||
|
|
29197
|
+
let str2 = stringify2.stringify(item, itemCtx, () => comment = null);
|
|
29198
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str2.includes("\n"));
|
|
29137
29199
|
if (i2 < items.length - 1) {
|
|
29138
|
-
|
|
29200
|
+
str2 += ",";
|
|
29139
29201
|
} else if (ctx.options.trailingComma) {
|
|
29140
29202
|
if (ctx.options.lineWidth > 0) {
|
|
29141
|
-
reqNewline || (reqNewline = lines.reduce((sum, line3) => sum + line3.length + 2, 2) + (
|
|
29203
|
+
reqNewline || (reqNewline = lines.reduce((sum, line3) => sum + line3.length + 2, 2) + (str2.length + 2) > ctx.options.lineWidth);
|
|
29142
29204
|
}
|
|
29143
29205
|
if (reqNewline) {
|
|
29144
|
-
|
|
29206
|
+
str2 += ",";
|
|
29145
29207
|
}
|
|
29146
29208
|
}
|
|
29147
29209
|
if (comment)
|
|
29148
|
-
|
|
29149
|
-
lines.push(
|
|
29210
|
+
str2 += stringifyComment.lineComment(str2, itemIndent, commentString(comment));
|
|
29211
|
+
lines.push(str2);
|
|
29150
29212
|
linesAtValue = lines.length;
|
|
29151
29213
|
}
|
|
29152
29214
|
const { start: start2, end } = flowChars;
|
|
@@ -29158,11 +29220,11 @@ ${indent}${line3}` : "\n";
|
|
|
29158
29220
|
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
29159
29221
|
}
|
|
29160
29222
|
if (reqNewline) {
|
|
29161
|
-
let
|
|
29223
|
+
let str2 = start2;
|
|
29162
29224
|
for (const line3 of lines)
|
|
29163
|
-
|
|
29225
|
+
str2 += line3 ? `
|
|
29164
29226
|
${indentStep}${indent}${line3}` : "\n";
|
|
29165
|
-
return `${
|
|
29227
|
+
return `${str2}
|
|
29166
29228
|
${indent}${end}`;
|
|
29167
29229
|
} else {
|
|
29168
29230
|
return `${start2}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
@@ -29494,7 +29556,7 @@ var require_string = __commonJS({
|
|
|
29494
29556
|
identify: (value) => typeof value === "string",
|
|
29495
29557
|
default: true,
|
|
29496
29558
|
tag: "tag:yaml.org,2002:str",
|
|
29497
|
-
resolve: (
|
|
29559
|
+
resolve: (str2) => str2,
|
|
29498
29560
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
29499
29561
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
29500
29562
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
@@ -29532,7 +29594,7 @@ var require_bool = __commonJS({
|
|
|
29532
29594
|
default: true,
|
|
29533
29595
|
tag: "tag:yaml.org,2002:bool",
|
|
29534
29596
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
29535
|
-
resolve: (
|
|
29597
|
+
resolve: (str2) => new Scalar.Scalar(str2[0] === "t" || str2[0] === "T"),
|
|
29536
29598
|
stringify({ source, value }, ctx) {
|
|
29537
29599
|
if (source && boolTag.test.test(source)) {
|
|
29538
29600
|
const sv = source[0] === "t" || source[0] === "T";
|
|
@@ -29584,7 +29646,7 @@ var require_float = __commonJS({
|
|
|
29584
29646
|
default: true,
|
|
29585
29647
|
tag: "tag:yaml.org,2002:float",
|
|
29586
29648
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
29587
|
-
resolve: (
|
|
29649
|
+
resolve: (str2) => str2.slice(-3).toLowerCase() === "nan" ? NaN : str2[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
29588
29650
|
stringify: stringifyNumber.stringifyNumber
|
|
29589
29651
|
};
|
|
29590
29652
|
var floatExp = {
|
|
@@ -29593,7 +29655,7 @@ var require_float = __commonJS({
|
|
|
29593
29655
|
tag: "tag:yaml.org,2002:float",
|
|
29594
29656
|
format: "EXP",
|
|
29595
29657
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
29596
|
-
resolve: (
|
|
29658
|
+
resolve: (str2) => parseFloat(str2),
|
|
29597
29659
|
stringify(node2) {
|
|
29598
29660
|
const num = Number(node2.value);
|
|
29599
29661
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node2);
|
|
@@ -29604,11 +29666,11 @@ var require_float = __commonJS({
|
|
|
29604
29666
|
default: true,
|
|
29605
29667
|
tag: "tag:yaml.org,2002:float",
|
|
29606
29668
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
29607
|
-
resolve(
|
|
29608
|
-
const node2 = new Scalar.Scalar(parseFloat(
|
|
29609
|
-
const dot =
|
|
29610
|
-
if (dot !== -1 &&
|
|
29611
|
-
node2.minFractionDigits =
|
|
29669
|
+
resolve(str2) {
|
|
29670
|
+
const node2 = new Scalar.Scalar(parseFloat(str2));
|
|
29671
|
+
const dot = str2.indexOf(".");
|
|
29672
|
+
if (dot !== -1 && str2[str2.length - 1] === "0")
|
|
29673
|
+
node2.minFractionDigits = str2.length - dot - 1;
|
|
29612
29674
|
return node2;
|
|
29613
29675
|
},
|
|
29614
29676
|
stringify: stringifyNumber.stringifyNumber
|
|
@@ -29625,7 +29687,7 @@ var require_int = __commonJS({
|
|
|
29625
29687
|
"use strict";
|
|
29626
29688
|
var stringifyNumber = require_stringifyNumber();
|
|
29627
29689
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
29628
|
-
var intResolve = (
|
|
29690
|
+
var intResolve = (str2, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str2) : parseInt(str2.substring(offset), radix);
|
|
29629
29691
|
function intStringify(node2, radix, prefix) {
|
|
29630
29692
|
const { value } = node2;
|
|
29631
29693
|
if (intIdentify(value) && value >= 0)
|
|
@@ -29638,7 +29700,7 @@ var require_int = __commonJS({
|
|
|
29638
29700
|
tag: "tag:yaml.org,2002:int",
|
|
29639
29701
|
format: "OCT",
|
|
29640
29702
|
test: /^0o[0-7]+$/,
|
|
29641
|
-
resolve: (
|
|
29703
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 8, opt),
|
|
29642
29704
|
stringify: (node2) => intStringify(node2, 8, "0o")
|
|
29643
29705
|
};
|
|
29644
29706
|
var int2 = {
|
|
@@ -29646,7 +29708,7 @@ var require_int = __commonJS({
|
|
|
29646
29708
|
default: true,
|
|
29647
29709
|
tag: "tag:yaml.org,2002:int",
|
|
29648
29710
|
test: /^[-+]?[0-9]+$/,
|
|
29649
|
-
resolve: (
|
|
29711
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 0, 10, opt),
|
|
29650
29712
|
stringify: stringifyNumber.stringifyNumber
|
|
29651
29713
|
};
|
|
29652
29714
|
var intHex = {
|
|
@@ -29655,7 +29717,7 @@ var require_int = __commonJS({
|
|
|
29655
29717
|
tag: "tag:yaml.org,2002:int",
|
|
29656
29718
|
format: "HEX",
|
|
29657
29719
|
test: /^0x[0-9a-fA-F]+$/,
|
|
29658
|
-
resolve: (
|
|
29720
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 16, opt),
|
|
29659
29721
|
stringify: (node2) => intStringify(node2, 16, "0x")
|
|
29660
29722
|
};
|
|
29661
29723
|
exports.int = int2;
|
|
@@ -29708,7 +29770,7 @@ var require_schema2 = __commonJS({
|
|
|
29708
29770
|
identify: (value) => typeof value === "string",
|
|
29709
29771
|
default: true,
|
|
29710
29772
|
tag: "tag:yaml.org,2002:str",
|
|
29711
|
-
resolve: (
|
|
29773
|
+
resolve: (str2) => str2,
|
|
29712
29774
|
stringify: stringifyJSON
|
|
29713
29775
|
},
|
|
29714
29776
|
{
|
|
@@ -29725,7 +29787,7 @@ var require_schema2 = __commonJS({
|
|
|
29725
29787
|
default: true,
|
|
29726
29788
|
tag: "tag:yaml.org,2002:bool",
|
|
29727
29789
|
test: /^true$|^false$/,
|
|
29728
|
-
resolve: (
|
|
29790
|
+
resolve: (str2) => str2 === "true",
|
|
29729
29791
|
stringify: stringifyJSON
|
|
29730
29792
|
},
|
|
29731
29793
|
{
|
|
@@ -29733,7 +29795,7 @@ var require_schema2 = __commonJS({
|
|
|
29733
29795
|
default: true,
|
|
29734
29796
|
tag: "tag:yaml.org,2002:int",
|
|
29735
29797
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
29736
|
-
resolve: (
|
|
29798
|
+
resolve: (str2, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str2) : parseInt(str2, 10),
|
|
29737
29799
|
stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value)
|
|
29738
29800
|
},
|
|
29739
29801
|
{
|
|
@@ -29741,7 +29803,7 @@ var require_schema2 = __commonJS({
|
|
|
29741
29803
|
default: true,
|
|
29742
29804
|
tag: "tag:yaml.org,2002:float",
|
|
29743
29805
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
29744
|
-
resolve: (
|
|
29806
|
+
resolve: (str2) => parseFloat(str2),
|
|
29745
29807
|
stringify: stringifyJSON
|
|
29746
29808
|
}
|
|
29747
29809
|
];
|
|
@@ -29749,9 +29811,9 @@ var require_schema2 = __commonJS({
|
|
|
29749
29811
|
default: true,
|
|
29750
29812
|
tag: "",
|
|
29751
29813
|
test: /^/,
|
|
29752
|
-
resolve(
|
|
29753
|
-
onError(`Unresolved plain scalar ${JSON.stringify(
|
|
29754
|
-
return
|
|
29814
|
+
resolve(str2, onError) {
|
|
29815
|
+
onError(`Unresolved plain scalar ${JSON.stringify(str2)}`);
|
|
29816
|
+
return str2;
|
|
29755
29817
|
}
|
|
29756
29818
|
};
|
|
29757
29819
|
var schema = [map2.map, seq.seq].concat(jsonScalars, jsonError);
|
|
@@ -29783,10 +29845,10 @@ var require_binary = __commonJS({
|
|
|
29783
29845
|
if (typeof node_buffer.Buffer === "function") {
|
|
29784
29846
|
return node_buffer.Buffer.from(src, "base64");
|
|
29785
29847
|
} else if (typeof atob === "function") {
|
|
29786
|
-
const
|
|
29787
|
-
const buffer = new Uint8Array(
|
|
29788
|
-
for (let i2 = 0; i2 <
|
|
29789
|
-
buffer[i2] =
|
|
29848
|
+
const str2 = atob(src.replace(/[\n\r]/g, ""));
|
|
29849
|
+
const buffer = new Uint8Array(str2.length);
|
|
29850
|
+
for (let i2 = 0; i2 < str2.length; ++i2)
|
|
29851
|
+
buffer[i2] = str2.charCodeAt(i2);
|
|
29790
29852
|
return buffer;
|
|
29791
29853
|
} else {
|
|
29792
29854
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -29797,28 +29859,28 @@ var require_binary = __commonJS({
|
|
|
29797
29859
|
if (!value)
|
|
29798
29860
|
return "";
|
|
29799
29861
|
const buf = value;
|
|
29800
|
-
let
|
|
29862
|
+
let str2;
|
|
29801
29863
|
if (typeof node_buffer.Buffer === "function") {
|
|
29802
|
-
|
|
29864
|
+
str2 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
29803
29865
|
} else if (typeof btoa === "function") {
|
|
29804
29866
|
let s = "";
|
|
29805
29867
|
for (let i2 = 0; i2 < buf.length; ++i2)
|
|
29806
29868
|
s += String.fromCharCode(buf[i2]);
|
|
29807
|
-
|
|
29869
|
+
str2 = btoa(s);
|
|
29808
29870
|
} else {
|
|
29809
29871
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
29810
29872
|
}
|
|
29811
29873
|
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
|
|
29812
29874
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
29813
29875
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
29814
|
-
const n = Math.ceil(
|
|
29876
|
+
const n = Math.ceil(str2.length / lineWidth);
|
|
29815
29877
|
const lines = new Array(n);
|
|
29816
29878
|
for (let i2 = 0, o = 0; i2 < n; ++i2, o += lineWidth) {
|
|
29817
|
-
lines[i2] =
|
|
29879
|
+
lines[i2] = str2.substr(o, lineWidth);
|
|
29818
29880
|
}
|
|
29819
|
-
|
|
29881
|
+
str2 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
29820
29882
|
}
|
|
29821
|
-
return stringifyString.stringifyString({ comment, type, value:
|
|
29883
|
+
return stringifyString.stringifyString({ comment, type, value: str2 }, ctx, onComment, onChompKeep);
|
|
29822
29884
|
}
|
|
29823
29885
|
};
|
|
29824
29886
|
exports.binary = binary2;
|
|
@@ -30024,7 +30086,7 @@ var require_float2 = __commonJS({
|
|
|
30024
30086
|
default: true,
|
|
30025
30087
|
tag: "tag:yaml.org,2002:float",
|
|
30026
30088
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
30027
|
-
resolve: (
|
|
30089
|
+
resolve: (str2) => str2.slice(-3).toLowerCase() === "nan" ? NaN : str2[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
30028
30090
|
stringify: stringifyNumber.stringifyNumber
|
|
30029
30091
|
};
|
|
30030
30092
|
var floatExp = {
|
|
@@ -30033,7 +30095,7 @@ var require_float2 = __commonJS({
|
|
|
30033
30095
|
tag: "tag:yaml.org,2002:float",
|
|
30034
30096
|
format: "EXP",
|
|
30035
30097
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
30036
|
-
resolve: (
|
|
30098
|
+
resolve: (str2) => parseFloat(str2.replace(/_/g, "")),
|
|
30037
30099
|
stringify(node2) {
|
|
30038
30100
|
const num = Number(node2.value);
|
|
30039
30101
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node2);
|
|
@@ -30044,11 +30106,11 @@ var require_float2 = __commonJS({
|
|
|
30044
30106
|
default: true,
|
|
30045
30107
|
tag: "tag:yaml.org,2002:float",
|
|
30046
30108
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
30047
|
-
resolve(
|
|
30048
|
-
const node2 = new Scalar.Scalar(parseFloat(
|
|
30049
|
-
const dot =
|
|
30109
|
+
resolve(str2) {
|
|
30110
|
+
const node2 = new Scalar.Scalar(parseFloat(str2.replace(/_/g, "")));
|
|
30111
|
+
const dot = str2.indexOf(".");
|
|
30050
30112
|
if (dot !== -1) {
|
|
30051
|
-
const f =
|
|
30113
|
+
const f = str2.substring(dot + 1).replace(/_/g, "");
|
|
30052
30114
|
if (f[f.length - 1] === "0")
|
|
30053
30115
|
node2.minFractionDigits = f.length;
|
|
30054
30116
|
}
|
|
@@ -30068,34 +30130,34 @@ var require_int2 = __commonJS({
|
|
|
30068
30130
|
"use strict";
|
|
30069
30131
|
var stringifyNumber = require_stringifyNumber();
|
|
30070
30132
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
30071
|
-
function intResolve(
|
|
30072
|
-
const sign =
|
|
30133
|
+
function intResolve(str2, offset, radix, { intAsBigInt }) {
|
|
30134
|
+
const sign = str2[0];
|
|
30073
30135
|
if (sign === "-" || sign === "+")
|
|
30074
30136
|
offset += 1;
|
|
30075
|
-
|
|
30137
|
+
str2 = str2.substring(offset).replace(/_/g, "");
|
|
30076
30138
|
if (intAsBigInt) {
|
|
30077
30139
|
switch (radix) {
|
|
30078
30140
|
case 2:
|
|
30079
|
-
|
|
30141
|
+
str2 = `0b${str2}`;
|
|
30080
30142
|
break;
|
|
30081
30143
|
case 8:
|
|
30082
|
-
|
|
30144
|
+
str2 = `0o${str2}`;
|
|
30083
30145
|
break;
|
|
30084
30146
|
case 16:
|
|
30085
|
-
|
|
30147
|
+
str2 = `0x${str2}`;
|
|
30086
30148
|
break;
|
|
30087
30149
|
}
|
|
30088
|
-
const n2 = BigInt(
|
|
30150
|
+
const n2 = BigInt(str2);
|
|
30089
30151
|
return sign === "-" ? BigInt(-1) * n2 : n2;
|
|
30090
30152
|
}
|
|
30091
|
-
const n = parseInt(
|
|
30153
|
+
const n = parseInt(str2, radix);
|
|
30092
30154
|
return sign === "-" ? -1 * n : n;
|
|
30093
30155
|
}
|
|
30094
30156
|
function intStringify(node2, radix, prefix) {
|
|
30095
30157
|
const { value } = node2;
|
|
30096
30158
|
if (intIdentify(value)) {
|
|
30097
|
-
const
|
|
30098
|
-
return value < 0 ? "-" + prefix +
|
|
30159
|
+
const str2 = value.toString(radix);
|
|
30160
|
+
return value < 0 ? "-" + prefix + str2.substr(1) : prefix + str2;
|
|
30099
30161
|
}
|
|
30100
30162
|
return stringifyNumber.stringifyNumber(node2);
|
|
30101
30163
|
}
|
|
@@ -30105,7 +30167,7 @@ var require_int2 = __commonJS({
|
|
|
30105
30167
|
tag: "tag:yaml.org,2002:int",
|
|
30106
30168
|
format: "BIN",
|
|
30107
30169
|
test: /^[-+]?0b[0-1_]+$/,
|
|
30108
|
-
resolve: (
|
|
30170
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 2, opt),
|
|
30109
30171
|
stringify: (node2) => intStringify(node2, 2, "0b")
|
|
30110
30172
|
};
|
|
30111
30173
|
var intOct = {
|
|
@@ -30114,7 +30176,7 @@ var require_int2 = __commonJS({
|
|
|
30114
30176
|
tag: "tag:yaml.org,2002:int",
|
|
30115
30177
|
format: "OCT",
|
|
30116
30178
|
test: /^[-+]?0[0-7_]+$/,
|
|
30117
|
-
resolve: (
|
|
30179
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 1, 8, opt),
|
|
30118
30180
|
stringify: (node2) => intStringify(node2, 8, "0")
|
|
30119
30181
|
};
|
|
30120
30182
|
var int2 = {
|
|
@@ -30122,7 +30184,7 @@ var require_int2 = __commonJS({
|
|
|
30122
30184
|
default: true,
|
|
30123
30185
|
tag: "tag:yaml.org,2002:int",
|
|
30124
30186
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
30125
|
-
resolve: (
|
|
30187
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 0, 10, opt),
|
|
30126
30188
|
stringify: stringifyNumber.stringifyNumber
|
|
30127
30189
|
};
|
|
30128
30190
|
var intHex = {
|
|
@@ -30131,7 +30193,7 @@ var require_int2 = __commonJS({
|
|
|
30131
30193
|
tag: "tag:yaml.org,2002:int",
|
|
30132
30194
|
format: "HEX",
|
|
30133
30195
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
30134
|
-
resolve: (
|
|
30196
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 16, opt),
|
|
30135
30197
|
stringify: (node2) => intStringify(node2, 16, "0x")
|
|
30136
30198
|
};
|
|
30137
30199
|
exports.int = int2;
|
|
@@ -30235,9 +30297,9 @@ var require_timestamp = __commonJS({
|
|
|
30235
30297
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
30236
30298
|
"use strict";
|
|
30237
30299
|
var stringifyNumber = require_stringifyNumber();
|
|
30238
|
-
function parseSexagesimal(
|
|
30239
|
-
const sign =
|
|
30240
|
-
const parts2 = sign === "-" || sign === "+" ?
|
|
30300
|
+
function parseSexagesimal(str2, asBigInt) {
|
|
30301
|
+
const sign = str2[0];
|
|
30302
|
+
const parts2 = sign === "-" || sign === "+" ? str2.substring(1) : str2;
|
|
30241
30303
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
30242
30304
|
const res = parts2.replace(/_/g, "").split(":").reduce((res2, p2) => res2 * num(60) + num(p2), num(0));
|
|
30243
30305
|
return sign === "-" ? num(-1) * res : res;
|
|
@@ -30274,7 +30336,7 @@ var require_timestamp = __commonJS({
|
|
|
30274
30336
|
tag: "tag:yaml.org,2002:int",
|
|
30275
30337
|
format: "TIME",
|
|
30276
30338
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
30277
|
-
resolve: (
|
|
30339
|
+
resolve: (str2, _onError, { intAsBigInt }) => parseSexagesimal(str2, intAsBigInt),
|
|
30278
30340
|
stringify: stringifySexagesimal
|
|
30279
30341
|
};
|
|
30280
30342
|
var floatTime = {
|
|
@@ -30283,7 +30345,7 @@ var require_timestamp = __commonJS({
|
|
|
30283
30345
|
tag: "tag:yaml.org,2002:float",
|
|
30284
30346
|
format: "TIME",
|
|
30285
30347
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
30286
|
-
resolve: (
|
|
30348
|
+
resolve: (str2) => parseSexagesimal(str2, false),
|
|
30287
30349
|
stringify: stringifySexagesimal
|
|
30288
30350
|
};
|
|
30289
30351
|
var timestamp = {
|
|
@@ -30294,8 +30356,8 @@ var require_timestamp = __commonJS({
|
|
|
30294
30356
|
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
30295
30357
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
30296
30358
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
30297
|
-
resolve(
|
|
30298
|
-
const match =
|
|
30359
|
+
resolve(str2) {
|
|
30360
|
+
const match = str2.match(timestamp.test);
|
|
30299
30361
|
if (!match)
|
|
30300
30362
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
30301
30363
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -33213,9 +33275,9 @@ var require_lexer = __commonJS({
|
|
|
33213
33275
|
}
|
|
33214
33276
|
}
|
|
33215
33277
|
*parseQuotedScalar() {
|
|
33216
|
-
const
|
|
33217
|
-
let end = this.buffer.indexOf(
|
|
33218
|
-
if (
|
|
33278
|
+
const quote4 = this.charAt(0);
|
|
33279
|
+
let end = this.buffer.indexOf(quote4, this.pos + 1);
|
|
33280
|
+
if (quote4 === "'") {
|
|
33219
33281
|
while (end !== -1 && this.buffer[end + 1] === "'")
|
|
33220
33282
|
end = this.buffer.indexOf("'", end + 2);
|
|
33221
33283
|
} else {
|
|
@@ -34539,25 +34601,25 @@ var require_dist = __commonJS({
|
|
|
34539
34601
|
});
|
|
34540
34602
|
|
|
34541
34603
|
// src/assets.ts
|
|
34542
|
-
import { basename as basename5, join as
|
|
34604
|
+
import { basename as basename5, join as join31, resolve as resolve17 } from "node:path";
|
|
34543
34605
|
import { fileURLToPath } from "node:url";
|
|
34544
34606
|
function packageRoot(env = process.env) {
|
|
34545
34607
|
const override = env["MVRX_PACKAGE_ROOT"];
|
|
34546
34608
|
if (override !== void 0 && override !== "") return override;
|
|
34547
|
-
return
|
|
34609
|
+
return resolve17(fileURLToPath(new URL(".", import.meta.url)), "..");
|
|
34548
34610
|
}
|
|
34549
34611
|
function assetDir(env = process.env) {
|
|
34550
34612
|
const override = env["MVRX_ASSET_DIR"];
|
|
34551
|
-
return override !== void 0 && override !== "" ? override :
|
|
34613
|
+
return override !== void 0 && override !== "" ? override : join31(packageRoot(env), "assets");
|
|
34552
34614
|
}
|
|
34553
34615
|
function assetFile(name2) {
|
|
34554
|
-
return
|
|
34616
|
+
return join31(assetDir(), basename5(name2));
|
|
34555
34617
|
}
|
|
34556
34618
|
var VERSION;
|
|
34557
34619
|
var init_assets = __esm({
|
|
34558
34620
|
"src/assets.ts"() {
|
|
34559
34621
|
"use strict";
|
|
34560
|
-
VERSION = true ? "0.1.
|
|
34622
|
+
VERSION = true ? "0.1.141" : "0.0.0-dev";
|
|
34561
34623
|
}
|
|
34562
34624
|
});
|
|
34563
34625
|
|
|
@@ -35799,10 +35861,10 @@ function parseTextFormatScalarValue(type, value) {
|
|
|
35799
35861
|
return parseInt(value, 10);
|
|
35800
35862
|
}
|
|
35801
35863
|
}
|
|
35802
|
-
function unescapeBytesDefaultValue(
|
|
35864
|
+
function unescapeBytesDefaultValue(str2) {
|
|
35803
35865
|
const b = [];
|
|
35804
35866
|
const input2 = {
|
|
35805
|
-
tail:
|
|
35867
|
+
tail: str2,
|
|
35806
35868
|
c: "",
|
|
35807
35869
|
next() {
|
|
35808
35870
|
if (this.tail.length == 0) {
|
|
@@ -35975,7 +36037,7 @@ function createFileRegistry(...args2) {
|
|
|
35975
36037
|
if (seen.has(protoFileName)) {
|
|
35976
36038
|
continue;
|
|
35977
36039
|
}
|
|
35978
|
-
const dep =
|
|
36040
|
+
const dep = resolve20(protoFileName);
|
|
35979
36041
|
if (!dep) {
|
|
35980
36042
|
throw new Error(`Unable to resolve ${protoFileName}, imported by ${file2.name}`);
|
|
35981
36043
|
}
|
|
@@ -35989,7 +36051,7 @@ function createFileRegistry(...args2) {
|
|
|
35989
36051
|
return deps.concat(...deps.map(recurseDeps));
|
|
35990
36052
|
};
|
|
35991
36053
|
const input2 = args2[0];
|
|
35992
|
-
const
|
|
36054
|
+
const resolve20 = args2[1];
|
|
35993
36055
|
const seen = /* @__PURE__ */ new Set();
|
|
35994
36056
|
for (const file2 of [input2, ...recurseDeps(input2)].reverse()) {
|
|
35995
36057
|
addFile(file2, registry2);
|
|
@@ -36573,7 +36635,7 @@ function findMapEntryFields(mapEntry) {
|
|
|
36573
36635
|
}
|
|
36574
36636
|
function isEnumOpen(desc) {
|
|
36575
36637
|
var _a3;
|
|
36576
|
-
return
|
|
36638
|
+
return OPEN2 == resolveFeature("enumType", {
|
|
36577
36639
|
proto: desc.proto,
|
|
36578
36640
|
parent: (_a3 = desc.parent) !== null && _a3 !== void 0 ? _a3 : desc.file
|
|
36579
36641
|
});
|
|
@@ -36619,7 +36681,7 @@ function assert2(condition, msg) {
|
|
|
36619
36681
|
throw new Error(msg);
|
|
36620
36682
|
}
|
|
36621
36683
|
}
|
|
36622
|
-
var EDITION_PROTO22, EDITION_PROTO32, EDITION_UNSTABLE, TYPE_STRING, TYPE_GROUP, TYPE_MESSAGE, TYPE_BYTES, TYPE_ENUM, LABEL_REPEATED, LABEL_REQUIRED, JS_STRING, IDEMPOTENCY_UNKNOWN, EXPLICIT, IMPLICIT2, LEGACY_REQUIRED, PACKED, DELIMITED,
|
|
36684
|
+
var EDITION_PROTO22, EDITION_PROTO32, EDITION_UNSTABLE, TYPE_STRING, TYPE_GROUP, TYPE_MESSAGE, TYPE_BYTES, TYPE_ENUM, LABEL_REPEATED, LABEL_REQUIRED, JS_STRING, IDEMPOTENCY_UNKNOWN, EXPLICIT, IMPLICIT2, LEGACY_REQUIRED, PACKED, DELIMITED, OPEN2, VERIFY, maximumEdition, featureDefaults;
|
|
36623
36685
|
var init_registry = __esm({
|
|
36624
36686
|
"../../node_modules/.pnpm/@bufbuild+protobuf@2.16.0/node_modules/@bufbuild/protobuf/dist/esm/registry.js"() {
|
|
36625
36687
|
init_descriptors();
|
|
@@ -36645,7 +36707,7 @@ var init_registry = __esm({
|
|
|
36645
36707
|
LEGACY_REQUIRED = 3;
|
|
36646
36708
|
PACKED = 1;
|
|
36647
36709
|
DELIMITED = 2;
|
|
36648
|
-
|
|
36710
|
+
OPEN2 = 1;
|
|
36649
36711
|
VERIFY = 2;
|
|
36650
36712
|
maximumEdition = 1002;
|
|
36651
36713
|
featureDefaults = {
|
|
@@ -38402,13 +38464,13 @@ async function Module2(moduleArg = {}) {
|
|
|
38402
38464
|
}
|
|
38403
38465
|
readAsync = /* @__PURE__ */ __name(async (url2) => {
|
|
38404
38466
|
if (isFileURI(url2)) {
|
|
38405
|
-
return new Promise((
|
|
38467
|
+
return new Promise((resolve20, reject) => {
|
|
38406
38468
|
var xhr = new XMLHttpRequest();
|
|
38407
38469
|
xhr.open("GET", url2, true);
|
|
38408
38470
|
xhr.responseType = "arraybuffer";
|
|
38409
38471
|
xhr.onload = () => {
|
|
38410
38472
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
38411
|
-
|
|
38473
|
+
resolve20(xhr.response);
|
|
38412
38474
|
return;
|
|
38413
38475
|
}
|
|
38414
38476
|
reject(xhr.status);
|
|
@@ -38604,9 +38666,9 @@ async function Module2(moduleArg = {}) {
|
|
|
38604
38666
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
38605
38667
|
var info2 = getWasmImports();
|
|
38606
38668
|
if (Module["instantiateWasm"]) {
|
|
38607
|
-
return new Promise((
|
|
38669
|
+
return new Promise((resolve20, reject) => {
|
|
38608
38670
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
38609
|
-
|
|
38671
|
+
resolve20(receiveInstance(mod, inst));
|
|
38610
38672
|
});
|
|
38611
38673
|
});
|
|
38612
38674
|
}
|
|
@@ -38677,16 +38739,16 @@ async function Module2(moduleArg = {}) {
|
|
|
38677
38739
|
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
38678
38740
|
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
38679
38741
|
}
|
|
38680
|
-
var
|
|
38742
|
+
var str2 = "";
|
|
38681
38743
|
while (idx < endPtr) {
|
|
38682
38744
|
var u0 = heapOrArray[idx++];
|
|
38683
38745
|
if (!(u0 & 128)) {
|
|
38684
|
-
|
|
38746
|
+
str2 += String.fromCharCode(u0);
|
|
38685
38747
|
continue;
|
|
38686
38748
|
}
|
|
38687
38749
|
var u1 = heapOrArray[idx++] & 63;
|
|
38688
38750
|
if ((u0 & 224) == 192) {
|
|
38689
|
-
|
|
38751
|
+
str2 += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
38690
38752
|
continue;
|
|
38691
38753
|
}
|
|
38692
38754
|
var u2 = heapOrArray[idx++] & 63;
|
|
@@ -38696,13 +38758,13 @@ async function Module2(moduleArg = {}) {
|
|
|
38696
38758
|
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
38697
38759
|
}
|
|
38698
38760
|
if (u0 < 65536) {
|
|
38699
|
-
|
|
38761
|
+
str2 += String.fromCharCode(u0);
|
|
38700
38762
|
} else {
|
|
38701
38763
|
var ch = u0 - 65536;
|
|
38702
|
-
|
|
38764
|
+
str2 += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
38703
38765
|
}
|
|
38704
38766
|
}
|
|
38705
|
-
return
|
|
38767
|
+
return str2;
|
|
38706
38768
|
}, "UTF8ArrayToString");
|
|
38707
38769
|
var getDylinkMetadata = /* @__PURE__ */ __name((binary2) => {
|
|
38708
38770
|
var offset = 0;
|
|
@@ -39561,10 +39623,10 @@ async function Module2(moduleArg = {}) {
|
|
|
39561
39623
|
}
|
|
39562
39624
|
quit_(1, e2);
|
|
39563
39625
|
}, "handleException");
|
|
39564
|
-
var lengthBytesUTF8 = /* @__PURE__ */ __name((
|
|
39626
|
+
var lengthBytesUTF8 = /* @__PURE__ */ __name((str2) => {
|
|
39565
39627
|
var len = 0;
|
|
39566
|
-
for (var i2 = 0; i2 <
|
|
39567
|
-
var c2 =
|
|
39628
|
+
for (var i2 = 0; i2 < str2.length; ++i2) {
|
|
39629
|
+
var c2 = str2.charCodeAt(i2);
|
|
39568
39630
|
if (c2 <= 127) {
|
|
39569
39631
|
len++;
|
|
39570
39632
|
} else if (c2 <= 2047) {
|
|
@@ -39578,12 +39640,12 @@ async function Module2(moduleArg = {}) {
|
|
|
39578
39640
|
}
|
|
39579
39641
|
return len;
|
|
39580
39642
|
}, "lengthBytesUTF8");
|
|
39581
|
-
var stringToUTF8Array = /* @__PURE__ */ __name((
|
|
39643
|
+
var stringToUTF8Array = /* @__PURE__ */ __name((str2, heap, outIdx, maxBytesToWrite) => {
|
|
39582
39644
|
if (!(maxBytesToWrite > 0)) return 0;
|
|
39583
39645
|
var startIdx = outIdx;
|
|
39584
39646
|
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
39585
|
-
for (var i2 = 0; i2 <
|
|
39586
|
-
var u =
|
|
39647
|
+
for (var i2 = 0; i2 < str2.length; ++i2) {
|
|
39648
|
+
var u = str2.codePointAt(i2);
|
|
39587
39649
|
if (u <= 127) {
|
|
39588
39650
|
if (outIdx >= endIdx) break;
|
|
39589
39651
|
heap[outIdx++] = u;
|
|
@@ -39608,30 +39670,30 @@ async function Module2(moduleArg = {}) {
|
|
|
39608
39670
|
heap[outIdx] = 0;
|
|
39609
39671
|
return outIdx - startIdx;
|
|
39610
39672
|
}, "stringToUTF8Array");
|
|
39611
|
-
var stringToUTF8 = /* @__PURE__ */ __name((
|
|
39673
|
+
var stringToUTF8 = /* @__PURE__ */ __name((str2, outPtr, maxBytesToWrite) => stringToUTF8Array(str2, HEAPU8, outPtr, maxBytesToWrite), "stringToUTF8");
|
|
39612
39674
|
var stackAlloc = /* @__PURE__ */ __name((sz) => __emscripten_stack_alloc(sz), "stackAlloc");
|
|
39613
|
-
var stringToUTF8OnStack = /* @__PURE__ */ __name((
|
|
39614
|
-
var size = lengthBytesUTF8(
|
|
39675
|
+
var stringToUTF8OnStack = /* @__PURE__ */ __name((str2) => {
|
|
39676
|
+
var size = lengthBytesUTF8(str2) + 1;
|
|
39615
39677
|
var ret = stackAlloc(size);
|
|
39616
|
-
stringToUTF8(
|
|
39678
|
+
stringToUTF8(str2, ret, size);
|
|
39617
39679
|
return ret;
|
|
39618
39680
|
}, "stringToUTF8OnStack");
|
|
39619
39681
|
var AsciiToString = /* @__PURE__ */ __name((ptr) => {
|
|
39620
|
-
var
|
|
39682
|
+
var str2 = "";
|
|
39621
39683
|
while (1) {
|
|
39622
39684
|
var ch = HEAPU8[ptr++];
|
|
39623
|
-
if (!ch) return
|
|
39624
|
-
|
|
39685
|
+
if (!ch) return str2;
|
|
39686
|
+
str2 += String.fromCharCode(ch);
|
|
39625
39687
|
}
|
|
39626
39688
|
}, "AsciiToString");
|
|
39627
|
-
var stringToUTF16 = /* @__PURE__ */ __name((
|
|
39689
|
+
var stringToUTF16 = /* @__PURE__ */ __name((str2, outPtr, maxBytesToWrite) => {
|
|
39628
39690
|
maxBytesToWrite ??= 2147483647;
|
|
39629
39691
|
if (maxBytesToWrite < 2) return 0;
|
|
39630
39692
|
maxBytesToWrite -= 2;
|
|
39631
39693
|
var startPtr = outPtr;
|
|
39632
|
-
var numCharsToWrite = maxBytesToWrite <
|
|
39694
|
+
var numCharsToWrite = maxBytesToWrite < str2.length * 2 ? maxBytesToWrite / 2 : str2.length;
|
|
39633
39695
|
for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
|
|
39634
|
-
var codeUnit =
|
|
39696
|
+
var codeUnit = str2.charCodeAt(i2);
|
|
39635
39697
|
LE_HEAP_STORE_I16((outPtr >> 1) * 2, codeUnit);
|
|
39636
39698
|
outPtr += 2;
|
|
39637
39699
|
}
|
|
@@ -39939,8 +40001,8 @@ async function Module2(moduleArg = {}) {
|
|
|
39939
40001
|
if (runtimeInitialized) {
|
|
39940
40002
|
moduleRtn = Module;
|
|
39941
40003
|
} else {
|
|
39942
|
-
moduleRtn = new Promise((
|
|
39943
|
-
readyPromiseResolve =
|
|
40004
|
+
moduleRtn = new Promise((resolve20, reject) => {
|
|
40005
|
+
readyPromiseResolve = resolve20;
|
|
39944
40006
|
readyPromiseReject = reject;
|
|
39945
40007
|
});
|
|
39946
40008
|
}
|
|
@@ -42244,9 +42306,9 @@ function parserFor(language) {
|
|
|
42244
42306
|
if (!grammar) throw new Error(`no grammar for ${language}`);
|
|
42245
42307
|
cached2 = (async () => {
|
|
42246
42308
|
await ensureInit();
|
|
42247
|
-
const
|
|
42309
|
+
const loaded2 = await Language2.load(assetFile(grammar));
|
|
42248
42310
|
const parser = new Parser();
|
|
42249
|
-
parser.setLanguage(
|
|
42311
|
+
parser.setLanguage(loaded2);
|
|
42250
42312
|
return parser;
|
|
42251
42313
|
})();
|
|
42252
42314
|
parsers.set(language, cached2);
|
|
@@ -42483,10 +42545,10 @@ var init_treesitter = __esm({
|
|
|
42483
42545
|
});
|
|
42484
42546
|
|
|
42485
42547
|
// ../index-builder/src/snapshot.ts
|
|
42486
|
-
import { execFile } from "node:child_process";
|
|
42548
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
42487
42549
|
import { createHash as createHash6 } from "node:crypto";
|
|
42488
42550
|
import { lstat, readFile as readFile4 } from "node:fs/promises";
|
|
42489
|
-
import { join as
|
|
42551
|
+
import { join as join32 } from "node:path";
|
|
42490
42552
|
import { promisify } from "node:util";
|
|
42491
42553
|
function shardKeyOf(shard) {
|
|
42492
42554
|
return `sha256:${sha256Hex2(Buffer.from(`${shard.path}\0${shard.contentHash}\0${shard.precision}`, "utf8"))}`;
|
|
@@ -42513,7 +42575,7 @@ async function mapLimit(items, limit, task) {
|
|
|
42513
42575
|
return results;
|
|
42514
42576
|
}
|
|
42515
42577
|
async function hashRegularFile(repoRoot, path) {
|
|
42516
|
-
const absolute =
|
|
42578
|
+
const absolute = join32(repoRoot, path);
|
|
42517
42579
|
try {
|
|
42518
42580
|
const stats = await lstat(absolute);
|
|
42519
42581
|
if (!stats.isFile()) return null;
|
|
@@ -42551,7 +42613,7 @@ async function buildSnapshot(options) {
|
|
|
42551
42613
|
const needParse = [...hashes.keys()].filter((path) => !byPath.has(path));
|
|
42552
42614
|
const parsed = await mapLimit(needParse, 8, async (path) => {
|
|
42553
42615
|
if (languageForPath(path) === null) return { path, shard: null };
|
|
42554
|
-
const bytes = await readFile4(
|
|
42616
|
+
const bytes = await readFile4(join32(options.repoRoot, path));
|
|
42555
42617
|
if (bytes.byteLength > MAX_PARSE_BYTES) return { path, shard: null };
|
|
42556
42618
|
const hash2 = `sha256:${sha256Hex2(bytes)}`;
|
|
42557
42619
|
if (hash2 !== hashes.get(path)) throw new Error(`${path} changed while the snapshot was being built`);
|
|
@@ -42588,7 +42650,7 @@ var init_snapshot = __esm({
|
|
|
42588
42650
|
init_languages();
|
|
42589
42651
|
init_scip();
|
|
42590
42652
|
init_treesitter();
|
|
42591
|
-
execFileAsync = promisify(
|
|
42653
|
+
execFileAsync = promisify(execFile2);
|
|
42592
42654
|
MAX_PARSE_BYTES = 2e6;
|
|
42593
42655
|
TREE_SITTER_INDEXER = { name: "web-tree-sitter", version: "0.27.0" };
|
|
42594
42656
|
}
|
|
@@ -42619,7 +42681,7 @@ async function uploadSnapshot(options) {
|
|
|
42619
42681
|
failure4 = error62 instanceof Error ? error62.message : String(error62);
|
|
42620
42682
|
if (attempt2 >= ATTEMPTS) throw new Error(`POST ${path} failed: ${failure4}`);
|
|
42621
42683
|
}
|
|
42622
|
-
await new Promise((
|
|
42684
|
+
await new Promise((resolve20) => setTimeout(resolve20, (options.retryDelayMs ?? 500) * attempt2));
|
|
42623
42685
|
}
|
|
42624
42686
|
};
|
|
42625
42687
|
const manifestPath = byProject ? codePaths.projectUploadManifest(tenantId, projectId ?? "") : codePaths.uploadManifest(tenantId, repository?.owner ?? "", repository?.name ?? "");
|
|
@@ -42713,20 +42775,45 @@ function wordsOf(text) {
|
|
|
42713
42775
|
function idf(index, word) {
|
|
42714
42776
|
return Math.log(index.wordDocs / (1 + (index.words.get(word) ?? 0)));
|
|
42715
42777
|
}
|
|
42716
|
-
function
|
|
42717
|
-
|
|
42778
|
+
function isGeneric(index, word) {
|
|
42779
|
+
return (index.words.get(word) ?? 0) >= Math.max(GENERIC_DF_FLOOR, index.wordDocs * GENERIC_DF_SHARE);
|
|
42780
|
+
}
|
|
42781
|
+
function isTestPath2(path) {
|
|
42782
|
+
return /(^|\/)(tests?|__tests__|__mocks__|fixtures?|__fixtures__)\//.test(path) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(path) || /(^|\/)[^/]*\.fixtures?\.[cm]?[jt]sx?$/.test(path);
|
|
42783
|
+
}
|
|
42784
|
+
function testFilter(task) {
|
|
42785
|
+
if (/\b(tests?|specs?|fixtures?|testing|vitest|jest|mocks?)\b/i.test(task)) return () => true;
|
|
42786
|
+
const lower = task.toLowerCase();
|
|
42787
|
+
return (path) => {
|
|
42788
|
+
if (!isTestPath2(path)) return true;
|
|
42789
|
+
const file2 = (path.split("/").pop() ?? path).toLowerCase();
|
|
42790
|
+
return lower.includes(file2) || lower.includes(file2.replace(/\.[cm]?[jt]sx?$/, ""));
|
|
42791
|
+
};
|
|
42792
|
+
}
|
|
42793
|
+
function identifierTokens(task) {
|
|
42794
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
42718
42795
|
for (const match of task.matchAll(/[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*/g)) {
|
|
42719
42796
|
const token = match[0];
|
|
42797
|
+
if (/^[A-Za-z][a-z]*$/.test(token) && task.charAt((match.index ?? 0) - 1) !== "`") continue;
|
|
42798
|
+
out2.add(token);
|
|
42799
|
+
}
|
|
42800
|
+
return out2;
|
|
42801
|
+
}
|
|
42802
|
+
function scoreSymbols(index, task) {
|
|
42803
|
+
const exactNames = /* @__PURE__ */ new Set();
|
|
42804
|
+
for (const token of identifierTokens(task)) {
|
|
42720
42805
|
if (token.length >= 4 && index.byName.has(token)) exactNames.add(token);
|
|
42721
42806
|
if (token.includes(".")) exactNames.add(token);
|
|
42722
42807
|
}
|
|
42723
42808
|
const taskWords = new Set(wordsOf(task));
|
|
42809
|
+
const allowed = testFilter(task);
|
|
42724
42810
|
const scored = [];
|
|
42725
42811
|
for (const symbol2 of index.symbols.values()) {
|
|
42726
|
-
if (!SEEDABLE.has(symbol2.kind)) continue;
|
|
42812
|
+
if (!SEEDABLE.has(symbol2.kind) || !allowed(symbol2.path)) continue;
|
|
42727
42813
|
if (symbol2.kind === "constant" && !/^[A-Z][A-Z0-9_]+$/.test(symbol2.name)) continue;
|
|
42728
42814
|
let score = 0;
|
|
42729
42815
|
let exact = false;
|
|
42816
|
+
const hitWords = [];
|
|
42730
42817
|
if (exactNames.has(symbol2.qualified)) {
|
|
42731
42818
|
score = 200;
|
|
42732
42819
|
exact = true;
|
|
@@ -42742,14 +42829,19 @@ function scoreSymbols(index, task) {
|
|
|
42742
42829
|
let hits = 0;
|
|
42743
42830
|
for (const word of own2) if (taskWords.has(word) && idf(index, word) >= MIN_WORD_IDF) {
|
|
42744
42831
|
score += idf(index, word);
|
|
42832
|
+
if (isGeneric(index, word)) continue;
|
|
42745
42833
|
hits += 1;
|
|
42834
|
+
hitWords.push([word, idf(index, word)]);
|
|
42835
|
+
}
|
|
42836
|
+
for (const word of fileWords) if (!own2.has(word) && taskWords.has(word) && idf(index, word) >= MIN_WORD_IDF) {
|
|
42837
|
+
score += idf(index, word) * 0.4;
|
|
42838
|
+
if (!isGeneric(index, word)) hitWords.push([word, idf(index, word) * 0.4]);
|
|
42746
42839
|
}
|
|
42747
|
-
for (const word of fileWords) if (!own2.has(word) && taskWords.has(word) && idf(index, word) >= MIN_WORD_IDF) score += idf(index, word) * 0.4;
|
|
42748
42840
|
if (hits === 0) score = 0;
|
|
42749
42841
|
else score /= 1 + 0.15 * own2.size;
|
|
42750
42842
|
if (score < MIN_SOFT_SCORE) score = 0;
|
|
42751
42843
|
}
|
|
42752
|
-
if (score > 0) scored.push({ symbol: symbol2, score, exact });
|
|
42844
|
+
if (score > 0) scored.push({ symbol: symbol2, score, exact, hits: hitWords });
|
|
42753
42845
|
}
|
|
42754
42846
|
return scored.sort((a, b) => b.score - a.score || a.symbol.path.localeCompare(b.symbol.path) || a.symbol.line - b.symbol.line);
|
|
42755
42847
|
}
|
|
@@ -42847,11 +42939,11 @@ function layout(index) {
|
|
|
42847
42939
|
}
|
|
42848
42940
|
return [`Layout: ${index.files} source files. ${[...domains].sort().map(([key, count]) => `${key}(${count})`).join(" ")}`];
|
|
42849
42941
|
}
|
|
42850
|
-
function mostCalled(index, limit) {
|
|
42942
|
+
function mostCalled(index, limit, allowed) {
|
|
42851
42943
|
const counts2 = [];
|
|
42852
42944
|
for (const [id2, callers] of index.callers) {
|
|
42853
42945
|
const symbol2 = index.symbols.get(id2);
|
|
42854
|
-
if (symbol2 === void 0 || !SEEDABLE.has(symbol2.kind) || symbol2.kind === "constant") continue;
|
|
42946
|
+
if (symbol2 === void 0 || !SEEDABLE.has(symbol2.kind) || symbol2.kind === "constant" || !allowed(symbol2.path)) continue;
|
|
42855
42947
|
counts2.push({ symbol: symbol2, callers: callers.size });
|
|
42856
42948
|
}
|
|
42857
42949
|
counts2.sort((a, b) => b.callers - a.callers || a.symbol.path.localeCompare(b.symbol.path) || a.symbol.line - b.symbol.line);
|
|
@@ -42861,11 +42953,12 @@ function buildCodeMap(index, task, options = DEFAULT_MAP_OPTIONS) {
|
|
|
42861
42953
|
const lines = [...layout(index), "Edges: 'called by' and 'calls' are resolved by name within imported files, ignoring comments and strings. Lines are file:line of the declaration."];
|
|
42862
42954
|
const fits = (extra) => estimateTokens(`${[...lines, ...extra].join("\n")}
|
|
42863
42955
|
`) <= options.maxTokens;
|
|
42956
|
+
const allowed = testFilter(task);
|
|
42864
42957
|
const scored = scoreSymbols(index, task);
|
|
42865
42958
|
const seeds = [];
|
|
42866
42959
|
const shownFiles = /* @__PURE__ */ new Set();
|
|
42867
42960
|
const taskFree = scored.length === 0;
|
|
42868
|
-
const candidates = taskFree ? mostCalled(index, options.maxSeeds).map((symbol2) => ({ symbol: symbol2, score: 1 })) : scored;
|
|
42961
|
+
const candidates = taskFree ? mostCalled(index, options.maxSeeds, allowed).map((symbol2) => ({ symbol: symbol2, score: 1 })) : scored;
|
|
42869
42962
|
lines.push("", taskFree ? "Most called symbols:" : "Symbols most relevant to the task:");
|
|
42870
42963
|
for (const item of candidates) {
|
|
42871
42964
|
if (seeds.length >= options.maxSeeds) break;
|
|
@@ -42879,10 +42972,13 @@ function buildCodeMap(index, task, options = DEFAULT_MAP_OPTIONS) {
|
|
|
42879
42972
|
shownFiles.add(item.symbol.path);
|
|
42880
42973
|
}
|
|
42881
42974
|
const personal = /* @__PURE__ */ new Map();
|
|
42882
|
-
if (taskFree)
|
|
42883
|
-
|
|
42975
|
+
if (taskFree) {
|
|
42976
|
+
for (const path of index.byFile.keys()) if (allowed(path)) personal.set(path, 1);
|
|
42977
|
+
} else {
|
|
42978
|
+
for (const item of scored.slice(0, 40)) personal.set(item.symbol.path, (personal.get(item.symbol.path) ?? 0) + item.score);
|
|
42979
|
+
}
|
|
42884
42980
|
const rank = pageRank(index, personal);
|
|
42885
|
-
const ordered = [...rank].filter(([path]) => !shownFiles.has(path)).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
42981
|
+
const ordered = [...rank].filter(([path]) => !shownFiles.has(path) && allowed(path)).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
42886
42982
|
const related = [];
|
|
42887
42983
|
const top = ordered[0]?.[1] ?? 0;
|
|
42888
42984
|
for (const [path, mass] of ordered) {
|
|
@@ -42916,7 +43012,7 @@ function serializeRepoIndex(index) {
|
|
|
42916
43012
|
const heritage = [...index.heritage].map(([id2, h]) => ({ id: at(id2), extends: h.extends.map(at), implements: h.implements.map(at) }));
|
|
42917
43013
|
return { schemaVersion: "1", files: index.files, wordDocs: index.wordDocs, symbols: symbols2, callees, heritage, paths: [...index.imports.keys()], words: [...index.words] };
|
|
42918
43014
|
}
|
|
42919
|
-
var SEEDABLE, MIN_WORD_IDF, MIN_SOFT_SCORE, MAX_RELATED_FILES, STOP, DEFAULT_MAP_OPTIONS, estimateTokens, where;
|
|
43015
|
+
var SEEDABLE, MIN_WORD_IDF, MIN_SOFT_SCORE, MAX_RELATED_FILES, GENERIC_DF_SHARE, GENERIC_DF_FLOOR, STOP, DEFAULT_MAP_OPTIONS, estimateTokens, where;
|
|
42920
43016
|
var init_rank = __esm({
|
|
42921
43017
|
"../index-builder/src/rank.ts"() {
|
|
42922
43018
|
"use strict";
|
|
@@ -42925,6 +43021,8 @@ var init_rank = __esm({
|
|
|
42925
43021
|
MIN_WORD_IDF = 2.5;
|
|
42926
43022
|
MIN_SOFT_SCORE = 3.5;
|
|
42927
43023
|
MAX_RELATED_FILES = 14;
|
|
43024
|
+
GENERIC_DF_SHARE = 4e-3;
|
|
43025
|
+
GENERIC_DF_FLOOR = 30;
|
|
42928
43026
|
STOP = /* @__PURE__ */ new Set(["the", "a", "an", "of", "to", "in", "is", "are", "and", "or", "for", "that", "this", "it", "its", "by", "be", "on", "as", "at", "with", "from", "which", "what", "when", "where", "who", "how", "do", "does", "not", "any", "each", "every", "all", "also", "than", "then", "so", "if", "into", "file", "path", "answer", "end", "final", "message", "line", "start", "follow", "separate", "comma", "give", "name", "modify", "files", "repository", "source", "code", "change", "update", "make", "use", "uses", "used", "other", "only", "about", "will", "can", "should", "need", "needs", "happen", "merely", "share", "same", "return", "returns", "pass", "passes"]);
|
|
42929
43027
|
DEFAULT_MAP_OPTIONS = { maxTokens: 3400, maxSeeds: 6 };
|
|
42930
43028
|
estimateTokens = estimateCodeMapTokens;
|
|
@@ -43016,7 +43114,7 @@ async function buildRepoIndex(files) {
|
|
|
43016
43114
|
}
|
|
43017
43115
|
const heritage = /* @__PURE__ */ new Map();
|
|
43018
43116
|
const heirs = /* @__PURE__ */ new Map();
|
|
43019
|
-
const
|
|
43117
|
+
const resolve20 = (from, name2) => {
|
|
43020
43118
|
const visible = imports.get(from.path) ?? /* @__PURE__ */ new Set();
|
|
43021
43119
|
return (byName.get(baseName(name2)) ?? []).find((candidate) => candidate.path === from.path || reaches(visible, candidate.path));
|
|
43022
43120
|
};
|
|
@@ -43025,8 +43123,8 @@ async function buildRepoIndex(files) {
|
|
|
43025
43123
|
const stem2 = header.slice(header.indexOf(entry.name) + entry.name.length).replace(/^<[^>]*>/, "").replace(/\{.*$/, "");
|
|
43026
43124
|
const ext = /\bextends\s+([A-Za-z_$][\w$.]*)/.exec(stem2)?.[1];
|
|
43027
43125
|
const impl = /\bimplements\s+(.+)$/.exec(stem2)?.[1];
|
|
43028
|
-
const extendsIds = ext === void 0 ? [] : [
|
|
43029
|
-
const implementsIds = (impl === void 0 ? [] : impl.split(/,(?![^<]*>)/).map((part) =>
|
|
43126
|
+
const extendsIds = ext === void 0 ? [] : [resolve20(entry, ext)?.id].filter((value) => value !== void 0);
|
|
43127
|
+
const implementsIds = (impl === void 0 ? [] : impl.split(/,(?![^<]*>)/).map((part) => resolve20(entry, part.trim()))).filter((value) => value !== void 0).map((value) => value.id);
|
|
43030
43128
|
if (extendsIds.length === 0 && implementsIds.length === 0) continue;
|
|
43031
43129
|
heritage.set(id2, { extends: extendsIds, implements: implementsIds });
|
|
43032
43130
|
for (const target2 of extendsIds) heirs.set(target2, { extendedBy: [...heirs.get(target2)?.extendedBy ?? [], id2], implementedBy: heirs.get(target2)?.implementedBy ?? [] });
|
|
@@ -43052,9 +43150,9 @@ var init_context_map = __esm({
|
|
|
43052
43150
|
});
|
|
43053
43151
|
|
|
43054
43152
|
// ../index-builder/src/context-map-build.ts
|
|
43055
|
-
import { execFile as
|
|
43153
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
43056
43154
|
import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
43057
|
-
import { dirname as
|
|
43155
|
+
import { dirname as dirname11, join as join33 } from "node:path";
|
|
43058
43156
|
import { promisify as promisify2 } from "node:util";
|
|
43059
43157
|
async function git5(root, args2) {
|
|
43060
43158
|
const { stdout } = await execFileAsync2("git", args2, { cwd: root, encoding: "utf8", maxBuffer: 256 * 1024 * 1024 });
|
|
@@ -43067,7 +43165,7 @@ async function buildArtifactsForCheckout(options) {
|
|
|
43067
43165
|
for (const path of tracked) {
|
|
43068
43166
|
if (languageForPath(path) === null) continue;
|
|
43069
43167
|
try {
|
|
43070
|
-
const bytes = await readFile5(
|
|
43168
|
+
const bytes = await readFile5(join33(options.root, path));
|
|
43071
43169
|
if (bytes.byteLength > MAX_PARSE_BYTES) {
|
|
43072
43170
|
uncovered += 1;
|
|
43073
43171
|
continue;
|
|
@@ -43091,15 +43189,15 @@ async function buildArtifactsForCheckout(options) {
|
|
|
43091
43189
|
return { digest, indexFile };
|
|
43092
43190
|
}
|
|
43093
43191
|
async function writeIndexFile(root, indexFile) {
|
|
43094
|
-
const path =
|
|
43095
|
-
await mkdir3(
|
|
43192
|
+
const path = join33(root, CODE_INDEX_PATH);
|
|
43193
|
+
await mkdir3(dirname11(path), { recursive: true });
|
|
43096
43194
|
await writeFile3(path, `${JSON.stringify(indexFile)}
|
|
43097
43195
|
`);
|
|
43098
43196
|
return path;
|
|
43099
43197
|
}
|
|
43100
43198
|
async function writeDigest(root, digest, out2) {
|
|
43101
|
-
const path = out2 ??
|
|
43102
|
-
await mkdir3(
|
|
43199
|
+
const path = out2 ?? join33(root, CODE_MAP_DIGEST_PATH);
|
|
43200
|
+
await mkdir3(dirname11(path), { recursive: true });
|
|
43103
43201
|
await writeFile3(path, `${JSON.stringify(digest)}
|
|
43104
43202
|
`);
|
|
43105
43203
|
return path;
|
|
@@ -43112,14 +43210,14 @@ var init_context_map_build = __esm({
|
|
|
43112
43210
|
init_context_map();
|
|
43113
43211
|
init_languages();
|
|
43114
43212
|
init_snapshot();
|
|
43115
|
-
execFileAsync2 = promisify2(
|
|
43213
|
+
execFileAsync2 = promisify2(execFile3);
|
|
43116
43214
|
}
|
|
43117
43215
|
});
|
|
43118
43216
|
|
|
43119
43217
|
// ../index-builder/src/run.ts
|
|
43120
|
-
import { execFile as
|
|
43218
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
43121
43219
|
import { mkdir as mkdir4, readdir as readdir4, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
43122
|
-
import { join as
|
|
43220
|
+
import { join as join34, resolve as resolve18 } from "node:path";
|
|
43123
43221
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
43124
43222
|
import { promisify as promisify3 } from "node:util";
|
|
43125
43223
|
async function git6(root, args2) {
|
|
@@ -43140,7 +43238,7 @@ async function repositoryFromRemote(root) {
|
|
|
43140
43238
|
}
|
|
43141
43239
|
}
|
|
43142
43240
|
async function snapshotFromArgs(values, env) {
|
|
43143
|
-
const root =
|
|
43241
|
+
const root = resolve18(typeof values["root"] === "string" ? values["root"] : process.cwd());
|
|
43144
43242
|
const projectId = typeof values["project"] === "string" ? values["project"] : void 0;
|
|
43145
43243
|
if (projectId !== void 0 && !ProjectId.safeParse(projectId).success) throw new UsageError2(`--project must be a project identifier, got "${projectId}"`);
|
|
43146
43244
|
const repoText = projectId !== void 0 ? typeof values["repo"] === "string" ? values["repo"] : void 0 : (typeof values["repo"] === "string" ? values["repo"] : void 0) ?? env["GITHUB_REPOSITORY"] ?? await repositoryFromRemote(root);
|
|
@@ -43152,7 +43250,7 @@ async function snapshotFromArgs(values, env) {
|
|
|
43152
43250
|
const scip = Array.isArray(values["scip"]) ? values["scip"] : [];
|
|
43153
43251
|
return buildSnapshot({
|
|
43154
43252
|
repoRoot: root,
|
|
43155
|
-
scipFiles: scip.map((file2) =>
|
|
43253
|
+
scipFiles: scip.map((file2) => resolve18(file2)),
|
|
43156
43254
|
tenantId: tenant,
|
|
43157
43255
|
...repoText ? { repository: parseRepository(repoText) } : {},
|
|
43158
43256
|
...projectId !== void 0 ? { projectId } : {},
|
|
@@ -43168,14 +43266,14 @@ async function runCli2(argv, env, out2 = console.log, err2 = console.error) {
|
|
|
43168
43266
|
const outDir = values.out;
|
|
43169
43267
|
if (!outDir) throw new UsageError2("build needs --out DIR");
|
|
43170
43268
|
const built = await snapshotFromArgs({ ...values, tenant: values.tenant ?? env["HARNESS_TENANT"] ?? "local" }, env);
|
|
43171
|
-
await writeSnapshot(
|
|
43172
|
-
out2(`built ${built.shards.length} shards (${built.uncovered.length} files uncovered) into ${
|
|
43269
|
+
await writeSnapshot(resolve18(outDir), built);
|
|
43270
|
+
out2(`built ${built.shards.length} shards (${built.uncovered.length} files uncovered) into ${resolve18(outDir)}`);
|
|
43173
43271
|
return 0;
|
|
43174
43272
|
}
|
|
43175
43273
|
if (command === "map") {
|
|
43176
|
-
const root =
|
|
43274
|
+
const root = resolve18(values.root ?? process.cwd());
|
|
43177
43275
|
const { digest, indexFile } = await buildArtifactsForCheckout({ root, ...values.task === void 0 ? {} : { task: values.task } });
|
|
43178
|
-
const path = await writeDigest(root, digest, values.out === void 0 ? void 0 :
|
|
43276
|
+
const path = await writeDigest(root, digest, values.out === void 0 ? void 0 : resolve18(values.out));
|
|
43179
43277
|
const indexPath = values.out === void 0 ? await writeIndexFile(root, indexFile) : null;
|
|
43180
43278
|
out2(`wrote the code map digest for ${digest.revision.commitSha.slice(0, 12)} (${digest.coverage.files} files, ${digest.coverage.symbols} symbols, ${digest.lines.length} lines) to ${path}${indexPath === null ? "" : `, and the ranking index to ${indexPath}`}`);
|
|
43181
43279
|
return 0;
|
|
@@ -43203,13 +43301,13 @@ ${USAGE}`);
|
|
|
43203
43301
|
}
|
|
43204
43302
|
}
|
|
43205
43303
|
async function writeSnapshot(dir, built) {
|
|
43206
|
-
await mkdir4(
|
|
43207
|
-
for (const name2 of await readdir4(
|
|
43208
|
-
await writeFile4(
|
|
43209
|
-
await writeFile4(
|
|
43304
|
+
await mkdir4(join34(dir, "shards"), { recursive: true });
|
|
43305
|
+
for (const name2 of await readdir4(join34(dir, "shards"))) await rm2(join34(dir, "shards", name2));
|
|
43306
|
+
await writeFile4(join34(dir, "manifest.json"), JSON.stringify(built.manifest, null, 2));
|
|
43307
|
+
await writeFile4(join34(dir, "uncovered.json"), JSON.stringify(built.uncovered, null, 2));
|
|
43210
43308
|
for (const shard of built.shards) {
|
|
43211
43309
|
const name2 = shardKeyOf(shard).slice("sha256:".length);
|
|
43212
|
-
await writeFile4(
|
|
43310
|
+
await writeFile4(join34(dir, "shards", `${name2}.json`), JSON.stringify(shard));
|
|
43213
43311
|
}
|
|
43214
43312
|
}
|
|
43215
43313
|
var execFileAsync3, USAGE, UsageError2, OPTIONS;
|
|
@@ -43221,7 +43319,7 @@ var init_run = __esm({
|
|
|
43221
43319
|
init_oidc();
|
|
43222
43320
|
init_snapshot();
|
|
43223
43321
|
init_upload();
|
|
43224
|
-
execFileAsync3 = promisify3(
|
|
43322
|
+
execFileAsync3 = promisify3(execFile4);
|
|
43225
43323
|
USAGE = `usage:
|
|
43226
43324
|
mvrx-index build --scip FILE [--scip FILE ...] --out DIR [--project ID | --repo owner/name] [--tenant ID] [--commit SHA] [--branch B] [--root DIR]
|
|
43227
43325
|
mvrx-index map [--root DIR] [--out FILE] [--task TEXT]
|
|
@@ -46815,14 +46913,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
46815
46913
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
46816
46914
|
}
|
|
46817
46915
|
function sleep2(ms, signal) {
|
|
46818
|
-
return new Promise((
|
|
46916
|
+
return new Promise((resolve20, reject) => {
|
|
46819
46917
|
if (signal?.aborted) {
|
|
46820
46918
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
46821
46919
|
return;
|
|
46822
46920
|
}
|
|
46823
46921
|
const timer = setTimeout(() => {
|
|
46824
46922
|
signal?.removeEventListener("abort", onAbort);
|
|
46825
|
-
|
|
46923
|
+
resolve20();
|
|
46826
46924
|
}, ms);
|
|
46827
46925
|
const onAbort = () => {
|
|
46828
46926
|
clearTimeout(timer);
|
|
@@ -48618,7 +48716,7 @@ var init_src_CX2iR2pK = __esm({
|
|
|
48618
48716
|
const flowStartedAt = Date.now();
|
|
48619
48717
|
let onAbort;
|
|
48620
48718
|
let cleanupMessageId;
|
|
48621
|
-
return new Promise((
|
|
48719
|
+
return new Promise((resolve20, reject) => {
|
|
48622
48720
|
const earlyReject = (error62) => {
|
|
48623
48721
|
reject(error62);
|
|
48624
48722
|
};
|
|
@@ -48686,7 +48784,7 @@ var init_src_CX2iR2pK = __esm({
|
|
|
48686
48784
|
}
|
|
48687
48785
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
48688
48786
|
if (decoded.kind === "input_required") {
|
|
48689
|
-
if (options?.allowInputRequired === true) return
|
|
48787
|
+
if (options?.allowInputRequired === true) return resolve20(manualInputRequiredValue(decoded));
|
|
48690
48788
|
const flow = {
|
|
48691
48789
|
codec: codec2,
|
|
48692
48790
|
request,
|
|
@@ -48698,11 +48796,11 @@ var init_src_CX2iR2pK = __esm({
|
|
|
48698
48796
|
params
|
|
48699
48797
|
}, resultSchema2, legOptions)
|
|
48700
48798
|
};
|
|
48701
|
-
return
|
|
48799
|
+
return resolve20(this._resolveNonCompleteResult(decoded, flow));
|
|
48702
48800
|
}
|
|
48703
48801
|
const result = decoded.result;
|
|
48704
48802
|
validateStandardSchema(resultSchema2, result).then((parseResult) => {
|
|
48705
|
-
if (parseResult.success)
|
|
48803
|
+
if (parseResult.success) resolve20(parseResult.data);
|
|
48706
48804
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
|
|
48707
48805
|
}, reject);
|
|
48708
48806
|
});
|
|
@@ -49008,7 +49106,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
49008
49106
|
}
|
|
49009
49107
|
exports._ = _;
|
|
49010
49108
|
const plus = new _Code("+");
|
|
49011
|
-
function
|
|
49109
|
+
function str2(strs, ...args2) {
|
|
49012
49110
|
const expr = [safeStringify(strs[0])];
|
|
49013
49111
|
let i2 = 0;
|
|
49014
49112
|
while (i2 < args2.length) {
|
|
@@ -49019,7 +49117,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
49019
49117
|
optimize(expr);
|
|
49020
49118
|
return new _Code(expr);
|
|
49021
49119
|
}
|
|
49022
|
-
exports.str =
|
|
49120
|
+
exports.str = str2;
|
|
49023
49121
|
function addCodeArg(code2, arg4) {
|
|
49024
49122
|
if (arg4 instanceof _Code) code2.push(...arg4._items);
|
|
49025
49123
|
else if (arg4 instanceof Name3) code2.push(arg4);
|
|
@@ -49052,7 +49150,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
49052
49150
|
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name3)) return `"${a}${b.slice(1)}`;
|
|
49053
49151
|
}
|
|
49054
49152
|
function strConcat(c1, c2) {
|
|
49055
|
-
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 :
|
|
49153
|
+
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str2`${c1}${c2}`;
|
|
49056
49154
|
}
|
|
49057
49155
|
exports.strConcat = strConcat;
|
|
49058
49156
|
function interpolate(x) {
|
|
@@ -49931,21 +50029,21 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
49931
50029
|
return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
|
|
49932
50030
|
}
|
|
49933
50031
|
exports.schemaRefOrVal = schemaRefOrVal;
|
|
49934
|
-
function unescapeFragment(
|
|
49935
|
-
return unescapeJsonPointer(decodeURIComponent(
|
|
50032
|
+
function unescapeFragment(str2) {
|
|
50033
|
+
return unescapeJsonPointer(decodeURIComponent(str2));
|
|
49936
50034
|
}
|
|
49937
50035
|
exports.unescapeFragment = unescapeFragment;
|
|
49938
|
-
function escapeFragment(
|
|
49939
|
-
return encodeURIComponent(escapeJsonPointer(
|
|
50036
|
+
function escapeFragment(str2) {
|
|
50037
|
+
return encodeURIComponent(escapeJsonPointer(str2));
|
|
49940
50038
|
}
|
|
49941
50039
|
exports.escapeFragment = escapeFragment;
|
|
49942
|
-
function escapeJsonPointer(
|
|
49943
|
-
if (typeof
|
|
49944
|
-
return
|
|
50040
|
+
function escapeJsonPointer(str2) {
|
|
50041
|
+
if (typeof str2 == "number") return `${str2}`;
|
|
50042
|
+
return str2.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
49945
50043
|
}
|
|
49946
50044
|
exports.escapeJsonPointer = escapeJsonPointer;
|
|
49947
|
-
function unescapeJsonPointer(
|
|
49948
|
-
return
|
|
50045
|
+
function unescapeJsonPointer(str2) {
|
|
50046
|
+
return str2.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
49949
50047
|
}
|
|
49950
50048
|
exports.unescapeJsonPointer = unescapeJsonPointer;
|
|
49951
50049
|
function eachItem(xs, f) {
|
|
@@ -50831,8 +50929,8 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
50831
50929
|
post2(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
50832
50930
|
}
|
|
50833
50931
|
}
|
|
50834
|
-
function escapeJsonPtr(
|
|
50835
|
-
return
|
|
50932
|
+
function escapeJsonPtr(str2) {
|
|
50933
|
+
return str2.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
50836
50934
|
}
|
|
50837
50935
|
}));
|
|
50838
50936
|
require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -51518,7 +51616,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
51518
51616
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
51519
51617
|
const schOrFunc = root.refs[ref];
|
|
51520
51618
|
if (schOrFunc) return schOrFunc;
|
|
51521
|
-
let _sch =
|
|
51619
|
+
let _sch = resolve20.call(this, root, ref);
|
|
51522
51620
|
if (_sch === void 0) {
|
|
51523
51621
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
51524
51622
|
const { schemaId } = this.opts;
|
|
@@ -51544,7 +51642,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
51544
51642
|
function sameSchemaEnv(s1, s2) {
|
|
51545
51643
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
51546
51644
|
}
|
|
51547
|
-
function
|
|
51645
|
+
function resolve20(root, ref) {
|
|
51548
51646
|
let sch;
|
|
51549
51647
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
51550
51648
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -51724,9 +51822,9 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
51724
51822
|
isIPV6: false
|
|
51725
51823
|
};
|
|
51726
51824
|
}
|
|
51727
|
-
function findToken3(
|
|
51825
|
+
function findToken3(str2, token) {
|
|
51728
51826
|
let ind = 0;
|
|
51729
|
-
for (let i2 = 0; i2 <
|
|
51827
|
+
for (let i2 = 0; i2 < str2.length; i2++) if (str2[i2] === token) ind++;
|
|
51730
51828
|
return ind;
|
|
51731
51829
|
}
|
|
51732
51830
|
function removeDotSegments(path) {
|
|
@@ -51994,47 +52092,47 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
51994
52092
|
else if (typeof uri === "object") uri = parse5(serialize(uri, options), options);
|
|
51995
52093
|
return uri;
|
|
51996
52094
|
}
|
|
51997
|
-
function
|
|
52095
|
+
function resolve20(baseURI, relativeURI, options) {
|
|
51998
52096
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
51999
52097
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
52000
52098
|
schemelessOptions.skipEscape = true;
|
|
52001
52099
|
return serialize(resolved, schemelessOptions);
|
|
52002
52100
|
}
|
|
52003
|
-
function resolveComponent(base5,
|
|
52101
|
+
function resolveComponent(base5, relative6, options, skipNormalization) {
|
|
52004
52102
|
const target2 = {};
|
|
52005
52103
|
if (!skipNormalization) {
|
|
52006
52104
|
base5 = parse5(serialize(base5, options), options);
|
|
52007
|
-
|
|
52105
|
+
relative6 = parse5(serialize(relative6, options), options);
|
|
52008
52106
|
}
|
|
52009
52107
|
options = options || {};
|
|
52010
|
-
if (!options.tolerant &&
|
|
52011
|
-
target2.scheme =
|
|
52012
|
-
target2.userinfo =
|
|
52013
|
-
target2.host =
|
|
52014
|
-
target2.port =
|
|
52015
|
-
target2.path = removeDotSegments(
|
|
52016
|
-
target2.query =
|
|
52108
|
+
if (!options.tolerant && relative6.scheme) {
|
|
52109
|
+
target2.scheme = relative6.scheme;
|
|
52110
|
+
target2.userinfo = relative6.userinfo;
|
|
52111
|
+
target2.host = relative6.host;
|
|
52112
|
+
target2.port = relative6.port;
|
|
52113
|
+
target2.path = removeDotSegments(relative6.path || "");
|
|
52114
|
+
target2.query = relative6.query;
|
|
52017
52115
|
} else {
|
|
52018
|
-
if (
|
|
52019
|
-
target2.userinfo =
|
|
52020
|
-
target2.host =
|
|
52021
|
-
target2.port =
|
|
52022
|
-
target2.path = removeDotSegments(
|
|
52023
|
-
target2.query =
|
|
52116
|
+
if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
|
|
52117
|
+
target2.userinfo = relative6.userinfo;
|
|
52118
|
+
target2.host = relative6.host;
|
|
52119
|
+
target2.port = relative6.port;
|
|
52120
|
+
target2.path = removeDotSegments(relative6.path || "");
|
|
52121
|
+
target2.query = relative6.query;
|
|
52024
52122
|
} else {
|
|
52025
|
-
if (!
|
|
52123
|
+
if (!relative6.path) {
|
|
52026
52124
|
target2.path = base5.path;
|
|
52027
|
-
if (
|
|
52125
|
+
if (relative6.query !== void 0) target2.query = relative6.query;
|
|
52028
52126
|
else target2.query = base5.query;
|
|
52029
52127
|
} else {
|
|
52030
|
-
if (
|
|
52128
|
+
if (relative6.path[0] === "/") target2.path = removeDotSegments(relative6.path);
|
|
52031
52129
|
else {
|
|
52032
|
-
if ((base5.userinfo !== void 0 || base5.host !== void 0 || base5.port !== void 0) && !base5.path) target2.path = "/" +
|
|
52033
|
-
else if (!base5.path) target2.path =
|
|
52034
|
-
else target2.path = base5.path.slice(0, base5.path.lastIndexOf("/") + 1) +
|
|
52130
|
+
if ((base5.userinfo !== void 0 || base5.host !== void 0 || base5.port !== void 0) && !base5.path) target2.path = "/" + relative6.path;
|
|
52131
|
+
else if (!base5.path) target2.path = relative6.path;
|
|
52132
|
+
else target2.path = base5.path.slice(0, base5.path.lastIndexOf("/") + 1) + relative6.path;
|
|
52035
52133
|
target2.path = removeDotSegments(target2.path);
|
|
52036
52134
|
}
|
|
52037
|
-
target2.query =
|
|
52135
|
+
target2.query = relative6.query;
|
|
52038
52136
|
}
|
|
52039
52137
|
target2.userinfo = base5.userinfo;
|
|
52040
52138
|
target2.host = base5.host;
|
|
@@ -52042,7 +52140,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
52042
52140
|
}
|
|
52043
52141
|
target2.scheme = base5.scheme;
|
|
52044
52142
|
}
|
|
52045
|
-
target2.fragment =
|
|
52143
|
+
target2.fragment = relative6.fragment;
|
|
52046
52144
|
return target2;
|
|
52047
52145
|
}
|
|
52048
52146
|
function equal(uriA, uriB, options) {
|
|
@@ -52168,7 +52266,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
52168
52266
|
const fastUri = {
|
|
52169
52267
|
SCHEMES,
|
|
52170
52268
|
normalize,
|
|
52171
|
-
resolve:
|
|
52269
|
+
resolve: resolve20,
|
|
52172
52270
|
resolveComponent,
|
|
52173
52271
|
equal,
|
|
52174
52272
|
serialize,
|
|
@@ -52241,7 +52339,7 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
52241
52339
|
const util_1 = require_util();
|
|
52242
52340
|
const $dataRefSchema = require_data();
|
|
52243
52341
|
const uri_1 = require_uri();
|
|
52244
|
-
const defaultRegExp = (
|
|
52342
|
+
const defaultRegExp = (str2, flags2) => new RegExp(str2, flags2);
|
|
52245
52343
|
defaultRegExp.code = "new RegExp";
|
|
52246
52344
|
const META_IGNORE_OPTIONS = [
|
|
52247
52345
|
"removeAdditional",
|
|
@@ -52947,16 +53045,16 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
52947
53045
|
}));
|
|
52948
53046
|
require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
52949
53047
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52950
|
-
function ucs2length(
|
|
52951
|
-
const len =
|
|
53048
|
+
function ucs2length(str2) {
|
|
53049
|
+
const len = str2.length;
|
|
52952
53050
|
let length = 0;
|
|
52953
53051
|
let pos = 0;
|
|
52954
53052
|
let value;
|
|
52955
53053
|
while (pos < len) {
|
|
52956
53054
|
length++;
|
|
52957
|
-
value =
|
|
53055
|
+
value = str2.charCodeAt(pos++);
|
|
52958
53056
|
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
52959
|
-
value =
|
|
53057
|
+
value = str2.charCodeAt(pos);
|
|
52960
53058
|
if ((value & 64512) === 56320) pos++;
|
|
52961
53059
|
}
|
|
52962
53060
|
}
|
|
@@ -55667,8 +55765,8 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
55667
55765
|
30,
|
|
55668
55766
|
31
|
|
55669
55767
|
];
|
|
55670
|
-
function date5(
|
|
55671
|
-
const matches = DATE.exec(
|
|
55768
|
+
function date5(str2) {
|
|
55769
|
+
const matches = DATE.exec(str2);
|
|
55672
55770
|
if (!matches) return false;
|
|
55673
55771
|
const year = +matches[1];
|
|
55674
55772
|
const month = +matches[2];
|
|
@@ -55683,8 +55781,8 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
55683
55781
|
}
|
|
55684
55782
|
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
55685
55783
|
function getTime(strictTimeZone) {
|
|
55686
|
-
return function time3(
|
|
55687
|
-
const matches = TIME.exec(
|
|
55784
|
+
return function time3(str2) {
|
|
55785
|
+
const matches = TIME.exec(str2);
|
|
55688
55786
|
if (!matches) return false;
|
|
55689
55787
|
const hr = +matches[1];
|
|
55690
55788
|
const min = +matches[2];
|
|
@@ -55721,8 +55819,8 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
55721
55819
|
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
55722
55820
|
function getDateTime(strictTimeZone) {
|
|
55723
55821
|
const time3 = getTime(strictTimeZone);
|
|
55724
|
-
return function date_time(
|
|
55725
|
-
const dateTime =
|
|
55822
|
+
return function date_time(str2) {
|
|
55823
|
+
const dateTime = str2.split(DATE_TIME_SEPARATOR);
|
|
55726
55824
|
return dateTime.length === 2 && date5(dateTime[0]) && time3(dateTime[1]);
|
|
55727
55825
|
};
|
|
55728
55826
|
}
|
|
@@ -55743,13 +55841,13 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
55743
55841
|
}
|
|
55744
55842
|
const NOT_URI_FRAGMENT = /\/|:/;
|
|
55745
55843
|
const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
55746
|
-
function uri(
|
|
55747
|
-
return NOT_URI_FRAGMENT.test(
|
|
55844
|
+
function uri(str2) {
|
|
55845
|
+
return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
|
|
55748
55846
|
}
|
|
55749
55847
|
const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
|
|
55750
|
-
function byte(
|
|
55848
|
+
function byte(str2) {
|
|
55751
55849
|
BYTE.lastIndex = 0;
|
|
55752
|
-
return BYTE.test(
|
|
55850
|
+
return BYTE.test(str2);
|
|
55753
55851
|
}
|
|
55754
55852
|
const MIN_INT32 = -(2 ** 31);
|
|
55755
55853
|
const MAX_INT32 = 2 ** 31 - 1;
|
|
@@ -55763,10 +55861,10 @@ var init_ajvProvider_CEoC_sr = __esm({
|
|
|
55763
55861
|
return true;
|
|
55764
55862
|
}
|
|
55765
55863
|
const Z_ANCHOR = /[^\\]\\Z/;
|
|
55766
|
-
function regex(
|
|
55767
|
-
if (Z_ANCHOR.test(
|
|
55864
|
+
function regex(str2) {
|
|
55865
|
+
if (Z_ANCHOR.test(str2)) return false;
|
|
55768
55866
|
try {
|
|
55769
|
-
new RegExp(
|
|
55867
|
+
new RegExp(str2);
|
|
55770
55868
|
return true;
|
|
55771
55869
|
} catch (e2) {
|
|
55772
55870
|
return false;
|
|
@@ -57865,7 +57963,7 @@ var init_stdio = __esm({
|
|
|
57865
57963
|
}
|
|
57866
57964
|
send(message) {
|
|
57867
57965
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
57868
|
-
return new Promise((
|
|
57966
|
+
return new Promise((resolve20, reject) => {
|
|
57869
57967
|
const json2 = serializeMessage(message);
|
|
57870
57968
|
let settled = false;
|
|
57871
57969
|
const onError = (error62) => {
|
|
@@ -57880,14 +57978,14 @@ var init_stdio = __esm({
|
|
|
57880
57978
|
settled = true;
|
|
57881
57979
|
this._stdout.off("error", onError);
|
|
57882
57980
|
this._stdout.off("drain", onDrain);
|
|
57883
|
-
|
|
57981
|
+
resolve20();
|
|
57884
57982
|
};
|
|
57885
57983
|
this._stdout.once("error", onError);
|
|
57886
57984
|
if (this._stdout.write(json2)) {
|
|
57887
57985
|
if (settled) return;
|
|
57888
57986
|
settled = true;
|
|
57889
57987
|
this._stdout.off("error", onError);
|
|
57890
|
-
|
|
57988
|
+
resolve20();
|
|
57891
57989
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
57892
57990
|
});
|
|
57893
57991
|
}
|
|
@@ -57941,14 +58039,14 @@ var init_stdio = __esm({
|
|
|
57941
58039
|
*/
|
|
57942
58040
|
async whenRequestsAnswered(timeoutMs) {
|
|
57943
58041
|
if (this._closed || this._pendingRequests.size === 0) return true;
|
|
57944
|
-
return await new Promise((
|
|
58042
|
+
return await new Promise((resolve20) => {
|
|
57945
58043
|
const waiter = () => {
|
|
57946
58044
|
clearTimeout(timer);
|
|
57947
|
-
|
|
58045
|
+
resolve20(true);
|
|
57948
58046
|
};
|
|
57949
58047
|
const timer = setTimeout(() => {
|
|
57950
58048
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
57951
|
-
|
|
58049
|
+
resolve20(false);
|
|
57952
58050
|
}, timeoutMs);
|
|
57953
58051
|
this._drainWaiters.push(waiter);
|
|
57954
58052
|
});
|
|
@@ -58055,8 +58153,8 @@ var init_cloud = __esm({
|
|
|
58055
58153
|
|
|
58056
58154
|
// ../code-shim/src/git.ts
|
|
58057
58155
|
import { execFileSync } from "node:child_process";
|
|
58058
|
-
import { existsSync as
|
|
58059
|
-
import { join as
|
|
58156
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
58157
|
+
import { join as join38 } from "node:path";
|
|
58060
58158
|
function git7(root, args2) {
|
|
58061
58159
|
try {
|
|
58062
58160
|
return execFileSync("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 64 * 1024 * 1024, timeout: 1e4 });
|
|
@@ -58118,7 +58216,7 @@ function readWorkingCopyState(root) {
|
|
|
58118
58216
|
const head = headCommit2(root);
|
|
58119
58217
|
const raw = git7(root, ["status", "--porcelain=v2", "-z", "--untracked-files=all"]);
|
|
58120
58218
|
if (raw === null) return { head, dirty: /* @__PURE__ */ new Set(), deleted: /* @__PURE__ */ new Set(), renamed: /* @__PURE__ */ new Map() };
|
|
58121
|
-
return { head, ...parseStatus(raw, (path) =>
|
|
58219
|
+
return { head, ...parseStatus(raw, (path) => existsSync14(join38(root, path))) };
|
|
58122
58220
|
}
|
|
58123
58221
|
var init_git2 = __esm({
|
|
58124
58222
|
"../code-shim/src/git.ts"() {
|
|
@@ -58127,18 +58225,18 @@ var init_git2 = __esm({
|
|
|
58127
58225
|
});
|
|
58128
58226
|
|
|
58129
58227
|
// ../code-shim/src/config.ts
|
|
58130
|
-
import { readFileSync as
|
|
58228
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
58131
58229
|
import { homedir as homedir2 } from "node:os";
|
|
58132
|
-
import { join as
|
|
58230
|
+
import { join as join39 } from "node:path";
|
|
58133
58231
|
function configDir(env) {
|
|
58134
|
-
const base5 = env["XDG_CONFIG_HOME"] ?? (process.platform === "win32" ? env["APPDATA"] : void 0) ??
|
|
58135
|
-
return
|
|
58232
|
+
const base5 = env["XDG_CONFIG_HOME"] ?? (process.platform === "win32" ? env["APPDATA"] : void 0) ?? join39(homedir2(), ".config");
|
|
58233
|
+
return join39(base5, "mvrx-harness");
|
|
58136
58234
|
}
|
|
58137
58235
|
function findToken2(env, serviceUrl, now) {
|
|
58138
58236
|
const fromEnv = env["HARNESS_TOKEN"];
|
|
58139
58237
|
if (fromEnv !== void 0 && fromEnv.length > 0) return fromEnv;
|
|
58140
58238
|
try {
|
|
58141
|
-
const file2 = JSON.parse(
|
|
58239
|
+
const file2 = JSON.parse(readFileSync21(join39(configDir(env), "credentials.json"), "utf8"));
|
|
58142
58240
|
const stored = file2[serviceUrl];
|
|
58143
58241
|
if (stored === void 0 || typeof stored.accessToken !== "string" || stored.accessToken.length === 0) return null;
|
|
58144
58242
|
if (typeof stored.expiresAt === "number" && stored.expiresAt <= now) return null;
|
|
@@ -58150,7 +58248,7 @@ function findToken2(env, serviceUrl, now) {
|
|
|
58150
58248
|
function resolveCloudConfig(root, env, now) {
|
|
58151
58249
|
let binding;
|
|
58152
58250
|
try {
|
|
58153
|
-
const parsed = ProjectBinding.safeParse(JSON.parse(
|
|
58251
|
+
const parsed = ProjectBinding.safeParse(JSON.parse(readFileSync21(join39(root, ".harness", "project.json"), "utf8")));
|
|
58154
58252
|
if (!parsed.success) return null;
|
|
58155
58253
|
binding = parsed.data;
|
|
58156
58254
|
} catch {
|
|
@@ -58172,11 +58270,11 @@ var init_config = __esm({
|
|
|
58172
58270
|
});
|
|
58173
58271
|
|
|
58174
58272
|
// ../code-shim/src/local.ts
|
|
58175
|
-
import { readFileSync as
|
|
58176
|
-
import { isAbsolute as isAbsolute2, relative as
|
|
58273
|
+
import { readFileSync as readFileSync22, statSync as statSync4 } from "node:fs";
|
|
58274
|
+
import { isAbsolute as isAbsolute2, relative as relative5, resolve as resolve19, sep as sep2 } from "node:path";
|
|
58177
58275
|
function resolveInside(root, path) {
|
|
58178
|
-
const absolute =
|
|
58179
|
-
const rel =
|
|
58276
|
+
const absolute = resolve19(root, path);
|
|
58277
|
+
const rel = relative5(root, absolute);
|
|
58180
58278
|
if (rel.length === 0 || rel.startsWith("..") || isAbsolute2(rel)) return null;
|
|
58181
58279
|
return absolute;
|
|
58182
58280
|
}
|
|
@@ -58281,7 +58379,7 @@ var init_local = __esm({
|
|
|
58281
58379
|
if (absolute === null || !this.supports(path)) return null;
|
|
58282
58380
|
let key;
|
|
58283
58381
|
try {
|
|
58284
|
-
const stat =
|
|
58382
|
+
const stat = statSync4(absolute);
|
|
58285
58383
|
if (!stat.isFile() || stat.size > MAX_PARSE_BYTES2) return null;
|
|
58286
58384
|
key = `${stat.mtimeMs}:${stat.size}`;
|
|
58287
58385
|
} catch {
|
|
@@ -58292,7 +58390,7 @@ var init_local = __esm({
|
|
|
58292
58390
|
let shard;
|
|
58293
58391
|
try {
|
|
58294
58392
|
this.parses += 1;
|
|
58295
|
-
shard = await this.parse(path,
|
|
58393
|
+
shard = await this.parse(path, readFileSync22(absolute, "utf8"));
|
|
58296
58394
|
} catch {
|
|
58297
58395
|
shard = null;
|
|
58298
58396
|
}
|
|
@@ -58304,7 +58402,7 @@ var init_local = __esm({
|
|
|
58304
58402
|
const absolute = resolveInside(this.root, path);
|
|
58305
58403
|
if (absolute === null) return null;
|
|
58306
58404
|
try {
|
|
58307
|
-
return
|
|
58405
|
+
return readFileSync22(absolute, "utf8");
|
|
58308
58406
|
} catch {
|
|
58309
58407
|
return null;
|
|
58310
58408
|
}
|
|
@@ -58314,7 +58412,7 @@ var init_local = __esm({
|
|
|
58314
58412
|
const absolute = resolveInside(this.root, path);
|
|
58315
58413
|
if (absolute === null) return void 0;
|
|
58316
58414
|
try {
|
|
58317
|
-
const lines =
|
|
58415
|
+
const lines = readFileSync22(absolute, "utf8").split("\n");
|
|
58318
58416
|
const start2 = range[0];
|
|
58319
58417
|
if (start2 >= lines.length) return void 0;
|
|
58320
58418
|
const end = Math.min(Math.max(range[2], start2), start2 + maxLines - 1, lines.length - 1);
|
|
@@ -58541,7 +58639,7 @@ var init_nav = __esm({
|
|
|
58541
58639
|
|
|
58542
58640
|
// ../code-shim/src/edit.ts
|
|
58543
58641
|
import { createHash as createHash8 } from "node:crypto";
|
|
58544
|
-
import { readFileSync as
|
|
58642
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync11 } from "node:fs";
|
|
58545
58643
|
function lineStarts(text) {
|
|
58546
58644
|
const starts = [0];
|
|
58547
58645
|
for (let i2 = 0; i2 < text.length; i2 += 1) if (text[i2] === "\n") starts.push(i2 + 1);
|
|
@@ -58582,7 +58680,7 @@ async function editSymbol(index, args2) {
|
|
|
58582
58680
|
if (!found.ok) return found;
|
|
58583
58681
|
const absolute = resolveInside(index.root, args2.path);
|
|
58584
58682
|
if (absolute === null) return { ok: false, reason: `path ${args2.path} is outside the repository` };
|
|
58585
|
-
const original =
|
|
58683
|
+
const original = readFileSync23(absolute, "utf8");
|
|
58586
58684
|
const starts = lineStarts(original);
|
|
58587
58685
|
const range = found.symbol.enclosingRange ?? found.symbol.range;
|
|
58588
58686
|
const from = offsetOf(starts, original, range[0], range[1]);
|
|
@@ -58649,7 +58747,7 @@ async function renameSymbol(deps, args2) {
|
|
|
58649
58747
|
if (absolute === null) return { ok: false, reason: `reference path ${path} is outside the repository` };
|
|
58650
58748
|
let text;
|
|
58651
58749
|
try {
|
|
58652
|
-
text =
|
|
58750
|
+
text = readFileSync23(absolute, "utf8");
|
|
58653
58751
|
} catch {
|
|
58654
58752
|
return { ok: false, reason: `cannot read ${path}` };
|
|
58655
58753
|
}
|
|
@@ -58926,6 +59024,7 @@ function defineCommand(definition) {
|
|
|
58926
59024
|
result: definition.result,
|
|
58927
59025
|
style: definition.style ?? "normal",
|
|
58928
59026
|
...definition.text === void 0 ? {} : { text: definition.text },
|
|
59027
|
+
...definition.textDefault === true ? { textDefault: true } : {},
|
|
58929
59028
|
handler: definition.handler
|
|
58930
59029
|
};
|
|
58931
59030
|
}
|
|
@@ -59473,12 +59572,12 @@ function parseKeyPath(source) {
|
|
|
59473
59572
|
const s = source.trim();
|
|
59474
59573
|
while (i2 < s.length) {
|
|
59475
59574
|
while (s[i2] === " " || s[i2] === " ") i2 += 1;
|
|
59476
|
-
const
|
|
59575
|
+
const quote4 = s[i2];
|
|
59477
59576
|
let part = "";
|
|
59478
|
-
if (
|
|
59577
|
+
if (quote4 === '"' || quote4 === "'") {
|
|
59479
59578
|
i2 += 1;
|
|
59480
|
-
while (i2 < s.length && s[i2] !==
|
|
59481
|
-
if (
|
|
59579
|
+
while (i2 < s.length && s[i2] !== quote4) {
|
|
59580
|
+
if (quote4 === '"' && s[i2] === "\\" && i2 + 1 < s.length) {
|
|
59482
59581
|
part += s[i2 + 1];
|
|
59483
59582
|
i2 += 2;
|
|
59484
59583
|
} else {
|
|
@@ -59486,7 +59585,7 @@ function parseKeyPath(source) {
|
|
|
59486
59585
|
i2 += 1;
|
|
59487
59586
|
}
|
|
59488
59587
|
}
|
|
59489
|
-
if (s[i2] !==
|
|
59588
|
+
if (s[i2] !== quote4) return null;
|
|
59490
59589
|
i2 += 1;
|
|
59491
59590
|
} else {
|
|
59492
59591
|
const start2 = i2;
|
|
@@ -59692,19 +59791,19 @@ function pkcePair() {
|
|
|
59692
59791
|
return { verifier, challenge: base64url3(createHash("sha256").update(verifier).digest()) };
|
|
59693
59792
|
}
|
|
59694
59793
|
function listen(server2, port) {
|
|
59695
|
-
return new Promise((
|
|
59794
|
+
return new Promise((resolve20, reject) => {
|
|
59696
59795
|
const onError = (error62) => reject(error62);
|
|
59697
59796
|
server2.once("error", onError);
|
|
59698
59797
|
server2.listen(port, "127.0.0.1", () => {
|
|
59699
59798
|
server2.off("error", onError);
|
|
59700
|
-
|
|
59799
|
+
resolve20();
|
|
59701
59800
|
});
|
|
59702
59801
|
});
|
|
59703
59802
|
}
|
|
59704
59803
|
async function startLoopback(preferredPort, state) {
|
|
59705
59804
|
let settle2;
|
|
59706
|
-
const code2 = new Promise((
|
|
59707
|
-
settle2 = { resolve:
|
|
59805
|
+
const code2 = new Promise((resolve20, reject) => {
|
|
59806
|
+
settle2 = { resolve: resolve20, reject };
|
|
59708
59807
|
});
|
|
59709
59808
|
code2.catch(() => void 0);
|
|
59710
59809
|
const server2 = createServer((request, response) => {
|
|
@@ -59858,13 +59957,13 @@ async function findToken(deps, serviceUrl) {
|
|
|
59858
59957
|
rememberSecret(fromEnv);
|
|
59859
59958
|
return { token: fromEnv, source: "environment" };
|
|
59860
59959
|
}
|
|
59861
|
-
const
|
|
59862
|
-
if (
|
|
59863
|
-
const { tokens } =
|
|
59960
|
+
const loaded2 = await loadTokens(deps, serviceUrl);
|
|
59961
|
+
if (loaded2 === null) return null;
|
|
59962
|
+
const { tokens } = loaded2;
|
|
59864
59963
|
rememberSecret(tokens.accessToken);
|
|
59865
59964
|
rememberSecret(tokens.refreshToken);
|
|
59866
59965
|
if (tokens.expiresAt === void 0 || deps.now() < tokens.expiresAt - EXPIRY_MARGIN_MS) {
|
|
59867
|
-
return { token: tokens.accessToken, source:
|
|
59966
|
+
return { token: tokens.accessToken, source: loaded2.store };
|
|
59868
59967
|
}
|
|
59869
59968
|
const renewed = await refresh(deps, serviceUrl, tokens);
|
|
59870
59969
|
if (renewed === null) return null;
|
|
@@ -60481,8 +60580,8 @@ function withTimeout(deps, ms) {
|
|
|
60481
60580
|
}
|
|
60482
60581
|
async function attempt(deps, ms, work) {
|
|
60483
60582
|
let timer;
|
|
60484
|
-
const deadline = new Promise((
|
|
60485
|
-
timer = setTimeout(() =>
|
|
60583
|
+
const deadline = new Promise((resolve20) => {
|
|
60584
|
+
timer = setTimeout(() => resolve20("unreachable"), ms);
|
|
60486
60585
|
});
|
|
60487
60586
|
try {
|
|
60488
60587
|
return await Promise.race([work(withTimeout(deps, ms)).catch((error62) => error62 instanceof ServiceError && error62.exit === EXIT.auth ? "unauthenticated" : "unreachable"), deadline]);
|
|
@@ -60521,16 +60620,16 @@ async function authStatus(deps, serviceFlag) {
|
|
|
60521
60620
|
how = "environment";
|
|
60522
60621
|
token = fromEnv;
|
|
60523
60622
|
} else {
|
|
60524
|
-
const
|
|
60525
|
-
if (
|
|
60526
|
-
how =
|
|
60527
|
-
token =
|
|
60528
|
-
rememberSecret(
|
|
60529
|
-
rememberSecret(
|
|
60530
|
-
canRefresh =
|
|
60531
|
-
if (
|
|
60532
|
-
expiresAt = new Date(
|
|
60533
|
-
expired = deps.now() >=
|
|
60623
|
+
const loaded2 = await loadTokens(deps, storeKey).catch(() => null);
|
|
60624
|
+
if (loaded2 !== null) {
|
|
60625
|
+
how = loaded2.store;
|
|
60626
|
+
token = loaded2.tokens.accessToken;
|
|
60627
|
+
rememberSecret(loaded2.tokens.accessToken);
|
|
60628
|
+
rememberSecret(loaded2.tokens.refreshToken);
|
|
60629
|
+
canRefresh = loaded2.tokens.refreshToken !== void 0;
|
|
60630
|
+
if (loaded2.tokens.expiresAt !== void 0) {
|
|
60631
|
+
expiresAt = new Date(loaded2.tokens.expiresAt).toISOString();
|
|
60632
|
+
expired = deps.now() >= loaded2.tokens.expiresAt;
|
|
60534
60633
|
}
|
|
60535
60634
|
}
|
|
60536
60635
|
}
|
|
@@ -63250,12 +63349,12 @@ async function buildContext(deps, version2) {
|
|
|
63250
63349
|
token = fromEnv;
|
|
63251
63350
|
how = "environment";
|
|
63252
63351
|
} else {
|
|
63253
|
-
const
|
|
63254
|
-
if (
|
|
63255
|
-
token =
|
|
63256
|
-
how =
|
|
63257
|
-
rememberSecret(
|
|
63258
|
-
if (
|
|
63352
|
+
const loaded2 = await loadTokens(deps, storeKey).catch(() => null);
|
|
63353
|
+
if (loaded2 !== null) {
|
|
63354
|
+
token = loaded2.tokens.accessToken;
|
|
63355
|
+
how = loaded2.store;
|
|
63356
|
+
rememberSecret(loaded2.tokens.refreshToken);
|
|
63357
|
+
if (loaded2.tokens.expiresAt !== void 0) expired = deps.now() >= loaded2.tokens.expiresAt;
|
|
63259
63358
|
}
|
|
63260
63359
|
}
|
|
63261
63360
|
rememberSecret(token);
|
|
@@ -63642,7 +63741,7 @@ async function post(deps, base5, path, body2) {
|
|
|
63642
63741
|
return { status: response.status, json: json2 };
|
|
63643
63742
|
}
|
|
63644
63743
|
function sleep(ms) {
|
|
63645
|
-
return new Promise((
|
|
63744
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
63646
63745
|
}
|
|
63647
63746
|
async function deviceLogin(deps, service, options) {
|
|
63648
63747
|
const started = await post(deps, service, "/auth/device", {});
|
|
@@ -63800,14 +63899,14 @@ var authLogoutCommand = defineCommand({
|
|
|
63800
63899
|
);
|
|
63801
63900
|
}
|
|
63802
63901
|
const tokenEnvSet = (inv.deps.env["HARNESS_TOKEN"] ?? "") !== "";
|
|
63803
|
-
const
|
|
63902
|
+
const loaded2 = await loadTokens(inv.deps, target2.storeKey).catch(() => null);
|
|
63804
63903
|
let revoked = "not_needed";
|
|
63805
|
-
if (
|
|
63806
|
-
rememberSecret(
|
|
63904
|
+
if (loaded2 !== null && loaded2.tokens.accessToken.startsWith(SERVER_TOKEN_PREFIX)) {
|
|
63905
|
+
rememberSecret(loaded2.tokens.accessToken);
|
|
63807
63906
|
try {
|
|
63808
63907
|
const response = await inv.deps.fetch(`${target2.service}/v1/auth/logout`, {
|
|
63809
63908
|
method: "POST",
|
|
63810
|
-
headers: { authorization: `Bearer ${
|
|
63909
|
+
headers: { authorization: `Bearer ${loaded2.tokens.accessToken}`, accept: "application/json" },
|
|
63811
63910
|
signal: AbortSignal.timeout(LOGOUT_TIMEOUT_MS)
|
|
63812
63911
|
});
|
|
63813
63912
|
revoked = response.ok || response.status === 401 ? "server" : "unreachable";
|
|
@@ -63818,8 +63917,8 @@ var authLogoutCommand = defineCommand({
|
|
|
63818
63917
|
await deleteTokens(inv.deps, target2.storeKey);
|
|
63819
63918
|
if (revoked === "unreachable") warn(inv.deps, "The service could not be reached, so the session may stay valid there until it expires.");
|
|
63820
63919
|
if (tokenEnvSet) warn(inv.deps, "HARNESS_TOKEN is still set in this environment.");
|
|
63821
|
-
say(inv.deps,
|
|
63822
|
-
return { data: { signedOut:
|
|
63920
|
+
say(inv.deps, loaded2 === null ? "Nothing was stored; you were not signed in from this machine." : "Signed out.");
|
|
63921
|
+
return { data: { signedOut: loaded2 !== null, revoked, service: target2.service, tokenEnvSet, next: "overlane auth login" } };
|
|
63823
63922
|
}
|
|
63824
63923
|
});
|
|
63825
63924
|
var authTokenCommand = defineCommand({
|
|
@@ -67124,12 +67223,12 @@ init_zod();
|
|
|
67124
67223
|
init_src();
|
|
67125
67224
|
import { existsSync as existsSync5, lstatSync as lstatSync2, mkdirSync as mkdirSync8, readFileSync as readFileSync12, renameSync as renameSync5, writeFileSync as writeFileSync7 } from "node:fs";
|
|
67126
67225
|
import { dirname as dirname8, join as join21 } from "node:path";
|
|
67127
|
-
function readIfRegular(root,
|
|
67128
|
-
const full = join21(root,
|
|
67226
|
+
function readIfRegular(root, relative6, unsafe) {
|
|
67227
|
+
const full = join21(root, relative6);
|
|
67129
67228
|
if (!existsSync5(full) && !isLink(full)) return null;
|
|
67130
67229
|
const stat = lstatSync2(full);
|
|
67131
67230
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
67132
|
-
unsafe.push(
|
|
67231
|
+
unsafe.push(relative6);
|
|
67133
67232
|
return null;
|
|
67134
67233
|
}
|
|
67135
67234
|
return readFileSync12(full, "utf8");
|
|
@@ -71441,6 +71540,1420 @@ var observeCommands = [
|
|
|
71441
71540
|
observeRetentionPurgeCommand
|
|
71442
71541
|
];
|
|
71443
71542
|
|
|
71543
|
+
// ../cli/src/commands/code.ts
|
|
71544
|
+
init_src();
|
|
71545
|
+
init_zod();
|
|
71546
|
+
|
|
71547
|
+
// ../cli/src/token/brief.ts
|
|
71548
|
+
import { existsSync as existsSync9, readFileSync as readFileSync15 } from "node:fs";
|
|
71549
|
+
import { join as join26 } from "node:path";
|
|
71550
|
+
|
|
71551
|
+
// ../cli/src/token/ctx.ts
|
|
71552
|
+
import { execFile } from "node:child_process";
|
|
71553
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
71554
|
+
import { dirname as dirname10, join as join25, relative as relative2, resolve as resolve14 } from "node:path";
|
|
71555
|
+
var CoreError = class extends Error {
|
|
71556
|
+
exit;
|
|
71557
|
+
hint;
|
|
71558
|
+
code;
|
|
71559
|
+
constructor(message, options = {}) {
|
|
71560
|
+
super(message);
|
|
71561
|
+
this.exit = options.exit ?? 1;
|
|
71562
|
+
this.hint = options.hint;
|
|
71563
|
+
this.code = options.code ?? "failure";
|
|
71564
|
+
}
|
|
71565
|
+
};
|
|
71566
|
+
function nodeCtx(cwd, env = process.env, now = Date.now) {
|
|
71567
|
+
return {
|
|
71568
|
+
cwd,
|
|
71569
|
+
env,
|
|
71570
|
+
now,
|
|
71571
|
+
git: (args2, dir) => new Promise((done) => {
|
|
71572
|
+
execFile("git", [...args2], { cwd: dir ?? cwd, encoding: "utf8", maxBuffer: 64 * 1024 * 1024, env: { ...env } }, (error62, stdout, stderr) => {
|
|
71573
|
+
if (error62 === null) done({ code: 0, stdout, stderr });
|
|
71574
|
+
else done({ code: typeof error62.code === "number" ? error62.code : 127, stdout: stdout ?? "", stderr: stderr ?? error62.message });
|
|
71575
|
+
});
|
|
71576
|
+
})
|
|
71577
|
+
};
|
|
71578
|
+
}
|
|
71579
|
+
function findRoot(cwd) {
|
|
71580
|
+
let dir = resolve14(cwd);
|
|
71581
|
+
for (; ; ) {
|
|
71582
|
+
if (existsSync8(join25(dir, ".git")) || existsSync8(join25(dir, ".harness"))) return dir;
|
|
71583
|
+
const up = dirname10(dir);
|
|
71584
|
+
if (up === dir) return resolve14(cwd);
|
|
71585
|
+
dir = up;
|
|
71586
|
+
}
|
|
71587
|
+
}
|
|
71588
|
+
function shortPath(cwd, path) {
|
|
71589
|
+
const rel = relative2(cwd, path);
|
|
71590
|
+
return rel === "" || rel.startsWith("..") ? path : rel;
|
|
71591
|
+
}
|
|
71592
|
+
var sha7 = (sha) => sha.slice(0, 7);
|
|
71593
|
+
function clip(text, max) {
|
|
71594
|
+
const one = text.replace(/\s+/g, " ").trim();
|
|
71595
|
+
return one.length <= max ? one : `${one.slice(0, max - 1)}\u2026`;
|
|
71596
|
+
}
|
|
71597
|
+
|
|
71598
|
+
// ../cli/src/token/brief.ts
|
|
71599
|
+
var MAX_TASKS = 15;
|
|
71600
|
+
function parseGitBrief(status, subject) {
|
|
71601
|
+
let sha = "";
|
|
71602
|
+
let branch = "";
|
|
71603
|
+
let upstream = null;
|
|
71604
|
+
let ahead = 0;
|
|
71605
|
+
let behind = 0;
|
|
71606
|
+
let dirty2 = 0;
|
|
71607
|
+
for (const line3 of status.split("\n")) {
|
|
71608
|
+
if (line3.startsWith("# branch.oid ")) sha = line3.slice(13).trim();
|
|
71609
|
+
else if (line3.startsWith("# branch.head ")) branch = line3.slice(14).trim();
|
|
71610
|
+
else if (line3.startsWith("# branch.upstream ")) upstream = line3.slice(18).trim();
|
|
71611
|
+
else if (line3.startsWith("# branch.ab ")) {
|
|
71612
|
+
const m = line3.match(/\+(\d+) -(\d+)/);
|
|
71613
|
+
ahead = Number(m?.[1] ?? 0);
|
|
71614
|
+
behind = Number(m?.[2] ?? 0);
|
|
71615
|
+
} else if (line3 !== "" && !line3.startsWith("#")) dirty2 += 1;
|
|
71616
|
+
}
|
|
71617
|
+
if (sha === "") return null;
|
|
71618
|
+
return { branch: branch === "(detached)" ? "detached" : branch, sha: sha === "(initial)" ? "initial" : sha7(sha), upstream, ahead, behind, dirty: dirty2, subject: clip(subject, 100) };
|
|
71619
|
+
}
|
|
71620
|
+
function formatGitBrief(b) {
|
|
71621
|
+
const where2 = b.upstream === null ? "no upstream" : `ahead ${b.ahead} behind ${b.behind} of ${b.upstream}`;
|
|
71622
|
+
return `${b.branch} ${b.sha} ${where2}, ${b.dirty} dirty, last: ${b.subject === "" ? "(no commits)" : b.subject}`;
|
|
71623
|
+
}
|
|
71624
|
+
function openP0Lines(text) {
|
|
71625
|
+
return text.split("\n").filter((line3) => /^\s*- \[ \]\s+P0\b/.test(line3)).map((line3) => clip(line3.trim(), 160));
|
|
71626
|
+
}
|
|
71627
|
+
async function brief(ctx, input2) {
|
|
71628
|
+
const mode = input2.mode ?? "all";
|
|
71629
|
+
const root = findRoot(ctx.cwd);
|
|
71630
|
+
const data = {};
|
|
71631
|
+
const lines = [];
|
|
71632
|
+
if (mode === "git" || mode === "all") {
|
|
71633
|
+
const [status, log] = await Promise.all([ctx.git(["status", "--porcelain=v2", "--branch"], ctx.cwd), ctx.git(["log", "-1", "--format=%s"], ctx.cwd)]);
|
|
71634
|
+
const parsed = status.code === 0 ? parseGitBrief(status.stdout, log.code === 0 ? log.stdout.trim() : "") : null;
|
|
71635
|
+
data.git = parsed;
|
|
71636
|
+
lines.push(parsed === null ? "not a git repository" : formatGitBrief(parsed));
|
|
71637
|
+
}
|
|
71638
|
+
if (mode === "tasks" || mode === "all") {
|
|
71639
|
+
const file2 = join26(root, "TASKS.md");
|
|
71640
|
+
if (existsSync9(file2)) {
|
|
71641
|
+
const open2 = openP0Lines(readFileSync15(file2, "utf8"));
|
|
71642
|
+
data.tasks = { source: "TASKS.md", open: open2.slice(0, MAX_TASKS), more: Math.max(0, open2.length - MAX_TASKS) };
|
|
71643
|
+
lines.push(...open2.length === 0 ? ["no open P0 lines in TASKS.md"] : [`${open2.length} open P0:`, ...data.tasks.open], ...data.tasks.more > 0 ? [`+${data.tasks.more} more in TASKS.md`] : []);
|
|
71644
|
+
} else {
|
|
71645
|
+
data.tasks = { source: "none", open: [], more: 0 };
|
|
71646
|
+
lines.push("no TASKS.md here; for a connected project run: overlane task status");
|
|
71647
|
+
}
|
|
71648
|
+
}
|
|
71649
|
+
return { data, lines, exit: 0 };
|
|
71650
|
+
}
|
|
71651
|
+
|
|
71652
|
+
// ../cli/src/token/code.ts
|
|
71653
|
+
import { existsSync as existsSync11, readFileSync as readFileSync17, statSync as statSync2 } from "node:fs";
|
|
71654
|
+
import { join as join28, relative as relative3, resolve as resolve15 } from "node:path";
|
|
71655
|
+
|
|
71656
|
+
// ../cli/src/token/index-file.ts
|
|
71657
|
+
import { existsSync as existsSync10, readFileSync as readFileSync16 } from "node:fs";
|
|
71658
|
+
import { join as join27 } from "node:path";
|
|
71659
|
+
var INDEX_PATH = ".harness/code-index.json";
|
|
71660
|
+
var BUILD_INDEX_COMMAND = "node packages/index-builder/dist/mvrx-index.mjs map --root .";
|
|
71661
|
+
var LoadedIndex = class {
|
|
71662
|
+
constructor(sha, fileCount, uncovered, builtAt, rows, edges) {
|
|
71663
|
+
this.sha = sha;
|
|
71664
|
+
this.fileCount = fileCount;
|
|
71665
|
+
this.uncovered = uncovered;
|
|
71666
|
+
this.builtAt = builtAt;
|
|
71667
|
+
this.rows = rows;
|
|
71668
|
+
this.edges = edges;
|
|
71669
|
+
}
|
|
71670
|
+
sha;
|
|
71671
|
+
fileCount;
|
|
71672
|
+
uncovered;
|
|
71673
|
+
builtAt;
|
|
71674
|
+
rows;
|
|
71675
|
+
edges;
|
|
71676
|
+
cache = /* @__PURE__ */ new Map();
|
|
71677
|
+
files = /* @__PURE__ */ new Map();
|
|
71678
|
+
callerMap;
|
|
71679
|
+
get count() {
|
|
71680
|
+
return this.rows.length;
|
|
71681
|
+
}
|
|
71682
|
+
/** The symbol at a position (call edges and parents refer to positions). */
|
|
71683
|
+
symbol(i2) {
|
|
71684
|
+
const hit = this.cache.get(i2);
|
|
71685
|
+
if (hit !== void 0) return hit;
|
|
71686
|
+
const r = this.rows[i2];
|
|
71687
|
+
if (r === void 0) return void 0;
|
|
71688
|
+
const symbol2 = { i: i2, name: r[0], qualified: r[1], kind: r[2], path: r[3], line: r[4], parent: typeof r[5] === "number" ? r[5] : -1 };
|
|
71689
|
+
this.cache.set(i2, symbol2);
|
|
71690
|
+
return symbol2;
|
|
71691
|
+
}
|
|
71692
|
+
/** Every symbol whose row passes the test, in index order. */
|
|
71693
|
+
where(test) {
|
|
71694
|
+
const out2 = [];
|
|
71695
|
+
for (let i2 = 0; i2 < this.rows.length; i2 += 1) {
|
|
71696
|
+
const r = this.rows[i2];
|
|
71697
|
+
if (test(r[0], r[1], r)) out2.push(this.symbol(i2));
|
|
71698
|
+
}
|
|
71699
|
+
return out2;
|
|
71700
|
+
}
|
|
71701
|
+
named(name2) {
|
|
71702
|
+
return this.where((n) => n === name2);
|
|
71703
|
+
}
|
|
71704
|
+
/** Symbols of one file, sorted by line. */
|
|
71705
|
+
inFile(path) {
|
|
71706
|
+
let list2 = this.files.get(path);
|
|
71707
|
+
if (list2 === void 0) {
|
|
71708
|
+
list2 = this.where((_n, _q, r) => r[3] === path).sort((a, b) => a.line - b.line || a.i - b.i);
|
|
71709
|
+
this.files.set(path, list2);
|
|
71710
|
+
}
|
|
71711
|
+
return list2;
|
|
71712
|
+
}
|
|
71713
|
+
/** Positions of the symbols that call the one at `i`. */
|
|
71714
|
+
callersOf(i2) {
|
|
71715
|
+
if (this.callerMap === void 0) {
|
|
71716
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
71717
|
+
for (const edge of this.edges) {
|
|
71718
|
+
const [from, ...to] = edge;
|
|
71719
|
+
if (from === void 0) continue;
|
|
71720
|
+
for (const target2 of to) {
|
|
71721
|
+
const list2 = map2.get(target2);
|
|
71722
|
+
if (list2 === void 0) map2.set(target2, [from]);
|
|
71723
|
+
else list2.push(from);
|
|
71724
|
+
}
|
|
71725
|
+
}
|
|
71726
|
+
this.callerMap = map2;
|
|
71727
|
+
}
|
|
71728
|
+
return this.callerMap.get(i2) ?? [];
|
|
71729
|
+
}
|
|
71730
|
+
};
|
|
71731
|
+
function parseIndex(text) {
|
|
71732
|
+
let raw;
|
|
71733
|
+
try {
|
|
71734
|
+
const cut = text.lastIndexOf(',"words":[');
|
|
71735
|
+
raw = JSON.parse(cut > 0 ? `${text.slice(0, cut)}}}` : text);
|
|
71736
|
+
} catch {
|
|
71737
|
+
try {
|
|
71738
|
+
raw = JSON.parse(text);
|
|
71739
|
+
} catch {
|
|
71740
|
+
return null;
|
|
71741
|
+
}
|
|
71742
|
+
}
|
|
71743
|
+
const rows = raw.index?.symbols;
|
|
71744
|
+
const sha = raw.revision?.commitSha;
|
|
71745
|
+
if (raw.schemaVersion !== "1" || !Array.isArray(rows) || typeof sha !== "string") return null;
|
|
71746
|
+
return new LoadedIndex(sha, raw.index?.files ?? 0, raw.uncovered ?? 0, raw.builtAt ?? "", rows, raw.index?.callees ?? []);
|
|
71747
|
+
}
|
|
71748
|
+
var loaded = /* @__PURE__ */ new WeakMap();
|
|
71749
|
+
function loadFreshIndex(ctx, root) {
|
|
71750
|
+
let pending = loaded.get(ctx);
|
|
71751
|
+
if (pending === void 0) {
|
|
71752
|
+
pending = loadFreshIndexUncached(ctx, root);
|
|
71753
|
+
loaded.set(ctx, pending);
|
|
71754
|
+
}
|
|
71755
|
+
return pending;
|
|
71756
|
+
}
|
|
71757
|
+
async function loadFreshIndexUncached(ctx, root) {
|
|
71758
|
+
const file2 = join27(root, INDEX_PATH);
|
|
71759
|
+
if (!existsSync10(file2)) return { state: "missing" };
|
|
71760
|
+
let text;
|
|
71761
|
+
try {
|
|
71762
|
+
text = readFileSync16(file2, "utf8");
|
|
71763
|
+
} catch {
|
|
71764
|
+
return { state: "missing" };
|
|
71765
|
+
}
|
|
71766
|
+
const index = parseIndex(text);
|
|
71767
|
+
if (index === null) return { state: "unusable", reason: "the index file is not a version 1 code index" };
|
|
71768
|
+
const [diff, untracked, head, count] = await Promise.all([
|
|
71769
|
+
ctx.git(["diff", "--name-only", index.sha], root),
|
|
71770
|
+
ctx.git(["ls-files", "--others", "--exclude-standard"], root),
|
|
71771
|
+
ctx.git(["rev-parse", "HEAD"], root),
|
|
71772
|
+
ctx.git(["rev-list", "--count", `${index.sha}..HEAD`], root)
|
|
71773
|
+
]);
|
|
71774
|
+
if (diff.code !== 0) return { state: "unusable", reason: `the index was built at ${index.sha.slice(0, 7)}, which this checkout does not have` };
|
|
71775
|
+
const changed = new Set([...diff.stdout.split("\n"), ...untracked.code === 0 ? untracked.stdout.split("\n") : []].filter((p2) => p2 !== "" && !p2.startsWith(".harness/")));
|
|
71776
|
+
return { state: "ready", index, headSha: head.code === 0 ? head.stdout.trim() : "", behind: count.code === 0 ? Number.parseInt(count.stdout.trim(), 10) || 0 : 0, changed };
|
|
71777
|
+
}
|
|
71778
|
+
|
|
71779
|
+
// ../cli/src/token/span.ts
|
|
71780
|
+
function nextSiblingLine(index, symbol2) {
|
|
71781
|
+
const list2 = index.inFile(symbol2.path);
|
|
71782
|
+
const inside = (candidate) => {
|
|
71783
|
+
let parent = candidate.parent;
|
|
71784
|
+
for (let hops = 0; parent >= 0 && hops < 64; hops += 1) {
|
|
71785
|
+
if (parent === symbol2.i) return true;
|
|
71786
|
+
parent = index.symbol(parent)?.parent ?? -1;
|
|
71787
|
+
}
|
|
71788
|
+
return false;
|
|
71789
|
+
};
|
|
71790
|
+
for (const candidate of list2) if (candidate.line > symbol2.line && !inside(candidate)) return candidate.line;
|
|
71791
|
+
return void 0;
|
|
71792
|
+
}
|
|
71793
|
+
var COMMENT_LINE = /^\s*(?:\/\/|\/\*|\*|#(?!\[)|--\s|"""|''')/;
|
|
71794
|
+
function trimBefore(lines, start2, nextStart) {
|
|
71795
|
+
let end = nextStart === void 0 ? lines.length : Math.min(nextStart - 1, lines.length);
|
|
71796
|
+
while (end > start2 && (lines[end - 1] ?? "").trim() === "") end -= 1;
|
|
71797
|
+
if (nextStart !== void 0) {
|
|
71798
|
+
let probe = end;
|
|
71799
|
+
while (probe > start2 && COMMENT_LINE.test(lines[probe - 1] ?? "")) probe -= 1;
|
|
71800
|
+
if (probe < end) end = probe;
|
|
71801
|
+
while (end > start2 && (lines[end - 1] ?? "").trim() === "") end -= 1;
|
|
71802
|
+
}
|
|
71803
|
+
return Math.max(start2, end);
|
|
71804
|
+
}
|
|
71805
|
+
var OPEN = /* @__PURE__ */ new Set(["{", "(", "["]);
|
|
71806
|
+
var CLOSE = /* @__PURE__ */ new Set(["}", ")", "]"]);
|
|
71807
|
+
function braceEnd(lines, start2, limit = lines.length) {
|
|
71808
|
+
let depth = 0;
|
|
71809
|
+
let opened = false;
|
|
71810
|
+
let block2 = false;
|
|
71811
|
+
let quote4 = "";
|
|
71812
|
+
const stop3 = Math.min(limit, lines.length);
|
|
71813
|
+
for (let n = start2; n <= stop3; n += 1) {
|
|
71814
|
+
const text = lines[n - 1] ?? "";
|
|
71815
|
+
let lastCode = "";
|
|
71816
|
+
for (let i2 = 0; i2 < text.length; i2 += 1) {
|
|
71817
|
+
const c2 = text[i2];
|
|
71818
|
+
const two = text.slice(i2, i2 + 2);
|
|
71819
|
+
if (block2) {
|
|
71820
|
+
if (two === "*/") {
|
|
71821
|
+
block2 = false;
|
|
71822
|
+
i2 += 1;
|
|
71823
|
+
}
|
|
71824
|
+
continue;
|
|
71825
|
+
}
|
|
71826
|
+
if (quote4 !== "") {
|
|
71827
|
+
if (c2 === "\\") i2 += 1;
|
|
71828
|
+
else if (c2 === quote4) quote4 = "";
|
|
71829
|
+
continue;
|
|
71830
|
+
}
|
|
71831
|
+
if (two === "//") break;
|
|
71832
|
+
if (two === "/*") {
|
|
71833
|
+
block2 = true;
|
|
71834
|
+
i2 += 1;
|
|
71835
|
+
continue;
|
|
71836
|
+
}
|
|
71837
|
+
if (c2 === '"' || c2 === "'" || c2 === "`") {
|
|
71838
|
+
quote4 = c2;
|
|
71839
|
+
lastCode = c2;
|
|
71840
|
+
continue;
|
|
71841
|
+
}
|
|
71842
|
+
if (OPEN.has(c2)) {
|
|
71843
|
+
depth += 1;
|
|
71844
|
+
opened = true;
|
|
71845
|
+
} else if (CLOSE.has(c2)) depth -= 1;
|
|
71846
|
+
if (c2.trim() !== "") lastCode = c2;
|
|
71847
|
+
}
|
|
71848
|
+
if (quote4 === '"' || quote4 === "'") quote4 = "";
|
|
71849
|
+
if (depth <= 0 && quote4 === "" && !block2) {
|
|
71850
|
+
const t2 = text.trim();
|
|
71851
|
+
if (opened || depth < 0) return n;
|
|
71852
|
+
if (t2 !== "" && !/[=,(&|?:+\-*/<>]$/.test(t2) && lastCode !== "" && !/^\s*(?:@|\/\/)/.test(text)) {
|
|
71853
|
+
const nextText = (lines[n] ?? "").trim();
|
|
71854
|
+
if (!/^[|&?:.]/.test(nextText) && !/^extends\b|^implements\b/.test(nextText)) return n;
|
|
71855
|
+
}
|
|
71856
|
+
}
|
|
71857
|
+
}
|
|
71858
|
+
return null;
|
|
71859
|
+
}
|
|
71860
|
+
function indentEnd(lines, start2) {
|
|
71861
|
+
const base5 = (lines[start2 - 1] ?? "").match(/^\s*/)?.[0].length ?? 0;
|
|
71862
|
+
let end = start2;
|
|
71863
|
+
for (let n = start2 + 1; n <= lines.length; n += 1) {
|
|
71864
|
+
const text = lines[n - 1] ?? "";
|
|
71865
|
+
if (text.trim() === "") continue;
|
|
71866
|
+
const indent = text.match(/^\s*/)?.[0].length ?? 0;
|
|
71867
|
+
if (indent <= base5 && !/^\s*[)\]}]/.test(text)) break;
|
|
71868
|
+
end = n;
|
|
71869
|
+
}
|
|
71870
|
+
return end;
|
|
71871
|
+
}
|
|
71872
|
+
function spanEnd(lines, start2, path, nextStart) {
|
|
71873
|
+
const upper = trimBefore(lines, start2, nextStart);
|
|
71874
|
+
const scanned = /\.(?:py|rb)$/.test(path) ? indentEnd(lines, start2) : braceEnd(lines, start2, nextStart === void 0 ? lines.length : Math.max(start2, nextStart - 1));
|
|
71875
|
+
return scanned !== null && scanned <= upper ? scanned : upper;
|
|
71876
|
+
}
|
|
71877
|
+
|
|
71878
|
+
// ../cli/src/token/code.ts
|
|
71879
|
+
var DEFAULT_FIND_LIMIT = 20;
|
|
71880
|
+
var DEFAULT_REFS_LIMIT = 30;
|
|
71881
|
+
var SHOW_CAP = 200;
|
|
71882
|
+
var GREP_LIMIT = 20;
|
|
71883
|
+
var SOURCE_FILE = /\.(?:[cm]?[jt]sx?|py|go|rs|java|rb|php|cs|kt|swift|astro|vue|svelte)$/;
|
|
71884
|
+
var DEF_WORDS = "function\\*?|class|interface|type|enum|const|let|var|def|fn|func|struct|trait|namespace|abstract class";
|
|
71885
|
+
var KIND_RANK = { function: 0, class: 1, interface: 2, type: 3, constant: 4, method: 5, variable: 6, namespace: 7, property: 9 };
|
|
71886
|
+
var GREP_EXCLUDES = [":(exclude)pnpm-lock.yaml", ":(exclude)*.lock", ":(exclude)evals/results"];
|
|
71887
|
+
var escapeRegex2 = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
71888
|
+
var isTestPath = (path) => /(?:^|\/)(?:tests?|__tests__|fixtures)\/|\.(?:test|spec)\.[a-z]+$/.test(path);
|
|
71889
|
+
function readLines(root, path) {
|
|
71890
|
+
try {
|
|
71891
|
+
const file2 = join28(root, path);
|
|
71892
|
+
if (statSync2(file2).size > 4 * 1024 * 1024) return null;
|
|
71893
|
+
return readFileSync17(file2, "utf8").split("\n");
|
|
71894
|
+
} catch {
|
|
71895
|
+
return null;
|
|
71896
|
+
}
|
|
71897
|
+
}
|
|
71898
|
+
function hitOf(symbol2) {
|
|
71899
|
+
return { kind: symbol2.kind, qualified: symbol2.qualified, path: symbol2.path, line: symbol2.line };
|
|
71900
|
+
}
|
|
71901
|
+
function rankHit(a, b) {
|
|
71902
|
+
return (KIND_RANK[a.kind] ?? 8) - (KIND_RANK[b.kind] ?? 8) || Number(isTestPath(a.path)) - Number(isTestPath(b.path)) || a.path.length - b.path.length || a.path.localeCompare(b.path) || a.line - b.line;
|
|
71903
|
+
}
|
|
71904
|
+
async function gitGrep(ctx, root, pattern, limit, extra = []) {
|
|
71905
|
+
const result = await ctx.git(["grep", "-n", "-w", "-I", "-F", "--no-color", ...extra, "-e", pattern, "--", ".", ...GREP_EXCLUDES], root);
|
|
71906
|
+
if (result.code > 1) return { hits: [], more: false, failed: true };
|
|
71907
|
+
const hits = [];
|
|
71908
|
+
let more = false;
|
|
71909
|
+
for (const raw of result.stdout.split("\n")) {
|
|
71910
|
+
const m = raw.match(/^(.*?):(\d+):(.*)$/);
|
|
71911
|
+
if (m === null) continue;
|
|
71912
|
+
if (hits.length >= limit) {
|
|
71913
|
+
more = true;
|
|
71914
|
+
break;
|
|
71915
|
+
}
|
|
71916
|
+
hits.push({ path: m[1], line: Number(m[2]), text: clip(m[3], 110) });
|
|
71917
|
+
}
|
|
71918
|
+
return { hits, more, failed: false };
|
|
71919
|
+
}
|
|
71920
|
+
function definitionRegex(name2) {
|
|
71921
|
+
const n = escapeRegex2(name2);
|
|
71922
|
+
return new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?(?:${DEF_WORDS})\\s+${n}(?![A-Za-z0-9_$])`);
|
|
71923
|
+
}
|
|
71924
|
+
var KIND_OF_WORD = { function: "function", class: "class", interface: "interface", type: "type", enum: "type", const: "constant", let: "variable", var: "variable", def: "function", fn: "function", func: "function", struct: "class", trait: "interface", namespace: "namespace" };
|
|
71925
|
+
function scanForDefinitions(root, files, name2) {
|
|
71926
|
+
const regex = definitionRegex(name2);
|
|
71927
|
+
const hits = [];
|
|
71928
|
+
for (const path of files) {
|
|
71929
|
+
if (!SOURCE_FILE.test(path)) continue;
|
|
71930
|
+
const lines = readLines(root, path);
|
|
71931
|
+
if (lines === null) continue;
|
|
71932
|
+
lines.forEach((text, i2) => {
|
|
71933
|
+
const m = text.match(regex);
|
|
71934
|
+
if (m === null) return;
|
|
71935
|
+
const word = (text.match(new RegExp(`(?:${DEF_WORDS})(?=\\s+${escapeRegex2(name2)})`))?.[0] ?? "const").replace("abstract ", "").replace("*", "");
|
|
71936
|
+
hits.push({ kind: KIND_OF_WORD[word] ?? "constant", qualified: name2, path, line: i2 + 1 });
|
|
71937
|
+
});
|
|
71938
|
+
}
|
|
71939
|
+
return hits;
|
|
71940
|
+
}
|
|
71941
|
+
function indexProblem(fresh) {
|
|
71942
|
+
if (fresh.state === "missing") return `no code index at .harness/code-index.json; build it with: ${BUILD_INDEX_COMMAND}`;
|
|
71943
|
+
if (fresh.state === "unusable") return `code index unusable (${fresh.reason}); rebuild with: ${BUILD_INDEX_COMMAND}`;
|
|
71944
|
+
return "";
|
|
71945
|
+
}
|
|
71946
|
+
function staleNote(fresh, scanned) {
|
|
71947
|
+
return `index ${sha7(fresh.index.sha)} is ${fresh.behind} commit${fresh.behind === 1 ? "" : "s"} behind HEAD; ${scanned} changed file${scanned === 1 ? "" : "s"} matched by pattern, not index`;
|
|
71948
|
+
}
|
|
71949
|
+
function matchName(index, name2) {
|
|
71950
|
+
const exactSet = name2.includes(".") ? index.where((_n, q) => q === name2 || q.endsWith(`.${name2}`)) : index.named(name2);
|
|
71951
|
+
if (exactSet.length > 0) return { exact: exactSet, near: [] };
|
|
71952
|
+
const lower = name2.toLowerCase();
|
|
71953
|
+
const ci = index.where((n, q) => n.toLowerCase() === lower || q.toLowerCase() === lower);
|
|
71954
|
+
if (ci.length > 0) return { exact: ci, near: [] };
|
|
71955
|
+
const near = lower.length >= 3 ? index.where((n) => n.toLowerCase().includes(lower)) : [];
|
|
71956
|
+
return { exact: [], near };
|
|
71957
|
+
}
|
|
71958
|
+
async function definitionsOf(ctx, root, name2, kind) {
|
|
71959
|
+
const fresh = await loadFreshIndex(ctx, root);
|
|
71960
|
+
if (fresh.state !== "ready") return { hits: [], symbols: [], fresh, notes: [indexProblem(fresh)], approximate: false };
|
|
71961
|
+
const { index, changed } = fresh;
|
|
71962
|
+
const { exact, near } = matchName(index, name2);
|
|
71963
|
+
const chosen = (exact.length > 0 ? exact : near).filter((s) => kind === void 0 || s.kind === kind);
|
|
71964
|
+
const trusted = chosen.filter((s) => !changed.has(s.path));
|
|
71965
|
+
const dropped = chosen.length - trusted.length;
|
|
71966
|
+
const changedList = [...changed].slice(0, 400);
|
|
71967
|
+
const scanned = changedList.length > 0 ? scanForDefinitions(root, changedList, name2).filter((h) => kind === void 0 || h.kind === kind) : [];
|
|
71968
|
+
const notes = [];
|
|
71969
|
+
if (dropped > 0 || scanned.length > 0) notes.push(staleNote(fresh, (/* @__PURE__ */ new Set([...scanned.map((h) => h.path), ...chosen.filter((s) => changed.has(s.path)).map((s) => s.path)])).size));
|
|
71970
|
+
if (exact.length === 0 && near.length > 0 && trusted.length > 0) notes.push(`no exact match for ${name2}; ${trusted.length} near match${trusted.length === 1 ? "" : "es"}`);
|
|
71971
|
+
const hits = [...trusted.map(hitOf), ...scanned].sort(rankHit);
|
|
71972
|
+
return { hits, symbols: trusted, fresh, notes, approximate: exact.length === 0 };
|
|
71973
|
+
}
|
|
71974
|
+
async function findCore(ctx, input2) {
|
|
71975
|
+
const root = findRoot(ctx.cwd);
|
|
71976
|
+
const limit = Math.max(1, input2.limit ?? DEFAULT_FIND_LIMIT);
|
|
71977
|
+
const defs = await definitionsOf(ctx, root, input2.name, input2.kind);
|
|
71978
|
+
if (defs.fresh.state !== "ready") {
|
|
71979
|
+
const grep = await gitGrep(ctx, root, input2.name, Math.min(limit, GREP_LIMIT));
|
|
71980
|
+
const notice2 = defs.notes[0] ?? "";
|
|
71981
|
+
const lines2 = [notice2, ...grep.hits.map((h) => `${h.path}:${h.line} ${h.text}`), ...grep.more ? [`more matches exist: narrow with overlane code find <name> --kind K or build the index`] : []];
|
|
71982
|
+
if (grep.hits.length === 0) return { data: { source: "search", matches: [], lines: [], more: false, notice: notice2 }, lines: [notice2, `none: no literal match for ${input2.name}`], exit: 4 };
|
|
71983
|
+
return { data: { source: "search", matches: [], lines: grep.hits, more: grep.more, notice: notice2 }, lines: lines2, exit: 0 };
|
|
71984
|
+
}
|
|
71985
|
+
const matches = defs.hits.slice(0, limit);
|
|
71986
|
+
const more = defs.hits.length > limit;
|
|
71987
|
+
const notice = defs.notes.join("; ");
|
|
71988
|
+
if (defs.hits.length === 0) {
|
|
71989
|
+
const grep = await gitGrep(ctx, root, input2.name, 5);
|
|
71990
|
+
const tail = grep.hits.length === 0 ? [] : [`no definition in the index; literal matches:`, ...grep.hits.map((h) => `${h.path}:${h.line} ${h.text}`)];
|
|
71991
|
+
return { data: { source: "index", matches: [], lines: grep.hits, more: false, notice }, lines: [...defs.notes, `none: no definition of ${input2.name}${input2.kind === void 0 ? "" : ` (kind ${input2.kind})`}`, ...tail], exit: 4 };
|
|
71992
|
+
}
|
|
71993
|
+
const lines = [...defs.notes, ...matches.map((h) => `${h.kind} ${h.qualified} ${h.path}:${h.line}`), ...more ? [`+${defs.hits.length - limit} more: overlane code find ${input2.name} --limit ${defs.hits.length}`] : []];
|
|
71994
|
+
return { data: { source: "index", matches, more, ...notice === "" ? {} : { notice } }, lines, exit: 0 };
|
|
71995
|
+
}
|
|
71996
|
+
var PATH_LINE = /^(.+):(\d+)$/;
|
|
71997
|
+
function numbered(lines, from, to) {
|
|
71998
|
+
const out2 = [];
|
|
71999
|
+
for (let n = from; n <= to; n += 1) out2.push(`${n} ${lines[n - 1] ?? ""}`);
|
|
72000
|
+
return out2;
|
|
72001
|
+
}
|
|
72002
|
+
function resolveFile(ctx, root, path) {
|
|
72003
|
+
for (const base5 of [root, ctx.cwd]) {
|
|
72004
|
+
const full = resolve15(base5, path);
|
|
72005
|
+
if (existsSync11(full) && statSync2(full).isFile()) return relative3(root, full);
|
|
72006
|
+
}
|
|
72007
|
+
return null;
|
|
72008
|
+
}
|
|
72009
|
+
function symbolAt(index, root, path, line3, lines) {
|
|
72010
|
+
const list2 = index.inFile(path).filter((s) => s.line <= line3);
|
|
72011
|
+
for (let k = list2.length - 1; k >= 0; k -= 1) {
|
|
72012
|
+
const symbol2 = list2[k];
|
|
72013
|
+
if (symbol2.kind === "property" && symbol2.line !== line3) continue;
|
|
72014
|
+
const end = spanEnd(lines, symbol2.line, path, nextSiblingLine(index, symbol2));
|
|
72015
|
+
if (end >= line3) return symbol2;
|
|
72016
|
+
}
|
|
72017
|
+
return void 0;
|
|
72018
|
+
}
|
|
72019
|
+
async function showCore(ctx, input2) {
|
|
72020
|
+
const root = findRoot(ctx.cwd);
|
|
72021
|
+
const context4 = Math.max(0, input2.context ?? 0);
|
|
72022
|
+
const cap = Math.max(1, input2.max ?? SHOW_CAP);
|
|
72023
|
+
let path;
|
|
72024
|
+
let start2 = 0;
|
|
72025
|
+
let kind = "text";
|
|
72026
|
+
let qualified = "";
|
|
72027
|
+
let also = [];
|
|
72028
|
+
const notes = [];
|
|
72029
|
+
let lines = null;
|
|
72030
|
+
let symbol2;
|
|
72031
|
+
let fresh;
|
|
72032
|
+
let nextStart;
|
|
72033
|
+
const pl = input2.target.match(PATH_LINE);
|
|
72034
|
+
const asFile = pl === null ? null : resolveFile(ctx, root, pl[1]);
|
|
72035
|
+
if (pl !== null && asFile !== null) {
|
|
72036
|
+
path = asFile;
|
|
72037
|
+
const wanted = Number(pl[2]);
|
|
72038
|
+
lines = readLines(root, path);
|
|
72039
|
+
if (lines === null) throw new CoreError(`cannot read ${path}`, { exit: 1 });
|
|
72040
|
+
if (wanted < 1 || wanted > lines.length) throw new CoreError(`${path} has ${lines.length} lines; ${wanted} is out of range`, { exit: 2, code: "usage" });
|
|
72041
|
+
fresh = await loadFreshIndex(ctx, root);
|
|
72042
|
+
if (fresh.state === "ready" && !fresh.changed.has(path)) {
|
|
72043
|
+
symbol2 = symbolAt(fresh.index, root, path, wanted, lines);
|
|
72044
|
+
if (symbol2 !== void 0) {
|
|
72045
|
+
start2 = symbol2.line;
|
|
72046
|
+
kind = symbol2.kind;
|
|
72047
|
+
qualified = symbol2.qualified;
|
|
72048
|
+
nextStart = nextSiblingLine(fresh.index, symbol2);
|
|
72049
|
+
}
|
|
72050
|
+
}
|
|
72051
|
+
if (symbol2 === void 0) {
|
|
72052
|
+
const found = enclosingDeclaration(lines, wanted, path);
|
|
72053
|
+
if (found !== void 0) {
|
|
72054
|
+
start2 = found.start;
|
|
72055
|
+
kind = found.kind;
|
|
72056
|
+
qualified = found.name;
|
|
72057
|
+
} else {
|
|
72058
|
+
notes.push(`no symbol at ${path}:${wanted}; showing lines around it`);
|
|
72059
|
+
start2 = Math.max(1, wanted - 10);
|
|
72060
|
+
const end2 = Math.min(lines.length, wanted + 10);
|
|
72061
|
+
return finishShow(path, "text", "", start2, end2, lines, context4, input2.from, cap, [], notes);
|
|
72062
|
+
}
|
|
72063
|
+
}
|
|
72064
|
+
} else {
|
|
72065
|
+
const defs = await definitionsOf(ctx, root, input2.target, input2.kind);
|
|
72066
|
+
fresh = defs.fresh;
|
|
72067
|
+
let hits = defs.hits;
|
|
72068
|
+
if (hits.length === 0 && defs.fresh.state !== "ready") {
|
|
72069
|
+
const grep = await ctx.git(["grep", "-n", "-I", "-E", "--no-color", "-e", `(${DEF_WORDS.replaceAll("\\*?", "")})[[:space:]]+${input2.target}([^A-Za-z0-9_$]|$)`, "--", ".", ...GREP_EXCLUDES], root);
|
|
72070
|
+
hits = grep.stdout.split("\n").map((raw) => raw.match(/^(.*?):(\d+):/)).filter((m) => m !== null).slice(0, 8).map((m) => ({ kind: "text", qualified: input2.target, path: m[1], line: Number(m[2]) })).sort(rankHit);
|
|
72071
|
+
notes.push(indexProblem(defs.fresh));
|
|
72072
|
+
} else notes.push(...defs.notes);
|
|
72073
|
+
const first = hits[0];
|
|
72074
|
+
if (first === void 0) return { data: { path: "", kind: "", qualified: input2.target, start: 0, end: 0, from: 0, to: 0, truncated: false, remaining: 0, text: [], also: [] }, lines: [...notes.filter((n) => n !== ""), `none: no definition of ${input2.target}`], exit: 4 };
|
|
72075
|
+
path = first.path;
|
|
72076
|
+
start2 = first.line;
|
|
72077
|
+
kind = first.kind;
|
|
72078
|
+
qualified = first.qualified;
|
|
72079
|
+
also = hits.slice(1, 5);
|
|
72080
|
+
lines = readLines(root, path);
|
|
72081
|
+
if (lines === null) throw new CoreError(`cannot read ${path}`, { exit: 1 });
|
|
72082
|
+
symbol2 = defs.symbols.find((s) => s.path === first.path && s.line === first.line);
|
|
72083
|
+
if (symbol2 !== void 0 && defs.fresh.state === "ready") nextStart = nextSiblingLine(defs.fresh.index, symbol2);
|
|
72084
|
+
}
|
|
72085
|
+
const end = spanEnd(lines, start2, path, nextStart);
|
|
72086
|
+
return finishShow(path, kind, qualified, start2, end, lines, context4, input2.from, cap, also, notes);
|
|
72087
|
+
}
|
|
72088
|
+
function enclosingDeclaration(lines, line3, path) {
|
|
72089
|
+
const any2 = new RegExp(`^\\s{0,2}(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?(${DEF_WORDS})\\s+([A-Za-z_$][\\w$]*)`);
|
|
72090
|
+
for (let n = line3; n >= 1 && line3 - n < 400; n -= 1) {
|
|
72091
|
+
const m = (lines[n - 1] ?? "").match(any2);
|
|
72092
|
+
if (m === null) continue;
|
|
72093
|
+
const end = spanEnd(lines, n, path, void 0);
|
|
72094
|
+
if (end >= line3) return { start: n, kind: KIND_OF_WORD[m[1].replace("*", "")] ?? "constant", name: m[2] };
|
|
72095
|
+
}
|
|
72096
|
+
return void 0;
|
|
72097
|
+
}
|
|
72098
|
+
function finishShow(path, kind, qualified, start2, end, lines, context4, fromOpt, cap, also, notes) {
|
|
72099
|
+
const first = Math.max(1, start2 - context4);
|
|
72100
|
+
const last = Math.min(lines.length, end + context4);
|
|
72101
|
+
const from = Math.min(Math.max(fromOpt ?? first, first), last);
|
|
72102
|
+
const to = Math.min(last, from + cap - 1);
|
|
72103
|
+
const remaining = last - to;
|
|
72104
|
+
const body2 = numbered(lines, from, to);
|
|
72105
|
+
const header = `${path}:${start2}-${end} ${kind}${qualified === "" ? "" : ` ${qualified}`}`;
|
|
72106
|
+
const hint = remaining > 0 ? [`... truncated, ${remaining} more lines: overlane code show ${path}:${start2} --from ${to + 1}`] : [];
|
|
72107
|
+
const alsoLine = also.length > 0 ? [`also: ${also.map((h) => `${h.path}:${h.line}`).join(" ")}`] : [];
|
|
72108
|
+
const noticeText = notes.filter((n) => n !== "").join("; ");
|
|
72109
|
+
return {
|
|
72110
|
+
data: { path, kind, qualified, start: start2, end, from, to, truncated: remaining > 0, remaining, text: body2, also, ...noticeText === "" ? {} : { notice: noticeText } },
|
|
72111
|
+
lines: [...notes.filter((n) => n !== ""), header, ...body2, ...hint, ...alsoLine],
|
|
72112
|
+
exit: 0
|
|
72113
|
+
};
|
|
72114
|
+
}
|
|
72115
|
+
async function outlineCore(ctx, input2) {
|
|
72116
|
+
const root = findRoot(ctx.cwd);
|
|
72117
|
+
const path = resolveFile(ctx, root, input2.path);
|
|
72118
|
+
if (path === null) return { data: { path: input2.path, source: "pattern", symbols: [] }, lines: [`none: no file ${input2.path}`], exit: 4 };
|
|
72119
|
+
const fresh = await loadFreshIndex(ctx, root);
|
|
72120
|
+
let symbols2 = [];
|
|
72121
|
+
let source = "pattern";
|
|
72122
|
+
let notice = "";
|
|
72123
|
+
if (fresh.state === "ready" && !fresh.changed.has(path) && fresh.index.inFile(path).length > 0) {
|
|
72124
|
+
source = "index";
|
|
72125
|
+
symbols2 = fresh.index.inFile(path).filter((s) => input2.all === true || s.kind !== "property").map((s) => ({ line: s.line, kind: s.kind, name: s.qualified }));
|
|
72126
|
+
} else {
|
|
72127
|
+
notice = fresh.state === "ready" ? fresh.changed.has(path) ? `${path} changed since index ${sha7(fresh.index.sha)}; outline by pattern` : `${path} is not in the index; outline by pattern` : indexProblem(fresh);
|
|
72128
|
+
const lines = readLines(root, path) ?? [];
|
|
72129
|
+
const any2 = new RegExp(`^(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?(${DEF_WORDS})\\s+([A-Za-z_$][\\w$]*)`);
|
|
72130
|
+
lines.forEach((text2, i2) => {
|
|
72131
|
+
const m = text2.match(any2);
|
|
72132
|
+
if (m !== null) symbols2.push({ line: i2 + 1, kind: KIND_OF_WORD[m[1].replace("*", "")] ?? "constant", name: m[2] });
|
|
72133
|
+
});
|
|
72134
|
+
}
|
|
72135
|
+
const text = symbols2.map((s) => `${s.line} ${s.kind} ${s.name}`);
|
|
72136
|
+
if (symbols2.length === 0) return { data: { path, source, symbols: symbols2, ...notice === "" ? {} : { notice } }, lines: [...notice === "" ? [] : [notice], `none: no symbols in ${path}`], exit: 4 };
|
|
72137
|
+
return { data: { path, source, symbols: symbols2, ...notice === "" ? {} : { notice } }, lines: [...notice === "" ? [] : [notice], ...text], exit: 0 };
|
|
72138
|
+
}
|
|
72139
|
+
async function refsCore(ctx, input2) {
|
|
72140
|
+
const root = findRoot(ctx.cwd);
|
|
72141
|
+
const limit = Math.max(1, input2.limit ?? DEFAULT_REFS_LIMIT);
|
|
72142
|
+
const defs = await definitionsOf(ctx, root, input2.name, void 0);
|
|
72143
|
+
const callers = [];
|
|
72144
|
+
const ends = /* @__PURE__ */ new Map();
|
|
72145
|
+
if (defs.fresh.state === "ready") {
|
|
72146
|
+
const { index, changed } = defs.fresh;
|
|
72147
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72148
|
+
for (const symbol2 of defs.symbols) {
|
|
72149
|
+
for (const from of index.callersOf(symbol2.i)) {
|
|
72150
|
+
const caller = index.symbol(from);
|
|
72151
|
+
if (caller === void 0 || changed.has(caller.path) || seen.has(`${caller.path}:${caller.line}`)) continue;
|
|
72152
|
+
seen.add(`${caller.path}:${caller.line}`);
|
|
72153
|
+
ends.set(`${caller.path}:${caller.line}`, nextSiblingLine(index, caller) ?? Number.POSITIVE_INFINITY);
|
|
72154
|
+
callers.push({ kind: "caller", qualified: caller.qualified, path: caller.path, line: caller.line });
|
|
72155
|
+
}
|
|
72156
|
+
}
|
|
72157
|
+
callers.sort((a, b) => a.path.localeCompare(b.path) || a.line - b.line);
|
|
72158
|
+
}
|
|
72159
|
+
const defKeys = new Set(defs.hits.map((h) => `${h.path}:${h.line}`));
|
|
72160
|
+
const listed = new Set(callers.map((h) => `${h.path}:${h.line}`));
|
|
72161
|
+
const budget = Math.max(0, limit - Math.min(callers.length, limit));
|
|
72162
|
+
const grep = await gitGrep(ctx, root, input2.name, 400);
|
|
72163
|
+
let skippedImports = 0;
|
|
72164
|
+
const matches = [];
|
|
72165
|
+
let extra = 0;
|
|
72166
|
+
for (const hit of grep.hits) {
|
|
72167
|
+
const key = `${hit.path}:${hit.line}`;
|
|
72168
|
+
if (defKeys.has(key) || listed.has(key)) continue;
|
|
72169
|
+
if (/^(?:import\b|export\s+(?:type\s+)?\{[^}]*\}\s+from\b|from\s+\S+\s+import\b|const\s+\{[^}]*\}\s*=\s*require)/.test(hit.text)) {
|
|
72170
|
+
skippedImports += 1;
|
|
72171
|
+
continue;
|
|
72172
|
+
}
|
|
72173
|
+
if (matches.length < budget) matches.push(hit);
|
|
72174
|
+
else extra += 1;
|
|
72175
|
+
}
|
|
72176
|
+
const enclosing = (hit) => callers.find((c2) => c2.path === hit.path && c2.line <= hit.line && hit.line < (ends.get(`${c2.path}:${c2.line}`) ?? 0));
|
|
72177
|
+
const covered = /* @__PURE__ */ new Set();
|
|
72178
|
+
const named = matches.map((m) => {
|
|
72179
|
+
const c2 = enclosing(m);
|
|
72180
|
+
if (c2 !== void 0) covered.add(c2);
|
|
72181
|
+
return c2 === void 0 ? `${m.path}:${m.line} ${m.text}` : `${m.path}:${m.line} ${m.text} <- ${c2.qualified}`;
|
|
72182
|
+
});
|
|
72183
|
+
const shownCallers = callers.slice(0, limit);
|
|
72184
|
+
const more = Math.max(0, callers.length - shownCallers.length) + extra + (grep.more ? 1 : 0);
|
|
72185
|
+
const notice = [...defs.notes.filter((n) => n !== "" && !n.startsWith("no exact match")), ...defs.fresh.state === "ready" ? [] : [indexProblem(defs.fresh)]].join("; ");
|
|
72186
|
+
const lines = [
|
|
72187
|
+
...notice === "" ? [] : [notice],
|
|
72188
|
+
...shownCallers.filter((h) => !covered.has(h)).map((h) => `caller ${h.qualified} ${h.path}:${h.line}`),
|
|
72189
|
+
...named,
|
|
72190
|
+
...skippedImports > 0 ? [`(${skippedImports} import lines not shown)`] : [],
|
|
72191
|
+
...more > 0 ? [`+${more}${grep.more ? "+" : ""} more: overlane code refs ${input2.name} --limit ${limit * 3}`] : []
|
|
72192
|
+
];
|
|
72193
|
+
const data = { name: input2.name, source: defs.fresh.state === "ready" ? "index" : "search", callers: shownCallers, matches, skippedImports, more, ...notice === "" ? {} : { notice } };
|
|
72194
|
+
if (shownCallers.length === 0 && matches.length === 0) return { data, lines: [...notice === "" ? [] : [notice], `none: no references to ${input2.name}${skippedImports > 0 ? ` (${skippedImports} import lines only)` : ""}`], exit: 4 };
|
|
72195
|
+
return { data, lines, exit: 0 };
|
|
72196
|
+
}
|
|
72197
|
+
|
|
72198
|
+
// ../cli/src/token/source.ts
|
|
72199
|
+
async function navMeta(ctx) {
|
|
72200
|
+
const root = findRoot(ctx.cwd);
|
|
72201
|
+
const fresh = await loadFreshIndex(ctx, root);
|
|
72202
|
+
if (fresh.state === "ready") {
|
|
72203
|
+
const { index, changed, headSha } = fresh;
|
|
72204
|
+
const freshness = changed.size === 0 && headSha === index.sha ? "fresh" : "partial";
|
|
72205
|
+
return { indexedCommit: index.sha, requestedCommit: headSha === "" ? null : headSha, coverage: { files: index.fileCount, symbols: index.count, uncovered: index.uncovered, changedSinceIndex: changed.size }, freshness, incomplete: freshness !== "fresh" || index.uncovered > 0 };
|
|
72206
|
+
}
|
|
72207
|
+
const head = await ctx.git(["rev-parse", "HEAD"], root);
|
|
72208
|
+
return {
|
|
72209
|
+
indexedCommit: null,
|
|
72210
|
+
requestedCommit: head.code === 0 ? head.stdout.trim() : null,
|
|
72211
|
+
coverage: { files: 0, symbols: 0, uncovered: 0, changedSinceIndex: 0 },
|
|
72212
|
+
freshness: fresh.state === "missing" ? "unavailable" : "stale",
|
|
72213
|
+
incomplete: true
|
|
72214
|
+
};
|
|
72215
|
+
}
|
|
72216
|
+
async function withMeta(ctx, result) {
|
|
72217
|
+
const meta3 = await navMeta(ctx);
|
|
72218
|
+
return { ...result, data: { ...meta3, ...result.data } };
|
|
72219
|
+
}
|
|
72220
|
+
var codeFind = async (ctx, input2) => withMeta(ctx, await findCore(ctx, input2));
|
|
72221
|
+
var codeShow = async (ctx, input2) => withMeta(ctx, await showCore(ctx, input2));
|
|
72222
|
+
var codeOutline = async (ctx, input2) => withMeta(ctx, await outlineCore(ctx, input2));
|
|
72223
|
+
var codeRefs = async (ctx, input2) => withMeta(ctx, await refsCore(ctx, input2));
|
|
72224
|
+
|
|
72225
|
+
// ../cli/src/token/exec.ts
|
|
72226
|
+
import { spawn } from "node:child_process";
|
|
72227
|
+
import { createWriteStream, mkdirSync as mkdirSync10 } from "node:fs";
|
|
72228
|
+
import { join as join29 } from "node:path";
|
|
72229
|
+
|
|
72230
|
+
// ../cli/src/token/parsers.ts
|
|
72231
|
+
var ANSI = /\u001b\[[0-9;?]*[A-Za-z]/g;
|
|
72232
|
+
var stripAnsi = (text) => text.replace(ANSI, "");
|
|
72233
|
+
var MAX_FAILURES = 15;
|
|
72234
|
+
function groupByPackage(lines) {
|
|
72235
|
+
const known = /* @__PURE__ */ new Set();
|
|
72236
|
+
for (const line3 of lines) {
|
|
72237
|
+
const m = line3.match(/^(\S+ [\w:.-]+)\$ /);
|
|
72238
|
+
if (m !== null) known.add(m[1]);
|
|
72239
|
+
}
|
|
72240
|
+
if (known.size === 0) return { groups: /* @__PURE__ */ new Map([["", [...lines]]]), prefixed: false };
|
|
72241
|
+
const groups = /* @__PURE__ */ new Map();
|
|
72242
|
+
const push = (key, line3) => {
|
|
72243
|
+
const list2 = groups.get(key);
|
|
72244
|
+
if (list2 === void 0) groups.set(key, [line3]);
|
|
72245
|
+
else list2.push(line3);
|
|
72246
|
+
};
|
|
72247
|
+
for (const line3 of lines) {
|
|
72248
|
+
const start2 = line3.match(/^(\S+ [\w:.-]+)\$ (.*)$/);
|
|
72249
|
+
if (start2 !== null) {
|
|
72250
|
+
push(start2[1], `$ ${start2[2]}`);
|
|
72251
|
+
continue;
|
|
72252
|
+
}
|
|
72253
|
+
const colon = line3.indexOf(": ");
|
|
72254
|
+
const head = colon === -1 ? line3.endsWith(":") ? line3.slice(0, -1) : "" : line3.slice(0, colon);
|
|
72255
|
+
if (head !== "" && known.has(head)) push(head, colon === -1 ? "" : line3.slice(colon + 2));
|
|
72256
|
+
else push("", line3);
|
|
72257
|
+
}
|
|
72258
|
+
return { groups, prefixed: true };
|
|
72259
|
+
}
|
|
72260
|
+
var packageOf = (key) => key.split(" ")[0] ?? key;
|
|
72261
|
+
function parseCountLine(text) {
|
|
72262
|
+
const get = (word) => Number(text.match(new RegExp(`(\\d+) ${word}`))?.[1] ?? 0);
|
|
72263
|
+
return { failed: get("failed"), passed: get("passed"), skipped: get("skipped"), todo: get("todo"), total: Number(text.match(/\((\d+)\)/)?.[1] ?? 0) };
|
|
72264
|
+
}
|
|
72265
|
+
function parseVitestBlock(lines, packageName2) {
|
|
72266
|
+
const clean2 = lines.map(stripAnsi);
|
|
72267
|
+
const sawRun = clean2.some((l) => /^\s*RUN\s+v\d/.test(l));
|
|
72268
|
+
const filesLine = clean2.find((l) => /^\s*Test Files\s/.test(l));
|
|
72269
|
+
const testsLine = clean2.find((l) => /^\s*Tests\s/.test(l) && /\(\d+\)/.test(l));
|
|
72270
|
+
if (!sawRun && filesLine === void 0 && testsLine === void 0) return null;
|
|
72271
|
+
const counts2 = filesLine === void 0 && testsLine === void 0 ? null : {
|
|
72272
|
+
files: (() => {
|
|
72273
|
+
const c2 = parseCountLine(filesLine ?? "");
|
|
72274
|
+
return { failed: c2.failed, passed: c2.passed, skipped: c2.skipped, total: c2.total };
|
|
72275
|
+
})(),
|
|
72276
|
+
tests: parseCountLine(testsLine ?? "")
|
|
72277
|
+
};
|
|
72278
|
+
const failures = [];
|
|
72279
|
+
for (let i2 = 0; i2 < clean2.length; i2 += 1) {
|
|
72280
|
+
const m = clean2[i2].match(/^\s*FAIL\s+(.+?)\s*$/);
|
|
72281
|
+
if (m === null) continue;
|
|
72282
|
+
const block2 = [];
|
|
72283
|
+
for (let j = i2 + 1; j < clean2.length; j += 1) {
|
|
72284
|
+
const line3 = clean2[j];
|
|
72285
|
+
if (/^\s*FAIL\s/.test(line3) || /^\s*⎯{3,}/.test(line3)) break;
|
|
72286
|
+
block2.push(line3);
|
|
72287
|
+
}
|
|
72288
|
+
failures.push({ name: m[1], detail: assertionLines(block2) });
|
|
72289
|
+
}
|
|
72290
|
+
const unhandled = Number(clean2.join("\n").match(/caught (\d+) unhandled error/)?.[1] ?? 0);
|
|
72291
|
+
return { package: packageName2, counts: counts2, failures: dedupeFailures(failures), unhandled, unfinished: counts2 === null };
|
|
72292
|
+
}
|
|
72293
|
+
function dedupeFailures(list2) {
|
|
72294
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72295
|
+
return list2.filter((f) => seen.has(f.name) ? false : (seen.add(f.name), true));
|
|
72296
|
+
}
|
|
72297
|
+
function assertionLines(block2) {
|
|
72298
|
+
const body2 = block2.map((l) => l.trimEnd()).filter((l) => l.trim() !== "");
|
|
72299
|
+
const message = body2[0];
|
|
72300
|
+
if (message === void 0) return [];
|
|
72301
|
+
const rest = body2.slice(1).filter((l) => !/^\s*[-+] (?:Expected|Received)\s*$/.test(l) && !/^\s*❯ /.test(l));
|
|
72302
|
+
const changed = rest.filter((l) => /^[-+] /.test(l));
|
|
72303
|
+
const more = changed.length > 0 ? changed : rest;
|
|
72304
|
+
return [message, ...more.slice(0, 2)].map((l) => clip(l, 200));
|
|
72305
|
+
}
|
|
72306
|
+
function parseVitest(output2) {
|
|
72307
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72308
|
+
const { groups, prefixed: prefixed2 } = groupByPackage(lines);
|
|
72309
|
+
const packages = [];
|
|
72310
|
+
for (const [key, list2] of groups) {
|
|
72311
|
+
if (prefixed2 && key === "") continue;
|
|
72312
|
+
const name2 = prefixed2 ? packageOf(key) : list2.map((l) => l.match(/^\s*RUN\s+v[\d.]+\s+(.+)$/)?.[1]).find((p2) => p2 !== void 0)?.split("/").slice(-2).join("/") ?? "";
|
|
72313
|
+
const block2 = parseVitestBlock(list2, name2);
|
|
72314
|
+
if (block2 !== null) packages.push(block2);
|
|
72315
|
+
}
|
|
72316
|
+
if (packages.length === 0) return null;
|
|
72317
|
+
const out2 = [];
|
|
72318
|
+
let explains = false;
|
|
72319
|
+
let failedTests = 0;
|
|
72320
|
+
const tot = { filesPassed: 0, filesFailed: 0, passed: 0, failed: 0, skipped: 0 };
|
|
72321
|
+
for (const p2 of packages) {
|
|
72322
|
+
const label2 = p2.package === "" ? "tests" : p2.package;
|
|
72323
|
+
if (p2.counts === null) {
|
|
72324
|
+
out2.push(`${label2}: no summary printed (vitest did not finish)`);
|
|
72325
|
+
explains = true;
|
|
72326
|
+
} else {
|
|
72327
|
+
const c2 = p2.counts;
|
|
72328
|
+
tot.filesPassed += c2.files.passed;
|
|
72329
|
+
tot.filesFailed += c2.files.failed;
|
|
72330
|
+
tot.passed += c2.tests.passed;
|
|
72331
|
+
tot.failed += c2.tests.failed;
|
|
72332
|
+
tot.skipped += c2.tests.skipped;
|
|
72333
|
+
out2.push(`${label2}: files ${c2.files.passed} passed${c2.files.failed > 0 ? ` ${c2.files.failed} FAILED` : ""}${c2.files.skipped > 0 ? ` ${c2.files.skipped} skipped` : ""}; tests ${c2.tests.passed} passed${c2.tests.failed > 0 ? ` ${c2.tests.failed} FAILED` : ""}${c2.tests.skipped > 0 ? ` ${c2.tests.skipped} skipped` : ""}`);
|
|
72334
|
+
}
|
|
72335
|
+
if (p2.unhandled > 0) {
|
|
72336
|
+
out2.push(`${label2}: ${p2.unhandled} unhandled error${p2.unhandled === 1 ? "" : "s"}`);
|
|
72337
|
+
explains = true;
|
|
72338
|
+
}
|
|
72339
|
+
for (const f of p2.failures.slice(0, MAX_FAILURES)) {
|
|
72340
|
+
out2.push(`FAIL ${f.name}`, ...f.detail.map((d) => ` ${d}`));
|
|
72341
|
+
explains = true;
|
|
72342
|
+
}
|
|
72343
|
+
failedTests += p2.failures.length;
|
|
72344
|
+
if (p2.failures.length > MAX_FAILURES) out2.push(`+${p2.failures.length - MAX_FAILURES} more failing tests in the log`);
|
|
72345
|
+
}
|
|
72346
|
+
if (packages.length > 1) out2.push(`total: tests ${tot.passed} passed${tot.failed > 0 ? ` ${tot.failed} FAILED` : ""}${tot.skipped > 0 ? ` ${tot.skipped} skipped` : ""} in ${packages.length} packages`);
|
|
72347
|
+
return { kind: "vitest", lines: out2, explains, data: { packages, failedTests } };
|
|
72348
|
+
}
|
|
72349
|
+
var TSC_PLAIN = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
|
|
72350
|
+
var TSC_PRETTY = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
|
|
72351
|
+
var TSC_GLOBAL = /^error (TS\d+): (.*)$/;
|
|
72352
|
+
function parseTscErrors(output2) {
|
|
72353
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72354
|
+
const { groups, prefixed: prefixed2 } = groupByPackage(lines);
|
|
72355
|
+
const errors = [];
|
|
72356
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72357
|
+
for (const [key, list2] of groups) {
|
|
72358
|
+
const dir = prefixed2 && key !== "" ? packageOf(key) : "";
|
|
72359
|
+
for (const line3 of list2) {
|
|
72360
|
+
const m = line3.match(TSC_PLAIN) ?? line3.match(TSC_PRETTY);
|
|
72361
|
+
const g = m === null ? line3.match(TSC_GLOBAL) : null;
|
|
72362
|
+
let error62;
|
|
72363
|
+
if (m !== null) error62 = { file: dir === "" || m[1].startsWith("/") ? m[1] : `${dir}/${m[1]}`, line: Number(m[2]), code: m[4], message: clip(m[5], 200) };
|
|
72364
|
+
else if (g !== null) error62 = { file: dir, line: 0, code: g[1], message: clip(g[2], 200) };
|
|
72365
|
+
if (error62 === void 0) continue;
|
|
72366
|
+
const id2 = `${error62.file}:${error62.line}:${error62.code}:${error62.message}`;
|
|
72367
|
+
if (seen.has(id2)) continue;
|
|
72368
|
+
seen.add(id2);
|
|
72369
|
+
errors.push(error62);
|
|
72370
|
+
}
|
|
72371
|
+
}
|
|
72372
|
+
return errors;
|
|
72373
|
+
}
|
|
72374
|
+
function parseTsc(output2, commandHints) {
|
|
72375
|
+
const errors = parseTscErrors(output2);
|
|
72376
|
+
if (errors.length === 0) return commandHints ? { kind: "typecheck", lines: ["typecheck: 0 errors"], explains: false, data: { errors: 0 } } : null;
|
|
72377
|
+
const shown2 = errors.slice(0, 10);
|
|
72378
|
+
const lines = [`typecheck: ${errors.length} error${errors.length === 1 ? "" : "s"}`, ...shown2.map((e2) => `${e2.file}${e2.line > 0 ? `:${e2.line}` : ""} ${e2.code} ${e2.message}`)];
|
|
72379
|
+
if (errors.length > shown2.length) lines.push(`+${errors.length - shown2.length} more in the log`);
|
|
72380
|
+
return { kind: "typecheck", lines, explains: true, data: { errors: errors.length, first: shown2 } };
|
|
72381
|
+
}
|
|
72382
|
+
function parseBuildErrors(output2) {
|
|
72383
|
+
const lines = stripAnsi(output2).split("\n").map((l) => l.replace(/^\S+ [\w:.-]+: /, ""));
|
|
72384
|
+
const errors = [];
|
|
72385
|
+
for (let i2 = 0; i2 < lines.length; i2 += 1) {
|
|
72386
|
+
const line3 = lines[i2];
|
|
72387
|
+
const m = line3.match(/^\s*(?:✘\s*)?\[(?:ERROR|error)\]\s*(.*)$/);
|
|
72388
|
+
if (m === null) continue;
|
|
72389
|
+
let location;
|
|
72390
|
+
for (let j = i2 + 1; j < Math.min(lines.length, i2 + 6); j += 1) {
|
|
72391
|
+
const loc = lines[j].match(/^\s+([^\s:][^\s]*?:\d+:\d+):?\s*$/) ?? lines[j].match(/^\s+(?:file|File): (\S+)/);
|
|
72392
|
+
if (loc !== null) {
|
|
72393
|
+
location = loc[1];
|
|
72394
|
+
break;
|
|
72395
|
+
}
|
|
72396
|
+
if (/^\s*(?:✘\s*)?\[(?:ERROR|error|WARNING)\]/.test(lines[j])) break;
|
|
72397
|
+
}
|
|
72398
|
+
errors.push({ message: clip(m[1], 200), ...location === void 0 ? {} : { location } });
|
|
72399
|
+
}
|
|
72400
|
+
return errors;
|
|
72401
|
+
}
|
|
72402
|
+
function parseBuild(output2) {
|
|
72403
|
+
const errors = parseBuildErrors(output2);
|
|
72404
|
+
if (errors.length === 0) return null;
|
|
72405
|
+
const shown2 = errors.slice(0, 10);
|
|
72406
|
+
const lines = [`build: ${errors.length} error${errors.length === 1 ? "" : "s"}`, ...shown2.map((e2) => `${e2.message}${e2.location === void 0 ? "" : ` at ${e2.location}`}`)];
|
|
72407
|
+
if (errors.length > shown2.length) lines.push(`+${errors.length - shown2.length} more in the log`);
|
|
72408
|
+
return { kind: "build", lines, explains: true, data: { errors: errors.length, first: shown2 } };
|
|
72409
|
+
}
|
|
72410
|
+
function parseWranglerDeploy(output2) {
|
|
72411
|
+
const lines = stripAnsi(output2).split("\n").map((l) => l.replace(/^\S+ [\w:.-]+: /, ""));
|
|
72412
|
+
const deploys = [];
|
|
72413
|
+
let current2 = { worker: void 0, versionId: void 0, routes: [] };
|
|
72414
|
+
let afterTriggers = false;
|
|
72415
|
+
const flush = () => {
|
|
72416
|
+
if (current2.versionId !== void 0 || current2.routes.length > 0 || current2.worker !== void 0) deploys.push(current2);
|
|
72417
|
+
current2 = { worker: void 0, versionId: void 0, routes: [] };
|
|
72418
|
+
};
|
|
72419
|
+
for (const line3 of lines) {
|
|
72420
|
+
const up = line3.match(/^Uploaded (\S+)/);
|
|
72421
|
+
if (up !== null) {
|
|
72422
|
+
if (current2.versionId !== void 0) flush();
|
|
72423
|
+
current2.worker = up[1];
|
|
72424
|
+
}
|
|
72425
|
+
if (/^Deployed .* triggers/.test(line3) || /^Published .*/.test(line3)) {
|
|
72426
|
+
afterTriggers = true;
|
|
72427
|
+
current2.worker ??= line3.match(/^(?:Deployed|Published) (\S+)/)?.[1];
|
|
72428
|
+
continue;
|
|
72429
|
+
}
|
|
72430
|
+
const version2 = line3.match(/^Current Version ID:\s*(\S+)/);
|
|
72431
|
+
if (version2 !== null) {
|
|
72432
|
+
current2.versionId = version2[1];
|
|
72433
|
+
afterTriggers = false;
|
|
72434
|
+
flush();
|
|
72435
|
+
continue;
|
|
72436
|
+
}
|
|
72437
|
+
if (afterTriggers) {
|
|
72438
|
+
const route = line3.match(/^\s{2,}(\S.*?)\s*$/);
|
|
72439
|
+
if (route !== null) current2.routes.push(route[1]);
|
|
72440
|
+
else if (line3.trim() !== "") afterTriggers = false;
|
|
72441
|
+
}
|
|
72442
|
+
}
|
|
72443
|
+
flush();
|
|
72444
|
+
const errors = wranglerErrors(lines);
|
|
72445
|
+
if (deploys.length === 0 && errors.length === 0) return null;
|
|
72446
|
+
const out2 = [];
|
|
72447
|
+
for (const d of deploys) {
|
|
72448
|
+
out2.push(`deploy ${d.worker ?? "worker"} version ${d.versionId ?? "unknown"}`);
|
|
72449
|
+
for (const r of d.routes) out2.push(` ${r}`);
|
|
72450
|
+
}
|
|
72451
|
+
for (const e2 of errors) out2.push(`error ${e2}`);
|
|
72452
|
+
return { kind: "wrangler deploy", lines: out2, explains: errors.length > 0, data: { deploys, errors } };
|
|
72453
|
+
}
|
|
72454
|
+
function wranglerErrors(lines) {
|
|
72455
|
+
const errors = [];
|
|
72456
|
+
for (let i2 = 0; i2 < lines.length; i2 += 1) {
|
|
72457
|
+
const m = lines[i2].match(/^\s*✘\s*\[ERROR\]\s*(.*)$/);
|
|
72458
|
+
if (m === null) continue;
|
|
72459
|
+
let text = m[1];
|
|
72460
|
+
for (let j = i2 + 1; j < Math.min(lines.length, i2 + 5); j += 1) {
|
|
72461
|
+
const next = lines[j].trim();
|
|
72462
|
+
if (next === "") continue;
|
|
72463
|
+
if (/^✘|^▲|^If you think/.test(next)) break;
|
|
72464
|
+
if (text.length < 160) text += ` ${next}`;
|
|
72465
|
+
}
|
|
72466
|
+
errors.push(clip(text, 220));
|
|
72467
|
+
}
|
|
72468
|
+
return errors.slice(0, 10);
|
|
72469
|
+
}
|
|
72470
|
+
var BOOKMARK = /\b[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{32}\b/;
|
|
72471
|
+
function parseWranglerD1(output2) {
|
|
72472
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72473
|
+
const bookmark = lines.map((l) => l.match(BOOKMARK)?.[0]).find((b) => b !== void 0);
|
|
72474
|
+
const applied = [];
|
|
72475
|
+
const failed = [];
|
|
72476
|
+
for (const line3 of lines) {
|
|
72477
|
+
const row = line3.match(/^[│|]\s*(\S+\.sql)\s*[│|]\s*(\S+)/);
|
|
72478
|
+
if (row === null) continue;
|
|
72479
|
+
if (/✅|ok|applied/i.test(row[2])) applied.push(row[1]);
|
|
72480
|
+
else if (/❌|fail/i.test(row[2])) failed.push(row[1]);
|
|
72481
|
+
}
|
|
72482
|
+
const none2 = lines.some((l) => /No migrations to apply/i.test(l));
|
|
72483
|
+
const errors = wranglerErrors(lines);
|
|
72484
|
+
if (bookmark === void 0 && applied.length === 0 && failed.length === 0 && !none2 && errors.length === 0) return null;
|
|
72485
|
+
const out2 = [];
|
|
72486
|
+
if (bookmark !== void 0) out2.push(`bookmark ${bookmark}`);
|
|
72487
|
+
if (applied.length > 0) out2.push(`migrations applied: ${applied.join(", ")}`);
|
|
72488
|
+
if (none2) out2.push("migrations: none to apply");
|
|
72489
|
+
if (failed.length > 0) out2.push(`migrations FAILED: ${failed.join(", ")}`);
|
|
72490
|
+
for (const e2 of errors) out2.push(`error ${e2}`);
|
|
72491
|
+
return { kind: "wrangler d1", lines: out2, explains: failed.length > 0 || errors.length > 0, data: { bookmark, applied, failed, errors } };
|
|
72492
|
+
}
|
|
72493
|
+
function parseGitPush(output2) {
|
|
72494
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72495
|
+
const updates = [];
|
|
72496
|
+
const notes = [];
|
|
72497
|
+
for (const line3 of lines) {
|
|
72498
|
+
const m = line3.match(/^\s*([ +\-*!=])\s+(\[[^\]]+\]|\S+)\s+(\S+) -> (\S+)(?:\s+\((.*)\))?\s*$/);
|
|
72499
|
+
if (m !== null) {
|
|
72500
|
+
const flag = m[1];
|
|
72501
|
+
const what = m[2];
|
|
72502
|
+
const status = flag === "!" ? "rejected" : flag === "+" ? "forced" : flag === "-" ? "deleted" : flag === "=" ? "up-to-date" : what === "[new branch]" || what === "[new tag]" ? "new" : /\.\./.test(what) ? "updated" : "other";
|
|
72503
|
+
updates.push({ status, ref: m[4], detail: status === "rejected" ? m[5] ?? what : what });
|
|
72504
|
+
continue;
|
|
72505
|
+
}
|
|
72506
|
+
if (/^(?:remote: )?(?:error|fatal|hint): /.test(line3) || /^remote: .*(?:rejected|denied|protected|violation|GH\d+)/i.test(line3)) notes.push(clip(line3.replace(/^remote:\s*/, "remote: "), 200));
|
|
72507
|
+
}
|
|
72508
|
+
if (updates.length === 0 && notes.length === 0) return /Everything up-to-date/.test(output2) ? { kind: "git push", lines: ["push: everything up to date"], explains: false, data: { updates: [] } } : null;
|
|
72509
|
+
const out2 = updates.map((u) => u.status === "rejected" ? `push REJECTED ${u.ref} (${u.detail})` : `push ${u.status} ${u.ref}${u.status === "updated" || u.status === "forced" ? ` ${u.detail}` : ""}`);
|
|
72510
|
+
const rejected = updates.some((u) => u.status === "rejected") || notes.length > 0 && updates.every((u) => u.status !== "updated" && u.status !== "new");
|
|
72511
|
+
if (rejected) out2.push(...[...new Set(notes)].slice(0, 6));
|
|
72512
|
+
return { kind: "git push", lines: out2, explains: rejected, data: { updates, notes } };
|
|
72513
|
+
}
|
|
72514
|
+
function parsePnpmFailures(output2) {
|
|
72515
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72516
|
+
const found = [];
|
|
72517
|
+
for (const line3 of lines) {
|
|
72518
|
+
const m = line3.match(/(ERR_PNPM_[A-Z_]+)/) ?? line3.match(/(\[ELIFECYCLE\].*)$/);
|
|
72519
|
+
if (m !== null && /Command failed|ELIFECYCLE|ERR_PNPM/.test(line3) && !/RECURSIVE_RUN_FIRST_FAIL/.test(line3)) found.push(clip(line3.replace(/^.*?(\[ELIFECYCLE\])/, "$1"), 200));
|
|
72520
|
+
}
|
|
72521
|
+
return [...new Set(found)].slice(0, 5);
|
|
72522
|
+
}
|
|
72523
|
+
function lastLines(output2, count) {
|
|
72524
|
+
const lines = stripAnsi(output2).split("\n");
|
|
72525
|
+
while (lines.length > 0 && lines.at(-1).trim() === "") lines.pop();
|
|
72526
|
+
return lines.slice(-count).map((l) => clip(l, 240));
|
|
72527
|
+
}
|
|
72528
|
+
var HINTS = {
|
|
72529
|
+
vitest: /\b(?:vitest|jest)\b|(?:pnpm|npm|yarn)(?:\s+-\S+(?:\s+\S+)?)*\s+(?:run\s+)?test\b/,
|
|
72530
|
+
tsc: /\btsc\b|\btypecheck\b/,
|
|
72531
|
+
build: /\besbuild\b|\bastro\s+build\b|\bvite\s+build\b|(?:pnpm|npm|yarn)(?:\s+-\S+(?:\s+\S+)?)*\s+(?:run\s+)?build\b/,
|
|
72532
|
+
deploy: /\bwrangler\b.*\b(?:deploy|publish|versions\s+upload)\b/,
|
|
72533
|
+
d1: /\bwrangler\b.*\bd1\b/,
|
|
72534
|
+
push: /\bgit\b.*\bpush\b/
|
|
72535
|
+
};
|
|
72536
|
+
function summarise(command, output2, exit) {
|
|
72537
|
+
const parts2 = [];
|
|
72538
|
+
const add = (part) => {
|
|
72539
|
+
if (part !== null) parts2.push(part);
|
|
72540
|
+
};
|
|
72541
|
+
add(parseVitest(output2));
|
|
72542
|
+
add(parseTsc(output2, HINTS.tsc.test(command) && !HINTS.vitest.test(command)));
|
|
72543
|
+
const wrangler = [parseWranglerDeploy(output2), parseWranglerD1(output2)];
|
|
72544
|
+
if (wrangler.every((w) => w === null)) add(parseBuild(output2));
|
|
72545
|
+
add(wrangler[0] ?? null);
|
|
72546
|
+
add(wrangler[1] ?? null);
|
|
72547
|
+
add(parseGitPush(output2));
|
|
72548
|
+
const lines = parts2.flatMap((p2) => p2.lines);
|
|
72549
|
+
const explained = parts2.some((p2) => p2.explains);
|
|
72550
|
+
if (exit !== 0) {
|
|
72551
|
+
const pnpm = parsePnpmFailures(output2);
|
|
72552
|
+
if (!explained) {
|
|
72553
|
+
lines.push(...pnpm, ...lastLines(output2, 20));
|
|
72554
|
+
} else if (pnpm.length > 0) {
|
|
72555
|
+
lines.push(...pnpm.filter((l) => /signal|SIGKILL|ERR_PNPM_(?!RECURSIVE)/.test(l)));
|
|
72556
|
+
}
|
|
72557
|
+
}
|
|
72558
|
+
return { kinds: parts2.map((p2) => p2.kind), lines, parts: parts2 };
|
|
72559
|
+
}
|
|
72560
|
+
|
|
72561
|
+
// ../cli/src/token/exec.ts
|
|
72562
|
+
var MAX_CAPTURE = 64 * 1024 * 1024;
|
|
72563
|
+
var SAFE_TOKEN = /^[A-Za-z0-9_@%+=:,./~-]+$/;
|
|
72564
|
+
var quote2 = (token) => SAFE_TOKEN.test(token) ? token : `'${token.replaceAll("'", "'\\''")}'`;
|
|
72565
|
+
function commandLine(tokens) {
|
|
72566
|
+
if (tokens.length === 1) return tokens[0];
|
|
72567
|
+
return tokens.map(quote2).join(" ");
|
|
72568
|
+
}
|
|
72569
|
+
function slugOf(name2, command) {
|
|
72570
|
+
const base5 = name2 ?? command.split(/\s+/).filter((w) => !w.startsWith("-")).slice(0, 3).join("-");
|
|
72571
|
+
const slug = base5.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
72572
|
+
return slug === "" ? "run" : slug;
|
|
72573
|
+
}
|
|
72574
|
+
function utcStamp(ms) {
|
|
72575
|
+
return new Date(ms).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
72576
|
+
}
|
|
72577
|
+
var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
|
|
72578
|
+
async function execCommand(ctx, input2) {
|
|
72579
|
+
if (input2.tokens.length === 0 || input2.tokens.every((t2) => t2.trim() === "")) {
|
|
72580
|
+
throw new CoreError("exec needs a command after --", { exit: 2, code: "usage", hint: "overlane exec -- pnpm -r test" });
|
|
72581
|
+
}
|
|
72582
|
+
const command = commandLine(input2.tokens);
|
|
72583
|
+
const root = findRoot(ctx.cwd);
|
|
72584
|
+
const dir = join29(root, ".harness", "logs");
|
|
72585
|
+
mkdirSync10(dir, { recursive: true });
|
|
72586
|
+
const started = ctx.now();
|
|
72587
|
+
const logFile = join29(dir, `${utcStamp(started)}-${slugOf(input2.name, command)}.log`);
|
|
72588
|
+
const stream = createWriteStream(logFile);
|
|
72589
|
+
const chunks = [];
|
|
72590
|
+
let captured = 0;
|
|
72591
|
+
const outcome = await new Promise((done) => {
|
|
72592
|
+
const child = spawn(command, { shell: true, cwd: ctx.cwd, stdio: ["ignore", "pipe", "pipe"], env: { ...ctx.env } });
|
|
72593
|
+
const take = (chunk) => {
|
|
72594
|
+
stream.write(chunk);
|
|
72595
|
+
if (captured < MAX_CAPTURE) {
|
|
72596
|
+
chunks.push(chunk);
|
|
72597
|
+
captured += chunk.length;
|
|
72598
|
+
}
|
|
72599
|
+
};
|
|
72600
|
+
child.stdout.on("data", take);
|
|
72601
|
+
child.stderr.on("data", take);
|
|
72602
|
+
child.once("error", (error62) => {
|
|
72603
|
+
take(Buffer.from(`${error62.message}
|
|
72604
|
+
`));
|
|
72605
|
+
done({ code: 127 });
|
|
72606
|
+
});
|
|
72607
|
+
child.once("close", (code2, signal) => done({ code: code2 ?? (signal === null ? 1 : 128 + (signalNumber(signal) ?? 0)) }));
|
|
72608
|
+
});
|
|
72609
|
+
await new Promise((done) => stream.end(done));
|
|
72610
|
+
const elapsed = ctx.now() - started;
|
|
72611
|
+
const output2 = Buffer.concat(chunks).toString("utf8");
|
|
72612
|
+
const summary2 = summarise(command, output2, outcome.code);
|
|
72613
|
+
summary2.lines = summary2.lines.map(redact);
|
|
72614
|
+
const log = shortPath(ctx.cwd, logFile);
|
|
72615
|
+
const ok2 = outcome.code === 0;
|
|
72616
|
+
const status = `${ok2 ? "ok" : "FAIL"} exit=${outcome.code} ${formatSeconds(elapsed)} log=${log}`;
|
|
72617
|
+
const data = { ok: ok2, exit: outcome.code, seconds: Math.round(elapsed / 100) / 10, log, command: redact(command), kinds: summary2.kinds, summary: summary2.lines };
|
|
72618
|
+
return { data, lines: [status, ...summary2.lines], exit: outcome.code };
|
|
72619
|
+
}
|
|
72620
|
+
function signalNumber(signal) {
|
|
72621
|
+
const table2 = { SIGHUP: 1, SIGINT: 2, SIGQUIT: 3, SIGABRT: 6, SIGKILL: 9, SIGSEGV: 11, SIGPIPE: 13, SIGTERM: 15 };
|
|
72622
|
+
return table2[signal];
|
|
72623
|
+
}
|
|
72624
|
+
|
|
72625
|
+
// ../cli/src/token/ledger.ts
|
|
72626
|
+
import { existsSync as existsSync12, readFileSync as readFileSync18 } from "node:fs";
|
|
72627
|
+
import { join as join30, resolve as resolve16 } from "node:path";
|
|
72628
|
+
var LEDGER_PATH = ".harness/token-ledger.jsonl";
|
|
72629
|
+
var CATEGORY_RULES = [
|
|
72630
|
+
["wrangler", /\bwrangler\b/],
|
|
72631
|
+
["typecheck", /\btsc\b|\btypecheck\b/],
|
|
72632
|
+
["test", /\bvitest\b|\bjest\b|\bpytest\b|(?:pnpm|npm|yarn)(?:\s+-\S+(?:\s+\S+)?)*\s+(?:run\s+)?test\b|\bcargo\s+test\b|\bgo\s+test\b/],
|
|
72633
|
+
["build", /\besbuild\b|\bastro\s+build\b|\bvite\s+build\b|(?:pnpm|npm|yarn)(?:\s+-\S+(?:\s+\S+)?)*\s+(?:run\s+)?build\b|\bcargo\s+build\b/],
|
|
72634
|
+
["grep/sed/cat", /\bgit\s+grep\b/],
|
|
72635
|
+
["git", /^\s*(?:cd\s+\S+\s*&&\s*)?git\b/],
|
|
72636
|
+
["grep/sed/cat", /(?:^|[|;&(]\s*)(?:grep|egrep|fgrep|rg|ag|sed|awk|cat|head|tail|nl|less|find|ls|wc|bat)\b/],
|
|
72637
|
+
["git", /(?:^|[|;&(]\s*)git\b/],
|
|
72638
|
+
["curl", /(?:^|[|;&(]\s*)(?:curl|wget|http)\b/]
|
|
72639
|
+
];
|
|
72640
|
+
function categorise(tool, command) {
|
|
72641
|
+
if (tool === "Bash" || tool === "bash" || tool === "shell") {
|
|
72642
|
+
const text = (command ?? "").trim();
|
|
72643
|
+
for (const [name2, pattern] of CATEGORY_RULES) if (pattern.test(text)) return name2;
|
|
72644
|
+
return "other";
|
|
72645
|
+
}
|
|
72646
|
+
if (tool === "Grep" || tool === "Glob") return "grep/sed/cat";
|
|
72647
|
+
if (tool === "Read") return "read";
|
|
72648
|
+
if (tool.startsWith("mcp__")) return "mcp";
|
|
72649
|
+
return tool.toLowerCase();
|
|
72650
|
+
}
|
|
72651
|
+
var SUGGESTIONS = {
|
|
72652
|
+
"grep/sed/cat": "overlane code find <name> | code show <name|path:line> | code outline <path> | code refs <name>",
|
|
72653
|
+
read: "overlane code show <name|path:line> for one symbol; overlane code outline <path> for a file map",
|
|
72654
|
+
test: "overlane exec -- <command> (one status line, failures parsed, full log kept)",
|
|
72655
|
+
typecheck: "overlane exec -- <command> (error count and first 10 errors)",
|
|
72656
|
+
build: "overlane exec -- <command> (errors only)",
|
|
72657
|
+
wrangler: "overlane exec -- <command> (version id, routes, bookmark, migrations)",
|
|
72658
|
+
git: "overlane brief git (status and last commit in one line)",
|
|
72659
|
+
curl: "overlane exec --name <label> -- curl ... (summary on screen, body in the log)"
|
|
72660
|
+
};
|
|
72661
|
+
var tokensOf = (chars) => Math.round(chars / 4);
|
|
72662
|
+
function formatTokens(n) {
|
|
72663
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(2)}M`;
|
|
72664
|
+
if (n >= 1e4) return `${Math.round(n / 1e3)}k`;
|
|
72665
|
+
return n.toLocaleString("en-US");
|
|
72666
|
+
}
|
|
72667
|
+
function parseSince(value, now) {
|
|
72668
|
+
const rel = value.match(/^(\d+)([mhdw])$/);
|
|
72669
|
+
if (rel !== null) return now - Number(rel[1]) * { m: 6e4, h: 36e5, d: 864e5, w: 6048e5 }[rel[2]];
|
|
72670
|
+
const date5 = Date.parse(value);
|
|
72671
|
+
if (Number.isNaN(date5)) throw new CoreError(`--since must be like 7d, 12h, 30m or a date; got "${value}"`, { exit: 2, code: "usage", hint: "overlane tokens report --since 7d" });
|
|
72672
|
+
return date5;
|
|
72673
|
+
}
|
|
72674
|
+
function readLedger(text) {
|
|
72675
|
+
const calls = [];
|
|
72676
|
+
let skipped = 0;
|
|
72677
|
+
for (const line3 of text.split("\n")) {
|
|
72678
|
+
if (line3.trim() === "") continue;
|
|
72679
|
+
try {
|
|
72680
|
+
const o = JSON.parse(line3);
|
|
72681
|
+
const tool = typeof o["tool"] === "string" ? o["tool"] : "";
|
|
72682
|
+
const command = typeof o["command"] === "string" ? o["command"] : void 0;
|
|
72683
|
+
const ts = typeof o["ts"] === "number" ? o["ts"] : typeof o["ts"] === "string" ? Date.parse(o["ts"]) : Number.NaN;
|
|
72684
|
+
if (tool === "" || Number.isNaN(ts)) {
|
|
72685
|
+
skipped += 1;
|
|
72686
|
+
continue;
|
|
72687
|
+
}
|
|
72688
|
+
const category = typeof o["category"] === "string" && o["category"] !== "" ? o["category"] : categorise(tool, command);
|
|
72689
|
+
calls.push({ ts, tool, category, inChars: Number(o["inChars"] ?? 0) || 0, outChars: Number(o["outChars"] ?? 0) || 0, ...command === void 0 ? {} : { command } });
|
|
72690
|
+
} catch {
|
|
72691
|
+
skipped += 1;
|
|
72692
|
+
}
|
|
72693
|
+
}
|
|
72694
|
+
return { calls, skipped };
|
|
72695
|
+
}
|
|
72696
|
+
function textOf2(content) {
|
|
72697
|
+
if (typeof content === "string") return content;
|
|
72698
|
+
if (Array.isArray(content)) return content.map((part) => typeof part === "string" ? part : typeof part.text === "string" ? part.text : "").join("");
|
|
72699
|
+
return "";
|
|
72700
|
+
}
|
|
72701
|
+
function readTranscript(text) {
|
|
72702
|
+
const pending = /* @__PURE__ */ new Map();
|
|
72703
|
+
const order = [];
|
|
72704
|
+
let skipped = 0;
|
|
72705
|
+
for (const line3 of text.split("\n")) {
|
|
72706
|
+
if (line3.trim() === "") continue;
|
|
72707
|
+
let entry;
|
|
72708
|
+
try {
|
|
72709
|
+
entry = JSON.parse(line3);
|
|
72710
|
+
} catch {
|
|
72711
|
+
skipped += 1;
|
|
72712
|
+
continue;
|
|
72713
|
+
}
|
|
72714
|
+
const content = entry.message?.content;
|
|
72715
|
+
if (!Array.isArray(content)) continue;
|
|
72716
|
+
const ts = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : typeof entry.timestamp === "number" ? entry.timestamp : 0;
|
|
72717
|
+
for (const block2 of content) {
|
|
72718
|
+
if (block2["type"] === "tool_use" && typeof block2["id"] === "string" && typeof block2["name"] === "string") {
|
|
72719
|
+
const input2 = block2["input"] ?? {};
|
|
72720
|
+
const command = typeof input2["command"] === "string" ? input2["command"] : typeof input2["pattern"] === "string" ? String(input2["pattern"]) : typeof input2["file_path"] === "string" ? String(input2["file_path"]) : void 0;
|
|
72721
|
+
const call2 = { ts: Number.isNaN(ts) ? 0 : ts, tool: block2["name"], category: categorise(block2["name"], typeof input2["command"] === "string" ? input2["command"] : void 0), inChars: JSON.stringify(input2).length, outChars: 0, ...command === void 0 ? {} : { command } };
|
|
72722
|
+
pending.set(block2["id"], call2);
|
|
72723
|
+
order.push(call2);
|
|
72724
|
+
} else if (block2["type"] === "tool_result" && typeof block2["tool_use_id"] === "string") {
|
|
72725
|
+
const call2 = pending.get(block2["tool_use_id"]);
|
|
72726
|
+
if (call2 !== void 0) call2.outChars = textOf2(block2["content"]).length;
|
|
72727
|
+
}
|
|
72728
|
+
}
|
|
72729
|
+
}
|
|
72730
|
+
return { calls: order, skipped };
|
|
72731
|
+
}
|
|
72732
|
+
function buildReport(calls, top, source, since, skipped) {
|
|
72733
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
72734
|
+
for (const c2 of calls) {
|
|
72735
|
+
const row = byCategory.get(c2.category) ?? { calls: 0, inChars: 0, outChars: 0 };
|
|
72736
|
+
row.calls += 1;
|
|
72737
|
+
row.inChars += c2.inChars;
|
|
72738
|
+
row.outChars += c2.outChars;
|
|
72739
|
+
byCategory.set(c2.category, row);
|
|
72740
|
+
}
|
|
72741
|
+
const rows = [...byCategory].map(([category, r]) => {
|
|
72742
|
+
const tokens = tokensOf(r.inChars + r.outChars);
|
|
72743
|
+
return { category, calls: r.calls, inTokens: tokensOf(r.inChars), outTokens: tokensOf(r.outChars), tokens, avg: Math.round(tokens / r.calls), suggestion: SUGGESTIONS[category] ?? "" };
|
|
72744
|
+
});
|
|
72745
|
+
rows.sort((a, b) => b.tokens - a.tokens || a.category.localeCompare(b.category));
|
|
72746
|
+
return { source, since, calls: calls.length, tokens: rows.reduce((sum, r) => sum + r.tokens, 0), skipped, rows: rows.slice(0, top) };
|
|
72747
|
+
}
|
|
72748
|
+
function reportLines(report2) {
|
|
72749
|
+
const head = `${report2.calls} calls, ~${formatTokens(report2.tokens)} tokens${report2.since === null ? "" : ` since ${report2.since}`} (${report2.source}${report2.skipped > 0 ? `, ${report2.skipped} unreadable lines skipped` : ""})`;
|
|
72750
|
+
return [head, ...report2.rows.map((r) => `${r.category} ${r.calls} calls ~${formatTokens(r.tokens)} tok avg ${formatTokens(r.avg)}${r.suggestion === "" ? "" : ` -> ${r.suggestion}`}`)];
|
|
72751
|
+
}
|
|
72752
|
+
async function tokensReport(ctx, input2) {
|
|
72753
|
+
const root = findRoot(ctx.cwd);
|
|
72754
|
+
const top = Math.max(1, input2.top ?? 10);
|
|
72755
|
+
const cutoff = input2.since === void 0 ? null : parseSince(input2.since, ctx.now());
|
|
72756
|
+
let source;
|
|
72757
|
+
let read;
|
|
72758
|
+
if (input2.transcript !== void 0) {
|
|
72759
|
+
const file2 = resolve16(ctx.cwd, input2.transcript);
|
|
72760
|
+
if (!existsSync12(file2)) return { data: { source: input2.transcript, since: input2.since ?? null, calls: 0, tokens: 0, skipped: 0, rows: [] }, lines: [`none: no transcript at ${input2.transcript}`], exit: 4 };
|
|
72761
|
+
source = input2.transcript;
|
|
72762
|
+
read = readTranscript(readFileSync18(file2, "utf8"));
|
|
72763
|
+
} else {
|
|
72764
|
+
const file2 = join30(root, LEDGER_PATH);
|
|
72765
|
+
if (!existsSync12(file2)) {
|
|
72766
|
+
return { data: { source: LEDGER_PATH, since: input2.since ?? null, calls: 0, tokens: 0, skipped: 0, rows: [] }, lines: [`none: no ledger at ${LEDGER_PATH}; the tool-call hook writes it, or pass --transcript <path.jsonl>`], exit: 4 };
|
|
72767
|
+
}
|
|
72768
|
+
source = LEDGER_PATH;
|
|
72769
|
+
read = readLedger(readFileSync18(file2, "utf8"));
|
|
72770
|
+
}
|
|
72771
|
+
const calls = cutoff === null ? read.calls : read.calls.filter((c2) => c2.ts >= cutoff);
|
|
72772
|
+
const report2 = buildReport(calls, top, source, input2.since ?? null, read.skipped);
|
|
72773
|
+
if (calls.length === 0) return { data: report2, lines: [`none: no tool calls${input2.since === void 0 ? "" : ` since ${input2.since}`} in ${source}`], exit: 4 };
|
|
72774
|
+
return { data: report2, lines: reportLines(report2), exit: 0 };
|
|
72775
|
+
}
|
|
72776
|
+
|
|
72777
|
+
// ../cli/src/token/commands.ts
|
|
72778
|
+
function intFlag(values, name2, min = 0) {
|
|
72779
|
+
const raw = values[name2];
|
|
72780
|
+
if (typeof raw !== "string") return void 0;
|
|
72781
|
+
const n = Number(raw);
|
|
72782
|
+
if (!Number.isInteger(n) || n < min) throw new CoreError(`--${name2} must be a whole number of at least ${min}; got "${raw}"`, { exit: 2, code: "usage" });
|
|
72783
|
+
return n;
|
|
72784
|
+
}
|
|
72785
|
+
var str = (values, name2) => typeof values[name2] === "string" ? values[name2] : void 0;
|
|
72786
|
+
var NOTE = "Output is plain text, one fact per line; --json prints the same facts as JSON. Exit 4 when nothing matches.";
|
|
72787
|
+
var TOKEN_COMMANDS = [
|
|
72788
|
+
{
|
|
72789
|
+
path: ["code", "find"],
|
|
72790
|
+
summary: "Find where a symbol is defined: one line each, kind, qualified name, path:line",
|
|
72791
|
+
description: `Looks the name up in the local code index (.harness/code-index.json) and prints "kind qualified path:line", best match first, at most --limit lines (default 20). Entries in files that changed since the index was built are replaced by a pattern scan, and the output says so. With no index, or one this checkout does not have, it prints one line saying so and falls back to a bounded literal search (git grep -n -w, at most 20 lines). ${NOTE} Use this in place of grep for "where is X defined".`,
|
|
72792
|
+
args: [{ name: "name", required: true, description: "Symbol name, or a qualified name such as Class.method" }],
|
|
72793
|
+
flags: [
|
|
72794
|
+
{ name: "kind", type: "string", value: "KIND", description: "Only this kind: function, class, interface, type, constant, method, variable, property, namespace" },
|
|
72795
|
+
{ name: "limit", type: "string", value: "N", default: "20", description: "Most lines to print (default 20)" }
|
|
72796
|
+
],
|
|
72797
|
+
examples: ["overlane code find hashSecret", "overlane code find Registry --kind class --limit 5"],
|
|
72798
|
+
keywords: ["grep", "where is defined", "definition", "symbol", "find function", "find class", "locate", "code index", "navigate"],
|
|
72799
|
+
run: (ctx, v, p2) => codeFind(ctx, { name: p2[0], kind: str(v, "kind"), limit: intFlag(v, "limit", 1) })
|
|
72800
|
+
},
|
|
72801
|
+
{
|
|
72802
|
+
path: ["code", "show"],
|
|
72803
|
+
summary: "Print one symbol's source with line numbers, instead of cat or sed on a whole file",
|
|
72804
|
+
description: `Takes a symbol name or path:line and prints only that symbol's span: a header "path:start-end kind name", then numbered lines. The end comes from the next symbol in the file, tightened by a bracket scan (an indent scan for Python). Output is capped at 200 lines; a longer span ends with "truncated, N more lines: overlane code show path:line --from X". --context adds lines around the span. When a name has several definitions the best one is shown and the others are listed on an "also:" line. ${NOTE}`,
|
|
72805
|
+
args: [{ name: "target", required: true, description: "A symbol name, or path:line (any line inside the symbol)" }],
|
|
72806
|
+
flags: [
|
|
72807
|
+
{ name: "context", type: "string", value: "N", default: "0", description: "Extra lines before and after the span" },
|
|
72808
|
+
{ name: "from", type: "string", value: "LINE", description: "Start printing at this line (continue a truncated span)" },
|
|
72809
|
+
{ name: "max", type: "string", value: "N", default: "200", description: "Most lines to print (default 200)" },
|
|
72810
|
+
{ name: "kind", type: "string", value: "KIND", description: "When showing by name, only this kind" }
|
|
72811
|
+
],
|
|
72812
|
+
examples: ["overlane code show hashSecret", "overlane code show apps/api-worker/src/identity/store.ts:24 --context 3"],
|
|
72813
|
+
keywords: ["cat", "sed", "read function", "read file", "show source", "print symbol", "line range", "view code"],
|
|
72814
|
+
run: (ctx, v, p2) => codeShow(ctx, { target: p2[0], context: intFlag(v, "context", 0), from: intFlag(v, "from", 1), max: intFlag(v, "max", 1), kind: str(v, "kind") })
|
|
72815
|
+
},
|
|
72816
|
+
{
|
|
72817
|
+
path: ["code", "outline"],
|
|
72818
|
+
summary: "List a file's symbols, one per line: line, kind, name",
|
|
72819
|
+
description: `Prints "line kind name" for each symbol the code index holds for the file (properties are left out unless --all). A file that changed since the index was built, or is not in it, gets a pattern-based outline and a one-line note. ${NOTE}`,
|
|
72820
|
+
args: [{ name: "path", required: true, description: "File path, relative to the repository root or the current directory" }],
|
|
72821
|
+
flags: [{ name: "all", type: "boolean", description: "Also list properties and fields" }],
|
|
72822
|
+
examples: ["overlane code outline packages/cli/src/registry/run.ts"],
|
|
72823
|
+
keywords: ["file map", "list functions in file", "outline", "table of contents", "symbols in file"],
|
|
72824
|
+
run: (ctx, v, p2) => codeOutline(ctx, { path: p2[0], all: v["all"] === true })
|
|
72825
|
+
},
|
|
72826
|
+
{
|
|
72827
|
+
path: ["code", "refs"],
|
|
72828
|
+
summary: "List callers and other uses of a symbol: path:line plus the trimmed line",
|
|
72829
|
+
description: `Prints the callers the index records for the name ("caller qualified path:line"), then the literal git grep -n -w matches that are not already listed, as "path:line text". Definitions and import lines are not repeated (import lines are counted). At most --limit lines (default 30). ${NOTE}`,
|
|
72830
|
+
args: [{ name: "name", required: true, description: "Symbol name" }],
|
|
72831
|
+
flags: [{ name: "limit", type: "string", value: "N", default: "30", description: "Most lines to print (default 30)" }],
|
|
72832
|
+
examples: ["overlane code refs hashSecret", "overlane code refs createRegistry --limit 10"],
|
|
72833
|
+
keywords: ["who calls", "callers", "usages", "references", "find usages", "grep references"],
|
|
72834
|
+
run: (ctx, v, p2) => codeRefs(ctx, { name: p2[0], limit: intFlag(v, "limit", 1) })
|
|
72835
|
+
},
|
|
72836
|
+
{
|
|
72837
|
+
path: ["exec"],
|
|
72838
|
+
summary: "Run a command; keep the full output in a log and print a short status and parsed summary",
|
|
72839
|
+
description: `Runs the command after -- through the shell, streams nothing, saves stdout and stderr to .harness/logs/TIMESTAMP-NAME.log, and prints one line "ok|FAIL exit=N 12.3s log=PATH" followed by a summary parsed from the output: vitest (files and tests per package, each failing test with the first lines of its assertion), tsc (error count and the first 10 errors), esbuild and astro build errors, wrangler deploy (version id, routes, errors), wrangler d1 (bookmark, applied migrations), git push (ref updates or the rejection). A command it does not know prints nothing more on success and its last 20 lines on failure. The exit code is the command's. A failure always shows its cause; the full text is in the log.`,
|
|
72840
|
+
args: [{ name: "command", required: true, variadic: true, description: "The command and its arguments, after --" }],
|
|
72841
|
+
flags: [{ name: "name", type: "string", value: "NAME", description: "Label used in the log file name" }],
|
|
72842
|
+
examples: ["overlane exec -- pnpm -r test", "overlane exec --name typecheck -- pnpm -r typecheck", "overlane exec -- 'git push -u origin wip/unit'"],
|
|
72843
|
+
keywords: ["run tests", "run build", "typecheck", "wrangler deploy", "short output", "log to file", "quiet", "test summary", "git push"],
|
|
72844
|
+
run: (ctx, v, p2) => execCommand(ctx, { tokens: p2, name: str(v, "name") })
|
|
72845
|
+
},
|
|
72846
|
+
{
|
|
72847
|
+
path: ["brief"],
|
|
72848
|
+
summary: "Repository state in one line and the open P0 lines of TASKS.md",
|
|
72849
|
+
description: `git: "branch sha7 ahead N behind N of upstream, N dirty, last: subject" in one line, in place of git status and git log. tasks: the unticked "- [ ] P0" lines of TASKS.md cut to 160 characters (a repository without TASKS.md points at overlane task status). all (the default) prints both. Works offline.`,
|
|
72850
|
+
args: [{ name: "what", required: false, description: "git, tasks or all (default all)" }],
|
|
72851
|
+
flags: [],
|
|
72852
|
+
examples: ["overlane brief", "overlane brief git", "overlane brief tasks"],
|
|
72853
|
+
keywords: ["git status", "git log", "branch", "dirty", "last commit", "open tasks", "P0", "state of the repo"],
|
|
72854
|
+
run: (ctx, _v, p2) => {
|
|
72855
|
+
const mode = p2[0];
|
|
72856
|
+
if (mode !== void 0 && mode !== "git" && mode !== "tasks" && mode !== "all") throw new CoreError(`brief takes git, tasks or all; got "${mode}"`, { exit: 2, code: "usage", hint: "overlane brief git" });
|
|
72857
|
+
return brief(ctx, { mode });
|
|
72858
|
+
}
|
|
72859
|
+
},
|
|
72860
|
+
{
|
|
72861
|
+
path: ["tokens", "report"],
|
|
72862
|
+
summary: "Where tool-call tokens went, by category, with the terse command that replaces each",
|
|
72863
|
+
description: `Reads .harness/token-ledger.jsonl (one JSON object per tool call: ts, tool, category, inChars, outChars, command) or, with --transcript, a Claude Code transcript (tool_use and tool_result pairs, Bash calls categorised by command: test, typecheck, wrangler, build, git, grep/sed/cat, curl, other). Prints the top categories by estimated tokens (characters / 4) with calls, average and the suggested replacement: grep, cat and sed to overlane code find, show, outline and refs; test, typecheck, build and wrangler to overlane exec; git status and log to overlane brief git. ${NOTE}`,
|
|
72864
|
+
args: [],
|
|
72865
|
+
flags: [
|
|
72866
|
+
{ name: "since", type: "string", value: "WINDOW", description: "Only calls in this window: 7d, 12h, 30m, 2w or a date" },
|
|
72867
|
+
{ name: "top", type: "string", value: "N", default: "10", description: "Categories to print (default 10)" },
|
|
72868
|
+
{ name: "transcript", type: "string", value: "PATH", description: "Read a Claude Code transcript (.jsonl) instead of the ledger" }
|
|
72869
|
+
],
|
|
72870
|
+
examples: ["overlane tokens report --since 7d", "overlane tokens report --transcript ~/.claude/projects/x/session.jsonl --top 5"],
|
|
72871
|
+
keywords: ["token burn", "token usage", "cost", "tool output size", "what is expensive", "reduce tokens"],
|
|
72872
|
+
run: (ctx, v) => tokensReport(ctx, { since: str(v, "since"), top: intFlag(v, "top", 1), transcript: str(v, "transcript") })
|
|
72873
|
+
}
|
|
72874
|
+
];
|
|
72875
|
+
var LEAN_ROOTS = new Set(TOKEN_COMMANDS.map((c2) => c2.path[0]));
|
|
72876
|
+
|
|
72877
|
+
// ../cli/src/commands/token-lib.ts
|
|
72878
|
+
function tokenCommand(path, result, effect = "read") {
|
|
72879
|
+
const table2 = TOKEN_COMMANDS.find((c2) => c2.path.join(" ") === path.join(" "));
|
|
72880
|
+
if (table2 === void 0) throw new Error(`no token command ${path.join(" ")}`);
|
|
72881
|
+
return defineCommand({
|
|
72882
|
+
path: table2.path,
|
|
72883
|
+
summary: table2.summary,
|
|
72884
|
+
description: table2.description,
|
|
72885
|
+
args: table2.args,
|
|
72886
|
+
flags: table2.flags,
|
|
72887
|
+
examples: table2.examples,
|
|
72888
|
+
keywords: table2.keywords,
|
|
72889
|
+
effect,
|
|
72890
|
+
needsAuth: false,
|
|
72891
|
+
needsNetwork: false,
|
|
72892
|
+
textDefault: true,
|
|
72893
|
+
result,
|
|
72894
|
+
handler: async (inv) => {
|
|
72895
|
+
if (inv.dryRun) {
|
|
72896
|
+
const line3 = inv.positionals.join(" ");
|
|
72897
|
+
return planOutcome(inv.deps, dryRunPlan({ commands: [line3], writes: [{ path: ".harness/logs", action: "write", description: "the full output of the command, in a new log file" }] }));
|
|
72898
|
+
}
|
|
72899
|
+
const ctx = nodeCtx(inv.deps.paths.cwd, inv.deps.env, inv.deps.now);
|
|
72900
|
+
try {
|
|
72901
|
+
const out2 = await table2.run(ctx, inv.values, inv.positionals);
|
|
72902
|
+
for (const line3 of out2.lines) say(inv.deps, line3);
|
|
72903
|
+
return { data: out2.data, exit: out2.exit };
|
|
72904
|
+
} catch (error62) {
|
|
72905
|
+
if (error62 instanceof CoreError) throw new CliError(error62.message, { code: error62.code, exit: error62.exit, ...error62.hint === void 0 ? {} : { hint: error62.hint } });
|
|
72906
|
+
throw error62;
|
|
72907
|
+
}
|
|
72908
|
+
}
|
|
72909
|
+
});
|
|
72910
|
+
}
|
|
72911
|
+
|
|
72912
|
+
// ../cli/src/commands/code.ts
|
|
72913
|
+
var Show2 = CodeNavMeta.extend({
|
|
72914
|
+
path: external_exports.string(),
|
|
72915
|
+
kind: external_exports.string(),
|
|
72916
|
+
qualified: external_exports.string(),
|
|
72917
|
+
start: external_exports.number().int(),
|
|
72918
|
+
end: external_exports.number().int(),
|
|
72919
|
+
from: external_exports.number().int(),
|
|
72920
|
+
to: external_exports.number().int(),
|
|
72921
|
+
truncated: external_exports.boolean(),
|
|
72922
|
+
remaining: external_exports.number().int(),
|
|
72923
|
+
/** Numbered source lines, "N<TAB>text". */
|
|
72924
|
+
text: external_exports.array(external_exports.string()),
|
|
72925
|
+
also: external_exports.array(external_exports.object({ kind: external_exports.string(), qualified: external_exports.string(), path: external_exports.string(), line: external_exports.number().int() }).passthrough())
|
|
72926
|
+
}).passthrough();
|
|
72927
|
+
var codeCommands = [
|
|
72928
|
+
tokenCommand(["code", "find"], CodeFindAnswer.passthrough()),
|
|
72929
|
+
tokenCommand(["code", "show"], Show2),
|
|
72930
|
+
tokenCommand(["code", "outline"], CodeOutlineAnswer.passthrough()),
|
|
72931
|
+
tokenCommand(["code", "refs"], CodeRefsAnswer.passthrough())
|
|
72932
|
+
];
|
|
72933
|
+
|
|
72934
|
+
// ../cli/src/commands/exec.ts
|
|
72935
|
+
init_zod();
|
|
72936
|
+
var execCommands = [
|
|
72937
|
+
tokenCommand(
|
|
72938
|
+
["exec"],
|
|
72939
|
+
withDryRun(external_exports.object({ ok: external_exports.boolean(), exit: external_exports.number().int(), seconds: external_exports.number(), log: external_exports.string(), command: external_exports.string(), kinds: external_exports.array(external_exports.string()), summary: external_exports.array(external_exports.string()) }).strict()),
|
|
72940
|
+
"write"
|
|
72941
|
+
)
|
|
72942
|
+
];
|
|
72943
|
+
|
|
72944
|
+
// ../cli/src/commands/brief.ts
|
|
72945
|
+
init_zod();
|
|
72946
|
+
var Git = external_exports.object({ branch: external_exports.string(), sha: external_exports.string(), upstream: external_exports.string().nullable(), ahead: external_exports.number().int(), behind: external_exports.number().int(), dirty: external_exports.number().int(), subject: external_exports.string() }).strict();
|
|
72947
|
+
var Tasks = external_exports.object({ source: external_exports.enum(["TASKS.md", "none"]), open: external_exports.array(external_exports.string()), more: external_exports.number().int() }).strict();
|
|
72948
|
+
var briefCommands = [tokenCommand(["brief"], external_exports.object({ git: Git.nullable().optional(), tasks: Tasks.optional() }).strict())];
|
|
72949
|
+
|
|
72950
|
+
// ../cli/src/commands/tokens.ts
|
|
72951
|
+
init_zod();
|
|
72952
|
+
var Row = external_exports.object({ category: external_exports.string(), calls: external_exports.number().int(), inTokens: external_exports.number().int(), outTokens: external_exports.number().int(), tokens: external_exports.number().int(), avg: external_exports.number().int(), suggestion: external_exports.string() }).strict();
|
|
72953
|
+
var tokensCommands = [
|
|
72954
|
+
tokenCommand(["tokens", "report"], external_exports.object({ source: external_exports.string(), since: external_exports.string().nullable(), calls: external_exports.number().int(), tokens: external_exports.number().int(), skipped: external_exports.number().int(), rows: external_exports.array(Row) }).strict())
|
|
72955
|
+
];
|
|
72956
|
+
|
|
71444
72957
|
// ../cli/src/commands/index.ts
|
|
71445
72958
|
function coreCommands() {
|
|
71446
72959
|
return [
|
|
@@ -71480,7 +72993,11 @@ function coreCommands() {
|
|
|
71480
72993
|
...repoCommands,
|
|
71481
72994
|
...ciCommands,
|
|
71482
72995
|
...deployCommands,
|
|
71483
|
-
...enterpriseCommands
|
|
72996
|
+
...enterpriseCommands,
|
|
72997
|
+
...codeCommands,
|
|
72998
|
+
...execCommands,
|
|
72999
|
+
...briefCommands,
|
|
73000
|
+
...tokensCommands
|
|
71484
73001
|
];
|
|
71485
73002
|
}
|
|
71486
73003
|
function createRegistry(extra = []) {
|
|
@@ -71553,10 +73070,10 @@ function extractGlobals(argv) {
|
|
|
71553
73070
|
}
|
|
71554
73071
|
return out2;
|
|
71555
73072
|
}
|
|
71556
|
-
var
|
|
71557
|
-
function outputMode(globals, deps) {
|
|
73073
|
+
var quote3 = (token) => /^[A-Za-z0-9_@%+=:,./-]+$/.test(token) ? token : `'${token.replaceAll("'", "'\\''")}'`;
|
|
73074
|
+
function outputMode(globals, deps, textDefault) {
|
|
71558
73075
|
if (globals.json) return "json";
|
|
71559
|
-
if (globals.text) return "text";
|
|
73076
|
+
if (globals.text || textDefault) return "text";
|
|
71560
73077
|
return deps.stdoutIsTTY ?? deps.isTTY ? "text" : "json";
|
|
71561
73078
|
}
|
|
71562
73079
|
function printLines(deps, lines) {
|
|
@@ -71586,7 +73103,7 @@ function unknownCommand(registry2, tokens) {
|
|
|
71586
73103
|
const near = closestCommands(pool, tokens);
|
|
71587
73104
|
const first = near[0];
|
|
71588
73105
|
if (first === void 0) {
|
|
71589
|
-
return new UsageError(`unknown command "${typed}"; run \`overlane commands\` to list them or \`overlane search "<task>"\` to find one`, { code: "unknown_command", hint: `overlane search ${
|
|
73106
|
+
return new UsageError(`unknown command "${typed}"; run \`overlane commands\` to list them or \`overlane search "<task>"\` to find one`, { code: "unknown_command", hint: `overlane search ${quote3(typed)}` });
|
|
71590
73107
|
}
|
|
71591
73108
|
return new UsageError(`unknown command "${typed}"; did you mean: ${near.map((spec) => `overlane ${commandName(spec)}`).join(", ")}`, {
|
|
71592
73109
|
code: "unknown_command",
|
|
@@ -71605,7 +73122,7 @@ async function runCli(argv, deps, options) {
|
|
|
71605
73122
|
const { registry: registry2 } = options;
|
|
71606
73123
|
const version2 = options.version ?? "";
|
|
71607
73124
|
const globals = extractGlobals(argv);
|
|
71608
|
-
const mode = outputMode(globals, deps);
|
|
73125
|
+
const mode = outputMode(globals, deps, registry2.find(globals.tokens)?.spec.textDefault === true);
|
|
71609
73126
|
rememberSecret(deps.env["HARNESS_TOKEN"]);
|
|
71610
73127
|
const inner = mode === "json" ? { ...deps, stdout: globals.verbose ? (text) => deps.stderr(redact(text)) : () => void 0 } : deps;
|
|
71611
73128
|
const [first, ...more] = globals.tokens;
|
|
@@ -71633,7 +73150,7 @@ async function runCli(argv, deps, options) {
|
|
|
71633
73150
|
const parsed = spec.style === "passthrough" ? { values: {}, positionals: [] } : parseFor(spec, rest);
|
|
71634
73151
|
const safety = spec.style === "passthrough" ? safetyFlags(rest) : { dryRun: parsed.values["dry-run"] === true, force: parsed.values["force"] === true };
|
|
71635
73152
|
if (spec.effect === "destructive" && !safety.dryRun && !safety.force && !deps.isTTY) {
|
|
71636
|
-
const line3 = ["overlane", ...globals.tokens, "--force"].map(
|
|
73153
|
+
const line3 = ["overlane", ...globals.tokens, "--force"].map(quote3).join(" ");
|
|
71637
73154
|
throw new UsageError(`overlane ${commandName(spec)} is destructive and there is no terminal to confirm on; pass --force to proceed, or --dry-run to preview`, {
|
|
71638
73155
|
code: "force_required",
|
|
71639
73156
|
hint: line3
|
|
@@ -71701,37 +73218,37 @@ init_src2();
|
|
|
71701
73218
|
|
|
71702
73219
|
// src/data-dir.ts
|
|
71703
73220
|
import { homedir } from "node:os";
|
|
71704
|
-
import { join as
|
|
73221
|
+
import { join as join35 } from "node:path";
|
|
71705
73222
|
function dataDir(env = process.env, home = homedir()) {
|
|
71706
73223
|
const override = env["MVRX_DATA_DIR"];
|
|
71707
73224
|
if (override !== void 0 && override !== "") return override;
|
|
71708
|
-
const base5 = env["XDG_DATA_HOME"] ?? (process.platform === "win32" ? env["LOCALAPPDATA"] : void 0) ?? (process.platform === "darwin" ?
|
|
71709
|
-
return
|
|
73225
|
+
const base5 = env["XDG_DATA_HOME"] ?? (process.platform === "win32" ? env["LOCALAPPDATA"] : void 0) ?? (process.platform === "darwin" ? join35(home, "Library", "Application Support") : join35(home, ".local", "share"));
|
|
73226
|
+
return join35(base5, "mvrx-harness");
|
|
71710
73227
|
}
|
|
71711
73228
|
function marketplaceRoot(env = process.env, home = homedir()) {
|
|
71712
|
-
return
|
|
73229
|
+
return join35(dataDir(env, home), "marketplace");
|
|
71713
73230
|
}
|
|
71714
73231
|
|
|
71715
73232
|
// src/plugin.ts
|
|
71716
|
-
import { readFileSync as
|
|
71717
|
-
import { join as
|
|
73233
|
+
import { readFileSync as readFileSync20 } from "node:fs";
|
|
73234
|
+
import { join as join37 } from "node:path";
|
|
71718
73235
|
import { parseArgs as parseArgs3 } from "node:util";
|
|
71719
73236
|
|
|
71720
73237
|
// src/marketplace.ts
|
|
71721
73238
|
init_src();
|
|
71722
73239
|
import { createHash as createHash7 } from "node:crypto";
|
|
71723
|
-
import { cpSync, existsSync as
|
|
71724
|
-
import { dirname as
|
|
73240
|
+
import { cpSync, existsSync as existsSync13, mkdirSync as mkdirSync11, readdirSync as readdirSync3, readFileSync as readFileSync19, renameSync as renameSync7, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync10 } from "node:fs";
|
|
73241
|
+
import { dirname as dirname12, join as join36, relative as relative4, sep } from "node:path";
|
|
71725
73242
|
var CLIENT_DIRS = ["claude", "codex"];
|
|
71726
73243
|
var EMBEDDED_MANIFEST = "release-manifest.json";
|
|
71727
|
-
var INSTALLED_MANIFEST =
|
|
73244
|
+
var INSTALLED_MANIFEST = join36(".release", "manifest.json");
|
|
71728
73245
|
var MarketplaceError = class extends Error {
|
|
71729
73246
|
};
|
|
71730
73247
|
function loadEmbedded(packageRoot2) {
|
|
71731
|
-
const dir =
|
|
71732
|
-
const path =
|
|
71733
|
-
if (!
|
|
71734
|
-
const parsed = ReleaseManifest.safeParse(JSON.parse(
|
|
73248
|
+
const dir = join36(packageRoot2, "plugins");
|
|
73249
|
+
const path = join36(dir, EMBEDDED_MANIFEST);
|
|
73250
|
+
if (!existsSync13(path)) throw new MarketplaceError(`this package has no embedded plugin release (${path} is missing)`);
|
|
73251
|
+
const parsed = ReleaseManifest.safeParse(JSON.parse(readFileSync19(path, "utf8")));
|
|
71735
73252
|
if (!parsed.success) throw new MarketplaceError(`the embedded release manifest is invalid: ${parsed.error.message}`);
|
|
71736
73253
|
return { dir, manifest: parsed.data };
|
|
71737
73254
|
}
|
|
@@ -71739,12 +73256,12 @@ function sha2562(data) {
|
|
|
71739
73256
|
return `sha256:${createHash7("sha256").update(data).digest("hex")}`;
|
|
71740
73257
|
}
|
|
71741
73258
|
function listFiles(root, dir = root) {
|
|
71742
|
-
if (!
|
|
73259
|
+
if (!existsSync13(dir)) return [];
|
|
71743
73260
|
const out2 = [];
|
|
71744
73261
|
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
71745
|
-
const full =
|
|
73262
|
+
const full = join36(dir, entry.name);
|
|
71746
73263
|
if (entry.isDirectory()) out2.push(...listFiles(root, full));
|
|
71747
|
-
else out2.push(
|
|
73264
|
+
else out2.push(relative4(root, full).split(sep).join("/"));
|
|
71748
73265
|
}
|
|
71749
73266
|
return out2.sort();
|
|
71750
73267
|
}
|
|
@@ -71754,15 +73271,15 @@ async function verifyTree(treeRoot, manifest) {
|
|
|
71754
73271
|
if (recomputed !== manifest.digest) problems.push(`manifest digest ${manifest.digest} does not match its file list (${recomputed})`);
|
|
71755
73272
|
const listed = new Set(manifest.files.map((file2) => file2.path));
|
|
71756
73273
|
for (const file2 of manifest.files) {
|
|
71757
|
-
const path =
|
|
71758
|
-
if (!
|
|
73274
|
+
const path = join36(treeRoot, file2.path);
|
|
73275
|
+
if (!existsSync13(path)) {
|
|
71759
73276
|
problems.push(`missing: ${file2.path}`);
|
|
71760
73277
|
continue;
|
|
71761
73278
|
}
|
|
71762
|
-
if (sha2562(
|
|
73279
|
+
if (sha2562(readFileSync19(path)) !== file2.digest) problems.push(`modified: ${file2.path}`);
|
|
71763
73280
|
}
|
|
71764
73281
|
for (const client of CLIENT_DIRS) {
|
|
71765
|
-
for (const found of listFiles(
|
|
73282
|
+
for (const found of listFiles(join36(treeRoot, client))) {
|
|
71766
73283
|
if (!listed.has(`${client}/${found}`)) problems.push(`unlisted: ${client}/${found}`);
|
|
71767
73284
|
}
|
|
71768
73285
|
}
|
|
@@ -71770,7 +73287,7 @@ async function verifyTree(treeRoot, manifest) {
|
|
|
71770
73287
|
}
|
|
71771
73288
|
function readInstalledManifest(target2) {
|
|
71772
73289
|
try {
|
|
71773
|
-
const parsed = ReleaseManifest.safeParse(JSON.parse(
|
|
73290
|
+
const parsed = ReleaseManifest.safeParse(JSON.parse(readFileSync19(join36(target2, INSTALLED_MANIFEST), "utf8")));
|
|
71774
73291
|
return parsed.success ? parsed.data : null;
|
|
71775
73292
|
} catch {
|
|
71776
73293
|
return null;
|
|
@@ -71795,23 +73312,23 @@ async function syncMarketplace(embedded, target2) {
|
|
|
71795
73312
|
const staging = `${target2}.new-${process.pid}`;
|
|
71796
73313
|
const previous = `${target2}.old-${process.pid}`;
|
|
71797
73314
|
rmSync4(staging, { recursive: true, force: true });
|
|
71798
|
-
|
|
73315
|
+
mkdirSync11(staging, { recursive: true });
|
|
71799
73316
|
try {
|
|
71800
73317
|
for (const client of CLIENT_DIRS) {
|
|
71801
|
-
if (
|
|
73318
|
+
if (existsSync13(join36(embedded.dir, client))) cpSync(join36(embedded.dir, client), join36(staging, client), { recursive: true });
|
|
71802
73319
|
}
|
|
71803
|
-
|
|
71804
|
-
writeFileSync10(
|
|
73320
|
+
mkdirSync11(join36(staging, ".release"), { recursive: true });
|
|
73321
|
+
writeFileSync10(join36(staging, INSTALLED_MANIFEST), `${JSON.stringify(embedded.manifest, null, 2)}
|
|
71805
73322
|
`);
|
|
71806
73323
|
const after = await verifyTree(staging, embedded.manifest);
|
|
71807
73324
|
if (after.length > 0) throw new MarketplaceError(`the copied plugin files do not match the release manifest:
|
|
71808
73325
|
${after.join("\n ")}`);
|
|
71809
|
-
|
|
71810
|
-
if (
|
|
73326
|
+
mkdirSync11(dirname12(target2), { recursive: true });
|
|
73327
|
+
if (existsSync13(target2)) renameSync7(target2, previous);
|
|
71811
73328
|
try {
|
|
71812
73329
|
renameSync7(staging, target2);
|
|
71813
73330
|
} catch (error62) {
|
|
71814
|
-
if (
|
|
73331
|
+
if (existsSync13(previous)) renameSync7(previous, target2);
|
|
71815
73332
|
throw error62;
|
|
71816
73333
|
}
|
|
71817
73334
|
rmSync4(previous, { recursive: true, force: true });
|
|
@@ -71821,7 +73338,7 @@ async function syncMarketplace(embedded, target2) {
|
|
|
71821
73338
|
}
|
|
71822
73339
|
async function ensureMarketplace(embedded, target2) {
|
|
71823
73340
|
const installed = readInstalledManifest(target2);
|
|
71824
|
-
const present =
|
|
73341
|
+
const present = existsSync13(target2) && statSync3(target2).isDirectory();
|
|
71825
73342
|
if (installed !== null && present && !isNewer(embedded.manifest.version, installed.version)) return false;
|
|
71826
73343
|
await syncMarketplace(embedded, target2);
|
|
71827
73344
|
return true;
|
|
@@ -71833,8 +73350,8 @@ var PLUGIN_USAGE = ` overlane plugin install [--scope project|user] [--client c
|
|
|
71833
73350
|
var PluginUsageError = class extends Error {
|
|
71834
73351
|
};
|
|
71835
73352
|
function readNames(treeRoot, client) {
|
|
71836
|
-
const file2 = client === "claude" ?
|
|
71837
|
-
const parsed = JSON.parse(
|
|
73353
|
+
const file2 = client === "claude" ? join37(treeRoot, "claude", ".claude-plugin", "marketplace.json") : join37(treeRoot, "codex", ".agents", "plugins", "marketplace.json");
|
|
73354
|
+
const parsed = JSON.parse(readFileSync20(file2, "utf8"));
|
|
71838
73355
|
const record3 = parsed;
|
|
71839
73356
|
const plugin = record3.plugins?.[0]?.name;
|
|
71840
73357
|
if (typeof record3.name !== "string" || typeof plugin !== "string") throw new MarketplaceError(`${file2} names no marketplace or plugin`);
|
|
@@ -71880,7 +73397,7 @@ ${PLUGIN_USAGE}`);
|
|
|
71880
73397
|
const key = `${names.plugin}@${names.marketplace}`;
|
|
71881
73398
|
if (!await available(deps, client)) {
|
|
71882
73399
|
if (explicit !== void 0) {
|
|
71883
|
-
deps.stderr(`overlane: \`${client}\` was not found on PATH; the marketplace is at ${
|
|
73400
|
+
deps.stderr(`overlane: \`${client}\` was not found on PATH; the marketplace is at ${join37(root, client)}
|
|
71884
73401
|
`);
|
|
71885
73402
|
failed = true;
|
|
71886
73403
|
} else {
|
|
@@ -71892,7 +73409,7 @@ ${PLUGIN_USAGE}`);
|
|
|
71892
73409
|
ranAny = true;
|
|
71893
73410
|
deps.stdout(`${client}:
|
|
71894
73411
|
`);
|
|
71895
|
-
const dir =
|
|
73412
|
+
const dir = join37(root, client);
|
|
71896
73413
|
const steps = client === "claude" ? [
|
|
71897
73414
|
["claude", ["plugin", "marketplace", "add", dir, "--scope", scope]],
|
|
71898
73415
|
["claude", ["plugin", "marketplace", "update", names.marketplace]],
|
|
@@ -72058,13 +73575,13 @@ var pluginInstallCommand = defineCommand({
|
|
|
72058
73575
|
var packageCommands = [indexBuildCommand, indexUploadCommand, shimCommand, pluginInstallCommand];
|
|
72059
73576
|
|
|
72060
73577
|
// src/deps.ts
|
|
72061
|
-
import { execFile as
|
|
73578
|
+
import { execFile as execFile5, spawn as spawn2 } from "node:child_process";
|
|
72062
73579
|
import { homedir as homedir3 } from "node:os";
|
|
72063
|
-
import { join as
|
|
73580
|
+
import { join as join40 } from "node:path";
|
|
72064
73581
|
import { createInterface } from "node:readline/promises";
|
|
72065
73582
|
function exec(command, args2, options) {
|
|
72066
73583
|
return new Promise((resolveResult) => {
|
|
72067
|
-
|
|
73584
|
+
execFile5(command, [...args2], { cwd: options?.cwd, encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }, (error62, stdout, stderr) => {
|
|
72068
73585
|
if (error62 === null) {
|
|
72069
73586
|
resolveResult({ code: 0, stdout, stderr });
|
|
72070
73587
|
} else if ("code" in error62 && typeof error62.code === "number") {
|
|
@@ -72089,7 +73606,7 @@ var noKeychain = {
|
|
|
72089
73606
|
function openBrowser(url2) {
|
|
72090
73607
|
const [command, args2] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
72091
73608
|
return new Promise((resolveOpen, reject) => {
|
|
72092
|
-
const child =
|
|
73609
|
+
const child = spawn2(command, args2, { stdio: "ignore", detached: true });
|
|
72093
73610
|
child.once("error", reject);
|
|
72094
73611
|
child.once("spawn", () => {
|
|
72095
73612
|
child.unref();
|
|
@@ -72106,8 +73623,8 @@ async function confirm(question) {
|
|
|
72106
73623
|
}
|
|
72107
73624
|
}
|
|
72108
73625
|
function configDir2(env) {
|
|
72109
|
-
const base5 = env["XDG_CONFIG_HOME"] ?? (process.platform === "win32" ? env["APPDATA"] : void 0) ??
|
|
72110
|
-
return
|
|
73626
|
+
const base5 = env["XDG_CONFIG_HOME"] ?? (process.platform === "win32" ? env["APPDATA"] : void 0) ?? join40(homedir3(), ".config");
|
|
73627
|
+
return join40(base5, "mvrx-harness");
|
|
72111
73628
|
}
|
|
72112
73629
|
function createDeps2(env = process.env) {
|
|
72113
73630
|
return {
|