sonance-brand-mcp 1.3.8 → 1.3.10

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -39
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -300,17 +300,22 @@ function runDevToolsInstaller() {
300
300
  console.log(" └─────────────────────────────────────────────────┘");
301
301
  console.log("");
302
302
  const targetDir = process.cwd();
303
- // Paths
304
- const libDir = path.join(targetDir, "src/lib");
305
- const devToolsDir = path.join(targetDir, "src/components/dev-tools");
306
- const stylesDir = path.join(targetDir, "src/styles");
307
- const apiThemeDir = path.join(targetDir, "src/app/api/sonance-theme");
308
- const apiComponentsDir = path.join(targetDir, "src/app/api/sonance-components");
309
- const apiSaveLogoDir = path.join(targetDir, "src/app/api/sonance-save-logo");
310
- const apiAssetsDir = path.join(targetDir, "src/app/api/sonance-assets");
311
- const apiInjectIdDir = path.join(targetDir, "src/app/api/sonance-inject-id");
312
- const apiAnalyzeDir = path.join(targetDir, "src/app/api/sonance-analyze");
313
- const themeDir = path.join(targetDir, "src/theme");
303
+ // Detect project structure (src/ vs root)
304
+ const useSrcDir = fs.existsSync(path.join(targetDir, "src/app")) ||
305
+ fs.existsSync(path.join(targetDir, "src/components"));
306
+ const baseDir = useSrcDir ? "src" : "";
307
+ console.log(` 📁 Detected structure: ${useSrcDir ? "src/" : "root"}`);
308
+ // Dynamic paths based on detected structure
309
+ const libDir = path.join(targetDir, baseDir, "lib");
310
+ const devToolsDir = path.join(targetDir, baseDir, "components/dev-tools");
311
+ const stylesDir = path.join(targetDir, baseDir, "styles");
312
+ const apiThemeDir = path.join(targetDir, baseDir, "app/api/sonance-theme");
313
+ const apiComponentsDir = path.join(targetDir, baseDir, "app/api/sonance-components");
314
+ const apiSaveLogoDir = path.join(targetDir, baseDir, "app/api/sonance-save-logo");
315
+ const apiAssetsDir = path.join(targetDir, baseDir, "app/api/sonance-assets");
316
+ const apiInjectIdDir = path.join(targetDir, baseDir, "app/api/sonance-inject-id");
317
+ const apiAnalyzeDir = path.join(targetDir, baseDir, "app/api/sonance-analyze");
318
+ const themeDir = path.join(targetDir, baseDir, "theme");
314
319
  // Source resolution
315
320
  let sourceBrandSystem;
316
321
  let sourceBrandContext;
@@ -406,16 +411,18 @@ function runDevToolsInstaller() {
406
411
  process.exit(1);
407
412
  }
408
413
  console.log(" 📂 Installing files...");
414
+ // Path prefix for logging (shows "src/" or "" based on detected structure)
415
+ const pathPrefix = baseDir ? `${baseDir}/` : "";
409
416
  // 1. Install lib files (brand-system.ts, brand-context.tsx, utils.ts)
410
417
  if (!fs.existsSync(libDir)) {
411
418
  fs.mkdirSync(libDir, { recursive: true });
412
419
  }
413
420
  fs.copyFileSync(sourceBrandSystem, path.join(libDir, "brand-system.ts"));
414
- console.log(" ✓ Created src/lib/brand-system.ts");
421
+ console.log(` ✓ Created ${pathPrefix}lib/brand-system.ts`);
415
422
  fs.copyFileSync(sourceBrandContext, path.join(libDir, "brand-context.tsx"));
416
- console.log(" ✓ Created src/lib/brand-context.tsx");
423
+ console.log(` ✓ Created ${pathPrefix}lib/brand-context.tsx`);
417
424
  fs.copyFileSync(sourceUtils, path.join(libDir, "utils.ts"));
418
- console.log(" ✓ Created src/lib/utils.ts");
425
+ console.log(` ✓ Created ${pathPrefix}lib/utils.ts`);
419
426
  // 2. Install DevTools components
420
427
  if (!fs.existsSync(devToolsDir)) {
421
428
  fs.mkdirSync(devToolsDir, { recursive: true });
@@ -427,49 +434,49 @@ function runDevToolsInstaller() {
427
434
  fs.copyFileSync(path.join(sourceDevTools, entry.name), path.join(devToolsDir, entry.name));
428
435
  }
429
436
  }
430
- console.log(" ✓ Created src/components/dev-tools/");
437
+ console.log(` ✓ Created ${pathPrefix}components/dev-tools/`);
431
438
  // 3. Install API route for saving theme
432
439
  if (!fs.existsSync(apiThemeDir)) {
433
440
  fs.mkdirSync(apiThemeDir, { recursive: true });
434
441
  }
435
442
  fs.copyFileSync(sourceApiTheme, path.join(apiThemeDir, "route.ts"));
436
- console.log(" ✓ Created src/app/api/sonance-theme/route.ts");
443
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-theme/route.ts`);
437
444
  // 4. Install API route for component detection
438
445
  if (!fs.existsSync(apiComponentsDir)) {
439
446
  fs.mkdirSync(apiComponentsDir, { recursive: true });
440
447
  }
441
448
  fs.copyFileSync(sourceApiComponents, path.join(apiComponentsDir, "route.ts"));
442
- console.log(" ✓ Created src/app/api/sonance-components/route.ts");
449
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-components/route.ts`);
443
450
  // 5. Install API route for saving logo configuration
444
451
  if (!fs.existsSync(apiSaveLogoDir)) {
445
452
  fs.mkdirSync(apiSaveLogoDir, { recursive: true });
446
453
  }
447
454
  fs.copyFileSync(sourceApiSaveLogo, path.join(apiSaveLogoDir, "route.ts"));
448
- console.log(" ✓ Created src/app/api/sonance-save-logo/route.ts");
455
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-save-logo/route.ts`);
449
456
  // 7. Install API route for listing logo assets
450
457
  if (!fs.existsSync(apiAssetsDir)) {
451
458
  fs.mkdirSync(apiAssetsDir, { recursive: true });
452
459
  }
453
460
  fs.copyFileSync(sourceApiAssets, path.join(apiAssetsDir, "route.ts"));
454
- console.log(" ✓ Created src/app/api/sonance-assets/route.ts");
461
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-assets/route.ts`);
455
462
  // 8. Install API route for auto-fixing logo IDs
456
463
  if (!fs.existsSync(apiInjectIdDir)) {
457
464
  fs.mkdirSync(apiInjectIdDir, { recursive: true });
458
465
  }
459
466
  fs.copyFileSync(sourceApiInjectId, path.join(apiInjectIdDir, "route.ts"));
460
- console.log(" ✓ Created src/app/api/sonance-inject-id/route.ts");
467
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-inject-id/route.ts`);
461
468
  // 9. Install API route for project analysis
462
469
  if (!fs.existsSync(apiAnalyzeDir)) {
463
470
  fs.mkdirSync(apiAnalyzeDir, { recursive: true });
464
471
  }
465
472
  fs.copyFileSync(sourceApiAnalyze, path.join(apiAnalyzeDir, "route.ts"));
466
- console.log(" ✓ Created src/app/api/sonance-analyze/route.ts");
473
+ console.log(` ✓ Created ${pathPrefix}app/api/sonance-analyze/route.ts`);
467
474
  // 11. Install brand-overrides.css for production logo sizing
468
475
  if (!fs.existsSync(stylesDir)) {
469
476
  fs.mkdirSync(stylesDir, { recursive: true });
470
477
  }
471
478
  fs.copyFileSync(sourceBrandOverridesCss, path.join(stylesDir, "brand-overrides.css"));
472
- console.log(" ✓ Created src/styles/brand-overrides.css");
479
+ console.log(` ✓ Created ${pathPrefix}styles/brand-overrides.css`);
473
480
  // 12. Create theme directory with initial files
474
481
  if (!fs.existsSync(themeDir)) {
475
482
  fs.mkdirSync(themeDir, { recursive: true });
@@ -495,7 +502,7 @@ function runDevToolsInstaller() {
495
502
  spacing: "default"
496
503
  };
497
504
  fs.writeFileSync(path.join(themeDir, "sonance-config.json"), JSON.stringify(initialConfig, null, 2), "utf-8");
498
- console.log(" ✓ Created src/theme/ with initial files");
505
+ console.log(` ✓ Created ${pathPrefix}theme/ with initial files`);
499
506
  }
500
507
  // Detect user's file paths
501
508
  const globalsCssPaths = [
@@ -583,14 +590,21 @@ function runDevToolsInstaller() {
583
590
  modified = true;
584
591
  }
585
592
  }
586
- // Add component before </body> if not present
593
+ // Add component - try ThemeProvider first, then body
587
594
  if (!layoutContent.includes("<SonanceDevTools")) {
588
- if (layoutContent.includes("</body>")) {
589
- layoutContent = layoutContent.replace(/<\/body>/, ` {process.env.NODE_ENV === 'development' && <SonanceDevTools />}\n </body>`);
595
+ const componentLine = "{process.env.NODE_ENV === 'development' && <SonanceDevTools />}";
596
+ // Priority 1: Inside ThemeProvider (for next-themes compatibility)
597
+ if (layoutContent.includes("</ThemeProvider>")) {
598
+ layoutContent = layoutContent.replace(/<\/ThemeProvider>/, ` ${componentLine}\n </ThemeProvider>`);
599
+ modified = true;
600
+ }
601
+ // Priority 2: Before </body>
602
+ else if (layoutContent.includes("</body>")) {
603
+ layoutContent = layoutContent.replace(/<\/body>/, ` ${componentLine}\n </body>`);
590
604
  modified = true;
591
605
  }
592
606
  else {
593
- manualSteps.push("Could not find </body> tag - add DevTools component manually");
607
+ manualSteps.push("Could not find ThemeProvider or body tag - add DevTools component manually");
594
608
  }
595
609
  }
596
610
  if (modified) {
@@ -712,19 +726,24 @@ function runDevToolsUninstaller() {
712
726
  }
713
727
  }
714
728
  // --- 3. Delete installed directories/files ---
729
+ // Detect project structure (src/ vs root)
730
+ const useSrcDir = fs.existsSync(path.join(targetDir, "src/app")) ||
731
+ fs.existsSync(path.join(targetDir, "src/components"));
732
+ const baseDir = useSrcDir ? "src" : "";
733
+ const pathPrefix = baseDir ? `${baseDir}/` : "";
715
734
  const itemsToDelete = [
716
- "src/components/dev-tools",
717
- "src/styles/brand-overrides.css",
718
- "src/theme",
719
- "src/app/api/sonance-theme",
720
- "src/app/api/sonance-components",
721
- "src/app/api/sonance-save-logo",
722
- "src/app/api/sonance-assets",
723
- "src/app/api/sonance-inject-id",
724
- "src/app/api/sonance-analyze",
725
- "src/lib/brand-system.ts",
726
- "src/lib/brand-context.tsx",
727
- "src/lib/utils.ts"
735
+ `${pathPrefix}components/dev-tools`,
736
+ `${pathPrefix}styles/brand-overrides.css`,
737
+ `${pathPrefix}theme`,
738
+ `${pathPrefix}app/api/sonance-theme`,
739
+ `${pathPrefix}app/api/sonance-components`,
740
+ `${pathPrefix}app/api/sonance-save-logo`,
741
+ `${pathPrefix}app/api/sonance-assets`,
742
+ `${pathPrefix}app/api/sonance-inject-id`,
743
+ `${pathPrefix}app/api/sonance-analyze`,
744
+ `${pathPrefix}lib/brand-system.ts`,
745
+ `${pathPrefix}lib/brand-context.tsx`,
746
+ `${pathPrefix}lib/utils.ts`
728
747
  ];
729
748
  for (const item of itemsToDelete) {
730
749
  const fullPath = path.join(targetDir, item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
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",