@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.
@@ -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.create(request);
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
- const findings = await runFileReviewWithTools({
739
- openaiInstance,
740
- aiModel,
741
- filePath: change.new_path,
742
- fileDiff: change.diff,
743
- summary: triageResult.summary,
744
- otherChangedFiles: otherFiles,
745
- refs,
746
- gitLabProjectApiUrl,
747
- projectId,
748
- headers,
749
- forceTools,
750
- promptProfile,
751
- loggers,
752
- debugDumpFile,
753
- debugRecordWriter,
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,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@krotovm/gitlab-ai-review",
4
- "version": "1.0.34",
4
+ "version": "1.0.35",
5
5
  "description": "CLI tool to generate AI code reviews for GitLab merge requests.",
6
6
  "main": "dist/cli.js",
7
7
  "bin": {