job51-gitlab-cr-node-jt-1 2.9.0 → 2.9.1

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.
Files changed (2) hide show
  1. package/index.js +12 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -201,9 +201,13 @@ class GitLabCodeReviewer {
201
201
  collectAllReviewReports(results) {
202
202
  let allReportsText = '';
203
203
 
204
- // 遍历所有审查结果
205
- for (let i = 0; i < results.length; i++) {
206
- const result = results[i];
204
+ // 遍历所有审查结果,过滤掉检测到幻觉的结果
205
+ const validResults = results.filter(result => !result.hallucination_detected);
206
+
207
+ debugLog(`汇总报告过滤:总共 ${results.length} 个结果,过滤掉 ${results.length - validResults.length} 个幻觉检测结果,保留 ${validResults.length} 个有效结果`);
208
+
209
+ for (let i = 0; i < validResults.length; i++) {
210
+ const result = validResults[i];
207
211
  const filePath = result.diff_info.new_path || result.diff_info.old_path;
208
212
  const blockIndex = result.block_index;
209
213
  const reportContent = result.review_result?.reportContent || '';
@@ -860,6 +864,8 @@ ${allReportsText}
860
864
  if (problemInfo.new_path && diff_info.new_path &&
861
865
  problemInfo.new_path !== diff_info.new_path) {
862
866
  console.warn(`⚠️ 检测到AI幻觉:第 ${i + 1} 个问题的文件路径 ${problemInfo.new_path} 与当前 diff 块文件 ${diff_info.new_path} 不匹配,跳过该问题的评论发布`);
867
+ // 标记该结果存在幻觉问题,后续生成汇总报告时会过滤掉
868
+ result.hallucination_detected = true;
863
869
  continue; // 直接跳过,不发布评论
864
870
  }
865
871
 
@@ -903,11 +909,9 @@ ${allReportsText}
903
909
  }
904
910
 
905
911
  if (!targetLine) {
906
- // 无法解析行号或行号超出范围,使用一般讨论
907
- debugLog(`第 ${i + 1} 个问题 ${skipReason || '无法解析行号'},发布为一般讨论`);
908
- await this.createGeneralDiscussion(projectId, mergeRequestIid, file_path_with_line, singleProblemContent);
909
- debugLog(`第 ${i + 1} 个问题的评论已发布 (作为一般讨论)`);
910
- this.metrics.recordCommentPublished();
912
+ // 无法解析行号或行号超出范围,标记为幻觉问题,跳过发布
913
+ console.warn(`⚠️ 检测到AI幻觉:第 ${i + 1} 个问题 ${skipReason || '无法解析行号'},该问题可能报告在上下文行或删除行,跳过发布`);
914
+ result.hallucination_detected = true;
911
915
  continue;
912
916
  }
913
917
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "job51-gitlab-cr-node-jt-1",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "GitLab merge request code review tool with AI-powered analysis and project context support",
5
5
  "main": "index.js",
6
6
  "bin": {