sonance-brand-mcp 1.3.101 → 1.3.103

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,43 @@ 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 structured list with code hints to guide the LLM
1523
+ const problemsList = problems.map((p, i) => {
1524
+ const hint = p.codeHint ? `\n → Look for: ${p.codeHint}` : '';
1525
+ return `${i + 1}. [${p.severity.toUpperCase()}] ${p.description}${hint}`;
1526
+ }).join('\n\n');
1523
1527
 
1524
1528
  return `
1525
1529
  ═══════════════════════════════════════════════════════════════════════════════
1526
- PHASE 2: TARGETED PATCH GENERATION
1530
+ DESIGN ISSUES TO FIX (${problems.length} problems identified)
1527
1531
  ═══════════════════════════════════════════════════════════════════════════════
1528
1532
 
1529
- A visual analysis identified these specific problems in the UI:
1533
+ ${problemsList}
1530
1534
 
1531
- ${problemsJson}
1535
+ YOUR TASK: Generate AT LEAST ONE PATCH for EACH problem listed above.
1536
+ Expected minimum patches: ${problems.length}
1532
1537
 
1533
- YOUR TASK: Generate patches that fix ONLY these specific problems.
1538
+ Use the "Look for" hints to find the relevant code in the file.
1534
1539
 
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
1540
+ ⚠️ CRITICAL - EXACT CODE MATCHING:
1541
+ Your "search" string MUST be copied CHARACTER-FOR-CHARACTER from the file.
1542
+ Use the line numbers on the left to find the exact code.
1541
1543
 
1542
- For each problem, find the exact code that causes it and create a targeted fix.
1544
+ EXAMPLE:
1545
+ If line 42 shows: 42| <div className="mt-6 flex items-center">
1546
+ Your search must be: <div className="mt-6 flex items-center">
1543
1547
 
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
- }
1548
+ DO NOT:
1549
+ - Combine multiple lines into one search string
1550
+ - Add or remove classes/attributes
1551
+ - Invent code that "should" exist
1552
+ - Guess at the structure
1564
1553
 
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
1554
+ DO:
1555
+ - Copy the exact text from the numbered lines
1556
+ - Make small, targeted changes in the "replace" field
1557
+ - Keep patches focused on one change each
1558
+ - Generate one patch per problem minimum
1569
1559
  `;
1570
1560
  }
1571
1561
 
@@ -2664,36 +2654,17 @@ This is better than generating patches with made-up code.`,
2664
2654
  // New patch-based approach
2665
2655
  console.log(`[Apply-First] Applying ${mod.patches.length} patches to ${mod.filePath}`);
2666
2656
 
2667
- // DESIGN VALIDATION: For design-heavy requests, validate patches have problemIds
2668
- let patchesToApply = mod.patches;
2657
+ // Use patches directly - simplified approach focuses on exact code matching
2658
+ // rather than problemId validation (which was causing LLM to prioritize
2659
+ // problem-solving over exact code copying)
2660
+ const patchesToApply = mod.patches;
2661
+
2669
2662
  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", {
2663
+ debugLog("Design patches received", {
2691
2664
  filePath: mod.filePath,
2692
- problemsBeingFixed,
2693
- patchCount: validationResult.valid.length
2665
+ patchCount: patchesToApply.length,
2666
+ problemsIdentified: identifiedProblems.length
2694
2667
  });
2695
-
2696
- patchesToApply = validationResult.valid;
2697
2668
  }
2698
2669
 
2699
2670
  // PRE-VALIDATION: Check if all search strings exist in the file BEFORE applying
@@ -1515,53 +1515,43 @@ 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 structured list with code hints to guide the LLM
1519
+ const problemsList = problems.map((p, i) => {
1520
+ const hint = p.codeHint ? `\n → Look for: ${p.codeHint}` : '';
1521
+ return `${i + 1}. [${p.severity.toUpperCase()}] ${p.description}${hint}`;
1522
+ }).join('\n\n');
1519
1523
 
1520
1524
  return `
1521
1525
  ═══════════════════════════════════════════════════════════════════════════════
1522
- PHASE 2: TARGETED PATCH GENERATION
1526
+ DESIGN ISSUES TO FIX (${problems.length} problems identified)
1523
1527
  ═══════════════════════════════════════════════════════════════════════════════
1524
1528
 
1525
- A visual analysis identified these specific problems in the UI:
1529
+ ${problemsList}
1526
1530
 
1527
- ${problemsJson}
1531
+ YOUR TASK: Generate AT LEAST ONE PATCH for EACH problem listed above.
1532
+ Expected minimum patches: ${problems.length}
1528
1533
 
1529
- YOUR TASK: Generate patches that fix ONLY these specific problems.
1534
+ Use the "Look for" hints to find the relevant code in the file.
1530
1535
 
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
1536
+ ⚠️ CRITICAL - EXACT CODE MATCHING:
1537
+ Your "search" string MUST be copied CHARACTER-FOR-CHARACTER from the file.
1538
+ Use the line numbers on the left to find the exact code.
1537
1539
 
1538
- For each problem, find the exact code that causes it and create a targeted fix.
1540
+ EXAMPLE:
1541
+ If line 42 shows: 42| <div className="mt-6 flex items-center">
1542
+ Your search must be: <div className="mt-6 flex items-center">
1539
1543
 
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
- }
1544
+ DO NOT:
1545
+ - Combine multiple lines into one search string
1546
+ - Add or remove classes/attributes
1547
+ - Invent code that "should" exist
1548
+ - Guess at the structure
1560
1549
 
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
1550
+ DO:
1551
+ - Copy the exact text from the numbered lines
1552
+ - Make small, targeted changes in the "replace" field
1553
+ - Keep patches focused on one change each
1554
+ - Generate one patch per problem minimum
1565
1555
  `;
1566
1556
  }
1567
1557
 
@@ -2632,41 +2622,17 @@ This is better than generating patches with made-up code.`,
2632
2622
  // New patch-based approach
2633
2623
  console.log(`[Vision Mode] Applying ${mod.patches.length} patches to ${mod.filePath}`);
2634
2624
 
2635
- // DESIGN VALIDATION: For design-heavy requests, validate patches have problemIds
2636
- let patchesToApply = mod.patches;
2625
+ // Use patches directly - simplified approach focuses on exact code matching
2626
+ // rather than problemId validation (which was causing LLM to prioritize
2627
+ // problem-solving over exact code copying)
2628
+ const patchesToApply = mod.patches;
2629
+
2637
2630
  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", {
2631
+ debugLog("Design patches received", {
2659
2632
  filePath: mod.filePath,
2660
- problemsBeingFixed,
2661
- patchCount: validationResult.valid.length
2633
+ patchCount: patchesToApply.length,
2634
+ problemsIdentified: identifiedProblems.length
2662
2635
  });
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
2636
  }
2671
2637
 
2672
2638
  // 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.103",
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",