@andrebuzeli/git-mcp 10.0.9 → 11.0.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/README.md +34 -428
- package/bin/git-mcp.js +21 -0
- package/docs/TOOLS.md +110 -0
- package/mcp.json.template +12 -0
- package/package.json +9 -76
- package/src/local/git.js +14 -0
- package/src/providers/gitea.js +13 -0
- package/src/providers/github.js +13 -0
- package/src/server.js +63 -0
- package/src/tools/git-actions.js +19 -0
- package/src/tools/git-activity.js +28 -0
- package/src/tools/git-admin.js +20 -0
- package/src/tools/git-checks.js +14 -0
- package/src/tools/git-commits.js +34 -0
- package/src/tools/git-contents.js +30 -0
- package/src/tools/git-deployments.js +21 -0
- package/src/tools/git-gists.js +15 -0
- package/src/tools/git-gitdata.js +19 -0
- package/src/tools/git-issues-prs.js +44 -0
- package/src/tools/git-issues.js +12 -0
- package/src/tools/git-local.js +66 -0
- package/src/tools/git-meta.js +19 -0
- package/src/tools/git-misc.js +21 -0
- package/src/tools/git-orgs.js +26 -0
- package/src/tools/git-packages.js +12 -0
- package/src/tools/git-raw.js +14 -0
- package/src/tools/git-releases.js +17 -0
- package/src/tools/git-remote.js +29 -0
- package/src/tools/git-repos.js +60 -0
- package/src/tools/git-search.js +18 -0
- package/src/tools/git-sync.js +40 -0
- package/src/tools/git-user.js +26 -0
- package/src/tools/schema.js +3 -0
- package/src/utils/fs.js +29 -0
- package/src/utils/project.js +7 -0
- package/tests/errors.js +26 -0
- package/tests/full_suite.js +98 -0
- package/tests/run.js +50 -0
- package/LICENSE +0 -21
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -224
- package/dist/prompts/gitPrompts.d.ts +0 -93
- package/dist/prompts/gitPrompts.js +0 -177
- package/dist/providers/giteaProvider.d.ts +0 -3
- package/dist/providers/giteaProvider.js +0 -6
- package/dist/providers/githubProvider.d.ts +0 -2
- package/dist/providers/githubProvider.js +0 -4
- package/dist/providers/providerManager.d.ts +0 -11
- package/dist/providers/providerManager.js +0 -49
- package/dist/resources/toolsGuide.d.ts +0 -12
- package/dist/resources/toolsGuide.js +0 -1713
- package/dist/scripts/test_e2e.d.ts +0 -1
- package/dist/scripts/test_e2e.js +0 -199
- package/dist/scripts/test_exhaustive.d.ts +0 -1
- package/dist/scripts/test_exhaustive.js +0 -275
- package/dist/scripts/test_gitea_creation.d.ts +0 -1
- package/dist/scripts/test_gitea_creation.js +0 -116
- package/dist/scripts/verify_setup.d.ts +0 -1
- package/dist/scripts/verify_setup.js +0 -61
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -73
- package/dist/tools/gitAnalytics.d.ts +0 -35
- package/dist/tools/gitAnalytics.js +0 -220
- package/dist/tools/gitArchive.d.ts +0 -119
- package/dist/tools/gitArchive.js +0 -150
- package/dist/tools/gitBackup.d.ts +0 -116
- package/dist/tools/gitBackup.js +0 -156
- package/dist/tools/gitBranches.d.ts +0 -54
- package/dist/tools/gitBranches.js +0 -282
- package/dist/tools/gitChangelog.d.ts +0 -37
- package/dist/tools/gitChangelog.js +0 -67
- package/dist/tools/gitConfig.d.ts +0 -97
- package/dist/tools/gitConfig.js +0 -125
- package/dist/tools/gitFiles.d.ts +0 -129
- package/dist/tools/gitFiles.js +0 -213
- package/dist/tools/gitFix.d.ts +0 -4
- package/dist/tools/gitFix.js +0 -159
- package/dist/tools/gitFix.tool.d.ts +0 -31
- package/dist/tools/gitFix.tool.js +0 -92
- package/dist/tools/gitHistory.d.ts +0 -41
- package/dist/tools/gitHistory.js +0 -349
- package/dist/tools/gitIgnore.d.ts +0 -214
- package/dist/tools/gitIgnore.js +0 -338
- package/dist/tools/gitIssues.d.ts +0 -80
- package/dist/tools/gitIssues.js +0 -363
- package/dist/tools/gitLog.d.ts +0 -30
- package/dist/tools/gitLog.js +0 -46
- package/dist/tools/gitMonitor.d.ts +0 -30
- package/dist/tools/gitMonitor.js +0 -284
- package/dist/tools/gitPackages.d.ts +0 -180
- package/dist/tools/gitPackages.js +0 -214
- package/dist/tools/gitPulls.d.ts +0 -66
- package/dist/tools/gitPulls.js +0 -347
- package/dist/tools/gitPush.d.ts +0 -40
- package/dist/tools/gitPush.js +0 -59
- package/dist/tools/gitRelease.d.ts +0 -49
- package/dist/tools/gitRelease.js +0 -359
- package/dist/tools/gitRemote.d.ts +0 -47
- package/dist/tools/gitRemote.js +0 -111
- package/dist/tools/gitReset.d.ts +0 -57
- package/dist/tools/gitReset.js +0 -79
- package/dist/tools/gitStash.d.ts +0 -61
- package/dist/tools/gitStash.js +0 -80
- package/dist/tools/gitSync.d.ts +0 -34
- package/dist/tools/gitSync.js +0 -182
- package/dist/tools/gitTags.d.ts +0 -45
- package/dist/tools/gitTags.js +0 -251
- package/dist/tools/gitUpdate.d.ts +0 -60
- package/dist/tools/gitUpdate.js +0 -474
- package/dist/tools/gitUpload.d.ts +0 -35
- package/dist/tools/gitUpload.js +0 -385
- package/dist/tools/gitWorkflow.d.ts +0 -117
- package/dist/tools/gitWorkflow.js +0 -472
- package/dist/types.d.ts +0 -20
- package/dist/types.js +0 -1
- package/dist/utils/agentHelpers.d.ts +0 -11
- package/dist/utils/agentHelpers.js +0 -41
- package/dist/utils/apiHelpers.d.ts +0 -29
- package/dist/utils/apiHelpers.js +0 -125
- package/dist/utils/cache.d.ts +0 -96
- package/dist/utils/cache.js +0 -208
- package/dist/utils/contextDetector.d.ts +0 -0
- package/dist/utils/contextDetector.js +0 -1
- package/dist/utils/errors.d.ts +0 -13
- package/dist/utils/errors.js +0 -17
- package/dist/utils/gitAdapter.d.ts +0 -224
- package/dist/utils/gitAdapter.js +0 -1162
- package/dist/utils/logger.d.ts +0 -45
- package/dist/utils/logger.js +0 -140
- package/dist/utils/rateLimiter.d.ts +0 -113
- package/dist/utils/rateLimiter.js +0 -257
- package/dist/utils/repoHelpers.d.ts +0 -44
- package/dist/utils/repoHelpers.js +0 -122
- package/dist/utils/safetyController.d.ts +0 -1
- package/dist/utils/safetyController.js +0 -12
- package/dist/utils/validation.d.ts +0 -115
- package/dist/utils/validation.js +0 -270
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Tool, MCPContext } from '../types.js';
|
|
2
|
-
export declare class GitBackupTool implements Tool {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: "object";
|
|
7
|
-
properties: {
|
|
8
|
-
projectPath: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
action: {
|
|
13
|
-
type: string;
|
|
14
|
-
enum: string[];
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
backupPath: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
compress: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
confirm: {
|
|
26
|
-
type: string;
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
name: {
|
|
30
|
-
type: string;
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
required: string[];
|
|
35
|
-
additionalProperties: boolean;
|
|
36
|
-
};
|
|
37
|
-
handle(params: Record<string, any>, ctx: MCPContext): Promise<{
|
|
38
|
-
success: boolean;
|
|
39
|
-
backupPath: string;
|
|
40
|
-
backupData: {
|
|
41
|
-
projectPath: any;
|
|
42
|
-
timestamp: string;
|
|
43
|
-
branch: string;
|
|
44
|
-
lastCommit: string | null;
|
|
45
|
-
files: number;
|
|
46
|
-
};
|
|
47
|
-
message: string;
|
|
48
|
-
backups?: undefined;
|
|
49
|
-
count?: undefined;
|
|
50
|
-
backupDir?: undefined;
|
|
51
|
-
valid?: undefined;
|
|
52
|
-
backup?: undefined;
|
|
53
|
-
error?: undefined;
|
|
54
|
-
note?: undefined;
|
|
55
|
-
} | {
|
|
56
|
-
success: boolean;
|
|
57
|
-
backups: any[];
|
|
58
|
-
count: number;
|
|
59
|
-
backupDir: any;
|
|
60
|
-
backupPath?: undefined;
|
|
61
|
-
backupData?: undefined;
|
|
62
|
-
message?: undefined;
|
|
63
|
-
valid?: undefined;
|
|
64
|
-
backup?: undefined;
|
|
65
|
-
error?: undefined;
|
|
66
|
-
note?: undefined;
|
|
67
|
-
} | {
|
|
68
|
-
success: boolean;
|
|
69
|
-
backups: never[];
|
|
70
|
-
count: number;
|
|
71
|
-
message: string;
|
|
72
|
-
backupPath?: undefined;
|
|
73
|
-
backupData?: undefined;
|
|
74
|
-
backupDir?: undefined;
|
|
75
|
-
valid?: undefined;
|
|
76
|
-
backup?: undefined;
|
|
77
|
-
error?: undefined;
|
|
78
|
-
note?: undefined;
|
|
79
|
-
} | {
|
|
80
|
-
success: boolean;
|
|
81
|
-
valid: any;
|
|
82
|
-
backup: any;
|
|
83
|
-
message: string;
|
|
84
|
-
backupPath?: undefined;
|
|
85
|
-
backupData?: undefined;
|
|
86
|
-
backups?: undefined;
|
|
87
|
-
count?: undefined;
|
|
88
|
-
backupDir?: undefined;
|
|
89
|
-
error?: undefined;
|
|
90
|
-
note?: undefined;
|
|
91
|
-
} | {
|
|
92
|
-
success: boolean;
|
|
93
|
-
valid: boolean;
|
|
94
|
-
error: any;
|
|
95
|
-
backupPath?: undefined;
|
|
96
|
-
backupData?: undefined;
|
|
97
|
-
message?: undefined;
|
|
98
|
-
backups?: undefined;
|
|
99
|
-
count?: undefined;
|
|
100
|
-
backupDir?: undefined;
|
|
101
|
-
backup?: undefined;
|
|
102
|
-
note?: undefined;
|
|
103
|
-
} | {
|
|
104
|
-
success: boolean;
|
|
105
|
-
message: string;
|
|
106
|
-
backup: any;
|
|
107
|
-
note: string;
|
|
108
|
-
backupPath?: undefined;
|
|
109
|
-
backupData?: undefined;
|
|
110
|
-
backups?: undefined;
|
|
111
|
-
count?: undefined;
|
|
112
|
-
backupDir?: undefined;
|
|
113
|
-
valid?: undefined;
|
|
114
|
-
error?: undefined;
|
|
115
|
-
}>;
|
|
116
|
-
}
|
package/dist/tools/gitBackup.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { MCPError } from '../utils/errors.js';
|
|
4
|
-
export class GitBackupTool {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.name = 'git-backup';
|
|
7
|
-
this.description = 'Repository backup and restore operations';
|
|
8
|
-
this.inputSchema = {
|
|
9
|
-
type: "object",
|
|
10
|
-
properties: {
|
|
11
|
-
projectPath: {
|
|
12
|
-
type: "string",
|
|
13
|
-
description: "The absolute path to the Git repository directory on the local filesystem. This should be the root directory containing the .git folder. For example: '/home/user/my-project' on Linux/Mac or 'C:\\Users\\user\\my-project' on Windows."
|
|
14
|
-
},
|
|
15
|
-
action: {
|
|
16
|
-
type: "string",
|
|
17
|
-
enum: ["create", "restore", "list", "delete"],
|
|
18
|
-
description: "Backup operation to perform: create (create backup), restore (restore from backup), list (list backups), delete (delete backup)"
|
|
19
|
-
},
|
|
20
|
-
backupPath: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Path to backup file (required for create/restore/delete)"
|
|
23
|
-
},
|
|
24
|
-
compress: {
|
|
25
|
-
type: "boolean",
|
|
26
|
-
description: "Compress backup (optional for create, default: true)"
|
|
27
|
-
},
|
|
28
|
-
confirm: {
|
|
29
|
-
type: "boolean",
|
|
30
|
-
description: "Confirm destructive operations (optional for restore/delete)"
|
|
31
|
-
},
|
|
32
|
-
name: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: "Backup name (optional for create)"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
required: ["projectPath", "action"],
|
|
38
|
-
additionalProperties: true
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async handle(params, ctx) {
|
|
42
|
-
const action = params.action;
|
|
43
|
-
const projectPath = params.projectPath;
|
|
44
|
-
if (!action || !projectPath) {
|
|
45
|
-
throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
|
|
46
|
-
}
|
|
47
|
-
switch (action) {
|
|
48
|
-
case 'create':
|
|
49
|
-
case 'backup': {
|
|
50
|
-
const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
|
|
51
|
-
const backupName = params.backupName || `backup-${Date.now()}.json`;
|
|
52
|
-
try {
|
|
53
|
-
// Criar diretório de backups
|
|
54
|
-
await fs.mkdir(backupDir, { recursive: true });
|
|
55
|
-
const backupPath = path.join(backupDir, backupName);
|
|
56
|
-
const git = ctx.gitAdapter;
|
|
57
|
-
const status = await git.status(projectPath);
|
|
58
|
-
const log = await git.log(projectPath, { maxCount: 1 });
|
|
59
|
-
const backupData = {
|
|
60
|
-
projectPath,
|
|
61
|
-
timestamp: new Date().toISOString(),
|
|
62
|
-
branch: status.current,
|
|
63
|
-
lastCommit: log.length > 0 ? log[0].hash : null,
|
|
64
|
-
files: status.files.length,
|
|
65
|
-
};
|
|
66
|
-
await fs.writeFile(backupPath, JSON.stringify(backupData, null, 2));
|
|
67
|
-
return {
|
|
68
|
-
success: true,
|
|
69
|
-
backupPath,
|
|
70
|
-
backupData,
|
|
71
|
-
message: 'Backup created successfully',
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
throw new MCPError('FILE_ERROR', `Failed to create backup: ${error.message}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
case 'list': {
|
|
79
|
-
const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
|
|
80
|
-
try {
|
|
81
|
-
const files = await fs.readdir(backupDir);
|
|
82
|
-
const backups = [];
|
|
83
|
-
for (const file of files) {
|
|
84
|
-
if (file.endsWith('.json')) {
|
|
85
|
-
try {
|
|
86
|
-
const content = await fs.readFile(path.join(backupDir, file), 'utf-8');
|
|
87
|
-
const backup = JSON.parse(content);
|
|
88
|
-
backups.push({ file, ...backup });
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
// Ignorar arquivos inválidos
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
success: true,
|
|
97
|
-
backups,
|
|
98
|
-
count: backups.length,
|
|
99
|
-
backupDir,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
return {
|
|
104
|
-
success: true,
|
|
105
|
-
backups: [],
|
|
106
|
-
count: 0,
|
|
107
|
-
message: 'No backups directory found',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
case 'verify': {
|
|
112
|
-
const backupPath = params.backupPath;
|
|
113
|
-
if (!backupPath)
|
|
114
|
-
throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
|
|
115
|
-
try {
|
|
116
|
-
const content = await fs.readFile(backupPath, 'utf-8');
|
|
117
|
-
const backup = JSON.parse(content);
|
|
118
|
-
const isValid = backup.timestamp && backup.projectPath;
|
|
119
|
-
return {
|
|
120
|
-
success: true,
|
|
121
|
-
valid: isValid,
|
|
122
|
-
backup,
|
|
123
|
-
message: isValid ? 'Backup is valid' : 'Backup is invalid',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
return {
|
|
128
|
-
success: false,
|
|
129
|
-
valid: false,
|
|
130
|
-
error: error.message,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
case 'restore': {
|
|
135
|
-
const backupPath = params.backupPath;
|
|
136
|
-
if (!backupPath)
|
|
137
|
-
throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
|
|
138
|
-
try {
|
|
139
|
-
const content = await fs.readFile(backupPath, 'utf-8');
|
|
140
|
-
const backup = JSON.parse(content);
|
|
141
|
-
return {
|
|
142
|
-
success: true,
|
|
143
|
-
message: 'Backup info retrieved - manual restore required',
|
|
144
|
-
backup,
|
|
145
|
-
note: 'Use git commands to restore to the specified commit',
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
throw new MCPError('FILE_ERROR', `Failed to read backup: ${error.message}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
default:
|
|
153
|
-
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Tool, MCPContext } from '../types.js';
|
|
2
|
-
export declare class GitBranchesTool implements Tool {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: "object";
|
|
7
|
-
properties: {
|
|
8
|
-
projectPath: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
action: {
|
|
13
|
-
type: string;
|
|
14
|
-
enum: string[];
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
branchName: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
checkout: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
sourceBranch: {
|
|
26
|
-
type: string;
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
confirm: {
|
|
30
|
-
type: string;
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
force: {
|
|
34
|
-
type: string;
|
|
35
|
-
description: string;
|
|
36
|
-
};
|
|
37
|
-
targetBranch: {
|
|
38
|
-
type: string;
|
|
39
|
-
description: string;
|
|
40
|
-
};
|
|
41
|
-
baseBranch: {
|
|
42
|
-
type: string;
|
|
43
|
-
description: string;
|
|
44
|
-
};
|
|
45
|
-
compareBranch: {
|
|
46
|
-
type: string;
|
|
47
|
-
description: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
required: string[];
|
|
51
|
-
additionalProperties: boolean;
|
|
52
|
-
};
|
|
53
|
-
handle(params: Record<string, any>, ctx: MCPContext): Promise<any>;
|
|
54
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { MCPError } from '../utils/errors.js';
|
|
2
|
-
import { requireConfirmationIfDestructive } from '../utils/safetyController.js';
|
|
3
|
-
import { getRepoInfo } from '../utils/repoHelpers.js';
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
export class GitBranchesTool {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.name = 'git-branches';
|
|
8
|
-
this.description = 'Branch management operations - automatic dual-provider execution for remote queries';
|
|
9
|
-
this.inputSchema = {
|
|
10
|
-
type: "object",
|
|
11
|
-
properties: {
|
|
12
|
-
projectPath: {
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "Absolute path to the project/repository (REQUIRED)"
|
|
15
|
-
},
|
|
16
|
-
action: {
|
|
17
|
-
type: "string",
|
|
18
|
-
enum: ["create", "list", "get", "delete", "merge", "compare"],
|
|
19
|
-
description: "Action to perform: create (create branch), list (list branches), get (get branch info), delete (delete branch), merge (merge branches), compare (compare branches)"
|
|
20
|
-
},
|
|
21
|
-
branchName: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Branch name (required for create/get/delete/merge)"
|
|
24
|
-
},
|
|
25
|
-
checkout: {
|
|
26
|
-
type: "boolean",
|
|
27
|
-
description: "Checkout after creating branch (optional for create, default: true)"
|
|
28
|
-
},
|
|
29
|
-
sourceBranch: {
|
|
30
|
-
type: "string",
|
|
31
|
-
description: "Source branch to create from (optional for create)"
|
|
32
|
-
},
|
|
33
|
-
confirm: {
|
|
34
|
-
type: "boolean",
|
|
35
|
-
description: "Confirm destructive operations (optional for delete)"
|
|
36
|
-
},
|
|
37
|
-
force: {
|
|
38
|
-
type: "boolean",
|
|
39
|
-
description: "Force delete branch (optional for delete)"
|
|
40
|
-
},
|
|
41
|
-
targetBranch: {
|
|
42
|
-
type: "string",
|
|
43
|
-
description: "Target branch for merge (optional for merge)"
|
|
44
|
-
},
|
|
45
|
-
baseBranch: {
|
|
46
|
-
type: "string",
|
|
47
|
-
description: "Base branch for comparison (required for compare)"
|
|
48
|
-
},
|
|
49
|
-
compareBranch: {
|
|
50
|
-
type: "string",
|
|
51
|
-
description: "Branch to compare against base (required for compare)"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
required: ["projectPath", "action"],
|
|
55
|
-
additionalProperties: true
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async handle(params, ctx) {
|
|
59
|
-
const action = params.action;
|
|
60
|
-
const projectPath = params.projectPath;
|
|
61
|
-
if (!action || !projectPath) {
|
|
62
|
-
throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
|
|
63
|
-
}
|
|
64
|
-
if (!ctx.gitAdapter) {
|
|
65
|
-
throw new MCPError('INTERNAL_ERROR', 'Git adapter not available');
|
|
66
|
-
}
|
|
67
|
-
switch (action) {
|
|
68
|
-
case 'create': {
|
|
69
|
-
const branchName = params.branchName;
|
|
70
|
-
if (!branchName)
|
|
71
|
-
throw new MCPError('VALIDATION_ERROR', 'branchName is required');
|
|
72
|
-
const sourceBranch = params.sourceBranch;
|
|
73
|
-
if (sourceBranch) {
|
|
74
|
-
await ctx.gitAdapter.checkout(projectPath, sourceBranch);
|
|
75
|
-
}
|
|
76
|
-
await ctx.gitAdapter.createBranch(projectPath, branchName);
|
|
77
|
-
if (params.checkout !== false) {
|
|
78
|
-
await ctx.gitAdapter.checkout(projectPath, branchName);
|
|
79
|
-
}
|
|
80
|
-
return { success: true, branch: branchName, local: true };
|
|
81
|
-
}
|
|
82
|
-
case 'list': {
|
|
83
|
-
const branches = await ctx.gitAdapter.listBranches(projectPath);
|
|
84
|
-
const current = await ctx.gitAdapter.getCurrentBranch(projectPath);
|
|
85
|
-
const results = {
|
|
86
|
-
success: true,
|
|
87
|
-
local: {
|
|
88
|
-
branches,
|
|
89
|
-
current,
|
|
90
|
-
},
|
|
91
|
-
providers: {}
|
|
92
|
-
};
|
|
93
|
-
// Also query remote APIs
|
|
94
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
95
|
-
const repo = params.repo || repoInfo.repoName;
|
|
96
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
97
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
98
|
-
// GitHub
|
|
99
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
100
|
-
try {
|
|
101
|
-
const branches = await ctx.providerManager.github.rest.repos.listBranches({
|
|
102
|
-
owner: githubOwner,
|
|
103
|
-
repo: repo,
|
|
104
|
-
});
|
|
105
|
-
results.providers.github = {
|
|
106
|
-
success: true,
|
|
107
|
-
branches: branches.data.map((b) => ({
|
|
108
|
-
name: b.name,
|
|
109
|
-
protected: b.protected,
|
|
110
|
-
sha: b.commit.sha,
|
|
111
|
-
})),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
results.providers.github = { success: false, error: err.message };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Gitea
|
|
119
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
120
|
-
try {
|
|
121
|
-
const branches = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/branches`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
122
|
-
results.providers.gitea = {
|
|
123
|
-
success: true,
|
|
124
|
-
branches: branches.data.map((b) => ({
|
|
125
|
-
name: b.name,
|
|
126
|
-
protected: b.protected,
|
|
127
|
-
sha: b.commit.id,
|
|
128
|
-
})),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
results.providers.gitea = { success: false, error: err.message };
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return results;
|
|
136
|
-
}
|
|
137
|
-
case 'get': {
|
|
138
|
-
const branchName = params.branchName;
|
|
139
|
-
if (!branchName)
|
|
140
|
-
throw new MCPError('VALIDATION_ERROR', 'branchName is required');
|
|
141
|
-
const branches = await ctx.gitAdapter.listBranches(projectPath);
|
|
142
|
-
const current = await ctx.gitAdapter.getCurrentBranch(projectPath);
|
|
143
|
-
const found = branches.includes(branchName);
|
|
144
|
-
const results = {
|
|
145
|
-
success: true,
|
|
146
|
-
local: found ? { branch: branchName, current: current === branchName } : { found: false },
|
|
147
|
-
providers: {}
|
|
148
|
-
};
|
|
149
|
-
// Also query remote APIs
|
|
150
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
151
|
-
const repo = params.repo || repoInfo.repoName;
|
|
152
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
153
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
154
|
-
// GitHub
|
|
155
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
156
|
-
try {
|
|
157
|
-
const branchData = await ctx.providerManager.github.rest.repos.getBranch({
|
|
158
|
-
owner: githubOwner,
|
|
159
|
-
repo: repo,
|
|
160
|
-
branch: branchName,
|
|
161
|
-
});
|
|
162
|
-
results.providers.github = {
|
|
163
|
-
success: true,
|
|
164
|
-
branch: {
|
|
165
|
-
name: branchData.data.name,
|
|
166
|
-
protected: branchData.data.protected,
|
|
167
|
-
sha: branchData.data.commit.sha,
|
|
168
|
-
commit: branchData.data.commit,
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
catch (err) {
|
|
173
|
-
results.providers.github = { success: false, error: err.message };
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// Gitea
|
|
177
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
178
|
-
try {
|
|
179
|
-
const branchData = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/branches/${branchName}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
180
|
-
results.providers.gitea = {
|
|
181
|
-
success: true,
|
|
182
|
-
branch: {
|
|
183
|
-
name: branchData.data.name,
|
|
184
|
-
protected: branchData.data.protected,
|
|
185
|
-
sha: branchData.data.commit.id,
|
|
186
|
-
commit: branchData.data.commit,
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
catch (err) {
|
|
191
|
-
results.providers.gitea = { success: false, error: err.message };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return results;
|
|
195
|
-
}
|
|
196
|
-
case 'delete': {
|
|
197
|
-
requireConfirmationIfDestructive('delete', params);
|
|
198
|
-
const branchName = params.branchName;
|
|
199
|
-
if (!branchName)
|
|
200
|
-
throw new MCPError('VALIDATION_ERROR', 'branchName is required');
|
|
201
|
-
await ctx.gitAdapter.deleteBranch(projectPath, branchName, params.force);
|
|
202
|
-
return { success: true, deleted: branchName, local: true };
|
|
203
|
-
}
|
|
204
|
-
case 'merge': {
|
|
205
|
-
const branchName = params.branchName;
|
|
206
|
-
const targetBranch = params.targetBranch;
|
|
207
|
-
if (!branchName)
|
|
208
|
-
throw new MCPError('VALIDATION_ERROR', 'branchName is required');
|
|
209
|
-
if (targetBranch) {
|
|
210
|
-
await ctx.gitAdapter.checkout(projectPath, targetBranch);
|
|
211
|
-
}
|
|
212
|
-
const result = await ctx.gitAdapter.merge(projectPath, branchName);
|
|
213
|
-
return { success: true, result, local: true };
|
|
214
|
-
}
|
|
215
|
-
case 'compare': {
|
|
216
|
-
const baseBranch = params.baseBranch;
|
|
217
|
-
const compareBranch = params.compareBranch;
|
|
218
|
-
if (!baseBranch || !compareBranch) {
|
|
219
|
-
throw new MCPError('VALIDATION_ERROR', 'baseBranch and compareBranch are required');
|
|
220
|
-
}
|
|
221
|
-
// Basic comparison using log
|
|
222
|
-
// Note: This is a simplified comparison compared to git log base..compare
|
|
223
|
-
const baseLog = await ctx.gitAdapter.log(projectPath, { ref: baseBranch, maxCount: 20 });
|
|
224
|
-
const compareLog = await ctx.gitAdapter.log(projectPath, { ref: compareBranch, maxCount: 20 });
|
|
225
|
-
// Find commits in compare that are not in base
|
|
226
|
-
const baseHashes = new Set(baseLog.map(c => c.hash));
|
|
227
|
-
const uniqueCommits = compareLog.filter(c => !baseHashes.has(c.hash));
|
|
228
|
-
const results = {
|
|
229
|
-
success: true,
|
|
230
|
-
local: {
|
|
231
|
-
baseBranch,
|
|
232
|
-
compareBranch,
|
|
233
|
-
commits: uniqueCommits,
|
|
234
|
-
diff: "Diff not supported in adapter yet", // Placeholder
|
|
235
|
-
},
|
|
236
|
-
providers: {}
|
|
237
|
-
};
|
|
238
|
-
// Also compare on remote APIs
|
|
239
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
240
|
-
const repo = params.repo || repoInfo.repoName;
|
|
241
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
242
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
243
|
-
// GitHub
|
|
244
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
245
|
-
try {
|
|
246
|
-
const comparison = await ctx.providerManager.github.rest.repos.compareCommits({
|
|
247
|
-
owner: githubOwner,
|
|
248
|
-
repo: repo,
|
|
249
|
-
base: baseBranch,
|
|
250
|
-
head: compareBranch,
|
|
251
|
-
});
|
|
252
|
-
results.providers.github = {
|
|
253
|
-
success: true,
|
|
254
|
-
comparison: {
|
|
255
|
-
status: comparison.data.status,
|
|
256
|
-
ahead_by: comparison.data.ahead_by,
|
|
257
|
-
behind_by: comparison.data.behind_by,
|
|
258
|
-
total_commits: comparison.data.total_commits,
|
|
259
|
-
commits: comparison.data.commits.map((c) => ({
|
|
260
|
-
sha: c.sha,
|
|
261
|
-
message: c.commit.message,
|
|
262
|
-
author: c.commit.author.name,
|
|
263
|
-
date: c.commit.author.date,
|
|
264
|
-
})),
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
catch (err) {
|
|
269
|
-
results.providers.github = { success: false, error: err.message };
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
// Gitea - comparison API might not be available
|
|
273
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
274
|
-
results.providers.gitea = { success: false, error: 'Comparison API not available in Gitea' };
|
|
275
|
-
}
|
|
276
|
-
return results;
|
|
277
|
-
}
|
|
278
|
-
default:
|
|
279
|
-
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Tool, MCPContext } from '../types.js';
|
|
2
|
-
export declare class GitChangelogTool implements Tool {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: "object";
|
|
7
|
-
properties: {
|
|
8
|
-
projectPath: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
from: {
|
|
13
|
-
type: string;
|
|
14
|
-
description: string;
|
|
15
|
-
};
|
|
16
|
-
to: {
|
|
17
|
-
type: string;
|
|
18
|
-
description: string;
|
|
19
|
-
};
|
|
20
|
-
format: {
|
|
21
|
-
type: string;
|
|
22
|
-
description: string;
|
|
23
|
-
enum: string[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
required: string[];
|
|
27
|
-
additionalProperties: boolean;
|
|
28
|
-
};
|
|
29
|
-
handle(params: Record<string, any>, ctx: MCPContext): Promise<{
|
|
30
|
-
success: boolean;
|
|
31
|
-
changelog: string;
|
|
32
|
-
format: any;
|
|
33
|
-
commits: number;
|
|
34
|
-
from: any;
|
|
35
|
-
to: any;
|
|
36
|
-
}>;
|
|
37
|
-
}
|