@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.
package/dist/config.js CHANGED
@@ -1,11 +1,5 @@
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.loadMCPConfig = loadMCPConfig;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
1
+ import fs from 'fs';
2
+ import path from 'path';
9
3
  function maskSecret(value) {
10
4
  if (!value)
11
5
  return 'undefined';
@@ -13,12 +7,12 @@ function maskSecret(value) {
13
7
  return '****';
14
8
  return `${value.slice(0, 4)}...${value.slice(-4)}`;
15
9
  }
16
- function loadMCPConfig(configPath) {
17
- const cfgPath = path_1.default.resolve(process.cwd(), configPath ?? 'mcp.json');
18
- if (!fs_1.default.existsSync(cfgPath))
10
+ export function loadMCPConfig(configPath) {
11
+ const cfgPath = path.resolve(process.cwd(), configPath ?? 'mcp.json');
12
+ if (!fs.existsSync(cfgPath))
19
13
  return null;
20
14
  try {
21
- const raw = fs_1.default.readFileSync(cfgPath, 'utf8');
15
+ const raw = fs.readFileSync(cfgPath, 'utf8');
22
16
  const cfg = JSON.parse(raw);
23
17
  if (cfg.env) {
24
18
  for (const [k, v] of Object.entries(cfg.env)) {
package/dist/index.js CHANGED
@@ -1,71 +1,66 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const index_1 = require("@modelcontextprotocol/sdk/server/index");
8
- const stdio_1 = require("@modelcontextprotocol/sdk/server/stdio");
9
- const types_1 = require("@modelcontextprotocol/sdk/types");
10
- const providerManager_1 = require("./providers/providerManager");
11
- const config_1 = require("./config");
12
- const gitFiles_1 = require("./tools/gitFiles");
13
- const gitWorkflow_1 = require("./tools/gitWorkflow");
14
- const gitBranches_1 = require("./tools/gitBranches");
15
- const gitIssues_1 = require("./tools/gitIssues");
16
- const gitPulls_1 = require("./tools/gitPulls");
17
- const gitTags_1 = require("./tools/gitTags");
18
- const gitRelease_1 = require("./tools/gitRelease");
19
- const gitRemote_1 = require("./tools/gitRemote");
20
- const gitReset_1 = require("./tools/gitReset");
21
- const gitStash_1 = require("./tools/gitStash");
22
- const gitConfig_1 = require("./tools/gitConfig");
23
- const gitMonitor_1 = require("./tools/gitMonitor");
24
- const gitBackup_1 = require("./tools/gitBackup");
25
- const gitArchive_1 = require("./tools/gitArchive");
26
- const gitSync_1 = require("./tools/gitSync");
27
- const gitPackages_1 = require("./tools/gitPackages");
28
- const gitAnalytics_1 = require("./tools/gitAnalytics");
29
- const gitUpload_1 = require("./tools/gitUpload");
30
- const gitUpdate_1 = require("./tools/gitUpdate");
31
- const gitHistory_1 = require("./tools/gitHistory");
32
- const gitFix_tool_1 = require("./tools/gitFix.tool");
33
- const gitIgnore_1 = require("./tools/gitIgnore");
34
- const toolsGuide_1 = __importDefault(require("./resources/toolsGuide"));
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
+ import { ProviderManager } from './providers/providerManager.js';
6
+ import { loadMCPConfig } from './config.js';
7
+ import { GitFilesTool } from './tools/gitFiles.js';
8
+ import { GitWorkflowTool } from './tools/gitWorkflow.js';
9
+ import { GitBranchesTool } from './tools/gitBranches.js';
10
+ import { GitIssuesTool } from './tools/gitIssues.js';
11
+ import { GitPullsTool } from './tools/gitPulls.js';
12
+ import { GitTagsTool } from './tools/gitTags.js';
13
+ import { GitReleaseTool } from './tools/gitRelease.js';
14
+ import { GitRemoteTool } from './tools/gitRemote.js';
15
+ import { GitResetTool } from './tools/gitReset.js';
16
+ import { GitStashTool } from './tools/gitStash.js';
17
+ import { GitConfigTool } from './tools/gitConfig.js';
18
+ import { GitMonitorTool } from './tools/gitMonitor.js';
19
+ import { GitBackupTool } from './tools/gitBackup.js';
20
+ import { GitArchiveTool } from './tools/gitArchive.js';
21
+ import { GitSyncTool } from './tools/gitSync.js';
22
+ import { GitPackagesTool } from './tools/gitPackages.js';
23
+ import { GitAnalyticsTool } from './tools/gitAnalytics.js';
24
+ import { GitUploadTool } from './tools/gitUpload.js';
25
+ import { GitUpdateTool } from './tools/gitUpdate.js';
26
+ import { GitHistoryTool } from './tools/gitHistory.js';
27
+ import { GitFixTool } from './tools/gitFix.tool.js';
28
+ import { GitIgnoreTool } from './tools/gitIgnore.js';
29
+ import TOOLS_GUIDE from './resources/toolsGuide.js';
35
30
  async function main() {
36
31
  // Load optional mcp.json configuration (will populate process.env if values present)
37
- (0, config_1.loadMCPConfig)();
38
- const providerManager = new providerManager_1.ProviderManager();
32
+ loadMCPConfig();
33
+ const providerManager = new ProviderManager();
39
34
  // Skip validation on startup to prevent hanging (validation happens on first use)
40
35
  // Provider validation moved to lazy initialization
41
36
  // Register all 22 Git tools
42
37
  const tools = [
43
- new gitWorkflow_1.GitWorkflowTool(),
44
- new gitFiles_1.GitFilesTool(),
45
- new gitBranches_1.GitBranchesTool(),
46
- new gitIssues_1.GitIssuesTool(),
47
- new gitPulls_1.GitPullsTool(),
48
- new gitTags_1.GitTagsTool(),
49
- new gitRelease_1.GitReleaseTool(),
50
- new gitRemote_1.GitRemoteTool(),
51
- new gitReset_1.GitResetTool(),
52
- new gitStash_1.GitStashTool(),
53
- new gitConfig_1.GitConfigTool(),
54
- new gitMonitor_1.GitMonitorTool(),
55
- new gitBackup_1.GitBackupTool(),
56
- new gitArchive_1.GitArchiveTool(),
57
- new gitSync_1.GitSyncTool(),
58
- new gitPackages_1.GitPackagesTool(),
59
- new gitAnalytics_1.GitAnalyticsTool(),
60
- new gitUpload_1.GitUploadTool(),
61
- new gitUpdate_1.GitUpdateTool(),
62
- new gitHistory_1.GitHistoryTool(),
63
- new gitFix_tool_1.GitFixTool(),
64
- new gitIgnore_1.GitIgnoreTool(),
38
+ new GitWorkflowTool(),
39
+ new GitFilesTool(),
40
+ new GitBranchesTool(),
41
+ new GitIssuesTool(),
42
+ new GitPullsTool(),
43
+ new GitTagsTool(),
44
+ new GitReleaseTool(),
45
+ new GitRemoteTool(),
46
+ new GitResetTool(),
47
+ new GitStashTool(),
48
+ new GitConfigTool(),
49
+ new GitMonitorTool(),
50
+ new GitBackupTool(),
51
+ new GitArchiveTool(),
52
+ new GitSyncTool(),
53
+ new GitPackagesTool(),
54
+ new GitAnalyticsTool(),
55
+ new GitUploadTool(),
56
+ new GitUpdateTool(),
57
+ new GitHistoryTool(),
58
+ new GitFixTool(),
59
+ new GitIgnoreTool(),
65
60
  ];
66
61
  // Register resources
67
62
  const resources = [
68
- toolsGuide_1.default
63
+ TOOLS_GUIDE
69
64
  ];
70
65
  // Silent mode for MCP clients - only log to stderr in debug mode
71
66
  if (process.env.DEBUG) {
@@ -73,12 +68,12 @@ async function main() {
73
68
  console.error(`Registered ${resources.length} resource(s)`);
74
69
  }
75
70
  // Create MCP Server with STDIO transport
76
- const server = new index_1.Server({
71
+ const server = new Server({
77
72
  name: '@andrebuzeli/git-mcp',
78
- version: '7.2.5',
73
+ version: '7.3.1',
79
74
  });
80
75
  // Register tool list handler
81
- server.setRequestHandler(types_1.ListToolsRequestSchema, async () => {
76
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
82
77
  return {
83
78
  tools: tools.map(tool => ({
84
79
  name: tool.name,
@@ -92,7 +87,7 @@ async function main() {
92
87
  };
93
88
  });
94
89
  // Register tool execution handler
95
- server.setRequestHandler(types_1.CallToolRequestSchema, async (request) => {
90
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
96
91
  const toolName = request.params.name;
97
92
  const tool = tools.find(t => t.name === toolName);
98
93
  if (!tool) {
@@ -122,7 +117,7 @@ async function main() {
122
117
  }
123
118
  });
124
119
  // Register resource list handler
125
- server.setRequestHandler(types_1.ListResourcesRequestSchema, async () => {
120
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
126
121
  return {
127
122
  resources: resources.map(resource => ({
128
123
  uri: resource.uri,
@@ -133,7 +128,7 @@ async function main() {
133
128
  };
134
129
  });
135
130
  // Register resource read handler
136
- server.setRequestHandler(types_1.ReadResourceRequestSchema, async (request) => {
131
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
137
132
  const uri = request.params.uri;
138
133
  const resource = resources.find(r => r.uri === uri);
139
134
  if (!resource) {
@@ -150,7 +145,7 @@ async function main() {
150
145
  };
151
146
  });
152
147
  // Start server with STDIO transport
153
- const transport = new stdio_1.StdioServerTransport();
148
+ const transport = new StdioServerTransport();
154
149
  await server.connect(transport);
155
150
  // Only log in debug mode
156
151
  if (process.env.DEBUG) {
@@ -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.createGiteaClient = createGiteaClient;
7
- const axios_1 = __importDefault(require("axios"));
8
- function createGiteaClient(baseUrl, token) {
1
+ import axios from 'axios';
2
+ export function createGiteaClient(baseUrl, token) {
9
3
  return {
10
- request: (path, opts = {}) => axios_1.default.request({ url: `${baseUrl}${path}`, headers: { Authorization: `token ${token}` }, ...opts }),
4
+ request: (path, opts = {}) => axios.request({ url: `${baseUrl}${path}`, headers: { Authorization: `token ${token}` }, ...opts }),
11
5
  };
12
6
  }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createGitHubClient = createGitHubClient;
4
- const rest_1 = require("@octokit/rest");
5
- function createGitHubClient(token) {
6
- return new rest_1.Octokit({ auth: token });
1
+ import { Octokit } from '@octokit/rest';
2
+ export function createGitHubClient(token) {
3
+ return new Octokit({ auth: token });
7
4
  }
@@ -1,16 +1,10 @@
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.ProviderManager = void 0;
7
- const rest_1 = require("@octokit/rest");
8
- const axios_1 = __importDefault(require("axios"));
9
- class ProviderManager {
1
+ import { Octokit } from '@octokit/rest';
2
+ import axios from 'axios';
3
+ export class ProviderManager {
10
4
  constructor() {
11
5
  const ghToken = process.env.GITHUB_TOKEN;
12
6
  if (ghToken) {
13
- this.github = new rest_1.Octokit({ auth: ghToken });
7
+ this.github = new Octokit({ auth: ghToken });
14
8
  }
15
9
  if (process.env.GITEA_URL && process.env.GITEA_TOKEN) {
16
10
  this.giteaBaseUrl = process.env.GITEA_URL;
@@ -37,7 +31,7 @@ class ProviderManager {
37
31
  }
38
32
  if (this.giteaBaseUrl && this.giteaToken) {
39
33
  try {
40
- const resp = await axios_1.default.get(`${this.giteaBaseUrl}/api/v1/user`, {
34
+ const resp = await axios.get(`${this.giteaBaseUrl}/api/v1/user`, {
41
35
  headers: { Authorization: `token ${this.giteaToken}` },
42
36
  timeout: timeout,
43
37
  });
@@ -53,4 +47,3 @@ class ProviderManager {
53
47
  return results;
54
48
  }
55
49
  }
56
- exports.ProviderManager = ProviderManager;
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Git-MCP Tools Guide Resource
4
3
  * Comprehensive documentation for all 20 Git tools available in the MCP server
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.TOOLS_GUIDE = void 0;
8
- exports.TOOLS_GUIDE = {
5
+ export const TOOLS_GUIDE = {
9
6
  uri: "git-mcp://tools/guide",
10
7
  name: "Git-MCP Tools Complete Guide",
11
8
  description: "Detailed documentation and usage instructions for all 20 Git tools with 102 actions",
@@ -1713,4 +1710,4 @@ for (const repo of repos) {
1713
1710
  **Git-MCP v6.3.1** | Built with ❤️ for developers | 110+ Actions | 21 Tools | 3 Provider Types | NEW: git-fix migration tool
1714
1711
  `
1715
1712
  };
1716
- exports.default = exports.TOOLS_GUIDE;
1713
+ export default TOOLS_GUIDE;
package/dist/server.js CHANGED
@@ -1,15 +1,9 @@
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.createServer = createServer;
7
- const express_1 = __importDefault(require("express"));
8
- const body_parser_1 = __importDefault(require("body-parser"));
9
- const errors_1 = require("./utils/errors");
10
- function createServer(opts) {
11
- const app = (0, express_1.default)();
12
- app.use(body_parser_1.default.json({ limit: '1mb' }));
1
+ import express from 'express';
2
+ import bodyParser from 'body-parser';
3
+ import { createErrorResponse } from './utils/errors';
4
+ export function createServer(opts) {
5
+ const app = express();
6
+ app.use(bodyParser.json({ limit: '1mb' }));
13
7
  const toolRegistry = new Map();
14
8
  for (const t of opts.tools)
15
9
  toolRegistry.set(t.name, t);
@@ -33,7 +27,7 @@ function createServer(opts) {
33
27
  const uri = req.params.uri;
34
28
  const resource = resourceRegistry.get(uri);
35
29
  if (!resource) {
36
- return res.status(404).json((0, errors_1.createErrorResponse)('RESOURCE_NOT_FOUND', `Resource not found: ${uri}`));
30
+ return res.status(404).json(createErrorResponse('RESOURCE_NOT_FOUND', `Resource not found: ${uri}`));
37
31
  }
38
32
  res.json({
39
33
  success: true,
@@ -49,14 +43,14 @@ function createServer(opts) {
49
43
  app.post('/call', async (req, res) => {
50
44
  const { tool, params } = req.body ?? {};
51
45
  if (!tool)
52
- return res.status(400).json((0, errors_1.createErrorResponse)('VALIDATION_ERROR', 'Missing tool name'));
46
+ return res.status(400).json(createErrorResponse('VALIDATION_ERROR', 'Missing tool name'));
53
47
  const t = toolRegistry.get(tool);
54
48
  if (!t)
55
- return res.status(404).json((0, errors_1.createErrorResponse)('TOOL_NOT_FOUND', `Tool not found: ${tool}`));
49
+ return res.status(404).json(createErrorResponse('TOOL_NOT_FOUND', `Tool not found: ${tool}`));
56
50
  // Enforce projectPath presence for all tool calls to avoid agents calling tools without context
57
51
  // Many tools require projectPath; centralize the check so callers receive a clear validation error.
58
52
  if (!params || !params.projectPath) {
59
- return res.status(400).json((0, errors_1.createErrorResponse)('VALIDATION_ERROR', 'projectPath is required for all tool calls'));
53
+ return res.status(400).json(createErrorResponse('VALIDATION_ERROR', 'projectPath is required for all tool calls'));
60
54
  }
61
55
  try {
62
56
  // TODO: validate params via JSON Schema
@@ -67,7 +61,7 @@ function createServer(opts) {
67
61
  console.error(`Error in tool ${tool}:`, err);
68
62
  const errorCode = err.status || err.code || 'INTERNAL_ERROR';
69
63
  const errorMsg = err.message || String(err);
70
- res.status(500).json((0, errors_1.createErrorResponse)(errorCode, errorMsg));
64
+ res.status(500).json(createErrorResponse(errorCode, errorMsg));
71
65
  }
72
66
  });
73
67
  return app;
@@ -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.GitAnalyticsTool = void 0;
7
- const errors_1 = require("../utils/errors");
8
- const axios_1 = __importDefault(require("axios"));
9
- const repoHelpers_1 = require("../utils/repoHelpers");
10
- class GitAnalyticsTool {
1
+ import { MCPError } from '../utils/errors';
2
+ import axios from 'axios';
3
+ import { getRepoInfo } from '../utils/repoHelpers';
4
+ export class GitAnalyticsTool {
11
5
  constructor() {
12
6
  this.name = 'git-analytics';
13
7
  this.description = 'Repository analytics and statistics - automatic dual-provider execution using GitHub and Gitea APIs';
@@ -16,11 +10,11 @@ class GitAnalyticsTool {
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
  // Auto-extract repo info from projectPath
23
- const repoInfo = (0, repoHelpers_1.getRepoInfo)(projectPath);
17
+ const repoInfo = getRepoInfo(projectPath);
24
18
  const repo = repoInfo.repoName;
25
19
  // Each provider uses its own username from env
26
20
  const githubOwner = process.env.GITHUB_USERNAME;
@@ -71,10 +65,10 @@ class GitAnalyticsTool {
71
65
  // Gitea API
72
66
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
73
67
  try {
74
- const repoData = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
75
- const branches = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/branches`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
76
- const tags = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
77
- const commits = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
68
+ const repoData = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
69
+ const branches = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/branches`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
70
+ const tags = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
71
+ const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
78
72
  params: { limit: 1 },
79
73
  headers: { Authorization: `token ${ctx.providerManager.giteaToken}` }
80
74
  });
@@ -125,7 +119,7 @@ class GitAnalyticsTool {
125
119
  // Gitea API
126
120
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
127
121
  try {
128
- const commits = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
122
+ const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
129
123
  params: {
130
124
  since: params.since,
131
125
  until: params.until,
@@ -172,7 +166,7 @@ class GitAnalyticsTool {
172
166
  // Gitea API
173
167
  if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
174
168
  try {
175
- const contributors = await axios_1.default.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/contributors`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
169
+ const contributors = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/contributors`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
176
170
  results.providers.gitea = {
177
171
  success: true,
178
172
  contributors: contributors.data.map((c) => ({
@@ -190,8 +184,7 @@ class GitAnalyticsTool {
190
184
  return results;
191
185
  }
192
186
  default:
193
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
187
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
194
188
  }
195
189
  }
196
190
  }
197
- exports.GitAnalyticsTool = GitAnalyticsTool;
@@ -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.GitArchiveTool = void 0;
7
- const promises_1 = __importDefault(require("fs/promises"));
8
- const path_1 = __importDefault(require("path"));
9
- const errors_1 = require("../utils/errors");
10
- class GitArchiveTool {
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { MCPError } from '../utils/errors';
4
+ export class GitArchiveTool {
11
5
  constructor() {
12
6
  this.name = 'git-archive';
13
7
  this.description = 'Repository archive operations';
@@ -16,22 +10,22 @@ class GitArchiveTool {
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
15
  switch (action) {
22
16
  case 'create': {
23
17
  const archiveName = params.archiveName || `archive-${Date.now()}.json`;
24
- const outputPath = params.outputPath || path_1.default.join(projectPath, '.git-archives');
18
+ const outputPath = params.outputPath || path.join(projectPath, '.git-archives');
25
19
  try {
26
20
  // Criar diretório de archives se não existir
27
- await promises_1.default.mkdir(outputPath, { recursive: true });
28
- const archivePath = path_1.default.join(outputPath, archiveName);
21
+ await fs.mkdir(outputPath, { recursive: true });
22
+ const archivePath = path.join(outputPath, archiveName);
29
23
  const archiveData = {
30
24
  projectPath,
31
25
  timestamp: new Date().toISOString(),
32
26
  type: 'git-archive',
33
27
  };
34
- await promises_1.default.writeFile(archivePath, JSON.stringify(archiveData, null, 2));
28
+ await fs.writeFile(archivePath, JSON.stringify(archiveData, null, 2));
35
29
  return {
36
30
  success: true,
37
31
  archivePath,
@@ -39,13 +33,13 @@ class GitArchiveTool {
39
33
  };
40
34
  }
41
35
  catch (error) {
42
- throw new errors_1.MCPError('FILE_ERROR', `Failed to create archive: ${error.message}`);
36
+ throw new MCPError('FILE_ERROR', `Failed to create archive: ${error.message}`);
43
37
  }
44
38
  }
45
39
  case 'list': {
46
- const archivesDir = params.archivesDir || path_1.default.join(projectPath, '.git-archives');
40
+ const archivesDir = params.archivesDir || path.join(projectPath, '.git-archives');
47
41
  try {
48
- const files = await promises_1.default.readdir(archivesDir);
42
+ const files = await fs.readdir(archivesDir);
49
43
  const archives = files.filter(f => f.endsWith('.json'));
50
44
  return {
51
45
  success: true,
@@ -66,9 +60,9 @@ class GitArchiveTool {
66
60
  case 'verify': {
67
61
  const archivePath = params.archivePath;
68
62
  if (!archivePath)
69
- throw new errors_1.MCPError('VALIDATION_ERROR', 'archivePath is required');
63
+ throw new MCPError('VALIDATION_ERROR', 'archivePath is required');
70
64
  try {
71
- const content = await promises_1.default.readFile(archivePath, 'utf-8');
65
+ const content = await fs.readFile(archivePath, 'utf-8');
72
66
  const archive = JSON.parse(content);
73
67
  return {
74
68
  success: true,
@@ -86,10 +80,9 @@ class GitArchiveTool {
86
80
  }
87
81
  }
88
82
  case 'extract':
89
- throw new errors_1.MCPError('NOT_IMPLEMENTED', 'Extract not yet fully implemented');
83
+ throw new MCPError('NOT_IMPLEMENTED', 'Extract not yet fully implemented');
90
84
  default:
91
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
85
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
92
86
  }
93
87
  }
94
88
  }
95
- exports.GitArchiveTool = GitArchiveTool;
@@ -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.GitBackupTool = void 0;
7
- const promises_1 = __importDefault(require("fs/promises"));
8
- const path_1 = __importDefault(require("path"));
9
- const simple_git_1 = __importDefault(require("simple-git"));
10
- const errors_1 = require("../utils/errors");
11
- class GitBackupTool {
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import simpleGit from 'simple-git';
4
+ import { MCPError } from '../utils/errors';
5
+ export class GitBackupTool {
12
6
  constructor() {
13
7
  this.name = 'git-backup';
14
8
  this.description = 'Repository backup and restore operations';
@@ -17,17 +11,17 @@ class GitBackupTool {
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
16
  switch (action) {
23
17
  case 'backup': {
24
- const backupDir = params.backupDir || path_1.default.join(projectPath, '.git-backups');
18
+ const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
25
19
  const backupName = params.backupName || `backup-${Date.now()}.json`;
26
20
  try {
27
21
  // Criar diretório de backups
28
- await promises_1.default.mkdir(backupDir, { recursive: true });
29
- const backupPath = path_1.default.join(backupDir, backupName);
30
- const git = (0, simple_git_1.default)({ baseDir: projectPath });
22
+ await fs.mkdir(backupDir, { recursive: true });
23
+ const backupPath = path.join(backupDir, backupName);
24
+ const git = simpleGit({ baseDir: projectPath });
31
25
  const status = await git.status();
32
26
  const log = await git.log({ maxCount: 1 });
33
27
  const backupData = {
@@ -37,7 +31,7 @@ class GitBackupTool {
37
31
  lastCommit: log.latest?.hash,
38
32
  files: status.files.length,
39
33
  };
40
- await promises_1.default.writeFile(backupPath, JSON.stringify(backupData, null, 2));
34
+ await fs.writeFile(backupPath, JSON.stringify(backupData, null, 2));
41
35
  return {
42
36
  success: true,
43
37
  backupPath,
@@ -46,18 +40,18 @@ class GitBackupTool {
46
40
  };
47
41
  }
48
42
  catch (error) {
49
- throw new errors_1.MCPError('FILE_ERROR', `Failed to create backup: ${error.message}`);
43
+ throw new MCPError('FILE_ERROR', `Failed to create backup: ${error.message}`);
50
44
  }
51
45
  }
52
46
  case 'list': {
53
- const backupDir = params.backupDir || path_1.default.join(projectPath, '.git-backups');
47
+ const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
54
48
  try {
55
- const files = await promises_1.default.readdir(backupDir);
49
+ const files = await fs.readdir(backupDir);
56
50
  const backups = [];
57
51
  for (const file of files) {
58
52
  if (file.endsWith('.json')) {
59
53
  try {
60
- const content = await promises_1.default.readFile(path_1.default.join(backupDir, file), 'utf-8');
54
+ const content = await fs.readFile(path.join(backupDir, file), 'utf-8');
61
55
  const backup = JSON.parse(content);
62
56
  backups.push({ file, ...backup });
63
57
  }
@@ -85,9 +79,9 @@ class GitBackupTool {
85
79
  case 'verify': {
86
80
  const backupPath = params.backupPath;
87
81
  if (!backupPath)
88
- throw new errors_1.MCPError('VALIDATION_ERROR', 'backupPath is required');
82
+ throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
89
83
  try {
90
- const content = await promises_1.default.readFile(backupPath, 'utf-8');
84
+ const content = await fs.readFile(backupPath, 'utf-8');
91
85
  const backup = JSON.parse(content);
92
86
  const isValid = backup.timestamp && backup.projectPath;
93
87
  return {
@@ -108,9 +102,9 @@ class GitBackupTool {
108
102
  case 'restore': {
109
103
  const backupPath = params.backupPath;
110
104
  if (!backupPath)
111
- throw new errors_1.MCPError('VALIDATION_ERROR', 'backupPath is required');
105
+ throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
112
106
  try {
113
- const content = await promises_1.default.readFile(backupPath, 'utf-8');
107
+ const content = await fs.readFile(backupPath, 'utf-8');
114
108
  const backup = JSON.parse(content);
115
109
  return {
116
110
  success: true,
@@ -120,12 +114,11 @@ class GitBackupTool {
120
114
  };
121
115
  }
122
116
  catch (error) {
123
- throw new errors_1.MCPError('FILE_ERROR', `Failed to read backup: ${error.message}`);
117
+ throw new MCPError('FILE_ERROR', `Failed to read backup: ${error.message}`);
124
118
  }
125
119
  }
126
120
  default:
127
- throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
121
+ throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
128
122
  }
129
123
  }
130
124
  }
131
- exports.GitBackupTool = GitBackupTool;