@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,270 +1,270 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitWorktreeTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
-
/**
|
|
7
|
-
* Tool: git-worktree
|
|
8
|
-
*
|
|
9
|
-
* DESCRIÇÃO:
|
|
10
|
-
* Gerenciamento de worktrees Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
-
*
|
|
12
|
-
* FUNCIONALIDADES:
|
|
13
|
-
* - Adicionar worktree
|
|
14
|
-
* - Remover worktree
|
|
15
|
-
* - Listar worktrees
|
|
16
|
-
* - Prune worktrees
|
|
17
|
-
* - Mover worktree
|
|
18
|
-
* - Reparar worktree
|
|
19
|
-
*
|
|
20
|
-
* USO:
|
|
21
|
-
* - Para trabalhar em múltiplas branches simultaneamente
|
|
22
|
-
* - Para testes em branches diferentes
|
|
23
|
-
* - Para desenvolvimento paralelo
|
|
24
|
-
* - Para builds em branches específicas
|
|
25
|
-
*
|
|
26
|
-
* RECOMENDAÇÕES:
|
|
27
|
-
* - Use para branches de longa duração
|
|
28
|
-
* - Mantenha worktrees organizados
|
|
29
|
-
* - Limpe worktrees antigos
|
|
30
|
-
*/
|
|
31
|
-
const GitWorktreeInputSchema = zod_1.z.object({
|
|
32
|
-
action: zod_1.z.enum(['add', 'remove', 'list', 'prune', 'move', 'repair']),
|
|
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
|
-
worktree_path: zod_1.z.string().optional(),
|
|
39
|
-
branch_name: zod_1.z.string().optional(),
|
|
40
|
-
commit_hash: zod_1.z.string().optional(),
|
|
41
|
-
// Para remove
|
|
42
|
-
worktree_to_remove: zod_1.z.string().optional(),
|
|
43
|
-
force: zod_1.z.boolean().optional(),
|
|
44
|
-
// Para move
|
|
45
|
-
old_path: zod_1.z.string().optional(),
|
|
46
|
-
new_path: zod_1.z.string().optional(),
|
|
47
|
-
// Para repair
|
|
48
|
-
worktree_to_repair: zod_1.z.string().optional(),
|
|
49
|
-
});
|
|
50
|
-
const GitWorktreeResultSchema = zod_1.z.object({
|
|
51
|
-
success: zod_1.z.boolean(),
|
|
52
|
-
action: zod_1.z.string(),
|
|
53
|
-
message: zod_1.z.string(),
|
|
54
|
-
data: zod_1.z.any().optional(),
|
|
55
|
-
error: zod_1.z.string().optional()
|
|
56
|
-
});
|
|
57
|
-
exports.gitWorktreeTool = {
|
|
58
|
-
name: 'git-worktree',
|
|
59
|
-
description: 'tool: Gerencia worktrees Git para trabalhar em múltiplas branches\n──────────────\naction add: adiciona novo worktree\naction add requires: repo, provider, projectPath, worktree_path, branch_name, commit_hash\n───────────────\naction remove: remove worktree\naction remove requires: repo, provider, projectPath, worktree_to_remove, force\n───────────────\naction list: lista worktrees disponíveis\naction list requires: repo, provider, projectPath\n───────────────\naction prune: remove worktrees órfãos\naction prune requires: repo, provider, projectPath, force\n───────────────\naction move: move worktree para novo local\naction move requires: repo, provider, projectPath, old_path, new_path, force\n───────────────\naction repair: repara worktree corrompido\naction repair requires: repo, provider, projectPath, worktree_to_repair',
|
|
60
|
-
inputSchema: {
|
|
61
|
-
type: 'object',
|
|
62
|
-
properties: {
|
|
63
|
-
action: {
|
|
64
|
-
type: 'string',
|
|
65
|
-
enum: ['add', 'remove', 'list', 'prune', 'move', 'repair'],
|
|
66
|
-
description: 'Action to perform on worktrees'
|
|
67
|
-
},
|
|
68
|
-
owner: { type: 'string', description: 'Repository owner' },
|
|
69
|
-
repo: { type: 'string', description: 'Repository name' },
|
|
70
|
-
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
71
|
-
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
72
|
-
worktree_path: { type: 'string', description: 'Worktree path' },
|
|
73
|
-
branch_name: { type: 'string', description: 'Branch name' },
|
|
74
|
-
commit_hash: { type: 'string', description: 'Commit hash' },
|
|
75
|
-
worktree_to_remove: { type: 'string', description: 'Worktree to remove' },
|
|
76
|
-
force: { type: 'boolean', description: 'Force operation' },
|
|
77
|
-
old_path: { type: 'string', description: 'Old worktree path' },
|
|
78
|
-
new_path: { type: 'string', description: 'New worktree path' },
|
|
79
|
-
worktree_to_repair: { type: 'string', description: 'Worktree to repair' }
|
|
80
|
-
},
|
|
81
|
-
required: ['action', 'repo', 'provider', 'projectPath']
|
|
82
|
-
},
|
|
83
|
-
async handler(input) {
|
|
84
|
-
try {
|
|
85
|
-
const validatedInput = GitWorktreeInputSchema.parse(input);
|
|
86
|
-
switch (validatedInput.action) {
|
|
87
|
-
case 'add':
|
|
88
|
-
return await this.add(validatedInput);
|
|
89
|
-
case 'remove':
|
|
90
|
-
return await this.remove(validatedInput);
|
|
91
|
-
case 'list':
|
|
92
|
-
return await this.list(validatedInput);
|
|
93
|
-
case 'prune':
|
|
94
|
-
return await this.prune(validatedInput);
|
|
95
|
-
case 'move':
|
|
96
|
-
return await this.move(validatedInput);
|
|
97
|
-
case 'repair':
|
|
98
|
-
return await this.repair(validatedInput);
|
|
99
|
-
default:
|
|
100
|
-
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return {
|
|
105
|
-
success: false,
|
|
106
|
-
action: input.action,
|
|
107
|
-
message: 'Erro na operação de worktree',
|
|
108
|
-
error: error instanceof Error ? error.message : String(error)
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
async add(params) {
|
|
113
|
-
try {
|
|
114
|
-
if (!params.worktree_path) {
|
|
115
|
-
throw new Error('worktree_path é obrigatório para add');
|
|
116
|
-
}
|
|
117
|
-
let gitCommand = `worktree add ${params.worktree_path}`;
|
|
118
|
-
if (params.branch_name) {
|
|
119
|
-
gitCommand += ` -b ${params.branch_name}`;
|
|
120
|
-
}
|
|
121
|
-
else if (params.commit_hash) {
|
|
122
|
-
gitCommand += ` ${params.commit_hash}`;
|
|
123
|
-
}
|
|
124
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando worktree');
|
|
125
|
-
if (result.exitCode !== 0) {
|
|
126
|
-
throw new Error(`Falha ao adicionar worktree: ${result.output}`);
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
success: true,
|
|
130
|
-
action: 'add',
|
|
131
|
-
message: `Worktree adicionado com sucesso em ${params.worktree_path}`,
|
|
132
|
-
data: {
|
|
133
|
-
worktree_path: params.worktree_path,
|
|
134
|
-
branch_name: params.branch_name,
|
|
135
|
-
commit_hash: params.commit_hash,
|
|
136
|
-
output: result.output
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
throw new Error(`Falha ao adicionar worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
async remove(params) {
|
|
145
|
-
try {
|
|
146
|
-
if (!params.worktree_to_remove) {
|
|
147
|
-
throw new Error('worktree_to_remove é obrigatório para remove');
|
|
148
|
-
}
|
|
149
|
-
let gitCommand = `worktree remove ${params.worktree_to_remove}`;
|
|
150
|
-
if (params.force) {
|
|
151
|
-
gitCommand += ' --force';
|
|
152
|
-
}
|
|
153
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo worktree');
|
|
154
|
-
if (result.exitCode !== 0) {
|
|
155
|
-
throw new Error(`Falha ao remover worktree: ${result.output}`);
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
success: true,
|
|
159
|
-
action: 'remove',
|
|
160
|
-
message: `Worktree removido com sucesso: ${params.worktree_to_remove}`,
|
|
161
|
-
data: {
|
|
162
|
-
worktree_to_remove: params.worktree_to_remove,
|
|
163
|
-
force: params.force,
|
|
164
|
-
output: result.output
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
throw new Error(`Falha ao remover worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
async list(params) {
|
|
173
|
-
try {
|
|
174
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree list`, params.projectPath, 'Listando worktrees');
|
|
175
|
-
if (result.exitCode !== 0) {
|
|
176
|
-
throw new Error(`Falha ao listar worktrees: ${result.output}`);
|
|
177
|
-
}
|
|
178
|
-
const worktrees = result.output.split('\n')
|
|
179
|
-
.filter((line) => line.trim())
|
|
180
|
-
.map((line) => {
|
|
181
|
-
const parts = line.trim().split(' ');
|
|
182
|
-
return {
|
|
183
|
-
path: parts[0],
|
|
184
|
-
commit: parts[1],
|
|
185
|
-
branch: parts[2] || 'detached'
|
|
186
|
-
};
|
|
187
|
-
});
|
|
188
|
-
return {
|
|
189
|
-
success: true,
|
|
190
|
-
action: 'list',
|
|
191
|
-
message: 'Worktrees listados com sucesso',
|
|
192
|
-
data: {
|
|
193
|
-
worktrees,
|
|
194
|
-
output: result.output
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
throw new Error(`Falha ao listar worktrees: ${error instanceof Error ? error.message : String(error)}`);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
async prune(params) {
|
|
203
|
-
try {
|
|
204
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree prune`, params.projectPath, 'Prunando worktrees');
|
|
205
|
-
if (result.exitCode !== 0) {
|
|
206
|
-
throw new Error(`Falha ao prunar worktrees: ${result.output}`);
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
success: true,
|
|
210
|
-
action: 'prune',
|
|
211
|
-
message: 'Worktrees prunados com sucesso',
|
|
212
|
-
data: {
|
|
213
|
-
pruned: true,
|
|
214
|
-
output: result.output
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
throw new Error(`Falha ao prunar worktrees: ${error instanceof Error ? error.message : String(error)}`);
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
async move(params) {
|
|
223
|
-
try {
|
|
224
|
-
if (!params.old_path || !params.new_path) {
|
|
225
|
-
throw new Error('old_path e new_path são obrigatórios para move');
|
|
226
|
-
}
|
|
227
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree move ${params.old_path} ${params.new_path}`, params.projectPath, 'Movendo worktree');
|
|
228
|
-
if (result.exitCode !== 0) {
|
|
229
|
-
throw new Error(`Falha ao mover worktree: ${result.output}`);
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
success: true,
|
|
233
|
-
action: 'move',
|
|
234
|
-
message: `Worktree movido de ${params.old_path} para ${params.new_path}`,
|
|
235
|
-
data: {
|
|
236
|
-
old_path: params.old_path,
|
|
237
|
-
new_path: params.new_path,
|
|
238
|
-
output: result.output
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
throw new Error(`Falha ao mover worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
async repair(params) {
|
|
247
|
-
try {
|
|
248
|
-
if (!params.worktree_to_repair) {
|
|
249
|
-
throw new Error('worktree_to_repair é obrigatório para repair');
|
|
250
|
-
}
|
|
251
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree repair ${params.worktree_to_repair}`, params.projectPath, 'Reparando worktree');
|
|
252
|
-
if (result.exitCode !== 0) {
|
|
253
|
-
throw new Error(`Falha ao reparar worktree: ${result.output}`);
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
success: true,
|
|
257
|
-
action: 'repair',
|
|
258
|
-
message: `Worktree reparado com sucesso: ${params.worktree_to_repair}`,
|
|
259
|
-
data: {
|
|
260
|
-
worktree_to_repair: params.worktree_to_repair,
|
|
261
|
-
output: result.output
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
catch (error) {
|
|
266
|
-
throw new Error(`Falha ao reparar worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitWorktreeTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
+
/**
|
|
7
|
+
* Tool: git-worktree
|
|
8
|
+
*
|
|
9
|
+
* DESCRIÇÃO:
|
|
10
|
+
* Gerenciamento de worktrees Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
+
*
|
|
12
|
+
* FUNCIONALIDADES:
|
|
13
|
+
* - Adicionar worktree
|
|
14
|
+
* - Remover worktree
|
|
15
|
+
* - Listar worktrees
|
|
16
|
+
* - Prune worktrees
|
|
17
|
+
* - Mover worktree
|
|
18
|
+
* - Reparar worktree
|
|
19
|
+
*
|
|
20
|
+
* USO:
|
|
21
|
+
* - Para trabalhar em múltiplas branches simultaneamente
|
|
22
|
+
* - Para testes em branches diferentes
|
|
23
|
+
* - Para desenvolvimento paralelo
|
|
24
|
+
* - Para builds em branches específicas
|
|
25
|
+
*
|
|
26
|
+
* RECOMENDAÇÕES:
|
|
27
|
+
* - Use para branches de longa duração
|
|
28
|
+
* - Mantenha worktrees organizados
|
|
29
|
+
* - Limpe worktrees antigos
|
|
30
|
+
*/
|
|
31
|
+
const GitWorktreeInputSchema = zod_1.z.object({
|
|
32
|
+
action: zod_1.z.enum(['add', 'remove', 'list', 'prune', 'move', 'repair']),
|
|
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
|
+
worktree_path: zod_1.z.string().optional(),
|
|
39
|
+
branch_name: zod_1.z.string().optional(),
|
|
40
|
+
commit_hash: zod_1.z.string().optional(),
|
|
41
|
+
// Para remove
|
|
42
|
+
worktree_to_remove: zod_1.z.string().optional(),
|
|
43
|
+
force: zod_1.z.boolean().optional(),
|
|
44
|
+
// Para move
|
|
45
|
+
old_path: zod_1.z.string().optional(),
|
|
46
|
+
new_path: zod_1.z.string().optional(),
|
|
47
|
+
// Para repair
|
|
48
|
+
worktree_to_repair: zod_1.z.string().optional(),
|
|
49
|
+
});
|
|
50
|
+
const GitWorktreeResultSchema = zod_1.z.object({
|
|
51
|
+
success: zod_1.z.boolean(),
|
|
52
|
+
action: zod_1.z.string(),
|
|
53
|
+
message: zod_1.z.string(),
|
|
54
|
+
data: zod_1.z.any().optional(),
|
|
55
|
+
error: zod_1.z.string().optional()
|
|
56
|
+
});
|
|
57
|
+
exports.gitWorktreeTool = {
|
|
58
|
+
name: 'git-worktree',
|
|
59
|
+
description: 'tool: Gerencia worktrees Git para trabalhar em múltiplas branches\n──────────────\naction add: adiciona novo worktree\naction add requires: repo, provider, projectPath, worktree_path, branch_name, commit_hash\n───────────────\naction remove: remove worktree\naction remove requires: repo, provider, projectPath, worktree_to_remove, force\n───────────────\naction list: lista worktrees disponíveis\naction list requires: repo, provider, projectPath\n───────────────\naction prune: remove worktrees órfãos\naction prune requires: repo, provider, projectPath, force\n───────────────\naction move: move worktree para novo local\naction move requires: repo, provider, projectPath, old_path, new_path, force\n───────────────\naction repair: repara worktree corrompido\naction repair requires: repo, provider, projectPath, worktree_to_repair',
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
action: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
enum: ['add', 'remove', 'list', 'prune', 'move', 'repair'],
|
|
66
|
+
description: 'Action to perform on worktrees'
|
|
67
|
+
},
|
|
68
|
+
owner: { type: 'string', description: 'Repository owner' },
|
|
69
|
+
repo: { type: 'string', description: 'Repository name' },
|
|
70
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
71
|
+
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
72
|
+
worktree_path: { type: 'string', description: 'Worktree path' },
|
|
73
|
+
branch_name: { type: 'string', description: 'Branch name' },
|
|
74
|
+
commit_hash: { type: 'string', description: 'Commit hash' },
|
|
75
|
+
worktree_to_remove: { type: 'string', description: 'Worktree to remove' },
|
|
76
|
+
force: { type: 'boolean', description: 'Force operation' },
|
|
77
|
+
old_path: { type: 'string', description: 'Old worktree path' },
|
|
78
|
+
new_path: { type: 'string', description: 'New worktree path' },
|
|
79
|
+
worktree_to_repair: { type: 'string', description: 'Worktree to repair' }
|
|
80
|
+
},
|
|
81
|
+
required: ['action', 'repo', 'provider', 'projectPath']
|
|
82
|
+
},
|
|
83
|
+
async handler(input) {
|
|
84
|
+
try {
|
|
85
|
+
const validatedInput = GitWorktreeInputSchema.parse(input);
|
|
86
|
+
switch (validatedInput.action) {
|
|
87
|
+
case 'add':
|
|
88
|
+
return await this.add(validatedInput);
|
|
89
|
+
case 'remove':
|
|
90
|
+
return await this.remove(validatedInput);
|
|
91
|
+
case 'list':
|
|
92
|
+
return await this.list(validatedInput);
|
|
93
|
+
case 'prune':
|
|
94
|
+
return await this.prune(validatedInput);
|
|
95
|
+
case 'move':
|
|
96
|
+
return await this.move(validatedInput);
|
|
97
|
+
case 'repair':
|
|
98
|
+
return await this.repair(validatedInput);
|
|
99
|
+
default:
|
|
100
|
+
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
action: input.action,
|
|
107
|
+
message: 'Erro na operação de worktree',
|
|
108
|
+
error: error instanceof Error ? error.message : String(error)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
async add(params) {
|
|
113
|
+
try {
|
|
114
|
+
if (!params.worktree_path) {
|
|
115
|
+
throw new Error('worktree_path é obrigatório para add');
|
|
116
|
+
}
|
|
117
|
+
let gitCommand = `worktree add ${params.worktree_path}`;
|
|
118
|
+
if (params.branch_name) {
|
|
119
|
+
gitCommand += ` -b ${params.branch_name}`;
|
|
120
|
+
}
|
|
121
|
+
else if (params.commit_hash) {
|
|
122
|
+
gitCommand += ` ${params.commit_hash}`;
|
|
123
|
+
}
|
|
124
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Adicionando worktree');
|
|
125
|
+
if (result.exitCode !== 0) {
|
|
126
|
+
throw new Error(`Falha ao adicionar worktree: ${result.output}`);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
action: 'add',
|
|
131
|
+
message: `Worktree adicionado com sucesso em ${params.worktree_path}`,
|
|
132
|
+
data: {
|
|
133
|
+
worktree_path: params.worktree_path,
|
|
134
|
+
branch_name: params.branch_name,
|
|
135
|
+
commit_hash: params.commit_hash,
|
|
136
|
+
output: result.output
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw new Error(`Falha ao adicionar worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
async remove(params) {
|
|
145
|
+
try {
|
|
146
|
+
if (!params.worktree_to_remove) {
|
|
147
|
+
throw new Error('worktree_to_remove é obrigatório para remove');
|
|
148
|
+
}
|
|
149
|
+
let gitCommand = `worktree remove ${params.worktree_to_remove}`;
|
|
150
|
+
if (params.force) {
|
|
151
|
+
gitCommand += ' --force';
|
|
152
|
+
}
|
|
153
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo worktree');
|
|
154
|
+
if (result.exitCode !== 0) {
|
|
155
|
+
throw new Error(`Falha ao remover worktree: ${result.output}`);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
success: true,
|
|
159
|
+
action: 'remove',
|
|
160
|
+
message: `Worktree removido com sucesso: ${params.worktree_to_remove}`,
|
|
161
|
+
data: {
|
|
162
|
+
worktree_to_remove: params.worktree_to_remove,
|
|
163
|
+
force: params.force,
|
|
164
|
+
output: result.output
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
throw new Error(`Falha ao remover worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
async list(params) {
|
|
173
|
+
try {
|
|
174
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree list`, params.projectPath, 'Listando worktrees');
|
|
175
|
+
if (result.exitCode !== 0) {
|
|
176
|
+
throw new Error(`Falha ao listar worktrees: ${result.output}`);
|
|
177
|
+
}
|
|
178
|
+
const worktrees = result.output.split('\n')
|
|
179
|
+
.filter((line) => line.trim())
|
|
180
|
+
.map((line) => {
|
|
181
|
+
const parts = line.trim().split(' ');
|
|
182
|
+
return {
|
|
183
|
+
path: parts[0],
|
|
184
|
+
commit: parts[1],
|
|
185
|
+
branch: parts[2] || 'detached'
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
action: 'list',
|
|
191
|
+
message: 'Worktrees listados com sucesso',
|
|
192
|
+
data: {
|
|
193
|
+
worktrees,
|
|
194
|
+
output: result.output
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
throw new Error(`Falha ao listar worktrees: ${error instanceof Error ? error.message : String(error)}`);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
async prune(params) {
|
|
203
|
+
try {
|
|
204
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree prune`, params.projectPath, 'Prunando worktrees');
|
|
205
|
+
if (result.exitCode !== 0) {
|
|
206
|
+
throw new Error(`Falha ao prunar worktrees: ${result.output}`);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
success: true,
|
|
210
|
+
action: 'prune',
|
|
211
|
+
message: 'Worktrees prunados com sucesso',
|
|
212
|
+
data: {
|
|
213
|
+
pruned: true,
|
|
214
|
+
output: result.output
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
throw new Error(`Falha ao prunar worktrees: ${error instanceof Error ? error.message : String(error)}`);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
async move(params) {
|
|
223
|
+
try {
|
|
224
|
+
if (!params.old_path || !params.new_path) {
|
|
225
|
+
throw new Error('old_path e new_path são obrigatórios para move');
|
|
226
|
+
}
|
|
227
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree move ${params.old_path} ${params.new_path}`, params.projectPath, 'Movendo worktree');
|
|
228
|
+
if (result.exitCode !== 0) {
|
|
229
|
+
throw new Error(`Falha ao mover worktree: ${result.output}`);
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
success: true,
|
|
233
|
+
action: 'move',
|
|
234
|
+
message: `Worktree movido de ${params.old_path} para ${params.new_path}`,
|
|
235
|
+
data: {
|
|
236
|
+
old_path: params.old_path,
|
|
237
|
+
new_path: params.new_path,
|
|
238
|
+
output: result.output
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
throw new Error(`Falha ao mover worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
async repair(params) {
|
|
247
|
+
try {
|
|
248
|
+
if (!params.worktree_to_repair) {
|
|
249
|
+
throw new Error('worktree_to_repair é obrigatório para repair');
|
|
250
|
+
}
|
|
251
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`worktree repair ${params.worktree_to_repair}`, params.projectPath, 'Reparando worktree');
|
|
252
|
+
if (result.exitCode !== 0) {
|
|
253
|
+
throw new Error(`Falha ao reparar worktree: ${result.output}`);
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
success: true,
|
|
257
|
+
action: 'repair',
|
|
258
|
+
message: `Worktree reparado com sucesso: ${params.worktree_to_repair}`,
|
|
259
|
+
data: {
|
|
260
|
+
worktree_to_repair: params.worktree_to_repair,
|
|
261
|
+
output: result.output
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
throw new Error(`Falha ao reparar worktree: ${error instanceof Error ? error.message : String(error)}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
270
|
//# sourceMappingURL=git-worktree.js.map
|