gitlab-ai-review 2.5.2 → 2.5.4

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 (3) hide show
  1. package/cli.js +78 -0
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -28,6 +28,84 @@ async function main() {
28
28
  const changes = await sdk.getMergeRequestChanges();
29
29
  console.log(`✅ 共发现 ${changes.length} 个文件变更\n`);
30
30
 
31
+ // 3.1 输出详细的变更列表
32
+ if (changes.length > 0) {
33
+ console.log('📝 变更文件列表:');
34
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
35
+
36
+ changes.forEach((change, index) => {
37
+ const fileName = change.new_path || change.old_path;
38
+ let status = '';
39
+ let statusIcon = '';
40
+
41
+ // 判断文件状态
42
+ if (change.new_file) {
43
+ status = '新增';
44
+ statusIcon = '✨';
45
+ } else if (change.deleted_file) {
46
+ status = '删除';
47
+ statusIcon = '🗑️';
48
+ } else if (change.renamed_file) {
49
+ status = '重命名';
50
+ statusIcon = '📝';
51
+ } else {
52
+ status = '修改';
53
+ statusIcon = '✏️';
54
+ }
55
+
56
+ // 计算变更行数
57
+ const diff = change.diff || '';
58
+ const addedLines = (diff.match(/^\+[^+]/gm) || []).length;
59
+ const deletedLines = (diff.match(/^-[^-]/gm) || []).length;
60
+
61
+ console.log(`${index + 1}. ${statusIcon} ${status} - ${fileName}`);
62
+ if (addedLines > 0 || deletedLines > 0) {
63
+ console.log(` 📊 +${addedLines} -${deletedLines} 行`);
64
+ }
65
+
66
+ // 如果是重命名,显示旧路径
67
+ if (change.renamed_file && change.old_path !== change.new_path) {
68
+ console.log(` 📂 ${change.old_path} → ${change.new_path}`);
69
+ }
70
+
71
+ // 输出具体的 diff 内容
72
+ if (diff) {
73
+ console.log(`\n 📄 Diff 内容:`);
74
+ console.log(' ┌─────────────────────────────────────────────────────');
75
+
76
+ // 分行显示 diff,并添加颜色标记
77
+ const diffLines = diff.split('\n');
78
+ diffLines.forEach((line, lineIndex) => {
79
+ // 限制显示最多 100 行 diff
80
+ if (lineIndex >= 100) {
81
+ if (lineIndex === 100) {
82
+ console.log(' │ ... (diff 内容过长,已截断)');
83
+ }
84
+ return;
85
+ }
86
+
87
+ // 为不同类型的行添加标记
88
+ let prefix = ' │ ';
89
+ if (line.startsWith('+++') || line.startsWith('---')) {
90
+ prefix = ' │ 📁 '; // 文件路径
91
+ } else if (line.startsWith('@@')) {
92
+ prefix = ' │ 🔵 '; // hunk 标记
93
+ } else if (line.startsWith('+') && !line.startsWith('+++')) {
94
+ prefix = ' │ ➕ '; // 新增行
95
+ } else if (line.startsWith('-') && !line.startsWith('---')) {
96
+ prefix = ' │ ➖ '; // 删除行
97
+ }
98
+
99
+ console.log(prefix + line);
100
+ });
101
+
102
+ console.log(' └─────────────────────────────────────────────────────\n');
103
+ }
104
+ });
105
+
106
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
107
+ }
108
+
31
109
  // 4. 执行 AI 代码审查
32
110
  if (sdk.config.ai?.arkApiKey && changes.length > 0) {
33
111
  console.log('🤖 开始 AI 代码审查...\n');
package/index.js CHANGED
@@ -15,7 +15,7 @@ import * as DiffParser from './lib/diff-parser.js';
15
15
  export class GitLabAIReview {
16
16
  constructor(options = {}) {
17
17
  this.name = 'GitLab AI Review SDK';
18
- this.version = '2.5.2';
18
+ this.version = '2.5.4';
19
19
 
20
20
  // 如果传入了配置,使用手动配置;否则使用自动检测
21
21
  if (options.token || options.gitlab) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-ai-review",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "GitLab AI Review SDK - 支持 SDK 调用和 CLI 执行",
5
5
  "main": "index.js",
6
6
  "type": "module",