@krotovm/gitlab-ai-review 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/ci-review.js +40 -18
- package/package.json +1 -1
package/dist/cli/ci-review.js
CHANGED
|
@@ -61,8 +61,13 @@ async function createCompletionWithDebug(params) {
|
|
|
61
61
|
label: requestLabel,
|
|
62
62
|
request,
|
|
63
63
|
});
|
|
64
|
+
// Stream and reassemble: reverse proxies (nginx proxy_read_timeout) return 504 on
|
|
65
|
+
// long silent non-streamed completions; streamed chunks keep the connection alive.
|
|
66
|
+
const { stream: _stream, ...createParams } = request;
|
|
64
67
|
try {
|
|
65
|
-
const completion = await openaiInstance.chat.completions
|
|
68
|
+
const completion = await openaiInstance.chat.completions
|
|
69
|
+
.stream(createParams)
|
|
70
|
+
.finalChatCompletion();
|
|
66
71
|
await appendDebugDump(debugDumpFile, debugRecordWriter, {
|
|
67
72
|
kind: "openai_response",
|
|
68
73
|
label: requestLabel,
|
|
@@ -733,27 +738,44 @@ export async function reviewMergeRequestMultiPass(params) {
|
|
|
733
738
|
}
|
|
734
739
|
logStep(`Pass 2/4: reviewing ${reviewFiles.length} file(s) (concurrency=${reviewConcurrency})`);
|
|
735
740
|
const allChangedPaths = changes.map((c) => c.new_path);
|
|
741
|
+
const failedPaths = [];
|
|
736
742
|
const perFileFindings = await mapWithConcurrency(reviewFiles, reviewConcurrency, async (change) => {
|
|
737
743
|
const otherFiles = allChangedPaths.filter((p) => p !== change.new_path);
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
744
|
+
let findings;
|
|
745
|
+
try {
|
|
746
|
+
findings = await runFileReviewWithTools({
|
|
747
|
+
openaiInstance,
|
|
748
|
+
aiModel,
|
|
749
|
+
filePath: change.new_path,
|
|
750
|
+
fileDiff: change.diff,
|
|
751
|
+
summary: triageResult.summary,
|
|
752
|
+
otherChangedFiles: otherFiles,
|
|
753
|
+
refs,
|
|
754
|
+
gitLabProjectApiUrl,
|
|
755
|
+
projectId,
|
|
756
|
+
headers,
|
|
757
|
+
forceTools,
|
|
758
|
+
promptProfile,
|
|
759
|
+
loggers,
|
|
760
|
+
debugDumpFile,
|
|
761
|
+
debugRecordWriter,
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
catch (error) {
|
|
765
|
+
const preview = String(error?.message ?? error)
|
|
766
|
+
.replace(/\s+/g, " ")
|
|
767
|
+
.slice(0, 200);
|
|
768
|
+
logStep(`Pass 2: review failed for ${change.new_path}: ${preview}. Continuing with remaining files.`);
|
|
769
|
+
failedPaths.push(change.new_path);
|
|
770
|
+
// ponytail: failed file surfaces as "no findings" in the MR comment;
|
|
771
|
+
// thread failedPaths into the consolidate prompt if that ever matters.
|
|
772
|
+
findings = NO_FINDINGS_SENTENCE;
|
|
773
|
+
}
|
|
755
774
|
return { path: change.new_path, findings };
|
|
756
775
|
});
|
|
776
|
+
if (failedPaths.length === reviewFiles.length) {
|
|
777
|
+
throw new Error(`All ${reviewFiles.length} per-file reviews failed (e.g. ${failedPaths[0]}). See log above.`);
|
|
778
|
+
}
|
|
757
779
|
logStep("Pass 3/4: consolidating findings");
|
|
758
780
|
const consolidateMessages = buildConsolidatePrompt({
|
|
759
781
|
perFileFindings,
|