sonance-brand-mcp 1.3.42 → 1.3.43

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.
@@ -521,17 +521,32 @@ export async function POST(request: Request) {
521
521
 
522
522
  // Identify the recommended file (highest scoring file, prefer filename matches)
523
523
  if (searchResults.length > 0) {
524
- // Find the best filename match first
525
- const filenameMatch = searchResults.find(r =>
526
- analysis.componentNames.some(name =>
527
- r.path.toLowerCase().includes(name.toLowerCase())
528
- )
529
- );
524
+ // Helper to extract filename without extension
525
+ const getFilenameWithoutExt = (filePath: string): string => {
526
+ const filename = filePath.split('/').pop() || '';
527
+ return filename.replace(/\.(tsx?|jsx?)$/, '').toLowerCase();
528
+ };
529
+
530
+ // Find file where FILENAME matches a component name (not just path)
531
+ const filenameMatch = searchResults.find(r => {
532
+ const filename = getFilenameWithoutExt(r.path);
533
+ return analysis.componentNames.some(name => {
534
+ const nameLower = name.toLowerCase();
535
+ // Exact match: ProcessDetailPanel === processdetailpanel
536
+ // Or filename contains the component name
537
+ return filename === nameLower || filename.includes(nameLower);
538
+ });
539
+ });
530
540
 
531
541
  if (filenameMatch) {
542
+ const matchedName = analysis.componentNames.find(name => {
543
+ const filename = getFilenameWithoutExt(filenameMatch.path);
544
+ const nameLower = name.toLowerCase();
545
+ return filename === nameLower || filename.includes(nameLower);
546
+ });
532
547
  recommendedFile = {
533
548
  path: filenameMatch.path,
534
- reason: `Component name match from screenshot analysis`
549
+ reason: `Filename matches component "${matchedName}" from screenshot`
535
550
  };
536
551
  } else {
537
552
  // Fall back to highest score
@@ -823,6 +838,11 @@ CRITICAL: Edit the TARGET COMPONENT (marked with ***), not the page wrapper.`;
823
838
  validFilePaths.add(comp.path);
824
839
  }
825
840
 
841
+ // FIX: Add the recommended file to validFilePaths (it was spliced out for display purposes)
842
+ if (recommendedFileContent) {
843
+ validFilePaths.add(recommendedFileContent.path);
844
+ }
845
+
826
846
  debugLog("VALIDATION: Valid file paths from page context", {
827
847
  pageFile: pageContext.pageFile,
828
848
  validFilePaths: Array.from(validFilePaths),
@@ -531,17 +531,32 @@ export async function POST(request: Request) {
531
531
 
532
532
  // Identify the recommended file (highest scoring file, prefer filename matches)
533
533
  if (searchResults.length > 0) {
534
- // Find the best filename match first
535
- const filenameMatch = searchResults.find(r =>
536
- analysis.componentNames.some(name =>
537
- r.path.toLowerCase().includes(name.toLowerCase())
538
- )
539
- );
534
+ // Helper to extract filename without extension
535
+ const getFilenameWithoutExt = (filePath: string): string => {
536
+ const filename = filePath.split('/').pop() || '';
537
+ return filename.replace(/\.(tsx?|jsx?)$/, '').toLowerCase();
538
+ };
539
+
540
+ // Find file where FILENAME matches a component name (not just path)
541
+ const filenameMatch = searchResults.find(r => {
542
+ const filename = getFilenameWithoutExt(r.path);
543
+ return analysis.componentNames.some(name => {
544
+ const nameLower = name.toLowerCase();
545
+ // Exact match: ProcessDetailPanel === processdetailpanel
546
+ // Or filename contains the component name
547
+ return filename === nameLower || filename.includes(nameLower);
548
+ });
549
+ });
540
550
 
541
551
  if (filenameMatch) {
552
+ const matchedName = analysis.componentNames.find(name => {
553
+ const filename = getFilenameWithoutExt(filenameMatch.path);
554
+ const nameLower = name.toLowerCase();
555
+ return filename === nameLower || filename.includes(nameLower);
556
+ });
542
557
  recommendedFile = {
543
558
  path: filenameMatch.path,
544
- reason: `Component name match from screenshot analysis`
559
+ reason: `Filename matches component "${matchedName}" from screenshot`
545
560
  };
546
561
  } else {
547
562
  // Fall back to highest score
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.42",
3
+ "version": "1.3.43",
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",