megareviewer 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/server.js +1755 -632
- package/dist/web/assets/{core-BA-T5xXr.js → core-CYFBPA6U.js} +1 -1
- package/dist/web/assets/index-BSQIpAcx.css +1 -0
- package/dist/web/assets/index-UMMt3ddb.js +68 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -2
- package/dist/web/assets/index-BMYUoVGR.js +0 -68
- package/dist/web/assets/index-CdCdWN06.css +0 -1
package/dist/server.js
CHANGED
|
@@ -265,16 +265,16 @@ var init_values = __esm({
|
|
|
265
265
|
var sleep;
|
|
266
266
|
var init_sleep = __esm({
|
|
267
267
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
268
|
-
sleep = (ms, signal) => new Promise((
|
|
268
|
+
sleep = (ms, signal) => new Promise((resolve5) => {
|
|
269
269
|
if (signal?.aborted)
|
|
270
|
-
return
|
|
270
|
+
return resolve5();
|
|
271
271
|
const onAbort = () => {
|
|
272
272
|
clearTimeout(timer);
|
|
273
|
-
|
|
273
|
+
resolve5();
|
|
274
274
|
};
|
|
275
275
|
const timer = setTimeout(() => {
|
|
276
276
|
signal?.removeEventListener("abort", onAbort);
|
|
277
|
-
|
|
277
|
+
resolve5();
|
|
278
278
|
}, ms);
|
|
279
279
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
280
280
|
});
|
|
@@ -437,21 +437,21 @@ function registerRequestSignalCleanup(controller, signal, listener) {
|
|
|
437
437
|
}
|
|
438
438
|
function armAbandonmentBackstop(body2, controller) {
|
|
439
439
|
if (cleanups.has(controller))
|
|
440
|
-
|
|
440
|
+
registry2?.register(body2, controller, controller);
|
|
441
441
|
}
|
|
442
442
|
function releaseRequestSignal(controller) {
|
|
443
443
|
const cleanup = cleanups.get(controller);
|
|
444
444
|
if (cleanup) {
|
|
445
445
|
cleanups.delete(controller);
|
|
446
|
-
|
|
446
|
+
registry2?.unregister(controller);
|
|
447
447
|
cleanup();
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
var cleanups,
|
|
450
|
+
var cleanups, registry2;
|
|
451
451
|
var init_request_signal = __esm({
|
|
452
452
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/request-signal.mjs"() {
|
|
453
453
|
cleanups = /* @__PURE__ */ new WeakMap();
|
|
454
|
-
|
|
454
|
+
registry2 = typeof globalThis.FinalizationRegistry === "function" ? new globalThis.FinalizationRegistry((controller) => releaseRequestSignal(controller)) : null;
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
457
|
|
|
@@ -1221,8 +1221,8 @@ function getSpan(context2) {
|
|
|
1221
1221
|
function getActiveSpan() {
|
|
1222
1222
|
return getSpan(ContextAPI.getInstance().active());
|
|
1223
1223
|
}
|
|
1224
|
-
function setSpan(context2,
|
|
1225
|
-
return context2.setValue(SPAN_KEY,
|
|
1224
|
+
function setSpan(context2, span2) {
|
|
1225
|
+
return context2.setValue(SPAN_KEY, span2);
|
|
1226
1226
|
}
|
|
1227
1227
|
function deleteSpan(context2) {
|
|
1228
1228
|
return context2.deleteValue(SPAN_KEY);
|
|
@@ -1279,9 +1279,9 @@ var init_NoopTracer = __esm({
|
|
|
1279
1279
|
fn = arg4;
|
|
1280
1280
|
}
|
|
1281
1281
|
const parentContext = (_ctx = ctx) !== null && _ctx !== void 0 ? _ctx : contextApi.active();
|
|
1282
|
-
const
|
|
1283
|
-
const contextWithSpanSet = setSpan(parentContext,
|
|
1284
|
-
return contextApi.with(contextWithSpanSet, fn, void 0,
|
|
1282
|
+
const span2 = this.startSpan(name2, opts, parentContext);
|
|
1283
|
+
const contextWithSpanSet = setSpan(parentContext, span2);
|
|
1284
|
+
return contextApi.with(contextWithSpanSet, fn, void 0, span2);
|
|
1285
1285
|
}
|
|
1286
1286
|
};
|
|
1287
1287
|
}
|
|
@@ -1624,8 +1624,8 @@ function encodeUTF8(str) {
|
|
|
1624
1624
|
return (encodeUTF8_ ?? (encoder = new globalThis.TextEncoder(), encodeUTF8_ = encoder.encode.bind(encoder)))(str);
|
|
1625
1625
|
}
|
|
1626
1626
|
function decodeUTF8(bytes) {
|
|
1627
|
-
let
|
|
1628
|
-
return (decodeUTF8_ ?? (
|
|
1627
|
+
let decoder2;
|
|
1628
|
+
return (decodeUTF8_ ?? (decoder2 = new globalThis.TextDecoder(), decodeUTF8_ = decoder2.decode.bind(decoder2)))(bytes);
|
|
1629
1629
|
}
|
|
1630
1630
|
var encodeUTF8_, decodeUTF8_;
|
|
1631
1631
|
var init_bytes = __esm({
|
|
@@ -2219,7 +2219,7 @@ function startApiCallSpan(client, name2, options, settings) {
|
|
|
2219
2219
|
const startTime = Date.now();
|
|
2220
2220
|
const threadID = settings?.attributes?.[ATTR_ANTHROPIC_SESSION_THREAD_ID];
|
|
2221
2221
|
const conversationId = options?.openTelemetry?.conversationId ?? (typeof threadID === "string" ? threadID : void 0);
|
|
2222
|
-
const
|
|
2222
|
+
const span2 = tracer.startSpan(name2, {
|
|
2223
2223
|
kind: SpanKind.CLIENT,
|
|
2224
2224
|
// On the span from its start, with what the method gives, for a sampler to decide on.
|
|
2225
2225
|
attributes: {
|
|
@@ -2230,10 +2230,10 @@ function startApiCallSpan(client, name2, options, settings) {
|
|
|
2230
2230
|
...settings?.attributes
|
|
2231
2231
|
}
|
|
2232
2232
|
});
|
|
2233
|
-
if (!
|
|
2233
|
+
if (!span2.isRecording() && !(client.openTelemetry.propagation ? Object.keys(injectContext(span2)).length > 0 : trace.isSpanContextValid(span2.spanContext()))) {
|
|
2234
2234
|
return void 0;
|
|
2235
2235
|
}
|
|
2236
|
-
return { ...settings, span, name: name2, startTime };
|
|
2236
|
+
return { ...settings, span: span2, name: name2, startTime };
|
|
2237
2237
|
});
|
|
2238
2238
|
}
|
|
2239
2239
|
function setCreatedIDAttribute(call, data) {
|
|
@@ -2303,27 +2303,27 @@ function definedQuery(query, defined, contentParams) {
|
|
|
2303
2303
|
});
|
|
2304
2304
|
return parts2.length ? { value: parts2.join("&"), content } : void 0;
|
|
2305
2305
|
}
|
|
2306
|
-
function injectTraceHeaders(
|
|
2306
|
+
function injectTraceHeaders(span2, headers) {
|
|
2307
2307
|
const values = buildHeaders([headers]).values;
|
|
2308
|
-
for (const [key, value] of Object.entries(injectContext(
|
|
2308
|
+
for (const [key, value] of Object.entries(injectContext(span2))) {
|
|
2309
2309
|
values.set(key, value);
|
|
2310
2310
|
}
|
|
2311
2311
|
return values;
|
|
2312
2312
|
}
|
|
2313
|
-
function endApiCallSpan(
|
|
2314
|
-
if (!
|
|
2313
|
+
function endApiCallSpan(span2, result) {
|
|
2314
|
+
if (!span2.isRecording()) {
|
|
2315
2315
|
return;
|
|
2316
2316
|
}
|
|
2317
|
-
setResponseStatusCode(
|
|
2317
|
+
setResponseStatusCode(span2, result);
|
|
2318
2318
|
switch (result.status) {
|
|
2319
2319
|
case "success":
|
|
2320
|
-
|
|
2320
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
2321
2321
|
break;
|
|
2322
2322
|
case "error":
|
|
2323
|
-
setErrorStatus(
|
|
2323
|
+
setErrorStatus(span2, result.error);
|
|
2324
2324
|
break;
|
|
2325
2325
|
}
|
|
2326
|
-
|
|
2326
|
+
span2.end();
|
|
2327
2327
|
}
|
|
2328
2328
|
function observeStream(stream3, signal, observer) {
|
|
2329
2329
|
const iterate = stream3[Symbol.asyncIterator];
|
|
@@ -2383,38 +2383,38 @@ function observeStream(stream3, signal, observer) {
|
|
|
2383
2383
|
return iterator2;
|
|
2384
2384
|
};
|
|
2385
2385
|
}
|
|
2386
|
-
function endApiCallSpanWhenStreamEnds(
|
|
2387
|
-
if (!
|
|
2386
|
+
function endApiCallSpanWhenStreamEnds(span2, stream3, props) {
|
|
2387
|
+
if (!span2.isRecording())
|
|
2388
2388
|
return;
|
|
2389
|
-
|
|
2389
|
+
span2.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, props.response.status);
|
|
2390
2390
|
const isSSE = stream3 instanceof Stream;
|
|
2391
2391
|
observeStream(stream3, props.controller.signal, {
|
|
2392
2392
|
onEnd(end) {
|
|
2393
2393
|
if (end.reason === "failed")
|
|
2394
|
-
setErrorStatus(
|
|
2394
|
+
setErrorStatus(span2, end.error);
|
|
2395
2395
|
else if (end.reason === "completed" && !isSSE) {
|
|
2396
|
-
|
|
2396
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
2397
2397
|
}
|
|
2398
|
-
|
|
2398
|
+
span2.end();
|
|
2399
2399
|
}
|
|
2400
2400
|
});
|
|
2401
2401
|
}
|
|
2402
|
-
function setResponseStatusCode(
|
|
2402
|
+
function setResponseStatusCode(span2, result) {
|
|
2403
2403
|
const status = result.response?.status ?? (result.status === "error" && result.error instanceof APIError ? result.error.status : void 0);
|
|
2404
2404
|
if (status !== void 0) {
|
|
2405
|
-
|
|
2405
|
+
span2.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, status);
|
|
2406
2406
|
}
|
|
2407
2407
|
}
|
|
2408
|
-
function setErrorStatus(
|
|
2408
|
+
function setErrorStatus(span2, error62, type) {
|
|
2409
2409
|
if (error62 instanceof APIUserAbortError || isAbortError(error62)) {
|
|
2410
2410
|
return;
|
|
2411
2411
|
}
|
|
2412
|
-
|
|
2413
|
-
|
|
2412
|
+
span2.setStatus({ code: SpanStatusCode.ERROR });
|
|
2413
|
+
span2.setAttribute(ATTR_ERROR_TYPE, type ?? errorType(error62));
|
|
2414
2414
|
}
|
|
2415
|
-
function injectContext(
|
|
2415
|
+
function injectContext(span2) {
|
|
2416
2416
|
const carrier = {};
|
|
2417
|
-
propagation.inject(trace.setSpan(context.active(),
|
|
2417
|
+
propagation.inject(trace.setSpan(context.active(), span2), carrier);
|
|
2418
2418
|
return carrier;
|
|
2419
2419
|
}
|
|
2420
2420
|
function errorType(error62) {
|
|
@@ -2495,7 +2495,7 @@ function maybe_map(val, fn) {
|
|
|
2495
2495
|
}
|
|
2496
2496
|
return fn(val);
|
|
2497
2497
|
}
|
|
2498
|
-
var has, hex_table, limit,
|
|
2498
|
+
var has, hex_table, limit, encode3;
|
|
2499
2499
|
var init_utils2 = __esm({
|
|
2500
2500
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/qs/utils.mjs"() {
|
|
2501
2501
|
init_formats();
|
|
@@ -2509,7 +2509,7 @@ var init_utils2 = __esm({
|
|
|
2509
2509
|
return array2;
|
|
2510
2510
|
})();
|
|
2511
2511
|
limit = 1024;
|
|
2512
|
-
|
|
2512
|
+
encode3 = (str, _defaultEncoder, charset, _kind, format) => {
|
|
2513
2513
|
if (str.length === 0) {
|
|
2514
2514
|
return str;
|
|
2515
2515
|
}
|
|
@@ -2833,7 +2833,7 @@ var init_stringify = __esm({
|
|
|
2833
2833
|
delimiter: "&",
|
|
2834
2834
|
encode: true,
|
|
2835
2835
|
encodeDotInKeys: false,
|
|
2836
|
-
encoder:
|
|
2836
|
+
encoder: encode3,
|
|
2837
2837
|
encodeValuesOnly: false,
|
|
2838
2838
|
format: default_format,
|
|
2839
2839
|
formatter: default_formatter,
|
|
@@ -3222,16 +3222,16 @@ var init_attributes = __esm({
|
|
|
3222
3222
|
|
|
3223
3223
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/lib/internal/tracing/content.mjs
|
|
3224
3224
|
function setMessageContentAttributes(call, body2, output2, limit2) {
|
|
3225
|
-
const
|
|
3225
|
+
const span2 = call.span;
|
|
3226
3226
|
const requestSize = call.requestContentSize;
|
|
3227
3227
|
if (output2 !== void 0 && requestSize !== void 0) {
|
|
3228
3228
|
const outputMessages = JSON.stringify([{ role: "assistant", parts: contentParts(output2) }]);
|
|
3229
3229
|
if (requestSize + 3 * outputMessages.length <= limit2 || requestSize + utf8Length(outputMessages) <= limit2) {
|
|
3230
|
-
|
|
3230
|
+
span2.setAttribute(ATTR_GEN_AI_OUTPUT_MESSAGES, outputMessages);
|
|
3231
3231
|
return;
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
|
-
const size = setContentAttributes(
|
|
3234
|
+
const size = setContentAttributes(span2, {
|
|
3235
3235
|
// An empty list sets no attribute.
|
|
3236
3236
|
[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES]: body2.stop_sequences?.length ? [...body2.stop_sequences] : void 0,
|
|
3237
3237
|
[ATTR_GEN_AI_SYSTEM_INSTRUCTIONS]: body2.system === void 0 ? void 0 : contentParts(body2.system),
|
|
@@ -3344,7 +3344,7 @@ function withoutLeftOutFields(value) {
|
|
|
3344
3344
|
const isImageOrDocumentView = type === "text_editor_code_execution_view_result" && (file_type === "image" || file_type === "pdf");
|
|
3345
3345
|
return Object.fromEntries(Object.entries(value).filter(([name2]) => !name2.startsWith("encrypted_") && !(name2 === "content" && isImageOrDocumentView)).map(([name2, field]) => [name2, withoutLeftOutFields(field)]));
|
|
3346
3346
|
}
|
|
3347
|
-
function setContentAttributes(
|
|
3347
|
+
function setContentAttributes(span2, attributes2, limit2) {
|
|
3348
3348
|
const { [ATTR_GEN_AI_REQUEST_STOP_SEQUENCES]: stopSequences, [ATTR_GEN_AI_SYSTEM_INSTRUCTIONS]: instructions, [ATTR_GEN_AI_INPUT_MESSAGES]: input2, [ATTR_GEN_AI_OUTPUT_MESSAGES]: output2, [ATTR_ANTHROPIC_TOOL_RESULT_CONTENT]: toolResult, ...others } = attributes2;
|
|
3349
3349
|
const messages = {
|
|
3350
3350
|
[ATTR_GEN_AI_SYSTEM_INSTRUCTIONS]: instructions,
|
|
@@ -3384,13 +3384,13 @@ function setContentAttributes(span, attributes2, limit2) {
|
|
|
3384
3384
|
truncated || (truncated = kept.truncated);
|
|
3385
3385
|
}
|
|
3386
3386
|
if (truncated) {
|
|
3387
|
-
|
|
3387
|
+
span2.setAttribute(ATTR_ANTHROPIC_CONTENT_TRUNCATED, true);
|
|
3388
3388
|
}
|
|
3389
3389
|
if (keepsStopSequences) {
|
|
3390
|
-
|
|
3390
|
+
span2.setAttribute(ATTR_GEN_AI_REQUEST_STOP_SEQUENCES, stopSequences);
|
|
3391
3391
|
}
|
|
3392
3392
|
for (const [key, value] of Object.entries(values)) {
|
|
3393
|
-
|
|
3393
|
+
span2.setAttribute(key, value);
|
|
3394
3394
|
}
|
|
3395
3395
|
return size;
|
|
3396
3396
|
}
|
|
@@ -3497,39 +3497,39 @@ var init_content = __esm({
|
|
|
3497
3497
|
});
|
|
3498
3498
|
|
|
3499
3499
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/lib/internal/tracing/response.mjs
|
|
3500
|
-
function setResponseAttributes(
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3500
|
+
function setResponseAttributes(span2, message, usage, complete) {
|
|
3501
|
+
span2.setAttribute(ATTR_GEN_AI_RESPONSE_ID, message.id);
|
|
3502
|
+
span2.setAttribute(ATTR_GEN_AI_RESPONSE_MODEL, message.model);
|
|
3503
|
+
span2.setAttribute(ATTR_GEN_AI_USAGE_INPUT_TOKENS, usage.input_tokens + (usage.cache_read_input_tokens ?? 0) + (usage.cache_creation_input_tokens ?? 0));
|
|
3504
3504
|
if (usage.cache_creation_input_tokens != null) {
|
|
3505
|
-
|
|
3505
|
+
span2.setAttribute(ATTR_GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, usage.cache_creation_input_tokens);
|
|
3506
3506
|
}
|
|
3507
3507
|
if (usage.cache_read_input_tokens != null) {
|
|
3508
|
-
|
|
3508
|
+
span2.setAttribute(ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, usage.cache_read_input_tokens);
|
|
3509
3509
|
}
|
|
3510
3510
|
const written = usage.cache_creation;
|
|
3511
3511
|
if (written != null) {
|
|
3512
|
-
|
|
3513
|
-
|
|
3512
|
+
span2.setAttribute(ATTR_ANTHROPIC_USAGE_CACHE_CREATION_EPHEMERAL_5M_INPUT_TOKENS, written.ephemeral_5m_input_tokens);
|
|
3513
|
+
span2.setAttribute(ATTR_ANTHROPIC_USAGE_CACHE_CREATION_EPHEMERAL_1H_INPUT_TOKENS, written.ephemeral_1h_input_tokens);
|
|
3514
3514
|
}
|
|
3515
3515
|
if (usage.service_tier != null) {
|
|
3516
|
-
|
|
3516
|
+
span2.setAttribute(ATTR_ANTHROPIC_RESPONSE_SERVICE_TIER, usage.service_tier);
|
|
3517
3517
|
}
|
|
3518
3518
|
if (!complete) {
|
|
3519
3519
|
return;
|
|
3520
3520
|
}
|
|
3521
|
-
|
|
3521
|
+
span2.setAttribute(ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, usage.output_tokens);
|
|
3522
3522
|
const details = usage.output_tokens_details;
|
|
3523
3523
|
if (details != null) {
|
|
3524
|
-
|
|
3524
|
+
span2.setAttribute(ATTR_GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, details.thinking_tokens);
|
|
3525
3525
|
}
|
|
3526
3526
|
const compactions = usage.iterations?.filter((each) => each.type === "compaction") ?? [];
|
|
3527
3527
|
if (compactions.length > 0) {
|
|
3528
|
-
|
|
3529
|
-
|
|
3528
|
+
span2.setAttribute(ATTR_ANTHROPIC_USAGE_COMPACTION_INPUT_TOKENS, compactions.reduce((sum, each) => sum + each.input_tokens + each.cache_read_input_tokens + each.cache_creation_input_tokens, 0));
|
|
3529
|
+
span2.setAttribute(ATTR_ANTHROPIC_USAGE_COMPACTION_OUTPUT_TOKENS, compactions.reduce((sum, each) => sum + each.output_tokens, 0));
|
|
3530
3530
|
}
|
|
3531
3531
|
if (message.stop_reason != null) {
|
|
3532
|
-
|
|
3532
|
+
span2.setAttribute(ATTR_ANTHROPIC_MESSAGE_STOP_REASON, message.stop_reason);
|
|
3533
3533
|
}
|
|
3534
3534
|
}
|
|
3535
3535
|
var init_response = __esm({
|
|
@@ -3539,8 +3539,8 @@ var init_response = __esm({
|
|
|
3539
3539
|
});
|
|
3540
3540
|
|
|
3541
3541
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/lib/internal/tracing/api-call.mjs
|
|
3542
|
-
function setAnthropicSpanAttributes(client,
|
|
3543
|
-
if (!
|
|
3542
|
+
function setAnthropicSpanAttributes(client, span2, result) {
|
|
3543
|
+
if (!span2.isRecording()) {
|
|
3544
3544
|
return;
|
|
3545
3545
|
}
|
|
3546
3546
|
try {
|
|
@@ -3549,7 +3549,7 @@ function setAnthropicSpanAttributes(client, span, result) {
|
|
|
3549
3549
|
for (const [attribute, header2] of RESPONSE_HEADER_ATTRIBUTES) {
|
|
3550
3550
|
const value = headers?.get(header2);
|
|
3551
3551
|
if (value) {
|
|
3552
|
-
|
|
3552
|
+
span2.setAttribute(attribute, value);
|
|
3553
3553
|
}
|
|
3554
3554
|
}
|
|
3555
3555
|
} catch (problem) {
|
|
@@ -3619,9 +3619,9 @@ function recordMessagesCreateResponse(client, call, body2, data) {
|
|
|
3619
3619
|
if (!call?.span.isRecording() || data instanceof Stream) {
|
|
3620
3620
|
return;
|
|
3621
3621
|
}
|
|
3622
|
-
const
|
|
3622
|
+
const span2 = call.span;
|
|
3623
3623
|
try {
|
|
3624
|
-
setResponseAttributes(
|
|
3624
|
+
setResponseAttributes(span2, data, data.usage, true);
|
|
3625
3625
|
const { contentMode, maxContentBytes } = client.openTelemetry.traces;
|
|
3626
3626
|
if (contentMode === "content") {
|
|
3627
3627
|
setMessageContentAttributes(call, body2, data.content, maxContentBytes);
|
|
@@ -3716,18 +3716,18 @@ function recordStreamedMessageContent(client, call, body2, message) {
|
|
|
3716
3716
|
loggerFor(client).debug("could not record the streamed message on its span", problem);
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
|
-
function endAnthropicApiCallSpanWhenStreamEnds(client,
|
|
3719
|
+
function endAnthropicApiCallSpanWhenStreamEnds(client, span2, stream3, props) {
|
|
3720
3720
|
if (props.options.__span?.name === "anthropic.messages.create" && stream3 instanceof Stream) {
|
|
3721
|
-
endMessagesCreateSpanWhenStreamEnds(client,
|
|
3721
|
+
endMessagesCreateSpanWhenStreamEnds(client, span2, stream3, props);
|
|
3722
3722
|
} else {
|
|
3723
|
-
endApiCallSpanWhenStreamEnds(
|
|
3723
|
+
endApiCallSpanWhenStreamEnds(span2, stream3, props);
|
|
3724
3724
|
}
|
|
3725
3725
|
}
|
|
3726
|
-
function endMessagesCreateSpanWhenStreamEnds(client,
|
|
3727
|
-
if (!
|
|
3726
|
+
function endMessagesCreateSpanWhenStreamEnds(client, span2, stream3, props) {
|
|
3727
|
+
if (!span2.isRecording()) {
|
|
3728
3728
|
return;
|
|
3729
3729
|
}
|
|
3730
|
-
|
|
3730
|
+
span2.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, props.response.status);
|
|
3731
3731
|
const call = props.options.__span;
|
|
3732
3732
|
const startTime = call?.startTime;
|
|
3733
3733
|
let message;
|
|
@@ -3779,7 +3779,7 @@ function endMessagesCreateSpanWhenStreamEnds(client, span, stream3, props) {
|
|
|
3779
3779
|
break;
|
|
3780
3780
|
case "content_block_delta":
|
|
3781
3781
|
if (!sawDelta && startTime !== void 0) {
|
|
3782
|
-
|
|
3782
|
+
span2.setAttribute(ATTR_GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK, (Date.now() - startTime) / 1e3);
|
|
3783
3783
|
}
|
|
3784
3784
|
sawDelta = true;
|
|
3785
3785
|
break;
|
|
@@ -3795,7 +3795,7 @@ function endMessagesCreateSpanWhenStreamEnds(client, span, stream3, props) {
|
|
|
3795
3795
|
onEnd(end) {
|
|
3796
3796
|
try {
|
|
3797
3797
|
if (message && usage) {
|
|
3798
|
-
setResponseAttributes(
|
|
3798
|
+
setResponseAttributes(span2, message, usage, sawMessageDelta || sawStop);
|
|
3799
3799
|
}
|
|
3800
3800
|
} catch (problem) {
|
|
3801
3801
|
loggerFor(client).debug("could not record the stream on its span", problem);
|
|
@@ -3805,17 +3805,17 @@ function endMessagesCreateSpanWhenStreamEnds(client, span, stream3, props) {
|
|
|
3805
3805
|
recordStreamedMessageContent(client, call, call.streamed.body, call.streamed.message);
|
|
3806
3806
|
}
|
|
3807
3807
|
if (end.reason === "failed") {
|
|
3808
|
-
setErrorStatus(
|
|
3808
|
+
setErrorStatus(span2, end.error);
|
|
3809
3809
|
} else if (failure2 !== void 0) {
|
|
3810
|
-
setErrorStatus(
|
|
3810
|
+
setErrorStatus(span2, failure2, "client_error");
|
|
3811
3811
|
} else if (end.reason === "completed") {
|
|
3812
3812
|
if (sawStop) {
|
|
3813
|
-
|
|
3813
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
3814
3814
|
} else {
|
|
3815
|
-
setErrorStatus(
|
|
3815
|
+
setErrorStatus(span2, new AnthropicError("The stream ended before message_stop."), "api_error");
|
|
3816
3816
|
}
|
|
3817
3817
|
}
|
|
3818
|
-
guardTracing(client, () =>
|
|
3818
|
+
guardTracing(client, () => span2.end());
|
|
3819
3819
|
}
|
|
3820
3820
|
});
|
|
3821
3821
|
}
|
|
@@ -3845,35 +3845,35 @@ function startEnvironmentWorkSpan(client, work, parentContext) {
|
|
|
3845
3845
|
}
|
|
3846
3846
|
}, parentContext);
|
|
3847
3847
|
}
|
|
3848
|
-
function endEnvironmentWorkSpan(
|
|
3849
|
-
if (!
|
|
3848
|
+
function endEnvironmentWorkSpan(span2, signal) {
|
|
3849
|
+
if (!span2?.isRecording()) {
|
|
3850
3850
|
return;
|
|
3851
3851
|
}
|
|
3852
3852
|
if (!signal.aborted) {
|
|
3853
|
-
|
|
3853
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
3854
3854
|
}
|
|
3855
|
-
|
|
3855
|
+
span2.end();
|
|
3856
3856
|
}
|
|
3857
|
-
function failEnvironmentWorkSpan(
|
|
3858
|
-
if (!
|
|
3857
|
+
function failEnvironmentWorkSpan(span2, signal, error62) {
|
|
3858
|
+
if (!span2?.isRecording()) {
|
|
3859
3859
|
return;
|
|
3860
3860
|
}
|
|
3861
3861
|
if (!signal.aborted) {
|
|
3862
|
-
setErrorStatus(
|
|
3862
|
+
setErrorStatus(span2, error62);
|
|
3863
3863
|
}
|
|
3864
|
-
|
|
3864
|
+
span2.end();
|
|
3865
3865
|
}
|
|
3866
|
-
async function withEnvironmentWorkSpan(client,
|
|
3867
|
-
if (!
|
|
3866
|
+
async function withEnvironmentWorkSpan(client, span2, signal, handle2) {
|
|
3867
|
+
if (!span2) {
|
|
3868
3868
|
return handle2();
|
|
3869
3869
|
}
|
|
3870
3870
|
try {
|
|
3871
|
-
await context.with(trace.setSpan(context.active(),
|
|
3871
|
+
await context.with(trace.setSpan(context.active(), span2), handle2);
|
|
3872
3872
|
} catch (error62) {
|
|
3873
|
-
guardTracing(client, () => failEnvironmentWorkSpan(
|
|
3873
|
+
guardTracing(client, () => failEnvironmentWorkSpan(span2, signal, error62));
|
|
3874
3874
|
throw error62;
|
|
3875
3875
|
}
|
|
3876
|
-
guardTracing(client, () => endEnvironmentWorkSpan(
|
|
3876
|
+
guardTracing(client, () => endEnvironmentWorkSpan(span2, signal));
|
|
3877
3877
|
}
|
|
3878
3878
|
var init_environments = __esm({
|
|
3879
3879
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/lib/internal/tracing/environments.mjs"() {
|
|
@@ -3978,20 +3978,20 @@ async function withToolUseSpan(client, tool, toolUse, options, run3) {
|
|
|
3978
3978
|
..."session_thread_id" in toolUse && toolUse.session_thread_id != null ? { "anthropic.session.thread.id": toolUse.session_thread_id } : void 0
|
|
3979
3979
|
};
|
|
3980
3980
|
const operation = toolUse.type === "agent.tool_use" ? "anthropic.tool_use" : wasCreatedByStainlessHelper(tool) && tool[SDK_HELPER_SYMBOL] === "mcpTool" ? "anthropic.mcp_tool_use" : "anthropic.custom_tool_use";
|
|
3981
|
-
const
|
|
3982
|
-
if (!
|
|
3981
|
+
const span2 = guardTracing(client, () => tracer.startSpan(`${operation} ${toolUse.name}`, { kind: SpanKind.INTERNAL, attributes: attributes2 }, parentContext));
|
|
3982
|
+
if (!span2)
|
|
3983
3983
|
return run3();
|
|
3984
3984
|
let result;
|
|
3985
3985
|
try {
|
|
3986
|
-
result = await context.with(trace.setSpan(parentContext,
|
|
3986
|
+
result = await context.with(trace.setSpan(parentContext, span2), run3);
|
|
3987
3987
|
return result;
|
|
3988
3988
|
} finally {
|
|
3989
3989
|
const succeeded = result !== void 0 && !result.isError;
|
|
3990
3990
|
const canceled = !succeeded && signal?.aborted === true;
|
|
3991
3991
|
const { contentMode, maxContentBytes } = client.openTelemetry.traces;
|
|
3992
|
-
if (contentMode === "content" &&
|
|
3992
|
+
if (contentMode === "content" && span2.isRecording()) {
|
|
3993
3993
|
try {
|
|
3994
|
-
setContentAttributes(
|
|
3994
|
+
setContentAttributes(span2, {
|
|
3995
3995
|
[ATTR_GEN_AI_TOOL_CALL_ARGUMENTS]: toolUse.input,
|
|
3996
3996
|
[ATTR_ANTHROPIC_TOOL_RESULT_CONTENT]: result && !canceled ? toolResultContentBlocks(result.content) : void 0
|
|
3997
3997
|
}, maxContentBytes);
|
|
@@ -4001,11 +4001,11 @@ async function withToolUseSpan(client, tool, toolUse, options, run3) {
|
|
|
4001
4001
|
}
|
|
4002
4002
|
guardTracing(client, () => {
|
|
4003
4003
|
if (succeeded) {
|
|
4004
|
-
|
|
4004
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
4005
4005
|
} else if (!canceled) {
|
|
4006
|
-
setErrorStatus(
|
|
4006
|
+
setErrorStatus(span2, result, "tool_error");
|
|
4007
4007
|
}
|
|
4008
|
-
|
|
4008
|
+
span2.end();
|
|
4009
4009
|
});
|
|
4010
4010
|
}
|
|
4011
4011
|
}
|
|
@@ -4055,13 +4055,13 @@ var init_base64 = __esm({
|
|
|
4055
4055
|
});
|
|
4056
4056
|
|
|
4057
4057
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/utils/uuid.mjs
|
|
4058
|
-
var
|
|
4058
|
+
var uuid42;
|
|
4059
4059
|
var init_uuid = __esm({
|
|
4060
4060
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/utils/uuid.mjs"() {
|
|
4061
|
-
|
|
4061
|
+
uuid42 = function() {
|
|
4062
4062
|
const { crypto: crypto4 } = globalThis;
|
|
4063
4063
|
if (crypto4?.randomUUID) {
|
|
4064
|
-
|
|
4064
|
+
uuid42 = crypto4.randomUUID.bind(crypto4);
|
|
4065
4065
|
return crypto4.randomUUID();
|
|
4066
4066
|
}
|
|
4067
4067
|
const u8 = new Uint8Array(1);
|
|
@@ -4800,9 +4800,9 @@ var init_uploads = __esm({
|
|
|
4800
4800
|
try {
|
|
4801
4801
|
return { ...opts, body: await createForm(opts.body, fetch2, stripFilenames) };
|
|
4802
4802
|
} catch (error62) {
|
|
4803
|
-
const
|
|
4804
|
-
if (
|
|
4805
|
-
guardTracing(typeof fetch2 === "function" ? void 0 : fetch2, () => endApiCallSpan(
|
|
4803
|
+
const span2 = opts.__span?.span;
|
|
4804
|
+
if (span2) {
|
|
4805
|
+
guardTracing(typeof fetch2 === "function" ? void 0 : fetch2, () => endApiCallSpan(span2, { status: "error", options: opts, error: error62 }));
|
|
4806
4806
|
}
|
|
4807
4807
|
throw error62;
|
|
4808
4808
|
}
|
|
@@ -4864,8 +4864,8 @@ var init_api_promise = __esm({
|
|
|
4864
4864
|
APIPromise = /* @__PURE__ */ (() => {
|
|
4865
4865
|
class APIPromise2 extends Promise {
|
|
4866
4866
|
constructor(client, responsePromise, parseResponse = defaultParseResponse) {
|
|
4867
|
-
super((
|
|
4868
|
-
|
|
4867
|
+
super((resolve5) => {
|
|
4868
|
+
resolve5(null);
|
|
4869
4869
|
});
|
|
4870
4870
|
this.responsePromise = responsePromise;
|
|
4871
4871
|
this.parseResponse = parseResponse;
|
|
@@ -4888,11 +4888,11 @@ var init_api_promise = __esm({
|
|
|
4888
4888
|
*/
|
|
4889
4889
|
asResponse() {
|
|
4890
4890
|
return this.responsePromise.then((props) => {
|
|
4891
|
-
const
|
|
4892
|
-
if (
|
|
4891
|
+
const span2 = props.options.__span?.span;
|
|
4892
|
+
if (span2 && !this.parsedPromise) {
|
|
4893
4893
|
const result = { status: "success", ...props, data: void 0 };
|
|
4894
|
-
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"),
|
|
4895
|
-
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(
|
|
4894
|
+
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"), span2, result);
|
|
4895
|
+
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(span2, result));
|
|
4896
4896
|
}
|
|
4897
4897
|
return props.response;
|
|
4898
4898
|
});
|
|
@@ -4933,23 +4933,23 @@ var init_api_promise = __esm({
|
|
|
4933
4933
|
if (!call) {
|
|
4934
4934
|
return this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), props);
|
|
4935
4935
|
}
|
|
4936
|
-
const { span } = call;
|
|
4936
|
+
const { span: span2 } = call;
|
|
4937
4937
|
let data;
|
|
4938
4938
|
try {
|
|
4939
4939
|
data = await this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), props);
|
|
4940
4940
|
} catch (error62) {
|
|
4941
4941
|
const result2 = { status: "error", ...props, error: error62 };
|
|
4942
|
-
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"),
|
|
4943
|
-
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(
|
|
4942
|
+
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"), span2, result2);
|
|
4943
|
+
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(span2, result2));
|
|
4944
4944
|
throw error62;
|
|
4945
4945
|
}
|
|
4946
4946
|
const result = { status: "success", ...props, data };
|
|
4947
4947
|
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => setCreatedIDAttribute(call, data));
|
|
4948
|
-
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"),
|
|
4948
|
+
setAnthropicSpanAttributes(__classPrivateFieldGet(this, _APIPromise_client, "f"), span2, result);
|
|
4949
4949
|
if (props.options.stream && isAsyncIterable(data)) {
|
|
4950
|
-
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endAnthropicApiCallSpanWhenStreamEnds(__classPrivateFieldGet(this, _APIPromise_client, "f"),
|
|
4950
|
+
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endAnthropicApiCallSpanWhenStreamEnds(__classPrivateFieldGet(this, _APIPromise_client, "f"), span2, data, props));
|
|
4951
4951
|
} else {
|
|
4952
|
-
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(
|
|
4952
|
+
guardTracing(__classPrivateFieldGet(this, _APIPromise_client, "f"), () => endApiCallSpan(span2, result));
|
|
4953
4953
|
}
|
|
4954
4954
|
return data;
|
|
4955
4955
|
}
|
|
@@ -4999,14 +4999,14 @@ var init_pagination = __esm({
|
|
|
4999
4999
|
if (!nextOptions) {
|
|
5000
5000
|
throw new AnthropicError("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
|
|
5001
5001
|
}
|
|
5002
|
-
const
|
|
5002
|
+
const span2 = this.options.__span;
|
|
5003
5003
|
return await __classPrivateFieldGet(this, _AbstractPage_client, "f").requestAPIList(this.constructor, {
|
|
5004
5004
|
...nextOptions,
|
|
5005
|
-
__span:
|
|
5006
|
-
route:
|
|
5007
|
-
queryParams:
|
|
5008
|
-
contentQueryParams:
|
|
5009
|
-
attributes:
|
|
5005
|
+
__span: span2 && startApiCallSpan(__classPrivateFieldGet(this, _AbstractPage_client, "f"), span2.name, { openTelemetry: this.options.openTelemetry }, {
|
|
5006
|
+
route: span2.route,
|
|
5007
|
+
queryParams: span2.queryParams,
|
|
5008
|
+
contentQueryParams: span2.contentQueryParams,
|
|
5009
|
+
attributes: span2.attributes
|
|
5010
5010
|
})
|
|
5011
5011
|
});
|
|
5012
5012
|
}
|
|
@@ -5711,12 +5711,12 @@ var init_MessageStream = __esm({
|
|
|
5711
5711
|
}
|
|
5712
5712
|
return this._emit("error", new AnthropicError(String(error62)));
|
|
5713
5713
|
});
|
|
5714
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
5715
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
5714
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve5, reject) => {
|
|
5715
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve5, "f");
|
|
5716
5716
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
5717
5717
|
}), "f");
|
|
5718
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
5719
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
5718
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve5, reject) => {
|
|
5719
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve5, "f");
|
|
5720
5720
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
5721
5721
|
}), "f");
|
|
5722
5722
|
__classPrivateFieldGet(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -5908,11 +5908,11 @@ var init_MessageStream = __esm({
|
|
|
5908
5908
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
5909
5909
|
*/
|
|
5910
5910
|
emitted(event) {
|
|
5911
|
-
return new Promise((
|
|
5911
|
+
return new Promise((resolve5, reject) => {
|
|
5912
5912
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
5913
5913
|
if (event !== "error")
|
|
5914
5914
|
this.once("error", reject);
|
|
5915
|
-
this.once(event,
|
|
5915
|
+
this.once(event, resolve5);
|
|
5916
5916
|
});
|
|
5917
5917
|
}
|
|
5918
5918
|
async done() {
|
|
@@ -6247,7 +6247,7 @@ var init_MessageStream = __esm({
|
|
|
6247
6247
|
if (done) {
|
|
6248
6248
|
return { value: void 0, done: true };
|
|
6249
6249
|
}
|
|
6250
|
-
return new Promise((
|
|
6250
|
+
return new Promise((resolve5, reject) => readQueue.push({ resolve: resolve5, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
6251
6251
|
}
|
|
6252
6252
|
const chunk = pushQueue.shift();
|
|
6253
6253
|
return { value: chunk, done: false };
|
|
@@ -8674,7 +8674,7 @@ function backoff2(attempt) {
|
|
|
8674
8674
|
function defaultWorkerId() {
|
|
8675
8675
|
const env = globalThis.process?.env;
|
|
8676
8676
|
const host = env?.["HOSTNAME"];
|
|
8677
|
-
return host ? `${host}-${
|
|
8677
|
+
return host ? `${host}-${uuid42()}` : uuid42();
|
|
8678
8678
|
}
|
|
8679
8679
|
var _WorkPoller_runnerClient, _WorkPoller_consumed, _WorkPoller_controller, _WorkPoller_detachExternal, _WorkPoller_autoStop, _WorkPoller_drain, _WorkPoller_blockMs, _WorkPoller_reclaimOlderThanMs, _WorkPoller_requestOpts, _IdleLog_log, _IdleLog_environmentId, _IdleLog_idleSince, _IdleLog_lastReport, POLL_BLOCK_MS, POLL_BACKOFF_BASE_MS, POLL_BACKOFF_CAP_MS, IDLE_REPORT_INTERVAL_MS, WorkPoller, IdleLog;
|
|
8680
8680
|
var init_poller = __esm({
|
|
@@ -8890,16 +8890,16 @@ var init_async_queue = __esm({
|
|
|
8890
8890
|
if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f") || signal?.aborted) {
|
|
8891
8891
|
return Promise.resolve({ done: true, value: void 0 });
|
|
8892
8892
|
}
|
|
8893
|
-
return new Promise((
|
|
8893
|
+
return new Promise((resolve5) => {
|
|
8894
8894
|
const waiter = (r) => {
|
|
8895
8895
|
signal?.removeEventListener("abort", onAbort);
|
|
8896
|
-
|
|
8896
|
+
resolve5(r);
|
|
8897
8897
|
};
|
|
8898
8898
|
const onAbort = () => {
|
|
8899
8899
|
const idx = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").indexOf(waiter);
|
|
8900
8900
|
if (idx >= 0)
|
|
8901
8901
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").splice(idx, 1);
|
|
8902
|
-
|
|
8902
|
+
resolve5({ done: true, value: void 0 });
|
|
8903
8903
|
};
|
|
8904
8904
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").push(waiter);
|
|
8905
8905
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -8942,11 +8942,11 @@ var init_ToolError = __esm({
|
|
|
8942
8942
|
function wellFormed(text) {
|
|
8943
8943
|
return text.replace(LONE_SURROGATE_RE, "\uFFFD");
|
|
8944
8944
|
}
|
|
8945
|
-
function
|
|
8945
|
+
function oneLine2(text, limit2 = FIELD_MAX) {
|
|
8946
8946
|
return cutPoints(wellFormed(text).replace(CONTROL_RE, " ").trim(), limit2);
|
|
8947
8947
|
}
|
|
8948
8948
|
function logSafe(name2) {
|
|
8949
|
-
return
|
|
8949
|
+
return oneLine2(name2, LOG_MAX);
|
|
8950
8950
|
}
|
|
8951
8951
|
function quotedName(name2) {
|
|
8952
8952
|
return logSafe(name2).replace(/[' ]+/g, " ").trim();
|
|
@@ -9626,13 +9626,13 @@ var init_json_schema = __esm({
|
|
|
9626
9626
|
|
|
9627
9627
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs
|
|
9628
9628
|
function promiseWithResolvers() {
|
|
9629
|
-
let
|
|
9629
|
+
let resolve5;
|
|
9630
9630
|
let reject;
|
|
9631
9631
|
const promise2 = new Promise((res, rej) => {
|
|
9632
|
-
|
|
9632
|
+
resolve5 = res;
|
|
9633
9633
|
reject = rej;
|
|
9634
9634
|
});
|
|
9635
|
-
return { promise: promise2, resolve:
|
|
9635
|
+
return { promise: promise2, resolve: resolve5, reject };
|
|
9636
9636
|
}
|
|
9637
9637
|
var init_promise = __esm({
|
|
9638
9638
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs"() {
|
|
@@ -10427,10 +10427,10 @@ async function settledOrAborted(p, signal) {
|
|
|
10427
10427
|
return;
|
|
10428
10428
|
}
|
|
10429
10429
|
let onAbort;
|
|
10430
|
-
const aborted2 = new Promise((
|
|
10431
|
-
onAbort =
|
|
10430
|
+
const aborted2 = new Promise((resolve5) => {
|
|
10431
|
+
onAbort = resolve5;
|
|
10432
10432
|
if (signal.aborted)
|
|
10433
|
-
|
|
10433
|
+
resolve5();
|
|
10434
10434
|
});
|
|
10435
10435
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
10436
10436
|
try {
|
|
@@ -11514,7 +11514,7 @@ function betaGrepTool(ctx) {
|
|
|
11514
11514
|
});
|
|
11515
11515
|
}
|
|
11516
11516
|
function runRipgrep(rg, pattern, searchPath, signal) {
|
|
11517
|
-
return new Promise((
|
|
11517
|
+
return new Promise((resolve5, reject) => {
|
|
11518
11518
|
const proc = cp.spawn(rg, ["-n", "--no-heading", "-e", pattern, "--", searchPath], {
|
|
11519
11519
|
...signal ? { signal } : {}
|
|
11520
11520
|
});
|
|
@@ -11536,12 +11536,12 @@ function runRipgrep(rg, pattern, searchPath, signal) {
|
|
|
11536
11536
|
if (signal?.aborted)
|
|
11537
11537
|
return reject(new ToolError("grep: aborted"));
|
|
11538
11538
|
if (truncated)
|
|
11539
|
-
return
|
|
11539
|
+
return resolve5(out2 + `
|
|
11540
11540
|
[output truncated at ${GREP_OUTPUT_LIMIT} bytes]`);
|
|
11541
11541
|
if (code2 === 0)
|
|
11542
|
-
return
|
|
11542
|
+
return resolve5(out2);
|
|
11543
11543
|
if (code2 === 1)
|
|
11544
|
-
return
|
|
11544
|
+
return resolve5("no matches");
|
|
11545
11545
|
reject(new ToolError(`grep: rg failed: ${errOut || `exit ${code2}`}`));
|
|
11546
11546
|
});
|
|
11547
11547
|
proc.on("error", (e) => {
|
|
@@ -11723,8 +11723,8 @@ var init_node2 = __esm({
|
|
|
11723
11723
|
`;
|
|
11724
11724
|
__classPrivateFieldGet(this, _BashSession_proc, "f").stdin.write(wrapped);
|
|
11725
11725
|
if (__classPrivateFieldGet(this, _BashSession_buf, "f").indexOf(sentinel2) < 0) {
|
|
11726
|
-
const { promise: sentinelSeen, resolve:
|
|
11727
|
-
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel2, resolve:
|
|
11726
|
+
const { promise: sentinelSeen, resolve: resolve5 } = promiseWithResolvers();
|
|
11727
|
+
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel2, resolve: resolve5 }, "f");
|
|
11728
11728
|
let timer;
|
|
11729
11729
|
let onAbort;
|
|
11730
11730
|
try {
|
|
@@ -11886,8 +11886,8 @@ async function withTimeout(p, ms) {
|
|
|
11886
11886
|
try {
|
|
11887
11887
|
return await Promise.race([
|
|
11888
11888
|
p.then(() => false, () => false),
|
|
11889
|
-
new Promise((
|
|
11890
|
-
timer = setTimeout(() =>
|
|
11889
|
+
new Promise((resolve5) => {
|
|
11890
|
+
timer = setTimeout(() => resolve5(true), ms);
|
|
11891
11891
|
})
|
|
11892
11892
|
]);
|
|
11893
11893
|
} finally {
|
|
@@ -13724,12 +13724,12 @@ var init_BetaMessageStream = __esm({
|
|
|
13724
13724
|
}
|
|
13725
13725
|
return this._emit("error", new AnthropicError(String(error62)));
|
|
13726
13726
|
});
|
|
13727
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
13728
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
13727
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve5, reject) => {
|
|
13728
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve5, "f");
|
|
13729
13729
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
13730
13730
|
}), "f");
|
|
13731
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
13732
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
13731
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve5, reject) => {
|
|
13732
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve5, "f");
|
|
13733
13733
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
13734
13734
|
}), "f");
|
|
13735
13735
|
__classPrivateFieldGet(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -13924,11 +13924,11 @@ var init_BetaMessageStream = __esm({
|
|
|
13924
13924
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
13925
13925
|
*/
|
|
13926
13926
|
emitted(event) {
|
|
13927
|
-
return new Promise((
|
|
13927
|
+
return new Promise((resolve5, reject) => {
|
|
13928
13928
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
13929
13929
|
if (event !== "error")
|
|
13930
13930
|
this.once("error", reject);
|
|
13931
|
-
this.once(event,
|
|
13931
|
+
this.once(event, resolve5);
|
|
13932
13932
|
});
|
|
13933
13933
|
}
|
|
13934
13934
|
async done() {
|
|
@@ -14316,7 +14316,7 @@ var init_BetaMessageStream = __esm({
|
|
|
14316
14316
|
if (done) {
|
|
14317
14317
|
return { value: void 0, done: true };
|
|
14318
14318
|
}
|
|
14319
|
-
return new Promise((
|
|
14319
|
+
return new Promise((resolve5, reject) => readQueue.push({ resolve: resolve5, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
14320
14320
|
}
|
|
14321
14321
|
const chunk = pushQueue.shift();
|
|
14322
14322
|
return { value: chunk, done: false };
|
|
@@ -25431,7 +25431,7 @@ var init_resources2 = __esm({
|
|
|
25431
25431
|
});
|
|
25432
25432
|
|
|
25433
25433
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/client.mjs
|
|
25434
|
-
var _BaseAnthropic_instances,
|
|
25434
|
+
var _BaseAnthropic_instances, _a3, _BaseAnthropic_encoder, _BaseAnthropic_openTelemetry, _BaseAnthropic_baseURLOverridden, HUMAN_PROMPT, AI_PROMPT, BaseAnthropic, Anthropic;
|
|
25435
25435
|
var init_client = __esm({
|
|
25436
25436
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.137.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/client.mjs"() {
|
|
25437
25437
|
init_tslib();
|
|
@@ -25556,7 +25556,7 @@ var init_client = __esm({
|
|
|
25556
25556
|
}
|
|
25557
25557
|
this.baseURL = options.baseURL;
|
|
25558
25558
|
this._baseURLIsExplicit = opts.__baseURLIsExplicit ?? !!baseURL;
|
|
25559
|
-
this.timeout = options.timeout ??
|
|
25559
|
+
this.timeout = options.timeout ?? _a3.DEFAULT_TIMEOUT;
|
|
25560
25560
|
this.logger = options.logger ?? console;
|
|
25561
25561
|
this.logLevel = defaultLogLevel;
|
|
25562
25562
|
this.logLevel = parseLogLevel(options.logLevel, "ClientOptions.logLevel", loggerFor(this)) ?? parseLogLevel(readEnv("ANTHROPIC_LOG"), "process.env['ANTHROPIC_LOG']", loggerFor(this)) ?? defaultLogLevel;
|
|
@@ -25928,20 +25928,20 @@ var init_client = __esm({
|
|
|
25928
25928
|
*/
|
|
25929
25929
|
async makeTracedRequest(optionsInput, retriesRemaining) {
|
|
25930
25930
|
const options = await optionsInput;
|
|
25931
|
-
const
|
|
25932
|
-
if (!
|
|
25931
|
+
const span2 = options.__span?.span;
|
|
25932
|
+
if (!span2) {
|
|
25933
25933
|
return this.makeRequest(options, retriesRemaining, void 0);
|
|
25934
25934
|
}
|
|
25935
25935
|
try {
|
|
25936
|
-
return await context.with(trace.setSpan(context.active(),
|
|
25936
|
+
return await context.with(trace.setSpan(context.active(), span2), () => this.makeRequest(options, retriesRemaining, void 0, span2));
|
|
25937
25937
|
} catch (error62) {
|
|
25938
25938
|
const result = { status: "error", options, error: error62 };
|
|
25939
|
-
setAnthropicSpanAttributes(this,
|
|
25940
|
-
guardTracing(this, () => endApiCallSpan(
|
|
25939
|
+
setAnthropicSpanAttributes(this, span2, result);
|
|
25940
|
+
guardTracing(this, () => endApiCallSpan(span2, result));
|
|
25941
25941
|
throw error62;
|
|
25942
25942
|
}
|
|
25943
25943
|
}
|
|
25944
|
-
async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID,
|
|
25944
|
+
async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID, span2) {
|
|
25945
25945
|
const options = await optionsInput;
|
|
25946
25946
|
let maxRetries = validatePositiveInteger("maxRetries", options.maxRetries ?? this.maxRetries);
|
|
25947
25947
|
if (this.isStreamBody(options.body)) {
|
|
@@ -25957,8 +25957,8 @@ var init_client = __esm({
|
|
|
25957
25957
|
});
|
|
25958
25958
|
const requestLogID = "log_" + (Math.random() * (1 << 24) | 0).toString(16).padStart(6, "0");
|
|
25959
25959
|
const retryLogStr = retryOfRequestLogID === void 0 ? "" : `, retryOf: ${retryOfRequestLogID}`;
|
|
25960
|
-
if (
|
|
25961
|
-
req.headers = guardTracing(this, () => injectTraceHeaders(
|
|
25960
|
+
if (span2 && this.openTelemetry.propagation) {
|
|
25961
|
+
req.headers = guardTracing(this, () => injectTraceHeaders(span2, req.headers)) ?? req.headers;
|
|
25962
25962
|
}
|
|
25963
25963
|
const startTime = Date.now();
|
|
25964
25964
|
if (options.signal?.aborted) {
|
|
@@ -25996,7 +25996,7 @@ var init_client = __esm({
|
|
|
25996
25996
|
durationMs: headersTime - startTime,
|
|
25997
25997
|
message: response.message
|
|
25998
25998
|
});
|
|
25999
|
-
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID,
|
|
25999
|
+
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, span2);
|
|
26000
26000
|
}
|
|
26001
26001
|
loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - error; no more retries left`);
|
|
26002
26002
|
debugLogRequestDetails(loggerFor(this), `[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (error; no more retries left)`, {
|
|
@@ -26029,7 +26029,7 @@ var init_client = __esm({
|
|
|
26029
26029
|
headers: response.headers,
|
|
26030
26030
|
durationMs: headersTime - startTime
|
|
26031
26031
|
});
|
|
26032
|
-
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID,
|
|
26032
|
+
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, span2, response.headers);
|
|
26033
26033
|
}
|
|
26034
26034
|
const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
|
|
26035
26035
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
@@ -26150,7 +26150,7 @@ var init_client = __esm({
|
|
|
26150
26150
|
return true;
|
|
26151
26151
|
return false;
|
|
26152
26152
|
}
|
|
26153
|
-
async retryRequest(options, retriesRemaining, requestLogID,
|
|
26153
|
+
async retryRequest(options, retriesRemaining, requestLogID, span2, responseHeaders) {
|
|
26154
26154
|
let timeoutMillis;
|
|
26155
26155
|
const retryAfterMillisHeader = responseHeaders?.get("retry-after-ms");
|
|
26156
26156
|
if (retryAfterMillisHeader) {
|
|
@@ -26173,7 +26173,7 @@ var init_client = __esm({
|
|
|
26173
26173
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
26174
26174
|
}
|
|
26175
26175
|
await sleep(timeoutMillis, options.signal ?? void 0);
|
|
26176
|
-
return this.makeRequest(options, retriesRemaining - 1, requestLogID,
|
|
26176
|
+
return this.makeRequest(options, retriesRemaining - 1, requestLogID, span2);
|
|
26177
26177
|
}
|
|
26178
26178
|
calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
|
|
26179
26179
|
const initialRetryDelay = 0.5;
|
|
@@ -26283,10 +26283,10 @@ var init_client = __esm({
|
|
|
26283
26283
|
return typeof body2 === "object" && body2 !== null && (Symbol.asyncIterator in body2 || Symbol.iterator in body2 && "next" in body2 && typeof body2.next === "function");
|
|
26284
26284
|
}
|
|
26285
26285
|
}
|
|
26286
|
-
|
|
26286
|
+
_a3 = BaseAnthropic2, _BaseAnthropic_encoder = /* @__PURE__ */ new WeakMap(), _BaseAnthropic_openTelemetry = /* @__PURE__ */ new WeakMap(), _BaseAnthropic_instances = /* @__PURE__ */ new WeakSet(), _BaseAnthropic_baseURLOverridden = function _BaseAnthropic_baseURLOverridden2() {
|
|
26287
26287
|
return this.baseURL !== "https://api.anthropic.com";
|
|
26288
26288
|
};
|
|
26289
|
-
BaseAnthropic2.Anthropic =
|
|
26289
|
+
BaseAnthropic2.Anthropic = _a3;
|
|
26290
26290
|
BaseAnthropic2.DEFAULT_TIMEOUT = 6e5;
|
|
26291
26291
|
BaseAnthropic2.AnthropicError = AnthropicError;
|
|
26292
26292
|
BaseAnthropic2.APIError = APIError;
|
|
@@ -26350,13 +26350,13 @@ process.on("warning", (warning) => {
|
|
|
26350
26350
|
|
|
26351
26351
|
// src/cli/main.ts
|
|
26352
26352
|
import { existsSync } from "node:fs";
|
|
26353
|
-
import { dirname as dirname5, join as join8 } from "node:path";
|
|
26353
|
+
import { dirname as dirname5, join as join8, resolve as resolve4 } from "node:path";
|
|
26354
26354
|
import { fileURLToPath } from "node:url";
|
|
26355
26355
|
|
|
26356
26356
|
// package.json
|
|
26357
26357
|
var package_default = {
|
|
26358
26358
|
name: "megareviewer",
|
|
26359
|
-
version: "0.2.
|
|
26359
|
+
version: "0.2.6",
|
|
26360
26360
|
description: "Guided code review for GitHub and Bitbucket Cloud pull requests: intent first, changes sorted by risk, decisions to approve.",
|
|
26361
26361
|
keywords: [
|
|
26362
26362
|
"code-review",
|
|
@@ -26398,7 +26398,8 @@ var package_default = {
|
|
|
26398
26398
|
"dev:web:mock": "vite --config web/vite.config.ts --mode mock",
|
|
26399
26399
|
"dev:fake": "node src/cli/dev/fake-main.ts",
|
|
26400
26400
|
build: "node scripts/build.ts",
|
|
26401
|
-
e2e: "playwright test -c e2e"
|
|
26401
|
+
e2e: "playwright test -c e2e",
|
|
26402
|
+
measure: "node scripts/measure-pr.ts"
|
|
26402
26403
|
},
|
|
26403
26404
|
devDependencies: {
|
|
26404
26405
|
"@anthropic-ai/sdk": "0.137.0",
|
|
@@ -26433,88 +26434,6 @@ var package_default = {
|
|
|
26433
26434
|
}
|
|
26434
26435
|
};
|
|
26435
26436
|
|
|
26436
|
-
// src/cli/args.ts
|
|
26437
|
-
import { parseArgs } from "node:util";
|
|
26438
|
-
|
|
26439
|
-
// src/domain/shared/hash.ts
|
|
26440
|
-
var OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
26441
|
-
var PRIME = 0x100000001b3n;
|
|
26442
|
-
var MASK = 0xffffffffffffffffn;
|
|
26443
|
-
var utf8 = new TextEncoder();
|
|
26444
|
-
var fnv1a64 = (input2) => {
|
|
26445
|
-
let hash2 = OFFSET_BASIS;
|
|
26446
|
-
for (const byte of utf8.encode(input2)) {
|
|
26447
|
-
hash2 = (hash2 ^ BigInt(byte)) * PRIME & MASK;
|
|
26448
|
-
}
|
|
26449
|
-
return hash2.toString(16).padStart(16, "0");
|
|
26450
|
-
};
|
|
26451
|
-
|
|
26452
|
-
// src/domain/shared/result.ts
|
|
26453
|
-
var ok = (value) => ({ ok: true, value });
|
|
26454
|
-
var err2 = (error62) => ({ ok: false, error: error62 });
|
|
26455
|
-
|
|
26456
|
-
// src/cli/args.ts
|
|
26457
|
-
var EXIT = { ok: 0, config: 1, usage: 2 };
|
|
26458
|
-
var USAGE = `Usage:
|
|
26459
|
-
megareviewer [--port <n>] [--no-open] [--ai]
|
|
26460
|
-
Start the review UI (any free port by default);
|
|
26461
|
-
--ai adds intent, decisions and a guided tour from Claude
|
|
26462
|
-
megareviewer doctor Check credentials and setup
|
|
26463
|
-
megareviewer --version
|
|
26464
|
-
megareviewer --help`;
|
|
26465
|
-
var MAX_PORT = 65535;
|
|
26466
|
-
var parseCliArgs = (argv) => {
|
|
26467
|
-
let parsed;
|
|
26468
|
-
try {
|
|
26469
|
-
parsed = parse(argv);
|
|
26470
|
-
} catch (error62) {
|
|
26471
|
-
if (error62 instanceof TypeError) return err2(error62.message);
|
|
26472
|
-
throw error62;
|
|
26473
|
-
}
|
|
26474
|
-
const { values, positionals } = parsed;
|
|
26475
|
-
if (values.help === true) return ok({ kind: "help" });
|
|
26476
|
-
const [command, ...extra] = positionals;
|
|
26477
|
-
if (extra.length > 0) return err2(`Unexpected argument: ${extra.join(" ")}`);
|
|
26478
|
-
const serveFlags = values.port !== void 0 || values["no-open"] === true || values.ai === true;
|
|
26479
|
-
if (values.version === true) {
|
|
26480
|
-
if (command !== void 0 || serveFlags) return err2("--version takes no other arguments");
|
|
26481
|
-
return ok({ kind: "version" });
|
|
26482
|
-
}
|
|
26483
|
-
if (command === "doctor") {
|
|
26484
|
-
if (serveFlags) return err2("doctor takes no options");
|
|
26485
|
-
return ok({ kind: "doctor" });
|
|
26486
|
-
}
|
|
26487
|
-
if (command !== void 0) return err2(`Unknown command: ${command}`);
|
|
26488
|
-
let port = 0;
|
|
26489
|
-
if (values.port !== void 0) {
|
|
26490
|
-
if (!/^\d+$/.test(values.port) || Number(values.port) > MAX_PORT) {
|
|
26491
|
-
return err2(`--port must be a number from 0 to ${MAX_PORT}`);
|
|
26492
|
-
}
|
|
26493
|
-
port = Number(values.port);
|
|
26494
|
-
}
|
|
26495
|
-
return ok({ kind: "serve", port, open: values["no-open"] !== true, ai: values.ai === true });
|
|
26496
|
-
};
|
|
26497
|
-
var parse = (argv) => parseArgs({
|
|
26498
|
-
args: [...argv],
|
|
26499
|
-
options: {
|
|
26500
|
-
port: { type: "string" },
|
|
26501
|
-
"no-open": { type: "boolean" },
|
|
26502
|
-
ai: { type: "boolean" },
|
|
26503
|
-
version: { type: "boolean" },
|
|
26504
|
-
help: { type: "boolean", short: "h" }
|
|
26505
|
-
},
|
|
26506
|
-
allowPositionals: true,
|
|
26507
|
-
strict: true
|
|
26508
|
-
});
|
|
26509
|
-
|
|
26510
|
-
// src/cli/compose.ts
|
|
26511
|
-
init_sdk();
|
|
26512
|
-
init_credentials();
|
|
26513
|
-
import { randomBytes } from "node:crypto";
|
|
26514
|
-
import { mkdirSync } from "node:fs";
|
|
26515
|
-
import { join as join5 } from "node:path";
|
|
26516
|
-
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
26517
|
-
|
|
26518
26437
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
26519
26438
|
var external_exports = {};
|
|
26520
26439
|
__export(external_exports, {
|
|
@@ -26639,7 +26558,7 @@ __export(external_exports, {
|
|
|
26639
26558
|
e164: () => e1642,
|
|
26640
26559
|
email: () => email2,
|
|
26641
26560
|
emoji: () => emoji2,
|
|
26642
|
-
encode: () =>
|
|
26561
|
+
encode: () => encode2,
|
|
26643
26562
|
encodeAsync: () => encodeAsync2,
|
|
26644
26563
|
endsWith: () => _endsWith,
|
|
26645
26564
|
enum: () => _enum2,
|
|
@@ -26713,7 +26632,7 @@ __export(external_exports, {
|
|
|
26713
26632
|
optional: () => optional,
|
|
26714
26633
|
output: () => output,
|
|
26715
26634
|
overwrite: () => _overwrite,
|
|
26716
|
-
parse: () =>
|
|
26635
|
+
parse: () => parse2,
|
|
26717
26636
|
parseAsync: () => parseAsync2,
|
|
26718
26637
|
partialRecord: () => partialRecord,
|
|
26719
26638
|
pipe: () => pipe,
|
|
@@ -26729,7 +26648,7 @@ __export(external_exports, {
|
|
|
26729
26648
|
refine: () => refine,
|
|
26730
26649
|
regex: () => _regex,
|
|
26731
26650
|
regexes: () => regexes_exports,
|
|
26732
|
-
registry: () =>
|
|
26651
|
+
registry: () => registry,
|
|
26733
26652
|
safeDecode: () => safeDecode2,
|
|
26734
26653
|
safeDecodeAsync: () => safeDecodeAsync2,
|
|
26735
26654
|
safeEncode: () => safeEncode2,
|
|
@@ -27041,7 +26960,7 @@ __export(core_exports2, {
|
|
|
27041
26960
|
decode: () => decode,
|
|
27042
26961
|
decodeAsync: () => decodeAsync,
|
|
27043
26962
|
describe: () => describe,
|
|
27044
|
-
encode: () =>
|
|
26963
|
+
encode: () => encode,
|
|
27045
26964
|
encodeAsync: () => encodeAsync,
|
|
27046
26965
|
extractDefs: () => extractDefs,
|
|
27047
26966
|
finalize: () => finalize,
|
|
@@ -27065,14 +26984,14 @@ __export(core_exports2, {
|
|
|
27065
26984
|
memoizer: () => memoizer,
|
|
27066
26985
|
mergeValues: () => mergeValues,
|
|
27067
26986
|
meta: () => meta,
|
|
27068
|
-
parse: () =>
|
|
26987
|
+
parse: () => parse,
|
|
27069
26988
|
parseAsync: () => parseAsync,
|
|
27070
26989
|
parseURLObject: () => parseURLObject,
|
|
27071
26990
|
prettifyError: () => prettifyError,
|
|
27072
26991
|
process: () => processSchema,
|
|
27073
26992
|
processSchema: () => processSchema,
|
|
27074
26993
|
regexes: () => regexes_exports,
|
|
27075
|
-
registry: () =>
|
|
26994
|
+
registry: () => registry,
|
|
27076
26995
|
safeDecode: () => safeDecode,
|
|
27077
26996
|
safeDecodeAsync: () => safeDecodeAsync,
|
|
27078
26997
|
safeEncode: () => safeEncode,
|
|
@@ -27952,7 +27871,7 @@ function constantCatch(value) {
|
|
|
27952
27871
|
}
|
|
27953
27872
|
|
|
27954
27873
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
|
|
27955
|
-
var
|
|
27874
|
+
var _a;
|
|
27956
27875
|
var NEVER = /* @__PURE__ */ Object.freeze({
|
|
27957
27876
|
status: "aborted"
|
|
27958
27877
|
});
|
|
@@ -28065,7 +27984,7 @@ var $ZodEncodeError = class extends Error {
|
|
|
28065
27984
|
this.name = "ZodEncodeError";
|
|
28066
27985
|
}
|
|
28067
27986
|
};
|
|
28068
|
-
(
|
|
27987
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
28069
27988
|
var globalConfig = globalThis.__zod_globalConfig;
|
|
28070
27989
|
function config(newConfig) {
|
|
28071
27990
|
if (newConfig)
|
|
@@ -28285,7 +28204,7 @@ var _parse = (_Err) => {
|
|
|
28285
28204
|
};
|
|
28286
28205
|
return fn;
|
|
28287
28206
|
};
|
|
28288
|
-
var
|
|
28207
|
+
var parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
28289
28208
|
var _parseAsync = (_Err) => {
|
|
28290
28209
|
const fn = async (schema, value, _ctx, params) => {
|
|
28291
28210
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
@@ -28380,7 +28299,7 @@ var _encode = (_Err) => {
|
|
|
28380
28299
|
};
|
|
28381
28300
|
return fn;
|
|
28382
28301
|
};
|
|
28383
|
-
var
|
|
28302
|
+
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
28384
28303
|
var _decode = (_Err) => {
|
|
28385
28304
|
const parse6 = _parse(_Err);
|
|
28386
28305
|
const fn = (schema, value, _ctx, _params) => {
|
|
@@ -28488,7 +28407,7 @@ __export(regexes_exports, {
|
|
|
28488
28407
|
unicodeEmail: () => unicodeEmail,
|
|
28489
28408
|
uppercase: () => uppercase,
|
|
28490
28409
|
uuid: () => uuid,
|
|
28491
|
-
uuid4: () =>
|
|
28410
|
+
uuid4: () => uuid4,
|
|
28492
28411
|
uuid6: () => uuid6,
|
|
28493
28412
|
uuid7: () => uuid7,
|
|
28494
28413
|
xid: () => xid
|
|
@@ -28510,7 +28429,7 @@ var uuid = (version3) => {
|
|
|
28510
28429
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
28511
28430
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
28512
28431
|
};
|
|
28513
|
-
var
|
|
28432
|
+
var uuid4 = /* @__PURE__ */ uuid(4);
|
|
28514
28433
|
var uuid6 = /* @__PURE__ */ uuid(6);
|
|
28515
28434
|
var uuid7 = /* @__PURE__ */ uuid(7);
|
|
28516
28435
|
var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
@@ -31438,10 +31357,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
31438
31357
|
throw new Error("implement() must be called with a function");
|
|
31439
31358
|
}
|
|
31440
31359
|
return Object.defineProperty(function(...args2) {
|
|
31441
|
-
const parsedArgs = inst._def.input ?
|
|
31360
|
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args2) : args2;
|
|
31442
31361
|
const result = Reflect.apply(func2, this, parsedArgs);
|
|
31443
31362
|
if (inst._def.output) {
|
|
31444
|
-
return
|
|
31363
|
+
return parse(inst._def.output, result);
|
|
31445
31364
|
}
|
|
31446
31365
|
return result;
|
|
31447
31366
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -31582,7 +31501,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
31582
31501
|
var NONE = 0;
|
|
31583
31502
|
var ASSUMED = 1;
|
|
31584
31503
|
var PROVEN = 2;
|
|
31585
|
-
function isRecursive(inst, stack,
|
|
31504
|
+
function isRecursive(inst, stack, resolve5) {
|
|
31586
31505
|
const cached2 = recursive.get(inst);
|
|
31587
31506
|
if (cached2 !== void 0)
|
|
31588
31507
|
return cached2 ? PROVEN : NONE;
|
|
@@ -31592,7 +31511,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
31592
31511
|
let result = NONE;
|
|
31593
31512
|
const check3 = (child) => {
|
|
31594
31513
|
if (result !== PROVEN && child?._zod) {
|
|
31595
|
-
const answer = isRecursive(child, stack,
|
|
31514
|
+
const answer = isRecursive(child, stack, resolve5);
|
|
31596
31515
|
if (answer > result)
|
|
31597
31516
|
result = answer;
|
|
31598
31517
|
}
|
|
@@ -31603,7 +31522,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
31603
31522
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
31604
31523
|
if (spread && !desc.enumerable)
|
|
31605
31524
|
continue;
|
|
31606
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
31525
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve5) : NONE;
|
|
31607
31526
|
if (child > answer)
|
|
31608
31527
|
answer = child;
|
|
31609
31528
|
}
|
|
@@ -31667,7 +31586,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
31667
31586
|
break;
|
|
31668
31587
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
31669
31588
|
case "lazy": {
|
|
31670
|
-
const inner = def._cachedInner ?? (
|
|
31589
|
+
const inner = def._cachedInner ?? (resolve5 ? inst._zod.innerType : void 0);
|
|
31671
31590
|
merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
31672
31591
|
break;
|
|
31673
31592
|
}
|
|
@@ -39408,7 +39327,7 @@ function yo_default() {
|
|
|
39408
39327
|
}
|
|
39409
39328
|
|
|
39410
39329
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
|
|
39411
|
-
var
|
|
39330
|
+
var _a2;
|
|
39412
39331
|
var $output = /* @__PURE__ */ Symbol("ZodOutput");
|
|
39413
39332
|
var $input = /* @__PURE__ */ Symbol("ZodInput");
|
|
39414
39333
|
var $ZodRegistry = class {
|
|
@@ -39451,10 +39370,10 @@ var $ZodRegistry = class {
|
|
|
39451
39370
|
return this._map.has(schema);
|
|
39452
39371
|
}
|
|
39453
39372
|
};
|
|
39454
|
-
function
|
|
39373
|
+
function registry() {
|
|
39455
39374
|
return new $ZodRegistry();
|
|
39456
39375
|
}
|
|
39457
|
-
(
|
|
39376
|
+
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
39458
39377
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
39459
39378
|
|
|
39460
39379
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/compile.js
|
|
@@ -43748,11 +43667,11 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
|
|
|
43748
43667
|
});
|
|
43749
43668
|
|
|
43750
43669
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/parse.js
|
|
43751
|
-
var
|
|
43670
|
+
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
43752
43671
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
43753
43672
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
43754
43673
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
43755
|
-
var
|
|
43674
|
+
var encode2 = /* @__PURE__ */ _encode(ZodRealError);
|
|
43756
43675
|
var decode2 = /* @__PURE__ */ _decode(ZodRealError);
|
|
43757
43676
|
var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
43758
43677
|
var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
@@ -43885,7 +43804,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
43885
43804
|
util_exports.own(this, "~standard", value);
|
|
43886
43805
|
},
|
|
43887
43806
|
parse: function _parse2(data, params) {
|
|
43888
|
-
return
|
|
43807
|
+
return parse2(this, data, params, { callee: _parse2 });
|
|
43889
43808
|
},
|
|
43890
43809
|
parseAsync: async function _parseAsync2(data, params) {
|
|
43891
43810
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -43910,7 +43829,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
43910
43829
|
return validateAsync(this, data, params);
|
|
43911
43830
|
},
|
|
43912
43831
|
encode: function _encode2(data, params) {
|
|
43913
|
-
return
|
|
43832
|
+
return encode2(this, data, params, { callee: _encode2 });
|
|
43914
43833
|
},
|
|
43915
43834
|
decode: function _decode2(data, params) {
|
|
43916
43835
|
return decode2(this, data, params, { callee: _decode2 });
|
|
@@ -46242,16 +46161,16 @@ var languageFamily = (language) => FAMILIES[language] ?? language;
|
|
|
46242
46161
|
var RESOLVED = /* @__PURE__ */ new Set(["typescript", "tsx", "javascript", "python", "go", "java"]);
|
|
46243
46162
|
var resolvesImports = (language) => RESOLVED.has(language);
|
|
46244
46163
|
var DIRECTORY_PACKAGES = /* @__PURE__ */ new Set(["go", "java"]);
|
|
46245
|
-
var sharesPackage = (language, from, to) => DIRECTORY_PACKAGES.has(language) &&
|
|
46246
|
-
var
|
|
46164
|
+
var sharesPackage = (language, from, to) => DIRECTORY_PACKAGES.has(language) && dirname(from) === dirname(to);
|
|
46165
|
+
var dirname = (path4) => path4.slice(0, Math.max(path4.lastIndexOf("/"), 0));
|
|
46247
46166
|
var basename = (path4) => path4.slice(path4.lastIndexOf("/") + 1);
|
|
46248
|
-
var
|
|
46167
|
+
var join = (dir, path4) => dir === "" ? path4 : `${dir}/${path4}`;
|
|
46249
46168
|
var stem = (path4) => {
|
|
46250
46169
|
const name2 = basename(path4).replace(/\.d\.ts$/, "");
|
|
46251
46170
|
const dot = name2.lastIndexOf(".");
|
|
46252
|
-
return
|
|
46171
|
+
return join(dirname(path4), dot <= 0 ? name2 : name2.slice(0, dot));
|
|
46253
46172
|
};
|
|
46254
|
-
var
|
|
46173
|
+
var resolve = (dir, relative) => {
|
|
46255
46174
|
const parts2 = dir === "" ? [] : dir.split("/");
|
|
46256
46175
|
for (const part of relative.split("/")) {
|
|
46257
46176
|
if (part === "" || part === ".") continue;
|
|
@@ -46265,7 +46184,7 @@ var resolve2 = (dir, relative) => {
|
|
|
46265
46184
|
return parts2.join("/");
|
|
46266
46185
|
};
|
|
46267
46186
|
var covers = (path4, target, anchored) => {
|
|
46268
|
-
const module2 = /(^|\/)(index|__init__)$/.test(target) ?
|
|
46187
|
+
const module2 = /(^|\/)(index|__init__)$/.test(target) ? dirname(target) : target;
|
|
46269
46188
|
const at = anchored ? stem(path4) === target : stem(path4) === target || stem(path4).endsWith(`/${target}`);
|
|
46270
46189
|
const inside = anchored ? module2 === "" || path4.startsWith(`${module2}/`) : path4.startsWith(`${module2}/`) || path4.includes(`/${module2}/`);
|
|
46271
46190
|
return at || inside;
|
|
@@ -46274,7 +46193,7 @@ var JS_EXTENSION = /\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/;
|
|
|
46274
46193
|
var javascriptReach = (from, { module: module2, names }) => {
|
|
46275
46194
|
const bare = module2.replace(JS_EXTENSION, "");
|
|
46276
46195
|
if (bare.startsWith(".")) {
|
|
46277
|
-
const target =
|
|
46196
|
+
const target = resolve(dirname(from), bare);
|
|
46278
46197
|
if (target === null) return null;
|
|
46279
46198
|
const reaches2 = (path4) => covers(path4, target, true);
|
|
46280
46199
|
return { names, name: reaches2, member: reaches2 };
|
|
@@ -46289,35 +46208,35 @@ var pythonReach = (from, { module: module2, names }) => {
|
|
|
46289
46208
|
const rest = module2.slice(dots).replaceAll(".", "/");
|
|
46290
46209
|
let target = rest;
|
|
46291
46210
|
if (dots > 0) {
|
|
46292
|
-
const base =
|
|
46293
|
-
target = base === null ? null :
|
|
46211
|
+
const base = resolve(dirname(from), "../".repeat(dots - 1));
|
|
46212
|
+
target = base === null ? null : join(base, rest).replace(/\/$/, "");
|
|
46294
46213
|
}
|
|
46295
46214
|
if (target === null) return null;
|
|
46296
46215
|
const anchored = dots > 0;
|
|
46297
46216
|
const resolved = target;
|
|
46298
46217
|
const within = (path4, module3) => covers(path4, module3, anchored);
|
|
46299
|
-
const isModule = (path4) => [resolved,
|
|
46218
|
+
const isModule = (path4) => [resolved, join(resolved, "__init__")].some(
|
|
46300
46219
|
(name2) => anchored ? stem(path4) === name2 : stem(path4) === name2 || stem(path4).endsWith(`/${name2}`)
|
|
46301
46220
|
);
|
|
46302
46221
|
return {
|
|
46303
46222
|
names,
|
|
46304
46223
|
name: (path4) => within(path4, resolved),
|
|
46305
46224
|
// `from pkg import mod` imports a module, so `mod.f()` reaches pkg/mod.py.
|
|
46306
|
-
member: (path4) => names === null ? within(path4, resolved) : isModule(path4) || names.some((name2) => within(path4,
|
|
46225
|
+
member: (path4) => names === null ? within(path4, resolved) : isModule(path4) || names.some((name2) => within(path4, join(resolved, name2)))
|
|
46307
46226
|
};
|
|
46308
46227
|
};
|
|
46309
46228
|
var goReach = ({ module: module2 }) => {
|
|
46310
46229
|
const reaches = (path4) => {
|
|
46311
|
-
const dir =
|
|
46230
|
+
const dir = dirname(path4);
|
|
46312
46231
|
return dir !== "" && (module2 === dir || module2.endsWith(`/${dir}`));
|
|
46313
46232
|
};
|
|
46314
46233
|
return { names: null, name: reaches, member: reaches };
|
|
46315
46234
|
};
|
|
46316
46235
|
var javaReach = ({ module: module2, names }) => {
|
|
46317
46236
|
const path4 = module2.replaceAll(".", "/");
|
|
46318
|
-
const reaches = names?.includes("*") ? (file2) =>
|
|
46237
|
+
const reaches = names?.includes("*") ? (file2) => dirname(file2) === path4 || dirname(file2).endsWith(`/${path4}`) : (file2) => (
|
|
46319
46238
|
// `import static a.b.C.m` names a member of a/b/C.
|
|
46320
|
-
[path4,
|
|
46239
|
+
[path4, dirname(path4)].some(
|
|
46321
46240
|
(target) => target !== "" && (stem(file2) === target || stem(file2).endsWith(`/${target}`))
|
|
46322
46241
|
)
|
|
46323
46242
|
);
|
|
@@ -46338,6 +46257,225 @@ var importReach = (from, language, symbolImport) => {
|
|
|
46338
46257
|
}
|
|
46339
46258
|
};
|
|
46340
46259
|
|
|
46260
|
+
// src/domain/diff/types.ts
|
|
46261
|
+
var HunkId = external_exports.string().regex(/^h_[0-9a-f]{16}(-[2-9]|-[1-9][0-9]+)?$/).brand();
|
|
46262
|
+
var PartId = external_exports.union([
|
|
46263
|
+
HunkId,
|
|
46264
|
+
external_exports.string().regex(/^h_[0-9a-f]{16}(-[2-9]|-[1-9][0-9]+)?\.[1-9][0-9]*$/).brand()
|
|
46265
|
+
]);
|
|
46266
|
+
var FileStatus = external_exports.enum(["added", "deleted", "modified", "renamed"]);
|
|
46267
|
+
var LineNumber = external_exports.number().int().positive();
|
|
46268
|
+
var DiffLine = external_exports.object({
|
|
46269
|
+
kind: external_exports.enum(["context", "add", "del"]),
|
|
46270
|
+
oldLine: LineNumber.nullable(),
|
|
46271
|
+
newLine: LineNumber.nullable(),
|
|
46272
|
+
text: external_exports.string(),
|
|
46273
|
+
/** Set when the diff says "" after this line. */
|
|
46274
|
+
noNewlineAtEnd: external_exports.boolean()
|
|
46275
|
+
}).readonly();
|
|
46276
|
+
var LineCount = external_exports.number().int().nonnegative();
|
|
46277
|
+
var Hunk = external_exports.object({
|
|
46278
|
+
id: HunkId,
|
|
46279
|
+
path: external_exports.string().min(1),
|
|
46280
|
+
oldStart: LineCount,
|
|
46281
|
+
oldLines: LineCount,
|
|
46282
|
+
newStart: LineCount,
|
|
46283
|
+
newLines: LineCount,
|
|
46284
|
+
sectionHeading: external_exports.string().nullable(),
|
|
46285
|
+
lines: external_exports.array(DiffLine).readonly()
|
|
46286
|
+
}).readonly();
|
|
46287
|
+
var FileChange = external_exports.object({
|
|
46288
|
+
/** The new path, or the old one for a deleted file. */
|
|
46289
|
+
path: external_exports.string().min(1),
|
|
46290
|
+
oldPath: external_exports.string().min(1).nullable(),
|
|
46291
|
+
status: FileStatus,
|
|
46292
|
+
binary: external_exports.boolean(),
|
|
46293
|
+
/** Set only when the file mode changed. */
|
|
46294
|
+
oldMode: external_exports.string().nullable(),
|
|
46295
|
+
newMode: external_exports.string().nullable(),
|
|
46296
|
+
/** A tree-sitter language name, filled after parsing; null when unknown. */
|
|
46297
|
+
language: external_exports.string().nullable(),
|
|
46298
|
+
hunks: external_exports.array(Hunk).readonly(),
|
|
46299
|
+
additions: LineCount,
|
|
46300
|
+
deletions: LineCount
|
|
46301
|
+
}).readonly();
|
|
46302
|
+
var MechanicalProofKind = external_exports.enum([
|
|
46303
|
+
"generated",
|
|
46304
|
+
"whitespace",
|
|
46305
|
+
"rename",
|
|
46306
|
+
"move",
|
|
46307
|
+
"formatting"
|
|
46308
|
+
]);
|
|
46309
|
+
var MechanicalProof = external_exports.object({
|
|
46310
|
+
path: external_exports.string().min(1),
|
|
46311
|
+
/** null for a file-level proof of a file with no hunks, such as a pure rename. */
|
|
46312
|
+
hunkId: HunkId.nullable(),
|
|
46313
|
+
kind: MechanicalProofKind,
|
|
46314
|
+
/** What was checked, for the reviewer: "moved from src/a.ts:10–42, identical". */
|
|
46315
|
+
detail: external_exports.string().min(1)
|
|
46316
|
+
}).readonly();
|
|
46317
|
+
var HunkPart = external_exports.object({
|
|
46318
|
+
id: PartId,
|
|
46319
|
+
hunkId: HunkId,
|
|
46320
|
+
start: external_exports.number().int().nonnegative(),
|
|
46321
|
+
end: external_exports.number().int().positive(),
|
|
46322
|
+
definitions: external_exports.array(external_exports.string()).readonly()
|
|
46323
|
+
}).readonly();
|
|
46324
|
+
var CallGraphHint = external_exports.object({
|
|
46325
|
+
fromPartId: PartId,
|
|
46326
|
+
toPartId: PartId,
|
|
46327
|
+
symbol: external_exports.string().min(1),
|
|
46328
|
+
line: external_exports.number().int().positive(),
|
|
46329
|
+
use: external_exports.enum(["call", "type", "request"])
|
|
46330
|
+
}).readonly();
|
|
46331
|
+
var UnchangedUse = external_exports.object({
|
|
46332
|
+
path: external_exports.string().min(1),
|
|
46333
|
+
line: LineNumber,
|
|
46334
|
+
use: external_exports.enum(["call", "type"]),
|
|
46335
|
+
excerpt: external_exports.object({ start: LineNumber, lines: external_exports.array(external_exports.string()).max(5).readonly() }).readonly()
|
|
46336
|
+
}).readonly();
|
|
46337
|
+
var UnchangedCallers = external_exports.object({
|
|
46338
|
+
partId: PartId,
|
|
46339
|
+
symbol: external_exports.string().min(1),
|
|
46340
|
+
uses: external_exports.array(UnchangedUse).max(50).readonly(),
|
|
46341
|
+
more: external_exports.number().int().nonnegative()
|
|
46342
|
+
}).readonly();
|
|
46343
|
+
|
|
46344
|
+
// src/domain/diff/parts.ts
|
|
46345
|
+
var hunkIdOf = (id) => HunkId.parse(id.replace(/\.[0-9]+$/, ""));
|
|
46346
|
+
var partId = (hunkId2, n) => PartId.parse(`${hunkId2}.${n}`);
|
|
46347
|
+
var holds = (definition, line) => line >= definition.startLine && line <= definition.endLine;
|
|
46348
|
+
var span = (definition) => definition.endLine - definition.startLine;
|
|
46349
|
+
var cutters = (definitions, lines) => {
|
|
46350
|
+
if (lines.length === 0) return [];
|
|
46351
|
+
const first = Math.min(...lines);
|
|
46352
|
+
const last = Math.max(...lines);
|
|
46353
|
+
const inside = definitions.filter(
|
|
46354
|
+
(definition) => definition.startLine <= last && definition.endLine >= first && !(definition.startLine <= first && definition.endLine >= last)
|
|
46355
|
+
);
|
|
46356
|
+
return inside.filter(
|
|
46357
|
+
(definition) => !inside.some(
|
|
46358
|
+
(other) => other !== definition && other.startLine <= definition.startLine && other.endLine >= definition.endLine && span(other) > span(definition)
|
|
46359
|
+
)
|
|
46360
|
+
);
|
|
46361
|
+
};
|
|
46362
|
+
var changes = (line) => line.kind !== "context";
|
|
46363
|
+
var splitByDefinition = (hunk, definitions) => {
|
|
46364
|
+
const head = cutters(
|
|
46365
|
+
definitions.head,
|
|
46366
|
+
hunk.lines.flatMap((line) => line.newLine ?? [])
|
|
46367
|
+
);
|
|
46368
|
+
const base = cutters(
|
|
46369
|
+
definitions.base,
|
|
46370
|
+
hunk.lines.flatMap((line) => line.oldLine ?? [])
|
|
46371
|
+
);
|
|
46372
|
+
const around = (cut, line) => line === null ? null : cut.find((definition) => holds(definition, line))?.name ?? null;
|
|
46373
|
+
const same = /* @__PURE__ */ new Map();
|
|
46374
|
+
const root = (name2) => {
|
|
46375
|
+
const parent = same.get(name2);
|
|
46376
|
+
return parent === void 0 || parent === name2 ? name2 : root(parent);
|
|
46377
|
+
};
|
|
46378
|
+
for (const line of hunk.lines) {
|
|
46379
|
+
const [inHead, inBase] = [around(head, line.newLine), around(base, line.oldLine)];
|
|
46380
|
+
if (line.kind === "context" && inHead !== null && inBase !== null) {
|
|
46381
|
+
same.set(root(inBase), root(inHead));
|
|
46382
|
+
}
|
|
46383
|
+
}
|
|
46384
|
+
const nameOf = (line) => line.kind === "del" ? around(base, line.oldLine) : around(head, line.newLine);
|
|
46385
|
+
const changedKey = (line) => {
|
|
46386
|
+
const name2 = changes(line) ? nameOf(line) : null;
|
|
46387
|
+
return name2 === null ? null : root(name2);
|
|
46388
|
+
};
|
|
46389
|
+
const changed = new Set(hunk.lines.flatMap((line) => changedKey(line) ?? []));
|
|
46390
|
+
const keyOf = (line) => {
|
|
46391
|
+
if (changes(line)) return changedKey(line);
|
|
46392
|
+
const name2 = around(head, line.newLine) ?? around(base, line.oldLine);
|
|
46393
|
+
return name2 !== null && changed.has(root(name2)) ? root(name2) : null;
|
|
46394
|
+
};
|
|
46395
|
+
const runs2 = [];
|
|
46396
|
+
let pending = 0;
|
|
46397
|
+
hunk.lines.forEach((line, at) => {
|
|
46398
|
+
const key = keyOf(line);
|
|
46399
|
+
if (key === null) return;
|
|
46400
|
+
const name2 = changes(line) ? nameOf(line) : null;
|
|
46401
|
+
const last2 = runs2.at(-1);
|
|
46402
|
+
if (last2 !== void 0 && last2.key === key) {
|
|
46403
|
+
last2.end = at + 1;
|
|
46404
|
+
if (name2 !== null) last2.names.push(name2);
|
|
46405
|
+
} else {
|
|
46406
|
+
runs2.push({ start: pending, end: at + 1, key, names: name2 === null ? [] : [name2] });
|
|
46407
|
+
if (last2 !== void 0) last2.end = pending;
|
|
46408
|
+
}
|
|
46409
|
+
pending = at + 1;
|
|
46410
|
+
});
|
|
46411
|
+
const last = runs2.at(-1);
|
|
46412
|
+
if (last !== void 0) last.end = hunk.lines.length;
|
|
46413
|
+
const merged = [];
|
|
46414
|
+
let carried = null;
|
|
46415
|
+
for (const run3 of runs2) {
|
|
46416
|
+
const current = carried === null ? run3 : { ...run3, start: carried.start, names: [...carried.names, ...run3.names] };
|
|
46417
|
+
carried = null;
|
|
46418
|
+
if (hunk.lines.slice(current.start, current.end).some(changes)) merged.push(current);
|
|
46419
|
+
else carried = current;
|
|
46420
|
+
}
|
|
46421
|
+
const previous = merged.at(-1);
|
|
46422
|
+
if (carried !== null && previous !== void 0) previous.end = carried.end;
|
|
46423
|
+
if (merged.length < 2) return [];
|
|
46424
|
+
return merged.map((run3, at) => ({
|
|
46425
|
+
id: partId(hunk.id, at + 1),
|
|
46426
|
+
hunkId: hunk.id,
|
|
46427
|
+
start: run3.start,
|
|
46428
|
+
end: run3.end,
|
|
46429
|
+
definitions: [...new Set(run3.names)]
|
|
46430
|
+
}));
|
|
46431
|
+
};
|
|
46432
|
+
var splitHunks = (files, definitionsByPath, unsplit) => files.flatMap((file2) => {
|
|
46433
|
+
const definitions = definitionsByPath.get(file2.path);
|
|
46434
|
+
if (definitions === void 0) return [];
|
|
46435
|
+
return file2.hunks.flatMap(
|
|
46436
|
+
(hunk) => unsplit.has(hunk.id) ? [] : splitByDefinition(hunk, definitions)
|
|
46437
|
+
);
|
|
46438
|
+
});
|
|
46439
|
+
var partHunk = (hunk, part) => {
|
|
46440
|
+
const before = hunk.lines.slice(0, part.start);
|
|
46441
|
+
const lines = hunk.lines.slice(part.start, part.end);
|
|
46442
|
+
const count3 = (of, kind) => of.filter((line) => line.kind !== kind).length;
|
|
46443
|
+
const oldLines = count3(lines, "add");
|
|
46444
|
+
const newLines2 = count3(lines, "del");
|
|
46445
|
+
const start3 = (hunkStart, hunkLines, skipped, length) => Math.max(hunkStart + (hunkLines === 0 ? 1 : 0) + skipped - (length === 0 ? 1 : 0), 0);
|
|
46446
|
+
return {
|
|
46447
|
+
...hunk,
|
|
46448
|
+
oldStart: start3(hunk.oldStart, hunk.oldLines, count3(before, "add"), oldLines),
|
|
46449
|
+
oldLines,
|
|
46450
|
+
newStart: start3(hunk.newStart, hunk.newLines, count3(before, "del"), newLines2),
|
|
46451
|
+
newLines: newLines2,
|
|
46452
|
+
lines
|
|
46453
|
+
};
|
|
46454
|
+
};
|
|
46455
|
+
var partsByHunk = (parts2) => {
|
|
46456
|
+
const byHunk = /* @__PURE__ */ new Map();
|
|
46457
|
+
for (const part of parts2) byHunk.set(part.hunkId, [...byHunk.get(part.hunkId) ?? [], part]);
|
|
46458
|
+
return byHunk;
|
|
46459
|
+
};
|
|
46460
|
+
var piecesOf = (file2, byHunk) => file2.hunks.flatMap((hunk) => {
|
|
46461
|
+
const parts2 = byHunk.get(hunk.id);
|
|
46462
|
+
return parts2 === void 0 ? [{ id: hunk.id, hunk }] : parts2.map((part) => ({ id: part.id, hunk: partHunk(hunk, part) }));
|
|
46463
|
+
});
|
|
46464
|
+
var renameHints = (hints, rename) => {
|
|
46465
|
+
const kept = /* @__PURE__ */ new Map();
|
|
46466
|
+
for (const hint of hints) {
|
|
46467
|
+
const fromPartId = rename(hint.fromPartId);
|
|
46468
|
+
const toPartId = rename(hint.toPartId);
|
|
46469
|
+
if (fromPartId === toPartId) continue;
|
|
46470
|
+
const key = `${fromPartId}>${toPartId}:${hint.use}:${hint.symbol}`;
|
|
46471
|
+
const known = kept.get(key);
|
|
46472
|
+
if (known === void 0 || hint.line < known.line) {
|
|
46473
|
+
kept.set(key, { ...hint, fromPartId, toPartId });
|
|
46474
|
+
}
|
|
46475
|
+
}
|
|
46476
|
+
return [...kept.values()];
|
|
46477
|
+
};
|
|
46478
|
+
|
|
46341
46479
|
// src/domain/diff/test-files.ts
|
|
46342
46480
|
var basename2 = (path4) => path4.slice(path4.lastIndexOf("/") + 1);
|
|
46343
46481
|
var directories = (path4) => path4.split("/").slice(0, -1);
|
|
@@ -46347,16 +46485,148 @@ var isTestFile = (path4) => {
|
|
|
46347
46485
|
return /\.(test|spec)\.[^.]+$/i.test(name2) || /_(test|spec)\.[^.]+$/i.test(name2) || /^test_.*\.py$/i.test(name2) || /Tests?\.(java|kt)$/.test(name2) || directories(path4).some((directory) => TEST_DIRECTORIES.has(directory.toLowerCase()));
|
|
46348
46486
|
};
|
|
46349
46487
|
|
|
46488
|
+
// src/domain/diff/requests.ts
|
|
46489
|
+
var METHODS = "get|post|put|patch|delete|head|options|all";
|
|
46490
|
+
var RECEIVER = String.raw`(?:app|router|server|mux|r|e|g|fastify|\w*(?:Router|router|App))`;
|
|
46491
|
+
var PATH = String.raw`["'\`](\/[^"'\`]*)["'\`]`;
|
|
46492
|
+
var ROUTE_PATTERNS = [
|
|
46493
|
+
// FastAPI and the like: @router.put("/p").
|
|
46494
|
+
(line) => [...line.matchAll(new RegExp(String.raw`@[\w.]+\.(${METHODS})\(\s*${PATH}`, "gi"))].map(
|
|
46495
|
+
([, method = "", path4 = ""]) => ({ method: method.toUpperCase(), path: path4 })
|
|
46496
|
+
),
|
|
46497
|
+
// Flask: @app.route("/p", methods=["GET", "POST"]).
|
|
46498
|
+
(line) => {
|
|
46499
|
+
const match2 = new RegExp(String.raw`@[\w.]+\.route\(\s*${PATH}(.*)`).exec(line);
|
|
46500
|
+
if (match2 === null) return [];
|
|
46501
|
+
const [, path4 = "", rest = ""] = match2;
|
|
46502
|
+
const methods = /methods\s*=\s*[[(]([^\])]*)/.exec(rest)?.[1];
|
|
46503
|
+
const listed2 = [...(methods ?? "").matchAll(/["'](\w+)["']/g)].map(
|
|
46504
|
+
([, m = ""]) => m.toUpperCase()
|
|
46505
|
+
);
|
|
46506
|
+
return (listed2.length > 0 ? listed2 : ["GET"]).map((method) => ({ method, path: path4 }));
|
|
46507
|
+
},
|
|
46508
|
+
// Express, Fastify, Gin, Echo, Chi: app.get("/p", …), r.GET("/p", …).
|
|
46509
|
+
(line) => [
|
|
46510
|
+
...line.matchAll(
|
|
46511
|
+
new RegExp(String.raw`(?<![\w@.])${RECEIVER}\.(${METHODS})\(\s*${PATH}`, "gi")
|
|
46512
|
+
)
|
|
46513
|
+
].map(([, method = "", path4 = ""]) => ({ method: method.toUpperCase(), path: path4 })),
|
|
46514
|
+
// Spring: @GetMapping("/p"), @RequestMapping(value = "/p").
|
|
46515
|
+
(line) => {
|
|
46516
|
+
const match2 = new RegExp(
|
|
46517
|
+
String.raw`@(Get|Post|Put|Patch|Delete|Request)Mapping\(\s*(?:(?:value|path)\s*=\s*)?${PATH}`
|
|
46518
|
+
).exec(line);
|
|
46519
|
+
if (match2 === null) return [];
|
|
46520
|
+
const [, verb = "", path4 = ""] = match2;
|
|
46521
|
+
return [{ method: verb === "Request" ? "ALL" : verb.toUpperCase(), path: path4 }];
|
|
46522
|
+
},
|
|
46523
|
+
// Go's net/http: mux.HandleFunc("/p", …) and, since Go 1.22, HandleFunc("GET /p", …).
|
|
46524
|
+
(line) => {
|
|
46525
|
+
const match2 = /\bHandle(?:Func)?\(\s*"(?:([A-Z]+) )?(\/[^"]*)"/.exec(line);
|
|
46526
|
+
if (match2 === null) return [];
|
|
46527
|
+
const [, method = "ALL", path4 = ""] = match2;
|
|
46528
|
+
return [{ method, path: path4 }];
|
|
46529
|
+
}
|
|
46530
|
+
];
|
|
46531
|
+
var routesOn = (line) => ROUTE_PATTERNS.flatMap((pattern) => pattern(line));
|
|
46532
|
+
var routeReceivers = (line) => routesOn(line).length > 0 ? [
|
|
46533
|
+
...line.matchAll(
|
|
46534
|
+
new RegExp(String.raw`([\w$]+)\s*\.\s*(?:${METHODS}|route|Handle|HandleFunc)\(`, "gi")
|
|
46535
|
+
)
|
|
46536
|
+
].flatMap(([, receiver]) => receiver ?? []) : [];
|
|
46537
|
+
var REQUEST_PATH = String.raw`(?<![\w])(?:[fFrRuU]{1,2})?(?<quote>["'\`])(?:\$\{[^}]*\})?(?<path>\/[^"'\`]*)\k<quote>`;
|
|
46538
|
+
var HANDLER = /^\s*,\s*(?:async\b|function\b|func\b|\(|[\w$]+\s*=>)/;
|
|
46539
|
+
var callsOn = (line, callee, flags2 = "g") => [...line.matchAll(new RegExp(String.raw`${callee}\(\s*${REQUEST_PATH}`, flags2))].map((match2) => ({
|
|
46540
|
+
method: match2.groups?.method?.toUpperCase() ?? null,
|
|
46541
|
+
path: match2.groups?.path ?? "",
|
|
46542
|
+
rest: line.slice(match2.index + match2[0].length)
|
|
46543
|
+
}));
|
|
46544
|
+
var CLIENT_METHODS = "get|post|put|patch|delete|head|options";
|
|
46545
|
+
var REQUEST_PATTERNS = [
|
|
46546
|
+
// Typed clients, like openapi-fetch: client.PUT("/p/{id}", …). Methods in upper case. Not in
|
|
46547
|
+
// Go, where Gin declares routes that way on any router group.
|
|
46548
|
+
(line, path4) => path4.endsWith(".go") ? [] : callsOn(line, String.raw`(?<![\w$])[\w$.]*[\w$]\.(?<method>GET|POST|PUT|PATCH|DELETE)`),
|
|
46549
|
+
// Plain HTTP clients: axios.get("/p"), api.post("/p"), this.http.put("/p"), ky.delete("/p").
|
|
46550
|
+
(line) => callsOn(
|
|
46551
|
+
line,
|
|
46552
|
+
String.raw`(?<![\w$@.])(?:this\.|self\.)?(?:axios|api|http|\$http|ky)\.(?<method>${CLIENT_METHODS})`,
|
|
46553
|
+
"gi"
|
|
46554
|
+
),
|
|
46555
|
+
// fetch("/p") is a GET; with options on the same line, their method, else still a GET.
|
|
46556
|
+
(line) => callsOn(line, String.raw`(?<![\w$.])(?:window\.)?fetch`).flatMap((found) => {
|
|
46557
|
+
if (/^\s*\)/.test(found.rest)) return [{ ...found, method: "GET" }];
|
|
46558
|
+
const options = /^\s*,\s*\{([^}]*)\}/.exec(found.rest)?.[1];
|
|
46559
|
+
if (options === void 0) return [];
|
|
46560
|
+
const method = /\bmethod\s*:\s*["'`](\w+)["'`]/.exec(options)?.[1];
|
|
46561
|
+
return [{ ...found, method: (method ?? "GET").toUpperCase() }];
|
|
46562
|
+
}),
|
|
46563
|
+
// Test clients: FastAPI's, Flask's and Django's (self.client.get), and supertest's request(app).
|
|
46564
|
+
(line, path4) => isTestFile(path4) ? [
|
|
46565
|
+
...callsOn(
|
|
46566
|
+
line,
|
|
46567
|
+
String.raw`(?<![\w$@])(?:(?:self|this)\.)?(?:\w*_)?[cC]lient\.(?<method>${CLIENT_METHODS})`,
|
|
46568
|
+
"gi"
|
|
46569
|
+
),
|
|
46570
|
+
...callsOn(
|
|
46571
|
+
line,
|
|
46572
|
+
String.raw`(?<![\w$.])(?:request|supertest)\([\w$.]+\)\.(?<method>${CLIENT_METHODS})`,
|
|
46573
|
+
"gi"
|
|
46574
|
+
)
|
|
46575
|
+
] : []
|
|
46576
|
+
];
|
|
46577
|
+
var requestsOn = (line, path4) => {
|
|
46578
|
+
if (routesOn(line).length > 0) return [];
|
|
46579
|
+
const seen = /* @__PURE__ */ new Set();
|
|
46580
|
+
return REQUEST_PATTERNS.flatMap((pattern) => pattern(line, path4)).flatMap((found) => {
|
|
46581
|
+
if (found.method === null || HANDLER.test(found.rest) || /^\s*\+/.test(found.rest)) return [];
|
|
46582
|
+
const request2 = { method: found.method, path: found.path.replace(/[?#].*$/, "") };
|
|
46583
|
+
const key = `${request2.method} ${request2.path}`;
|
|
46584
|
+
if (seen.has(key)) return [];
|
|
46585
|
+
seen.add(key);
|
|
46586
|
+
return [request2];
|
|
46587
|
+
});
|
|
46588
|
+
};
|
|
46589
|
+
var PLACEHOLDER = /\$\{[^}]*\}|\{[^}]*\}|<[^>]*>|^:[\w$]+$|^\*$/g;
|
|
46590
|
+
var segments = (path4) => path4.replace(/\/+$/, "").split("/").filter((segment2) => segment2 !== "");
|
|
46591
|
+
var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
46592
|
+
var fits = (pattern, text) => {
|
|
46593
|
+
const literal2 = pattern.split(PLACEHOLDER).map(escapeRegExp);
|
|
46594
|
+
return new RegExp(`^${literal2.join("[^/]+")}$`).test(text);
|
|
46595
|
+
};
|
|
46596
|
+
var hasPlaceholder = (segment2) => segment2.match(PLACEHOLDER) !== null;
|
|
46597
|
+
var segmentsMatch = (a, b) => {
|
|
46598
|
+
if (a === b) return true;
|
|
46599
|
+
const [aOpen, bOpen] = [hasPlaceholder(a), hasPlaceholder(b)];
|
|
46600
|
+
if (aOpen && bOpen) return a.replace(PLACEHOLDER, "{}") === b.replace(PLACEHOLDER, "{}");
|
|
46601
|
+
if (aOpen) return fits(a, b);
|
|
46602
|
+
if (bOpen) return fits(b, a);
|
|
46603
|
+
return false;
|
|
46604
|
+
};
|
|
46605
|
+
var pathsMatch = (request2, route) => request2.length === route.length && request2.every((segment2, at) => segmentsMatch(segment2, route[at] ?? ""));
|
|
46606
|
+
var methodsMatch = (request2, route) => route.method === "ALL" || request2.method === route.method;
|
|
46607
|
+
var routesFor = (request2, routes2) => {
|
|
46608
|
+
const wanted = segments(request2.path);
|
|
46609
|
+
const candidates = routes2.filter((route) => methodsMatch(request2, route));
|
|
46610
|
+
const exact = candidates.filter((route) => pathsMatch(wanted, segments(route.path)));
|
|
46611
|
+
if (exact.length > 0) return exact;
|
|
46612
|
+
const prefixed = candidates.filter((route) => {
|
|
46613
|
+
const tail = segments(route.path);
|
|
46614
|
+
return tail.length > 0 && tail.length < wanted.length && pathsMatch(wanted.slice(wanted.length - tail.length), tail);
|
|
46615
|
+
});
|
|
46616
|
+
return prefixed.length === 1 ? prefixed : [];
|
|
46617
|
+
};
|
|
46618
|
+
|
|
46350
46619
|
// src/domain/diff/call-graph.ts
|
|
46351
46620
|
var MAX_HINTS_PER_HUNK = 10;
|
|
46352
|
-
var buildCallGraphHints = (files, symbolsByPath) => {
|
|
46353
|
-
const
|
|
46621
|
+
var buildCallGraphHints = (files, symbolsByPath, parts2 = []) => {
|
|
46622
|
+
const byHunk = partsByHunk(parts2);
|
|
46623
|
+
const hunks = files.flatMap((file2) => piecesOf(file2, byHunk).map((piece) => ({ file: file2, piece }))).map((entry, order2) => ({ ...entry, order: order2 }));
|
|
46354
46624
|
const changedBy = /* @__PURE__ */ new Map();
|
|
46355
46625
|
for (const at of hunks) {
|
|
46356
|
-
for (const definition of changedDefinitions(at.hunk, symbolsByPath.get(at.file.path))) {
|
|
46357
|
-
const
|
|
46358
|
-
if (!
|
|
46359
|
-
changedBy.set(definition.name, [...
|
|
46626
|
+
for (const definition of changedDefinitions(at.piece.hunk, symbolsByPath.get(at.file.path))) {
|
|
46627
|
+
const changes2 = changedBy.get(definition.name) ?? [];
|
|
46628
|
+
if (!changes2.some((change) => change.definition === definition)) {
|
|
46629
|
+
changedBy.set(definition.name, [...changes2, { at, definition }]);
|
|
46360
46630
|
}
|
|
46361
46631
|
}
|
|
46362
46632
|
}
|
|
@@ -46369,8 +46639,14 @@ var buildCallGraphHints = (files, symbolsByPath) => {
|
|
|
46369
46639
|
])
|
|
46370
46640
|
);
|
|
46371
46641
|
const visible = (from, kind, name2, to) => from.path === to.path || canLink(from, to) && (!resolvesImports(from.language ?? "") || sharesPackage(from.language ?? "", from.path, to.path) || (reaches.get(from.path) ?? []).some((reach) => reachesBy(reach, kind, name2, to.path)));
|
|
46642
|
+
const routes2 = hunks.flatMap(
|
|
46643
|
+
(at) => at.file.language === null ? [] : at.piece.hunk.lines.flatMap(
|
|
46644
|
+
(line) => line.kind === "add" ? routesOn(line.text).map((route) => ({ ...route, at })) : []
|
|
46645
|
+
)
|
|
46646
|
+
);
|
|
46372
46647
|
return hunks.flatMap((from) => {
|
|
46373
|
-
const
|
|
46648
|
+
const requests = requestHints(from, routes2);
|
|
46649
|
+
const lines = new Set(newLines(from.piece.hunk, ["add", "context"]));
|
|
46374
46650
|
const firstUse = { call: /* @__PURE__ */ new Map(), type: /* @__PURE__ */ new Map() };
|
|
46375
46651
|
const own2 = symbolsByPath.get(from.file.path);
|
|
46376
46652
|
for (const { name: name2, line, kind } of own2?.references ?? []) {
|
|
@@ -46383,7 +46659,7 @@ var buildCallGraphHints = (files, symbolsByPath) => {
|
|
|
46383
46659
|
);
|
|
46384
46660
|
const byUse = firstUse[kind === "type" ? "type" : "call"];
|
|
46385
46661
|
for (const { at: to } of local.length > 0 ? local : reached) {
|
|
46386
|
-
if (to.
|
|
46662
|
+
if (to.piece.id === from.piece.id) continue;
|
|
46387
46663
|
const uses = byUse.get(to) ?? /* @__PURE__ */ new Map();
|
|
46388
46664
|
const first = uses.get(name2);
|
|
46389
46665
|
if (first === void 0 || line < first) uses.set(name2, line);
|
|
@@ -46400,34 +46676,63 @@ var buildCallGraphHints = (files, symbolsByPath) => {
|
|
|
46400
46676
|
).sort(
|
|
46401
46677
|
(a, b) => Number(b.sameFile) - Number(a.sameFile) || compare(a.symbol, b.symbol) || a.to.order - b.to.order
|
|
46402
46678
|
).slice(0, MAX_HINTS_PER_HUNK).map(({ to, symbol: symbol2, line }) => ({
|
|
46403
|
-
|
|
46404
|
-
|
|
46679
|
+
fromPartId: from.piece.id,
|
|
46680
|
+
toPartId: to.piece.id,
|
|
46405
46681
|
symbol: symbol2,
|
|
46406
46682
|
line,
|
|
46407
46683
|
use
|
|
46408
46684
|
}));
|
|
46409
|
-
return [...hints("call"), ...hints("type")];
|
|
46410
|
-
});
|
|
46685
|
+
return [...hints("call"), ...hints("type"), ...requests];
|
|
46686
|
+
});
|
|
46687
|
+
};
|
|
46688
|
+
var requestHints = (from, routes2) => {
|
|
46689
|
+
if (from.file.language === null) return [];
|
|
46690
|
+
const first = /* @__PURE__ */ new Map();
|
|
46691
|
+
for (const line of from.piece.hunk.lines) {
|
|
46692
|
+
if (line.kind === "del" || line.newLine === null) continue;
|
|
46693
|
+
for (const request2 of requestsOn(line.text, from.file.path)) {
|
|
46694
|
+
for (const route of routesFor(request2, routes2)) {
|
|
46695
|
+
const to = route.at;
|
|
46696
|
+
if (to.piece.id === from.piece.id || isTestFile(to.file.path) && !isTestFile(from.file.path))
|
|
46697
|
+
continue;
|
|
46698
|
+
const symbol2 = `${route.method} ${route.path}`;
|
|
46699
|
+
const key = `${to.piece.id} ${symbol2}`;
|
|
46700
|
+
if (!first.has(key)) {
|
|
46701
|
+
first.set(key, {
|
|
46702
|
+
fromPartId: from.piece.id,
|
|
46703
|
+
toPartId: to.piece.id,
|
|
46704
|
+
symbol: symbol2,
|
|
46705
|
+
line: line.newLine,
|
|
46706
|
+
use: "request"
|
|
46707
|
+
});
|
|
46708
|
+
}
|
|
46709
|
+
}
|
|
46710
|
+
}
|
|
46711
|
+
}
|
|
46712
|
+
return [...first.values()].slice(0, MAX_HINTS_PER_HUNK);
|
|
46713
|
+
};
|
|
46714
|
+
var changedDefinitionNames = (files, symbolsByPath, parts2 = []) => {
|
|
46715
|
+
const byHunk = partsByHunk(parts2);
|
|
46716
|
+
return new Map(
|
|
46717
|
+
files.flatMap(
|
|
46718
|
+
(file2) => piecesOf(file2, byHunk).map(({ id, hunk }) => [
|
|
46719
|
+
id,
|
|
46720
|
+
[...changedDefinitions(hunk, symbolsByPath.get(file2.path))].map(
|
|
46721
|
+
(definition) => definition.name
|
|
46722
|
+
)
|
|
46723
|
+
])
|
|
46724
|
+
)
|
|
46725
|
+
);
|
|
46411
46726
|
};
|
|
46412
|
-
var changedDefinitionNames = (files, symbolsByPath) => new Map(
|
|
46413
|
-
files.flatMap(
|
|
46414
|
-
(file2) => file2.hunks.map((hunk) => [
|
|
46415
|
-
hunk.id,
|
|
46416
|
-
[...changedDefinitions(hunk, symbolsByPath.get(file2.path))].map(
|
|
46417
|
-
(definition) => definition.name
|
|
46418
|
-
)
|
|
46419
|
-
])
|
|
46420
|
-
)
|
|
46421
|
-
);
|
|
46422
46727
|
var changedDefinitions = (hunk, symbols) => {
|
|
46423
46728
|
const changed = /* @__PURE__ */ new Set();
|
|
46424
46729
|
for (const line of newLines(hunk, ["add"])) {
|
|
46425
46730
|
const around = (symbols?.definitions ?? []).filter(
|
|
46426
46731
|
(definition) => line >= definition.startLine && line <= definition.endLine
|
|
46427
46732
|
);
|
|
46428
|
-
const
|
|
46733
|
+
const span2 = Math.min(...around.map((definition) => definition.endLine - definition.startLine));
|
|
46429
46734
|
for (const definition of around) {
|
|
46430
|
-
if (definition.endLine - definition.startLine ===
|
|
46735
|
+
if (definition.endLine - definition.startLine === span2) changed.add(definition);
|
|
46431
46736
|
}
|
|
46432
46737
|
}
|
|
46433
46738
|
return changed;
|
|
@@ -46443,6 +46748,19 @@ var newLines = (hunk, kinds) => hunk.lines.flatMap(
|
|
|
46443
46748
|
);
|
|
46444
46749
|
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
46445
46750
|
|
|
46751
|
+
// src/domain/diff/file-links.ts
|
|
46752
|
+
var FileLink = external_exports.object({ from: external_exports.string().min(1), to: external_exports.string().min(1) }).readonly();
|
|
46753
|
+
var fileLinks = (files, symbolsByPath) => files.flatMap((from) => {
|
|
46754
|
+
const language = from.language;
|
|
46755
|
+
if (language === null) return [];
|
|
46756
|
+
const reaches = (symbolsByPath.get(from.path)?.imports ?? []).flatMap(
|
|
46757
|
+
(symbolImport) => importReach(from.path, language, symbolImport) ?? []
|
|
46758
|
+
);
|
|
46759
|
+
return files.filter(
|
|
46760
|
+
(to) => to.path !== from.path && to.language !== null && languageFamily(to.language) === languageFamily(language) && (isTestFile(from.path) || !isTestFile(to.path)) && reaches.some((reach) => reach.member(to.path))
|
|
46761
|
+
).map((to) => ({ from: from.path, to: to.path }));
|
|
46762
|
+
});
|
|
46763
|
+
|
|
46446
46764
|
// src/domain/diff/formatting.ts
|
|
46447
46765
|
var DETAIL = "formatting only: syntax tree unchanged";
|
|
46448
46766
|
var findFormattingProofs = (files, nodesByPath) => files.flatMap((file2) => {
|
|
@@ -46458,66 +46776,22 @@ var findFormattingProofs = (files, nodesByPath) => files.flatMap((file2) => {
|
|
|
46458
46776
|
var isEligible = (file2) => (file2.status === "modified" || file2.status === "renamed") && file2.hunks.length > 0 && !file2.binary && file2.oldMode === null && file2.newMode === null;
|
|
46459
46777
|
var sameNodes = (base, head) => base.length > 0 && base.length === head.length && base.every((node2, index) => node2.type === head[index]?.type && node2.text === head[index]?.text);
|
|
46460
46778
|
|
|
46461
|
-
// src/domain/
|
|
46462
|
-
var
|
|
46463
|
-
var
|
|
46464
|
-
var
|
|
46465
|
-
var
|
|
46466
|
-
|
|
46467
|
-
|
|
46468
|
-
|
|
46469
|
-
|
|
46470
|
-
|
|
46471
|
-
|
|
46472
|
-
}
|
|
46473
|
-
|
|
46474
|
-
|
|
46475
|
-
|
|
46476
|
-
|
|
46477
|
-
oldStart: LineCount,
|
|
46478
|
-
oldLines: LineCount,
|
|
46479
|
-
newStart: LineCount,
|
|
46480
|
-
newLines: LineCount,
|
|
46481
|
-
sectionHeading: external_exports.string().nullable(),
|
|
46482
|
-
lines: external_exports.array(DiffLine).readonly()
|
|
46483
|
-
}).readonly();
|
|
46484
|
-
var FileChange = external_exports.object({
|
|
46485
|
-
/** The new path, or the old one for a deleted file. */
|
|
46486
|
-
path: external_exports.string().min(1),
|
|
46487
|
-
oldPath: external_exports.string().min(1).nullable(),
|
|
46488
|
-
status: FileStatus,
|
|
46489
|
-
binary: external_exports.boolean(),
|
|
46490
|
-
/** Set only when the file mode changed. */
|
|
46491
|
-
oldMode: external_exports.string().nullable(),
|
|
46492
|
-
newMode: external_exports.string().nullable(),
|
|
46493
|
-
/** A tree-sitter language name, filled after parsing; null when unknown. */
|
|
46494
|
-
language: external_exports.string().nullable(),
|
|
46495
|
-
hunks: external_exports.array(Hunk).readonly(),
|
|
46496
|
-
additions: LineCount,
|
|
46497
|
-
deletions: LineCount
|
|
46498
|
-
}).readonly();
|
|
46499
|
-
var MechanicalProofKind = external_exports.enum([
|
|
46500
|
-
"generated",
|
|
46501
|
-
"whitespace",
|
|
46502
|
-
"rename",
|
|
46503
|
-
"move",
|
|
46504
|
-
"formatting"
|
|
46505
|
-
]);
|
|
46506
|
-
var MechanicalProof = external_exports.object({
|
|
46507
|
-
path: external_exports.string().min(1),
|
|
46508
|
-
/** null for a file-level proof of a file with no hunks, such as a pure rename. */
|
|
46509
|
-
hunkId: HunkId.nullable(),
|
|
46510
|
-
kind: MechanicalProofKind,
|
|
46511
|
-
/** What was checked, for the reviewer: "moved from src/a.ts:10–42, identical". */
|
|
46512
|
-
detail: external_exports.string().min(1)
|
|
46513
|
-
}).readonly();
|
|
46514
|
-
var CallGraphHint = external_exports.object({
|
|
46515
|
-
fromHunkId: HunkId,
|
|
46516
|
-
toHunkId: HunkId,
|
|
46517
|
-
symbol: external_exports.string().min(1),
|
|
46518
|
-
line: external_exports.number().int().positive(),
|
|
46519
|
-
use: external_exports.enum(["call", "type"])
|
|
46520
|
-
}).readonly();
|
|
46779
|
+
// src/domain/shared/hash.ts
|
|
46780
|
+
var OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
46781
|
+
var PRIME = 0x100000001b3n;
|
|
46782
|
+
var MASK = 0xffffffffffffffffn;
|
|
46783
|
+
var utf8 = new TextEncoder();
|
|
46784
|
+
var fnv1a64 = (input2) => {
|
|
46785
|
+
let hash2 = OFFSET_BASIS;
|
|
46786
|
+
for (const byte of utf8.encode(input2)) {
|
|
46787
|
+
hash2 = (hash2 ^ BigInt(byte)) * PRIME & MASK;
|
|
46788
|
+
}
|
|
46789
|
+
return hash2.toString(16).padStart(16, "0");
|
|
46790
|
+
};
|
|
46791
|
+
|
|
46792
|
+
// src/domain/shared/result.ts
|
|
46793
|
+
var ok = (value) => ({ ok: true, value });
|
|
46794
|
+
var err2 = (error62) => ({ ok: false, error: error62 });
|
|
46521
46795
|
|
|
46522
46796
|
// src/domain/diff/hunk-id.ts
|
|
46523
46797
|
var KIND_CHARS = { context: " ", add: "+", del: "-" };
|
|
@@ -46839,7 +47113,7 @@ var parseHunk = (lines, start3) => {
|
|
|
46839
47113
|
|
|
46840
47114
|
// src/domain/diff/path.ts
|
|
46841
47115
|
var basename3 = (path4) => path4.slice(path4.lastIndexOf("/") + 1);
|
|
46842
|
-
var
|
|
47116
|
+
var dirname2 = (path4) => path4.slice(0, Math.max(path4.lastIndexOf("/"), 0));
|
|
46843
47117
|
var extension = (path4) => {
|
|
46844
47118
|
const name2 = basename3(path4);
|
|
46845
47119
|
const dot = name2.lastIndexOf(".");
|
|
@@ -46952,10 +47226,10 @@ var patternToRegExp = (pattern) => {
|
|
|
46952
47226
|
regex += `(?!/)[${inner}]`;
|
|
46953
47227
|
i2 = end;
|
|
46954
47228
|
} else if (char === "\\" && i2 + 1 < body2.length) {
|
|
46955
|
-
regex +=
|
|
47229
|
+
regex += escapeRegExp2(body2.charAt(i2 + 1));
|
|
46956
47230
|
i2 += 1;
|
|
46957
47231
|
} else {
|
|
46958
|
-
regex +=
|
|
47232
|
+
regex += escapeRegExp2(char);
|
|
46959
47233
|
}
|
|
46960
47234
|
}
|
|
46961
47235
|
try {
|
|
@@ -46964,7 +47238,7 @@ var patternToRegExp = (pattern) => {
|
|
|
46964
47238
|
return null;
|
|
46965
47239
|
}
|
|
46966
47240
|
};
|
|
46967
|
-
var
|
|
47241
|
+
var escapeRegExp2 = (text) => text.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
|
|
46968
47242
|
|
|
46969
47243
|
// src/domain/diff/whitespace.ts
|
|
46970
47244
|
var TRAILING_WHITESPACE = /[ \t\r]+$/;
|
|
@@ -47166,13 +47440,98 @@ var findMechanicalProofs = (files, context2) => {
|
|
|
47166
47440
|
});
|
|
47167
47441
|
};
|
|
47168
47442
|
|
|
47443
|
+
// src/domain/diff/unchanged-callers.ts
|
|
47444
|
+
var MAX_UNCHANGED_USES = 50;
|
|
47445
|
+
var EXCERPT_LINES_AROUND = 2;
|
|
47446
|
+
var holds2 = (definition, line) => line >= definition.startLine && line <= definition.endLine;
|
|
47447
|
+
var innermost = (definitions, line) => definitions.filter((definition) => holds2(definition, line)).sort((a, b) => a.endLine - a.startLine - (b.endLine - b.startLine))[0];
|
|
47448
|
+
var changedDefinitions2 = (files, definitions, parts2 = []) => {
|
|
47449
|
+
const byHunk = partsByHunk(parts2);
|
|
47450
|
+
const changed = [];
|
|
47451
|
+
for (const file2 of files) {
|
|
47452
|
+
const spans = definitions.get(file2.path);
|
|
47453
|
+
if (file2.status === "added" || spans === void 0) continue;
|
|
47454
|
+
const before = new Set(spans.base.map((definition) => definition.name));
|
|
47455
|
+
for (const piece of piecesOf(file2, byHunk)) {
|
|
47456
|
+
for (const line of piece.hunk.lines) {
|
|
47457
|
+
if (line.kind === "context" || line.text.trim() === "") continue;
|
|
47458
|
+
const definition = line.kind === "add" ? line.newLine === null ? void 0 : innermost(spans.head, line.newLine) : line.oldLine === null ? void 0 : innermost(spans.base, line.oldLine);
|
|
47459
|
+
if (definition !== void 0 && before.has(definition.name) && !changed.some((known) => known.path === file2.path && known.name === definition.name)) {
|
|
47460
|
+
changed.push({ partId: piece.id, path: file2.path, name: definition.name });
|
|
47461
|
+
}
|
|
47462
|
+
}
|
|
47463
|
+
}
|
|
47464
|
+
}
|
|
47465
|
+
return changed;
|
|
47466
|
+
};
|
|
47467
|
+
var canCall = (from, to) => to.language !== null && languageFamily(from.language) === languageFamily(to.language) && (isTestFile(from.path) || !isTestFile(to.path));
|
|
47468
|
+
var findUnchangedCallers = (files, changed, unchanged, generated) => {
|
|
47469
|
+
const changedPaths = new Set(files.map((file2) => file2.path));
|
|
47470
|
+
const fileOf = new Map(files.map((file2) => [file2.path, file2]));
|
|
47471
|
+
const byName2 = /* @__PURE__ */ new Map();
|
|
47472
|
+
for (const definition of changed) {
|
|
47473
|
+
const file2 = fileOf.get(definition.path);
|
|
47474
|
+
if (file2 === void 0) continue;
|
|
47475
|
+
byName2.set(definition.name, [...byName2.get(definition.name) ?? [], { definition, file: file2 }]);
|
|
47476
|
+
}
|
|
47477
|
+
const usesOf = /* @__PURE__ */ new Map();
|
|
47478
|
+
for (const caller of unchanged) {
|
|
47479
|
+
if (changedPaths.has(caller.path) || !resolvesImports(caller.language)) continue;
|
|
47480
|
+
const reaches = caller.symbols.imports.flatMap(
|
|
47481
|
+
(symbolImport) => importReach(caller.path, caller.language, symbolImport) ?? []
|
|
47482
|
+
);
|
|
47483
|
+
const own2 = new Set(caller.symbols.definitions.map((definition) => definition.name));
|
|
47484
|
+
const lines = caller.content.split(/\r?\n/);
|
|
47485
|
+
for (const { name: name2, line, kind } of caller.symbols.references) {
|
|
47486
|
+
if (kind !== "member" && own2.has(name2)) continue;
|
|
47487
|
+
for (const { definition, file: file2 } of byName2.get(name2) ?? []) {
|
|
47488
|
+
const visible = canCall(caller, file2) && (sharesPackage(caller.language, caller.path, file2.path) || reaches.some(
|
|
47489
|
+
(reach) => kind === "member" ? reach.member(file2.path) : (reach.names === null || reach.names.includes(name2)) && reach.name(file2.path)
|
|
47490
|
+
));
|
|
47491
|
+
if (!visible || kind === "type" && generated.has(file2.path)) continue;
|
|
47492
|
+
const uses = usesOf.get(definition) ?? /* @__PURE__ */ new Map();
|
|
47493
|
+
const key = `${caller.path}:${line}`;
|
|
47494
|
+
const use = kind === "type" ? "type" : "call";
|
|
47495
|
+
if (uses.get(key)?.use !== "call") {
|
|
47496
|
+
uses.set(key, { path: caller.path, line, use, excerpt: excerpt(lines, line) });
|
|
47497
|
+
}
|
|
47498
|
+
usesOf.set(definition, uses);
|
|
47499
|
+
}
|
|
47500
|
+
}
|
|
47501
|
+
}
|
|
47502
|
+
return changed.flatMap((definition) => {
|
|
47503
|
+
const uses = [...usesOf.get(definition)?.values() ?? []].sort(
|
|
47504
|
+
(a, b) => Number(isTestFile(a.path)) - Number(isTestFile(b.path)) || (a.path < b.path ? -1 : a.path > b.path ? 1 : a.line - b.line)
|
|
47505
|
+
);
|
|
47506
|
+
return uses.length === 0 ? [] : [
|
|
47507
|
+
{
|
|
47508
|
+
partId: definition.partId,
|
|
47509
|
+
symbol: definition.name,
|
|
47510
|
+
uses: uses.slice(0, MAX_UNCHANGED_USES),
|
|
47511
|
+
more: Math.max(0, uses.length - MAX_UNCHANGED_USES)
|
|
47512
|
+
}
|
|
47513
|
+
];
|
|
47514
|
+
});
|
|
47515
|
+
};
|
|
47516
|
+
var excerpt = (lines, line) => {
|
|
47517
|
+
const start3 = Math.max(1, line - EXCERPT_LINES_AROUND);
|
|
47518
|
+
const end = Math.min(lines.length, line + EXCERPT_LINES_AROUND);
|
|
47519
|
+
return { start: start3, lines: lines.slice(start3 - 1, end) };
|
|
47520
|
+
};
|
|
47521
|
+
var mentionsAny = (content, names) => {
|
|
47522
|
+
for (const word of content.matchAll(/[A-Za-z_$][\w$]*/g)) {
|
|
47523
|
+
if (names.has(word[0])) return true;
|
|
47524
|
+
}
|
|
47525
|
+
return false;
|
|
47526
|
+
};
|
|
47527
|
+
|
|
47169
47528
|
// src/domain/diff/warnings.ts
|
|
47170
47529
|
var lockfileWarnings = (files) => {
|
|
47171
47530
|
const changed = files.flatMap((file2) => file2.oldPath ? [file2.path, file2.oldPath] : [file2.path]);
|
|
47172
47531
|
return files.flatMap((file2) => {
|
|
47173
47532
|
const manifests = LOCKFILE_MANIFESTS.get(basename3(file2.path));
|
|
47174
47533
|
if (manifests === void 0) return [];
|
|
47175
|
-
const dir =
|
|
47534
|
+
const dir = dirname2(file2.path);
|
|
47176
47535
|
const inScope = changed.filter((path4) => dir === "" || path4.startsWith(`${dir}/`));
|
|
47177
47536
|
const hasManifest = inScope.some(
|
|
47178
47537
|
(path4) => manifests.some(
|
|
@@ -47325,15 +47684,29 @@ var TourStep = external_exports.object({
|
|
|
47325
47684
|
id: TourStepId,
|
|
47326
47685
|
title: external_exports.string().min(1),
|
|
47327
47686
|
explanation: external_exports.string(),
|
|
47328
|
-
|
|
47687
|
+
/** The parts the step reads, in order: a hunk that isn't split is one part. */
|
|
47688
|
+
partIds: external_exports.array(PartId).readonly(),
|
|
47329
47689
|
/** flow: an entry point and the code it runs; supporting: changes no flow runs, by kind. */
|
|
47330
47690
|
kind: external_exports.enum(["flow", "supporting"]),
|
|
47331
|
-
/**
|
|
47332
|
-
via: external_exports.array(
|
|
47691
|
+
/** Parts of earlier steps this step passes through, in reading order. */
|
|
47692
|
+
via: external_exports.array(PartId).readonly(),
|
|
47693
|
+
/** The parts a flow starts at: its routes, page or command. Empty for the others. */
|
|
47694
|
+
entries: external_exports.array(PartId).readonly(),
|
|
47695
|
+
/**
|
|
47696
|
+
* The code's own title, when the model wrote `title`: a flow's entry label, or what a
|
|
47697
|
+
* supporting step holds. Null when `title` is the code's.
|
|
47698
|
+
*/
|
|
47699
|
+
codeTitle: external_exports.string().nullable(),
|
|
47700
|
+
/** Supporting steps the model merged into this one: their code title and the model's reason. */
|
|
47701
|
+
merged: external_exports.array(external_exports.object({ title: external_exports.string(), reason: external_exports.string() }).readonly()).readonly()
|
|
47333
47702
|
}).readonly();
|
|
47334
47703
|
var Tour = external_exports.object({
|
|
47335
47704
|
steps: external_exports.array(TourStep).readonly(),
|
|
47336
|
-
/**
|
|
47705
|
+
/**
|
|
47706
|
+
* Both are the code's steps from the call graph. model: titled by the tour pass, which may
|
|
47707
|
+
* have merged supporting steps; code: the code's titles, without the model or when the pass
|
|
47708
|
+
* failed.
|
|
47709
|
+
*/
|
|
47337
47710
|
builtBy: external_exports.enum(["model", "code"])
|
|
47338
47711
|
}).readonly();
|
|
47339
47712
|
|
|
@@ -47364,6 +47737,7 @@ var AnalysisError = external_exports.object({
|
|
|
47364
47737
|
}).readonly();
|
|
47365
47738
|
var AnalysisStatus = external_exports.enum(["running", "complete", "failed"]);
|
|
47366
47739
|
var FilesFetched = external_exports.object({ done: external_exports.number().int().nonnegative(), total: external_exports.number().int().nonnegative() }).readonly();
|
|
47740
|
+
var CheckoutStatus = external_exports.enum(["read", "none", "missing-commit"]);
|
|
47367
47741
|
var Analysis = external_exports.object({
|
|
47368
47742
|
id: AnalysisId,
|
|
47369
47743
|
key: AnalysisKey,
|
|
@@ -47377,7 +47751,16 @@ var Analysis = external_exports.object({
|
|
|
47377
47751
|
/** Ticket keys found in the PR that Jira didn't return. */
|
|
47378
47752
|
missingTicketKeys: external_exports.array(external_exports.string()).readonly(),
|
|
47379
47753
|
proofs: external_exports.array(MechanicalProof).readonly(),
|
|
47754
|
+
/** The parts of split hunks, in diff order. A hunk with none here is one part. */
|
|
47755
|
+
parts: external_exports.array(HunkPart).readonly(),
|
|
47380
47756
|
callGraph: external_exports.array(CallGraphHint).readonly(),
|
|
47757
|
+
/** Changed files an import in another changed file reaches. */
|
|
47758
|
+
fileLinks: external_exports.array(FileLink).readonly(),
|
|
47759
|
+
/** Paths whose first lines say a tool wrote them. Grouped and faded, never hidden. */
|
|
47760
|
+
generated: external_exports.array(external_exports.string()).readonly(),
|
|
47761
|
+
checkout: CheckoutStatus,
|
|
47762
|
+
/** Read from the checkout: uses outside the PR of the definitions it changes. */
|
|
47763
|
+
unchangedCallers: external_exports.array(UnchangedCallers).readonly(),
|
|
47381
47764
|
intent: Intent.nullable(),
|
|
47382
47765
|
risk: external_exports.array(RiskAssessment).readonly(),
|
|
47383
47766
|
decisions: external_exports.array(Decision).readonly(),
|
|
@@ -47395,54 +47778,12 @@ var analysisId = (key) => {
|
|
|
47395
47778
|
};
|
|
47396
47779
|
|
|
47397
47780
|
// src/domain/review/entry-points.ts
|
|
47398
|
-
var METHODS = "get|post|put|patch|delete|head|options|all";
|
|
47399
|
-
var RECEIVER = String.raw`(?:app|router|server|mux|r|e|g|fastify|\w*(?:Router|router|App))`;
|
|
47400
|
-
var PATH = String.raw`["'\`](\/[^"'\`]*)["'\`]`;
|
|
47401
|
-
var ROUTE_PATTERNS = [
|
|
47402
|
-
// FastAPI and the like: @router.put("/p").
|
|
47403
|
-
(line) => [...line.matchAll(new RegExp(String.raw`@[\w.]+\.(${METHODS})\(\s*${PATH}`, "gi"))].map(
|
|
47404
|
-
([, method = "", path4 = ""]) => ({ method: method.toUpperCase(), path: path4 })
|
|
47405
|
-
),
|
|
47406
|
-
// Flask: @app.route("/p", methods=["GET", "POST"]).
|
|
47407
|
-
(line) => {
|
|
47408
|
-
const match2 = new RegExp(String.raw`@[\w.]+\.route\(\s*${PATH}(.*)`).exec(line);
|
|
47409
|
-
if (match2 === null) return [];
|
|
47410
|
-
const [, path4 = "", rest = ""] = match2;
|
|
47411
|
-
const methods = /methods\s*=\s*[[(]([^\])]*)/.exec(rest)?.[1];
|
|
47412
|
-
const listed2 = [...(methods ?? "").matchAll(/["'](\w+)["']/g)].map(
|
|
47413
|
-
([, m = ""]) => m.toUpperCase()
|
|
47414
|
-
);
|
|
47415
|
-
return (listed2.length > 0 ? listed2 : ["GET"]).map((method) => ({ method, path: path4 }));
|
|
47416
|
-
},
|
|
47417
|
-
// Express, Fastify, Gin, Echo, Chi: app.get("/p", …), r.GET("/p", …).
|
|
47418
|
-
(line) => [
|
|
47419
|
-
...line.matchAll(
|
|
47420
|
-
new RegExp(String.raw`(?<![\w@.])${RECEIVER}\.(${METHODS})\(\s*${PATH}`, "gi")
|
|
47421
|
-
)
|
|
47422
|
-
].map(([, method = "", path4 = ""]) => ({ method: method.toUpperCase(), path: path4 })),
|
|
47423
|
-
// Spring: @GetMapping("/p"), @RequestMapping(value = "/p").
|
|
47424
|
-
(line) => {
|
|
47425
|
-
const match2 = new RegExp(
|
|
47426
|
-
String.raw`@(Get|Post|Put|Patch|Delete|Request)Mapping\(\s*(?:(?:value|path)\s*=\s*)?${PATH}`
|
|
47427
|
-
).exec(line);
|
|
47428
|
-
if (match2 === null) return [];
|
|
47429
|
-
const [, verb = "", path4 = ""] = match2;
|
|
47430
|
-
return [{ method: verb === "Request" ? "ALL" : verb.toUpperCase(), path: path4 }];
|
|
47431
|
-
},
|
|
47432
|
-
// Go's net/http: mux.HandleFunc("/p", …) and, since Go 1.22, HandleFunc("GET /p", …).
|
|
47433
|
-
(line) => {
|
|
47434
|
-
const match2 = /\bHandle(?:Func)?\(\s*"(?:([A-Z]+) )?(\/[^"]*)"/.exec(line);
|
|
47435
|
-
if (match2 === null) return [];
|
|
47436
|
-
const [, method = "ALL", path4 = ""] = match2;
|
|
47437
|
-
return [{ method, path: path4 }];
|
|
47438
|
-
}
|
|
47439
|
-
];
|
|
47440
47781
|
var PAGE_DIRECTORIES = /* @__PURE__ */ new Set(["routes", "pages", "app", "screens", "views"]);
|
|
47441
47782
|
var isPageFile = (path4) => /\.(tsx|jsx)$/.test(path4) && path4.split("/").slice(0, -1).some((directory) => PAGE_DIRECTORIES.has(directory));
|
|
47442
47783
|
var basename4 = (path4) => path4.slice(path4.lastIndexOf("/") + 1);
|
|
47443
47784
|
var entryOf = (file2, hunk, definitions) => {
|
|
47444
47785
|
const added = hunk.lines.flatMap((line) => line.kind === "add" ? [line.text] : []);
|
|
47445
|
-
const routes2 = added.flatMap(
|
|
47786
|
+
const routes2 = added.flatMap(routesOn);
|
|
47446
47787
|
if (routes2.length > 0) return { kind: "route", routes: unique(routes2) };
|
|
47447
47788
|
const components = definitions.filter((name2) => /^[A-Z]/.test(name2));
|
|
47448
47789
|
if (isPageFile(file2.path) && components.length > 0) return { kind: "page", names: components };
|
|
@@ -47493,7 +47834,7 @@ var entryLabel = (entries) => {
|
|
|
47493
47834
|
// src/domain/review/code-tour.ts
|
|
47494
47835
|
var MAX_LISTED = 3;
|
|
47495
47836
|
var basename5 = (path4) => path4.slice(path4.lastIndexOf("/") + 1);
|
|
47496
|
-
var
|
|
47837
|
+
var dirname3 = (path4) => path4.slice(0, Math.max(path4.lastIndexOf("/"), 0));
|
|
47497
47838
|
var stem2 = (name2) => {
|
|
47498
47839
|
const dot = name2.indexOf(".");
|
|
47499
47840
|
return dot <= 0 ? name2 : name2.slice(0, dot);
|
|
@@ -47514,7 +47855,7 @@ var subjectNames = (path4) => {
|
|
|
47514
47855
|
];
|
|
47515
47856
|
return [...new Set(names)].filter((one) => one !== "" && (marked || one !== base));
|
|
47516
47857
|
};
|
|
47517
|
-
var area = (path4) =>
|
|
47858
|
+
var area = (path4) => dirname3(path4).split("/").slice(0, 3).join("/");
|
|
47518
47859
|
var listed = (items) => {
|
|
47519
47860
|
const shown = items.slice(0, MAX_LISTED);
|
|
47520
47861
|
const rest = items.length - shown.length;
|
|
@@ -47525,29 +47866,39 @@ var KIND_RANK = { route: 0, page: 1, command: 2, root: 3 };
|
|
|
47525
47866
|
var codeTour = (input2) => {
|
|
47526
47867
|
const { files, required: required2, callGraph, risk, definitions } = input2;
|
|
47527
47868
|
const generated = input2.generated ?? /* @__PURE__ */ new Set();
|
|
47869
|
+
const byHunk = partsByHunk(input2.parts ?? []);
|
|
47528
47870
|
const located = files.flatMap(
|
|
47529
|
-
(file2) => file2.
|
|
47871
|
+
(file2) => piecesOf(file2, byHunk).filter(({ hunk }) => required2.has(hunk.id)).map(({ id, hunk }) => ({ file: file2, id, hunk }))
|
|
47530
47872
|
);
|
|
47531
|
-
const ids2 = located.map(({
|
|
47873
|
+
const ids2 = located.map(({ id }) => id);
|
|
47532
47874
|
const order2 = new Map(ids2.map((id, at) => [id, at]));
|
|
47533
|
-
const fileOf = new Map(located.map(({ file: file2,
|
|
47875
|
+
const fileOf = new Map(located.map(({ file: file2, id }) => [id, file2]));
|
|
47534
47876
|
const pathOf = (id) => fileOf.get(id)?.path ?? "";
|
|
47535
47877
|
const isTest = (id) => isTestFile(pathOf(id));
|
|
47536
47878
|
const isCode = (id) => !isTest(id) && !isDoc(pathOf(id));
|
|
47537
47879
|
const isSchemaLike = (id) => generated.has(pathOf(id)) || isSchema(pathOf(id));
|
|
47538
|
-
const
|
|
47880
|
+
const contractHunks = new Set(
|
|
47539
47881
|
risk.flatMap((assessment) => assessment.riskClass === "contract" ? [assessment.hunkId] : [])
|
|
47540
47882
|
);
|
|
47883
|
+
const contract = new Set(ids2.filter((id) => contractHunks.has(hunkIdOf(id))));
|
|
47541
47884
|
const edges = () => new Map(ids2.map((id) => [id, []]));
|
|
47542
47885
|
const [callees, callers, typeUses, usedAsType] = [edges(), edges(), edges(), edges()];
|
|
47543
|
-
|
|
47886
|
+
const requests = /* @__PURE__ */ new Map();
|
|
47887
|
+
for (const { fromPartId: from, toPartId: to, use, symbol: symbol2 } of [...callGraph].sort(
|
|
47544
47888
|
(a, b) => a.line - b.line
|
|
47545
47889
|
)) {
|
|
47546
|
-
if (from === to || !
|
|
47890
|
+
if (from === to || !order2.has(from) || !order2.has(to)) continue;
|
|
47891
|
+
if (use === "request") {
|
|
47892
|
+
const routes2 = requests.get(from) ?? /* @__PURE__ */ new Map();
|
|
47893
|
+
routes2.set(to, [...routes2.get(to) ?? [], symbol2]);
|
|
47894
|
+
requests.set(from, routes2);
|
|
47895
|
+
continue;
|
|
47896
|
+
}
|
|
47547
47897
|
const [out2, back] = use === "call" ? [callees, callers] : [typeUses, usedAsType];
|
|
47548
47898
|
if (!out2.get(from)?.includes(to)) out2.get(from)?.push(to);
|
|
47549
47899
|
if (!back.get(to)?.includes(from)) back.get(to)?.push(from);
|
|
47550
47900
|
}
|
|
47901
|
+
const requestsOf = (id) => [...requests.get(id) ?? []];
|
|
47551
47902
|
const codeCallees = (id) => (callees.get(id) ?? []).filter(isCode);
|
|
47552
47903
|
const codeCallers = (id) => (callers.get(id) ?? []).filter(isCode);
|
|
47553
47904
|
const reach = (starts2) => {
|
|
@@ -47561,10 +47912,10 @@ var codeTour = (input2) => {
|
|
|
47561
47912
|
return seen;
|
|
47562
47913
|
};
|
|
47563
47914
|
const entryOfHunk = /* @__PURE__ */ new Map();
|
|
47564
|
-
for (const { file: file2, hunk } of located) {
|
|
47565
|
-
if (!isCode(
|
|
47566
|
-
const entry = entryOf(file2, hunk, definitions.get(
|
|
47567
|
-
if (entry !== null) entryOfHunk.set(
|
|
47915
|
+
for (const { file: file2, id, hunk } of located) {
|
|
47916
|
+
if (!isCode(id)) continue;
|
|
47917
|
+
const entry = entryOf(file2, hunk, definitions.get(id) ?? []);
|
|
47918
|
+
if (entry !== null) entryOfHunk.set(id, entry);
|
|
47568
47919
|
}
|
|
47569
47920
|
const entryGroups = /* @__PURE__ */ new Map();
|
|
47570
47921
|
for (const [id, entry] of entryOfHunk) {
|
|
@@ -47572,13 +47923,46 @@ var codeTour = (input2) => {
|
|
|
47572
47923
|
const key = entry.kind === "route" || names === "" ? id : `${pathOf(id)}#${names}`;
|
|
47573
47924
|
entryGroups.set(key, [...entryGroups.get(key) ?? [], id]);
|
|
47574
47925
|
}
|
|
47575
|
-
const
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
|
|
47926
|
+
const textOf2 = new Map(located.map(({ id, hunk }) => [id, hunk.lines]));
|
|
47927
|
+
const onRouteLine = /* @__PURE__ */ new Set();
|
|
47928
|
+
for (const { fromPartId: from, toPartId: to, line, symbol: symbol2 } of callGraph) {
|
|
47929
|
+
const text = textOf2.get(from)?.find((one) => one.kind !== "del" && one.newLine === line)?.text;
|
|
47930
|
+
if (text !== void 0 && routeReceivers(text).includes(symbol2))
|
|
47931
|
+
onRouteLine.add(`${from}>${to}`);
|
|
47932
|
+
}
|
|
47933
|
+
const wiring = new Set(
|
|
47934
|
+
ids2.filter((id) => isCode(id) && !entryOfHunk.has(id) && linked(id).length > 0)
|
|
47935
|
+
);
|
|
47936
|
+
function linked(id) {
|
|
47937
|
+
return [...codeCallers(id), ...codeCallees(id)];
|
|
47938
|
+
}
|
|
47939
|
+
for (let dropped = true; dropped; ) {
|
|
47940
|
+
dropped = false;
|
|
47941
|
+
for (const id of wiring) {
|
|
47942
|
+
const fits2 = codeCallers(id).every(
|
|
47943
|
+
(caller) => wiring.has(caller) || onRouteLine.has(`${caller}>${id}`)
|
|
47944
|
+
) && codeCallees(id).every((callee) => wiring.has(callee) || entryOfHunk.has(callee));
|
|
47945
|
+
if (!fits2) {
|
|
47946
|
+
wiring.delete(id);
|
|
47947
|
+
dropped = true;
|
|
47948
|
+
}
|
|
47580
47949
|
}
|
|
47581
47950
|
}
|
|
47951
|
+
const registers = (id) => {
|
|
47952
|
+
const seen = /* @__PURE__ */ new Set([id]);
|
|
47953
|
+
const found = [];
|
|
47954
|
+
const visit2 = (at) => {
|
|
47955
|
+
for (const other of linked(at)) {
|
|
47956
|
+
if (seen.has(other)) continue;
|
|
47957
|
+
seen.add(other);
|
|
47958
|
+
if (entryOfHunk.has(other)) found.push(other);
|
|
47959
|
+
else if (wiring.has(other)) visit2(other);
|
|
47960
|
+
}
|
|
47961
|
+
};
|
|
47962
|
+
visit2(id);
|
|
47963
|
+
return found;
|
|
47964
|
+
};
|
|
47965
|
+
for (const id of wiring) if (registers(id).length === 0) wiring.delete(id);
|
|
47582
47966
|
const roots = ids2.filter(
|
|
47583
47967
|
(id) => isCode(id) && !entryOfHunk.has(id) && !wiring.has(id) && codeCallers(id).length === 0 && codeCallees(id).length > 0
|
|
47584
47968
|
);
|
|
@@ -47594,13 +47978,17 @@ var codeTour = (input2) => {
|
|
|
47594
47978
|
starts.sort(
|
|
47595
47979
|
(a, b) => Number(reachesContract(b)) - Number(reachesContract(a)) || KIND_RANK[a.kind] - KIND_RANK[b.kind] || firstAt(a) - firstAt(b)
|
|
47596
47980
|
);
|
|
47981
|
+
const ordered = afterRequestedRoutes(
|
|
47982
|
+
starts,
|
|
47983
|
+
(start3) => reach(start3.starts).flatMap((id) => requestsOf(id).map(([route]) => route))
|
|
47984
|
+
);
|
|
47597
47985
|
const owner = /* @__PURE__ */ new Map();
|
|
47598
47986
|
const flows = [];
|
|
47599
47987
|
const own2 = (flow, id) => {
|
|
47600
47988
|
flow.hunks.push(id);
|
|
47601
47989
|
owner.set(id, flow);
|
|
47602
47990
|
};
|
|
47603
|
-
for (const start3 of
|
|
47991
|
+
for (const start3 of ordered) {
|
|
47604
47992
|
const reached = reach(start3.starts);
|
|
47605
47993
|
const read = reached.filter((id) => owner.has(id));
|
|
47606
47994
|
const host = start3.kind === "root" && read.length * 2 >= reached.length - 1 ? mostCommon(read.map((id) => owner.get(id))) : void 0;
|
|
@@ -47615,12 +48003,56 @@ var codeTour = (input2) => {
|
|
|
47615
48003
|
else own2(flow, id);
|
|
47616
48004
|
}
|
|
47617
48005
|
}
|
|
47618
|
-
|
|
47619
|
-
|
|
48006
|
+
const flowAt = new Map(flows.map((flow, at) => [flow, at]));
|
|
48007
|
+
const placed = [...wiring].sort(
|
|
48008
|
+
(a, b) => Number(codeCallers(a).some((one) => wiring.has(one))) - Number(codeCallers(b).some((one) => wiring.has(one))) || (order2.get(a) ?? 0) - (order2.get(b) ?? 0)
|
|
48009
|
+
);
|
|
48010
|
+
const firstFlow = (id) => registers(id).flatMap((entry) => owner.get(entry) ?? []).sort((a, b) => (flowAt.get(a) ?? 0) - (flowAt.get(b) ?? 0))[0];
|
|
48011
|
+
for (const id of placed.reverse()) {
|
|
48012
|
+
const flow = firstFlow(id);
|
|
47620
48013
|
if (flow === void 0) continue;
|
|
48014
|
+
const before = owner.get(id);
|
|
48015
|
+
if (before !== void 0) before.hunks.splice(before.hunks.indexOf(id), 1);
|
|
47621
48016
|
flow.hunks.unshift(id);
|
|
47622
48017
|
owner.set(id, flow);
|
|
47623
48018
|
}
|
|
48019
|
+
const consumers = /* @__PURE__ */ new Map();
|
|
48020
|
+
for (const flow of flows) {
|
|
48021
|
+
for (const id of reach(flow.starts)) {
|
|
48022
|
+
if (entryOfHunk.has(id) || wiring.has(id)) continue;
|
|
48023
|
+
consumers.set(id, [...consumers.get(id) ?? [], flow]);
|
|
48024
|
+
}
|
|
48025
|
+
}
|
|
48026
|
+
const shared = new Set([...consumers].flatMap(([id, users]) => users.length > 1 ? [id] : []));
|
|
48027
|
+
const usedBy = /* @__PURE__ */ new Map();
|
|
48028
|
+
while (shared.size > 0) {
|
|
48029
|
+
const first = ids2.find((id) => shared.has(id));
|
|
48030
|
+
if (first === void 0) break;
|
|
48031
|
+
const component = /* @__PURE__ */ new Set();
|
|
48032
|
+
const collect2 = (id) => {
|
|
48033
|
+
if (!shared.delete(id)) return;
|
|
48034
|
+
component.add(id);
|
|
48035
|
+
for (const other of linked(id)) collect2(other);
|
|
48036
|
+
};
|
|
48037
|
+
collect2(first);
|
|
48038
|
+
const roots2 = [...component].filter(
|
|
48039
|
+
(id) => !codeCallers(id).some((caller) => component.has(caller))
|
|
48040
|
+
);
|
|
48041
|
+
const orderedParts = reach([...roots2, ...component]).filter((id) => component.has(id));
|
|
48042
|
+
const section = { starts: roots2, entries: [], kind: "root", hunks: [], via: [] };
|
|
48043
|
+
const users = [];
|
|
48044
|
+
usedBy.set(section, users);
|
|
48045
|
+
for (const id of orderedParts) {
|
|
48046
|
+
const previous = owner.get(id);
|
|
48047
|
+
if (previous !== void 0) previous.hunks.splice(previous.hunks.indexOf(id), 1);
|
|
48048
|
+
own2(section, id);
|
|
48049
|
+
for (const consumer of consumers.get(id) ?? []) {
|
|
48050
|
+
if (!consumer.via.includes(id)) consumer.via.push(id);
|
|
48051
|
+
if (!users.includes(consumer)) users.push(consumer);
|
|
48052
|
+
}
|
|
48053
|
+
}
|
|
48054
|
+
}
|
|
48055
|
+
flows.unshift(...usedBy.keys());
|
|
47624
48056
|
const flowWithMostOf = (path4, kind) => mostCommon([...owner].flatMap(([id, flow]) => pathOf(id) === path4 && kind(id) ? [flow] : []));
|
|
47625
48057
|
const flowOfSubject = (names) => mostCommon(
|
|
47626
48058
|
[...owner].flatMap(
|
|
@@ -47634,15 +48066,17 @@ var codeTour = (input2) => {
|
|
|
47634
48066
|
return mostCommon((usedAsType.get(id) ?? []).map((user) => owner.get(user))) ?? flowWithMostOf(path4, isCode);
|
|
47635
48067
|
}
|
|
47636
48068
|
if (isTest(id)) {
|
|
47637
|
-
const
|
|
48069
|
+
const requested = mostCommon(requestsOf(id).map(([route]) => owner.get(route)));
|
|
48070
|
+
if (requested !== void 0) return requested;
|
|
48071
|
+
const linked2 = [
|
|
47638
48072
|
...callees.get(id) ?? [],
|
|
47639
48073
|
...typeUses.get(id) ?? [],
|
|
47640
48074
|
...[...callers.get(id) ?? [], ...usedAsType.get(id) ?? []].filter(isTest)
|
|
47641
48075
|
];
|
|
47642
|
-
return mostCommon(
|
|
48076
|
+
return mostCommon(linked2.map((to) => owner.get(to))) ?? flowWithMostOf(path4, isTest) ?? flowOfSubject(subjectNames(path4));
|
|
47643
48077
|
}
|
|
47644
48078
|
const here = flows.filter(
|
|
47645
|
-
(flow) => flow.hunks.some((other) => isCode(other) &&
|
|
48079
|
+
(flow) => flow.hunks.some((other) => isCode(other) && dirname3(pathOf(other)) === dirname3(path4))
|
|
47646
48080
|
);
|
|
47647
48081
|
return here.length === 1 ? here[0] : void 0;
|
|
47648
48082
|
};
|
|
@@ -47666,19 +48100,45 @@ var codeTour = (input2) => {
|
|
|
47666
48100
|
}
|
|
47667
48101
|
flow.hunks.splice(0, flow.hunks.length, ...code2, ...flow.hunks.filter(isTest).sort(byOrder));
|
|
47668
48102
|
}
|
|
48103
|
+
const sendsOf = (flow, at) => {
|
|
48104
|
+
const sent = [];
|
|
48105
|
+
for (const [route, symbols] of flow.hunks.flatMap(requestsOf)) {
|
|
48106
|
+
const routeAt = flows.findIndex((other) => other.hunks.includes(route));
|
|
48107
|
+
if (routeAt < 0 || routeAt >= at) continue;
|
|
48108
|
+
if (!flow.via.includes(route)) flow.via.push(route);
|
|
48109
|
+
for (const symbol2 of symbols) {
|
|
48110
|
+
if (!sent.some((one) => one.symbol === symbol2))
|
|
48111
|
+
sent.push({ route, symbol: symbol2, step: routeAt + 1 });
|
|
48112
|
+
}
|
|
48113
|
+
}
|
|
48114
|
+
return sent;
|
|
48115
|
+
};
|
|
47669
48116
|
const stepOfFlow = new Map(flows.map((flow, at) => [flow, at + 1]));
|
|
47670
48117
|
const stepOf = (id) => {
|
|
47671
48118
|
const flow = owner.get(id);
|
|
47672
48119
|
return flow === void 0 ? void 0 : stepOfFlow.get(flow);
|
|
47673
48120
|
};
|
|
47674
48121
|
const steps = [
|
|
47675
|
-
...flows.map((flow) =>
|
|
47676
|
-
|
|
47677
|
-
|
|
47678
|
-
|
|
47679
|
-
|
|
47680
|
-
|
|
47681
|
-
|
|
48122
|
+
...flows.map((flow, at) => {
|
|
48123
|
+
const sent = sendsOf(flow, at);
|
|
48124
|
+
return {
|
|
48125
|
+
title: `${usedBy.has(flow) ? "Shared: " : ""}${flowTitle(flow, pathOf, definitions)}`,
|
|
48126
|
+
explanation: flowExplanation(
|
|
48127
|
+
flow,
|
|
48128
|
+
pathOf,
|
|
48129
|
+
isTest,
|
|
48130
|
+
stepOf,
|
|
48131
|
+
sent,
|
|
48132
|
+
(usedBy.get(flow) ?? []).map((user) => stepOfFlow.get(user) ?? 0).sort((a, b) => a - b)
|
|
48133
|
+
),
|
|
48134
|
+
partIds: flow.hunks,
|
|
48135
|
+
kind: "flow",
|
|
48136
|
+
via: flow.via,
|
|
48137
|
+
entries: flow.kind === "root" ? [] : flow.starts,
|
|
48138
|
+
codeTitle: null,
|
|
48139
|
+
merged: []
|
|
48140
|
+
};
|
|
48141
|
+
}),
|
|
47682
48142
|
...supportingSteps(
|
|
47683
48143
|
ids2.filter((id) => !owner.has(id)),
|
|
47684
48144
|
pathOf,
|
|
@@ -47692,6 +48152,21 @@ var codeTour = (input2) => {
|
|
|
47692
48152
|
builtBy: "code"
|
|
47693
48153
|
};
|
|
47694
48154
|
};
|
|
48155
|
+
var afterRequestedRoutes = (starts, requestedBy) => {
|
|
48156
|
+
const left = starts.map((start3) => {
|
|
48157
|
+
const routes2 = requestedBy(start3);
|
|
48158
|
+
const after = starts.filter(
|
|
48159
|
+
(other) => other !== start3 && other.starts.some((id) => routes2.includes(id))
|
|
48160
|
+
);
|
|
48161
|
+
return { start: start3, after };
|
|
48162
|
+
});
|
|
48163
|
+
const placed = [];
|
|
48164
|
+
while (left.length > 0) {
|
|
48165
|
+
const ready = left.findIndex(({ after }) => after.every((one) => placed.includes(one)));
|
|
48166
|
+
for (const { start: start3 } of left.splice(Math.max(ready, 0), 1)) placed.push(start3);
|
|
48167
|
+
}
|
|
48168
|
+
return placed;
|
|
48169
|
+
};
|
|
47695
48170
|
var mostCommon = (values) => {
|
|
47696
48171
|
const counts = /* @__PURE__ */ new Map();
|
|
47697
48172
|
for (const value of values) {
|
|
@@ -47714,15 +48189,23 @@ var flowTitle = (flow, pathOf, definitions) => {
|
|
|
47714
48189
|
const names = start3 === void 0 ? [] : definitions.get(start3) ?? [];
|
|
47715
48190
|
return names.length === 0 ? path4 : `${listed(names)} in ${basename5(path4)}`;
|
|
47716
48191
|
};
|
|
47717
|
-
var flowExplanation = (flow, pathOf, isTest, stepOf) => {
|
|
48192
|
+
var flowExplanation = (flow, pathOf, isTest, stepOf, sends, users) => {
|
|
47718
48193
|
const names = (ids2) => [...new Set(ids2.map((id) => basename5(pathOf(id))))];
|
|
47719
48194
|
const tests = names(flow.hunks.filter(isTest));
|
|
47720
|
-
const
|
|
48195
|
+
const requested = new Set(sends.map((one) => one.route));
|
|
48196
|
+
const walkedVia = flow.via.filter((id) => !requested.has(id));
|
|
48197
|
+
const earlier = [...new Set(walkedVia.flatMap((id) => stepOf(id) ?? []))].sort((a, b) => a - b);
|
|
47721
48198
|
const parts2 = [
|
|
47722
48199
|
`Reads ${listed(names(flow.hunks.filter((id) => !isTest(id))))}`,
|
|
47723
48200
|
...tests.length > 0 ? [`tested in ${listed(tests)}`] : [],
|
|
48201
|
+
...users.length === 0 ? [] : [`used by ${users.length === 1 ? "step" : "steps"} ${listed(users.map(String))}`],
|
|
47724
48202
|
...earlier.length === 0 ? [] : [
|
|
47725
48203
|
`passes through ${earlier.length === 1 ? "step" : "steps"} ${listed(earlier.map(String))}`
|
|
48204
|
+
],
|
|
48205
|
+
...sends.length === 0 ? [] : [
|
|
48206
|
+
`sends ${listed(
|
|
48207
|
+
[...sends].sort((a, b) => a.step - b.step).map(({ symbol: symbol2, step }) => `${symbol2} (step ${step})`)
|
|
48208
|
+
)}`
|
|
47726
48209
|
]
|
|
47727
48210
|
];
|
|
47728
48211
|
return `${parts2.join("; ")}.`;
|
|
@@ -47740,15 +48223,18 @@ var supportingSteps = (left, pathOf, isSchemaLike, isTest, contract) => {
|
|
|
47740
48223
|
const rank = (title) => SUPPORTING_RANK[title] ?? 3;
|
|
47741
48224
|
return [...groups].sort(
|
|
47742
48225
|
([titleA, a], [titleB, b]) => contractCount(b) - contractCount(a) || rank(titleA) - rank(titleB) || compare2(titleA, titleB)
|
|
47743
|
-
).map(([title,
|
|
47744
|
-
const paths = [...new Set(
|
|
48226
|
+
).map(([title, partIds]) => {
|
|
48227
|
+
const paths = [...new Set(partIds.map(pathOf))];
|
|
47745
48228
|
const count3 = paths.length === 1 ? "1 file" : `${paths.length} files`;
|
|
47746
48229
|
return {
|
|
47747
48230
|
title,
|
|
47748
48231
|
explanation: `${count3}: ${listed(paths.map(basename5))}. No flow runs ${paths.length === 1 ? "it" : "them"}.`,
|
|
47749
|
-
|
|
48232
|
+
partIds,
|
|
47750
48233
|
kind: "supporting",
|
|
47751
|
-
via: []
|
|
48234
|
+
via: [],
|
|
48235
|
+
entries: [],
|
|
48236
|
+
codeTitle: null,
|
|
48237
|
+
merged: []
|
|
47752
48238
|
};
|
|
47753
48239
|
});
|
|
47754
48240
|
};
|
|
@@ -47798,6 +48284,60 @@ var ModelError = external_exports.object({
|
|
|
47798
48284
|
message: external_exports.string()
|
|
47799
48285
|
}).readonly();
|
|
47800
48286
|
|
|
48287
|
+
// src/domain/review/join-parts.ts
|
|
48288
|
+
var joinParts = (tour, candidates, callGraph, unchangedCallers = []) => {
|
|
48289
|
+
const stepOf = /* @__PURE__ */ new Map();
|
|
48290
|
+
tour.steps.forEach((step, at) => {
|
|
48291
|
+
for (const id of step.partIds) if (!stepOf.has(id)) stepOf.set(id, at);
|
|
48292
|
+
});
|
|
48293
|
+
const rename = /* @__PURE__ */ new Map();
|
|
48294
|
+
const parts2 = [];
|
|
48295
|
+
for (const [hunkId2, ofHunk] of partsByHunk(candidates)) {
|
|
48296
|
+
const groups = [];
|
|
48297
|
+
for (const part of ofHunk) {
|
|
48298
|
+
const group = groups.at(-1);
|
|
48299
|
+
if (group !== void 0 && stepOf.get(group.first.id) === stepOf.get(part.id)) {
|
|
48300
|
+
group.parts.push(part);
|
|
48301
|
+
group.last = part;
|
|
48302
|
+
} else groups.push({ first: part, last: part, parts: [part] });
|
|
48303
|
+
}
|
|
48304
|
+
if (groups.length === 1) {
|
|
48305
|
+
for (const part of ofHunk) rename.set(part.id, hunkId2);
|
|
48306
|
+
continue;
|
|
48307
|
+
}
|
|
48308
|
+
groups.forEach((group, at) => {
|
|
48309
|
+
const joined = {
|
|
48310
|
+
id: partId(hunkId2, at + 1),
|
|
48311
|
+
hunkId: hunkId2,
|
|
48312
|
+
start: group.first.start,
|
|
48313
|
+
end: group.last.end,
|
|
48314
|
+
definitions: [...new Set(group.parts.flatMap((part) => part.definitions))]
|
|
48315
|
+
};
|
|
48316
|
+
parts2.push(joined);
|
|
48317
|
+
for (const part of group.parts) rename.set(part.id, joined.id);
|
|
48318
|
+
});
|
|
48319
|
+
}
|
|
48320
|
+
const renamed = (id) => rename.get(id) ?? id;
|
|
48321
|
+
const each = (ids2) => [...new Set(ids2.map(renamed))];
|
|
48322
|
+
return {
|
|
48323
|
+
tour: {
|
|
48324
|
+
...tour,
|
|
48325
|
+
steps: tour.steps.map((step) => ({
|
|
48326
|
+
...step,
|
|
48327
|
+
partIds: each(step.partIds),
|
|
48328
|
+
via: each(step.via),
|
|
48329
|
+
entries: each(step.entries)
|
|
48330
|
+
}))
|
|
48331
|
+
},
|
|
48332
|
+
parts: parts2,
|
|
48333
|
+
callGraph: renameHints(callGraph, renamed),
|
|
48334
|
+
unchangedCallers: unchangedCallers.map((callers) => ({
|
|
48335
|
+
...callers,
|
|
48336
|
+
partId: renamed(callers.partId)
|
|
48337
|
+
}))
|
|
48338
|
+
};
|
|
48339
|
+
};
|
|
48340
|
+
|
|
47801
48341
|
// src/domain/review/publication.ts
|
|
47802
48342
|
var PublicationVerdict = external_exports.enum(["approve", "request_changes", "comment"]);
|
|
47803
48343
|
var CommentKey = external_exports.string().regex(
|
|
@@ -47881,7 +48421,7 @@ ${comment}`
|
|
|
47881
48421
|
const decisionLines = reviewed.map(({ decision, verdict: verdict2, comment }) => {
|
|
47882
48422
|
const label = { approved: "\u2705 ", rejected: "\u274C ", pending: "\u23F3 Not reviewed: " }[verdict2];
|
|
47883
48423
|
const showComment = comment !== "" && (verdict2 === "rejected" || !anchored.has(decision.id));
|
|
47884
|
-
return `- ${label}${decision.title}${showComment ? ` \u2014 ${
|
|
48424
|
+
return `- ${label}${decision.title}${showComment ? ` \u2014 ${oneLine(comment)}` : ""}`;
|
|
47885
48425
|
});
|
|
47886
48426
|
const summary = [
|
|
47887
48427
|
input2.summary.trim(),
|
|
@@ -47905,7 +48445,7 @@ var hunkAnchors = (analysis) => {
|
|
|
47905
48445
|
const hunks = analysis.files.flatMap((file2) => file2.hunks);
|
|
47906
48446
|
const order2 = [
|
|
47907
48447
|
.../* @__PURE__ */ new Set([
|
|
47908
|
-
...analysis.tour?.steps.flatMap((step) => step.
|
|
48448
|
+
...analysis.tour?.steps.flatMap((step) => step.partIds.map(hunkIdOf)) ?? [],
|
|
47909
48449
|
...hunks.map((hunk) => hunk.id)
|
|
47910
48450
|
])
|
|
47911
48451
|
];
|
|
@@ -47926,7 +48466,7 @@ var onCode = (comments) => {
|
|
|
47926
48466
|
const count3 = comments.filter((comment) => comment.key.startsWith("hunk:")).length;
|
|
47927
48467
|
return count3 === 0 ? "" : `${count3} ${count3 === 1 ? "comment" : "comments"} on the code.`;
|
|
47928
48468
|
};
|
|
47929
|
-
var
|
|
48469
|
+
var oneLine = (text) => text.replace(/\s*\n\s*/g, " ");
|
|
47930
48470
|
|
|
47931
48471
|
// src/domain/review/pull-request-url.ts
|
|
47932
48472
|
var HOSTS = {
|
|
@@ -48101,7 +48641,83 @@ var TEST_SKIPS = [
|
|
|
48101
48641
|
];
|
|
48102
48642
|
var textOf = (hunk, kind) => hunk.lines.flatMap((line) => line.kind === kind ? [line.text] : []);
|
|
48103
48643
|
var count = (lines, patterns) => lines.filter((line) => patterns.some((pattern) => pattern.test(line))).length;
|
|
48644
|
+
var CREDENTIAL_NOUNS = /* @__PURE__ */ new Set([
|
|
48645
|
+
"secret",
|
|
48646
|
+
"secrets",
|
|
48647
|
+
"token",
|
|
48648
|
+
"tokens",
|
|
48649
|
+
"credential",
|
|
48650
|
+
"credentials",
|
|
48651
|
+
"password",
|
|
48652
|
+
"passwords",
|
|
48653
|
+
"passphrase"
|
|
48654
|
+
]);
|
|
48655
|
+
var STORAGE_VERBS = /* @__PURE__ */ new Set([
|
|
48656
|
+
"save",
|
|
48657
|
+
"saved",
|
|
48658
|
+
"store",
|
|
48659
|
+
"stored",
|
|
48660
|
+
"persist",
|
|
48661
|
+
"set",
|
|
48662
|
+
"get",
|
|
48663
|
+
"load",
|
|
48664
|
+
"read",
|
|
48665
|
+
"write",
|
|
48666
|
+
"find",
|
|
48667
|
+
"delete",
|
|
48668
|
+
"remove",
|
|
48669
|
+
"forget",
|
|
48670
|
+
"clear",
|
|
48671
|
+
"clone",
|
|
48672
|
+
"rotate",
|
|
48673
|
+
"revoke",
|
|
48674
|
+
"refresh"
|
|
48675
|
+
]);
|
|
48676
|
+
var AUTHORIZATION_WORDS = /* @__PURE__ */ new Set([
|
|
48677
|
+
"authorize",
|
|
48678
|
+
"authorized",
|
|
48679
|
+
"authorization",
|
|
48680
|
+
"authenticate",
|
|
48681
|
+
"authentication",
|
|
48682
|
+
"permission",
|
|
48683
|
+
"permissions"
|
|
48684
|
+
]);
|
|
48685
|
+
var CHECK_VERBS = /* @__PURE__ */ new Set(["verify", "validate", "check"]);
|
|
48686
|
+
var CHANGING_METHODS = /* @__PURE__ */ new Set(["PUT", "POST", "PATCH", "DELETE", "ALL"]);
|
|
48687
|
+
var CREDENTIAL_SEGMENT = /^(?:tokens?|credentials?|passwords?|secrets?|api[-_]?keys?)$/i;
|
|
48688
|
+
var calledNames = (line) => [...line.matchAll(/([A-Za-z_$][\w$]*)\s*\(/g)].flatMap(
|
|
48689
|
+
([, name2]) => name2 === void 0 || /^(?:test(?:_|[A-Z])|set[A-Z])/.test(name2) ? [] : [name2]
|
|
48690
|
+
);
|
|
48691
|
+
var namesWhere = (fits2) => (line) => calledNames(line).filter((name2) => fits2(pathWords(name2)));
|
|
48692
|
+
var CREDENTIAL_RULES = [
|
|
48693
|
+
{
|
|
48694
|
+
found: namesWhere(
|
|
48695
|
+
(words) => CREDENTIAL_NOUNS.has(words.at(-1) ?? "") && words.slice(0, -1).some((word) => STORAGE_VERBS.has(word))
|
|
48696
|
+
),
|
|
48697
|
+
reason: "changes credential storage"
|
|
48698
|
+
},
|
|
48699
|
+
{
|
|
48700
|
+
found: namesWhere(
|
|
48701
|
+
(words) => words.some((word) => AUTHORIZATION_WORDS.has(word)) || CREDENTIAL_NOUNS.has(words.at(-1) ?? "") && words.some((word) => CHECK_VERBS.has(word))
|
|
48702
|
+
),
|
|
48703
|
+
reason: "changes authorization"
|
|
48704
|
+
},
|
|
48705
|
+
{
|
|
48706
|
+
found: (line) => routesOn(line).filter(
|
|
48707
|
+
({ method, path: path4 }) => CHANGING_METHODS.has(method) && path4.split("/").some((segment2) => CREDENTIAL_SEGMENT.test(segment2))
|
|
48708
|
+
).map(({ method, path: path4 }) => `${method} ${path4}`),
|
|
48709
|
+
reason: "changes a credential endpoint"
|
|
48710
|
+
}
|
|
48711
|
+
];
|
|
48104
48712
|
var HUNK_RULES = [
|
|
48713
|
+
(hunk) => {
|
|
48714
|
+
const changed = [...textOf(hunk, "add"), ...textOf(hunk, "del")];
|
|
48715
|
+
const reasons = CREDENTIAL_RULES.flatMap(({ found, reason }) => {
|
|
48716
|
+
const names = [...new Set(changed.flatMap(found))];
|
|
48717
|
+
return names.length === 0 ? [] : [`${reason} (${names.join(", ")})`];
|
|
48718
|
+
});
|
|
48719
|
+
return reasons.length === 0 ? null : reasons.join("; ");
|
|
48720
|
+
},
|
|
48105
48721
|
(hunk) => {
|
|
48106
48722
|
const added = textOf(hunk, "add");
|
|
48107
48723
|
const labels = DANGEROUS_CALLS.filter(
|
|
@@ -48161,39 +48777,368 @@ var extractTicketKeys = (texts) => {
|
|
|
48161
48777
|
return [...keys];
|
|
48162
48778
|
};
|
|
48163
48779
|
|
|
48780
|
+
// src/domain/review/tour-titles.ts
|
|
48781
|
+
var MAX_TITLE = 80;
|
|
48782
|
+
var MAX_EXPLANATION = 300;
|
|
48783
|
+
var TourStepTitle = external_exports.object({ stepId: external_exports.string(), title: external_exports.string(), explanation: external_exports.string() }).readonly();
|
|
48784
|
+
var TourMerge = external_exports.object({ stepId: external_exports.string(), intoStepId: external_exports.string(), reason: external_exports.string() }).readonly();
|
|
48785
|
+
var TourTitles = external_exports.object({
|
|
48786
|
+
steps: external_exports.array(TourStepTitle).readonly(),
|
|
48787
|
+
merges: external_exports.array(TourMerge).readonly()
|
|
48788
|
+
}).readonly();
|
|
48789
|
+
var applyTourTitles = (skeleton, titles) => {
|
|
48790
|
+
const written = new Map(titles.steps.map((step) => [step.stepId, step]));
|
|
48791
|
+
const stepById = new Map(skeleton.steps.map((step) => [step.id, step]));
|
|
48792
|
+
const merging = new Set(titles.merges.map((merge3) => merge3.stepId));
|
|
48793
|
+
const steps = skeleton.steps.filter((step) => !merging.has(step.id)).map((step, at) => {
|
|
48794
|
+
const joining = titles.merges.flatMap((merge3) => {
|
|
48795
|
+
const merged = stepById.get(merge3.stepId);
|
|
48796
|
+
return merge3.intoStepId === step.id && merged !== void 0 ? [{ step: merged, reason: merge3.reason.trim() }] : [];
|
|
48797
|
+
});
|
|
48798
|
+
const own2 = written.get(step.id);
|
|
48799
|
+
return {
|
|
48800
|
+
...step,
|
|
48801
|
+
id: TourStepId.parse(`s${at + 1}`),
|
|
48802
|
+
title: own2?.title.trim() ?? step.title,
|
|
48803
|
+
explanation: own2?.explanation.trim() ?? step.explanation,
|
|
48804
|
+
codeTitle: step.title,
|
|
48805
|
+
partIds: [...step.partIds, ...joining.flatMap(({ step: step2 }) => step2.partIds)],
|
|
48806
|
+
via: [.../* @__PURE__ */ new Set([...step.via, ...joining.flatMap(({ step: step2 }) => step2.via)])],
|
|
48807
|
+
merged: joining.map(({ step: step2, reason }) => ({ title: step2.title, reason }))
|
|
48808
|
+
};
|
|
48809
|
+
});
|
|
48810
|
+
return { steps, builtBy: "model" };
|
|
48811
|
+
};
|
|
48812
|
+
|
|
48164
48813
|
// src/domain/review/validation.ts
|
|
48165
48814
|
var CoverageProblem = external_exports.object({
|
|
48166
48815
|
kind: external_exports.enum(["missing", "duplicate", "unknown"]),
|
|
48167
|
-
|
|
48816
|
+
id: PartId
|
|
48168
48817
|
}).readonly();
|
|
48169
48818
|
var validateHunkReferences = (known, referenced) => [...new Set(referenced.filter((id) => !known.has(id)))];
|
|
48170
48819
|
var coverageProblems = (listed2, required2) => {
|
|
48171
48820
|
const problems = [];
|
|
48172
48821
|
const seen = /* @__PURE__ */ new Set();
|
|
48173
48822
|
const reported = /* @__PURE__ */ new Set();
|
|
48174
|
-
for (const
|
|
48175
|
-
if (!required2.has(
|
|
48176
|
-
if (!reported.has(
|
|
48177
|
-
reported.add(
|
|
48178
|
-
} else if (seen.has(
|
|
48179
|
-
if (!reported.has(
|
|
48180
|
-
reported.add(
|
|
48823
|
+
for (const id of listed2) {
|
|
48824
|
+
if (!required2.has(id)) {
|
|
48825
|
+
if (!reported.has(id)) problems.push({ kind: "unknown", id });
|
|
48826
|
+
reported.add(id);
|
|
48827
|
+
} else if (seen.has(id)) {
|
|
48828
|
+
if (!reported.has(id)) problems.push({ kind: "duplicate", id });
|
|
48829
|
+
reported.add(id);
|
|
48181
48830
|
}
|
|
48182
|
-
seen.add(
|
|
48831
|
+
seen.add(id);
|
|
48183
48832
|
}
|
|
48184
|
-
for (const
|
|
48185
|
-
if (!seen.has(
|
|
48833
|
+
for (const id of required2) {
|
|
48834
|
+
if (!seen.has(id)) problems.push({ kind: "missing", id });
|
|
48186
48835
|
}
|
|
48187
48836
|
return problems;
|
|
48188
48837
|
};
|
|
48189
|
-
var validateTour = (tour, requiredHunkIds) => coverageProblems(
|
|
48190
|
-
tour.steps.flatMap((step) => step.hunkIds),
|
|
48191
|
-
requiredHunkIds
|
|
48192
|
-
);
|
|
48193
48838
|
var validateRiskCoverage = (assessments, requiredHunkIds) => coverageProblems(
|
|
48194
48839
|
assessments.map((assessment) => assessment.hunkId),
|
|
48195
48840
|
requiredHunkIds
|
|
48196
48841
|
);
|
|
48842
|
+
var validateTourTitles = (titles, skeleton) => {
|
|
48843
|
+
const problems = [];
|
|
48844
|
+
const kindOf = new Map(
|
|
48845
|
+
skeleton.steps.map((step) => [step.id, step.kind])
|
|
48846
|
+
);
|
|
48847
|
+
const titled = /* @__PURE__ */ new Set();
|
|
48848
|
+
const reported = /* @__PURE__ */ new Set();
|
|
48849
|
+
for (const step of titles.steps) {
|
|
48850
|
+
const { stepId } = step;
|
|
48851
|
+
if (!kindOf.has(stepId) || titled.has(stepId)) {
|
|
48852
|
+
if (!reported.has(stepId)) {
|
|
48853
|
+
problems.push({ kind: kindOf.has(stepId) ? "duplicate" : "unknown", stepId });
|
|
48854
|
+
}
|
|
48855
|
+
reported.add(stepId);
|
|
48856
|
+
continue;
|
|
48857
|
+
}
|
|
48858
|
+
titled.add(stepId);
|
|
48859
|
+
for (const [field, max] of [
|
|
48860
|
+
["title", MAX_TITLE],
|
|
48861
|
+
["explanation", MAX_EXPLANATION]
|
|
48862
|
+
]) {
|
|
48863
|
+
const text = step[field].trim();
|
|
48864
|
+
if (text === "") problems.push({ kind: "blank", stepId, field });
|
|
48865
|
+
else if (text.length > max) problems.push({ kind: "too-long", stepId, field });
|
|
48866
|
+
}
|
|
48867
|
+
}
|
|
48868
|
+
for (const id of kindOf.keys()) {
|
|
48869
|
+
if (!titled.has(id) && !reported.has(id)) problems.push({ kind: "missing", stepId: id });
|
|
48870
|
+
}
|
|
48871
|
+
const merging = new Set(titles.merges.map((merge3) => merge3.stepId));
|
|
48872
|
+
const merged = /* @__PURE__ */ new Set();
|
|
48873
|
+
for (const { stepId, intoStepId, reason } of titles.merges) {
|
|
48874
|
+
const kind = kindOf.get(stepId);
|
|
48875
|
+
if (merged.has(stepId)) {
|
|
48876
|
+
problems.push({ kind: "merged-twice", stepId });
|
|
48877
|
+
continue;
|
|
48878
|
+
}
|
|
48879
|
+
merged.add(stepId);
|
|
48880
|
+
if (kind === void 0) problems.push({ kind: "merge-unknown", stepId });
|
|
48881
|
+
else if (kind === "flow") problems.push({ kind: "merge-of-flow", stepId });
|
|
48882
|
+
if (!kindOf.has(intoStepId)) problems.push({ kind: "merge-into-unknown", stepId, intoStepId });
|
|
48883
|
+
else if (merging.has(intoStepId)) {
|
|
48884
|
+
problems.push({ kind: "merge-into-merged", stepId, intoStepId });
|
|
48885
|
+
}
|
|
48886
|
+
if (reason.trim() === "") problems.push({ kind: "merge-no-reason", stepId });
|
|
48887
|
+
}
|
|
48888
|
+
return problems;
|
|
48889
|
+
};
|
|
48890
|
+
|
|
48891
|
+
// src/application/ports/analysis-model.ts
|
|
48892
|
+
var ModelRisk = external_exports.object({
|
|
48893
|
+
hunkId: HunkId,
|
|
48894
|
+
riskClass: external_exports.enum(["logic", "contract"]),
|
|
48895
|
+
reason: external_exports.string()
|
|
48896
|
+
}).readonly();
|
|
48897
|
+
var DecisionDraft = Decision.unwrap().omit({ id: true }).readonly();
|
|
48898
|
+
var TourDraft = TourTitles;
|
|
48899
|
+
|
|
48900
|
+
// src/application/ports/local-checkout.ts
|
|
48901
|
+
var MAX_CHECKOUT_FILE_BYTES = 1024 * 1024;
|
|
48902
|
+
|
|
48903
|
+
// src/adapters/git/remotes.ts
|
|
48904
|
+
var HOSTS2 = {
|
|
48905
|
+
"github.com": "github",
|
|
48906
|
+
"bitbucket.org": "bitbucket"
|
|
48907
|
+
};
|
|
48908
|
+
var repoOfRemote = (url2) => {
|
|
48909
|
+
const trimmed = url2.trim();
|
|
48910
|
+
const scp = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/)(.+)$/.exec(trimmed);
|
|
48911
|
+
const full = /^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/\s]+@)?([^:/\s]+)(?::\d+)?\/(.+)$/.exec(
|
|
48912
|
+
trimmed
|
|
48913
|
+
);
|
|
48914
|
+
const match2 = full ?? (/^[a-z+]+:\/\//.test(trimmed) ? null : scp);
|
|
48915
|
+
if (match2 === null) return null;
|
|
48916
|
+
const [, hostName2 = "", path4 = ""] = match2;
|
|
48917
|
+
const host = HOSTS2[hostName2.toLowerCase()];
|
|
48918
|
+
const segments2 = path4.replace(/\/+$/, "").replace(/\.git$/, "").split("/");
|
|
48919
|
+
const [owner, repo] = segments2;
|
|
48920
|
+
if (host === void 0 || segments2.length !== 2 || !owner || !repo) return null;
|
|
48921
|
+
return { host, owner: owner.toLowerCase(), repo: repo.toLowerCase() };
|
|
48922
|
+
};
|
|
48923
|
+
var sameRepo = (a, b) => a.host === b.host && a.owner.toLowerCase() === b.owner.toLowerCase() && a.repo.toLowerCase() === b.repo.toLowerCase();
|
|
48924
|
+
var reposOfRemotes = (output2) => {
|
|
48925
|
+
const repos = [];
|
|
48926
|
+
for (const line of output2.split("\n")) {
|
|
48927
|
+
const url2 = line.split(/\s+/)[1];
|
|
48928
|
+
const repo = url2 === void 0 ? null : repoOfRemote(url2);
|
|
48929
|
+
if (repo !== null && !repos.some((known) => sameRepo(known, repo))) repos.push(repo);
|
|
48930
|
+
}
|
|
48931
|
+
return repos;
|
|
48932
|
+
};
|
|
48933
|
+
|
|
48934
|
+
// src/adapters/git/run-git.ts
|
|
48935
|
+
import { spawn } from "node:child_process";
|
|
48936
|
+
var runGit = (dir, args2, input2) => new Promise((resolve5) => {
|
|
48937
|
+
const child = spawn("git", ["-C", dir, ...args2], {
|
|
48938
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
48939
|
+
// A checkout's own config can't page or prompt for credentials: nothing here reads a remote.
|
|
48940
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_PAGER: "cat", LC_ALL: "C" }
|
|
48941
|
+
});
|
|
48942
|
+
const stdout = [];
|
|
48943
|
+
const stderr = [];
|
|
48944
|
+
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
48945
|
+
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
48946
|
+
child.stdin.on("error", () => {
|
|
48947
|
+
});
|
|
48948
|
+
child.on(
|
|
48949
|
+
"error",
|
|
48950
|
+
() => resolve5({ code: null, stdout: Buffer.alloc(0), stderr: "git couldn't be started" })
|
|
48951
|
+
);
|
|
48952
|
+
child.on(
|
|
48953
|
+
"close",
|
|
48954
|
+
(code2) => resolve5({
|
|
48955
|
+
code: code2,
|
|
48956
|
+
stdout: Buffer.concat(stdout),
|
|
48957
|
+
stderr: Buffer.concat(stderr).toString("utf8").trim()
|
|
48958
|
+
})
|
|
48959
|
+
);
|
|
48960
|
+
child.stdin.end(input2 ?? "");
|
|
48961
|
+
});
|
|
48962
|
+
|
|
48963
|
+
// src/adapters/git/git-checkout.ts
|
|
48964
|
+
var SHA = /^[0-9a-f]{4,64}$/;
|
|
48965
|
+
var failed = (message) => ({ kind: "failed", message });
|
|
48966
|
+
var decoder = new TextDecoder("utf-8");
|
|
48967
|
+
var createGitCheckout = (options) => {
|
|
48968
|
+
const { dir } = options;
|
|
48969
|
+
const run3 = options.run ?? runGit;
|
|
48970
|
+
const hasCommit = async (sha) => SHA.test(sha) && (await run3(dir, ["cat-file", "-e", `${sha}^{commit}`])).code === 0;
|
|
48971
|
+
const atCommit = async (sha, read) => await hasCommit(sha) ? read() : err2({ kind: "missing-commit", message: `The checkout doesn't have commit ${sha}` });
|
|
48972
|
+
return {
|
|
48973
|
+
hasCommit,
|
|
48974
|
+
listFiles: (sha) => atCommit(sha, async () => {
|
|
48975
|
+
const listed2 = await run3(dir, ["ls-tree", "-r", "-z", "--name-only", sha]);
|
|
48976
|
+
if (listed2.code !== 0) return err2(failed(`git ls-tree failed: ${listed2.stderr}`));
|
|
48977
|
+
const paths = decoder.decode(listed2.stdout).split("\0").filter(Boolean);
|
|
48978
|
+
return ok(paths.sort());
|
|
48979
|
+
}),
|
|
48980
|
+
readFiles: (sha, paths) => atCommit(sha, async () => {
|
|
48981
|
+
const readable = paths.filter((path4) => !path4.includes("\n"));
|
|
48982
|
+
const names = readable.map((path4) => `${sha}:${path4}`);
|
|
48983
|
+
const checked = await run3(
|
|
48984
|
+
dir,
|
|
48985
|
+
["cat-file", "--batch-check=%(objecttype) %(objectsize)"],
|
|
48986
|
+
names.map((name2) => `${name2}
|
|
48987
|
+
`).join("")
|
|
48988
|
+
);
|
|
48989
|
+
if (checked.code !== 0) return err2(failed(`git cat-file failed: ${checked.stderr}`));
|
|
48990
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
48991
|
+
const lines = decoder.decode(checked.stdout).split("\n");
|
|
48992
|
+
readable.forEach((path4, at) => {
|
|
48993
|
+
const [type, size] = (lines[at] ?? "").split(" ");
|
|
48994
|
+
if (type === "blob" && size !== void 0) sizes.set(path4, Number(size));
|
|
48995
|
+
});
|
|
48996
|
+
const wanted = readable.filter(
|
|
48997
|
+
(path4) => (sizes.get(path4) ?? Infinity) <= MAX_CHECKOUT_FILE_BYTES
|
|
48998
|
+
);
|
|
48999
|
+
const contents = /* @__PURE__ */ new Map();
|
|
49000
|
+
if (wanted.length > 0) {
|
|
49001
|
+
const batch = await run3(
|
|
49002
|
+
dir,
|
|
49003
|
+
["cat-file", "--batch"],
|
|
49004
|
+
wanted.map((path4) => `${sha}:${path4}
|
|
49005
|
+
`).join("")
|
|
49006
|
+
);
|
|
49007
|
+
if (batch.code !== 0) return err2(failed(`git cat-file failed: ${batch.stderr}`));
|
|
49008
|
+
const parsed = parseBatch(batch.stdout, wanted.length);
|
|
49009
|
+
if (parsed === null) return err2(failed("git cat-file gave output it couldn't parse"));
|
|
49010
|
+
wanted.forEach((path4, at) => {
|
|
49011
|
+
const content = parsed[at];
|
|
49012
|
+
if (content !== void 0) contents.set(path4, decoder.decode(content));
|
|
49013
|
+
});
|
|
49014
|
+
}
|
|
49015
|
+
return ok(
|
|
49016
|
+
paths.map((path4) => {
|
|
49017
|
+
const content = contents.get(path4);
|
|
49018
|
+
if (content !== void 0) return { kind: "text", content };
|
|
49019
|
+
const size = sizes.get(path4);
|
|
49020
|
+
return size !== void 0 && size > MAX_CHECKOUT_FILE_BYTES ? { kind: "too-large" } : { kind: "unreadable" };
|
|
49021
|
+
})
|
|
49022
|
+
);
|
|
49023
|
+
})
|
|
49024
|
+
};
|
|
49025
|
+
};
|
|
49026
|
+
var parseBatch = (out2, count3) => {
|
|
49027
|
+
const objects = [];
|
|
49028
|
+
let at = 0;
|
|
49029
|
+
while (objects.length < count3) {
|
|
49030
|
+
const end = out2.indexOf(10, at);
|
|
49031
|
+
if (end === -1) return null;
|
|
49032
|
+
const header2 = out2.subarray(at, end).toString("utf8");
|
|
49033
|
+
at = end + 1;
|
|
49034
|
+
const found = /^[0-9a-f]+ \w+ (\d+)$/.exec(header2);
|
|
49035
|
+
if (found === null) {
|
|
49036
|
+
if (!header2.endsWith(" missing") && !header2.endsWith(" ambiguous")) return null;
|
|
49037
|
+
objects.push(void 0);
|
|
49038
|
+
continue;
|
|
49039
|
+
}
|
|
49040
|
+
const size = Number(found[1]);
|
|
49041
|
+
if (at + size > out2.length) return null;
|
|
49042
|
+
objects.push(out2.subarray(at, at + size));
|
|
49043
|
+
at += size + 1;
|
|
49044
|
+
}
|
|
49045
|
+
return objects;
|
|
49046
|
+
};
|
|
49047
|
+
var inspectCheckout = async (dir, run3 = runGit) => {
|
|
49048
|
+
const root = await run3(dir, ["rev-parse", "--show-toplevel"]);
|
|
49049
|
+
if (root.code !== 0) return null;
|
|
49050
|
+
const remotes = await run3(dir, ["remote", "-v"]);
|
|
49051
|
+
return {
|
|
49052
|
+
root: root.stdout.toString("utf8").trim(),
|
|
49053
|
+
repos: remotes.code === 0 ? reposOfRemotes(remotes.stdout.toString("utf8")) : []
|
|
49054
|
+
};
|
|
49055
|
+
};
|
|
49056
|
+
var createGitCheckouts = (options) => ({
|
|
49057
|
+
async find(repo) {
|
|
49058
|
+
const info2 = await inspectCheckout(options.dir, options.run);
|
|
49059
|
+
if (info2 === null) return null;
|
|
49060
|
+
return {
|
|
49061
|
+
checkout: createGitCheckout({ dir: info2.root, run: options.run }),
|
|
49062
|
+
namesRepo: info2.repos.some((known) => sameRepo(known, repo))
|
|
49063
|
+
};
|
|
49064
|
+
}
|
|
49065
|
+
});
|
|
49066
|
+
|
|
49067
|
+
// src/cli/args.ts
|
|
49068
|
+
import { parseArgs } from "node:util";
|
|
49069
|
+
var EXIT = { ok: 0, config: 1, usage: 2 };
|
|
49070
|
+
var USAGE = `Usage:
|
|
49071
|
+
megareviewer [--port <n>] [--no-open] [--ai] [--checkout <dir>]
|
|
49072
|
+
Start the review UI (any free port by default);
|
|
49073
|
+
--ai adds intent, decisions and a guided tour from Claude;
|
|
49074
|
+
callers outside the PR come from the git checkout in
|
|
49075
|
+
<dir>, or else the current directory, when it has the PR
|
|
49076
|
+
megareviewer doctor [--checkout <dir>] Check credentials and setup
|
|
49077
|
+
megareviewer --version
|
|
49078
|
+
megareviewer --help`;
|
|
49079
|
+
var MAX_PORT = 65535;
|
|
49080
|
+
var parseCliArgs = (argv) => {
|
|
49081
|
+
let parsed;
|
|
49082
|
+
try {
|
|
49083
|
+
parsed = parse3(argv);
|
|
49084
|
+
} catch (error62) {
|
|
49085
|
+
if (error62 instanceof TypeError) return err2(error62.message);
|
|
49086
|
+
throw error62;
|
|
49087
|
+
}
|
|
49088
|
+
const { values, positionals } = parsed;
|
|
49089
|
+
if (values.help === true) return ok({ kind: "help" });
|
|
49090
|
+
const [command, ...extra] = positionals;
|
|
49091
|
+
if (extra.length > 0) return err2(`Unexpected argument: ${extra.join(" ")}`);
|
|
49092
|
+
const serveFlags = values.port !== void 0 || values["no-open"] === true || values.ai === true;
|
|
49093
|
+
const checkout = values.checkout ?? null;
|
|
49094
|
+
if (checkout === "") return err2("--checkout needs a directory");
|
|
49095
|
+
if (values.version === true) {
|
|
49096
|
+
if (command !== void 0 || serveFlags || checkout !== null) {
|
|
49097
|
+
return err2("--version takes no other arguments");
|
|
49098
|
+
}
|
|
49099
|
+
return ok({ kind: "version" });
|
|
49100
|
+
}
|
|
49101
|
+
if (command === "doctor") {
|
|
49102
|
+
if (serveFlags) return err2("doctor takes no options but --checkout");
|
|
49103
|
+
return ok({ kind: "doctor", checkout });
|
|
49104
|
+
}
|
|
49105
|
+
if (command !== void 0) return err2(`Unknown command: ${command}`);
|
|
49106
|
+
let port = 0;
|
|
49107
|
+
if (values.port !== void 0) {
|
|
49108
|
+
if (!/^\d+$/.test(values.port) || Number(values.port) > MAX_PORT) {
|
|
49109
|
+
return err2(`--port must be a number from 0 to ${MAX_PORT}`);
|
|
49110
|
+
}
|
|
49111
|
+
port = Number(values.port);
|
|
49112
|
+
}
|
|
49113
|
+
return ok({
|
|
49114
|
+
kind: "serve",
|
|
49115
|
+
port,
|
|
49116
|
+
open: values["no-open"] !== true,
|
|
49117
|
+
ai: values.ai === true,
|
|
49118
|
+
checkout
|
|
49119
|
+
});
|
|
49120
|
+
};
|
|
49121
|
+
var parse3 = (argv) => parseArgs({
|
|
49122
|
+
args: [...argv],
|
|
49123
|
+
options: {
|
|
49124
|
+
port: { type: "string" },
|
|
49125
|
+
"no-open": { type: "boolean" },
|
|
49126
|
+
ai: { type: "boolean" },
|
|
49127
|
+
checkout: { type: "string" },
|
|
49128
|
+
version: { type: "boolean" },
|
|
49129
|
+
help: { type: "boolean", short: "h" }
|
|
49130
|
+
},
|
|
49131
|
+
allowPositionals: true,
|
|
49132
|
+
strict: true
|
|
49133
|
+
});
|
|
49134
|
+
|
|
49135
|
+
// src/cli/compose.ts
|
|
49136
|
+
init_sdk();
|
|
49137
|
+
init_credentials();
|
|
49138
|
+
import { randomBytes } from "node:crypto";
|
|
49139
|
+
import { mkdirSync } from "node:fs";
|
|
49140
|
+
import { join as join5 } from "node:path";
|
|
49141
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
48197
49142
|
|
|
48198
49143
|
// src/adapters/bitbucket/schemas.ts
|
|
48199
49144
|
var BitbucketTimestamp = external_exports.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
@@ -48762,16 +49707,6 @@ var tooLarge = (inputTokens, limit2) => modelError(
|
|
|
48762
49707
|
`The pull request is ~${inputTokens} tokens, over the limit of ${limit2}.`
|
|
48763
49708
|
);
|
|
48764
49709
|
|
|
48765
|
-
// src/application/ports/analysis-model.ts
|
|
48766
|
-
var ModelRisk = external_exports.object({
|
|
48767
|
-
hunkId: HunkId,
|
|
48768
|
-
riskClass: external_exports.enum(["logic", "contract"]),
|
|
48769
|
-
reason: external_exports.string()
|
|
48770
|
-
}).readonly();
|
|
48771
|
-
var DecisionDraft = Decision.unwrap().omit({ id: true }).readonly();
|
|
48772
|
-
var TourStepDraft = TourStep.unwrap().omit({ id: true, kind: true, via: true }).readonly();
|
|
48773
|
-
var TourDraft = external_exports.object({ steps: external_exports.array(TourStepDraft).readonly() }).readonly();
|
|
48774
|
-
|
|
48775
49710
|
// src/adapters/claude/output-schema.ts
|
|
48776
49711
|
var PassAnswer = external_exports.object({
|
|
48777
49712
|
answer: external_exports.discriminatedUnion("pass", [
|
|
@@ -48870,7 +49805,9 @@ var TAGS = [
|
|
|
48870
49805
|
"earlier_results",
|
|
48871
49806
|
"intent",
|
|
48872
49807
|
"risk",
|
|
48873
|
-
"decisions"
|
|
49808
|
+
"decisions",
|
|
49809
|
+
"tour_skeleton",
|
|
49810
|
+
"step"
|
|
48874
49811
|
];
|
|
48875
49812
|
var TAG_START = new RegExp(`<(/?)(?=(?:${TAGS.join("|")})\\b)`, "g");
|
|
48876
49813
|
var escapeText = (text) => text.replace(TAG_START, "<$1");
|
|
@@ -48943,7 +49880,7 @@ ${escapeText(commit.message)}
|
|
|
48943
49880
|
...block(
|
|
48944
49881
|
"call_graph",
|
|
48945
49882
|
callGraph.map(
|
|
48946
|
-
({
|
|
49883
|
+
({ fromPartId, toPartId, symbol: symbol2 }) => `${fromPartId} \u2192 ${toPartId} (${escapeText(symbol2)})`
|
|
48947
49884
|
)
|
|
48948
49885
|
),
|
|
48949
49886
|
"</pull_request_data>"
|
|
@@ -48983,13 +49920,39 @@ For each decision:
|
|
|
48983
49920
|
Order them by importance, most important first. At most 15. A small or routine change may have none.`,
|
|
48984
49921
|
tour: `Task: tour.
|
|
48985
49922
|
|
|
48986
|
-
|
|
48987
|
-
|
|
48988
|
-
Start where execution or the reader enters the change (an endpoint, a CLI command, a UI action, a public function), then follow the call graph to what it uses. Group hunks by concept, not by file: a step can span files, and a file can appear in several steps.
|
|
49923
|
+
The tour is already built: <tour_skeleton> lists its steps in reading order. A "flow" step starts at an entry point (an HTTP route, a page, a command), listed under entries, and reads the changed code that entry runs, callers before callees. "passes through" names code an earlier step already read. A "supporting" step holds changes no flow runs: an API schema, docs, tests, or other changes by area. Each step has the code's own title, which names the code ("PUT /api/items/{id}", a function name, "Tests"), and the code's explanation. A hunk ID with lines is the part of that hunk on those lines; a hunk ID alone is the whole hunk.
|
|
48989
49924
|
|
|
48990
|
-
|
|
49925
|
+
The steps and the code in them are fixed. Write, for every step, by its id:
|
|
49926
|
+
- title: what the step does, as behavior a user or caller would notice, in plain language, at most 80 characters ("Save a host's token", not "PUT /api/account-connections/{domain}/token" or a function name). Don't repeat the code's title: the reviewer sees it under yours.
|
|
49927
|
+
- explanation: one or two sentences, at most 300 characters, on what this step changes and what the reviewer should check in it.
|
|
48991
49928
|
|
|
48992
|
-
|
|
49929
|
+
merges: you may merge a supporting step into the step it belongs with, such as docs into the flow they document, or tests into the flow they test. Each merge names the supporting step (stepId), the step it joins (intoStepId) and a one-sentence reason. Merge only supporting steps, never a flow, each at most once, and never into a step you merge elsewhere. A supporting step that belongs with several steps or none stays. Most tours need no merges.`
|
|
49930
|
+
};
|
|
49931
|
+
var partLabel = (id, parts2, hunks) => {
|
|
49932
|
+
const part = parts2.get(id);
|
|
49933
|
+
if (part === void 0) return id;
|
|
49934
|
+
const numbers = (hunks.get(part.hunkId)?.lines ?? []).slice(part.start, part.end).flatMap((line) => line.newLine ?? line.oldLine ?? []);
|
|
49935
|
+
const first = numbers[0];
|
|
49936
|
+
const last = numbers.at(-1);
|
|
49937
|
+
return first === void 0 || last === void 0 ? part.hunkId : `${part.hunkId} lines ${first}\u2013${last}`;
|
|
49938
|
+
};
|
|
49939
|
+
var renderSkeleton = (skeleton, input2) => {
|
|
49940
|
+
const parts2 = new Map(skeleton.parts.map((part) => [part.id, part]));
|
|
49941
|
+
const hunks = new Map(input2.files.flatMap((file2) => file2.hunks.map((hunk) => [hunk.id, hunk])));
|
|
49942
|
+
const labels = (partIds) => partIds.map((id) => partLabel(id, parts2, hunks)).join(", ");
|
|
49943
|
+
return [
|
|
49944
|
+
"<tour_skeleton>",
|
|
49945
|
+
...skeleton.tour.steps.flatMap((step) => [
|
|
49946
|
+
`<step id="${step.id}" kind="${step.kind}">`,
|
|
49947
|
+
`code's title: ${escapeText(step.title)}`,
|
|
49948
|
+
`code's explanation: ${escapeText(step.explanation)}`,
|
|
49949
|
+
...step.entries.length === 0 ? [] : [`entries: ${labels(step.entries)}`],
|
|
49950
|
+
`reads: ${labels(step.partIds)}`,
|
|
49951
|
+
...step.via.length === 0 ? [] : [`passes through: ${labels(step.via)}`],
|
|
49952
|
+
"</step>"
|
|
49953
|
+
]),
|
|
49954
|
+
"</tour_skeleton>"
|
|
49955
|
+
];
|
|
48993
49956
|
};
|
|
48994
49957
|
var ids = (hunkIds) => hunkIds.length === 0 ? "" : ` (${hunkIds.join(", ")})`;
|
|
48995
49958
|
var renderIntent = (intent) => [
|
|
@@ -49023,7 +49986,8 @@ var passMessage = (pass, earlier, feedback) => {
|
|
|
49023
49986
|
...earlier.risk === void 0 ? [] : renderRisk(earlier.risk),
|
|
49024
49987
|
...earlier.decisions === void 0 ? [] : renderDecisions(earlier.decisions),
|
|
49025
49988
|
"</earlier_results>",
|
|
49026
|
-
""
|
|
49989
|
+
"",
|
|
49990
|
+
...earlier.skeleton === void 0 ? [] : [...earlier.skeleton, ""]
|
|
49027
49991
|
];
|
|
49028
49992
|
const problems = feedback === void 0 || feedback.length === 0 ? [] : ["", `Your previous answer had these problems: ${feedback.join("; ")}. Fix them.`];
|
|
49029
49993
|
return [...results, PASS_INSTRUCTIONS[pass], ...problems].join("\n");
|
|
@@ -49094,7 +50058,7 @@ var countTokensRequest = (request2) => {
|
|
|
49094
50058
|
};
|
|
49095
50059
|
|
|
49096
50060
|
// src/adapters/claude/version.ts
|
|
49097
|
-
var PROMPT_VERSION =
|
|
50061
|
+
var PROMPT_VERSION = 3;
|
|
49098
50062
|
var VERSION3 = `${MODEL}/p${PROMPT_VERSION}`;
|
|
49099
50063
|
|
|
49100
50064
|
// src/adapters/claude/claude-analysis-model.ts
|
|
@@ -49207,10 +50171,10 @@ var createClaudeAnalysisModel = (options) => {
|
|
|
49207
50171
|
passOptions,
|
|
49208
50172
|
(answer) => answer.pass === "decisions" ? answer.decisions : null
|
|
49209
50173
|
),
|
|
49210
|
-
tour: (input2, intent, risk, decisions, passOptions) => runPass(
|
|
50174
|
+
tour: (input2, intent, risk, decisions, skeleton, passOptions) => runPass(
|
|
49211
50175
|
"tour",
|
|
49212
50176
|
input2,
|
|
49213
|
-
{ intent, risk, decisions },
|
|
50177
|
+
{ intent, risk, decisions, skeleton: renderSkeleton(skeleton, input2) },
|
|
49214
50178
|
passOptions,
|
|
49215
50179
|
(answer) => answer.pass === "tour" ? answer.tour : null
|
|
49216
50180
|
)
|
|
@@ -53905,13 +54869,13 @@ var getPattern = (label, next) => {
|
|
|
53905
54869
|
}
|
|
53906
54870
|
return null;
|
|
53907
54871
|
};
|
|
53908
|
-
var tryDecode = (str,
|
|
54872
|
+
var tryDecode = (str, decoder2) => {
|
|
53909
54873
|
try {
|
|
53910
|
-
return
|
|
54874
|
+
return decoder2(str);
|
|
53911
54875
|
} catch {
|
|
53912
54876
|
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match2) => {
|
|
53913
54877
|
try {
|
|
53914
|
-
return
|
|
54878
|
+
return decoder2(match2);
|
|
53915
54879
|
} catch {
|
|
53916
54880
|
return match2;
|
|
53917
54881
|
}
|
|
@@ -53945,10 +54909,10 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
53945
54909
|
};
|
|
53946
54910
|
var checkOptionalParameter = (path4) => {
|
|
53947
54911
|
if (path4.charCodeAt(path4.length - 1) !== 63 || !path4.includes(":")) return null;
|
|
53948
|
-
const
|
|
54912
|
+
const segments2 = path4.split("/");
|
|
53949
54913
|
const results = [];
|
|
53950
54914
|
let basePath = "";
|
|
53951
|
-
|
|
54915
|
+
segments2.forEach((segment2) => {
|
|
53952
54916
|
if (segment2 !== "" && !/\:/.test(segment2)) basePath += "/" + segment2;
|
|
53953
54917
|
else if (/\:/.test(segment2)) {
|
|
53954
54918
|
if (segment2.charCodeAt(segment2.length - 1) === 63) {
|
|
@@ -55919,8 +56883,8 @@ var registerEventsRoute = (app, deps) => {
|
|
|
55919
56883
|
while (!stream3.aborted) {
|
|
55920
56884
|
const event = queue.shift();
|
|
55921
56885
|
if (event === void 0) {
|
|
55922
|
-
await new Promise((
|
|
55923
|
-
wake =
|
|
56886
|
+
await new Promise((resolve5) => {
|
|
56887
|
+
wake = resolve5;
|
|
55924
56888
|
});
|
|
55925
56889
|
wake = null;
|
|
55926
56890
|
} else if (event.type === "done") {
|
|
@@ -56066,11 +57030,11 @@ var baseMimes = {
|
|
|
56066
57030
|
var INDEX = "index.html";
|
|
56067
57031
|
var safeSegments = (pathname) => {
|
|
56068
57032
|
try {
|
|
56069
|
-
const
|
|
56070
|
-
const unsafe =
|
|
57033
|
+
const segments2 = pathname.split("/").filter((segment2) => segment2 !== "").map(decodeURIComponent);
|
|
57034
|
+
const unsafe = segments2.some(
|
|
56071
57035
|
(segment2) => segment2 === ".." || segment2.includes("/") || segment2.includes("\\") || segment2.includes("\0")
|
|
56072
57036
|
);
|
|
56073
|
-
return unsafe ? null :
|
|
57037
|
+
return unsafe ? null : segments2;
|
|
56074
57038
|
} catch {
|
|
56075
57039
|
return null;
|
|
56076
57040
|
}
|
|
@@ -56093,12 +57057,12 @@ var registerStaticFiles = (app, staticDir) => {
|
|
|
56093
57057
|
app.get("*", async (c) => {
|
|
56094
57058
|
const { pathname } = new URL(c.req.url);
|
|
56095
57059
|
if (pathname === "/api" || pathname.startsWith("/api/")) return c.notFound();
|
|
56096
|
-
const
|
|
56097
|
-
if (
|
|
56098
|
-
const name2 =
|
|
56099
|
-
const path4 = join3(staticDir, ...
|
|
57060
|
+
const segments2 = safeSegments(pathname);
|
|
57061
|
+
if (segments2 === null) return c.text("Not found", 404);
|
|
57062
|
+
const name2 = segments2.at(-1);
|
|
57063
|
+
const path4 = join3(staticDir, ...segments2);
|
|
56100
57064
|
if (name2 !== void 0 && name2 !== INDEX && await isFile(path4)) {
|
|
56101
|
-
const immutable =
|
|
57065
|
+
const immutable = segments2[0] === "assets";
|
|
56102
57066
|
return serveFile(c, path4, name2, immutable ? "public, max-age=31536000, immutable" : null);
|
|
56103
57067
|
}
|
|
56104
57068
|
const index = join3(staticDir, INDEX);
|
|
@@ -56550,7 +57514,7 @@ var readBodyDirect = (request2) => {
|
|
|
56550
57514
|
request2[bodyBufferKey] = buffered;
|
|
56551
57515
|
return Promise.resolve(buffered);
|
|
56552
57516
|
}
|
|
56553
|
-
const promise2 = new Promise((
|
|
57517
|
+
const promise2 = new Promise((resolve5, reject) => {
|
|
56554
57518
|
const chunks = [];
|
|
56555
57519
|
let settled = false;
|
|
56556
57520
|
const finish = (callback) => {
|
|
@@ -56568,7 +57532,7 @@ var readBodyDirect = (request2) => {
|
|
|
56568
57532
|
else if (recovered === void 0) reject(error62 ?? normalizeAbortError(request2, incoming));
|
|
56569
57533
|
else {
|
|
56570
57534
|
request2[bodyBufferKey] = recovered;
|
|
56571
|
-
|
|
57535
|
+
resolve5(recovered);
|
|
56572
57536
|
}
|
|
56573
57537
|
});
|
|
56574
57538
|
return true;
|
|
@@ -56580,7 +57544,7 @@ var readBodyDirect = (request2) => {
|
|
|
56580
57544
|
finish(() => {
|
|
56581
57545
|
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
56582
57546
|
request2[bodyBufferKey] = buffer;
|
|
56583
|
-
|
|
57547
|
+
resolve5(buffer);
|
|
56584
57548
|
});
|
|
56585
57549
|
};
|
|
56586
57550
|
const onError = (error62) => {
|
|
@@ -57127,7 +58091,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
57127
58091
|
});
|
|
57128
58092
|
if (!chunk) {
|
|
57129
58093
|
if (i2 === 1) {
|
|
57130
|
-
await new Promise((
|
|
58094
|
+
await new Promise((resolve5) => setTimeout(resolve5));
|
|
57131
58095
|
maxReadCount = 3;
|
|
57132
58096
|
continue;
|
|
57133
58097
|
}
|
|
@@ -57313,9 +58277,9 @@ var setupWebSocket = (options) => {
|
|
|
57313
58277
|
}
|
|
57314
58278
|
};
|
|
57315
58279
|
const waitForWebSocket = (request2, connectionSymbol) => {
|
|
57316
|
-
return new Promise((
|
|
58280
|
+
return new Promise((resolve5, reject) => {
|
|
57317
58281
|
waiterMap.set(request2, {
|
|
57318
|
-
resolve:
|
|
58282
|
+
resolve: resolve5,
|
|
57319
58283
|
reject,
|
|
57320
58284
|
connectionSymbol
|
|
57321
58285
|
});
|
|
@@ -57466,13 +58430,13 @@ var serve = (options, listeningListener) => {
|
|
|
57466
58430
|
};
|
|
57467
58431
|
|
|
57468
58432
|
// src/adapters/http/server.ts
|
|
57469
|
-
var startHttpServer = (app, options) => new Promise((
|
|
58433
|
+
var startHttpServer = (app, options) => new Promise((resolve5, reject) => {
|
|
57470
58434
|
const server = serve(
|
|
57471
58435
|
{ fetch: app.fetch, port: options.port, hostname: "127.0.0.1" },
|
|
57472
|
-
(info2) =>
|
|
58436
|
+
(info2) => resolve5({
|
|
57473
58437
|
port: info2.port,
|
|
57474
|
-
close: () => new Promise((closed,
|
|
57475
|
-
server.close((error62) => error62 === void 0 ? closed() :
|
|
58438
|
+
close: () => new Promise((closed, failed2) => {
|
|
58439
|
+
server.close((error62) => error62 === void 0 ? closed() : failed2(error62));
|
|
57476
58440
|
if ("closeAllConnections" in server) server.closeAllConnections();
|
|
57477
58441
|
})
|
|
57478
58442
|
})
|
|
@@ -57745,13 +58709,13 @@ var createJiraTicketSource = (options) => {
|
|
|
57745
58709
|
const unique2 = [...new Set(keys)];
|
|
57746
58710
|
const tickets = /* @__PURE__ */ new Map();
|
|
57747
58711
|
let next = 0;
|
|
57748
|
-
let
|
|
58712
|
+
let failed2 = false;
|
|
57749
58713
|
const worker = async () => {
|
|
57750
|
-
for (let key = unique2[next]; key !== void 0 && !
|
|
58714
|
+
for (let key = unique2[next]; key !== void 0 && !failed2; key = unique2[next]) {
|
|
57751
58715
|
next += 1;
|
|
57752
58716
|
const ticket = await fetchTicket(key);
|
|
57753
58717
|
if (!ticket.ok) {
|
|
57754
|
-
|
|
58718
|
+
failed2 = true;
|
|
57755
58719
|
return ticket.error;
|
|
57756
58720
|
}
|
|
57757
58721
|
tickets.set(key, ticket.value);
|
|
@@ -59710,13 +60674,13 @@ async function Module2(moduleArg = {}) {
|
|
|
59710
60674
|
}
|
|
59711
60675
|
readAsync = /* @__PURE__ */ __name(async (url2) => {
|
|
59712
60676
|
if (isFileURI(url2)) {
|
|
59713
|
-
return new Promise((
|
|
60677
|
+
return new Promise((resolve5, reject) => {
|
|
59714
60678
|
var xhr = new XMLHttpRequest();
|
|
59715
60679
|
xhr.open("GET", url2, true);
|
|
59716
60680
|
xhr.responseType = "arraybuffer";
|
|
59717
60681
|
xhr.onload = () => {
|
|
59718
60682
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
59719
|
-
|
|
60683
|
+
resolve5(xhr.response);
|
|
59720
60684
|
return;
|
|
59721
60685
|
}
|
|
59722
60686
|
reject(xhr.status);
|
|
@@ -59912,9 +60876,9 @@ async function Module2(moduleArg = {}) {
|
|
|
59912
60876
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
59913
60877
|
var info2 = getWasmImports();
|
|
59914
60878
|
if (Module["instantiateWasm"]) {
|
|
59915
|
-
return new Promise((
|
|
60879
|
+
return new Promise((resolve5, reject) => {
|
|
59916
60880
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
59917
|
-
|
|
60881
|
+
resolve5(receiveInstance(mod, inst));
|
|
59918
60882
|
});
|
|
59919
60883
|
});
|
|
59920
60884
|
}
|
|
@@ -61247,8 +62211,8 @@ async function Module2(moduleArg = {}) {
|
|
|
61247
62211
|
if (runtimeInitialized) {
|
|
61248
62212
|
moduleRtn = Module;
|
|
61249
62213
|
} else {
|
|
61250
|
-
moduleRtn = new Promise((
|
|
61251
|
-
readyPromiseResolve =
|
|
62214
|
+
moduleRtn = new Promise((resolve5, reject) => {
|
|
62215
|
+
readyPromiseResolve = resolve5;
|
|
61252
62216
|
readyPromiseReject = reject;
|
|
61253
62217
|
});
|
|
61254
62218
|
}
|
|
@@ -62373,8 +63337,8 @@ var appError = (code2, message) => ({ code: code2, message });
|
|
|
62373
63337
|
var fromHostError = (error62) => appError(error62.kind === "not-found" ? "not-found" : "host-error", error62.message);
|
|
62374
63338
|
|
|
62375
63339
|
// src/application/use-cases/pipeline-version.ts
|
|
62376
|
-
var PIPELINE_VERSION = "
|
|
62377
|
-
var pipelineVersion = (model, modelEnabled) => `${PIPELINE_VERSION}+${modelEnabled ? model.version : "no-model"}`;
|
|
63340
|
+
var PIPELINE_VERSION = "12";
|
|
63341
|
+
var pipelineVersion = (model, modelEnabled, checkoutRead) => `${PIPELINE_VERSION}+${modelEnabled ? model.version : "no-model"}${checkoutRead ? "+checkout" : ""}`;
|
|
62378
63342
|
|
|
62379
63343
|
// src/application/use-cases/text.ts
|
|
62380
63344
|
var count2 = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
@@ -62523,8 +63487,11 @@ var buildAnalysisInput = (input2) => {
|
|
|
62523
63487
|
headContent: hunks.length > 0 ? input2.headContents.get(file2.path) ?? null : null
|
|
62524
63488
|
};
|
|
62525
63489
|
}),
|
|
62526
|
-
// The model follows calls; type uses would only lengthen its prompt.
|
|
62527
|
-
callGraph:
|
|
63490
|
+
// The model follows calls; type uses would only lengthen its prompt. It sees whole hunks.
|
|
63491
|
+
callGraph: renameHints(
|
|
63492
|
+
prepared.callGraph.filter((hint) => hint.use === "call"),
|
|
63493
|
+
hunkIdOf
|
|
63494
|
+
)
|
|
62528
63495
|
};
|
|
62529
63496
|
};
|
|
62530
63497
|
var mechanicalHunk = (hunk, proof) => ({
|
|
@@ -62554,18 +63521,18 @@ var fitToModel = async (model, input2) => {
|
|
|
62554
63521
|
if (largestFirst.length === 0) return err2(failure2(first.error));
|
|
62555
63522
|
const all = await model.checkSize(without(largestFirst.length));
|
|
62556
63523
|
if (!all.ok) return err2(failure2(all.error));
|
|
62557
|
-
let
|
|
63524
|
+
let fits2 = largestFirst.length;
|
|
62558
63525
|
let tooLarge2 = 0;
|
|
62559
|
-
while (
|
|
62560
|
-
const middle = Math.floor((
|
|
63526
|
+
while (fits2 - tooLarge2 > 1) {
|
|
63527
|
+
const middle = Math.floor((fits2 + tooLarge2) / 2);
|
|
62561
63528
|
const result = await model.checkSize(without(middle));
|
|
62562
|
-
if (result.ok)
|
|
63529
|
+
if (result.ok) fits2 = middle;
|
|
62563
63530
|
else if (result.error.kind === "too-large") tooLarge2 = middle;
|
|
62564
63531
|
else return err2(failure2(result.error));
|
|
62565
63532
|
}
|
|
62566
63533
|
return ok({
|
|
62567
|
-
input: without(
|
|
62568
|
-
warnings: [`Full file contents omitted for ${count2(
|
|
63534
|
+
input: without(fits2),
|
|
63535
|
+
warnings: [`Full file contents omitted for ${count2(fits2, "file")} to fit the model's limit`]
|
|
62569
63536
|
});
|
|
62570
63537
|
};
|
|
62571
63538
|
|
|
@@ -62596,12 +63563,7 @@ var RISK_FEEDBACK = {
|
|
|
62596
63563
|
duplicate: (id) => `${id} is classified more than once.`,
|
|
62597
63564
|
unknown: (id) => `${id} isn't a hunk sent in full, so don't classify it.`
|
|
62598
63565
|
};
|
|
62599
|
-
var
|
|
62600
|
-
missing: (id) => `${id} is in no step. Put every hunk sent in full in exactly one step.`,
|
|
62601
|
-
duplicate: (id) => `${id} is in more than one step.`,
|
|
62602
|
-
unknown: (id) => `${id} isn't a hunk sent in full, so leave it out of the tour.`
|
|
62603
|
-
};
|
|
62604
|
-
var describeProblem = (feedback) => (problem) => feedback[problem.kind](problem.hunkId);
|
|
63566
|
+
var describeProblem = (feedback) => (problem) => feedback[problem.kind](problem.id);
|
|
62605
63567
|
var describeUnknown = (hunkId2) => `${hunkId2} isn't a hunk of this pull request.`;
|
|
62606
63568
|
var runIntent = async (model, input2, knownHunks, logger) => {
|
|
62607
63569
|
const unknownIn = (intent2) => validateHunkReferences(
|
|
@@ -62688,49 +63650,117 @@ var runDecisions = async (model, input2, intent, knownHunks, logger) => {
|
|
|
62688
63650
|
warnings: problems.length === 0 ? [] : [`Dropped ${count2(unknown2, "unknown hunk reference")} from decisions`]
|
|
62689
63651
|
};
|
|
62690
63652
|
};
|
|
63653
|
+
var TITLES_FEEDBACK = (problem) => {
|
|
63654
|
+
const { stepId } = problem;
|
|
63655
|
+
switch (problem.kind) {
|
|
63656
|
+
case "missing":
|
|
63657
|
+
return `${stepId} has no title. Title every step of the tour exactly once.`;
|
|
63658
|
+
case "duplicate":
|
|
63659
|
+
return `${stepId} is titled more than once.`;
|
|
63660
|
+
case "unknown":
|
|
63661
|
+
return `${stepId} isn't a step of the tour, so don't title it.`;
|
|
63662
|
+
case "blank":
|
|
63663
|
+
return `${stepId} has a blank ${problem.field}.`;
|
|
63664
|
+
case "too-long":
|
|
63665
|
+
return `${stepId}'s ${problem.field} is longer than ${problem.field === "title" ? MAX_TITLE : MAX_EXPLANATION} characters.`;
|
|
63666
|
+
case "merge-of-flow":
|
|
63667
|
+
return `${stepId} is a flow, and only supporting steps can be merged.`;
|
|
63668
|
+
case "merge-unknown":
|
|
63669
|
+
return `${stepId} isn't a step of the tour, so it can't be merged.`;
|
|
63670
|
+
case "merged-twice":
|
|
63671
|
+
return `${stepId} is merged more than once.`;
|
|
63672
|
+
case "merge-no-reason":
|
|
63673
|
+
return `The merge of ${stepId} has no reason.`;
|
|
63674
|
+
case "merge-into-unknown":
|
|
63675
|
+
return `${stepId} is merged into ${problem.intoStepId}, which isn't a step of the tour.`;
|
|
63676
|
+
case "merge-into-merged":
|
|
63677
|
+
return `${stepId} is merged into ${problem.intoStepId}, which is merged itself.`;
|
|
63678
|
+
}
|
|
63679
|
+
};
|
|
62691
63680
|
var runTour = async (model, input2, context2, logger) => {
|
|
62692
|
-
const {
|
|
63681
|
+
const { skeleton } = context2;
|
|
62693
63682
|
const { outcome, usage } = await callChecked(
|
|
62694
63683
|
"tour",
|
|
62695
|
-
(options) => model.tour(input2, context2.intent, context2.risk, context2.decisions, options),
|
|
62696
|
-
(
|
|
63684
|
+
(options) => model.tour(input2, context2.intent, context2.risk, context2.decisions, context2.view, options),
|
|
63685
|
+
(titles) => validateTourTitles(titles, skeleton).map(TITLES_FEEDBACK),
|
|
62697
63686
|
logger
|
|
62698
63687
|
);
|
|
62699
63688
|
const fallback = (reason) => ({
|
|
62700
|
-
tour:
|
|
62701
|
-
files: context2.files,
|
|
62702
|
-
required: required2,
|
|
62703
|
-
callGraph: context2.callGraph,
|
|
62704
|
-
risk: context2.assessments,
|
|
62705
|
-
definitions: context2.definitions,
|
|
62706
|
-
generated: context2.generated
|
|
62707
|
-
}),
|
|
63689
|
+
tour: skeleton,
|
|
62708
63690
|
usage,
|
|
62709
|
-
warnings: [`${reason}, so
|
|
63691
|
+
warnings: [`${reason}, so its steps keep the code's titles`]
|
|
62710
63692
|
});
|
|
62711
63693
|
if (!outcome.ok) {
|
|
62712
|
-
return fallback(`The guided tour couldn't be
|
|
63694
|
+
return fallback(`The guided tour couldn't be titled (${outcome.error.message})`);
|
|
62713
63695
|
}
|
|
62714
63696
|
if (outcome.value.problems.length > 0) {
|
|
62715
|
-
return fallback("The guided tour
|
|
63697
|
+
return fallback("The model's titles for the guided tour weren't valid");
|
|
63698
|
+
}
|
|
63699
|
+
return { tour: applyTourTitles(skeleton, outcome.value.value), usage, warnings: [] };
|
|
63700
|
+
};
|
|
63701
|
+
|
|
63702
|
+
// src/application/use-cases/unchanged-callers.ts
|
|
63703
|
+
var lookUpCheckout = async (checkouts, repo, headSha) => {
|
|
63704
|
+
const found = await checkouts.find(repo);
|
|
63705
|
+
if (found === null) return { status: "none", at: null };
|
|
63706
|
+
if (await found.checkout.hasCommit(headSha)) {
|
|
63707
|
+
return { status: "read", at: { checkout: found.checkout, sha: headSha } };
|
|
63708
|
+
}
|
|
63709
|
+
return { status: found.namesRepo ? "missing-commit" : "none", at: null };
|
|
63710
|
+
};
|
|
63711
|
+
var FILES_PER_READ = 500;
|
|
63712
|
+
var readUnchangedCallers = async (parser, at, files, changed, generated) => {
|
|
63713
|
+
if (changed.length === 0) return { unchangedCallers: [], warnings: [] };
|
|
63714
|
+
const listed2 = await at.checkout.listFiles(at.sha);
|
|
63715
|
+
if (!listed2.ok) {
|
|
63716
|
+
return {
|
|
63717
|
+
unchangedCallers: [],
|
|
63718
|
+
warnings: [`Couldn't read the local checkout: ${listed2.error.message}`]
|
|
63719
|
+
};
|
|
63720
|
+
}
|
|
63721
|
+
const changedPaths = new Set(files.map((file2) => file2.path));
|
|
63722
|
+
const families = new Set(
|
|
63723
|
+
files.flatMap((file2) => file2.language === null ? [] : [languageFamily(file2.language)])
|
|
63724
|
+
);
|
|
63725
|
+
const candidates = listed2.value.flatMap((path4) => {
|
|
63726
|
+
const language = changedPaths.has(path4) ? null : parser.languageFor(path4);
|
|
63727
|
+
return language !== null && resolvesImports(language) && families.has(languageFamily(language)) ? [{ path: path4, language }] : [];
|
|
63728
|
+
});
|
|
63729
|
+
const names = new Set(changed.map((definition) => definition.name));
|
|
63730
|
+
const unchanged = [];
|
|
63731
|
+
let tooLarge2 = 0;
|
|
63732
|
+
for (let start3 = 0; start3 < candidates.length; start3 += FILES_PER_READ) {
|
|
63733
|
+
const batch = candidates.slice(start3, start3 + FILES_PER_READ);
|
|
63734
|
+
const read = await at.checkout.readFiles(
|
|
63735
|
+
at.sha,
|
|
63736
|
+
batch.map((file2) => file2.path)
|
|
63737
|
+
);
|
|
63738
|
+
if (!read.ok) {
|
|
63739
|
+
return {
|
|
63740
|
+
unchangedCallers: [],
|
|
63741
|
+
warnings: [`Couldn't read the local checkout: ${read.error.message}`]
|
|
63742
|
+
};
|
|
63743
|
+
}
|
|
63744
|
+
for (const [index, file2] of read.value.entries()) {
|
|
63745
|
+
const candidate = batch[index];
|
|
63746
|
+
if (candidate === void 0) continue;
|
|
63747
|
+
if (file2.kind === "too-large") tooLarge2 += 1;
|
|
63748
|
+
if (file2.kind !== "text" || !mentionsAny(file2.content, names)) continue;
|
|
63749
|
+
const symbols = await parser.symbols(file2.content, candidate.language);
|
|
63750
|
+
if (symbols.ok)
|
|
63751
|
+
unchanged.push({ ...candidate, content: file2.content, symbols: symbols.value });
|
|
63752
|
+
}
|
|
62716
63753
|
}
|
|
62717
63754
|
return {
|
|
62718
|
-
|
|
62719
|
-
|
|
62720
|
-
|
|
62721
|
-
|
|
62722
|
-
kind: "flow",
|
|
62723
|
-
via: []
|
|
62724
|
-
})),
|
|
62725
|
-
builtBy: "model"
|
|
62726
|
-
},
|
|
62727
|
-
usage,
|
|
62728
|
-
warnings: []
|
|
63755
|
+
unchangedCallers: findUnchangedCallers(files, changed, unchanged, generated),
|
|
63756
|
+
warnings: tooLarge2 === 0 ? [] : [
|
|
63757
|
+
`${tooLarge2 === 1 ? "1 file" : `${tooLarge2} files`} in the local checkout ${tooLarge2 === 1 ? "is" : "are"} over 1 MB, so callers in ${tooLarge2 === 1 ? "it" : "them"} aren't shown.`
|
|
63758
|
+
]
|
|
62729
63759
|
};
|
|
62730
63760
|
};
|
|
62731
63761
|
|
|
62732
63762
|
// src/application/use-cases/prep.ts
|
|
62733
|
-
var prep = async (parser, collected) => {
|
|
63763
|
+
var prep = async (parser, collected, checkout = null) => {
|
|
62734
63764
|
const { files, baseContents, headContents } = collected;
|
|
62735
63765
|
const diffProofs = findMechanicalProofs(files, {
|
|
62736
63766
|
gitattributes: collected.gitattributes,
|
|
@@ -62756,23 +63786,48 @@ var prep = async (parser, collected) => {
|
|
|
62756
63786
|
);
|
|
62757
63787
|
const proofs = [...diffProofs, ...formattingProofs];
|
|
62758
63788
|
const symbolsByPath = /* @__PURE__ */ new Map();
|
|
63789
|
+
const definitionsByPath = /* @__PURE__ */ new Map();
|
|
62759
63790
|
for (const file2 of files) {
|
|
63791
|
+
if (file2.language === null) continue;
|
|
62760
63792
|
const head = headContents.get(file2.path);
|
|
62761
|
-
|
|
62762
|
-
|
|
62763
|
-
|
|
63793
|
+
const headSymbols = head == null ? null : await parser.symbols(head, file2.language);
|
|
63794
|
+
if (headSymbols?.ok) symbolsByPath.set(file2.path, headSymbols.value);
|
|
63795
|
+
const base = file2.status === "added" ? null : baseContents.get(file2.oldPath ?? file2.path);
|
|
63796
|
+
const baseSymbols = base == null ? null : await parser.symbols(base, file2.language);
|
|
63797
|
+
definitionsByPath.set(file2.path, {
|
|
63798
|
+
head: headSymbols?.ok ? headSymbols.value.definitions : [],
|
|
63799
|
+
base: baseSymbols?.ok ? baseSymbols.value.definitions : []
|
|
63800
|
+
});
|
|
62764
63801
|
}
|
|
62765
63802
|
const provedHunks = new Set(proofs.flatMap((proof) => proof.hunkId ?? []));
|
|
63803
|
+
const parts2 = splitHunks(files, definitionsByPath, provedHunks);
|
|
63804
|
+
const generated = new Set(
|
|
63805
|
+
files.flatMap((file2) => looksGenerated(headContents.get(file2.path) ?? "") ? [file2.path] : [])
|
|
63806
|
+
);
|
|
63807
|
+
const outside = checkout === null ? { unchangedCallers: [], warnings: [] } : await readUnchangedCallers(
|
|
63808
|
+
parser,
|
|
63809
|
+
checkout,
|
|
63810
|
+
files,
|
|
63811
|
+
// Mechanical hunks don't change what a definition does.
|
|
63812
|
+
changedDefinitions2(
|
|
63813
|
+
files.map((file2) => ({
|
|
63814
|
+
...file2,
|
|
63815
|
+
hunks: file2.hunks.filter((hunk) => !provedHunks.has(hunk.id))
|
|
63816
|
+
})),
|
|
63817
|
+
definitionsByPath,
|
|
63818
|
+
parts2
|
|
63819
|
+
),
|
|
63820
|
+
generated
|
|
63821
|
+
);
|
|
62766
63822
|
return {
|
|
62767
63823
|
proofs,
|
|
62768
|
-
|
|
62769
|
-
|
|
62770
|
-
|
|
62771
|
-
|
|
62772
|
-
|
|
62773
|
-
|
|
62774
|
-
),
|
|
62775
|
-
warnings: lockfileWarnings(files),
|
|
63824
|
+
parts: parts2,
|
|
63825
|
+
callGraph: buildCallGraphHints(files, symbolsByPath, parts2),
|
|
63826
|
+
fileLinks: fileLinks(files, symbolsByPath),
|
|
63827
|
+
definitions: changedDefinitionNames(files, symbolsByPath, parts2),
|
|
63828
|
+
generated,
|
|
63829
|
+
unchangedCallers: outside.unchangedCallers,
|
|
63830
|
+
warnings: [...lockfileWarnings(files), ...outside.warnings],
|
|
62776
63831
|
required: new Set(
|
|
62777
63832
|
files.flatMap((file2) => file2.hunks.map((hunk) => hunk.id)).filter((id) => !provedHunks.has(id))
|
|
62778
63833
|
)
|
|
@@ -62785,8 +63840,8 @@ var createTracker = (deps, initial) => {
|
|
|
62785
63840
|
let analysis = initial;
|
|
62786
63841
|
let lastStage = "collect";
|
|
62787
63842
|
const save = async (patch) => {
|
|
62788
|
-
const
|
|
62789
|
-
analysis = { ...analysis, ...
|
|
63843
|
+
const changes2 = typeof patch === "function" ? patch(analysis) : patch;
|
|
63844
|
+
analysis = { ...analysis, ...changes2, updatedAt: deps.clock.now() };
|
|
62790
63845
|
await deps.store.saveAnalysis(analysis);
|
|
62791
63846
|
};
|
|
62792
63847
|
const setStage = async (stage, status, patch = {}) => {
|
|
@@ -62823,10 +63878,10 @@ var adding = (added) => (analysis) => ({
|
|
|
62823
63878
|
warnings: [...analysis.warnings, ...added.warnings ?? []],
|
|
62824
63879
|
usage: [...analysis.usage, ...added.usage ?? []]
|
|
62825
63880
|
});
|
|
62826
|
-
var runPipeline = async (deps, host, analysis, pullRequest) => {
|
|
63881
|
+
var runPipeline = async (deps, host, analysis, pullRequest, checkout = null) => {
|
|
62827
63882
|
const tracker = createTracker(deps, analysis);
|
|
62828
63883
|
try {
|
|
62829
|
-
await stages(deps, host, pullRequest, tracker);
|
|
63884
|
+
await stages(deps, host, pullRequest, checkout, tracker);
|
|
62830
63885
|
} catch (error62) {
|
|
62831
63886
|
deps.logger.error("The analysis pipeline crashed", { analysisId: analysis.id, error: error62 });
|
|
62832
63887
|
await tracker.fail(tracker.lastStage, {
|
|
@@ -62835,7 +63890,7 @@ var runPipeline = async (deps, host, analysis, pullRequest) => {
|
|
|
62835
63890
|
});
|
|
62836
63891
|
}
|
|
62837
63892
|
};
|
|
62838
|
-
var stages = async (deps, host, pullRequest, tracker) => {
|
|
63893
|
+
var stages = async (deps, host, pullRequest, checkout, tracker) => {
|
|
62839
63894
|
const { model, logger } = deps;
|
|
62840
63895
|
await tracker.setStage("collect", "running");
|
|
62841
63896
|
const collected = await collect(deps, host, pullRequest, tracker.setFilesFetched);
|
|
@@ -62848,8 +63903,8 @@ var stages = async (deps, host, pullRequest, tracker) => {
|
|
|
62848
63903
|
...adding({ warnings: collected.value.warnings })(analysis)
|
|
62849
63904
|
}));
|
|
62850
63905
|
await tracker.setStage("prep", "running");
|
|
62851
|
-
const prepared = await prep(deps.parser, collected.value);
|
|
62852
|
-
const { proofs, callGraph, required: required2, definitions, generated } = prepared;
|
|
63906
|
+
const prepared = await prep(deps.parser, collected.value, checkout);
|
|
63907
|
+
const { proofs, parts: parts2, callGraph, required: required2, definitions, generated, unchangedCallers } = prepared;
|
|
62853
63908
|
const proofRisk = proofs.flatMap(
|
|
62854
63909
|
(proof) => proof.hunkId === null ? [] : [
|
|
62855
63910
|
{
|
|
@@ -62861,13 +63916,26 @@ var stages = async (deps, host, pullRequest, tracker) => {
|
|
|
62861
63916
|
]
|
|
62862
63917
|
);
|
|
62863
63918
|
const ruleRisk = classifyByRules(files, new Set(proofRisk.map((risk2) => risk2.hunkId)));
|
|
62864
|
-
const
|
|
63919
|
+
const skeleton = codeTour({
|
|
63920
|
+
files,
|
|
63921
|
+
required: required2,
|
|
63922
|
+
parts: parts2,
|
|
63923
|
+
callGraph,
|
|
63924
|
+
risk: [...proofRisk, ...ruleRisk],
|
|
63925
|
+
definitions,
|
|
63926
|
+
generated
|
|
63927
|
+
});
|
|
63928
|
+
const joined = joinParts(skeleton, parts2, callGraph, unchangedCallers);
|
|
63929
|
+
const prepPatch = {
|
|
63930
|
+
proofs,
|
|
63931
|
+
...joined,
|
|
63932
|
+
fileLinks: prepared.fileLinks,
|
|
63933
|
+
generated: [...generated].sort()
|
|
63934
|
+
};
|
|
62865
63935
|
if (!deps.modelEnabled) {
|
|
62866
|
-
const risk2 = [...proofRisk, ...ruleRisk];
|
|
62867
63936
|
await tracker.setStage("prep", "done", (analysis) => ({
|
|
62868
63937
|
...prepPatch,
|
|
62869
|
-
risk:
|
|
62870
|
-
tour: codeTour({ files, required: required2, callGraph, risk: risk2, definitions, generated }),
|
|
63938
|
+
risk: [...proofRisk, ...ruleRisk],
|
|
62871
63939
|
...adding(prepared)(analysis)
|
|
62872
63940
|
}));
|
|
62873
63941
|
for (const stage of MODEL_STAGES) await tracker.setStage(stage, "skipped");
|
|
@@ -62941,17 +64009,13 @@ var stages = async (deps, host, pullRequest, tracker) => {
|
|
|
62941
64009
|
intent,
|
|
62942
64010
|
risk: risk.value.forTour,
|
|
62943
64011
|
decisions: decisions.value,
|
|
62944
|
-
|
|
62945
|
-
|
|
62946
|
-
callGraph,
|
|
62947
|
-
definitions,
|
|
62948
|
-
generated,
|
|
62949
|
-
assessments: risk.value.assessments
|
|
64012
|
+
skeleton,
|
|
64013
|
+
view: { tour: joined.tour, parts: joined.parts }
|
|
62950
64014
|
},
|
|
62951
64015
|
logger
|
|
62952
64016
|
);
|
|
62953
64017
|
await tracker.setStage("tour", "done", (analysis) => ({
|
|
62954
|
-
tour
|
|
64018
|
+
...joinParts(tour.tour, parts2, callGraph, unchangedCallers),
|
|
62955
64019
|
...adding(tour)(analysis)
|
|
62956
64020
|
}));
|
|
62957
64021
|
await tracker.finish(null);
|
|
@@ -62971,7 +64035,7 @@ var fetchPullRequest = async (deps, ref) => {
|
|
|
62971
64035
|
const pullRequest = await host.value.getPullRequest(ref);
|
|
62972
64036
|
return pullRequest.ok ? ok({ host: host.value, pullRequest: pullRequest.value }) : err2(fromHostError(pullRequest.error));
|
|
62973
64037
|
};
|
|
62974
|
-
var newAnalysis = (deps, key, pullRequest, createdAt) => ({
|
|
64038
|
+
var newAnalysis = (deps, key, pullRequest, checkout, createdAt) => ({
|
|
62975
64039
|
id: analysisId(key),
|
|
62976
64040
|
key,
|
|
62977
64041
|
status: "running",
|
|
@@ -62989,7 +64053,12 @@ var newAnalysis = (deps, key, pullRequest, createdAt) => ({
|
|
|
62989
64053
|
tickets: [],
|
|
62990
64054
|
missingTicketKeys: [],
|
|
62991
64055
|
proofs: [],
|
|
64056
|
+
parts: [],
|
|
62992
64057
|
callGraph: [],
|
|
64058
|
+
fileLinks: [],
|
|
64059
|
+
generated: [],
|
|
64060
|
+
checkout,
|
|
64061
|
+
unchangedCallers: [],
|
|
62993
64062
|
intent: null,
|
|
62994
64063
|
risk: [],
|
|
62995
64064
|
decisions: [],
|
|
@@ -63003,18 +64072,29 @@ var newAnalysis = (deps, key, pullRequest, createdAt) => ({
|
|
|
63003
64072
|
var createAnalysisRunner = (deps) => {
|
|
63004
64073
|
const inFlight = /* @__PURE__ */ new Map();
|
|
63005
64074
|
const startFor = async (host, pullRequest) => {
|
|
64075
|
+
const checkout = await lookUpCheckout(
|
|
64076
|
+
deps.checkouts,
|
|
64077
|
+
pullRequest.ref.repo,
|
|
64078
|
+
pullRequest.headSha
|
|
64079
|
+
);
|
|
63006
64080
|
const key = {
|
|
63007
64081
|
ref: pullRequest.ref,
|
|
63008
64082
|
headSha: pullRequest.headSha,
|
|
63009
|
-
pipelineVersion: pipelineVersion(deps.model, deps.modelEnabled)
|
|
64083
|
+
pipelineVersion: pipelineVersion(deps.model, deps.modelEnabled, checkout.status === "read")
|
|
63010
64084
|
};
|
|
63011
64085
|
const existing = await deps.store.findByKey(key);
|
|
63012
64086
|
const id = existing?.id ?? analysisId(key);
|
|
63013
64087
|
if (existing?.status === "complete" || inFlight.has(id)) return id;
|
|
63014
|
-
const analysis = newAnalysis(
|
|
64088
|
+
const analysis = newAnalysis(
|
|
64089
|
+
deps,
|
|
64090
|
+
key,
|
|
64091
|
+
pullRequest,
|
|
64092
|
+
checkout.status,
|
|
64093
|
+
existing?.createdAt ?? deps.clock.now()
|
|
64094
|
+
);
|
|
63015
64095
|
const run3 = (async () => {
|
|
63016
64096
|
await deps.store.saveAnalysis(analysis);
|
|
63017
|
-
await runPipeline(deps, host, analysis, pullRequest);
|
|
64097
|
+
await runPipeline(deps, host, analysis, pullRequest, checkout.at);
|
|
63018
64098
|
})().catch((error62) => {
|
|
63019
64099
|
deps.logger.error("Couldn't record the analysis", { analysisId: id, error: error62 });
|
|
63020
64100
|
}).finally(() => inFlight.delete(id));
|
|
@@ -63210,12 +64290,12 @@ var createReviewUseCases = (deps) => {
|
|
|
63210
64290
|
};
|
|
63211
64291
|
|
|
63212
64292
|
// src/application/use-cases/status.ts
|
|
63213
|
-
var
|
|
64293
|
+
var HOSTS3 = HostKind.options;
|
|
63214
64294
|
var createStatusUseCases = (deps, version3) => ({
|
|
63215
64295
|
/** PRs to review and the user's own, from every configured host. */
|
|
63216
64296
|
async listPullRequests() {
|
|
63217
64297
|
const listed2 = await Promise.all(
|
|
63218
|
-
|
|
64298
|
+
HOSTS3.flatMap((host) => {
|
|
63219
64299
|
const gitHost = deps.hosts[host];
|
|
63220
64300
|
return gitHost === void 0 ? [] : [gitHost.listPullRequests().then((result) => ({ host, result }))];
|
|
63221
64301
|
})
|
|
@@ -63351,6 +64431,7 @@ var compose2 = async (config2, options) => {
|
|
|
63351
64431
|
modelEnabled: options.ai,
|
|
63352
64432
|
store,
|
|
63353
64433
|
fileCache: store,
|
|
64434
|
+
checkouts: createGitCheckouts({ dir: options.checkoutDir }),
|
|
63354
64435
|
parser: await createTreeSitterCodeParser({ grammarsDir: options.grammarsDir }),
|
|
63355
64436
|
clock,
|
|
63356
64437
|
logger
|
|
@@ -63567,6 +64648,28 @@ var checkAnthropic = async (deps) => {
|
|
|
63567
64648
|
"Check ANTHROPIC_API_KEY, or run `ant auth login` again."
|
|
63568
64649
|
);
|
|
63569
64650
|
};
|
|
64651
|
+
var HOST_DOMAINS = {
|
|
64652
|
+
github: "github.com",
|
|
64653
|
+
bitbucket: "bitbucket.org"
|
|
64654
|
+
};
|
|
64655
|
+
var repoName = ({ host, owner, repo }) => `${HOST_DOMAINS[host]}/${owner}/${repo}`;
|
|
64656
|
+
var checkCheckout = ({ checkout: { dir, info: info2 } }) => {
|
|
64657
|
+
if (info2 === null) {
|
|
64658
|
+
return check2(
|
|
64659
|
+
"skip",
|
|
64660
|
+
"Checkout",
|
|
64661
|
+
`${dir} isn't in a git checkout: callers outside a PR aren't shown`,
|
|
64662
|
+
"Run megareviewer in a checkout of the PR's repository, or pass --checkout <dir>."
|
|
64663
|
+
);
|
|
64664
|
+
}
|
|
64665
|
+
const repos = info2.repos.length === 0 ? "with no GitHub or Bitbucket remote; read for a PR whose head commit it has" : `a checkout of ${info2.repos.map(repoName).join(", ")}`;
|
|
64666
|
+
return check2(
|
|
64667
|
+
"pass",
|
|
64668
|
+
"Checkout",
|
|
64669
|
+
`${info2.root}, ${repos}`,
|
|
64670
|
+
"Callers outside a PR need its head commit: if a review says it's missing, run `git fetch` there."
|
|
64671
|
+
);
|
|
64672
|
+
};
|
|
63570
64673
|
var runDoctor = async (deps) => {
|
|
63571
64674
|
const node2 = nodeSupported(deps.nodeVersion) ? check2("pass", "Node", deps.nodeVersion) : check2("fail", "Node", deps.nodeVersion, NODE_FIX);
|
|
63572
64675
|
const problems = deps.problems.map((problem) => check2("fail", "Configuration", problem));
|
|
@@ -63578,7 +64681,7 @@ var runDoctor = async (deps) => {
|
|
|
63578
64681
|
]);
|
|
63579
64682
|
const opened = deps.openStore();
|
|
63580
64683
|
const store = opened.ok ? check2("pass", "Home", `${deps.config.home} is writable and the database opens`) : check2("fail", "Home", opened.error, "Set MEGAREVIEWER_HOME to a writable directory.");
|
|
63581
|
-
return [node2, ...problems, ...services, store];
|
|
64684
|
+
return [node2, ...problems, ...services, checkCheckout(deps), store];
|
|
63582
64685
|
};
|
|
63583
64686
|
var MARK = { pass: "\u2713", fail: "\u2717", skip: "\u2013" };
|
|
63584
64687
|
var formatCheck = ({ status, title, detail, fix }) => `${MARK[status]} ${title}: ${detail}${fix === null ? "" : `
|
|
@@ -63589,6 +64692,7 @@ var createDoctorDeps = async (options) => {
|
|
|
63589
64692
|
const client = new Anthropic({ maxRetries: 0 });
|
|
63590
64693
|
return {
|
|
63591
64694
|
nodeVersion: process.versions.node,
|
|
64695
|
+
checkout: { dir: options.checkoutDir, info: await inspectCheckout(options.checkoutDir) },
|
|
63592
64696
|
config: config2,
|
|
63593
64697
|
problems: options.problems,
|
|
63594
64698
|
hosts: createHosts(config2, { version: options.version, clock: systemClock, logger }),
|
|
@@ -63648,7 +64752,7 @@ var createLogger2 = (options) => {
|
|
|
63648
64752
|
};
|
|
63649
64753
|
|
|
63650
64754
|
// src/cli/open-browser.ts
|
|
63651
|
-
import { spawn as
|
|
64755
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
63652
64756
|
var browserCommand = (url2, platform) => {
|
|
63653
64757
|
switch (platform) {
|
|
63654
64758
|
case "darwin":
|
|
@@ -63663,7 +64767,7 @@ var openBrowser = (url2, logger, platform = process.platform) => {
|
|
|
63663
64767
|
const [file2, args2] = browserCommand(url2, platform);
|
|
63664
64768
|
const warn = (reason) => logger.warn("Couldn't open the browser; open the printed URL yourself", { reason });
|
|
63665
64769
|
try {
|
|
63666
|
-
const child =
|
|
64770
|
+
const child = spawn3(file2, args2, {
|
|
63667
64771
|
detached: true,
|
|
63668
64772
|
stdio: "ignore",
|
|
63669
64773
|
windowsVerbatimArguments: platform === "win32"
|
|
@@ -63706,24 +64810,36 @@ var printProblems = (problems) => {
|
|
|
63706
64810
|
for (const problem of problems) console.error(` \u2717 ${problem}`);
|
|
63707
64811
|
console.error("\nRun `megareviewer doctor` for details.");
|
|
63708
64812
|
};
|
|
63709
|
-
var printSummary = (config2, composition, url2, ui) => {
|
|
64813
|
+
var printSummary = (config2, composition, checkout, url2, ui) => {
|
|
63710
64814
|
const github = config2.github === null ? "not configured" : `token from ${config2.github.source}`;
|
|
63711
64815
|
const bitbucket = config2.bitbucket === null ? "not configured" : `as ${config2.bitbucket.username} (${config2.bitbucket.credential})${config2.bitbucket.workspace === null ? "" : `, workspace ${config2.bitbucket.workspace}`}`;
|
|
63712
64816
|
const jira = config2.jira === null ? "not configured: ticket keys aren't fetched" : config2.jira.baseUrl;
|
|
63713
|
-
const model = composition.modelEnabled ? "on: intent, decisions and the
|
|
64817
|
+
const model = composition.modelEnabled ? "on: intent, decisions and the tour's titles come from Claude" : "off: start with --ai to add intent, decisions and a guided tour from Claude";
|
|
64818
|
+
const repos = checkout?.repos.map(repoName).join(", ") ?? "";
|
|
64819
|
+
const local = checkout === null ? "none: start in a checkout of the PR's repository, or pass --checkout, to show callers outside the PR" : `${checkout.root}${repos === "" ? "" : ` (${repos})`}`;
|
|
63714
64820
|
console.log(`megareviewer ${version2}
|
|
63715
64821
|
GitHub ${github}
|
|
63716
64822
|
Bitbucket ${bitbucket}
|
|
63717
64823
|
Jira ${jira}
|
|
63718
64824
|
Anthropic ${model}
|
|
64825
|
+
Checkout ${local}
|
|
63719
64826
|
${ui ? "" : "\nNo built UI found, so only the API is served.\n"}
|
|
63720
64827
|
Open ${url2}
|
|
63721
64828
|
Press Ctrl+C to stop.`);
|
|
63722
64829
|
};
|
|
63723
|
-
var
|
|
64830
|
+
var checkoutDir = (given) => resolve4(given ?? process.cwd());
|
|
64831
|
+
var doctor = async (options) => {
|
|
63724
64832
|
const { config: config2, problems } = await loadConfig2();
|
|
63725
64833
|
const logger = createLogger2({ level: "error" });
|
|
63726
|
-
const checks = await runDoctor(
|
|
64834
|
+
const checks = await runDoctor(
|
|
64835
|
+
await createDoctorDeps({
|
|
64836
|
+
config: config2,
|
|
64837
|
+
problems,
|
|
64838
|
+
checkoutDir: checkoutDir(options.checkout),
|
|
64839
|
+
version: version2,
|
|
64840
|
+
logger
|
|
64841
|
+
})
|
|
64842
|
+
);
|
|
63727
64843
|
for (const check3 of checks) console.log(formatCheck(check3));
|
|
63728
64844
|
return checks.some((check3) => check3.status === "fail") ? EXIT.config : EXIT.ok;
|
|
63729
64845
|
};
|
|
@@ -63752,7 +64868,14 @@ var start2 = async (options) => {
|
|
|
63752
64868
|
}
|
|
63753
64869
|
const logger = createLogger2({ level: config2.logLevel });
|
|
63754
64870
|
const assets = locateAssets();
|
|
63755
|
-
const
|
|
64871
|
+
const dir = checkoutDir(options.checkout);
|
|
64872
|
+
const composed = await compose2(config2, {
|
|
64873
|
+
...assets,
|
|
64874
|
+
ai: options.ai,
|
|
64875
|
+
checkoutDir: dir,
|
|
64876
|
+
version: version2,
|
|
64877
|
+
logger
|
|
64878
|
+
});
|
|
63756
64879
|
if (!composed.ok) {
|
|
63757
64880
|
printProblems([composed.error]);
|
|
63758
64881
|
return EXIT.config;
|
|
@@ -63771,7 +64894,7 @@ var start2 = async (options) => {
|
|
|
63771
64894
|
await composition.close();
|
|
63772
64895
|
}, logger);
|
|
63773
64896
|
const url2 = `http://127.0.0.1:${server.port}/?token=${composition.sessionToken}`;
|
|
63774
|
-
printSummary(config2, composition, url2, assets.staticDir !== null);
|
|
64897
|
+
printSummary(config2, composition, await inspectCheckout(dir), url2, assets.staticDir !== null);
|
|
63775
64898
|
if (options.open) openBrowser(url2, logger);
|
|
63776
64899
|
return null;
|
|
63777
64900
|
};
|
|
@@ -63792,7 +64915,7 @@ ${USAGE}`);
|
|
|
63792
64915
|
console.log(version2);
|
|
63793
64916
|
return EXIT.ok;
|
|
63794
64917
|
case "doctor":
|
|
63795
|
-
return doctor();
|
|
64918
|
+
return doctor(command);
|
|
63796
64919
|
case "serve":
|
|
63797
64920
|
return start2(command);
|
|
63798
64921
|
}
|