@andre.buzeli/git-mcp 16.0.6 → 16.1.2

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.
@@ -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 = `Reset Git - desfaz commits e/ou mudanças.
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 { name: "git-reset", description, inputSchema, handle };
117
+ return {
118
+ name: "git-reset",
119
+ description,
120
+ inputSchema,
121
+ handle,
122
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false }
123
+ };
105
124
  }
@@ -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",
@@ -41,7 +41,11 @@ export function createGitStashTool(git) {
41
41
  additionalProperties: false
42
42
  };
43
43
 
44
- const description = `Gerenciamento de stash Git - salva mudanças temporariamente.
44
+ const description = `IMPORTANTE projectPath:
45
+ Informe o caminho absoluto do projeto aberto no IDE. O servidor MCP não tem acesso ao
46
+ contexto do IDE e não consegue detectar automaticamente qual projeto está sendo trabalhado.
47
+
48
+ Gerenciamento de stash Git - salva mudanças temporariamente.
45
49
 
46
50
  QUANDO USAR STASH:
47
51
  - Precisa trocar de branch mas tem mudanças não commitadas
@@ -117,5 +121,11 @@ AÇÕES:
117
121
  }
118
122
  }
119
123
 
120
- return { name: "git-stash", description, inputSchema, handle };
124
+ return {
125
+ name: "git-stash",
126
+ description,
127
+ inputSchema,
128
+ handle,
129
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
130
+ };
121
131
  }
@@ -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 = `Sincronização com repositórios remotos (GitHub/Gitea).
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 { name: "git-sync", description, inputSchema, handle };
132
+ return {
133
+ name: "git-sync",
134
+ description,
135
+ inputSchema,
136
+ handle,
137
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
138
+ };
129
139
  }
@@ -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 = `Gerenciamento de tags Git para versionamento.
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 { name: "git-tags", description, inputSchema, handle };
116
+ return {
117
+ name: "git-tags",
118
+ description,
119
+ inputSchema,
120
+ handle,
121
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
122
+ };
113
123
  }