@andrebuzeli/git-mcp 5.5.1 → 5.8.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 (232) hide show
  1. package/README.md +94 -6
  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 +118 -140
  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/resources/toolsGuide.d.ts +12 -0
  13. package/dist/resources/toolsGuide.js +1491 -0
  14. package/dist/server.d.ts +7 -40
  15. package/dist/server.js +59 -696
  16. package/dist/tools/gitAnalytics.d.ts +29 -0
  17. package/dist/tools/gitAnalytics.js +72 -0
  18. package/dist/tools/gitArchive.d.ts +6 -0
  19. package/dist/tools/gitArchive.js +27 -0
  20. package/dist/tools/gitBackup.d.ts +10 -0
  21. package/dist/tools/gitBackup.js +44 -0
  22. package/dist/tools/gitBranches.d.ts +72 -0
  23. package/dist/tools/gitBranches.js +98 -0
  24. package/dist/tools/gitConfig.d.ts +34 -0
  25. package/dist/tools/gitConfig.js +73 -0
  26. package/dist/tools/gitFiles.d.ts +30 -0
  27. package/dist/tools/gitFiles.js +55 -0
  28. package/dist/tools/gitHistory.d.ts +17 -0
  29. package/dist/tools/gitHistory.js +365 -0
  30. package/dist/tools/gitIssues.d.ts +6 -0
  31. package/dist/tools/gitIssues.js +279 -0
  32. package/dist/tools/gitMonitor.d.ts +51 -0
  33. package/dist/tools/gitMonitor.js +102 -0
  34. package/dist/tools/gitPackages.d.ts +6 -0
  35. package/dist/tools/gitPackages.js +28 -0
  36. package/dist/tools/gitPulls.d.ts +6 -0
  37. package/dist/tools/gitPulls.js +288 -0
  38. package/dist/tools/gitRelease.d.ts +6 -0
  39. package/dist/tools/gitRelease.js +321 -0
  40. package/dist/tools/gitRemote.d.ts +51 -0
  41. package/dist/tools/gitRemote.js +68 -0
  42. package/dist/tools/gitReset.d.ts +34 -0
  43. package/dist/tools/gitReset.js +64 -0
  44. package/dist/tools/gitStash.d.ts +41 -0
  45. package/dist/tools/gitStash.js +67 -0
  46. package/dist/tools/gitSync.d.ts +25 -0
  47. package/dist/tools/gitSync.js +51 -0
  48. package/dist/tools/gitTags.d.ts +30 -0
  49. package/dist/tools/gitTags.js +69 -0
  50. package/dist/tools/gitUpdate.d.ts +14 -0
  51. package/dist/tools/gitUpdate.js +374 -0
  52. package/dist/tools/gitUpload.d.ts +11 -0
  53. package/dist/tools/gitUpload.js +342 -0
  54. package/dist/tools/gitWorkflow.d.ts +6 -0
  55. package/dist/tools/gitWorkflow.js +303 -0
  56. package/dist/types.d.ts +17 -0
  57. package/dist/types.js +2 -0
  58. package/dist/utils/errors.d.ts +13 -0
  59. package/dist/utils/errors.js +22 -0
  60. package/dist/utils/safetyController.d.ts +1 -0
  61. package/dist/utils/safetyController.js +15 -0
  62. package/package.json +8 -3
  63. package/dist/config.d.ts.map +0 -1
  64. package/dist/config.js.map +0 -1
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/providers/base-provider.d.ts +0 -66
  68. package/dist/providers/base-provider.d.ts.map +0 -1
  69. package/dist/providers/base-provider.js +0 -65
  70. package/dist/providers/base-provider.js.map +0 -1
  71. package/dist/providers/gitea-provider.d.ts +0 -79
  72. package/dist/providers/gitea-provider.d.ts.map +0 -1
  73. package/dist/providers/gitea-provider.js +0 -576
  74. package/dist/providers/gitea-provider.js.map +0 -1
  75. package/dist/providers/github-provider.d.ts +0 -74
  76. package/dist/providers/github-provider.d.ts.map +0 -1
  77. package/dist/providers/github-provider.js +0 -683
  78. package/dist/providers/github-provider.js.map +0 -1
  79. package/dist/providers/index.d.ts +0 -13
  80. package/dist/providers/index.d.ts.map +0 -1
  81. package/dist/providers/index.js +0 -35
  82. package/dist/providers/index.js.map +0 -1
  83. package/dist/providers/provider-factory.d.ts +0 -49
  84. package/dist/providers/provider-factory.d.ts.map +0 -1
  85. package/dist/providers/provider-factory.js +0 -193
  86. package/dist/providers/provider-factory.js.map +0 -1
  87. package/dist/providers/provider-operation-handler.d.ts +0 -115
  88. package/dist/providers/provider-operation-handler.d.ts.map +0 -1
  89. package/dist/providers/provider-operation-handler.js +0 -449
  90. package/dist/providers/provider-operation-handler.js.map +0 -1
  91. package/dist/providers/types.d.ts +0 -200
  92. package/dist/providers/types.d.ts.map +0 -1
  93. package/dist/providers/types.js +0 -8
  94. package/dist/providers/types.js.map +0 -1
  95. package/dist/server.d.ts.map +0 -1
  96. package/dist/server.js.map +0 -1
  97. package/dist/tools/git-analytics.d.ts +0 -237
  98. package/dist/tools/git-analytics.d.ts.map +0 -1
  99. package/dist/tools/git-analytics.js +0 -819
  100. package/dist/tools/git-analytics.js.map +0 -1
  101. package/dist/tools/git-archive.d.ts +0 -113
  102. package/dist/tools/git-archive.d.ts.map +0 -1
  103. package/dist/tools/git-archive.js +0 -466
  104. package/dist/tools/git-archive.js.map +0 -1
  105. package/dist/tools/git-auto-monitor.d.ts +0 -180
  106. package/dist/tools/git-auto-monitor.d.ts.map +0 -1
  107. package/dist/tools/git-auto-monitor.js +0 -522
  108. package/dist/tools/git-auto-monitor.js.map +0 -1
  109. package/dist/tools/git-backup.d.ts +0 -105
  110. package/dist/tools/git-backup.d.ts.map +0 -1
  111. package/dist/tools/git-backup.js +0 -414
  112. package/dist/tools/git-backup.js.map +0 -1
  113. package/dist/tools/git-branches.d.ts +0 -183
  114. package/dist/tools/git-branches.d.ts.map +0 -1
  115. package/dist/tools/git-branches.js +0 -498
  116. package/dist/tools/git-branches.js.map +0 -1
  117. package/dist/tools/git-config.d.ts +0 -119
  118. package/dist/tools/git-config.d.ts.map +0 -1
  119. package/dist/tools/git-config.js +0 -449
  120. package/dist/tools/git-config.js.map +0 -1
  121. package/dist/tools/git-files.d.ts +0 -150
  122. package/dist/tools/git-files.d.ts.map +0 -1
  123. package/dist/tools/git-files.js +0 -527
  124. package/dist/tools/git-files.js.map +0 -1
  125. package/dist/tools/git-history.d.ts +0 -253
  126. package/dist/tools/git-history.d.ts.map +0 -1
  127. package/dist/tools/git-history.js +0 -824
  128. package/dist/tools/git-history.js.map +0 -1
  129. package/dist/tools/git-issues.d.ts +0 -164
  130. package/dist/tools/git-issues.d.ts.map +0 -1
  131. package/dist/tools/git-issues.js +0 -340
  132. package/dist/tools/git-issues.js.map +0 -1
  133. package/dist/tools/git-monitor.d.ts +0 -154
  134. package/dist/tools/git-monitor.d.ts.map +0 -1
  135. package/dist/tools/git-monitor.js +0 -531
  136. package/dist/tools/git-monitor.js.map +0 -1
  137. package/dist/tools/git-packages.d.ts +0 -157
  138. package/dist/tools/git-packages.d.ts.map +0 -1
  139. package/dist/tools/git-packages.js +0 -534
  140. package/dist/tools/git-packages.js.map +0 -1
  141. package/dist/tools/git-pulls.d.ts +0 -180
  142. package/dist/tools/git-pulls.d.ts.map +0 -1
  143. package/dist/tools/git-pulls.js +0 -369
  144. package/dist/tools/git-pulls.js.map +0 -1
  145. package/dist/tools/git-release.d.ts +0 -161
  146. package/dist/tools/git-release.d.ts.map +0 -1
  147. package/dist/tools/git-release.js +0 -466
  148. package/dist/tools/git-release.js.map +0 -1
  149. package/dist/tools/git-remote.d.ts +0 -128
  150. package/dist/tools/git-remote.d.ts.map +0 -1
  151. package/dist/tools/git-remote.js +0 -542
  152. package/dist/tools/git-remote.js.map +0 -1
  153. package/dist/tools/git-reset.d.ts +0 -120
  154. package/dist/tools/git-reset.d.ts.map +0 -1
  155. package/dist/tools/git-reset.js +0 -479
  156. package/dist/tools/git-reset.js.map +0 -1
  157. package/dist/tools/git-stash.d.ts +0 -124
  158. package/dist/tools/git-stash.d.ts.map +0 -1
  159. package/dist/tools/git-stash.js +0 -506
  160. package/dist/tools/git-stash.js.map +0 -1
  161. package/dist/tools/git-sync.d.ts +0 -154
  162. package/dist/tools/git-sync.d.ts.map +0 -1
  163. package/dist/tools/git-sync.js +0 -479
  164. package/dist/tools/git-sync.js.map +0 -1
  165. package/dist/tools/git-tags.d.ts +0 -136
  166. package/dist/tools/git-tags.d.ts.map +0 -1
  167. package/dist/tools/git-tags.js +0 -461
  168. package/dist/tools/git-tags.js.map +0 -1
  169. package/dist/tools/git-update.d.ts +0 -224
  170. package/dist/tools/git-update.d.ts.map +0 -1
  171. package/dist/tools/git-update.js +0 -948
  172. package/dist/tools/git-update.js.map +0 -1
  173. package/dist/tools/git-workflow.d.ts +0 -189
  174. package/dist/tools/git-workflow.d.ts.map +0 -1
  175. package/dist/tools/git-workflow.js +0 -542
  176. package/dist/tools/git-workflow.js.map +0 -1
  177. package/dist/utils/credential-manager.d.ts +0 -119
  178. package/dist/utils/credential-manager.d.ts.map +0 -1
  179. package/dist/utils/credential-manager.js +0 -450
  180. package/dist/utils/credential-manager.js.map +0 -1
  181. package/dist/utils/data-merger.d.ts +0 -49
  182. package/dist/utils/data-merger.d.ts.map +0 -1
  183. package/dist/utils/data-merger.js +0 -233
  184. package/dist/utils/data-merger.js.map +0 -1
  185. package/dist/utils/git-command-executor.d.ts +0 -330
  186. package/dist/utils/git-command-executor.d.ts.map +0 -1
  187. package/dist/utils/git-command-executor.js +0 -901
  188. package/dist/utils/git-command-executor.js.map +0 -1
  189. package/dist/utils/logger.d.ts +0 -143
  190. package/dist/utils/logger.d.ts.map +0 -1
  191. package/dist/utils/logger.js +0 -473
  192. package/dist/utils/logger.js.map +0 -1
  193. package/dist/utils/operation-error-handler.d.ts +0 -97
  194. package/dist/utils/operation-error-handler.d.ts.map +0 -1
  195. package/dist/utils/operation-error-handler.js +0 -367
  196. package/dist/utils/operation-error-handler.js.map +0 -1
  197. package/dist/utils/parameter-validator.d.ts +0 -49
  198. package/dist/utils/parameter-validator.d.ts.map +0 -1
  199. package/dist/utils/parameter-validator.js +0 -647
  200. package/dist/utils/parameter-validator.js.map +0 -1
  201. package/dist/utils/repository-checker.d.ts +0 -46
  202. package/dist/utils/repository-checker.d.ts.map +0 -1
  203. package/dist/utils/repository-checker.js +0 -151
  204. package/dist/utils/repository-checker.js.map +0 -1
  205. package/dist/utils/repository-detector.d.ts +0 -128
  206. package/dist/utils/repository-detector.d.ts.map +0 -1
  207. package/dist/utils/repository-detector.js +0 -422
  208. package/dist/utils/repository-detector.js.map +0 -1
  209. package/dist/utils/repository-sync.d.ts +0 -67
  210. package/dist/utils/repository-sync.d.ts.map +0 -1
  211. package/dist/utils/repository-sync.js +0 -344
  212. package/dist/utils/repository-sync.js.map +0 -1
  213. package/dist/utils/response-formatter.d.ts +0 -146
  214. package/dist/utils/response-formatter.d.ts.map +0 -1
  215. package/dist/utils/response-formatter.js +0 -378
  216. package/dist/utils/response-formatter.js.map +0 -1
  217. package/dist/utils/retry.d.ts +0 -12
  218. package/dist/utils/retry.d.ts.map +0 -1
  219. package/dist/utils/retry.js +0 -28
  220. package/dist/utils/retry.js.map +0 -1
  221. package/dist/utils/safety-warnings.d.ts +0 -56
  222. package/dist/utils/safety-warnings.d.ts.map +0 -1
  223. package/dist/utils/safety-warnings.js +0 -330
  224. package/dist/utils/safety-warnings.js.map +0 -1
  225. package/dist/utils/terminal-controller.d.ts +0 -79
  226. package/dist/utils/terminal-controller.d.ts.map +0 -1
  227. package/dist/utils/terminal-controller.js +0 -291
  228. package/dist/utils/terminal-controller.js.map +0 -1
  229. package/dist/utils/user-friendly-formatter.d.ts +0 -45
  230. package/dist/utils/user-friendly-formatter.d.ts.map +0 -1
  231. package/dist/utils/user-friendly-formatter.js +0 -175
  232. package/dist/utils/user-friendly-formatter.js.map +0 -1
@@ -1,647 +0,0 @@
1
- "use strict";
2
- /**
3
- * Parameter Validation
4
- *
5
- * Provides robust input validation for all Git MCP operations.
6
- * Validates required parameters, formats, and operation support.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ParameterValidator = void 0;
10
- class ParameterValidator {
11
- static VALID_PROVIDERS = ['github', 'gitea', 'both'];
12
- static TOOL_OPERATIONS = {
13
- 'git-workflow': ['init', 'commit', 'sync', 'status', 'backup', 'push', 'pull', 'create', 'list', 'get', 'update', 'delete', 'fork', 'search'],
14
- 'git-files': ['read', 'search', 'backup', 'list'],
15
- 'git-branches': ['create', 'list', 'get', 'delete', 'merge', 'compare'],
16
- 'git-issues': ['create', 'list', 'get', 'update', 'close', 'comment', 'search'],
17
- 'git-pulls': ['create', 'list', 'get', 'update', 'merge', 'close', 'review', 'search'],
18
- 'git-tags': ['create', 'list', 'get', 'delete', 'search'],
19
- 'git-release': ['create', 'list', 'get', 'update', 'delete', 'publish', 'download'],
20
- 'git-remote': ['add', 'remove', 'rename', 'show', 'set-url', 'prune', 'list'],
21
- 'git-reset': ['soft', 'mixed', 'hard', 'reset-to-commit', 'reset-branch'],
22
- 'git-stash': ['stash', 'pop', 'apply', 'list', 'show', 'drop', 'clear'],
23
- 'git-config': ['get', 'set', 'unset', 'list', 'edit', 'show'],
24
- 'git-monitor': ['log', 'status', 'commits', 'contributors'],
25
- 'git-backup': ['backup', 'restore', 'list', 'verify'],
26
- 'git-archive': ['create', 'extract', 'list', 'verify'],
27
- 'git-packages': ['list', 'get', 'create', 'update', 'delete', 'publish', 'download'],
28
- 'git-analytics': ['stats', 'commits', 'contributors'],
29
- 'git-sync': ['sync', 'status'],
30
- 'git-update': ['update', 'history', 'changelog', 'track', 'sync-providers', 'status', 'rollback', 'compare'],
31
- 'git-history': ['log', 'track', 'sync', 'export', 'auto']
32
- };
33
- static REMOTE_OPERATIONS = {
34
- 'git-workflow': ['create', 'list', 'get', 'update', 'delete', 'fork', 'search'],
35
- // git-files operations are local by default, remote only when provider is explicitly specified (read-only only)
36
- 'git-files': [],
37
- 'git-branches': [], // All branch operations are local for now
38
- 'git-issues': ['create', 'list', 'get', 'update', 'close', 'comment', 'search'],
39
- 'git-pulls': ['create', 'list', 'get', 'update', 'merge', 'close', 'review', 'search'],
40
- 'git-tags': [], // All tag operations are local
41
- 'git-release': ['create', 'list', 'get', 'update', 'delete', 'publish', 'download'],
42
- 'git-remote': [], // Remote operations are local Git commands
43
- 'git-reset': [], // Reset operations are local
44
- 'git-stash': [], // Stash operations are local
45
- 'git-config': [], // Config operations are local
46
- 'git-monitor': [], // Monitor operations are local
47
- 'git-backup': [], // Backup operations are local
48
- 'git-archive': [], // Archive operations are local
49
- 'git-packages': ['create', 'update', 'delete', 'publish', 'download'], // list and get are local
50
- 'git-analytics': [], // All analytics operations are local by default
51
- 'git-sync': [], // All sync operations are local by default
52
- 'git-update': ['sync-providers'], // Only sync-providers is remote
53
- 'git-history': ['sync'] // sync operation can be remote when using API method
54
- };
55
- /**
56
- * Validates basic tool parameters
57
- */
58
- static validateToolParams(toolName, params) {
59
- const result = {
60
- isValid: true,
61
- errors: [],
62
- warnings: [],
63
- suggestions: []
64
- };
65
- // Validate required parameters
66
- if (!params.projectPath) {
67
- result.errors.push('projectPath is required for all operations');
68
- result.suggestions.push('Provide the absolute path to your project directory');
69
- result.isValid = false;
70
- }
71
- if (!params.action) {
72
- result.errors.push('action is required to specify the operation to perform');
73
- result.suggestions.push(`Valid actions for ${toolName}: ${this.TOOL_OPERATIONS[toolName]?.join(', ') || 'unknown tool'}`);
74
- result.isValid = false;
75
- }
76
- // Validate tool exists
77
- if (!this.TOOL_OPERATIONS[toolName]) {
78
- result.errors.push(`Unknown tool: ${toolName}`);
79
- result.suggestions.push(`Available tools: ${Object.keys(this.TOOL_OPERATIONS).join(', ')}`);
80
- result.isValid = false;
81
- return result;
82
- }
83
- // Validate action is supported by tool
84
- if (params.action && !this.TOOL_OPERATIONS[toolName].includes(params.action)) {
85
- result.errors.push(`Action '${params.action}' is not supported by ${toolName}`);
86
- result.suggestions.push(`Valid actions: ${this.TOOL_OPERATIONS[toolName].join(', ')}`);
87
- result.isValid = false;
88
- }
89
- // Provider is now automatically determined by the system
90
- // Validate projectPath format
91
- if (params.projectPath && typeof params.projectPath !== 'string') {
92
- result.errors.push('projectPath must be a string');
93
- result.isValid = false;
94
- }
95
- // Check for common parameter format issues
96
- if (params.projectPath && params.projectPath.includes('\\') && !params.projectPath.includes(':\\')) {
97
- result.warnings.push('projectPath contains backslashes - ensure it is a valid absolute path');
98
- }
99
- // Validate URLs format
100
- if (params.provider === 'gitea' && params.projectPath) {
101
- // This is a basic check - more specific validation would be in the operation-specific validator
102
- if (params.projectPath.startsWith('http://') || params.projectPath.startsWith('https://')) {
103
- result.warnings.push('projectPath appears to be a URL - ensure you are using the local repository path');
104
- }
105
- }
106
- // Validate branch names format
107
- if (params.action && ['create', 'delete', 'merge'].includes(params.action) && params.branch) {
108
- if (typeof params.branch !== 'string') {
109
- result.errors.push('branch parameter must be a string');
110
- result.isValid = false;
111
- }
112
- else {
113
- // Basic branch name validation
114
- if (params.branch.includes('..') || params.branch.includes('~') || params.branch.includes('^')) {
115
- result.warnings.push('branch name contains special characters - ensure it is a valid branch name');
116
- }
117
- if (params.branch.startsWith('-')) {
118
- result.errors.push('branch name cannot start with a hyphen');
119
- result.isValid = false;
120
- }
121
- if (params.branch.includes(' ')) {
122
- result.warnings.push('branch name contains spaces - consider using hyphens or underscores');
123
- }
124
- }
125
- }
126
- // Validate commit hash format
127
- if (params.commit && typeof params.commit === 'string') {
128
- if (params.commit.length < 7 || params.commit.length > 40) {
129
- result.warnings.push('commit hash appears to be invalid format (should be 7-40 characters)');
130
- }
131
- if (!/^[a-f0-9]+$/i.test(params.commit)) {
132
- result.errors.push('commit hash contains invalid characters (only hex digits allowed)');
133
- result.isValid = false;
134
- }
135
- }
136
- // Validate token format (basic check)
137
- if (params.token && typeof params.token === 'string') {
138
- if (params.token.length < 20) {
139
- result.warnings.push('token appears to be too short - ensure it is a valid API token');
140
- }
141
- if (params.token.includes(' ')) {
142
- result.errors.push('token contains spaces - ensure it is a valid token without spaces');
143
- result.isValid = false;
144
- }
145
- }
146
- return result;
147
- }
148
- /**
149
- * Validates specific operation parameters
150
- */
151
- static validateOperationParams(toolName, action, params) {
152
- const result = {
153
- isValid: true,
154
- errors: [],
155
- warnings: [],
156
- suggestions: []
157
- };
158
- // Tool-specific validations
159
- switch (toolName) {
160
- case 'git-workflow':
161
- return this.validateWorkflowParams(action, params);
162
- case 'git-files':
163
- return this.validateFilesParams(action, params);
164
- case 'git-branches':
165
- return this.validateBranchesParams(action, params);
166
- case 'git-tags':
167
- return this.validateTagsParams(action, params);
168
- case 'git-issues':
169
- return this.validateIssuesParams(action, params);
170
- case 'git-pulls':
171
- return this.validatePullsParams(action, params);
172
- case 'git-sync':
173
- return this.validateSyncParams(action, params);
174
- case 'git-files':
175
- return this.validateFilesParams(action, params);
176
- case 'git-update':
177
- return this.validateUpdateParams(action, params);
178
- default:
179
- // Generic validation for other tools
180
- return result;
181
- }
182
- }
183
- static validateWorkflowParams(action, params) {
184
- const result = {
185
- isValid: true,
186
- errors: [],
187
- warnings: [],
188
- suggestions: []
189
- };
190
- switch (action) {
191
- case 'commit':
192
- if (!params.message) {
193
- result.errors.push('message is required for commit operation');
194
- result.suggestions.push('Provide a commit message describing your changes');
195
- result.isValid = false;
196
- }
197
- break;
198
- case 'create':
199
- if (!params.name) {
200
- result.errors.push('name is required for repository creation');
201
- result.suggestions.push('Provide a repository name');
202
- result.isValid = false;
203
- }
204
- break;
205
- case 'get':
206
- case 'update':
207
- case 'delete':
208
- case 'fork':
209
- if (!params.repo) {
210
- result.errors.push('repo is required for repository operations');
211
- result.suggestions.push('Provide repository name');
212
- result.isValid = false;
213
- }
214
- break;
215
- case 'search':
216
- if (!params.query) {
217
- result.errors.push('query is required for search operation');
218
- result.suggestions.push('Provide a search query string');
219
- result.isValid = false;
220
- }
221
- break;
222
- case 'push':
223
- // Validate push parameters
224
- if (params.force) {
225
- result.warnings.push('Force push will override remote changes. Use with caution.');
226
- }
227
- break;
228
- case 'pull':
229
- // Validate pull parameters
230
- if (params.strategy && !['merge', 'rebase', 'fast-forward'].includes(params.strategy)) {
231
- result.errors.push('Invalid pull strategy. Must be one of: merge, rebase, fast-forward');
232
- result.suggestions.push('Use strategy: "merge", "rebase", or "fast-forward"');
233
- result.isValid = false;
234
- }
235
- break;
236
- case 'backup':
237
- if (params.backupPath && typeof params.backupPath !== 'string') {
238
- result.errors.push('backupPath must be a string');
239
- result.isValid = false;
240
- }
241
- break;
242
- case 'sync':
243
- if (params.remote && typeof params.remote !== 'string') {
244
- result.errors.push('remote must be a string');
245
- result.isValid = false;
246
- }
247
- if (params.branch && typeof params.branch !== 'string') {
248
- result.errors.push('branch must be a string');
249
- result.isValid = false;
250
- }
251
- break;
252
- }
253
- return result;
254
- }
255
- static validateBranchesParams(action, params) {
256
- const result = {
257
- isValid: true,
258
- errors: [],
259
- warnings: [],
260
- suggestions: []
261
- };
262
- switch (action) {
263
- case 'create':
264
- if (!params.branchName) {
265
- result.errors.push('branchName is required for branch creation');
266
- result.suggestions.push('Provide a name for the new branch');
267
- result.isValid = false;
268
- }
269
- break;
270
- case 'get':
271
- case 'delete':
272
- case 'merge':
273
- if (!params.branchName) {
274
- result.errors.push('branchName is required for branch operation');
275
- result.suggestions.push('Provide the name of the branch to operate on');
276
- result.isValid = false;
277
- }
278
- break;
279
- case 'compare':
280
- if (!params.baseBranch || !params.compareBranch) {
281
- result.errors.push('baseBranch and compareBranch are required for comparison');
282
- result.suggestions.push('Provide both branch names to compare');
283
- result.isValid = false;
284
- }
285
- break;
286
- case 'list':
287
- // list operation doesn't require any additional parameters
288
- break;
289
- }
290
- return result;
291
- }
292
- static validateTagsParams(action, params) {
293
- const result = {
294
- isValid: true,
295
- errors: [],
296
- warnings: [],
297
- suggestions: []
298
- };
299
- switch (action) {
300
- case 'create':
301
- if (!params.tagName) {
302
- result.errors.push('tagName is required for tag creation');
303
- result.suggestions.push('Provide a name for the new tag');
304
- result.isValid = false;
305
- }
306
- break;
307
- case 'get':
308
- case 'delete':
309
- if (!params.tagName) {
310
- result.errors.push('tagName is required for tag operation');
311
- result.suggestions.push('Provide the name of the tag to operate on');
312
- result.isValid = false;
313
- }
314
- break;
315
- case 'search':
316
- if (!params.query) {
317
- result.errors.push('query is required for tag search');
318
- result.suggestions.push('Provide a search query to find tags');
319
- result.isValid = false;
320
- }
321
- break;
322
- case 'list':
323
- // list operation doesn't require any additional parameters
324
- break;
325
- }
326
- return result;
327
- }
328
- static validateIssuesParams(action, params) {
329
- const result = {
330
- isValid: true,
331
- errors: [],
332
- warnings: [],
333
- suggestions: []
334
- };
335
- switch (action) {
336
- case 'create':
337
- if (!params.title) {
338
- result.errors.push('title is required for issue creation');
339
- result.suggestions.push('Provide a descriptive title for the issue');
340
- result.isValid = false;
341
- }
342
- break;
343
- case 'get':
344
- case 'update':
345
- case 'close':
346
- if (params.issue_number === undefined) {
347
- result.errors.push('issue_number is required for issue operations');
348
- result.suggestions.push('Provide the issue number');
349
- result.isValid = false;
350
- }
351
- break;
352
- case 'comment':
353
- if (params.issue_number === undefined) {
354
- result.errors.push('issue_number is required for commenting on issues');
355
- result.suggestions.push('Provide the issue number');
356
- result.isValid = false;
357
- }
358
- if (!params.comment_body) {
359
- result.errors.push('comment_body is required for commenting on issues');
360
- result.suggestions.push('Provide the comment text');
361
- result.isValid = false;
362
- }
363
- break;
364
- case 'search':
365
- if (!params.query) {
366
- result.errors.push('query is required for issue search');
367
- result.suggestions.push('Provide a search query to find issues');
368
- result.isValid = false;
369
- }
370
- break;
371
- }
372
- return result;
373
- }
374
- static validatePullsParams(action, params) {
375
- const result = {
376
- isValid: true,
377
- errors: [],
378
- warnings: [],
379
- suggestions: []
380
- };
381
- switch (action) {
382
- case 'create':
383
- if (!params.title) {
384
- result.errors.push('title is required for pull request creation');
385
- result.suggestions.push('Provide a descriptive title for the pull request');
386
- result.isValid = false;
387
- }
388
- if (!params.head || !params.base) {
389
- result.errors.push('head and base branches are required for pull request creation');
390
- result.suggestions.push('Specify the source (head) and target (base) branches');
391
- result.isValid = false;
392
- }
393
- break;
394
- case 'get':
395
- case 'update':
396
- case 'merge':
397
- case 'close':
398
- if (params.pull_number === undefined) {
399
- result.errors.push('pull_number is required for pull request operations');
400
- result.suggestions.push('Provide the pull request number');
401
- result.isValid = false;
402
- }
403
- break;
404
- case 'review':
405
- if (params.pull_number === undefined) {
406
- result.errors.push('pull_number is required for reviewing pull requests');
407
- result.suggestions.push('Provide the pull request number');
408
- result.isValid = false;
409
- }
410
- if (!params.event) {
411
- result.errors.push('event is required for pull request reviews');
412
- result.suggestions.push('Specify review event: APPROVE, REQUEST_CHANGES, or COMMENT');
413
- result.isValid = false;
414
- }
415
- if (params.event === 'REQUEST_CHANGES' && !params.review_body) {
416
- result.warnings.push('review_body is recommended for REQUEST_CHANGES reviews');
417
- }
418
- break;
419
- case 'search':
420
- if (!params.query) {
421
- result.errors.push('query is required for pull request search');
422
- result.suggestions.push('Provide a search query to find pull requests');
423
- result.isValid = false;
424
- }
425
- break;
426
- }
427
- return result;
428
- }
429
- /**
430
- * Provides usage examples for correct parameter format
431
- */
432
- static getUsageExamples(toolName, action) {
433
- const examples = [];
434
- if (!action) {
435
- examples.push(`${toolName} usage examples:`);
436
- const operations = this.TOOL_OPERATIONS[toolName] || [];
437
- operations.slice(0, 3).forEach(op => {
438
- examples.push(` ${toolName} with action="${op}"`);
439
- });
440
- return examples;
441
- }
442
- switch (toolName) {
443
- case 'git-workflow':
444
- switch (action) {
445
- case 'commit':
446
- examples.push('git-workflow commit: { "action": "commit", "projectPath": "/path/to/project", "message": "Fix bug in authentication" }');
447
- break;
448
- case 'create':
449
- examples.push('git-workflow create: { "action": "create", "projectPath": "/path/to/project", "provider": "github", "name": "my-repo", "description": "My new repository" }');
450
- break;
451
- case 'get':
452
- examples.push('git-workflow get: { "action": "get", "projectPath": "/path/to/project", "provider": "github", "repo": "repository-name" }');
453
- break;
454
- case 'list':
455
- examples.push('git-workflow list: { "action": "list", "projectPath": "/path/to/project", "provider": "github" }');
456
- break;
457
- case 'update':
458
- examples.push('git-workflow update: { "action": "update", "projectPath": "/path/to/project", "provider": "github", "repo": "repository-name", "description": "Updated description" }');
459
- break;
460
- case 'delete':
461
- examples.push('git-workflow delete: { "action": "delete", "projectPath": "/path/to/project", "provider": "github", "repo": "repository-name" }');
462
- break;
463
- case 'fork':
464
- examples.push('git-workflow fork: { "action": "fork", "projectPath": "/path/to/project", "provider": "github", "repo": "repository-name" }');
465
- break;
466
- case 'search':
467
- examples.push('git-workflow search: { "action": "search", "projectPath": "/path/to/project", "provider": "github", "query": "javascript framework" }');
468
- break;
469
- }
470
- break;
471
- case 'git-files':
472
- switch (action) {
473
- case 'read':
474
- examples.push('git-files read: { "action": "read", "projectPath": "/path/to/project", "filePath": "src/index.js" }');
475
- examples.push('git-files read (remote): { "action": "read", "projectPath": "/path/to/project", "provider": "github", "filePath": "README.md", "repo": "repository" }');
476
- break;
477
- case 'create':
478
- examples.push('git-files create: { "action": "create", "projectPath": "/path/to/project", "filePath": "README.md", "content": "# My Project" }');
479
- examples.push('git-files create (remote): { "action": "create", "projectPath": "/path/to/project", "provider": "github", "filePath": "docs/api.md", "content": "# API Documentation", "message": "Add API docs" }');
480
- break;
481
- case 'update':
482
- examples.push('git-files update: { "action": "update", "projectPath": "/path/to/project", "filePath": "package.json", "content": "{\\"name\\": \\"my-package\\"}" }');
483
- examples.push('git-files update (remote): { "action": "update", "projectPath": "/path/to/project", "provider": "github", "filePath": "README.md", "content": "Updated content", "message": "Update README", "sha": "abc123" }');
484
- break;
485
- case 'delete':
486
- examples.push('git-files delete: { "action": "delete", "projectPath": "/path/to/project", "filePath": "temp.txt" }');
487
- examples.push('git-files delete (remote): { "action": "delete", "projectPath": "/path/to/project", "provider": "github", "filePath": "old-file.txt", "message": "Remove old file", "sha": "def456" }');
488
- break;
489
- case 'search':
490
- examples.push('git-files search: { "action": "search", "projectPath": "/path/to/project", "query": "function authenticate" }');
491
- examples.push('git-files search (remote): { "action": "search", "projectPath": "/path/to/project", "provider": "github", "query": "TODO" }');
492
- break;
493
- case 'backup':
494
- examples.push('git-files backup: { "action": "backup", "projectPath": "/path/to/project" }');
495
- examples.push('git-files backup (custom): { "action": "backup", "projectPath": "/path/to/project", "backupPath": "/backup/location", "includePattern": "*.js" }');
496
- break;
497
- }
498
- break;
499
- }
500
- if (examples.length === 0) {
501
- examples.push(`${toolName} ${action}: { "action": "${action}", "projectPath": "/path/to/project" }`);
502
- }
503
- return examples;
504
- }
505
- /**
506
- * Validate git-sync specific parameters
507
- */
508
- static validateSyncParams(action, params) {
509
- const result = {
510
- isValid: true,
511
- errors: [],
512
- warnings: [],
513
- suggestions: []
514
- };
515
- switch (action) {
516
- case 'sync':
517
- // Validate sync parameters
518
- if (params.strategy && !['merge', 'rebase', 'fast-forward'].includes(params.strategy)) {
519
- result.errors.push('Invalid sync strategy. Must be one of: merge, rebase, fast-forward');
520
- result.suggestions.push('Use strategy: "merge", "rebase", or "fast-forward"');
521
- result.isValid = false;
522
- }
523
- if (params.force) {
524
- result.warnings.push('Force sync will override uncommitted changes. Use with caution.');
525
- }
526
- break;
527
- case 'status':
528
- // Status operation has no specific validation requirements
529
- break;
530
- }
531
- return result;
532
- }
533
- /**
534
- * Validate git-files specific parameters
535
- */
536
- static validateFilesParams(action, params) {
537
- const result = {
538
- isValid: true,
539
- errors: [],
540
- warnings: [],
541
- suggestions: []
542
- };
543
- switch (action) {
544
- case 'read':
545
- if (!params.filePath) {
546
- result.errors.push('filePath is required for read operation');
547
- result.suggestions.push('Provide a filePath parameter with the relative path to the file');
548
- result.isValid = false;
549
- }
550
- if (params.encoding && !['utf8', 'base64', 'binary'].includes(params.encoding)) {
551
- result.errors.push('Invalid encoding. Must be one of: utf8, base64, binary');
552
- result.suggestions.push('Use encoding: "utf8", "base64", or "binary"');
553
- result.isValid = false;
554
- }
555
- break;
556
- case 'search':
557
- if (!params.query) {
558
- result.errors.push('query is required for search operation');
559
- result.suggestions.push('Provide a query parameter with the text to search for');
560
- result.isValid = false;
561
- }
562
- break;
563
- case 'list':
564
- // List operation has no specific validation requirements
565
- break;
566
- case 'backup':
567
- // Backup operation has no specific validation requirements
568
- break;
569
- }
570
- return result;
571
- }
572
- static validateUpdateParams(action, params) {
573
- const result = {
574
- isValid: true,
575
- errors: [],
576
- warnings: [],
577
- suggestions: []
578
- };
579
- switch (action) {
580
- case 'update':
581
- if (params.updateType && !['all', 'dependencies', 'code', 'docs', 'config'].includes(params.updateType)) {
582
- result.errors.push('Invalid update type. Must be one of: all, dependencies, code, docs, config');
583
- result.suggestions.push('Use updateType: "all", "dependencies", "code", "docs", or "config"');
584
- result.isValid = false;
585
- }
586
- break;
587
- case 'history':
588
- if (params.format && !['json', 'markdown', 'text'].includes(params.format)) {
589
- result.errors.push('Invalid format. Must be one of: json, markdown, text');
590
- result.suggestions.push('Use format: "json", "markdown", or "text"');
591
- result.isValid = false;
592
- }
593
- break;
594
- case 'changelog':
595
- if (params.version && !/^[\d]+\.[\d]+\.[\d]+/.test(params.version)) {
596
- result.warnings.push('Version format should follow semantic versioning (e.g., 1.0.0)');
597
- }
598
- break;
599
- case 'track':
600
- if (!params.trackFile && !params.trackPattern) {
601
- result.warnings.push('No specific file or pattern to track - will track all changes');
602
- }
603
- break;
604
- case 'sync-providers':
605
- if (params.providers && Array.isArray(params.providers)) {
606
- const validProviders = ['github', 'gitea'];
607
- const invalidProviders = params.providers.filter(p => !validProviders.includes(p));
608
- if (invalidProviders.length > 0) {
609
- result.errors.push(`Invalid providers: ${invalidProviders.join(', ')}`);
610
- result.suggestions.push('Use providers: "github", "gitea", or both');
611
- result.isValid = false;
612
- }
613
- }
614
- break;
615
- case 'rollback':
616
- if (!params.rollbackTo) {
617
- result.errors.push('rollbackTo parameter is required for rollback operation');
618
- result.suggestions.push('Provide a commit hash, tag name, or version to rollback to');
619
- result.isValid = false;
620
- }
621
- if (params.rollbackType && !['commit', 'tag', 'version'].includes(params.rollbackType)) {
622
- result.errors.push('Invalid rollback type. Must be one of: commit, tag, version');
623
- result.suggestions.push('Use rollbackType: "commit", "tag", or "version"');
624
- result.isValid = false;
625
- }
626
- break;
627
- case 'compare':
628
- if (!params.compareWith) {
629
- result.errors.push('compareWith parameter is required for compare operation');
630
- result.suggestions.push('Provide a commit hash, tag name, branch, or provider to compare with');
631
- result.isValid = false;
632
- }
633
- if (params.compareType && !['commit', 'tag', 'branch', 'provider'].includes(params.compareType)) {
634
- result.errors.push('Invalid compare type. Must be one of: commit, tag, branch, provider');
635
- result.suggestions.push('Use compareType: "commit", "tag", "branch", or "provider"');
636
- result.isValid = false;
637
- }
638
- break;
639
- case 'status':
640
- // Status operation has no specific validation requirements
641
- break;
642
- }
643
- return result;
644
- }
645
- }
646
- exports.ParameterValidator = ParameterValidator;
647
- //# sourceMappingURL=parameter-validator.js.map