shadermesh-mcp 0.1.0 → 0.2.0

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 +38 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -71,6 +71,9 @@ async function detectProject(root) {
71
71
  else if (dependencyVersion(pkg, "@remix-run/react")) framework = "remix";
72
72
  else if (dependencyVersion(pkg, "astro")) framework = "astro";
73
73
  else if (dependencyVersion(pkg, "vite")) framework = "vite";
74
+ let ui = "vanilla";
75
+ if (dependencyVersion(pkg, "react")) ui = "react";
76
+ else if (dependencyVersion(pkg, "vue") || dependencyVersion(pkg, "nuxt")) ui = "vue";
74
77
  const tailwindRange = dependencyVersion(pkg, "tailwindcss");
75
78
  let alias = null;
76
79
  if (typescript) {
@@ -89,6 +92,7 @@ async function detectProject(root) {
89
92
  return {
90
93
  root,
91
94
  framework,
95
+ ui,
92
96
  typescript,
93
97
  srcDir,
94
98
  tailwind: Boolean(tailwindRange),
@@ -103,6 +107,7 @@ function proposeConfig(detected, registry2) {
103
107
  const runtimeImport = detected.alias ? `${detected.alias}/lib/shader-runtime` : "../../../lib/shader-runtime";
104
108
  return {
105
109
  $schema: `${registry2}/schema.json`,
110
+ ui: detected.ui,
106
111
  typescript: detected.typescript,
107
112
  tailwind: detected.tailwind,
108
113
  aliases: { components, lib, runtimeImport },
@@ -162,6 +167,7 @@ async function fetchPreset(config, slug, key, options = {}) {
162
167
  const url = new URL(
163
168
  `${config.registry.replace(/\/$/, "")}/api/registry/${encodeURIComponent(slug)}`
164
169
  );
170
+ url.searchParams.set("ui", config.ui ?? "react");
165
171
  url.searchParams.set("ts", String(config.typescript));
166
172
  url.searchParams.set("tailwind", String(config.tailwind));
167
173
  url.searchParams.set("componentDir", config.aliases.components);
@@ -339,11 +345,17 @@ var installShaderSchema = {
339
345
  ),
340
346
  colors: z2.array(z2.string()).length(3).optional().describe("Three hex colours baked in as the component's defaults. Pass the output of customize_shader_palette."),
341
347
  bg: z2.string().optional().describe("Background hex baked in as the component's default. Pass alongside colours from customize_shader_palette."),
342
- overwrite: z2.boolean().optional().describe("Replace files that already exist. Defaults to false.")
348
+ overwrite: z2.boolean().optional().describe("Replace files that already exist. Defaults to false."),
349
+ ui: z2.enum(["react", "vue", "vanilla"]).optional().describe(
350
+ "Component flavour to generate: a React .tsx, a Vue .vue single-file component, or a framework-free module (also the route for Svelte, Solid and Astro). Defaults to the project's shadermesh.json, otherwise whatever is detected. Only pass this to override a wrong guess."
351
+ )
343
352
  };
344
353
  async function installShader(args) {
345
354
  const root = workspaceRoot();
346
- const { config, source } = await resolveProjectConfig(root);
355
+ const resolved = await resolveProjectConfig(root);
356
+ const source = resolved.source;
357
+ const config = args.ui ? { ...resolved.config, ui: args.ui } : resolved.config;
358
+ const ui = config.ui ?? "react";
347
359
  if (args.targetDir) {
348
360
  if (!safeJoin(root, args.targetDir)) {
349
361
  return {
@@ -423,17 +435,32 @@ Free alternatives are available via list_shaders with free_only: true.`
423
435
  const results = [];
424
436
  for (const file of payload.files) {
425
437
  const overwrite = file.kind === "runtime" ? false : args.overwrite ?? false;
426
- results.push(await writeFileSafely(root, file.path, file.content, overwrite));
438
+ results.push({
439
+ ...await writeFileSafely(root, file.path, file.content, overwrite),
440
+ kind: file.kind
441
+ });
427
442
  }
428
443
  const written = results.filter((r) => r.written);
429
444
  const skipped = results.filter((r) => !r.written);
445
+ const component = results.find((r) => r.kind !== "runtime") ?? results[0];
446
+ const installed = component?.written ?? written.length > 0;
430
447
  const lines = [
431
- `Installed ${payload.name} (${payload.category}) into ${root}.`,
448
+ installed ? `Installed ${payload.name} (${payload.category}) into ${root}.` : `No changes. ${payload.name} (${payload.category}) is already installed in ${root}.`,
432
449
  "",
433
450
  ...written.map((r) => ` wrote ${r.path}`),
434
451
  ...skipped.map((r) => ` skipped ${r.path} \u2014 ${r.reason}`),
435
452
  "",
436
453
  `Project settings came from ${source}.`,
454
+ `Flavour: ${ui}${args.ui ? " (overridden)" : ""}.`
455
+ ];
456
+ if (!installed && (colors || bg)) {
457
+ lines.push(
458
+ "",
459
+ "The colours you passed were NOT applied \u2014 the existing file was left as it is.",
460
+ "Pass overwrite: true to rewrite it with them."
461
+ );
462
+ }
463
+ lines.push(
437
464
  "",
438
465
  "Usage:",
439
466
  "",
@@ -441,8 +468,8 @@ Free alternatives are available via list_shaders with free_only: true.`
441
468
  "",
442
469
  'The component fills its parent, so give it a height (`className="h-screen"`).',
443
470
  "Children render above the canvas automatically."
444
- ];
445
- if (skipped.some((r) => r.reason === "already exists" && !r.path.includes("shader-runtime"))) {
471
+ );
472
+ if (!installed && !colors && !bg) {
446
473
  lines.push("", "Pass overwrite: true to replace the existing component.");
447
474
  }
448
475
  return {
@@ -450,12 +477,14 @@ Free alternatives are available via list_shaders with free_only: true.`
450
477
  structuredContent: {
451
478
  slug: payload.slug,
452
479
  component: payload.component,
480
+ ui,
453
481
  root,
454
482
  written: written.map((r) => r.path),
455
483
  skipped: skipped.map((r) => ({ path: r.path, reason: r.reason })),
456
484
  usage: payload.usage,
457
- ...colors ? { colors } : {},
458
- ...bg ? { bg } : {}
485
+ installed,
486
+ ...installed && colors ? { colors } : {},
487
+ ...installed && bg ? { bg } : {}
459
488
  }
460
489
  };
461
490
  }
@@ -660,7 +689,7 @@ async function customizePalette(registry2, args) {
660
689
  }
661
690
 
662
691
  // src/index.ts
663
- var VERSION = "0.1.0";
692
+ var VERSION = "0.2.0";
664
693
  var registry = DEFAULT_REGISTRY;
665
694
  var server = new McpServer(
666
695
  { name: "shadermesh", version: VERSION },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadermesh-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for shadermesh — browse, install and recolour interactive WebGL shader backgrounds from Claude Code, Cursor or Windsurf.",
5
5
  "license": "MIT",
6
6
  "type": "module",