@andrebuzeli/git-mcp 2.27.3 → 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 -357
- 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-config.js
CHANGED
|
@@ -1,269 +1,269 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitConfigTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
-
/**
|
|
7
|
-
* Tool: git-config
|
|
8
|
-
*
|
|
9
|
-
* DESCRIÇÃO:
|
|
10
|
-
* Gerenciamento de configuração Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
-
*
|
|
12
|
-
* FUNCIONALIDADES:
|
|
13
|
-
* - Obter configurações
|
|
14
|
-
* - Definir configurações
|
|
15
|
-
* - Remover configurações
|
|
16
|
-
* - Listar configurações
|
|
17
|
-
* - Editar configuração
|
|
18
|
-
* - Mostrar configurações
|
|
19
|
-
*
|
|
20
|
-
* USO:
|
|
21
|
-
* - Para configurar usuário e email
|
|
22
|
-
* - Para configurar aliases
|
|
23
|
-
* - Para configurar branches padrão
|
|
24
|
-
* - Para configurar merge tools
|
|
25
|
-
* - Para configurar credenciais
|
|
26
|
-
*
|
|
27
|
-
* RECOMENDAÇÕES:
|
|
28
|
-
* - Use configurações globais para usuário
|
|
29
|
-
* - Use configurações locais para projeto
|
|
30
|
-
* - Documente configurações customizadas
|
|
31
|
-
*/
|
|
32
|
-
const GitConfigInputSchema = zod_1.z.object({
|
|
33
|
-
action: zod_1.z.enum(['get', 'set', 'unset', 'list', 'edit', 'show']),
|
|
34
|
-
// owner: obtido automaticamente do provider,
|
|
35
|
-
repo: zod_1.z.string(),
|
|
36
|
-
provider: zod_1.z.enum(['gitea', 'github']).describe('Provider to use (gitea or github)'),
|
|
37
|
-
projectPath: zod_1.z.string().describe('Local project path for git operations'),
|
|
38
|
-
// Para get/set/unset
|
|
39
|
-
key: zod_1.z.string().optional(),
|
|
40
|
-
value: zod_1.z.string().optional(),
|
|
41
|
-
// Para set
|
|
42
|
-
scope: zod_1.z.enum(['local', 'global', 'system']).optional(),
|
|
43
|
-
// Para list
|
|
44
|
-
pattern: zod_1.z.string().optional(),
|
|
45
|
-
// Para show
|
|
46
|
-
show_origin: zod_1.z.boolean().optional(),
|
|
47
|
-
});
|
|
48
|
-
const GitConfigResultSchema = zod_1.z.object({
|
|
49
|
-
success: zod_1.z.boolean(),
|
|
50
|
-
action: zod_1.z.string(),
|
|
51
|
-
message: zod_1.z.string(),
|
|
52
|
-
data: zod_1.z.any().optional(),
|
|
53
|
-
error: zod_1.z.string().optional()
|
|
54
|
-
});
|
|
55
|
-
exports.gitConfigTool = {
|
|
56
|
-
name: 'git-config',
|
|
57
|
-
description: 'tool: Gerencia configurações Git para personalização do ambiente\n──────────────\naction get: obtém valor de configuração\naction get requires: repo, key, scope, provider\n───────────────\naction set: define valor de configuração\naction set requires: repo, key, value, scope, provider\n───────────────\naction unset: remove configuração\naction unset requires: repo, key, scope, provider\n───────────────\naction list: lista configurações\naction list requires: repo, pattern, scope, provider\n───────────────\naction edit: edita arquivo de configuração\naction edit requires: repo, scope, provider\n───────────────\naction show: mostra configurações com origem\naction show requires: repo, show_origin, provider',
|
|
58
|
-
inputSchema: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
action: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
enum: ['get', 'set', 'unset', 'list', 'edit', 'show'],
|
|
64
|
-
description: 'Action to perform on config'
|
|
65
|
-
},
|
|
66
|
-
owner: { type: 'string', description: 'Repository owner' },
|
|
67
|
-
repo: { type: 'string', description: 'Repository name' },
|
|
68
|
-
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
69
|
-
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
70
|
-
key: { type: 'string', description: 'Config key' },
|
|
71
|
-
value: { type: 'string', description: 'Config value' },
|
|
72
|
-
scope: { type: 'string', enum: ['local', 'global', 'system'], description: 'Config scope' },
|
|
73
|
-
pattern: { type: 'string', description: 'Pattern for listing configs' },
|
|
74
|
-
show_origin: { type: 'boolean', description: 'Show origin of config values' }
|
|
75
|
-
},
|
|
76
|
-
required: ['action', 'repo', 'provider', 'projectPath']
|
|
77
|
-
},
|
|
78
|
-
async handler(input) {
|
|
79
|
-
try {
|
|
80
|
-
const validatedInput = GitConfigInputSchema.parse(input);
|
|
81
|
-
switch (validatedInput.action) {
|
|
82
|
-
case 'get':
|
|
83
|
-
return await this.get(validatedInput);
|
|
84
|
-
case 'set':
|
|
85
|
-
return await this.set(validatedInput);
|
|
86
|
-
case 'unset':
|
|
87
|
-
return await this.unset(validatedInput);
|
|
88
|
-
case 'list':
|
|
89
|
-
return await this.list(validatedInput);
|
|
90
|
-
case 'edit':
|
|
91
|
-
return await this.edit(validatedInput);
|
|
92
|
-
case 'show':
|
|
93
|
-
return await this.show(validatedInput);
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
return {
|
|
100
|
-
success: false,
|
|
101
|
-
action: input.action,
|
|
102
|
-
message: 'Erro na operação de config',
|
|
103
|
-
error: error instanceof Error ? error.message : String(error)
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
async get(params) {
|
|
108
|
-
try {
|
|
109
|
-
if (!params.key) {
|
|
110
|
-
throw new Error('key é obrigatório para get');
|
|
111
|
-
}
|
|
112
|
-
const scope = params.scope || 'local';
|
|
113
|
-
const gitCommand = `config --${scope} ${params.key}`;
|
|
114
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Obtendo configuração');
|
|
115
|
-
if (result.exitCode !== 0) {
|
|
116
|
-
throw new Error(`Falha ao obter configuração: ${result.output}`);
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
success: true,
|
|
120
|
-
action: 'get',
|
|
121
|
-
message: `Configuração ${params.key} obtida com sucesso`,
|
|
122
|
-
data: {
|
|
123
|
-
key: params.key,
|
|
124
|
-
value: result.output.trim(),
|
|
125
|
-
scope,
|
|
126
|
-
output: result.output
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
throw new Error(`Falha ao obter configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
async set(params) {
|
|
135
|
-
try {
|
|
136
|
-
if (!params.key || !params.value) {
|
|
137
|
-
throw new Error('key e value são obrigatórios para set');
|
|
138
|
-
}
|
|
139
|
-
const scope = params.scope || 'local';
|
|
140
|
-
const gitCommand = `config --${scope} ${params.key} "${params.value}"`;
|
|
141
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Definindo configuração');
|
|
142
|
-
if (result.exitCode !== 0) {
|
|
143
|
-
throw new Error(`Falha ao definir configuração: ${result.output}`);
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
success: true,
|
|
147
|
-
action: 'set',
|
|
148
|
-
message: `Configuração ${params.key} definida com sucesso`,
|
|
149
|
-
data: {
|
|
150
|
-
key: params.key,
|
|
151
|
-
value: params.value,
|
|
152
|
-
scope,
|
|
153
|
-
output: result.output
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
throw new Error(`Falha ao definir configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
async unset(params) {
|
|
162
|
-
try {
|
|
163
|
-
if (!params.key) {
|
|
164
|
-
throw new Error('key é obrigatório para unset');
|
|
165
|
-
}
|
|
166
|
-
const scope = params.scope || 'local';
|
|
167
|
-
const gitCommand = `config --${scope} --unset ${params.key}`;
|
|
168
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo configuração');
|
|
169
|
-
if (result.exitCode !== 0) {
|
|
170
|
-
throw new Error(`Falha ao remover configuração: ${result.output}`);
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
success: true,
|
|
174
|
-
action: 'unset',
|
|
175
|
-
message: `Configuração ${params.key} removida com sucesso`,
|
|
176
|
-
data: {
|
|
177
|
-
key: params.key,
|
|
178
|
-
scope,
|
|
179
|
-
output: result.output
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
throw new Error(`Falha ao remover configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
async list(params) {
|
|
188
|
-
try {
|
|
189
|
-
const scope = params.scope || 'local';
|
|
190
|
-
let gitCommand = `config --${scope} --list`;
|
|
191
|
-
if (params.pattern) {
|
|
192
|
-
gitCommand += ` | grep "${params.pattern}"`;
|
|
193
|
-
}
|
|
194
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Listando configurações');
|
|
195
|
-
if (result.exitCode !== 0) {
|
|
196
|
-
throw new Error(`Falha ao listar configurações: ${result.output}`);
|
|
197
|
-
}
|
|
198
|
-
const configs = result.output.split('\n')
|
|
199
|
-
.filter(line => line.trim())
|
|
200
|
-
.map(line => {
|
|
201
|
-
const [key, ...valueParts] = line.split('=');
|
|
202
|
-
return { key, value: valueParts.join('=') };
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
success: true,
|
|
206
|
-
action: 'list',
|
|
207
|
-
message: `Configurações ${scope} listadas com sucesso`,
|
|
208
|
-
data: {
|
|
209
|
-
scope,
|
|
210
|
-
pattern: params.pattern,
|
|
211
|
-
configs,
|
|
212
|
-
output: result.output
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
throw new Error(`Falha ao listar configurações: ${error instanceof Error ? error.message : String(error)}`);
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
async edit(params) {
|
|
221
|
-
try {
|
|
222
|
-
const scope = params.scope || 'local';
|
|
223
|
-
const gitCommand = `config --${scope} --edit`;
|
|
224
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Editando configuração');
|
|
225
|
-
if (result.exitCode !== 0) {
|
|
226
|
-
throw new Error(`Falha ao editar configuração: ${result.output}`);
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
success: true,
|
|
230
|
-
action: 'edit',
|
|
231
|
-
message: `Configuração ${scope} editada com sucesso`,
|
|
232
|
-
data: {
|
|
233
|
-
scope,
|
|
234
|
-
output: result.output
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
throw new Error(`Falha ao editar configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
async show(params) {
|
|
243
|
-
try {
|
|
244
|
-
const scope = params.scope || 'local';
|
|
245
|
-
let gitCommand = `config --${scope} --list`;
|
|
246
|
-
if (params.show_origin) {
|
|
247
|
-
gitCommand = `config --${scope} --show-origin --list`;
|
|
248
|
-
}
|
|
249
|
-
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Mostrando configurações');
|
|
250
|
-
if (result.exitCode !== 0) {
|
|
251
|
-
throw new Error(`Falha ao mostrar configurações: ${result.output}`);
|
|
252
|
-
}
|
|
253
|
-
return {
|
|
254
|
-
success: true,
|
|
255
|
-
action: 'show',
|
|
256
|
-
message: `Configurações ${scope} mostradas com sucesso`,
|
|
257
|
-
data: {
|
|
258
|
-
scope,
|
|
259
|
-
show_origin: params.show_origin,
|
|
260
|
-
output: result.output
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
throw new Error(`Falha ao mostrar configurações: ${error instanceof Error ? error.message : String(error)}`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitConfigTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
|
+
/**
|
|
7
|
+
* Tool: git-config
|
|
8
|
+
*
|
|
9
|
+
* DESCRIÇÃO:
|
|
10
|
+
* Gerenciamento de configuração Git (GitHub + Gitea) com múltiplas ações
|
|
11
|
+
*
|
|
12
|
+
* FUNCIONALIDADES:
|
|
13
|
+
* - Obter configurações
|
|
14
|
+
* - Definir configurações
|
|
15
|
+
* - Remover configurações
|
|
16
|
+
* - Listar configurações
|
|
17
|
+
* - Editar configuração
|
|
18
|
+
* - Mostrar configurações
|
|
19
|
+
*
|
|
20
|
+
* USO:
|
|
21
|
+
* - Para configurar usuário e email
|
|
22
|
+
* - Para configurar aliases
|
|
23
|
+
* - Para configurar branches padrão
|
|
24
|
+
* - Para configurar merge tools
|
|
25
|
+
* - Para configurar credenciais
|
|
26
|
+
*
|
|
27
|
+
* RECOMENDAÇÕES:
|
|
28
|
+
* - Use configurações globais para usuário
|
|
29
|
+
* - Use configurações locais para projeto
|
|
30
|
+
* - Documente configurações customizadas
|
|
31
|
+
*/
|
|
32
|
+
const GitConfigInputSchema = zod_1.z.object({
|
|
33
|
+
action: zod_1.z.enum(['get', 'set', 'unset', 'list', 'edit', 'show']),
|
|
34
|
+
// owner: obtido automaticamente do provider,
|
|
35
|
+
repo: zod_1.z.string(),
|
|
36
|
+
provider: zod_1.z.enum(['gitea', 'github']).describe('Provider to use (gitea or github)'),
|
|
37
|
+
projectPath: zod_1.z.string().describe('Local project path for git operations'),
|
|
38
|
+
// Para get/set/unset
|
|
39
|
+
key: zod_1.z.string().optional(),
|
|
40
|
+
value: zod_1.z.string().optional(),
|
|
41
|
+
// Para set
|
|
42
|
+
scope: zod_1.z.enum(['local', 'global', 'system']).optional(),
|
|
43
|
+
// Para list
|
|
44
|
+
pattern: zod_1.z.string().optional(),
|
|
45
|
+
// Para show
|
|
46
|
+
show_origin: zod_1.z.boolean().optional(),
|
|
47
|
+
});
|
|
48
|
+
const GitConfigResultSchema = zod_1.z.object({
|
|
49
|
+
success: zod_1.z.boolean(),
|
|
50
|
+
action: zod_1.z.string(),
|
|
51
|
+
message: zod_1.z.string(),
|
|
52
|
+
data: zod_1.z.any().optional(),
|
|
53
|
+
error: zod_1.z.string().optional()
|
|
54
|
+
});
|
|
55
|
+
exports.gitConfigTool = {
|
|
56
|
+
name: 'git-config',
|
|
57
|
+
description: 'tool: Gerencia configurações Git para personalização do ambiente\n──────────────\naction get: obtém valor de configuração\naction get requires: repo, key, scope, provider\n───────────────\naction set: define valor de configuração\naction set requires: repo, key, value, scope, provider\n───────────────\naction unset: remove configuração\naction unset requires: repo, key, scope, provider\n───────────────\naction list: lista configurações\naction list requires: repo, pattern, scope, provider\n───────────────\naction edit: edita arquivo de configuração\naction edit requires: repo, scope, provider\n───────────────\naction show: mostra configurações com origem\naction show requires: repo, show_origin, provider',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
action: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
enum: ['get', 'set', 'unset', 'list', 'edit', 'show'],
|
|
64
|
+
description: 'Action to perform on config'
|
|
65
|
+
},
|
|
66
|
+
owner: { type: 'string', description: 'Repository owner' },
|
|
67
|
+
repo: { type: 'string', description: 'Repository name' },
|
|
68
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
69
|
+
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
70
|
+
key: { type: 'string', description: 'Config key' },
|
|
71
|
+
value: { type: 'string', description: 'Config value' },
|
|
72
|
+
scope: { type: 'string', enum: ['local', 'global', 'system'], description: 'Config scope' },
|
|
73
|
+
pattern: { type: 'string', description: 'Pattern for listing configs' },
|
|
74
|
+
show_origin: { type: 'boolean', description: 'Show origin of config values' }
|
|
75
|
+
},
|
|
76
|
+
required: ['action', 'repo', 'provider', 'projectPath']
|
|
77
|
+
},
|
|
78
|
+
async handler(input) {
|
|
79
|
+
try {
|
|
80
|
+
const validatedInput = GitConfigInputSchema.parse(input);
|
|
81
|
+
switch (validatedInput.action) {
|
|
82
|
+
case 'get':
|
|
83
|
+
return await this.get(validatedInput);
|
|
84
|
+
case 'set':
|
|
85
|
+
return await this.set(validatedInput);
|
|
86
|
+
case 'unset':
|
|
87
|
+
return await this.unset(validatedInput);
|
|
88
|
+
case 'list':
|
|
89
|
+
return await this.list(validatedInput);
|
|
90
|
+
case 'edit':
|
|
91
|
+
return await this.edit(validatedInput);
|
|
92
|
+
case 'show':
|
|
93
|
+
return await this.show(validatedInput);
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
action: input.action,
|
|
102
|
+
message: 'Erro na operação de config',
|
|
103
|
+
error: error instanceof Error ? error.message : String(error)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
async get(params) {
|
|
108
|
+
try {
|
|
109
|
+
if (!params.key) {
|
|
110
|
+
throw new Error('key é obrigatório para get');
|
|
111
|
+
}
|
|
112
|
+
const scope = params.scope || 'local';
|
|
113
|
+
const gitCommand = `config --${scope} ${params.key}`;
|
|
114
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Obtendo configuração');
|
|
115
|
+
if (result.exitCode !== 0) {
|
|
116
|
+
throw new Error(`Falha ao obter configuração: ${result.output}`);
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
success: true,
|
|
120
|
+
action: 'get',
|
|
121
|
+
message: `Configuração ${params.key} obtida com sucesso`,
|
|
122
|
+
data: {
|
|
123
|
+
key: params.key,
|
|
124
|
+
value: result.output.trim(),
|
|
125
|
+
scope,
|
|
126
|
+
output: result.output
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
throw new Error(`Falha ao obter configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
async set(params) {
|
|
135
|
+
try {
|
|
136
|
+
if (!params.key || !params.value) {
|
|
137
|
+
throw new Error('key e value são obrigatórios para set');
|
|
138
|
+
}
|
|
139
|
+
const scope = params.scope || 'local';
|
|
140
|
+
const gitCommand = `config --${scope} ${params.key} "${params.value}"`;
|
|
141
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Definindo configuração');
|
|
142
|
+
if (result.exitCode !== 0) {
|
|
143
|
+
throw new Error(`Falha ao definir configuração: ${result.output}`);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
action: 'set',
|
|
148
|
+
message: `Configuração ${params.key} definida com sucesso`,
|
|
149
|
+
data: {
|
|
150
|
+
key: params.key,
|
|
151
|
+
value: params.value,
|
|
152
|
+
scope,
|
|
153
|
+
output: result.output
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw new Error(`Falha ao definir configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
async unset(params) {
|
|
162
|
+
try {
|
|
163
|
+
if (!params.key) {
|
|
164
|
+
throw new Error('key é obrigatório para unset');
|
|
165
|
+
}
|
|
166
|
+
const scope = params.scope || 'local';
|
|
167
|
+
const gitCommand = `config --${scope} --unset ${params.key}`;
|
|
168
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Removendo configuração');
|
|
169
|
+
if (result.exitCode !== 0) {
|
|
170
|
+
throw new Error(`Falha ao remover configuração: ${result.output}`);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
action: 'unset',
|
|
175
|
+
message: `Configuração ${params.key} removida com sucesso`,
|
|
176
|
+
data: {
|
|
177
|
+
key: params.key,
|
|
178
|
+
scope,
|
|
179
|
+
output: result.output
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
throw new Error(`Falha ao remover configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
async list(params) {
|
|
188
|
+
try {
|
|
189
|
+
const scope = params.scope || 'local';
|
|
190
|
+
let gitCommand = `config --${scope} --list`;
|
|
191
|
+
if (params.pattern) {
|
|
192
|
+
gitCommand += ` | grep "${params.pattern}"`;
|
|
193
|
+
}
|
|
194
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Listando configurações');
|
|
195
|
+
if (result.exitCode !== 0) {
|
|
196
|
+
throw new Error(`Falha ao listar configurações: ${result.output}`);
|
|
197
|
+
}
|
|
198
|
+
const configs = result.output.split('\n')
|
|
199
|
+
.filter(line => line.trim())
|
|
200
|
+
.map(line => {
|
|
201
|
+
const [key, ...valueParts] = line.split('=');
|
|
202
|
+
return { key, value: valueParts.join('=') };
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
success: true,
|
|
206
|
+
action: 'list',
|
|
207
|
+
message: `Configurações ${scope} listadas com sucesso`,
|
|
208
|
+
data: {
|
|
209
|
+
scope,
|
|
210
|
+
pattern: params.pattern,
|
|
211
|
+
configs,
|
|
212
|
+
output: result.output
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
throw new Error(`Falha ao listar configurações: ${error instanceof Error ? error.message : String(error)}`);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
async edit(params) {
|
|
221
|
+
try {
|
|
222
|
+
const scope = params.scope || 'local';
|
|
223
|
+
const gitCommand = `config --${scope} --edit`;
|
|
224
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Editando configuração');
|
|
225
|
+
if (result.exitCode !== 0) {
|
|
226
|
+
throw new Error(`Falha ao editar configuração: ${result.output}`);
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
success: true,
|
|
230
|
+
action: 'edit',
|
|
231
|
+
message: `Configuração ${scope} editada com sucesso`,
|
|
232
|
+
data: {
|
|
233
|
+
scope,
|
|
234
|
+
output: result.output
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
throw new Error(`Falha ao editar configuração: ${error instanceof Error ? error.message : String(error)}`);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
async show(params) {
|
|
243
|
+
try {
|
|
244
|
+
const scope = params.scope || 'local';
|
|
245
|
+
let gitCommand = `config --${scope} --list`;
|
|
246
|
+
if (params.show_origin) {
|
|
247
|
+
gitCommand = `config --${scope} --show-origin --list`;
|
|
248
|
+
}
|
|
249
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(gitCommand, params.projectPath, 'Mostrando configurações');
|
|
250
|
+
if (result.exitCode !== 0) {
|
|
251
|
+
throw new Error(`Falha ao mostrar configurações: ${result.output}`);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
success: true,
|
|
255
|
+
action: 'show',
|
|
256
|
+
message: `Configurações ${scope} mostradas com sucesso`,
|
|
257
|
+
data: {
|
|
258
|
+
scope,
|
|
259
|
+
show_origin: params.show_origin,
|
|
260
|
+
output: result.output
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
throw new Error(`Falha ao mostrar configurações: ${error instanceof Error ? error.message : String(error)}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
269
|
//# sourceMappingURL=git-config.js.map
|