sonance-brand-mcp 1.3.97 → 1.3.98

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.
@@ -1341,6 +1341,85 @@ Output format:
1341
1341
 
1342
1342
  The "search" field must match the file EXACTLY (copy-paste from the code provided).`;
1343
1343
 
1344
+ /**
1345
+ * DESIGN REASONING PROMPT
1346
+ * Forces the LLM through a structured analysis before making design changes.
1347
+ * This prevents over-engineering and ensures thoughtful, targeted modifications.
1348
+ */
1349
+ const DESIGN_REASONING_PROMPT = `
1350
+ ═══════════════════════════════════════════════════════════════════════════════
1351
+ DESIGN REASONING PROTOCOL (Follow BEFORE generating patches)
1352
+ ═══════════════════════════════════════════════════════════════════════════════
1353
+
1354
+ STEP 1 - VISUAL ANALYSIS:
1355
+ Before making any changes, analyze the current UI in the screenshot:
1356
+ • What type of component is this? (form wizard, modal, card, data table, sidebar, etc.)
1357
+ • What is currently working well that should be PRESERVED?
1358
+ • What specific visual issues exist? (inconsistent spacing, unclear hierarchy, alignment problems, clutter)
1359
+
1360
+ STEP 2 - MINIMAL CHANGE PLAN:
1361
+ Identify the MINIMUM changes needed to address the user's request:
1362
+ • What 1-3 targeted fixes would solve the issue?
1363
+ • What should you explicitly NOT change?
1364
+ • Will these changes break existing functionality or visual balance?
1365
+
1366
+ STEP 3 - GUARDRAILS CHECK:
1367
+ Before implementing, verify you are following these rules:
1368
+ • Am I preserving the existing layout structure? (flex stays flex, grid stays grid)
1369
+ • Am I keeping the existing color palette unless specifically asked to change it?
1370
+ • Am I making incremental improvements, NOT a complete restructure?
1371
+ • Am I keeping the same visual hierarchy and element positions?
1372
+
1373
+ STEP 4 - IMPLEMENT:
1374
+ Only now generate patches for the targeted changes from Step 2.
1375
+ Each patch should be small and focused - prefer multiple small patches over one large rewrite.
1376
+ `;
1377
+
1378
+ /**
1379
+ * DESIGN GUARDRAILS
1380
+ * Explicit constraints to prevent the LLM from over-engineering design changes.
1381
+ */
1382
+ const DESIGN_GUARDRAILS = `
1383
+ ═══════════════════════════════════════════════════════════════════════════════
1384
+ DESIGN GUARDRAILS (MUST FOLLOW)
1385
+ ═══════════════════════════════════════════════════════════════════════════════
1386
+
1387
+ ❌ DO NOT:
1388
+ • Convert layout systems (do NOT change flex to grid or vice versa)
1389
+ • Restructure component hierarchy unless explicitly asked
1390
+ • Change color schemes unless specifically requested
1391
+ • Move elements to different positions unless asked
1392
+ • Rewrite entire sections - make targeted changes only
1393
+ • Add new wrapper elements or change semantic structure
1394
+
1395
+ ✓ DO:
1396
+ • Focus on spacing, padding, and margins for "cleaner" requests
1397
+ • Improve typography (font size, weight, line-height) for readability
1398
+ • Fix alignment issues within the existing structure
1399
+ • Adjust visual hierarchy through subtle styling, not restructuring
1400
+ • Make the smallest change that addresses the user's request
1401
+ • Preserve what is already working well
1402
+ `;
1403
+
1404
+ /**
1405
+ * Detect if a user request is design-heavy and needs the reasoning protocol.
1406
+ * Simple requests like "change button color to blue" don't need it.
1407
+ */
1408
+ function isDesignHeavyRequest(userPrompt: string): boolean {
1409
+ const designKeywords = [
1410
+ 'redesign', 'design', 'layout', 'improve', 'better', 'modernize', 'modern',
1411
+ 'cleaner', 'clean', 'messy', 'cluttered', 'update look', 'looks bad',
1412
+ 'ugly', 'prettier', 'beautiful', 'professional', 'polish', 'refine',
1413
+ 'restructure', 'reorganize', 'rearrange', 'simplify', 'streamline',
1414
+ 'compact', 'spacious', 'breathing room', 'visual', 'aesthetic',
1415
+ 'ux', 'user experience', 'ui', 'user interface', 'make it look',
1416
+ 'looks weird', 'not right', 'fix the look', 'appearance'
1417
+ ];
1418
+
1419
+ const lowerPrompt = userPrompt.toLowerCase();
1420
+ return designKeywords.some(keyword => lowerPrompt.includes(keyword));
1421
+ }
1422
+
1344
1423
  export async function POST(request: Request) {
1345
1424
  // Only allow in development
1346
1425
  if (process.env.NODE_ENV !== "development") {
@@ -1748,6 +1827,23 @@ User Request: "${userPrompt}"
1748
1827
 
1749
1828
  `;
1750
1829
 
1830
+ // ========== DESIGN REASONING PROTOCOL ==========
1831
+ // For design-heavy requests, add structured reasoning and guardrails
1832
+ // This prevents over-engineering and ensures thoughtful changes
1833
+ const isDesignRequest = isDesignHeavyRequest(userPrompt || '');
1834
+
1835
+ if (isDesignRequest) {
1836
+ debugLog("Design-heavy request detected, adding reasoning protocol", {
1837
+ prompt: userPrompt?.substring(0, 50),
1838
+ triggerKeywords: ['redesign', 'better', 'improve', 'cleaner', 'layout', 'modernize']
1839
+ .filter(k => userPrompt?.toLowerCase().includes(k))
1840
+ });
1841
+
1842
+ textContent += DESIGN_REASONING_PROMPT;
1843
+ textContent += DESIGN_GUARDRAILS;
1844
+ textContent += '\n';
1845
+ }
1846
+
1751
1847
  // ========== TARGET COMPONENT ONLY (with line numbers) ==========
1752
1848
  // CRITICAL: Only include the TARGET file to avoid overwhelming the LLM with noise
1753
1849
  if (recommendedFileContent) {
@@ -1337,6 +1337,85 @@ Output format:
1337
1337
 
1338
1338
  The "search" field must match the file EXACTLY (copy-paste from the code provided).`;
1339
1339
 
1340
+ /**
1341
+ * DESIGN REASONING PROMPT
1342
+ * Forces the LLM through a structured analysis before making design changes.
1343
+ * This prevents over-engineering and ensures thoughtful, targeted modifications.
1344
+ */
1345
+ const DESIGN_REASONING_PROMPT = `
1346
+ ═══════════════════════════════════════════════════════════════════════════════
1347
+ DESIGN REASONING PROTOCOL (Follow BEFORE generating patches)
1348
+ ═══════════════════════════════════════════════════════════════════════════════
1349
+
1350
+ STEP 1 - VISUAL ANALYSIS:
1351
+ Before making any changes, analyze the current UI in the screenshot:
1352
+ • What type of component is this? (form wizard, modal, card, data table, sidebar, etc.)
1353
+ • What is currently working well that should be PRESERVED?
1354
+ • What specific visual issues exist? (inconsistent spacing, unclear hierarchy, alignment problems, clutter)
1355
+
1356
+ STEP 2 - MINIMAL CHANGE PLAN:
1357
+ Identify the MINIMUM changes needed to address the user's request:
1358
+ • What 1-3 targeted fixes would solve the issue?
1359
+ • What should you explicitly NOT change?
1360
+ • Will these changes break existing functionality or visual balance?
1361
+
1362
+ STEP 3 - GUARDRAILS CHECK:
1363
+ Before implementing, verify you are following these rules:
1364
+ • Am I preserving the existing layout structure? (flex stays flex, grid stays grid)
1365
+ • Am I keeping the existing color palette unless specifically asked to change it?
1366
+ • Am I making incremental improvements, NOT a complete restructure?
1367
+ • Am I keeping the same visual hierarchy and element positions?
1368
+
1369
+ STEP 4 - IMPLEMENT:
1370
+ Only now generate patches for the targeted changes from Step 2.
1371
+ Each patch should be small and focused - prefer multiple small patches over one large rewrite.
1372
+ `;
1373
+
1374
+ /**
1375
+ * DESIGN GUARDRAILS
1376
+ * Explicit constraints to prevent the LLM from over-engineering design changes.
1377
+ */
1378
+ const DESIGN_GUARDRAILS = `
1379
+ ═══════════════════════════════════════════════════════════════════════════════
1380
+ DESIGN GUARDRAILS (MUST FOLLOW)
1381
+ ═══════════════════════════════════════════════════════════════════════════════
1382
+
1383
+ ❌ DO NOT:
1384
+ • Convert layout systems (do NOT change flex to grid or vice versa)
1385
+ • Restructure component hierarchy unless explicitly asked
1386
+ • Change color schemes unless specifically requested
1387
+ • Move elements to different positions unless asked
1388
+ • Rewrite entire sections - make targeted changes only
1389
+ • Add new wrapper elements or change semantic structure
1390
+
1391
+ ✓ DO:
1392
+ • Focus on spacing, padding, and margins for "cleaner" requests
1393
+ • Improve typography (font size, weight, line-height) for readability
1394
+ • Fix alignment issues within the existing structure
1395
+ • Adjust visual hierarchy through subtle styling, not restructuring
1396
+ • Make the smallest change that addresses the user's request
1397
+ • Preserve what is already working well
1398
+ `;
1399
+
1400
+ /**
1401
+ * Detect if a user request is design-heavy and needs the reasoning protocol.
1402
+ * Simple requests like "change button color to blue" don't need it.
1403
+ */
1404
+ function isDesignHeavyRequest(userPrompt: string): boolean {
1405
+ const designKeywords = [
1406
+ 'redesign', 'design', 'layout', 'improve', 'better', 'modernize', 'modern',
1407
+ 'cleaner', 'clean', 'messy', 'cluttered', 'update look', 'looks bad',
1408
+ 'ugly', 'prettier', 'beautiful', 'professional', 'polish', 'refine',
1409
+ 'restructure', 'reorganize', 'rearrange', 'simplify', 'streamline',
1410
+ 'compact', 'spacious', 'breathing room', 'visual', 'aesthetic',
1411
+ 'ux', 'user experience', 'ui', 'user interface', 'make it look',
1412
+ 'looks weird', 'not right', 'fix the look', 'appearance'
1413
+ ];
1414
+
1415
+ const lowerPrompt = userPrompt.toLowerCase();
1416
+ return designKeywords.some(keyword => lowerPrompt.includes(keyword));
1417
+ }
1418
+
1340
1419
  export async function POST(request: Request) {
1341
1420
  // Only allow in development
1342
1421
  if (process.env.NODE_ENV !== "development") {
@@ -1717,6 +1796,23 @@ User Request: "${userPrompt}"
1717
1796
 
1718
1797
  `;
1719
1798
 
1799
+ // ========== DESIGN REASONING PROTOCOL ==========
1800
+ // For design-heavy requests, add structured reasoning and guardrails
1801
+ // This prevents over-engineering and ensures thoughtful changes
1802
+ const isDesignRequest = isDesignHeavyRequest(userPrompt || '');
1803
+
1804
+ if (isDesignRequest) {
1805
+ debugLog("Design-heavy request detected, adding reasoning protocol", {
1806
+ prompt: userPrompt?.substring(0, 50),
1807
+ triggerKeywords: ['redesign', 'better', 'improve', 'cleaner', 'layout', 'modernize']
1808
+ .filter(k => userPrompt?.toLowerCase().includes(k))
1809
+ });
1810
+
1811
+ textContent += DESIGN_REASONING_PROMPT;
1812
+ textContent += DESIGN_GUARDRAILS;
1813
+ textContent += '\n';
1814
+ }
1815
+
1720
1816
  // ========== TARGET COMPONENT ONLY (with line numbers) ==========
1721
1817
  // CRITICAL: Only include the TARGET file to avoid overwhelming the LLM with noise
1722
1818
  if (recommendedFileContent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.97",
3
+ "version": "1.3.98",
4
4
  "description": "MCP Server for Sonance Brand Guidelines and Component Library - gives Claude instant access to brand colors, typography, and UI components.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",