@andrebuzeli/git-mcp 7.2.4 → 7.3.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.
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitReleaseTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- const axios_1 = __importDefault(require("axios"));
10
- class GitReleaseTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import axios from 'axios';
4
+ export class GitReleaseTool {
11
5
  constructor() {
12
6
  this.name = 'git-release';
13
7
  this.description = 'Release management operations - automatic dual-provider execution';
@@ -16,9 +10,9 @@ class GitReleaseTool {
16
10
  const action = params.action;
17
11
  const projectPath = params.projectPath;
18
12
  if (!action)
19
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action is required');
13
+ throw new MCPError('VALIDATION_ERROR', 'action is required');
20
14
  if (!projectPath)
21
- throw new errors_1.MCPError('VALIDATION_ERROR', 'projectPath is required');
15
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
22
16
  const githubOwner = params.owner || process.env.GITHUB_USERNAME;
23
17
  const giteaOwner = params.owner || process.env.GITEA_USERNAME;
24
18
  const repo = params.repo;
@@ -26,8 +20,8 @@ class GitReleaseTool {
26
20
  case 'create': {
27
21
  const tagName = params.tagName;
28
22
  if (!tagName)
29
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
30
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
23
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
24
+ const git = simpleGit({ baseDir: projectPath });
31
25
  await git.addAnnotatedTag(tagName, params.description || tagName);
32
26
  const results = { success: true, localTag: tagName, providers: {} };
33
27
  if (ctx.providerManager.github) {
@@ -49,7 +43,7 @@ class GitReleaseTool {
49
43
  }
50
44
  if (ctx.providerManager.giteaBaseUrl) {
51
45
  try {
52
- const result = await axios_1.default.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, {
46
+ const result = await axios.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, {
53
47
  tag_name: tagName,
54
48
  name: params.releaseName || tagName,
55
49
  body: params.body,
@@ -80,7 +74,7 @@ class GitReleaseTool {
80
74
  }
81
75
  if (ctx.providerManager.giteaBaseUrl) {
82
76
  try {
83
- const result = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
77
+ const result = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
84
78
  results.providers.gitea = { success: true, releases: result.data };
85
79
  }
86
80
  catch (err) {
@@ -92,7 +86,7 @@ class GitReleaseTool {
92
86
  case 'get': {
93
87
  const tagName = params.tagName;
94
88
  if (!tagName)
95
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
89
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
96
90
  const results = { success: true, providers: {} };
97
91
  if (ctx.providerManager.github) {
98
92
  try {
@@ -109,7 +103,7 @@ class GitReleaseTool {
109
103
  }
110
104
  if (ctx.providerManager.giteaBaseUrl) {
111
105
  try {
112
- const result = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/tags/${tagName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
106
+ const result = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/tags/${tagName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
113
107
  results.providers.gitea = { success: true, release: result.data };
114
108
  }
115
109
  catch (err) {
@@ -121,7 +115,7 @@ class GitReleaseTool {
121
115
  case 'update': {
122
116
  const tagName = params.tagName;
123
117
  if (!tagName)
124
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
118
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
125
119
  const results = { success: true, providers: {} };
126
120
  // GitHub
127
121
  if (ctx.providerManager.github) {
@@ -154,13 +148,13 @@ class GitReleaseTool {
154
148
  // Gitea
155
149
  if (ctx.providerManager.giteaBaseUrl) {
156
150
  try {
157
- const releases = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
151
+ const releases = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
158
152
  const release = releases.data.find((r) => r.tag_name === tagName);
159
153
  if (!release) {
160
154
  results.providers.gitea = { success: false, error: 'Release not found' };
161
155
  }
162
156
  else {
163
- const result = await axios_1.default.patch(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, {
157
+ const result = await axios.patch(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, {
164
158
  name: params.releaseName,
165
159
  body: params.body,
166
160
  draft: params.draft,
@@ -178,7 +172,7 @@ class GitReleaseTool {
178
172
  case 'delete': {
179
173
  const tagName = params.tagName;
180
174
  if (!tagName)
181
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
175
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
182
176
  const results = { success: true, providers: {} };
183
177
  // GitHub
184
178
  if (ctx.providerManager.github) {
@@ -207,13 +201,13 @@ class GitReleaseTool {
207
201
  // Gitea
208
202
  if (ctx.providerManager.giteaBaseUrl) {
209
203
  try {
210
- const releases = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
204
+ const releases = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
211
205
  const release = releases.data.find((r) => r.tag_name === tagName);
212
206
  if (!release) {
213
207
  results.providers.gitea = { success: false, error: 'Release not found' };
214
208
  }
215
209
  else {
216
- await axios_1.default.delete(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
210
+ await axios.delete(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
217
211
  results.providers.gitea = { success: true, deleted: true };
218
212
  }
219
213
  }
@@ -226,7 +220,7 @@ class GitReleaseTool {
226
220
  case 'publish': {
227
221
  const tagName = params.tagName;
228
222
  if (!tagName)
229
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
223
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
230
224
  const results = { success: true, providers: {} };
231
225
  // GitHub - publish = set draft: false
232
226
  if (ctx.providerManager.github) {
@@ -256,13 +250,13 @@ class GitReleaseTool {
256
250
  // Gitea - publish = set draft: false
257
251
  if (ctx.providerManager.giteaBaseUrl) {
258
252
  try {
259
- const releases = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
253
+ const releases = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
260
254
  const release = releases.data.find((r) => r.tag_name === tagName);
261
255
  if (!release) {
262
256
  results.providers.gitea = { success: false, error: 'Release not found' };
263
257
  }
264
258
  else {
265
- const result = await axios_1.default.patch(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, { draft: false }, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
259
+ const result = await axios.patch(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/${release.id}`, { draft: false }, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
266
260
  results.providers.gitea = { success: true, release: result.data };
267
261
  }
268
262
  }
@@ -275,7 +269,7 @@ class GitReleaseTool {
275
269
  case 'download': {
276
270
  const tagName = params.tagName;
277
271
  if (!tagName)
278
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
272
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
279
273
  const results = { success: true, providers: {} };
280
274
  // GitHub
281
275
  if (ctx.providerManager.github) {
@@ -299,7 +293,7 @@ class GitReleaseTool {
299
293
  // Gitea
300
294
  if (ctx.providerManager.giteaBaseUrl) {
301
295
  try {
302
- const result = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/tags/${tagName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
296
+ const result = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/releases/tags/${tagName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
303
297
  const assets = result.data.assets?.map((a) => ({
304
298
  name: a.name,
305
299
  url: a.browser_download_url,
@@ -314,8 +308,7 @@ class GitReleaseTool {
314
308
  return results;
315
309
  }
316
310
  default:
317
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
311
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
318
312
  }
319
313
  }
320
314
  }
321
- exports.GitReleaseTool = GitReleaseTool;
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitRemoteTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- const repoHelpers_1 = require("../utils/repoHelpers");
10
- class GitRemoteTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import { getRepoInfo, buildGitHubUrl, buildGiteaUrl } from '../utils/repoHelpers';
4
+ export class GitRemoteTool {
11
5
  constructor() {
12
6
  this.name = 'git-remote';
13
7
  this.description = 'Remote repository management - automatic username detection from env vars';
@@ -16,28 +10,28 @@ class GitRemoteTool {
16
10
  const action = params.action;
17
11
  const projectPath = params.projectPath;
18
12
  if (!action || !projectPath) {
19
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
13
+ throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
20
14
  }
21
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
15
+ const git = simpleGit({ baseDir: projectPath });
22
16
  switch (action) {
23
17
  case 'add': {
24
18
  const name = params.name || 'origin';
25
19
  let url = params.url;
26
20
  // Auto-construct URL if not provided
27
21
  if (!url) {
28
- const { repoName, githubOwner, giteaOwner } = (0, repoHelpers_1.getRepoInfo)(projectPath);
22
+ const { repoName, githubOwner, giteaOwner } = getRepoInfo(projectPath);
29
23
  if (name === 'github' && githubOwner) {
30
- url = (0, repoHelpers_1.buildGitHubUrl)(githubOwner, repoName);
24
+ url = buildGitHubUrl(githubOwner, repoName);
31
25
  }
32
26
  else if (name === 'gitea' && giteaOwner) {
33
- url = (0, repoHelpers_1.buildGiteaUrl)(giteaOwner, repoName);
27
+ url = buildGiteaUrl(giteaOwner, repoName);
34
28
  }
35
29
  else if (name === 'origin' && githubOwner) {
36
30
  // Default to GitHub for 'origin'
37
- url = (0, repoHelpers_1.buildGitHubUrl)(githubOwner, repoName);
31
+ url = buildGitHubUrl(githubOwner, repoName);
38
32
  }
39
33
  else {
40
- throw new errors_1.MCPError('VALIDATION_ERROR', 'url is required or set GITHUB_USERNAME/GITEA_USERNAME in environment');
34
+ throw new MCPError('VALIDATION_ERROR', 'url is required or set GITHUB_USERNAME/GITEA_USERNAME in environment');
41
35
  }
42
36
  }
43
37
  await git.addRemote(name, url);
@@ -46,7 +40,7 @@ class GitRemoteTool {
46
40
  case 'remove': {
47
41
  const name = params.name;
48
42
  if (!name)
49
- throw new errors_1.MCPError('VALIDATION_ERROR', 'name is required');
43
+ throw new MCPError('VALIDATION_ERROR', 'name is required');
50
44
  await git.removeRemote(name);
51
45
  return { success: true, removed: name };
52
46
  }
@@ -54,7 +48,7 @@ class GitRemoteTool {
54
48
  const name = params.name;
55
49
  const newName = params.newName;
56
50
  if (!name || !newName)
57
- throw new errors_1.MCPError('VALIDATION_ERROR', 'name and newName are required');
51
+ throw new MCPError('VALIDATION_ERROR', 'name and newName are required');
58
52
  await git.remote(['rename', name, newName]);
59
53
  return { success: true, renamed: name, to: newName };
60
54
  }
@@ -68,19 +62,19 @@ class GitRemoteTool {
68
62
  let url = params.url;
69
63
  // Auto-construct URL if not provided
70
64
  if (!url) {
71
- const { repoName, githubOwner, giteaOwner } = (0, repoHelpers_1.getRepoInfo)(projectPath);
65
+ const { repoName, githubOwner, giteaOwner } = getRepoInfo(projectPath);
72
66
  if (name === 'github' && githubOwner) {
73
- url = (0, repoHelpers_1.buildGitHubUrl)(githubOwner, repoName);
67
+ url = buildGitHubUrl(githubOwner, repoName);
74
68
  }
75
69
  else if (name === 'gitea' && giteaOwner) {
76
- url = (0, repoHelpers_1.buildGiteaUrl)(giteaOwner, repoName);
70
+ url = buildGiteaUrl(giteaOwner, repoName);
77
71
  }
78
72
  else if (name === 'origin' && githubOwner) {
79
73
  // Default to GitHub for 'origin'
80
- url = (0, repoHelpers_1.buildGitHubUrl)(githubOwner, repoName);
74
+ url = buildGitHubUrl(githubOwner, repoName);
81
75
  }
82
76
  else {
83
- throw new errors_1.MCPError('VALIDATION_ERROR', 'url is required or set GITHUB_USERNAME/GITEA_USERNAME in environment');
77
+ throw new MCPError('VALIDATION_ERROR', 'url is required or set GITHUB_USERNAME/GITEA_USERNAME in environment');
84
78
  }
85
79
  }
86
80
  await git.remote(['set-url', name, url]);
@@ -92,8 +86,7 @@ class GitRemoteTool {
92
86
  return { success: true, pruned: name };
93
87
  }
94
88
  default:
95
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
89
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
96
90
  }
97
91
  }
98
92
  }
99
- exports.GitRemoteTool = GitRemoteTool;
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitResetTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- const safetyController_1 = require("../utils/safetyController");
10
- class GitResetTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import { requireConfirmationIfDestructive } from '../utils/safetyController';
4
+ export class GitResetTool {
11
5
  constructor() {
12
6
  this.name = 'git-reset';
13
7
  this.description = 'Repository reset operations (USE WITH CAUTION)';
@@ -16,10 +10,10 @@ class GitResetTool {
16
10
  const action = params.action;
17
11
  const projectPath = params.projectPath;
18
12
  if (!action || !projectPath) {
19
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
13
+ throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
20
14
  }
21
- (0, safetyController_1.requireConfirmationIfDestructive)(action, params);
22
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
15
+ requireConfirmationIfDestructive(action, params);
16
+ const git = simpleGit({ baseDir: projectPath });
23
17
  switch (action) {
24
18
  case 'soft': {
25
19
  const target = params.target || 'HEAD~1';
@@ -44,7 +38,7 @@ class GitResetTool {
44
38
  case 'reset-to-commit': {
45
39
  const commit = params.commit;
46
40
  if (!commit)
47
- throw new errors_1.MCPError('VALIDATION_ERROR', 'commit is required');
41
+ throw new MCPError('VALIDATION_ERROR', 'commit is required');
48
42
  const mode = params.mode || 'mixed';
49
43
  await git.reset([`--${mode}`, commit]);
50
44
  return { success: true, mode, commit };
@@ -52,13 +46,12 @@ class GitResetTool {
52
46
  case 'reset-branch': {
53
47
  const branch = params.branch;
54
48
  if (!branch)
55
- throw new errors_1.MCPError('VALIDATION_ERROR', 'branch is required');
49
+ throw new MCPError('VALIDATION_ERROR', 'branch is required');
56
50
  await git.reset(['--hard', `origin/${branch}`]);
57
51
  return { success: true, branch, warning: 'Branch reset to match origin' };
58
52
  }
59
53
  default:
60
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
54
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
61
55
  }
62
56
  }
63
57
  }
64
- exports.GitResetTool = GitResetTool;
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitStashTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- class GitStashTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ export class GitStashTool {
10
4
  constructor() {
11
5
  this.name = 'git-stash';
12
6
  this.description = 'Stash management operations - local Git operations';
@@ -15,9 +9,9 @@ class GitStashTool {
15
9
  const action = params.action;
16
10
  const projectPath = params.projectPath;
17
11
  if (!action || !projectPath) {
18
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
12
+ throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
19
13
  }
20
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
14
+ const git = simpleGit({ baseDir: projectPath });
21
15
  switch (action) {
22
16
  case 'stash': {
23
17
  const message = params.message;
@@ -60,8 +54,7 @@ class GitStashTool {
60
54
  return { success: true, message: 'All stashes cleared' };
61
55
  }
62
56
  default:
63
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
57
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
64
58
  }
65
59
  }
66
60
  }
67
- exports.GitStashTool = GitStashTool;
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitSyncTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- class GitSyncTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ export class GitSyncTool {
10
4
  constructor() {
11
5
  this.name = 'git-sync';
12
6
  this.description = 'Repository synchronization operations - local Git operations';
@@ -15,9 +9,9 @@ class GitSyncTool {
15
9
  const action = params.action;
16
10
  const projectPath = params.projectPath;
17
11
  if (!action || !projectPath) {
18
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
12
+ throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
19
13
  }
20
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
14
+ const git = simpleGit({ baseDir: projectPath });
21
15
  switch (action) {
22
16
  case 'sync': {
23
17
  const remote = params.remote || 'origin';
@@ -44,8 +38,7 @@ class GitSyncTool {
44
38
  };
45
39
  }
46
40
  default:
47
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
41
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
48
42
  }
49
43
  }
50
44
  }
51
- exports.GitSyncTool = GitSyncTool;
@@ -1,14 +1,8 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitTagsTool = void 0;
7
- const simple_git_1 = __importDefault(require("simple-git"));
8
- const errors_1 = require("../utils/errors");
9
- const axios_1 = __importDefault(require("axios"));
10
- const repoHelpers_1 = require("../utils/repoHelpers");
11
- class GitTagsTool {
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import axios from 'axios';
4
+ import { getRepoInfo } from '../utils/repoHelpers';
5
+ export class GitTagsTool {
12
6
  constructor() {
13
7
  this.name = 'git-tags';
14
8
  this.description = 'Tag management operations - automatic dual-provider execution for remote queries';
@@ -17,14 +11,14 @@ class GitTagsTool {
17
11
  const action = params.action;
18
12
  const projectPath = params.projectPath;
19
13
  if (!action || !projectPath) {
20
- throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
14
+ throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
21
15
  }
22
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
16
+ const git = simpleGit({ baseDir: projectPath });
23
17
  switch (action) {
24
18
  case 'create': {
25
19
  const tagName = params.tagName;
26
20
  if (!tagName)
27
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
21
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
28
22
  if (params.annotated) {
29
23
  await git.addAnnotatedTag(tagName, params.message || tagName);
30
24
  }
@@ -41,7 +35,7 @@ class GitTagsTool {
41
35
  providers: {}
42
36
  };
43
37
  // Also query remote APIs
44
- const repoInfo = (0, repoHelpers_1.getRepoInfo)(projectPath);
38
+ const repoInfo = getRepoInfo(projectPath);
45
39
  const githubOwner = process.env.GITHUB_USERNAME;
46
40
  const giteaOwner = process.env.GITEA_USERNAME;
47
41
  // GitHub
@@ -68,7 +62,7 @@ class GitTagsTool {
68
62
  // Gitea
69
63
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
70
64
  try {
71
- const tags = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
65
+ const tags = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
72
66
  results.providers.gitea = {
73
67
  success: true,
74
68
  tags: tags.data.map((t) => ({
@@ -88,7 +82,7 @@ class GitTagsTool {
88
82
  case 'get': {
89
83
  const tagName = params.tagName;
90
84
  if (!tagName)
91
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
85
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
92
86
  const localTags = await git.tags();
93
87
  const localTag = localTags.all.find(t => t === tagName);
94
88
  const results = {
@@ -104,7 +98,7 @@ class GitTagsTool {
104
98
  catch { }
105
99
  }
106
100
  // Also query remote APIs
107
- const repoInfo = (0, repoHelpers_1.getRepoInfo)(projectPath);
101
+ const repoInfo = getRepoInfo(projectPath);
108
102
  const githubOwner = process.env.GITHUB_USERNAME;
109
103
  const giteaOwner = process.env.GITEA_USERNAME;
110
104
  // GitHub
@@ -132,7 +126,7 @@ class GitTagsTool {
132
126
  // Gitea
133
127
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
134
128
  try {
135
- const tags = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
129
+ const tags = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
136
130
  const tag = tags.data.find((t) => t.name === tagName);
137
131
  if (tag) {
138
132
  results.providers.gitea = {
@@ -157,14 +151,14 @@ class GitTagsTool {
157
151
  case 'delete': {
158
152
  const tagName = params.tagName;
159
153
  if (!tagName)
160
- throw new errors_1.MCPError('VALIDATION_ERROR', 'tagName is required');
154
+ throw new MCPError('VALIDATION_ERROR', 'tagName is required');
161
155
  await git.tag(['-d', tagName]);
162
156
  return { success: true, deleted: tagName, local: true };
163
157
  }
164
158
  case 'search': {
165
159
  const pattern = params.pattern;
166
160
  if (!pattern)
167
- throw new errors_1.MCPError('VALIDATION_ERROR', 'pattern is required');
161
+ throw new MCPError('VALIDATION_ERROR', 'pattern is required');
168
162
  const localTags = await git.tags();
169
163
  const filtered = localTags.all.filter(t => t.includes(pattern));
170
164
  const results = {
@@ -173,7 +167,7 @@ class GitTagsTool {
173
167
  providers: {}
174
168
  };
175
169
  // Also search remote APIs
176
- const repoInfo = (0, repoHelpers_1.getRepoInfo)(projectPath);
170
+ const repoInfo = getRepoInfo(projectPath);
177
171
  const githubOwner = process.env.GITHUB_USERNAME;
178
172
  const giteaOwner = process.env.GITEA_USERNAME;
179
173
  // GitHub
@@ -196,7 +190,7 @@ class GitTagsTool {
196
190
  // Gitea
197
191
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
198
192
  try {
199
- const tags = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
193
+ const tags = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoInfo.repoName}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
200
194
  const matchedTags = tags.data.filter((t) => t.name.includes(pattern));
201
195
  results.providers.gitea = {
202
196
  success: true,
@@ -210,8 +204,7 @@ class GitTagsTool {
210
204
  return results;
211
205
  }
212
206
  default:
213
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
207
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
214
208
  }
215
209
  }
216
210
  }
217
- exports.GitTagsTool = GitTagsTool;