@andrebuzeli/git-mcp 9.1.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +460 -328
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/config.d.ts +0 -1
  5. package/dist/config.js +0 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +6 -36
  8. package/dist/index.js.map +1 -1
  9. package/dist/prompts/gitPrompts.d.ts +20 -1
  10. package/dist/prompts/gitPrompts.d.ts.map +1 -1
  11. package/dist/prompts/gitPrompts.js +49 -9
  12. package/dist/prompts/gitPrompts.js.map +1 -1
  13. package/dist/providers/giteaProvider.d.ts +1 -18
  14. package/dist/providers/giteaProvider.js +1 -87
  15. package/dist/providers/githubProvider.d.ts +0 -1
  16. package/dist/providers/githubProvider.js +0 -1
  17. package/dist/providers/providerManager.d.ts +0 -15
  18. package/dist/providers/providerManager.js +0 -65
  19. package/dist/resources/toolsGuide.d.ts +0 -1
  20. package/dist/resources/toolsGuide.js +1701 -1702
  21. package/dist/server.d.ts +0 -1
  22. package/dist/server.js +0 -1
  23. package/dist/tools/gitAnalytics.d.ts +0 -29
  24. package/dist/tools/gitAnalytics.js +4 -39
  25. package/dist/tools/gitArchive.d.ts +0 -30
  26. package/dist/tools/gitArchive.d.ts.map +1 -1
  27. package/dist/tools/gitArchive.js +1 -32
  28. package/dist/tools/gitArchive.js.map +1 -1
  29. package/dist/tools/gitBackup.d.ts +2 -35
  30. package/dist/tools/gitBackup.d.ts.map +1 -1
  31. package/dist/tools/gitBackup.js +7 -41
  32. package/dist/tools/gitBackup.js.map +1 -1
  33. package/dist/tools/gitBranches.d.ts +0 -49
  34. package/dist/tools/gitBranches.js +28 -92
  35. package/dist/tools/gitChangelog.d.ts +37 -1
  36. package/dist/tools/gitChangelog.d.ts.map +1 -1
  37. package/dist/tools/gitChangelog.js +67 -2
  38. package/dist/tools/gitChangelog.js.map +1 -1
  39. package/dist/tools/gitConfig.d.ts +2 -31
  40. package/dist/tools/gitConfig.js +9 -38
  41. package/dist/tools/gitFiles.d.ts +0 -37
  42. package/dist/tools/gitFiles.js +1 -39
  43. package/dist/tools/gitFix.d.ts +1 -4
  44. package/dist/tools/gitFix.js +32 -62
  45. package/dist/tools/gitFix.tool.d.ts +2 -26
  46. package/dist/tools/gitFix.tool.js +61 -85
  47. package/dist/tools/gitHistory.d.ts +5 -18
  48. package/dist/tools/gitHistory.js +208 -193
  49. package/dist/tools/gitIgnore.d.ts +0 -24
  50. package/dist/tools/gitIgnore.js +113 -136
  51. package/dist/tools/gitIssues.d.ts +0 -79
  52. package/dist/tools/gitIssues.js +16 -123
  53. package/dist/tools/gitLog.d.ts +30 -1
  54. package/dist/tools/gitLog.d.ts.map +1 -1
  55. package/dist/tools/gitLog.js +46 -2
  56. package/dist/tools/gitLog.js.map +1 -1
  57. package/dist/tools/gitMonitor.d.ts +0 -29
  58. package/dist/tools/gitMonitor.js +18 -47
  59. package/dist/tools/gitPackages.d.ts +146 -34
  60. package/dist/tools/gitPackages.js +147 -280
  61. package/dist/tools/gitPulls.d.ts +0 -66
  62. package/dist/tools/gitPulls.d.ts.map +1 -1
  63. package/dist/tools/gitPulls.js +7 -93
  64. package/dist/tools/gitPulls.js.map +1 -1
  65. package/dist/tools/gitPush.d.ts +0 -1
  66. package/dist/tools/gitPush.js +0 -1
  67. package/dist/tools/gitRelease.d.ts +0 -49
  68. package/dist/tools/gitRelease.js +6 -122
  69. package/dist/tools/gitRemote.d.ts +1 -31
  70. package/dist/tools/gitRemote.js +17 -59
  71. package/dist/tools/gitReset.d.ts +0 -25
  72. package/dist/tools/gitReset.js +8 -33
  73. package/dist/tools/gitStash.d.ts +2 -35
  74. package/dist/tools/gitStash.js +26 -56
  75. package/dist/tools/gitSync.d.ts +0 -29
  76. package/dist/tools/gitSync.js +20 -65
  77. package/dist/tools/gitTags.d.ts +0 -37
  78. package/dist/tools/gitTags.d.ts.map +1 -1
  79. package/dist/tools/gitTags.js +26 -53
  80. package/dist/tools/gitTags.js.map +1 -1
  81. package/dist/tools/gitUpdate.d.ts +6 -11
  82. package/dist/tools/gitUpdate.js +304 -61
  83. package/dist/tools/gitUpload.d.ts +1 -24
  84. package/dist/tools/gitUpload.js +50 -45
  85. package/dist/tools/gitWorkflow.d.ts +0 -27
  86. package/dist/tools/gitWorkflow.js +55 -87
  87. package/dist/types.d.ts +0 -7
  88. package/dist/types.js +0 -1
  89. package/dist/utils/apiHelpers.d.ts +0 -1
  90. package/dist/utils/apiHelpers.js +0 -1
  91. package/dist/utils/errors.d.ts +0 -1
  92. package/dist/utils/errors.js +0 -1
  93. package/dist/utils/gitAdapter.d.ts +14 -13
  94. package/dist/utils/gitAdapter.d.ts.map +1 -1
  95. package/dist/utils/gitAdapter.js +47 -9
  96. package/dist/utils/gitAdapter.js.map +1 -1
  97. package/dist/utils/repoHelpers.d.ts +0 -2
  98. package/dist/utils/repoHelpers.js +3 -16
  99. package/dist/utils/safetyController.d.ts +0 -1
  100. package/dist/utils/safetyController.js +0 -1
  101. package/dist/utils/safetyController.js.map +1 -1
  102. package/package.json +87 -96
@@ -1,7 +1,8 @@
1
+ import simpleGit from 'simple-git';
1
2
  import path from 'path';
2
3
  import fs from 'fs/promises';
3
4
  import { existsSync } from 'fs';
4
- export async function handleGitFix(args, git, providerManager) {
5
+ export async function handleGitFix(args) {
5
6
  try {
6
7
  const { projectPath, githubRepo, giteaRepo, autoDetect = true } = args;
7
8
  if (!projectPath) {
@@ -11,6 +12,7 @@ export async function handleGitFix(args, git, providerManager) {
11
12
  if (!existsSync(absolutePath)) {
12
13
  throw new Error(`Caminho não existe: ${absolutePath}`);
13
14
  }
15
+ const git = simpleGit(absolutePath);
14
16
  const result = {
15
17
  success: false,
16
18
  projectPath: absolutePath,
@@ -25,14 +27,14 @@ export async function handleGitFix(args, git, providerManager) {
25
27
  // Verificar se é um repositório Git
26
28
  let isGitRepo = false;
27
29
  try {
28
- await git.status(absolutePath);
30
+ await git.status();
29
31
  isGitRepo = true;
30
32
  result.fixed.push('✅ Repositório Git válido encontrado');
31
33
  }
32
34
  catch (err) {
33
35
  if (err.message.includes('not a git repository')) {
34
36
  result.warnings.push('⚠️ Não é um repositório Git - inicializando...');
35
- await git.init(absolutePath);
37
+ await git.init();
36
38
  result.fixed.push('✅ Git inicializado');
37
39
  isGitRepo = true;
38
40
  }
@@ -41,18 +43,21 @@ export async function handleGitFix(args, git, providerManager) {
41
43
  }
42
44
  }
43
45
  // Capturar remotes antes
44
- const remotesBefore = await git.listRemotes(absolutePath);
45
- result.remotes.before = remotesBefore.map(r => ({ name: r.name, url: r.url }));
46
- // Obter usernames automaticamente (API ou env vars)
47
- const githubUsername = await providerManager.getGitHubUsername();
48
- const giteaUsername = await providerManager.getGiteaUsername();
46
+ const remotesBefore = await git.getRemotes(true);
47
+ result.remotes.before = remotesBefore.map(r => ({ name: r.name, url: r.refs.fetch || '' }));
48
+ // Obter usernames das env vars (OBRIGATÓRIO usar as credenciais fornecidas)
49
+ const githubUsername = process.env.GITHUB_USERNAME;
50
+ const giteaUsername = process.env.GITEA_USERNAME;
51
+ if (!githubUsername || !giteaUsername) {
52
+ throw new Error('GITHUB_USERNAME e GITEA_USERNAME são obrigatórios nas env vars');
53
+ }
49
54
  // Auto-detectar repos se solicitado
50
55
  let finalGithubRepo = githubRepo;
51
56
  let finalGiteaRepo = giteaRepo;
52
57
  let detectedRepoName = null;
53
58
  if (autoDetect && remotesBefore.length > 0) {
54
59
  for (const remote of remotesBefore) {
55
- const url = remote.url || '';
60
+ const url = remote.refs.fetch || '';
56
61
  // Detectar APENAS o nome do repo (sem username)
57
62
  if (url.includes('github.com') && !detectedRepoName) {
58
63
  const match = url.match(/github\.com[:/][^/]+\/([^/.]+)/);
@@ -96,63 +101,29 @@ export async function handleGitFix(args, git, providerManager) {
96
101
  for (const remoteName of remotesToRemove) {
97
102
  const exists = remotesBefore.find(r => r.name === remoteName);
98
103
  if (exists) {
99
- await git.removeRemote(absolutePath, remoteName);
104
+ await git.removeRemote(remoteName);
100
105
  result.fixed.push(`🗑️ Removido remote antigo: ${remoteName}`);
101
106
  }
102
107
  }
103
108
  // Adicionar novos remotes no padrão dual
104
109
  const giteaUrl = process.env.GITEA_URL || 'http://nas-ubuntu:9999';
105
- const giteaToken = process.env.GITEA_TOKEN;
106
- const githubToken = process.env.GITHUB_TOKEN;
107
- // Build GitHub URL
108
- let githubUrl = `https://github.com/${finalGithubRepo}.git`;
109
- if (githubToken) {
110
- // Use token for private repos or to avoid 2FA prompts
111
- githubUrl = `https://${githubToken}@github.com/${finalGithubRepo}.git`;
112
- }
113
- // Build Gitea URL - support both HTTP and HTTPS (Cloudflare Tunnels)
114
- let giteaRepoUrl;
115
- if (giteaToken) {
116
- const parsedGiteaUrl = new URL(giteaUrl);
117
- const protocol = parsedGiteaUrl.protocol;
118
- const host = parsedGiteaUrl.host;
119
- if (protocol === 'https:') {
120
- // HTTPS (Cloudflare Tunnel): use token-based auth
121
- giteaRepoUrl = `${protocol}//${giteaToken}@${host}/${finalGiteaRepo}.git`;
122
- }
123
- else {
124
- // HTTP: use username:token format
125
- giteaRepoUrl = `${protocol}//${giteaUsername}:${giteaToken}@${host}/${finalGiteaRepo}.git`;
126
- }
127
- }
128
- else {
129
- // No token - use basic URL (will prompt for credentials)
130
- giteaRepoUrl = `${giteaUrl}/${finalGiteaRepo}.git`;
131
- }
132
- await git.addRemote(absolutePath, 'github', githubUrl);
133
- result.fixed.push(`✅ Adicionado remote GitHub: ${githubUrl.replace(githubToken || '', '***')}`);
134
- await git.addRemote(absolutePath, 'gitea', giteaRepoUrl);
135
- result.fixed.push(`✅ Adicionado remote Gitea: ${giteaRepoUrl.replace(giteaToken || '', '***')}`);
110
+ const githubUrl = `https://github.com/${finalGithubRepo}.git`;
111
+ const giteaRepoUrl = `${giteaUrl}/${finalGiteaRepo}.git`;
112
+ await git.addRemote('github', githubUrl);
113
+ result.fixed.push(`✅ Adicionado remote GitHub: ${githubUrl}`);
114
+ await git.addRemote('gitea', giteaRepoUrl);
115
+ result.fixed.push(`✅ Adicionado remote Gitea: ${giteaRepoUrl}`);
136
116
  // Configurar origin como push múltiplo
137
- await git.addRemote(absolutePath, 'origin', githubUrl);
138
- // Configure dual push URL using shell command (not supported by isomorphic-git)
139
- const { exec } = await import('child_process');
140
- const { promisify } = await import('util');
141
- const execAsync = promisify(exec);
142
- await execAsync(`git -C "${absolutePath}" config --add remote.origin.pushurl "${giteaRepoUrl}"`);
117
+ await git.addRemote('origin', githubUrl);
118
+ await git.addConfig('remote.origin.pushurl', giteaRepoUrl, false, 'local');
143
119
  result.fixed.push(`✅ Configurado origin para push dual (GitHub + Gitea)`);
144
120
  // Capturar remotes depois
145
- const remotesAfter = await git.listRemotes(absolutePath);
146
- result.remotes.after = remotesAfter.map(r => ({ name: r.name, url: r.url }));
121
+ const remotesAfter = await git.getRemotes(true);
122
+ result.remotes.after = remotesAfter.map(r => ({ name: r.name, url: r.refs.fetch || '' }));
147
123
  // Verificar se há commits
148
124
  try {
149
- const log = await git.log(absolutePath);
150
- if (log.length > 0) {
151
- result.fixed.push('✅ Histórico de commits preservado');
152
- }
153
- else {
154
- result.warnings.push('⚠️ Sem commits ainda - faça o primeiro commit');
155
- }
125
+ await git.log();
126
+ result.fixed.push('✅ Histórico de commits preservado');
156
127
  }
157
128
  catch (err) {
158
129
  result.warnings.push('⚠️ Sem commits ainda - faça o primeiro commit');
@@ -160,11 +131,11 @@ export async function handleGitFix(args, git, providerManager) {
160
131
  // Criar/atualizar .gitignore se necessário
161
132
  const gitignorePath = path.join(absolutePath, '.gitignore');
162
133
  if (!existsSync(gitignorePath)) {
163
- const defaultGitignore = `node_modules/
164
- dist/
165
- .env
166
- *.log
167
- .DS_Store
134
+ const defaultGitignore = `node_modules/
135
+ dist/
136
+ .env
137
+ *.log
138
+ .DS_Store
168
139
  `;
169
140
  await fs.writeFile(gitignorePath, defaultGitignore, 'utf-8');
170
141
  result.fixed.push('✅ Criado .gitignore padrão');
@@ -190,4 +161,3 @@ dist/
190
161
  };
191
162
  }
192
163
  }
193
- //# sourceMappingURL=gitFix.js.map
@@ -1,32 +1,8 @@
1
- import { Tool, MCPContext } from '../types.js';
1
+ import { Tool } from '../types.js';
2
2
  export declare class GitFixTool implements Tool {
3
3
  name: string;
4
4
  description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- projectPath: {
9
- type: string;
10
- description: string;
11
- };
12
- githubRepo: {
13
- type: string;
14
- description: string;
15
- };
16
- giteaRepo: {
17
- type: string;
18
- description: string;
19
- };
20
- autoDetect: {
21
- type: string;
22
- description: string;
23
- };
24
- };
25
- required: string[];
26
- additionalProperties: boolean;
27
- };
28
- handle(args: any, ctx: MCPContext): Promise<{
5
+ handle(args: any): Promise<{
29
6
  content: any[];
30
7
  }>;
31
8
  }
32
- //# sourceMappingURL=gitFix.tool.d.ts.map
@@ -2,92 +2,68 @@ import { handleGitFix } from './gitFix.js';
2
2
  export class GitFixTool {
3
3
  constructor() {
4
4
  this.name = 'git-fix';
5
- this.description = `Fix local Git repository to work with dual-provider system (GitHub + Gitea).
6
-
7
- 🔧 WHAT IT DOES:
8
- - Converts existing Git repos to dual-provider system
9
- - Auto-detects GitHub/Gitea remotes from existing configuration
10
- - Removes old remotes and configures new dual-push system
11
- - Initializes Git if not already a repository
12
- - Creates standard .gitignore if missing
13
-
14
- 📋 PARAMETERS:
15
- - projectPath (required): Absolute path to the Git repository
16
- - githubRepo (optional): GitHub repo in format "owner/repo" (auto-detected if not provided)
17
- - giteaRepo (optional): Gitea repo in format "owner/repo" (auto-detected if not provided)
18
- - autoDetect (optional): Auto-detect repos from existing remotes (default: true)
19
-
20
- 🎯 WHEN TO USE:
21
- - You have an existing Git repo not configured for dual-provider
22
- - Need to migrate from single remote to dual-push system
23
- - Want to standardize repo configuration for git-mcp tools
24
-
25
- ✅ WHAT GETS FIXED:
26
- 1. Verifies/initializes Git repository
27
- 2. Captures current remotes (before)
28
- 3. Auto-detects GitHub/Gitea repos from URLs
29
- 4. Removes old remotes (origin, github, gitea)
30
- 5. Adds new 'github' remote
31
- 6. Adds new 'gitea' remote
32
- 7. Configures 'origin' for dual-push (GitHub + Gitea)
33
- 8. Creates .gitignore if missing
34
- 9. Shows before/after comparison
35
-
36
- 📊 RESULT STRUCTURE:
37
- {
38
- success: boolean,
39
- projectPath: string,
40
- fixed: string[], // Actions performed
41
- warnings: string[], // Non-critical issues
42
- errors: string[], // Critical issues
43
- remotes: {
44
- before: [...], // Remotes before fix
45
- after: [...] // Remotes after fix
46
- }
47
- }
48
-
49
- 💡 EXAMPLE:
50
- {
51
- "projectPath": "/path/to/my-project",
52
- "autoDetect": true
53
- }
54
-
55
- 🔍 AUTO-DETECTION:
56
- - Scans existing remotes for github.com URLs → extracts owner/repo
57
- - Scans existing remotes for Gitea URLs → extracts owner/repo
58
- - Falls back to folder name if no remotes found
59
-
60
- ⚠️ REQUIREMENTS:
61
- - GITHUB_USERNAME and GITEA_USERNAME env vars for fallback
62
- - GITEA_URL env var (default: http://nas-ubuntu:9999)
63
- - Git must be installed and accessible
5
+ this.description = `Fix local Git repository to work with dual-provider system (GitHub + Gitea).
6
+
7
+ 🔧 WHAT IT DOES:
8
+ - Converts existing Git repos to dual-provider system
9
+ - Auto-detects GitHub/Gitea remotes from existing configuration
10
+ - Removes old remotes and configures new dual-push system
11
+ - Initializes Git if not already a repository
12
+ - Creates standard .gitignore if missing
13
+
14
+ 📋 PARAMETERS:
15
+ - projectPath (required): Absolute path to the Git repository
16
+ - githubRepo (optional): GitHub repo in format "owner/repo" (auto-detected if not provided)
17
+ - giteaRepo (optional): Gitea repo in format "owner/repo" (auto-detected if not provided)
18
+ - autoDetect (optional): Auto-detect repos from existing remotes (default: true)
19
+
20
+ 🎯 WHEN TO USE:
21
+ - You have an existing Git repo not configured for dual-provider
22
+ - Need to migrate from single remote to dual-push system
23
+ - Want to standardize repo configuration for git-mcp tools
24
+
25
+ ✅ WHAT GETS FIXED:
26
+ 1. Verifies/initializes Git repository
27
+ 2. Captures current remotes (before)
28
+ 3. Auto-detects GitHub/Gitea repos from URLs
29
+ 4. Removes old remotes (origin, github, gitea)
30
+ 5. Adds new 'github' remote
31
+ 6. Adds new 'gitea' remote
32
+ 7. Configures 'origin' for dual-push (GitHub + Gitea)
33
+ 8. Creates .gitignore if missing
34
+ 9. Shows before/after comparison
35
+
36
+ 📊 RESULT STRUCTURE:
37
+ {
38
+ success: boolean,
39
+ projectPath: string,
40
+ fixed: string[], // Actions performed
41
+ warnings: string[], // Non-critical issues
42
+ errors: string[], // Critical issues
43
+ remotes: {
44
+ before: [...], // Remotes before fix
45
+ after: [...] // Remotes after fix
46
+ }
47
+ }
48
+
49
+ 💡 EXAMPLE:
50
+ {
51
+ "projectPath": "/path/to/my-project",
52
+ "autoDetect": true
53
+ }
54
+
55
+ 🔍 AUTO-DETECTION:
56
+ - Scans existing remotes for github.com URLs → extracts owner/repo
57
+ - Scans existing remotes for Gitea URLs → extracts owner/repo
58
+ - Falls back to folder name if no remotes found
59
+
60
+ ⚠️ REQUIREMENTS:
61
+ - GITHUB_USERNAME and GITEA_USERNAME env vars for fallback
62
+ - GITEA_URL env var (default: http://nas-ubuntu:9999)
63
+ - Git must be installed and accessible
64
64
  `;
65
- this.inputSchema = {
66
- type: "object",
67
- properties: {
68
- projectPath: {
69
- type: "string",
70
- description: "Absolute path to the Git repository (REQUIRED)"
71
- },
72
- githubRepo: {
73
- type: "string",
74
- description: "GitHub repo in format 'owner/repo' (optional, auto-detected)"
75
- },
76
- giteaRepo: {
77
- type: "string",
78
- description: "Gitea repo in format 'owner/repo' (optional, auto-detected)"
79
- },
80
- autoDetect: {
81
- type: "boolean",
82
- description: "Auto-detect repos from existing remotes (default: true)"
83
- }
84
- },
85
- required: ["projectPath"],
86
- additionalProperties: true
87
- };
88
65
  }
89
- async handle(args, ctx) {
90
- return handleGitFix(args, ctx.gitAdapter, ctx.providerManager);
66
+ async handle(args) {
67
+ return handleGitFix(args);
91
68
  }
92
69
  }
93
- //# sourceMappingURL=gitFix.tool.js.map
@@ -1,17 +1,12 @@
1
1
  import { Tool, MCPContext } from '../types.js';
2
+ /**
3
+ * Git History Tool - Mantém histórico detalhado de TODAS alterações
4
+ * Modo DUAL automático - cria issues de histórico em GitHub e Gitea
5
+ * Rastreabilidade completa de cada mudança local
6
+ */
2
7
  export declare class GitHistoryTool implements Tool {
3
8
  name: string;
4
9
  description: string;
5
- inputSchema: {
6
- type: "object";
7
- properties: {
8
- projectPath: {
9
- type: string;
10
- };
11
- };
12
- required: string[];
13
- additionalProperties: boolean;
14
- };
15
10
  handle(params: Record<string, any>, ctx: MCPContext): Promise<any>;
16
11
  private trackChange;
17
12
  private listLocalHistory;
@@ -19,12 +14,4 @@ export declare class GitHistoryTool implements Tool {
19
14
  private generateReport;
20
15
  private saveLocalHistory;
21
16
  private formatHistoryBody;
22
- private generateChangelog;
23
- private groupCommitsByType;
24
- private formatKeepAChangelog;
25
- private formatConventionalChangelog;
26
- private getHistoryEntry;
27
- private searchHistory;
28
- private getStats;
29
17
  }
30
- //# sourceMappingURL=gitHistory.d.ts.map