gemini-design-mcp 3.12.3 → 3.12.4

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.
@@ -1,56 +1,15 @@
1
1
  import { z } from "zod";
2
- import { type Scale } from "../lib/scale.js";
3
2
  export declare const createFrontendSchema: {
4
3
  request: z.ZodString;
5
4
  techStack: z.ZodString;
6
- context: z.ZodOptional<z.ZodString>;
7
- designSystem: z.ZodOptional<z.ZodObject<{
8
- vibe: z.ZodObject<{
9
- name: z.ZodString;
10
- description: z.ZodString;
11
- scale: z.ZodEnum<["refined", "balanced", "zoomed"]>;
12
- keywords: z.ZodArray<z.ZodString, "many">;
13
- }, "strip", z.ZodTypeAny, {
14
- name: string;
15
- description: string;
16
- scale: "refined" | "balanced" | "zoomed";
17
- keywords: string[];
18
- }, {
19
- name: string;
20
- description: string;
21
- scale: "refined" | "balanced" | "zoomed";
22
- keywords: string[];
23
- }>;
24
- }, "strip", z.ZodTypeAny, {
25
- vibe: {
26
- name: string;
27
- description: string;
28
- scale: "refined" | "balanced" | "zoomed";
29
- keywords: string[];
30
- };
31
- }, {
32
- vibe: {
33
- name: string;
34
- description: string;
35
- scale: "refined" | "balanced" | "zoomed";
36
- keywords: string[];
37
- };
38
- }>>;
39
- writeFile: z.ZodDefault<z.ZodBoolean>;
5
+ designSystem: z.ZodString;
6
+ context: z.ZodString;
40
7
  };
41
8
  export declare function createFrontend(params: {
42
9
  request: string;
43
10
  techStack: string;
44
- context?: string;
45
- designSystem?: {
46
- vibe: {
47
- name: string;
48
- description: string;
49
- scale: Scale;
50
- keywords: string[];
51
- };
52
- };
53
- writeFile?: boolean;
11
+ designSystem: string;
12
+ context: string;
54
13
  }): Promise<{
55
14
  content: {
56
15
  type: "text";
@@ -1,125 +1,53 @@
1
1
  import { z } from "zod";
2
2
  import { generateWithGemini } from "../lib/gemini.js";
3
- import { CREATE_FRONTEND_PROMPT, DESIGN_SYSTEM_GENERATION_PROMPT, DESIGN_SYSTEM_USAGE_INSTRUCTIONS } from "../prompts/system.js";
4
- import { stripCodeFences, parseGeminiResponseWithDesignSystem, loadDesignSystemIfExists } from "../lib/filesystem.js";
5
- import { scaleSchema, scaleDescriptions } from "../lib/scale.js";
3
+ import { CREATE_FRONTEND_PROMPT, DESIGN_SYSTEM_USAGE_INSTRUCTIONS } from "../prompts/system.js";
4
+ import { stripCodeFences } from "../lib/filesystem.js";
6
5
  export const createFrontendSchema = {
7
6
  request: z.string().describe("What to create: describe the page, component, or section. " +
8
7
  "Be specific about functionality and content. " +
9
8
  "Example: 'A pricing page with 3 tiers (Basic, Pro, Enterprise) with feature comparison table'"),
10
9
  techStack: z.string().describe("The tech stack to use. Be specific. " +
11
10
  "Examples: 'React + TypeScript + Tailwind CSS', 'Next.js 14 App Router + shadcn/ui', 'Vue 3 + Composition API + CSS Modules'"),
12
- context: z.string().optional().describe("CRITICAL FOR EXISTING PROJECTS: Pass the styling files (CSS, SCSS, theme config, etc.). " +
13
- "Include: variables, tokens, classes, and component patterns from your project. " +
14
- "Without this, Gemini will create standalone styles that won't match your design system. " +
15
- "Omit ONLY if this is the FIRST file in a new project."),
16
- designSystem: z.object({
17
- vibe: z.object({
18
- name: z.string().describe("Vibe name (e.g., 'Pristine Museum', 'Dark Luxe')"),
19
- description: z.string().describe("Rich, evocative description of the mood (2-3 sentences)"),
20
- scale: scaleSchema.describe("Scale: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large elements)"),
21
- keywords: z.array(z.string()).describe("Style keywords (e.g., ['minimal', 'whitespace', 'gallery'])"),
22
- }).describe("The selected design vibe"),
23
- }).optional().describe("Design system with selected vibe. REQUIRED for new projects without existing design. " +
24
- "Call generate_vibes first, user selects, then pass the selection here."),
25
- generateDesignSystem: z.boolean().optional().describe(
26
- "Si true, Gemini génère aussi un design system complet en plus du code. " +
27
- "Activer UNIQUEMENT pour la PREMIÈRE page du projet. " +
28
- "Le design system sera retourné séparément pour être sauvegardé dans design-system.md"
29
- ),
30
- projectRoot: z.string().optional().describe(
31
- "Root directory du projet. Utilisé pour auto-charger design-system.md s'il existe. " +
32
- "TOUJOURS passer ce paramètre pour que Gemini utilise le design system existant."
33
- ),
11
+ designSystem: z.string().describe("REQUIRED: Copy-paste the ENTIRE content of design-system.md here. " +
12
+ "This must contain the complete design system code (colors, typography, components, spacing, etc.). " +
13
+ "Do NOT summarize or extract rules - paste the FULL file content as-is."),
14
+ context: z.string().describe("REQUIRED: Provide MAXIMUM context about the project. Include: " +
15
+ "1) Existing components/pages code that are similar or related, " +
16
+ "2) Global styles, CSS files, theme config, " +
17
+ "3) Type definitions and interfaces, " +
18
+ "4) Any utilities, hooks, or helpers used in the project, " +
19
+ "5) Package.json dependencies if relevant. " +
20
+ "The MORE context you provide, the BETTER the result will match your project."),
34
21
  };
35
22
  export async function createFrontend(params) {
36
- const { request, techStack, context, designSystem, generateDesignSystem, projectRoot } = params;
23
+ const { request, techStack, designSystem, context } = params;
37
24
 
38
- // Auto-load design system if exists
39
- const autoDesignSystem = loadDesignSystemIfExists(projectRoot);
25
+ const systemPrompt = `${CREATE_FRONTEND_PROMPT}
26
+ ${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
40
27
 
41
- // Build design system instructions if provided
42
- let designSystemInstructions = '';
43
- if (designSystem?.vibe) {
44
- const { vibe } = designSystem;
45
- const scale = vibe.scale || "balanced";
46
- designSystemInstructions = `
47
- MANDATORY DESIGN SYSTEM (User Selected Vibe):
28
+ ## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
48
29
 
49
- **Design Vibe: "${vibe.name}"**
50
- ${vibe.description}
30
+ ${designSystem}
51
31
 
52
- ${scaleDescriptions[scale] || scaleDescriptions.balanced}
53
-
54
- Keywords: ${vibe.keywords.join(', ')}
55
-
56
- Interpret this vibe creatively — choose colors, typography, and styling that embody this atmosphere.
57
- The scale above is MANDATORY and defines how large or small UI elements should be.
58
- `;
59
- }
60
- // Build context instructions - prioritize auto-loaded design system
61
- let contextInstructions = '';
62
- let designSystemRules = '';
63
-
64
- if (autoDesignSystem) {
65
- contextInstructions = `
66
- ## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - TOUT LE CODE):
32
+ ---
67
33
 
68
- ${autoDesignSystem}
34
+ ## PROJECT CONTEXT:
69
35
 
70
- ---
71
- RÈGLE CRITIQUE: Copier EXACTEMENT les classes Tailwind, couleurs, spacing, border-radius du code ci-dessus.
72
- NE JAMAIS inventer de nouvelles valeurs. Le nouveau composant doit ressembler EXACTEMENT au design system.
73
- `;
74
- designSystemRules = DESIGN_SYSTEM_USAGE_INSTRUCTIONS;
75
- } else if (context && context !== "null" && context.trim() !== "") {
76
- contextInstructions = `
77
- EXISTING PROJECT CONTEXT (match this design system):
78
36
  ${context}
79
37
 
80
- IMPORTANT: Analyze the existing code carefully and match:
81
- - Color palette and theme
82
- - Typography and font choices
83
- - Component patterns and naming conventions
84
- - Spacing and layout rhythms
85
- - Import patterns and file structure
86
- `;
87
- }
88
- // Build the system prompt - design system generation instructions go FIRST if enabled
89
- let systemPrompt;
90
- if (generateDesignSystem) {
91
- systemPrompt = `${DESIGN_SYSTEM_GENERATION_PROMPT}
92
-
93
38
  ---
94
39
 
95
- ${CREATE_FRONTEND_PROMPT}
96
- ${designSystemInstructions}
97
- ${contextInstructions}
98
40
  TECH STACK: ${techStack}
99
41
 
100
- RAPPEL CRITIQUE: Tu DOIS utiliser le format avec les markers <!-- CODE_START/END --> et <!-- DESIGN_SYSTEM_START/END -->. Ne retourne JAMAIS juste le code.`.trim();
101
- } else {
102
- systemPrompt = `${CREATE_FRONTEND_PROMPT}
103
- ${designSystemRules}
104
- ${designSystemInstructions}
105
- ${contextInstructions}
106
- TECH STACK: ${techStack}
42
+ CRITICAL RULES:
43
+ - Copy EXACTLY the Tailwind classes, colors, spacing, border-radius from the design system above.
44
+ - NEVER invent new values. The new component must look EXACTLY like the design system.
45
+ - Match the patterns, naming conventions, and structure from the context.
107
46
 
108
47
  Remember: Return a COMPLETE, functional file ready to use.`.trim();
109
- }
48
+
110
49
  const rawResult = await generateWithGemini(systemPrompt, request, undefined, "high", "create_frontend");
111
- // Handle design system generation mode
112
- if (generateDesignSystem) {
113
- const parsed = parseGeminiResponseWithDesignSystem(rawResult);
114
- const code = stripCodeFences(parsed.code);
115
- return {
116
- content: [{ type: "text", text: code }],
117
- designSystem: parsed.designSystem,
118
- };
119
- }
120
- // Strip markdown code fences from the result
121
50
  const result = stripCodeFences(rawResult);
122
- // Return the code for the agent to write
123
51
  return {
124
52
  content: [{ type: "text", text: result }],
125
53
  };
@@ -1,18 +1,15 @@
1
1
  import { z } from "zod";
2
- import { type Scale } from "../lib/scale.js";
3
2
  export declare const modifyFrontendSchema: {
4
3
  modification: z.ZodString;
5
4
  targetCode: z.ZodString;
6
- context: z.ZodOptional<z.ZodString>;
7
- scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
8
- writeFile: z.ZodDefault<z.ZodBoolean>;
5
+ designSystem: z.ZodString;
6
+ context: z.ZodString;
9
7
  };
10
8
  export declare function modifyFrontend(params: {
11
9
  modification: string;
12
10
  targetCode: string;
13
- context?: string;
14
- scale?: Scale;
15
- writeFile?: boolean;
11
+ designSystem: string;
12
+ context: string;
16
13
  }): Promise<{
17
14
  content: {
18
15
  type: "text";
@@ -1,8 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { generateWithGemini } from "../lib/gemini.js";
3
3
  import { MODIFY_FRONTEND_PROMPT, DESIGN_SYSTEM_USAGE_INSTRUCTIONS } from "../prompts/system.js";
4
- import { scaleSchema, getScaleInstructions } from "../lib/scale.js";
5
- import { loadDesignSystemIfExists } from "../lib/filesystem.js";
6
4
  export const modifyFrontendSchema = {
7
5
  modification: z.string().describe("The SINGLE design modification to make. Be specific. " +
8
6
  "Examples: " +
@@ -12,51 +10,35 @@ export const modifyFrontendSchema = {
12
10
  targetCode: z.string().describe("The specific code section to modify (NOT the full file). " +
13
11
  "Pass only the relevant component/element that needs redesigning. " +
14
12
  "This helps Gemini focus on exactly what to change."),
15
- context: z.string().optional().describe("CRITICAL: Pass the styling files (CSS, SCSS, theme config, etc.) with design tokens. " +
16
- "Include: variables, tokens, classes from your project. " +
17
- "Without this, Gemini may introduce styles that don't match your design system. " +
18
- "Example: 'Project uses: var(--font-heading), var(--bg-primary), .section-padding class'"),
19
- scale: scaleSchema.optional().describe("Element sizing: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large). " +
20
- "Controls button sizes, typography, spacing, icons."),
21
- projectRoot: z.string().optional().describe("Root directory of the project. Used to auto-load design-system.md if it exists. " +
22
- "If not provided, uses current working directory."),
13
+ designSystem: z.string().describe("REQUIRED: Copy-paste the ENTIRE content of design-system.md here. " +
14
+ "This must contain the complete design system code (colors, typography, components, spacing, etc.). " +
15
+ "Do NOT summarize or extract rules - paste the FULL file content as-is."),
16
+ context: z.string().describe("REQUIRED: Provide MAXIMUM context about the project. Include: " +
17
+ "1) The FULL file being modified (not just the target section), " +
18
+ "2) Related components that interact with this code, " +
19
+ "3) Global styles, CSS files, theme config, " +
20
+ "4) Type definitions and interfaces, " +
21
+ "5) Any utilities or helpers used. " +
22
+ "The MORE context you provide, the BETTER the modification will match your project."),
23
23
  };
24
24
  export async function modifyFrontend(params) {
25
- const { modification, targetCode, context, scale, projectRoot } = params;
26
- // Auto-load design system if exists
27
- const autoDesignSystem = loadDesignSystemIfExists(projectRoot);
28
- // Build context instructions with design system merged
29
- let contextInstructions = '';
30
- if (autoDesignSystem) {
31
- contextInstructions = `
32
- ## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - NE RIEN MODIFIER):
25
+ const { modification, targetCode, designSystem, context } = params;
33
26
 
34
- ${autoDesignSystem}
27
+ const systemPrompt = `${MODIFY_FRONTEND_PROMPT}
28
+ ${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
29
+
30
+ ## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
31
+
32
+ ${designSystem}
35
33
 
36
34
  ---
37
35
 
38
- RÈGLES CRITIQUES:
39
- - Copier EXACTEMENT les classes Tailwind du design system ci-dessus
40
- - NE JAMAIS inventer de nouvelles couleurs, paddings, ou border-radius
41
- - Utiliser les mêmes patterns visuels (shadows, transitions, etc.)
42
- - Le code modifié doit être INDISTINGUABLE du reste du projet
36
+ ## PROJECT CONTEXT:
43
37
 
44
- `;
45
- }
46
- if (context) {
47
- contextInstructions += `
48
- DESIGN CONTEXT:
49
38
  ${context}
50
- `;
51
- }
52
- // Build scale instructions
53
- const scaleInstructions = getScaleInstructions(scale);
54
- // Add design system usage instructions if design system was loaded
55
- const designSystemRules = autoDesignSystem ? DESIGN_SYSTEM_USAGE_INSTRUCTIONS : '';
56
- const systemPrompt = `${MODIFY_FRONTEND_PROMPT}
57
- ${designSystemRules}
58
- ${scaleInstructions}
59
- ${contextInstructions}
39
+
40
+ ---
41
+
60
42
  CODE TO MODIFY:
61
43
  \`\`\`
62
44
  ${targetCode}
@@ -64,9 +46,14 @@ ${targetCode}
64
46
 
65
47
  MODIFICATION REQUESTED: ${modification}
66
48
 
49
+ CRITICAL RULES:
50
+ - Copy EXACTLY the Tailwind classes, colors, spacing, border-radius from the design system above.
51
+ - NEVER invent new values. The modified code must look EXACTLY like the design system.
52
+ - Match the patterns from the context.
53
+
67
54
  Remember: Return ONLY the find/replace block. ONE modification, surgical precision.`.trim();
55
+
68
56
  const result = await generateWithGemini(systemPrompt, modification, undefined, "high", "modify_frontend");
69
- // Return the find/replace instructions for the agent to apply
70
57
  return {
71
58
  content: [{ type: "text", text: result }],
72
59
  };
@@ -1,24 +1,17 @@
1
1
  import { z } from "zod";
2
- import { type Scale } from "../lib/scale.js";
3
2
  export declare const snippetFrontendSchema: {
4
3
  request: z.ZodString;
5
4
  techStack: z.ZodString;
5
+ designSystem: z.ZodString;
6
+ context: z.ZodString;
6
7
  insertionContext: z.ZodString;
7
- context: z.ZodOptional<z.ZodString>;
8
- scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
9
- writeFile: z.ZodDefault<z.ZodBoolean>;
10
- insertAtLine: z.ZodOptional<z.ZodNumber>;
11
- insertAfterPattern: z.ZodOptional<z.ZodString>;
12
8
  };
13
9
  export declare function snippetFrontend(params: {
14
10
  request: string;
15
11
  techStack: string;
12
+ designSystem: string;
13
+ context: string;
16
14
  insertionContext: string;
17
- context?: string;
18
- scale?: Scale;
19
- writeFile?: boolean;
20
- insertAtLine?: number;
21
- insertAfterPattern?: string;
22
15
  }): Promise<{
23
16
  content: {
24
17
  type: "text";
@@ -1,8 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { generateWithGemini } from "../lib/gemini.js";
3
3
  import { SNIPPET_FRONTEND_PROMPT, DESIGN_SYSTEM_USAGE_INSTRUCTIONS } from "../prompts/system.js";
4
- import { scaleSchema, getScaleInstructions } from "../lib/scale.js";
5
- import { loadDesignSystemIfExists } from "../lib/filesystem.js";
6
4
  export const snippetFrontendSchema = {
7
5
  request: z.string().describe("What code snippet to generate. Be specific about what you need. " +
8
6
  "Examples: " +
@@ -12,62 +10,50 @@ export const snippetFrontendSchema = {
12
10
  "'A custom hook for handling API requests with loading/error states'"),
13
11
  techStack: z.string().describe("The tech stack being used. " +
14
12
  "Examples: 'React + TypeScript + Tailwind CSS', 'Vue 3 + Composition API'"),
15
- insertionContext: z.string().describe("WHERE in the file this snippet will go AND the design tokens to use. " +
16
- "MUST include: styling conventions (variables, classes, tokens) from the project. " +
17
- "Example: 'Inside the Dashboard component, after the header. " +
18
- "Use project tokens: var(--font-heading), var(--bg-primary), .section-padding class.'"),
19
- context: z.string().optional().describe("CRITICAL FOR EXISTING PROJECTS: Pass the styling files (CSS, SCSS, theme config, etc.). " +
20
- "Include: variables, tokens, classes, and component patterns from your project. " +
21
- "Without this, Gemini will create standalone styles that won't match your design system."),
22
- scale: scaleSchema.optional().describe("Element sizing: 'refined' (small, elegant), 'balanced' (standard), 'zoomed' (large). " +
23
- "Controls button sizes, typography, spacing, icons."),
24
- projectRoot: z.string().optional().describe("Root directory of the project. Used to auto-load design-system.md if it exists. " +
25
- "If not provided, uses current working directory."),
13
+ designSystem: z.string().describe("REQUIRED: Copy-paste the ENTIRE content of design-system.md here. " +
14
+ "This must contain the complete design system code (colors, typography, components, spacing, etc.). " +
15
+ "Do NOT summarize or extract rules - paste the FULL file content as-is."),
16
+ context: z.string().describe("REQUIRED: Provide MAXIMUM context about the project. Include: " +
17
+ "1) The file where this snippet will be inserted, " +
18
+ "2) Related components that will interact with this snippet, " +
19
+ "3) Global styles, CSS files, theme config, " +
20
+ "4) Type definitions and interfaces, " +
21
+ "5) Any utilities, hooks, or helpers used in the project. " +
22
+ "The MORE context you provide, the BETTER the snippet will integrate."),
23
+ insertionContext: z.string().describe("WHERE in the file this snippet will go. " +
24
+ "Example: 'Inside the Dashboard component, after the header section.'"),
26
25
  };
27
26
  export async function snippetFrontend(params) {
28
- const { request, techStack, insertionContext, context, scale, projectRoot } = params;
29
- // Auto-load design system if exists
30
- const autoDesignSystem = loadDesignSystemIfExists(projectRoot);
31
- // Build context instructions with design system merged
32
- let contextInstructions = '';
33
- if (autoDesignSystem) {
34
- contextInstructions = `
35
- ## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - NE RIEN MODIFIER):
27
+ const { request, techStack, designSystem, context, insertionContext } = params;
36
28
 
37
- ${autoDesignSystem}
29
+ const systemPrompt = `${SNIPPET_FRONTEND_PROMPT}
30
+ ${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
31
+
32
+ ## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
33
+
34
+ ${designSystem}
38
35
 
39
36
  ---
40
37
 
41
- RÈGLES CRITIQUES:
42
- - Copier EXACTEMENT les classes Tailwind du design system ci-dessus
43
- - NE JAMAIS inventer de nouvelles couleurs, paddings, ou border-radius
44
- - Utiliser les mêmes patterns visuels (shadows, transitions, etc.)
45
- - Le snippet doit être INDISTINGUABLE du reste du projet
38
+ ## PROJECT CONTEXT:
46
39
 
47
- `;
48
- }
49
- if (context) {
50
- contextInstructions += `
51
- PROJECT CONTEXT (match these patterns):
52
40
  ${context}
53
- `;
54
- }
55
- // Build scale instructions
56
- const scaleInstructions = getScaleInstructions(scale);
57
- // Add design system usage instructions if design system was loaded
58
- const designSystemRules = autoDesignSystem ? DESIGN_SYSTEM_USAGE_INSTRUCTIONS : '';
59
- const systemPrompt = `${SNIPPET_FRONTEND_PROMPT}
60
- ${designSystemRules}
61
- ${scaleInstructions}
62
- ${contextInstructions}
41
+
42
+ ---
43
+
63
44
  TECH STACK: ${techStack}
64
45
 
65
46
  INSERTION CONTEXT:
66
47
  ${insertionContext}
67
48
 
49
+ CRITICAL RULES:
50
+ - Copy EXACTLY the Tailwind classes, colors, spacing, border-radius from the design system above.
51
+ - NEVER invent new values. The snippet must look EXACTLY like the design system.
52
+ - Match the patterns, naming conventions, and structure from the context.
53
+
68
54
  Generate a snippet that will integrate smoothly at this location.`.trim();
55
+
69
56
  const result = await generateWithGemini(systemPrompt, request, undefined, "high", "snippet_frontend");
70
- // Return the snippet for the agent to insert
71
57
  return {
72
58
  content: [{ type: "text", text: result }],
73
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-design-mcp",
3
- "version": "3.12.3",
3
+ "version": "3.12.4",
4
4
  "description": "MCP server that uses Gemini 3 Pro for frontend/design code generation",
5
5
  "main": "build/index.js",
6
6
  "bin": {