glyph-ai 0.2.0 → 0.2.1
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/design-philosophy.d.ts +17 -2
- package/bundled/server/context/design-philosophy.d.ts.map +1 -1
- package/bundled/server/context/design-philosophy.js +157 -51
- package/bundled/server/context/design-philosophy.js.map +1 -1
- package/bundled/server/context/prompt-builder.d.ts +2 -0
- package/bundled/server/context/prompt-builder.d.ts.map +1 -1
- package/bundled/server/context/prompt-builder.js +47 -7
- package/bundled/server/context/prompt-builder.js.map +1 -1
- package/bundled/server/data/design.md +398 -610
- package/bundled/server/mcp/tools/generate-variations.d.ts.map +1 -1
- package/bundled/server/mcp/tools/generate-variations.js +4 -2
- package/bundled/server/mcp/tools/generate-variations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Agent Identity + Instructions — sets Claude's posture as a creative director.
|
|
3
|
+
* Should be injected as the first thing Claude reads, before the design brief.
|
|
4
|
+
*/
|
|
5
|
+
export declare function renderAgentIdentity(): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Design Philosophy (Sections 1-12) — rules, anti-patterns, component guidelines.
|
|
8
|
+
* Non-negotiable constraints for all generated interfaces.
|
|
4
9
|
*/
|
|
5
10
|
export declare function renderDesignPhilosophy(): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a specific preset (a, b, c) or the full presets section.
|
|
13
|
+
* Includes canonical screen descriptions, per-preset bans, and token overrides.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderPreset(preset: 'a' | 'b' | 'c' | 'full'): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the Visual Scoring Rubric (Section 18).
|
|
18
|
+
* Used for self-evaluation before submitting variations.
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderScoringRubric(): Promise<string>;
|
|
6
21
|
//# sourceMappingURL=design-philosophy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-philosophy.d.ts","sourceRoot":"","sources":["../../src/context/design-philosophy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"design-philosophy.d.ts","sourceRoot":"","sources":["../../src/context/design-philosophy.ts"],"names":[],"mappings":"AA0LA;;;GAGG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAG3D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAO9D;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASpF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAG3D"}
|
|
@@ -1,82 +1,188 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
let
|
|
4
|
+
let cache = null;
|
|
5
5
|
function getDataDir() {
|
|
6
6
|
const thisFile = fileURLToPath(import.meta.url);
|
|
7
7
|
const packageRoot = path.resolve(path.dirname(thisFile), '..', '..');
|
|
8
8
|
return path.join(packageRoot, 'data');
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Sections extracted:
|
|
15
|
-
* - 1. Guiding Principles
|
|
16
|
-
* - 2. Color (roles, rules, anti-patterns)
|
|
17
|
-
* - 3. Typography (rules)
|
|
18
|
-
* - 4. Spacing (rules)
|
|
19
|
-
* - 5. Layout (rules)
|
|
20
|
-
* - 6. Borders & Radius (rules)
|
|
21
|
-
* - 7. Elevation & Shadow (rules)
|
|
22
|
-
* - 8. Iconography
|
|
23
|
-
* - 9. Motion & Animation (rules)
|
|
24
|
-
* - 10. Component Guidelines
|
|
25
|
-
* - 11. Accessibility Baselines
|
|
26
|
-
* - 12. Anti-patterns (Global)
|
|
27
|
-
*/
|
|
28
|
-
async function loadPhilosophy() {
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Parser — extracts structured sections from design.md
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
async function parseDesignMd() {
|
|
29
14
|
const filePath = path.join(getDataDir(), 'design.md');
|
|
30
15
|
const raw = await fs.readFile(filePath, 'utf-8');
|
|
31
|
-
const sections = [];
|
|
32
16
|
const lines = raw.split('\n');
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
// -- Agent Identity & Instructions (everything between "## Agent Identity" and "## 1.")
|
|
18
|
+
const agentLines = [];
|
|
19
|
+
let inAgent = false;
|
|
20
|
+
// -- Numbered sections 1-12
|
|
21
|
+
const philosophySections = [];
|
|
22
|
+
// -- Presets (Section 17) — full block + individual presets
|
|
23
|
+
const presetLines = [];
|
|
24
|
+
const presetALines = [];
|
|
25
|
+
const presetBLines = [];
|
|
26
|
+
const presetCLines = [];
|
|
27
|
+
// -- Scoring Rubric (Section 18)
|
|
28
|
+
const rubricLines = [];
|
|
29
|
+
let region = 'none';
|
|
30
|
+
let currentPhilosophy = [];
|
|
31
|
+
const flushPhilosophy = () => {
|
|
32
|
+
if (currentPhilosophy.length > 0) {
|
|
33
|
+
philosophySections.push(currentPhilosophy.join('\n').trim());
|
|
34
|
+
currentPhilosophy = [];
|
|
40
35
|
}
|
|
41
|
-
sectionLines = [];
|
|
42
36
|
};
|
|
43
37
|
for (const line of lines) {
|
|
38
|
+
// Detect ## headings to transition regions
|
|
44
39
|
if (line.startsWith('## ')) {
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
flushPhilosophy();
|
|
41
|
+
// Agent Identity or Agent Instructions
|
|
42
|
+
if (line.startsWith('## Agent Identity') || line.startsWith('## Agent Instructions')) {
|
|
43
|
+
region = 'agent';
|
|
44
|
+
agentLines.push(line);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// Numbered sections 1-12
|
|
48
|
+
const numMatch = line.match(/^## (\d+)\.\s/);
|
|
49
|
+
if (numMatch) {
|
|
50
|
+
const num = parseInt(numMatch[1], 10);
|
|
50
51
|
if (num >= 1 && num <= 12) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
region = 'philosophy';
|
|
53
|
+
currentPhilosophy = [line];
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (num === 17) {
|
|
57
|
+
region = 'preset-full';
|
|
58
|
+
presetLines.push(line);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (num === 18) {
|
|
62
|
+
region = 'rubric';
|
|
63
|
+
rubricLines.push(line);
|
|
54
64
|
continue;
|
|
55
65
|
}
|
|
66
|
+
// Any other numbered section (13-16, 19) — stop capturing
|
|
67
|
+
region = 'none';
|
|
68
|
+
continue;
|
|
56
69
|
}
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
// ### sub-headings within presets
|
|
71
|
+
if (region === 'preset-full' || region === 'preset-a' || region === 'preset-b' || region === 'preset-c') {
|
|
72
|
+
if (line.startsWith('### Preset A')) {
|
|
73
|
+
region = 'preset-a';
|
|
74
|
+
presetLines.push(line);
|
|
75
|
+
presetALines.push(line);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (line.startsWith('### Preset B')) {
|
|
79
|
+
region = 'preset-b';
|
|
80
|
+
presetLines.push(line);
|
|
81
|
+
presetBLines.push(line);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (line.startsWith('### Preset C')) {
|
|
85
|
+
region = 'preset-c';
|
|
86
|
+
presetLines.push(line);
|
|
87
|
+
presetCLines.push(line);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Any other ## heading — stop capturing
|
|
92
|
+
region = 'none';
|
|
93
|
+
continue;
|
|
60
94
|
}
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
// Accumulate lines in the active region
|
|
96
|
+
switch (region) {
|
|
97
|
+
case 'agent':
|
|
98
|
+
agentLines.push(line);
|
|
99
|
+
break;
|
|
100
|
+
case 'philosophy':
|
|
101
|
+
currentPhilosophy.push(line);
|
|
102
|
+
break;
|
|
103
|
+
case 'preset-full':
|
|
104
|
+
presetLines.push(line);
|
|
105
|
+
break;
|
|
106
|
+
case 'preset-a':
|
|
107
|
+
presetLines.push(line);
|
|
108
|
+
presetALines.push(line);
|
|
109
|
+
break;
|
|
110
|
+
case 'preset-b':
|
|
111
|
+
presetLines.push(line);
|
|
112
|
+
presetBLines.push(line);
|
|
113
|
+
break;
|
|
114
|
+
case 'preset-c':
|
|
115
|
+
presetLines.push(line);
|
|
116
|
+
presetCLines.push(line);
|
|
117
|
+
break;
|
|
118
|
+
case 'rubric':
|
|
119
|
+
rubricLines.push(line);
|
|
120
|
+
break;
|
|
63
121
|
}
|
|
64
122
|
}
|
|
65
|
-
|
|
123
|
+
flushPhilosophy();
|
|
124
|
+
return {
|
|
125
|
+
agentIdentity: agentLines.join('\n').trim(),
|
|
126
|
+
philosophy: philosophySections.join('\n\n---\n\n'),
|
|
127
|
+
presets: {
|
|
128
|
+
a: presetALines.join('\n').trim(),
|
|
129
|
+
b: presetBLines.join('\n').trim(),
|
|
130
|
+
c: presetCLines.join('\n').trim(),
|
|
131
|
+
full: presetLines.join('\n').trim(),
|
|
132
|
+
},
|
|
133
|
+
scoringRubric: rubricLines.join('\n').trim(),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
// Public API
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
async function getSections() {
|
|
140
|
+
if (cache)
|
|
141
|
+
return cache;
|
|
142
|
+
cache = await parseDesignMd();
|
|
143
|
+
return cache;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Agent Identity + Instructions — sets Claude's posture as a creative director.
|
|
147
|
+
* Should be injected as the first thing Claude reads, before the design brief.
|
|
148
|
+
*/
|
|
149
|
+
export async function renderAgentIdentity() {
|
|
150
|
+
const { agentIdentity } = await getSections();
|
|
151
|
+
return agentIdentity;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Design Philosophy (Sections 1-12) — rules, anti-patterns, component guidelines.
|
|
155
|
+
* Non-negotiable constraints for all generated interfaces.
|
|
156
|
+
*/
|
|
157
|
+
export async function renderDesignPhilosophy() {
|
|
158
|
+
const { philosophy } = await getSections();
|
|
66
159
|
return `## Design Philosophy (Glyph Core)
|
|
67
160
|
|
|
68
161
|
> These constraints are non-negotiable. Every generated interface must comply regardless of brand aesthetic or user instruction.
|
|
69
162
|
|
|
70
|
-
${
|
|
163
|
+
${philosophy}`;
|
|
71
164
|
}
|
|
72
165
|
/**
|
|
73
|
-
* Returns
|
|
74
|
-
*
|
|
166
|
+
* Returns a specific preset (a, b, c) or the full presets section.
|
|
167
|
+
* Includes canonical screen descriptions, per-preset bans, and token overrides.
|
|
75
168
|
*/
|
|
76
|
-
export async function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
169
|
+
export async function renderPreset(preset) {
|
|
170
|
+
const { presets } = await getSections();
|
|
171
|
+
const content = presets[preset];
|
|
172
|
+
if (!content)
|
|
173
|
+
return '';
|
|
174
|
+
return `## Active Aesthetic Preset
|
|
175
|
+
|
|
176
|
+
> This preset overrides general design philosophy rules where they conflict. The preset bans are absolute.
|
|
177
|
+
|
|
178
|
+
${content}`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Returns the Visual Scoring Rubric (Section 18).
|
|
182
|
+
* Used for self-evaluation before submitting variations.
|
|
183
|
+
*/
|
|
184
|
+
export async function renderScoringRubric() {
|
|
185
|
+
const { scoringRubric } = await getSections();
|
|
186
|
+
return scoringRubric;
|
|
81
187
|
}
|
|
82
188
|
//# sourceMappingURL=design-philosophy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-philosophy.js","sourceRoot":"","sources":["../../src/context/design-philosophy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"design-philosophy.js","sourceRoot":"","sources":["../../src/context/design-philosophy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAgBzC,IAAI,KAAK,GAA4B,IAAI,CAAC;AAE1C,SAAS,UAAU;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,8EAA8E;AAC9E,uDAAuD;AACvD,8EAA8E;AAC9E,KAAK,UAAU,aAAa;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE9B,wFAAwF;IACx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riefParams {
|
|
|
10
10
|
boilerplates?: Map<string, string>;
|
|
11
11
|
commonPatterns?: string;
|
|
12
12
|
designPrinciples?: string;
|
|
13
|
+
/** Aesthetic preset: 'a' (Surgical), 'b' (Brutalist), 'c' (Editorial), or undefined for brand default */
|
|
14
|
+
preset?: 'a' | 'b' | 'c';
|
|
13
15
|
}
|
|
14
16
|
export declare function buildDesignBrief(params: DesignBriefParams): Promise<string>;
|
|
15
17
|
//# sourceMappingURL=prompt-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/context/prompt-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/context/prompt-builder.ts"],"names":[],"mappings":"AAOA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yGAAyG;IACzG,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC1B;AA+ID,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmDjF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getBrandReference, getBrandFullData } from './brand-references.js';
|
|
2
|
-
import { renderDesignPhilosophy } from './design-philosophy.js';
|
|
2
|
+
import { renderAgentIdentity, renderDesignPhilosophy, renderPreset, renderScoringRubric, } from './design-philosophy.js';
|
|
3
3
|
import { renderProjectTokens } from './token-template.js';
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Shared context builder — resolves brand data, philosophy, tokens once
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
async function buildSharedSections(params) {
|
|
8
|
-
const { fileContent, filePath, brand, instruction, designSystemContext, projectTokens } = params;
|
|
8
|
+
const { fileContent, filePath, brand, instruction, designSystemContext, projectTokens, preset } = params;
|
|
9
9
|
const isProjectMode = brand === 'project';
|
|
10
10
|
let { boilerplates, commonPatterns, designPrinciples } = params;
|
|
11
11
|
let resolvedBrandRef = '';
|
|
@@ -23,6 +23,14 @@ async function buildSharedSections(params) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
const sections = [];
|
|
26
|
+
// -----------------------------------------------------------------------
|
|
27
|
+
// 1. Agent Identity — sets Claude's posture BEFORE anything else
|
|
28
|
+
// -----------------------------------------------------------------------
|
|
29
|
+
const agentIdentity = await renderAgentIdentity();
|
|
30
|
+
sections.push(agentIdentity);
|
|
31
|
+
// -----------------------------------------------------------------------
|
|
32
|
+
// 2. Brief header + source file
|
|
33
|
+
// -----------------------------------------------------------------------
|
|
26
34
|
sections.push(isProjectMode
|
|
27
35
|
? `# Glyph Design Brief — Project Design System`
|
|
28
36
|
: `# Glyph Design Brief — ${brand.charAt(0).toUpperCase() + brand.slice(1)} Aesthetic`);
|
|
@@ -32,8 +40,23 @@ async function buildSharedSections(params) {
|
|
|
32
40
|
\`\`\`tsx
|
|
33
41
|
${fileContent}
|
|
34
42
|
\`\`\``);
|
|
43
|
+
// -----------------------------------------------------------------------
|
|
44
|
+
// 3. Design Philosophy (Sections 1-12) — non-negotiable constraints
|
|
45
|
+
// -----------------------------------------------------------------------
|
|
35
46
|
const philosophy = await renderDesignPhilosophy();
|
|
36
47
|
sections.push(philosophy);
|
|
48
|
+
// -----------------------------------------------------------------------
|
|
49
|
+
// 4. Active Aesthetic Preset — overrides philosophy where they conflict
|
|
50
|
+
// -----------------------------------------------------------------------
|
|
51
|
+
if (preset) {
|
|
52
|
+
const presetContent = await renderPreset(preset);
|
|
53
|
+
if (presetContent) {
|
|
54
|
+
sections.push(presetContent);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// -----------------------------------------------------------------------
|
|
58
|
+
// 5. Brand or project design system
|
|
59
|
+
// -----------------------------------------------------------------------
|
|
37
60
|
if (isProjectMode) {
|
|
38
61
|
sections.push(`## Design System\nUse the project's own design tokens below. Do not introduce external brand colors, typography, or patterns — stay consistent with the existing codebase.`);
|
|
39
62
|
}
|
|
@@ -63,28 +86,33 @@ ${fileContent}
|
|
|
63
86
|
if (designSystemContext && !designSystemContext.startsWith('No design system')) {
|
|
64
87
|
sections.push(`## Raw Project Context\n${designSystemContext}`);
|
|
65
88
|
}
|
|
89
|
+
// -----------------------------------------------------------------------
|
|
90
|
+
// 6. Workflow Rules
|
|
91
|
+
// -----------------------------------------------------------------------
|
|
66
92
|
sections.push(isProjectMode
|
|
67
93
|
? `## Workflow Rules
|
|
68
94
|
- **Adhere to the Design Philosophy above** — these are non-negotiable constraints.
|
|
69
95
|
- If any generated code violates the anti-patterns table, fix it before outputting.
|
|
70
96
|
- Use the project's existing color values, typography, spacing, and component patterns.
|
|
71
|
-
- **Hierarchy: Philosophy constraints > Project values > Defaults.**
|
|
72
|
-
- Preserve the source file's structure and functionality — only transform the visual presentation
|
|
97
|
+
- **Hierarchy: Philosophy constraints > Active Preset bans > Project values > Defaults.**
|
|
98
|
+
- Preserve the source file's structure and functionality — only transform the visual presentation.
|
|
99
|
+
- **Two-pass mindset**: Think about structure first (hierarchy, layout, composition), then apply styling. Do not compromise structure to accommodate a styling shortcut.`
|
|
73
100
|
: `## Workflow Rules
|
|
74
101
|
- **Adhere to the Design Philosophy above** — these are non-negotiable constraints.
|
|
75
102
|
- If any generated code violates the anti-patterns table, fix it before outputting.
|
|
76
103
|
- Use the exact color values, typography, spacing, and component patterns from the Brand Design System.
|
|
77
|
-
- **Hierarchy: Philosophy constraints > Brand values > Project values > Defaults.**
|
|
104
|
+
- **Hierarchy: Philosophy constraints > Active Preset bans > Brand values > Project values > Defaults.**
|
|
78
105
|
- Identify the sections present in the source file (hero, navigation, features, pricing, footer, etc.) and reference the matching section boilerplates above.
|
|
79
106
|
- If the brand's font is not available in the project, substitute: **Inter** for sans-serif fonts, **EB Garamond** for serif fonts.
|
|
80
|
-
- Preserve the source file's structure and functionality — only transform the visual presentation
|
|
107
|
+
- Preserve the source file's structure and functionality — only transform the visual presentation.
|
|
108
|
+
- **Two-pass mindset**: Think about structure first (hierarchy, layout, composition), then apply styling. Do not compromise structure to accommodate a styling shortcut.`);
|
|
81
109
|
if (instruction) {
|
|
82
110
|
sections.push(`## Additional Instructions\n${instruction}`);
|
|
83
111
|
}
|
|
84
112
|
return sections;
|
|
85
113
|
}
|
|
86
114
|
// ---------------------------------------------------------------------------
|
|
87
|
-
// Multi-variation brief (
|
|
115
|
+
// Multi-variation brief (used by MCP tool)
|
|
88
116
|
// ---------------------------------------------------------------------------
|
|
89
117
|
export async function buildDesignBrief(params) {
|
|
90
118
|
const { filePath, count } = params;
|
|
@@ -93,6 +121,10 @@ export async function buildDesignBrief(params) {
|
|
|
93
121
|
return `\`\`\`glyph-variation-${i + 1}\n// Variation ${i + 1} code here\n\`\`\``;
|
|
94
122
|
}).join('\n\n');
|
|
95
123
|
const isProjectMode = params.brand === 'project';
|
|
124
|
+
// -----------------------------------------------------------------------
|
|
125
|
+
// Scoring Rubric — self-evaluation before submitting
|
|
126
|
+
// -----------------------------------------------------------------------
|
|
127
|
+
const rubric = await renderScoringRubric();
|
|
96
128
|
sections.push(`## Your Task
|
|
97
129
|
|
|
98
130
|
Generate **${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`}.
|
|
@@ -109,6 +141,14 @@ Generate **${count} distinct variations** of the source file above, ${isProjectM
|
|
|
109
141
|
5. Keep all imports and exports intact.
|
|
110
142
|
6. Use inline styles or Tailwind classes as appropriate for the existing codebase.
|
|
111
143
|
|
|
144
|
+
### Self-Evaluation (Required)
|
|
145
|
+
|
|
146
|
+
Before submitting your variations, mentally score each one against these dimensions. If any score is below 7/10, revise that variation before outputting it.
|
|
147
|
+
|
|
148
|
+
${rubric}
|
|
149
|
+
|
|
150
|
+
**If a variation looks like it could have been produced by a generic UI generator, redesign it before delivering.**
|
|
151
|
+
|
|
112
152
|
### Output Format
|
|
113
153
|
Return each variation in a labeled fenced code block:
|
|
114
154
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/context/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/context/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,qBAAqB,CAAC;AAiB9E,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAC9E,KAAK,UAAU,mBAAmB,CAAC,MAWlC;IACC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACzG,MAAM,aAAa,GAAG,KAAK,KAAK,SAAS,CAAC;IAE1C,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAA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