@andrebuzeli/git-mcp 7.3.2 → 7.3.4
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/gitArchive.d.ts +34 -0
- package/dist/tools/gitArchive.js +35 -2
- package/dist/tools/gitConfig.d.ts +27 -0
- package/dist/tools/gitConfig.js +26 -2
- package/dist/tools/gitFiles.d.ts +45 -0
- package/dist/tools/gitFiles.js +80 -3
- package/dist/tools/gitPackages.d.ts +128 -0
- package/dist/tools/gitPackages.js +134 -6
- package/dist/tools/gitSync.d.ts +1 -20
- package/dist/tools/gitSync.js +38 -0
- package/dist/tools/gitWorkflow.js +31 -0
- package/package.json +1 -1
|
@@ -12,6 +12,10 @@ export declare class GitArchiveTool implements Tool {
|
|
|
12
12
|
valid?: undefined;
|
|
13
13
|
archive?: undefined;
|
|
14
14
|
error?: undefined;
|
|
15
|
+
extracted?: undefined;
|
|
16
|
+
extractTo?: undefined;
|
|
17
|
+
metadataPath?: undefined;
|
|
18
|
+
note?: undefined;
|
|
15
19
|
} | {
|
|
16
20
|
success: boolean;
|
|
17
21
|
archives: string[];
|
|
@@ -22,6 +26,10 @@ export declare class GitArchiveTool implements Tool {
|
|
|
22
26
|
valid?: undefined;
|
|
23
27
|
archive?: undefined;
|
|
24
28
|
error?: undefined;
|
|
29
|
+
extracted?: undefined;
|
|
30
|
+
extractTo?: undefined;
|
|
31
|
+
metadataPath?: undefined;
|
|
32
|
+
note?: undefined;
|
|
25
33
|
} | {
|
|
26
34
|
success: boolean;
|
|
27
35
|
archives: never[];
|
|
@@ -32,6 +40,10 @@ export declare class GitArchiveTool implements Tool {
|
|
|
32
40
|
valid?: undefined;
|
|
33
41
|
archive?: undefined;
|
|
34
42
|
error?: undefined;
|
|
43
|
+
extracted?: undefined;
|
|
44
|
+
extractTo?: undefined;
|
|
45
|
+
metadataPath?: undefined;
|
|
46
|
+
note?: undefined;
|
|
35
47
|
} | {
|
|
36
48
|
success: boolean;
|
|
37
49
|
valid: boolean;
|
|
@@ -42,6 +54,10 @@ export declare class GitArchiveTool implements Tool {
|
|
|
42
54
|
count?: undefined;
|
|
43
55
|
archivesDir?: undefined;
|
|
44
56
|
error?: undefined;
|
|
57
|
+
extracted?: undefined;
|
|
58
|
+
extractTo?: undefined;
|
|
59
|
+
metadataPath?: undefined;
|
|
60
|
+
note?: undefined;
|
|
45
61
|
} | {
|
|
46
62
|
success: boolean;
|
|
47
63
|
valid: boolean;
|
|
@@ -52,5 +68,23 @@ export declare class GitArchiveTool implements Tool {
|
|
|
52
68
|
count?: undefined;
|
|
53
69
|
archivesDir?: undefined;
|
|
54
70
|
archive?: undefined;
|
|
71
|
+
extracted?: undefined;
|
|
72
|
+
extractTo?: undefined;
|
|
73
|
+
metadataPath?: undefined;
|
|
74
|
+
note?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
success: boolean;
|
|
77
|
+
extracted: boolean;
|
|
78
|
+
archivePath: any;
|
|
79
|
+
extractTo: any;
|
|
80
|
+
archive: any;
|
|
81
|
+
metadataPath: string;
|
|
82
|
+
message: string;
|
|
83
|
+
note: string;
|
|
84
|
+
archives?: undefined;
|
|
85
|
+
count?: undefined;
|
|
86
|
+
archivesDir?: undefined;
|
|
87
|
+
valid?: undefined;
|
|
88
|
+
error?: undefined;
|
|
55
89
|
}>;
|
|
56
90
|
}
|
package/dist/tools/gitArchive.js
CHANGED
|
@@ -79,8 +79,41 @@ export class GitArchiveTool {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
case 'extract':
|
|
83
|
-
|
|
82
|
+
case 'extract': {
|
|
83
|
+
const archivePath = params.archivePath;
|
|
84
|
+
const extractTo = params.extractTo || projectPath;
|
|
85
|
+
if (!archivePath)
|
|
86
|
+
throw new MCPError('VALIDATION_ERROR', 'archivePath is required');
|
|
87
|
+
if (!extractTo)
|
|
88
|
+
throw new MCPError('VALIDATION_ERROR', 'extractTo is required');
|
|
89
|
+
try {
|
|
90
|
+
// Ler o arquivo de archive
|
|
91
|
+
const content = await fs.readFile(archivePath, 'utf-8');
|
|
92
|
+
const archive = JSON.parse(content);
|
|
93
|
+
// Verificar se é um archive válido
|
|
94
|
+
if (!archive.projectPath || !archive.timestamp) {
|
|
95
|
+
throw new MCPError('VALIDATION_ERROR', 'Invalid archive format');
|
|
96
|
+
}
|
|
97
|
+
// Criar diretório de extração
|
|
98
|
+
await fs.mkdir(extractTo, { recursive: true });
|
|
99
|
+
// Copiar informações do archive para um arquivo de metadados
|
|
100
|
+
const metadataPath = path.join(extractTo, '.archive-metadata.json');
|
|
101
|
+
await fs.writeFile(metadataPath, JSON.stringify(archive, null, 2), 'utf-8');
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
extracted: true,
|
|
105
|
+
archivePath,
|
|
106
|
+
extractTo,
|
|
107
|
+
archive,
|
|
108
|
+
metadataPath,
|
|
109
|
+
message: 'Archive extracted successfully. Metadata saved to .archive-metadata.json',
|
|
110
|
+
note: 'This is a simplified extraction. For full restoration, use git commands or backup tools.',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new MCPError('EXTRACT_ERROR', `Failed to extract archive: ${error.message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
84
117
|
default:
|
|
85
118
|
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
86
119
|
}
|
|
@@ -9,6 +9,10 @@ export declare class GitConfigTool implements Tool {
|
|
|
9
9
|
message?: undefined;
|
|
10
10
|
scope?: undefined;
|
|
11
11
|
configs?: undefined;
|
|
12
|
+
configFile?: undefined;
|
|
13
|
+
content?: undefined;
|
|
14
|
+
lines?: undefined;
|
|
15
|
+
note?: undefined;
|
|
12
16
|
} | {
|
|
13
17
|
success: boolean;
|
|
14
18
|
key: any;
|
|
@@ -16,6 +20,10 @@ export declare class GitConfigTool implements Tool {
|
|
|
16
20
|
value?: undefined;
|
|
17
21
|
scope?: undefined;
|
|
18
22
|
configs?: undefined;
|
|
23
|
+
configFile?: undefined;
|
|
24
|
+
content?: undefined;
|
|
25
|
+
lines?: undefined;
|
|
26
|
+
note?: undefined;
|
|
19
27
|
} | {
|
|
20
28
|
success: boolean;
|
|
21
29
|
scope: string;
|
|
@@ -23,6 +31,10 @@ export declare class GitConfigTool implements Tool {
|
|
|
23
31
|
key?: undefined;
|
|
24
32
|
value?: undefined;
|
|
25
33
|
message?: undefined;
|
|
34
|
+
configFile?: undefined;
|
|
35
|
+
content?: undefined;
|
|
36
|
+
lines?: undefined;
|
|
37
|
+
note?: undefined;
|
|
26
38
|
} | {
|
|
27
39
|
success: boolean;
|
|
28
40
|
key: any;
|
|
@@ -30,5 +42,20 @@ export declare class GitConfigTool implements Tool {
|
|
|
30
42
|
scope: string | undefined;
|
|
31
43
|
message?: undefined;
|
|
32
44
|
configs?: undefined;
|
|
45
|
+
configFile?: undefined;
|
|
46
|
+
content?: undefined;
|
|
47
|
+
lines?: undefined;
|
|
48
|
+
note?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
success: boolean;
|
|
51
|
+
configFile: string;
|
|
52
|
+
scope: string;
|
|
53
|
+
content: string;
|
|
54
|
+
lines: number;
|
|
55
|
+
message: string;
|
|
56
|
+
note: string;
|
|
57
|
+
key?: undefined;
|
|
58
|
+
value?: undefined;
|
|
59
|
+
configs?: undefined;
|
|
33
60
|
}>;
|
|
34
61
|
}
|
package/dist/tools/gitConfig.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import simpleGit from 'simple-git';
|
|
2
2
|
import { MCPError } from '../utils/errors.js';
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
import * as path from 'path';
|
|
3
5
|
export class GitConfigTool {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = 'git-config';
|
|
@@ -57,8 +59,30 @@ export class GitConfigTool {
|
|
|
57
59
|
scope: params.showScope ? scope : undefined,
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
case 'edit':
|
|
61
|
-
|
|
62
|
+
case 'edit': {
|
|
63
|
+
// Return config file path and instructions for manual editing
|
|
64
|
+
const configFile = scope === 'global'
|
|
65
|
+
? path.join(require('os').homedir(), '.gitconfig')
|
|
66
|
+
: scope === 'system'
|
|
67
|
+
? '/etc/gitconfig'
|
|
68
|
+
: path.join(projectPath, '.git', 'config');
|
|
69
|
+
try {
|
|
70
|
+
await fs.access(configFile);
|
|
71
|
+
const content = await fs.readFile(configFile, 'utf-8');
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
configFile,
|
|
75
|
+
scope,
|
|
76
|
+
content,
|
|
77
|
+
lines: content.split('\n').length,
|
|
78
|
+
message: 'Config file content retrieved. Edit and use "set" action to update values.',
|
|
79
|
+
note: 'For direct file editing, use your preferred text editor',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw new MCPError('FILE_ERROR', `Config file not accessible: ${error.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
62
86
|
default:
|
|
63
87
|
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
64
88
|
}
|
package/dist/tools/gitFiles.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare class GitFilesTool implements Tool {
|
|
|
7
7
|
path: string;
|
|
8
8
|
content: string;
|
|
9
9
|
files?: undefined;
|
|
10
|
+
created?: undefined;
|
|
11
|
+
size?: undefined;
|
|
12
|
+
updated?: undefined;
|
|
13
|
+
deleted?: undefined;
|
|
10
14
|
matches?: undefined;
|
|
11
15
|
count?: undefined;
|
|
12
16
|
} | {
|
|
@@ -14,6 +18,43 @@ export declare class GitFilesTool implements Tool {
|
|
|
14
18
|
files: string[];
|
|
15
19
|
path?: undefined;
|
|
16
20
|
content?: undefined;
|
|
21
|
+
created?: undefined;
|
|
22
|
+
size?: undefined;
|
|
23
|
+
updated?: undefined;
|
|
24
|
+
deleted?: undefined;
|
|
25
|
+
matches?: undefined;
|
|
26
|
+
count?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
success: boolean;
|
|
29
|
+
created: boolean;
|
|
30
|
+
path: string;
|
|
31
|
+
size: any;
|
|
32
|
+
content?: undefined;
|
|
33
|
+
files?: undefined;
|
|
34
|
+
updated?: undefined;
|
|
35
|
+
deleted?: undefined;
|
|
36
|
+
matches?: undefined;
|
|
37
|
+
count?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
success: boolean;
|
|
40
|
+
updated: boolean;
|
|
41
|
+
path: string;
|
|
42
|
+
size: any;
|
|
43
|
+
content?: undefined;
|
|
44
|
+
files?: undefined;
|
|
45
|
+
created?: undefined;
|
|
46
|
+
deleted?: undefined;
|
|
47
|
+
matches?: undefined;
|
|
48
|
+
count?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
success: boolean;
|
|
51
|
+
deleted: boolean;
|
|
52
|
+
path: string;
|
|
53
|
+
content?: undefined;
|
|
54
|
+
files?: undefined;
|
|
55
|
+
created?: undefined;
|
|
56
|
+
size?: undefined;
|
|
57
|
+
updated?: undefined;
|
|
17
58
|
matches?: undefined;
|
|
18
59
|
count?: undefined;
|
|
19
60
|
} | {
|
|
@@ -26,5 +67,9 @@ export declare class GitFilesTool implements Tool {
|
|
|
26
67
|
path?: undefined;
|
|
27
68
|
content?: undefined;
|
|
28
69
|
files?: undefined;
|
|
70
|
+
created?: undefined;
|
|
71
|
+
size?: undefined;
|
|
72
|
+
updated?: undefined;
|
|
73
|
+
deleted?: undefined;
|
|
29
74
|
}>;
|
|
30
75
|
}
|
package/dist/tools/gitFiles.js
CHANGED
|
@@ -21,9 +21,86 @@ export class GitFilesTool {
|
|
|
21
21
|
const files = await fs.readdir(dirPath);
|
|
22
22
|
return { success: true, files };
|
|
23
23
|
}
|
|
24
|
-
//
|
|
25
|
-
if (
|
|
26
|
-
|
|
24
|
+
// File modification operations with security validations
|
|
25
|
+
if (action === 'create') {
|
|
26
|
+
const filePath = params.filePath;
|
|
27
|
+
const content = params.content || '';
|
|
28
|
+
if (!filePath)
|
|
29
|
+
throw new MCPError('VALIDATION_ERROR', 'filePath is required');
|
|
30
|
+
// Security: ensure file is within projectPath
|
|
31
|
+
const targetPath = path.resolve(projectPath, filePath);
|
|
32
|
+
if (!targetPath.startsWith(path.resolve(projectPath))) {
|
|
33
|
+
throw new MCPError('SECURITY_ERROR', 'File path must be within project directory');
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// Create directory if needed
|
|
37
|
+
const dir = path.dirname(targetPath);
|
|
38
|
+
await fs.mkdir(dir, { recursive: true });
|
|
39
|
+
await fs.writeFile(targetPath, content, 'utf-8');
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
created: true,
|
|
43
|
+
path: targetPath,
|
|
44
|
+
size: content.length,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new MCPError('FILE_ERROR', `Failed to create file: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (action === 'update') {
|
|
52
|
+
const filePath = params.filePath;
|
|
53
|
+
const content = params.content;
|
|
54
|
+
if (!filePath)
|
|
55
|
+
throw new MCPError('VALIDATION_ERROR', 'filePath is required');
|
|
56
|
+
if (content === undefined)
|
|
57
|
+
throw new MCPError('VALIDATION_ERROR', 'content is required');
|
|
58
|
+
// Security: ensure file is within projectPath
|
|
59
|
+
const targetPath = path.resolve(projectPath, filePath);
|
|
60
|
+
if (!targetPath.startsWith(path.resolve(projectPath))) {
|
|
61
|
+
throw new MCPError('SECURITY_ERROR', 'File path must be within project directory');
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
// Check if file exists
|
|
65
|
+
await fs.access(targetPath);
|
|
66
|
+
await fs.writeFile(targetPath, content, 'utf-8');
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
updated: true,
|
|
70
|
+
path: targetPath,
|
|
71
|
+
size: content.length,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.code === 'ENOENT') {
|
|
76
|
+
throw new MCPError('FILE_NOT_FOUND', 'File does not exist. Use create action.');
|
|
77
|
+
}
|
|
78
|
+
throw new MCPError('FILE_ERROR', `Failed to update file: ${error.message}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (action === 'delete') {
|
|
82
|
+
const filePath = params.filePath;
|
|
83
|
+
if (!filePath)
|
|
84
|
+
throw new MCPError('VALIDATION_ERROR', 'filePath is required');
|
|
85
|
+
// Security: ensure file is within projectPath
|
|
86
|
+
const targetPath = path.resolve(projectPath, filePath);
|
|
87
|
+
if (!targetPath.startsWith(path.resolve(projectPath))) {
|
|
88
|
+
throw new MCPError('SECURITY_ERROR', 'File path must be within project directory');
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
await fs.unlink(targetPath);
|
|
92
|
+
return {
|
|
93
|
+
success: true,
|
|
94
|
+
deleted: true,
|
|
95
|
+
path: targetPath,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error.code === 'ENOENT') {
|
|
100
|
+
throw new MCPError('FILE_NOT_FOUND', 'File does not exist');
|
|
101
|
+
}
|
|
102
|
+
throw new MCPError('FILE_ERROR', `Failed to delete file: ${error.message}`);
|
|
103
|
+
}
|
|
27
104
|
}
|
|
28
105
|
if (action === 'search') {
|
|
29
106
|
// Simple string search within files in projectPath (non-recursive)
|
|
@@ -11,6 +11,13 @@ export declare class GitPackagesTool implements Tool {
|
|
|
11
11
|
scripts: any;
|
|
12
12
|
message?: undefined;
|
|
13
13
|
note?: undefined;
|
|
14
|
+
created?: undefined;
|
|
15
|
+
path?: undefined;
|
|
16
|
+
package?: undefined;
|
|
17
|
+
updated?: undefined;
|
|
18
|
+
deleted?: undefined;
|
|
19
|
+
instructions?: undefined;
|
|
20
|
+
projectPath?: undefined;
|
|
14
21
|
} | {
|
|
15
22
|
success: boolean;
|
|
16
23
|
message: string;
|
|
@@ -20,5 +27,126 @@ export declare class GitPackagesTool implements Tool {
|
|
|
20
27
|
dependencies?: undefined;
|
|
21
28
|
devDependencies?: undefined;
|
|
22
29
|
scripts?: undefined;
|
|
30
|
+
created?: undefined;
|
|
31
|
+
path?: undefined;
|
|
32
|
+
package?: undefined;
|
|
33
|
+
updated?: undefined;
|
|
34
|
+
deleted?: undefined;
|
|
35
|
+
instructions?: undefined;
|
|
36
|
+
projectPath?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
success: boolean;
|
|
39
|
+
created: boolean;
|
|
40
|
+
path: string;
|
|
41
|
+
package: any;
|
|
42
|
+
name?: undefined;
|
|
43
|
+
version?: undefined;
|
|
44
|
+
dependencies?: undefined;
|
|
45
|
+
devDependencies?: undefined;
|
|
46
|
+
scripts?: undefined;
|
|
47
|
+
message?: undefined;
|
|
48
|
+
note?: undefined;
|
|
49
|
+
updated?: undefined;
|
|
50
|
+
deleted?: undefined;
|
|
51
|
+
instructions?: undefined;
|
|
52
|
+
projectPath?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
success: boolean;
|
|
55
|
+
updated: boolean;
|
|
56
|
+
path: string;
|
|
57
|
+
package: any;
|
|
58
|
+
name?: undefined;
|
|
59
|
+
version?: undefined;
|
|
60
|
+
dependencies?: undefined;
|
|
61
|
+
devDependencies?: undefined;
|
|
62
|
+
scripts?: undefined;
|
|
63
|
+
message?: undefined;
|
|
64
|
+
note?: undefined;
|
|
65
|
+
created?: undefined;
|
|
66
|
+
deleted?: undefined;
|
|
67
|
+
instructions?: undefined;
|
|
68
|
+
projectPath?: undefined;
|
|
69
|
+
} | {
|
|
70
|
+
success: boolean;
|
|
71
|
+
deleted: boolean;
|
|
72
|
+
path: string;
|
|
73
|
+
name?: undefined;
|
|
74
|
+
version?: undefined;
|
|
75
|
+
dependencies?: undefined;
|
|
76
|
+
devDependencies?: undefined;
|
|
77
|
+
scripts?: undefined;
|
|
78
|
+
message?: undefined;
|
|
79
|
+
note?: undefined;
|
|
80
|
+
created?: undefined;
|
|
81
|
+
package?: undefined;
|
|
82
|
+
updated?: undefined;
|
|
83
|
+
instructions?: undefined;
|
|
84
|
+
projectPath?: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
success: boolean;
|
|
87
|
+
message: string;
|
|
88
|
+
path: string;
|
|
89
|
+
name?: undefined;
|
|
90
|
+
version?: undefined;
|
|
91
|
+
dependencies?: undefined;
|
|
92
|
+
devDependencies?: undefined;
|
|
93
|
+
scripts?: undefined;
|
|
94
|
+
note?: undefined;
|
|
95
|
+
created?: undefined;
|
|
96
|
+
package?: undefined;
|
|
97
|
+
updated?: undefined;
|
|
98
|
+
deleted?: undefined;
|
|
99
|
+
instructions?: undefined;
|
|
100
|
+
projectPath?: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
success: boolean;
|
|
103
|
+
message: string;
|
|
104
|
+
instructions: {
|
|
105
|
+
command: string;
|
|
106
|
+
registry: any;
|
|
107
|
+
access: any;
|
|
108
|
+
tag: any;
|
|
109
|
+
note: string;
|
|
110
|
+
package?: undefined;
|
|
111
|
+
version?: undefined;
|
|
112
|
+
destination?: undefined;
|
|
113
|
+
};
|
|
114
|
+
projectPath: any;
|
|
115
|
+
name?: undefined;
|
|
116
|
+
version?: undefined;
|
|
117
|
+
dependencies?: undefined;
|
|
118
|
+
devDependencies?: undefined;
|
|
119
|
+
scripts?: undefined;
|
|
120
|
+
note?: undefined;
|
|
121
|
+
created?: undefined;
|
|
122
|
+
path?: undefined;
|
|
123
|
+
package?: undefined;
|
|
124
|
+
updated?: undefined;
|
|
125
|
+
deleted?: undefined;
|
|
126
|
+
} | {
|
|
127
|
+
success: boolean;
|
|
128
|
+
message: string;
|
|
129
|
+
instructions: {
|
|
130
|
+
command: string;
|
|
131
|
+
package: any;
|
|
132
|
+
version: any;
|
|
133
|
+
destination: any;
|
|
134
|
+
note: string;
|
|
135
|
+
registry?: undefined;
|
|
136
|
+
access?: undefined;
|
|
137
|
+
tag?: undefined;
|
|
138
|
+
};
|
|
139
|
+
name?: undefined;
|
|
140
|
+
version?: undefined;
|
|
141
|
+
dependencies?: undefined;
|
|
142
|
+
devDependencies?: undefined;
|
|
143
|
+
scripts?: undefined;
|
|
144
|
+
note?: undefined;
|
|
145
|
+
created?: undefined;
|
|
146
|
+
path?: undefined;
|
|
147
|
+
package?: undefined;
|
|
148
|
+
updated?: undefined;
|
|
149
|
+
deleted?: undefined;
|
|
150
|
+
projectPath?: undefined;
|
|
23
151
|
}>;
|
|
24
152
|
}
|
|
@@ -43,12 +43,140 @@ export class GitPackagesTool {
|
|
|
43
43
|
note: 'Use npm view or yarn info for detailed package information',
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
case 'create':
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
case 'create': {
|
|
47
|
+
if (!projectPath)
|
|
48
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
49
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
50
|
+
const packageData = {
|
|
51
|
+
name: params.name || path.basename(projectPath),
|
|
52
|
+
version: params.version || '1.0.0',
|
|
53
|
+
description: params.description || '',
|
|
54
|
+
main: params.main || 'index.js',
|
|
55
|
+
scripts: params.scripts || {},
|
|
56
|
+
keywords: params.keywords || [],
|
|
57
|
+
author: params.author || '',
|
|
58
|
+
license: params.license || 'MIT',
|
|
59
|
+
};
|
|
60
|
+
if (params.dependencies)
|
|
61
|
+
packageData.dependencies = params.dependencies;
|
|
62
|
+
if (params.devDependencies)
|
|
63
|
+
packageData.devDependencies = params.devDependencies;
|
|
64
|
+
try {
|
|
65
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
created: true,
|
|
69
|
+
path: packageJsonPath,
|
|
70
|
+
package: packageData,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new MCPError('FILE_ERROR', `Failed to create package.json: ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
case 'update': {
|
|
78
|
+
if (!projectPath)
|
|
79
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
80
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
81
|
+
try {
|
|
82
|
+
const content = await fs.readFile(packageJsonPath, 'utf-8');
|
|
83
|
+
const pkg = JSON.parse(content);
|
|
84
|
+
// Update fields if provided
|
|
85
|
+
if (params.name)
|
|
86
|
+
pkg.name = params.name;
|
|
87
|
+
if (params.version)
|
|
88
|
+
pkg.version = params.version;
|
|
89
|
+
if (params.description)
|
|
90
|
+
pkg.description = params.description;
|
|
91
|
+
if (params.main)
|
|
92
|
+
pkg.main = params.main;
|
|
93
|
+
if (params.scripts)
|
|
94
|
+
pkg.scripts = { ...pkg.scripts, ...params.scripts };
|
|
95
|
+
if (params.keywords)
|
|
96
|
+
pkg.keywords = params.keywords;
|
|
97
|
+
if (params.author)
|
|
98
|
+
pkg.author = params.author;
|
|
99
|
+
if (params.license)
|
|
100
|
+
pkg.license = params.license;
|
|
101
|
+
if (params.dependencies)
|
|
102
|
+
pkg.dependencies = { ...pkg.dependencies, ...params.dependencies };
|
|
103
|
+
if (params.devDependencies)
|
|
104
|
+
pkg.devDependencies = { ...pkg.devDependencies, ...params.devDependencies };
|
|
105
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2), 'utf-8');
|
|
106
|
+
return {
|
|
107
|
+
success: true,
|
|
108
|
+
updated: true,
|
|
109
|
+
path: packageJsonPath,
|
|
110
|
+
package: pkg,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new MCPError('FILE_ERROR', `Failed to update package.json: ${error.message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
case 'delete': {
|
|
118
|
+
if (!projectPath)
|
|
119
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
120
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
121
|
+
try {
|
|
122
|
+
await fs.unlink(packageJsonPath);
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
deleted: true,
|
|
126
|
+
path: packageJsonPath,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (error.code === 'ENOENT') {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
message: 'package.json not found',
|
|
134
|
+
path: packageJsonPath,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
throw new MCPError('FILE_ERROR', `Failed to delete package.json: ${error.message}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
case 'publish': {
|
|
141
|
+
if (!projectPath)
|
|
142
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
143
|
+
const registry = params.registry || 'https://registry.npmjs.org';
|
|
144
|
+
const access = params.access || 'public'; // public or restricted
|
|
145
|
+
const tag = params.tag || 'latest';
|
|
146
|
+
const dryRun = params.dryRun || false;
|
|
147
|
+
return {
|
|
148
|
+
success: true,
|
|
149
|
+
message: 'To publish, run: npm publish in your terminal',
|
|
150
|
+
instructions: {
|
|
151
|
+
command: dryRun ? 'npm publish --dry-run' : 'npm publish',
|
|
152
|
+
registry,
|
|
153
|
+
access,
|
|
154
|
+
tag,
|
|
155
|
+
note: 'Make sure you are logged in with: npm login',
|
|
156
|
+
},
|
|
157
|
+
projectPath,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case 'download': {
|
|
161
|
+
const packageName = params.packageName;
|
|
162
|
+
const version = params.version || 'latest';
|
|
163
|
+
const destination = params.destination || projectPath;
|
|
164
|
+
if (!packageName)
|
|
165
|
+
throw new MCPError('VALIDATION_ERROR', 'packageName is required');
|
|
166
|
+
if (!destination)
|
|
167
|
+
throw new MCPError('VALIDATION_ERROR', 'destination is required');
|
|
168
|
+
return {
|
|
169
|
+
success: true,
|
|
170
|
+
message: `To download ${packageName}@${version}, run: npm install ${packageName}@${version} in your terminal`,
|
|
171
|
+
instructions: {
|
|
172
|
+
command: `npm install ${packageName}@${version}`,
|
|
173
|
+
package: packageName,
|
|
174
|
+
version,
|
|
175
|
+
destination,
|
|
176
|
+
note: 'Run this command in your project directory',
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
52
180
|
default:
|
|
53
181
|
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
54
182
|
}
|
package/dist/tools/gitSync.d.ts
CHANGED
|
@@ -2,24 +2,5 @@ import { Tool, MCPContext } from '../types.js';
|
|
|
2
2
|
export declare class GitSyncTool implements Tool {
|
|
3
3
|
name: string;
|
|
4
4
|
description: string;
|
|
5
|
-
handle(params: Record<string, any>, ctx: MCPContext): Promise<
|
|
6
|
-
success: boolean;
|
|
7
|
-
remote: any;
|
|
8
|
-
branch: any;
|
|
9
|
-
message: string;
|
|
10
|
-
status?: undefined;
|
|
11
|
-
remotes?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
success: boolean;
|
|
14
|
-
status: {
|
|
15
|
-
branch: string | null;
|
|
16
|
-
ahead: number;
|
|
17
|
-
behind: number;
|
|
18
|
-
clean: boolean;
|
|
19
|
-
};
|
|
20
|
-
remotes: import("simple-git").RemoteWithRefs[];
|
|
21
|
-
remote?: undefined;
|
|
22
|
-
branch?: undefined;
|
|
23
|
-
message?: undefined;
|
|
24
|
-
}>;
|
|
5
|
+
handle(params: Record<string, any>, ctx: MCPContext): Promise<any>;
|
|
25
6
|
}
|
package/dist/tools/gitSync.js
CHANGED
|
@@ -37,6 +37,44 @@ export class GitSyncTool {
|
|
|
37
37
|
remotes,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
+
case 'one-shot': {
|
|
41
|
+
// One-shot sync: fetch, pull, and push in a single operation
|
|
42
|
+
const remote = params.remote || 'origin';
|
|
43
|
+
const branch = params.branch;
|
|
44
|
+
const results = {
|
|
45
|
+
success: true,
|
|
46
|
+
remote,
|
|
47
|
+
branch: branch || 'current',
|
|
48
|
+
steps: [],
|
|
49
|
+
};
|
|
50
|
+
// Step 1: Fetch
|
|
51
|
+
results.steps.push({ action: 'fetch', timestamp: new Date().toISOString() });
|
|
52
|
+
await git.fetch(remote);
|
|
53
|
+
// Step 2: Pull
|
|
54
|
+
results.steps.push({ action: 'pull', timestamp: new Date().toISOString() });
|
|
55
|
+
if (branch) {
|
|
56
|
+
await git.pull(remote, branch);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await git.pull(remote);
|
|
60
|
+
}
|
|
61
|
+
// Step 3: Push
|
|
62
|
+
results.steps.push({ action: 'push', timestamp: new Date().toISOString() });
|
|
63
|
+
const pushResult = await git.push(remote, branch);
|
|
64
|
+
results.pushResult = {
|
|
65
|
+
pushed: pushResult.pushed || [],
|
|
66
|
+
remoteMessages: pushResult.remoteMessages?.all || [],
|
|
67
|
+
};
|
|
68
|
+
// Step 4: Final status
|
|
69
|
+
const finalStatus = await git.status();
|
|
70
|
+
results.finalStatus = {
|
|
71
|
+
branch: finalStatus.current,
|
|
72
|
+
ahead: finalStatus.ahead,
|
|
73
|
+
behind: finalStatus.behind,
|
|
74
|
+
clean: finalStatus.isClean(),
|
|
75
|
+
};
|
|
76
|
+
return results;
|
|
77
|
+
}
|
|
40
78
|
default:
|
|
41
79
|
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
42
80
|
}
|
|
@@ -289,6 +289,37 @@ export class GitWorkflowTool {
|
|
|
289
289
|
}
|
|
290
290
|
return results;
|
|
291
291
|
}
|
|
292
|
+
case 'push': {
|
|
293
|
+
if (!projectPath || !git)
|
|
294
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required for push');
|
|
295
|
+
const remote = params.remote || 'origin';
|
|
296
|
+
const branch = params.branch;
|
|
297
|
+
const force = params.force || false;
|
|
298
|
+
const setUpstream = params.setUpstream || false;
|
|
299
|
+
const pushOptions = [];
|
|
300
|
+
if (force)
|
|
301
|
+
pushOptions.push('--force');
|
|
302
|
+
if (setUpstream)
|
|
303
|
+
pushOptions.push('--set-upstream');
|
|
304
|
+
try {
|
|
305
|
+
const pushResult = await git.push(remote, branch, pushOptions);
|
|
306
|
+
return {
|
|
307
|
+
success: true,
|
|
308
|
+
remote,
|
|
309
|
+
branch: branch || 'current',
|
|
310
|
+
force,
|
|
311
|
+
setUpstream,
|
|
312
|
+
result: {
|
|
313
|
+
pushed: pushResult.pushed || [],
|
|
314
|
+
remoteMessages: pushResult.remoteMessages?.all || [],
|
|
315
|
+
update: pushResult.update,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
throw new MCPError('PUSH_ERROR', `Failed to push: ${err.message}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
292
323
|
default:
|
|
293
324
|
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
294
325
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrebuzeli/git-mcp",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Professional MCP server for Git operations - STDIO UNIVERSAL: works in ANY IDE (Cursor, VSCode, Claude Desktop). Fully autonomous DUAL execution (GitHub + Gitea APIs) with automatic username detection. All tools execute on BOTH providers simultaneously. No manual parameters needed.",
|
|
6
6
|
"main": "dist/index.js",
|