gemini-design-mcp 3.6.6 → 3.6.8
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/build/lib/gemini.d.ts +0 -2
- package/build/lib/gemini.js +50 -31
- package/build/tools/create-frontend.js +4 -2
- package/package.json +1 -1
package/build/lib/gemini.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { GoogleGenAI } from "@google/genai";
|
|
2
1
|
export type ThinkingMode = "minimal" | "low" | "medium" | "high";
|
|
3
|
-
export declare const ai: GoogleGenAI;
|
|
4
2
|
export declare const DEFAULT_MODEL = "gemini-3-flash-preview";
|
|
5
3
|
export declare function generateWithGemini(systemPrompt: string, userPrompt: string, model?: string, thinkingMode?: ThinkingMode): Promise<string>;
|
package/build/lib/gemini.js
CHANGED
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const VERTEX_CONFIG = {
|
|
4
|
-
project: "gemini-3-pro-481223",
|
|
5
|
-
location: "global", // Gemini 3 models are only served from the global endpoint
|
|
6
|
-
credentials: {
|
|
7
|
-
client_email: "service-account@gemini-3-pro-481223.iam.gserviceaccount.com",
|
|
8
|
-
private_key: "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDmj7bquZXIll38\nQHo2jzqInSfeRV/eR35RfBlK4lCuBfWslOuDY4kwUiu+M7hDZfNXgVlf+91u/+qY\nl0FnxIDoHBRR7WytLwsBWz2VeROqhnLI2nwmkkG2UBil0S2Xwg/hJVYaL312qLPV\nvWF5bNLd4shFwzwOYpt7+4XQf7YyPkvJ4MHsxeXGZ8ZRNRa0X7wLSW50//VmkKbE\nci9QFDhxqL1Z1CrwmFmJvbhXesLYDtAjmE8hKsn3o6y2556uP4mT5oUXYHTxkf9Y\nYnbjzBSfukKeMoHewnA+Ox05cKPQLk/6I7GJleAbNpgz4swnixlbbAl86XNsU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t4BRHg9kAGu4QKBgQC0DBVOgc0iSZI9esOp\niKgnG6IKvHPHRYgsRMdjyURwNuHGnBMuS8mszeOjWG8OQuaIxTOf4wvqYaeA8y20\nCeUP7usFwGEJHkWt6AcsuCjkpGEzg7CTF8RV4Sdalsag26OBSSMCnAQjjOYVwJ2m\n6ZKyMYvQwGDooVf/sghI17jReA==\n-----END PRIVATE KEY-----\n",
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
// Initialize Vertex AI client
|
|
12
|
-
export const ai = new GoogleGenAI({
|
|
13
|
-
vertexai: true,
|
|
14
|
-
project: VERTEX_CONFIG.project,
|
|
15
|
-
location: VERTEX_CONFIG.location,
|
|
16
|
-
googleAuthOptions: {
|
|
17
|
-
credentials: VERTEX_CONFIG.credentials,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
1
|
+
// API Proxy endpoint
|
|
2
|
+
const PROXY_URL = "https://brave-turtle-253.convex.site/v1/generate";
|
|
20
3
|
// Default model - Gemini 3 Flash Preview
|
|
21
4
|
export const DEFAULT_MODEL = "gemini-3-flash-preview";
|
|
5
|
+
// Get and validate API key
|
|
6
|
+
function getApiKey() {
|
|
7
|
+
const apiKey = process.env.API_KEY;
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
throw new Error("Missing API_KEY environment variable. " +
|
|
10
|
+
"Get your API key at https://gemini-design.com/dashboard/api-keys");
|
|
11
|
+
}
|
|
12
|
+
if (!apiKey.startsWith("gd_")) {
|
|
13
|
+
throw new Error("Invalid API key format. API keys must start with 'gd_'. " +
|
|
14
|
+
"Get your API key at https://gemini-design.com/dashboard/api-keys");
|
|
15
|
+
}
|
|
16
|
+
return apiKey;
|
|
17
|
+
}
|
|
22
18
|
export async function generateWithGemini(systemPrompt, userPrompt, model = DEFAULT_MODEL, thinkingMode = "minimal") {
|
|
19
|
+
const apiKey = getApiKey();
|
|
23
20
|
try {
|
|
24
|
-
const response = await
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
temperature: 1,
|
|
30
|
-
thinkingConfig: {
|
|
31
|
-
thinkingLevel: thinkingMode,
|
|
32
|
-
},
|
|
21
|
+
const response = await fetch(PROXY_URL, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: {
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
33
26
|
},
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
model,
|
|
29
|
+
contents: [
|
|
30
|
+
{
|
|
31
|
+
role: "user",
|
|
32
|
+
parts: [{ text: userPrompt }],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
systemInstruction: {
|
|
36
|
+
parts: [{ text: systemPrompt }],
|
|
37
|
+
},
|
|
38
|
+
generationConfig: {
|
|
39
|
+
temperature: 1,
|
|
40
|
+
},
|
|
41
|
+
// Pass thinking mode for billing/logging purposes
|
|
42
|
+
thinkingMode,
|
|
43
|
+
}),
|
|
34
44
|
});
|
|
35
|
-
|
|
45
|
+
const result = await response.json();
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error(result.error || `API error: ${response.status}`);
|
|
48
|
+
}
|
|
49
|
+
// Extract text from Gemini response format
|
|
50
|
+
const text = result.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
51
|
+
if (!text) {
|
|
52
|
+
throw new Error("No content in response");
|
|
53
|
+
}
|
|
54
|
+
return text;
|
|
36
55
|
}
|
|
37
56
|
catch (error) {
|
|
38
57
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
39
|
-
console.error("Gemini API error:", errorMessage);
|
|
40
|
-
throw new Error(`Gemini API error: ${errorMessage}`);
|
|
58
|
+
console.error("Gemini Design API error:", errorMessage);
|
|
59
|
+
throw new Error(`Gemini Design API error: ${errorMessage}`);
|
|
41
60
|
}
|
|
42
61
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { generateWithGemini } from "../lib/gemini.js";
|
|
3
3
|
import { CREATE_FRONTEND_PROMPT } from "../prompts/system.js";
|
|
4
|
-
import { writeFileWithDirs, getFileSize } from "../lib/filesystem.js";
|
|
4
|
+
import { writeFileWithDirs, getFileSize, stripCodeFences } from "../lib/filesystem.js";
|
|
5
5
|
import { scaleSchema, scaleDescriptions } from "../lib/scale.js";
|
|
6
6
|
export const createFrontendSchema = {
|
|
7
7
|
request: z.string().describe("What to create: describe the page, component, or section. " +
|
|
@@ -69,7 +69,9 @@ TECH STACK: ${techStack}
|
|
|
69
69
|
FILE PATH: ${filePath}
|
|
70
70
|
|
|
71
71
|
Remember: Return a COMPLETE file ready to save at ${filePath}`.trim();
|
|
72
|
-
const
|
|
72
|
+
const rawResult = await generateWithGemini(systemPrompt, request, undefined, "high");
|
|
73
|
+
// Strip markdown code fences from the result
|
|
74
|
+
const result = stripCodeFences(rawResult);
|
|
73
75
|
// Write file directly if requested
|
|
74
76
|
if (writeFile) {
|
|
75
77
|
writeFileWithDirs(filePath, result);
|