gemini-design-mcp 3.12.2 → 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.
- package/build/tools/create-frontend.d.ts +4 -47
- package/build/tools/create-frontend.js +25 -101
- package/build/tools/modify-frontend.d.ts +4 -9
- package/build/tools/modify-frontend.js +26 -43
- package/build/tools/snippet-frontend.d.ts +4 -13
- package/build/tools/snippet-frontend.js +29 -46
- package/package.json +1 -1
|
@@ -1,58 +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
|
-
filePath: z.ZodString;
|
|
6
4
|
techStack: z.ZodString;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
vibe: z.ZodObject<{
|
|
10
|
-
name: z.ZodString;
|
|
11
|
-
description: z.ZodString;
|
|
12
|
-
scale: z.ZodEnum<["refined", "balanced", "zoomed"]>;
|
|
13
|
-
keywords: z.ZodArray<z.ZodString, "many">;
|
|
14
|
-
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
scale: "refined" | "balanced" | "zoomed";
|
|
18
|
-
keywords: string[];
|
|
19
|
-
}, {
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
scale: "refined" | "balanced" | "zoomed";
|
|
23
|
-
keywords: string[];
|
|
24
|
-
}>;
|
|
25
|
-
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
vibe: {
|
|
27
|
-
name: string;
|
|
28
|
-
description: string;
|
|
29
|
-
scale: "refined" | "balanced" | "zoomed";
|
|
30
|
-
keywords: string[];
|
|
31
|
-
};
|
|
32
|
-
}, {
|
|
33
|
-
vibe: {
|
|
34
|
-
name: string;
|
|
35
|
-
description: string;
|
|
36
|
-
scale: "refined" | "balanced" | "zoomed";
|
|
37
|
-
keywords: string[];
|
|
38
|
-
};
|
|
39
|
-
}>>;
|
|
40
|
-
writeFile: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
designSystem: z.ZodString;
|
|
6
|
+
context: z.ZodString;
|
|
41
7
|
};
|
|
42
8
|
export declare function createFrontend(params: {
|
|
43
9
|
request: string;
|
|
44
|
-
filePath: string;
|
|
45
10
|
techStack: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
vibe: {
|
|
49
|
-
name: string;
|
|
50
|
-
description: string;
|
|
51
|
-
scale: Scale;
|
|
52
|
-
keywords: string[];
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
writeFile?: boolean;
|
|
11
|
+
designSystem: string;
|
|
12
|
+
context: string;
|
|
56
13
|
}): Promise<{
|
|
57
14
|
content: {
|
|
58
15
|
type: "text";
|
|
@@ -1,129 +1,53 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { generateWithGemini } from "../lib/gemini.js";
|
|
3
|
-
import { CREATE_FRONTEND_PROMPT,
|
|
4
|
-
import { stripCodeFences
|
|
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
|
-
filePath: z.string().describe("The path where this file will be created. " +
|
|
11
|
-
"Example: 'src/components/PricingPage.tsx' or 'app/dashboard/page.tsx'"),
|
|
12
9
|
techStack: z.string().describe("The tech stack to use. Be specific. " +
|
|
13
10
|
"Examples: 'React + TypeScript + Tailwind CSS', 'Next.js 14 App Router + shadcn/ui', 'Vue 3 + Composition API + CSS Modules'"),
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}).describe("The selected design vibe"),
|
|
25
|
-
}).optional().describe("Design system with selected vibe. REQUIRED for new projects without existing design. " +
|
|
26
|
-
"Call generate_vibes first, user selects, then pass the selection here."),
|
|
27
|
-
generateDesignSystem: z.boolean().optional().describe(
|
|
28
|
-
"Si true, Gemini génère aussi un design system complet en plus du code. " +
|
|
29
|
-
"Activer UNIQUEMENT pour la PREMIÈRE page du projet. " +
|
|
30
|
-
"Le design system sera retourné séparément pour être sauvegardé dans design-system.md"
|
|
31
|
-
),
|
|
32
|
-
projectRoot: z.string().optional().describe(
|
|
33
|
-
"Root directory du projet. Utilisé pour auto-charger design-system.md s'il existe. " +
|
|
34
|
-
"TOUJOURS passer ce paramètre pour que Gemini utilise le design system existant."
|
|
35
|
-
),
|
|
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."),
|
|
36
21
|
};
|
|
37
22
|
export async function createFrontend(params) {
|
|
38
|
-
const { request,
|
|
23
|
+
const { request, techStack, designSystem, context } = params;
|
|
39
24
|
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
const systemPrompt = `${CREATE_FRONTEND_PROMPT}
|
|
26
|
+
${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
|
|
42
27
|
|
|
43
|
-
|
|
44
|
-
let designSystemInstructions = '';
|
|
45
|
-
if (designSystem?.vibe) {
|
|
46
|
-
const { vibe } = designSystem;
|
|
47
|
-
const scale = vibe.scale || "balanced";
|
|
48
|
-
designSystemInstructions = `
|
|
49
|
-
MANDATORY DESIGN SYSTEM (User Selected Vibe):
|
|
28
|
+
## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
|
|
50
29
|
|
|
51
|
-
|
|
52
|
-
${vibe.description}
|
|
30
|
+
${designSystem}
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Keywords: ${vibe.keywords.join(', ')}
|
|
57
|
-
|
|
58
|
-
Interpret this vibe creatively — choose colors, typography, and styling that embody this atmosphere.
|
|
59
|
-
The scale above is MANDATORY and defines how large or small UI elements should be.
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
// Build context instructions - prioritize auto-loaded design system
|
|
63
|
-
let contextInstructions = '';
|
|
64
|
-
let designSystemRules = '';
|
|
65
|
-
|
|
66
|
-
if (autoDesignSystem) {
|
|
67
|
-
contextInstructions = `
|
|
68
|
-
## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - TOUT LE CODE):
|
|
32
|
+
---
|
|
69
33
|
|
|
70
|
-
|
|
34
|
+
## PROJECT CONTEXT:
|
|
71
35
|
|
|
72
|
-
---
|
|
73
|
-
RÈGLE CRITIQUE: Copier EXACTEMENT les classes Tailwind, couleurs, spacing, border-radius du code ci-dessus.
|
|
74
|
-
NE JAMAIS inventer de nouvelles valeurs. Le nouveau composant doit ressembler EXACTEMENT au design system.
|
|
75
|
-
`;
|
|
76
|
-
designSystemRules = DESIGN_SYSTEM_USAGE_INSTRUCTIONS;
|
|
77
|
-
} else if (context && context !== "null" && context.trim() !== "") {
|
|
78
|
-
contextInstructions = `
|
|
79
|
-
EXISTING PROJECT CONTEXT (match this design system):
|
|
80
36
|
${context}
|
|
81
37
|
|
|
82
|
-
IMPORTANT: Analyze the existing code carefully and match:
|
|
83
|
-
- Color palette and theme
|
|
84
|
-
- Typography and font choices
|
|
85
|
-
- Component patterns and naming conventions
|
|
86
|
-
- Spacing and layout rhythms
|
|
87
|
-
- Import patterns and file structure
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
// Build the system prompt - design system generation instructions go FIRST if enabled
|
|
91
|
-
let systemPrompt;
|
|
92
|
-
if (generateDesignSystem) {
|
|
93
|
-
systemPrompt = `${DESIGN_SYSTEM_GENERATION_PROMPT}
|
|
94
|
-
|
|
95
38
|
---
|
|
96
39
|
|
|
97
|
-
${CREATE_FRONTEND_PROMPT}
|
|
98
|
-
${designSystemInstructions}
|
|
99
|
-
${contextInstructions}
|
|
100
40
|
TECH STACK: ${techStack}
|
|
101
|
-
FILE PATH: ${filePath}
|
|
102
41
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
TECH STACK: ${techStack}
|
|
110
|
-
FILE PATH: ${filePath}
|
|
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.
|
|
46
|
+
|
|
47
|
+
Remember: Return a COMPLETE, functional file ready to use.`.trim();
|
|
111
48
|
|
|
112
|
-
Remember: Return a COMPLETE file ready to save at ${filePath}`.trim();
|
|
113
|
-
}
|
|
114
49
|
const rawResult = await generateWithGemini(systemPrompt, request, undefined, "high", "create_frontend");
|
|
115
|
-
// Handle design system generation mode
|
|
116
|
-
if (generateDesignSystem) {
|
|
117
|
-
const parsed = parseGeminiResponseWithDesignSystem(rawResult);
|
|
118
|
-
const code = stripCodeFences(parsed.code);
|
|
119
|
-
return {
|
|
120
|
-
content: [{ type: "text", text: code }],
|
|
121
|
-
designSystem: parsed.designSystem,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
// Strip markdown code fences from the result
|
|
125
50
|
const result = stripCodeFences(rawResult);
|
|
126
|
-
// Return the code for the agent to write
|
|
127
51
|
return {
|
|
128
52
|
content: [{ type: "text", text: result }],
|
|
129
53
|
};
|
|
@@ -1,20 +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
|
-
|
|
7
|
-
context: z.
|
|
8
|
-
scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
|
|
9
|
-
writeFile: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
designSystem: z.ZodString;
|
|
6
|
+
context: z.ZodString;
|
|
10
7
|
};
|
|
11
8
|
export declare function modifyFrontend(params: {
|
|
12
9
|
modification: string;
|
|
13
10
|
targetCode: string;
|
|
14
|
-
|
|
15
|
-
context
|
|
16
|
-
scale?: Scale;
|
|
17
|
-
writeFile?: boolean;
|
|
11
|
+
designSystem: string;
|
|
12
|
+
context: string;
|
|
18
13
|
}): Promise<{
|
|
19
14
|
content: {
|
|
20
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,54 +10,34 @@ 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
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
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."),
|
|
25
23
|
};
|
|
26
24
|
export async function modifyFrontend(params) {
|
|
27
|
-
const { modification, targetCode,
|
|
28
|
-
// Auto-load design system if exists
|
|
29
|
-
const autoDesignSystem = loadDesignSystemIfExists(projectRoot);
|
|
30
|
-
// Build context instructions with design system merged
|
|
31
|
-
let contextInstructions = '';
|
|
32
|
-
if (autoDesignSystem) {
|
|
33
|
-
contextInstructions = `
|
|
34
|
-
## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - NE RIEN MODIFIER):
|
|
25
|
+
const { modification, targetCode, designSystem, context } = params;
|
|
35
26
|
|
|
36
|
-
|
|
27
|
+
const systemPrompt = `${MODIFY_FRONTEND_PROMPT}
|
|
28
|
+
${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
|
|
29
|
+
|
|
30
|
+
## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
|
|
31
|
+
|
|
32
|
+
${designSystem}
|
|
37
33
|
|
|
38
34
|
---
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
- Copier EXACTEMENT les classes Tailwind du design system ci-dessus
|
|
42
|
-
- NE JAMAIS inventer de nouvelles couleurs, paddings, ou border-radius
|
|
43
|
-
- Utiliser les mêmes patterns visuels (shadows, transitions, etc.)
|
|
44
|
-
- Le code modifié doit être INDISTINGUABLE du reste du projet
|
|
36
|
+
## PROJECT CONTEXT:
|
|
45
37
|
|
|
46
|
-
`;
|
|
47
|
-
}
|
|
48
|
-
if (context) {
|
|
49
|
-
contextInstructions += `
|
|
50
|
-
DESIGN CONTEXT:
|
|
51
38
|
${context}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Build scale instructions
|
|
55
|
-
const scaleInstructions = getScaleInstructions(scale);
|
|
56
|
-
// Add design system usage instructions if design system was loaded
|
|
57
|
-
const designSystemRules = autoDesignSystem ? DESIGN_SYSTEM_USAGE_INSTRUCTIONS : '';
|
|
58
|
-
const systemPrompt = `${MODIFY_FRONTEND_PROMPT}
|
|
59
|
-
${designSystemRules}
|
|
60
|
-
${scaleInstructions}
|
|
61
|
-
${contextInstructions}
|
|
62
|
-
FILE: ${filePath}
|
|
39
|
+
|
|
40
|
+
---
|
|
63
41
|
|
|
64
42
|
CODE TO MODIFY:
|
|
65
43
|
\`\`\`
|
|
@@ -68,9 +46,14 @@ ${targetCode}
|
|
|
68
46
|
|
|
69
47
|
MODIFICATION REQUESTED: ${modification}
|
|
70
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
|
+
|
|
71
54
|
Remember: Return ONLY the find/replace block. ONE modification, surgical precision.`.trim();
|
|
55
|
+
|
|
72
56
|
const result = await generateWithGemini(systemPrompt, modification, undefined, "high", "modify_frontend");
|
|
73
|
-
// Return the find/replace instructions for the agent to apply
|
|
74
57
|
return {
|
|
75
58
|
content: [{ type: "text", text: result }],
|
|
76
59
|
};
|
|
@@ -1,26 +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
|
-
targetFile: z.ZodString;
|
|
6
4
|
techStack: z.ZodString;
|
|
5
|
+
designSystem: z.ZodString;
|
|
6
|
+
context: z.ZodString;
|
|
7
7
|
insertionContext: z.ZodString;
|
|
8
|
-
context: z.ZodOptional<z.ZodString>;
|
|
9
|
-
scale: z.ZodOptional<z.ZodEnum<["refined", "balanced", "zoomed"]>>;
|
|
10
|
-
writeFile: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
-
insertAtLine: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
insertAfterPattern: z.ZodOptional<z.ZodString>;
|
|
13
8
|
};
|
|
14
9
|
export declare function snippetFrontend(params: {
|
|
15
10
|
request: string;
|
|
16
|
-
targetFile: string;
|
|
17
11
|
techStack: string;
|
|
12
|
+
designSystem: string;
|
|
13
|
+
context: string;
|
|
18
14
|
insertionContext: string;
|
|
19
|
-
context?: string;
|
|
20
|
-
scale?: Scale;
|
|
21
|
-
writeFile?: boolean;
|
|
22
|
-
insertAtLine?: number;
|
|
23
|
-
insertAfterPattern?: string;
|
|
24
15
|
}): Promise<{
|
|
25
16
|
content: {
|
|
26
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: " +
|
|
@@ -10,67 +8,52 @@ export const snippetFrontendSchema = {
|
|
|
10
8
|
"'A data table with sorting, filtering, and pagination', " +
|
|
11
9
|
"'A form validation function for email and password', " +
|
|
12
10
|
"'A custom hook for handling API requests with loading/error states'"),
|
|
13
|
-
targetFile: z.string().describe("The file where this snippet will be inserted. " +
|
|
14
|
-
"Example: 'src/components/Dashboard.tsx' - helps Gemini match the file's patterns"),
|
|
15
11
|
techStack: z.string().describe("The tech stack being used. " +
|
|
16
12
|
"Examples: 'React + TypeScript + Tailwind CSS', 'Vue 3 + Composition API'"),
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
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.'"),
|
|
28
25
|
};
|
|
29
26
|
export async function snippetFrontend(params) {
|
|
30
|
-
const { request,
|
|
31
|
-
// Auto-load design system if exists
|
|
32
|
-
const autoDesignSystem = loadDesignSystemIfExists(projectRoot);
|
|
33
|
-
// Build context instructions with design system merged
|
|
34
|
-
let contextInstructions = '';
|
|
35
|
-
if (autoDesignSystem) {
|
|
36
|
-
contextInstructions = `
|
|
37
|
-
## DESIGN SYSTEM COMPLET (COPIER EXACTEMENT - NE RIEN MODIFIER):
|
|
27
|
+
const { request, techStack, designSystem, context, insertionContext } = params;
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
const systemPrompt = `${SNIPPET_FRONTEND_PROMPT}
|
|
30
|
+
${DESIGN_SYSTEM_USAGE_INSTRUCTIONS}
|
|
31
|
+
|
|
32
|
+
## DESIGN SYSTEM (COPY EXACTLY - ALL CODE):
|
|
33
|
+
|
|
34
|
+
${designSystem}
|
|
40
35
|
|
|
41
36
|
---
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
- Copier EXACTEMENT les classes Tailwind du design system ci-dessus
|
|
45
|
-
- NE JAMAIS inventer de nouvelles couleurs, paddings, ou border-radius
|
|
46
|
-
- Utiliser les mêmes patterns visuels (shadows, transitions, etc.)
|
|
47
|
-
- Le snippet doit être INDISTINGUABLE du reste du projet
|
|
38
|
+
## PROJECT CONTEXT:
|
|
48
39
|
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
if (context) {
|
|
52
|
-
contextInstructions += `
|
|
53
|
-
PROJECT CONTEXT (match these patterns):
|
|
54
40
|
${context}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const scaleInstructions = getScaleInstructions(scale);
|
|
59
|
-
// Add design system usage instructions if design system was loaded
|
|
60
|
-
const designSystemRules = autoDesignSystem ? DESIGN_SYSTEM_USAGE_INSTRUCTIONS : '';
|
|
61
|
-
const systemPrompt = `${SNIPPET_FRONTEND_PROMPT}
|
|
62
|
-
${designSystemRules}
|
|
63
|
-
${scaleInstructions}
|
|
64
|
-
${contextInstructions}
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
65
44
|
TECH STACK: ${techStack}
|
|
66
|
-
TARGET FILE: ${targetFile}
|
|
67
45
|
|
|
68
46
|
INSERTION CONTEXT:
|
|
69
47
|
${insertionContext}
|
|
70
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
|
+
|
|
71
54
|
Generate a snippet that will integrate smoothly at this location.`.trim();
|
|
55
|
+
|
|
72
56
|
const result = await generateWithGemini(systemPrompt, request, undefined, "high", "snippet_frontend");
|
|
73
|
-
// Return the snippet for the agent to insert
|
|
74
57
|
return {
|
|
75
58
|
content: [{ type: "text", text: result }],
|
|
76
59
|
};
|