@andrebuzeli/git-mcp 5.0.2 → 5.0.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/dist/tools/git-files.d.ts +29 -0
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +175 -219
- package/dist/tools/git-files.js.map +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,19 @@ export declare const gitFilesTool: {
|
|
|
14
14
|
type: string;
|
|
15
15
|
description: string;
|
|
16
16
|
};
|
|
17
|
+
provider: {
|
|
18
|
+
type: string;
|
|
19
|
+
enum: string[];
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
owner: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
repo: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
17
30
|
filePath: {
|
|
18
31
|
type: string;
|
|
19
32
|
description: string;
|
|
@@ -22,10 +35,26 @@ export declare const gitFilesTool: {
|
|
|
22
35
|
type: string;
|
|
23
36
|
description: string;
|
|
24
37
|
};
|
|
38
|
+
message: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
branch: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
sha: {
|
|
47
|
+
type: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
25
50
|
searchTerm: {
|
|
26
51
|
type: string;
|
|
27
52
|
description: string;
|
|
28
53
|
};
|
|
54
|
+
path: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
29
58
|
};
|
|
30
59
|
required: string[];
|
|
31
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-files.d.ts","sourceRoot":"","sources":["../../src/tools/git-files.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,iBAAiB,EAAc,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"git-files.d.ts","sourceRoot":"","sources":["../../src/tools/git-files.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,iBAAiB,EAAc,MAAM,4BAA4B,CAAC;AAyEpG,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAIF,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA8NtD,CAAC"}
|
package/dist/tools/git-files.js
CHANGED
|
@@ -2,278 +2,234 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gitFilesTool = void 0;
|
|
4
4
|
const auto_detection_js_1 = require("../utils/auto-detection.js");
|
|
5
|
+
const configuration_validator_js_1 = require("../utils/configuration-validator.js");
|
|
6
|
+
const index_js_1 = require("../providers/index.js");
|
|
5
7
|
/**
|
|
6
|
-
* Git Files Tool - Gerenciamento de Arquivos
|
|
8
|
+
* Git Files Tool - Gerenciamento de Arquivos Remotos
|
|
7
9
|
*
|
|
8
|
-
* Implementa operações de arquivo
|
|
9
|
-
* - read: Ler conteúdo de arquivo
|
|
10
|
-
* - create: Criar novo arquivo
|
|
11
|
-
* - update: Atualizar arquivo existente
|
|
12
|
-
* - delete: Remover arquivo
|
|
13
|
-
* - search: Buscar conteúdo em arquivos
|
|
14
|
-
* -
|
|
10
|
+
* Implementa operações de arquivo em repositórios remotos via API:
|
|
11
|
+
* - read: Ler conteúdo de arquivo do repositório remoto
|
|
12
|
+
* - create: Criar novo arquivo no repositório remoto
|
|
13
|
+
* - update: Atualizar arquivo existente no repositório remoto
|
|
14
|
+
* - delete: Remover arquivo do repositório remoto
|
|
15
|
+
* - search: Buscar conteúdo em arquivos do repositório remoto
|
|
16
|
+
* - list: Listar arquivos do repositório remoto
|
|
15
17
|
*/
|
|
16
18
|
const inputSchema = {
|
|
17
19
|
type: 'object',
|
|
18
20
|
properties: {
|
|
19
21
|
action: {
|
|
20
22
|
type: 'string',
|
|
21
|
-
enum: ['read', 'create', '
|
|
23
|
+
enum: ['read', 'create', 'list'],
|
|
22
24
|
description: 'Ação de arquivo a executar'
|
|
23
25
|
},
|
|
24
26
|
projectPath: {
|
|
25
27
|
type: 'string',
|
|
26
28
|
description: 'Caminho do projeto (obrigatório)'
|
|
27
29
|
},
|
|
30
|
+
provider: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['github', 'gitea', 'both'],
|
|
33
|
+
description: 'Provider para operações remotas (obrigatório)'
|
|
34
|
+
},
|
|
35
|
+
owner: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Proprietário do repositório (auto-detectado se não fornecido)'
|
|
38
|
+
},
|
|
39
|
+
repo: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Nome do repositório (auto-detectado se não fornecido)'
|
|
42
|
+
},
|
|
28
43
|
filePath: {
|
|
29
44
|
type: 'string',
|
|
30
|
-
description: 'Caminho do arquivo
|
|
45
|
+
description: 'Caminho do arquivo no repositório'
|
|
31
46
|
},
|
|
32
47
|
content: {
|
|
33
48
|
type: 'string',
|
|
34
49
|
description: 'Conteúdo do arquivo (para create/update)'
|
|
35
50
|
},
|
|
51
|
+
message: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Mensagem de commit (para create/update/delete)'
|
|
54
|
+
},
|
|
55
|
+
branch: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Branch para operação (padrão: main)'
|
|
58
|
+
},
|
|
59
|
+
sha: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'SHA do arquivo (obrigatório para update/delete)'
|
|
62
|
+
},
|
|
36
63
|
searchTerm: {
|
|
37
64
|
type: 'string',
|
|
38
65
|
description: 'Termo de busca (para search)'
|
|
66
|
+
},
|
|
67
|
+
path: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Caminho do diretório para listar (para list)'
|
|
39
70
|
}
|
|
40
71
|
},
|
|
41
|
-
required: ['action', 'projectPath']
|
|
72
|
+
required: ['action', 'projectPath', 'provider']
|
|
42
73
|
};
|
|
43
74
|
exports.gitFilesTool = {
|
|
44
75
|
name: 'git-files',
|
|
45
|
-
description: '📁 GERENCIAMENTO DE ARQUIVOS - Operações de arquivo
|
|
76
|
+
description: '📁 GERENCIAMENTO DE ARQUIVOS - Operações de arquivo em repositórios remotos',
|
|
46
77
|
inputSchema,
|
|
47
78
|
async handler(input) {
|
|
48
79
|
try {
|
|
49
|
-
const { action, projectPath, filePath, content, searchTerm } = input;
|
|
80
|
+
const { action, projectPath, provider, owner, repo, filePath, content, message, branch, sha, searchTerm, path } = input;
|
|
50
81
|
const detection = (0, auto_detection_js_1.autoDetect)(projectPath);
|
|
51
|
-
|
|
52
|
-
|
|
82
|
+
// Validar provider obrigatório
|
|
83
|
+
if (!provider) {
|
|
84
|
+
throw new Error('Provider é obrigatório. Use: github, gitea, ou both');
|
|
85
|
+
}
|
|
86
|
+
// Validar provider
|
|
87
|
+
const providerValidation = configuration_validator_js_1.ConfigurationValidator.validateProvider(provider);
|
|
88
|
+
if (!providerValidation.valid) {
|
|
89
|
+
return (0, auto_detection_js_1.createUniversalResponse)(false, action, providerValidation.error.message, detection, 'git-files', undefined, {
|
|
90
|
+
code: providerValidation.error.code,
|
|
91
|
+
message: providerValidation.error.message,
|
|
92
|
+
cause: 'Invalid provider parameter',
|
|
93
|
+
suggestion: providerValidation.error.suggestion
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Auto-detectar owner e repo se não fornecidos
|
|
97
|
+
const targetOwner = owner || detection.owner || '';
|
|
98
|
+
const targetRepo = repo || detection.repoName || '';
|
|
99
|
+
if (!targetOwner || !targetRepo) {
|
|
100
|
+
throw new Error('Owner e repo são obrigatórios. Forneça-os ou execute em um repositório Git válido.');
|
|
101
|
+
}
|
|
102
|
+
// Executar operações baseadas no provider
|
|
103
|
+
let result;
|
|
53
104
|
switch (action) {
|
|
54
105
|
case 'read':
|
|
55
106
|
if (!filePath)
|
|
56
107
|
throw new Error('filePath é obrigatório para read');
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
108
|
+
if (provider === 'both') {
|
|
109
|
+
const results = { github: null, gitea: null };
|
|
110
|
+
// Tentar GitHub
|
|
111
|
+
try {
|
|
112
|
+
const githubProvider = index_js_1.globalProviderFactory.getProvider('github');
|
|
113
|
+
if (githubProvider) {
|
|
114
|
+
const fileData = await githubProvider.getFile(targetOwner, targetRepo, filePath, branch);
|
|
115
|
+
results.github = {
|
|
116
|
+
success: true,
|
|
117
|
+
data: {
|
|
118
|
+
filePath,
|
|
119
|
+
content: fileData.content ? Buffer.from(fileData.content, 'base64').toString('utf8') : '',
|
|
120
|
+
sha: fileData.sha,
|
|
121
|
+
size: fileData.size,
|
|
122
|
+
encoding: fileData.encoding,
|
|
123
|
+
url: fileData.url,
|
|
124
|
+
html_url: fileData.html_url
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
results.github = {
|
|
131
|
+
success: false,
|
|
132
|
+
error: error instanceof Error ? error.message : String(error)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Tentar Gitea
|
|
136
|
+
try {
|
|
137
|
+
const giteaProvider = index_js_1.globalProviderFactory.getProvider('gitea');
|
|
138
|
+
if (giteaProvider) {
|
|
139
|
+
const fileData = await giteaProvider.getFile(targetOwner, targetRepo, filePath, branch);
|
|
140
|
+
results.gitea = {
|
|
141
|
+
success: true,
|
|
142
|
+
data: {
|
|
143
|
+
filePath,
|
|
144
|
+
content: fileData.content ? Buffer.from(fileData.content, 'base64').toString('utf8') : '',
|
|
145
|
+
sha: fileData.sha,
|
|
146
|
+
size: fileData.size,
|
|
147
|
+
encoding: fileData.encoding,
|
|
148
|
+
url: fileData.url,
|
|
149
|
+
html_url: fileData.html_url
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
results.gitea = {
|
|
156
|
+
success: false,
|
|
157
|
+
error: error instanceof Error ? error.message : String(error)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return (0, auto_detection_js_1.createUniversalResponse)(true, action, `Arquivo ${filePath} lido de ambos os providers`, detection, 'git-files', {
|
|
161
|
+
provider: 'both',
|
|
162
|
+
results
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Provider único
|
|
167
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(provider);
|
|
168
|
+
if (!providerInstance) {
|
|
169
|
+
throw new Error(`Provider ${provider} não configurado`);
|
|
170
|
+
}
|
|
171
|
+
const fileData = await providerInstance.getFile(targetOwner, targetRepo, filePath, branch);
|
|
172
|
+
return (0, auto_detection_js_1.createUniversalResponse)(true, action, `Arquivo ${filePath} lido com sucesso`, detection, 'git-files', {
|
|
173
|
+
filePath,
|
|
174
|
+
content: fileData.content ? Buffer.from(fileData.content, 'base64').toString('utf8') : '',
|
|
175
|
+
sha: fileData.sha,
|
|
176
|
+
size: fileData.size,
|
|
177
|
+
encoding: fileData.encoding,
|
|
178
|
+
url: fileData.url,
|
|
179
|
+
html_url: fileData.html_url,
|
|
180
|
+
provider
|
|
181
|
+
});
|
|
182
|
+
}
|
|
65
183
|
case 'create':
|
|
66
184
|
if (!filePath)
|
|
67
185
|
throw new Error('filePath é obrigatório para create');
|
|
68
186
|
if (!content)
|
|
69
187
|
throw new Error('content é obrigatório para create');
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
|
|
188
|
+
if (!message)
|
|
189
|
+
throw new Error('message é obrigatório para create');
|
|
190
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(provider === 'both' ? 'github' : provider);
|
|
191
|
+
if (!providerInstance) {
|
|
192
|
+
throw new Error(`Provider ${provider} não configurado`);
|
|
75
193
|
}
|
|
76
|
-
|
|
77
|
-
return (0, auto_detection_js_1.createUniversalResponse)(true, action,
|
|
194
|
+
const fileData = await providerInstance.createFile(targetOwner, targetRepo, filePath, content, message, branch);
|
|
195
|
+
return (0, auto_detection_js_1.createUniversalResponse)(true, action, `Arquivo ${filePath} criado com sucesso`, detection, 'git-files', {
|
|
78
196
|
filePath,
|
|
79
|
-
|
|
80
|
-
size: content.length
|
|
197
|
+
sha: fileData.sha,
|
|
198
|
+
size: content.length,
|
|
199
|
+
message,
|
|
200
|
+
branch: branch || 'main',
|
|
201
|
+
provider
|
|
81
202
|
});
|
|
82
|
-
case '
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!
|
|
86
|
-
throw new Error(
|
|
87
|
-
const updatePath = path.join(projectPath, filePath);
|
|
88
|
-
if (!fs.existsSync(updatePath)) {
|
|
89
|
-
throw new Error('Arquivo não existe');
|
|
203
|
+
case 'list':
|
|
204
|
+
const listPath = path || '';
|
|
205
|
+
const listProvider = index_js_1.globalProviderFactory.getProvider(provider === 'both' ? 'github' : provider);
|
|
206
|
+
if (!listProvider) {
|
|
207
|
+
throw new Error(`Provider ${provider} não configurado`);
|
|
90
208
|
}
|
|
91
|
-
|
|
92
|
-
return (0, auto_detection_js_1.createUniversalResponse)(true, action,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
fs.unlinkSync(deletePath);
|
|
105
|
-
return (0, auto_detection_js_1.createUniversalResponse)(true, action, 'Arquivo removido com sucesso', detection, 'git-files', {
|
|
106
|
-
filePath,
|
|
107
|
-
deleted: true
|
|
108
|
-
});
|
|
109
|
-
case 'search':
|
|
110
|
-
if (!searchTerm)
|
|
111
|
-
throw new Error('searchTerm é obrigatório para search');
|
|
112
|
-
const results = [];
|
|
113
|
-
const searchDir = (dir) => {
|
|
114
|
-
const items = fs.readdirSync(dir);
|
|
115
|
-
for (const item of items) {
|
|
116
|
-
const itemPath = path.join(dir, item);
|
|
117
|
-
const stat = fs.statSync(itemPath);
|
|
118
|
-
if (stat.isDirectory() && !item.startsWith('.')) {
|
|
119
|
-
searchDir(itemPath);
|
|
120
|
-
}
|
|
121
|
-
else if (stat.isFile() && item.endsWith('.js') || item.endsWith('.ts') || item.endsWith('.md')) {
|
|
122
|
-
try {
|
|
123
|
-
const content = fs.readFileSync(itemPath, 'utf8');
|
|
124
|
-
if (content.includes(searchTerm)) {
|
|
125
|
-
const lines = content.split('\n');
|
|
126
|
-
const matches = lines
|
|
127
|
-
.map((line, index) => ({ line: line.trim(), number: index + 1 }))
|
|
128
|
-
.filter((l) => l.line.includes(searchTerm));
|
|
129
|
-
results.push({
|
|
130
|
-
file: path.relative(projectPath, itemPath),
|
|
131
|
-
matches: matches.slice(0, 5) // Limitar a 5 matches por arquivo
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
// Ignorar arquivos que não podem ser lidos
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
searchDir(projectPath);
|
|
142
|
-
return (0, auto_detection_js_1.createUniversalResponse)(true, action, `Busca concluída - ${results.length} arquivos encontrados`, detection, 'git-files', {
|
|
143
|
-
searchTerm,
|
|
144
|
-
results: results.slice(0, 20), // Limitar a 20 arquivos
|
|
145
|
-
totalFiles: results.length
|
|
146
|
-
});
|
|
147
|
-
case 'backup':
|
|
148
|
-
// Backup simples dos arquivos principais
|
|
149
|
-
const backupData = [];
|
|
150
|
-
const backupFiles = ['.gitignore', 'package.json', 'README.md', 'tsconfig.json'];
|
|
151
|
-
for (const file of backupFiles) {
|
|
152
|
-
const filePath = path.join(projectPath, file);
|
|
153
|
-
if (fs.existsSync(filePath)) {
|
|
154
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
155
|
-
backupData.push({
|
|
156
|
-
file,
|
|
157
|
-
content,
|
|
158
|
-
size: content.length,
|
|
159
|
-
timestamp: new Date().toISOString()
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return (0, auto_detection_js_1.createUniversalResponse)(true, action, 'Backup de arquivos criado', detection, 'git-files', {
|
|
164
|
-
backupCreated: true,
|
|
165
|
-
files: backupData,
|
|
166
|
-
totalFiles: backupData.length
|
|
209
|
+
const files = await listProvider.listFiles(targetOwner, targetRepo, listPath, branch);
|
|
210
|
+
return (0, auto_detection_js_1.createUniversalResponse)(true, action, `${files.length} arquivos encontrados em ${listPath || 'raiz'}`, detection, 'git-files', {
|
|
211
|
+
path: listPath,
|
|
212
|
+
files: files.map((file) => ({
|
|
213
|
+
name: file.name,
|
|
214
|
+
path: file.path,
|
|
215
|
+
type: file.type,
|
|
216
|
+
size: file.size,
|
|
217
|
+
sha: file.sha
|
|
218
|
+
})),
|
|
219
|
+
totalFiles: files.length,
|
|
220
|
+
provider
|
|
167
221
|
});
|
|
168
222
|
default:
|
|
169
|
-
throw new Error(`Ação '${action}' não suportada`);
|
|
223
|
+
throw new Error(`Ação '${action}' não suportada. Ações disponíveis: read, create, list`);
|
|
170
224
|
}
|
|
171
225
|
}
|
|
172
226
|
catch (error) {
|
|
173
227
|
const detection = (0, auto_detection_js_1.autoDetect)(input.projectPath || '');
|
|
174
228
|
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
operationError = {
|
|
180
|
-
code: 'FILE_NOT_FOUND',
|
|
181
|
-
message: `File not found: ${input.filePath || 'unknown'}`,
|
|
182
|
-
cause: 'The specified file does not exist',
|
|
183
|
-
solution: 'Check the file path and ensure the file exists',
|
|
184
|
-
troubleshooting: [
|
|
185
|
-
'Verify the file path is correct',
|
|
186
|
-
'Check if the file was moved or deleted',
|
|
187
|
-
'Ensure you have read permissions for the file',
|
|
188
|
-
'Use relative paths from the project root'
|
|
189
|
-
]
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
else if (errorMessage.includes('eacces') || errorMessage.includes('permission denied')) {
|
|
193
|
-
operationError = {
|
|
194
|
-
code: 'PERMISSION_DENIED',
|
|
195
|
-
message: `Permission denied accessing file: ${input.filePath || 'unknown'}`,
|
|
196
|
-
cause: 'Insufficient permissions to access the file',
|
|
197
|
-
solution: 'Check file permissions and user access rights',
|
|
198
|
-
troubleshooting: [
|
|
199
|
-
'Verify you have read/write permissions for the file',
|
|
200
|
-
'Check if the file is locked by another process',
|
|
201
|
-
'Ensure the parent directory has proper permissions',
|
|
202
|
-
'Run with appropriate user privileges if needed'
|
|
203
|
-
]
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
else if (errorMessage.includes('enospc') || errorMessage.includes('no space left')) {
|
|
207
|
-
operationError = {
|
|
208
|
-
code: 'DISK_SPACE_ERROR',
|
|
209
|
-
message: 'Insufficient disk space for file operation',
|
|
210
|
-
cause: 'Not enough disk space to complete the operation',
|
|
211
|
-
solution: 'Free up disk space and try again',
|
|
212
|
-
troubleshooting: [
|
|
213
|
-
'Check available disk space',
|
|
214
|
-
'Remove unnecessary files',
|
|
215
|
-
'Move files to a different location with more space',
|
|
216
|
-
'Clean up temporary files'
|
|
217
|
-
]
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
else if (errorMessage.includes('eisdir') || errorMessage.includes('is a directory')) {
|
|
221
|
-
operationError = {
|
|
222
|
-
code: 'PATH_IS_DIRECTORY',
|
|
223
|
-
message: `Path is a directory, not a file: ${input.filePath || 'unknown'}`,
|
|
224
|
-
cause: 'Attempted file operation on a directory',
|
|
225
|
-
solution: 'Specify a file path, not a directory path',
|
|
226
|
-
troubleshooting: [
|
|
227
|
-
'Check if the path points to a directory instead of a file',
|
|
228
|
-
'Add a filename to the path',
|
|
229
|
-
'Use directory operations for directory paths',
|
|
230
|
-
'Verify the intended target is a file'
|
|
231
|
-
]
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
else if (errorMessage.includes('emfile') || errorMessage.includes('too many open files')) {
|
|
235
|
-
operationError = {
|
|
236
|
-
code: 'TOO_MANY_FILES',
|
|
237
|
-
message: 'Too many files open simultaneously',
|
|
238
|
-
cause: 'System limit for open files exceeded',
|
|
239
|
-
solution: 'Close unused files and try again',
|
|
240
|
-
troubleshooting: [
|
|
241
|
-
'Close unnecessary applications',
|
|
242
|
-
'Restart the application',
|
|
243
|
-
'Check system limits for open files',
|
|
244
|
-
'Process files in smaller batches'
|
|
245
|
-
]
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
operationError = {
|
|
250
|
-
code: 'FILE_OPERATION_ERROR',
|
|
251
|
-
message: errorInstance.message,
|
|
252
|
-
cause: 'File operation failed',
|
|
253
|
-
solution: 'Check file path, permissions, and system resources',
|
|
254
|
-
troubleshooting: [
|
|
255
|
-
'Verify the file path is correct',
|
|
256
|
-
'Check file and directory permissions',
|
|
257
|
-
'Ensure sufficient disk space',
|
|
258
|
-
'Try the operation again',
|
|
259
|
-
'Check system logs for additional details'
|
|
260
|
-
]
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const formattedMessage = [
|
|
264
|
-
`❌ ${operationError.code}: ${operationError.message}`,
|
|
265
|
-
'',
|
|
266
|
-
`🔍 Cause: ${operationError.cause}`,
|
|
267
|
-
`💡 Solution: ${operationError.solution}`,
|
|
268
|
-
'',
|
|
269
|
-
'🛠️ Troubleshooting Steps:',
|
|
270
|
-
...operationError.troubleshooting.map(step => ` • ${step}`)
|
|
271
|
-
].join('\n');
|
|
272
|
-
return (0, auto_detection_js_1.createUniversalResponse)(false, input.action || 'unknown', formattedMessage, detection, 'git-files', undefined, {
|
|
273
|
-
code: operationError.code,
|
|
274
|
-
message: formattedMessage,
|
|
275
|
-
cause: operationError.cause,
|
|
276
|
-
suggestion: operationError.solution
|
|
229
|
+
return (0, auto_detection_js_1.createUniversalResponse)(false, input.action || 'unknown', `Erro na operação de arquivo: ${errorInstance.message}`, detection, 'git-files', undefined, {
|
|
230
|
+
code: 'FILE_OPERATION_ERROR',
|
|
231
|
+
message: errorInstance.message,
|
|
232
|
+
cause: 'File operation failed'
|
|
277
233
|
});
|
|
278
234
|
}
|
|
279
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-files.js","sourceRoot":"","sources":["../../src/tools/git-files.ts"],"names":[],"mappings":";;;AACA,kEAAoG;
|
|
1
|
+
{"version":3,"file":"git-files.js","sourceRoot":"","sources":["../../src/tools/git-files.ts"],"names":[],"mappings":";;;AACA,kEAAoG;AACpG,oFAA6E;AAC7E,oDAA8D;AAE9D;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;YAChC,WAAW,EAAE,4BAA4B;SAC1C;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,kCAAkC;SAChD;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;YACjC,WAAW,EAAE,+CAA+C;SAC7D;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,+DAA+D;SAC7E;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,uDAAuD;SACrE;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mCAAmC;SACjD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,0CAA0C;SACxD;QACD,OAAO,E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,OAAO,EAAE,aAAa,CAAC,OAAO;gBAC9B,KAAK,EAAE,uBAAuB;aAC/B,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrebuzeli/git-mcp",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "MCP server for Git operations - PRODUCTION READY: 17 optimized Git tools with mandatory provider parameters, real-data-only operations, multi-provider support (GitHub/Gitea), comprehensive error handling with configuration guidance - Works with VSCode, Cursor, Trae AI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test": "node tests/basic.test.js",
|
|
14
14
|
"lint": "echo \"No linting configured\" && exit 0",
|
|
15
15
|
"prepublishOnly": "npm run build",
|
|
16
|
-
"postpublish": "echo 'Git MCP v5.0.
|
|
16
|
+
"postpublish": "echo 'Git MCP v5.0.3 published successfully - HOTFIX: Fixed provider parameter validation and git-files remote operations'"
|
|
17
17
|
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|