@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,154 +0,0 @@
1
- /**
2
- * Git Monitor Tool
3
- *
4
- * Git monitoring and logging tool providing comprehensive repository monitoring.
5
- * Supports log, status, commits, and contributors operations for repository analysis.
6
- *
7
- * Operations: log, status, commits, contributors
8
- */
9
- import { ToolParams } from '../utils/parameter-validator.js';
10
- import { ToolResult } from '../utils/operation-error-handler.js';
11
- export interface GitMonitorParams extends ToolParams {
12
- action: 'log' | 'status' | 'commits' | 'contributors';
13
- limit?: number;
14
- branch?: string;
15
- since?: string;
16
- until?: string;
17
- author?: string;
18
- grep?: string;
19
- detailed?: boolean;
20
- format?: 'short' | 'full' | 'oneline' | 'raw';
21
- graph?: boolean;
22
- sortBy?: 'commits' | 'lines' | 'name';
23
- includeStats?: boolean;
24
- }
25
- export interface CommitInfo {
26
- hash: string;
27
- shortHash: string;
28
- message: string;
29
- author: string;
30
- authorEmail: string;
31
- date: string;
32
- insertions?: number;
33
- deletions?: number;
34
- }
35
- export interface ContributorInfo {
36
- name: string;
37
- email: string;
38
- commits: number;
39
- insertions: number;
40
- deletions: number;
41
- firstCommit: string;
42
- lastCommit: string;
43
- }
44
- export declare class GitMonitorTool {
45
- private gitExecutor;
46
- constructor();
47
- /**
48
- * Execute git-monitor operation
49
- */
50
- execute(params: GitMonitorParams): Promise<ToolResult>;
51
- /**
52
- * Validate operation-specific parameters
53
- */
54
- private validateOperationParams;
55
- /**
56
- * Validate date format
57
- */
58
- private isValidDateFormat;
59
- /**
60
- * Handle log operation
61
- */
62
- private handleLog;
63
- /**
64
- * Handle status operation
65
- */
66
- private handleStatus;
67
- /**
68
- * Handle commits operation
69
- */
70
- private handleCommits;
71
- /**
72
- * Handle contributors operation
73
- */
74
- private handleContributors;
75
- /**
76
- * Parse log output into structured commit information
77
- */
78
- private parseLogOutput;
79
- /**
80
- * Enrich commits with statistics (insertions/deletions)
81
- */
82
- private enrichCommitsWithStats;
83
- /**
84
- * Get tool schema for MCP registration
85
- */
86
- static getToolSchema(): {
87
- name: string;
88
- description: string;
89
- inputSchema: {
90
- type: string;
91
- properties: {
92
- action: {
93
- type: string;
94
- enum: string[];
95
- description: string;
96
- };
97
- projectPath: {
98
- type: string;
99
- description: string;
100
- };
101
- limit: {
102
- type: string;
103
- description: string;
104
- minimum: number;
105
- maximum: number;
106
- };
107
- branch: {
108
- type: string;
109
- description: string;
110
- };
111
- since: {
112
- type: string;
113
- description: string;
114
- };
115
- until: {
116
- type: string;
117
- description: string;
118
- };
119
- author: {
120
- type: string;
121
- description: string;
122
- };
123
- grep: {
124
- type: string;
125
- description: string;
126
- };
127
- detailed: {
128
- type: string;
129
- description: string;
130
- };
131
- format: {
132
- type: string;
133
- enum: string[];
134
- description: string;
135
- };
136
- graph: {
137
- type: string;
138
- description: string;
139
- };
140
- sortBy: {
141
- type: string;
142
- enum: string[];
143
- description: string;
144
- };
145
- includeStats: {
146
- type: string;
147
- description: string;
148
- };
149
- };
150
- required: string[];
151
- };
152
- };
153
- }
154
- //# sourceMappingURL=git-monitor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-monitor.d.ts","sourceRoot":"","sources":["../../src/tools/git-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAsB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAyB,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGxF,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;IAGtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,WAAW,CAAqB;;IAMxC;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IA4D5D;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwC/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;YACW,SAAS;IAgFvB;;OAEG;YACW,YAAY;IAqE1B;;OAEG;YACW,aAAa;IAsG3B;;OAEG;YACW,kBAAkB;IA8IhC;;OAEG;IACH,OAAO,CAAC,cAAc;IAqBtB;;OAEG;YACW,sBAAsB;IAkCpC;;OAEG;IACH,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqErB"}
@@ -1,531 +0,0 @@
1
- "use strict";
2
- /**
3
- * Git Monitor Tool
4
- *
5
- * Git monitoring and logging tool providing comprehensive repository monitoring.
6
- * Supports log, status, commits, and contributors operations for repository analysis.
7
- *
8
- * Operations: log, status, commits, contributors
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GitMonitorTool = 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 GitMonitorTool {
16
- gitExecutor;
17
- constructor() {
18
- this.gitExecutor = new git_command_executor_js_1.GitCommandExecutor();
19
- }
20
- /**
21
- * Execute git-monitor 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-monitor', 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
- // Route to appropriate handler
37
- switch (params.action) {
38
- case 'log':
39
- return await this.handleLog(params, startTime);
40
- case 'status':
41
- return await this.handleStatus(params, startTime);
42
- case 'commits':
43
- return await this.handleCommits(params, startTime);
44
- case 'contributors':
45
- return await this.handleContributors(params, startTime);
46
- default:
47
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('UNSUPPORTED_OPERATION', `Operation '${params.action}' is not supported`, params.action, {}, ['Use one of: log, status, commits, contributors']);
48
- }
49
- }
50
- catch (error) {
51
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
52
- 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']);
53
- }
54
- }
55
- /**
56
- * Validate operation-specific parameters
57
- */
58
- validateOperationParams(params) {
59
- const errors = [];
60
- const suggestions = [];
61
- // Validate limit parameter
62
- if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) {
63
- errors.push('Limit must be between 1 and 1000');
64
- suggestions.push('Use a reasonable limit (e.g., 10, 50, 100)');
65
- }
66
- // Validate format parameter
67
- if (params.format && !['short', 'full', 'oneline', 'raw'].includes(params.format)) {
68
- errors.push('Invalid format specified');
69
- suggestions.push('Use one of: short, full, oneline, raw');
70
- }
71
- // Validate sortBy parameter
72
- if (params.sortBy && !['commits', 'lines', 'name'].includes(params.sortBy)) {
73
- errors.push('Invalid sortBy specified');
74
- suggestions.push('Use one of: commits, lines, name');
75
- }
76
- // Validate date formats
77
- if (params.since && !this.isValidDateFormat(params.since)) {
78
- errors.push('Invalid since date format');
79
- suggestions.push('Use formats like: "2024-01-01", "1 week ago", "2024-01-01 10:00"');
80
- }
81
- if (params.until && !this.isValidDateFormat(params.until)) {
82
- errors.push('Invalid until date format');
83
- suggestions.push('Use formats like: "2024-01-01", "1 week ago", "2024-01-01 10:00"');
84
- }
85
- return {
86
- isValid: errors.length === 0,
87
- errors,
88
- suggestions
89
- };
90
- }
91
- /**
92
- * Validate date format
93
- */
94
- isValidDateFormat(dateStr) {
95
- // Accept various Git date formats
96
- const patterns = [
97
- /^\d{4}-\d{2}-\d{2}$/, // 2024-01-01
98
- /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/, // 2024-01-01 10:00
99
- /^\d+ (second|minute|hour|day|week|month|year)s? ago$/, // 1 week ago
100
- /^yesterday$/,
101
- /^today$/
102
- ];
103
- return patterns.some(pattern => pattern.test(dateStr));
104
- }
105
- /**
106
- * Handle log operation
107
- */
108
- async handleLog(params, startTime) {
109
- try {
110
- const args = ['log'];
111
- // Add limit
112
- const limit = params.limit || 10;
113
- args.push('-n', limit.toString());
114
- // Add format
115
- args.push('--format=%H|%h|%s|%an|%ae|%ad');
116
- args.push('--date=iso');
117
- // Add branch if specified
118
- if (params.branch) {
119
- args.push(params.branch);
120
- }
121
- // Add date filters
122
- if (params.since) {
123
- args.push(`--since=${params.since}`);
124
- }
125
- if (params.until) {
126
- args.push(`--until=${params.until}`);
127
- }
128
- // Add author filter
129
- if (params.author) {
130
- args.push(`--author=${params.author}`);
131
- }
132
- // Add grep filter
133
- if (params.grep) {
134
- args.push(`--grep=${params.grep}`);
135
- }
136
- const result = await this.gitExecutor.executeGitCommand('log', args.slice(1), params.projectPath);
137
- if (!result.success) {
138
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'get log', params.projectPath);
139
- }
140
- const commits = this.parseLogOutput(result.stdout);
141
- return {
142
- success: true,
143
- data: {
144
- message: `Retrieved ${commits.length} commits from log`,
145
- totalCommits: commits.length,
146
- commits: commits,
147
- filters: {
148
- branch: params.branch,
149
- since: params.since,
150
- until: params.until,
151
- author: params.author,
152
- grep: params.grep,
153
- limit: limit
154
- },
155
- raw: result.stdout
156
- },
157
- metadata: {
158
- operation: 'log',
159
- timestamp: new Date().toISOString(),
160
- executionTime: Date.now() - startTime
161
- }
162
- };
163
- }
164
- catch (error) {
165
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
166
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('LOG_ERROR', `Failed to get repository log: ${errorMessage}`, 'log', { error: errorMessage });
167
- }
168
- }
169
- /**
170
- * Handle status operation
171
- */
172
- async handleStatus(params, startTime) {
173
- try {
174
- // Get basic status
175
- const statusResult = await this.gitExecutor.getStatus(params.projectPath);
176
- if (!statusResult.success) {
177
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(statusResult.stderr, 'get status', params.projectPath);
178
- }
179
- let additionalInfo = {};
180
- if (params.detailed) {
181
- // Get additional detailed information
182
- const branchResult = await this.gitExecutor.getCurrentBranch(params.projectPath);
183
- const remoteResult = await this.gitExecutor.getRemoteUrl(params.projectPath);
184
- // Get last commit info
185
- const lastCommitResult = await this.gitExecutor.executeGitCommand('log', ['-1', '--format=%H|%h|%s|%an|%ad', '--date=iso'], params.projectPath);
186
- // Get stash count
187
- const stashResult = await this.gitExecutor.executeGitCommand('stash', ['list'], params.projectPath);
188
- const stashCount = stashResult.success
189
- ? stashResult.stdout.split('\n').filter(line => line.trim()).length
190
- : 0;
191
- additionalInfo = {
192
- currentBranch: branchResult.branch,
193
- remoteUrl: remoteResult.url,
194
- lastCommit: lastCommitResult.success ? this.parseLogOutput(lastCommitResult.stdout)[0] : null,
195
- stashCount: stashCount,
196
- isGitRepository: statusResult.isGitRepository
197
- };
198
- }
199
- return {
200
- success: true,
201
- data: {
202
- message: 'Repository status retrieved successfully',
203
- status: statusResult.parsedStatus,
204
- detailed: params.detailed,
205
- ...additionalInfo,
206
- raw: statusResult.stdout
207
- },
208
- metadata: {
209
- operation: 'status',
210
- timestamp: new Date().toISOString(),
211
- executionTime: Date.now() - startTime
212
- }
213
- };
214
- }
215
- catch (error) {
216
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
217
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('STATUS_ERROR', `Failed to get repository status: ${errorMessage}`, 'status', { error: errorMessage });
218
- }
219
- }
220
- /**
221
- * Handle commits operation
222
- */
223
- async handleCommits(params, startTime) {
224
- try {
225
- const args = ['log'];
226
- // Add limit
227
- const limit = params.limit || 50;
228
- args.push('-n', limit.toString());
229
- // Add format based on requested format
230
- let formatString = '%H|%h|%s|%an|%ae|%ad';
231
- if (params.format === 'full') {
232
- formatString = '%H|%h|%s|%an|%ae|%ad|%B';
233
- }
234
- else if (params.format === 'oneline') {
235
- formatString = '%h %s';
236
- }
237
- else if (params.format === 'raw') {
238
- formatString = 'raw';
239
- }
240
- if (params.format !== 'raw') {
241
- args.push(`--format=${formatString}`);
242
- args.push('--date=iso');
243
- }
244
- // Add graph if requested
245
- if (params.graph) {
246
- args.push('--graph');
247
- }
248
- // Add branch if specified
249
- if (params.branch) {
250
- args.push(params.branch);
251
- }
252
- // Add date filters
253
- if (params.since) {
254
- args.push(`--since=${params.since}`);
255
- }
256
- if (params.until) {
257
- args.push(`--until=${params.until}`);
258
- }
259
- // Add author filter
260
- if (params.author) {
261
- args.push(`--author=${params.author}`);
262
- }
263
- const result = await this.gitExecutor.executeGitCommand('log', args.slice(1), params.projectPath);
264
- if (!result.success) {
265
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(result.stderr, 'get commits', params.projectPath);
266
- }
267
- let commits = [];
268
- let formattedOutput = result.stdout;
269
- if (params.format !== 'raw' && params.format !== 'oneline') {
270
- commits = this.parseLogOutput(result.stdout);
271
- // Get commit stats if requested
272
- if (params.includeStats) {
273
- commits = await this.enrichCommitsWithStats(commits, params.projectPath);
274
- }
275
- }
276
- return {
277
- success: true,
278
- data: {
279
- message: `Retrieved ${commits.length || 'commits'} from repository`,
280
- totalCommits: commits.length,
281
- commits: commits.length > 0 ? commits : undefined,
282
- format: params.format || 'short',
283
- graph: params.graph,
284
- filters: {
285
- branch: params.branch,
286
- since: params.since,
287
- until: params.until,
288
- author: params.author,
289
- limit: limit
290
- },
291
- raw: formattedOutput
292
- },
293
- metadata: {
294
- operation: 'commits',
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('COMMITS_ERROR', `Failed to get repository commits: ${errorMessage}`, 'commits', { error: errorMessage });
303
- }
304
- }
305
- /**
306
- * Handle contributors operation
307
- */
308
- async handleContributors(params, startTime) {
309
- try {
310
- // Get contributors with commit counts
311
- const shortlogResult = await this.gitExecutor.executeGitCommand('shortlog', ['-sn', '--all'], params.projectPath);
312
- if (!shortlogResult.success) {
313
- return operation_error_handler_js_1.OperationErrorHandler.handleGitError(shortlogResult.stderr, 'get contributors', params.projectPath);
314
- }
315
- const contributors = [];
316
- const lines = shortlogResult.stdout.split('\n').filter(line => line.trim());
317
- for (const line of lines) {
318
- const match = line.match(/^\s*(\d+)\s+(.+)$/);
319
- if (match) {
320
- const commits = parseInt(match[1]);
321
- const name = match[2];
322
- // Get email for this contributor
323
- const emailResult = await this.gitExecutor.executeGitCommand('log', ['--format=%ae', `--author=${name}`, '-1'], params.projectPath);
324
- const email = emailResult.success ? emailResult.stdout.trim() : '';
325
- let insertions = 0;
326
- let deletions = 0;
327
- let firstCommit = '';
328
- let lastCommit = '';
329
- if (params.includeStats) {
330
- // Get detailed stats for this contributor
331
- const statsResult = await this.gitExecutor.executeGitCommand('log', ['--author=' + name, '--numstat', '--format=%ad', '--date=iso'], params.projectPath);
332
- if (statsResult.success) {
333
- const statsLines = statsResult.stdout.split('\n');
334
- for (const statsLine of statsLines) {
335
- const statMatch = statsLine.match(/^(\d+)\s+(\d+)\s+/);
336
- if (statMatch) {
337
- insertions += parseInt(statMatch[1]) || 0;
338
- deletions += parseInt(statMatch[2]) || 0;
339
- }
340
- }
341
- }
342
- // Get first and last commit dates
343
- const firstCommitResult = await this.gitExecutor.executeGitCommand('log', ['--author=' + name, '--format=%ad', '--date=iso', '--reverse'], params.projectPath);
344
- const lastCommitResult = await this.gitExecutor.executeGitCommand('log', ['--author=' + name, '--format=%ad', '--date=iso', '-1'], params.projectPath);
345
- if (firstCommitResult.success) {
346
- const firstLine = firstCommitResult.stdout.split('\n')[0];
347
- firstCommit = firstLine ? firstLine.trim() : '';
348
- }
349
- if (lastCommitResult.success) {
350
- lastCommit = lastCommitResult.stdout.trim();
351
- }
352
- }
353
- contributors.push({
354
- name,
355
- email,
356
- commits,
357
- insertions,
358
- deletions,
359
- firstCommit,
360
- lastCommit
361
- });
362
- }
363
- }
364
- // Sort contributors
365
- const sortBy = params.sortBy || 'commits';
366
- contributors.sort((a, b) => {
367
- switch (sortBy) {
368
- case 'commits':
369
- return b.commits - a.commits;
370
- case 'lines':
371
- return (b.insertions + b.deletions) - (a.insertions + a.deletions);
372
- case 'name':
373
- return a.name.localeCompare(b.name);
374
- default:
375
- return b.commits - a.commits;
376
- }
377
- });
378
- const totalCommits = contributors.reduce((sum, c) => sum + c.commits, 0);
379
- const totalInsertions = contributors.reduce((sum, c) => sum + c.insertions, 0);
380
- const totalDeletions = contributors.reduce((sum, c) => sum + c.deletions, 0);
381
- return {
382
- success: true,
383
- data: {
384
- message: `Found ${contributors.length} contributors`,
385
- totalContributors: contributors.length,
386
- contributors: contributors,
387
- summary: {
388
- totalCommits,
389
- totalInsertions,
390
- totalDeletions,
391
- totalLines: totalInsertions + totalDeletions
392
- },
393
- sortBy: sortBy,
394
- includeStats: params.includeStats,
395
- raw: shortlogResult.stdout
396
- },
397
- metadata: {
398
- operation: 'contributors',
399
- timestamp: new Date().toISOString(),
400
- executionTime: Date.now() - startTime
401
- }
402
- };
403
- }
404
- catch (error) {
405
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
406
- return operation_error_handler_js_1.OperationErrorHandler.createToolError('CONTRIBUTORS_ERROR', `Failed to get repository contributors: ${errorMessage}`, 'contributors', { error: errorMessage });
407
- }
408
- }
409
- /**
410
- * Parse log output into structured commit information
411
- */
412
- parseLogOutput(logOutput) {
413
- const commits = [];
414
- const lines = logOutput.split('\n').filter(line => line.trim());
415
- for (const line of lines) {
416
- const parts = line.split('|');
417
- if (parts.length >= 6) {
418
- commits.push({
419
- hash: parts[0],
420
- shortHash: parts[1],
421
- message: parts[2],
422
- author: parts[3],
423
- authorEmail: parts[4],
424
- date: parts[5]
425
- });
426
- }
427
- }
428
- return commits;
429
- }
430
- /**
431
- * Enrich commits with statistics (insertions/deletions)
432
- */
433
- async enrichCommitsWithStats(commits, projectPath) {
434
- const enrichedCommits = [];
435
- for (const commit of commits) {
436
- const statsResult = await this.gitExecutor.executeGitCommand('show', ['--numstat', '--format=', commit.hash], projectPath);
437
- let insertions = 0;
438
- let deletions = 0;
439
- if (statsResult.success) {
440
- const lines = statsResult.stdout.split('\n').filter(line => line.trim());
441
- for (const line of lines) {
442
- const match = line.match(/^(\d+)\s+(\d+)\s+/);
443
- if (match) {
444
- insertions += parseInt(match[1]) || 0;
445
- deletions += parseInt(match[2]) || 0;
446
- }
447
- }
448
- }
449
- enrichedCommits.push({
450
- ...commit,
451
- insertions,
452
- deletions
453
- });
454
- }
455
- return enrichedCommits;
456
- }
457
- /**
458
- * Get tool schema for MCP registration
459
- */
460
- static getToolSchema() {
461
- return {
462
- name: 'git-monitor',
463
- description: 'Git monitoring and logging tool for log, status, commits, and contributors operations. Provides comprehensive repository analysis and monitoring capabilities.',
464
- inputSchema: {
465
- type: 'object',
466
- properties: {
467
- action: {
468
- type: 'string',
469
- enum: ['log', 'status', 'commits', 'contributors'],
470
- description: 'The Git monitoring operation to perform'
471
- },
472
- projectPath: {
473
- type: 'string',
474
- description: 'Absolute path to the project directory'
475
- },
476
- limit: {
477
- type: 'number',
478
- description: 'Number of commits to show (1-1000, default: 10 for log, 50 for commits)',
479
- minimum: 1,
480
- maximum: 1000
481
- },
482
- branch: {
483
- type: 'string',
484
- description: 'Branch to analyze (default: current branch)'
485
- },
486
- since: {
487
- type: 'string',
488
- description: 'Date since when to show logs (e.g., "2024-01-01", "1 week ago")'
489
- },
490
- until: {
491
- type: 'string',
492
- description: 'Date until when to show logs (e.g., "2024-01-01", "1 week ago")'
493
- },
494
- author: {
495
- type: 'string',
496
- description: 'Filter by author name or email'
497
- },
498
- grep: {
499
- type: 'string',
500
- description: 'Filter by commit message pattern'
501
- },
502
- detailed: {
503
- type: 'boolean',
504
- description: 'Show detailed status information (for status operation)'
505
- },
506
- format: {
507
- type: 'string',
508
- enum: ['short', 'full', 'oneline', 'raw'],
509
- description: 'Commit format (for commits operation)'
510
- },
511
- graph: {
512
- type: 'boolean',
513
- description: 'Show commit graph (for commits operation)'
514
- },
515
- sortBy: {
516
- type: 'string',
517
- enum: ['commits', 'lines', 'name'],
518
- description: 'Sort contributors by (for contributors operation)'
519
- },
520
- includeStats: {
521
- type: 'boolean',
522
- description: 'Include detailed statistics (insertions/deletions)'
523
- }
524
- },
525
- required: ['action', 'projectPath']
526
- }
527
- };
528
- }
529
- }
530
- exports.GitMonitorTool = GitMonitorTool;
531
- //# sourceMappingURL=git-monitor.js.map