job51-gitlab-cr-node-jt-1 3.0.0 → 3.0.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 +26 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -144,7 +144,22 @@ class GitLabCodeReviewer {
144
144
  const blockStartTime = Date.now();
145
145
  const blockIdentifier = `${diffObject.new_path || diffObject.old_path}#large-file`;
146
146
  const review_result = await this.reviewDiffWithClaudeUsingFile(tmpFileName, blockIdentifier, true);
147
- const blockObj = { ...diffObject, review_result, temp_file_path: tmpFileName, is_large_file: true };
147
+
148
+ // 对于大文件,设置完整的行号范围信息(使用文件总行数)
149
+ const fileLineCount = fileContent.split('\n').length;
150
+ const blockObj = {
151
+ ...diffObject,
152
+ review_result,
153
+ temp_file_path: tmpFileName,
154
+ is_large_file: true,
155
+ // 设置行号范围信息,让行级评论验证能够通过
156
+ line_info: {
157
+ old_start: diffObject.new_file ? 0 : 1,
158
+ old_count: diffObject.new_file ? 0 : fileLineCount,
159
+ new_start: 1,
160
+ new_count: fileLineCount
161
+ }
162
+ };
148
163
 
149
164
  // 记录审查指标
150
165
  const reviewTime = Date.now() - blockStartTime;
@@ -156,11 +171,16 @@ class GitLabCodeReviewer {
156
171
 
157
172
  // 检查审查结果中是否包含严重问题
158
173
  if (blockObj.review_result && blockObj.review_result.reportContent && blockObj.review_result.reportContent.includes('严重问题')) {
159
- // 对于大文件,发布为一般讨论(无法精确定位行号)
160
- const file_path_with_line = `${diffObject.new_path || diffObject.old_path}#L1`;
161
- await this.createGeneralDiscussion(projectId, mergeRequestIid, file_path_with_line, blockObj.review_result.reportContent);
162
- debugLog(`大文件审查结果已发布为一般讨论: ${file_path_with_line}`);
163
- this.metrics.recordCommentPublished();
174
+ // 尝试发布行级评论(大文件现在也有 line_info,可以验证行号)
175
+ const commentResult = await this.postSingleCommentToGitLab(projectId, mergeRequestIid, {
176
+ diff_info: blockObj,
177
+ block_index: blockIndex,
178
+ review_result: blockObj.review_result,
179
+ });
180
+ if (commentResult && commentResult.hallucination_detected) {
181
+ hallucinationDetected = true;
182
+ }
183
+ debugLog(`大文件审查结果已尝试发布行级评论: ${diffObject.new_path || diffObject.old_path}`);
164
184
  } else {
165
185
  debugLog(`大文件审查未发现严重问题: ${diffObject.new_path || diffObject.old_path}`);
166
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "job51-gitlab-cr-node-jt-1",
3
- "version": "3.0.0",
3
+ "version": "3.0.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": {