open-azdo 0.2.5 → 0.2.7
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
CHANGED
package/dist/open-azdo.js
CHANGED
|
@@ -47044,6 +47044,26 @@ var resolvePullRequestDiff = (input) => exports_Effect.gen(function* () {
|
|
|
47044
47044
|
// ../../packages/core/src/platform/Services/ProcessRunner.ts
|
|
47045
47045
|
class ProcessRunner extends exports_ServiceMap.Service()("open-azdo/platform/ProcessRunner") {
|
|
47046
47046
|
}
|
|
47047
|
+
// ../../packages/core/src/format-unknown.ts
|
|
47048
|
+
var formatUnknownDetail = (value3) => {
|
|
47049
|
+
if (typeof value3 === "string") {
|
|
47050
|
+
return value3;
|
|
47051
|
+
}
|
|
47052
|
+
if (value3 instanceof Error) {
|
|
47053
|
+
return value3.message;
|
|
47054
|
+
}
|
|
47055
|
+
if (typeof value3 === "number" || typeof value3 === "boolean" || typeof value3 === "bigint") {
|
|
47056
|
+
return String(value3);
|
|
47057
|
+
}
|
|
47058
|
+
if (value3 === undefined) {
|
|
47059
|
+
return "undefined";
|
|
47060
|
+
}
|
|
47061
|
+
if (value3 === null) {
|
|
47062
|
+
return "null";
|
|
47063
|
+
}
|
|
47064
|
+
return stringifyJson2(value3);
|
|
47065
|
+
};
|
|
47066
|
+
|
|
47047
47067
|
// ../../packages/core/src/platform/Layers/ProcessRunner.ts
|
|
47048
47068
|
var DEFAULT_TIMEOUT = seconds(30);
|
|
47049
47069
|
var DEFAULT_MAX_OUTPUT_BYTES = 1e6;
|
|
@@ -47113,7 +47133,7 @@ var makeProcessRunner = exports_Effect.gen(function* () {
|
|
|
47113
47133
|
stderr: "pipe"
|
|
47114
47134
|
});
|
|
47115
47135
|
return yield* exports_Effect.gen(function* () {
|
|
47116
|
-
const handle = yield* spawner.spawn(command).pipe(exports_Effect.mapError((error2) => toCommandExecutionError(input, `Failed to start ${commandLabel(input)}: ${
|
|
47136
|
+
const handle = yield* spawner.spawn(command).pipe(exports_Effect.mapError((error2) => toCommandExecutionError(input, `Failed to start ${commandLabel(input)}: ${formatUnknownDetail(error2)}`)));
|
|
47117
47137
|
const [stdout, stderr, exitCode] = yield* exports_Effect.all([
|
|
47118
47138
|
collectOutput(input, handle.stdout, "stdout", maxOutputBytes),
|
|
47119
47139
|
collectOutput(input, handle.stderr, "stderr", maxOutputBytes),
|
|
@@ -47234,10 +47254,68 @@ var buildOpenCodeArgs = (request3) => [
|
|
|
47234
47254
|
...request3.variant ? ["--variant", request3.variant] : [],
|
|
47235
47255
|
REVIEW_TRIGGER_MESSAGE
|
|
47236
47256
|
];
|
|
47237
|
-
var
|
|
47257
|
+
var isRecord = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
|
|
47258
|
+
var toNumberOrUndefined = (value3) => typeof value3 === "number" && Number.isFinite(value3) ? value3 : undefined;
|
|
47259
|
+
var parseTokenUsage = (value3) => {
|
|
47260
|
+
if (!isRecord(value3)) {
|
|
47261
|
+
return;
|
|
47262
|
+
}
|
|
47263
|
+
const input = toNumberOrUndefined(value3.input);
|
|
47264
|
+
const output = toNumberOrUndefined(value3.output);
|
|
47265
|
+
if (input === undefined || output === undefined) {
|
|
47266
|
+
return;
|
|
47267
|
+
}
|
|
47268
|
+
return {
|
|
47269
|
+
input,
|
|
47270
|
+
output,
|
|
47271
|
+
reasoning: toNumberOrUndefined(value3.reasoning) ?? 0,
|
|
47272
|
+
cacheRead: toNumberOrUndefined(value3.cacheRead) ?? 0,
|
|
47273
|
+
cacheWrite: toNumberOrUndefined(value3.cacheWrite) ?? 0
|
|
47274
|
+
};
|
|
47275
|
+
};
|
|
47276
|
+
var buildUsage = ({
|
|
47277
|
+
costUsd,
|
|
47278
|
+
tokens
|
|
47279
|
+
}) => {
|
|
47280
|
+
if (costUsd === undefined && tokens === undefined) {
|
|
47281
|
+
return;
|
|
47282
|
+
}
|
|
47283
|
+
return {
|
|
47284
|
+
...costUsd !== undefined ? { costUsd } : {},
|
|
47285
|
+
...tokens ? { tokens } : {}
|
|
47286
|
+
};
|
|
47287
|
+
};
|
|
47288
|
+
var parsePartUsage = (value3) => {
|
|
47289
|
+
if (!isRecord(value3) || value3.type !== "step-finish") {
|
|
47290
|
+
return;
|
|
47291
|
+
}
|
|
47292
|
+
return buildUsage({
|
|
47293
|
+
costUsd: toNumberOrUndefined(value3.cost),
|
|
47294
|
+
tokens: parseTokenUsage(value3.tokens)
|
|
47295
|
+
});
|
|
47296
|
+
};
|
|
47297
|
+
var parseAssistantUsage = (value3) => {
|
|
47298
|
+
if (!isRecord(value3)) {
|
|
47299
|
+
return;
|
|
47300
|
+
}
|
|
47301
|
+
const candidate = isRecord(value3.info) ? value3.info : value3;
|
|
47302
|
+
return buildUsage({
|
|
47303
|
+
costUsd: toNumberOrUndefined(candidate.cost),
|
|
47304
|
+
tokens: parseTokenUsage(candidate.tokens)
|
|
47305
|
+
});
|
|
47306
|
+
};
|
|
47307
|
+
var extractOpenCodeRunResult = (output) => {
|
|
47238
47308
|
const texts = [];
|
|
47239
47309
|
const structuredCandidates = [];
|
|
47240
47310
|
const reportedErrors = [];
|
|
47311
|
+
let sessionId;
|
|
47312
|
+
let stepFinishUsage;
|
|
47313
|
+
let assistantUsage;
|
|
47314
|
+
const buildRunResult = (response2) => ({
|
|
47315
|
+
response: response2,
|
|
47316
|
+
...sessionId ? { sessionId } : {},
|
|
47317
|
+
...stepFinishUsage || assistantUsage ? { usage: stepFinishUsage ?? assistantUsage } : {}
|
|
47318
|
+
});
|
|
47241
47319
|
const describeError = (value3) => {
|
|
47242
47320
|
if (value3 === null || value3 === undefined) {
|
|
47243
47321
|
return;
|
|
@@ -47246,19 +47324,21 @@ var extractFinalResponse = (output) => {
|
|
|
47246
47324
|
const trimmed = value3.trim();
|
|
47247
47325
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
47248
47326
|
}
|
|
47249
|
-
if (typeof value3
|
|
47327
|
+
if (typeof value3 === "number" || typeof value3 === "boolean" || typeof value3 === "bigint") {
|
|
47250
47328
|
return String(value3);
|
|
47251
47329
|
}
|
|
47252
|
-
|
|
47253
|
-
|
|
47330
|
+
if (!isRecord(value3)) {
|
|
47331
|
+
return;
|
|
47332
|
+
}
|
|
47333
|
+
const message = describeError(value3.message) ?? describeError(value3.detail) ?? describeError(value3.data) ?? describeError(value3.error) ?? describeError(value3.cause);
|
|
47254
47334
|
if (!message) {
|
|
47255
|
-
return stringifyJson2(
|
|
47335
|
+
return stringifyJson2(value3);
|
|
47256
47336
|
}
|
|
47257
|
-
const name = typeof
|
|
47337
|
+
const name = typeof value3.name === "string" ? value3.name.trim() : "";
|
|
47258
47338
|
return name.length > 0 && !message.startsWith(`${name}:`) ? `${name}: ${message}` : message;
|
|
47259
47339
|
};
|
|
47260
47340
|
const maybeCollectStructuredCandidate = (value3) => {
|
|
47261
|
-
if (!
|
|
47341
|
+
if (!isRecord(value3)) {
|
|
47262
47342
|
return;
|
|
47263
47343
|
}
|
|
47264
47344
|
if ("summary" in value3 && "verdict" in value3 && "findings" in value3) {
|
|
@@ -47286,10 +47366,21 @@ var extractFinalResponse = (output) => {
|
|
|
47286
47366
|
}
|
|
47287
47367
|
return;
|
|
47288
47368
|
}
|
|
47289
|
-
if (
|
|
47369
|
+
if (!isRecord(value3)) {
|
|
47290
47370
|
return;
|
|
47291
47371
|
}
|
|
47292
47372
|
maybeCollectStructuredCandidate(value3);
|
|
47373
|
+
const usageFromPart = parsePartUsage(value3);
|
|
47374
|
+
if (usageFromPart) {
|
|
47375
|
+
stepFinishUsage = usageFromPart;
|
|
47376
|
+
}
|
|
47377
|
+
const usageFromAssistant = parseAssistantUsage(value3);
|
|
47378
|
+
if (usageFromAssistant) {
|
|
47379
|
+
assistantUsage = usageFromAssistant;
|
|
47380
|
+
}
|
|
47381
|
+
if (typeof value3.sessionID === "string") {
|
|
47382
|
+
sessionId = value3.sessionID;
|
|
47383
|
+
}
|
|
47293
47384
|
if ("type" in value3 && value3.type === "text" && "text" in value3 && typeof value3.text === "string") {
|
|
47294
47385
|
texts.push(value3.text.trim());
|
|
47295
47386
|
}
|
|
@@ -47324,7 +47415,7 @@ var extractFinalResponse = (output) => {
|
|
|
47324
47415
|
}
|
|
47325
47416
|
const structuredResponse = structuredCandidates.at(-1)?.trim();
|
|
47326
47417
|
if (structuredResponse) {
|
|
47327
|
-
return structuredResponse;
|
|
47418
|
+
return buildRunResult(structuredResponse);
|
|
47328
47419
|
}
|
|
47329
47420
|
const response = texts.join(`
|
|
47330
47421
|
`).trim();
|
|
@@ -47334,7 +47425,7 @@ var extractFinalResponse = (output) => {
|
|
|
47334
47425
|
output
|
|
47335
47426
|
});
|
|
47336
47427
|
}
|
|
47337
|
-
return response;
|
|
47428
|
+
return buildRunResult(response);
|
|
47338
47429
|
};
|
|
47339
47430
|
var makeOpenCodeRunner = exports_Effect.gen(function* () {
|
|
47340
47431
|
const runner = yield* ProcessRunner;
|
|
@@ -47350,7 +47441,7 @@ var makeOpenCodeRunner = exports_Effect.gen(function* () {
|
|
|
47350
47441
|
});
|
|
47351
47442
|
const tempDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "open-azdo-opencode-" }).pipe(exports_Effect.mapError((error2) => new OpenCodeOutputError({
|
|
47352
47443
|
message: "Failed to create OpenCode temp directory.",
|
|
47353
|
-
output:
|
|
47444
|
+
output: formatUnknownDetail(error2)
|
|
47354
47445
|
})));
|
|
47355
47446
|
const configPath = path3.join(tempDir, "opencode.json");
|
|
47356
47447
|
const promptPath = path3.join(tempDir, "agent-prompt.md");
|
|
@@ -47359,7 +47450,7 @@ var makeOpenCodeRunner = exports_Effect.gen(function* () {
|
|
|
47359
47450
|
fileSystem.writeFileString(configPath, stringifyJson2(buildOpenCodeConfig(request3.agent)))
|
|
47360
47451
|
], { concurrency: "unbounded" }).pipe(exports_Effect.mapError((error2) => new OpenCodeOutputError({
|
|
47361
47452
|
message: "Failed to write temporary OpenCode configuration.",
|
|
47362
|
-
output:
|
|
47453
|
+
output: formatUnknownDetail(error2)
|
|
47363
47454
|
})));
|
|
47364
47455
|
yield* logInfo2("Prepared temporary OpenCode files.", {
|
|
47365
47456
|
tempDir,
|
|
@@ -47400,11 +47491,11 @@ var makeOpenCodeRunner = exports_Effect.gen(function* () {
|
|
|
47400
47491
|
exitCode: result4.exitCode
|
|
47401
47492
|
});
|
|
47402
47493
|
}
|
|
47403
|
-
const
|
|
47404
|
-
try: () =>
|
|
47494
|
+
const runResult = yield* exports_Effect.try({
|
|
47495
|
+
try: () => extractOpenCodeRunResult(result4.stdout),
|
|
47405
47496
|
catch: (error2) => error2 instanceof OpenCodeOutputError ? error2 : new OpenCodeOutputError({
|
|
47406
47497
|
message: "OpenCode did not return a valid final response.",
|
|
47407
|
-
output:
|
|
47498
|
+
output: formatUnknownDetail(error2)
|
|
47408
47499
|
})
|
|
47409
47500
|
}).pipe(exports_Effect.tapError((error2) => logError2("Failed to extract final OpenCode response.", {
|
|
47410
47501
|
stdoutPreview: truncateForLog(result4.stdout),
|
|
@@ -47412,10 +47503,14 @@ var makeOpenCodeRunner = exports_Effect.gen(function* () {
|
|
|
47412
47503
|
detail: error2.message
|
|
47413
47504
|
})));
|
|
47414
47505
|
yield* logInfo2("Extracted final OpenCode response.", {
|
|
47415
|
-
responseChars: response.length,
|
|
47416
|
-
responsePreview: truncateForLog(response)
|
|
47506
|
+
responseChars: runResult.response.length,
|
|
47507
|
+
responsePreview: truncateForLog(runResult.response),
|
|
47508
|
+
sessionId: runResult.sessionId,
|
|
47509
|
+
costUsd: runResult.usage?.costUsd,
|
|
47510
|
+
inputTokens: runResult.usage?.tokens?.input,
|
|
47511
|
+
outputTokens: runResult.usage?.tokens?.output
|
|
47417
47512
|
});
|
|
47418
|
-
return
|
|
47513
|
+
return runResult;
|
|
47419
47514
|
}).pipe(exports_Effect.scoped);
|
|
47420
47515
|
});
|
|
47421
47516
|
return {
|
|
@@ -47514,6 +47609,24 @@ var SeverityCountsSchema = exports_Schema.Struct({
|
|
|
47514
47609
|
high: exports_Schema.Int,
|
|
47515
47610
|
critical: exports_Schema.Int
|
|
47516
47611
|
});
|
|
47612
|
+
var ReviewHistoryTokensSchema = exports_Schema.Struct({
|
|
47613
|
+
input: exports_Schema.Int,
|
|
47614
|
+
output: exports_Schema.Int,
|
|
47615
|
+
reasoning: exports_Schema.Int,
|
|
47616
|
+
cacheRead: exports_Schema.Int,
|
|
47617
|
+
cacheWrite: exports_Schema.Int
|
|
47618
|
+
});
|
|
47619
|
+
var ReviewHistoryEntrySchema = exports_Schema.Struct({
|
|
47620
|
+
reviewedCommit: exports_Schema.String,
|
|
47621
|
+
reviewMode: exports_Schema.Literals(["full", "follow-up"]),
|
|
47622
|
+
model: exports_Schema.String,
|
|
47623
|
+
variant: exports_Schema.optionalKey(exports_Schema.String),
|
|
47624
|
+
buildNumber: exports_Schema.optionalKey(exports_Schema.String),
|
|
47625
|
+
buildId: exports_Schema.optionalKey(exports_Schema.String),
|
|
47626
|
+
buildLink: exports_Schema.optionalKey(exports_Schema.String),
|
|
47627
|
+
costUsd: exports_Schema.optionalKey(exports_Schema.Number),
|
|
47628
|
+
tokens: exports_Schema.optionalKey(ReviewHistoryTokensSchema)
|
|
47629
|
+
});
|
|
47517
47630
|
var ManagedReviewStateSchema = exports_Schema.Struct({
|
|
47518
47631
|
schemaVersion: exports_Schema.Int,
|
|
47519
47632
|
reviewedCommit: exports_Schema.String,
|
|
@@ -47522,10 +47635,11 @@ var ManagedReviewStateSchema = exports_Schema.Struct({
|
|
|
47522
47635
|
severityCounts: SeverityCountsSchema,
|
|
47523
47636
|
findingsCount: exports_Schema.Int,
|
|
47524
47637
|
inlineFindingsCount: exports_Schema.Int,
|
|
47525
|
-
unmappedNotesCount: exports_Schema.Int
|
|
47638
|
+
unmappedNotesCount: exports_Schema.Int,
|
|
47639
|
+
reviewHistory: exports_Schema.optionalKey(exports_Schema.Array(ReviewHistoryEntrySchema))
|
|
47526
47640
|
});
|
|
47527
47641
|
var isActiveThreadStatus = (status) => status === 1 || status === "active" || status === "pending";
|
|
47528
|
-
var STATE_SCHEMA_VERSION =
|
|
47642
|
+
var STATE_SCHEMA_VERSION = 2;
|
|
47529
47643
|
var FINDING_MARKER_PREFIX = "<!-- open-azdo:";
|
|
47530
47644
|
var SUMMARY_STATE_PREFIX = "<!-- open-azdo-review:";
|
|
47531
47645
|
var COMMENT_SUFFIX = " -->";
|
|
@@ -47570,7 +47684,8 @@ var fingerprintFinding = (finding) => {
|
|
|
47570
47684
|
var buildManagedReviewState = ({
|
|
47571
47685
|
reviewedCommit,
|
|
47572
47686
|
pullRequestBaseRef,
|
|
47573
|
-
reviewResult
|
|
47687
|
+
reviewResult,
|
|
47688
|
+
reviewHistory
|
|
47574
47689
|
}) => ({
|
|
47575
47690
|
schemaVersion: STATE_SCHEMA_VERSION,
|
|
47576
47691
|
reviewedCommit,
|
|
@@ -47579,8 +47694,56 @@ var buildManagedReviewState = ({
|
|
|
47579
47694
|
severityCounts: countBySeverity(reviewResult.findings),
|
|
47580
47695
|
findingsCount: reviewResult.findings.length,
|
|
47581
47696
|
inlineFindingsCount: reviewResult.inlineFindings?.length ?? 0,
|
|
47582
|
-
unmappedNotesCount: reviewResult.unmappedNotes.length
|
|
47583
|
-
}
|
|
47697
|
+
unmappedNotesCount: reviewResult.unmappedNotes.length,
|
|
47698
|
+
...reviewHistory && reviewHistory.length > 0 ? { reviewHistory: [...reviewHistory] } : {}
|
|
47699
|
+
});
|
|
47700
|
+
var shortCommit = (value3) => value3.slice(0, 12);
|
|
47701
|
+
var formatInteger = (value3) => new Intl.NumberFormat("en-US").format(value3);
|
|
47702
|
+
var formatCostUsd = (value3) => new Intl.NumberFormat("en-US", {
|
|
47703
|
+
style: "currency",
|
|
47704
|
+
currency: "USD",
|
|
47705
|
+
minimumFractionDigits: 4,
|
|
47706
|
+
maximumFractionDigits: 4
|
|
47707
|
+
}).format(value3);
|
|
47708
|
+
var escapeTableCell = (value3) => value3.replaceAll("|", "\\|").replaceAll(`
|
|
47709
|
+
`, "<br>");
|
|
47710
|
+
var formatReviewLabel = (entry) => {
|
|
47711
|
+
const buildLabel = entry.buildNumber ? `Build ${entry.buildNumber}` : entry.buildId ? `Build ${entry.buildId}` : undefined;
|
|
47712
|
+
const commitLabel = shortCommit(entry.reviewedCommit);
|
|
47713
|
+
if (buildLabel && entry.buildLink) {
|
|
47714
|
+
return `[${buildLabel}](${entry.buildLink}) \xB7 ${commitLabel}`;
|
|
47715
|
+
}
|
|
47716
|
+
if (buildLabel) {
|
|
47717
|
+
return `${buildLabel} \xB7 ${commitLabel}`;
|
|
47718
|
+
}
|
|
47719
|
+
return commitLabel;
|
|
47720
|
+
};
|
|
47721
|
+
var formatTokenBreakdown = (tokens) => {
|
|
47722
|
+
if (!tokens) {
|
|
47723
|
+
return "-";
|
|
47724
|
+
}
|
|
47725
|
+
const segments = [`input ${formatInteger(tokens.input)}`, `output ${formatInteger(tokens.output)}`];
|
|
47726
|
+
if (tokens.reasoning > 0) {
|
|
47727
|
+
segments.push(`reasoning ${formatInteger(tokens.reasoning)}`);
|
|
47728
|
+
}
|
|
47729
|
+
if (tokens.cacheRead > 0) {
|
|
47730
|
+
segments.push(`cache read ${formatInteger(tokens.cacheRead)}`);
|
|
47731
|
+
}
|
|
47732
|
+
if (tokens.cacheWrite > 0) {
|
|
47733
|
+
segments.push(`cache write ${formatInteger(tokens.cacheWrite)}`);
|
|
47734
|
+
}
|
|
47735
|
+
return segments.join(", ");
|
|
47736
|
+
};
|
|
47737
|
+
var formatModelLabel = (entry) => entry.variant ? `${entry.model} (${entry.variant})` : entry.model;
|
|
47738
|
+
var appendReviewHistorySection = (lines, reviewHistory) => {
|
|
47739
|
+
if (reviewHistory.length === 0) {
|
|
47740
|
+
return;
|
|
47741
|
+
}
|
|
47742
|
+
lines.push("", "| Review | Mode | Model | Tokens | Cost |", "| --- | --- | --- | --- | --- |");
|
|
47743
|
+
for (const entry of reviewHistory) {
|
|
47744
|
+
lines.push(`| ${escapeTableCell(formatReviewLabel(entry))} | ${escapeTableCell(entry.reviewMode)} | ${escapeTableCell(formatModelLabel(entry))} | ${escapeTableCell(formatTokenBreakdown(entry.tokens))} | ${escapeTableCell(entry.costUsd !== undefined ? formatCostUsd(entry.costUsd) : "-")} |`);
|
|
47745
|
+
}
|
|
47746
|
+
};
|
|
47584
47747
|
var buildSummaryComment = (snapshot) => {
|
|
47585
47748
|
const lines = [
|
|
47586
47749
|
`Verdict: **${snapshot.verdict}**`,
|
|
@@ -47598,6 +47761,7 @@ var buildSummaryComment = (snapshot) => {
|
|
|
47598
47761
|
if (snapshot.buildLink) {
|
|
47599
47762
|
lines.push("", `Build: ${snapshot.buildLink}`);
|
|
47600
47763
|
}
|
|
47764
|
+
appendReviewHistorySection(lines, snapshot.persistedState?.reviewHistory ?? []);
|
|
47601
47765
|
if (snapshot.persistedState) {
|
|
47602
47766
|
lines.push("", encodeManagedReviewState(snapshot.persistedState));
|
|
47603
47767
|
}
|
|
@@ -48019,6 +48183,50 @@ var decodeOpenCodeResult = (rawResult) => parseJsonUnknown(rawResult).pipe(expor
|
|
|
48019
48183
|
}),
|
|
48020
48184
|
onSuccess: (decodedJson) => decodedJson
|
|
48021
48185
|
}));
|
|
48186
|
+
var mapUsageTokens = (usage) => usage?.tokens ? {
|
|
48187
|
+
input: usage.tokens.input,
|
|
48188
|
+
output: usage.tokens.output,
|
|
48189
|
+
reasoning: usage.tokens.reasoning,
|
|
48190
|
+
cacheRead: usage.tokens.cacheRead,
|
|
48191
|
+
cacheWrite: usage.tokens.cacheWrite
|
|
48192
|
+
} : undefined;
|
|
48193
|
+
var buildReviewHistoryEntry = ({
|
|
48194
|
+
reviewedCommit,
|
|
48195
|
+
reviewMode,
|
|
48196
|
+
config,
|
|
48197
|
+
buildLink,
|
|
48198
|
+
usage
|
|
48199
|
+
}) => {
|
|
48200
|
+
const tokens = mapUsageTokens(usage);
|
|
48201
|
+
return {
|
|
48202
|
+
reviewedCommit,
|
|
48203
|
+
reviewMode,
|
|
48204
|
+
model: config.model,
|
|
48205
|
+
...config.opencodeVariant ? { variant: config.opencodeVariant } : {},
|
|
48206
|
+
...config.buildNumber ? { buildNumber: config.buildNumber } : {},
|
|
48207
|
+
...config.buildId ? { buildId: config.buildId } : {},
|
|
48208
|
+
...buildLink ? { buildLink } : {},
|
|
48209
|
+
...usage?.costUsd !== undefined ? { costUsd: usage.costUsd } : {},
|
|
48210
|
+
...tokens ? { tokens } : {}
|
|
48211
|
+
};
|
|
48212
|
+
};
|
|
48213
|
+
var appendReviewHistoryEntry = ({
|
|
48214
|
+
previousSummaryState,
|
|
48215
|
+
reviewedCommit,
|
|
48216
|
+
reviewMode,
|
|
48217
|
+
config,
|
|
48218
|
+
buildLink,
|
|
48219
|
+
usage
|
|
48220
|
+
}) => [
|
|
48221
|
+
...previousSummaryState?.reviewHistory ?? [],
|
|
48222
|
+
buildReviewHistoryEntry({
|
|
48223
|
+
reviewedCommit,
|
|
48224
|
+
reviewMode,
|
|
48225
|
+
config,
|
|
48226
|
+
buildLink,
|
|
48227
|
+
usage
|
|
48228
|
+
})
|
|
48229
|
+
];
|
|
48022
48230
|
var writeReviewWorkflowOutput = (config, output) => {
|
|
48023
48231
|
if (config.json) {
|
|
48024
48232
|
return writeStdout(`${stringifyJson2({
|
|
@@ -48135,7 +48343,7 @@ var runReviewWithResolvedConfig = (config, azureContext, buildLink) => exports_E
|
|
|
48135
48343
|
yield* logInfo2("Built review prompt.", {
|
|
48136
48344
|
promptChars: prompt.length
|
|
48137
48345
|
});
|
|
48138
|
-
const
|
|
48346
|
+
const openCodeResult = yield* openCodeRunner.run({
|
|
48139
48347
|
workspace: config.workspace,
|
|
48140
48348
|
model: config.model,
|
|
48141
48349
|
agent: config.agent,
|
|
@@ -48145,9 +48353,13 @@ var runReviewWithResolvedConfig = (config, azureContext, buildLink) => exports_E
|
|
|
48145
48353
|
inheritedEnv: config.inheritedEnv
|
|
48146
48354
|
});
|
|
48147
48355
|
yield* logInfo2("Received OpenCode response.", {
|
|
48148
|
-
responseChars:
|
|
48356
|
+
responseChars: openCodeResult.response.length,
|
|
48357
|
+
sessionId: openCodeResult.sessionId,
|
|
48358
|
+
costUsd: openCodeResult.usage?.costUsd,
|
|
48359
|
+
inputTokens: openCodeResult.usage?.tokens?.input,
|
|
48360
|
+
outputTokens: openCodeResult.usage?.tokens?.output
|
|
48149
48361
|
});
|
|
48150
|
-
const reviewResult = yield* decodeOpenCodeResult(
|
|
48362
|
+
const reviewResult = yield* decodeOpenCodeResult(openCodeResult.response).pipe(exports_Effect.flatMap((decodedJson) => decodeReviewResult(decodedJson, scopedDiff.changedLinesByFile)));
|
|
48151
48363
|
yield* logInfo2("Decoded review result.", {
|
|
48152
48364
|
reviewMode,
|
|
48153
48365
|
verdict: reviewResult.verdict,
|
|
@@ -48162,10 +48374,19 @@ var runReviewWithResolvedConfig = (config, azureContext, buildLink) => exports_E
|
|
|
48162
48374
|
scopedDeletedLinesByFile: scopedDiff.deletedLinesByFile,
|
|
48163
48375
|
reviewResult
|
|
48164
48376
|
}) : reviewResult;
|
|
48377
|
+
const reviewHistory = appendReviewHistoryEntry({
|
|
48378
|
+
previousSummaryState,
|
|
48379
|
+
reviewedCommit: reviewedSourceCommit,
|
|
48380
|
+
reviewMode,
|
|
48381
|
+
config,
|
|
48382
|
+
buildLink,
|
|
48383
|
+
usage: openCodeResult.usage
|
|
48384
|
+
});
|
|
48165
48385
|
const summaryState = buildManagedReviewState({
|
|
48166
48386
|
reviewedCommit: reviewedSourceCommit,
|
|
48167
48387
|
pullRequestBaseRef: fullPullRequestDiff.baseRef,
|
|
48168
|
-
reviewResult: outstandingReviewResult
|
|
48388
|
+
reviewResult: outstandingReviewResult,
|
|
48389
|
+
reviewHistory
|
|
48169
48390
|
});
|
|
48170
48391
|
const summaryContent = buildSummaryComment({
|
|
48171
48392
|
verdict: summaryState.verdict,
|
|
@@ -48473,7 +48694,7 @@ var reviewCommandConfig = {
|
|
|
48473
48694
|
var reviewCommand = make33("review", reviewCommandConfig).pipe(withDescription3("Review an Azure DevOps pull request with OpenCode."), withHandler((input) => runReviewCommand(input)));
|
|
48474
48695
|
var openAzdoCli = make33("open-azdo").pipe(withDescription3("Secure Azure DevOps pull-request review CLI powered by OpenCode."), withSubcommands([reviewCommand]));
|
|
48475
48696
|
// package.json
|
|
48476
|
-
var version2 = "0.2.
|
|
48697
|
+
var version2 = "0.2.7";
|
|
48477
48698
|
|
|
48478
48699
|
// src/Main.ts
|
|
48479
48700
|
var cliProgram = run3(openAzdoCli, { version: version2 }).pipe(exports_Effect.scoped, exports_Effect.provide(BaseRuntimeLayer));
|
|
@@ -48482,4 +48703,4 @@ var main = () => runMain2(cliProgram, { disableErrorReporting: true });
|
|
|
48482
48703
|
// bin/open-azdo.ts
|
|
48483
48704
|
main();
|
|
48484
48705
|
|
|
48485
|
-
//# debugId=
|
|
48706
|
+
//# debugId=DE545330B8B0705764756E2164756E21
|