gitlab-auto-reviewers 2.0.0 → 2.1.0

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 (98) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +20 -10
  3. package/dist/bin/cli.js +155 -85
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/bin/index.d.ts +1 -8
  6. package/dist/bin/index.d.ts.map +1 -1
  7. package/dist/bin/index.js +26 -9
  8. package/dist/bin/index.js.map +1 -1
  9. package/dist/bin/mcp.js +0 -0
  10. package/dist/cli/cicd-integration.d.ts +127 -0
  11. package/dist/cli/cicd-integration.d.ts.map +1 -0
  12. package/dist/cli/cicd-integration.js +385 -0
  13. package/dist/cli/cicd-integration.js.map +1 -0
  14. package/dist/cli/commands.d.ts +21 -4
  15. package/dist/cli/commands.d.ts.map +1 -1
  16. package/dist/cli/commands.js +417 -71
  17. package/dist/cli/commands.js.map +1 -1
  18. package/dist/cli/config.d.ts +145 -0
  19. package/dist/cli/config.d.ts.map +1 -0
  20. package/dist/cli/config.js +277 -0
  21. package/dist/cli/config.js.map +1 -0
  22. package/dist/cli/consistency-validator.d.ts +175 -0
  23. package/dist/cli/consistency-validator.d.ts.map +1 -0
  24. package/dist/cli/consistency-validator.js +599 -0
  25. package/dist/cli/consistency-validator.js.map +1 -0
  26. package/dist/cli/data-source-consistency.d.ts +105 -0
  27. package/dist/cli/data-source-consistency.d.ts.map +1 -0
  28. package/dist/cli/data-source-consistency.js +271 -0
  29. package/dist/cli/data-source-consistency.js.map +1 -0
  30. package/dist/cli/data-source-selector.d.ts +103 -0
  31. package/dist/cli/data-source-selector.d.ts.map +1 -0
  32. package/dist/cli/data-source-selector.js +242 -0
  33. package/dist/cli/data-source-selector.js.map +1 -0
  34. package/dist/cli/enhanced-cli.d.ts +104 -0
  35. package/dist/cli/enhanced-cli.d.ts.map +1 -0
  36. package/dist/cli/enhanced-cli.js +321 -0
  37. package/dist/cli/enhanced-cli.js.map +1 -0
  38. package/dist/cli/enhanced-data-source-resolver.d.ts +67 -0
  39. package/dist/cli/enhanced-data-source-resolver.d.ts.map +1 -0
  40. package/dist/cli/enhanced-data-source-resolver.js +249 -0
  41. package/dist/cli/enhanced-data-source-resolver.js.map +1 -0
  42. package/dist/cli/enhanced-parameter-resolver.d.ts +111 -0
  43. package/dist/cli/enhanced-parameter-resolver.d.ts.map +1 -0
  44. package/dist/cli/enhanced-parameter-resolver.js +233 -0
  45. package/dist/cli/enhanced-parameter-resolver.js.map +1 -0
  46. package/dist/cli/errors.d.ts +105 -0
  47. package/dist/cli/errors.d.ts.map +1 -0
  48. package/dist/cli/errors.js +577 -0
  49. package/dist/cli/errors.js.map +1 -0
  50. package/dist/cli/output.d.ts +43 -3
  51. package/dist/cli/output.d.ts.map +1 -1
  52. package/dist/cli/output.js +157 -30
  53. package/dist/cli/output.js.map +1 -1
  54. package/dist/cli/parameter-source-tracker.d.ts +169 -0
  55. package/dist/cli/parameter-source-tracker.d.ts.map +1 -0
  56. package/dist/cli/parameter-source-tracker.js +252 -0
  57. package/dist/cli/parameter-source-tracker.js.map +1 -0
  58. package/dist/cli/template-engine.d.ts +109 -0
  59. package/dist/cli/template-engine.d.ts.map +1 -0
  60. package/dist/cli/template-engine.js +220 -0
  61. package/dist/cli/template-engine.js.map +1 -0
  62. package/dist/config/config.service.d.ts +24 -2
  63. package/dist/config/config.service.d.ts.map +1 -1
  64. package/dist/config/config.service.js +39 -6
  65. package/dist/config/config.service.js.map +1 -1
  66. package/dist/datasources/local-git-data-source.d.ts +39 -0
  67. package/dist/datasources/local-git-data-source.d.ts.map +1 -1
  68. package/dist/datasources/local-git-data-source.js +121 -1
  69. package/dist/datasources/local-git-data-source.js.map +1 -1
  70. package/dist/enhanced-config.js +26 -0
  71. package/dist/index.js +0 -0
  72. package/dist/mcp/server.js +2 -2
  73. package/dist/mcp/server.js.map +1 -1
  74. package/dist/services/blacklist.service.d.ts +11 -5
  75. package/dist/services/blacklist.service.d.ts.map +1 -1
  76. package/dist/services/blacklist.service.js +28 -7
  77. package/dist/services/blacklist.service.js.map +1 -1
  78. package/dist/services/reviewer-service.d.ts +24 -0
  79. package/dist/services/reviewer-service.d.ts.map +1 -1
  80. package/dist/services/reviewer-service.js +177 -7
  81. package/dist/services/reviewer-service.js.map +1 -1
  82. package/dist/services/whitelist.service.js +1 -1
  83. package/dist/services/whitelist.service.js.map +1 -1
  84. package/dist/types/enhanced-config.d.ts +121 -0
  85. package/dist/types/enhanced-config.d.ts.map +1 -0
  86. package/dist/types/enhanced-config.js +27 -0
  87. package/dist/types/enhanced-config.js.map +1 -0
  88. package/dist/types.d.ts +28 -0
  89. package/dist/types.d.ts.map +1 -1
  90. package/package.json +11 -11
  91. package/dist/bin/deprecated-mcp.d.ts +0 -12
  92. package/dist/bin/deprecated-mcp.d.ts.map +0 -1
  93. package/dist/bin/deprecated-mcp.js +0 -73
  94. package/dist/bin/deprecated-mcp.js.map +0 -1
  95. package/dist/tools.d.ts +0 -22
  96. package/dist/tools.d.ts.map +0 -1
  97. package/dist/tools.js +0 -176
  98. package/dist/tools.js.map +0 -1
@@ -0,0 +1,577 @@
1
+ /**
2
+ * CLI Error Handling
3
+ *
4
+ * Provides comprehensive error handling and validation for CLI operations.
5
+ * Includes specific error types, validation functions, and user-friendly error messages.
6
+ *
7
+ * @module cli/errors
8
+ */
9
+ import { MCPError, ErrorCategory } from '../errors/error-handler.js';
10
+ /**
11
+ * CLI-specific error codes
12
+ */
13
+ export var CLIErrorCode;
14
+ (function (CLIErrorCode) {
15
+ CLIErrorCode[CLIErrorCode["SUCCESS"] = 0] = "SUCCESS";
16
+ CLIErrorCode[CLIErrorCode["VALIDATION_ERROR"] = 1] = "VALIDATION_ERROR";
17
+ CLIErrorCode[CLIErrorCode["AUTHENTICATION_ERROR"] = 2] = "AUTHENTICATION_ERROR";
18
+ CLIErrorCode[CLIErrorCode["NETWORK_ERROR"] = 3] = "NETWORK_ERROR";
19
+ CLIErrorCode[CLIErrorCode["API_ERROR"] = 4] = "API_ERROR";
20
+ CLIErrorCode[CLIErrorCode["PERMISSION_ERROR"] = 5] = "PERMISSION_ERROR";
21
+ CLIErrorCode[CLIErrorCode["CONFIGURATION_ERROR"] = 6] = "CONFIGURATION_ERROR";
22
+ CLIErrorCode[CLIErrorCode["TEMPLATE_ERROR"] = 7] = "TEMPLATE_ERROR";
23
+ CLIErrorCode[CLIErrorCode["RATE_LIMITED"] = 8] = "RATE_LIMITED";
24
+ CLIErrorCode[CLIErrorCode["NOT_FOUND"] = 9] = "NOT_FOUND";
25
+ CLIErrorCode[CLIErrorCode["UNKNOWN_ERROR"] = 99] = "UNKNOWN_ERROR";
26
+ })(CLIErrorCode || (CLIErrorCode = {}));
27
+ /**
28
+ * CLI Error class with specific error codes and user guidance
29
+ */
30
+ export class CLIError extends MCPError {
31
+ exitCode;
32
+ userGuidance;
33
+ /**
34
+ * Creates a new CLI error with specific exit code and user guidance
35
+ *
36
+ * @param message - The error message
37
+ * @param exitCode - CLI exit code for this error
38
+ * @param userGuidance - Optional user guidance for resolving the error
39
+ * @param details - Optional additional error details
40
+ * @param cause - Optional underlying error that caused this error
41
+ */
42
+ constructor(message, exitCode, userGuidance, details, cause) {
43
+ super(message, ErrorCategory.VALIDATION, details, cause);
44
+ this.exitCode = exitCode;
45
+ this.userGuidance = userGuidance;
46
+ this.name = 'CLIError';
47
+ }
48
+ /**
49
+ * Get formatted error message with guidance
50
+ */
51
+ getFormattedMessage() {
52
+ const parts = [this.message];
53
+ if (this.userGuidance) {
54
+ parts.push('');
55
+ parts.push('Suggested action:');
56
+ parts.push(this.userGuidance);
57
+ }
58
+ return parts.join('\n');
59
+ }
60
+ }
61
+ /**
62
+ * Parameter validation functions
63
+ */
64
+ export class ParameterValidator {
65
+ /**
66
+ * Validate repository path
67
+ */
68
+ static validateRepositoryPath(repoPath) {
69
+ if (!repoPath || repoPath.trim().length === 0) {
70
+ throw new CLIError('Repository path is required', CLIErrorCode.VALIDATION_ERROR, 'Use --repo-path to specify the path to your git repository', { providedPath: repoPath });
71
+ }
72
+ const trimmedPath = repoPath.trim();
73
+ // Basic path validation
74
+ if (trimmedPath.includes('\0')) {
75
+ throw new CLIError('Repository path contains invalid characters', CLIErrorCode.VALIDATION_ERROR, 'Ensure the path does not contain null characters', { providedPath: repoPath });
76
+ }
77
+ return trimmedPath;
78
+ }
79
+ /**
80
+ * Validate merge request IID
81
+ */
82
+ static validateMergeRequestIid(mrIid) {
83
+ if (mrIid === undefined) {
84
+ return undefined;
85
+ }
86
+ if (!Number.isInteger(mrIid) || mrIid <= 0) {
87
+ throw new CLIError('Merge request IID must be a positive integer', CLIErrorCode.VALIDATION_ERROR, 'Use --mr followed by a positive number (e.g., --mr 123)', { providedValue: mrIid });
88
+ }
89
+ if (mrIid > 2147483647) { // Max 32-bit signed integer
90
+ throw new CLIError('Merge request IID is too large', CLIErrorCode.VALIDATION_ERROR, 'Use a smaller merge request IID number', { providedValue: mrIid });
91
+ }
92
+ return mrIid;
93
+ }
94
+ /**
95
+ * Validate branch name
96
+ */
97
+ static validateBranchName(branch) {
98
+ if (branch === undefined) {
99
+ return undefined;
100
+ }
101
+ const trimmedBranch = branch.trim();
102
+ if (trimmedBranch.length === 0) {
103
+ throw new CLIError('Branch name cannot be empty', CLIErrorCode.VALIDATION_ERROR, 'Use --branch followed by a valid branch name (e.g., --branch feature/my-feature)', { providedValue: branch });
104
+ }
105
+ // Git branch name validation rules
106
+ const invalidPatterns = [
107
+ /^\./, // Cannot start with dot
108
+ /\.$/, // Cannot end with dot
109
+ /\.\./, // Cannot contain double dots
110
+ /\s/, // Cannot contain spaces
111
+ /[\x00-\x1f\x7f]/, // Cannot contain control characters
112
+ /[~^:?*\[]/, // Cannot contain special characters
113
+ /\/$/, // Cannot end with slash
114
+ /\/\//, // Cannot contain double slashes
115
+ ];
116
+ for (const pattern of invalidPatterns) {
117
+ if (pattern.test(trimmedBranch)) {
118
+ throw new CLIError('Branch name contains invalid characters or format', CLIErrorCode.VALIDATION_ERROR, 'Use a valid git branch name (letters, numbers, hyphens, underscores, and forward slashes)', { providedValue: branch, pattern: pattern.toString() });
119
+ }
120
+ }
121
+ if (trimmedBranch.length > 250) {
122
+ throw new CLIError('Branch name is too long', CLIErrorCode.VALIDATION_ERROR, 'Use a shorter branch name (maximum 250 characters)', { providedValue: branch, length: trimmedBranch.length });
123
+ }
124
+ return trimmedBranch;
125
+ }
126
+ /**
127
+ * Validate GitLab URL
128
+ */
129
+ static validateGitLabUrl(url) {
130
+ if (!url) {
131
+ return undefined;
132
+ }
133
+ const trimmedUrl = url.trim();
134
+ if (trimmedUrl.length === 0) {
135
+ return undefined;
136
+ }
137
+ try {
138
+ const parsedUrl = new URL(trimmedUrl);
139
+ if (!['http:', 'https:'].includes(parsedUrl.protocol)) {
140
+ throw new CLIError('GitLab URL must use HTTP or HTTPS protocol', CLIErrorCode.VALIDATION_ERROR, 'Use a URL starting with http:// or https:// (e.g., https://gitlab.com)', { providedUrl: url, protocol: parsedUrl.protocol });
141
+ }
142
+ if (!parsedUrl.hostname) {
143
+ throw new CLIError('GitLab URL must include a hostname', CLIErrorCode.VALIDATION_ERROR, 'Use a complete URL with hostname (e.g., https://gitlab.example.com)', { providedUrl: url });
144
+ }
145
+ return trimmedUrl;
146
+ }
147
+ catch (error) {
148
+ if (error instanceof CLIError) {
149
+ throw error;
150
+ }
151
+ throw new CLIError('GitLab URL is not valid', CLIErrorCode.VALIDATION_ERROR, 'Use a valid URL format (e.g., https://gitlab.com or https://gitlab.example.com)', { providedUrl: url, parseError: error instanceof Error ? error.message : String(error) });
152
+ }
153
+ }
154
+ /**
155
+ * Validate GitLab token
156
+ */
157
+ static validateGitLabToken(token) {
158
+ if (!token) {
159
+ return undefined;
160
+ }
161
+ const trimmedToken = token.trim();
162
+ if (trimmedToken.length === 0) {
163
+ return undefined;
164
+ }
165
+ if (trimmedToken.length < 10) {
166
+ throw new CLIError('GitLab token appears to be too short', CLIErrorCode.VALIDATION_ERROR, 'Generate a new personal access token at your GitLab instance: Settings → Access Tokens', { tokenLength: trimmedToken.length });
167
+ }
168
+ if (trimmedToken.length > 100) {
169
+ throw new CLIError('GitLab token appears to be too long', CLIErrorCode.VALIDATION_ERROR, 'Verify the token is correct and does not include extra characters', { tokenLength: trimmedToken.length });
170
+ }
171
+ // Check for common token format patterns
172
+ const validTokenPatterns = [
173
+ /^glpat-/, // GitLab personal access token
174
+ /^gldt-/, // GitLab deploy token
175
+ /^[a-zA-Z0-9_-]+$/, // General alphanumeric with hyphens/underscores
176
+ ];
177
+ const hasValidPattern = validTokenPatterns.some(pattern => pattern.test(trimmedToken));
178
+ if (!hasValidPattern) {
179
+ throw new CLIError('GitLab token format appears invalid', CLIErrorCode.VALIDATION_ERROR, 'Verify the token is copied correctly from GitLab (should contain only letters, numbers, hyphens, and underscores)', { tokenPrefix: trimmedToken.substring(0, 10) + '...' });
180
+ }
181
+ return trimmedToken;
182
+ }
183
+ /**
184
+ * Validate output format
185
+ */
186
+ static validateFormat(format) {
187
+ if (!format) {
188
+ return undefined;
189
+ }
190
+ const trimmedFormat = format.trim().toLowerCase();
191
+ if (trimmedFormat === 'json' || trimmedFormat === 'text') {
192
+ return trimmedFormat;
193
+ }
194
+ throw new CLIError(`Invalid output format: ${format}`, CLIErrorCode.VALIDATION_ERROR, 'Use --format json or --format text', { providedFormat: format, validFormats: ['json', 'text'] });
195
+ }
196
+ /**
197
+ * Validate that either MR IID or branch is provided
198
+ */
199
+ static validateMergeRequestIdentifier(mergeRequestIid, branch) {
200
+ if (!mergeRequestIid && !branch) {
201
+ throw new CLIError('Either merge request IID or branch name must be provided', CLIErrorCode.VALIDATION_ERROR, 'Use --mr <number> to specify a merge request IID, or --branch <name> to specify a branch name', { mergeRequestIid, branch });
202
+ }
203
+ if (mergeRequestIid && branch) {
204
+ throw new CLIError('Cannot specify both merge request IID and branch name', CLIErrorCode.VALIDATION_ERROR, 'Use either --mr <number> OR --branch <name>, not both', { mergeRequestIid, branch });
205
+ }
206
+ }
207
+ /**
208
+ * Validate conflicting options
209
+ */
210
+ static validateConflictingOptions(verbose, quiet) {
211
+ if (verbose && quiet) {
212
+ throw new CLIError('Cannot use both --verbose and --quiet options', CLIErrorCode.VALIDATION_ERROR, 'Use either --verbose for detailed output OR --quiet for minimal output, not both', { verbose, quiet });
213
+ }
214
+ }
215
+ }
216
+ /**
217
+ * Error detection and classification functions
218
+ */
219
+ export class ErrorClassifier {
220
+ /**
221
+ * Classify an error and return appropriate CLI error code
222
+ */
223
+ static classifyError(error) {
224
+ const message = error.message.toLowerCase();
225
+ // Authentication errors
226
+ if (message.includes('401') || message.includes('unauthorized') ||
227
+ message.includes('invalid token') || message.includes('authentication failed')) {
228
+ return CLIErrorCode.AUTHENTICATION_ERROR;
229
+ }
230
+ // Permission errors
231
+ if (message.includes('403') || message.includes('forbidden') ||
232
+ message.includes('permission denied') || message.includes('access denied')) {
233
+ return CLIErrorCode.PERMISSION_ERROR;
234
+ }
235
+ // Rate limiting
236
+ if (message.includes('429') || message.includes('rate limit') ||
237
+ message.includes('too many requests')) {
238
+ return CLIErrorCode.RATE_LIMITED;
239
+ }
240
+ // Network errors
241
+ if (message.includes('econnrefused') || message.includes('econnreset') ||
242
+ message.includes('etimedout') || message.includes('enotfound') ||
243
+ message.includes('network error') || message.includes('fetch failed') ||
244
+ message.includes('socket hang up')) {
245
+ return CLIErrorCode.NETWORK_ERROR;
246
+ }
247
+ // Configuration errors (check before generic "not found")
248
+ if (message.includes('config') || message.includes('template') ||
249
+ message.includes('invalid format')) {
250
+ return CLIErrorCode.CONFIGURATION_ERROR;
251
+ }
252
+ // Not found errors
253
+ if (message.includes('404') || message.includes('not found') ||
254
+ message.includes('does not exist')) {
255
+ return CLIErrorCode.NOT_FOUND;
256
+ }
257
+ // API errors
258
+ if (message.includes('api') || message.includes('http') ||
259
+ message.includes('500') || message.includes('502') ||
260
+ message.includes('503') || message.includes('504')) {
261
+ return CLIErrorCode.API_ERROR;
262
+ }
263
+ return CLIErrorCode.UNKNOWN_ERROR;
264
+ }
265
+ /**
266
+ * Get user-friendly error message with guidance
267
+ */
268
+ static getErrorGuidance(_error, errorCode) {
269
+ switch (errorCode) {
270
+ case CLIErrorCode.AUTHENTICATION_ERROR:
271
+ return `🔐 Authentication failed. Here's how to fix it:
272
+
273
+ QUICK FIX:
274
+ export GITLAB_TOKEN=your-token-here
275
+ gitlab-auto-reviewers cli --repo-path . --mr 123
276
+
277
+ DETAILED STEPS:
278
+ 1. 🎫 Generate a new personal access token:
279
+ • Go to your GitLab instance → Settings → Access Tokens
280
+ • Name: "Auto Reviewers CLI"
281
+ • Scopes: ✅ api (required for posting comments)
282
+ • Expiration: Set appropriate date
283
+
284
+ 2. 🔧 Set the token:
285
+ • Option A: export GITLAB_TOKEN=glpat-your-token-here
286
+ • Option B: gitlab-auto-reviewers cli --gitlab-token glpat-your-token-here ...
287
+
288
+ 3. ✅ Verify GitLab URL is correct:
289
+ • Default: https://gitlab.com
290
+ • Custom: --gitlab-url https://your-gitlab.com
291
+
292
+ TROUBLESHOOTING:
293
+ • Token expired? Generate a new one
294
+ • Wrong GitLab instance? Check --gitlab-url
295
+ • Still failing? Use --verbose for details`;
296
+ case CLIErrorCode.PERMISSION_ERROR:
297
+ return `🚫 Permission denied. Here's how to fix it:
298
+
299
+ QUICK CHECK:
300
+ • Do you have Developer+ access to the project?
301
+ • Does your token have 'api' scope?
302
+
303
+ DETAILED STEPS:
304
+ 1. 👤 Check project access:
305
+ • Go to the project in GitLab
306
+ • Check if you can view merge requests
307
+ • Verify you have at least Developer role
308
+
309
+ 2. 🔑 Check token permissions:
310
+ • Token must have 'api' scope (not just 'read_api')
311
+ • Token must not be expired
312
+ • Token owner must have project access
313
+
314
+ 3. 🎯 Verify project exists:
315
+ • Project ID/path is correct
316
+ • Project is not private (unless you have access)
317
+ • Merge request exists and is accessible
318
+
319
+ COMMON FIXES:
320
+ • Regenerate token with 'api' scope
321
+ • Ask project maintainer for Developer access
322
+ • Double-check project ID/path spelling`;
323
+ case CLIErrorCode.RATE_LIMITED:
324
+ return `⏱️ GitLab API rate limit exceeded. Here's what to do:
325
+
326
+ IMMEDIATE ACTIONS:
327
+ 1. ⏳ Wait before retrying (usually 1-10 minutes)
328
+ 2. 🔍 Use --dry-run to test without API calls:
329
+ gitlab-auto-reviewers cli --repo-path . --mr 123 --dry-run
330
+
331
+ RATE LIMIT INFO:
332
+ • GitLab.com: 2000 requests/hour per user
333
+ • Self-hosted: Varies by configuration
334
+ • Comment posting uses ~5-10 API calls per MR
335
+
336
+ OPTIMIZATION TIPS:
337
+ • Use --repo-path for faster local analysis
338
+ • Enable caching: export CACHE_ENABLED=true
339
+ • Use --dry-run to test without API calls
340
+ • Use different token if available
341
+
342
+ MONITORING:
343
+ • Use --verbose to see API call counts
344
+ • Check GitLab → Settings → Applications → Rate Limits`;
345
+ case CLIErrorCode.NETWORK_ERROR:
346
+ return `🌐 Network connection failed. Here's how to fix it:
347
+
348
+ QUICK CHECKS:
349
+ 1. 🔌 Test internet connection:
350
+ curl -I https://gitlab.com (or your GitLab URL)
351
+
352
+ 2. 🔍 Verify GitLab URL:
353
+ • Default: https://gitlab.com
354
+ • Custom: --gitlab-url https://your-gitlab.com
355
+ • Check for typos in URL
356
+
357
+ COMMON ISSUES:
358
+ • 🔥 Firewall blocking HTTPS (port 443)
359
+ • 🏢 Corporate proxy requiring configuration
360
+ • 📡 DNS resolution issues
361
+ • 🚫 GitLab instance temporarily down
362
+
363
+ TROUBLESHOOTING:
364
+ • Try from different network
365
+ • Check GitLab status page
366
+ • Use --verbose for detailed network errors
367
+ • Test with curl: curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/user
368
+
369
+ PROXY SETUP (if needed):
370
+ export HTTP_PROXY=http://proxy.company.com:8080
371
+ export HTTPS_PROXY=http://proxy.company.com:8080`;
372
+ case CLIErrorCode.NOT_FOUND:
373
+ return `🔍 Resource not found. Here's how to fix it:
374
+
375
+ QUICK CHECKS:
376
+ 1. ✅ Verify merge request exists:
377
+ • Check MR number is correct
378
+ • MR hasn't been closed/deleted
379
+ • You have access to view it
380
+
381
+ 2. ✅ Verify project access:
382
+ • Project ID/path is correct
383
+ • Project exists and is accessible
384
+ • You have at least Guest access
385
+
386
+ COMMON MISTAKES:
387
+ • 🔢 Wrong MR number (use IID, not ID)
388
+ • 📝 Typo in project path (group/project)
389
+ • 🔒 Private project without access
390
+ • 🌿 Branch name doesn't exist
391
+
392
+ DEBUGGING STEPS:
393
+ 1. 🌐 Check in browser:
394
+ https://gitlab.com/group/project/-/merge_requests/123
395
+
396
+ 2. 🔍 Verify project path:
397
+ gitlab-auto-reviewers cli --project group/project --mr 123 --dry-run
398
+
399
+ 3. 📋 List recent MRs:
400
+ curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \\
401
+ "https://gitlab.com/api/v4/projects/group%2Fproject/merge_requests"
402
+
403
+ EXAMPLES:
404
+ • Project ID: --project 12345
405
+ • Project path: --project group/project
406
+ • Branch: --branch feature/my-feature`;
407
+ case CLIErrorCode.API_ERROR:
408
+ return `🚨 GitLab API error occurred. Here's how to fix it:
409
+
410
+ IMMEDIATE ACTIONS:
411
+ 1. ⏳ Wait 1-2 minutes and retry
412
+ 2. 🔍 Use --verbose for detailed error info
413
+ 3. 📊 Check GitLab status: https://status.gitlab.com
414
+
415
+ COMMON API ERRORS:
416
+ • 500: GitLab server error (temporary)
417
+ • 502/503: GitLab maintenance/overload
418
+ • 422: Invalid request data
419
+ • 409: Conflict (e.g., duplicate comment)
420
+
421
+ DEBUGGING STEPS:
422
+ 1. 📝 Enable verbose logging:
423
+ gitlab-auto-reviewers cli --repo-path . --mr 123 --verbose
424
+
425
+ 2. 🧪 Test with dry-run first:
426
+ gitlab-auto-reviewers cli --repo-path . --mr 123 --dry-run
427
+
428
+ 3. 🔍 Check API directly:
429
+ curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \\
430
+ "https://gitlab.com/api/v4/projects/PROJECT/merge_requests/123"
431
+
432
+ RECOVERY OPTIONS:
433
+ • Retry after a few minutes
434
+ • Use --dry-run to test without posting
435
+ • Check GitLab instance health
436
+ • Contact GitLab admin if self-hosted`;
437
+ case CLIErrorCode.CONFIGURATION_ERROR:
438
+ return `⚙️ Configuration error. Here's how to fix it:
439
+
440
+ QUICK FIXES:
441
+ 1. 📄 Check config file syntax:
442
+ cat .gitlab-auto-reviewers.json | jq .
443
+
444
+ 2. 📝 Validate template files:
445
+ ls -la custom-template.md
446
+
447
+ COMMON CONFIG ISSUES:
448
+ • 🔧 Invalid JSON syntax in config file
449
+ • 📄 Template file doesn't exist or not readable
450
+ • 🔢 Invalid values (negative numbers, etc.)
451
+ • 📁 Wrong file paths
452
+
453
+ CONFIG FILE EXAMPLE:
454
+ {
455
+
456
+ "gitlabUrl": "https://gitlab.com",
457
+ "template": "./templates/custom.md",
458
+ "cacheEnabled": true
459
+ }
460
+
461
+ TEMPLATE FILE EXAMPLE:
462
+ ## Suggested Reviewers
463
+
464
+ {{#contributors}}
465
+ - @{{username}} ({{score}} points)
466
+ {{/contributors}}
467
+
468
+ DEBUGGING:
469
+ • Use --verbose for detailed config validation
470
+ • Test without config: remove --config flag
471
+ • Validate JSON: cat config.json | jq .
472
+ • Check file permissions: ls -la config.json`;
473
+ default:
474
+ return `❌ Unexpected error occurred. Here's how to get help:
475
+
476
+ IMMEDIATE STEPS:
477
+ 1. 🔍 Get detailed error info:
478
+ gitlab-auto-reviewers cli --repo-path . --mr 123 --verbose
479
+
480
+ 2. 🧪 Test with minimal options:
481
+ gitlab-auto-reviewers cli --repo-path . --mr 123 --dry-run
482
+
483
+ GATHER DEBUG INFO:
484
+ • Node.js version: node --version
485
+ • CLI version: gitlab-auto-reviewers --version
486
+ • OS: uname -a (Linux/Mac) or ver (Windows)
487
+ • Git version: git --version
488
+
489
+ COMMON SOLUTIONS:
490
+ • 🔄 Update to latest version: npm update gitlab-auto-reviewers
491
+ • 🧹 Clear cache: rm -rf ~/.cache/gitlab-auto-reviewers
492
+ • 🔧 Check all required parameters are provided
493
+ • 🌐 Verify network connectivity to GitLab
494
+
495
+ GET HELP:
496
+ • 📖 Documentation: https://github.com/your-org/gitlab-auto-reviewers
497
+ • 🐛 Report bug: https://github.com/your-org/gitlab-auto-reviewers/issues
498
+ • 💬 Include --verbose output in bug reports`;
499
+ }
500
+ }
501
+ /**
502
+ * Extract wait time from rate limit error
503
+ */
504
+ static extractRateLimitWaitTime(error) {
505
+ const message = error.message;
506
+ // Look for common rate limit wait time patterns
507
+ const patterns = [
508
+ /retry after (\d+) seconds?/i,
509
+ /wait (\d+) seconds?/i,
510
+ /try again in (\d+) seconds?/i,
511
+ /rate limit reset in (\d+) seconds?/i,
512
+ ];
513
+ for (const pattern of patterns) {
514
+ const match = message.match(pattern);
515
+ if (match) {
516
+ const seconds = parseInt(match[1], 10);
517
+ if (!isNaN(seconds) && seconds > 0) {
518
+ return seconds;
519
+ }
520
+ }
521
+ }
522
+ // Default wait time for rate limiting
523
+ return 60;
524
+ }
525
+ }
526
+ /**
527
+ * Format error for CLI output
528
+ */
529
+ export function formatCLIError(error, format = 'text', verbose = false) {
530
+ const errorCode = ErrorClassifier.classifyError(error);
531
+ const guidance = ErrorClassifier.getErrorGuidance(error, errorCode);
532
+ if (format === 'json') {
533
+ const errorOutput = {
534
+ error: error.message,
535
+ code: errorCode,
536
+ guidance: guidance.split('\n'),
537
+ hint: 'Use --help for complete usage information',
538
+ };
539
+ if (verbose && error.stack) {
540
+ errorOutput.stack = error.stack;
541
+ }
542
+ if (error instanceof CLIError && error.details) {
543
+ errorOutput.details = error.details;
544
+ }
545
+ if (errorCode === CLIErrorCode.RATE_LIMITED) {
546
+ const waitTime = ErrorClassifier.extractRateLimitWaitTime(error);
547
+ if (waitTime) {
548
+ errorOutput.waitTimeSeconds = waitTime;
549
+ }
550
+ }
551
+ return JSON.stringify(errorOutput, null, 2);
552
+ }
553
+ else {
554
+ const parts = [`Error: ${error.message}`];
555
+ if (guidance) {
556
+ parts.push('');
557
+ parts.push(guidance);
558
+ }
559
+ if (errorCode === CLIErrorCode.RATE_LIMITED) {
560
+ const waitTime = ErrorClassifier.extractRateLimitWaitTime(error);
561
+ if (waitTime) {
562
+ parts.push('');
563
+ parts.push(`Estimated wait time: ${waitTime} seconds`);
564
+ }
565
+ }
566
+ if (verbose && error.stack) {
567
+ parts.push('');
568
+ parts.push('Stack trace:');
569
+ parts.push(error.stack);
570
+ }
571
+ // Always add help hint at the end
572
+ parts.push('');
573
+ parts.push('Use --help for complete usage information.');
574
+ return parts.join('\n');
575
+ }
576
+ }
577
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/cli/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAErE;;GAEG;AACH,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,uEAAoB,CAAA;IACpB,+EAAwB,CAAA;IACxB,iEAAiB,CAAA;IACjB,yDAAa,CAAA;IACb,uEAAoB,CAAA;IACpB,6EAAuB,CAAA;IACvB,mEAAkB,CAAA;IAClB,+DAAgB,CAAA;IAChB,yDAAa,CAAA;IACb,kEAAkB,CAAA;AACpB,CAAC,EAZW,YAAY,KAAZ,YAAY,QAYvB;AAED;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IAY3B;IACA;IAZT;;;;;;;;OAQG;IACH,YACE,OAAe,EACR,QAAsB,EACtB,YAAqB,EAC5B,OAAiC,EACjC,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QALlD,aAAQ,GAAR,QAAQ,CAAc;QACtB,iBAAY,GAAZ,YAAY,CAAS;QAK5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;IA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,MAAM,KAAK,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAE1C,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED,IAAI,SAAS,KAAK,YAAY,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;YACjE,IAAI,QAAQ,EAAE,CAAC;gBACb,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,wBAAwB,QAAQ,UAAU,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,IAAI,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,kCAAkC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QAEzD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
@@ -2,23 +2,63 @@
2
2
  * CLI Output Formatters
3
3
  *
4
4
  * This module provides output formatting functions for CLI results.
5
- * Supports both JSON and human-readable text formats.
5
+ * Supports both JSON and human-readable text formats with enhanced features
6
+ * for verbose/quiet modes and structured CI/CD output.
6
7
  *
7
8
  * @module cli/output
8
9
  */
9
10
  import { AutoReviewerResult } from "../types.js";
11
+ import type { CLIOptions } from "./commands.js";
12
+ /**
13
+ * Enhanced CLI result with metadata
14
+ *
15
+ * @property metadata - Execution metadata including timing, data source, and CI/CD context
16
+ * @property commentResult - Result of comment posting operation (optional)
17
+ */
18
+ export interface CLIResult extends AutoReviewerResult {
19
+ metadata: {
20
+ executionTime: number;
21
+ dataSource: 'local-git' | 'gitlab-api';
22
+ dryRun: boolean;
23
+ configSource: string[];
24
+ cicd?: {
25
+ platform?: string;
26
+ projectId?: string | number;
27
+ mergeRequestIid?: number;
28
+ pipelineId?: string;
29
+ jobId?: string;
30
+ };
31
+ };
32
+ commentResult?: {
33
+ posted: boolean;
34
+ commentId?: number;
35
+ url?: string;
36
+ error?: string;
37
+ };
38
+ }
39
+ /**
40
+ * Enhanced output handler for CLI results
41
+ *
42
+ * @param result - Reviewer analysis result or enhanced CLI result
43
+ * @param options - CLI options for output control
44
+ * @returns Formatted output string
45
+ */
46
+ export declare function handleOutput(result: AutoReviewerResult | CLIResult, options: CLIOptions): string;
10
47
  /**
11
48
  * Format reviewer suggestions as JSON
12
49
  *
13
50
  * @param result - Reviewer analysis result
51
+ * @param verbose - Include detailed information
14
52
  * @returns JSON string with formatted output
15
53
  */
16
- export declare function formatJSON(result: AutoReviewerResult): string;
54
+ export declare function formatJSON(result: AutoReviewerResult | CLIResult, verbose?: boolean): string;
17
55
  /**
18
56
  * Format reviewer suggestions as human-readable text
19
57
  *
20
58
  * @param result - Reviewer analysis result
59
+ * @param verbose - Include detailed information
60
+ * @param quiet - Suppress non-essential output
21
61
  * @returns Formatted text string
22
62
  */
23
- export declare function formatText(result: AutoReviewerResult): string;
63
+ export declare function formatText(result: AutoReviewerResult | CLIResult, verbose?: boolean, quiet?: boolean): string;
24
64
  //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAsB,MAAM,aAAa,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAA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