sunpeak 0.15.4 → 0.16.1

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 (98) hide show
  1. package/README.md +51 -48
  2. package/bin/commands/build.mjs +13 -4
  3. package/bin/commands/dev.mjs +64 -19
  4. package/bin/commands/new.mjs +13 -3
  5. package/bin/lib/extract-resource.mjs +1 -1
  6. package/bin/lib/extract-tool.mjs +78 -0
  7. package/bin/lib/patterns.mjs +2 -26
  8. package/dist/chatgpt/index.cjs +3 -6
  9. package/dist/chatgpt/index.cjs.map +1 -1
  10. package/dist/chatgpt/index.d.ts +1 -1
  11. package/dist/chatgpt/index.js +6 -9
  12. package/dist/claude/index.cjs +1 -1
  13. package/dist/claude/index.js +1 -1
  14. package/dist/discovery-CH80W5l9.js +217 -0
  15. package/dist/discovery-CH80W5l9.js.map +1 -0
  16. package/dist/discovery-DmB8_4QL.cjs +216 -0
  17. package/dist/discovery-DmB8_4QL.cjs.map +1 -0
  18. package/dist/{index-CutQgPzR.js → index-BjnAsaqp.js} +3 -6
  19. package/dist/index-BjnAsaqp.js.map +1 -0
  20. package/dist/{index-Cngntkp2.cjs → index-BvQ_ZuOO.cjs} +3 -6
  21. package/dist/{index-Cngntkp2.cjs.map → index-BvQ_ZuOO.cjs.map} +1 -1
  22. package/dist/{index-B0dxRJvS.cjs → index-C9CVbGFt.cjs} +3 -6
  23. package/dist/index-C9CVbGFt.cjs.map +1 -0
  24. package/dist/{index-Ce_5ZIdJ.js → index-CTGEqlgk.js} +3 -6
  25. package/dist/{index-Ce_5ZIdJ.js.map → index-CTGEqlgk.js.map} +1 -1
  26. package/dist/index.cjs +48 -5
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +3404 -3361
  30. package/dist/index.js.map +1 -1
  31. package/dist/lib/discovery-cli.cjs +58 -5
  32. package/dist/lib/discovery-cli.cjs.map +1 -1
  33. package/dist/lib/discovery-cli.d.ts +3 -2
  34. package/dist/lib/discovery-cli.js +61 -8
  35. package/dist/lib/discovery-cli.js.map +1 -1
  36. package/dist/lib/discovery.d.ts +42 -43
  37. package/dist/lib/extract-tool.d.ts +12 -0
  38. package/dist/mcp/favicon.d.ts +1 -1
  39. package/dist/mcp/index.cjs +3 -2
  40. package/dist/mcp/index.cjs.map +1 -1
  41. package/dist/mcp/index.d.ts +1 -1
  42. package/dist/mcp/index.js +3 -2
  43. package/dist/mcp/index.js.map +1 -1
  44. package/dist/mcp/types.d.ts +24 -1
  45. package/dist/platform/chatgpt/index.cjs +1 -1
  46. package/dist/platform/chatgpt/index.js +1 -1
  47. package/dist/simulator/index.cjs +2 -5
  48. package/dist/simulator/index.cjs.map +1 -1
  49. package/dist/simulator/index.d.ts +1 -1
  50. package/dist/simulator/index.js +5 -8
  51. package/dist/simulator/simulator-url.d.ts +9 -9
  52. package/dist/{simulator-DcfQBRXE.cjs → simulator-B56j5P8W.cjs} +8 -2
  53. package/dist/{simulator-DcfQBRXE.cjs.map → simulator-B56j5P8W.cjs.map} +1 -1
  54. package/dist/{simulator-CxrtnguM.js → simulator-C0H_k092.js} +8 -2
  55. package/dist/{simulator-CxrtnguM.js.map → simulator-C0H_k092.js.map} +1 -1
  56. package/dist/simulator-url-CuLqtnSS.js.map +1 -1
  57. package/dist/simulator-url-rgg_KYOg.cjs.map +1 -1
  58. package/dist/types/resource-config.d.ts +7 -5
  59. package/dist/{use-app-D_TeaMFG.js → use-app-BThbgFFT.js} +51 -22
  60. package/dist/{use-app-D_TeaMFG.js.map → use-app-BThbgFFT.js.map} +1 -1
  61. package/dist/{use-app-BnoSPiUT.cjs → use-app-BuufpXTQ.cjs} +49 -20
  62. package/dist/{use-app-BnoSPiUT.cjs.map → use-app-BuufpXTQ.cjs.map} +1 -1
  63. package/package.json +1 -1
  64. package/template/.sunpeak/dev.tsx +8 -4
  65. package/template/.sunpeak/resource-loader.tsx +2 -1
  66. package/template/README.md +14 -10
  67. package/template/package.json +2 -1
  68. package/template/src/resources/albums/{albums-resource.test.tsx → albums.test.tsx} +1 -1
  69. package/template/src/resources/albums/{albums-resource.tsx → albums.tsx} +0 -1
  70. package/template/src/resources/carousel/{carousel-resource.test.tsx → carousel.test.tsx} +1 -1
  71. package/template/src/resources/carousel/{carousel-resource.tsx → carousel.tsx} +0 -1
  72. package/template/src/resources/index.ts +4 -4
  73. package/template/src/resources/map/{map-resource.test.tsx → map.test.tsx} +1 -1
  74. package/template/src/resources/map/{map-resource.tsx → map.tsx} +0 -1
  75. package/template/src/resources/review/{review-resource.test.tsx → review.test.tsx} +1 -1
  76. package/template/src/resources/review/{review-resource.tsx → review.tsx} +1 -2
  77. package/template/src/server.ts +15 -0
  78. package/template/src/tools/review-diff.ts +24 -0
  79. package/template/src/tools/review-post.ts +26 -0
  80. package/template/src/tools/review-purchase.ts +31 -0
  81. package/template/src/tools/show-albums.ts +22 -0
  82. package/template/src/tools/show-carousel.ts +25 -0
  83. package/template/src/tools/show-map.ts +29 -0
  84. package/template/tests/e2e/albums.spec.ts +6 -6
  85. package/template/tests/e2e/carousel.spec.ts +6 -6
  86. package/template/tests/e2e/map.spec.ts +11 -11
  87. package/template/tests/simulations/{review/review-diff-simulation.json → review-diff.json} +1 -31
  88. package/template/tests/simulations/{review/review-post-simulation.json → review-post.json} +1 -37
  89. package/template/tests/simulations/{review/review-purchase-simulation.json → review-purchase.json} +1 -38
  90. package/template/tests/simulations/{albums/albums-show-simulation.json → show-albums.json} +1 -24
  91. package/template/tests/simulations/{carousel/carousel-show-simulation.json → show-carousel.json} +1 -24
  92. package/template/tests/simulations/{map/map-show-simulation.json → show-map.json} +1 -35
  93. package/dist/discovery-CRR3SlyI.cjs +0 -156
  94. package/dist/discovery-CRR3SlyI.cjs.map +0 -1
  95. package/dist/discovery-DzV3HLXs.js +0 -157
  96. package/dist/discovery-DzV3HLXs.js.map +0 -1
  97. package/dist/index-B0dxRJvS.cjs.map +0 -1
  98. package/dist/index-CutQgPzR.js.map +0 -1
@@ -0,0 +1,217 @@
1
+ function toPascalCase(str) {
2
+ return str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
3
+ }
4
+ function extractResourceKey(path) {
5
+ const match = path.match(/([^/]+)\.tsx$/);
6
+ return match ? match[1] : void 0;
7
+ }
8
+ function extractSimulationKey(path) {
9
+ const match = path.match(/([^/]+)\.json$/);
10
+ return match ? match[1] : void 0;
11
+ }
12
+ function findResourceKey(simulationKey, resourceKeys) {
13
+ const sorted = [...resourceKeys].sort((a, b) => b.length - a.length);
14
+ for (const resourceKey of sorted) {
15
+ if (simulationKey === resourceKey || simulationKey.startsWith(resourceKey + "-")) {
16
+ return resourceKey;
17
+ }
18
+ }
19
+ return void 0;
20
+ }
21
+ function getComponentName(resourceKey) {
22
+ return `${toPascalCase(resourceKey)}Resource`;
23
+ }
24
+ function createResourceExports(modules) {
25
+ const resources = {};
26
+ for (const [path, module] of Object.entries(modules)) {
27
+ const key = extractResourceKey(path);
28
+ if (!key) continue;
29
+ const exportName = getComponentName(key);
30
+ const mod = module;
31
+ const component = mod.default ?? mod[exportName];
32
+ if (component && (typeof component === "function" || typeof component === "object")) {
33
+ resources[exportName] = component;
34
+ }
35
+ }
36
+ return resources;
37
+ }
38
+ function buildResourceMap(modules) {
39
+ const map = /* @__PURE__ */ new Map();
40
+ for (const [path, module] of Object.entries(modules)) {
41
+ const key = extractResourceKey(path);
42
+ if (key) {
43
+ map.set(key, module.resource);
44
+ }
45
+ }
46
+ return map;
47
+ }
48
+ function buildSimulations(options) {
49
+ const {
50
+ simulationModules,
51
+ resourcesMap,
52
+ resourceComponents,
53
+ createSimulation,
54
+ onMissingResource = (key, prefix) => console.warn(
55
+ `No matching resource found for simulation "${key}". Expected a resource file like src/resources/${prefix}/${prefix}.tsx`
56
+ )
57
+ } = options;
58
+ const resourceKeys = Array.from(resourcesMap.keys());
59
+ const simulations = {};
60
+ for (const [path, module] of Object.entries(simulationModules)) {
61
+ const simulationKey = extractSimulationKey(path);
62
+ if (!simulationKey) continue;
63
+ const simulationData = module.default;
64
+ const resourceKey = findResourceKey(simulationKey, resourceKeys);
65
+ if (!resourceKey) {
66
+ onMissingResource(simulationKey, simulationKey.split("-")[0]);
67
+ continue;
68
+ }
69
+ const resource = resourcesMap.get(resourceKey);
70
+ const componentName = getComponentName(resourceKey);
71
+ const resourceComponent = resourceComponents[componentName];
72
+ if (!resourceComponent) {
73
+ console.warn(
74
+ `Resource component "${componentName}" not found for resource "${resourceKey}". Make sure src/resources/${resourceKey}/${resourceKey}.tsx exists with a default export.`
75
+ );
76
+ continue;
77
+ }
78
+ simulations[simulationKey] = createSimulation(
79
+ simulationKey,
80
+ simulationData,
81
+ resource,
82
+ resourceComponent
83
+ );
84
+ }
85
+ return simulations;
86
+ }
87
+ function buildDevSimulations(options) {
88
+ const { simulationModules, resourceComponents, toolModules, resourceModules } = options;
89
+ const resourceMetaByName = /* @__PURE__ */ new Map();
90
+ const resourceKeyByName = /* @__PURE__ */ new Map();
91
+ for (const [path, module] of Object.entries(resourceModules)) {
92
+ const key = extractResourceKey(path);
93
+ if (!key) continue;
94
+ const mod = module;
95
+ if (mod.resource) {
96
+ const name = mod.resource.name ?? key;
97
+ resourceMetaByName.set(name, { ...mod.resource, name });
98
+ resourceKeyByName.set(name, key);
99
+ }
100
+ }
101
+ const toolsMap = /* @__PURE__ */ new Map();
102
+ if (toolModules) {
103
+ for (const [path, module] of Object.entries(toolModules)) {
104
+ const nameMatch = path.match(/([^/]+)\.ts$/);
105
+ if (!nameMatch) continue;
106
+ const mod = module;
107
+ if (mod.tool) {
108
+ const resourceName = mod.tool.resource;
109
+ if (resourceName) {
110
+ toolsMap.set(nameMatch[1], { tool: mod.tool, resourceName });
111
+ }
112
+ }
113
+ }
114
+ }
115
+ const simulations = {};
116
+ for (const [path, module] of Object.entries(simulationModules)) {
117
+ const simKey = extractSimulationKey(path);
118
+ if (!simKey) continue;
119
+ const simulationData = module.default;
120
+ const toolName = typeof simulationData.tool === "string" ? simulationData.tool : simKey;
121
+ const toolInfo = toolsMap.get(toolName);
122
+ if (!toolInfo) {
123
+ console.warn(
124
+ `Tool "${toolName}" not found for simulation "${simKey}". Make sure src/tools/${toolName}.ts exists.`
125
+ );
126
+ continue;
127
+ }
128
+ const resourceMeta = resourceMetaByName.get(toolInfo.resourceName);
129
+ const resourceKey = resourceKeyByName.get(toolInfo.resourceName);
130
+ if (!resourceMeta || !resourceKey) {
131
+ console.warn(
132
+ `Resource "${toolInfo.resourceName}" not found for tool "${toolName}". Make sure a resource with name "${toolInfo.resourceName}" exists in src/resources/.`
133
+ );
134
+ continue;
135
+ }
136
+ const componentName = getComponentName(resourceKey);
137
+ const resourceComponent = resourceComponents[componentName];
138
+ if (!resourceComponent) {
139
+ console.warn(`Resource component "${componentName}" not found for tool "${toolName}".`);
140
+ continue;
141
+ }
142
+ simulations[simKey] = {
143
+ name: simKey,
144
+ userMessage: simulationData.userMessage,
145
+ tool: {
146
+ name: toolName,
147
+ description: toolInfo.tool.description ?? "",
148
+ inputSchema: { type: "object" },
149
+ ...toolInfo.tool.title != null ? { title: toolInfo.tool.title } : {},
150
+ ...toolInfo.tool.annotations != null ? { annotations: toolInfo.tool.annotations } : {},
151
+ ...toolInfo.tool._meta != null ? { _meta: toolInfo.tool._meta } : {}
152
+ },
153
+ resource: {
154
+ uri: `ui://${resourceKey}`,
155
+ name: resourceKey,
156
+ ...resourceMeta.title != null ? { title: resourceMeta.title } : {},
157
+ ...resourceMeta.description != null ? { description: resourceMeta.description } : {},
158
+ ...resourceMeta.mimeType != null ? { mimeType: resourceMeta.mimeType } : {},
159
+ ...resourceMeta._meta != null ? { _meta: resourceMeta._meta } : {}
160
+ },
161
+ toolInput: simulationData.toolInput,
162
+ toolResult: simulationData.toolResult,
163
+ resourceUrl: `/.sunpeak/resource-loader.html?component=${componentName}`
164
+ };
165
+ }
166
+ return simulations;
167
+ }
168
+ function findResourceDirs(baseDir, filePattern, fs) {
169
+ if (!fs.existsSync(baseDir)) {
170
+ return [];
171
+ }
172
+ const entries = fs.readdirSync(baseDir, { withFileTypes: true });
173
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => {
174
+ const key = entry.name;
175
+ const dir = `${baseDir}/${key}`;
176
+ const resourcePath = `${dir}/${filePattern(key)}`;
177
+ if (!fs.existsSync(resourcePath)) {
178
+ return null;
179
+ }
180
+ return { key, dir, resourcePath };
181
+ }).filter((info) => info !== null);
182
+ }
183
+ function findToolFiles(toolsDir, fs) {
184
+ if (!fs.existsSync(toolsDir)) {
185
+ return [];
186
+ }
187
+ const entries = fs.readdirSync(toolsDir, { withFileTypes: true });
188
+ return entries.filter((entry) => !entry.isDirectory() && entry.name.endsWith(".ts")).map((entry) => ({
189
+ name: entry.name.replace(/\.ts$/, ""),
190
+ path: `${toolsDir}/${entry.name}`
191
+ }));
192
+ }
193
+ function findSimulationFilesFlat(simulationsDir, fs) {
194
+ if (!fs.existsSync(simulationsDir)) {
195
+ return [];
196
+ }
197
+ const entries = fs.readdirSync(simulationsDir, { withFileTypes: true });
198
+ return entries.filter((entry) => !entry.isDirectory() && entry.name.endsWith(".json")).map((entry) => ({
199
+ name: entry.name.replace(/\.json$/, ""),
200
+ path: `${simulationsDir}/${entry.name}`
201
+ }));
202
+ }
203
+ export {
204
+ buildResourceMap as a,
205
+ buildDevSimulations as b,
206
+ buildSimulations as c,
207
+ createResourceExports as d,
208
+ extractResourceKey as e,
209
+ extractSimulationKey as f,
210
+ findResourceDirs as g,
211
+ findResourceKey as h,
212
+ getComponentName as i,
213
+ findSimulationFilesFlat as j,
214
+ findToolFiles as k,
215
+ toPascalCase as t
216
+ };
217
+ //# sourceMappingURL=discovery-CH80W5l9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-CH80W5l9.js","sources":["../src/lib/discovery.ts"],"sourcesContent":["/**\n * Discovery utilities for auto-discovering resources and simulations\n *\n * These helpers process the results of import.meta.glob() calls to extract\n * keys, build component maps, and connect simulations to resources.\n *\n * The glob calls themselves must remain in the template (Vite compile-time),\n * but all the processing logic lives here for easy updates across templates.\n *\n * Node.js utilities (findResourceDirs, findToolFiles, etc.) can be used\n * by CLI commands for build-time and runtime discovery.\n */\n\nimport type { Simulation } from '../types/simulation.js';\n\n/**\n * Convert a kebab-case string to PascalCase\n * @example toPascalCase('review') // 'Review'\n * @example toPascalCase('album-art') // 'AlbumArt'\n */\nexport function toPascalCase(str: string): string {\n return str\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n}\n\n/**\n * Extract the resource key from a resource file path.\n * Matches {name}.tsx (e.g., './albums/albums.tsx' → 'albums')\n */\nexport function extractResourceKey(path: string): string | undefined {\n const match = path.match(/([^/]+)\\.tsx$/);\n return match ? match[1] : undefined;\n}\n\n/**\n * Extract the simulation key from a simulation file path.\n * Matches any *.json file (e.g., './show-albums.json' → 'show-albums')\n */\nexport function extractSimulationKey(path: string): string | undefined {\n const match = path.match(/([^/]+)\\.json$/);\n return match ? match[1] : undefined;\n}\n\n/**\n * Find the best matching resource key for a simulation key.\n * Matches the longest resource name that is a prefix of the simulation key.\n * @example findResourceKey('review-diff', ['review', 'carousel']) // 'review'\n * @example findResourceKey('albums', ['albums', 'review']) // 'albums'\n */\nexport function findResourceKey(simulationKey: string, resourceKeys: string[]): string | undefined {\n // Sort by length descending to find longest match first\n const sorted = [...resourceKeys].sort((a, b) => b.length - a.length);\n for (const resourceKey of sorted) {\n if (simulationKey === resourceKey || simulationKey.startsWith(resourceKey + '-')) {\n return resourceKey;\n }\n }\n return undefined;\n}\n\n/**\n * Get the expected component export name for a resource\n * @example getComponentName('review') // 'ReviewResource'\n * @example getComponentName('album-art') // 'AlbumArtResource'\n */\nexport function getComponentName(resourceKey: string): string {\n return `${toPascalCase(resourceKey)}Resource`;\n}\n\n// --- Glob processing helpers ---\n\ntype GlobModules = Record<string, unknown>;\n\n/**\n * Process resource component modules from import.meta.glob() result.\n * Extracts components and exports them with PascalCase names.\n *\n * @example\n * const modules = import.meta.glob('./*\\/*.tsx', { eager: true });\n * export default createResourceExports(modules);\n */\nexport function createResourceExports(modules: GlobModules): Record<string, React.ComponentType> {\n const resources: Record<string, React.ComponentType> = {};\n\n for (const [path, module] of Object.entries(modules)) {\n const key = extractResourceKey(path);\n if (!key) continue;\n\n const exportName = getComponentName(key);\n const mod = module as Record<string, unknown>;\n\n // Try default export first, then named export matching the expected name\n const component = mod.default ?? mod[exportName];\n\n // Accept functions (regular components) or objects (forwardRef/memo components)\n if (component && (typeof component === 'function' || typeof component === 'object')) {\n resources[exportName] = component as React.ComponentType;\n }\n }\n\n return resources;\n}\n\n/**\n * Build a resource metadata map from import.meta.glob() result.\n * Used for connecting simulations to their resource definitions.\n *\n * @example\n * const modules = import.meta.glob('../src/resources/*\\/*.tsx', { eager: true });\n * const resourcesMap = buildResourceMap(modules);\n */\nexport function buildResourceMap<T>(modules: GlobModules): Map<string, T> {\n const map = new Map<string, T>();\n\n for (const [path, module] of Object.entries(modules)) {\n const key = extractResourceKey(path);\n if (key) {\n map.set(key, (module as { resource: T }).resource);\n }\n }\n\n return map;\n}\n\n/**\n * Options for building simulations from discovered modules\n */\nexport interface BuildSimulationsOptions<TResource, TSimulation> {\n /** Glob result of simulation JSON files */\n simulationModules: GlobModules;\n /** Map of resource key -> resource metadata */\n resourcesMap: Map<string, TResource>;\n /** Map of component name -> React component */\n resourceComponents: Record<string, React.ComponentType>;\n /** Create the final simulation object */\n createSimulation: (\n simulationKey: string,\n simulationData: unknown,\n resource: TResource,\n resourceComponent: React.ComponentType\n ) => TSimulation;\n /** Optional warning handler for missing resources */\n onMissingResource?: (simulationKey: string, expectedPrefix: string) => void;\n}\n\n/**\n * Build simulations by connecting simulation data with resources and components.\n * This is the main orchestration function for dev server bootstrap.\n */\nexport function buildSimulations<TResource, TSimulation>(\n options: BuildSimulationsOptions<TResource, TSimulation>\n): Record<string, TSimulation> {\n const {\n simulationModules,\n resourcesMap,\n resourceComponents,\n createSimulation,\n onMissingResource = (key, prefix) =>\n console.warn(\n `No matching resource found for simulation \"${key}\". ` +\n `Expected a resource file like src/resources/${prefix}/${prefix}.tsx`\n ),\n } = options;\n\n const resourceKeys = Array.from(resourcesMap.keys());\n const simulations: Record<string, TSimulation> = {};\n\n for (const [path, module] of Object.entries(simulationModules)) {\n const simulationKey = extractSimulationKey(path);\n if (!simulationKey) continue;\n\n const simulationData = (module as { default: unknown }).default;\n\n // Find matching resource\n const resourceKey = findResourceKey(simulationKey, resourceKeys);\n if (!resourceKey) {\n onMissingResource(simulationKey, simulationKey.split('-')[0]);\n continue;\n }\n\n const resource = resourcesMap.get(resourceKey)!;\n\n // Get component\n const componentName = getComponentName(resourceKey);\n const resourceComponent = resourceComponents[componentName];\n\n if (!resourceComponent) {\n console.warn(\n `Resource component \"${componentName}\" not found for resource \"${resourceKey}\". ` +\n `Make sure src/resources/${resourceKey}/${resourceKey}.tsx exists with a default export.`\n );\n continue;\n }\n\n simulations[simulationKey] = createSimulation(\n simulationKey,\n simulationData,\n resource,\n resourceComponent\n );\n }\n\n return simulations;\n}\n\n// --- Dev server helpers ---\n\n/**\n * Resource metadata from resource .tsx files\n */\nexport interface ResourceMetadata {\n name: string;\n [key: string]: unknown;\n}\n\n/**\n * Options for building dev simulations\n */\nexport interface BuildDevSimulationsOptions {\n /** Glob result of simulation JSON files */\n simulationModules: GlobModules;\n /** Resource components map from src/resources/index.ts */\n resourceComponents: Record<string, React.ComponentType>;\n /** Glob result of tool files: import.meta.glob('src/tools/*.ts', { eager: true }) */\n toolModules: GlobModules;\n /** Glob result of resource .tsx files from src/resources/ */\n resourceModules: GlobModules;\n}\n\n/**\n * Tool metadata extracted from a tool module's `tool` export\n */\ninterface ToolModuleInfo {\n tool: Record<string, unknown>;\n /** Resource name string from tool.resource */\n resourceName: string;\n}\n\n/**\n * Build simulations for the dev server from glob results.\n * Simulation JSON has `\"tool\": \"tool-name\"` string referencing a tool file.\n * Tool files have `resource: 'name'` linking to a resource discovered from resourceModules.\n */\nexport function buildDevSimulations(\n options: BuildDevSimulationsOptions\n): Record<string, Simulation> {\n const { simulationModules, resourceComponents, toolModules, resourceModules } = options;\n\n // Build resource metadata map from resource modules (keyed by resource name)\n const resourceMetaByName = new Map<string, ResourceMetadata>();\n const resourceKeyByName = new Map<string, string>();\n for (const [path, module] of Object.entries(resourceModules)) {\n const key = extractResourceKey(path);\n if (!key) continue;\n const mod = module as { resource?: ResourceMetadata };\n if (mod.resource) {\n // Use explicit name if provided, otherwise derive from directory key\n const name = mod.resource.name ?? key;\n resourceMetaByName.set(name, { ...mod.resource, name });\n resourceKeyByName.set(name, key);\n }\n }\n\n // Build tool map from tool modules\n const toolsMap = new Map<string, ToolModuleInfo>();\n if (toolModules) {\n for (const [path, module] of Object.entries(toolModules)) {\n const nameMatch = path.match(/([^/]+)\\.ts$/);\n if (!nameMatch) continue;\n const mod = module as { tool?: Record<string, unknown> };\n if (mod.tool) {\n const resourceName = mod.tool.resource as string | undefined;\n if (resourceName) {\n toolsMap.set(nameMatch[1], { tool: mod.tool, resourceName });\n }\n }\n }\n }\n\n const simulations: Record<string, Simulation> = {};\n\n for (const [path, module] of Object.entries(simulationModules)) {\n const simKey = extractSimulationKey(path);\n if (!simKey) continue;\n\n const simulationData = (module as { default: Record<string, unknown> }).default;\n\n const toolName =\n typeof simulationData.tool === 'string' ? (simulationData.tool as string) : simKey;\n const toolInfo = toolsMap.get(toolName);\n if (!toolInfo) {\n console.warn(\n `Tool \"${toolName}\" not found for simulation \"${simKey}\". ` +\n `Make sure src/tools/${toolName}.ts exists.`\n );\n continue;\n }\n\n // Look up resource metadata by name\n const resourceMeta = resourceMetaByName.get(toolInfo.resourceName);\n const resourceKey = resourceKeyByName.get(toolInfo.resourceName);\n if (!resourceMeta || !resourceKey) {\n console.warn(\n `Resource \"${toolInfo.resourceName}\" not found for tool \"${toolName}\". ` +\n `Make sure a resource with name \"${toolInfo.resourceName}\" exists in src/resources/.`\n );\n continue;\n }\n\n const componentName = getComponentName(resourceKey);\n const resourceComponent = resourceComponents[componentName];\n\n if (!resourceComponent) {\n console.warn(`Resource component \"${componentName}\" not found for tool \"${toolName}\".`);\n continue;\n }\n\n simulations[simKey] = {\n name: simKey,\n userMessage: simulationData.userMessage as string | undefined,\n tool: {\n name: toolName,\n description: (toolInfo.tool.description as string) ?? '',\n inputSchema: { type: 'object' as const },\n ...(toolInfo.tool.title != null ? { title: toolInfo.tool.title as string } : {}),\n ...(toolInfo.tool.annotations != null\n ? { annotations: toolInfo.tool.annotations as Record<string, unknown> }\n : {}),\n ...(toolInfo.tool._meta != null\n ? { _meta: toolInfo.tool._meta as Record<string, unknown> }\n : {}),\n },\n resource: {\n uri: `ui://${resourceKey}`,\n name: resourceKey,\n ...(resourceMeta.title != null ? { title: resourceMeta.title as string } : {}),\n ...(resourceMeta.description != null\n ? { description: resourceMeta.description as string }\n : {}),\n ...(resourceMeta.mimeType != null ? { mimeType: resourceMeta.mimeType as string } : {}),\n ...(resourceMeta._meta != null\n ? { _meta: resourceMeta._meta as Record<string, unknown> }\n : {}),\n },\n toolInput: simulationData.toolInput as Record<string, unknown> | undefined,\n toolResult: simulationData.toolResult as Simulation['toolResult'],\n resourceUrl: `/.sunpeak/resource-loader.html?component=${componentName}`,\n };\n }\n\n return simulations;\n}\n\n// --- Node.js utilities for CLI commands ---\n// These utilities use standard Node.js APIs and can be imported by build/push/mcp commands.\n\n/**\n * Information about a discovered resource directory\n */\nexport interface ResourceDirInfo {\n /** Resource key (directory name), e.g., 'albums', 'carousel' */\n key: string;\n /** Full path to the resource directory */\n dir: string;\n /** Full path to the main resource file (tsx or json depending on context) */\n resourcePath: string;\n}\n\n/**\n * File system operations interface for dependency injection in tests\n */\nexport interface FsOps {\n readdirSync: (\n path: string,\n options: { withFileTypes: true }\n ) => Array<{ name: string; isDirectory: () => boolean }>;\n existsSync: (path: string) => boolean;\n}\n\n/**\n * Find all resource directories in a base directory.\n * Each valid resource directory contains a file matching the expected pattern.\n *\n * @param baseDir - Base directory to scan (e.g., 'src/resources' or 'dist')\n * @param filePattern - Function to generate expected filename from resource key\n * @param fs - File system operations (for testing)\n *\n * @example\n * // Find source resources (tsx files)\n * const resources = findResourceDirs('src/resources', key => `${key}.tsx`);\n *\n * @example\n * // Find built resources (js files)\n * const resources = findResourceDirs('dist', key => `${key}.js`);\n */\nexport function findResourceDirs(\n baseDir: string,\n filePattern: (key: string) => string,\n fs: FsOps\n): ResourceDirInfo[] {\n if (!fs.existsSync(baseDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(baseDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => entry.isDirectory())\n .map((entry) => {\n const key = entry.name;\n const dir = `${baseDir}/${key}`;\n const resourcePath = `${dir}/${filePattern(key)}`;\n\n if (!fs.existsSync(resourcePath)) {\n return null;\n }\n\n return { key, dir, resourcePath };\n })\n .filter((info): info is ResourceDirInfo => info !== null);\n}\n\n// --- Tool files + flat simulations discovery ---\n\n/**\n * Information about a discovered tool file\n */\nexport interface ToolFileInfo {\n /** Tool name derived from filename (e.g., 'show-albums') */\n name: string;\n /** Full path to the tool file */\n path: string;\n}\n\n/**\n * Find all tool files in a tools directory.\n * Matches *.ts files directly in the directory (not recursive).\n *\n * @example\n * findToolFiles('src/tools', fs)\n * // [{ name: 'show-albums', path: 'src/tools/show-albums.ts' }]\n */\nexport function findToolFiles(\n toolsDir: string,\n fs: Pick<FsOps, 'readdirSync' | 'existsSync'>\n): ToolFileInfo[] {\n if (!fs.existsSync(toolsDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(toolsDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => !entry.isDirectory() && entry.name.endsWith('.ts'))\n .map((entry) => ({\n name: entry.name.replace(/\\.ts$/, ''),\n path: `${toolsDir}/${entry.name}`,\n }));\n}\n\n/**\n * Information about a discovered simulation file (flat convention)\n */\nexport interface SimulationFileInfo {\n /** Filename without extension (e.g., 'show-albums') */\n name: string;\n /** Full path to the simulation file */\n path: string;\n}\n\n/**\n * Find all simulation JSON files in a flat simulations directory.\n * Matches any *.json file directly in the directory.\n *\n * @example\n * findSimulationFilesFlat('tests/simulations', fs)\n * // [{ name: 'show-albums', path: 'tests/simulations/show-albums.json' }]\n */\nexport function findSimulationFilesFlat(\n simulationsDir: string,\n fs: Pick<FsOps, 'readdirSync' | 'existsSync'>\n): SimulationFileInfo[] {\n if (!fs.existsSync(simulationsDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(simulationsDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => !entry.isDirectory() && entry.name.endsWith('.json'))\n .map((entry) => ({\n name: entry.name.replace(/\\.json$/, ''),\n path: `${simulationsDir}/${entry.name}`,\n }));\n}\n"],"names":[],"mappings":"AAoBO,SAAS,aAAa,KAAqB;AAChD,SAAO,IACJ,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAA,IAAgB,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;AAMO,SAAS,mBAAmB,MAAkC;AACnE,QAAM,QAAQ,KAAK,MAAM,eAAe;AACxC,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAMO,SAAS,qBAAqB,MAAkC;AACrE,QAAM,QAAQ,KAAK,MAAM,gBAAgB;AACzC,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAQO,SAAS,gBAAgB,eAAuB,cAA4C;AAEjG,QAAM,SAAS,CAAC,GAAG,YAAY,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AACnE,aAAW,eAAe,QAAQ;AAChC,QAAI,kBAAkB,eAAe,cAAc,WAAW,cAAc,GAAG,GAAG;AAChF,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,iBAAiB,aAA6B;AAC5D,SAAO,GAAG,aAAa,WAAW,CAAC;AACrC;AAcO,SAAS,sBAAsB,SAA2D;AAC/F,QAAM,YAAiD,CAAA;AAEvD,aAAW,CAAC,MAAM,MAAM,KAAK,OA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AAS,wBACd,gBACA,IACsB;AACtB,MAAI,CAAC,GAAG,WAAW,cAAc,GAAG;AAClC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,UAAU,GAAG,YAAY,gBAAgB,EAAE,eAAe,MAAM;AAEtE,SAAO,QACJ,OAAO,CAAC,UAAU,CAAC,MAAM,YAAA,KAAiB,MAAM,KAAK,SAAS,OAAO,CAAC,EACtE,IAAI,CAAC,WAAW;AAAA,IACf,MAAM,MAAM,KAAK,QAAQ,WAAW,EAAE;AAAA,IACtC,MAAM,GAAG,cAAc,IAAI,MAAM,IAAI;AAAA,EAAA,EACrC;AACN;"}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ function toPascalCase(str) {
3
+ return str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
4
+ }
5
+ function extractResourceKey(path) {
6
+ const match = path.match(/([^/]+)\.tsx$/);
7
+ return match ? match[1] : void 0;
8
+ }
9
+ function extractSimulationKey(path) {
10
+ const match = path.match(/([^/]+)\.json$/);
11
+ return match ? match[1] : void 0;
12
+ }
13
+ function findResourceKey(simulationKey, resourceKeys) {
14
+ const sorted = [...resourceKeys].sort((a, b) => b.length - a.length);
15
+ for (const resourceKey of sorted) {
16
+ if (simulationKey === resourceKey || simulationKey.startsWith(resourceKey + "-")) {
17
+ return resourceKey;
18
+ }
19
+ }
20
+ return void 0;
21
+ }
22
+ function getComponentName(resourceKey) {
23
+ return `${toPascalCase(resourceKey)}Resource`;
24
+ }
25
+ function createResourceExports(modules) {
26
+ const resources = {};
27
+ for (const [path, module2] of Object.entries(modules)) {
28
+ const key = extractResourceKey(path);
29
+ if (!key) continue;
30
+ const exportName = getComponentName(key);
31
+ const mod = module2;
32
+ const component = mod.default ?? mod[exportName];
33
+ if (component && (typeof component === "function" || typeof component === "object")) {
34
+ resources[exportName] = component;
35
+ }
36
+ }
37
+ return resources;
38
+ }
39
+ function buildResourceMap(modules) {
40
+ const map = /* @__PURE__ */ new Map();
41
+ for (const [path, module2] of Object.entries(modules)) {
42
+ const key = extractResourceKey(path);
43
+ if (key) {
44
+ map.set(key, module2.resource);
45
+ }
46
+ }
47
+ return map;
48
+ }
49
+ function buildSimulations(options) {
50
+ const {
51
+ simulationModules,
52
+ resourcesMap,
53
+ resourceComponents,
54
+ createSimulation,
55
+ onMissingResource = (key, prefix) => console.warn(
56
+ `No matching resource found for simulation "${key}". Expected a resource file like src/resources/${prefix}/${prefix}.tsx`
57
+ )
58
+ } = options;
59
+ const resourceKeys = Array.from(resourcesMap.keys());
60
+ const simulations = {};
61
+ for (const [path, module2] of Object.entries(simulationModules)) {
62
+ const simulationKey = extractSimulationKey(path);
63
+ if (!simulationKey) continue;
64
+ const simulationData = module2.default;
65
+ const resourceKey = findResourceKey(simulationKey, resourceKeys);
66
+ if (!resourceKey) {
67
+ onMissingResource(simulationKey, simulationKey.split("-")[0]);
68
+ continue;
69
+ }
70
+ const resource = resourcesMap.get(resourceKey);
71
+ const componentName = getComponentName(resourceKey);
72
+ const resourceComponent = resourceComponents[componentName];
73
+ if (!resourceComponent) {
74
+ console.warn(
75
+ `Resource component "${componentName}" not found for resource "${resourceKey}". Make sure src/resources/${resourceKey}/${resourceKey}.tsx exists with a default export.`
76
+ );
77
+ continue;
78
+ }
79
+ simulations[simulationKey] = createSimulation(
80
+ simulationKey,
81
+ simulationData,
82
+ resource,
83
+ resourceComponent
84
+ );
85
+ }
86
+ return simulations;
87
+ }
88
+ function buildDevSimulations(options) {
89
+ const { simulationModules, resourceComponents, toolModules, resourceModules } = options;
90
+ const resourceMetaByName = /* @__PURE__ */ new Map();
91
+ const resourceKeyByName = /* @__PURE__ */ new Map();
92
+ for (const [path, module2] of Object.entries(resourceModules)) {
93
+ const key = extractResourceKey(path);
94
+ if (!key) continue;
95
+ const mod = module2;
96
+ if (mod.resource) {
97
+ const name = mod.resource.name ?? key;
98
+ resourceMetaByName.set(name, { ...mod.resource, name });
99
+ resourceKeyByName.set(name, key);
100
+ }
101
+ }
102
+ const toolsMap = /* @__PURE__ */ new Map();
103
+ if (toolModules) {
104
+ for (const [path, module2] of Object.entries(toolModules)) {
105
+ const nameMatch = path.match(/([^/]+)\.ts$/);
106
+ if (!nameMatch) continue;
107
+ const mod = module2;
108
+ if (mod.tool) {
109
+ const resourceName = mod.tool.resource;
110
+ if (resourceName) {
111
+ toolsMap.set(nameMatch[1], { tool: mod.tool, resourceName });
112
+ }
113
+ }
114
+ }
115
+ }
116
+ const simulations = {};
117
+ for (const [path, module2] of Object.entries(simulationModules)) {
118
+ const simKey = extractSimulationKey(path);
119
+ if (!simKey) continue;
120
+ const simulationData = module2.default;
121
+ const toolName = typeof simulationData.tool === "string" ? simulationData.tool : simKey;
122
+ const toolInfo = toolsMap.get(toolName);
123
+ if (!toolInfo) {
124
+ console.warn(
125
+ `Tool "${toolName}" not found for simulation "${simKey}". Make sure src/tools/${toolName}.ts exists.`
126
+ );
127
+ continue;
128
+ }
129
+ const resourceMeta = resourceMetaByName.get(toolInfo.resourceName);
130
+ const resourceKey = resourceKeyByName.get(toolInfo.resourceName);
131
+ if (!resourceMeta || !resourceKey) {
132
+ console.warn(
133
+ `Resource "${toolInfo.resourceName}" not found for tool "${toolName}". Make sure a resource with name "${toolInfo.resourceName}" exists in src/resources/.`
134
+ );
135
+ continue;
136
+ }
137
+ const componentName = getComponentName(resourceKey);
138
+ const resourceComponent = resourceComponents[componentName];
139
+ if (!resourceComponent) {
140
+ console.warn(`Resource component "${componentName}" not found for tool "${toolName}".`);
141
+ continue;
142
+ }
143
+ simulations[simKey] = {
144
+ name: simKey,
145
+ userMessage: simulationData.userMessage,
146
+ tool: {
147
+ name: toolName,
148
+ description: toolInfo.tool.description ?? "",
149
+ inputSchema: { type: "object" },
150
+ ...toolInfo.tool.title != null ? { title: toolInfo.tool.title } : {},
151
+ ...toolInfo.tool.annotations != null ? { annotations: toolInfo.tool.annotations } : {},
152
+ ...toolInfo.tool._meta != null ? { _meta: toolInfo.tool._meta } : {}
153
+ },
154
+ resource: {
155
+ uri: `ui://${resourceKey}`,
156
+ name: resourceKey,
157
+ ...resourceMeta.title != null ? { title: resourceMeta.title } : {},
158
+ ...resourceMeta.description != null ? { description: resourceMeta.description } : {},
159
+ ...resourceMeta.mimeType != null ? { mimeType: resourceMeta.mimeType } : {},
160
+ ...resourceMeta._meta != null ? { _meta: resourceMeta._meta } : {}
161
+ },
162
+ toolInput: simulationData.toolInput,
163
+ toolResult: simulationData.toolResult,
164
+ resourceUrl: `/.sunpeak/resource-loader.html?component=${componentName}`
165
+ };
166
+ }
167
+ return simulations;
168
+ }
169
+ function findResourceDirs(baseDir, filePattern, fs) {
170
+ if (!fs.existsSync(baseDir)) {
171
+ return [];
172
+ }
173
+ const entries = fs.readdirSync(baseDir, { withFileTypes: true });
174
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => {
175
+ const key = entry.name;
176
+ const dir = `${baseDir}/${key}`;
177
+ const resourcePath = `${dir}/${filePattern(key)}`;
178
+ if (!fs.existsSync(resourcePath)) {
179
+ return null;
180
+ }
181
+ return { key, dir, resourcePath };
182
+ }).filter((info) => info !== null);
183
+ }
184
+ function findToolFiles(toolsDir, fs) {
185
+ if (!fs.existsSync(toolsDir)) {
186
+ return [];
187
+ }
188
+ const entries = fs.readdirSync(toolsDir, { withFileTypes: true });
189
+ return entries.filter((entry) => !entry.isDirectory() && entry.name.endsWith(".ts")).map((entry) => ({
190
+ name: entry.name.replace(/\.ts$/, ""),
191
+ path: `${toolsDir}/${entry.name}`
192
+ }));
193
+ }
194
+ function findSimulationFilesFlat(simulationsDir, fs) {
195
+ if (!fs.existsSync(simulationsDir)) {
196
+ return [];
197
+ }
198
+ const entries = fs.readdirSync(simulationsDir, { withFileTypes: true });
199
+ return entries.filter((entry) => !entry.isDirectory() && entry.name.endsWith(".json")).map((entry) => ({
200
+ name: entry.name.replace(/\.json$/, ""),
201
+ path: `${simulationsDir}/${entry.name}`
202
+ }));
203
+ }
204
+ exports.buildDevSimulations = buildDevSimulations;
205
+ exports.buildResourceMap = buildResourceMap;
206
+ exports.buildSimulations = buildSimulations;
207
+ exports.createResourceExports = createResourceExports;
208
+ exports.extractResourceKey = extractResourceKey;
209
+ exports.extractSimulationKey = extractSimulationKey;
210
+ exports.findResourceDirs = findResourceDirs;
211
+ exports.findResourceKey = findResourceKey;
212
+ exports.findSimulationFilesFlat = findSimulationFilesFlat;
213
+ exports.findToolFiles = findToolFiles;
214
+ exports.getComponentName = getComponentName;
215
+ exports.toPascalCase = toPascalCase;
216
+ //# sourceMappingURL=discovery-DmB8_4QL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-DmB8_4QL.cjs","sources":["../src/lib/discovery.ts"],"sourcesContent":["/**\n * Discovery utilities for auto-discovering resources and simulations\n *\n * These helpers process the results of import.meta.glob() calls to extract\n * keys, build component maps, and connect simulations to resources.\n *\n * The glob calls themselves must remain in the template (Vite compile-time),\n * but all the processing logic lives here for easy updates across templates.\n *\n * Node.js utilities (findResourceDirs, findToolFiles, etc.) can be used\n * by CLI commands for build-time and runtime discovery.\n */\n\nimport type { Simulation } from '../types/simulation.js';\n\n/**\n * Convert a kebab-case string to PascalCase\n * @example toPascalCase('review') // 'Review'\n * @example toPascalCase('album-art') // 'AlbumArt'\n */\nexport function toPascalCase(str: string): string {\n return str\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n}\n\n/**\n * Extract the resource key from a resource file path.\n * Matches {name}.tsx (e.g., './albums/albums.tsx' → 'albums')\n */\nexport function extractResourceKey(path: string): string | undefined {\n const match = path.match(/([^/]+)\\.tsx$/);\n return match ? match[1] : undefined;\n}\n\n/**\n * Extract the simulation key from a simulation file path.\n * Matches any *.json file (e.g., './show-albums.json' → 'show-albums')\n */\nexport function extractSimulationKey(path: string): string | undefined {\n const match = path.match(/([^/]+)\\.json$/);\n return match ? match[1] : undefined;\n}\n\n/**\n * Find the best matching resource key for a simulation key.\n * Matches the longest resource name that is a prefix of the simulation key.\n * @example findResourceKey('review-diff', ['review', 'carousel']) // 'review'\n * @example findResourceKey('albums', ['albums', 'review']) // 'albums'\n */\nexport function findResourceKey(simulationKey: string, resourceKeys: string[]): string | undefined {\n // Sort by length descending to find longest match first\n const sorted = [...resourceKeys].sort((a, b) => b.length - a.length);\n for (const resourceKey of sorted) {\n if (simulationKey === resourceKey || simulationKey.startsWith(resourceKey + '-')) {\n return resourceKey;\n }\n }\n return undefined;\n}\n\n/**\n * Get the expected component export name for a resource\n * @example getComponentName('review') // 'ReviewResource'\n * @example getComponentName('album-art') // 'AlbumArtResource'\n */\nexport function getComponentName(resourceKey: string): string {\n return `${toPascalCase(resourceKey)}Resource`;\n}\n\n// --- Glob processing helpers ---\n\ntype GlobModules = Record<string, unknown>;\n\n/**\n * Process resource component modules from import.meta.glob() result.\n * Extracts components and exports them with PascalCase names.\n *\n * @example\n * const modules = import.meta.glob('./*\\/*.tsx', { eager: true });\n * export default createResourceExports(modules);\n */\nexport function createResourceExports(modules: GlobModules): Record<string, React.ComponentType> {\n const resources: Record<string, React.ComponentType> = {};\n\n for (const [path, module] of Object.entries(modules)) {\n const key = extractResourceKey(path);\n if (!key) continue;\n\n const exportName = getComponentName(key);\n const mod = module as Record<string, unknown>;\n\n // Try default export first, then named export matching the expected name\n const component = mod.default ?? mod[exportName];\n\n // Accept functions (regular components) or objects (forwardRef/memo components)\n if (component && (typeof component === 'function' || typeof component === 'object')) {\n resources[exportName] = component as React.ComponentType;\n }\n }\n\n return resources;\n}\n\n/**\n * Build a resource metadata map from import.meta.glob() result.\n * Used for connecting simulations to their resource definitions.\n *\n * @example\n * const modules = import.meta.glob('../src/resources/*\\/*.tsx', { eager: true });\n * const resourcesMap = buildResourceMap(modules);\n */\nexport function buildResourceMap<T>(modules: GlobModules): Map<string, T> {\n const map = new Map<string, T>();\n\n for (const [path, module] of Object.entries(modules)) {\n const key = extractResourceKey(path);\n if (key) {\n map.set(key, (module as { resource: T }).resource);\n }\n }\n\n return map;\n}\n\n/**\n * Options for building simulations from discovered modules\n */\nexport interface BuildSimulationsOptions<TResource, TSimulation> {\n /** Glob result of simulation JSON files */\n simulationModules: GlobModules;\n /** Map of resource key -> resource metadata */\n resourcesMap: Map<string, TResource>;\n /** Map of component name -> React component */\n resourceComponents: Record<string, React.ComponentType>;\n /** Create the final simulation object */\n createSimulation: (\n simulationKey: string,\n simulationData: unknown,\n resource: TResource,\n resourceComponent: React.ComponentType\n ) => TSimulation;\n /** Optional warning handler for missing resources */\n onMissingResource?: (simulationKey: string, expectedPrefix: string) => void;\n}\n\n/**\n * Build simulations by connecting simulation data with resources and components.\n * This is the main orchestration function for dev server bootstrap.\n */\nexport function buildSimulations<TResource, TSimulation>(\n options: BuildSimulationsOptions<TResource, TSimulation>\n): Record<string, TSimulation> {\n const {\n simulationModules,\n resourcesMap,\n resourceComponents,\n createSimulation,\n onMissingResource = (key, prefix) =>\n console.warn(\n `No matching resource found for simulation \"${key}\". ` +\n `Expected a resource file like src/resources/${prefix}/${prefix}.tsx`\n ),\n } = options;\n\n const resourceKeys = Array.from(resourcesMap.keys());\n const simulations: Record<string, TSimulation> = {};\n\n for (const [path, module] of Object.entries(simulationModules)) {\n const simulationKey = extractSimulationKey(path);\n if (!simulationKey) continue;\n\n const simulationData = (module as { default: unknown }).default;\n\n // Find matching resource\n const resourceKey = findResourceKey(simulationKey, resourceKeys);\n if (!resourceKey) {\n onMissingResource(simulationKey, simulationKey.split('-')[0]);\n continue;\n }\n\n const resource = resourcesMap.get(resourceKey)!;\n\n // Get component\n const componentName = getComponentName(resourceKey);\n const resourceComponent = resourceComponents[componentName];\n\n if (!resourceComponent) {\n console.warn(\n `Resource component \"${componentName}\" not found for resource \"${resourceKey}\". ` +\n `Make sure src/resources/${resourceKey}/${resourceKey}.tsx exists with a default export.`\n );\n continue;\n }\n\n simulations[simulationKey] = createSimulation(\n simulationKey,\n simulationData,\n resource,\n resourceComponent\n );\n }\n\n return simulations;\n}\n\n// --- Dev server helpers ---\n\n/**\n * Resource metadata from resource .tsx files\n */\nexport interface ResourceMetadata {\n name: string;\n [key: string]: unknown;\n}\n\n/**\n * Options for building dev simulations\n */\nexport interface BuildDevSimulationsOptions {\n /** Glob result of simulation JSON files */\n simulationModules: GlobModules;\n /** Resource components map from src/resources/index.ts */\n resourceComponents: Record<string, React.ComponentType>;\n /** Glob result of tool files: import.meta.glob('src/tools/*.ts', { eager: true }) */\n toolModules: GlobModules;\n /** Glob result of resource .tsx files from src/resources/ */\n resourceModules: GlobModules;\n}\n\n/**\n * Tool metadata extracted from a tool module's `tool` export\n */\ninterface ToolModuleInfo {\n tool: Record<string, unknown>;\n /** Resource name string from tool.resource */\n resourceName: string;\n}\n\n/**\n * Build simulations for the dev server from glob results.\n * Simulation JSON has `\"tool\": \"tool-name\"` string referencing a tool file.\n * Tool files have `resource: 'name'` linking to a resource discovered from resourceModules.\n */\nexport function buildDevSimulations(\n options: BuildDevSimulationsOptions\n): Record<string, Simulation> {\n const { simulationModules, resourceComponents, toolModules, resourceModules } = options;\n\n // Build resource metadata map from resource modules (keyed by resource name)\n const resourceMetaByName = new Map<string, ResourceMetadata>();\n const resourceKeyByName = new Map<string, string>();\n for (const [path, module] of Object.entries(resourceModules)) {\n const key = extractResourceKey(path);\n if (!key) continue;\n const mod = module as { resource?: ResourceMetadata };\n if (mod.resource) {\n // Use explicit name if provided, otherwise derive from directory key\n const name = mod.resource.name ?? key;\n resourceMetaByName.set(name, { ...mod.resource, name });\n resourceKeyByName.set(name, key);\n }\n }\n\n // Build tool map from tool modules\n const toolsMap = new Map<string, ToolModuleInfo>();\n if (toolModules) {\n for (const [path, module] of Object.entries(toolModules)) {\n const nameMatch = path.match(/([^/]+)\\.ts$/);\n if (!nameMatch) continue;\n const mod = module as { tool?: Record<string, unknown> };\n if (mod.tool) {\n const resourceName = mod.tool.resource as string | undefined;\n if (resourceName) {\n toolsMap.set(nameMatch[1], { tool: mod.tool, resourceName });\n }\n }\n }\n }\n\n const simulations: Record<string, Simulation> = {};\n\n for (const [path, module] of Object.entries(simulationModules)) {\n const simKey = extractSimulationKey(path);\n if (!simKey) continue;\n\n const simulationData = (module as { default: Record<string, unknown> }).default;\n\n const toolName =\n typeof simulationData.tool === 'string' ? (simulationData.tool as string) : simKey;\n const toolInfo = toolsMap.get(toolName);\n if (!toolInfo) {\n console.warn(\n `Tool \"${toolName}\" not found for simulation \"${simKey}\". ` +\n `Make sure src/tools/${toolName}.ts exists.`\n );\n continue;\n }\n\n // Look up resource metadata by name\n const resourceMeta = resourceMetaByName.get(toolInfo.resourceName);\n const resourceKey = resourceKeyByName.get(toolInfo.resourceName);\n if (!resourceMeta || !resourceKey) {\n console.warn(\n `Resource \"${toolInfo.resourceName}\" not found for tool \"${toolName}\". ` +\n `Make sure a resource with name \"${toolInfo.resourceName}\" exists in src/resources/.`\n );\n continue;\n }\n\n const componentName = getComponentName(resourceKey);\n const resourceComponent = resourceComponents[componentName];\n\n if (!resourceComponent) {\n console.warn(`Resource component \"${componentName}\" not found for tool \"${toolName}\".`);\n continue;\n }\n\n simulations[simKey] = {\n name: simKey,\n userMessage: simulationData.userMessage as string | undefined,\n tool: {\n name: toolName,\n description: (toolInfo.tool.description as string) ?? '',\n inputSchema: { type: 'object' as const },\n ...(toolInfo.tool.title != null ? { title: toolInfo.tool.title as string } : {}),\n ...(toolInfo.tool.annotations != null\n ? { annotations: toolInfo.tool.annotations as Record<string, unknown> }\n : {}),\n ...(toolInfo.tool._meta != null\n ? { _meta: toolInfo.tool._meta as Record<string, unknown> }\n : {}),\n },\n resource: {\n uri: `ui://${resourceKey}`,\n name: resourceKey,\n ...(resourceMeta.title != null ? { title: resourceMeta.title as string } : {}),\n ...(resourceMeta.description != null\n ? { description: resourceMeta.description as string }\n : {}),\n ...(resourceMeta.mimeType != null ? { mimeType: resourceMeta.mimeType as string } : {}),\n ...(resourceMeta._meta != null\n ? { _meta: resourceMeta._meta as Record<string, unknown> }\n : {}),\n },\n toolInput: simulationData.toolInput as Record<string, unknown> | undefined,\n toolResult: simulationData.toolResult as Simulation['toolResult'],\n resourceUrl: `/.sunpeak/resource-loader.html?component=${componentName}`,\n };\n }\n\n return simulations;\n}\n\n// --- Node.js utilities for CLI commands ---\n// These utilities use standard Node.js APIs and can be imported by build/push/mcp commands.\n\n/**\n * Information about a discovered resource directory\n */\nexport interface ResourceDirInfo {\n /** Resource key (directory name), e.g., 'albums', 'carousel' */\n key: string;\n /** Full path to the resource directory */\n dir: string;\n /** Full path to the main resource file (tsx or json depending on context) */\n resourcePath: string;\n}\n\n/**\n * File system operations interface for dependency injection in tests\n */\nexport interface FsOps {\n readdirSync: (\n path: string,\n options: { withFileTypes: true }\n ) => Array<{ name: string; isDirectory: () => boolean }>;\n existsSync: (path: string) => boolean;\n}\n\n/**\n * Find all resource directories in a base directory.\n * Each valid resource directory contains a file matching the expected pattern.\n *\n * @param baseDir - Base directory to scan (e.g., 'src/resources' or 'dist')\n * @param filePattern - Function to generate expected filename from resource key\n * @param fs - File system operations (for testing)\n *\n * @example\n * // Find source resources (tsx files)\n * const resources = findResourceDirs('src/resources', key => `${key}.tsx`);\n *\n * @example\n * // Find built resources (js files)\n * const resources = findResourceDirs('dist', key => `${key}.js`);\n */\nexport function findResourceDirs(\n baseDir: string,\n filePattern: (key: string) => string,\n fs: FsOps\n): ResourceDirInfo[] {\n if (!fs.existsSync(baseDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(baseDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => entry.isDirectory())\n .map((entry) => {\n const key = entry.name;\n const dir = `${baseDir}/${key}`;\n const resourcePath = `${dir}/${filePattern(key)}`;\n\n if (!fs.existsSync(resourcePath)) {\n return null;\n }\n\n return { key, dir, resourcePath };\n })\n .filter((info): info is ResourceDirInfo => info !== null);\n}\n\n// --- Tool files + flat simulations discovery ---\n\n/**\n * Information about a discovered tool file\n */\nexport interface ToolFileInfo {\n /** Tool name derived from filename (e.g., 'show-albums') */\n name: string;\n /** Full path to the tool file */\n path: string;\n}\n\n/**\n * Find all tool files in a tools directory.\n * Matches *.ts files directly in the directory (not recursive).\n *\n * @example\n * findToolFiles('src/tools', fs)\n * // [{ name: 'show-albums', path: 'src/tools/show-albums.ts' }]\n */\nexport function findToolFiles(\n toolsDir: string,\n fs: Pick<FsOps, 'readdirSync' | 'existsSync'>\n): ToolFileInfo[] {\n if (!fs.existsSync(toolsDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(toolsDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => !entry.isDirectory() && entry.name.endsWith('.ts'))\n .map((entry) => ({\n name: entry.name.replace(/\\.ts$/, ''),\n path: `${toolsDir}/${entry.name}`,\n }));\n}\n\n/**\n * Information about a discovered simulation file (flat convention)\n */\nexport interface SimulationFileInfo {\n /** Filename without extension (e.g., 'show-albums') */\n name: string;\n /** Full path to the simulation file */\n path: string;\n}\n\n/**\n * Find all simulation JSON files in a flat simulations directory.\n * Matches any *.json file directly in the directory.\n *\n * @example\n * findSimulationFilesFlat('tests/simulations', fs)\n * // [{ name: 'show-albums', path: 'tests/simulations/show-albums.json' }]\n */\nexport function findSimulationFilesFlat(\n simulationsDir: string,\n fs: Pick<FsOps, 'readdirSync' | 'existsSync'>\n): SimulationFileInfo[] {\n if (!fs.existsSync(simulationsDir)) {\n return [];\n }\n\n const entries = fs.readdirSync(simulationsDir, { withFileTypes: true });\n\n return entries\n .filter((entry) => !entry.isDirectory() && entry.name.endsWith('.json'))\n .map((entry) => ({\n name: entry.name.replace(/\\.json$/, ''),\n path: `${simulationsDir}/${entry.name}`,\n }));\n}\n"],"names":["module"],"mappings":";AAoBO,SAAS,aAAa,KAAqB;AAChD,SAAO,IACJ,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAA,IAAgB,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;AAMO,SAAS,mBAAmB,MAAkC;AACnE,QAAM,QAAQ,KAAK,MAAM,eAAe;AACxC,SAAO,QAAQ,MAAM,CAAC,IAAI;AA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CAAC,GAAG,WAAW,YAAY,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,EAAE,KAAK,KAAK,aAAA;AAAA,EACrB,CAAC,EACA,OAAO,CAAC,SAAkC,SAAS,IAAI;AAC5D;AAsBO,SAAS,cACd,UACA,IACgB;AAChB,MAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC5B,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,UAAU,GAAG,YAAY,UAAU,EAAE,eAAe,MAAM;AAEhE,SAAO,QACJ,OAAO,CAAC,UAAU,CAAC,MAAM,YAAA,KAAiB,MAAM,KAAK,SAAS,KAAK,CAAC,EACpE,IAAI,CAAC,WAAW;AAAA,IACf,MAAM,MAAM,KAAK,QAAQ,SAAS,EAAE;AAAA,IACpC,MAAM,GAAG,QAAQ,IAAI,MAAM,IAAI;AAAA,EAAA,EAC/B;AACN;AAoBO,SAAS,wBACd,gBACA,IACsB;AACtB,MAAI,CAAC,GAAG,WAAW,cAAc,GAAG;AAClC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,UAAU,GAAG,YAAY,gBAAgB,EAAE,eAAe,MAAM;AAEtE,SAAO,QACJ,OAAO,CAAC,UAAU,CAAC,MAAM,YAAA,KAAiB,MAAM,KAAK,SAAS,OAAO,CAAC,EACtE,IAAI,CAAC,WAAW;AAAA,IACf,MAAM,MAAM,KAAK,QAAQ,WAAW,EAAE;AAAA,IACtC,MAAM,GAAG,cAAc,IAAI,MAAM,IAAI;AAAA,EAAA,EACrC;AACN;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
- import { I as IframeResource, M as McpAppHost, a as SCREEN_WIDTHS, b as SidebarCheckbox, c as SidebarCollapsibleControl, d as SidebarControl, e as SidebarInput, f as SidebarSelect, g as SidebarTextarea, h as SidebarToggle, i as SimpleSidebar, S as Simulator, T as ThemeProvider, j as extractResourceCSP, k as getHostShell, l as getRegisteredHosts, r as registerHostShell, u as useSimulatorState, m as useThemeContext } from "./simulator-CxrtnguM.js";
1
+ import { I as IframeResource, M as McpAppHost, a as SCREEN_WIDTHS, b as SidebarCheckbox, c as SidebarCollapsibleControl, d as SidebarControl, e as SidebarInput, f as SidebarSelect, g as SidebarTextarea, h as SidebarToggle, i as SimpleSidebar, S as Simulator, T as ThemeProvider, j as extractResourceCSP, k as getHostShell, l as getRegisteredHosts, r as registerHostShell, u as useSimulatorState, m as useThemeContext } from "./simulator-C0H_k092.js";
2
2
  import { c as createSimulatorUrl } from "./simulator-url-CuLqtnSS.js";
3
- import { b as buildDevSimulations, a as buildResourceMap, c as buildSimulations, d as createResourceExports, e as extractResourceKey, f as extractSimulationKey, g as extractSimulationName, h as findResourceDirs, i as findResourceKey, j as findSimulationFiles, k as getComponentName, l as isSimulationFile, t as toPascalCase } from "./discovery-DzV3HLXs.js";
3
+ import { b as buildDevSimulations, a as buildResourceMap, c as buildSimulations, d as createResourceExports, e as extractResourceKey, f as extractSimulationKey, g as findResourceDirs, h as findResourceKey, i as getComponentName, t as toPascalCase } from "./discovery-CH80W5l9.js";
4
4
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5
5
  __proto__: null,
6
6
  IframeResource,
@@ -24,14 +24,11 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
24
24
  extractResourceCSP,
25
25
  extractResourceKey,
26
26
  extractSimulationKey,
27
- extractSimulationName,
28
27
  findResourceDirs,
29
28
  findResourceKey,
30
- findSimulationFiles,
31
29
  getComponentName,
32
30
  getHostShell,
33
31
  getRegisteredHosts,
34
- isSimulationFile,
35
32
  registerHostShell,
36
33
  toPascalCase,
37
34
  useSimulatorState,
@@ -40,4 +37,4 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
40
37
  export {
41
38
  index as i
42
39
  };
43
- //# sourceMappingURL=index-CutQgPzR.js.map
40
+ //# sourceMappingURL=index-BjnAsaqp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BjnAsaqp.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- const simulator = require("./simulator-DcfQBRXE.cjs");
2
+ const simulator = require("./simulator-B56j5P8W.cjs");
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const simulatorUrl = require("./simulator-url-rgg_KYOg.cjs");
6
- const discovery = require("./discovery-CRR3SlyI.cjs");
6
+ const discovery = require("./discovery-DmB8_4QL.cjs");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
9
  if (e) {
@@ -513,15 +513,12 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
513
513
  extractResourceCSP: simulator.extractResourceCSP,
514
514
  extractResourceKey: discovery.extractResourceKey,
515
515
  extractSimulationKey: discovery.extractSimulationKey,
516
- extractSimulationName: discovery.extractSimulationName,
517
516
  findResourceDirs: discovery.findResourceDirs,
518
517
  findResourceKey: discovery.findResourceKey,
519
- findSimulationFiles: discovery.findSimulationFiles,
520
518
  getComponentName: discovery.getComponentName,
521
- isSimulationFile: discovery.isSimulationFile,
522
519
  toPascalCase: discovery.toPascalCase,
523
520
  useThemeContext: simulator.useThemeContext
524
521
  }, Symbol.toStringTag, { value: "Module" }));
525
522
  exports.ChatGPTSimulator = ChatGPTSimulator;
526
523
  exports.index = index;
527
- //# sourceMappingURL=index-Cngntkp2.cjs.map
524
+ //# sourceMappingURL=index-BvQ_ZuOO.cjs.map