glyph-ai 0.5.1 → 0.6.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/bundled/server/context/prompt-builder.d.ts +4 -0
- package/bundled/server/context/prompt-builder.js +118 -46
- package/bundled/server/context/taste-layer.d.ts +11 -3
- package/bundled/server/context/taste-layer.js +17 -3
- package/bundled/server/mcp/tools/generate-variations.js +15 -2
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@ export interface DesignBriefParams {
|
|
|
12
12
|
designPrinciples?: string;
|
|
13
13
|
/** Aesthetic preset: 'a' (Surgical), 'b' (Brutalist), 'c' (Editorial), 'd' (Dashboard/Functional), 'e' (Consumer/Warm), or undefined for brand default */
|
|
14
14
|
preset?: 'a' | 'b' | 'c' | 'd' | 'e';
|
|
15
|
+
/** When true, Glyph uses its opinionated design judgment. Default: false (preserve existing design). */
|
|
16
|
+
redesign?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare function buildDesignBrief(params: DesignBriefParams): Promise<string>;
|
|
17
19
|
export interface DirectionBriefParams {
|
|
@@ -23,5 +25,7 @@ export interface DirectionBriefParams {
|
|
|
23
25
|
count: number;
|
|
24
26
|
designSystemContext?: string;
|
|
25
27
|
projectTokens?: ProjectTokens;
|
|
28
|
+
/** When true, Glyph uses its opinionated design judgment. Default: false (preserve existing design). */
|
|
29
|
+
redesign?: boolean;
|
|
26
30
|
}
|
|
27
31
|
export declare function buildDirectionBrief(params: DirectionBriefParams): Promise<string>;
|
|
@@ -2,12 +2,12 @@ import { getBrandReference, getBrandFullData } from './brand-references.js';
|
|
|
2
2
|
import { renderAgentIdentity, renderDesignPhilosophy, renderPreset, renderScoringRubric, } from './design-philosophy.js';
|
|
3
3
|
import { renderProjectTokens } from './token-template.js';
|
|
4
4
|
import { renderReferenceSection } from './reference-images.js';
|
|
5
|
-
import { renderTasteLayer } from './taste-layer.js';
|
|
5
|
+
import { renderTasteLayer, renderPreserveVoice } from './taste-layer.js';
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// Shared context builder — resolves brand data, philosophy, tokens once
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
async function buildSharedSections(params) {
|
|
10
|
-
const { fileContent, filePath, brand, instruction, designSystemContext, projectTokens, preset } = params;
|
|
10
|
+
const { fileContent, filePath, brand, instruction, designSystemContext, projectTokens, preset, redesign } = params;
|
|
11
11
|
const isProjectMode = brand === 'project';
|
|
12
12
|
let { boilerplates, commonPatterns, designPrinciples } = params;
|
|
13
13
|
let resolvedBrandRef = '';
|
|
@@ -26,9 +26,9 @@ async function buildSharedSections(params) {
|
|
|
26
26
|
}
|
|
27
27
|
const sections = [];
|
|
28
28
|
// -----------------------------------------------------------------------
|
|
29
|
-
// 0.
|
|
29
|
+
// 0. Voice — opinionated (redesign) or preserving (default)
|
|
30
30
|
// -----------------------------------------------------------------------
|
|
31
|
-
sections.push(renderTasteLayer());
|
|
31
|
+
sections.push(redesign ? renderTasteLayer() : renderPreserveVoice());
|
|
32
32
|
// -----------------------------------------------------------------------
|
|
33
33
|
// 1. Agent Identity — sets Claude's posture BEFORE anything else
|
|
34
34
|
// -----------------------------------------------------------------------
|
|
@@ -65,14 +65,16 @@ ${fileContent}
|
|
|
65
65
|
}
|
|
66
66
|
sections.push(`## Source File\n${sourceBlock}`);
|
|
67
67
|
// -----------------------------------------------------------------------
|
|
68
|
-
// 3. Design Philosophy (Sections 1-12) —
|
|
68
|
+
// 3. Design Philosophy (Sections 1-12) — only in redesign mode
|
|
69
69
|
// -----------------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (redesign) {
|
|
71
|
+
const philosophy = await renderDesignPhilosophy();
|
|
72
|
+
sections.push(philosophy);
|
|
73
|
+
}
|
|
72
74
|
// -----------------------------------------------------------------------
|
|
73
|
-
// 4. Active Aesthetic Preset —
|
|
75
|
+
// 4. Active Aesthetic Preset — only in redesign mode
|
|
74
76
|
// -----------------------------------------------------------------------
|
|
75
|
-
if (preset) {
|
|
77
|
+
if (redesign && preset) {
|
|
76
78
|
const presetContent = await renderPreset(preset);
|
|
77
79
|
if (presetContent) {
|
|
78
80
|
sections.push(presetContent);
|
|
@@ -81,7 +83,7 @@ ${fileContent}
|
|
|
81
83
|
// -----------------------------------------------------------------------
|
|
82
84
|
// 4b. Reference Images — visual anchors for the active preset
|
|
83
85
|
// -----------------------------------------------------------------------
|
|
84
|
-
if (preset) {
|
|
86
|
+
if (redesign && preset) {
|
|
85
87
|
const port = Number(process.env.GLYPH_PORT) || 3013;
|
|
86
88
|
const referenceSection = await renderReferenceSection(preset, port);
|
|
87
89
|
if (referenceSection) {
|
|
@@ -127,16 +129,29 @@ ${fileContent}
|
|
|
127
129
|
Work in two passes per variation:
|
|
128
130
|
1. **Structure** — Component hierarchy + layout utilities only (flex, grid, gap). No colors, typography, or visual styling. Verify information architecture.
|
|
129
131
|
2. **Style** — Apply design tokens over the locked structure. Typography, colors, spacing, shadows, interactions. Do not reorganize structure to accommodate styling.`;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
if (!redesign) {
|
|
133
|
+
// Preserve mode — respect existing design, don't impose opinions
|
|
134
|
+
sections.push(`## Workflow Rules
|
|
135
|
+
- **Respect the existing design system** — colors, typography, spacing, component patterns. Do not change the aesthetic.
|
|
136
|
+
- Use the project's existing token values. Do not introduce new colors, fonts, or visual patterns.
|
|
137
|
+
- Preserve the source file's structure and functionality.
|
|
138
|
+
- Variations should explore different **layouts, content arrangements, and structural approaches** — not different aesthetics.
|
|
139
|
+
- Every variation must look like it belongs to the same product.
|
|
140
|
+
|
|
141
|
+
${twoPassInstructions}`);
|
|
142
|
+
}
|
|
143
|
+
else if (isProjectMode) {
|
|
144
|
+
sections.push(`## Workflow Rules
|
|
132
145
|
- **Adhere to the Design Philosophy above** — these are non-negotiable constraints.
|
|
133
146
|
- If any generated code violates the anti-patterns table, fix it before outputting.
|
|
134
147
|
- Use the project's existing color values, typography, spacing, and component patterns.
|
|
135
148
|
- **Hierarchy: Philosophy constraints > Active Preset bans > Project values > Defaults.**
|
|
136
149
|
- Preserve the source file's structure and functionality — only transform the visual presentation.
|
|
137
150
|
|
|
138
|
-
${twoPassInstructions}`
|
|
139
|
-
|
|
151
|
+
${twoPassInstructions}`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
sections.push(`## Workflow Rules
|
|
140
155
|
- **Adhere to the Design Philosophy above** — these are non-negotiable constraints.
|
|
141
156
|
- If any generated code violates the anti-patterns table, fix it before outputting.
|
|
142
157
|
- Use the exact color values, typography, spacing, and component patterns from the Brand Design System.
|
|
@@ -146,6 +161,7 @@ ${twoPassInstructions}`
|
|
|
146
161
|
- Preserve the source file's structure and functionality — only transform the visual presentation.
|
|
147
162
|
|
|
148
163
|
${twoPassInstructions}`);
|
|
164
|
+
}
|
|
149
165
|
if (instruction) {
|
|
150
166
|
sections.push(`## Additional Instructions\n${instruction}`);
|
|
151
167
|
}
|
|
@@ -165,11 +181,11 @@ export async function buildDesignBrief(params) {
|
|
|
165
181
|
// Scoring Rubric — self-evaluation before submitting
|
|
166
182
|
// -----------------------------------------------------------------------
|
|
167
183
|
const rubric = await renderScoringRubric();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Generate exactly **${count}** distinct variations of the source file above,
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
const taskPreamble = params.redesign
|
|
185
|
+
? `Generate exactly **${count}** distinct variations of the source file above, ${isProjectMode ? "improving the design using the project's own design system" : `each applying the **${params.brand}** design aesthetic`}. This count is a hard requirement — generating fewer is a failure. You MUST produce all ${count} variations.`
|
|
186
|
+
: `Generate exactly **${count}** distinct variations of the source file above, **preserving the existing design system**. Each variation should explore a different layout or structural approach while staying true to the current aesthetic. This count is a hard requirement — generating fewer is a failure. You MUST produce all ${count} variations.`;
|
|
187
|
+
const taskRequirements = params.redesign
|
|
188
|
+
? `### Requirements
|
|
173
189
|
1. Each variation must be a **complete, working replacement** for the source file.
|
|
174
190
|
2. Preserve all functionality — only change visual presentation and styling.
|
|
175
191
|
3. Each variation should explore a **different interpretation** of the ${isProjectMode ? 'design' : 'brand aesthetic'}:
|
|
@@ -179,14 +195,32 @@ Generate exactly **${count}** distinct variations of the source file above, ${is
|
|
|
179
195
|
- Variation 4+: Creative explorations (different layouts, emphasis, density)
|
|
180
196
|
4. Comply with Design Philosophy constraints. ${isProjectMode ? "Use the project's existing token values." : 'Use the exact token values from the brand guide.'}
|
|
181
197
|
5. Keep all imports and exports intact.
|
|
182
|
-
6. Use inline styles or Tailwind classes as appropriate for the existing codebase
|
|
198
|
+
6. Use inline styles or Tailwind classes as appropriate for the existing codebase.`
|
|
199
|
+
: `### Requirements
|
|
200
|
+
1. Each variation must be a **complete, working replacement** for the source file.
|
|
201
|
+
2. Preserve all functionality — only change visual presentation and styling.
|
|
202
|
+
3. **Use the existing design tokens** — same colors, fonts, spacing, border-radius, shadows. Do not change the aesthetic.
|
|
203
|
+
4. Each variation should explore a **different structural approach** within the existing design:
|
|
204
|
+
- Variation 1: Faithful to current layout with subtle refinements
|
|
205
|
+
- Variation 2: Different layout arrangement (e.g. sidebar ↔ top-nav, grid ↔ list)
|
|
206
|
+
- Variation 3: Different content density or information hierarchy
|
|
207
|
+
- Variation 4+: Alternative structural approaches (card layouts, split views, etc.)
|
|
208
|
+
5. Keep all imports and exports intact.
|
|
209
|
+
6. Use inline styles or Tailwind classes as appropriate for the existing codebase.`;
|
|
210
|
+
const evalNote = params.redesign
|
|
211
|
+
? `\n\n**If a variation looks like it could have been produced by a generic UI generator, it fails. Redesign it.**`
|
|
212
|
+
: `\n\n**Every variation must feel like it belongs to the same product as the original. If it looks like a different app, it fails.**`;
|
|
213
|
+
sections.push(`## Your Task
|
|
214
|
+
|
|
215
|
+
${taskPreamble}
|
|
216
|
+
|
|
217
|
+
${taskRequirements}
|
|
183
218
|
|
|
184
219
|
### Visual Self-Evaluation (Mandatory)
|
|
185
|
-
For each variation: call \`preview_draft\` → screenshot → score 1-10 on: hierarchy clarity, type precision, color restraint, preset fidelity, whitespace composition. All must be 7+. If any < 7, fix the weakest element and re-evaluate. Max 2 rounds. Do NOT call \`submit_variations\` until all pass.
|
|
220
|
+
For each variation: call \`preview_draft\` → screenshot → score 1-10 on: hierarchy clarity, type precision, color restraint, ${params.redesign ? 'preset fidelity' : 'design system fidelity'}, whitespace composition. All must be 7+. If any < 7, fix the weakest element and re-evaluate. Max 2 rounds. Do NOT call \`submit_variations\` until all pass.
|
|
186
221
|
|
|
187
222
|
${rubric}
|
|
188
|
-
|
|
189
|
-
**If a variation looks like it could have been produced by a generic UI generator, it fails. Redesign it.**
|
|
223
|
+
${evalNote}
|
|
190
224
|
|
|
191
225
|
### Output Format
|
|
192
226
|
Return each variation in a labeled fenced code block:
|
|
@@ -200,10 +234,10 @@ Once all ${count} variations have passed visual self-evaluation (all dimensions
|
|
|
200
234
|
return sections.join('\n\n');
|
|
201
235
|
}
|
|
202
236
|
export async function buildDirectionBrief(params) {
|
|
203
|
-
const { fileContent, filePath, direction, directionPath, instruction, count, designSystemContext, projectTokens } = params;
|
|
237
|
+
const { fileContent, filePath, direction, directionPath, instruction, count, designSystemContext, projectTokens, redesign } = params;
|
|
204
238
|
const sections = [];
|
|
205
|
-
// 0.
|
|
206
|
-
sections.push(renderTasteLayer());
|
|
239
|
+
// 0. Voice — opinionated (redesign) or preserving (default)
|
|
240
|
+
sections.push(redesign ? renderTasteLayer() : renderPreserveVoice());
|
|
207
241
|
// 1. Agent Identity
|
|
208
242
|
const agentIdentity = await renderAgentIdentity();
|
|
209
243
|
sections.push(agentIdentity);
|
|
@@ -221,11 +255,15 @@ export async function buildDirectionBrief(params) {
|
|
|
221
255
|
dirSourceBlock = `**Path:** \`${filePath}\`\n\n\`\`\`tsx\n${fileContent}\n\`\`\``;
|
|
222
256
|
}
|
|
223
257
|
sections.push(`## Source File\n${dirSourceBlock}`);
|
|
224
|
-
// 4. Design Philosophy
|
|
225
|
-
|
|
226
|
-
|
|
258
|
+
// 4. Design Philosophy — only in redesign mode
|
|
259
|
+
if (redesign) {
|
|
260
|
+
const philosophy = await renderDesignPhilosophy();
|
|
261
|
+
sections.push(philosophy);
|
|
262
|
+
}
|
|
227
263
|
// 5. The project direction — this is the primary design authority
|
|
228
|
-
sections.push(
|
|
264
|
+
sections.push(redesign
|
|
265
|
+
? `## Project Visual Direction\n\nThis is the established design direction for this project. All variations MUST follow it.\n\n${direction}`
|
|
266
|
+
: `## Project Visual Direction\n\nThis is the established design direction for this project. All variations MUST preserve its aesthetic and work within it — do not change the visual identity.\n\n${direction}`);
|
|
229
267
|
// 6. Project tokens (if available)
|
|
230
268
|
if (projectTokens) {
|
|
231
269
|
const rendered = renderProjectTokens(projectTokens);
|
|
@@ -237,20 +275,33 @@ export async function buildDirectionBrief(params) {
|
|
|
237
275
|
sections.push(`## Raw Project Context\n${designSystemContext}`);
|
|
238
276
|
}
|
|
239
277
|
// 7. Workflow rules
|
|
240
|
-
|
|
278
|
+
const dirTwoPass = `### Two-Pass Generation (Required)
|
|
279
|
+
|
|
280
|
+
For each variation, work in two explicit passes:
|
|
281
|
+
|
|
282
|
+
**Pass 1 — Structure:** Generate the component hierarchy and layout in semantic HTML. Use only structural utilities (flex, grid, gap, w-full, etc.). No colors, no typography classes, no shadows, no visual styling. Review the structure: does the hierarchy make sense? Is the information architecture clear? Are the right elements grouped together?
|
|
283
|
+
|
|
284
|
+
**Pass 2 — Style:** Apply the direction's design tokens over the confirmed structure. Typography scale, color roles, spacing values, shadows, border radii, interaction states — all applied in this pass. The structure is locked; do not reorganize components to accommodate styling.`;
|
|
285
|
+
if (redesign) {
|
|
286
|
+
sections.push(`## Workflow Rules
|
|
241
287
|
- **Adhere to the Design Philosophy above** — these are non-negotiable constraints.
|
|
242
288
|
- **Follow the Project Visual Direction** — this is the established aesthetic for this project. Do not deviate.
|
|
243
289
|
- If any generated code violates the anti-patterns table, fix it before outputting.
|
|
244
290
|
- **Hierarchy: Philosophy constraints > Project Direction > Project token values > Defaults.**
|
|
245
291
|
- Preserve the source file's structure and functionality — only transform the visual presentation.
|
|
246
292
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
**
|
|
293
|
+
${dirTwoPass}`);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
sections.push(`## Workflow Rules
|
|
297
|
+
- **Preserve the existing design** — do not change the aesthetic, colors, typography, or visual patterns.
|
|
298
|
+
- **Follow the Project Visual Direction** — this is the established identity. Work within it, not against it.
|
|
299
|
+
- Use the project's existing token values. Do not introduce new design elements.
|
|
300
|
+
- Variations should explore different **layouts, content arrangements, and structural approaches** — not different aesthetics.
|
|
301
|
+
- Every variation must look like it belongs to the same product.
|
|
252
302
|
|
|
253
|
-
|
|
303
|
+
${dirTwoPass}`);
|
|
304
|
+
}
|
|
254
305
|
if (instruction) {
|
|
255
306
|
sections.push(`## Additional Instructions\n${instruction}`);
|
|
256
307
|
}
|
|
@@ -260,11 +311,11 @@ For each variation, work in two explicit passes:
|
|
|
260
311
|
const variationBlocks = Array.from({ length: count }, (_, i) => {
|
|
261
312
|
return `\`\`\`glyph-variation-${i + 1}\n// Variation ${i + 1} code here\n\`\`\``;
|
|
262
313
|
}).join('\n\n');
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
Generate exactly **${count}** distinct variations of the source file above,
|
|
266
|
-
|
|
267
|
-
|
|
314
|
+
const dirTaskPreamble = redesign
|
|
315
|
+
? `Generate exactly **${count}** distinct variations of the source file above, each following the **Project Visual Direction**. This count is a hard requirement — generating fewer is a failure. You MUST produce all ${count} variations.`
|
|
316
|
+
: `Generate exactly **${count}** distinct variations of the source file above, **preserving the existing design** while exploring different structural approaches. Each variation must follow the Project Visual Direction and use the same design tokens. This count is a hard requirement — generating fewer is a failure. You MUST produce all ${count} variations.`;
|
|
317
|
+
const dirTaskRequirements = redesign
|
|
318
|
+
? `### Requirements
|
|
268
319
|
1. Each variation must be a **complete, working replacement** for the source file.
|
|
269
320
|
2. Preserve all functionality — only change visual presentation and styling.
|
|
270
321
|
3. Each variation should explore a **different interpretation** of the direction:
|
|
@@ -274,7 +325,29 @@ Generate exactly **${count}** distinct variations of the source file above, each
|
|
|
274
325
|
- Variation 4+: Creative explorations (different layouts, emphasis, density)
|
|
275
326
|
4. Comply with Design Philosophy constraints. Use the direction's token values.
|
|
276
327
|
5. Keep all imports and exports intact.
|
|
277
|
-
6. Use inline styles or Tailwind classes as appropriate for the existing codebase
|
|
328
|
+
6. Use inline styles or Tailwind classes as appropriate for the existing codebase.`
|
|
329
|
+
: `### Requirements
|
|
330
|
+
1. Each variation must be a **complete, working replacement** for the source file.
|
|
331
|
+
2. Preserve all functionality — only change visual presentation and styling.
|
|
332
|
+
3. **Use the existing design tokens** — same colors, fonts, spacing, border-radius, shadows. Do not change the aesthetic.
|
|
333
|
+
4. Each variation should explore a **different structural approach** within the existing design:
|
|
334
|
+
- Variation 1: Faithful to current layout with subtle refinements
|
|
335
|
+
- Variation 2: Different layout arrangement (e.g. sidebar ↔ top-nav, grid ↔ list)
|
|
336
|
+
- Variation 3: Different content density or information hierarchy
|
|
337
|
+
- Variation 4+: Alternative structural approaches (card layouts, split views, etc.)
|
|
338
|
+
5. Keep all imports and exports intact.
|
|
339
|
+
6. Use inline styles or Tailwind classes as appropriate for the existing codebase.`;
|
|
340
|
+
const dirFidelityDimension = redesign
|
|
341
|
+
? `**Direction fidelity** — Does this unmistakably follow the established project direction?`
|
|
342
|
+
: `**Design system fidelity** — Does this look like it belongs to the same product as the original?`;
|
|
343
|
+
const dirEvalNote = redesign
|
|
344
|
+
? `\n\n**If a variation looks like it could have been produced by a generic UI generator, it fails. Redesign it.**`
|
|
345
|
+
: `\n\n**Every variation must feel like it belongs to the same product as the original. If it looks like a different app, it fails.**`;
|
|
346
|
+
sections.push(`## Your Task
|
|
347
|
+
|
|
348
|
+
${dirTaskPreamble}
|
|
349
|
+
|
|
350
|
+
${dirTaskRequirements}
|
|
278
351
|
|
|
279
352
|
### Visual Self-Evaluation (Mandatory Gate)
|
|
280
353
|
|
|
@@ -286,7 +359,7 @@ After generating each variation (both passes complete), you **MUST** evaluate it
|
|
|
286
359
|
- **Optical hierarchy clarity** — Can the eye find the primary action in under 1 second?
|
|
287
360
|
- **Typographic precision** — Is the type scale intentional? Are weights and sizes doing real work?
|
|
288
361
|
- **Color restraint and intentionality** — Is every color earning its place? No decorative noise?
|
|
289
|
-
-
|
|
362
|
+
- ${dirFidelityDimension}
|
|
290
363
|
- **Whitespace and composition** — Is spacing rhythmic and intentional, not just default gaps?
|
|
291
364
|
4. If ANY dimension scores below 7: identify the single weakest element, propose a specific token-level fix, apply it, and re-evaluate
|
|
292
365
|
5. Maximum 2 iteration rounds per variation
|
|
@@ -294,8 +367,7 @@ After generating each variation (both passes complete), you **MUST** evaluate it
|
|
|
294
367
|
7. If still below threshold after 2 iterations, submit with a note explaining what couldn't be resolved
|
|
295
368
|
|
|
296
369
|
${rubric}
|
|
297
|
-
|
|
298
|
-
**If a variation looks like it could have been produced by a generic UI generator, it fails. Redesign it.**
|
|
370
|
+
${dirEvalNote}
|
|
299
371
|
|
|
300
372
|
### Output Format
|
|
301
373
|
Return each variation in a labeled fenced code block:
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creative/opinionated voice for variation generation
|
|
3
|
-
*
|
|
4
|
-
* brief — before agent identity, before
|
|
2
|
+
* Creative/opinionated voice for variation generation when the user has
|
|
3
|
+
* explicitly requested Glyph's design judgment (redesign: true).
|
|
4
|
+
* Injected at the very top of the brief — before agent identity, before
|
|
5
|
+
* philosophy, before everything.
|
|
5
6
|
*/
|
|
6
7
|
export declare function renderTasteLayer(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Default preserve voice — respects the existing design system.
|
|
10
|
+
* Glyph scans and understands the current design language but does NOT
|
|
11
|
+
* impose its own aesthetic opinions. Variations stay within the
|
|
12
|
+
* established visual identity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderPreserveVoice(): string;
|
|
7
15
|
/**
|
|
8
16
|
* Precise/systematic voice for generate_design_system extract mode.
|
|
9
17
|
* When documenting what exists, accuracy matters more than opinions.
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// Taste Layer — the voice that interprets all design reference material
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
/**
|
|
6
|
-
* Creative/opinionated voice for variation generation
|
|
7
|
-
*
|
|
8
|
-
* brief — before agent identity, before
|
|
6
|
+
* Creative/opinionated voice for variation generation when the user has
|
|
7
|
+
* explicitly requested Glyph's design judgment (redesign: true).
|
|
8
|
+
* Injected at the very top of the brief — before agent identity, before
|
|
9
|
+
* philosophy, before everything.
|
|
9
10
|
*/
|
|
10
11
|
export function renderTasteLayer() {
|
|
11
12
|
return `## Design Voice
|
|
@@ -14,6 +15,19 @@ export function renderTasteLayer() {
|
|
|
14
15
|
|
|
15
16
|
You are a senior product designer with 15 years of craft experience. You have strong opinions and you act on them. You do not generate safe, average, or template-looking interfaces. Every layout decision is intentional. Every pixel of whitespace is earned. If a component looks like it could have been produced by a generic AI code generator, you redesign it until it couldn't have been. You treat the design system as a constraint to work within, not a paint-by-numbers kit. When in doubt, subtract. The best interfaces feel inevitable — like nothing could be added or removed.`;
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Default preserve voice — respects the existing design system.
|
|
20
|
+
* Glyph scans and understands the current design language but does NOT
|
|
21
|
+
* impose its own aesthetic opinions. Variations stay within the
|
|
22
|
+
* established visual identity.
|
|
23
|
+
*/
|
|
24
|
+
export function renderPreserveVoice() {
|
|
25
|
+
return `## Design Voice
|
|
26
|
+
|
|
27
|
+
> This sets the posture for everything that follows. Read all subsequent material through this lens.
|
|
28
|
+
|
|
29
|
+
You are a senior product designer who deeply respects existing design systems. Your job is to understand the current design language — its colors, typography, spacing, component patterns, and overall aesthetic — and work faithfully within it. You do NOT redesign, restyle, or impose a different aesthetic. You preserve the existing visual identity while generating variations that explore different layouts, content arrangements, and structural approaches within the established design system. Every variation must feel like it belongs to the same product. When the existing design has clear patterns, follow them. When it has gaps, fill them by extending the existing language — not by introducing a new one.`;
|
|
30
|
+
}
|
|
17
31
|
/**
|
|
18
32
|
* Precise/systematic voice for generate_design_system extract mode.
|
|
19
33
|
* When documenting what exists, accuracy matters more than opinions.
|
|
@@ -19,11 +19,23 @@ async function loadDirection(root) {
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
export function registerGenerateVariations(server) {
|
|
22
|
-
server.tool('generate_variations',
|
|
22
|
+
server.tool('generate_variations', `Analyze a file and generate a design brief for creating UI variations. Uses the project's established design direction (design.md or redesign.md) as the constraint system.
|
|
23
|
+
|
|
24
|
+
By default (redesign: false), Glyph preserves the existing design system — same colors, typography, spacing — and explores different layouts and structural approaches within it.
|
|
25
|
+
|
|
26
|
+
Set redesign: true when the user's intent signals they want a new or different aesthetic. Examples of redesign intent:
|
|
27
|
+
- "rethink the design", "new design system", "totally different look"
|
|
28
|
+
- "make it look like Linear/Stripe/etc.", "redesign the landing page"
|
|
29
|
+
- "I want Glyph's opinion", "make it better looking", "the design needs work"
|
|
30
|
+
- "fresh design", "modern redesign", "overhaul the UI"
|
|
31
|
+
- Any request for a brand aesthetic, preset, or style change
|
|
32
|
+
|
|
33
|
+
Keep redesign: false (default) when the user just wants layout variations, structural alternatives, or component rearrangements without changing the visual identity.`, {
|
|
23
34
|
file: z.string(),
|
|
24
35
|
instruction: z.string().optional(),
|
|
25
36
|
count: z.number().optional().default(4),
|
|
26
|
-
|
|
37
|
+
redesign: z.boolean().optional().default(false).describe('Set to true when the user wants a new aesthetic, different design system, or Glyph\'s opinionated design judgment. Keep false (default) for layout/structural variations that preserve the existing design.'),
|
|
38
|
+
}, async ({ file, instruction, count, redesign }) => {
|
|
27
39
|
const projectRoot = process.env.GLYPH_PROJECT_ROOT || process.cwd();
|
|
28
40
|
const filePath = path.resolve(projectRoot, file);
|
|
29
41
|
track('mcp:generate_variations', { file, count });
|
|
@@ -71,6 +83,7 @@ export function registerGenerateVariations(server) {
|
|
|
71
83
|
count,
|
|
72
84
|
designSystemContext,
|
|
73
85
|
projectTokens,
|
|
86
|
+
redesign,
|
|
74
87
|
});
|
|
75
88
|
track('prompt:generated', {
|
|
76
89
|
file,
|