@commitsage/mcp-server 1.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 +434 -0
- package/dist/adapters/sse.d.ts +26 -0
- package/dist/adapters/sse.d.ts.map +1 -0
- package/dist/adapters/sse.js +45 -0
- package/dist/adapters/sse.js.map +1 -0
- package/dist/auth/jwt.d.ts +70 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +171 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/oauth.d.ts +71 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +213 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/models/errors.d.ts +34 -0
- package/dist/models/errors.d.ts.map +1 -0
- package/dist/models/errors.js +67 -0
- package/dist/models/errors.js.map +1 -0
- package/dist/models/types.d.ts +39 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +9 -0
- package/dist/models/types.js.map +1 -0
- package/dist/server/mcpServer.d.ts +11 -0
- package/dist/server/mcpServer.d.ts.map +1 -0
- package/dist/server/mcpServer.js +216 -0
- package/dist/server/mcpServer.js.map +1 -0
- package/dist/server/tools.d.ts +93 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/server/tools.js +272 -0
- package/dist/server/tools.js.map +1 -0
- package/dist/services/aiService.d.ts +12 -0
- package/dist/services/aiService.d.ts.map +1 -0
- package/dist/services/aiService.js +86 -0
- package/dist/services/aiService.js.map +1 -0
- package/dist/services/baseAIService.d.ts +47 -0
- package/dist/services/baseAIService.d.ts.map +1 -0
- package/dist/services/baseAIService.js +153 -0
- package/dist/services/baseAIService.js.map +1 -0
- package/dist/services/codestralService.d.ts +7 -0
- package/dist/services/codestralService.d.ts.map +1 -0
- package/dist/services/codestralService.js +49 -0
- package/dist/services/codestralService.js.map +1 -0
- package/dist/services/geminiService.d.ts +18 -0
- package/dist/services/geminiService.d.ts.map +1 -0
- package/dist/services/geminiService.js +139 -0
- package/dist/services/geminiService.js.map +1 -0
- package/dist/services/gitBlameAnalyzer.d.ts +15 -0
- package/dist/services/gitBlameAnalyzer.d.ts.map +1 -0
- package/dist/services/gitBlameAnalyzer.js +135 -0
- package/dist/services/gitBlameAnalyzer.js.map +1 -0
- package/dist/services/gitService.d.ts +54 -0
- package/dist/services/gitService.d.ts.map +1 -0
- package/dist/services/gitService.js +394 -0
- package/dist/services/gitService.js.map +1 -0
- package/dist/services/ollamaService.d.ts +7 -0
- package/dist/services/ollamaService.d.ts.map +1 -0
- package/dist/services/ollamaService.js +43 -0
- package/dist/services/ollamaService.js.map +1 -0
- package/dist/services/openaiService.d.ts +9 -0
- package/dist/services/openaiService.d.ts.map +1 -0
- package/dist/services/openaiService.js +69 -0
- package/dist/services/openaiService.js.map +1 -0
- package/dist/services/promptService.d.ts +10 -0
- package/dist/services/promptService.d.ts.map +1 -0
- package/dist/services/promptService.js +136 -0
- package/dist/services/promptService.js.map +1 -0
- package/dist/utils/config.d.ts +27 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +80 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/httpUtils.d.ts +33 -0
- package/dist/utils/httpUtils.d.ts.map +1 -0
- package/dist/utils/httpUtils.js +54 -0
- package/dist/utils/httpUtils.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +59 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/retryUtils.d.ts +29 -0
- package/dist/utils/retryUtils.d.ts.map +1 -0
- package/dist/utils/retryUtils.js +49 -0
- package/dist/utils/retryUtils.js.map +1 -0
- package/dist/utils/textProcessing.d.ts +8 -0
- package/dist/utils/textProcessing.d.ts.map +1 -0
- package/dist/utils/textProcessing.js +10 -0
- package/dist/utils/textProcessing.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/models/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsCH,MAAM,OAAO,oBAAoB;IAC/B,MAAM,CAAC,MAAgD;QACrD,uBAAuB;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server implementation for CommitSage
|
|
3
|
+
*/
|
|
4
|
+
export declare class CommitSageMCPServer {
|
|
5
|
+
private server;
|
|
6
|
+
constructor();
|
|
7
|
+
private setupToolHandlers;
|
|
8
|
+
private setupErrorHandling;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mcpServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServer.d.ts","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsBH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;;IAmBvB,OAAO,CAAC,iBAAiB;IAqKzB,OAAO,CAAC,kBAAkB;IAkBpB,KAAK;CAoBZ"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server implementation for CommitSage
|
|
3
|
+
*/
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { Logger } from "../utils/logger.js";
|
|
8
|
+
import { ConfigService } from "../utils/config.js";
|
|
9
|
+
import { GitService } from "../services/gitService.js";
|
|
10
|
+
import { GenerateCommitMessageSchema, AnalyzeChangesSchema, ListCommitFormatsSchema, ValidateApiKeySchema, handleGenerateCommitMessage, handleAnalyzeChanges, handleListCommitFormats, handleValidateApiKey, } from "./tools.js";
|
|
11
|
+
export class CommitSageMCPServer {
|
|
12
|
+
server;
|
|
13
|
+
constructor() {
|
|
14
|
+
this.server = new Server({
|
|
15
|
+
name: "commitsage",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
}, {
|
|
18
|
+
capabilities: {
|
|
19
|
+
tools: {},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
this.setupToolHandlers();
|
|
23
|
+
this.setupErrorHandling();
|
|
24
|
+
}
|
|
25
|
+
setupToolHandlers() {
|
|
26
|
+
// List available tools
|
|
27
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
28
|
+
return {
|
|
29
|
+
tools: [
|
|
30
|
+
{
|
|
31
|
+
name: "generate_commit_message",
|
|
32
|
+
description: "Generate an AI-powered commit message for a Git repository based on staged or all changes. Analyzes the diff and git blame information to create a meaningful commit message in the specified format and language.",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
repoPath: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Path to the git repository",
|
|
39
|
+
},
|
|
40
|
+
provider: {
|
|
41
|
+
type: "string",
|
|
42
|
+
enum: ["gemini", "openai", "codestral", "ollama"],
|
|
43
|
+
description: "AI provider to use (defaults to configured provider)",
|
|
44
|
+
},
|
|
45
|
+
format: {
|
|
46
|
+
type: "string",
|
|
47
|
+
enum: [
|
|
48
|
+
"conventional",
|
|
49
|
+
"angular",
|
|
50
|
+
"karma",
|
|
51
|
+
"semantic",
|
|
52
|
+
"emoji",
|
|
53
|
+
"emojiKarma",
|
|
54
|
+
"google",
|
|
55
|
+
"atom",
|
|
56
|
+
],
|
|
57
|
+
description: "Commit message format",
|
|
58
|
+
},
|
|
59
|
+
language: {
|
|
60
|
+
type: "string",
|
|
61
|
+
enum: [
|
|
62
|
+
"english",
|
|
63
|
+
"russian",
|
|
64
|
+
"chinese",
|
|
65
|
+
"japanese",
|
|
66
|
+
"spanish",
|
|
67
|
+
],
|
|
68
|
+
description: "Language for commit message",
|
|
69
|
+
},
|
|
70
|
+
onlyStaged: {
|
|
71
|
+
type: "boolean",
|
|
72
|
+
description: "Only analyze staged changes (default: false)",
|
|
73
|
+
},
|
|
74
|
+
customInstructions: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Custom instructions for commit message generation",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ["repoPath"],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "analyze_changes",
|
|
84
|
+
description: "Analyze git changes in a repository. Returns information about staged/unstaged changes, changed files, and a preview of the diff.",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
repoPath: {
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "Path to the git repository",
|
|
91
|
+
},
|
|
92
|
+
onlyStaged: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
description: "Only analyze staged changes (default: false)",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
required: ["repoPath"],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "list_commit_formats",
|
|
102
|
+
description: "List all available commit message formats with descriptions and examples.",
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "validate_api_key",
|
|
110
|
+
description: "Validate that an API key is configured for a specific provider.",
|
|
111
|
+
inputSchema: {
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
provider: {
|
|
115
|
+
type: "string",
|
|
116
|
+
enum: ["gemini", "openai", "codestral", "ollama"],
|
|
117
|
+
description: "Provider to validate",
|
|
118
|
+
},
|
|
119
|
+
apiKey: {
|
|
120
|
+
type: "string",
|
|
121
|
+
description: "API key to validate (optional, uses env if not provided)",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
required: ["provider"],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
// Handle tool calls
|
|
131
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
132
|
+
const { name, arguments: args } = request.params;
|
|
133
|
+
try {
|
|
134
|
+
switch (name) {
|
|
135
|
+
case "generate_commit_message": {
|
|
136
|
+
const parsed = GenerateCommitMessageSchema.parse(args);
|
|
137
|
+
return await handleGenerateCommitMessage(parsed);
|
|
138
|
+
}
|
|
139
|
+
case "analyze_changes": {
|
|
140
|
+
const parsed = AnalyzeChangesSchema.parse(args);
|
|
141
|
+
return await handleAnalyzeChanges(parsed);
|
|
142
|
+
}
|
|
143
|
+
case "list_commit_formats": {
|
|
144
|
+
const parsed = ListCommitFormatsSchema.parse(args);
|
|
145
|
+
return await handleListCommitFormats(parsed);
|
|
146
|
+
}
|
|
147
|
+
case "validate_api_key": {
|
|
148
|
+
const parsed = ValidateApiKeySchema.parse(args);
|
|
149
|
+
return await handleValidateApiKey(parsed);
|
|
150
|
+
}
|
|
151
|
+
default:
|
|
152
|
+
return {
|
|
153
|
+
content: [
|
|
154
|
+
{
|
|
155
|
+
type: "text",
|
|
156
|
+
text: JSON.stringify({
|
|
157
|
+
error: `Unknown tool: ${name}`,
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
isError: true,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
Logger.error(`Error handling tool call ${name}:`, error);
|
|
167
|
+
return {
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: "text",
|
|
171
|
+
text: JSON.stringify({
|
|
172
|
+
error: error instanceof Error ? error.message : String(error),
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
isError: true,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
setupErrorHandling() {
|
|
182
|
+
this.server.onerror = (error) => {
|
|
183
|
+
Logger.error("MCP Server error:", error);
|
|
184
|
+
};
|
|
185
|
+
process.on("SIGINT", async () => {
|
|
186
|
+
Logger.log("Received SIGINT, shutting down gracefully...");
|
|
187
|
+
await this.server.close();
|
|
188
|
+
process.exit(0);
|
|
189
|
+
});
|
|
190
|
+
process.on("SIGTERM", async () => {
|
|
191
|
+
Logger.log("Received SIGTERM, shutting down gracefully...");
|
|
192
|
+
await this.server.close();
|
|
193
|
+
process.exit(0);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async start() {
|
|
197
|
+
try {
|
|
198
|
+
// Initialize services
|
|
199
|
+
Logger.log("Initializing CommitSage MCP Server...");
|
|
200
|
+
ConfigService.initialize();
|
|
201
|
+
await GitService.validateGit();
|
|
202
|
+
// Connect via stdio transport
|
|
203
|
+
const transport = new StdioServerTransport();
|
|
204
|
+
await this.server.connect(transport);
|
|
205
|
+
Logger.log("CommitSage MCP Server started successfully");
|
|
206
|
+
Logger.log(`Default provider: ${ConfigService.getProvider()}`);
|
|
207
|
+
Logger.log(`Default format: ${ConfigService.getCommitFormat()}`);
|
|
208
|
+
Logger.log(`Default language: ${ConfigService.getCommitLanguage()}`);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
Logger.error("Failed to start MCP server:", error);
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=mcpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServer.js","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,E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,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,sBAAsB;YACtB,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;YACpD,aAAa,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC;YAE/B,8BAA8B;YAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;YAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAErC,MAAM,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;YACzD,MAAM,CAAC,GAAG,CAAC,qBAAqB,aAAa,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC/D,MAAM,CAAC,GAAG,CAAC,mBAAmB,aAAa,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YACjE,MAAM,CAAC,GAAG,CAAC,qBAAqB,aAAa,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools definitions for CommitSage
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare const GenerateCommitMessageSchema: z.ZodObject<{
|
|
6
|
+
repoPath: z.ZodString;
|
|
7
|
+
provider: z.ZodOptional<z.ZodEnum<["gemini", "openai", "codestral", "ollama"]>>;
|
|
8
|
+
format: z.ZodOptional<z.ZodEnum<["conventional", "angular", "karma", "semantic", "emoji", "emojiKarma", "google", "atom"]>>;
|
|
9
|
+
language: z.ZodOptional<z.ZodEnum<["english", "russian", "chinese", "japanese", "spanish"]>>;
|
|
10
|
+
onlyStaged: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
customInstructions: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
repoPath: string;
|
|
14
|
+
provider?: "gemini" | "openai" | "codestral" | "ollama" | undefined;
|
|
15
|
+
format?: "conventional" | "angular" | "karma" | "semantic" | "emoji" | "emojiKarma" | "google" | "atom" | undefined;
|
|
16
|
+
language?: "english" | "russian" | "chinese" | "japanese" | "spanish" | undefined;
|
|
17
|
+
onlyStaged?: boolean | undefined;
|
|
18
|
+
customInstructions?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
repoPath: string;
|
|
21
|
+
provider?: "gemini" | "openai" | "codestral" | "ollama" | undefined;
|
|
22
|
+
format?: "conventional" | "angular" | "karma" | "semantic" | "emoji" | "emojiKarma" | "google" | "atom" | undefined;
|
|
23
|
+
language?: "english" | "russian" | "chinese" | "japanese" | "spanish" | undefined;
|
|
24
|
+
onlyStaged?: boolean | undefined;
|
|
25
|
+
customInstructions?: string | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const AnalyzeChangesSchema: z.ZodObject<{
|
|
28
|
+
repoPath: z.ZodString;
|
|
29
|
+
onlyStaged: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
repoPath: string;
|
|
32
|
+
onlyStaged?: boolean | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
repoPath: string;
|
|
35
|
+
onlyStaged?: boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const ListCommitFormatsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
38
|
+
export declare const ValidateApiKeySchema: z.ZodObject<{
|
|
39
|
+
provider: z.ZodEnum<["gemini", "openai", "codestral", "ollama"]>;
|
|
40
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
provider: "gemini" | "openai" | "codestral" | "ollama";
|
|
43
|
+
apiKey?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
provider: "gemini" | "openai" | "codestral" | "ollama";
|
|
46
|
+
apiKey?: string | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function handleGenerateCommitMessage(args: z.infer<typeof GenerateCommitMessageSchema>): Promise<{
|
|
49
|
+
content: {
|
|
50
|
+
type: string;
|
|
51
|
+
text: string;
|
|
52
|
+
}[];
|
|
53
|
+
isError?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
content: {
|
|
56
|
+
type: string;
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
isError: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
export declare function handleAnalyzeChanges(args: z.infer<typeof AnalyzeChangesSchema>): Promise<{
|
|
62
|
+
content: {
|
|
63
|
+
type: string;
|
|
64
|
+
text: string;
|
|
65
|
+
}[];
|
|
66
|
+
isError?: undefined;
|
|
67
|
+
} | {
|
|
68
|
+
content: {
|
|
69
|
+
type: string;
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
isError: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
export declare function handleListCommitFormats(_args: z.infer<typeof ListCommitFormatsSchema>): Promise<{
|
|
75
|
+
content: {
|
|
76
|
+
type: string;
|
|
77
|
+
text: string;
|
|
78
|
+
}[];
|
|
79
|
+
}>;
|
|
80
|
+
export declare function handleValidateApiKey(args: z.infer<typeof ValidateApiKeySchema>): Promise<{
|
|
81
|
+
content: {
|
|
82
|
+
type: string;
|
|
83
|
+
text: string;
|
|
84
|
+
}[];
|
|
85
|
+
isError?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
content: {
|
|
88
|
+
type: string;
|
|
89
|
+
text: string;
|
|
90
|
+
}[];
|
|
91
|
+
isError: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/server/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;EA+BtC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;EAM/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gDAAe,CAAC;AAEpD,eAAO,MAAM,oBAAoB;;;;;;;;;EAK/B,CAAC;AAGH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC;;;;;;;;;;;;GAkElG;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;;;;GAuDpF;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC;;;;;GA4D3F;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;;;;GA+DpF"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools definitions for CommitSage
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { AIService } from '../services/aiService.js';
|
|
6
|
+
import { GitService } from '../services/gitService.js';
|
|
7
|
+
import { Logger } from '../utils/logger.js';
|
|
8
|
+
import { ConfigService } from '../utils/config.js';
|
|
9
|
+
// Tool schemas
|
|
10
|
+
export const GenerateCommitMessageSchema = z.object({
|
|
11
|
+
repoPath: z.string().describe('Path to the git repository'),
|
|
12
|
+
provider: z
|
|
13
|
+
.enum(['gemini', 'openai', 'codestral', 'ollama'])
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('AI provider to use (defaults to configured provider)'),
|
|
16
|
+
format: z
|
|
17
|
+
.enum([
|
|
18
|
+
'conventional',
|
|
19
|
+
'angular',
|
|
20
|
+
'karma',
|
|
21
|
+
'semantic',
|
|
22
|
+
'emoji',
|
|
23
|
+
'emojiKarma',
|
|
24
|
+
'google',
|
|
25
|
+
'atom',
|
|
26
|
+
])
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Commit message format'),
|
|
29
|
+
language: z
|
|
30
|
+
.enum(['english', 'russian', 'chinese', 'japanese', 'spanish'])
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Language for commit message'),
|
|
33
|
+
onlyStaged: z
|
|
34
|
+
.boolean()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Only analyze staged changes (default: false)'),
|
|
37
|
+
customInstructions: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('Custom instructions for commit message generation'),
|
|
41
|
+
});
|
|
42
|
+
export const AnalyzeChangesSchema = z.object({
|
|
43
|
+
repoPath: z.string().describe('Path to the git repository'),
|
|
44
|
+
onlyStaged: z
|
|
45
|
+
.boolean()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('Only analyze staged changes (default: false)'),
|
|
48
|
+
});
|
|
49
|
+
export const ListCommitFormatsSchema = z.object({});
|
|
50
|
+
export const ValidateApiKeySchema = z.object({
|
|
51
|
+
provider: z
|
|
52
|
+
.enum(['gemini', 'openai', 'codestral', 'ollama'])
|
|
53
|
+
.describe('Provider to validate'),
|
|
54
|
+
apiKey: z.string().optional().describe('API key to validate (optional, uses env if not provided)'),
|
|
55
|
+
});
|
|
56
|
+
// Tool handlers
|
|
57
|
+
export async function handleGenerateCommitMessage(args) {
|
|
58
|
+
try {
|
|
59
|
+
Logger.log(`Generating commit message for: ${args.repoPath}`);
|
|
60
|
+
// Temporarily override config if needed
|
|
61
|
+
const originalEnv = { ...process.env };
|
|
62
|
+
if (args.format) {
|
|
63
|
+
process.env.DEFAULT_COMMIT_FORMAT = args.format;
|
|
64
|
+
}
|
|
65
|
+
if (args.language) {
|
|
66
|
+
process.env.DEFAULT_COMMIT_LANGUAGE = args.language;
|
|
67
|
+
}
|
|
68
|
+
if (args.customInstructions) {
|
|
69
|
+
process.env.USE_CUSTOM_INSTRUCTIONS = 'true';
|
|
70
|
+
process.env.CUSTOM_INSTRUCTIONS = args.customInstructions;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = await AIService.generateCommitMessageForRepo(args.repoPath, args.onlyStaged || false, args.provider);
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: 'text',
|
|
78
|
+
text: JSON.stringify({
|
|
79
|
+
success: true,
|
|
80
|
+
message: result.message,
|
|
81
|
+
model: result.model,
|
|
82
|
+
provider: args.provider || ConfigService.getProvider(),
|
|
83
|
+
}, null, 2),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
// Restore original env
|
|
90
|
+
process.env = originalEnv;
|
|
91
|
+
ConfigService.initialize();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
Logger.error('Error generating commit message:', error);
|
|
96
|
+
return {
|
|
97
|
+
content: [
|
|
98
|
+
{
|
|
99
|
+
type: 'text',
|
|
100
|
+
text: JSON.stringify({
|
|
101
|
+
success: false,
|
|
102
|
+
error: error instanceof Error ? error.message : String(error),
|
|
103
|
+
}, null, 2),
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
isError: true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function handleAnalyzeChanges(args) {
|
|
111
|
+
try {
|
|
112
|
+
Logger.log(`Analyzing changes for: ${args.repoPath}`);
|
|
113
|
+
await GitService.validateRepository(args.repoPath);
|
|
114
|
+
const hasStagedChanges = await GitService.hasChanges(args.repoPath, 'staged');
|
|
115
|
+
const hasUnstagedChanges = await GitService.hasChanges(args.repoPath, 'unstaged');
|
|
116
|
+
const hasUntrackedFiles = await GitService.hasChanges(args.repoPath, 'untracked');
|
|
117
|
+
const diff = await GitService.getDiff(args.repoPath, args.onlyStaged || false);
|
|
118
|
+
const changedFiles = await GitService.getChangedFiles(args.repoPath, args.onlyStaged || false);
|
|
119
|
+
return {
|
|
120
|
+
content: [
|
|
121
|
+
{
|
|
122
|
+
type: 'text',
|
|
123
|
+
text: JSON.stringify({
|
|
124
|
+
success: true,
|
|
125
|
+
analysis: {
|
|
126
|
+
hasStagedChanges,
|
|
127
|
+
hasUnstagedChanges,
|
|
128
|
+
hasUntrackedFiles,
|
|
129
|
+
changedFilesCount: changedFiles.length,
|
|
130
|
+
changedFiles,
|
|
131
|
+
diffLength: diff.length,
|
|
132
|
+
diffPreview: diff.substring(0, 500),
|
|
133
|
+
},
|
|
134
|
+
}, null, 2),
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
Logger.error('Error analyzing changes:', error);
|
|
141
|
+
return {
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: 'text',
|
|
145
|
+
text: JSON.stringify({
|
|
146
|
+
success: false,
|
|
147
|
+
error: error instanceof Error ? error.message : String(error),
|
|
148
|
+
}, null, 2),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
isError: true,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export async function handleListCommitFormats(_args) {
|
|
156
|
+
const formats = [
|
|
157
|
+
{
|
|
158
|
+
name: 'conventional',
|
|
159
|
+
description: 'Conventional Commits format: type(scope): description',
|
|
160
|
+
example: 'feat(auth): add OAuth2 authentication',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'angular',
|
|
164
|
+
description: 'Angular commit format with type, scope, and summary',
|
|
165
|
+
example: 'build(deps): update dependency versions',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'karma',
|
|
169
|
+
description: 'Karma format: type(scope): message',
|
|
170
|
+
example: 'fix(parser): handle edge case in tokenizer',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'semantic',
|
|
174
|
+
description: 'Semantic format: type: message',
|
|
175
|
+
example: 'refactor: simplify user authentication flow',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'emoji',
|
|
179
|
+
description: 'Emoji-based commit messages',
|
|
180
|
+
example: ':sparkles: Add dark mode support',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'emojiKarma',
|
|
184
|
+
description: 'Combination of emoji and Karma format',
|
|
185
|
+
example: ':bug: fix(ui): correct button alignment',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'google',
|
|
189
|
+
description: 'Google commit format with capitalized type',
|
|
190
|
+
example: 'Feature: Add user profile page',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'atom',
|
|
194
|
+
description: 'Atom editor commit format',
|
|
195
|
+
example: 'feat(editor): add syntax highlighting',
|
|
196
|
+
},
|
|
197
|
+
];
|
|
198
|
+
return {
|
|
199
|
+
content: [
|
|
200
|
+
{
|
|
201
|
+
type: 'text',
|
|
202
|
+
text: JSON.stringify({
|
|
203
|
+
success: true,
|
|
204
|
+
formats,
|
|
205
|
+
currentFormat: ConfigService.getCommitFormat(),
|
|
206
|
+
}, null, 2),
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export async function handleValidateApiKey(args) {
|
|
212
|
+
try {
|
|
213
|
+
const provider = args.provider;
|
|
214
|
+
// Ollama doesn't require API key
|
|
215
|
+
if (provider === 'ollama') {
|
|
216
|
+
return {
|
|
217
|
+
content: [
|
|
218
|
+
{
|
|
219
|
+
type: 'text',
|
|
220
|
+
text: JSON.stringify({
|
|
221
|
+
success: true,
|
|
222
|
+
valid: true,
|
|
223
|
+
message: 'Ollama does not require an API key',
|
|
224
|
+
}),
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const hasKey = ConfigService.hasApiKey(provider);
|
|
230
|
+
if (!hasKey) {
|
|
231
|
+
return {
|
|
232
|
+
content: [
|
|
233
|
+
{
|
|
234
|
+
type: 'text',
|
|
235
|
+
text: JSON.stringify({
|
|
236
|
+
success: false,
|
|
237
|
+
valid: false,
|
|
238
|
+
message: `No API key found for ${provider}`,
|
|
239
|
+
}),
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: 'text',
|
|
248
|
+
text: JSON.stringify({
|
|
249
|
+
success: true,
|
|
250
|
+
valid: true,
|
|
251
|
+
message: `API key found for ${provider}`,
|
|
252
|
+
}),
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
content: [
|
|
260
|
+
{
|
|
261
|
+
type: 'text',
|
|
262
|
+
text: JSON.stringify({
|
|
263
|
+
success: false,
|
|
264
|
+
error: error instanceof Error ? error.message : String(error),
|
|
265
|
+
}),
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
isError: true,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/server/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;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
3
|
+
* Coordinates between different AI providers
|
|
4
|
+
*/
|
|
5
|
+
import { CommitMessage, ProgressReporter } from '../models/types.js';
|
|
6
|
+
export declare class AIService {
|
|
7
|
+
static requiresApiKey(provider: string): boolean;
|
|
8
|
+
static generateCommitMessage(diff: string, blameAnalysis: string, progress?: ProgressReporter, provider?: string): Promise<CommitMessage>;
|
|
9
|
+
private static truncateDiff;
|
|
10
|
+
static generateCommitMessageForRepo(repoPath: string, onlyStaged?: boolean, provider?: string): Promise<CommitMessage>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=aiService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiService.d.ts","sourceRoot":"","sources":["../../src/services/aiService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAwB,MAAM,oBAAoB,CAAC;AAY3F,qBAAa,SAAS;IACpB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;WAInC,qBAAqB,CAChC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,gBAA6C,EACvD,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC;IA2CzB,OAAO,CAAC,MAAM,CAAC,YAAY;WAMd,4BAA4B,CACvC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,OAAe,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC;CA0B1B"}
|