@andrebuzeli/git-mcp 5.1.0 → 5.2.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 (48) hide show
  1. package/dist/__tests__/setup.d.ts +10 -0
  2. package/dist/__tests__/setup.d.ts.map +1 -0
  3. package/dist/__tests__/setup.js +105 -0
  4. package/dist/__tests__/setup.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/server.d.ts +8 -1
  7. package/dist/server.d.ts.map +1 -1
  8. package/dist/server.js +100 -4
  9. package/dist/server.js.map +1 -1
  10. package/dist/tools/git-archive.d.ts.map +1 -1
  11. package/dist/tools/git-archive.js +1 -3
  12. package/dist/tools/git-archive.js.map +1 -1
  13. package/dist/tools/git-automations.d.ts +257 -0
  14. package/dist/tools/git-automations.d.ts.map +1 -0
  15. package/dist/tools/git-automations.js +878 -0
  16. package/dist/tools/git-automations.js.map +1 -0
  17. package/dist/tools/git-bisect.d.ts +158 -0
  18. package/dist/tools/git-bisect.d.ts.map +1 -0
  19. package/dist/tools/git-bisect.js +571 -0
  20. package/dist/tools/git-bisect.js.map +1 -0
  21. package/dist/tools/git-changelog.d.ts +253 -0
  22. package/dist/tools/git-changelog.d.ts.map +1 -0
  23. package/dist/tools/git-changelog.js +728 -0
  24. package/dist/tools/git-changelog.js.map +1 -0
  25. package/dist/tools/git-cherry-pick.d.ts +150 -0
  26. package/dist/tools/git-cherry-pick.d.ts.map +1 -0
  27. package/dist/tools/git-cherry-pick.js +455 -0
  28. package/dist/tools/git-cherry-pick.js.map +1 -0
  29. package/dist/tools/git-dependencies.d.ts +233 -0
  30. package/dist/tools/git-dependencies.d.ts.map +1 -0
  31. package/dist/tools/git-dependencies.js +761 -0
  32. package/dist/tools/git-dependencies.js.map +1 -0
  33. package/dist/tools/git-hooks.d.ts +146 -0
  34. package/dist/tools/git-hooks.d.ts.map +1 -0
  35. package/dist/tools/git-hooks.js +634 -0
  36. package/dist/tools/git-hooks.js.map +1 -0
  37. package/dist/tools/git-stats-personal.d.ts +210 -0
  38. package/dist/tools/git-stats-personal.d.ts.map +1 -0
  39. package/dist/tools/git-stats-personal.js +718 -0
  40. package/dist/tools/git-stats-personal.js.map +1 -0
  41. package/dist/tools/git-tags.d.ts.map +1 -1
  42. package/dist/tools/git-tags.js +11 -3
  43. package/dist/tools/git-tags.js.map +1 -1
  44. package/dist/utils/parameter-validator.d.ts +9 -0
  45. package/dist/utils/parameter-validator.d.ts.map +1 -1
  46. package/dist/utils/parameter-validator.js +390 -14
  47. package/dist/utils/parameter-validator.js.map +1 -1
  48. package/package.json +81 -78
@@ -0,0 +1,761 @@
1
+ "use strict";
2
+ /**
3
+ * Git Dependencies Tool
4
+ *
5
+ * Dependencies analysis tool providing comprehensive dependency management operations.
6
+ * Supports multiple package managers and automated dependency updates.
7
+ *
8
+ * Operations: list, outdated, update, audit, changelog, compare
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.GitDependenciesTool = void 0;
15
+ const git_command_executor_js_1 = require("../utils/git-command-executor.js");
16
+ const parameter_validator_js_1 = require("../utils/parameter-validator.js");
17
+ const operation_error_handler_js_1 = require("../utils/operation-error-handler.js");
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const path_1 = __importDefault(require("path"));
20
+ class GitDependenciesTool {
21
+ gitExecutor;
22
+ constructor() {
23
+ this.gitExecutor = new git_command_executor_js_1.GitCommandExecutor();
24
+ }
25
+ /**
26
+ * Execute git-dependencies operation
27
+ */
28
+ async execute(params) {
29
+ const startTime = Date.now();
30
+ try {
31
+ // Validate basic parameters
32
+ const validation = parameter_validator_js_1.ParameterValidator.validateToolParams('git-dependencies', params);
33
+ if (!validation.isValid) {
34
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('VALIDATION_ERROR', `Parameter validation failed: ${validation.errors.join(', ')}`, params.action, { validationErrors: validation.errors }, validation.suggestions);
35
+ }
36
+ // Validate operation-specific parameters
37
+ const operationValidation = parameter_validator_js_1.ParameterValidator.validateOperationParams('git-dependencies', params.action, params);
38
+ if (!operationValidation.isValid) {
39
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('VALIDATION_ERROR', `Operation validation failed: ${operationValidation.errors.join(', ')}`, params.action, { validationErrors: operationValidation.errors }, operationValidation.suggestions);
40
+ }
41
+ // Detect package manager if not specified
42
+ const packageManager = params.packageManager || this.detectPackageManager(params.projectPath);
43
+ // Route to appropriate handler
44
+ switch (params.action) {
45
+ case 'list':
46
+ return await this.handleList(params, packageManager, startTime);
47
+ case 'outdated':
48
+ return await this.handleOutdated(params, packageManager, startTime);
49
+ case 'update':
50
+ return await this.handleUpdate(params, packageManager, startTime);
51
+ case 'audit':
52
+ return await this.handleAudit(params, packageManager, startTime);
53
+ case 'changelog':
54
+ return await this.handleChangelog(params, packageManager, startTime);
55
+ case 'compare':
56
+ return await this.handleCompare(params, packageManager, startTime);
57
+ default:
58
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('INVALID_ACTION', `Unknown action: ${params.action}`, params.action, { supportedActions: ['list', 'outdated', 'update', 'audit', 'changelog', 'compare'] }, ['Use one of the supported actions']);
59
+ }
60
+ }
61
+ catch (error) {
62
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
63
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('EXECUTION_ERROR', `Failed to execute ${params.action}: ${errorMessage}`, params.action, { error: errorMessage }, ['Check the error details and try again']);
64
+ }
65
+ }
66
+ /**
67
+ * Detect package manager
68
+ */
69
+ detectPackageManager(projectPath) {
70
+ const packageFiles = {
71
+ 'package.json': 'npm',
72
+ 'yarn.lock': 'yarn',
73
+ 'pnpm-lock.yaml': 'pnpm',
74
+ 'requirements.txt': 'pip',
75
+ 'Cargo.toml': 'cargo',
76
+ 'composer.json': 'composer',
77
+ 'pom.xml': 'maven',
78
+ 'build.gradle': 'gradle'
79
+ };
80
+ for (const [file, manager] of Object.entries(packageFiles)) {
81
+ if (fs_1.default.existsSync(path_1.default.join(projectPath, file))) {
82
+ return manager;
83
+ }
84
+ }
85
+ return 'npm'; // Default to npm
86
+ }
87
+ /**
88
+ * List dependencies
89
+ */
90
+ async handleList(params, packageManager, startTime) {
91
+ try {
92
+ const dependencies = await this.getDependencies(params, packageManager);
93
+ const executionTime = Date.now() - startTime;
94
+ return {
95
+ success: true,
96
+ data: {
97
+ dependencies: {
98
+ packageManager,
99
+ dependencies,
100
+ count: dependencies.length,
101
+ format: params.format || 'json'
102
+ },
103
+ message: `Listed ${dependencies.length} dependencies using ${packageManager}`,
104
+ executionTime
105
+ }
106
+ };
107
+ }
108
+ catch (error) {
109
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
110
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('LIST_ERROR', `Failed to list dependencies: ${errorMessage}`, params.action, { packageManager, error: errorMessage }, ['Check package manager configuration', 'Verify package files exist']);
111
+ }
112
+ }
113
+ /**
114
+ * Check for outdated dependencies
115
+ */
116
+ async handleOutdated(params, packageManager, startTime) {
117
+ try {
118
+ const outdated = await this.getOutdatedDependencies(params, packageManager);
119
+ const executionTime = Date.now() - startTime;
120
+ return {
121
+ success: true,
122
+ data: {
123
+ dependencies: {
124
+ packageManager,
125
+ outdated,
126
+ count: outdated.length,
127
+ format: params.format || 'json'
128
+ },
129
+ message: `Found ${outdated.length} outdated dependencies using ${packageManager}`,
130
+ executionTime
131
+ }
132
+ };
133
+ }
134
+ catch (error) {
135
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
136
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('OUTDATED_ERROR', `Failed to check outdated dependencies: ${errorMessage}`, params.action, { packageManager, error: errorMessage }, ['Check package manager configuration', 'Verify network connectivity']);
137
+ }
138
+ }
139
+ /**
140
+ * Update dependencies
141
+ */
142
+ async handleUpdate(params, packageManager, startTime) {
143
+ try {
144
+ // Create branch if requested
145
+ let branchName = '';
146
+ if (params.createBranch) {
147
+ branchName = params.branchName || `update-dependencies-${Date.now()}`;
148
+ await this.createBranch(branchName, params.projectPath);
149
+ }
150
+ const updates = await this.updateDependencies(params, packageManager);
151
+ // Commit changes if requested
152
+ if (params.autoCommit && updates.length > 0) {
153
+ const commitMessage = params.commitMessage || `chore: update dependencies (${updates.length} packages)`;
154
+ await this.commitUpdates(commitMessage, params.projectPath);
155
+ }
156
+ const executionTime = Date.now() - startTime;
157
+ return {
158
+ success: true,
159
+ data: {
160
+ dependencies: {
161
+ packageManager,
162
+ updates,
163
+ count: updates.length,
164
+ branchName,
165
+ committed: params.autoCommit,
166
+ format: params.format || 'json'
167
+ },
168
+ message: `Updated ${updates.length} dependencies using ${packageManager}`,
169
+ executionTime
170
+ }
171
+ };
172
+ }
173
+ catch (error) {
174
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
175
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('UPDATE_ERROR', `Failed to update dependencies: ${errorMessage}`, params.action, { packageManager, error: errorMessage }, ['Check package manager configuration', 'Verify package files exist']);
176
+ }
177
+ }
178
+ /**
179
+ * Audit dependencies
180
+ */
181
+ async handleAudit(params, packageManager, startTime) {
182
+ try {
183
+ const audit = await this.auditDependencies(params, packageManager);
184
+ const executionTime = Date.now() - startTime;
185
+ return {
186
+ success: true,
187
+ data: {
188
+ dependencies: {
189
+ packageManager,
190
+ audit,
191
+ vulnerabilities: audit.vulnerabilities || [],
192
+ count: (audit.vulnerabilities || []).length,
193
+ format: params.format || 'json'
194
+ },
195
+ message: `Audit completed using ${packageManager}. Found ${(audit.vulnerabilities || []).length} vulnerabilities.`,
196
+ executionTime
197
+ }
198
+ };
199
+ }
200
+ catch (error) {
201
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
202
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('AUDIT_ERROR', `Failed to audit dependencies: ${errorMessage}`, params.action, { packageManager, error: errorMessage }, ['Check package manager configuration', 'Verify audit command is available']);
203
+ }
204
+ }
205
+ /**
206
+ * Get dependency changelog
207
+ */
208
+ async handleChangelog(params, packageManager, startTime) {
209
+ try {
210
+ if (!params.packageName) {
211
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('MISSING_PACKAGE', 'Package name is required for changelog', params.action, { packageName: params.packageName }, ['Provide packageName parameter']);
212
+ }
213
+ const changelog = await this.getPackageChangelog(params.packageName, packageManager, params);
214
+ const executionTime = Date.now() - startTime;
215
+ return {
216
+ success: true,
217
+ data: {
218
+ dependencies: {
219
+ packageManager,
220
+ packageName: params.packageName,
221
+ changelog,
222
+ format: params.format || 'json'
223
+ },
224
+ message: `Retrieved changelog for ${params.packageName}`,
225
+ executionTime
226
+ }
227
+ };
228
+ }
229
+ catch (error) {
230
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
231
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('CHANGELOG_ERROR', `Failed to get changelog: ${errorMessage}`, params.action, { packageManager, packageName: params.packageName, error: errorMessage }, ['Check package name is valid', 'Verify package manager supports changelog']);
232
+ }
233
+ }
234
+ /**
235
+ * Compare dependency versions
236
+ */
237
+ async handleCompare(params, packageManager, startTime) {
238
+ try {
239
+ if (!params.packageName || !params.compareWith) {
240
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('MISSING_PARAMETERS', 'Both packageName and compareWith are required for comparison', params.action, { packageName: params.packageName, compareWith: params.compareWith }, ['Provide both packageName and compareWith parameters']);
241
+ }
242
+ const comparison = await this.compareVersions(params.packageName, params.compareWith, packageManager, params);
243
+ const executionTime = Date.now() - startTime;
244
+ return {
245
+ success: true,
246
+ data: {
247
+ dependencies: {
248
+ packageManager,
249
+ packageName: params.packageName,
250
+ comparison,
251
+ format: params.format || 'json'
252
+ },
253
+ message: `Compared versions for ${params.packageName}`,
254
+ executionTime
255
+ }
256
+ };
257
+ }
258
+ catch (error) {
259
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
260
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('COMPARE_ERROR', `Failed to compare versions: ${errorMessage}`, params.action, { packageManager, packageName: params.packageName, error: errorMessage }, ['Check package name is valid', 'Verify version format']);
261
+ }
262
+ }
263
+ /**
264
+ * Get dependencies list
265
+ */
266
+ async getDependencies(params, packageManager) {
267
+ let command = '';
268
+ switch (packageManager) {
269
+ case 'npm':
270
+ command = 'npm list --depth=0 --json';
271
+ break;
272
+ case 'yarn':
273
+ command = 'yarn list --depth=0 --json';
274
+ break;
275
+ case 'pnpm':
276
+ command = 'pnpm list --depth=0 --json';
277
+ break;
278
+ case 'pip':
279
+ command = 'pip list --format=json';
280
+ break;
281
+ case 'cargo':
282
+ command = 'cargo tree --format "{p} {f}"';
283
+ break;
284
+ default:
285
+ throw new Error(`Unsupported package manager: ${packageManager}`);
286
+ }
287
+ const result = await this.gitExecutor.executeGitCommand(command, [], params.projectPath);
288
+ if (!result.success) {
289
+ throw new Error(`Failed to list dependencies: ${result.stderr}`);
290
+ }
291
+ return this.parseDependenciesList(result.stdout, packageManager);
292
+ }
293
+ /**
294
+ * Get outdated dependencies
295
+ */
296
+ async getOutdatedDependencies(params, packageManager) {
297
+ let command = '';
298
+ switch (packageManager) {
299
+ case 'npm':
300
+ command = 'npm outdated --json';
301
+ break;
302
+ case 'yarn':
303
+ command = 'yarn outdated --json';
304
+ break;
305
+ case 'pnpm':
306
+ command = 'pnpm outdated --json';
307
+ break;
308
+ case 'pip':
309
+ command = 'pip list --outdated --format=json';
310
+ break;
311
+ case 'cargo':
312
+ command = 'cargo outdated --format json';
313
+ break;
314
+ default:
315
+ throw new Error(`Unsupported package manager: ${packageManager}`);
316
+ }
317
+ const result = await this.gitExecutor.executeGitCommand(command, [], params.projectPath);
318
+ if (!result.success) {
319
+ throw new Error(`Failed to check outdated dependencies: ${result.stderr}`);
320
+ }
321
+ return this.parseOutdatedDependencies(result.stdout, packageManager);
322
+ }
323
+ /**
324
+ * Update dependencies
325
+ */
326
+ async updateDependencies(params, packageManager) {
327
+ let command = '';
328
+ if (params.packageName) {
329
+ // Update specific package
330
+ switch (packageManager) {
331
+ case 'npm':
332
+ command = `npm update ${params.packageName}`;
333
+ break;
334
+ case 'yarn':
335
+ command = `yarn upgrade ${params.packageName}`;
336
+ break;
337
+ case 'pnpm':
338
+ command = `pnpm update ${params.packageName}`;
339
+ break;
340
+ case 'pip':
341
+ command = `pip install --upgrade ${params.packageName}`;
342
+ break;
343
+ case 'cargo':
344
+ command = `cargo update -p ${params.packageName}`;
345
+ break;
346
+ }
347
+ }
348
+ else {
349
+ // Update all packages
350
+ switch (packageManager) {
351
+ case 'npm':
352
+ command = 'npm update';
353
+ break;
354
+ case 'yarn':
355
+ command = 'yarn upgrade';
356
+ break;
357
+ case 'pnpm':
358
+ command = 'pnpm update';
359
+ break;
360
+ case 'pip':
361
+ command = 'pip install --upgrade -r requirements.txt';
362
+ break;
363
+ case 'cargo':
364
+ command = 'cargo update';
365
+ break;
366
+ }
367
+ }
368
+ const result = await this.gitExecutor.executeGitCommand(command, [], params.projectPath);
369
+ if (!result.success) {
370
+ throw new Error(`Failed to update dependencies: ${result.stderr}`);
371
+ }
372
+ return this.parseUpdateResult(result.stdout, packageManager);
373
+ }
374
+ /**
375
+ * Audit dependencies
376
+ */
377
+ async auditDependencies(params, packageManager) {
378
+ let command = '';
379
+ switch (packageManager) {
380
+ case 'npm':
381
+ command = 'npm audit --json';
382
+ break;
383
+ case 'yarn':
384
+ command = 'yarn audit --json';
385
+ break;
386
+ case 'pnpm':
387
+ command = 'pnpm audit --json';
388
+ break;
389
+ case 'pip':
390
+ command = 'safety check --json';
391
+ break;
392
+ case 'cargo':
393
+ command = 'cargo audit --json';
394
+ break;
395
+ default:
396
+ throw new Error(`Unsupported package manager: ${packageManager}`);
397
+ }
398
+ const result = await this.gitExecutor.executeGitCommand(command, [], params.projectPath);
399
+ if (!result.success) {
400
+ throw new Error(`Failed to audit dependencies: ${result.stderr}`);
401
+ }
402
+ return this.parseAuditResult(result.stdout, packageManager);
403
+ }
404
+ /**
405
+ * Get package changelog
406
+ */
407
+ async getPackageChangelog(packageName, packageManager, params) {
408
+ let command = '';
409
+ switch (packageManager) {
410
+ case 'npm':
411
+ command = `npm view ${packageName} versions --json`;
412
+ break;
413
+ case 'yarn':
414
+ command = `yarn info ${packageName} versions --json`;
415
+ break;
416
+ case 'pip':
417
+ command = `pip show ${packageName}`;
418
+ break;
419
+ default:
420
+ throw new Error(`Changelog not supported for ${packageManager}`);
421
+ }
422
+ const result = await this.gitExecutor.executeGitCommand(command, [], params.projectPath);
423
+ if (!result.success) {
424
+ throw new Error(`Failed to get changelog: ${result.stderr}`);
425
+ }
426
+ return this.parseChangelogResult(result.stdout, packageManager, packageName);
427
+ }
428
+ /**
429
+ * Compare package versions
430
+ */
431
+ async compareVersions(packageName, compareWith, packageManager, params) {
432
+ // Get current version
433
+ const currentResult = await this.gitExecutor.executeGitCommand('npm', ['list', packageName, '--depth=0', '--json'], params.projectPath);
434
+ const currentVersion = this.extractVersionFromOutput(currentResult.stdout, packageName);
435
+ return {
436
+ packageName,
437
+ currentVersion,
438
+ compareWith,
439
+ difference: this.compareVersionStrings(currentVersion, compareWith),
440
+ upgradeAvailable: this.isVersionNewer(compareWith, currentVersion),
441
+ downgradeAvailable: this.isVersionNewer(currentVersion, compareWith)
442
+ };
443
+ }
444
+ /**
445
+ * Create branch for updates
446
+ */
447
+ async createBranch(branchName, projectPath) {
448
+ const result = await this.gitExecutor.executeGitCommand('git', ['checkout', '-b', branchName], projectPath);
449
+ if (!result.success) {
450
+ throw new Error(`Failed to create branch: ${result.stderr}`);
451
+ }
452
+ }
453
+ /**
454
+ * Commit dependency updates
455
+ */
456
+ async commitUpdates(message, projectPath) {
457
+ // Add changed files
458
+ await this.gitExecutor.executeGitCommand('git', ['add', 'package.json', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'requirements.txt', 'Cargo.toml', 'composer.json', 'pom.xml', 'build.gradle'], projectPath);
459
+ // Commit changes
460
+ const result = await this.gitExecutor.executeGitCommand('git', ['commit', '-m', message], projectPath);
461
+ if (!result.success) {
462
+ throw new Error(`Failed to commit updates: ${result.stderr}`);
463
+ }
464
+ }
465
+ /**
466
+ * Parse dependencies list output
467
+ */
468
+ parseDependenciesList(output, packageManager) {
469
+ try {
470
+ switch (packageManager) {
471
+ case 'npm':
472
+ case 'yarn':
473
+ case 'pnpm':
474
+ const data = JSON.parse(output);
475
+ const dependencies = data.dependencies || {};
476
+ return Object.entries(dependencies).map(([name, info]) => ({
477
+ name,
478
+ version: info.version,
479
+ type: info.dev ? 'devDependency' : 'dependency'
480
+ }));
481
+ case 'pip':
482
+ const pipData = JSON.parse(output);
483
+ return pipData.map((pkg) => ({
484
+ name: pkg.name,
485
+ version: pkg.version,
486
+ type: 'dependency'
487
+ }));
488
+ default:
489
+ return [];
490
+ }
491
+ }
492
+ catch (error) {
493
+ return [];
494
+ }
495
+ }
496
+ /**
497
+ * Parse outdated dependencies output
498
+ */
499
+ parseOutdatedDependencies(output, packageManager) {
500
+ try {
501
+ switch (packageManager) {
502
+ case 'npm':
503
+ case 'yarn':
504
+ case 'pnpm':
505
+ const data = JSON.parse(output);
506
+ return Object.entries(data).map(([name, info]) => ({
507
+ name,
508
+ current: info.current,
509
+ wanted: info.wanted,
510
+ latest: info.latest,
511
+ type: info.type || 'dependency'
512
+ }));
513
+ case 'pip':
514
+ const pipData = JSON.parse(output);
515
+ return pipData.map((pkg) => ({
516
+ name: pkg.name,
517
+ current: pkg.version,
518
+ latest: pkg.latest_version,
519
+ type: 'dependency'
520
+ }));
521
+ default:
522
+ return [];
523
+ }
524
+ }
525
+ catch (error) {
526
+ return [];
527
+ }
528
+ }
529
+ /**
530
+ * Parse update result
531
+ */
532
+ parseUpdateResult(output, packageManager) {
533
+ // Parse update output to extract updated packages
534
+ const lines = output.split('\n');
535
+ const updates = [];
536
+ for (const line of lines) {
537
+ if (line.includes('updated') || line.includes('upgraded')) {
538
+ // Extract package name and version from output
539
+ const match = line.match(/(\w+)@([^\s]+)/);
540
+ if (match) {
541
+ updates.push({
542
+ name: match[1],
543
+ version: match[2],
544
+ updated: true
545
+ });
546
+ }
547
+ }
548
+ }
549
+ return updates;
550
+ }
551
+ /**
552
+ * Parse audit result
553
+ */
554
+ parseAuditResult(output, packageManager) {
555
+ try {
556
+ const data = JSON.parse(output);
557
+ switch (packageManager) {
558
+ case 'npm':
559
+ case 'yarn':
560
+ case 'pnpm':
561
+ return {
562
+ vulnerabilities: data.vulnerabilities || [],
563
+ summary: data.metadata || {},
564
+ advisories: data.advisories || {}
565
+ };
566
+ default:
567
+ return { vulnerabilities: [] };
568
+ }
569
+ }
570
+ catch (error) {
571
+ return { vulnerabilities: [] };
572
+ }
573
+ }
574
+ /**
575
+ * Parse changelog result
576
+ */
577
+ parseChangelogResult(output, packageManager, packageName) {
578
+ try {
579
+ switch (packageManager) {
580
+ case 'npm':
581
+ const data = JSON.parse(output);
582
+ return {
583
+ packageName,
584
+ versions: data,
585
+ latest: data[data.length - 1],
586
+ count: data.length
587
+ };
588
+ case 'pip':
589
+ return {
590
+ packageName,
591
+ info: output,
592
+ parsed: this.parsePipShowOutput(output)
593
+ };
594
+ default:
595
+ return { packageName, info: output };
596
+ }
597
+ }
598
+ catch (error) {
599
+ return { packageName, error: 'Failed to parse changelog' };
600
+ }
601
+ }
602
+ /**
603
+ * Parse pip show output
604
+ */
605
+ parsePipShowOutput(output) {
606
+ const lines = output.split('\n');
607
+ const info = {};
608
+ for (const line of lines) {
609
+ const [key, value] = line.split(': ', 2);
610
+ if (key && value) {
611
+ info[key.toLowerCase().replace(/\s+/g, '_')] = value;
612
+ }
613
+ }
614
+ return info;
615
+ }
616
+ /**
617
+ * Extract version from output
618
+ */
619
+ extractVersionFromOutput(output, packageName) {
620
+ try {
621
+ const data = JSON.parse(output);
622
+ const pkg = data.dependencies?.[packageName];
623
+ return pkg?.version || 'unknown';
624
+ }
625
+ catch {
626
+ return 'unknown';
627
+ }
628
+ }
629
+ /**
630
+ * Compare version strings
631
+ */
632
+ compareVersionStrings(version1, version2) {
633
+ // Simple version comparison - can be enhanced with semver library
634
+ const v1parts = version1.split('.').map(Number);
635
+ const v2parts = version2.split('.').map(Number);
636
+ for (let i = 0; i < Math.max(v1parts.length, v2parts.length); i++) {
637
+ const v1part = v1parts[i] || 0;
638
+ const v2part = v2parts[i] || 0;
639
+ if (v1part > v2part)
640
+ return 'higher';
641
+ if (v1part < v2part)
642
+ return 'lower';
643
+ }
644
+ return 'equal';
645
+ }
646
+ /**
647
+ * Check if version is newer
648
+ */
649
+ isVersionNewer(version1, version2) {
650
+ return this.compareVersionStrings(version1, version2) === 'higher';
651
+ }
652
+ /**
653
+ * Get tool schema for MCP registration
654
+ */
655
+ static getToolSchema() {
656
+ return {
657
+ name: 'git-dependencies',
658
+ description: 'Dependency analysis and management tool. Supports multiple package managers for listing, updating, auditing, and comparing dependencies.',
659
+ inputSchema: {
660
+ type: 'object',
661
+ properties: {
662
+ "action": {
663
+ "type": "string",
664
+ "enum": [
665
+ "list",
666
+ "outdated",
667
+ "update",
668
+ "audit",
669
+ "changelog",
670
+ "compare"
671
+ ],
672
+ "description": "The operation to perform"
673
+ },
674
+ "projectPath": {
675
+ "type": "string",
676
+ "description": "Path to the Git repository"
677
+ },
678
+ "packageManager": {
679
+ "type": "string",
680
+ "description": "packageManager parameter"
681
+ },
682
+ "packageName": {
683
+ "type": "string",
684
+ "description": "packageName parameter"
685
+ },
686
+ "packageNames": {
687
+ "type": "array",
688
+ "items": {
689
+ "type": "string"
690
+ },
691
+ "description": "packageNames parameter"
692
+ },
693
+ "updateType": {
694
+ "type": "string",
695
+ "description": "updateType parameter"
696
+ },
697
+ "autoCommit": {
698
+ "type": "string",
699
+ "description": "autoCommit parameter"
700
+ },
701
+ "commitMessage": {
702
+ "type": "string",
703
+ "description": "commitMessage parameter"
704
+ },
705
+ "includeDevDeps": {
706
+ "type": "string",
707
+ "description": "includeDevDeps parameter"
708
+ },
709
+ "includePeerDeps": {
710
+ "type": "string",
711
+ "description": "includePeerDeps parameter"
712
+ },
713
+ "includeOptionalDeps": {
714
+ "type": "string",
715
+ "description": "includeOptionalDeps parameter"
716
+ },
717
+ "auditLevel": {
718
+ "type": "string",
719
+ "description": "auditLevel parameter"
720
+ },
721
+ "fixVulnerabilities": {
722
+ "type": "string",
723
+ "description": "fixVulnerabilities parameter"
724
+ },
725
+ "compareWith": {
726
+ "type": "string",
727
+ "description": "compareWith parameter"
728
+ },
729
+ "format": {
730
+ "type": "string",
731
+ "description": "format parameter"
732
+ },
733
+ "output": {
734
+ "type": "string",
735
+ "description": "output parameter"
736
+ },
737
+ "createBranch": {
738
+ "type": "string",
739
+ "description": "createBranch parameter"
740
+ },
741
+ "branchName": {
742
+ "type": "string",
743
+ "description": "branchName parameter"
744
+ },
745
+ "createPR": {
746
+ "type": "string",
747
+ "description": "createPR parameter"
748
+ }
749
+ },
750
+ required: ['action', 'projectPath'],
751
+ additionalProperties: false
752
+ },
753
+ errorCodes: {
754
+ 'VALIDATION_ERROR': 'Parameter validation failed',
755
+ 'EXECUTION_ERROR': 'Tool execution failed'
756
+ }
757
+ };
758
+ }
759
+ }
760
+ exports.GitDependenciesTool = GitDependenciesTool;
761
+ //# sourceMappingURL=git-dependencies.js.map