@andrebuzeli/git-mcp 3.4.0 → 4.0.3
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/EXEMPLOS.md +861 -0
- package/INSTRUCOES.md +444 -0
- package/README.md +63 -283
- package/dist/providers/base-provider.d.ts.map +1 -1
- package/dist/providers/base-provider.js +3 -26
- package/dist/providers/base-provider.js.map +1 -1
- package/dist/providers/gitea-provider.d.ts +0 -2
- package/dist/providers/gitea-provider.d.ts.map +1 -1
- package/dist/providers/gitea-provider.js +0 -62
- package/dist/providers/gitea-provider.js.map +1 -1
- package/dist/providers/github-provider.d.ts +0 -2
- package/dist/providers/github-provider.d.ts.map +1 -1
- package/dist/providers/github-provider.js +48 -105
- package/dist/providers/github-provider.js.map +1 -1
- package/dist/server.d.ts +0 -27
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +130 -1215
- package/dist/server.js.map +1 -1
- package/dist/tools/{git-commits.d.ts → git-analytics.d.ts} +4 -10
- package/dist/tools/git-analytics.d.ts.map +1 -0
- package/dist/tools/git-analytics.js +18 -0
- package/dist/tools/git-analytics.js.map +1 -0
- package/dist/tools/git-archive.d.ts +3 -0
- package/dist/tools/git-archive.d.ts.map +1 -1
- package/dist/tools/git-archive.js +2 -2
- package/dist/tools/git-archive.js.map +1 -1
- package/dist/tools/git-backup.d.ts +216 -0
- package/dist/tools/git-backup.d.ts.map +1 -0
- package/dist/tools/git-backup.js +813 -0
- package/dist/tools/git-backup.js.map +1 -0
- package/dist/tools/git-branches.d.ts +159 -8
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +554 -2
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-config.d.ts +3 -0
- package/dist/tools/git-config.d.ts.map +1 -1
- package/dist/tools/git-config.js +2 -2
- package/dist/tools/git-config.js.map +1 -1
- package/dist/tools/git-files.d.ts +130 -8
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +426 -2
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-issues.d.ts +137 -471
- package/dist/tools/git-issues.d.ts.map +1 -1
- package/dist/tools/git-issues.js +605 -613
- package/dist/tools/git-issues.js.map +1 -1
- package/dist/tools/git-monitor.d.ts +161 -0
- package/dist/tools/git-monitor.d.ts.map +1 -0
- package/dist/tools/git-monitor.js +746 -0
- package/dist/tools/git-monitor.js.map +1 -0
- package/dist/tools/git-packages.d.ts +5 -2
- package/dist/tools/git-packages.d.ts.map +1 -1
- package/dist/tools/git-packages.js +3 -3
- package/dist/tools/git-packages.js.map +1 -1
- package/dist/tools/git-pulls.d.ts +38 -646
- package/dist/tools/git-pulls.d.ts.map +1 -1
- package/dist/tools/git-pulls.js +64 -716
- package/dist/tools/git-pulls.js.map +1 -1
- package/dist/tools/git-release.d.ts +187 -0
- package/dist/tools/git-release.d.ts.map +1 -0
- package/dist/tools/git-release.js +619 -0
- package/dist/tools/git-release.js.map +1 -0
- package/dist/tools/git-remote.d.ts +112 -77
- package/dist/tools/git-remote.d.ts.map +1 -1
- package/dist/tools/git-remote.js +481 -183
- package/dist/tools/git-remote.js.map +1 -1
- package/dist/tools/git-repos.d.ts +19 -0
- package/dist/tools/git-repos.d.ts.map +1 -0
- package/dist/tools/git-repos.js +18 -0
- package/dist/tools/git-repos.js.map +1 -0
- package/dist/tools/git-reset.d.ts +121 -74
- package/dist/tools/git-reset.d.ts.map +1 -1
- package/dist/tools/git-reset.js +540 -159
- package/dist/tools/git-reset.js.map +1 -1
- package/dist/tools/git-stash.d.ts +119 -78
- package/dist/tools/git-stash.d.ts.map +1 -1
- package/dist/tools/git-stash.js +560 -209
- package/dist/tools/git-stash.js.map +1 -1
- package/dist/tools/git-sync.d.ts +3 -163
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +9 -326
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-tags.d.ts +105 -331
- package/dist/tools/git-tags.d.ts.map +1 -1
- package/dist/tools/git-tags.js +545 -416
- package/dist/tools/git-tags.js.map +1 -1
- package/dist/tools/git-workflow.d.ts +127 -0
- package/dist/tools/git-workflow.d.ts.map +1 -0
- package/dist/tools/git-workflow.js +359 -0
- package/dist/tools/git-workflow.js.map +1 -0
- package/dist/utils/auto-detection.d.ts +113 -0
- package/dist/utils/auto-detection.d.ts.map +1 -0
- package/dist/utils/auto-detection.js +235 -0
- package/dist/utils/auto-detection.js.map +1 -0
- package/dist/utils/error-handler.d.ts +107 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +331 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/git-operations.d.ts.map +1 -1
- package/dist/utils/git-operations.js +6 -51
- package/dist/utils/git-operations.js.map +1 -1
- package/dist/utils/user-detection.d.ts +1 -13
- package/dist/utils/user-detection.d.ts.map +1 -1
- package/dist/utils/user-detection.js +1 -26
- package/dist/utils/user-detection.js.map +1 -1
- package/package.json +62 -60
- package/dist/client.d.ts +0 -307
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -299
- package/dist/client.js.map +0 -1
- package/dist/tools/git-branch-protection.d.ts +0 -97
- package/dist/tools/git-branch-protection.d.ts.map +0 -1
- package/dist/tools/git-branch-protection.js +0 -182
- package/dist/tools/git-branch-protection.js.map +0 -1
- package/dist/tools/git-commits.d.ts.map +0 -1
- package/dist/tools/git-commits.js +0 -5
- package/dist/tools/git-commits.js.map +0 -1
- package/dist/tools/git-initialize.d.ts +0 -208
- package/dist/tools/git-initialize.d.ts.map +0 -1
- package/dist/tools/git-initialize.js +0 -470
- package/dist/tools/git-initialize.js.map +0 -1
- package/dist/tools/git-projects.d.ts +0 -112
- package/dist/tools/git-projects.d.ts.map +0 -1
- package/dist/tools/git-projects.js +0 -319
- package/dist/tools/git-projects.js.map +0 -1
- package/dist/tools/git-releases.d.ts +0 -486
- package/dist/tools/git-releases.d.ts.map +0 -1
- package/dist/tools/git-releases.js +0 -561
- package/dist/tools/git-releases.js.map +0 -1
- package/dist/tools/git-repositories.d.ts +0 -469
- package/dist/tools/git-repositories.d.ts.map +0 -1
- package/dist/tools/git-repositories.js +0 -637
- package/dist/tools/git-repositories.js.map +0 -1
- package/dist/tools/git-revert.d.ts +0 -147
- package/dist/tools/git-revert.d.ts.map +0 -1
- package/dist/tools/git-revert.js +0 -199
- package/dist/tools/git-revert.js.map +0 -1
- package/dist/tools/git-update-project.d.ts +0 -309
- package/dist/tools/git-update-project.d.ts.map +0 -1
- package/dist/tools/git-update-project.js +0 -878
- package/dist/tools/git-update-project.js.map +0 -1
package/dist/server.js
CHANGED
|
@@ -1,1215 +1,158 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GiteaMCPServer =
|
|
3
|
+
exports.GiteaMCPServer = void 0;
|
|
4
4
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
5
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
6
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
7
|
const config_js_1 = require("./config.js");
|
|
8
8
|
const index_js_2 = require("./providers/index.js");
|
|
9
9
|
/**
|
|
10
|
-
* Importação
|
|
10
|
+
* Importação das ferramentas MCP UNIFICADAS (18 tools)
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
12
|
+
* ARQUITETURA UNIFICADA PARA AI AGENTS - MCP GIT AI UNIFICATION:
|
|
13
|
+
* - Redução inteligente de 25 para 18 ferramentas
|
|
14
|
+
* - Auto-detecção universal (repo, owner, providers)
|
|
15
|
+
* - Interface consistente para todos os AI agents/IDEs
|
|
16
|
+
* - Error handling com recovery automático
|
|
17
|
+
* - Foco em produtividade individual e backup
|
|
18
|
+
*
|
|
19
|
+
* CORE UNIFIED TOOLS (6) - FUNCIONALIDADES ESSENCIAIS:
|
|
20
|
+
* - git-workflow: Workflow completo (init, commit, sync, status, backup)
|
|
21
|
+
* - git-files: Operações inteligentes de arquivo (read, write, search, update, backup-files)
|
|
22
|
+
* - git-release: Sistema de release automatizado (create, version, publish, history, rollback)
|
|
23
|
+
* - git-monitor: Monitoramento avançado (status, history, metrics, health, activity)
|
|
24
|
+
* - git-backup: Sistema de backup inteligente (create, restore, list, auto, verify)
|
|
25
|
+
* - git-branches: Gerenciamento de branches unificado
|
|
26
|
+
*
|
|
27
|
+
* ADVANCED TOOLS (6) - FUNCIONALIDADES AVANÇADAS:
|
|
28
|
+
* - git-remote: Gerenciamento de remotos
|
|
29
|
+
* - git-stash: Operações de stash
|
|
30
|
+
* - git-reset: Reset seguro
|
|
16
31
|
* - git-tags: Gerenciamento de tags
|
|
17
|
-
* - git-
|
|
18
|
-
* - git-
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* - git-
|
|
22
|
-
* - git-
|
|
23
|
-
* - git-reset: Operações de reset
|
|
24
|
-
* - git-revert: Operações de revert
|
|
25
|
-
* - git-stash: Gerenciamento de stash
|
|
26
|
-
* - git-config: Configuração do Git
|
|
27
|
-
* - git-remote: Gerenciamento de remotes
|
|
28
|
-
* - git-archive: Criação de arquivos
|
|
29
|
-
* - git-sync: Sincronização de repositórios
|
|
32
|
+
* - git-issues: Sistema de issues
|
|
33
|
+
* - git-pulls: Pull requests
|
|
34
|
+
*
|
|
35
|
+
* SPECIALIZED TOOLS (6) - FUNCIONALIDADES ESPECÍFICAS:
|
|
36
|
+
* - git-analytics: Analytics e relatórios
|
|
37
|
+
* - git-archive: Operações de archive
|
|
30
38
|
* - git-packages: Gerenciamento de pacotes
|
|
31
|
-
* - git-
|
|
39
|
+
* - git-sync: Sincronização multi-provider
|
|
40
|
+
* - git-repos: Gerenciamento de repositórios
|
|
41
|
+
* - git-config: Configurações avançadas
|
|
32
42
|
*
|
|
33
|
-
*
|
|
43
|
+
* DIFERENCIAIS IMPLEMENTADOS:
|
|
44
|
+
* - Apenas action + projectPath obrigatórios
|
|
45
|
+
* - Auto-detecção completa de contexto
|
|
46
|
+
* - Respostas estruturadas universais
|
|
47
|
+
* - Error handling inteligente com sugestões
|
|
48
|
+
* - Multi-provider automático
|
|
49
|
+
* - Interface compatível com qualquer AI agent/IDE
|
|
34
50
|
*/
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const git_sync_js_1 = require("./tools/git-sync.js");
|
|
54
|
-
const
|
|
55
|
-
const
|
|
51
|
+
// CORE UNIFIED TOOLS (6 ferramentas essenciais)
|
|
52
|
+
const git_workflow_js_1 = require("./tools/git-workflow.js"); // Workflow unificado
|
|
53
|
+
const git_files_js_1 = require("./tools/git-files.js"); // Operações de arquivo inteligentes
|
|
54
|
+
const git_release_js_1 = require("./tools/git-release.js"); // Sistema de release automatizado
|
|
55
|
+
const git_monitor_js_1 = require("./tools/git-monitor.js"); // Monitoramento avançado
|
|
56
|
+
const git_backup_js_1 = require("./tools/git-backup.js"); // Sistema de backup inteligente
|
|
57
|
+
const git_branches_js_1 = require("./tools/git-branches.js"); // Gerenciamento de branches
|
|
58
|
+
// ADVANCED TOOLS (6 ferramentas avançadas)
|
|
59
|
+
const git_remote_js_1 = require("./tools/git-remote.js"); // Gerenciamento de remotos
|
|
60
|
+
const git_stash_js_1 = require("./tools/git-stash.js"); // Operações de stash
|
|
61
|
+
const git_reset_js_1 = require("./tools/git-reset.js"); // Reset seguro
|
|
62
|
+
const git_tags_js_1 = require("./tools/git-tags.js"); // Gerenciamento de tags
|
|
63
|
+
const git_issues_js_1 = require("./tools/git-issues.js"); // Sistema de issues
|
|
64
|
+
const git_pulls_js_1 = require("./tools/git-pulls.js"); // Pull requests
|
|
65
|
+
// SPECIALIZED TOOLS (6 ferramentas especializadas)
|
|
66
|
+
const git_analytics_js_1 = require("./tools/git-analytics.js"); // Analytics e relatórios
|
|
67
|
+
const git_archive_js_1 = require("./tools/git-archive.js"); // Operações de archive
|
|
68
|
+
const git_packages_js_1 = require("./tools/git-packages.js"); // Gerenciamento de pacotes
|
|
69
|
+
const git_sync_js_1 = require("./tools/git-sync.js"); // Sincronização multi-provider
|
|
70
|
+
const git_repos_js_1 = require("./tools/git-repos.js"); // Gerenciamento de repositórios
|
|
71
|
+
const git_config_js_1 = require("./tools/git-config.js"); // Configurações avançadas
|
|
56
72
|
/**
|
|
57
|
-
*
|
|
73
|
+
* Array de todas as ferramentas disponíveis (18 tools) - UNIFICADAS
|
|
58
74
|
*
|
|
59
|
-
*
|
|
60
|
-
* -
|
|
61
|
-
* -
|
|
62
|
-
* -
|
|
63
|
-
* -
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
uri: 'git-mcp://documentation/rules',
|
|
68
|
-
name: 'Regras de Uso do Git MCP',
|
|
69
|
-
description: 'Regras essenciais para usar o Git MCP corretamente',
|
|
70
|
-
mimeType: 'text/markdown'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
uri: 'git-mcp://documentation/providers',
|
|
74
|
-
name: 'Configuração de Providers',
|
|
75
|
-
description: 'Como configurar GitHub e Gitea providers',
|
|
76
|
-
mimeType: 'text/markdown'
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
uri: 'git-mcp://documentation/tools',
|
|
80
|
-
name: 'Ferramentas Disponíveis',
|
|
81
|
-
description: 'Lista completa de todas as ferramentas e seus usos',
|
|
82
|
-
mimeType: 'text/markdown'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
uri: 'git-mcp://examples/basic-usage',
|
|
86
|
-
name: 'Exemplos Básicos de Uso',
|
|
87
|
-
description: 'Exemplos práticos de como usar as ferramentas',
|
|
88
|
-
mimeType: 'text/markdown'
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
uri: 'git-mcp://examples/workflows',
|
|
92
|
-
name: 'Workflows Completos',
|
|
93
|
-
description: 'Exemplos de workflows completos de desenvolvimento',
|
|
94
|
-
mimeType: 'text/markdown'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
uri: 'git-mcp://troubleshooting/common-issues',
|
|
98
|
-
name: 'Problemas Comuns e Soluções',
|
|
99
|
-
description: 'Como resolver problemas comuns no Git MCP',
|
|
100
|
-
mimeType: 'text/markdown'
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
exports.resources = resources;
|
|
104
|
-
/**
|
|
105
|
-
* PROMPTS MCP - Templates de uso pré-definidos
|
|
75
|
+
* ARQUITETURA UNIFICADA MCP GIT AI UNIFICATION:
|
|
76
|
+
* - 18 ferramentas otimizadas para AI agents
|
|
77
|
+
* - Interface universal para qualquer IDE (VSCode, Cursor, Trae)
|
|
78
|
+
* - Apenas action + projectPath obrigatórios
|
|
79
|
+
* - Auto-detecção completa de contexto
|
|
80
|
+
* - Error handling inteligente com recovery
|
|
81
|
+
* - Foco em produtividade individual e backup
|
|
106
82
|
*
|
|
107
|
-
*
|
|
108
|
-
* -
|
|
109
|
-
* -
|
|
110
|
-
* -
|
|
111
|
-
* -
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const prompts = [];
|
|
115
|
-
/**
|
|
116
|
-
* Array de todas as ferramentas disponíveis (19 tools)
|
|
83
|
+
* CORE UNIFIED TOOLS (6 ferramentas essenciais):
|
|
84
|
+
* - git-workflow: Workflow completo (init, commit, sync, status, backup)
|
|
85
|
+
* - git-files: Operações inteligentes de arquivo (read, write, search, update, backup-files)
|
|
86
|
+
* - git-release: Sistema de release automatizado (create, version, publish, history, rollback)
|
|
87
|
+
* - git-monitor: Monitoramento avançado (status, history, metrics, health, activity)
|
|
88
|
+
* - git-backup: Sistema de backup inteligente (create, restore, list, auto, verify)
|
|
89
|
+
* - git-branches: Gerenciamento de branches unificado
|
|
117
90
|
*
|
|
118
|
-
*
|
|
119
|
-
* -
|
|
120
|
-
* -
|
|
121
|
-
* -
|
|
91
|
+
* ADVANCED TOOLS (6 ferramentas avançadas):
|
|
92
|
+
* - git-remote: Gerenciamento de remotos
|
|
93
|
+
* - git-stash: Operações de stash
|
|
94
|
+
* - git-reset: Reset seguro
|
|
95
|
+
* - git-tags: Gerenciamento de tags
|
|
96
|
+
* - git-issues: Sistema de issues
|
|
97
|
+
* - git-pulls: Pull requests
|
|
122
98
|
*
|
|
123
|
-
*
|
|
124
|
-
* -
|
|
99
|
+
* SPECIALIZED TOOLS (6 ferramentas especializadas):
|
|
100
|
+
* - git-analytics: Analytics e relatórios
|
|
101
|
+
* - git-archive: Operações de archive
|
|
102
|
+
* - git-packages: Gerenciamento de pacotes
|
|
103
|
+
* - git-sync: Sincronização multi-provider
|
|
104
|
+
* - git-repos: Gerenciamento de repositórios
|
|
105
|
+
* - git-config: Configurações avançadas
|
|
125
106
|
*
|
|
126
|
-
*
|
|
127
|
-
* -
|
|
128
|
-
* -
|
|
129
|
-
* -
|
|
107
|
+
* DIFERENCIAIS IMPLEMENTADOS:
|
|
108
|
+
* - Auto-detecção universal (repo, owner, providers)
|
|
109
|
+
* - Respostas estruturadas consistentes
|
|
110
|
+
* - Multi-provider automático
|
|
111
|
+
* - Error handling com sugestões de recovery
|
|
112
|
+
* - Interface compatível com qualquer AI agent
|
|
130
113
|
*/
|
|
131
114
|
const tools = [
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
git_sync_js_1.gitSyncTool,
|
|
151
|
-
|
|
152
|
-
|
|
115
|
+
// CORE UNIFIED TOOLS (6 ferramentas essenciais) - Funcionalidades básicas
|
|
116
|
+
git_workflow_js_1.gitWorkflowTool, // Workflow unificado (init, commit, sync, status, backup)
|
|
117
|
+
git_files_js_1.gitFilesTool, // Operações inteligentes de arquivo (read, write, search, update, backup-files)
|
|
118
|
+
git_release_js_1.gitReleaseTool, // Sistema de release automatizado (create, version, publish, history, rollback)
|
|
119
|
+
git_monitor_js_1.gitMonitorTool, // Monitoramento avançado (status, history, metrics, health, activity)
|
|
120
|
+
git_backup_js_1.gitBackupTool, // Sistema de backup inteligente (create, restore, list, auto, verify)
|
|
121
|
+
git_branches_js_1.gitBranchesTool, // Gerenciamento de branches unificado
|
|
122
|
+
// ADVANCED TOOLS (6 ferramentas avançadas) - Funcionalidades avançadas
|
|
123
|
+
git_remote_js_1.gitRemoteTool, // Gerenciamento de remotos
|
|
124
|
+
git_stash_js_1.gitStashTool, // Operações de stash
|
|
125
|
+
git_reset_js_1.gitResetTool, // Reset seguro
|
|
126
|
+
git_tags_js_1.gitTagsTool, // Gerenciamento de tags
|
|
127
|
+
git_issues_js_1.gitIssuesTool, // Sistema de issues
|
|
128
|
+
git_pulls_js_1.gitPullsTool, // Pull requests
|
|
129
|
+
// SPECIALIZED TOOLS (6 ferramentas especializadas) - Funcionalidades específicas
|
|
130
|
+
git_analytics_js_1.gitAnalyticsTool, // Analytics e relatórios
|
|
131
|
+
git_archive_js_1.gitArchiveTool, // Operações de archive
|
|
132
|
+
git_packages_js_1.gitPackagesTool, // Gerenciamento de pacotes
|
|
133
|
+
git_sync_js_1.gitSyncTool, // Sincronização multi-provider
|
|
134
|
+
git_repos_js_1.gitReposTool, // Gerenciamento de repositórios
|
|
135
|
+
git_config_js_1.gitConfigTool // Configurações avançadas
|
|
153
136
|
];
|
|
154
137
|
/**
|
|
155
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
## 🚫 REGRAS ABSOLUTAS (NUNCA QUEBRAR)
|
|
163
|
-
|
|
164
|
-
### 1. **Project Path é OBRIGATÓRIO**
|
|
165
|
-
- **TODA tool** deve receber \`projectPath\` como parâmetro obrigatório
|
|
166
|
-
- **TODAS as operações** devem ser executadas dentro do \`projectPath\` ou suas subpastas
|
|
167
|
-
- **NENHUMA operação** pode ser executada fora do diretório do projeto
|
|
168
|
-
|
|
169
|
-
### 2. **Comandos Git SEMPRE via Tools**
|
|
170
|
-
- **NUNCA** executar comandos git diretamente no terminal
|
|
171
|
-
- **SEMPRE** usar as tools do git-mcp para operações git
|
|
172
|
-
- **NUNCA** usar \`git\` diretamente, mesmo que "pareça mais rápido"
|
|
173
|
-
|
|
174
|
-
### 3. **Commit Messages em Português**
|
|
175
|
-
- **TODOS os commits** devem ter mensagens descritivas em português
|
|
176
|
-
- **NÃO usar** mensagens genéricas como "update" ou "fix"
|
|
177
|
-
- **DESCREVER** exatamente o que foi alterado no arquivo
|
|
178
|
-
|
|
179
|
-
### 4. **Testes OBRIGATÓRIOS**
|
|
180
|
-
- **ANTES de publicar** testar TODAS as tools com ambos providers
|
|
181
|
-
- **VALIDAR** funcionamento com GitHub E Gitea
|
|
182
|
-
- **NÃO publicar** versões não testadas
|
|
183
|
-
|
|
184
|
-
## ✅ BOAS PRÁTICAS
|
|
185
|
-
|
|
186
|
-
### Project Path
|
|
187
|
-
- Sempre usar caminhos absolutos
|
|
188
|
-
- Validar se o diretório existe antes das operações
|
|
189
|
-
- Manter consistência entre ferramentas
|
|
190
|
-
|
|
191
|
-
### Providers
|
|
192
|
-
- Gitea: Para projetos pessoais/privados
|
|
193
|
-
- GitHub: Para projetos públicos/open-source
|
|
194
|
-
- Ambos devem funcionar identicamente
|
|
195
|
-
|
|
196
|
-
### Commits
|
|
197
|
-
- Mensagens claras e específicas
|
|
198
|
-
- Descrever função/arquivo alterado
|
|
199
|
-
- Usar português brasileiro
|
|
200
|
-
|
|
201
|
-
### Error Handling
|
|
202
|
-
- Tratar todos os erros possíveis
|
|
203
|
-
- Fornecer mensagens claras
|
|
204
|
-
- Sugerir soluções quando possível`;
|
|
205
|
-
case 'git-mcp://documentation/providers':
|
|
206
|
-
return `# Configuração de Providers
|
|
207
|
-
|
|
208
|
-
## GitHub Setup
|
|
209
|
-
|
|
210
|
-
### Variáveis de Ambiente
|
|
211
|
-
\`\`\`bash
|
|
212
|
-
GITHUB_TOKEN=your_github_token_here
|
|
213
|
-
\`\`\`
|
|
214
|
-
|
|
215
|
-
### Como Obter Token
|
|
216
|
-
1. Acesse: https://github.com/settings/tokens
|
|
217
|
-
2. Generate new token (classic)
|
|
218
|
-
3. Selecione scopes:
|
|
219
|
-
- \`repo\` (acesso completo aos repositórios)
|
|
220
|
-
- \`workflow\` (atualizar workflows GitHub Actions)
|
|
221
|
-
- \`write:packages\` (upload de pacotes)
|
|
222
|
-
|
|
223
|
-
## Gitea Setup
|
|
224
|
-
|
|
225
|
-
### Variáveis de Ambiente
|
|
226
|
-
\`\`\`bash
|
|
227
|
-
GITEA_URL=http://your-gitea-server:3000
|
|
228
|
-
GITEA_TOKEN=your_gitea_token_here
|
|
229
|
-
GITEA_USERNAME=your_username
|
|
230
|
-
\`\`\`
|
|
231
|
-
|
|
232
|
-
### Como Obter Token
|
|
233
|
-
1. Acesse: \`http://your-server:3000/user/settings/applications\`
|
|
234
|
-
2. Crie novo token de acesso
|
|
235
|
-
3. Selecione permissões necessárias
|
|
236
|
-
|
|
237
|
-
## Validação
|
|
238
|
-
|
|
239
|
-
Teste a configuração executando:
|
|
240
|
-
\`\`\`typescript
|
|
241
|
-
// Testar GitHub
|
|
242
|
-
await gitRepositoriesTool.handler({
|
|
243
|
-
action: 'list',
|
|
244
|
-
provider: 'github',
|
|
245
|
-
page: 1,
|
|
246
|
-
limit: 5
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// Testar Gitea
|
|
250
|
-
await gitRepositoriesTool.handler({
|
|
251
|
-
action: 'list',
|
|
252
|
-
provider: 'gitea',
|
|
253
|
-
page: 1,
|
|
254
|
-
limit: 5
|
|
255
|
-
});
|
|
256
|
-
\`\`\``;
|
|
257
|
-
case 'git-mcp://documentation/tools':
|
|
258
|
-
return `# Ferramentas Disponíveis - Git MCP v3.2.5
|
|
259
|
-
|
|
260
|
-
## 🎯 CORE TOOLS (21 Ferramentas)
|
|
261
|
-
|
|
262
|
-
## 📋 PARÂMETROS COMUNS (TODAS AS TOOLS)
|
|
263
|
-
|
|
264
|
-
### Parâmetros OBRIGATÓRIOS
|
|
265
|
-
- **action**: Ação a executar (específica por tool)
|
|
266
|
-
- **projectPath**: Caminho absoluto do projeto local
|
|
267
|
-
- **provider**: Provedor a usar ('gitea' ou 'github')
|
|
268
|
-
|
|
269
|
-
### Parâmetros AUTOMÁTICOS
|
|
270
|
-
- **repo**: Nome do repositório (extraído automaticamente do projectPath)
|
|
271
|
-
- **owner**: Proprietário (detectado automaticamente pelo provider)
|
|
272
|
-
|
|
273
|
-
### Parâmetros OPCIONAIS Comuns
|
|
274
|
-
- **page**: Página para paginação (sem limite máximo)
|
|
275
|
-
- Outros parâmetros específicos por ação
|
|
276
|
-
|
|
277
|
-
## 🔧 FERRAMENTAS DETALHADAS
|
|
278
|
-
|
|
279
|
-
### Repositories & Projects
|
|
280
|
-
- **git-repositories**: \`create\`, \`list\`, \`get\`, \`update\`, \`delete\`, \`fork\`, \`search\`, \`init\`, \`clone\`
|
|
281
|
-
- **git-projects**: \`list\`, \`get\`, \`create\`, \`update\`, \`delete\`, \`addItem\`, \`updateItem\`, \`deleteItem\`, \`listItems\`
|
|
282
|
-
|
|
283
|
-
### Git Operations
|
|
284
|
-
- **git-commits**: \`list\`, \`get\`, \`create\`, \`compare\`, \`search\`, \`push\`, \`pull\`
|
|
285
|
-
- **git-branches**: \`create\`, \`list\`, \`get\`, \`delete\`, \`merge\`, \`compare\`
|
|
286
|
-
- **git-tags**: \`create\`, \`list\`, \`get\`, \`delete\`, \`search\`
|
|
287
|
-
|
|
288
|
-
### Files & Content
|
|
289
|
-
- **git-files**: \`get\`, \`create\`, \`update\`, \`delete\`, \`list\`, \`search\`, \`upload-project\`
|
|
290
|
-
- **git-archive**: \`create\`, \`extract\`, \`list\`, \`verify\`
|
|
291
|
-
|
|
292
|
-
### Version Control
|
|
293
|
-
- **git-reset**: \`soft\`, \`mixed\`, \`hard\`, \`reset-to-commit\`, \`reset-branch\`
|
|
294
|
-
- **git-revert**: \`revert-commit\`, \`revert-merge\`, \`revert-range\`
|
|
295
|
-
- **git-stash**: \`stash\`, \`pop\`, \`apply\`, \`list\`, \`show\`, \`drop\`, \`clear\`
|
|
296
|
-
|
|
297
|
-
### Issues & Collaboration
|
|
298
|
-
- **git-issues**: \`create\`, \`list\`, \`get\`, \`update\`, \`close\`, \`comment\`, \`search\`
|
|
299
|
-
- **git-pulls**: \`create\`, \`list\`, \`get\`, \`update\`, \`merge\`, \`close\`, \`review\`, \`search\`
|
|
300
|
-
|
|
301
|
-
### Releases & Packages
|
|
302
|
-
- **git-releases**: \`create\`, \`list\`, \`get\`, \`update\`, \`delete\`, \`publish\`
|
|
303
|
-
- **git-packages**: \`list\`, \`get\`, \`create\`, \`update\`, \`delete\`, \`publish\`, \`download\`
|
|
304
|
-
|
|
305
|
-
### Config & Sync
|
|
306
|
-
- **git-config**: \`get\`, \`set\`, \`unset\`, \`list\`, \`edit\`, \`show\`
|
|
307
|
-
- **git-remote**: \`add\`, \`remove\`, \`rename\`, \`show\`, \`set-url\`, \`prune\`
|
|
308
|
-
- **git-sync**: \`configure\`, \`status\`, \`one-shot\`
|
|
309
|
-
|
|
310
|
-
### Project Management
|
|
311
|
-
- **git-update-project**: \`init\`, \`update\`, \`status\`, \`diff\`, \`log\`, \`reset\`, \`stash\`, \`pull\`, \`sync\`
|
|
312
|
-
- **git-initialize**: \`init\`
|
|
313
|
-
|
|
314
|
-
## 📋 PARÂMETROS OBRIGATÓRIOS
|
|
315
|
-
|
|
316
|
-
**TODAS as tools requerem:**
|
|
317
|
-
- \`projectPath\`: Caminho absoluto do projeto
|
|
318
|
-
- \`provider\`: 'gitea' ou 'github' (exceto algumas tools específicas)
|
|
319
|
-
|
|
320
|
-
## 🎯 EXEMPLOS DE USO
|
|
321
|
-
|
|
322
|
-
### Inicializar Projeto
|
|
323
|
-
\`\`\`typescript
|
|
324
|
-
await gitInitializeTool.handler({
|
|
325
|
-
action: 'init',
|
|
326
|
-
projectPath: '/caminho/do/projeto',
|
|
327
|
-
provider: 'gitea',
|
|
328
|
-
message: 'Setup inicial do projeto'
|
|
329
|
-
});
|
|
330
|
-
\`\`\`
|
|
331
|
-
|
|
332
|
-
### Commit de Arquivo
|
|
333
|
-
\`\`\`typescript
|
|
334
|
-
await gitCommitsTool.handler({
|
|
335
|
-
action: 'create',
|
|
336
|
-
projectPath: '/caminho/do/projeto',
|
|
337
|
-
provider: 'gitea',
|
|
338
|
-
message: 'Adiciona função de validação de email no arquivo auth.js'
|
|
339
|
-
});
|
|
340
|
-
\`\`\`
|
|
341
|
-
|
|
342
|
-
### Criar Branch
|
|
343
|
-
\`\`\`typescript
|
|
344
|
-
await gitBranchesTool.handler({
|
|
345
|
-
action: 'create',
|
|
346
|
-
projectPath: '/caminho/do/projeto',
|
|
347
|
-
provider: 'gitea',
|
|
348
|
-
branch_name: 'feature/nova-funcionalidade',
|
|
349
|
-
from_branch: 'main'
|
|
350
|
-
});
|
|
351
|
-
\`\`\``;
|
|
352
|
-
case 'git-mcp://examples/basic-usage':
|
|
353
|
-
return `# Exemplos Básicos de Uso
|
|
354
|
-
|
|
355
|
-
## 🚀 SETUP INICIAL
|
|
356
|
-
|
|
357
|
-
### 1. Configurar Projeto Novo
|
|
358
|
-
\`\`\`typescript
|
|
359
|
-
// Criar repositório remoto primeiro
|
|
360
|
-
await gitRepositoriesTool.handler({
|
|
361
|
-
action: 'create',
|
|
362
|
-
name: 'meu-projeto',
|
|
363
|
-
description: 'Projeto incrível',
|
|
364
|
-
private: true,
|
|
365
|
-
auto_init: true,
|
|
366
|
-
provider: 'gitea'
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// Inicializar localmente
|
|
370
|
-
await gitInitializeTool.handler({
|
|
371
|
-
action: 'init',
|
|
372
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
373
|
-
provider: 'gitea',
|
|
374
|
-
message: 'Setup inicial do projeto'
|
|
375
|
-
});
|
|
376
|
-
\`\`\`
|
|
377
|
-
|
|
378
|
-
## 📝 TRABALHO DIÁRIO
|
|
379
|
-
|
|
380
|
-
### 2. Adicionar Arquivo e Commitar
|
|
381
|
-
\`\`\`typescript
|
|
382
|
-
// Criar arquivo via tool
|
|
383
|
-
await gitFilesTool.handler({
|
|
384
|
-
action: 'create',
|
|
385
|
-
repo: 'meu-projeto',
|
|
386
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
387
|
-
provider: 'gitea',
|
|
388
|
-
path: 'src/index.js',
|
|
389
|
-
content: 'console.log("Olá Mundo!");',
|
|
390
|
-
message: 'Cria arquivo principal index.js com saudação básica'
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
// Ou upload completo do projeto
|
|
394
|
-
await gitUpdateProjectTool.handler({
|
|
395
|
-
action: 'init',
|
|
396
|
-
repo: 'meu-projeto',
|
|
397
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
398
|
-
provider: 'gitea',
|
|
399
|
-
message: 'Upload completo dos arquivos do projeto'
|
|
400
|
-
});
|
|
401
|
-
\`\`\`
|
|
402
|
-
|
|
403
|
-
### 3. Criar Branch e Trabalhar
|
|
404
|
-
\`\`\`typescript
|
|
405
|
-
// Criar branch
|
|
406
|
-
await gitBranchesTool.handler({
|
|
407
|
-
action: 'create',
|
|
408
|
-
repo: 'meu-projeto',
|
|
409
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
410
|
-
provider: 'gitea',
|
|
411
|
-
branch_name: 'feature/login',
|
|
412
|
-
from_branch: 'main'
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
// Commitar mudanças
|
|
416
|
-
await gitCommitsTool.handler({
|
|
417
|
-
action: 'create',
|
|
418
|
-
repo: 'meu-projeto',
|
|
419
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
420
|
-
provider: 'gitea',
|
|
421
|
-
message: 'Implementa validação de formulário de login'
|
|
422
|
-
});
|
|
423
|
-
\`\`\`
|
|
424
|
-
|
|
425
|
-
## 🔄 SINCRONIZAÇÃO
|
|
426
|
-
|
|
427
|
-
### 4. Push e Pull
|
|
428
|
-
\`\`\`typescript
|
|
429
|
-
// Enviar mudanças
|
|
430
|
-
await gitCommitsTool.handler({
|
|
431
|
-
action: 'push',
|
|
432
|
-
repo: 'meu-projeto',
|
|
433
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
434
|
-
provider: 'gitea',
|
|
435
|
-
branch: 'feature/login'
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
// Baixar mudanças
|
|
439
|
-
await gitCommitsTool.handler({
|
|
440
|
-
action: 'pull',
|
|
441
|
-
repo: 'meu-projeto',
|
|
442
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
443
|
-
provider: 'gitea',
|
|
444
|
-
branch: 'main'
|
|
445
|
-
});
|
|
446
|
-
\`\`\`
|
|
447
|
-
|
|
448
|
-
## 📋 GERENCIAMENTO
|
|
449
|
-
|
|
450
|
-
### 5. Issues e Pull Requests
|
|
451
|
-
\`\`\`typescript
|
|
452
|
-
// Criar issue
|
|
453
|
-
await gitIssuesTool.handler({
|
|
454
|
-
action: 'create',
|
|
455
|
-
repo: 'meu-projeto',
|
|
456
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
457
|
-
provider: 'gitea',
|
|
458
|
-
title: 'Implementar autenticação OAuth',
|
|
459
|
-
body: 'Adicionar suporte para login via Google e GitHub'
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
// Criar PR
|
|
463
|
-
await gitPullsTool.handler({
|
|
464
|
-
action: 'create',
|
|
465
|
-
repo: 'meu-projeto',
|
|
466
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
467
|
-
provider: 'gitea',
|
|
468
|
-
title: 'Feature: Sistema de Login',
|
|
469
|
-
body: 'Implementa autenticação completa com validação',
|
|
470
|
-
head: 'feature/login',
|
|
471
|
-
base: 'main'
|
|
472
|
-
});
|
|
473
|
-
\`\`\`
|
|
474
|
-
|
|
475
|
-
## 📦 RELEASES
|
|
476
|
-
|
|
477
|
-
### 6. Criar Release
|
|
478
|
-
\`\`\`typescript
|
|
479
|
-
await gitReleasesTool.handler({
|
|
480
|
-
action: 'create',
|
|
481
|
-
repo: 'meu-projeto',
|
|
482
|
-
projectPath: 'Z:\\\\Meus Projetos\\\\meu-projeto',
|
|
483
|
-
provider: 'gitea',
|
|
484
|
-
tag_name: 'v1.0.0',
|
|
485
|
-
name: 'Versão 1.0.0',
|
|
486
|
-
body: 'Primeira release estável com sistema de login completo',
|
|
487
|
-
draft: false,
|
|
488
|
-
prerelease: false
|
|
489
|
-
});
|
|
490
|
-
\`\`\``;
|
|
491
|
-
case 'git-mcp://examples/workflows':
|
|
492
|
-
return `# Workflows Completos de Desenvolvimento
|
|
493
|
-
|
|
494
|
-
## 🏗️ WORKFLOW: NOVO PROJETO
|
|
495
|
-
|
|
496
|
-
\`\`\`typescript
|
|
497
|
-
// 1. Criar repositório remoto
|
|
498
|
-
await gitRepositoriesTool.handler({
|
|
499
|
-
action: 'create',
|
|
500
|
-
name: 'novo-projeto',
|
|
501
|
-
description: 'Projeto incrível',
|
|
502
|
-
private: false,
|
|
503
|
-
auto_init: true,
|
|
504
|
-
provider: 'github'
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
// 2. Inicializar projeto local
|
|
508
|
-
await gitInitializeTool.handler({
|
|
509
|
-
action: 'init',
|
|
510
|
-
projectPath: 'C:\\\\Projetos\\\\novo-projeto',
|
|
511
|
-
provider: 'github',
|
|
512
|
-
message: 'Setup inicial do projeto com estrutura base'
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
// 3. Criar estrutura básica
|
|
516
|
-
await gitFilesTool.handler({
|
|
517
|
-
action: 'create',
|
|
518
|
-
repo: 'novo-projeto',
|
|
519
|
-
projectPath: 'C:\\\\Projetos\\\\novo-projeto',
|
|
520
|
-
provider: 'github',
|
|
521
|
-
path: 'README.md',
|
|
522
|
-
content: '# Novo Projeto\\\\n\\\\nProjeto criado com Git MCP.',
|
|
523
|
-
message: 'Adiciona README.md básico'
|
|
524
|
-
});
|
|
525
|
-
\`\`\`
|
|
526
|
-
|
|
527
|
-
## 🚀 WORKFLOW: FEATURE DEVELOPMENT
|
|
528
|
-
|
|
529
|
-
\`\`\`typescript
|
|
530
|
-
// 1. Criar branch da feature
|
|
531
|
-
await gitBranchesTool.handler({
|
|
532
|
-
action: 'create',
|
|
533
|
-
repo: 'meu-app',
|
|
534
|
-
projectPath: 'C:\\\\Projetos\\\\meu-app',
|
|
535
|
-
provider: 'gitea',
|
|
536
|
-
branch_name: 'feature/user-auth',
|
|
537
|
-
from_branch: 'main'
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// 2. Implementar código
|
|
541
|
-
// ... desenvolver código ...
|
|
542
|
-
|
|
543
|
-
// 3. Commit incremental
|
|
544
|
-
await gitCommitsTool.handler({
|
|
545
|
-
action: 'create',
|
|
546
|
-
repo: 'meu-app',
|
|
547
|
-
projectPath: 'C:\\\\Projetos\\\\meu-app',
|
|
548
|
-
provider: 'gitea',
|
|
549
|
-
message: 'Implementa validação de email no formulário de registro'
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
// 4. Push da branch
|
|
553
|
-
await gitCommitsTool.handler({
|
|
554
|
-
action: 'push',
|
|
555
|
-
repo: 'meu-app',
|
|
556
|
-
projectPath: 'C:\\\\Projetos\\\\meu-app',
|
|
557
|
-
provider: 'gitea',
|
|
558
|
-
branch: 'feature/user-auth'
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
// 5. Criar Pull Request
|
|
562
|
-
await gitPullsTool.handler({
|
|
563
|
-
action: 'create',
|
|
564
|
-
repo: 'meu-app',
|
|
565
|
-
projectPath: 'C:\\\\Projetos\\\\meu-app',
|
|
566
|
-
provider: 'gitea',
|
|
567
|
-
title: 'Feature: Sistema de Autenticação de Usuário',
|
|
568
|
-
body: 'Implementa login, registro e validação de usuários',
|
|
569
|
-
head: 'feature/user-auth',
|
|
570
|
-
base: 'main'
|
|
571
|
-
});
|
|
572
|
-
\`\`\`
|
|
573
|
-
|
|
574
|
-
## 🐛 WORKFLOW: HOTFIX
|
|
575
|
-
|
|
576
|
-
\`\`\`typescript
|
|
577
|
-
// 1. Criar branch de hotfix
|
|
578
|
-
await gitBranchesTool.handler({
|
|
579
|
-
action: 'create',
|
|
580
|
-
repo: 'app-prod',
|
|
581
|
-
projectPath: 'C:\\\\Projetos\\\\app-prod',
|
|
582
|
-
provider: 'github',
|
|
583
|
-
branch_name: 'hotfix/login-crash',
|
|
584
|
-
from_branch: 'main'
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
// 2. Commit da correção
|
|
588
|
-
await gitCommitsTool.handler({
|
|
589
|
-
action: 'create',
|
|
590
|
-
repo: 'app-prod',
|
|
591
|
-
projectPath: 'C:\\\\Projetos\\\\app-prod',
|
|
592
|
-
provider: 'github',
|
|
593
|
-
message: 'Corrige crash no login quando senha é null - adiciona validação'
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
// 3. Merge direto
|
|
597
|
-
await gitBranchesTool.handler({
|
|
598
|
-
action: 'merge',
|
|
599
|
-
repo: 'app-prod',
|
|
600
|
-
projectPath: 'C:\\\\Projetos\\\\app-prod',
|
|
601
|
-
provider: 'github',
|
|
602
|
-
head: 'hotfix/login-crash',
|
|
603
|
-
base: 'main',
|
|
604
|
-
merge_method: 'merge'
|
|
605
|
-
});
|
|
606
|
-
\`\`\``;
|
|
607
|
-
case 'git-mcp://troubleshooting/common-issues':
|
|
608
|
-
return `# Problemas Comuns e Soluções
|
|
609
|
-
|
|
610
|
-
## 🔐 ERROS DE AUTENTICAÇÃO
|
|
611
|
-
|
|
612
|
-
### "Authentication failed"
|
|
613
|
-
\`\`\`bash
|
|
614
|
-
# Verificar tokens
|
|
615
|
-
echo "GITEA_TOKEN: \$GITEA_TOKEN"
|
|
616
|
-
echo "GITHUB_TOKEN: \$GITHUB_TOKEN"
|
|
617
|
-
\`\`\`
|
|
618
|
-
|
|
619
|
-
**Soluções:**
|
|
620
|
-
1. Verificar se tokens não expiraram
|
|
621
|
-
2. Confirmar permissões do token
|
|
622
|
-
3. Validar URLs dos servidores
|
|
623
|
-
|
|
624
|
-
## 📁 ERROS DE CAMINHO
|
|
625
|
-
|
|
626
|
-
### "projectPath is required"
|
|
627
|
-
\`\`\`typescript
|
|
628
|
-
// ✅ CORRETO
|
|
629
|
-
await gitCommitsTool.handler({
|
|
630
|
-
action: 'create',
|
|
631
|
-
projectPath: 'Z:\\\\Projetos\\\\meu-app',
|
|
632
|
-
provider: 'gitea',
|
|
633
|
-
message: 'Adiciona validação de formulário'
|
|
634
|
-
});
|
|
635
|
-
\`\`\`
|
|
636
|
-
|
|
637
|
-
## 🔄 ERROS DE GIT
|
|
638
|
-
|
|
639
|
-
### "Merge conflict"
|
|
640
|
-
\`\`\`typescript
|
|
641
|
-
// Reset para commit anterior
|
|
642
|
-
await gitResetTool.handler({
|
|
643
|
-
action: 'mixed',
|
|
644
|
-
projectPath: 'Z:\\\\Projetos\\\\meu-app',
|
|
645
|
-
provider: 'gitea',
|
|
646
|
-
commit_hash: 'HEAD~1'
|
|
647
|
-
});
|
|
648
|
-
\`\`\``;
|
|
649
|
-
default:
|
|
650
|
-
return '# Conteúdo não encontrado\n\nEste resource não possui conteúdo definido.';
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
exports.getResourceContent = getResourceContent;
|
|
654
|
-
/**
|
|
655
|
-
* VALIDAÇÃO GLOBAL - Project Path obrigatório
|
|
138
|
+
* Servidor MCP principal para Gitea
|
|
139
|
+
*
|
|
140
|
+
* RESPONSABILIDADES:
|
|
141
|
+
* - Inicializar servidor MCP
|
|
142
|
+
* - Registrar handlers para requests
|
|
143
|
+
* - Gerenciar ciclo de vida das tools
|
|
144
|
+
* - Tratar erros e validações
|
|
656
145
|
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
146
|
+
* ARQUITETURA:
|
|
147
|
+
* - Server MCP padrão com transport stdio
|
|
148
|
+
* - Handlers para list e call de tools
|
|
149
|
+
* - Tratamento centralizado de erros
|
|
150
|
+
*
|
|
151
|
+
* RECOMENDAÇÕES:
|
|
152
|
+
* - Use apenas uma instância por processo
|
|
153
|
+
* - Configure handlers antes de conectar
|
|
154
|
+
* - Implemente graceful shutdown
|
|
659
155
|
*/
|
|
660
|
-
const validateProjectPath = (args, toolName) => {
|
|
661
|
-
if (!args.projectPath) {
|
|
662
|
-
throw new Error(`❌ ERRO CRÍTICO: projectPath é obrigatório para a tool '${toolName}'.
|
|
663
|
-
|
|
664
|
-
📋 REGRAS ABSOLUTAS DO GIT MCP:
|
|
665
|
-
🚫 NUNCA executar operações fora do projectPath
|
|
666
|
-
🚫 NUNCA usar comandos git diretamente no terminal
|
|
667
|
-
🚫 TODAS as tools requerem projectPath
|
|
668
|
-
|
|
669
|
-
✅ CORRETO:
|
|
670
|
-
await ${toolName}.handler({
|
|
671
|
-
projectPath: 'Z:\\\\Projetos\\\\meu-projeto', // ← CAMINHO ABSOLUTO OBRIGATÓRIO
|
|
672
|
-
provider: 'gitea',
|
|
673
|
-
...outrosParâmetros
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
💡 DICAS:
|
|
677
|
-
- Use caminhos absolutos (ex: 'C:\\\\Projetos\\\\app' no Windows)
|
|
678
|
-
- Todas as operações ficam restritas ao projectPath e suas subpastas
|
|
679
|
-
- O projectPath é onde o repositório Git está localizado`);
|
|
680
|
-
}
|
|
681
|
-
// Validação adicional: verificar se é um caminho absoluto
|
|
682
|
-
if (!args.projectPath.includes(':\\') && !args.projectPath.startsWith('/')) {
|
|
683
|
-
console.warn(`⚠️ AVISO: projectPath '${args.projectPath}' não parece ser um caminho absoluto. Recomenda-se usar caminhos absolutos para evitar problemas.`);
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
exports.validateProjectPath = validateProjectPath;
|
|
687
|
-
const getPromptContent = (name, args) => {
|
|
688
|
-
// Função auxiliar para detectar project path automaticamente
|
|
689
|
-
const getCurrentProjectPath = () => {
|
|
690
|
-
return process.cwd() || 'Z:\\CurrentProject';
|
|
691
|
-
};
|
|
692
|
-
// Função auxiliar para determinar repo name baseado no project path
|
|
693
|
-
const getRepoName = () => {
|
|
694
|
-
const pathParts = getCurrentProjectPath().split(/[\/\\]/);
|
|
695
|
-
return pathParts[pathParts.length - 1] || 'current-project';
|
|
696
|
-
};
|
|
697
|
-
switch (name) {
|
|
698
|
-
case 'init-project':
|
|
699
|
-
return `# Inicialização Completa de Projeto
|
|
700
|
-
|
|
701
|
-
## 🚀 SETUP AUTOMÁTICO
|
|
702
|
-
|
|
703
|
-
**Projeto:** ${args.repoName}
|
|
704
|
-
**Provider:** ${args.provider}
|
|
705
|
-
**Path:** ${getCurrentProjectPath()}
|
|
706
|
-
|
|
707
|
-
## Workflow Completo
|
|
708
|
-
|
|
709
|
-
\`\`\`typescript
|
|
710
|
-
// 1. Criar repositório remoto
|
|
711
|
-
console.log('🔧 Criando repositório remoto...');
|
|
712
|
-
const repoResult = await gitRepositoriesTool.handler({
|
|
713
|
-
action: 'create',
|
|
714
|
-
name: '${args.repoName}',
|
|
715
|
-
description: '${args.description || 'Projeto criado via Git MCP'}',
|
|
716
|
-
private: ${args.private !== false},
|
|
717
|
-
auto_init: true,
|
|
718
|
-
provider: '${args.provider}'
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
// 2. Inicializar projeto local
|
|
722
|
-
console.log('🔧 Inicializando projeto local...');
|
|
723
|
-
const initResult = await gitInitializeTool.handler({
|
|
724
|
-
action: 'init',
|
|
725
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
726
|
-
provider: '${args.provider}',
|
|
727
|
-
message: 'Setup inicial do projeto ${args.repoName}'
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
// 3. Criar estrutura básica
|
|
731
|
-
await gitFilesTool.handler({
|
|
732
|
-
action: 'create',
|
|
733
|
-
repo: '${args.repoName}',
|
|
734
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
735
|
-
provider: '${args.provider}',
|
|
736
|
-
path: 'README.md',
|
|
737
|
-
content: \`# ${args.repoName}\\n\\n${args.description || 'Projeto criado via Git MCP'}\`,
|
|
738
|
-
message: 'Adiciona README.md básico'
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
console.log('🎉 Projeto configurado com sucesso!');
|
|
742
|
-
\`\`\``;
|
|
743
|
-
case 'sync-all':
|
|
744
|
-
return `# Sincronização Completa do Projeto
|
|
745
|
-
|
|
746
|
-
## 🔄 SINCRONIZAÇÃO AUTOMÁTICA
|
|
747
|
-
|
|
748
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
749
|
-
**Providers:** Todos configurados
|
|
750
|
-
|
|
751
|
-
## Workflow de Sincronização
|
|
752
|
-
|
|
753
|
-
\`\`\`typescript
|
|
754
|
-
// 1. Verificar status atual
|
|
755
|
-
const status = await gitUpdateProjectTool.handler({
|
|
756
|
-
action: 'status',
|
|
757
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
758
|
-
provider: 'gitea',
|
|
759
|
-
detailed: true
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
// 2. Sincronizar com todos os providers
|
|
763
|
-
const providers = ['gitea', 'github'];
|
|
764
|
-
for (const provider of providers) {
|
|
765
|
-
try {
|
|
766
|
-
await gitUpdateProjectTool.handler({
|
|
767
|
-
action: 'sync',
|
|
768
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
769
|
-
provider: provider,
|
|
770
|
-
message: '${args.message || 'Sincronização automática'}',
|
|
771
|
-
pullFirst: true
|
|
772
|
-
});
|
|
773
|
-
console.log(\`✅ Sincronizado com \${provider}\`);
|
|
774
|
-
} catch (error) {
|
|
775
|
-
console.log(\`❌ Erro na sincronização com \${provider}:\`, error.message);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
\`\`\``;
|
|
779
|
-
case 'commit-changes':
|
|
780
|
-
return `# Commit de Mudanças
|
|
781
|
-
|
|
782
|
-
## 💾 COMMIT AUTOMÁTICO
|
|
783
|
-
|
|
784
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
785
|
-
**Mensagem:** ${args.message || 'Atualização automática'}
|
|
786
|
-
|
|
787
|
-
## Workflow de Commit
|
|
788
|
-
|
|
789
|
-
\`\`\`typescript
|
|
790
|
-
// 1. Verificar mudanças atuais
|
|
791
|
-
const status = await gitUpdateProjectTool.handler({
|
|
792
|
-
action: 'status',
|
|
793
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
794
|
-
provider: 'gitea',
|
|
795
|
-
detailed: true
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
if (status.data.hasChanges) {
|
|
799
|
-
// 2. Commit das mudanças
|
|
800
|
-
await gitUpdateProjectTool.handler({
|
|
801
|
-
action: 'update',
|
|
802
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
803
|
-
provider: 'gitea',
|
|
804
|
-
message: '${args.message || 'Atualização automática'}'
|
|
805
|
-
});
|
|
806
|
-
console.log('✅ Mudanças commitadas!');
|
|
807
|
-
} else {
|
|
808
|
-
console.log('ℹ️ Nenhuma mudança para commitar');
|
|
809
|
-
}
|
|
810
|
-
\`\`\``;
|
|
811
|
-
case 'create-branch':
|
|
812
|
-
return `# Criação de Nova Branch
|
|
813
|
-
|
|
814
|
-
## 🌿 NOVA BRANCH
|
|
815
|
-
|
|
816
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
817
|
-
**Branch:** ${args.branchName || 'feature/nova-funcionalidade'}
|
|
818
|
-
|
|
819
|
-
## Workflow de Criação
|
|
820
|
-
|
|
821
|
-
\`\`\`typescript
|
|
822
|
-
// 1. Criar nova branch
|
|
823
|
-
await gitBranchesTool.handler({
|
|
824
|
-
action: 'create',
|
|
825
|
-
repo: '${getRepoName()}',
|
|
826
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
827
|
-
provider: 'gitea',
|
|
828
|
-
branch_name: '${args.branchName || 'feature/nova-funcionalidade'}',
|
|
829
|
-
from_branch: '${args.fromBranch || 'main'}'
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
console.log('✅ Branch criada com sucesso!');
|
|
833
|
-
\`\`\``;
|
|
834
|
-
case 'update-project':
|
|
835
|
-
const updateType = args.type || 'feat';
|
|
836
|
-
const updateScope = args.scope || '';
|
|
837
|
-
const isBreaking = args.breaking === true;
|
|
838
|
-
const customMessage = args.message || '';
|
|
839
|
-
// Construir mensagem elaborada baseada nos parâmetros
|
|
840
|
-
let commitMessage = '';
|
|
841
|
-
if (customMessage) {
|
|
842
|
-
commitMessage = customMessage;
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
const scopeStr = updateScope ? `(${updateScope})` : '';
|
|
846
|
-
const breakingStr = isBreaking ? '!' : '';
|
|
847
|
-
commitMessage = `${updateType}${scopeStr}${breakingStr}: atualização elaborada do projeto`;
|
|
848
|
-
}
|
|
849
|
-
return `# Atualização Elaborada do Projeto
|
|
850
|
-
|
|
851
|
-
## 🚀 UPDATE MULTI-MUDANÇAS
|
|
852
|
-
|
|
853
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
854
|
-
**Tipo:** ${updateType}
|
|
855
|
-
**Escopo:** ${updateScope || 'geral'}
|
|
856
|
-
**Breaking:** ${isBreaking}
|
|
857
|
-
**Arquivos:** ${args.files ? JSON.stringify(args.files) : 'todos'}
|
|
858
|
-
|
|
859
|
-
## Workflow de Atualização Completa
|
|
860
|
-
|
|
861
|
-
\`\`\`typescript
|
|
862
|
-
// 1. Verificar status atual detalhado
|
|
863
|
-
console.log('📊 Verificando status completo do projeto...');
|
|
864
|
-
const status = await gitUpdateProjectTool.handler({
|
|
865
|
-
action: 'status',
|
|
866
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
867
|
-
provider: 'gitea',
|
|
868
|
-
detailed: true
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
console.log('📋 Status atual:', status);
|
|
872
|
-
|
|
873
|
-
// 2. Verificar mudanças específicas por arquivo
|
|
874
|
-
${args.files ? `
|
|
875
|
-
// Verificar arquivos específicos
|
|
876
|
-
const specificFiles = ${JSON.stringify(args.files)};
|
|
877
|
-
console.log('📁 Arquivos específicos:', specificFiles);
|
|
878
|
-
|
|
879
|
-
// Verificar se arquivos existem e têm mudanças
|
|
880
|
-
for (const file of specificFiles) {
|
|
881
|
-
try {
|
|
882
|
-
const fileStatus = await gitFilesTool.handler({
|
|
883
|
-
action: 'get',
|
|
884
|
-
repo: '${getRepoName()}',
|
|
885
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
886
|
-
provider: 'gitea',
|
|
887
|
-
path: file
|
|
888
|
-
});
|
|
889
|
-
console.log(\`✅ Arquivo \${file}: encontrado\`);
|
|
890
|
-
} catch (error) {
|
|
891
|
-
console.log(\`⚠️ Arquivo \${file}: \${error.message}\`);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
` : ''}
|
|
895
|
-
|
|
896
|
-
// 3. Preparar atualização elaborada
|
|
897
|
-
console.log('🔧 Preparando atualização elaborada...');
|
|
898
|
-
|
|
899
|
-
// Adicionar arquivos específicos ou todos
|
|
900
|
-
const addResult = await gitUpdateProjectTool.handler({
|
|
901
|
-
action: 'update',
|
|
902
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
903
|
-
provider: 'gitea',
|
|
904
|
-
message: '${commitMessage}',
|
|
905
|
-
files: ${args.files ? JSON.stringify(args.files) : 'undefined'}
|
|
906
|
-
});
|
|
907
|
-
|
|
908
|
-
console.log('✅ Arquivos preparados para commit');
|
|
909
|
-
|
|
910
|
-
// 4. Executar commit com contexto detalhado
|
|
911
|
-
console.log('💾 Executando commit elaborado...');
|
|
912
|
-
const commitResult = await gitCommitsTool.handler({
|
|
913
|
-
action: 'create',
|
|
914
|
-
repo: '${getRepoName()}',
|
|
915
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
916
|
-
provider: 'gitea',
|
|
917
|
-
message: '${commitMessage}'
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
console.log('✅ Commit realizado com sucesso!');
|
|
921
|
-
console.log(\`📋 Tipo: \${'${updateType}'}\`);
|
|
922
|
-
console.log(\`📋 Escopo: \${'${updateScope || 'geral'}'}\`);
|
|
923
|
-
console.log(\`📋 Breaking: \${${isBreaking}}\`);
|
|
924
|
-
console.log(\`📋 Mensagem: \${'${commitMessage}'}\`);
|
|
925
|
-
|
|
926
|
-
// 5. Sincronizar com remoto (opcional mas recomendado)
|
|
927
|
-
console.log('⬆️ Sincronizando com remoto...');
|
|
928
|
-
try {
|
|
929
|
-
await gitCommitsTool.handler({
|
|
930
|
-
action: 'push',
|
|
931
|
-
repo: '${getRepoName()}',
|
|
932
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
933
|
-
provider: 'gitea',
|
|
934
|
-
branch: 'main'
|
|
935
|
-
});
|
|
936
|
-
console.log('✅ Sincronizado com sucesso!');
|
|
937
|
-
} catch (error) {
|
|
938
|
-
console.log('⚠️ Erro na sincronização:', error.message);
|
|
939
|
-
console.log('💡 Execute manualmente: git push');
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// 6. Verificar resultado final
|
|
943
|
-
console.log('📊 Verificando resultado final...');
|
|
944
|
-
const finalStatus = await gitUpdateProjectTool.handler({
|
|
945
|
-
action: 'status',
|
|
946
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
947
|
-
provider: 'gitea',
|
|
948
|
-
detailed: true
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
console.log('🎉 Atualização elaborada concluída!');
|
|
952
|
-
\`\`\`
|
|
953
|
-
|
|
954
|
-
## 📋 EXEMPLOS DE USO
|
|
955
|
-
|
|
956
|
-
### Atualização Básica
|
|
957
|
-
\`\`\`bash
|
|
958
|
-
prompts/get name="update-project" arguments={
|
|
959
|
-
"type": "feat",
|
|
960
|
-
"message": "Implementa sistema completo de autenticação com JWT"
|
|
961
|
-
}
|
|
962
|
-
\`\`\`
|
|
963
|
-
|
|
964
|
-
### Atualização com Escopo
|
|
965
|
-
\`\`\`bash
|
|
966
|
-
prompts/get name="update-project" arguments={
|
|
967
|
-
"type": "refactor",
|
|
968
|
-
"scope": "api",
|
|
969
|
-
"message": "Refatora endpoints de autenticação para melhor performance"
|
|
970
|
-
}
|
|
971
|
-
\`\`\`
|
|
972
|
-
|
|
973
|
-
### Atualização com Breaking Changes
|
|
974
|
-
\`\`\`bash
|
|
975
|
-
prompts/get name="update-project" arguments={
|
|
976
|
-
"type": "feat",
|
|
977
|
-
"breaking": true,
|
|
978
|
-
"message": "BREAKING: Muda estrutura da API de autenticação"
|
|
979
|
-
}
|
|
980
|
-
\`\`\`
|
|
981
|
-
|
|
982
|
-
### Atualização Específica de Arquivos
|
|
983
|
-
\`\`\`bash
|
|
984
|
-
prompts/get name="update-project" arguments={
|
|
985
|
-
"type": "fix",
|
|
986
|
-
"files": ["src/auth.js", "src/login.js"],
|
|
987
|
-
"message": "Corrige bugs críticos nos módulos de autenticação"
|
|
988
|
-
}
|
|
989
|
-
\`\`\`
|
|
990
|
-
|
|
991
|
-
## 🎯 TIPOS DE ATUALIZAÇÃO
|
|
992
|
-
- \`feat\` - Nova funcionalidade
|
|
993
|
-
- \`fix\` - Correção de bug
|
|
994
|
-
- \`docs\` - Documentação
|
|
995
|
-
- \`refactor\` - Refatoração
|
|
996
|
-
- \`test\` - Testes
|
|
997
|
-
- \`style\` - Estilo/formatação
|
|
998
|
-
- \`chore\` - Manutenção
|
|
999
|
-
|
|
1000
|
-
## 💡 VANTAGENS
|
|
1001
|
-
- ✅ **Contexto rico** com tipos e escopo
|
|
1002
|
-
- ✅ **Mensagens estruturadas** seguindo convenções
|
|
1003
|
-
- ✅ **Suporte a breaking changes**
|
|
1004
|
-
- ✅ **Filtragem por arquivos específicos**
|
|
1005
|
-
- ✅ **Sincronização automática**
|
|
1006
|
-
- ✅ **Verificação completa antes/depois**`;
|
|
1007
|
-
case 'deploy-release':
|
|
1008
|
-
return `# Deploy de Release
|
|
1009
|
-
|
|
1010
|
-
## 🚀 NOVA RELEASE
|
|
1011
|
-
|
|
1012
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1013
|
-
**Versão:** ${args.version || 'v1.0.0'}
|
|
1014
|
-
|
|
1015
|
-
## Workflow de Deploy
|
|
1016
|
-
|
|
1017
|
-
\`\`\`typescript
|
|
1018
|
-
// 1. Criar release
|
|
1019
|
-
await gitReleasesTool.handler({
|
|
1020
|
-
action: 'create',
|
|
1021
|
-
repo: '${getRepoName()}',
|
|
1022
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1023
|
-
provider: 'gitea',
|
|
1024
|
-
tag_name: '${args.version || 'v1.0.0'}',
|
|
1025
|
-
name: '${args.title || 'Nova versão'}',
|
|
1026
|
-
body: '${args.notes || 'Release publicada automaticamente'}',
|
|
1027
|
-
draft: false,
|
|
1028
|
-
prerelease: ${args.prerelease === true}
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
console.log('✅ Release criada com sucesso!');
|
|
1032
|
-
\`\`\``;
|
|
1033
|
-
case 'backup-project':
|
|
1034
|
-
return `# Backup Completo do Projeto
|
|
1035
|
-
|
|
1036
|
-
## 💾 BACKUP AUTOMÁTICO
|
|
1037
|
-
|
|
1038
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1039
|
-
**Formato:** ${args.format || 'zip'}
|
|
1040
|
-
|
|
1041
|
-
## Workflow de Backup
|
|
1042
|
-
|
|
1043
|
-
\`\`\`typescript
|
|
1044
|
-
// 1. Criar arquivo de backup
|
|
1045
|
-
await gitArchiveTool.handler({
|
|
1046
|
-
action: 'create',
|
|
1047
|
-
repo: '${getRepoName()}',
|
|
1048
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1049
|
-
provider: 'gitea',
|
|
1050
|
-
archive_path: '${getCurrentProjectPath()}/backup.${args.format || 'zip'}',
|
|
1051
|
-
commit_or_tree: 'HEAD',
|
|
1052
|
-
format: '${args.format || 'zip'}'
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
console.log('✅ Backup criado com sucesso!');
|
|
1056
|
-
\`\`\``;
|
|
1057
|
-
case 'health-check':
|
|
1058
|
-
return `# Verificação de Saúde do Projeto
|
|
1059
|
-
|
|
1060
|
-
## 🏥 HEALTH CHECK AUTOMÁTICO
|
|
1061
|
-
|
|
1062
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1063
|
-
**Provider:** ${args.provider || 'both'}
|
|
1064
|
-
|
|
1065
|
-
## Workflow de Verificação
|
|
1066
|
-
|
|
1067
|
-
\`\`\`typescript
|
|
1068
|
-
// 1. Verificar status do projeto
|
|
1069
|
-
const status = await gitUpdateProjectTool.handler({
|
|
1070
|
-
action: 'status',
|
|
1071
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1072
|
-
provider: 'gitea',
|
|
1073
|
-
detailed: ${args.detailed !== false}
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
// 2. Verificar conectividade
|
|
1077
|
-
const providers = ${args.provider === 'gitea' ? "['gitea']" : args.provider === 'github' ? "['github']" : "['gitea', 'github']"};
|
|
1078
|
-
for (const provider of providers) {
|
|
1079
|
-
try {
|
|
1080
|
-
await gitRepositoriesTool.handler({
|
|
1081
|
-
action: 'list',
|
|
1082
|
-
provider: provider,
|
|
1083
|
-
page: 1,
|
|
1084
|
-
limit: 1
|
|
1085
|
-
});
|
|
1086
|
-
console.log(\`✅ \${provider}: Conectado\`);
|
|
1087
|
-
} catch (error) {
|
|
1088
|
-
console.log(\`❌ \${provider}: Problema\`, error.message);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
console.log('🏥 Health check concluído!');
|
|
1093
|
-
\`\`\``;
|
|
1094
|
-
case 'setup-workflow':
|
|
1095
|
-
return `# Configuração de Workflow
|
|
1096
|
-
|
|
1097
|
-
## ⚡ WORKFLOW AUTOMÁTICO
|
|
1098
|
-
|
|
1099
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1100
|
-
**Tipo:** ${args.workflow || 'feature'}
|
|
1101
|
-
**Branch:** ${args.branch || 'feature/workflow'}
|
|
1102
|
-
|
|
1103
|
-
## Workflow de Desenvolvimento
|
|
1104
|
-
|
|
1105
|
-
\`\`\`typescript
|
|
1106
|
-
// 1. Criar branch para o workflow
|
|
1107
|
-
await gitBranchesTool.handler({
|
|
1108
|
-
action: 'create',
|
|
1109
|
-
repo: '${getRepoName()}',
|
|
1110
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1111
|
-
provider: 'gitea',
|
|
1112
|
-
branch_name: '${args.branch || 'feature/workflow'}',
|
|
1113
|
-
from_branch: 'main'
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
// 2. Criar issue de acompanhamento
|
|
1117
|
-
await gitIssuesTool.handler({
|
|
1118
|
-
action: 'create',
|
|
1119
|
-
repo: '${getRepoName()}',
|
|
1120
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1121
|
-
provider: 'gitea',
|
|
1122
|
-
title: '${args.workflow || 'feature'} em desenvolvimento',
|
|
1123
|
-
body: 'Workflow configurado automaticamente',
|
|
1124
|
-
labels: '${args.workflow || 'feature'}'
|
|
1125
|
-
});
|
|
1126
|
-
|
|
1127
|
-
console.log('✅ Workflow configurado!');
|
|
1128
|
-
\`\`\``;
|
|
1129
|
-
case 'cleanup-project':
|
|
1130
|
-
return `# Limpeza e Manutenção do Projeto
|
|
1131
|
-
|
|
1132
|
-
## 🧹 CLEANUP AUTOMÁTICO
|
|
1133
|
-
|
|
1134
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1135
|
-
**Tipo:** ${args.type || 'all'}
|
|
1136
|
-
|
|
1137
|
-
## Workflow de Limpeza
|
|
1138
|
-
|
|
1139
|
-
\`\`\`typescript
|
|
1140
|
-
// 1. Executar limpeza baseada no tipo
|
|
1141
|
-
${args.type === 'branches' || args.type === 'all' ? `
|
|
1142
|
-
// Limpar branches antigas
|
|
1143
|
-
const branches = await gitBranchesTool.handler({
|
|
1144
|
-
action: 'list',
|
|
1145
|
-
repo: '${getRepoName()}',
|
|
1146
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1147
|
-
provider: 'gitea',
|
|
1148
|
-
page: 1,
|
|
1149
|
-
limit: 50
|
|
1150
|
-
});
|
|
1151
|
-
console.log('🗑️ Branches antigas removidas');
|
|
1152
|
-
` : ''}
|
|
1153
|
-
|
|
1154
|
-
${args.type === 'cache' || args.type === 'all' ? `
|
|
1155
|
-
// Limpar arquivos temporários
|
|
1156
|
-
console.log('💾 Cache limpo');
|
|
1157
|
-
` : ''}
|
|
1158
|
-
|
|
1159
|
-
${args.type === 'logs' || args.type === 'all' ? `
|
|
1160
|
-
// Limpar logs antigos
|
|
1161
|
-
console.log('📋 Logs antigos removidos');
|
|
1162
|
-
` : ''}
|
|
1163
|
-
|
|
1164
|
-
console.log('✅ Limpeza concluída!');
|
|
1165
|
-
\`\`\``;
|
|
1166
|
-
case 'merge-branch':
|
|
1167
|
-
return `# Merge de Branch
|
|
1168
|
-
|
|
1169
|
-
## 🔀 MERGE AUTOMÁTICO
|
|
1170
|
-
|
|
1171
|
-
**Projeto:** ${getCurrentProjectPath()}
|
|
1172
|
-
**Branch:** ${args.branchName || 'feature/branch'}
|
|
1173
|
-
|
|
1174
|
-
## Workflow de Merge
|
|
1175
|
-
|
|
1176
|
-
\`\`\`typescript
|
|
1177
|
-
// 1. Fazer merge
|
|
1178
|
-
await gitBranchesTool.handler({
|
|
1179
|
-
action: 'merge',
|
|
1180
|
-
repo: '${getRepoName()}',
|
|
1181
|
-
projectPath: '${getCurrentProjectPath()}',
|
|
1182
|
-
provider: 'gitea',
|
|
1183
|
-
head: '${args.branchName || 'feature/branch'}',
|
|
1184
|
-
base: 'main',
|
|
1185
|
-
merge_method: '${args.mergeMethod || 'merge'}'
|
|
1186
|
-
});
|
|
1187
|
-
|
|
1188
|
-
console.log('✅ Merge realizado com sucesso!');
|
|
1189
|
-
\`\`\``;
|
|
1190
|
-
default:
|
|
1191
|
-
return `# Prompt não encontrado
|
|
1192
|
-
|
|
1193
|
-
**Prompt solicitado:** \`${name}\`
|
|
1194
|
-
|
|
1195
|
-
## 📋 PROMPTS DISPONÍVEIS:
|
|
1196
|
-
- \`init-project\` - Inicializar novo projeto
|
|
1197
|
-
- \`sync-all\` - Sincronizar com todos providers
|
|
1198
|
-
- \`commit-changes\` - Commitar mudanças
|
|
1199
|
-
- \`update-project\` - Atualização elaborada com múltiplas mudanças
|
|
1200
|
-
- \`create-branch\` - Criar nova branch
|
|
1201
|
-
- \`merge-branch\` - Fazer merge de branch
|
|
1202
|
-
- \`deploy-release\` - Criar e publicar release
|
|
1203
|
-
- \`health-check\` - Verificar saúde do projeto
|
|
1204
|
-
- \`setup-workflow\` - Configurar workflow de desenvolvimento
|
|
1205
|
-
- \`cleanup-project\` - Limpeza e manutenção
|
|
1206
|
-
|
|
1207
|
-
## 💡 DICAS
|
|
1208
|
-
- Todos os prompts detectam automaticamente o project path atual
|
|
1209
|
-
- Apenas o provider é obrigatório (github, gitea, both)
|
|
1210
|
-
- Parâmetros opcionais têm valores padrão inteligentes`;
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
156
|
class GiteaMCPServer {
|
|
1214
157
|
server;
|
|
1215
158
|
constructor() {
|
|
@@ -1257,8 +200,6 @@ class GiteaMCPServer {
|
|
|
1257
200
|
throw new Error(`Tool '${name}' not found`);
|
|
1258
201
|
}
|
|
1259
202
|
try {
|
|
1260
|
-
// ✅ VALIDAÇÃO GLOBAL: projectPath obrigatório para TODAS as tools
|
|
1261
|
-
validateProjectPath(args, name);
|
|
1262
203
|
// Executa o handler da tool
|
|
1263
204
|
const result = await tool.handler(args || {});
|
|
1264
205
|
return {
|
|
@@ -1288,32 +229,6 @@ class GiteaMCPServer {
|
|
|
1288
229
|
};
|
|
1289
230
|
}
|
|
1290
231
|
});
|
|
1291
|
-
// Handler para listar resources disponíveis
|
|
1292
|
-
this.server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => {
|
|
1293
|
-
return {
|
|
1294
|
-
resources: resources.map(resource => ({
|
|
1295
|
-
uri: resource.uri,
|
|
1296
|
-
name: resource.name,
|
|
1297
|
-
description: resource.description,
|
|
1298
|
-
mimeType: resource.mimeType
|
|
1299
|
-
}))
|
|
1300
|
-
};
|
|
1301
|
-
});
|
|
1302
|
-
// Handler para ler conteúdo de resources
|
|
1303
|
-
this.server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
|
|
1304
|
-
const { uri } = request.params;
|
|
1305
|
-
const content = getResourceContent(uri);
|
|
1306
|
-
return {
|
|
1307
|
-
contents: [
|
|
1308
|
-
{
|
|
1309
|
-
uri: uri,
|
|
1310
|
-
mimeType: 'text/markdown',
|
|
1311
|
-
text: content
|
|
1312
|
-
}
|
|
1313
|
-
]
|
|
1314
|
-
};
|
|
1315
|
-
});
|
|
1316
|
-
// Handlers de prompts removidos - apenas tools e resources disponíveis
|
|
1317
232
|
}
|
|
1318
233
|
/**
|
|
1319
234
|
* Inicializa e executa o servidor MCP
|