sonance-brand-mcp 1.3.50 → 1.3.51

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.
@@ -3,6 +3,7 @@ import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import Anthropic from "@anthropic-ai/sdk";
5
5
  import { randomUUID } from "crypto";
6
+ import { discoverTheme, formatThemeForPrompt } from "./theme-discovery";
6
7
 
7
8
  /**
8
9
  * Sonance DevTools API - Apply-First Vision Mode
@@ -471,10 +472,47 @@ Return search/replace patches (NOT full files). The system applies your patches
471
472
  - CRITICAL: NEVER invent or guess code. Your "search" string MUST be copied EXACTLY from the provided file content. If you cannot find the exact code to modify, return an empty modifications array.
472
473
  - If the file content appears truncated, only modify code that is visible in the provided content.
473
474
 
474
- **SONANCE BRAND COLORS:**
475
- - Charcoal: #333F48 (primary text)
476
- - IPORT Orange: #FC4C02
477
- - Blaze Blue: #00A3E1
475
+ ═══════════════════════════════════════════════════════════════════════════════
476
+ SONANCE BRAND COLOR SYSTEM
477
+ ═══════════════════════════════════════════════════════════════════════════════
478
+
479
+ **Core Colors:**
480
+ - Primary (Charcoal): #333F48 - main text, dark backgrounds
481
+ - Accent (Cyan "The Beam"): #00D3C8 - highlights, interactive elements, CTAs
482
+ - Success: Green tones - positive states, confirmations
483
+ - Warning: Amber/Orange tones - caution states, alerts
484
+ - Destructive: Red tones - errors, delete actions
485
+
486
+ **CRITICAL CONTRAST RULES:**
487
+ When using colored backgrounds, ALWAYS use high-contrast text:
488
+
489
+ | Background | Use This Text | NEVER Use |
490
+ |-------------------|------------------------------------|-----------------------|
491
+ | bg-accent | text-white | text-accent-foreground |
492
+ | bg-primary | text-primary-foreground, text-white | text-primary |
493
+ | bg-success | text-white | text-success |
494
+ | bg-warning | text-white | text-warning |
495
+ | bg-destructive | text-white | text-destructive |
496
+
497
+ **SEMANTIC TOKEN PATTERNS:**
498
+ - text-{color} = the color itself (use on NEUTRAL backgrounds like white/gray)
499
+ - text-{color}-foreground = INTENDED for text on {color} backgrounds, but MAY have contrast issues
500
+ - bg-{color} = background in that color
501
+ - WHEN IN DOUBT: Use text-white on any colored background for guaranteed contrast
502
+
503
+ **BUTTON PATTERNS (Sonance Standard):**
504
+ - Primary CTA: bg-primary text-primary-foreground
505
+ - Accent/Highlight: bg-accent text-white (NOT text-accent-foreground)
506
+ - Success: bg-success text-white
507
+ - Warning: bg-warning text-white
508
+ - Destructive: bg-destructive text-white
509
+ - Outlined: border-border bg-transparent text-foreground
510
+
511
+ **COMMON MISTAKES TO AVOID:**
512
+ - WRONG: bg-accent text-accent-foreground (accent-foreground is often dark = invisible text)
513
+ - RIGHT: bg-accent text-white (white text on cyan = visible)
514
+ - WRONG: bg-primary text-primary (same color = invisible)
515
+ - RIGHT: bg-primary text-primary-foreground OR text-white
478
516
 
479
517
  **RESPONSE FORMAT:**
480
518
  CRITICAL: Return ONLY the JSON object below. Do NOT include any text, explanation, or thinking before or after the JSON. No preamble. No "Looking at the screenshot..." No markdown code blocks. Just raw JSON:
@@ -666,7 +704,7 @@ export async function POST(request: Request) {
666
704
  const TOTAL_CONTEXT_BUDGET = 500000; // 500k chars total budget
667
705
  const MAX_RECOMMENDED_FILE = Infinity; // NEVER truncate the target file - AI needs full context
668
706
  const MAX_PAGE_FILE = 2000; // Page file is just a wrapper
669
- const MAX_GLOBALS_CSS = 1500;
707
+ const MAX_GLOBALS_CSS = 15000; // Increased to capture full theme definitions
670
708
  const MAX_FILES = 25;
671
709
 
672
710
  let usedContext = 0;
@@ -760,6 +798,25 @@ ${truncatedContent}${wasTruncated ? "\n// ... (truncated)" : ""}
760
798
  }
761
799
  }
762
800
 
801
+ // ========== THEME DISCOVERY ==========
802
+ // Dynamically discover theme tokens from the target codebase
803
+ const discoveredTheme = await discoverTheme(projectRoot);
804
+ const themeContext = formatThemeForPrompt(discoveredTheme);
805
+
806
+ if (discoveredTheme.discoveredFiles.length > 0) {
807
+ textContent += `
808
+ ═══════════════════════════════════════════════════════════════════════════════
809
+ ${themeContext}
810
+ ═══════════════════════════════════════════════════════════════════════════════
811
+
812
+ `;
813
+ debugLog("Theme discovery complete", {
814
+ filesFound: discoveredTheme.discoveredFiles,
815
+ cssVariableCount: Object.keys(discoveredTheme.cssVariables).length,
816
+ tailwindColorCount: Object.keys(discoveredTheme.tailwindColors).length,
817
+ });
818
+ }
819
+
763
820
  // ========== GLOBALS CSS ==========
764
821
  const globalsTruncated = pageContext.globalsCSS.substring(0, MAX_GLOBALS_CSS);
765
822
  textContent += `
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import Anthropic from "@anthropic-ai/sdk";
5
+ import { discoverTheme, formatThemeForPrompt } from "../sonance-vision-apply/theme-discovery";
5
6
 
6
7
  /**
7
8
  * Sonance DevTools API - Vision Mode Editor
@@ -469,10 +470,47 @@ Return search/replace patches (NOT full files). The system applies your patches
469
470
  - CRITICAL: NEVER invent or guess code. Your "search" string MUST be copied EXACTLY from the provided file content. If you cannot find the exact code to modify, return an empty modifications array.
470
471
  - If the file content appears truncated, only modify code that is visible in the provided content.
471
472
 
472
- **SONANCE BRAND COLORS:**
473
- - Charcoal: #333F48 (primary text)
474
- - IPORT Orange: #FC4C02
475
- - Blaze Blue: #00A3E1
473
+ ═══════════════════════════════════════════════════════════════════════════════
474
+ SONANCE BRAND COLOR SYSTEM
475
+ ═══════════════════════════════════════════════════════════════════════════════
476
+
477
+ **Core Colors:**
478
+ - Primary (Charcoal): #333F48 - main text, dark backgrounds
479
+ - Accent (Cyan "The Beam"): #00D3C8 - highlights, interactive elements, CTAs
480
+ - Success: Green tones - positive states, confirmations
481
+ - Warning: Amber/Orange tones - caution states, alerts
482
+ - Destructive: Red tones - errors, delete actions
483
+
484
+ **CRITICAL CONTRAST RULES:**
485
+ When using colored backgrounds, ALWAYS use high-contrast text:
486
+
487
+ | Background | Use This Text | NEVER Use |
488
+ |-------------------|------------------------------------|-----------------------|
489
+ | bg-accent | text-white | text-accent-foreground |
490
+ | bg-primary | text-primary-foreground, text-white | text-primary |
491
+ | bg-success | text-white | text-success |
492
+ | bg-warning | text-white | text-warning |
493
+ | bg-destructive | text-white | text-destructive |
494
+
495
+ **SEMANTIC TOKEN PATTERNS:**
496
+ - text-{color} = the color itself (use on NEUTRAL backgrounds like white/gray)
497
+ - text-{color}-foreground = INTENDED for text on {color} backgrounds, but MAY have contrast issues
498
+ - bg-{color} = background in that color
499
+ - WHEN IN DOUBT: Use text-white on any colored background for guaranteed contrast
500
+
501
+ **BUTTON PATTERNS (Sonance Standard):**
502
+ - Primary CTA: bg-primary text-primary-foreground
503
+ - Accent/Highlight: bg-accent text-white (NOT text-accent-foreground)
504
+ - Success: bg-success text-white
505
+ - Warning: bg-warning text-white
506
+ - Destructive: bg-destructive text-white
507
+ - Outlined: border-border bg-transparent text-foreground
508
+
509
+ **COMMON MISTAKES TO AVOID:**
510
+ - WRONG: bg-accent text-accent-foreground (accent-foreground is often dark = invisible text)
511
+ - RIGHT: bg-accent text-white (white text on cyan = visible)
512
+ - WRONG: bg-primary text-primary (same color = invisible)
513
+ - RIGHT: bg-primary text-primary-foreground OR text-white
476
514
 
477
515
  **RESPONSE FORMAT:**
478
516
  CRITICAL: Return ONLY the JSON object below. Do NOT include any text, explanation, or thinking before or after the JSON. No preamble. No "Looking at the screenshot..." No markdown code blocks. Just raw JSON:
@@ -675,7 +713,7 @@ export async function POST(request: Request) {
675
713
  const TOTAL_CONTEXT_BUDGET = 500000; // 500k chars total budget
676
714
  const MAX_RECOMMENDED_FILE = Infinity; // NEVER truncate the target file - AI needs full context
677
715
  const MAX_PAGE_FILE = 2000; // Page file is just a wrapper
678
- const MAX_GLOBALS_CSS = 1500;
716
+ const MAX_GLOBALS_CSS = 15000; // Increased to capture full theme definitions
679
717
  const MAX_FILES = 25;
680
718
 
681
719
  let usedContext = 0;
@@ -769,6 +807,25 @@ ${truncatedContent}${wasTruncated ? "\n// ... (truncated)" : ""}
769
807
  }
770
808
  }
771
809
 
810
+ // ========== THEME DISCOVERY ==========
811
+ // Dynamically discover theme tokens from the target codebase
812
+ const discoveredTheme = await discoverTheme(projectRoot);
813
+ const themeContext = formatThemeForPrompt(discoveredTheme);
814
+
815
+ if (discoveredTheme.discoveredFiles.length > 0) {
816
+ textContent += `
817
+ ═══════════════════════════════════════════════════════════════════════════════
818
+ ${themeContext}
819
+ ═══════════════════════════════════════════════════════════════════════════════
820
+
821
+ `;
822
+ debugLog("Theme discovery complete", {
823
+ filesFound: discoveredTheme.discoveredFiles,
824
+ cssVariableCount: Object.keys(discoveredTheme.cssVariables).length,
825
+ tailwindColorCount: Object.keys(discoveredTheme.tailwindColors).length,
826
+ });
827
+ }
828
+
772
829
  // ========== GLOBALS CSS ==========
773
830
  const globalsTruncated = pageContext.globalsCSS.substring(0, MAX_GLOBALS_CSS);
774
831
  textContent += `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.50",
3
+ "version": "1.3.51",
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",