mcp-server-gemini 1.1.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/CHANGELOG.md +155 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/dist/config/constants.js +71 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/models.js +121 -0
- package/dist/config/models.js.map +1 -0
- package/dist/enhanced-stdio-server.js +1164 -0
- package/dist/enhanced-stdio-server.js.map +1 -0
- package/dist/i18n.js +109 -0
- package/dist/i18n.js.map +1 -0
- package/dist/server.js +251 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/analyze-codebase.js +373 -0
- package/dist/tools/analyze-codebase.js.map +1 -0
- package/dist/tools/analyze-content.js +295 -0
- package/dist/tools/analyze-content.js.map +1 -0
- package/dist/tools/brainstorm.js +237 -0
- package/dist/tools/brainstorm.js.map +1 -0
- package/dist/tools/definitions.js +375 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/fix-ui.js +262 -0
- package/dist/tools/fix-ui.js.map +1 -0
- package/dist/tools/generate-ui.js +311 -0
- package/dist/tools/generate-ui.js.map +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-models.js +30 -0
- package/dist/tools/list-models.js.map +1 -0
- package/dist/tools/multimodal-query.js +83 -0
- package/dist/tools/multimodal-query.js.map +1 -0
- package/dist/tools/search.js +94 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/error-handler.js +69 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/file-reader.js +470 -0
- package/dist/utils/file-reader.js.map +1 -0
- package/dist/utils/gemini-client.js +184 -0
- package/dist/utils/gemini-client.js.map +1 -0
- package/dist/utils/security.js +370 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/validators.js +150 -0
- package/dist/utils/validators.js.map +1 -0
- package/dist/windows-utils.js +175 -0
- package/dist/windows-utils.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool 3: gemini_fix_ui_from_screenshot
|
|
3
|
+
* Visual Debug Loop - Identify and fix UI issues from screenshots
|
|
4
|
+
*
|
|
5
|
+
* Core features:
|
|
6
|
+
* - Requires three inputs: screenshot + source code + issue description
|
|
7
|
+
* - Outputs git diff format patches for direct application
|
|
8
|
+
*
|
|
9
|
+
* Priority: P0 - Core functionality
|
|
10
|
+
*/
|
|
11
|
+
import { GoogleGenAI } from '@google/genai';
|
|
12
|
+
import { validateRequired, validateString } from '../utils/validators.js';
|
|
13
|
+
import { handleAPIError, logError } from '../utils/error-handler.js';
|
|
14
|
+
import { readFile, readFiles } from '../utils/file-reader.js';
|
|
15
|
+
// System prompt for Visual Debug Loop
|
|
16
|
+
const UI_FIX_SYSTEM_PROMPT = `You are a professional UI visual debugging expert, specializing in diagnosing and fixing frontend issues from screenshots.
|
|
17
|
+
|
|
18
|
+
## Your expertise:
|
|
19
|
+
- Identifying layout issues (alignment, spacing, overflow)
|
|
20
|
+
- Detecting styling problems (colors, fonts, borders)
|
|
21
|
+
- Spotting responsive design failures
|
|
22
|
+
- Finding accessibility issues
|
|
23
|
+
- Recognizing browser compatibility problems
|
|
24
|
+
|
|
25
|
+
## Workflow (Visual Debug Loop):
|
|
26
|
+
1. Carefully analyze visual problems in the screenshot
|
|
27
|
+
2. Cross-reference with source code to locate root cause
|
|
28
|
+
3. Understand the user's expected behavior
|
|
29
|
+
4. Generate precise code fixes (git diff format)
|
|
30
|
+
|
|
31
|
+
## Output requirements:
|
|
32
|
+
|
|
33
|
+
### 1. Diagnosis
|
|
34
|
+
- List all identified issues
|
|
35
|
+
- Explain the root cause of each issue
|
|
36
|
+
- Prioritize by severity
|
|
37
|
+
|
|
38
|
+
### 2. Patches
|
|
39
|
+
**Must use unified diff format**, example:
|
|
40
|
+
\`\`\`diff
|
|
41
|
+
--- a/src/components/Button.tsx
|
|
42
|
+
+++ b/src/components/Button.tsx
|
|
43
|
+
@@ -15,7 +15,7 @@ export const Button = ({ children }) => {
|
|
44
|
+
return (
|
|
45
|
+
<button
|
|
46
|
+
- className="px-4 py-2 bg-blue-500"
|
|
47
|
+
+ className="px-4 py-2 bg-blue-500 hover:bg-blue-600 transition-colors"
|
|
48
|
+
onClick={handleClick}
|
|
49
|
+
>
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
### 3. Changes
|
|
53
|
+
- Explain the purpose of each modification
|
|
54
|
+
- Describe why the fix is effective
|
|
55
|
+
|
|
56
|
+
### 4. Prevention Tips
|
|
57
|
+
- How to avoid similar issues
|
|
58
|
+
- Recommended tools or best practices
|
|
59
|
+
|
|
60
|
+
## Code quality principles:
|
|
61
|
+
- Minimal changes (fix only what's broken)
|
|
62
|
+
- Maintain existing code style
|
|
63
|
+
- Ensure backward compatibility`;
|
|
64
|
+
/**
|
|
65
|
+
* Handle gemini_fix_ui_from_screenshot tool call
|
|
66
|
+
*/
|
|
67
|
+
export async function handleFixUI(params, client) {
|
|
68
|
+
try {
|
|
69
|
+
// Validate required parameters
|
|
70
|
+
// screenshot can be file path or Base64, gemini-client.ts will handle conversion automatically
|
|
71
|
+
validateRequired(params.screenshot, 'screenshot');
|
|
72
|
+
validateString(params.screenshot, 'screenshot', 5);
|
|
73
|
+
// [NEW] Read source code files
|
|
74
|
+
let codeContext = '';
|
|
75
|
+
const analyzedFiles = [];
|
|
76
|
+
// Read main source code file
|
|
77
|
+
if (params.sourceCodePath) {
|
|
78
|
+
try {
|
|
79
|
+
const fileContent = await readFile(params.sourceCodePath);
|
|
80
|
+
analyzedFiles.push(fileContent.path);
|
|
81
|
+
codeContext += `## Main source code file: ${fileContent.path}\n`;
|
|
82
|
+
codeContext += `\`\`\`${fileContent.language?.toLowerCase() || ''}\n`;
|
|
83
|
+
codeContext += fileContent.content;
|
|
84
|
+
codeContext += '\n```\n\n';
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
logError('fixUI:readSourceCodePath', error);
|
|
88
|
+
// Continue execution, do not interrupt
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Read related files
|
|
92
|
+
if (params.relatedFiles && params.relatedFiles.length > 0) {
|
|
93
|
+
try {
|
|
94
|
+
const relatedContents = await readFiles(params.relatedFiles);
|
|
95
|
+
for (const file of relatedContents) {
|
|
96
|
+
analyzedFiles.push(file.path);
|
|
97
|
+
codeContext += `## Related file: ${file.path}\n`;
|
|
98
|
+
codeContext += `\`\`\`${file.language?.toLowerCase() || ''}\n`;
|
|
99
|
+
codeContext += file.content;
|
|
100
|
+
codeContext += '\n```\n\n';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
logError('fixUI:readRelatedFiles', error);
|
|
105
|
+
// Continue execution, do not interrupt
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Backward compatibility: if currentCode provided and no source file read
|
|
109
|
+
if (params.currentCode && !params.sourceCodePath) {
|
|
110
|
+
codeContext += `## Current code\n\`\`\`\n${params.currentCode}\n\`\`\`\n\n`;
|
|
111
|
+
}
|
|
112
|
+
// Build prompt
|
|
113
|
+
let prompt = `Analyze this screenshot and identify all UI problems.\n\n`;
|
|
114
|
+
if (params.issueDescription) {
|
|
115
|
+
prompt += `Known Issue: ${params.issueDescription}\n\n`;
|
|
116
|
+
}
|
|
117
|
+
// Add code context
|
|
118
|
+
if (codeContext) {
|
|
119
|
+
prompt += `# Source Code Context\n${codeContext}\n`;
|
|
120
|
+
}
|
|
121
|
+
if (params.targetState) {
|
|
122
|
+
// Check if targetState is an image
|
|
123
|
+
const isBase64Image = params.targetState.startsWith('data:image');
|
|
124
|
+
const isFilePath = /\.(png|jpg|jpeg|gif|webp|bmp|svg|ico)$/i.test(params.targetState);
|
|
125
|
+
if (!isBase64Image && !isFilePath) {
|
|
126
|
+
prompt += `Expected State: ${params.targetState}\n\n`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Build Visual Debug Loop output requirements
|
|
130
|
+
const hasSourceFiles = analyzedFiles.length > 0;
|
|
131
|
+
if (!hasSourceFiles && !params.currentCode) {
|
|
132
|
+
prompt += `\n⚠️ Warning: No source code provided. Please provide sourceCodePath or relatedFiles for more accurate git diff patches.\n\n`;
|
|
133
|
+
}
|
|
134
|
+
prompt += `Please output the fix in the following JSON format:
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
"diagnosis": "Detailed problem diagnosis report including cause and severity",
|
|
138
|
+
"patches": [
|
|
139
|
+
{
|
|
140
|
+
"filePath": "src/components/Example.tsx",
|
|
141
|
+
"diff": "--- a/src/components/Example.tsx\\n+++ b/src/components/Example.tsx\\n@@ -10,3 +10,3 @@\\n- old code\\n+ new code",
|
|
142
|
+
"changes": ["Change description 1", "Change description 2"]
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"preventionTips": ["Prevention tip 1", "Prevention tip 2"]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
Important requirements:
|
|
149
|
+
1. The diff in patches must be valid unified diff format
|
|
150
|
+
2. Each patch must include the complete file path
|
|
151
|
+
3. The diff content should include sufficient context (at least 3 lines)
|
|
152
|
+
4. Ensure the diff can be directly applied with 'git apply'`;
|
|
153
|
+
// Call Gemini API
|
|
154
|
+
const images = [params.screenshot];
|
|
155
|
+
// targetState can be an image (file path or Base64) or text description
|
|
156
|
+
// If it looks like an image, add it to the image list
|
|
157
|
+
if (params.targetState) {
|
|
158
|
+
const isBase64Image = params.targetState.startsWith('data:image');
|
|
159
|
+
const isFilePath = /\.(png|jpg|jpeg|gif|webp|bmp|svg|ico)$/i.test(params.targetState);
|
|
160
|
+
if (isBase64Image || isFilePath) {
|
|
161
|
+
images.push(params.targetState);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Determine thinking level (default high for complex debugging)
|
|
165
|
+
const thinkingLevel = params.thinkingLevel || 'high';
|
|
166
|
+
let response;
|
|
167
|
+
// Always use thinking mode with direct GoogleGenAI call
|
|
168
|
+
const apiKey = process.env.GEMINI_API_KEY;
|
|
169
|
+
if (!apiKey) {
|
|
170
|
+
throw new Error('GEMINI_API_KEY environment variable is not set');
|
|
171
|
+
}
|
|
172
|
+
const ai = new GoogleGenAI({ apiKey });
|
|
173
|
+
// Convert images to inline data format
|
|
174
|
+
const imageParts = await Promise.all(images.map(async (img) => {
|
|
175
|
+
const { convertImageToInlineData } = await import('../utils/gemini-client.js');
|
|
176
|
+
const { mimeType, data } = convertImageToInlineData(img);
|
|
177
|
+
return { inlineData: { mimeType, data } };
|
|
178
|
+
}));
|
|
179
|
+
const config = {
|
|
180
|
+
thinkingConfig: { thinkingLevel },
|
|
181
|
+
systemInstruction: UI_FIX_SYSTEM_PROMPT,
|
|
182
|
+
};
|
|
183
|
+
const contents = [{
|
|
184
|
+
role: 'user',
|
|
185
|
+
parts: [{ text: prompt }, ...imageParts]
|
|
186
|
+
}];
|
|
187
|
+
const apiResult = await ai.models.generateContent({
|
|
188
|
+
model: 'gemini-3-pro-preview',
|
|
189
|
+
config,
|
|
190
|
+
contents,
|
|
191
|
+
});
|
|
192
|
+
response = apiResult.text || '';
|
|
193
|
+
// Try to parse JSON response
|
|
194
|
+
try {
|
|
195
|
+
const parsedResult = JSON.parse(response);
|
|
196
|
+
// Add analyzed files list
|
|
197
|
+
if (analyzedFiles.length > 0) {
|
|
198
|
+
parsedResult.analyzedFiles = analyzedFiles;
|
|
199
|
+
}
|
|
200
|
+
// Ensure patches field exists (compatibility handling)
|
|
201
|
+
if (!parsedResult.patches && parsedResult.fixes) {
|
|
202
|
+
// Convert legacy fixes format to new patches format
|
|
203
|
+
parsedResult.patches = parsedResult.fixes.map((fix) => ({
|
|
204
|
+
filePath: fix.filePath || 'unknown',
|
|
205
|
+
diff: fix.code || '',
|
|
206
|
+
changes: fix.changes || [fix.description]
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
return parsedResult;
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// If not JSON, try to extract code blocks as diff
|
|
213
|
+
const diffBlocks = extractDiffFromResponse(response);
|
|
214
|
+
return {
|
|
215
|
+
diagnosis: response,
|
|
216
|
+
patches: diffBlocks.length > 0 ? diffBlocks : [{
|
|
217
|
+
filePath: 'unknown',
|
|
218
|
+
diff: extractCodeFromResponse(response),
|
|
219
|
+
changes: ['See diagnosis report for details']
|
|
220
|
+
}],
|
|
221
|
+
analyzedFiles: analyzedFiles.length > 0 ? analyzedFiles : undefined
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
logError('fixUI', error);
|
|
227
|
+
throw handleAPIError(error);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Extract diff code blocks from response
|
|
232
|
+
*/
|
|
233
|
+
function extractDiffFromResponse(response) {
|
|
234
|
+
const patches = [];
|
|
235
|
+
// Match diff code blocks
|
|
236
|
+
const diffPattern = /```diff\n([\s\S]*?)```/g;
|
|
237
|
+
let match;
|
|
238
|
+
while ((match = diffPattern.exec(response)) !== null) {
|
|
239
|
+
const diffContent = match[1].trim();
|
|
240
|
+
// Try to extract file path from diff header
|
|
241
|
+
const filePathMatch = diffContent.match(/^---\s+a\/(.+)$/m);
|
|
242
|
+
const filePath = filePathMatch ? filePathMatch[1] : 'unknown';
|
|
243
|
+
patches.push({
|
|
244
|
+
filePath,
|
|
245
|
+
diff: diffContent,
|
|
246
|
+
changes: ['Diff patch extracted from response']
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return patches;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Extract code blocks from response (fallback when JSON parsing fails)
|
|
253
|
+
*/
|
|
254
|
+
function extractCodeFromResponse(response) {
|
|
255
|
+
// Try to extract code blocks
|
|
256
|
+
const codeBlocks = response.match(/```[\s\S]*?```/g);
|
|
257
|
+
if (codeBlocks && codeBlocks.length > 0) {
|
|
258
|
+
return codeBlocks.map(block => block.replace(/```[a-z]*\n/g, '').replace(/```/g, '').trim()).join('\n\n');
|
|
259
|
+
}
|
|
260
|
+
return response;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=fix-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-ui.js","sourceRoot":"","sources":["../../src/tools/fix-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAe,MAAM,yBAAyB,CAAC;AAE3E,sCAAsC;AACtC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA+CG,CAAC;AA0DjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,MAAoB;IAEpB,IAAI,CAAC;QACH,+BAA+B;QAC/B,+FAA+F;QAC/F,gBAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAClD,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QAEnD,+BAA+B;QAC/B,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,MAAM,aAAa,GAAa,EAAE,CAAC;QAEnC,6BAA6B;QAC7B,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;gBAC1D,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACr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|
|
2
|
+
* Tool 1: gemini_generate_ui
|
|
3
|
+
* Generate HTML/CSS/JavaScript UI components from description or design image
|
|
4
|
+
* Priority: P0 - Core functionality
|
|
5
|
+
*/
|
|
6
|
+
import { validateRequired, validateString, validateFramework, validateUIStyle } from '../utils/validators.js';
|
|
7
|
+
import { handleAPIError, logError } from '../utils/error-handler.js';
|
|
8
|
+
import { readFile } from '../utils/file-reader.js';
|
|
9
|
+
// System prompt for UI generation
|
|
10
|
+
const UI_GENERATION_SYSTEM_PROMPT = `You are an expert frontend developer specializing in UI/UX implementation.
|
|
11
|
+
|
|
12
|
+
Your strengths:
|
|
13
|
+
- Converting design mockups into pixel-perfect HTML/CSS/JavaScript
|
|
14
|
+
- Creating smooth animations and transitions
|
|
15
|
+
- Writing clean, semantic, accessible HTML
|
|
16
|
+
- Implementing responsive layouts (mobile-first approach)
|
|
17
|
+
- Adding interactive JavaScript with modern ES6+ syntax
|
|
18
|
+
|
|
19
|
+
Output requirements:
|
|
20
|
+
1. Return ONLY complete, working code
|
|
21
|
+
2. For vanilla HTML:
|
|
22
|
+
- Use inline <style> tags with organized CSS
|
|
23
|
+
- Use inline <script> tags with modern JavaScript
|
|
24
|
+
- Include all necessary HTML structure
|
|
25
|
+
3. For React/Vue/Svelte:
|
|
26
|
+
- Return component code with all imports
|
|
27
|
+
- Use modern hooks/composition API
|
|
28
|
+
- Include prop types and documentation
|
|
29
|
+
4. Make it production-ready:
|
|
30
|
+
- Semantic HTML5 elements
|
|
31
|
+
- Accessible (ARIA labels, keyboard navigation)
|
|
32
|
+
- Responsive (mobile, tablet, desktop)
|
|
33
|
+
- Smooth animations (CSS transitions/keyframes)
|
|
34
|
+
5. Code quality:
|
|
35
|
+
- No explanations unless explicitly asked
|
|
36
|
+
- Well-organized and commented
|
|
37
|
+
- Follow best practices and conventions
|
|
38
|
+
|
|
39
|
+
When given a design image:
|
|
40
|
+
- Match colors, spacing, typography exactly
|
|
41
|
+
- Implement all visible hover states and interactions
|
|
42
|
+
- Ensure pixel-perfect accuracy
|
|
43
|
+
- Infer missing details intelligently
|
|
44
|
+
|
|
45
|
+
When given only description:
|
|
46
|
+
- Create a beautiful, modern design
|
|
47
|
+
- Use current design trends (2025)
|
|
48
|
+
- Choose appropriate color schemes
|
|
49
|
+
- Add delightful micro-interactions`;
|
|
50
|
+
/**
|
|
51
|
+
* Build additional prompts based on tech stack context
|
|
52
|
+
* @param techContext Tech stack context
|
|
53
|
+
* @returns Tech stack related prompts
|
|
54
|
+
*/
|
|
55
|
+
function buildTechContextPrompt(techContext) {
|
|
56
|
+
const parts = [];
|
|
57
|
+
parts.push('\n## Tech Stack Requirements\n');
|
|
58
|
+
if (techContext.cssFramework) {
|
|
59
|
+
switch (techContext.cssFramework) {
|
|
60
|
+
case 'tailwind':
|
|
61
|
+
parts.push('- CSS Framework: Use Tailwind CSS class names, do not write native CSS styles, use Tailwind responsive prefixes (sm:, md:, lg:)\n');
|
|
62
|
+
break;
|
|
63
|
+
case 'bootstrap':
|
|
64
|
+
parts.push('- CSS Framework: Use Bootstrap class names and components\n');
|
|
65
|
+
break;
|
|
66
|
+
case 'styled-components':
|
|
67
|
+
parts.push('- CSS Framework: Use styled-components, create styled components\n');
|
|
68
|
+
break;
|
|
69
|
+
case 'css-modules':
|
|
70
|
+
parts.push('- CSS Framework: Use CSS Modules, create .module.css files\n');
|
|
71
|
+
break;
|
|
72
|
+
case 'emotion':
|
|
73
|
+
parts.push('- CSS Framework: Use Emotion, use css prop or styled API\n');
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (techContext.uiLibrary) {
|
|
78
|
+
switch (techContext.uiLibrary) {
|
|
79
|
+
case 'shadcn':
|
|
80
|
+
parts.push('- UI Component Library: Use shadcn/ui components, follow shadcn naming conventions and structure, import from @/components/ui\n');
|
|
81
|
+
break;
|
|
82
|
+
case 'antd':
|
|
83
|
+
parts.push('- UI Component Library: Use Ant Design components, import from antd\n');
|
|
84
|
+
break;
|
|
85
|
+
case 'mui':
|
|
86
|
+
parts.push('- UI Component Library: Use Material-UI (MUI) components, import from @mui/material\n');
|
|
87
|
+
break;
|
|
88
|
+
case 'chakra':
|
|
89
|
+
parts.push('- UI Component Library: Use Chakra UI components, import from @chakra-ui/react\n');
|
|
90
|
+
break;
|
|
91
|
+
case 'radix':
|
|
92
|
+
parts.push('- UI Component Library: Use Radix UI primitive components, import from @radix-ui\n');
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (techContext.typescript) {
|
|
97
|
+
parts.push('- Language: Use TypeScript, add complete type definitions and Props interfaces\n');
|
|
98
|
+
}
|
|
99
|
+
if (techContext.stateManagement) {
|
|
100
|
+
switch (techContext.stateManagement) {
|
|
101
|
+
case 'zustand':
|
|
102
|
+
parts.push('- State Management: If state management is needed, use Zustand\n');
|
|
103
|
+
break;
|
|
104
|
+
case 'redux':
|
|
105
|
+
parts.push('- State Management: If state management is needed, use Redux Toolkit\n');
|
|
106
|
+
break;
|
|
107
|
+
case 'jotai':
|
|
108
|
+
parts.push('- State Management: If state management is needed, use Jotai\n');
|
|
109
|
+
break;
|
|
110
|
+
case 'recoil':
|
|
111
|
+
parts.push('- State Management: If state management is needed, use Recoil\n');
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return parts.join('');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Automatically detect tech stack from package.json
|
|
119
|
+
* @param configPath package.json file path
|
|
120
|
+
* @returns Detected tech stack context
|
|
121
|
+
*/
|
|
122
|
+
async function detectTechStackFromConfig(configPath) {
|
|
123
|
+
try {
|
|
124
|
+
const fileContent = await readFile(configPath);
|
|
125
|
+
const pkg = JSON.parse(fileContent.content);
|
|
126
|
+
const deps = {
|
|
127
|
+
...(pkg.dependencies || {}),
|
|
128
|
+
...(pkg.devDependencies || {})
|
|
129
|
+
};
|
|
130
|
+
const techContext = {};
|
|
131
|
+
// Detect CSS framework
|
|
132
|
+
if (deps['tailwindcss']) {
|
|
133
|
+
techContext.cssFramework = 'tailwind';
|
|
134
|
+
}
|
|
135
|
+
else if (deps['bootstrap'] || deps['react-bootstrap']) {
|
|
136
|
+
techContext.cssFramework = 'bootstrap';
|
|
137
|
+
}
|
|
138
|
+
else if (deps['styled-components']) {
|
|
139
|
+
techContext.cssFramework = 'styled-components';
|
|
140
|
+
}
|
|
141
|
+
else if (deps['@emotion/react'] || deps['@emotion/styled']) {
|
|
142
|
+
techContext.cssFramework = 'emotion';
|
|
143
|
+
}
|
|
144
|
+
// Detect UI library (Note: shadcn is usually not in dependencies, detected via class-variance-authority)
|
|
145
|
+
if (deps['class-variance-authority'] || deps['@radix-ui/react-dialog']) {
|
|
146
|
+
techContext.uiLibrary = 'shadcn';
|
|
147
|
+
}
|
|
148
|
+
else if (deps['antd']) {
|
|
149
|
+
techContext.uiLibrary = 'antd';
|
|
150
|
+
}
|
|
151
|
+
else if (deps['@mui/material']) {
|
|
152
|
+
techContext.uiLibrary = 'mui';
|
|
153
|
+
}
|
|
154
|
+
else if (deps['@chakra-ui/react']) {
|
|
155
|
+
techContext.uiLibrary = 'chakra';
|
|
156
|
+
}
|
|
157
|
+
// Detect TypeScript
|
|
158
|
+
techContext.typescript = !!deps['typescript'];
|
|
159
|
+
// Detect state management
|
|
160
|
+
if (deps['zustand']) {
|
|
161
|
+
techContext.stateManagement = 'zustand';
|
|
162
|
+
}
|
|
163
|
+
else if (deps['@reduxjs/toolkit'] || deps['redux']) {
|
|
164
|
+
techContext.stateManagement = 'redux';
|
|
165
|
+
}
|
|
166
|
+
else if (deps['jotai']) {
|
|
167
|
+
techContext.stateManagement = 'jotai';
|
|
168
|
+
}
|
|
169
|
+
else if (deps['recoil']) {
|
|
170
|
+
techContext.stateManagement = 'recoil';
|
|
171
|
+
}
|
|
172
|
+
return techContext;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
// If unable to read or parse config file, return empty object
|
|
176
|
+
logError('detectTechStackFromConfig', error);
|
|
177
|
+
return {};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handle gemini_generate_ui tool call
|
|
182
|
+
*/
|
|
183
|
+
export async function handleGenerateUI(params, client) {
|
|
184
|
+
try {
|
|
185
|
+
// Validate required parameters
|
|
186
|
+
validateRequired(params.description, 'description');
|
|
187
|
+
validateString(params.description, 'description', 10);
|
|
188
|
+
// Validate optional parameters
|
|
189
|
+
const framework = params.framework || 'vanilla';
|
|
190
|
+
const includeAnimation = params.includeAnimation !== false; // Default true
|
|
191
|
+
const responsive = params.responsive !== false; // Default true
|
|
192
|
+
if (params.framework) {
|
|
193
|
+
validateFramework(params.framework);
|
|
194
|
+
}
|
|
195
|
+
if (params.style) {
|
|
196
|
+
validateUIStyle(params.style);
|
|
197
|
+
}
|
|
198
|
+
// [NEW] Handle tech stack context
|
|
199
|
+
let techContext = {};
|
|
200
|
+
let detectedTechContext;
|
|
201
|
+
// If configPath is provided, automatically detect tech stack
|
|
202
|
+
if (params.configPath) {
|
|
203
|
+
detectedTechContext = await detectTechStackFromConfig(params.configPath);
|
|
204
|
+
techContext = { ...detectedTechContext };
|
|
205
|
+
}
|
|
206
|
+
// If techContext is provided, override auto-detected values
|
|
207
|
+
if (params.techContext) {
|
|
208
|
+
techContext = { ...techContext, ...params.techContext };
|
|
209
|
+
}
|
|
210
|
+
// Build prompt
|
|
211
|
+
let prompt = `Generate a ${framework} UI component based on the following requirements:\n\n`;
|
|
212
|
+
prompt += `Description: ${params.description}\n\n`;
|
|
213
|
+
if (params.style) {
|
|
214
|
+
prompt += `Design Style: ${params.style}\n`;
|
|
215
|
+
}
|
|
216
|
+
prompt += `Framework: ${framework}\n`;
|
|
217
|
+
prompt += `Include Animations: ${includeAnimation ? 'Yes' : 'No'}\n`;
|
|
218
|
+
prompt += `Responsive: ${responsive ? 'Yes' : 'No'}\n`;
|
|
219
|
+
// [NEW] Add tech stack context to prompt
|
|
220
|
+
const hasTechContext = techContext.cssFramework || techContext.uiLibrary ||
|
|
221
|
+
techContext.typescript || techContext.stateManagement;
|
|
222
|
+
if (hasTechContext) {
|
|
223
|
+
prompt += buildTechContextPrompt(techContext);
|
|
224
|
+
}
|
|
225
|
+
prompt += '\n';
|
|
226
|
+
if (framework === 'vanilla') {
|
|
227
|
+
prompt += `Please provide a complete HTML file with inline CSS and JavaScript.\n`;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// Adjust output requirements based on TypeScript setting
|
|
231
|
+
if (techContext.typescript) {
|
|
232
|
+
prompt += `Please provide a complete ${framework} component with TypeScript (.tsx) and all necessary imports.\n`;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
prompt += `Please provide a complete ${framework} component with all necessary imports.\n`;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
prompt += `Return ONLY the code, no explanations.`;
|
|
239
|
+
// Call Gemini API
|
|
240
|
+
let code;
|
|
241
|
+
if (params.designImage) {
|
|
242
|
+
// Multimodal: text + image
|
|
243
|
+
code = await client.generateMultimodal(prompt, [params.designImage], {
|
|
244
|
+
systemInstruction: UI_GENERATION_SYSTEM_PROMPT,
|
|
245
|
+
temperature: 0.7,
|
|
246
|
+
maxTokens: 8192
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
// Text only
|
|
251
|
+
code = await client.generate(prompt, {
|
|
252
|
+
systemInstruction: UI_GENERATION_SYSTEM_PROMPT,
|
|
253
|
+
temperature: 0.7,
|
|
254
|
+
maxTokens: 8192
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
// Clean code output (remove markdown code blocks)
|
|
258
|
+
code = cleanCodeOutput(code);
|
|
259
|
+
// For React/Vue/Svelte, there may be multiple files
|
|
260
|
+
const files = framework !== 'vanilla' ? extractFiles(code, framework, techContext.typescript) : undefined;
|
|
261
|
+
return {
|
|
262
|
+
code,
|
|
263
|
+
framework,
|
|
264
|
+
files,
|
|
265
|
+
preview: framework === 'vanilla' ? code : undefined,
|
|
266
|
+
// [NEW] Return detected tech stack information
|
|
267
|
+
detectedTechContext: detectedTechContext
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
logError('generateUI', error);
|
|
272
|
+
throw handleAPIError(error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Clean code output (remove markdown code blocks)
|
|
277
|
+
*/
|
|
278
|
+
function cleanCodeOutput(code) {
|
|
279
|
+
// Remove markdown code blocks
|
|
280
|
+
code = code.replace(/```[a-z]*\n/g, '');
|
|
281
|
+
code = code.replace(/```\n?/g, '');
|
|
282
|
+
// Trim whitespace
|
|
283
|
+
return code.trim();
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Extract multiple files from code (for React/Vue/Svelte)
|
|
287
|
+
* @param code Generated code
|
|
288
|
+
* @param framework Framework type
|
|
289
|
+
* @param useTypescript Whether to use TypeScript
|
|
290
|
+
*/
|
|
291
|
+
function extractFiles(code, framework, useTypescript) {
|
|
292
|
+
// Currently returns a single file
|
|
293
|
+
// Future: can parse multi-file content returned by Gemini
|
|
294
|
+
let extension;
|
|
295
|
+
if (framework === 'react') {
|
|
296
|
+
extension = useTypescript ? 'tsx' : 'jsx';
|
|
297
|
+
}
|
|
298
|
+
else if (framework === 'vue') {
|
|
299
|
+
extension = 'vue';
|
|
300
|
+
}
|
|
301
|
+
else if (framework === 'svelte') {
|
|
302
|
+
extension = 'svelte';
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
extension = useTypescript ? 'ts' : 'js';
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
[`Component.${extension}`]: code
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=generate-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-ui.js","sourceRoot":"","sources":["../../src/tools/generate-ui.ts"],"names":[],"m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IAC9B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,8BAA8B;IAC9B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAEnC,kBAAkB;IAClB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,SAAiB,EAAE,aAAuB;IAC5E,kCAAkC;IAClC,0DAA0D;IAC1D,IAAI,SAAiB,CAAC;IAEtB,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC1B,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,CAAC;SAAM,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QAC/B,SAAS,GAAG,KAAK,CAAC;IACpB,CAAC;SAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,SAAS,GAAG,QAAQ,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,OAAO;QACL,CAAC,aAAa,SAAS,EAAE,CAAC,EAAE,IAAI;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool exports
|
|
3
|
+
* Unified entry point for all MCP tools
|
|
4
|
+
*/
|
|
5
|
+
// Export tool handlers
|
|
6
|
+
export { handleGenerateUI } from './generate-ui.js';
|
|
7
|
+
export { handleMultimodalQuery } from './multimodal-query.js';
|
|
8
|
+
export { handleFixUI } from './fix-ui.js';
|
|
9
|
+
// handleCreateAnimation removed - animation can be generated via generate_ui
|
|
10
|
+
export { handleAnalyzeContent } from './analyze-content.js';
|
|
11
|
+
export { handleAnalyzeCodebase } from './analyze-codebase.js';
|
|
12
|
+
export { handleBrainstorm } from './brainstorm.js';
|
|
13
|
+
export { handleSearch } from './search.js';
|
|
14
|
+
export { handleListModels } from './list-models.js';
|
|
15
|
+
// Export tool definitions
|
|
16
|
+
export { TOOL_DEFINITIONS } from './definitions.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uBAAuB;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,6EAA6E;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool 8: list_models
|
|
3
|
+
* List all available Gemini models
|
|
4
|
+
*/
|
|
5
|
+
import { getAllModels, getDefaultModel, MODEL_RECOMMENDATIONS } from '../config/models.js';
|
|
6
|
+
/**
|
|
7
|
+
* Handle list_models request
|
|
8
|
+
* Returns detailed information about all available models, including structured capability information
|
|
9
|
+
*/
|
|
10
|
+
export async function handleListModels() {
|
|
11
|
+
const models = getAllModels();
|
|
12
|
+
const defaultModel = getDefaultModel();
|
|
13
|
+
return {
|
|
14
|
+
models: models.map((model) => ({
|
|
15
|
+
id: model.id,
|
|
16
|
+
name: model.name,
|
|
17
|
+
description: model.description,
|
|
18
|
+
capabilities: model.capabilities,
|
|
19
|
+
useCases: model.useCases,
|
|
20
|
+
isDefault: model.isDefault,
|
|
21
|
+
features: model.features,
|
|
22
|
+
bestFor: model.bestFor,
|
|
23
|
+
lastUpdate: model.lastUpdate
|
|
24
|
+
})),
|
|
25
|
+
defaultModel: defaultModel.id,
|
|
26
|
+
totalCount: models.length,
|
|
27
|
+
recommendations: MODEL_RECOMMENDATIONS
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=list-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../src/tools/list-models.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,qBAAqB,EAGtB,MAAM,qBAAqB,CAAC;AAqC7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC,CAAC;QACH,YAAY,EAAE,YAAY,CAAC,EAAE;QAC7B,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,eAAe,EAAE,qBAAqB;KACvC,CAAC;AACJ,CAAC"}
|