glyph-ai 0.1.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.
Files changed (106) hide show
  1. package/README.md +69 -0
  2. package/bundled/overlay/overlay.js +63 -0
  3. package/bundled/server/context/brand-references.d.ts +7 -0
  4. package/bundled/server/context/brand-references.d.ts.map +1 -0
  5. package/bundled/server/context/brand-references.js +20 -0
  6. package/bundled/server/context/brand-references.js.map +1 -0
  7. package/bundled/server/context/design-philosophy.d.ts +6 -0
  8. package/bundled/server/context/design-philosophy.d.ts.map +1 -0
  9. package/bundled/server/context/design-philosophy.js +82 -0
  10. package/bundled/server/context/design-philosophy.js.map +1 -0
  11. package/bundled/server/context/design-system-loader.d.ts +11 -0
  12. package/bundled/server/context/design-system-loader.d.ts.map +1 -0
  13. package/bundled/server/context/design-system-loader.js +169 -0
  14. package/bundled/server/context/design-system-loader.js.map +1 -0
  15. package/bundled/server/context/design-system.d.ts +7 -0
  16. package/bundled/server/context/design-system.d.ts.map +1 -0
  17. package/bundled/server/context/design-system.js +75 -0
  18. package/bundled/server/context/design-system.js.map +1 -0
  19. package/bundled/server/context/prompt-builder.d.ts +15 -0
  20. package/bundled/server/context/prompt-builder.d.ts.map +1 -0
  21. package/bundled/server/context/prompt-builder.js +123 -0
  22. package/bundled/server/context/prompt-builder.js.map +1 -0
  23. package/bundled/server/context/token-template.d.ts +36 -0
  24. package/bundled/server/context/token-template.d.ts.map +1 -0
  25. package/bundled/server/context/token-template.js +226 -0
  26. package/bundled/server/context/token-template.js.map +1 -0
  27. package/bundled/server/data/design-systems/apple-design-system.md +474 -0
  28. package/bundled/server/data/design-systems/arc-design-system.md +922 -0
  29. package/bundled/server/data/design-systems/claude-ai-design-system.md +1443 -0
  30. package/bundled/server/data/design-systems/elevenlabs-design-system.md +669 -0
  31. package/bundled/server/data/design-systems/generating_design.md +9 -0
  32. package/bundled/server/data/design-systems/linear-design-system.md +607 -0
  33. package/bundled/server/data/design-systems/notion-design-system.md +866 -0
  34. package/bundled/server/data/design-systems/raycast-design-system.md +709 -0
  35. package/bundled/server/data/design-systems/stripe-design-system.md +592 -0
  36. package/bundled/server/data/design-systems/vercel-design-system.md +824 -0
  37. package/bundled/server/data/design.md +971 -0
  38. package/bundled/server/index.d.ts +2 -0
  39. package/bundled/server/index.d.ts.map +1 -0
  40. package/bundled/server/index.js +310 -0
  41. package/bundled/server/index.js.map +1 -0
  42. package/bundled/server/mcp/tools/apply-variation.d.ts +3 -0
  43. package/bundled/server/mcp/tools/apply-variation.d.ts.map +1 -0
  44. package/bundled/server/mcp/tools/apply-variation.js +43 -0
  45. package/bundled/server/mcp/tools/apply-variation.js.map +1 -0
  46. package/bundled/server/mcp/tools/generate-variations.d.ts +3 -0
  47. package/bundled/server/mcp/tools/generate-variations.d.ts.map +1 -0
  48. package/bundled/server/mcp/tools/generate-variations.js +58 -0
  49. package/bundled/server/mcp/tools/generate-variations.js.map +1 -0
  50. package/bundled/server/mcp/tools/index.d.ts +3 -0
  51. package/bundled/server/mcp/tools/index.d.ts.map +1 -0
  52. package/bundled/server/mcp/tools/index.js +11 -0
  53. package/bundled/server/mcp/tools/index.js.map +1 -0
  54. package/bundled/server/mcp/tools/scan-design-system.d.ts +3 -0
  55. package/bundled/server/mcp/tools/scan-design-system.d.ts.map +1 -0
  56. package/bundled/server/mcp/tools/scan-design-system.js +27 -0
  57. package/bundled/server/mcp/tools/scan-design-system.js.map +1 -0
  58. package/bundled/server/mcp/tools/submit-variations.d.ts +3 -0
  59. package/bundled/server/mcp/tools/submit-variations.d.ts.map +1 -0
  60. package/bundled/server/mcp/tools/submit-variations.js +50 -0
  61. package/bundled/server/mcp/tools/submit-variations.js.map +1 -0
  62. package/bundled/server/mcp-entry.d.ts +2 -0
  63. package/bundled/server/mcp-entry.d.ts.map +1 -0
  64. package/bundled/server/mcp-entry.js +56 -0
  65. package/bundled/server/mcp-entry.js.map +1 -0
  66. package/bundled/server/preview/css-resolver.d.ts +6 -0
  67. package/bundled/server/preview/css-resolver.d.ts.map +1 -0
  68. package/bundled/server/preview/css-resolver.js +57 -0
  69. package/bundled/server/preview/css-resolver.js.map +1 -0
  70. package/bundled/server/preview/html-builder.d.ts +6 -0
  71. package/bundled/server/preview/html-builder.d.ts.map +1 -0
  72. package/bundled/server/preview/html-builder.js +85 -0
  73. package/bundled/server/preview/html-builder.js.map +1 -0
  74. package/bundled/server/telemetry.d.ts +4 -0
  75. package/bundled/server/telemetry.d.ts.map +1 -0
  76. package/bundled/server/telemetry.js +71 -0
  77. package/bundled/server/telemetry.js.map +1 -0
  78. package/bundled/server/types.d.ts +69 -0
  79. package/bundled/server/types.d.ts.map +1 -0
  80. package/bundled/server/types.js +2 -0
  81. package/bundled/server/types.js.map +1 -0
  82. package/bundled/server/variations/file-writer.d.ts +5 -0
  83. package/bundled/server/variations/file-writer.d.ts.map +1 -0
  84. package/bundled/server/variations/file-writer.js +29 -0
  85. package/bundled/server/variations/file-writer.js.map +1 -0
  86. package/bundled/server/variations/git-utils.d.ts +3 -0
  87. package/bundled/server/variations/git-utils.d.ts.map +1 -0
  88. package/bundled/server/variations/git-utils.js +23 -0
  89. package/bundled/server/variations/git-utils.js.map +1 -0
  90. package/bundled/server/variations/store.d.ts +11 -0
  91. package/bundled/server/variations/store.d.ts.map +1 -0
  92. package/bundled/server/variations/store.js +52 -0
  93. package/bundled/server/variations/store.js.map +1 -0
  94. package/dist/commands/init.d.ts +2 -0
  95. package/dist/commands/init.d.ts.map +1 -0
  96. package/dist/commands/init.js +299 -0
  97. package/dist/commands/init.js.map +1 -0
  98. package/dist/commands/stop.d.ts +2 -0
  99. package/dist/commands/stop.d.ts.map +1 -0
  100. package/dist/commands/stop.js +32 -0
  101. package/dist/commands/stop.js.map +1 -0
  102. package/dist/index.d.ts +3 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +35 -0
  105. package/dist/index.js.map +1 -0
  106. package/package.json +35 -0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,310 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { createServer } from 'node:http';
4
+ import express from 'express';
5
+ import cors from 'cors';
6
+ import fs from 'fs-extra';
7
+ import { WebSocketServer, WebSocket } from 'ws';
8
+ import * as store from './variations/store.js';
9
+ import { backupFile, writeVariation, restoreBackup, cleanupBackup } from './variations/file-writer.js';
10
+ import { getGitBlobHash } from './variations/git-utils.js';
11
+ import { buildPreviewHtml } from './preview/html-builder.js';
12
+ import { resolveProjectCss } from './preview/css-resolver.js';
13
+ import { track, shutdown } from './telemetry.js';
14
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+ const PORT = Number(process.env.GLYPH_PORT) || 3001;
16
+ const PROJECT_ROOT = path.resolve(process.env.GLYPH_PROJECT_ROOT || process.cwd());
17
+ const PROJECT_NAME = path.basename(PROJECT_ROOT);
18
+ const app = express();
19
+ const httpServer = createServer(app);
20
+ // ---------------------------------------------------------------------------
21
+ // Middleware
22
+ // ---------------------------------------------------------------------------
23
+ app.use(cors({ origin: /localhost/ }));
24
+ app.use(express.json({ limit: '5mb' }));
25
+ // ---------------------------------------------------------------------------
26
+ // WebSocket
27
+ // ---------------------------------------------------------------------------
28
+ const wss = new WebSocketServer({ server: httpServer });
29
+ function broadcast(msg) {
30
+ const data = JSON.stringify(msg);
31
+ let count = 0;
32
+ for (const client of wss.clients) {
33
+ if (client.readyState === WebSocket.OPEN) {
34
+ client.send(data);
35
+ count++;
36
+ }
37
+ }
38
+ console.log(`[Glyph][ws] Broadcasting → ${msg.type} to ${count} clients`);
39
+ }
40
+ let connId = 0;
41
+ const wsIds = new WeakMap();
42
+ wss.on('connection', (ws) => {
43
+ const id = ++connId;
44
+ wsIds.set(ws, id);
45
+ console.log(`[Glyph][ws] Client #${id} connected (total: ${wss.clients.size})`);
46
+ track('ws:connect', { clientId: id, totalClients: wss.clients.size });
47
+ // Send current state on connect
48
+ const session = store.getSession();
49
+ ws.send(JSON.stringify({
50
+ type: 'state:update',
51
+ payload: { session, projectName: PROJECT_NAME },
52
+ }));
53
+ // If there's an active session with variations, also send previewUrls
54
+ if (session && session.variations.length > 0) {
55
+ const previewUrls = buildPreviewUrls(session.id, session.variations);
56
+ ws.send(JSON.stringify({
57
+ type: 'variations:ready',
58
+ payload: { sessionId: session.id, variations: session.variations, previewUrls },
59
+ }));
60
+ }
61
+ ws.on('message', async (raw) => {
62
+ try {
63
+ const msg = JSON.parse(String(raw));
64
+ const cid = wsIds.get(ws);
65
+ console.log(`[Glyph][ws] ← ${msg.type} (from #${cid})`);
66
+ if (msg.type === 'variation:preview') {
67
+ console.log(`[Glyph] Preview requested: ${msg.payload.id}`);
68
+ track('variation:preview', { variationId: msg.payload.id });
69
+ await previewVariation(msg.payload.id);
70
+ }
71
+ else if (msg.type === 'variation:cycle') {
72
+ const direction = msg.payload.direction;
73
+ console.log(`[Glyph] Cycle requested: ${direction}`);
74
+ track('variation:cycle', { direction });
75
+ await cycleVariation(direction);
76
+ }
77
+ else if (msg.type === 'variation:implement') {
78
+ console.log('[Glyph] Implement requested');
79
+ track('variation:implement', {});
80
+ await implementVariation();
81
+ }
82
+ else if (msg.type === 'variation:discard') {
83
+ console.log('[Glyph] Discard requested');
84
+ track('variation:discard', {});
85
+ await discardVariation();
86
+ }
87
+ }
88
+ catch (err) {
89
+ console.error('[ws] Error handling message:', err);
90
+ }
91
+ });
92
+ ws.on('close', () => {
93
+ const cid = wsIds.get(ws);
94
+ console.log(`[Glyph][ws] Client #${cid} disconnected (total: ${wss.clients.size})`);
95
+ track('ws:disconnect', { clientId: cid, totalClients: wss.clients.size });
96
+ });
97
+ });
98
+ // ---------------------------------------------------------------------------
99
+ // Preview lock — prevents race conditions during rapid cycling
100
+ // ---------------------------------------------------------------------------
101
+ let previewLock = Promise.resolve();
102
+ // ---------------------------------------------------------------------------
103
+ // Helpers
104
+ // ---------------------------------------------------------------------------
105
+ function buildPreviewUrls(sessionId, variations) {
106
+ const urls = {};
107
+ for (const v of variations) {
108
+ urls[v.id] = `/preview/${sessionId}/${v.id}`;
109
+ }
110
+ return urls;
111
+ }
112
+ async function previewVariation(variationId) {
113
+ // Chain writes to prevent rapid-cycling race conditions
114
+ const work = previewLock.then(async () => {
115
+ const session = store.getSession();
116
+ if (!session)
117
+ throw new Error('No active session');
118
+ const variation = session.variations.find((v) => v.id === variationId);
119
+ if (!variation)
120
+ throw new Error(`Variation not found: ${variationId}`);
121
+ const filePath = path.resolve(PROJECT_ROOT, session.sourceFile);
122
+ // Backup only on first preview per session
123
+ if (!session.backupPath) {
124
+ const backupPath = await backupFile(filePath);
125
+ session.backupPath = backupPath;
126
+ }
127
+ // Write directly — no restore-then-write to avoid HMR double-flash
128
+ await writeVariation(filePath, variation.code);
129
+ store.setPreviewing(session.id, variationId);
130
+ const index = session.variations.findIndex((v) => v.id === variationId);
131
+ broadcast({
132
+ type: 'variation:previewing',
133
+ payload: { id: variationId, index, total: session.variations.length },
134
+ });
135
+ track('variation:previewing', { variationId, file: session.sourceFile });
136
+ console.log(`[Glyph] Previewing: ${variationId} → ${session.sourceFile}`);
137
+ return { previewing: variationId, backupPath: session.backupPath, sourceFile: session.sourceFile };
138
+ });
139
+ previewLock = work.then(() => { }, () => { });
140
+ return work;
141
+ }
142
+ async function cycleVariation(direction) {
143
+ const session = store.getSession();
144
+ if (!session)
145
+ throw new Error('No active session');
146
+ if (session.variations.length === 0)
147
+ throw new Error('No variations to cycle');
148
+ const currentIndex = session.previewingId
149
+ ? session.variations.findIndex((v) => v.id === session.previewingId)
150
+ : -1;
151
+ let nextIndex;
152
+ if (direction === 'next') {
153
+ nextIndex = (currentIndex + 1) % session.variations.length;
154
+ }
155
+ else {
156
+ nextIndex = currentIndex <= 0 ? session.variations.length - 1 : currentIndex - 1;
157
+ }
158
+ await previewVariation(session.variations[nextIndex].id);
159
+ }
160
+ async function implementVariation() {
161
+ const session = store.getSession();
162
+ if (!session || !session.previewingId)
163
+ return;
164
+ // Code is already on disk from preview — just clean up the backup
165
+ if (session.backupPath) {
166
+ await cleanupBackup(session.backupPath);
167
+ session.backupPath = undefined;
168
+ }
169
+ session.implementedId = session.previewingId;
170
+ broadcast({
171
+ type: 'variation:implemented',
172
+ payload: { variationId: session.previewingId },
173
+ });
174
+ track('variation:implemented', { variationId: session.previewingId, file: session.sourceFile });
175
+ console.log(`[Glyph] Implemented: ${session.previewingId} → ${session.sourceFile}`);
176
+ }
177
+ async function discardVariation() {
178
+ const session = store.getSession();
179
+ if (!session)
180
+ throw new Error('No active session');
181
+ if (!session.backupPath)
182
+ throw new Error('No backup available');
183
+ const filePath = path.resolve(PROJECT_ROOT, session.sourceFile);
184
+ await restoreBackup(session.backupPath, filePath);
185
+ store.clearPreviewing(session.id);
186
+ broadcast({
187
+ type: 'variation:previewing',
188
+ payload: { id: null, index: 0, total: session.variations.length },
189
+ });
190
+ track('variation:discarded', { file: session.sourceFile });
191
+ console.log(`[Glyph] Discarded preview → ${session.sourceFile}`);
192
+ }
193
+ // ---------------------------------------------------------------------------
194
+ // Routes
195
+ // ---------------------------------------------------------------------------
196
+ app.get('/health', (_req, res) => {
197
+ res.json({ status: 'ok', version: '0.2.0' });
198
+ });
199
+ app.get('/overlay.js', (_req, res) => {
200
+ console.log('[Glyph] Serving overlay.js');
201
+ // Bundled (installed from npm): __dirname = cli/bundled/server/
202
+ const bundledPath = path.resolve(__dirname, '..', 'overlay', 'overlay.js');
203
+ // Dev (monorepo): __dirname = packages/server/dist/
204
+ const devPath = path.resolve(__dirname, '..', '..', 'overlay', 'dist', 'overlay.js');
205
+ const overlayPath = fs.existsSync(bundledPath) ? bundledPath : devPath;
206
+ res.sendFile(overlayPath, { headers: { 'Content-Type': 'application/javascript' } });
207
+ });
208
+ app.get('/api/variations', (_req, res) => {
209
+ const session = store.getSession();
210
+ res.json({ session });
211
+ });
212
+ app.post('/api/variations', async (req, res) => {
213
+ const { sourceFile, variations } = req.body;
214
+ if (!sourceFile || !Array.isArray(variations)) {
215
+ res.status(400).json({ error: 'Missing sourceFile or variations' });
216
+ return;
217
+ }
218
+ const fullSourcePath = path.resolve(PROJECT_ROOT, sourceFile);
219
+ const snapshotHash = await getGitBlobHash(fullSourcePath) ?? undefined;
220
+ const session = store.createSession(sourceFile, { gitSnapshotHash: snapshotHash });
221
+ const now = Date.now();
222
+ const mapped = variations.map((v) => ({
223
+ id: v.id,
224
+ sourceFile,
225
+ code: v.code,
226
+ createdAt: now,
227
+ }));
228
+ store.addVariations(session.id, mapped);
229
+ const previewUrls = buildPreviewUrls(session.id, mapped);
230
+ console.log(`[Glyph] Variations received: ${mapped.length} for ${sourceFile} (session: ${session.id})`);
231
+ broadcast({
232
+ type: 'variations:ready',
233
+ payload: { sessionId: session.id, variations: mapped, previewUrls },
234
+ });
235
+ res.json({ sessionId: session.id, count: mapped.length, previewUrls });
236
+ });
237
+ app.post('/api/variations/apply', async (req, res) => {
238
+ try {
239
+ const { variationId } = req.body;
240
+ console.log(`[Glyph] Preview request (via apply): ${variationId}`);
241
+ if (!variationId) {
242
+ res.status(400).json({ error: 'Missing variationId' });
243
+ return;
244
+ }
245
+ const result = await previewVariation(variationId);
246
+ res.json(result);
247
+ }
248
+ catch (err) {
249
+ const message = err instanceof Error ? err.message : String(err);
250
+ res.status(500).json({ error: message });
251
+ }
252
+ });
253
+ app.post('/api/variations/undo', async (_req, res) => {
254
+ console.log('[Glyph] Discard request (via undo)');
255
+ try {
256
+ await discardVariation();
257
+ res.json({ success: true });
258
+ }
259
+ catch (err) {
260
+ const message = err instanceof Error ? err.message : String(err);
261
+ res.status(500).json({ error: message });
262
+ }
263
+ });
264
+ app.post('/api/variations/implement', async (_req, res) => {
265
+ console.log('[Glyph] Implement request');
266
+ try {
267
+ await implementVariation();
268
+ res.json({ success: true });
269
+ }
270
+ catch (err) {
271
+ const message = err instanceof Error ? err.message : String(err);
272
+ res.status(500).json({ error: message });
273
+ }
274
+ });
275
+ // ---------------------------------------------------------------------------
276
+ // Preview iframe route — serves standalone HTML for each variation
277
+ // ---------------------------------------------------------------------------
278
+ app.get('/preview/:sessionId/:variationId', async (req, res) => {
279
+ const { sessionId, variationId } = req.params;
280
+ const session = store.getSessionById(sessionId);
281
+ if (!session) {
282
+ res.status(404).send('Session not found');
283
+ return;
284
+ }
285
+ const variation = session.variations.find((v) => v.id === variationId);
286
+ if (!variation) {
287
+ res.status(404).send('Variation not found');
288
+ return;
289
+ }
290
+ try {
291
+ const cssContent = await resolveProjectCss(PROJECT_ROOT);
292
+ const html = await buildPreviewHtml(variation.code, cssContent ?? undefined);
293
+ res.setHeader('Content-Type', 'text/html');
294
+ res.send(html);
295
+ }
296
+ catch (err) {
297
+ const message = err instanceof Error ? err.message : String(err);
298
+ console.error(`[Glyph] Preview build error: ${message}`);
299
+ res.status(500).send(`<html><body style="background:#0a0a0a;color:#f87171;padding:2rem;font-family:monospace">${message}</body></html>`);
300
+ }
301
+ });
302
+ // ---------------------------------------------------------------------------
303
+ // Start
304
+ // ---------------------------------------------------------------------------
305
+ process.on('SIGTERM', shutdown);
306
+ process.on('SIGINT', shutdown);
307
+ httpServer.listen(PORT, () => {
308
+ console.log(`Glyph server running at http://localhost:${PORT} (project: ${PROJECT_ROOT})`);
309
+ });
310
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,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,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,CAAC,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAC;QACzD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,2FAA2F,OAAO,gBAAgB,CAAC,CAAC;IAC3I,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAC9E,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE/B,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,cAAc,YAAY,GAAG,CAAC,CAAC;AAC7F,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerApplyVariation(server: McpServer): void;
3
+ //# sourceMappingURL=apply-variation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-variation.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/apply-variation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4C9D"}
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ import { track } from '../../telemetry.js';
3
+ const GLYPH_PORT = process.env.GLYPH_PORT || '3001';
4
+ export function registerApplyVariation(server) {
5
+ server.tool('apply_variation', 'Preview a variation by writing it to the source file (creates a backup). The user can finalize or discard via the browser overlay.', {
6
+ variation_id: z.string(),
7
+ }, async ({ variation_id }) => {
8
+ track('mcp:apply_variation', { variationId: variation_id });
9
+ try {
10
+ const response = await fetch(`http://localhost:${GLYPH_PORT}/api/variations/apply`, {
11
+ method: 'POST',
12
+ headers: { 'Content-Type': 'application/json' },
13
+ body: JSON.stringify({ variationId: variation_id }),
14
+ });
15
+ if (!response.ok) {
16
+ const text = await response.text();
17
+ return {
18
+ content: [{ type: 'text', text: `Error applying variation: ${response.status} ${text}` }],
19
+ };
20
+ }
21
+ const data = (await response.json());
22
+ return {
23
+ content: [
24
+ {
25
+ type: 'text',
26
+ text: `Previewing variation "${variation_id}" in ${data.sourceFile}.\nBackup saved at: ${data.backupPath}\nThe user can finalize this variation, cycle through others, or discard via the browser overlay.`,
27
+ },
28
+ ],
29
+ };
30
+ }
31
+ catch {
32
+ return {
33
+ content: [
34
+ {
35
+ type: 'text',
36
+ text: `Error: Could not connect to Glyph server at localhost:${GLYPH_PORT}. Is the server running?`,
37
+ },
38
+ ],
39
+ };
40
+ }
41
+ });
42
+ }
43
+ //# sourceMappingURL=apply-variation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-variation.js","sourceRoot":"","sources":["../../../src/mcp/tools/apply-variation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC;AAEpD,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,oIAAoI,EACpI;QACE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;KACzB,EACD,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACzB,KAAK,CAAC,qBAAqB,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,oBAAoB,UAAU,uBAAuB,EAAE;gBAClF,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;aACpD,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnC,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,6BAA6B,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC;iBACnG,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmE,CAAC;YACvG,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yBAAyB,YAAY,QAAQ,IAAI,CAAC,UAAU,uBAAuB,IAAI,CAAC,UAAU,mGAAmG;qBAC5M;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yDAAyD,UAAU,0BAA0B;qBACpG;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerGenerateVariations(server: McpServer): void;
3
+ //# sourceMappingURL=generate-variations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-variations.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/generate-variations.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyDlE"}
@@ -0,0 +1,58 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'node:path';
3
+ import { z } from 'zod';
4
+ import { track } from '../../telemetry.js';
5
+ import { isValidBrand } from '../../context/brand-references.js';
6
+ import { buildDesignBrief } from '../../context/prompt-builder.js';
7
+ import { scanDesignSystem } from '../../context/design-system.js';
8
+ export function registerGenerateVariations(server) {
9
+ server.tool('generate_variations', 'Analyze a file and generate a design brief for creating UI variations with a specific brand aesthetic', {
10
+ file: z.string(),
11
+ brand: z.string().optional().default('elevenlabs'),
12
+ instruction: z.string().optional(),
13
+ count: z.number().optional().default(4),
14
+ }, async ({ file, brand, instruction, count }) => {
15
+ track('mcp:generate_variations', { file, brand, count });
16
+ const projectRoot = process.env.GLYPH_PROJECT_ROOT || process.cwd();
17
+ const filePath = path.resolve(projectRoot, file);
18
+ let fileContent;
19
+ try {
20
+ fileContent = await fs.readFile(filePath, 'utf-8');
21
+ }
22
+ catch {
23
+ return {
24
+ content: [{ type: 'text', text: `Error: Could not read file at ${filePath}` }],
25
+ };
26
+ }
27
+ // Check if brand reference exists
28
+ if (!isValidBrand(brand)) {
29
+ return {
30
+ content: [{ type: 'text', text: `Error: Unknown brand "${brand}". Available: ${['apple', 'arc', 'claude', 'elevenlabs', 'linear', 'notion', 'raycast', 'stripe', 'vercel'].join(', ')}` }],
31
+ };
32
+ }
33
+ // Scan design system for context
34
+ let designSystemContext;
35
+ let projectTokens;
36
+ try {
37
+ const scanResult = await scanDesignSystem(projectRoot);
38
+ projectTokens = scanResult.structured;
39
+ designSystemContext = scanResult.raw;
40
+ }
41
+ catch {
42
+ // non-fatal — proceed without design system context
43
+ }
44
+ const brief = await buildDesignBrief({
45
+ fileContent,
46
+ filePath: file,
47
+ brand,
48
+ instruction,
49
+ count,
50
+ designSystemContext,
51
+ projectTokens,
52
+ });
53
+ return {
54
+ content: [{ type: 'text', text: brief }],
55
+ };
56
+ });
57
+ }
58
+ //# sourceMappingURL=generate-variations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-variations.js","sourceRoot":"","sources":["../../../src/mcp/tools/generate-variations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,IAAI,CACT,qBAAqB,EACrB,uGAAuG,EACvG;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;QAClD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;KACxC,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE;QAC5C,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI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C;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAllTools(server: McpServer): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAKxD"}
@@ -0,0 +1,11 @@
1
+ import { registerGenerateVariations } from './generate-variations.js';
2
+ import { registerSubmitVariations } from './submit-variations.js';
3
+ import { registerApplyVariation } from './apply-variation.js';
4
+ import { registerScanDesignSystem } from './scan-design-system.js';
5
+ export function registerAllTools(server) {
6
+ registerGenerateVariations(server);
7
+ registerSubmitVariations(server);
8
+ registerApplyVariation(server);
9
+ registerScanDesignSystem(server);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,wBAAwB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerScanDesignSystem(server: McpServer): void;
3
+ //# sourceMappingURL=scan-design-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-design-system.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/scan-design-system.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0BhE"}
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { scanDesignSystem } from '../../context/design-system.js';
3
+ import { track } from '../../telemetry.js';
4
+ import { renderProjectTokens } from '../../context/token-template.js';
5
+ export function registerScanDesignSystem(server) {
6
+ server.tool('scan_design_system', 'Scan a project for design tokens including Tailwind config, CSS custom properties, and token files. Returns tokens organized by semantic role (colors, typography, spacing, etc.)', {
7
+ project_root: z.string().optional(),
8
+ }, async ({ project_root }) => {
9
+ const root = project_root || process.env.GLYPH_PROJECT_ROOT || process.cwd();
10
+ track('mcp:scan_design_system', { projectRoot: root });
11
+ try {
12
+ const { structured, raw } = await scanDesignSystem(root);
13
+ const structuredOutput = renderProjectTokens(structured);
14
+ const output = `${structuredOutput}\n\n---\n\n## Raw Scan Output\n${raw}`;
15
+ return {
16
+ content: [{ type: 'text', text: output }],
17
+ };
18
+ }
19
+ catch (err) {
20
+ const message = err instanceof Error ? err.message : String(err);
21
+ return {
22
+ content: [{ type: 'text', text: `Error scanning design system: ${message}` }],
23
+ };
24
+ }
25
+ });
26
+ }
27
+ //# sourceMappingURL=scan-design-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-design-system.js","sourceRoot":"","sources":["../../../src/mcp/tools/scan-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,UAAU,wBAAwB,CAAC,MAAiB;IACxD,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,mLAAmL,EACnL;QACE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACpC,EACD,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7E,KAAK,CAAC,wBAAwB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvD,IAAI,CAAC;YACH,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACzD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,GAAG,gBAAgB,kCAAkC,GAAG,EAAE,CAAC;YAC1E,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;aACnD,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,iCAAiC,OAAO,EAAE,EAAE,CAAC;aACvF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerSubmitVariations(server: McpServer): void;
3
+ //# sourceMappingURL=submit-variations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit-variations.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/submit-variations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAqDhE"}
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { track } from '../../telemetry.js';
3
+ const GLYPH_PORT = process.env.GLYPH_PORT || '3001';
4
+ export function registerSubmitVariations(server) {
5
+ server.tool('submit_variations', 'Submit generated UI variations to the Glyph server for preview in the overlay', {
6
+ source_file: z.string(),
7
+ variations: z.array(z.object({
8
+ id: z.string(),
9
+ code: z.string(),
10
+ })),
11
+ }, async ({ source_file, variations }) => {
12
+ track('mcp:submit_variations', { file: source_file, variationCount: variations.length });
13
+ try {
14
+ const response = await fetch(`http://localhost:${GLYPH_PORT}/api/variations`, {
15
+ method: 'POST',
16
+ headers: { 'Content-Type': 'application/json' },
17
+ body: JSON.stringify({ sourceFile: source_file, variations }),
18
+ });
19
+ if (!response.ok) {
20
+ const text = await response.text();
21
+ return {
22
+ content: [{ type: 'text', text: `Error submitting variations: ${response.status} ${text}` }],
23
+ };
24
+ }
25
+ const data = (await response.json());
26
+ const urlList = Object.entries(data.previewUrls || {})
27
+ .map(([id, url]) => ` ${id}: http://localhost:${GLYPH_PORT}${url}`)
28
+ .join('\n');
29
+ return {
30
+ content: [
31
+ {
32
+ type: 'text',
33
+ text: `Successfully submitted ${variations.length} variations for ${source_file}.\nSession ID: ${data.sessionId}\nThe variations are now visible in the Glyph preview panel in the user's browser. They can click thumbnails to preview via HMR and click "Implement" to keep their favorite.\n\nPreview URLs:\n${urlList}`,
34
+ },
35
+ ],
36
+ };
37
+ }
38
+ catch (err) {
39
+ return {
40
+ content: [
41
+ {
42
+ type: 'text',
43
+ text: `Error: Could not connect to Glyph server at localhost:${GLYPH_PORT}. Is the server running?`,
44
+ },
45
+ ],
46
+ };
47
+ }
48
+ });
49
+ }
50
+ //# sourceMappingURL=submit-variations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit-variations.js","sourceRoot":"","sources":["../../../src/mcp/tools/submit-variations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC;AAEpD,MAAM,UAAU,wBAAwB,CAAC,MAAiB;IACxD,MAAM,CAAC,IAAI,CACT,mBAAmB,EACnB,+EAA+E,EAC/E;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,UAAU,EAAE,CAAC,CAAC,KAAK,CACjB,CAAC,CAAC,MAAM,CAAC;YACP,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACjB,CAAC,CACH;KACF,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;QACpC,KAAK,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,oBAAoB,UAAU,iBAAiB,EAAE;gBAC5E,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;aAC9D,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,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