sonance-brand-mcp 1.3.101 → 1.3.102

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.
@@ -1519,53 +1519,37 @@ function buildPhase2DesignPrompt(problems: DesignProblem[]): string {
1519
1519
  return ''; // No problems identified, skip design protocol
1520
1520
  }
1521
1521
 
1522
- const problemsJson = JSON.stringify(problems, null, 2);
1522
+ // Create a simple, readable list of problems (no JSON complexity)
1523
+ const problemsList = problems.map(p => `• ${p.description}`).join('\n');
1523
1524
 
1524
1525
  return `
1525
1526
  ═══════════════════════════════════════════════════════════════════════════════
1526
- PHASE 2: TARGETED PATCH GENERATION
1527
+ DESIGN ISSUES TO FIX
1527
1528
  ═══════════════════════════════════════════════════════════════════════════════
1528
1529
 
1529
- A visual analysis identified these specific problems in the UI:
1530
+ These visual issues were identified:
1531
+ ${problemsList}
1530
1532
 
1531
- ${problemsJson}
1533
+ Fix these issues by modifying the code below.
1532
1534
 
1533
- YOUR TASK: Generate patches that fix ONLY these specific problems.
1535
+ ⚠️ CRITICAL - EXACT CODE MATCHING:
1536
+ Your "search" string MUST be copied CHARACTER-FOR-CHARACTER from the file.
1537
+ Use the line numbers on the left to find the exact code.
1534
1538
 
1535
- STRICT RULES:
1536
- 1. Each patch MUST include a "problemId" field referencing one of the problems above
1537
- 2. Do NOT make changes unrelated to the identified problems
1538
- 3. Make the SMALLEST change that fixes each problem
1539
- 4. Do NOT change layout systems (flex→grid) unless absolutely necessary to fix a problem
1540
- 5. Preserve existing structure - adjust properties, don't restructure
1539
+ EXAMPLE:
1540
+ If line 42 shows: 42| <div className="mt-6 flex items-center">
1541
+ Your search must be: <div className="mt-6 flex items-center">
1541
1542
 
1542
- For each problem, find the exact code that causes it and create a targeted fix.
1543
+ DO NOT:
1544
+ - Combine multiple lines into one search string
1545
+ - Add or remove classes/attributes
1546
+ - Invent code that "should" exist
1547
+ - Guess at the structure
1543
1548
 
1544
- OUTPUT FORMAT (note the problemId and rationale fields):
1545
- {
1546
- "modifications": [{
1547
- "filePath": "components/Example.tsx",
1548
- "patches": [
1549
- {
1550
- "problemId": "grouping-1",
1551
- "search": "<Badge className=\"absolute right-4\">",
1552
- "replace": "<Badge className=\"ml-2\">",
1553
- "rationale": "Removes absolute positioning to group badge with label"
1554
- },
1555
- {
1556
- "problemId": "spacing-1",
1557
- "search": "className=\"mt-8\"",
1558
- "replace": "className=\"mt-4\"",
1559
- "rationale": "Reduces excessive vertical gap"
1560
- }
1561
- ]
1562
- }]
1563
- }
1564
-
1565
- VALIDATION:
1566
- - Patches without a valid problemId will be REJECTED
1567
- - Patches that don't trace to an identified problem will be REJECTED
1568
- - Each patch must have search, replace, problemId, and rationale fields
1549
+ DO:
1550
+ - Copy the exact text from the numbered lines
1551
+ - Make small, targeted changes in the "replace" field
1552
+ - Keep patches focused on one change each
1569
1553
  `;
1570
1554
  }
1571
1555
 
@@ -2664,36 +2648,17 @@ This is better than generating patches with made-up code.`,
2664
2648
  // New patch-based approach
2665
2649
  console.log(`[Apply-First] Applying ${mod.patches.length} patches to ${mod.filePath}`);
2666
2650
 
2667
- // DESIGN VALIDATION: For design-heavy requests, validate patches have problemIds
2668
- let patchesToApply = mod.patches;
2651
+ // Use patches directly - simplified approach focuses on exact code matching
2652
+ // rather than problemId validation (which was causing LLM to prioritize
2653
+ // problem-solving over exact code copying)
2654
+ const patchesToApply = mod.patches;
2655
+
2669
2656
  if (isDesignRequest && identifiedProblems.length > 0) {
2670
- const validationResult = validateDesignPatches(mod.patches, identifiedProblems);
2671
-
2672
- if (validationResult.rejected.length > 0) {
2673
- debugLog("Design patch validation rejected some patches", {
2674
- filePath: mod.filePath,
2675
- validCount: validationResult.valid.length,
2676
- rejectedCount: validationResult.rejected.length,
2677
- rejectedReasons: validationResult.rejected.map(r => r.reason)
2678
- });
2679
- console.warn(`[Apply-First] ${validationResult.rejected.length} patches rejected for missing/invalid problemId`);
2680
- }
2681
-
2682
- // Only use validated patches
2683
- if (validationResult.valid.length === 0) {
2684
- patchErrors.push(`${mod.filePath}: All patches were rejected - they don't reference identified problems`);
2685
- continue;
2686
- }
2687
-
2688
- // Log which problems are being fixed
2689
- const problemsBeingFixed = [...new Set(validationResult.valid.map(p => p.problemId))];
2690
- debugLog("Design patches validated", {
2657
+ debugLog("Design patches received", {
2691
2658
  filePath: mod.filePath,
2692
- problemsBeingFixed,
2693
- patchCount: validationResult.valid.length
2659
+ patchCount: patchesToApply.length,
2660
+ problemsIdentified: identifiedProblems.length
2694
2661
  });
2695
-
2696
- patchesToApply = validationResult.valid;
2697
2662
  }
2698
2663
 
2699
2664
  // PRE-VALIDATION: Check if all search strings exist in the file BEFORE applying
@@ -1515,53 +1515,37 @@ function buildPhase2DesignPrompt(problems: DesignProblem[]): string {
1515
1515
  return ''; // No problems identified, skip design protocol
1516
1516
  }
1517
1517
 
1518
- const problemsJson = JSON.stringify(problems, null, 2);
1518
+ // Create a simple, readable list of problems (no JSON complexity)
1519
+ const problemsList = problems.map(p => `• ${p.description}`).join('\n');
1519
1520
 
1520
1521
  return `
1521
1522
  ═══════════════════════════════════════════════════════════════════════════════
1522
- PHASE 2: TARGETED PATCH GENERATION
1523
+ DESIGN ISSUES TO FIX
1523
1524
  ═══════════════════════════════════════════════════════════════════════════════
1524
1525
 
1525
- A visual analysis identified these specific problems in the UI:
1526
+ These visual issues were identified:
1527
+ ${problemsList}
1526
1528
 
1527
- ${problemsJson}
1529
+ Fix these issues by modifying the code below.
1528
1530
 
1529
- YOUR TASK: Generate patches that fix ONLY these specific problems.
1531
+ ⚠️ CRITICAL - EXACT CODE MATCHING:
1532
+ Your "search" string MUST be copied CHARACTER-FOR-CHARACTER from the file.
1533
+ Use the line numbers on the left to find the exact code.
1530
1534
 
1531
- STRICT RULES:
1532
- 1. Each patch MUST include a "problemId" field referencing one of the problems above
1533
- 2. Do NOT make changes unrelated to the identified problems
1534
- 3. Make the SMALLEST change that fixes each problem
1535
- 4. Do NOT change layout systems (flex→grid) unless absolutely necessary to fix a problem
1536
- 5. Preserve existing structure - adjust properties, don't restructure
1535
+ EXAMPLE:
1536
+ If line 42 shows: 42| <div className="mt-6 flex items-center">
1537
+ Your search must be: <div className="mt-6 flex items-center">
1537
1538
 
1538
- For each problem, find the exact code that causes it and create a targeted fix.
1539
+ DO NOT:
1540
+ - Combine multiple lines into one search string
1541
+ - Add or remove classes/attributes
1542
+ - Invent code that "should" exist
1543
+ - Guess at the structure
1539
1544
 
1540
- OUTPUT FORMAT (note the problemId and rationale fields):
1541
- {
1542
- "modifications": [{
1543
- "filePath": "components/Example.tsx",
1544
- "patches": [
1545
- {
1546
- "problemId": "grouping-1",
1547
- "search": "<Badge className=\"absolute right-4\">",
1548
- "replace": "<Badge className=\"ml-2\">",
1549
- "rationale": "Removes absolute positioning to group badge with label"
1550
- },
1551
- {
1552
- "problemId": "spacing-1",
1553
- "search": "className=\"mt-8\"",
1554
- "replace": "className=\"mt-4\"",
1555
- "rationale": "Reduces excessive vertical gap"
1556
- }
1557
- ]
1558
- }]
1559
- }
1560
-
1561
- VALIDATION:
1562
- - Patches without a valid problemId will be REJECTED
1563
- - Patches that don't trace to an identified problem will be REJECTED
1564
- - Each patch must have search, replace, problemId, and rationale fields
1545
+ DO:
1546
+ - Copy the exact text from the numbered lines
1547
+ - Make small, targeted changes in the "replace" field
1548
+ - Keep patches focused on one change each
1565
1549
  `;
1566
1550
  }
1567
1551
 
@@ -2632,41 +2616,17 @@ This is better than generating patches with made-up code.`,
2632
2616
  // New patch-based approach
2633
2617
  console.log(`[Vision Mode] Applying ${mod.patches.length} patches to ${mod.filePath}`);
2634
2618
 
2635
- // DESIGN VALIDATION: For design-heavy requests, validate patches have problemIds
2636
- let patchesToApply = mod.patches;
2619
+ // Use patches directly - simplified approach focuses on exact code matching
2620
+ // rather than problemId validation (which was causing LLM to prioritize
2621
+ // problem-solving over exact code copying)
2622
+ const patchesToApply = mod.patches;
2623
+
2637
2624
  if (isDesignRequest && identifiedProblems.length > 0) {
2638
- const validationResult = validateDesignPatches(mod.patches, identifiedProblems);
2639
-
2640
- if (validationResult.rejected.length > 0) {
2641
- debugLog("Design patch validation rejected some patches", {
2642
- filePath: mod.filePath,
2643
- validCount: validationResult.valid.length,
2644
- rejectedCount: validationResult.rejected.length,
2645
- rejectedReasons: validationResult.rejected.map(r => r.reason)
2646
- });
2647
- console.warn(`[Vision Mode] ${validationResult.rejected.length} patches rejected for missing/invalid problemId`);
2648
- }
2649
-
2650
- // Only use validated patches
2651
- if (validationResult.valid.length === 0) {
2652
- patchErrors.push(`${mod.filePath}: All patches were rejected - they don't reference identified problems`);
2653
- continue;
2654
- }
2655
-
2656
- // Log which problems are being fixed
2657
- const problemsBeingFixed = [...new Set(validationResult.valid.map(p => p.problemId))];
2658
- debugLog("Design patches validated", {
2625
+ debugLog("Design patches received", {
2659
2626
  filePath: mod.filePath,
2660
- problemsBeingFixed,
2661
- patchCount: validationResult.valid.length
2627
+ patchCount: patchesToApply.length,
2628
+ problemsIdentified: identifiedProblems.length
2662
2629
  });
2663
-
2664
- // Map validated patches to Patch interface (rationale -> explanation)
2665
- patchesToApply = validationResult.valid.map(p => ({
2666
- search: p.search,
2667
- replace: p.replace,
2668
- explanation: `[${p.problemId}] ${p.rationale}`
2669
- }));
2670
2630
  }
2671
2631
 
2672
2632
  // PRE-VALIDATION: Check if all search strings exist in the file BEFORE applying
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.101",
3
+ "version": "1.3.102",
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",