@andrebuzeli/git-mcp 7.2.5 → 7.3.1

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.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;
@@ -1,54 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.GitUpdateTool = void 0;
40
- const simple_git_1 = __importDefault(require("simple-git"));
41
- const errors_1 = require("../utils/errors");
42
- const axios_1 = __importDefault(require("axios"));
43
- const fs = __importStar(require("fs/promises"));
44
- const path = __importStar(require("path"));
45
- const repoHelpers_1 = require("../utils/repoHelpers");
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import axios from 'axios';
4
+ import * as fs from 'fs/promises';
5
+ import * as path from 'path';
6
+ import { getRepoNameFromPath } from '../utils/repoHelpers';
46
7
  /**
47
8
  * Git Update Tool - Atualiza projeto completo em GitHub e Gitea automaticamente
48
9
  * Modo DUAL automático com rastreabilidade completa
49
10
  * Inclui: add, commit, push, sync, history tracking
50
11
  */
51
- class GitUpdateTool {
12
+ export class GitUpdateTool {
52
13
  constructor() {
53
14
  this.name = 'git-update';
54
15
  this.description = 'Complete project update workflow (add, commit, push) to GitHub and Gitea with full traceability - automatic dual-provider execution';
@@ -56,12 +17,12 @@ class GitUpdateTool {
56
17
  async handle(params, ctx) {
57
18
  const projectPath = params.projectPath;
58
19
  if (!projectPath) {
59
- throw new errors_1.MCPError('VALIDATION_ERROR', 'projectPath is required');
20
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
60
21
  }
61
22
  const commitMessage = params.message || params.commitMessage || `[git-update] Update at ${new Date().toISOString()}`;
62
23
  const branch = params.branch || 'master';
63
24
  const files = params.files || ['.'];
64
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
25
+ const git = simpleGit({ baseDir: projectPath });
65
26
  // Resultado com rastreabilidade completa
66
27
  const results = {
67
28
  success: true,
@@ -151,7 +112,7 @@ class GitUpdateTool {
151
112
  let githubRemote = remotes.find(r => r.name === 'github' || r.name === 'origin');
152
113
  let giteaRemote = remotes.find(r => r.name === 'gitea');
153
114
  // Auto-create repos if they don't exist
154
- const repoName = params.repoName || (0, repoHelpers_1.getRepoNameFromPath)(projectPath);
115
+ const repoName = params.repoName || getRepoNameFromPath(projectPath);
155
116
  const description = params.description || `Project updated via git-update at ${new Date().toISOString()}`;
156
117
  const isPrivate = params.private !== undefined ? params.private : true;
157
118
  const githubOwner = params.owner || process.env.GITHUB_USERNAME;
@@ -212,12 +173,12 @@ class GitUpdateTool {
212
173
  // Try to get repo, create if doesn't exist
213
174
  let repoExists = false;
214
175
  try {
215
- await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
176
+ await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
216
177
  repoExists = true;
217
178
  }
218
179
  catch { }
219
180
  if (!repoExists) {
220
- await axios_1.default.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/user/repos`, {
181
+ await axios.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/user/repos`, {
221
182
  name: repoName,
222
183
  description,
223
184
  private: isPrivate,
@@ -268,7 +229,7 @@ class GitUpdateTool {
268
229
  try {
269
230
  if (results.traceability.commit?.hash) {
270
231
  const githubOwner = params.owner || process.env.GITHUB_USERNAME;
271
- const repo = (0, repoHelpers_1.getRepoNameFromPath)(projectPath);
232
+ const repo = getRepoNameFromPath(projectPath);
272
233
  const commitInfo = await ctx.providerManager.github.rest.repos.getCommit({
273
234
  owner: githubOwner,
274
235
  repo,
@@ -320,8 +281,8 @@ class GitUpdateTool {
320
281
  try {
321
282
  if (results.traceability.commit?.hash) {
322
283
  const giteaOwner = params.owner || process.env.GITEA_USERNAME;
323
- const repo = (0, repoHelpers_1.getRepoNameFromPath)(projectPath);
324
- const commitInfo = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/git/commits/${results.traceability.commit.hash}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
284
+ const repo = getRepoNameFromPath(projectPath);
285
+ const commitInfo = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/git/commits/${results.traceability.commit.hash}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
325
286
  results.providers.gitea.commitVerified = true;
326
287
  results.providers.gitea.commitUrl = commitInfo.data.html_url;
327
288
  }
@@ -363,7 +324,7 @@ class GitUpdateTool {
363
324
  return results;
364
325
  }
365
326
  catch (err) {
366
- throw new errors_1.MCPError('UPDATE_ERROR', `Failed to update project: ${err.message}`);
327
+ throw new MCPError('UPDATE_ERROR', `Failed to update project: ${err.message}`);
367
328
  }
368
329
  }
369
330
  async saveUpdateHistory(projectPath, results) {
@@ -394,9 +355,9 @@ class GitUpdateTool {
394
355
  const githubOwner = params.owner || process.env.GITHUB_USERNAME;
395
356
  const giteaOwner = params.owner || process.env.GITEA_USERNAME;
396
357
  // Pegar nome do repo dos remotes do Git ao invés do nome da pasta
397
- const git = (0, simple_git_1.default)(projectPath);
358
+ const git = simpleGit(projectPath);
398
359
  const remotes = await git.getRemotes(true);
399
- let repoName = (0, repoHelpers_1.getRepoNameFromPath)(projectPath); // fallback
360
+ let repoName = getRepoNameFromPath(projectPath); // fallback
400
361
  if (remotes.length > 0) {
401
362
  const githubRemote = remotes.find(r => r.name === 'github') || remotes.find(r => r.name === 'origin') || remotes[0];
402
363
  const match = githubRemote.refs.push?.match(/\/([^\/]+?)(\.git)?$/);
@@ -423,7 +384,7 @@ class GitUpdateTool {
423
384
  // Gitea
424
385
  if (ctx.providerManager.giteaBaseUrl && results.providers.gitea?.success) {
425
386
  try {
426
- await axios_1.default.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}/issues`, {
387
+ await axios.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}/issues`, {
427
388
  title: historyTitle,
428
389
  body: historyBody,
429
390
  labels: [1], // Assumindo label ID 1 para git-history
@@ -465,4 +426,3 @@ ${results.providers.gitea?.commitUrl ? `- Gitea: ${results.providers.gitea.commi
465
426
  `;
466
427
  }
467
428
  }
468
- exports.GitUpdateTool = GitUpdateTool;
@@ -1,53 +1,14 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.GitUploadTool = void 0;
40
- const simple_git_1 = __importDefault(require("simple-git"));
41
- const errors_1 = require("../utils/errors");
42
- const axios_1 = __importDefault(require("axios"));
43
- const fs = __importStar(require("fs/promises"));
44
- const path = __importStar(require("path"));
45
- const repoHelpers_1 = require("../utils/repoHelpers");
1
+ import simpleGit from 'simple-git';
2
+ import { MCPError } from '../utils/errors';
3
+ import axios from 'axios';
4
+ import * as fs from 'fs/promises';
5
+ import * as path from 'path';
6
+ import { getRepoNameFromPath } from '../utils/repoHelpers';
46
7
  /**
47
8
  * Git Upload Tool - Envia projeto completo para GitHub e Gitea automaticamente
48
9
  * Modo DUAL automático com rastreabilidade completa
49
10
  */
50
- class GitUploadTool {
11
+ export class GitUploadTool {
51
12
  constructor() {
52
13
  this.name = 'git-upload';
53
14
  this.description = 'Upload complete project to GitHub and Gitea with full traceability - automatic dual-provider execution';
@@ -55,13 +16,13 @@ class GitUploadTool {
55
16
  async handle(params, ctx) {
56
17
  const projectPath = params.projectPath;
57
18
  if (!projectPath) {
58
- throw new errors_1.MCPError('VALIDATION_ERROR', 'projectPath is required');
19
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
59
20
  }
60
- const repoName = params.repoName || (0, repoHelpers_1.getRepoNameFromPath)(projectPath);
21
+ const repoName = params.repoName || getRepoNameFromPath(projectPath);
61
22
  const description = params.description || `Project uploaded via git-upload at ${new Date().toISOString()}`;
62
23
  const isPrivate = params.private !== undefined ? params.private : true;
63
24
  const branch = params.branch || 'master';
64
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
25
+ const git = simpleGit({ baseDir: projectPath });
65
26
  // Resultado com rastreabilidade completa
66
27
  const results = {
67
28
  success: true,
@@ -248,12 +209,12 @@ class GitUploadTool {
248
209
  // Verificar se repo já existe
249
210
  let repoExists = false;
250
211
  try {
251
- await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
212
+ await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repoName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
252
213
  repoExists = true;
253
214
  }
254
215
  catch { }
255
216
  if (!repoExists) {
256
- const createResult = await axios_1.default.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/user/repos`, {
217
+ const createResult = await axios.post(`${ctx.providerManager.giteaBaseUrl}/api/v1/user/repos`, {
257
218
  name: repoName,
258
219
  description,
259
220
  private: isPrivate,
@@ -330,7 +291,7 @@ class GitUploadTool {
330
291
  return results;
331
292
  }
332
293
  catch (err) {
333
- throw new errors_1.MCPError('UPLOAD_ERROR', `Failed to upload project: ${err.message}`);
294
+ throw new MCPError('UPLOAD_ERROR', `Failed to upload project: ${err.message}`);
334
295
  }
335
296
  }
336
297
  async saveUploadHistory(projectPath, results) {
@@ -357,4 +318,3 @@ class GitUploadTool {
357
318
  }
358
319
  }
359
320
  }
360
- exports.GitUploadTool = GitUploadTool;