sunpeak 0.16.29 → 0.17.2

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 (140) hide show
  1. package/bin/commands/dev.mjs +169 -342
  2. package/bin/commands/inspect.mjs +763 -0
  3. package/bin/commands/new.mjs +2 -2
  4. package/bin/lib/inspect/inspect-config.d.mts +20 -0
  5. package/bin/lib/inspect/inspect-config.mjs +76 -0
  6. package/bin/lib/live/global-setup.mjs +6 -1
  7. package/bin/sunpeak.js +11 -1
  8. package/dist/chatgpt/globals.css +8 -0
  9. package/dist/chatgpt/index.cjs +3 -11
  10. package/dist/chatgpt/index.cjs.map +1 -1
  11. package/dist/chatgpt/index.d.ts +2 -2
  12. package/dist/chatgpt/index.js +4 -8
  13. package/dist/chatgpt/index.js.map +1 -1
  14. package/dist/claude/index.cjs +1 -1
  15. package/dist/claude/index.js +1 -1
  16. package/dist/discovery-Cgoegt62.js +114 -0
  17. package/dist/discovery-Cgoegt62.js.map +1 -0
  18. package/dist/discovery-Clu4uHp1.cjs +161 -0
  19. package/dist/discovery-Clu4uHp1.cjs.map +1 -0
  20. package/dist/index.cjs +1 -4
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.js +2 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/discovery-cli.cjs +1 -1
  25. package/dist/lib/discovery-cli.js +1 -1
  26. package/dist/lib/discovery.d.ts +7 -67
  27. package/dist/lib/index.d.ts +0 -1
  28. package/dist/mcp/index.cjs +34 -23
  29. package/dist/mcp/index.cjs.map +1 -1
  30. package/dist/mcp/index.js +34 -23
  31. package/dist/mcp/index.js.map +1 -1
  32. package/dist/mcp/types.d.ts +5 -0
  33. package/dist/simulator/index.cjs +5 -11
  34. package/dist/simulator/index.cjs.map +1 -1
  35. package/dist/simulator/index.d.ts +4 -2
  36. package/dist/simulator/index.js +5 -8
  37. package/dist/simulator/index.js.map +1 -1
  38. package/dist/simulator/simple-sidebar.d.ts +7 -4
  39. package/dist/simulator/simulator-url.d.ts +8 -0
  40. package/dist/simulator/simulator.d.ts +15 -2
  41. package/dist/simulator/use-mcp-connection.d.ts +19 -0
  42. package/dist/{simulator-DIVvI69i.cjs → simulator-CH9hs0N6.cjs} +129 -21
  43. package/dist/simulator-CH9hs0N6.cjs.map +1 -0
  44. package/dist/{simulator-C7mkK7Sz.js → simulator-Dl8B-Ljb.js} +124 -22
  45. package/dist/simulator-Dl8B-Ljb.js.map +1 -0
  46. package/dist/{simulator-url-BDGD4vZD.cjs → simulator-url-CozKF1jf.cjs} +3 -1
  47. package/dist/simulator-url-CozKF1jf.cjs.map +1 -0
  48. package/dist/{simulator-url-Bkxj43yT.js → simulator-url-KoS_ToP6.js} +3 -1
  49. package/dist/simulator-url-KoS_ToP6.js.map +1 -0
  50. package/dist/style.css +8 -0
  51. package/package.json +11 -3
  52. package/template/dist/albums/albums.html +105 -0
  53. package/template/dist/albums/albums.json +16 -0
  54. package/template/dist/carousel/carousel.html +105 -0
  55. package/template/dist/carousel/carousel.json +16 -0
  56. package/template/dist/map/map.html +3060 -0
  57. package/template/dist/map/map.json +22 -0
  58. package/template/dist/review/review.html +105 -0
  59. package/template/dist/review/review.json +16 -0
  60. package/template/dist/server.js +15 -0
  61. package/template/dist/tools/review-diff.js +50 -0
  62. package/template/dist/tools/review-post.js +50 -0
  63. package/template/dist/tools/review-purchase.js +61 -0
  64. package/template/dist/tools/review.js +31 -0
  65. package/template/dist/tools/show-albums.js +56 -0
  66. package/template/dist/tools/show-carousel.js +41 -0
  67. package/template/dist/tools/show-map.js +47 -0
  68. package/template/node_modules/.vite/deps/_metadata.json +8 -0
  69. package/template/node_modules/.vite/deps/package.json +3 -0
  70. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +500 -0
  71. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -0
  72. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +563 -0
  73. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -0
  74. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +575 -0
  75. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -0
  76. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +11363 -0
  77. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -0
  78. package/template/node_modules/.vite-mcp/deps/_metadata.json +130 -0
  79. package/template/node_modules/.vite-mcp/deps/chunk-BoAXSpZd.js +33 -0
  80. package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js +14385 -0
  81. package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js.map +1 -0
  82. package/template/node_modules/.vite-mcp/deps/clsx.js +18 -0
  83. package/template/node_modules/.vite-mcp/deps/clsx.js.map +1 -0
  84. package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js +505 -0
  85. package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js.map +1 -0
  86. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js +1461 -0
  87. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js.map +1 -0
  88. package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js +536 -0
  89. package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js.map +1 -0
  90. package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js +1013 -0
  91. package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js.map +1 -0
  92. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js +46311 -0
  93. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js.map +1 -0
  94. package/template/node_modules/.vite-mcp/deps/package.json +3 -0
  95. package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js +2090 -0
  96. package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js.map +1 -0
  97. package/template/node_modules/.vite-mcp/deps/react-dom.js +186 -0
  98. package/template/node_modules/.vite-mcp/deps/react-dom.js.map +1 -0
  99. package/template/node_modules/.vite-mcp/deps/react-dom_client.js +2 -0
  100. package/template/node_modules/.vite-mcp/deps/react.js +769 -0
  101. package/template/node_modules/.vite-mcp/deps/react.js.map +1 -0
  102. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js +205 -0
  103. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js.map +1 -0
  104. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js +209 -0
  105. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js.map +1 -0
  106. package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js +12157 -0
  107. package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js.map +1 -0
  108. package/template/node_modules/.vite-mcp/deps/tailwind-merge.js +2025 -0
  109. package/template/node_modules/.vite-mcp/deps/tailwind-merge.js.map +1 -0
  110. package/template/node_modules/.vite-mcp/deps/vitest.js +14021 -0
  111. package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -0
  112. package/template/node_modules/.vite-mcp/deps/zod.js +624 -0
  113. package/template/node_modules/.vite-mcp/deps/zod.js.map +1 -0
  114. package/template/src/tools/review-diff.test.ts +5 -1
  115. package/template/src/tools/review-diff.ts +1 -1
  116. package/template/src/tools/review-post.test.ts +5 -1
  117. package/template/src/tools/review-post.ts +1 -1
  118. package/template/src/tools/review-purchase.test.ts +5 -1
  119. package/template/src/tools/review-purchase.ts +1 -1
  120. package/template/src/tools/review.test.ts +5 -1
  121. package/template/src/tools/review.ts +1 -1
  122. package/template/src/tools/show-albums.test.ts +5 -1
  123. package/template/src/tools/show-albums.ts +1 -1
  124. package/template/src/tools/show-carousel.test.ts +5 -1
  125. package/template/src/tools/show-carousel.ts +1 -1
  126. package/template/src/tools/show-map.test.ts +5 -1
  127. package/template/src/tools/show-map.ts +1 -1
  128. package/dist/discovery-BxKCIgG5.cjs +0 -332
  129. package/dist/discovery-BxKCIgG5.cjs.map +0 -1
  130. package/dist/discovery-Du4LHrih.js +0 -261
  131. package/dist/discovery-Du4LHrih.js.map +0 -1
  132. package/dist/simulator-C7mkK7Sz.js.map +0 -1
  133. package/dist/simulator-DIVvI69i.cjs.map +0 -1
  134. package/dist/simulator-url-BDGD4vZD.cjs.map +0 -1
  135. package/dist/simulator-url-Bkxj43yT.js.map +0 -1
  136. package/template/.sunpeak/dev.tsx +0 -79
  137. package/template/.sunpeak/resource-loader.html +0 -20
  138. package/template/.sunpeak/resource-loader.tsx +0 -57
  139. package/template/index.html +0 -14
  140. package/template/src/resources/index.ts +0 -17
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../chunk-9hOWP6kD.cjs");
3
- const require_discovery = require("../discovery-BxKCIgG5.cjs");
3
+ const require_discovery = require("../discovery-Clu4uHp1.cjs");
4
4
  let path = require("path");
5
5
  path = require_chunk.__toESM(path);
6
6
  //#region src/lib/extract-resource.ts
@@ -1,4 +1,4 @@
1
- import { a as extractResourceKey, c as findResourceKey, d as getComponentName, f as toPascalCase, l as findSimulationFilesFlat, o as extractSimulationKey, s as findResourceDirs, u as findToolFiles } from "../discovery-Du4LHrih.js";
1
+ import { a as findSimulationFilesFlat, c as toPascalCase, i as findResourceKey, n as extractSimulationKey, o as findToolFiles, r as findResourceDirs, s as getComponentName, t as extractResourceKey } from "../discovery-Cgoegt62.js";
2
2
  import path from "path";
3
3
  //#region src/lib/extract-resource.ts
4
4
  /**
@@ -1,4 +1,10 @@
1
- import { Simulation } from '../types/simulation.js';
1
+ /**
2
+ * Discovery utilities for resources, tools, and simulations.
3
+ *
4
+ * String helpers (toPascalCase, extractResourceKey, etc.) are used by both
5
+ * browser and Node.js code. Node.js utilities (findResourceDirs, findToolFiles,
6
+ * etc.) are used by CLI commands for build-time and runtime discovery.
7
+ */
2
8
  /**
3
9
  * Convert a kebab-case string to PascalCase
4
10
  * @example toPascalCase('review') // 'Review'
@@ -28,71 +34,6 @@ export declare function findResourceKey(simulationKey: string, resourceKeys: str
28
34
  * @example getComponentName('album-art') // 'AlbumArtResource'
29
35
  */
30
36
  export declare function getComponentName(resourceKey: string): string;
31
- type GlobModules = Record<string, unknown>;
32
- /**
33
- * Process resource component modules from import.meta.glob() result.
34
- * Extracts components and exports them with PascalCase names.
35
- *
36
- * @example
37
- * const modules = import.meta.glob('./*\/*.tsx', { eager: true });
38
- * export default createResourceExports(modules);
39
- */
40
- export declare function createResourceExports(modules: GlobModules): Record<string, React.ComponentType>;
41
- /**
42
- * Build a resource metadata map from import.meta.glob() result.
43
- * Used for connecting simulations to their resource definitions.
44
- *
45
- * @example
46
- * const modules = import.meta.glob('../src/resources/*\/*.tsx', { eager: true });
47
- * const resourcesMap = buildResourceMap(modules);
48
- */
49
- export declare function buildResourceMap<T>(modules: GlobModules): Map<string, T>;
50
- /**
51
- * Options for building simulations from discovered modules
52
- */
53
- export interface BuildSimulationsOptions<TResource, TSimulation> {
54
- /** Glob result of simulation JSON files */
55
- simulationModules: GlobModules;
56
- /** Map of resource key -> resource metadata */
57
- resourcesMap: Map<string, TResource>;
58
- /** Map of component name -> React component */
59
- resourceComponents: Record<string, React.ComponentType>;
60
- /** Create the final simulation object */
61
- createSimulation: (simulationKey: string, simulationData: unknown, resource: TResource, resourceComponent: React.ComponentType) => TSimulation;
62
- /** Optional warning handler for missing resources */
63
- onMissingResource?: (simulationKey: string, expectedPrefix: string) => void;
64
- }
65
- /**
66
- * Build simulations by connecting simulation data with resources and components.
67
- * This is the main orchestration function for dev server bootstrap.
68
- */
69
- export declare function buildSimulations<TResource, TSimulation>(options: BuildSimulationsOptions<TResource, TSimulation>): Record<string, TSimulation>;
70
- /**
71
- * Resource metadata from resource .tsx files
72
- */
73
- export interface ResourceMetadata {
74
- name: string;
75
- [key: string]: unknown;
76
- }
77
- /**
78
- * Options for building dev simulations
79
- */
80
- export interface BuildDevSimulationsOptions {
81
- /** Glob result of simulation JSON files */
82
- simulationModules: GlobModules;
83
- /** Resource components map from src/resources/index.ts */
84
- resourceComponents: Record<string, React.ComponentType>;
85
- /** Glob result of tool files: import.meta.glob('src/tools/*.ts', { eager: true }) */
86
- toolModules: GlobModules;
87
- /** Glob result of resource .tsx files from src/resources/ */
88
- resourceModules: GlobModules;
89
- }
90
- /**
91
- * Build simulations for the dev server from glob results.
92
- * Simulation JSON has `"tool": "tool-name"` string referencing a tool file.
93
- * Tool files have `resource: 'name'` linking to a resource discovered from resourceModules.
94
- */
95
- export declare function buildDevSimulations(options: BuildDevSimulationsOptions): Record<string, Simulation>;
96
37
  /**
97
38
  * Information about a discovered resource directory
98
39
  */
@@ -169,4 +110,3 @@ export interface SimulationFileInfo {
169
110
  * // [{ name: 'show-albums', path: 'tests/simulations/show-albums.json' }]
170
111
  */
171
112
  export declare function findSimulationFilesFlat(simulationsDir: string, fs: Pick<FsOps, 'readdirSync' | 'existsSync'>): SimulationFileInfo[];
172
- export {};
@@ -1,3 +1,2 @@
1
1
  export { cn } from './utils';
2
2
  export * from './media-queries';
3
- export { createResourceExports, buildResourceMap } from './discovery';
@@ -9183,14 +9183,16 @@ function createAppServer(config, simulations, viteMode) {
9183
9183
  };
9184
9184
  const toolHandle = uZ(mcpServer, tool.name, {
9185
9185
  description: tool.description,
9186
+ inputSchema: zod.z.object({}).passthrough(),
9186
9187
  ...simulation.outputSchema ? { outputSchema: simulation.outputSchema } : {},
9188
+ annotations: tool.annotations,
9187
9189
  _meta: fullToolMeta
9188
- }, async (extra) => {
9189
- const args = extra.request?.params?.arguments ?? {};
9190
+ }, async (args, extra) => {
9190
9191
  const argKeys = Object.keys(args);
9191
9192
  const argsStr = argKeys.length > 0 ? `{${argKeys.join(", ")}}` : "{}";
9193
+ const hasMockResult = toolResult?.structuredContent != null;
9192
9194
  const realHandler = simulation.handler;
9193
- if (realHandler) {
9195
+ if (realHandler && !hasMockResult) {
9194
9196
  console.log(`[MCP] CallTool: ${tool.name}${argsStr} → live handler`);
9195
9197
  try {
9196
9198
  const result = await realHandler(args, extra);
@@ -9211,8 +9213,7 @@ function createAppServer(config, simulations, viteMode) {
9211
9213
  };
9212
9214
  }
9213
9215
  }
9214
- const hasStructuredContent = toolResult?.structuredContent != null;
9215
- console.log(`[MCP] CallTool: ${tool.name}${argsStr} → ${hasStructuredContent ? "structured" : "text"}`);
9216
+ console.log(`[MCP] CallTool: ${tool.name}${argsStr} ${hasMockResult ? "structured" : "text"}`);
9216
9217
  return {
9217
9218
  content: [{
9218
9219
  type: "text",
@@ -9450,15 +9451,20 @@ function runMCPServer(config) {
9450
9451
  viteServer.ws.handleUpgrade(request, socket, head);
9451
9452
  });
9452
9453
  httpServer.on("clientError", (err, socket) => {
9453
- console.error("HTTP client error", err);
9454
+ if (err.code !== "ECONNRESET") console.error("HTTP client error", err);
9454
9455
  socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
9455
9456
  });
9457
+ let resolveReady;
9458
+ const ready = new Promise((resolve) => {
9459
+ resolveReady = resolve;
9460
+ });
9456
9461
  const onListening = () => {
9457
9462
  const actualPort = httpServer.address().port;
9458
9463
  localDevServerUrl = `http://localhost:${actualPort}`;
9459
9464
  console.log(`Sunpeak MCP server listening on http://localhost:${actualPort}`);
9460
9465
  console.log(` MCP endpoint: http://localhost:${actualPort}${MCP_PATH$1}`);
9461
9466
  if (viteMode) console.log(` Vite HMR: enabled (source files served with hot reload)`);
9467
+ resolveReady();
9462
9468
  };
9463
9469
  httpServer.on("error", (err) => {
9464
9470
  if (err.code === "EADDRINUSE") {
@@ -9480,25 +9486,30 @@ function runMCPServer(config) {
9480
9486
  };
9481
9487
  process.on("SIGTERM", () => void shutdown());
9482
9488
  process.on("SIGINT", () => void shutdown());
9483
- return { invalidateResources() {
9484
- if (sessions.size === 0) return;
9485
- const timestamp = Date.now().toString(36);
9486
- for (const [, session] of sessions) {
9487
- for (const [name, handle] of session.resourceHandles) handle.update({ uri: `ui://${name}-${timestamp}` });
9488
- for (const { handle, resourceName, toolMeta } of session.toolHandles) {
9489
- const newUri = `ui://${resourceName}-${timestamp}`;
9490
- handle.update({ _meta: {
9491
- ...toolMeta,
9492
- ui: {
9493
- ...toolMeta.ui,
9494
- resourceUri: newUri
9495
- },
9496
- "ui/resourceUri": newUri
9497
- } });
9489
+ return {
9490
+ ready,
9491
+ invalidateResources() {
9492
+ if (sessions.size === 0) return;
9493
+ const tunnelSessions = [...sessions].filter(([, s]) => !s.isLocal);
9494
+ if (tunnelSessions.length === 0) return;
9495
+ const timestamp = Date.now().toString(36);
9496
+ for (const [, session] of tunnelSessions) {
9497
+ for (const [name, handle] of session.resourceHandles) handle.update({ uri: `ui://${name}-${timestamp}` });
9498
+ for (const { handle, resourceName, toolMeta } of session.toolHandles) {
9499
+ const newUri = `ui://${resourceName}-${timestamp}`;
9500
+ handle.update({ _meta: {
9501
+ ...toolMeta,
9502
+ ui: {
9503
+ ...toolMeta.ui,
9504
+ resourceUri: newUri
9505
+ },
9506
+ "ui/resourceUri": newUri
9507
+ } });
9508
+ }
9498
9509
  }
9510
+ console.log(`[MCP] Cache-busted ${tunnelSessions.length} tunnel session(s) with timestamp ${timestamp}`);
9499
9511
  }
9500
- console.log(`[MCP] Cache-busted ${sessions.size} session(s) with timestamp ${timestamp}`);
9501
- } };
9512
+ };
9502
9513
  }
9503
9514
  //#endregion
9504
9515
  //#region src/mcp/production-server.ts