@andrebuzeli/git-mcp 5.0.4 → 5.0.6

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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -89
  3. package/dist/config.d.ts +72 -71
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +226 -139
  6. package/dist/config.js.map +1 -1
  7. package/dist/index.d.ts +15 -17
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +133 -128
  10. package/dist/index.js.map +1 -1
  11. package/dist/providers/base-provider.d.ts +42 -153
  12. package/dist/providers/base-provider.d.ts.map +1 -1
  13. package/dist/providers/base-provider.js +42 -302
  14. package/dist/providers/base-provider.js.map +1 -1
  15. package/dist/providers/gitea-provider.d.ts +67 -118
  16. package/dist/providers/gitea-provider.d.ts.map +1 -1
  17. package/dist/providers/gitea-provider.js +487 -1161
  18. package/dist/providers/gitea-provider.js.map +1 -1
  19. package/dist/providers/github-provider.d.ts +70 -81
  20. package/dist/providers/github-provider.d.ts.map +1 -1
  21. package/dist/providers/github-provider.js +641 -278
  22. package/dist/providers/github-provider.js.map +1 -1
  23. package/dist/providers/index.d.ts +9 -9
  24. package/dist/providers/index.d.ts.map +1 -1
  25. package/dist/providers/index.js +13 -19
  26. package/dist/providers/index.js.map +1 -1
  27. package/dist/providers/provider-factory.d.ts +29 -59
  28. package/dist/providers/provider-factory.d.ts.map +1 -1
  29. package/dist/providers/provider-factory.js +134 -265
  30. package/dist/providers/provider-factory.js.map +1 -1
  31. package/dist/providers/provider-operation-handler.d.ts +93 -0
  32. package/dist/providers/provider-operation-handler.d.ts.map +1 -0
  33. package/dist/providers/provider-operation-handler.js +280 -0
  34. package/dist/providers/provider-operation-handler.js.map +1 -0
  35. package/dist/providers/types.d.ts +201 -355
  36. package/dist/providers/types.d.ts.map +1 -1
  37. package/dist/providers/types.js +3 -2
  38. package/dist/providers/types.js.map +1 -1
  39. package/dist/server.d.ts +34 -4
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +439 -262
  42. package/dist/server.js.map +1 -1
  43. package/dist/tools/git-analytics.d.ts +239 -16
  44. package/dist/tools/git-analytics.d.ts.map +1 -1
  45. package/dist/tools/git-analytics.js +737 -25
  46. package/dist/tools/git-analytics.js.map +1 -1
  47. package/dist/tools/git-archive.d.ts +109 -15
  48. package/dist/tools/git-archive.d.ts.map +1 -1
  49. package/dist/tools/git-archive.js +462 -10
  50. package/dist/tools/git-archive.js.map +1 -1
  51. package/dist/tools/git-backup.d.ts +101 -15
  52. package/dist/tools/git-backup.d.ts.map +1 -1
  53. package/dist/tools/git-backup.js +410 -10
  54. package/dist/tools/git-backup.js.map +1 -1
  55. package/dist/tools/git-branches.d.ts +141 -15
  56. package/dist/tools/git-branches.d.ts.map +1 -1
  57. package/dist/tools/git-branches.js +466 -11
  58. package/dist/tools/git-branches.js.map +1 -1
  59. package/dist/tools/git-config.d.ts +115 -15
  60. package/dist/tools/git-config.d.ts.map +1 -1
  61. package/dist/tools/git-config.js +446 -11
  62. package/dist/tools/git-config.js.map +1 -1
  63. package/dist/tools/git-files.d.ts +179 -59
  64. package/dist/tools/git-files.d.ts.map +1 -1
  65. package/dist/tools/git-files.js +682 -222
  66. package/dist/tools/git-files.js.map +1 -1
  67. package/dist/tools/git-issues.d.ts +158 -15
  68. package/dist/tools/git-issues.d.ts.map +1 -1
  69. package/dist/tools/git-issues.js +323 -11
  70. package/dist/tools/git-issues.js.map +1 -1
  71. package/dist/tools/git-monitor.d.ts +149 -14
  72. package/dist/tools/git-monitor.d.ts.map +1 -1
  73. package/dist/tools/git-monitor.js +528 -11
  74. package/dist/tools/git-monitor.js.map +1 -1
  75. package/dist/tools/git-packages.d.ts +163 -15
  76. package/dist/tools/git-packages.d.ts.map +1 -1
  77. package/dist/tools/git-packages.js +526 -11
  78. package/dist/tools/git-packages.js.map +1 -1
  79. package/dist/tools/git-pulls.d.ts +174 -15
  80. package/dist/tools/git-pulls.d.ts.map +1 -1
  81. package/dist/tools/git-pulls.js +352 -11
  82. package/dist/tools/git-pulls.js.map +1 -1
  83. package/dist/tools/git-release.d.ts +167 -15
  84. package/dist/tools/git-release.d.ts.map +1 -1
  85. package/dist/tools/git-release.js +465 -11
  86. package/dist/tools/git-release.js.map +1 -1
  87. package/dist/tools/git-remote.d.ts +124 -15
  88. package/dist/tools/git-remote.d.ts.map +1 -1
  89. package/dist/tools/git-remote.js +539 -11
  90. package/dist/tools/git-remote.js.map +1 -1
  91. package/dist/tools/git-reset.d.ts +100 -15
  92. package/dist/tools/git-reset.d.ts.map +1 -1
  93. package/dist/tools/git-reset.js +409 -11
  94. package/dist/tools/git-reset.js.map +1 -1
  95. package/dist/tools/git-stash.d.ts +120 -15
  96. package/dist/tools/git-stash.d.ts.map +1 -1
  97. package/dist/tools/git-stash.js +503 -11
  98. package/dist/tools/git-stash.js.map +1 -1
  99. package/dist/tools/git-sync.d.ts +160 -16
  100. package/dist/tools/git-sync.d.ts.map +1 -1
  101. package/dist/tools/git-sync.js +462 -113
  102. package/dist/tools/git-sync.js.map +1 -1
  103. package/dist/tools/git-tags.d.ts +142 -15
  104. package/dist/tools/git-tags.d.ts.map +1 -1
  105. package/dist/tools/git-tags.js +471 -11
  106. package/dist/tools/git-tags.js.map +1 -1
  107. package/dist/tools/git-workflow.d.ts +151 -80
  108. package/dist/tools/git-workflow.d.ts.map +1 -1
  109. package/dist/tools/git-workflow.js +407 -912
  110. package/dist/tools/git-workflow.js.map +1 -1
  111. package/dist/utils/credential-manager.d.ts +119 -0
  112. package/dist/utils/credential-manager.d.ts.map +1 -0
  113. package/dist/utils/credential-manager.js +450 -0
  114. package/dist/utils/credential-manager.js.map +1 -0
  115. package/dist/utils/git-command-executor.d.ts +326 -0
  116. package/dist/utils/git-command-executor.d.ts.map +1 -0
  117. package/dist/utils/git-command-executor.js +877 -0
  118. package/dist/utils/git-command-executor.js.map +1 -0
  119. package/dist/utils/logger.d.ts +143 -0
  120. package/dist/utils/logger.d.ts.map +1 -0
  121. package/dist/utils/logger.js +473 -0
  122. package/dist/utils/logger.js.map +1 -0
  123. package/dist/utils/operation-error-handler.d.ts +54 -41
  124. package/dist/utils/operation-error-handler.d.ts.map +1 -1
  125. package/dist/utils/operation-error-handler.js +211 -227
  126. package/dist/utils/operation-error-handler.js.map +1 -1
  127. package/dist/utils/parameter-validator.d.ts +41 -0
  128. package/dist/utils/parameter-validator.d.ts.map +1 -0
  129. package/dist/utils/parameter-validator.js +464 -0
  130. package/dist/utils/parameter-validator.js.map +1 -0
  131. package/dist/utils/repository-detector.d.ts +128 -0
  132. package/dist/utils/repository-detector.d.ts.map +1 -0
  133. package/dist/utils/repository-detector.js +422 -0
  134. package/dist/utils/repository-detector.js.map +1 -0
  135. package/dist/utils/response-formatter.d.ts +146 -0
  136. package/dist/utils/response-formatter.d.ts.map +1 -0
  137. package/dist/utils/response-formatter.js +378 -0
  138. package/dist/utils/response-formatter.js.map +1 -0
  139. package/dist/utils/retry.d.ts +12 -0
  140. package/dist/utils/retry.d.ts.map +1 -0
  141. package/dist/utils/retry.js +28 -0
  142. package/dist/utils/retry.js.map +1 -0
  143. package/dist/utils/terminal-controller.d.ts +73 -139
  144. package/dist/utils/terminal-controller.d.ts.map +1 -1
  145. package/dist/utils/terminal-controller.js +234 -459
  146. package/dist/utils/terminal-controller.js.map +1 -1
  147. package/package.json +79 -60
  148. package/dist/providers/error-handler.d.ts +0 -51
  149. package/dist/providers/error-handler.d.ts.map +0 -1
  150. package/dist/providers/error-handler.js +0 -176
  151. package/dist/providers/error-handler.js.map +0 -1
  152. package/dist/providers/github-provider-backup.d.ts +0 -81
  153. package/dist/providers/github-provider-backup.d.ts.map +0 -1
  154. package/dist/providers/github-provider-backup.js +0 -1179
  155. package/dist/providers/github-provider-backup.js.map +0 -1
  156. package/dist/providers/github-provider-complete.d.ts +0 -1
  157. package/dist/providers/github-provider-complete.d.ts.map +0 -1
  158. package/dist/providers/github-provider-complete.js +0 -2
  159. package/dist/providers/github-provider-complete.js.map +0 -1
  160. package/dist/tools/git-init.d.ts +0 -50
  161. package/dist/tools/git-init.d.ts.map +0 -1
  162. package/dist/tools/git-init.js +0 -258
  163. package/dist/tools/git-init.js.map +0 -1
  164. package/dist/tools/git-log.d.ts +0 -67
  165. package/dist/tools/git-log.d.ts.map +0 -1
  166. package/dist/tools/git-log.js +0 -320
  167. package/dist/tools/git-log.js.map +0 -1
  168. package/dist/tools/git-status.d.ts +0 -29
  169. package/dist/tools/git-status.d.ts.map +0 -1
  170. package/dist/tools/git-status.js +0 -182
  171. package/dist/tools/git-status.js.map +0 -1
  172. package/dist/tools/git-update.d.ts +0 -34
  173. package/dist/tools/git-update.d.ts.map +0 -1
  174. package/dist/tools/git-update.js +0 -191
  175. package/dist/tools/git-update.js.map +0 -1
  176. package/dist/utils/auto-detection.d.ts +0 -120
  177. package/dist/utils/auto-detection.d.ts.map +0 -1
  178. package/dist/utils/auto-detection.js +0 -259
  179. package/dist/utils/auto-detection.js.map +0 -1
  180. package/dist/utils/configuration-error-generator.d.ts +0 -41
  181. package/dist/utils/configuration-error-generator.d.ts.map +0 -1
  182. package/dist/utils/configuration-error-generator.js +0 -168
  183. package/dist/utils/configuration-error-generator.js.map +0 -1
  184. package/dist/utils/configuration-validator.d.ts +0 -67
  185. package/dist/utils/configuration-validator.d.ts.map +0 -1
  186. package/dist/utils/configuration-validator.js +0 -257
  187. package/dist/utils/configuration-validator.js.map +0 -1
  188. package/dist/utils/error-handler.d.ts +0 -107
  189. package/dist/utils/error-handler.d.ts.map +0 -1
  190. package/dist/utils/error-handler.js +0 -331
  191. package/dist/utils/error-handler.js.map +0 -1
  192. package/dist/utils/git-operations.d.ts +0 -200
  193. package/dist/utils/git-operations.d.ts.map +0 -1
  194. package/dist/utils/git-operations.js +0 -836
  195. package/dist/utils/git-operations.js.map +0 -1
  196. package/dist/utils/multi-provider-error-handler.d.ts +0 -75
  197. package/dist/utils/multi-provider-error-handler.d.ts.map +0 -1
  198. package/dist/utils/multi-provider-error-handler.js +0 -276
  199. package/dist/utils/multi-provider-error-handler.js.map +0 -1
  200. package/dist/utils/multi-provider-operation-handler.d.ts +0 -113
  201. package/dist/utils/multi-provider-operation-handler.d.ts.map +0 -1
  202. package/dist/utils/multi-provider-operation-handler.js +0 -303
  203. package/dist/utils/multi-provider-operation-handler.js.map +0 -1
  204. package/dist/utils/provider-operation-handler.d.ts +0 -80
  205. package/dist/utils/provider-operation-handler.d.ts.map +0 -1
  206. package/dist/utils/provider-operation-handler.js +0 -201
  207. package/dist/utils/provider-operation-handler.js.map +0 -1
  208. package/dist/utils/response-helper.d.ts +0 -57
  209. package/dist/utils/response-helper.d.ts.map +0 -1
  210. package/dist/utils/response-helper.js +0 -54
  211. package/dist/utils/response-helper.js.map +0 -1
  212. package/dist/utils/user-detection.d.ts +0 -25
  213. package/dist/utils/user-detection.d.ts.map +0 -1
  214. package/dist/utils/user-detection.js +0 -54
  215. package/dist/utils/user-detection.js.map +0 -1
@@ -1,19 +1,124 @@
1
- import { UniversalResponse } from '../utils/auto-detection.js';
2
- export declare const gitStashTool: {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- action: {
9
- type: string;
10
- };
11
- projectPath: {
12
- type: string;
1
+ /**
2
+ * Git Stash Tool
3
+ *
4
+ * Comprehensive Git stash tool providing stash management operations.
5
+ * Supports stash, pop, apply, list, show, drop, clear operations for temporary changes storage.
6
+ *
7
+ * Operations: stash, pop, apply, list, show, drop, clear
8
+ */
9
+ import { ToolParams } from '../utils/parameter-validator.js';
10
+ import { ToolResult } from '../utils/operation-error-handler.js';
11
+ export interface GitStashParams extends ToolParams {
12
+ action: 'stash' | 'pop' | 'apply' | 'list' | 'show' | 'drop' | 'clear';
13
+ message?: string;
14
+ stashRef?: string;
15
+ includeUntracked?: boolean;
16
+ keepIndex?: boolean;
17
+ patch?: boolean;
18
+ quiet?: boolean;
19
+ index?: boolean;
20
+ oneline?: boolean;
21
+ }
22
+ export declare class GitStashTool {
23
+ private gitExecutor;
24
+ constructor();
25
+ /**
26
+ * Execute git-stash operation
27
+ */
28
+ execute(params: GitStashParams): Promise<ToolResult>;
29
+ /**
30
+ * Validate operation-specific parameters
31
+ */
32
+ private validateOperationParams;
33
+ /**
34
+ * Validate stash reference format
35
+ */
36
+ private isValidStashRef;
37
+ /**
38
+ * Handle git stash operation (save current changes)
39
+ */
40
+ private handleStash;
41
+ /**
42
+ * Handle git stash pop operation (apply and remove latest stash)
43
+ */
44
+ private handlePop;
45
+ /**
46
+ * Handle git stash apply operation (apply stash without removing)
47
+ */
48
+ private handleApply; /**
49
+
50
+ * Handle git stash list operation (show all stashes)
51
+ */
52
+ private handleList;
53
+ /**
54
+ * Handle git stash show operation (show stash contents)
55
+ */
56
+ private handleShow;
57
+ /**
58
+ * Handle git stash drop operation (remove specific stash)
59
+ */
60
+ private handleDrop;
61
+ /**
62
+ * Handle git stash clear operation (remove all stashes)
63
+ */
64
+ private handleClear;
65
+ /**
66
+ * Normalize stash reference to proper format
67
+ */
68
+ private normalizeStashRef;
69
+ /**
70
+ * Get tool schema for MCP registration
71
+ */
72
+ static getToolSchema(): {
73
+ name: string;
74
+ description: string;
75
+ inputSchema: {
76
+ type: string;
77
+ properties: {
78
+ action: {
79
+ type: string;
80
+ enum: string[];
81
+ description: string;
82
+ };
83
+ projectPath: {
84
+ type: string;
85
+ description: string;
86
+ };
87
+ message: {
88
+ type: string;
89
+ description: string;
90
+ };
91
+ stashRef: {
92
+ type: string;
93
+ description: string;
94
+ };
95
+ includeUntracked: {
96
+ type: string;
97
+ description: string;
98
+ };
99
+ keepIndex: {
100
+ type: string;
101
+ description: string;
102
+ };
103
+ patch: {
104
+ type: string;
105
+ description: string;
106
+ };
107
+ quiet: {
108
+ type: string;
109
+ description: string;
110
+ };
111
+ index: {
112
+ type: string;
113
+ description: string;
114
+ };
115
+ oneline: {
116
+ type: string;
117
+ description: string;
118
+ };
13
119
  };
120
+ required: string[];
14
121
  };
15
- required: string[];
16
122
  };
17
- handler(input: any): Promise<UniversalResponse>;
18
- };
123
+ }
19
124
  //# sourceMappingURL=git-stash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-stash.d.ts","sourceRoot":"","sources":["../../src/tools/git-stash.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAc,MAAM,4BAA4B,CAAC;AAEpG,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;mBAIF,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAItD,CAAC"}
1
+ {"version":3,"file":"git-stash.d.ts","sourceRoot":"","sources":["../../src/tools/git-stash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAsB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAyB,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAGvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAqB;;IAMxC;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IA8E1D;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA8B/B;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;YACW,WAAW;IAoEzB;;OAEG;YACW,SAAS;IAuDvB;;OAEG;YACW,WAAW,EAqDtB;;;OAGA;YACW,UAAU;IA4DxB;;OAEG;YACW,UAAU;IAoDxB;;OAEG;YACW,UAAU;IAiDxB;;OAEG;YACW,WAAW;IAwDzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDrB"}
@@ -1,14 +1,506 @@
1
1
  "use strict";
2
+ /**
3
+ * Git Stash Tool
4
+ *
5
+ * Comprehensive Git stash tool providing stash management operations.
6
+ * Supports stash, pop, apply, list, show, drop, clear operations for temporary changes storage.
7
+ *
8
+ * Operations: stash, pop, apply, list, show, drop, clear
9
+ */
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gitStashTool = void 0;
4
- const auto_detection_js_1 = require("../utils/auto-detection.js");
5
- exports.gitStashTool = {
6
- name: 'git-stash',
7
- description: '📚 STASH - Gerenciamento de stash',
8
- inputSchema: { type: 'object', properties: { action: { type: 'string' }, projectPath: { type: 'string' } }, required: ['action', 'projectPath'] },
9
- async handler(input) {
10
- const detection = (0, auto_detection_js_1.autoDetect)(input.projectPath);
11
- return (0, auto_detection_js_1.createUniversalResponse)(true, input.action, 'Stash processado', detection, 'git-stash', { stashes: [] });
12
- }
13
- };
11
+ exports.GitStashTool = 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 GitStashTool {
16
+ gitExecutor;
17
+ constructor() {
18
+ this.gitExecutor = new git_command_executor_js_1.GitCommandExecutor();
19
+ }
20
+ /**
21
+ * Execute git-stash 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-stash', 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 'stash':
44
+ return await this.handleStash(params, startTime);
45
+ case 'pop':
46
+ return await this.handlePop(params, startTime);
47
+ case 'apply':
48
+ return await this.handleApply(params, startTime);
49
+ case 'list':
50
+ return await this.handleList(params, startTime);
51
+ case 'show':
52
+ return await this.handleShow(params, startTime);
53
+ case 'drop':
54
+ return await this.handleDrop(params, startTime);
55
+ case 'clear':
56
+ return await this.handleClear(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: stash, pop, apply, list, show, drop, clear']);
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 'pop':
74
+ case 'apply':
75
+ case 'show':
76
+ case 'drop':
77
+ // These operations can optionally specify a stash reference
78
+ if (params.stashRef && !this.isValidStashRef(params.stashRef)) {
79
+ errors.push('Invalid stash reference format');
80
+ suggestions.push('Use format like "stash@{0}", "0", or omit for latest stash');
81
+ }
82
+ break;
83
+ case 'stash':
84
+ case 'list':
85
+ case 'clear':
86
+ // These operations don't require specific validation
87
+ break;
88
+ }
89
+ return {
90
+ isValid: errors.length === 0,
91
+ errors,
92
+ suggestions
93
+ };
94
+ }
95
+ /**
96
+ * Validate stash reference format
97
+ */
98
+ isValidStashRef(stashRef) {
99
+ // Valid formats: "stash@{0}", "stash@{1}", "0", "1", etc.
100
+ return /^(stash@\{\d+\}|\d+)$/.test(stashRef);
101
+ }
102
+ /**
103
+ * Handle git stash operation (save current changes)
104
+ */
105
+ async handleStash(params, startTime) {
106
+ try {
107
+ const args = [];
108
+ // Add message if provided
109
+ if (params.message) {
110
+ args.push('push', '-m', params.message);
111
+ }
112
+ else {
113
+ args.push('push');
114
+ }
115
+ // Add options
116
+ if (params.includeUntracked) {
117
+ args.push('--include-untracked');
118
+ }
119
+ if (params.keepIndex) {
120
+ args.push('--keep-index');
121
+ }
122
+ if (params.patch) {
123
+ args.push('--patch');
124
+ }
125
+ if (params.quiet) {
126
+ args.push('--quiet');
127
+ }
128
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
129
+ if (!result.success) {
130
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash', params.projectPath);
131
+ }
132
+ // Check if anything was actually stashed
133
+ const output = result.stdout.trim();
134
+ const noChanges = output.includes('No local changes to save');
135
+ return {
136
+ success: true,
137
+ data: {
138
+ message: noChanges ? 'No local changes to save' : 'Changes stashed successfully',
139
+ stashed: !noChanges,
140
+ stashMessage: params.message || 'WIP on current branch',
141
+ options: {
142
+ includeUntracked: params.includeUntracked || false,
143
+ keepIndex: params.keepIndex || false,
144
+ patch: params.patch || false
145
+ },
146
+ output
147
+ },
148
+ metadata: {
149
+ operation: 'stash',
150
+ timestamp: new Date().toISOString(),
151
+ executionTime: Date.now() - startTime
152
+ }
153
+ };
154
+ }
155
+ catch (error) {
156
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
157
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_ERROR', `Failed to stash changes: ${errorMessage}`, 'stash', { error: errorMessage, message: params.message });
158
+ }
159
+ }
160
+ /**
161
+ * Handle git stash pop operation (apply and remove latest stash)
162
+ */
163
+ async handlePop(params, startTime) {
164
+ try {
165
+ const args = ['pop'];
166
+ // Add stash reference if provided
167
+ if (params.stashRef) {
168
+ const normalizedRef = this.normalizeStashRef(params.stashRef);
169
+ args.push(normalizedRef);
170
+ }
171
+ // Add index option if specified
172
+ if (params.index) {
173
+ args.push('--index');
174
+ }
175
+ // Add quiet option if specified
176
+ if (params.quiet) {
177
+ args.push('--quiet');
178
+ }
179
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
180
+ if (!result.success) {
181
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash pop', params.projectPath);
182
+ }
183
+ const stashRef = params.stashRef || 'stash@{0}';
184
+ return {
185
+ success: true,
186
+ data: {
187
+ message: `Stash ${stashRef} popped successfully`,
188
+ stashRef,
189
+ applied: true,
190
+ removed: true,
191
+ description: 'Stash applied to working directory and removed from stash list',
192
+ output: result.stdout
193
+ },
194
+ metadata: {
195
+ operation: 'stash pop',
196
+ timestamp: new Date().toISOString(),
197
+ executionTime: Date.now() - startTime
198
+ }
199
+ };
200
+ }
201
+ catch (error) {
202
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
203
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_POP_ERROR', `Failed to pop stash: ${errorMessage}`, 'pop', { error: errorMessage, stashRef: params.stashRef });
204
+ }
205
+ }
206
+ /**
207
+ * Handle git stash apply operation (apply stash without removing)
208
+ */
209
+ async handleApply(params, startTime) {
210
+ try {
211
+ const args = ['apply'];
212
+ // Add stash reference if provided
213
+ if (params.stashRef) {
214
+ const normalizedRef = this.normalizeStashRef(params.stashRef);
215
+ args.push(normalizedRef);
216
+ }
217
+ // Add index option if specified
218
+ if (params.index) {
219
+ args.push('--index');
220
+ }
221
+ // Add quiet option if specified
222
+ if (params.quiet) {
223
+ args.push('--quiet');
224
+ }
225
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
226
+ if (!result.success) {
227
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash apply', params.projectPath);
228
+ }
229
+ const stashRef = params.stashRef || 'stash@{0}';
230
+ return {
231
+ success: true,
232
+ data: {
233
+ message: `Stash ${stashRef} applied successfully`,
234
+ stashRef,
235
+ applied: true,
236
+ removed: false,
237
+ description: 'Stash applied to working directory but kept in stash list',
238
+ output: result.stdout
239
+ },
240
+ metadata: {
241
+ operation: 'stash apply',
242
+ timestamp: new Date().toISOString(),
243
+ executionTime: Date.now() - startTime
244
+ }
245
+ };
246
+ }
247
+ catch (error) {
248
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
249
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_APPLY_ERROR', `Failed to apply stash: ${errorMessage}`, 'apply', { error: errorMessage, stashRef: params.stashRef });
250
+ }
251
+ } /**
252
+
253
+ * Handle git stash list operation (show all stashes)
254
+ */
255
+ async handleList(params, startTime) {
256
+ try {
257
+ const args = ['list'];
258
+ // Add oneline format if specified
259
+ if (params.oneline) {
260
+ args.push('--oneline');
261
+ }
262
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
263
+ if (!result.success) {
264
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash list', params.projectPath);
265
+ }
266
+ const output = result.stdout.trim();
267
+ const stashes = output ? output.split('\n').map((line, index) => {
268
+ const match = line.match(/^(stash@\{\d+\}):\s*(.+)$/);
269
+ if (match) {
270
+ return {
271
+ ref: match[1],
272
+ index,
273
+ message: match[2],
274
+ fullLine: line
275
+ };
276
+ }
277
+ return {
278
+ ref: `stash@{${index}}`,
279
+ index,
280
+ message: line,
281
+ fullLine: line
282
+ };
283
+ }) : [];
284
+ return {
285
+ success: true,
286
+ data: {
287
+ message: stashes.length > 0 ? `Found ${stashes.length} stash(es)` : 'No stashes found',
288
+ count: stashes.length,
289
+ stashes,
290
+ isEmpty: stashes.length === 0,
291
+ output
292
+ },
293
+ metadata: {
294
+ operation: 'stash list',
295
+ timestamp: new Date().toISOString(),
296
+ executionTime: Date.now() - startTime
297
+ }
298
+ };
299
+ }
300
+ catch (error) {
301
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
302
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_LIST_ERROR', `Failed to list stashes: ${errorMessage}`, 'list', { error: errorMessage });
303
+ }
304
+ }
305
+ /**
306
+ * Handle git stash show operation (show stash contents)
307
+ */
308
+ async handleShow(params, startTime) {
309
+ try {
310
+ const args = ['show'];
311
+ // Add stash reference if provided
312
+ if (params.stashRef) {
313
+ const normalizedRef = this.normalizeStashRef(params.stashRef);
314
+ args.push(normalizedRef);
315
+ }
316
+ // Add patch format for detailed diff
317
+ args.push('--patch');
318
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
319
+ if (!result.success) {
320
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash show', params.projectPath);
321
+ }
322
+ const stashRef = params.stashRef || 'stash@{0}';
323
+ // Get stash summary (files changed)
324
+ const summaryResult = await this.gitExecutor.executeGitCommand('stash', ['show', '--stat', stashRef], params.projectPath);
325
+ const summary = summaryResult.success ? summaryResult.stdout.trim() : '';
326
+ return {
327
+ success: true,
328
+ data: {
329
+ message: `Showing stash ${stashRef}`,
330
+ stashRef,
331
+ summary,
332
+ diff: result.stdout,
333
+ description: 'Detailed diff of stashed changes',
334
+ output: result.stdout
335
+ },
336
+ metadata: {
337
+ operation: 'stash show',
338
+ timestamp: new Date().toISOString(),
339
+ executionTime: Date.now() - startTime
340
+ }
341
+ };
342
+ }
343
+ catch (error) {
344
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
345
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_SHOW_ERROR', `Failed to show stash: ${errorMessage}`, 'show', { error: errorMessage, stashRef: params.stashRef });
346
+ }
347
+ }
348
+ /**
349
+ * Handle git stash drop operation (remove specific stash)
350
+ */
351
+ async handleDrop(params, startTime) {
352
+ try {
353
+ const args = ['drop'];
354
+ // Add stash reference if provided
355
+ if (params.stashRef) {
356
+ const normalizedRef = this.normalizeStashRef(params.stashRef);
357
+ args.push(normalizedRef);
358
+ }
359
+ // Add quiet option if specified
360
+ if (params.quiet) {
361
+ args.push('--quiet');
362
+ }
363
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
364
+ if (!result.success) {
365
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash drop', params.projectPath);
366
+ }
367
+ const stashRef = params.stashRef || 'stash@{0}';
368
+ return {
369
+ success: true,
370
+ data: {
371
+ message: `Stash ${stashRef} dropped successfully`,
372
+ stashRef,
373
+ removed: true,
374
+ description: 'Stash permanently removed from stash list',
375
+ output: result.stdout
376
+ },
377
+ metadata: {
378
+ operation: 'stash drop',
379
+ timestamp: new Date().toISOString(),
380
+ executionTime: Date.now() - startTime
381
+ }
382
+ };
383
+ }
384
+ catch (error) {
385
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
386
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_DROP_ERROR', `Failed to drop stash: ${errorMessage}`, 'drop', { error: errorMessage, stashRef: params.stashRef });
387
+ }
388
+ }
389
+ /**
390
+ * Handle git stash clear operation (remove all stashes)
391
+ */
392
+ async handleClear(params, startTime) {
393
+ try {
394
+ // Get current stash count before clearing
395
+ const listResult = await this.gitExecutor.executeGitCommand('stash', ['list'], params.projectPath);
396
+ const stashCount = listResult.success ? listResult.stdout.trim().split('\n').filter(line => line.trim()).length : 0;
397
+ if (stashCount === 0) {
398
+ return {
399
+ success: true,
400
+ data: {
401
+ message: 'No stashes to clear',
402
+ cleared: 0,
403
+ description: 'Stash list was already empty'
404
+ },
405
+ metadata: {
406
+ operation: 'stash clear',
407
+ timestamp: new Date().toISOString(),
408
+ executionTime: Date.now() - startTime
409
+ }
410
+ };
411
+ }
412
+ const args = ['clear'];
413
+ const result = await this.gitExecutor.executeGitCommand('stash', args, params.projectPath);
414
+ if (!result.success) {
415
+ return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'stash clear', params.projectPath);
416
+ }
417
+ return {
418
+ success: true,
419
+ data: {
420
+ message: `All ${stashCount} stash(es) cleared successfully`,
421
+ cleared: stashCount,
422
+ description: 'All stashes permanently removed from stash list',
423
+ warning: 'This operation cannot be undone',
424
+ output: result.stdout
425
+ },
426
+ metadata: {
427
+ operation: 'stash clear',
428
+ timestamp: new Date().toISOString(),
429
+ executionTime: Date.now() - startTime
430
+ }
431
+ };
432
+ }
433
+ catch (error) {
434
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
435
+ return operation_error_handler_js_1.OperationErrorHandler.createToolError('STASH_CLEAR_ERROR', `Failed to clear stashes: ${errorMessage}`, 'clear', { error: errorMessage });
436
+ }
437
+ }
438
+ /**
439
+ * Normalize stash reference to proper format
440
+ */
441
+ normalizeStashRef(stashRef) {
442
+ // If it's just a number, convert to stash@{n} format
443
+ if (/^\d+$/.test(stashRef)) {
444
+ return `stash@{${stashRef}}`;
445
+ }
446
+ return stashRef;
447
+ }
448
+ /**
449
+ * Get tool schema for MCP registration
450
+ */
451
+ static getToolSchema() {
452
+ return {
453
+ name: 'git-stash',
454
+ description: 'Git stash tool for temporary changes management. Supports stash, pop, apply, list, show, drop, clear operations for storing and retrieving work-in-progress changes.',
455
+ inputSchema: {
456
+ type: 'object',
457
+ properties: {
458
+ action: {
459
+ type: 'string',
460
+ enum: ['stash', 'pop', 'apply', 'list', 'show', 'drop', 'clear'],
461
+ description: 'The stash operation to perform'
462
+ },
463
+ projectPath: {
464
+ type: 'string',
465
+ description: 'Absolute path to the project directory'
466
+ },
467
+ message: {
468
+ type: 'string',
469
+ description: 'Stash message (for stash operation)'
470
+ },
471
+ stashRef: {
472
+ type: 'string',
473
+ description: 'Stash reference (e.g., "stash@{0}", "0") for pop, apply, show, drop operations'
474
+ },
475
+ includeUntracked: {
476
+ type: 'boolean',
477
+ description: 'Include untracked files when stashing'
478
+ },
479
+ keepIndex: {
480
+ type: 'boolean',
481
+ description: 'Keep index unchanged when stashing'
482
+ },
483
+ patch: {
484
+ type: 'boolean',
485
+ description: 'Interactive patch mode for selective stashing'
486
+ },
487
+ quiet: {
488
+ type: 'boolean',
489
+ description: 'Suppress output during stash operations'
490
+ },
491
+ index: {
492
+ type: 'boolean',
493
+ description: 'Try to reinstate index changes when applying/popping'
494
+ },
495
+ oneline: {
496
+ type: 'boolean',
497
+ description: 'Show stash list in oneline format'
498
+ }
499
+ },
500
+ required: ['action', 'projectPath']
501
+ }
502
+ };
503
+ }
504
+ }
505
+ exports.GitStashTool = GitStashTool;
14
506
  //# sourceMappingURL=git-stash.js.map