@andrebuzeli/git-mcp 2.27.4 → 2.28.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.
- package/dist/client.d.ts +306 -306
- package/dist/client.js +298 -298
- package/dist/config.d.ts +310 -310
- package/dist/config.js +392 -392
- package/dist/index.d.ts +22 -22
- package/dist/index.js +89 -89
- package/dist/providers/base-provider.d.ts +160 -156
- package/dist/providers/base-provider.d.ts.map +1 -1
- package/dist/providers/base-provider.js +274 -260
- package/dist/providers/base-provider.js.map +1 -1
- package/dist/providers/error-handler.d.ts +50 -50
- package/dist/providers/error-handler.js +175 -175
- package/dist/providers/gitea-provider.d.ts +97 -97
- package/dist/providers/gitea-provider.js +1001 -1001
- package/dist/providers/github-provider.d.ts +104 -104
- package/dist/providers/github-provider.js +1234 -1234
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.js +40 -40
- package/dist/providers/provider-factory.d.ts +74 -74
- package/dist/providers/provider-factory.js +311 -311
- package/dist/providers/types.d.ts +318 -298
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js +6 -6
- package/dist/server.d.ts +76 -76
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +306 -305
- package/dist/server.js.map +1 -1
- package/dist/tools/gh-actions.d.ts +252 -252
- package/dist/tools/gh-actions.js +389 -389
- package/dist/tools/gh-analytics.d.ts +263 -263
- package/dist/tools/gh-analytics.js +401 -401
- package/dist/tools/gh-code-review.d.ts +304 -304
- package/dist/tools/gh-code-review.js +512 -512
- package/dist/tools/gh-codespaces.d.ts +138 -138
- package/dist/tools/gh-codespaces.js +282 -282
- package/dist/tools/gh-deployments.d.ts +300 -300
- package/dist/tools/gh-deployments.js +367 -367
- package/dist/tools/gh-gists.d.ts +174 -174
- package/dist/tools/gh-gists.js +321 -321
- package/dist/tools/gh-projects.d.ts +205 -205
- package/dist/tools/gh-projects.js +358 -358
- package/dist/tools/gh-security.d.ts +274 -274
- package/dist/tools/gh-security.js +395 -395
- package/dist/tools/gh-sync.d.ts +213 -213
- package/dist/tools/gh-sync.js +378 -378
- package/dist/tools/gh-workflows.d.ts +290 -290
- package/dist/tools/gh-workflows.js +432 -432
- package/dist/tools/git-archive.d.ts +165 -165
- package/dist/tools/git-archive.js +233 -233
- package/dist/tools/git-branches.d.ts +430 -430
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +627 -530
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-bundle.d.ts +171 -171
- package/dist/tools/git-bundle.js +241 -241
- package/dist/tools/git-cherry-pick.d.ts +158 -158
- package/dist/tools/git-cherry-pick.js +224 -224
- package/dist/tools/git-commits.d.ts +485 -485
- package/dist/tools/git-commits.d.ts.map +1 -1
- package/dist/tools/git-commits.js +735 -625
- package/dist/tools/git-commits.js.map +1 -1
- package/dist/tools/git-config.d.ts +140 -140
- package/dist/tools/git-config.js +268 -268
- package/dist/tools/git-files.d.ts +486 -486
- package/dist/tools/git-files.js +607 -607
- package/dist/tools/git-issues.d.ts +571 -571
- package/dist/tools/git-issues.d.ts.map +1 -1
- package/dist/tools/git-issues.js +740 -693
- package/dist/tools/git-issues.js.map +1 -1
- package/dist/tools/git-pulls.d.ts +694 -694
- package/dist/tools/git-pulls.js +732 -732
- package/dist/tools/git-rebase.d.ts +137 -137
- package/dist/tools/git-rebase.js +213 -213
- package/dist/tools/git-releases.d.ts +487 -487
- package/dist/tools/git-releases.js +557 -557
- package/dist/tools/git-remote.d.ts +138 -138
- package/dist/tools/git-remote.js +274 -274
- package/dist/tools/git-repositories.d.ts +483 -483
- package/dist/tools/git-repositories.js +640 -640
- package/dist/tools/git-reset.d.ts +130 -130
- package/dist/tools/git-reset.js +223 -223
- package/dist/tools/git-revert.d.ts +149 -149
- package/dist/tools/git-revert.js +198 -198
- package/dist/tools/git-stash.d.ts +140 -140
- package/dist/tools/git-stash.js +269 -269
- package/dist/tools/git-submodule.d.ts +152 -152
- package/dist/tools/git-submodule.js +289 -289
- package/dist/tools/git-sync.d.ts +178 -166
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +312 -117
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-tags.d.ts +411 -411
- package/dist/tools/git-tags.js +485 -485
- package/dist/tools/git-webhooks.d.ts +470 -482
- package/dist/tools/git-webhooks.d.ts.map +1 -1
- package/dist/tools/git-webhooks.js +543 -555
- package/dist/tools/git-webhooks.js.map +1 -1
- package/dist/tools/git-worktree.d.ts +159 -159
- package/dist/tools/git-worktree.js +269 -269
- package/dist/tools/repositories.d.ts +405 -405
- package/dist/tools/repositories.js +569 -569
- package/dist/tools/users.d.ts +372 -372
- package/dist/tools/users.js +499 -499
- package/dist/tools/validator.d.ts +170 -170
- package/dist/tools/validator.js +194 -194
- package/dist/tools/version-control.d.ts +136 -136
- package/dist/tools/version-control.js +164 -164
- package/dist/utils/terminal-controller.d.ts +80 -80
- package/dist/utils/terminal-controller.js +345 -345
- package/dist/utils/user-detection.d.ts +24 -24
- package/dist/utils/user-detection.js +53 -53
- package/package.json +59 -59
package/dist/tools/git-remote.js
CHANGED
|
@@ -1,275 +1,275 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitRemoteTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
-
/**
|
|
7
|
-
* Tool: git-remote
|
|
8
|
-
*
|
|
9
|
-
* DESCRIÇÃO:
|
|
10
|
-
* Gerenciamento de remotes Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
-
*
|
|
12
|
-
* FUNCIONALIDADES:
|
|
13
|
-
* - Adicionar remote
|
|
14
|
-
* - Remover remote
|
|
15
|
-
* - Renomear remote
|
|
16
|
-
* - Mostrar remotes
|
|
17
|
-
* - Definir URL do remote
|
|
18
|
-
* - Prune remotes
|
|
19
|
-
*
|
|
20
|
-
* USO:
|
|
21
|
-
* - Para configurar repositórios remotos
|
|
22
|
-
* - Para gerenciar múltiplos remotes
|
|
23
|
-
* - Para sincronizar com diferentes servidores
|
|
24
|
-
* - Para configurar upstream
|
|
25
|
-
*
|
|
26
|
-
* RECOMENDAÇÕES:
|
|
27
|
-
* - Use 'origin' como remote principal
|
|
28
|
-
* - Configure upstream para branches
|
|
29
|
-
* - Mantenha URLs atualizadas
|
|
30
|
-
*/
|
|
31
|
-
const GitRemoteInputSchema = zod_1.z.object({
|
|
32
|
-
action: zod_1.z.enum(['add', 'remove', 'rename', 'show', 'set-url', 'prune']),
|
|
33
|
-
// owner: obtido automaticamente do provider,
|
|
34
|
-
repo: zod_1.z.string(),
|
|
35
|
-
provider: zod_1.z.enum(['gitea', 'github']).describe('Provider to use (gitea or github)'),
|
|
36
|
-
projectPath: zod_1.z.string().describe('Local project path for git operations'),
|
|
37
|
-
// Para add/set-url
|
|
38
|
-
remote_name: zod_1.z.string().optional(),
|
|
39
|
-
remote_url: zod_1.z.string().optional(),
|
|
40
|
-
// Para remove/rename/show
|
|
41
|
-
remote: zod_1.z.string().optional(),
|
|
42
|
-
// Para rename
|
|
43
|
-
new_name: zod_1.z.string().optional(),
|
|
44
|
-
// Para prune
|
|
45
|
-
remote_to_prune: zod_1.z.string().optional(),
|
|
46
|
-
});
|
|
47
|
-
const GitRemoteResultSchema = zod_1.z.object({
|
|
48
|
-
success: zod_1.z.boolean(),
|
|
49
|
-
action: zod_1.z.string(),
|
|
50
|
-
message: zod_1.z.string(),
|
|
51
|
-
data: zod_1.z.any().optional(),
|
|
52
|
-
error: zod_1.z.string().optional()
|
|
53
|
-
});
|
|
54
|
-
exports.gitRemoteTool = {
|
|
55
|
-
name: 'git-remote',
|
|
56
|
-
description: 'tool: Gerencia repositórios remotos Git para sincronização\n──────────────\naction add: adiciona novo remote\naction add requires: repo, remote_name, remote_url, provider\n───────────────\naction remove: remove remote\naction remove requires: repo, remote, provider\n───────────────\naction rename: renomeia remote\naction rename requires: repo, remote, new_name, provider\n───────────────\naction show: mostra informações do remote\naction show requires: repo, remote, provider\n───────────────\naction set-url: atualiza URL do remote\naction set-url requires: repo, remote, remote_url, provider\n───────────────\naction prune: remove referências obsoletas\naction prune requires: repo, remote_to_prune, provider',
|
|
57
|
-
inputSchema: {
|
|
58
|
-
type: 'object',
|
|
59
|
-
properties: {
|
|
60
|
-
action: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
enum: ['add', 'remove', 'rename', 'show', 'set-url', 'prune'],
|
|
63
|
-
description: 'Action to perform on remotes'
|
|
64
|
-
},
|
|
65
|
-
owner: { type: 'string', description: 'Repository owner' },
|
|
66
|
-
repo: { type: 'string', description: 'Repository name' },
|
|
67
|
-
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
68
|
-
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
69
|
-
remote_name: { type: 'string', description: 'Remote name' },
|
|
70
|
-
remote_url: { type: 'string', description: 'Remote URL' },
|
|
71
|
-
remote: { type: 'string', description: 'Remote to operate on' },
|
|
72
|
-
new_name: { type: 'string', description: 'New remote name' },
|
|
73
|
-
remote_to_prune: { type: 'string', description: 'Remote to prune' }
|
|
74
|
-
},
|
|
75
|
-
required: ['action', 'repo', 'provider', 'projectPath']
|
|
76
|
-
},
|
|
77
|
-
async handler(input) {
|
|
78
|
-
try {
|
|
79
|
-
const validatedInput = GitRemoteInputSchema.parse(input);
|
|
80
|
-
switch (validatedInput.action) {
|
|
81
|
-
case 'add':
|
|
82
|
-
return await this.add(validatedInput);
|
|
83
|
-
case 'remove':
|
|
84
|
-
return await this.remove(validatedInput);
|
|
85
|
-
case 'rename':
|
|
86
|
-
return await this.rename(validatedInput);
|
|
87
|
-
case 'show':
|
|
88
|
-
return await this.show(validatedInput);
|
|
89
|
-
case 'set-url':
|
|
90
|
-
return await this.setUrl(validatedInput);
|
|
91
|
-
case 'prune':
|
|
92
|
-
return await this.prune(validatedInput);
|
|
93
|
-
default:
|
|
94
|
-
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
action: input.action,
|
|
101
|
-
message: 'Erro na operação de remote',
|
|
102
|
-
error: error instanceof Error ? error.message : String(error)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
async add(params) {
|
|
107
|
-
try {
|
|
108
|
-
if (!params.remote_name || !params.remote_url) {
|
|
109
|
-
throw new Error('remote_name e remote_url são obrigatórios para add');
|
|
110
|
-
}
|
|
111
|
-
const gitCommand = `remote add ${params.remote_name} ${params.remote_url}`;
|
|
112
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando remote');
|
|
113
|
-
if (result.exitCode !== 0) {
|
|
114
|
-
throw new Error(`Falha ao adicionar remote: ${result.output}`);
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
success: true,
|
|
118
|
-
action: 'add',
|
|
119
|
-
message: `Remote ${params.remote_name} adicionado com sucesso`,
|
|
120
|
-
data: {
|
|
121
|
-
remote_name: params.remote_name,
|
|
122
|
-
remote_url: params.remote_url,
|
|
123
|
-
output: result.output
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
throw new Error(`Falha ao adicionar remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
async remove(params) {
|
|
132
|
-
try {
|
|
133
|
-
if (!params.remote) {
|
|
134
|
-
throw new Error('remote é obrigatório para remove');
|
|
135
|
-
}
|
|
136
|
-
const gitCommand = `remote remove ${params.remote}`;
|
|
137
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo remote');
|
|
138
|
-
if (result.exitCode !== 0) {
|
|
139
|
-
throw new Error(`Falha ao remover remote: ${result.output}`);
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
success: true,
|
|
143
|
-
action: 'remove',
|
|
144
|
-
message: `Remote ${params.remote} removido com sucesso`,
|
|
145
|
-
data: {
|
|
146
|
-
remote: params.remote,
|
|
147
|
-
output: result.output
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
throw new Error(`Falha ao remover remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
async rename(params) {
|
|
156
|
-
try {
|
|
157
|
-
if (!params.remote || !params.new_name) {
|
|
158
|
-
throw new Error('remote e new_name são obrigatórios para rename');
|
|
159
|
-
}
|
|
160
|
-
const gitCommand = `remote rename ${params.remote} ${params.new_name}`;
|
|
161
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Renomeando remote');
|
|
162
|
-
if (result.exitCode !== 0) {
|
|
163
|
-
throw new Error(`Falha ao renomear remote: ${result.output}`);
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
success: true,
|
|
167
|
-
action: 'rename',
|
|
168
|
-
message: `Remote ${params.remote} renomeado para ${params.new_name} com sucesso`,
|
|
169
|
-
data: {
|
|
170
|
-
old_name: params.remote,
|
|
171
|
-
new_name: params.new_name,
|
|
172
|
-
output: result.output
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
throw new Error(`Falha ao renomear remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
async show(params) {
|
|
181
|
-
try {
|
|
182
|
-
if (!params.remote) {
|
|
183
|
-
// Listar todos os remotes
|
|
184
|
-
const gitCommand = `remote -v`;
|
|
185
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Listando remotes');
|
|
186
|
-
if (result.exitCode !== 0) {
|
|
187
|
-
throw new Error(`Falha ao listar remotes: ${result.output}`);
|
|
188
|
-
}
|
|
189
|
-
const remotes = result.output.split('\n')
|
|
190
|
-
.filter(line => line.trim())
|
|
191
|
-
.map(line => {
|
|
192
|
-
const [name, url] = line.split('\t');
|
|
193
|
-
return { name, url };
|
|
194
|
-
});
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
action: 'show',
|
|
198
|
-
message: 'Remotes listados com sucesso',
|
|
199
|
-
data: {
|
|
200
|
-
remotes,
|
|
201
|
-
output: result.output
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
// Mostrar remote específico
|
|
207
|
-
const gitCommand = `remote show ${params.remote}`;
|
|
208
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Mostrando remote');
|
|
209
|
-
if (result.exitCode !== 0) {
|
|
210
|
-
throw new Error(`Falha ao mostrar remote: ${result.output}`);
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
success: true,
|
|
214
|
-
action: 'show',
|
|
215
|
-
message: `Remote ${params.remote} mostrado com sucesso`,
|
|
216
|
-
data: {
|
|
217
|
-
remote: params.remote,
|
|
218
|
-
output: result.output
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
throw new Error(`Falha ao mostrar remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
async setUrl(params) {
|
|
228
|
-
try {
|
|
229
|
-
if (!params.remote || !params.remote_url) {
|
|
230
|
-
throw new Error('remote e remote_url são obrigatórios para set-url');
|
|
231
|
-
}
|
|
232
|
-
const gitCommand = `remote set-url ${params.remote} ${params.remote_url}`;
|
|
233
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Definindo URL do remote');
|
|
234
|
-
if (result.exitCode !== 0) {
|
|
235
|
-
throw new Error(`Falha ao definir URL do remote: ${result.output}`);
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
success: true,
|
|
239
|
-
action: 'set-url',
|
|
240
|
-
message: `URL do remote ${params.remote} definida com sucesso`,
|
|
241
|
-
data: {
|
|
242
|
-
remote: params.remote,
|
|
243
|
-
remote_url: params.remote_url,
|
|
244
|
-
output: result.output
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
throw new Error(`Falha ao definir URL do remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
async prune(params) {
|
|
253
|
-
try {
|
|
254
|
-
const remote = params.remote_to_prune || '--all';
|
|
255
|
-
const gitCommand = `remote prune ${remote}`;
|
|
256
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Prunando remotes');
|
|
257
|
-
if (result.exitCode !== 0) {
|
|
258
|
-
throw new Error(`Falha ao prunar remotes: ${result.output}`);
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
success: true,
|
|
262
|
-
action: 'prune',
|
|
263
|
-
message: `Remotes prunados com sucesso`,
|
|
264
|
-
data: {
|
|
265
|
-
remote,
|
|
266
|
-
output: result.output
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
throw new Error(`Falha ao prunar remotes: ${error instanceof Error ? error.message : String(error)}`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitRemoteTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
+
/**
|
|
7
|
+
* Tool: git-remote
|
|
8
|
+
*
|
|
9
|
+
* DESCRIÇÃO:
|
|
10
|
+
* Gerenciamento de remotes Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
+
*
|
|
12
|
+
* FUNCIONALIDADES:
|
|
13
|
+
* - Adicionar remote
|
|
14
|
+
* - Remover remote
|
|
15
|
+
* - Renomear remote
|
|
16
|
+
* - Mostrar remotes
|
|
17
|
+
* - Definir URL do remote
|
|
18
|
+
* - Prune remotes
|
|
19
|
+
*
|
|
20
|
+
* USO:
|
|
21
|
+
* - Para configurar repositórios remotos
|
|
22
|
+
* - Para gerenciar múltiplos remotes
|
|
23
|
+
* - Para sincronizar com diferentes servidores
|
|
24
|
+
* - Para configurar upstream
|
|
25
|
+
*
|
|
26
|
+
* RECOMENDAÇÕES:
|
|
27
|
+
* - Use 'origin' como remote principal
|
|
28
|
+
* - Configure upstream para branches
|
|
29
|
+
* - Mantenha URLs atualizadas
|
|
30
|
+
*/
|
|
31
|
+
const GitRemoteInputSchema = zod_1.z.object({
|
|
32
|
+
action: zod_1.z.enum(['add', 'remove', 'rename', 'show', 'set-url', 'prune']),
|
|
33
|
+
// owner: obtido automaticamente do provider,
|
|
34
|
+
repo: zod_1.z.string(),
|
|
35
|
+
provider: zod_1.z.enum(['gitea', 'github']).describe('Provider to use (gitea or github)'),
|
|
36
|
+
projectPath: zod_1.z.string().describe('Local project path for git operations'),
|
|
37
|
+
// Para add/set-url
|
|
38
|
+
remote_name: zod_1.z.string().optional(),
|
|
39
|
+
remote_url: zod_1.z.string().optional(),
|
|
40
|
+
// Para remove/rename/show
|
|
41
|
+
remote: zod_1.z.string().optional(),
|
|
42
|
+
// Para rename
|
|
43
|
+
new_name: zod_1.z.string().optional(),
|
|
44
|
+
// Para prune
|
|
45
|
+
remote_to_prune: zod_1.z.string().optional(),
|
|
46
|
+
});
|
|
47
|
+
const GitRemoteResultSchema = zod_1.z.object({
|
|
48
|
+
success: zod_1.z.boolean(),
|
|
49
|
+
action: zod_1.z.string(),
|
|
50
|
+
message: zod_1.z.string(),
|
|
51
|
+
data: zod_1.z.any().optional(),
|
|
52
|
+
error: zod_1.z.string().optional()
|
|
53
|
+
});
|
|
54
|
+
exports.gitRemoteTool = {
|
|
55
|
+
name: 'git-remote',
|
|
56
|
+
description: 'tool: Gerencia repositórios remotos Git para sincronização\n──────────────\naction add: adiciona novo remote\naction add requires: repo, remote_name, remote_url, provider\n───────────────\naction remove: remove remote\naction remove requires: repo, remote, provider\n───────────────\naction rename: renomeia remote\naction rename requires: repo, remote, new_name, provider\n───────────────\naction show: mostra informações do remote\naction show requires: repo, remote, provider\n───────────────\naction set-url: atualiza URL do remote\naction set-url requires: repo, remote, remote_url, provider\n───────────────\naction prune: remove referências obsoletas\naction prune requires: repo, remote_to_prune, provider',
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
action: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
enum: ['add', 'remove', 'rename', 'show', 'set-url', 'prune'],
|
|
63
|
+
description: 'Action to perform on remotes'
|
|
64
|
+
},
|
|
65
|
+
owner: { type: 'string', description: 'Repository owner' },
|
|
66
|
+
repo: { type: 'string', description: 'Repository name' },
|
|
67
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
68
|
+
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
69
|
+
remote_name: { type: 'string', description: 'Remote name' },
|
|
70
|
+
remote_url: { type: 'string', description: 'Remote URL' },
|
|
71
|
+
remote: { type: 'string', description: 'Remote to operate on' },
|
|
72
|
+
new_name: { type: 'string', description: 'New remote name' },
|
|
73
|
+
remote_to_prune: { type: 'string', description: 'Remote to prune' }
|
|
74
|
+
},
|
|
75
|
+
required: ['action', 'repo', 'provider', 'projectPath']
|
|
76
|
+
},
|
|
77
|
+
async handler(input) {
|
|
78
|
+
try {
|
|
79
|
+
const validatedInput = GitRemoteInputSchema.parse(input);
|
|
80
|
+
switch (validatedInput.action) {
|
|
81
|
+
case 'add':
|
|
82
|
+
return await this.add(validatedInput);
|
|
83
|
+
case 'remove':
|
|
84
|
+
return await this.remove(validatedInput);
|
|
85
|
+
case 'rename':
|
|
86
|
+
return await this.rename(validatedInput);
|
|
87
|
+
case 'show':
|
|
88
|
+
return await this.show(validatedInput);
|
|
89
|
+
case 'set-url':
|
|
90
|
+
return await this.setUrl(validatedInput);
|
|
91
|
+
case 'prune':
|
|
92
|
+
return await this.prune(validatedInput);
|
|
93
|
+
default:
|
|
94
|
+
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
action: input.action,
|
|
101
|
+
message: 'Erro na operação de remote',
|
|
102
|
+
error: error instanceof Error ? error.message : String(error)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
async add(params) {
|
|
107
|
+
try {
|
|
108
|
+
if (!params.remote_name || !params.remote_url) {
|
|
109
|
+
throw new Error('remote_name e remote_url são obrigatórios para add');
|
|
110
|
+
}
|
|
111
|
+
const gitCommand = `remote add ${params.remote_name} ${params.remote_url}`;
|
|
112
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando remote');
|
|
113
|
+
if (result.exitCode !== 0) {
|
|
114
|
+
throw new Error(`Falha ao adicionar remote: ${result.output}`);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
action: 'add',
|
|
119
|
+
message: `Remote ${params.remote_name} adicionado com sucesso`,
|
|
120
|
+
data: {
|
|
121
|
+
remote_name: params.remote_name,
|
|
122
|
+
remote_url: params.remote_url,
|
|
123
|
+
output: result.output
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw new Error(`Falha ao adicionar remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
async remove(params) {
|
|
132
|
+
try {
|
|
133
|
+
if (!params.remote) {
|
|
134
|
+
throw new Error('remote é obrigatório para remove');
|
|
135
|
+
}
|
|
136
|
+
const gitCommand = `remote remove ${params.remote}`;
|
|
137
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo remote');
|
|
138
|
+
if (result.exitCode !== 0) {
|
|
139
|
+
throw new Error(`Falha ao remover remote: ${result.output}`);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success: true,
|
|
143
|
+
action: 'remove',
|
|
144
|
+
message: `Remote ${params.remote} removido com sucesso`,
|
|
145
|
+
data: {
|
|
146
|
+
remote: params.remote,
|
|
147
|
+
output: result.output
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
throw new Error(`Falha ao remover remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
async rename(params) {
|
|
156
|
+
try {
|
|
157
|
+
if (!params.remote || !params.new_name) {
|
|
158
|
+
throw new Error('remote e new_name são obrigatórios para rename');
|
|
159
|
+
}
|
|
160
|
+
const gitCommand = `remote rename ${params.remote} ${params.new_name}`;
|
|
161
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Renomeando remote');
|
|
162
|
+
if (result.exitCode !== 0) {
|
|
163
|
+
throw new Error(`Falha ao renomear remote: ${result.output}`);
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
action: 'rename',
|
|
168
|
+
message: `Remote ${params.remote} renomeado para ${params.new_name} com sucesso`,
|
|
169
|
+
data: {
|
|
170
|
+
old_name: params.remote,
|
|
171
|
+
new_name: params.new_name,
|
|
172
|
+
output: result.output
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw new Error(`Falha ao renomear remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
async show(params) {
|
|
181
|
+
try {
|
|
182
|
+
if (!params.remote) {
|
|
183
|
+
// Listar todos os remotes
|
|
184
|
+
const gitCommand = `remote -v`;
|
|
185
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Listando remotes');
|
|
186
|
+
if (result.exitCode !== 0) {
|
|
187
|
+
throw new Error(`Falha ao listar remotes: ${result.output}`);
|
|
188
|
+
}
|
|
189
|
+
const remotes = result.output.split('\n')
|
|
190
|
+
.filter(line => line.trim())
|
|
191
|
+
.map(line => {
|
|
192
|
+
const [name, url] = line.split('\t');
|
|
193
|
+
return { name, url };
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
success: true,
|
|
197
|
+
action: 'show',
|
|
198
|
+
message: 'Remotes listados com sucesso',
|
|
199
|
+
data: {
|
|
200
|
+
remotes,
|
|
201
|
+
output: result.output
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// Mostrar remote específico
|
|
207
|
+
const gitCommand = `remote show ${params.remote}`;
|
|
208
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Mostrando remote');
|
|
209
|
+
if (result.exitCode !== 0) {
|
|
210
|
+
throw new Error(`Falha ao mostrar remote: ${result.output}`);
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
success: true,
|
|
214
|
+
action: 'show',
|
|
215
|
+
message: `Remote ${params.remote} mostrado com sucesso`,
|
|
216
|
+
data: {
|
|
217
|
+
remote: params.remote,
|
|
218
|
+
output: result.output
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
throw new Error(`Falha ao mostrar remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async setUrl(params) {
|
|
228
|
+
try {
|
|
229
|
+
if (!params.remote || !params.remote_url) {
|
|
230
|
+
throw new Error('remote e remote_url são obrigatórios para set-url');
|
|
231
|
+
}
|
|
232
|
+
const gitCommand = `remote set-url ${params.remote} ${params.remote_url}`;
|
|
233
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Definindo URL do remote');
|
|
234
|
+
if (result.exitCode !== 0) {
|
|
235
|
+
throw new Error(`Falha ao definir URL do remote: ${result.output}`);
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
success: true,
|
|
239
|
+
action: 'set-url',
|
|
240
|
+
message: `URL do remote ${params.remote} definida com sucesso`,
|
|
241
|
+
data: {
|
|
242
|
+
remote: params.remote,
|
|
243
|
+
remote_url: params.remote_url,
|
|
244
|
+
output: result.output
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
throw new Error(`Falha ao definir URL do remote: ${error instanceof Error ? error.message : String(error)}`);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
async prune(params) {
|
|
253
|
+
try {
|
|
254
|
+
const remote = params.remote_to_prune || '--all';
|
|
255
|
+
const gitCommand = `remote prune ${remote}`;
|
|
256
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Prunando remotes');
|
|
257
|
+
if (result.exitCode !== 0) {
|
|
258
|
+
throw new Error(`Falha ao prunar remotes: ${result.output}`);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
success: true,
|
|
262
|
+
action: 'prune',
|
|
263
|
+
message: `Remotes prunados com sucesso`,
|
|
264
|
+
data: {
|
|
265
|
+
remote,
|
|
266
|
+
output: result.output
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
throw new Error(`Falha ao prunar remotes: ${error instanceof Error ? error.message : String(error)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
275
|
//# sourceMappingURL=git-remote.js.map
|