@andrebuzeli/git-mcp 5.5.0 → 5.5.2

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 (224) hide show
  1. package/README.md +25 -0
  2. package/dist/config.d.ts +5 -131
  3. package/dist/config.js +28 -430
  4. package/dist/index.d.ts +1 -21
  5. package/dist/index.js +66 -144
  6. package/dist/providers/giteaProvider.d.ts +3 -0
  7. package/dist/providers/giteaProvider.js +12 -0
  8. package/dist/providers/githubProvider.d.ts +2 -0
  9. package/dist/providers/githubProvider.js +7 -0
  10. package/dist/providers/providerManager.d.ts +11 -0
  11. package/dist/providers/providerManager.js +48 -0
  12. package/dist/server.d.ts +6 -40
  13. package/dist/server.js +30 -700
  14. package/dist/tools/gitAnalytics.d.ts +29 -0
  15. package/dist/tools/gitAnalytics.js +72 -0
  16. package/dist/tools/gitArchive.d.ts +6 -0
  17. package/dist/tools/gitArchive.js +27 -0
  18. package/dist/tools/gitBackup.d.ts +10 -0
  19. package/dist/tools/gitBackup.js +44 -0
  20. package/dist/tools/gitBranches.d.ts +72 -0
  21. package/dist/tools/gitBranches.js +97 -0
  22. package/dist/tools/gitConfig.d.ts +34 -0
  23. package/dist/tools/gitConfig.js +73 -0
  24. package/dist/tools/gitFiles.d.ts +24 -0
  25. package/dist/tools/gitFiles.js +53 -0
  26. package/dist/tools/gitIssues.d.ts +21 -0
  27. package/dist/tools/gitIssues.js +193 -0
  28. package/dist/tools/gitMonitor.d.ts +51 -0
  29. package/dist/tools/gitMonitor.js +102 -0
  30. package/dist/tools/gitPackages.d.ts +6 -0
  31. package/dist/tools/gitPackages.js +28 -0
  32. package/dist/tools/gitPulls.d.ts +74 -0
  33. package/dist/tools/gitPulls.js +190 -0
  34. package/dist/tools/gitRelease.d.ts +34 -0
  35. package/dist/tools/gitRelease.js +99 -0
  36. package/dist/tools/gitRemote.d.ts +51 -0
  37. package/dist/tools/gitRemote.js +68 -0
  38. package/dist/tools/gitReset.d.ts +34 -0
  39. package/dist/tools/gitReset.js +64 -0
  40. package/dist/tools/gitStash.d.ts +41 -0
  41. package/dist/tools/gitStash.js +67 -0
  42. package/dist/tools/gitSync.d.ts +25 -0
  43. package/dist/tools/gitSync.js +51 -0
  44. package/dist/tools/gitTags.d.ts +30 -0
  45. package/dist/tools/gitTags.js +69 -0
  46. package/dist/tools/gitWorkflow.d.ts +69 -0
  47. package/dist/tools/gitWorkflow.js +129 -0
  48. package/dist/types.d.ts +10 -0
  49. package/dist/types.js +2 -0
  50. package/dist/utils/errors.d.ts +13 -0
  51. package/dist/utils/errors.js +22 -0
  52. package/dist/utils/safetyController.d.ts +1 -0
  53. package/dist/utils/safetyController.js +15 -0
  54. package/package.json +7 -2
  55. package/dist/config.d.ts.map +0 -1
  56. package/dist/config.js.map +0 -1
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/providers/base-provider.d.ts +0 -66
  60. package/dist/providers/base-provider.d.ts.map +0 -1
  61. package/dist/providers/base-provider.js +0 -65
  62. package/dist/providers/base-provider.js.map +0 -1
  63. package/dist/providers/gitea-provider.d.ts +0 -79
  64. package/dist/providers/gitea-provider.d.ts.map +0 -1
  65. package/dist/providers/gitea-provider.js +0 -576
  66. package/dist/providers/gitea-provider.js.map +0 -1
  67. package/dist/providers/github-provider.d.ts +0 -74
  68. package/dist/providers/github-provider.d.ts.map +0 -1
  69. package/dist/providers/github-provider.js +0 -683
  70. package/dist/providers/github-provider.js.map +0 -1
  71. package/dist/providers/index.d.ts +0 -13
  72. package/dist/providers/index.d.ts.map +0 -1
  73. package/dist/providers/index.js +0 -35
  74. package/dist/providers/index.js.map +0 -1
  75. package/dist/providers/provider-factory.d.ts +0 -49
  76. package/dist/providers/provider-factory.d.ts.map +0 -1
  77. package/dist/providers/provider-factory.js +0 -193
  78. package/dist/providers/provider-factory.js.map +0 -1
  79. package/dist/providers/provider-operation-handler.d.ts +0 -115
  80. package/dist/providers/provider-operation-handler.d.ts.map +0 -1
  81. package/dist/providers/provider-operation-handler.js +0 -449
  82. package/dist/providers/provider-operation-handler.js.map +0 -1
  83. package/dist/providers/types.d.ts +0 -200
  84. package/dist/providers/types.d.ts.map +0 -1
  85. package/dist/providers/types.js +0 -8
  86. package/dist/providers/types.js.map +0 -1
  87. package/dist/server.d.ts.map +0 -1
  88. package/dist/server.js.map +0 -1
  89. package/dist/tools/git-analytics.d.ts +0 -237
  90. package/dist/tools/git-analytics.d.ts.map +0 -1
  91. package/dist/tools/git-analytics.js +0 -828
  92. package/dist/tools/git-analytics.js.map +0 -1
  93. package/dist/tools/git-archive.d.ts +0 -113
  94. package/dist/tools/git-archive.d.ts.map +0 -1
  95. package/dist/tools/git-archive.js +0 -466
  96. package/dist/tools/git-archive.js.map +0 -1
  97. package/dist/tools/git-auto-monitor.d.ts +0 -180
  98. package/dist/tools/git-auto-monitor.d.ts.map +0 -1
  99. package/dist/tools/git-auto-monitor.js +0 -522
  100. package/dist/tools/git-auto-monitor.js.map +0 -1
  101. package/dist/tools/git-backup.d.ts +0 -105
  102. package/dist/tools/git-backup.d.ts.map +0 -1
  103. package/dist/tools/git-backup.js +0 -414
  104. package/dist/tools/git-backup.js.map +0 -1
  105. package/dist/tools/git-branches.d.ts +0 -183
  106. package/dist/tools/git-branches.d.ts.map +0 -1
  107. package/dist/tools/git-branches.js +0 -507
  108. package/dist/tools/git-branches.js.map +0 -1
  109. package/dist/tools/git-config.d.ts +0 -119
  110. package/dist/tools/git-config.d.ts.map +0 -1
  111. package/dist/tools/git-config.js +0 -449
  112. package/dist/tools/git-config.js.map +0 -1
  113. package/dist/tools/git-files.d.ts +0 -150
  114. package/dist/tools/git-files.d.ts.map +0 -1
  115. package/dist/tools/git-files.js +0 -536
  116. package/dist/tools/git-files.js.map +0 -1
  117. package/dist/tools/git-history.d.ts +0 -253
  118. package/dist/tools/git-history.d.ts.map +0 -1
  119. package/dist/tools/git-history.js +0 -824
  120. package/dist/tools/git-history.js.map +0 -1
  121. package/dist/tools/git-issues.d.ts +0 -164
  122. package/dist/tools/git-issues.d.ts.map +0 -1
  123. package/dist/tools/git-issues.js +0 -349
  124. package/dist/tools/git-issues.js.map +0 -1
  125. package/dist/tools/git-monitor.d.ts +0 -154
  126. package/dist/tools/git-monitor.d.ts.map +0 -1
  127. package/dist/tools/git-monitor.js +0 -531
  128. package/dist/tools/git-monitor.js.map +0 -1
  129. package/dist/tools/git-packages.d.ts +0 -157
  130. package/dist/tools/git-packages.d.ts.map +0 -1
  131. package/dist/tools/git-packages.js +0 -534
  132. package/dist/tools/git-packages.js.map +0 -1
  133. package/dist/tools/git-pulls.d.ts +0 -180
  134. package/dist/tools/git-pulls.d.ts.map +0 -1
  135. package/dist/tools/git-pulls.js +0 -378
  136. package/dist/tools/git-pulls.js.map +0 -1
  137. package/dist/tools/git-release.d.ts +0 -161
  138. package/dist/tools/git-release.d.ts.map +0 -1
  139. package/dist/tools/git-release.js +0 -466
  140. package/dist/tools/git-release.js.map +0 -1
  141. package/dist/tools/git-remote.d.ts +0 -128
  142. package/dist/tools/git-remote.d.ts.map +0 -1
  143. package/dist/tools/git-remote.js +0 -542
  144. package/dist/tools/git-remote.js.map +0 -1
  145. package/dist/tools/git-reset.d.ts +0 -120
  146. package/dist/tools/git-reset.d.ts.map +0 -1
  147. package/dist/tools/git-reset.js +0 -479
  148. package/dist/tools/git-reset.js.map +0 -1
  149. package/dist/tools/git-stash.d.ts +0 -124
  150. package/dist/tools/git-stash.d.ts.map +0 -1
  151. package/dist/tools/git-stash.js +0 -506
  152. package/dist/tools/git-stash.js.map +0 -1
  153. package/dist/tools/git-sync.d.ts +0 -154
  154. package/dist/tools/git-sync.d.ts.map +0 -1
  155. package/dist/tools/git-sync.js +0 -479
  156. package/dist/tools/git-sync.js.map +0 -1
  157. package/dist/tools/git-tags.d.ts +0 -136
  158. package/dist/tools/git-tags.d.ts.map +0 -1
  159. package/dist/tools/git-tags.js +0 -470
  160. package/dist/tools/git-tags.js.map +0 -1
  161. package/dist/tools/git-update.d.ts +0 -224
  162. package/dist/tools/git-update.d.ts.map +0 -1
  163. package/dist/tools/git-update.js +0 -948
  164. package/dist/tools/git-update.js.map +0 -1
  165. package/dist/tools/git-workflow.d.ts +0 -189
  166. package/dist/tools/git-workflow.d.ts.map +0 -1
  167. package/dist/tools/git-workflow.js +0 -551
  168. package/dist/tools/git-workflow.js.map +0 -1
  169. package/dist/utils/credential-manager.d.ts +0 -119
  170. package/dist/utils/credential-manager.d.ts.map +0 -1
  171. package/dist/utils/credential-manager.js +0 -450
  172. package/dist/utils/credential-manager.js.map +0 -1
  173. package/dist/utils/data-merger.d.ts +0 -49
  174. package/dist/utils/data-merger.d.ts.map +0 -1
  175. package/dist/utils/data-merger.js +0 -233
  176. package/dist/utils/data-merger.js.map +0 -1
  177. package/dist/utils/git-command-executor.d.ts +0 -330
  178. package/dist/utils/git-command-executor.d.ts.map +0 -1
  179. package/dist/utils/git-command-executor.js +0 -901
  180. package/dist/utils/git-command-executor.js.map +0 -1
  181. package/dist/utils/logger.d.ts +0 -143
  182. package/dist/utils/logger.d.ts.map +0 -1
  183. package/dist/utils/logger.js +0 -473
  184. package/dist/utils/logger.js.map +0 -1
  185. package/dist/utils/operation-error-handler.d.ts +0 -97
  186. package/dist/utils/operation-error-handler.d.ts.map +0 -1
  187. package/dist/utils/operation-error-handler.js +0 -367
  188. package/dist/utils/operation-error-handler.js.map +0 -1
  189. package/dist/utils/parameter-validator.d.ts +0 -49
  190. package/dist/utils/parameter-validator.d.ts.map +0 -1
  191. package/dist/utils/parameter-validator.js +0 -647
  192. package/dist/utils/parameter-validator.js.map +0 -1
  193. package/dist/utils/repository-checker.d.ts +0 -46
  194. package/dist/utils/repository-checker.d.ts.map +0 -1
  195. package/dist/utils/repository-checker.js +0 -151
  196. package/dist/utils/repository-checker.js.map +0 -1
  197. package/dist/utils/repository-detector.d.ts +0 -128
  198. package/dist/utils/repository-detector.d.ts.map +0 -1
  199. package/dist/utils/repository-detector.js +0 -422
  200. package/dist/utils/repository-detector.js.map +0 -1
  201. package/dist/utils/repository-sync.d.ts +0 -67
  202. package/dist/utils/repository-sync.d.ts.map +0 -1
  203. package/dist/utils/repository-sync.js +0 -344
  204. package/dist/utils/repository-sync.js.map +0 -1
  205. package/dist/utils/response-formatter.d.ts +0 -146
  206. package/dist/utils/response-formatter.d.ts.map +0 -1
  207. package/dist/utils/response-formatter.js +0 -378
  208. package/dist/utils/response-formatter.js.map +0 -1
  209. package/dist/utils/retry.d.ts +0 -12
  210. package/dist/utils/retry.d.ts.map +0 -1
  211. package/dist/utils/retry.js +0 -28
  212. package/dist/utils/retry.js.map +0 -1
  213. package/dist/utils/safety-warnings.d.ts +0 -56
  214. package/dist/utils/safety-warnings.d.ts.map +0 -1
  215. package/dist/utils/safety-warnings.js +0 -330
  216. package/dist/utils/safety-warnings.js.map +0 -1
  217. package/dist/utils/terminal-controller.d.ts +0 -79
  218. package/dist/utils/terminal-controller.d.ts.map +0 -1
  219. package/dist/utils/terminal-controller.js +0 -291
  220. package/dist/utils/terminal-controller.js.map +0 -1
  221. package/dist/utils/user-friendly-formatter.d.ts +0 -45
  222. package/dist/utils/user-friendly-formatter.d.ts.map +0 -1
  223. package/dist/utils/user-friendly-formatter.js +0 -175
  224. package/dist/utils/user-friendly-formatter.js.map +0 -1
@@ -1,128 +0,0 @@
1
- /**
2
- * Git Remote Tool
3
- *
4
- * Comprehensive Git remote management tool providing remote repository operations.
5
- * Supports add, remove, rename, show, set-url, and prune operations.
6
- *
7
- * Operations: add, remove, rename, show, set-url, prune
8
- */
9
- import { ToolParams } from '../utils/parameter-validator.js';
10
- import { ToolResult } from '../utils/operation-error-handler.js';
11
- export interface GitRemoteParams extends ToolParams {
12
- action: 'add' | 'remove' | 'rename' | 'show' | 'set-url' | 'prune' | 'list';
13
- name?: string;
14
- url?: string;
15
- newName?: string;
16
- fetch?: boolean;
17
- push?: boolean;
18
- all?: boolean;
19
- verbose?: boolean;
20
- dryRun?: boolean;
21
- }
22
- export declare class GitRemoteTool {
23
- private gitExecutor;
24
- constructor();
25
- /**
26
- * Execute git-remote operation
27
- */
28
- execute(params: GitRemoteParams): Promise<ToolResult>;
29
- /**
30
- * Validate operation-specific parameters
31
- */
32
- private validateOperationParams;
33
- /**
34
- * Handle git remote add operation
35
- */
36
- private handleAdd;
37
- /**
38
- * Handle git remote remove operation
39
- */
40
- private handleRemove;
41
- /**
42
- * Handle git remote rename operation
43
- */
44
- private handleRename;
45
- /**
46
- * Handle git remote show operation
47
- */
48
- private handleShow;
49
- /**
50
- * Handle git remote set-url operation
51
- */
52
- private handleSetUrl;
53
- /**
54
- * Handle git remote prune operation
55
- */
56
- private handlePrune;
57
- /**
58
- * Handle list remotes
59
- */
60
- private handleList;
61
- /**
62
- * Parse remote details from git remote show output
63
- */
64
- private parseRemoteDetails;
65
- /**
66
- * Parse verbose remotes output
67
- */
68
- private parseVerboseRemotes;
69
- /**
70
- * Parse pruned branches from git remote prune output
71
- */
72
- private parsePrunedBranches;
73
- /**
74
- * Get tool schema for MCP registration
75
- */
76
- static getToolSchema(): {
77
- name: string;
78
- description: string;
79
- inputSchema: {
80
- type: string;
81
- properties: {
82
- action: {
83
- type: string;
84
- enum: string[];
85
- description: string;
86
- };
87
- projectPath: {
88
- type: string;
89
- description: string;
90
- };
91
- name: {
92
- type: string;
93
- description: string;
94
- };
95
- url: {
96
- type: string;
97
- description: string;
98
- };
99
- newName: {
100
- type: string;
101
- description: string;
102
- };
103
- fetch: {
104
- type: string;
105
- description: string;
106
- };
107
- push: {
108
- type: string;
109
- description: string;
110
- };
111
- all: {
112
- type: string;
113
- description: string;
114
- };
115
- verbose: {
116
- type: string;
117
- description: string;
118
- };
119
- dryRun: {
120
- type: string;
121
- description: string;
122
- };
123
- };
124
- required: string[];
125
- };
126
- };
127
- }
128
- //# sourceMappingURL=git-remote.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-remote.d.ts","sourceRoot":"","sources":["../../src/tools/git-remote.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAsB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAyB,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGxF,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAG5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAqB;;IAMxC;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IA8E3D;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAgE/B;;OAEG;YACW,SAAS;IA8CvB;;OAEG;YACW,YAAY;IA+C1B;;OAEG;YACW,YAAY;IAyD1B;;OAEG;YACW,UAAU;IA4DxB;;OAEG;YACW,YAAY;IA0D1B;;OAEG;YACW,WAAW;IA+DzB;;OAEG;YACW,UAAU;IAsCxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgC3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;OAEG;IACH,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDrB"}
@@ -1,542 +0,0 @@
1
- "use strict";
2
- /**
3
- * Git Remote Tool
4
- *
5
- * Comprehensive Git remote management tool providing remote repository operations.
6
- * Supports add, remove, rename, show, set-url, and prune operations.
7
- *
8
- * Operations: add, remove, rename, show, set-url, prune
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GitRemoteTool = void 0;
12
- const git_command_executor_js_1 = require("../utils/git-command-executor.js");
13
- const parameter_validator_js_1 = require("../utils/parameter-validator.js");
14
- const operation_error_handler_js_1 = require("../utils/operation-error-handler.js");
15
- class GitRemoteTool {
16
- gitExecutor;
17
- constructor() {
18
- this.gitExecutor = new git_command_executor_js_1.GitCommandExecutor();
19
- }
20
- /**
21
- * Execute git-remote operation
22
- */
23
- async execute(params) {
24
- const startTime = Date.now();
25
- try {
26
- // Validate basic parameters
27
- const validation = parameter_validator_js_1.ParameterValidator.validateToolParams('git-remote', params);
28
- if (!validation.isValid) {
29
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('VALIDATION_ERROR', `Parameter validation failed: ${validation.errors.join(', ')}`, params.action, { validationErrors: validation.errors }, validation.suggestions);
30
- }
31
- // Validate operation-specific parameters
32
- const operationValidation = this.validateOperationParams(params);
33
- if (!operationValidation.isValid) {
34
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('VALIDATION_ERROR', `Operation validation failed: ${operationValidation.errors.join(', ')}`, params.action, { validationErrors: operationValidation.errors }, operationValidation.suggestions);
35
- }
36
- // Check if it's a Git repository
37
- const isRepo = await this.gitExecutor.isGitRepository(params.projectPath);
38
- if (!isRepo) {
39
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('NOT_A_GIT_REPOSITORY', 'The specified path is not a Git repository', params.action, { projectPath: params.projectPath }, ['Initialize a Git repository first with: git init']);
40
- }
41
- // Route to appropriate handler
42
- switch (params.action) {
43
- case 'add':
44
- return await this.handleAdd(params, startTime);
45
- case 'remove':
46
- return await this.handleRemove(params, startTime);
47
- case 'rename':
48
- return await this.handleRename(params, startTime);
49
- case 'show':
50
- return await this.handleShow(params, startTime);
51
- case 'set-url':
52
- return await this.handleSetUrl(params, startTime);
53
- case 'prune':
54
- return await this.handlePrune(params, startTime);
55
- case 'list':
56
- return await this.handleList(params, startTime);
57
- default:
58
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('UNSUPPORTED_OPERATION', `Operation '${params.action}' is not supported`, params.action, {}, ['Use one of: add, remove, rename, show, set-url, prune, list']);
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
- * Validate operation-specific parameters
68
- */
69
- validateOperationParams(params) {
70
- const errors = [];
71
- const suggestions = [];
72
- switch (params.action) {
73
- case 'add':
74
- if (!params.name) {
75
- errors.push('Remote name is required for add operation');
76
- suggestions.push('Provide a remote name (e.g., "origin", "upstream")');
77
- }
78
- if (!params.url) {
79
- errors.push('Remote URL is required for add operation');
80
- suggestions.push('Provide a remote URL (e.g., "https://github.com/user/repo.git")');
81
- }
82
- break;
83
- case 'remove':
84
- if (!params.name) {
85
- errors.push('Remote name is required for remove operation');
86
- suggestions.push('Provide the name of the remote to remove');
87
- }
88
- break;
89
- case 'rename':
90
- if (!params.name) {
91
- errors.push('Current remote name is required for rename operation');
92
- suggestions.push('Provide the current remote name');
93
- }
94
- if (!params.newName) {
95
- errors.push('New remote name is required for rename operation');
96
- suggestions.push('Provide the new remote name');
97
- }
98
- break;
99
- case 'set-url':
100
- if (!params.name) {
101
- errors.push('Remote name is required for set-url operation');
102
- suggestions.push('Provide the remote name to update');
103
- }
104
- if (!params.url) {
105
- errors.push('Remote URL is required for set-url operation');
106
- suggestions.push('Provide the new remote URL');
107
- }
108
- break;
109
- case 'prune':
110
- if (!params.name) {
111
- errors.push('Remote name is required for prune operation');
112
- suggestions.push('Provide the remote name to prune (e.g., "origin")');
113
- }
114
- break;
115
- case 'show':
116
- // Show operation can work without parameters (shows all remotes)
117
- break;
118
- }
119
- return {
120
- isValid: errors.length === 0,
121
- errors,
122
- suggestions
123
- };
124
- }
125
- /**
126
- * Handle git remote add operation
127
- */
128
- async handleAdd(params, startTime) {
129
- try {
130
- const args = [params.name, params.url];
131
- // Add fetch option if specified
132
- if (params.fetch) {
133
- args.unshift('-f');
134
- }
135
- const result = await this.gitExecutor.executeGitCommand('remote', ['add', ...args], params.projectPath);
136
- if (!result.success) {
137
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote add', params.projectPath);
138
- }
139
- // If fetch was requested, the output will include fetch information
140
- const message = params.fetch
141
- ? `Remote '${params.name}' added and fetched successfully`
142
- : `Remote '${params.name}' added successfully`;
143
- return {
144
- success: true,
145
- data: {
146
- message,
147
- remoteName: params.name,
148
- remoteUrl: params.url,
149
- fetched: params.fetch || false,
150
- output: result.stdout
151
- },
152
- metadata: {
153
- operation: 'remote add',
154
- timestamp: new Date().toISOString(),
155
- executionTime: Date.now() - startTime
156
- }
157
- };
158
- }
159
- catch (error) {
160
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
161
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_ADD_ERROR', `Failed to add remote: ${errorMessage}`, 'add', { error: errorMessage, remoteName: params.name, remoteUrl: params.url });
162
- }
163
- }
164
- /**
165
- * Handle git remote remove operation
166
- */
167
- async handleRemove(params, startTime) {
168
- try {
169
- // Check if remote exists first
170
- const showResult = await this.gitExecutor.executeGitCommand('remote', ['show'], params.projectPath);
171
- if (showResult.success) {
172
- const remotes = showResult.stdout.split('\n').filter(line => line.trim());
173
- if (!remotes.includes(params.name)) {
174
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_NOT_FOUND', `Remote '${params.name}' does not exist`, 'remove', { remoteName: params.name, availableRemotes: remotes }, [`Available remotes: ${remotes.join(', ')}`]);
175
- }
176
- }
177
- const result = await this.gitExecutor.executeGitCommand('remote', ['remove', params.name], params.projectPath);
178
- if (!result.success) {
179
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote remove', params.projectPath);
180
- }
181
- return {
182
- success: true,
183
- data: {
184
- message: `Remote '${params.name}' removed successfully`,
185
- remoteName: params.name,
186
- output: result.stdout
187
- },
188
- metadata: {
189
- operation: 'remote remove',
190
- timestamp: new Date().toISOString(),
191
- executionTime: Date.now() - startTime
192
- }
193
- };
194
- }
195
- catch (error) {
196
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
197
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_REMOVE_ERROR', `Failed to remove remote: ${errorMessage}`, 'remove', { error: errorMessage, remoteName: params.name });
198
- }
199
- }
200
- /**
201
- * Handle git remote rename operation
202
- */
203
- async handleRename(params, startTime) {
204
- try {
205
- // Check if current remote exists
206
- const showResult = await this.gitExecutor.executeGitCommand('remote', ['show'], params.projectPath);
207
- if (showResult.success) {
208
- const remotes = showResult.stdout.split('\n').filter(line => line.trim());
209
- if (!remotes.includes(params.name)) {
210
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_NOT_FOUND', `Remote '${params.name}' does not exist`, 'rename', { remoteName: params.name, availableRemotes: remotes }, [`Available remotes: ${remotes.join(', ')}`]);
211
- }
212
- if (remotes.includes(params.newName)) {
213
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_ALREADY_EXISTS', `Remote '${params.newName}' already exists`, 'rename', { newRemoteName: params.newName, availableRemotes: remotes }, ['Choose a different name for the remote']);
214
- }
215
- }
216
- const result = await this.gitExecutor.executeGitCommand('remote', ['rename', params.name, params.newName], params.projectPath);
217
- if (!result.success) {
218
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote rename', params.projectPath);
219
- }
220
- return {
221
- success: true,
222
- data: {
223
- message: `Remote '${params.name}' renamed to '${params.newName}' successfully`,
224
- oldName: params.name,
225
- newName: params.newName,
226
- output: result.stdout
227
- },
228
- metadata: {
229
- operation: 'remote rename',
230
- timestamp: new Date().toISOString(),
231
- executionTime: Date.now() - startTime
232
- }
233
- };
234
- }
235
- catch (error) {
236
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
237
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_RENAME_ERROR', `Failed to rename remote: ${errorMessage}`, 'rename', { error: errorMessage, oldName: params.name, newName: params.newName });
238
- }
239
- }
240
- /**
241
- * Handle git remote show operation
242
- */
243
- async handleShow(params, startTime) {
244
- try {
245
- const args = [];
246
- if (params.verbose) {
247
- args.push('-v');
248
- }
249
- if (params.name && !params.all) {
250
- // Show specific remote details
251
- args.push(params.name);
252
- }
253
- const result = await this.gitExecutor.executeGitCommand('remote', ['show', ...args], params.projectPath);
254
- if (!result.success) {
255
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote show', params.projectPath);
256
- }
257
- // Parse the output
258
- const output = result.stdout.trim();
259
- let parsedData = { raw: output };
260
- if (params.name && !params.all) {
261
- // Detailed remote information
262
- parsedData.remoteName = params.name;
263
- parsedData.details = this.parseRemoteDetails(output);
264
- }
265
- else {
266
- // List of remotes
267
- const lines = output.split('\n').filter(line => line.trim());
268
- if (params.verbose) {
269
- parsedData.remotes = this.parseVerboseRemotes(lines);
270
- }
271
- else {
272
- parsedData.remotes = lines;
273
- }
274
- }
275
- return {
276
- success: true,
277
- data: {
278
- message: params.name ? `Remote '${params.name}' details` : 'Remote repositories',
279
- ...parsedData
280
- },
281
- metadata: {
282
- operation: 'remote show',
283
- timestamp: new Date().toISOString(),
284
- executionTime: Date.now() - startTime
285
- }
286
- };
287
- }
288
- catch (error) {
289
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
290
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_SHOW_ERROR', `Failed to show remote information: ${errorMessage}`, 'show', { error: errorMessage, remoteName: params.name });
291
- }
292
- }
293
- /**
294
- * Handle git remote set-url operation
295
- */
296
- async handleSetUrl(params, startTime) {
297
- try {
298
- // Check if remote exists
299
- const showResult = await this.gitExecutor.executeGitCommand('remote', ['show'], params.projectPath);
300
- if (showResult.success) {
301
- const remotes = showResult.stdout.split('\n').filter(line => line.trim());
302
- if (!remotes.includes(params.name)) {
303
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_NOT_FOUND', `Remote '${params.name}' does not exist`, 'set-url', { remoteName: params.name, availableRemotes: remotes }, [`Available remotes: ${remotes.join(', ')}`]);
304
- }
305
- }
306
- const args = [params.name, params.url];
307
- // Add push option if specified
308
- if (params.push) {
309
- args.unshift('--push');
310
- }
311
- const result = await this.gitExecutor.executeGitCommand('remote', ['set-url', ...args], params.projectPath);
312
- if (!result.success) {
313
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote set-url', params.projectPath);
314
- }
315
- const urlType = params.push ? 'push URL' : 'URL';
316
- return {
317
- success: true,
318
- data: {
319
- message: `Remote '${params.name}' ${urlType} updated successfully`,
320
- remoteName: params.name,
321
- newUrl: params.url,
322
- urlType: params.push ? 'push' : 'fetch',
323
- output: result.stdout
324
- },
325
- metadata: {
326
- operation: 'remote set-url',
327
- timestamp: new Date().toISOString(),
328
- executionTime: Date.now() - startTime
329
- }
330
- };
331
- }
332
- catch (error) {
333
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
334
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_SET_URL_ERROR', `Failed to set remote URL: ${errorMessage}`, 'set-url', { error: errorMessage, remoteName: params.name, url: params.url });
335
- }
336
- }
337
- /**
338
- * Handle git remote prune operation
339
- */
340
- async handlePrune(params, startTime) {
341
- try {
342
- // Check if remote exists
343
- const showResult = await this.gitExecutor.executeGitCommand('remote', ['show'], params.projectPath);
344
- if (showResult.success) {
345
- const remotes = showResult.stdout.split('\n').filter(line => line.trim());
346
- if (!remotes.includes(params.name)) {
347
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_NOT_FOUND', `Remote '${params.name}' does not exist`, 'prune', { remoteName: params.name, availableRemotes: remotes }, [`Available remotes: ${remotes.join(', ')}`]);
348
- }
349
- }
350
- const args = [params.name];
351
- // Add dry-run option if specified
352
- if (params.dryRun) {
353
- args.unshift('--dry-run');
354
- }
355
- const result = await this.gitExecutor.executeGitCommand('remote', ['prune', ...args], params.projectPath);
356
- if (!result.success) {
357
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote prune', params.projectPath);
358
- }
359
- // Parse pruned branches from output
360
- const prunedBranches = this.parsePrunedBranches(result.stdout);
361
- const message = params.dryRun
362
- ? `Dry run: Would prune ${prunedBranches.length} stale branches from '${params.name}'`
363
- : `Pruned ${prunedBranches.length} stale branches from '${params.name}'`;
364
- return {
365
- success: true,
366
- data: {
367
- message,
368
- remoteName: params.name,
369
- dryRun: params.dryRun || false,
370
- prunedBranches,
371
- output: result.stdout
372
- },
373
- metadata: {
374
- operation: 'remote prune',
375
- timestamp: new Date().toISOString(),
376
- executionTime: Date.now() - startTime
377
- }
378
- };
379
- }
380
- catch (error) {
381
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
382
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_PRUNE_ERROR', `Failed to prune remote: ${errorMessage}`, 'prune', { error: errorMessage, remoteName: params.name });
383
- }
384
- }
385
- /**
386
- * Handle list remotes
387
- */
388
- async handleList(params, startTime) {
389
- try {
390
- const result = await this.gitExecutor.executeGitCommand('remote', [], params.projectPath);
391
- if (!result.success) {
392
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'remote list', params.projectPath);
393
- }
394
- // Parse remotes from output
395
- const remotes = result.stdout
396
- .split('\n')
397
- .map(line => line.trim())
398
- .filter(line => line.length > 0);
399
- return {
400
- success: true,
401
- data: {
402
- operation: 'list',
403
- message: `Found ${remotes.length} remote(s)`,
404
- details: {
405
- remotes,
406
- count: remotes.length
407
- },
408
- duration: Date.now() - startTime
409
- }
410
- };
411
- }
412
- catch (error) {
413
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
414
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('REMOTE_LIST_ERROR', `Failed to list remotes: ${errorMessage}`, 'list', { error: errorMessage });
415
- }
416
- }
417
- /**
418
- * Parse remote details from git remote show output
419
- */
420
- parseRemoteDetails(output) {
421
- const lines = output.split('\n');
422
- const details = {};
423
- for (const line of lines) {
424
- const trimmed = line.trim();
425
- if (trimmed.includes('Fetch URL:')) {
426
- details.fetchUrl = trimmed.split('Fetch URL:')[1]?.trim();
427
- }
428
- else if (trimmed.includes('Push URL:')) {
429
- details.pushUrl = trimmed.split('Push URL:')[1]?.trim();
430
- }
431
- else if (trimmed.includes('HEAD branch:')) {
432
- details.headBranch = trimmed.split('HEAD branch:')[1]?.trim();
433
- }
434
- }
435
- return details;
436
- }
437
- /**
438
- * Parse verbose remotes output
439
- */
440
- parseVerboseRemotes(lines) {
441
- const remotes = [];
442
- const remoteMap = new Map();
443
- for (const line of lines) {
444
- const parts = line.split('\t');
445
- if (parts.length >= 2) {
446
- const name = parts[0].trim();
447
- const urlAndType = parts[1].trim();
448
- const urlMatch = urlAndType.match(/^(.+?)\s+\((.+)\)$/);
449
- if (urlMatch) {
450
- const url = urlMatch[1];
451
- const type = urlMatch[2];
452
- if (!remoteMap.has(name)) {
453
- remoteMap.set(name, { name });
454
- }
455
- const remote = remoteMap.get(name);
456
- if (type === 'fetch') {
457
- remote.fetchUrl = url;
458
- }
459
- else if (type === 'push') {
460
- remote.pushUrl = url;
461
- }
462
- }
463
- }
464
- }
465
- return Array.from(remoteMap.values());
466
- }
467
- /**
468
- * Parse pruned branches from git remote prune output
469
- */
470
- parsePrunedBranches(output) {
471
- const lines = output.split('\n');
472
- const prunedBranches = [];
473
- for (const line of lines) {
474
- const trimmed = line.trim();
475
- if (trimmed.startsWith('* [would prune]') || trimmed.startsWith('* [pruned]')) {
476
- const branchMatch = trimmed.match(/\* \[(would prune|pruned)\] (.+)/);
477
- if (branchMatch) {
478
- prunedBranches.push(branchMatch[2]);
479
- }
480
- }
481
- }
482
- return prunedBranches;
483
- }
484
- /**
485
- * Get tool schema for MCP registration
486
- */
487
- static getToolSchema() {
488
- return {
489
- name: 'git-remote',
490
- description: 'Git remote management tool for managing remote repositories. Supports add, remove, rename, show, set-url, and prune operations.',
491
- inputSchema: {
492
- type: 'object',
493
- properties: {
494
- action: {
495
- type: 'string',
496
- enum: ['add', 'remove', 'rename', 'show', 'set-url', 'prune', 'list'],
497
- description: 'The remote operation to perform'
498
- },
499
- projectPath: {
500
- type: 'string',
501
- description: 'Absolute path to the project directory'
502
- },
503
- name: {
504
- type: 'string',
505
- description: 'Remote name (required for most operations)'
506
- },
507
- url: {
508
- type: 'string',
509
- description: 'Remote URL (required for add and set-url operations)'
510
- },
511
- newName: {
512
- type: 'string',
513
- description: 'New remote name (required for rename operation)'
514
- },
515
- fetch: {
516
- type: 'boolean',
517
- description: 'Fetch after adding remote (for add action)'
518
- },
519
- push: {
520
- type: 'boolean',
521
- description: 'Set push URL instead of fetch URL (for set-url action)'
522
- },
523
- all: {
524
- type: 'boolean',
525
- description: 'Show all remotes (for show action)'
526
- },
527
- verbose: {
528
- type: 'boolean',
529
- description: 'Show verbose output with URLs (for show action)'
530
- },
531
- dryRun: {
532
- type: 'boolean',
533
- description: 'Show what would be pruned without actually pruning (for prune action)'
534
- }
535
- },
536
- required: ['action', 'projectPath']
537
- }
538
- };
539
- }
540
- }
541
- exports.GitRemoteTool = GitRemoteTool;
542
- //# sourceMappingURL=git-remote.js.map