gemini-design-mcp 3.6.4 → 3.6.6
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/filesystem.d.ts +5 -0
- package/build/lib/filesystem.js +18 -6
- package/build/lib/gemini.js +1 -1
- package/build/lib/scale.d.ts +10 -0
- package/build/lib/scale.js +41 -0
- package/build/tools/create-frontend.d.ts +2 -1
- package/build/tools/create-frontend.js +2 -26
- package/build/tools/modify-frontend.d.ts +3 -0
- package/build/tools/modify-frontend.js +7 -1
- package/build/tools/snippet-frontend.d.ts +3 -0
- package/build/tools/snippet-frontend.js +7 -1
- package/package.json +1 -1
package/build/lib/filesystem.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Strip markdown code fences from a string
|
|
5
|
+
* Removes ```language and ``` from the beginning and end
|
|
6
|
+
*/
|
|
7
|
+
export function stripCodeFences(code) {
|
|
8
|
+
let result = code.trim();
|
|
9
|
+
// Remove opening fence: ```tsx, ```jsx, ```typescript, ```javascript, ```html, etc.
|
|
10
|
+
result = result.replace(/^```[\w]*\s*\n?/i, '');
|
|
11
|
+
// Remove closing fence: ```
|
|
12
|
+
result = result.replace(/\n?```\s*$/i, '');
|
|
13
|
+
return result.trim();
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* Write a file, creating parent directories if they don't exist
|
|
5
17
|
*/
|
|
@@ -47,9 +59,9 @@ export function parseFindReplace(geminiOutput) {
|
|
|
47
59
|
if (!replaceMatch)
|
|
48
60
|
return null;
|
|
49
61
|
return {
|
|
50
|
-
imports: imports
|
|
51
|
-
find: findMatch[1]
|
|
52
|
-
replace: replaceMatch[1]
|
|
62
|
+
imports: imports ? stripCodeFences(imports) : undefined,
|
|
63
|
+
find: stripCodeFences(findMatch[1]),
|
|
64
|
+
replace: stripCodeFences(replaceMatch[1]),
|
|
53
65
|
};
|
|
54
66
|
}
|
|
55
67
|
catch {
|
|
@@ -72,11 +84,11 @@ export function parseSnippet(geminiOutput) {
|
|
|
72
84
|
const snippetMatch = geminiOutput.match(/\/\/ SNIPPET:\s*([\s\S]*?)$/);
|
|
73
85
|
if (!snippetMatch) {
|
|
74
86
|
// If no SNIPPET marker, assume the whole thing (minus imports) is the snippet
|
|
75
|
-
return { imports, snippet: geminiOutput
|
|
87
|
+
return { imports: imports ? stripCodeFences(imports) : undefined, snippet: stripCodeFences(geminiOutput) };
|
|
76
88
|
}
|
|
77
89
|
return {
|
|
78
|
-
imports: imports
|
|
79
|
-
snippet: snippetMatch[1]
|
|
90
|
+
imports: imports ? stripCodeFences(imports) : undefined,
|
|
91
|
+
snippet: stripCodeFences(snippetMatch[1]),
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
94
|
catch {
|
package/build/lib/gemini.js
CHANGED
|
@@ -2,7 +2,7 @@ import { GoogleGenAI } from "@google/genai";
|
|
|
2
2
|
// Vertex AI Configuration with Service Account
|
|
3
3
|
const VERTEX_CONFIG = {
|
|
4
4
|
project: "gemini-3-pro-481223",
|
|
5
|
-
location: "
|
|
5
|
+
location: "global", // Gemini 3 models are only served from the global endpoint
|
|
6
6
|
credentials: {
|
|
7
7
|
client_email: "service-account@gemini-3-pro-481223.iam.gserviceaccount.com",
|
|
8
8
|
private_key: "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDmj7bquZXIll38\nQHo2jzqInSfeRV/eR35RfBlK4lCuBfWslOuDY4kwUiu+M7hDZfNXgVlf+91u/+qY\nl0FnxIDoHBRR7WytLwsBWz2VeROqhnLI2nwmkkG2UBil0S2Xwg/hJVYaL312qLPV\nvWF5bNLd4shFwzwOYpt7+4XQf7YyPkvJ4MHsxeXGZ8ZRNRa0X7wLSW50//VmkKbE\nci9QFDhxqL1Z1CrwmFmJvbhXesLYDtAjmE8hKsn3o6y2556uP4mT5oU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VDnW5rw0vE8WgOW/4YAFJARpaxYAyokUhn7iicJsu\nXU3ul4WVDARjB/1zDGALv2KG6ifFgt4BRHg9kAGu4QKBgQC0DBVOgc0iSZI9esOp\niKgnG6IKvHPHRYgsRMdjyURwNuHGnBMuS8mszeOjWG8OQuaIxTOf4wvqYaeA8y20\nCeUP7usFwGEJHkWt6AcsuCjkpGEzg7CTF8RV4Sdalsag26OBSSMCnAQjjOYVwJ2m\n6ZKyMYvQwGDooVf/sghI17jReA==\n-----END PRIVATE KEY-----\n",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const scaleSchema: z.ZodEnum<["refined", "balanced", "zoomed"]>;
|
|
3
|
+
export type Scale = z.infer<typeof scaleSchema>;
|
|
4
|
+
export declare const scaleDescriptions: Record<Scale, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Generate scale instructions for prompts
|
|
7
|
+
* @param scale The scale to use (defaults to "balanced")
|
|
8
|
+
* @returns Formatted scale instructions string
|
|
9
|
+
*/
|
|
10
|
+
export declare function getScaleInstructions(scale?: Scale): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Scale schema for validation
|
|
3
|
+
export const scaleSchema = z.enum(["refined", "balanced", "zoomed"]).describe("Scale: 'refined' (small, elegant elements), 'balanced' (standard sizing), 'zoomed' (large elements)");
|
|
4
|
+
// Conceptual scale descriptions - let Gemini decide exact values
|
|
5
|
+
export const scaleDescriptions = {
|
|
6
|
+
refined: `**SCALE: REFINED**
|
|
7
|
+
This is about ELEMENT SIZE, not density. Refined means:
|
|
8
|
+
- Smaller, more elegant typography — avoid oversized headlines
|
|
9
|
+
- Compact, contained buttons — not chunky or oversized
|
|
10
|
+
- Cards and containers with constrained widths — not full-width sprawling layouts
|
|
11
|
+
- Tighter, purposeful spacing between elements
|
|
12
|
+
- Smaller icons that complement rather than dominate
|
|
13
|
+
|
|
14
|
+
Reference: Linear.app, Raycast, Notion — these apps feel sophisticated because their elements are proportionally small and refined, never billboard-sized or bloated.
|
|
15
|
+
|
|
16
|
+
The interface should feel like a premium Swiss watch: precise, elegant, where every element is intentionally sized smaller than the default.`,
|
|
17
|
+
balanced: `**SCALE: BALANCED**
|
|
18
|
+
Standard, conventional sizing. Use typical defaults — nothing particularly large or small. A middle-ground that works for most general-purpose applications.`,
|
|
19
|
+
zoomed: `**SCALE: ZOOMED**
|
|
20
|
+
This is about ELEMENT SIZE, not density. Zoomed means:
|
|
21
|
+
- Large, prominent typography — bold headlines that command attention
|
|
22
|
+
- Big, chunky buttons — easy to see and click/tap
|
|
23
|
+
- Wide cards and containers — full-width or near full-width layouts
|
|
24
|
+
- Generous spacing and padding throughout
|
|
25
|
+
- Large icons that stand out
|
|
26
|
+
|
|
27
|
+
Reference: Kids apps, accessibility-focused interfaces, bold marketing sites — elements are intentionally oversized for impact and ease of use.`
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Generate scale instructions for prompts
|
|
31
|
+
* @param scale The scale to use (defaults to "balanced")
|
|
32
|
+
* @returns Formatted scale instructions string
|
|
33
|
+
*/
|
|
34
|
+
export function getScaleInstructions(scale) {
|
|
35
|
+
const effectiveScale = scale || "balanced";
|
|
36
|
+
return `
|
|
37
|
+
${scaleDescriptions[effectiveScale]}
|
|
38
|
+
|
|
39
|
+
The scale above is MANDATORY and defines how large or small UI elements should be.
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type Scale } from "../lib/scale.js";
|
|
2
3
|
export declare const createFrontendSchema: {
|
|
3
4
|
request: z.ZodString;
|
|
4
5
|
filePath: z.ZodString;
|
|
@@ -47,7 +48,7 @@ export declare function createFrontend(params: {
|
|
|
47
48
|
vibe: {
|
|
48
49
|
name: string;
|
|
49
50
|
description: string;
|
|
50
|
-
scale:
|
|
51
|
+
scale: Scale;
|
|
51
52
|
keywords: string[];
|
|
52
53
|
};
|
|
53
54
|
};
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { generateWithGemini } from "../lib/gemini.js";
|
|
3
3
|
import { CREATE_FRONTEND_PROMPT } from "../prompts/system.js";
|
|
4
4
|
import { writeFileWithDirs, getFileSize } from "../lib/filesystem.js";
|
|
5
|
+
import { scaleSchema, scaleDescriptions } from "../lib/scale.js";
|
|
5
6
|
export const createFrontendSchema = {
|
|
6
7
|
request: z.string().describe("What to create: describe the page, component, or section. " +
|
|
7
8
|
"Be specific about functionality and content. " +
|
|
@@ -17,7 +18,7 @@ export const createFrontendSchema = {
|
|
|
17
18
|
vibe: z.object({
|
|
18
19
|
name: z.string().describe("Vibe name (e.g., 'Pristine Museum', 'Dark Luxe')"),
|
|
19
20
|
description: z.string().describe("Rich, evocative description of the mood (2-3 sentences)"),
|
|
20
|
-
scale:
|
|
21
|
+
scale: scaleSchema.describe("Scale: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large elements)"),
|
|
21
22
|
keywords: z.array(z.string()).describe("Style keywords (e.g., ['minimal', 'whitespace', 'gallery'])"),
|
|
22
23
|
}).describe("The selected design vibe"),
|
|
23
24
|
}).optional().describe("Design system with selected vibe. REQUIRED for new projects without existing design. " +
|
|
@@ -32,31 +33,6 @@ export async function createFrontend(params) {
|
|
|
32
33
|
if (designSystem?.vibe) {
|
|
33
34
|
const { vibe } = designSystem;
|
|
34
35
|
const scale = vibe.scale || "balanced";
|
|
35
|
-
// Conceptual scale descriptions - let Gemini decide exact values
|
|
36
|
-
const scaleDescriptions = {
|
|
37
|
-
refined: `**SCALE: REFINED**
|
|
38
|
-
This is about ELEMENT SIZE, not density. Refined means:
|
|
39
|
-
- Smaller, more elegant typography — avoid oversized headlines
|
|
40
|
-
- Compact, contained buttons — not chunky or oversized
|
|
41
|
-
- Cards and containers with constrained widths — not full-width sprawling layouts
|
|
42
|
-
- Tighter, purposeful spacing between elements
|
|
43
|
-
- Smaller icons that complement rather than dominate
|
|
44
|
-
|
|
45
|
-
Reference: Linear.app, Raycast, Notion — these apps feel sophisticated because their elements are proportionally small and refined, never billboard-sized or bloated.
|
|
46
|
-
|
|
47
|
-
The interface should feel like a premium Swiss watch: precise, elegant, where every element is intentionally sized smaller than the default.`,
|
|
48
|
-
balanced: `**SCALE: BALANCED**
|
|
49
|
-
Standard, conventional sizing. Use typical defaults — nothing particularly large or small. A middle-ground that works for most general-purpose applications.`,
|
|
50
|
-
zoomed: `**SCALE: ZOOMED**
|
|
51
|
-
This is about ELEMENT SIZE, not density. Zoomed means:
|
|
52
|
-
- Large, prominent typography — bold headlines that command attention
|
|
53
|
-
- Big, chunky buttons — easy to see and click/tap
|
|
54
|
-
- Wide cards and containers — full-width or near full-width layouts
|
|
55
|
-
- Generous spacing and padding throughout
|
|
56
|
-
- Large icons that stand out
|
|
57
|
-
|
|
58
|
-
Reference: Kids apps, accessibility-focused interfaces, bold marketing sites — elements are intentionally oversized for impact and ease of use.`
|
|
59
|
-
};
|
|
60
36
|
designSystemInstructions = `
|
|
61
37
|
MANDATORY DESIGN SYSTEM (User Selected Vibe):
|
|
62
38
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type Scale } from "../lib/scale.js";
|
|
2
3
|
export declare const modifyFrontendSchema: {
|
|
3
4
|
modification: z.ZodString;
|
|
4
5
|
targetCode: z.ZodString;
|
|
5
6
|
filePath: z.ZodString;
|
|
6
7
|
context: z.ZodOptional<z.ZodString>;
|
|
8
|
+
scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
|
|
7
9
|
writeFile: z.ZodOptional<z.ZodBoolean>;
|
|
8
10
|
};
|
|
9
11
|
export declare function modifyFrontend(params: {
|
|
@@ -11,6 +13,7 @@ export declare function modifyFrontend(params: {
|
|
|
11
13
|
targetCode: string;
|
|
12
14
|
filePath: string;
|
|
13
15
|
context?: string;
|
|
16
|
+
scale?: Scale;
|
|
14
17
|
writeFile?: boolean;
|
|
15
18
|
}): Promise<{
|
|
16
19
|
content: {
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { generateWithGemini } from "../lib/gemini.js";
|
|
3
3
|
import { MODIFY_FRONTEND_PROMPT } from "../prompts/system.js";
|
|
4
4
|
import { readFileIfExists, writeFileWithDirs, parseFindReplace, applyFindReplace, mergeImports, } from "../lib/filesystem.js";
|
|
5
|
+
import { scaleSchema, getScaleInstructions } from "../lib/scale.js";
|
|
5
6
|
export const modifyFrontendSchema = {
|
|
6
7
|
modification: z.string().describe("The SINGLE design modification to make. Be specific. " +
|
|
7
8
|
"Examples: " +
|
|
@@ -15,12 +16,14 @@ export const modifyFrontendSchema = {
|
|
|
15
16
|
"Example: 'src/components/Sidebar.tsx'"),
|
|
16
17
|
context: z.string().optional().describe("Additional context about the file's design system. " +
|
|
17
18
|
"Example: 'Uses Tailwind, dark theme with zinc colors, rounded-xl borders'"),
|
|
19
|
+
scale: scaleSchema.optional().describe("Element sizing: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large). " +
|
|
20
|
+
"Controls button sizes, typography, spacing, icons."),
|
|
18
21
|
writeFile: z.boolean().optional().describe("If true, apply the modification directly to the file on disk. " +
|
|
19
22
|
"Reads the file, applies find/replace, and writes back. " +
|
|
20
23
|
"Returns a confirmation instead of the find/replace instructions."),
|
|
21
24
|
};
|
|
22
25
|
export async function modifyFrontend(params) {
|
|
23
|
-
const { modification, targetCode, filePath, context, writeFile } = params;
|
|
26
|
+
const { modification, targetCode, filePath, context, scale, writeFile } = params;
|
|
24
27
|
// Build context instructions
|
|
25
28
|
let contextInstructions = '';
|
|
26
29
|
if (context) {
|
|
@@ -29,7 +32,10 @@ DESIGN CONTEXT:
|
|
|
29
32
|
${context}
|
|
30
33
|
`;
|
|
31
34
|
}
|
|
35
|
+
// Build scale instructions
|
|
36
|
+
const scaleInstructions = getScaleInstructions(scale);
|
|
32
37
|
const systemPrompt = `${MODIFY_FRONTEND_PROMPT}
|
|
38
|
+
${scaleInstructions}
|
|
33
39
|
${contextInstructions}
|
|
34
40
|
FILE: ${filePath}
|
|
35
41
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type Scale } from "../lib/scale.js";
|
|
2
3
|
export declare const snippetFrontendSchema: {
|
|
3
4
|
request: z.ZodString;
|
|
4
5
|
targetFile: z.ZodString;
|
|
5
6
|
techStack: z.ZodString;
|
|
6
7
|
insertionContext: z.ZodString;
|
|
7
8
|
context: z.ZodOptional<z.ZodString>;
|
|
9
|
+
scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
|
|
8
10
|
writeFile: z.ZodOptional<z.ZodBoolean>;
|
|
9
11
|
insertAtLine: z.ZodOptional<z.ZodNumber>;
|
|
10
12
|
insertAfterPattern: z.ZodOptional<z.ZodString>;
|
|
@@ -15,6 +17,7 @@ export declare function snippetFrontend(params: {
|
|
|
15
17
|
techStack: string;
|
|
16
18
|
insertionContext: string;
|
|
17
19
|
context?: string;
|
|
20
|
+
scale?: Scale;
|
|
18
21
|
writeFile?: boolean;
|
|
19
22
|
insertAtLine?: number;
|
|
20
23
|
insertAfterPattern?: string;
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { generateWithGemini } from "../lib/gemini.js";
|
|
3
3
|
import { SNIPPET_FRONTEND_PROMPT } from "../prompts/system.js";
|
|
4
4
|
import { readFileIfExists, writeFileWithDirs, parseSnippet, mergeImports, insertAfterLine, insertAfterPattern, } from "../lib/filesystem.js";
|
|
5
|
+
import { scaleSchema, getScaleInstructions } from "../lib/scale.js";
|
|
5
6
|
export const snippetFrontendSchema = {
|
|
6
7
|
request: z.string().describe("What code snippet to generate. Be specific about what you need. " +
|
|
7
8
|
"Examples: " +
|
|
@@ -20,6 +21,8 @@ export const snippetFrontendSchema = {
|
|
|
20
21
|
context: z.string().optional().describe("Additional project files for design/pattern reference. " +
|
|
21
22
|
"Pass components, styles, or utilities that the snippet should match. " +
|
|
22
23
|
"Optional but recommended for consistency."),
|
|
24
|
+
scale: scaleSchema.optional().describe("Element sizing: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large). " +
|
|
25
|
+
"Controls button sizes, typography, spacing, icons."),
|
|
23
26
|
writeFile: z.boolean().optional().describe("If true, insert the snippet directly into the file on disk. " +
|
|
24
27
|
"Requires insertAtLine OR insertAfterPattern to know where to insert."),
|
|
25
28
|
insertAtLine: z.number().optional().describe("Line number (1-indexed) where to insert the snippet. " +
|
|
@@ -30,7 +33,7 @@ export const snippetFrontendSchema = {
|
|
|
30
33
|
"Required if writeFile is true and insertAtLine is not provided."),
|
|
31
34
|
};
|
|
32
35
|
export async function snippetFrontend(params) {
|
|
33
|
-
const { request, targetFile, techStack, insertionContext, context, writeFile, insertAtLine: lineNumber, insertAfterPattern: pattern, } = params;
|
|
36
|
+
const { request, targetFile, techStack, insertionContext, context, scale, writeFile, insertAtLine: lineNumber, insertAfterPattern: pattern, } = params;
|
|
34
37
|
// Build context instructions
|
|
35
38
|
let contextInstructions = '';
|
|
36
39
|
if (context) {
|
|
@@ -39,7 +42,10 @@ PROJECT CONTEXT (match these patterns):
|
|
|
39
42
|
${context}
|
|
40
43
|
`;
|
|
41
44
|
}
|
|
45
|
+
// Build scale instructions
|
|
46
|
+
const scaleInstructions = getScaleInstructions(scale);
|
|
42
47
|
const systemPrompt = `${SNIPPET_FRONTEND_PROMPT}
|
|
48
|
+
${scaleInstructions}
|
|
43
49
|
${contextInstructions}
|
|
44
50
|
TECH STACK: ${techStack}
|
|
45
51
|
TARGET FILE: ${targetFile}
|