@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
|
@@ -1,290 +1,290 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitSubmoduleTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
-
/**
|
|
7
|
-
* Tool: git-submodule
|
|
8
|
-
*
|
|
9
|
-
* DESCRIÇÃO:
|
|
10
|
-
* Gerenciamento de submódulos Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
-
*
|
|
12
|
-
* FUNCIONALIDADES:
|
|
13
|
-
* - Adicionar submódulo
|
|
14
|
-
* - Atualizar submódulos
|
|
15
|
-
* - Inicializar submódulos
|
|
16
|
-
* - Deinicializar submódulos
|
|
17
|
-
* - Status de submódulos
|
|
18
|
-
* - Sincronizar submódulos
|
|
19
|
-
*
|
|
20
|
-
* USO:
|
|
21
|
-
* - Para incluir repositórios externos
|
|
22
|
-
* - Para gerenciar dependências
|
|
23
|
-
* - Para manter versões específicas
|
|
24
|
-
* - Para organizar projetos grandes
|
|
25
|
-
*
|
|
26
|
-
* RECOMENDAÇÕES:
|
|
27
|
-
* - Use para dependências estáveis
|
|
28
|
-
* - Mantenha versões específicas
|
|
29
|
-
* - Documente submódulos no README
|
|
30
|
-
*/
|
|
31
|
-
const GitSubmoduleInputSchema = zod_1.z.object({
|
|
32
|
-
action: zod_1.z.enum(['add', 'update', 'init', 'deinit', 'status', 'sync']),
|
|
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
|
|
38
|
-
submodule_url: zod_1.z.string().optional(),
|
|
39
|
-
submodule_path: zod_1.z.string().optional(),
|
|
40
|
-
submodule_branch: zod_1.z.string().optional(),
|
|
41
|
-
// Para update/init/deinit
|
|
42
|
-
submodule_name: zod_1.z.string().optional(),
|
|
43
|
-
// Para update
|
|
44
|
-
recursive: zod_1.z.boolean().optional(),
|
|
45
|
-
remote: zod_1.z.boolean().optional(),
|
|
46
|
-
// Para sync
|
|
47
|
-
recursive_sync: zod_1.z.boolean().optional(),
|
|
48
|
-
});
|
|
49
|
-
const GitSubmoduleResultSchema = zod_1.z.object({
|
|
50
|
-
success: zod_1.z.boolean(),
|
|
51
|
-
action: zod_1.z.string(),
|
|
52
|
-
message: zod_1.z.string(),
|
|
53
|
-
data: zod_1.z.any().optional(),
|
|
54
|
-
error: zod_1.z.string().optional()
|
|
55
|
-
});
|
|
56
|
-
exports.gitSubmoduleTool = {
|
|
57
|
-
name: 'git-submodule',
|
|
58
|
-
description: 'tool: Gerencia submódulos Git para incluir repositórios externos\n──────────────\naction add: adiciona novo submódulo\naction add requires: repo, provider, projectPath, submodule_url, submodule_path, submodule_branch\n───────────────\naction update: atualiza submódulos\naction update requires: repo, provider, projectPath, submodule_name, recursive, remote\n───────────────\naction init: inicializa submódulos\naction init requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction deinit: desinicializa submódulos\naction deinit requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction status: verifica status dos submódulos\naction status requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction sync: sincroniza submódulos\naction sync requires: repo, provider, projectPath, submodule_name, recursive_sync',
|
|
59
|
-
inputSchema: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
action: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
enum: ['add', 'update', 'init', 'deinit', 'status', 'sync'],
|
|
65
|
-
description: 'Action to perform on submodules'
|
|
66
|
-
},
|
|
67
|
-
owner: { type: 'string', description: 'Repository owner' },
|
|
68
|
-
repo: { type: 'string', description: 'Repository name' },
|
|
69
|
-
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
70
|
-
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
71
|
-
submodule_url: { type: 'string', description: 'Submodule URL' },
|
|
72
|
-
submodule_path: { type: 'string', description: 'Submodule path' },
|
|
73
|
-
submodule_branch: { type: 'string', description: 'Submodule branch' },
|
|
74
|
-
submodule_name: { type: 'string', description: 'Submodule name' },
|
|
75
|
-
recursive: { type: 'boolean', description: 'Recursive operation' },
|
|
76
|
-
remote: { type: 'boolean', description: 'Update from remote' },
|
|
77
|
-
recursive_sync: { type: 'boolean', description: 'Recursive sync' }
|
|
78
|
-
},
|
|
79
|
-
required: ['action', 'repo', 'provider', 'projectPath']
|
|
80
|
-
},
|
|
81
|
-
async handler(input) {
|
|
82
|
-
try {
|
|
83
|
-
const validatedInput = GitSubmoduleInputSchema.parse(input);
|
|
84
|
-
switch (validatedInput.action) {
|
|
85
|
-
case 'add':
|
|
86
|
-
return await this.add(validatedInput);
|
|
87
|
-
case 'update':
|
|
88
|
-
return await this.update(validatedInput);
|
|
89
|
-
case 'init':
|
|
90
|
-
return await this.init(validatedInput);
|
|
91
|
-
case 'deinit':
|
|
92
|
-
return await this.deinit(validatedInput);
|
|
93
|
-
case 'status':
|
|
94
|
-
return await this.status(validatedInput);
|
|
95
|
-
case 'sync':
|
|
96
|
-
return await this.sync(validatedInput);
|
|
97
|
-
default:
|
|
98
|
-
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
return {
|
|
103
|
-
success: false,
|
|
104
|
-
action: input.action,
|
|
105
|
-
message: 'Erro na operação de submódulo',
|
|
106
|
-
error: error instanceof Error ? error.message : String(error)
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
async add(params) {
|
|
111
|
-
try {
|
|
112
|
-
if (!params.submodule_url || !params.submodule_path) {
|
|
113
|
-
throw new Error('submodule_url e submodule_path são obrigatórios para add');
|
|
114
|
-
}
|
|
115
|
-
let gitCommand = `submodule add ${params.submodule_url} ${params.submodule_path}`;
|
|
116
|
-
if (params.submodule_branch) {
|
|
117
|
-
gitCommand += ` -b ${params.submodule_branch}`;
|
|
118
|
-
}
|
|
119
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando submódulo');
|
|
120
|
-
if (result.exitCode !== 0) {
|
|
121
|
-
throw new Error(`Falha ao adicionar submódulo: ${result.output}`);
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
success: true,
|
|
125
|
-
action: 'add',
|
|
126
|
-
message: `Submódulo adicionado com sucesso em ${params.submodule_path}`,
|
|
127
|
-
data: {
|
|
128
|
-
submodule_url: params.submodule_url,
|
|
129
|
-
submodule_path: params.submodule_path,
|
|
130
|
-
submodule_branch: params.submodule_branch,
|
|
131
|
-
output: result.output
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
throw new Error(`Falha ao adicionar submódulo: ${error instanceof Error ? error.message : String(error)}`);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
async update(params) {
|
|
140
|
-
try {
|
|
141
|
-
let gitCommand = `submodule update`;
|
|
142
|
-
if (params.recursive) {
|
|
143
|
-
gitCommand += ' --recursive';
|
|
144
|
-
}
|
|
145
|
-
if (params.remote) {
|
|
146
|
-
gitCommand += ' --remote';
|
|
147
|
-
}
|
|
148
|
-
if (params.submodule_name) {
|
|
149
|
-
gitCommand += ` ${params.submodule_name}`;
|
|
150
|
-
}
|
|
151
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Atualizando submódulos');
|
|
152
|
-
if (result.exitCode !== 0) {
|
|
153
|
-
throw new Error(`Falha ao atualizar submódulos: ${result.output}`);
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
success: true,
|
|
157
|
-
action: 'update',
|
|
158
|
-
message: 'Submódulos atualizados com sucesso',
|
|
159
|
-
data: {
|
|
160
|
-
submodule_name: params.submodule_name,
|
|
161
|
-
recursive: params.recursive,
|
|
162
|
-
remote: params.remote,
|
|
163
|
-
output: result.output
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
throw new Error(`Falha ao atualizar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
async init(params) {
|
|
172
|
-
try {
|
|
173
|
-
let gitCommand = `submodule init`;
|
|
174
|
-
if (params.submodule_name) {
|
|
175
|
-
gitCommand += ` ${params.submodule_name}`;
|
|
176
|
-
}
|
|
177
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Inicializando submódulos');
|
|
178
|
-
if (result.exitCode !== 0) {
|
|
179
|
-
throw new Error(`Falha ao inicializar submódulos: ${result.output}`);
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
success: true,
|
|
183
|
-
action: 'init',
|
|
184
|
-
message: 'Submódulos inicializados com sucesso',
|
|
185
|
-
data: {
|
|
186
|
-
submodule_name: params.submodule_name,
|
|
187
|
-
output: result.output
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
throw new Error(`Falha ao inicializar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
async deinit(params) {
|
|
196
|
-
try {
|
|
197
|
-
let gitCommand = `submodule deinit`;
|
|
198
|
-
if (params.recursive) {
|
|
199
|
-
gitCommand += ' --recursive';
|
|
200
|
-
}
|
|
201
|
-
if (params.submodule_name) {
|
|
202
|
-
gitCommand += ` ${params.submodule_name}`;
|
|
203
|
-
}
|
|
204
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Deinicializando submódulos');
|
|
205
|
-
if (result.exitCode !== 0) {
|
|
206
|
-
throw new Error(`Falha ao deinicializar submódulos: ${result.output}`);
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
success: true,
|
|
210
|
-
action: 'deinit',
|
|
211
|
-
message: 'Submódulos deinicializados com sucesso',
|
|
212
|
-
data: {
|
|
213
|
-
submodule_name: params.submodule_name,
|
|
214
|
-
recursive: params.recursive,
|
|
215
|
-
output: result.output
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
throw new Error(`Falha ao deinicializar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
async status(params) {
|
|
224
|
-
try {
|
|
225
|
-
let gitCommand = `submodule status`;
|
|
226
|
-
if (params.recursive) {
|
|
227
|
-
gitCommand += ' --recursive';
|
|
228
|
-
}
|
|
229
|
-
if (params.submodule_name) {
|
|
230
|
-
gitCommand += ` ${params.submodule_name}`;
|
|
231
|
-
}
|
|
232
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Verificando status dos submódulos');
|
|
233
|
-
if (result.exitCode !== 0) {
|
|
234
|
-
throw new Error(`Falha ao verificar status dos submódulos: ${result.output}`);
|
|
235
|
-
}
|
|
236
|
-
const submodules = result.output.split('\n')
|
|
237
|
-
.filter((line) => line.trim())
|
|
238
|
-
.map((line) => {
|
|
239
|
-
const parts = line.trim().split(' ');
|
|
240
|
-
return {
|
|
241
|
-
status: parts[0],
|
|
242
|
-
commit: parts[1],
|
|
243
|
-
path: parts[2]
|
|
244
|
-
};
|
|
245
|
-
});
|
|
246
|
-
return {
|
|
247
|
-
success: true,
|
|
248
|
-
action: 'status',
|
|
249
|
-
message: 'Status dos submódulos obtido com sucesso',
|
|
250
|
-
data: {
|
|
251
|
-
submodules,
|
|
252
|
-
recursive: params.recursive,
|
|
253
|
-
output: result.output
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
catch (error) {
|
|
258
|
-
throw new Error(`Falha ao verificar status dos submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
async sync(params) {
|
|
262
|
-
try {
|
|
263
|
-
let gitCommand = `submodule sync`;
|
|
264
|
-
if (params.recursive_sync) {
|
|
265
|
-
gitCommand += ' --recursive';
|
|
266
|
-
}
|
|
267
|
-
if (params.submodule_name) {
|
|
268
|
-
gitCommand += ` ${params.submodule_name}`;
|
|
269
|
-
}
|
|
270
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Sincronizando submódulos');
|
|
271
|
-
if (result.exitCode !== 0) {
|
|
272
|
-
throw new Error(`Falha ao sincronizar submódulos: ${result.output}`);
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
success: true,
|
|
276
|
-
action: 'sync',
|
|
277
|
-
message: 'Submódulos sincronizados com sucesso',
|
|
278
|
-
data: {
|
|
279
|
-
submodule_name: params.submodule_name,
|
|
280
|
-
recursive_sync: params.recursive_sync,
|
|
281
|
-
output: result.output
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
throw new Error(`Falha ao sincronizar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitSubmoduleTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
+
/**
|
|
7
|
+
* Tool: git-submodule
|
|
8
|
+
*
|
|
9
|
+
* DESCRIÇÃO:
|
|
10
|
+
* Gerenciamento de submódulos Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
+
*
|
|
12
|
+
* FUNCIONALIDADES:
|
|
13
|
+
* - Adicionar submódulo
|
|
14
|
+
* - Atualizar submódulos
|
|
15
|
+
* - Inicializar submódulos
|
|
16
|
+
* - Deinicializar submódulos
|
|
17
|
+
* - Status de submódulos
|
|
18
|
+
* - Sincronizar submódulos
|
|
19
|
+
*
|
|
20
|
+
* USO:
|
|
21
|
+
* - Para incluir repositórios externos
|
|
22
|
+
* - Para gerenciar dependências
|
|
23
|
+
* - Para manter versões específicas
|
|
24
|
+
* - Para organizar projetos grandes
|
|
25
|
+
*
|
|
26
|
+
* RECOMENDAÇÕES:
|
|
27
|
+
* - Use para dependências estáveis
|
|
28
|
+
* - Mantenha versões específicas
|
|
29
|
+
* - Documente submódulos no README
|
|
30
|
+
*/
|
|
31
|
+
const GitSubmoduleInputSchema = zod_1.z.object({
|
|
32
|
+
action: zod_1.z.enum(['add', 'update', 'init', 'deinit', 'status', 'sync']),
|
|
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
|
|
38
|
+
submodule_url: zod_1.z.string().optional(),
|
|
39
|
+
submodule_path: zod_1.z.string().optional(),
|
|
40
|
+
submodule_branch: zod_1.z.string().optional(),
|
|
41
|
+
// Para update/init/deinit
|
|
42
|
+
submodule_name: zod_1.z.string().optional(),
|
|
43
|
+
// Para update
|
|
44
|
+
recursive: zod_1.z.boolean().optional(),
|
|
45
|
+
remote: zod_1.z.boolean().optional(),
|
|
46
|
+
// Para sync
|
|
47
|
+
recursive_sync: zod_1.z.boolean().optional(),
|
|
48
|
+
});
|
|
49
|
+
const GitSubmoduleResultSchema = zod_1.z.object({
|
|
50
|
+
success: zod_1.z.boolean(),
|
|
51
|
+
action: zod_1.z.string(),
|
|
52
|
+
message: zod_1.z.string(),
|
|
53
|
+
data: zod_1.z.any().optional(),
|
|
54
|
+
error: zod_1.z.string().optional()
|
|
55
|
+
});
|
|
56
|
+
exports.gitSubmoduleTool = {
|
|
57
|
+
name: 'git-submodule',
|
|
58
|
+
description: 'tool: Gerencia submódulos Git para incluir repositórios externos\n──────────────\naction add: adiciona novo submódulo\naction add requires: repo, provider, projectPath, submodule_url, submodule_path, submodule_branch\n───────────────\naction update: atualiza submódulos\naction update requires: repo, provider, projectPath, submodule_name, recursive, remote\n───────────────\naction init: inicializa submódulos\naction init requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction deinit: desinicializa submódulos\naction deinit requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction status: verifica status dos submódulos\naction status requires: repo, provider, projectPath, submodule_name, recursive\n───────────────\naction sync: sincroniza submódulos\naction sync requires: repo, provider, projectPath, submodule_name, recursive_sync',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
action: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
enum: ['add', 'update', 'init', 'deinit', 'status', 'sync'],
|
|
65
|
+
description: 'Action to perform on submodules'
|
|
66
|
+
},
|
|
67
|
+
owner: { type: 'string', description: 'Repository owner' },
|
|
68
|
+
repo: { type: 'string', description: 'Repository name' },
|
|
69
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
70
|
+
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
71
|
+
submodule_url: { type: 'string', description: 'Submodule URL' },
|
|
72
|
+
submodule_path: { type: 'string', description: 'Submodule path' },
|
|
73
|
+
submodule_branch: { type: 'string', description: 'Submodule branch' },
|
|
74
|
+
submodule_name: { type: 'string', description: 'Submodule name' },
|
|
75
|
+
recursive: { type: 'boolean', description: 'Recursive operation' },
|
|
76
|
+
remote: { type: 'boolean', description: 'Update from remote' },
|
|
77
|
+
recursive_sync: { type: 'boolean', description: 'Recursive sync' }
|
|
78
|
+
},
|
|
79
|
+
required: ['action', 'repo', 'provider', 'projectPath']
|
|
80
|
+
},
|
|
81
|
+
async handler(input) {
|
|
82
|
+
try {
|
|
83
|
+
const validatedInput = GitSubmoduleInputSchema.parse(input);
|
|
84
|
+
switch (validatedInput.action) {
|
|
85
|
+
case 'add':
|
|
86
|
+
return await this.add(validatedInput);
|
|
87
|
+
case 'update':
|
|
88
|
+
return await this.update(validatedInput);
|
|
89
|
+
case 'init':
|
|
90
|
+
return await this.init(validatedInput);
|
|
91
|
+
case 'deinit':
|
|
92
|
+
return await this.deinit(validatedInput);
|
|
93
|
+
case 'status':
|
|
94
|
+
return await this.status(validatedInput);
|
|
95
|
+
case 'sync':
|
|
96
|
+
return await this.sync(validatedInput);
|
|
97
|
+
default:
|
|
98
|
+
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
action: input.action,
|
|
105
|
+
message: 'Erro na operação de submódulo',
|
|
106
|
+
error: error instanceof Error ? error.message : String(error)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
async add(params) {
|
|
111
|
+
try {
|
|
112
|
+
if (!params.submodule_url || !params.submodule_path) {
|
|
113
|
+
throw new Error('submodule_url e submodule_path são obrigatórios para add');
|
|
114
|
+
}
|
|
115
|
+
let gitCommand = `submodule add ${params.submodule_url} ${params.submodule_path}`;
|
|
116
|
+
if (params.submodule_branch) {
|
|
117
|
+
gitCommand += ` -b ${params.submodule_branch}`;
|
|
118
|
+
}
|
|
119
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando submódulo');
|
|
120
|
+
if (result.exitCode !== 0) {
|
|
121
|
+
throw new Error(`Falha ao adicionar submódulo: ${result.output}`);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
action: 'add',
|
|
126
|
+
message: `Submódulo adicionado com sucesso em ${params.submodule_path}`,
|
|
127
|
+
data: {
|
|
128
|
+
submodule_url: params.submodule_url,
|
|
129
|
+
submodule_path: params.submodule_path,
|
|
130
|
+
submodule_branch: params.submodule_branch,
|
|
131
|
+
output: result.output
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
throw new Error(`Falha ao adicionar submódulo: ${error instanceof Error ? error.message : String(error)}`);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async update(params) {
|
|
140
|
+
try {
|
|
141
|
+
let gitCommand = `submodule update`;
|
|
142
|
+
if (params.recursive) {
|
|
143
|
+
gitCommand += ' --recursive';
|
|
144
|
+
}
|
|
145
|
+
if (params.remote) {
|
|
146
|
+
gitCommand += ' --remote';
|
|
147
|
+
}
|
|
148
|
+
if (params.submodule_name) {
|
|
149
|
+
gitCommand += ` ${params.submodule_name}`;
|
|
150
|
+
}
|
|
151
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Atualizando submódulos');
|
|
152
|
+
if (result.exitCode !== 0) {
|
|
153
|
+
throw new Error(`Falha ao atualizar submódulos: ${result.output}`);
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
action: 'update',
|
|
158
|
+
message: 'Submódulos atualizados com sucesso',
|
|
159
|
+
data: {
|
|
160
|
+
submodule_name: params.submodule_name,
|
|
161
|
+
recursive: params.recursive,
|
|
162
|
+
remote: params.remote,
|
|
163
|
+
output: result.output
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
throw new Error(`Falha ao atualizar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
async init(params) {
|
|
172
|
+
try {
|
|
173
|
+
let gitCommand = `submodule init`;
|
|
174
|
+
if (params.submodule_name) {
|
|
175
|
+
gitCommand += ` ${params.submodule_name}`;
|
|
176
|
+
}
|
|
177
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Inicializando submódulos');
|
|
178
|
+
if (result.exitCode !== 0) {
|
|
179
|
+
throw new Error(`Falha ao inicializar submódulos: ${result.output}`);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
action: 'init',
|
|
184
|
+
message: 'Submódulos inicializados com sucesso',
|
|
185
|
+
data: {
|
|
186
|
+
submodule_name: params.submodule_name,
|
|
187
|
+
output: result.output
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
throw new Error(`Falha ao inicializar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
async deinit(params) {
|
|
196
|
+
try {
|
|
197
|
+
let gitCommand = `submodule deinit`;
|
|
198
|
+
if (params.recursive) {
|
|
199
|
+
gitCommand += ' --recursive';
|
|
200
|
+
}
|
|
201
|
+
if (params.submodule_name) {
|
|
202
|
+
gitCommand += ` ${params.submodule_name}`;
|
|
203
|
+
}
|
|
204
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Deinicializando submódulos');
|
|
205
|
+
if (result.exitCode !== 0) {
|
|
206
|
+
throw new Error(`Falha ao deinicializar submódulos: ${result.output}`);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
success: true,
|
|
210
|
+
action: 'deinit',
|
|
211
|
+
message: 'Submódulos deinicializados com sucesso',
|
|
212
|
+
data: {
|
|
213
|
+
submodule_name: params.submodule_name,
|
|
214
|
+
recursive: params.recursive,
|
|
215
|
+
output: result.output
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
throw new Error(`Falha ao deinicializar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
async status(params) {
|
|
224
|
+
try {
|
|
225
|
+
let gitCommand = `submodule status`;
|
|
226
|
+
if (params.recursive) {
|
|
227
|
+
gitCommand += ' --recursive';
|
|
228
|
+
}
|
|
229
|
+
if (params.submodule_name) {
|
|
230
|
+
gitCommand += ` ${params.submodule_name}`;
|
|
231
|
+
}
|
|
232
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Verificando status dos submódulos');
|
|
233
|
+
if (result.exitCode !== 0) {
|
|
234
|
+
throw new Error(`Falha ao verificar status dos submódulos: ${result.output}`);
|
|
235
|
+
}
|
|
236
|
+
const submodules = result.output.split('\n')
|
|
237
|
+
.filter((line) => line.trim())
|
|
238
|
+
.map((line) => {
|
|
239
|
+
const parts = line.trim().split(' ');
|
|
240
|
+
return {
|
|
241
|
+
status: parts[0],
|
|
242
|
+
commit: parts[1],
|
|
243
|
+
path: parts[2]
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
success: true,
|
|
248
|
+
action: 'status',
|
|
249
|
+
message: 'Status dos submódulos obtido com sucesso',
|
|
250
|
+
data: {
|
|
251
|
+
submodules,
|
|
252
|
+
recursive: params.recursive,
|
|
253
|
+
output: result.output
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
throw new Error(`Falha ao verificar status dos submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
async sync(params) {
|
|
262
|
+
try {
|
|
263
|
+
let gitCommand = `submodule sync`;
|
|
264
|
+
if (params.recursive_sync) {
|
|
265
|
+
gitCommand += ' --recursive';
|
|
266
|
+
}
|
|
267
|
+
if (params.submodule_name) {
|
|
268
|
+
gitCommand += ` ${params.submodule_name}`;
|
|
269
|
+
}
|
|
270
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Sincronizando submódulos');
|
|
271
|
+
if (result.exitCode !== 0) {
|
|
272
|
+
throw new Error(`Falha ao sincronizar submódulos: ${result.output}`);
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
success: true,
|
|
276
|
+
action: 'sync',
|
|
277
|
+
message: 'Submódulos sincronizados com sucesso',
|
|
278
|
+
data: {
|
|
279
|
+
submodule_name: params.submodule_name,
|
|
280
|
+
recursive_sync: params.recursive_sync,
|
|
281
|
+
output: result.output
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
throw new Error(`Falha ao sincronizar submódulos: ${error instanceof Error ? error.message : String(error)}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
290
|
//# sourceMappingURL=git-submodule.js.map
|