@andre.buzeli/git-mcp 16.0.8 → 16.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -29
- package/src/index.js +205 -147
- package/src/resources/index.js +3 -3
- package/src/tools/git-branches.js +13 -3
- package/src/tools/git-clone.js +48 -85
- package/src/tools/git-config.js +13 -3
- package/src/tools/git-diff.js +122 -137
- package/src/tools/git-files.js +13 -3
- package/src/tools/git-help.js +322 -284
- package/src/tools/git-history.js +15 -3
- package/src/tools/git-ignore.js +13 -3
- package/src/tools/git-issues.js +13 -3
- package/src/tools/git-merge.js +13 -3
- package/src/tools/git-pulls.js +14 -4
- package/src/tools/git-remote.js +503 -492
- package/src/tools/git-reset.js +23 -4
- package/src/tools/git-stash.js +14 -3
- package/src/tools/git-sync.js +13 -3
- package/src/tools/git-tags.js +13 -3
- package/src/tools/git-workflow.js +605 -456
- package/src/tools/git-worktree.js +180 -0
- package/src/utils/errors.js +434 -433
- package/src/utils/gitAdapter.js +118 -6
- package/src/utils/mcpNotify.js +45 -0
- package/src/utils/repoHelpers.js +5 -31
- package/src/utils/hooks.js +0 -255
- package/src/utils/metrics.js +0 -198
package/src/tools/git-reset.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import Ajv from "ajv";
|
|
2
2
|
import { asToolError, asToolResult, errorToResponse } from "../utils/errors.js";
|
|
3
3
|
import { validateProjectPath, withRetry } from "../utils/repoHelpers.js";
|
|
4
|
+
import { sendLog, requestConfirmation } from "../utils/mcpNotify.js";
|
|
4
5
|
|
|
5
6
|
const ajv = new Ajv({ allErrors: true });
|
|
6
7
|
|
|
7
|
-
export function createGitResetTool(git) {
|
|
8
|
+
export function createGitResetTool(git, server) {
|
|
8
9
|
const inputSchema = {
|
|
9
10
|
type: "object",
|
|
10
11
|
properties: {
|
|
11
12
|
projectPath: {
|
|
12
13
|
type: "string",
|
|
13
|
-
description: "Caminho absoluto do diretório do projeto"
|
|
14
|
+
description: "Caminho absoluto do diretório do projeto no IDE (ex: '/home/user/meu-projeto' ou 'C:/Users/user/meu-projeto'). IMPORTANTE: este valor não pode ser inferido automaticamente pelo servidor — o agente deve fornecer o path real do projeto sendo trabalhado, não o diretório home do usuário."
|
|
14
15
|
},
|
|
15
16
|
action: {
|
|
16
17
|
type: "string",
|
|
@@ -30,7 +31,11 @@ export function createGitResetTool(git) {
|
|
|
30
31
|
additionalProperties: false
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const description = `
|
|
34
|
+
const description = `IMPORTANTE — projectPath:
|
|
35
|
+
Informe o caminho absoluto do projeto aberto no IDE. O servidor MCP não tem acesso ao
|
|
36
|
+
contexto do IDE e não consegue detectar automaticamente qual projeto está sendo trabalhado.
|
|
37
|
+
|
|
38
|
+
Reset Git - desfaz commits e/ou mudanças.
|
|
34
39
|
|
|
35
40
|
⚠️ CUIDADO: Reset pode causar perda de dados!
|
|
36
41
|
|
|
@@ -81,10 +86,18 @@ REFERÊNCIAS:
|
|
|
81
86
|
return asToolResult({ success: true, action: "mixed", ref, message: "Commits desfeitos, mudanças mantidas no working directory" });
|
|
82
87
|
}
|
|
83
88
|
if (action === "hard") {
|
|
89
|
+
await sendLog(server, "warning", "reset hard solicitado", { ref });
|
|
90
|
+
const confirmed = await requestConfirmation(server, `⚠️ Vai executar reset hard para ${ref}. Isso DESCARTA mudanças permanentemente. Confirmar?`);
|
|
91
|
+
if (!confirmed) return asToolError("CANCELLED", "Operação cancelada pelo usuário");
|
|
92
|
+
|
|
84
93
|
await withRetry(() => git.resetHard(projectPath, ref), 3, "reset-hard");
|
|
85
94
|
return asToolResult({ success: true, action: "hard", ref, message: "⚠️ Reset hard executado - mudanças descartadas" });
|
|
86
95
|
}
|
|
87
96
|
if (action === "hard-clean") {
|
|
97
|
+
await sendLog(server, "warning", "reset hard-clean solicitado", { ref });
|
|
98
|
+
const confirmed = await requestConfirmation(server, `⚠️ Vai executar reset hard-clean para ${ref}. Isso DESCARTA mudanças E arquivos não rastreados permanentemente. Confirmar?`);
|
|
99
|
+
if (!confirmed) return asToolError("CANCELLED", "Operação cancelada pelo usuário");
|
|
100
|
+
|
|
88
101
|
const result = await withRetry(() => git.resetHardClean(projectPath, ref), 3, "reset-hard-clean");
|
|
89
102
|
return asToolResult({
|
|
90
103
|
success: true,
|
|
@@ -101,5 +114,11 @@ REFERÊNCIAS:
|
|
|
101
114
|
}
|
|
102
115
|
}
|
|
103
116
|
|
|
104
|
-
return {
|
|
117
|
+
return {
|
|
118
|
+
name: "git-reset",
|
|
119
|
+
description,
|
|
120
|
+
inputSchema,
|
|
121
|
+
handle,
|
|
122
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false }
|
|
123
|
+
};
|
|
105
124
|
}
|
package/src/tools/git-stash.js
CHANGED
|
@@ -11,7 +11,7 @@ export function createGitStashTool(git) {
|
|
|
11
11
|
properties: {
|
|
12
12
|
projectPath: {
|
|
13
13
|
type: "string",
|
|
14
|
-
description: "Caminho absoluto do diretório do projeto"
|
|
14
|
+
description: "Caminho absoluto do diretório do projeto no IDE (ex: '/home/user/meu-projeto' ou 'C:/Users/user/meu-projeto'). IMPORTANTE: este valor não pode ser inferido automaticamente pelo servidor — o agente deve fornecer o path real do projeto sendo trabalhado, não o diretório home do usuário."
|
|
15
15
|
},
|
|
16
16
|
action: {
|
|
17
17
|
type: "string",
|
|
@@ -34,6 +34,7 @@ export function createGitStashTool(git) {
|
|
|
34
34
|
},
|
|
35
35
|
includeUntracked: {
|
|
36
36
|
type: "boolean",
|
|
37
|
+
default: false,
|
|
37
38
|
description: "Incluir arquivos não rastreados no stash (action='save'). Default: false"
|
|
38
39
|
}
|
|
39
40
|
},
|
|
@@ -41,7 +42,11 @@ export function createGitStashTool(git) {
|
|
|
41
42
|
additionalProperties: false
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
const description = `
|
|
45
|
+
const description = `IMPORTANTE — projectPath:
|
|
46
|
+
Informe o caminho absoluto do projeto aberto no IDE. O servidor MCP não tem acesso ao
|
|
47
|
+
contexto do IDE e não consegue detectar automaticamente qual projeto está sendo trabalhado.
|
|
48
|
+
|
|
49
|
+
Gerenciamento de stash Git - salva mudanças temporariamente.
|
|
45
50
|
|
|
46
51
|
QUANDO USAR STASH:
|
|
47
52
|
- Precisa trocar de branch mas tem mudanças não commitadas
|
|
@@ -117,5 +122,11 @@ AÇÕES:
|
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
return {
|
|
125
|
+
return {
|
|
126
|
+
name: "git-stash",
|
|
127
|
+
description,
|
|
128
|
+
inputSchema,
|
|
129
|
+
handle,
|
|
130
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
|
|
131
|
+
};
|
|
121
132
|
}
|
package/src/tools/git-sync.js
CHANGED
|
@@ -10,7 +10,7 @@ export function createGitSyncTool(git) {
|
|
|
10
10
|
properties: {
|
|
11
11
|
projectPath: {
|
|
12
12
|
type: "string",
|
|
13
|
-
description: "Caminho absoluto do diretório do projeto"
|
|
13
|
+
description: "Caminho absoluto do diretório do projeto no IDE (ex: '/home/user/meu-projeto' ou 'C:/Users/user/meu-projeto'). IMPORTANTE: este valor não pode ser inferido automaticamente pelo servidor — o agente deve fornecer o path real do projeto sendo trabalhado, não o diretório home do usuário."
|
|
14
14
|
},
|
|
15
15
|
action: {
|
|
16
16
|
type: "string",
|
|
@@ -32,7 +32,11 @@ export function createGitSyncTool(git) {
|
|
|
32
32
|
additionalProperties: false
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const description = `
|
|
35
|
+
const description = `IMPORTANTE — projectPath:
|
|
36
|
+
Informe o caminho absoluto do projeto aberto no IDE. O servidor MCP não tem acesso ao
|
|
37
|
+
contexto do IDE e não consegue detectar automaticamente qual projeto está sendo trabalhado.
|
|
38
|
+
|
|
39
|
+
Sincronização com repositórios remotos (GitHub/Gitea).
|
|
36
40
|
|
|
37
41
|
DIFERENÇA FETCH vs PULL:
|
|
38
42
|
- fetch: Seguro - apenas baixa, não modifica working directory
|
|
@@ -125,5 +129,11 @@ NOTA: Se pull falhar com conflito, resolva manualmente e faça commit.`;
|
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
return {
|
|
132
|
+
return {
|
|
133
|
+
name: "git-sync",
|
|
134
|
+
description,
|
|
135
|
+
inputSchema,
|
|
136
|
+
handle,
|
|
137
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
|
|
138
|
+
};
|
|
129
139
|
}
|
package/src/tools/git-tags.js
CHANGED
|
@@ -10,7 +10,7 @@ export function createGitTagsTool(git) {
|
|
|
10
10
|
properties: {
|
|
11
11
|
projectPath: {
|
|
12
12
|
type: "string",
|
|
13
|
-
description: "Caminho absoluto do diretório do projeto"
|
|
13
|
+
description: "Caminho absoluto do diretório do projeto no IDE (ex: '/home/user/meu-projeto' ou 'C:/Users/user/meu-projeto'). IMPORTANTE: este valor não pode ser inferido automaticamente pelo servidor — o agente deve fornecer o path real do projeto sendo trabalhado, não o diretório home do usuário."
|
|
14
14
|
},
|
|
15
15
|
action: {
|
|
16
16
|
type: "string",
|
|
@@ -38,7 +38,11 @@ export function createGitTagsTool(git) {
|
|
|
38
38
|
additionalProperties: false
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const description = `
|
|
41
|
+
const description = `IMPORTANTE — projectPath:
|
|
42
|
+
Informe o caminho absoluto do projeto aberto no IDE. O servidor MCP não tem acesso ao
|
|
43
|
+
contexto do IDE e não consegue detectar automaticamente qual projeto está sendo trabalhado.
|
|
44
|
+
|
|
45
|
+
Gerenciamento de tags Git para versionamento.
|
|
42
46
|
|
|
43
47
|
AÇÕES DISPONÍVEIS:
|
|
44
48
|
- list: Ver todas as tags existentes
|
|
@@ -109,5 +113,11 @@ FLUXO TÍPICO:
|
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
return {
|
|
116
|
+
return {
|
|
117
|
+
name: "git-tags",
|
|
118
|
+
description,
|
|
119
|
+
inputSchema,
|
|
120
|
+
handle,
|
|
121
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
|
|
122
|
+
};
|
|
113
123
|
}
|