@plitzi/sdk-server 0.32.4 → 0.32.6

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 (476) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/adapters/jsonAdapters.js +6 -1
  3. package/dist/core/createServer.js +8 -44
  4. package/dist/core/health.js +15 -0
  5. package/dist/core/http/dispatcher.js +29 -0
  6. package/dist/core/http/securityHeaders.js +15 -0
  7. package/dist/core/http/stages/authRoutes.js +41 -0
  8. package/dist/core/http/stages/health.js +12 -0
  9. package/dist/core/http/stages/middlewares.js +16 -0
  10. package/dist/core/http/stages/pluginAssets.js +20 -0
  11. package/dist/core/http/stages/static.js +30 -0
  12. package/dist/core/server/baseServer.js +29 -0
  13. package/dist/core/server/mcpServer.js +29 -0
  14. package/dist/core/server/ssrServer.js +54 -0
  15. package/dist/core/services/mcp.js +22 -0
  16. package/dist/core/services/preview.js +37 -0
  17. package/dist/core/services/registry.js +30 -0
  18. package/dist/core/services/resolve.js +12 -0
  19. package/dist/core/services/rsc.js +11 -0
  20. package/dist/core/services/ssr.js +13 -0
  21. package/dist/core/transports.js +9 -9
  22. package/dist/helpers/buildServerInfo.js +3 -9
  23. package/dist/index.js +20 -6
  24. package/dist/modules/ai/AIEngine.js +4 -4
  25. package/dist/modules/ai/toolkit.js +58 -0
  26. package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
  27. package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
  28. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
  29. package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
  30. package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
  31. package/dist/modules/mcp/catalogs/cssCatalog.js +205 -0
  32. package/dist/modules/mcp/catalogs/observed.js +90 -0
  33. package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
  34. package/dist/modules/mcp/catalogs/registry.js +89 -0
  35. package/dist/modules/mcp/constants.js +4 -0
  36. package/dist/modules/mcp/handler.js +24 -20
  37. package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
  38. package/dist/modules/mcp/helpers/computeVersion.js +16 -0
  39. package/dist/modules/mcp/helpers/guide.js +449 -0
  40. package/dist/modules/mcp/helpers/interactions.js +123 -0
  41. package/dist/modules/mcp/helpers/log.js +54 -0
  42. package/dist/modules/mcp/helpers/opResult.js +18 -0
  43. package/dist/modules/mcp/helpers/space.js +262 -0
  44. package/dist/modules/mcp/helpers/uris.js +44 -0
  45. package/dist/modules/mcp/previewClient.js +31 -0
  46. package/dist/modules/mcp/resources/canonical.js +30 -0
  47. package/dist/modules/mcp/resources/core.js +15 -0
  48. package/dist/modules/mcp/resources/envelope.js +14 -0
  49. package/dist/modules/mcp/resources/primer.js +30 -0
  50. package/dist/modules/mcp/resources/register.js +174 -0
  51. package/dist/modules/mcp/resources/router.js +25 -0
  52. package/dist/modules/mcp/resources/schema.js +43 -0
  53. package/dist/modules/mcp/resources/style.js +34 -0
  54. package/dist/modules/mcp/screenshotClient.js +47 -0
  55. package/dist/modules/mcp/server.js +66 -20
  56. package/dist/modules/mcp/tools/apply/dispatch.js +103 -0
  57. package/dist/modules/mcp/tools/apply/index.js +136 -0
  58. package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
  59. package/dist/modules/mcp/tools/index.js +20 -148
  60. package/dist/modules/mcp/tools/operations/index.js +41 -0
  61. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
  62. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
  63. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
  64. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
  65. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
  66. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +58 -0
  67. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +65 -0
  68. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +30 -0
  69. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
  70. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
  71. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
  72. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
  73. package/dist/modules/mcp/tools/operations/schema/operations.js +39 -0
  74. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
  75. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
  76. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
  77. package/dist/modules/mcp/tools/operations/schema/shared.js +119 -0
  78. package/dist/modules/mcp/tools/operations/schema/translator.js +215 -0
  79. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
  80. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
  81. package/dist/modules/mcp/tools/operations/schema/write.js +109 -0
  82. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
  83. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
  84. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
  85. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
  86. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
  87. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
  88. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
  89. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
  90. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
  91. package/dist/modules/mcp/tools/operations/style/operations.js +27 -0
  92. package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
  93. package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
  94. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
  95. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
  96. package/dist/modules/mcp/tools/operations/style/write.js +108 -0
  97. package/dist/modules/mcp/tools/preview.js +37 -0
  98. package/dist/modules/mcp/tools/read.js +33 -0
  99. package/dist/modules/mcp/tools/screenshot.js +83 -0
  100. package/dist/modules/mcp/tools/search.js +115 -0
  101. package/dist/modules/mcp/tools/shared/tool.js +26 -0
  102. package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
  103. package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
  104. package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
  105. package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
  106. package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
  107. package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
  108. package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
  109. package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
  110. package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
  111. package/dist/modules/mcp/tools/validate.js +39 -0
  112. package/dist/modules/ssr/buildBody.js +2 -2
  113. package/dist/modules/ssr/handler.js +6 -4
  114. package/dist/modules/ssr/prepareRender.js +5 -5
  115. package/dist/modules/ssr/preview.js +106 -0
  116. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  117. package/dist/modules/ssr/streamBody.js +3 -3
  118. package/dist/modules/ssr/template.js +1 -1
  119. package/dist/modules/ssr/views/template.ejs +2 -0
  120. package/dist/plugins/compile.js +1 -1
  121. package/dist/plugins/copy.js +1 -1
  122. package/dist/plugins/manager.js +1 -1
  123. package/dist/server.js +34 -9
  124. package/dist/src/core/createServer.d.ts +5 -1
  125. package/dist/src/core/health.d.ts +10 -0
  126. package/dist/src/core/http/dispatcher.d.ts +7 -0
  127. package/dist/src/core/http/securityHeaders.d.ts +2 -0
  128. package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
  129. package/dist/src/core/http/stages/health.d.ts +2 -0
  130. package/dist/src/core/http/stages/middlewares.d.ts +2 -0
  131. package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
  132. package/dist/src/core/http/stages/static.d.ts +5 -0
  133. package/dist/src/core/http/types.d.ts +19 -0
  134. package/dist/src/core/server/baseServer.d.ts +9 -0
  135. package/dist/src/core/server/mcpServer.d.ts +2 -0
  136. package/dist/src/core/server/ssrServer.d.ts +2 -0
  137. package/dist/src/core/services/mcp.d.ts +3 -0
  138. package/dist/src/core/services/preview.d.ts +2 -0
  139. package/dist/src/core/services/registry.d.ts +4 -0
  140. package/dist/src/core/services/resolve.d.ts +3 -0
  141. package/dist/src/core/services/rsc.d.ts +2 -0
  142. package/dist/src/core/services/ssr.d.ts +3 -0
  143. package/dist/src/core/transports.d.ts +2 -2
  144. package/dist/src/index.d.ts +12 -3
  145. package/dist/src/modules/ai/index.d.ts +1 -0
  146. package/dist/src/modules/ai/toolkit.d.ts +17 -0
  147. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +23 -0
  148. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
  149. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
  150. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
  151. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
  152. package/dist/src/modules/mcp/catalogs/cssCatalog.d.ts +14 -0
  153. package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
  154. package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
  155. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
  156. package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -0
  157. package/dist/src/modules/mcp/constants.d.ts +1 -0
  158. package/dist/src/modules/mcp/handler.d.ts +6 -3
  159. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
  160. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
  161. package/dist/src/modules/mcp/helpers/guide.d.ts +3 -0
  162. package/dist/src/modules/mcp/helpers/index.d.ts +8 -0
  163. package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
  164. package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
  165. package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
  166. package/dist/src/modules/mcp/helpers/space.d.ts +105 -0
  167. package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
  168. package/dist/src/modules/mcp/index.d.ts +12 -5
  169. package/dist/src/modules/mcp/previewClient.d.ts +13 -0
  170. package/dist/src/modules/mcp/resources/canonical.d.ts +6 -0
  171. package/dist/src/modules/mcp/resources/core.d.ts +5 -0
  172. package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
  173. package/dist/src/modules/mcp/resources/index.d.ts +7 -10
  174. package/dist/src/modules/mcp/resources/primer.d.ts +7 -0
  175. package/dist/src/modules/mcp/resources/register.d.ts +6 -0
  176. package/dist/src/modules/mcp/resources/router.d.ts +6 -0
  177. package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
  178. package/dist/src/modules/mcp/resources/style.d.ts +5 -0
  179. package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
  180. package/dist/src/modules/mcp/server.d.ts +21 -3
  181. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
  182. package/dist/src/modules/mcp/tools/apply/index.d.ts +420 -0
  183. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
  184. package/dist/src/modules/mcp/tools/index.d.ts +17 -6
  185. package/dist/src/modules/mcp/tools/operations/index.d.ts +828 -0
  186. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
  187. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
  188. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
  189. package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
  190. package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
  191. package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +22 -0
  192. package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
  193. package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
  194. package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
  195. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +20 -0
  196. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
  197. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
  198. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
  199. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +210 -0
  200. package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
  201. package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
  202. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
  203. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +77 -0
  204. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
  205. package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
  206. package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
  207. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +42 -0
  208. package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
  209. package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
  210. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
  211. package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
  212. package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
  213. package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
  214. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
  215. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
  216. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
  217. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +14 -0
  218. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +231 -0
  219. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
  220. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +12 -0
  221. package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
  222. package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
  223. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +12 -0
  224. package/dist/src/modules/mcp/tools/preview.d.ts +415 -0
  225. package/dist/src/modules/mcp/tools/read.d.ts +8 -0
  226. package/dist/src/modules/mcp/tools/screenshot.d.ts +420 -0
  227. package/dist/src/modules/mcp/tools/search.d.ts +15 -0
  228. package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
  229. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
  230. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
  231. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
  232. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
  233. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
  234. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
  235. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
  236. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
  237. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
  238. package/dist/src/modules/mcp/tools/validate.d.ts +417 -0
  239. package/dist/src/modules/mcp/types/aiSchema.d.ts +218 -0
  240. package/dist/src/modules/mcp/types/index.d.ts +4 -0
  241. package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
  242. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
  243. package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
  244. package/dist/src/modules/ssr/buildBody.d.ts +2 -2
  245. package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
  246. package/dist/src/modules/ssr/preview.d.ts +16 -0
  247. package/dist/src/modules/ssr/streamBody.d.ts +2 -2
  248. package/package.json +16 -14
  249. package/dist/_virtual/_rolldown/runtime.js +0 -13
  250. package/dist/core/requestHandler.js +0 -126
  251. package/dist/modules/mcp/helpers.js +0 -75
  252. package/dist/modules/mcp/resources/glossary/binding.js +0 -73
  253. package/dist/modules/mcp/resources/glossary/collection.js +0 -76
  254. package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
  255. package/dist/modules/mcp/resources/glossary/element.js +0 -68
  256. package/dist/modules/mcp/resources/glossary/environment.js +0 -48
  257. package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
  258. package/dist/modules/mcp/resources/glossary/page.js +0 -70
  259. package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
  260. package/dist/modules/mcp/resources/glossary/resource.js +0 -75
  261. package/dist/modules/mcp/resources/glossary/schema.js +0 -69
  262. package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
  263. package/dist/modules/mcp/resources/glossary/segment.js +0 -59
  264. package/dist/modules/mcp/resources/glossary/space.js +0 -73
  265. package/dist/modules/mcp/resources/glossary/style.js +0 -81
  266. package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
  267. package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
  268. package/dist/modules/mcp/resources/index.js +0 -71
  269. package/dist/modules/mcp/resources/workflows/data.js +0 -49
  270. package/dist/modules/mcp/resources/workflows/elements.js +0 -53
  271. package/dist/modules/mcp/resources/workflows/segments.js +0 -55
  272. package/dist/modules/mcp/resources/workflows/styles.js +0 -91
  273. package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
  274. package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
  275. package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
  276. package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
  277. package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
  278. package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
  279. package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
  280. package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
  281. package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
  282. package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
  283. package/dist/modules/mcp/tools/docs/listResources.js +0 -16
  284. package/dist/modules/mcp/tools/docs/readResource.js +0 -23
  285. package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
  286. package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
  287. package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
  288. package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
  289. package/dist/modules/mcp/tools/resources/addResource.js +0 -33
  290. package/dist/modules/mcp/tools/resources/getResource.js +0 -29
  291. package/dist/modules/mcp/tools/resources/getResources.js +0 -27
  292. package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
  293. package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
  294. package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
  295. package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
  296. package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
  297. package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
  298. package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
  299. package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
  300. package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
  301. package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
  302. package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
  303. package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
  304. package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
  305. package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
  306. package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
  307. package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
  308. package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
  309. package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
  310. package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
  311. package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
  312. package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
  313. package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
  314. package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
  315. package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
  316. package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
  317. package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
  318. package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
  319. package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
  320. package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
  321. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
  322. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
  323. package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
  324. package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
  325. package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
  326. package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
  327. package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
  328. package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
  329. package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
  330. package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
  331. package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
  332. package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
  333. package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
  334. package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
  335. package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
  336. package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
  337. package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
  338. package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
  339. package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
  340. package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
  341. package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
  342. package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
  343. package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
  344. package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
  345. package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
  346. package/dist/package.js +0 -77
  347. package/dist/package.json.d.ts +0 -67
  348. package/dist/src/core/requestHandler.d.ts +0 -5
  349. package/dist/src/modules/mcp/helpers.d.ts +0 -9
  350. package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
  351. package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
  352. package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
  353. package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
  354. package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
  355. package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
  356. package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
  357. package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
  358. package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
  359. package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
  360. package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
  361. package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
  362. package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
  363. package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
  364. package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
  365. package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
  366. package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
  367. package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
  368. package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
  369. package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
  370. package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
  371. package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
  372. package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
  373. package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
  374. package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
  375. package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
  376. package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
  377. package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
  378. package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
  379. package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
  380. package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
  381. package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
  382. package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
  383. package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
  384. package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
  385. package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
  386. package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
  387. package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
  388. package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
  389. package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
  390. package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
  391. package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
  392. package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
  393. package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
  394. package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
  395. package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
  396. package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
  397. package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
  398. package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
  399. package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
  400. package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
  401. package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
  402. package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
  403. package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
  404. package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
  405. package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
  406. package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
  407. package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
  408. package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
  409. package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
  410. package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
  411. package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
  412. package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
  413. package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
  414. package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
  415. package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
  416. package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
  417. package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
  418. package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
  419. package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
  420. package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
  421. package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
  422. package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
  423. package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
  424. package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
  425. package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
  426. package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
  427. package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
  428. package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
  429. package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
  430. package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
  431. package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
  432. package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
  433. package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
  434. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
  435. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
  436. package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
  437. package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
  438. package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
  439. package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
  440. package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
  441. package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
  442. package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
  443. package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
  444. package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
  445. package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
  446. package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
  447. package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
  448. package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
  449. package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
  450. package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
  451. package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
  452. package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
  453. package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
  454. package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
  455. package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
  456. package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
  457. package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
  458. package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
  459. package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
  460. package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
  461. package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
  462. package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
  463. package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
  464. package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
  465. package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
  466. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
  467. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
  468. package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
  469. package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
  470. package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
  471. /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
  472. /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
  473. /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → catalogs/builtinTransformers.test.d.ts} +0 -0
  474. /package/dist/src/modules/mcp/{tools/resources/resources.test.d.ts → helpers/log.test.d.ts} +0 -0
  475. /package/dist/src/modules/mcp/{tools/segment/schema/elements/segmentElements.test.d.ts → mcp.bench.d.ts} +0 -0
  476. /package/dist/src/modules/mcp/{tools/segment/schema/variables/segmentVariables.test.d.ts → mcp.test.d.ts} +0 -0
@@ -0,0 +1,108 @@
1
+ import { expandShorthand } from "../../../catalogs/cssCatalog.js";
2
+ import { defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../../../helpers/uris.js";
3
+ import { fail } from "../../../helpers/opResult.js";
4
+ import processSelector from "@plitzi/sdk-style/helpers/processSelector";
5
+ //#region src/modules/mcp/tools/operations/style/write.ts
6
+ var MODES = [
7
+ "desktop",
8
+ "tablet",
9
+ "mobile"
10
+ ];
11
+ var KIND_LABEL = {
12
+ class: "a reusable class definition",
13
+ element: "a global style for an element type",
14
+ id: "an id rule targeting a single element"
15
+ };
16
+ var KIND_TOOL = {
17
+ class: "upsertDefinition/patchDefinition",
18
+ element: "upsertGlobalStyle/patchGlobalStyle",
19
+ id: "upsertIdStyle/patchIdStyle"
20
+ };
21
+ var KIND_FIELD = {
22
+ class: "ref",
23
+ element: "componentType",
24
+ id: "targetId"
25
+ };
26
+ var guardKind = (style, ref, want) => {
27
+ const clash = MODES.map((mode) => style.platform[mode][ref]).find((item) => item !== void 0 && item.type !== want);
28
+ if (!clash) return null;
29
+ return fail(KIND_FIELD[want], `"${ref}" is already ${KIND_LABEL[clash.type]}; it cannot be edited as ${KIND_LABEL[want]}`, `Edit it with ${KIND_TOOL[clash.type]}, or choose a different ${KIND_FIELD[want]}.`);
30
+ };
31
+ var slotToBlocks = (slot) => {
32
+ const perMode = {};
33
+ for (const mode of MODES) {
34
+ const block = {};
35
+ const baseCss = slot[mode];
36
+ if (baseCss && Object.keys(baseCss).length > 0) block.default = expandShorthand(baseCss);
37
+ for (const [state, dm] of Object.entries(slot.states ?? {})) if (dm[mode]) (block.states ??= {})[state] = expandShorthand(dm[mode]);
38
+ for (const [name, dm] of Object.entries(slot.variants ?? {})) if (dm[mode]) (block.variants ??= {})[name] = { default: expandShorthand(dm[mode]) };
39
+ if (Object.keys(block).length > 0) perMode[mode] = block;
40
+ }
41
+ return perMode;
42
+ };
43
+ var writeStyleItem = (style, ref, base, slots, itemType, componentType) => {
44
+ for (const mode of MODES) {
45
+ const attributes = {};
46
+ const baseBlocks = slotToBlocks(base);
47
+ if (baseBlocks[mode]) attributes.base = baseBlocks[mode];
48
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) {
49
+ const blocks = slotToBlocks(slotDef);
50
+ if (blocks[mode]) attributes[slotName] = blocks[mode];
51
+ }
52
+ if (Object.keys(attributes).length === 0) Reflect.deleteProperty(style.platform[mode], ref);
53
+ else {
54
+ const styleItem = {
55
+ name: ref,
56
+ type: itemType,
57
+ attributes,
58
+ cache: ""
59
+ };
60
+ if (componentType !== void 0) styleItem.componentType = componentType;
61
+ styleItem.cache = processSelector(styleItem);
62
+ style.platform[mode][ref] = styleItem;
63
+ }
64
+ }
65
+ };
66
+ var mergeCss = (base, patch) => {
67
+ const merged = { ...base };
68
+ for (const [key, value] of Object.entries(patch ?? {})) if (value === null) Reflect.deleteProperty(merged, key);
69
+ else merged[key] = value;
70
+ return Object.keys(merged).length > 0 ? merged : void 0;
71
+ };
72
+ var mergeDisplayMode = (base, patch) => {
73
+ const result = {};
74
+ for (const mode of MODES) {
75
+ const css = mergeCss(base?.[mode], patch?.[mode]);
76
+ if (css) result[mode] = css;
77
+ }
78
+ return result;
79
+ };
80
+ var mergeNamedModes = (base, patch) => {
81
+ const names = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(patch ?? {})]);
82
+ const result = {};
83
+ for (const name of names) {
84
+ const dm = mergeDisplayMode(base?.[name], patch?.[name]);
85
+ if (Object.keys(dm).length > 0) result[name] = dm;
86
+ }
87
+ return Object.keys(result).length > 0 ? result : void 0;
88
+ };
89
+ var mergeSlot = (base, patch) => {
90
+ const merged = mergeDisplayMode(base, patch);
91
+ const states = mergeNamedModes(base?.states, patch.states);
92
+ if (states) merged.states = states;
93
+ const variants = mergeNamedModes(base?.variants, patch.variants);
94
+ if (variants) merged.variants = variants;
95
+ return merged;
96
+ };
97
+ var mergePatch = (existing, basePatch, slotsPatch) => {
98
+ const base = mergeSlot(existing, basePatch);
99
+ const slotNames = /* @__PURE__ */ new Set([...Object.keys(existing.slots ?? {}), ...Object.keys(slotsPatch ?? {})]);
100
+ const slots = {};
101
+ for (const name of slotNames) slots[name] = mergeSlot(existing.slots?.[name], slotsPatch?.[name] ?? {});
102
+ return {
103
+ base,
104
+ slots: Object.keys(slots).length > 0 ? slots : void 0
105
+ };
106
+ };
107
+ //#endregion
108
+ export { MODES, defUri, defsUri, globalUri, globalsUri, guardKind, idUri, idsUri, mergePatch, styleVarUri, styleVarsUri, writeStyleItem };
@@ -0,0 +1,37 @@
1
+ import { operation } from "./operations/index.js";
2
+ import { defineTool } from "./shared/tool.js";
3
+ import { z } from "zod";
4
+ //#region src/modules/mcp/tools/preview.ts
5
+ var previewShape = {
6
+ pageRef: z.string().optional().describe("Page ref or id to preview; defaults to the space default page"),
7
+ operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply to a throwaway clone before rendering, so you can preview a change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to preview the current saved state.")
8
+ };
9
+ var previewTool = defineTool({
10
+ name: "plitzi_preview",
11
+ title: "Preview (HTML)",
12
+ description: "Render a page to a full HTML document to inspect the structure of your edits. Pass unsaved `operations` to preview a change before committing (nothing is persisted). Returns the HTML plus the page path and stateVersion. For a real rendered IMAGE that reveals visual issues like overflow, use plitzi_screenshot.",
13
+ inputShape: previewShape,
14
+ access: "read",
15
+ run: async (input, ctx) => {
16
+ if (!ctx.preview || ctx.spaceId === void 0) return {
17
+ error: "PREVIEW_UNAVAILABLE",
18
+ message: "Visual preview is not enabled on this server.",
19
+ hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
20
+ };
21
+ const result = await ctx.preview.render({
22
+ spaceId: ctx.spaceId,
23
+ env: ctx.env,
24
+ pageRef: input.pageRef,
25
+ operations: input.operations
26
+ });
27
+ if (!result.ok) return result;
28
+ return {
29
+ pageRef: input.pageRef ?? "default",
30
+ pagePath: result.pagePath,
31
+ stateVersion: result.stateVersion,
32
+ html: result.html
33
+ };
34
+ }
35
+ });
36
+ //#endregion
37
+ export { previewShape, previewTool };
@@ -0,0 +1,33 @@
1
+ import { resourceErrorMessage } from "../resources/canonical.js";
2
+ import { readResource } from "../resources/router.js";
3
+ import { defineTool } from "./shared/tool.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/read.ts
6
+ var readShape = { uris: z.array(z.string()).min(1).max(50).describe("Resource URIs to read in one batch (max 50). Use the ready-made uris from search / write responses.") };
7
+ var read = (input, space, env) => {
8
+ return { results: input.uris.map((uri) => {
9
+ const found = readResource(space, env, uri);
10
+ if (found) return {
11
+ uri,
12
+ stateVersion: found.stateVersion,
13
+ data: found.data
14
+ };
15
+ const parsed = JSON.parse(resourceErrorMessage(env, uri));
16
+ return {
17
+ uri,
18
+ error: parsed.error,
19
+ message: parsed.message,
20
+ hint: parsed.hint
21
+ };
22
+ }) };
23
+ };
24
+ var readTool = defineTool({
25
+ name: "plitzi_read",
26
+ title: "Batch read",
27
+ description: "Batch-fetch resource content for URIs you ALREADY HOLD (from plitzi_search or a write response) — the tool form of opening MCP resources, for many at once. Pass an array of URIs (pages, elements, definitions, variables) and get them all in one call. NOT for finding things: to locate an element by label/type use plitzi_search; to browse what exists, list the plitzi:// resources. Each result is { uri, stateVersion, data } or a teachable error, so one bad URI never fails the batch. Never hand-build a URI to guess your way to an element — search for it.",
28
+ inputShape: readShape,
29
+ access: "read",
30
+ run: (input, ctx) => read(input, ctx.space, ctx.env)
31
+ });
32
+ //#endregion
33
+ export { read, readShape, readTool };
@@ -0,0 +1,83 @@
1
+ import { operation } from "./operations/index.js";
2
+ import { defineTool, imageResult } from "./shared/tool.js";
3
+ import { z } from "zod";
4
+ //#region src/modules/mcp/tools/screenshot.ts
5
+ var VIEWPORTS = {
6
+ desktop: {
7
+ label: "desktop",
8
+ width: 1440,
9
+ height: 900
10
+ },
11
+ mobile: {
12
+ label: "mobile",
13
+ width: 390,
14
+ height: 844
15
+ }
16
+ };
17
+ var resolveViewports = (choice) => {
18
+ if (choice === "both") return [VIEWPORTS.desktop, VIEWPORTS.mobile];
19
+ if (choice === "mobile") return [VIEWPORTS.mobile];
20
+ return [VIEWPORTS.desktop];
21
+ };
22
+ var screenshotShape = {
23
+ pageRef: z.string().optional().describe("Page ref or id to capture; defaults to the space default page"),
24
+ operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply before rendering, so you can screenshot a proposed change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to capture the current saved state."),
25
+ viewport: z.enum([
26
+ "desktop",
27
+ "mobile",
28
+ "both"
29
+ ]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop.")
30
+ };
31
+ var screenshotTool = defineTool({
32
+ name: "plitzi_screenshot",
33
+ title: "Screenshot",
34
+ description: "Render a page to a real PNG image so you can SEE the visual result of your edits — overflow, misalignment and broken layout that data alone never reveals. Pass unsaved `operations` to screenshot a proposed change before committing, and viewport \"both\" to compare desktop and mobile. Returns the image(s).",
35
+ inputShape: screenshotShape,
36
+ access: "read",
37
+ requires: "screenshot",
38
+ run: async (input, ctx) => {
39
+ if (!ctx.preview || ctx.spaceId === void 0) return {
40
+ error: "PREVIEW_UNAVAILABLE",
41
+ message: "Visual preview is not enabled on this server.",
42
+ hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
43
+ };
44
+ const pv = await ctx.preview.render({
45
+ spaceId: ctx.spaceId,
46
+ env: ctx.env,
47
+ pageRef: input.pageRef,
48
+ operations: input.operations
49
+ });
50
+ if (!pv.ok) return pv;
51
+ const viewports = resolveViewports(input.viewport);
52
+ if (!ctx.screenshot) return {
53
+ warning: "SCREENSHOT_DISABLED",
54
+ message: "The screenshot service is not configured; returning the HTML preview instead.",
55
+ pageRef: input.pageRef ?? "default",
56
+ pagePath: pv.pagePath,
57
+ stateVersion: pv.stateVersion,
58
+ html: pv.html
59
+ };
60
+ const shot = await ctx.screenshot.capture({
61
+ pagePath: pv.pagePath,
62
+ token: pv.token,
63
+ viewports
64
+ });
65
+ if (!shot.ok) return {
66
+ warning: "SCREENSHOT_UNAVAILABLE",
67
+ message: `The screenshot service failed (${shot.message}); returning the HTML preview instead.`,
68
+ hint: "The dedicated browser service is down or unreachable. Inspect the HTML, or retry later.",
69
+ pageRef: input.pageRef ?? "default",
70
+ pagePath: pv.pagePath,
71
+ stateVersion: pv.stateVersion,
72
+ html: pv.html
73
+ };
74
+ return imageResult(shot.images, {
75
+ pageRef: input.pageRef ?? "default",
76
+ pagePath: pv.pagePath,
77
+ stateVersion: pv.stateVersion,
78
+ viewports: viewports.map((v) => v.label)
79
+ });
80
+ }
81
+ });
82
+ //#endregion
83
+ export { screenshotShape, screenshotTool };
@@ -0,0 +1,115 @@
1
+ import { computeVersion } from "../helpers/computeVersion.js";
2
+ import { elementRefOf, getPageElements, isPageElement, nameOf, pageRefOf, pageRefOfElement } from "../helpers/space.js";
3
+ import { elementUri, pageUri } from "../helpers/uris.js";
4
+ import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
5
+ import { elementView, pageSkeletonToAI } from "./operations/schema/translator.js";
6
+ import { defineTool } from "./shared/tool.js";
7
+ import { z } from "zod";
8
+ //#region src/modules/mcp/tools/search.ts
9
+ var searchShape = {
10
+ query: z.string().describe("Case-insensitive match on label, type and attribute values"),
11
+ filters: z.object({
12
+ type: z.string().optional(),
13
+ pageRef: z.string().optional()
14
+ }).optional(),
15
+ include: z.literal("detail").optional().describe("Set to \"detail\" to inline each hit's full props/style so an edit needs no follow-up read"),
16
+ limit: z.number().int().min(1).max(100).optional().describe("Max element hits to return (default 50). Response echoes total and, if more remain, nextOffset."),
17
+ offset: z.number().int().min(0).optional().describe("Element hits to skip (default 0). Page by re-calling with offset = nextOffset until it is absent.")
18
+ };
19
+ var breadcrumb = (schema, el) => {
20
+ const chain = [];
21
+ let current = el;
22
+ const guard = /* @__PURE__ */ new Set();
23
+ while (current && !guard.has(current.id)) {
24
+ guard.add(current.id);
25
+ chain.push(nameOf(current));
26
+ current = current.definition.parentId ? schema.flat[current.definition.parentId] : void 0;
27
+ }
28
+ return chain.reverse();
29
+ };
30
+ var search = (input, space, env) => {
31
+ const query = input.query.toLowerCase();
32
+ const matched = [];
33
+ for (const el of Object.values(space.schema.flat)) {
34
+ if (isPageElement(space.schema, el)) continue;
35
+ if (input.filters?.type && el.definition.type !== input.filters.type) continue;
36
+ const pageRef = pageRefOfElement(space.schema, el);
37
+ if (input.filters?.pageRef && pageRef !== input.filters.pageRef) continue;
38
+ const matches = [];
39
+ if (el.definition.label.toLowerCase().includes(query)) matches.push(`label: ${el.definition.label}`);
40
+ if (el.definition.type.toLowerCase().includes(query)) matches.push(`type: ${el.definition.type}`);
41
+ for (const [key, value] of Object.entries(el.attributes)) if (String(value).toLowerCase().includes(query)) matches.push(`${key}: ${String(value).slice(0, 100)}`);
42
+ if (matches.length === 0) continue;
43
+ matched.push({
44
+ el,
45
+ pageRef,
46
+ ref: elementRefOf(el),
47
+ matches
48
+ });
49
+ }
50
+ const offset = input.offset ?? 0;
51
+ const limit = input.limit ?? 50;
52
+ const total = matched.length;
53
+ const nextOffset = offset + limit < total ? offset + limit : void 0;
54
+ const results = matched.slice(offset, offset + limit).map((hit) => {
55
+ const { detail, version } = elementView(space.schema, hit.el, space.style);
56
+ return {
57
+ pageRef: hit.pageRef,
58
+ ref: hit.ref,
59
+ uri: elementUri(env, hit.ref),
60
+ pageUri: pageUri(env, hit.pageRef),
61
+ stateVersion: version,
62
+ parentRef: detail.parentRef,
63
+ path: breadcrumb(space.schema, hit.el),
64
+ label: hit.el.definition.label,
65
+ type: hit.el.definition.type,
66
+ matches: hit.matches,
67
+ detail: input.include === "detail" ? detail : void 0
68
+ };
69
+ });
70
+ const definitions = [];
71
+ for (const ref of definitionRefs(space.style)) {
72
+ if (ref.toLowerCase().includes(query)) {
73
+ const def = definitionToAI(space.style, ref);
74
+ if (def) definitions.push(def);
75
+ }
76
+ if (definitions.length >= 50) break;
77
+ }
78
+ const pages = [];
79
+ for (const page of getPageElements(space.schema)) {
80
+ const label = nameOf(page);
81
+ const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
82
+ const matches = [];
83
+ if (label.toLowerCase().includes(query)) matches.push(`label: ${label}`);
84
+ if (slug && slug.toLowerCase().includes(query)) matches.push(`slug: ${slug}`);
85
+ if (matches.length === 0) continue;
86
+ const ref = pageRefOf(page);
87
+ pages.push({
88
+ ref,
89
+ uri: pageUri(env, ref),
90
+ stateVersion: computeVersion(pageSkeletonToAI(space.schema, page, space.style)),
91
+ label,
92
+ slug,
93
+ matches
94
+ });
95
+ }
96
+ return {
97
+ results,
98
+ total,
99
+ offset,
100
+ limit,
101
+ nextOffset,
102
+ definitions: definitions.length > 0 ? definitions : void 0,
103
+ pages: pages.length > 0 ? pages : void 0
104
+ };
105
+ };
106
+ var searchTool = defineTool({
107
+ name: "plitzi_search",
108
+ title: "Search",
109
+ description: "FIND elements when you know what you want but not its ref/uri (e.g. \"the hero button\"). Matches label, type or attribute value across all pages. Each hit returns the element uri, its stateVersion (edit with optimistic concurrency, no read needed) and its tree path. Pass include: \"detail\" to inline the full props/style of each hit plus resolvedStyle (the CSS of its classes). Also returns any style definitions matching the query (with full CSS) under `definitions`, and matching pages under `pages`. Element hits are paginated: it returns at most `limit` (default 50) starting at `offset`, plus `total` and — while more remain — `nextOffset` to fetch the next page.",
110
+ inputShape: searchShape,
111
+ access: "read",
112
+ run: (input, ctx) => search(input, ctx.space, ctx.env)
113
+ });
114
+ //#endregion
115
+ export { search, searchShape, searchTool };
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ //#region src/modules/mcp/tools/shared/tool.ts
3
+ /** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
4
+ * PNG, so a vision-capable agent (or MCP client) sees the render directly. */
5
+ var imageResult = (images, meta) => ({ content: [{
6
+ type: "text",
7
+ text: JSON.stringify(meta)
8
+ }, ...images.map((img) => ({
9
+ type: "image",
10
+ data: img.data,
11
+ mimeType: img.mimeType
12
+ }))] });
13
+ /** Author a tool: give it its metadata, its input shape and a typed `run`. The returned descriptor parses the
14
+ * raw args against the shape before handing them to `run`, so `run` is fully typed and no cast is needed.
15
+ * Adding a tool is: call defineTool in its own file and append it to the `tools` registry. */
16
+ var defineTool = (spec) => ({
17
+ name: spec.name,
18
+ title: spec.title,
19
+ description: spec.description,
20
+ inputShape: spec.inputShape,
21
+ access: spec.access,
22
+ requires: spec.requires,
23
+ execute: (args, ctx) => spec.run(z.object(spec.inputShape).parse(args), ctx)
24
+ });
25
+ //#endregion
26
+ export { defineTool, imageResult };
@@ -0,0 +1,124 @@
1
+ import { elementRefOf, findElementByRef } from "../../../helpers/space.js";
2
+ import { definitionToAI, globalStyleToAI, idStyleToAI } from "../../operations/style/translator.js";
3
+ import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
4
+ import { checkSlotCss } from "./css.js";
5
+ import { checkVariantApplication } from "./elements.js";
6
+ import { checkInteractionNode } from "./interactions.js";
7
+ import { buildValidationCtx } from "./index.js";
8
+ //#region src/modules/mcp/tools/shared/validator/audit.ts
9
+ var harvest = (ctx, into, label, run) => {
10
+ const sub = {
11
+ ...ctx,
12
+ errors: [],
13
+ warnings: [],
14
+ warned: /* @__PURE__ */ new Set()
15
+ };
16
+ run(sub);
17
+ for (const e of sub.errors) into.errors.push({
18
+ path: e.path,
19
+ message: `Pre-existing malformation in ${label}: ${e.message}`,
20
+ hint: `${e.hint ? `${e.hint} ` : ""}This issue already exists in the space (NOT caused by your change), but the save is blocked until you fix it too, in this same batch.`,
21
+ ...e.validValues ? { validValues: e.validValues } : {}
22
+ });
23
+ for (const w of sub.warnings) {
24
+ const message = `Pre-existing issue in ${label} (not caused by your change, but worth fixing too): ${w}`;
25
+ if (!into.warnings.includes(message)) into.warnings.push(message);
26
+ }
27
+ };
28
+ var toNode = (id, node) => ({
29
+ id,
30
+ title: node.title,
31
+ nodeType: node.type,
32
+ action: node.action,
33
+ params: node.params,
34
+ enabled: node.enabled,
35
+ when: node.when,
36
+ elementId: node.elementId ?? void 0,
37
+ preview: node.preview
38
+ });
39
+ var auditElement = (space, sub, el) => {
40
+ const hostRef = elementRefOf(el);
41
+ const base = `element "${hostRef}"`;
42
+ for (const [category, list] of Object.entries(el.definition.bindings ?? {})) for (const binding of list) {
43
+ const path = `${base}.bindings.${category}[to=${binding.to}]`;
44
+ checkBindingTransformers(binding.transformers, `${path}.transformers`, sub);
45
+ checkBindingSourceScope(space, sub, hostRef, binding.source, `${path}.source`);
46
+ checkBindingTarget(hostRef, category, binding.to, path, sub);
47
+ }
48
+ for (const [id, node] of Object.entries(el.definition.interactions ?? {})) checkInteractionNode(toNode(id, node), `${base}.interactions.${id}`, sub, hostRef);
49
+ checkVariantApplication(el.definition.initialState, `${base}.initialState`, sub);
50
+ };
51
+ var auditDefinitionCss = (sub, label, def) => {
52
+ const { ref: _ref, slots, ...slot } = def;
53
+ checkSlotCss(slot, label, sub);
54
+ for (const [name, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${label}.slots.${name}`, sub);
55
+ };
56
+ var collectTouched = (ops) => {
57
+ const touched = {
58
+ elementRefs: /* @__PURE__ */ new Set(),
59
+ definitions: /* @__PURE__ */ new Set(),
60
+ globalStyles: /* @__PURE__ */ new Set(),
61
+ idStyles: /* @__PURE__ */ new Set()
62
+ };
63
+ for (const op of ops) switch (op.type) {
64
+ case "upsertElement":
65
+ touched.elementRefs.add(op.element.ref);
66
+ break;
67
+ case "patchElement":
68
+ case "moveElement":
69
+ case "upsertBinding":
70
+ case "patchBinding":
71
+ case "deleteBinding":
72
+ case "upsertInteractionFlow":
73
+ case "patchInteractionNode":
74
+ case "deleteInteraction":
75
+ touched.elementRefs.add(op.ref);
76
+ break;
77
+ case "upsertDefinition":
78
+ case "patchDefinition":
79
+ touched.definitions.add(op.ref);
80
+ break;
81
+ case "upsertGlobalStyle":
82
+ case "patchGlobalStyle":
83
+ touched.globalStyles.add(op.componentType);
84
+ break;
85
+ case "upsertIdStyle":
86
+ case "patchIdStyle":
87
+ touched.idStyles.add(op.targetId);
88
+ break;
89
+ default: break;
90
+ }
91
+ return touched;
92
+ };
93
+ var auditResources = (space, ops) => {
94
+ const ctx = buildValidationCtx(space, ops);
95
+ const result = {
96
+ valid: true,
97
+ errors: [],
98
+ warnings: []
99
+ };
100
+ const touched = collectTouched(ops);
101
+ const seenElements = /* @__PURE__ */ new Set();
102
+ for (const ref of touched.elementRefs) {
103
+ const el = findElementByRef(space.schema, ref);
104
+ if (!el || seenElements.has(el.id)) continue;
105
+ seenElements.add(el.id);
106
+ harvest(ctx, result, `element "${elementRefOf(el)}"`, (sub) => auditElement(space, sub, el));
107
+ }
108
+ for (const ref of touched.definitions) {
109
+ const def = definitionToAI(space.style, ref);
110
+ if (def) harvest(ctx, result, `definition "${ref}"`, (sub) => auditDefinitionCss(sub, `definition "${ref}"`, def));
111
+ }
112
+ for (const componentType of touched.globalStyles) {
113
+ const def = globalStyleToAI(space.style, componentType);
114
+ if (def) harvest(ctx, result, `global style "${componentType}"`, (sub) => auditDefinitionCss(sub, `global style "${componentType}"`, def));
115
+ }
116
+ for (const targetId of touched.idStyles) {
117
+ const def = idStyleToAI(space.style, targetId);
118
+ if (def) harvest(ctx, result, `id style "#${targetId}"`, (sub) => auditDefinitionCss(sub, `id style "#${targetId}"`, def));
119
+ }
120
+ result.valid = result.errors.length === 0;
121
+ return result;
122
+ };
123
+ //#endregion
124
+ export { auditResources };
@@ -0,0 +1,30 @@
1
+ import { slugRouteParams } from "../../../helpers/space.js";
2
+ //#region src/modules/mcp/tools/shared/validator/batch.ts
3
+ var batchDeclaredVars = (ops) => {
4
+ const names = [];
5
+ for (const op of ops) if (op.type === "upsertVariable") names.push(op.name);
6
+ else if (op.type === "upsertPage" && typeof op.slug === "string") names.push(...slugRouteParams(op.slug));
7
+ return names;
8
+ };
9
+ var batchDeclaredPages = (ops) => {
10
+ const refs = /* @__PURE__ */ new Set();
11
+ for (const op of ops) if (op.type === "upsertPage") refs.add(op.ref);
12
+ return refs;
13
+ };
14
+ var batchDeclaredFolders = (ops) => {
15
+ const refs = /* @__PURE__ */ new Set();
16
+ for (const op of ops) if (op.type === "upsertFolder") refs.add(op.ref);
17
+ return refs;
18
+ };
19
+ var batchDeclaredVariants = (ops) => {
20
+ const map = /* @__PURE__ */ new Map();
21
+ for (const op of ops) {
22
+ if (op.type !== "upsertDefinition" && op.type !== "patchDefinition") continue;
23
+ const names = new Set(Object.keys(op.variants ?? {}));
24
+ for (const slot of Object.values(op.slots ?? {})) for (const name of Object.keys(slot.variants ?? {})) names.add(name);
25
+ if (names.size > 0) map.set(op.ref, /* @__PURE__ */ new Set([...map.get(op.ref) ?? [], ...names]));
26
+ }
27
+ return map;
28
+ };
29
+ //#endregion
30
+ export { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };
@@ -0,0 +1,70 @@
1
+ import { getTransformer, suggestTransformer } from "../../../catalogs/builtinTransformers.js";
2
+ import { descendantIds, elementRefOf, findElementByRef } from "../../../helpers/space.js";
3
+ import { warnOnce } from "./context.js";
4
+ import getSourceName from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
5
+ //#region src/modules/mcp/tools/shared/validator/bindings.ts
6
+ var providerOfSource = (space, source) => {
7
+ const head = source.split(".")[0];
8
+ const sep = head.indexOf("_");
9
+ if (sep < 0) return;
10
+ const idRef = head.slice(sep + 1);
11
+ const el = findElementByRef(space.schema, idRef);
12
+ if (!el || getSourceName(el.definition.type, el) !== head) return;
13
+ return {
14
+ ref: elementRefOf(el),
15
+ id: el.id
16
+ };
17
+ };
18
+ var checkBindingTarget = (ref, category, to, path, ctx) => {
19
+ if (category !== "attributes" && category !== "initialState") return;
20
+ const type = ctx.elementType(ref);
21
+ const targets = type ? ctx.typeMeta.get(type)?.bindingTargets?.[category] : void 0;
22
+ if (!targets || targets.size === 0 || targets.has(to)) return;
23
+ warnOnce(ctx, `Binding target "${to}" at ${path} is not among the "${category}" targets the type "${type}" declares (${[...targets].sort().join(", ")}). Verify against plitzi://data-sources; it may still be valid.`);
24
+ };
25
+ var checkBindingSourceScope = (space, ctx, elementRef, source, path) => {
26
+ const provider = providerOfSource(space, source);
27
+ if (!provider) return;
28
+ const bound = findElementByRef(space.schema, elementRef);
29
+ if (!bound) return;
30
+ if (bound.id !== provider.id && descendantIds(space.schema, provider.id).includes(bound.id)) return;
31
+ ctx.errors.push({
32
+ path,
33
+ message: `Binding source "${source}" is provided by element "${provider.ref}", but "${elementRef}" is not inside its subtree`,
34
+ hint: `An element source is scoped to its DESCENDANTS only, so this binding resolves to nothing at runtime (the source is not available outside "${provider.ref}"). Move "${elementRef}" under "${provider.ref}", or bind to a source that is in scope (e.g. a global module source like state/space/navigation).`
35
+ });
36
+ };
37
+ var checkBindingTransformers = (transformers, path, ctx) => {
38
+ transformers?.forEach((transformer, i) => {
39
+ if (transformer.enabled === false) return;
40
+ const base = `${path}[${i}]`;
41
+ const spec = getTransformer(transformer.action);
42
+ if (!spec) {
43
+ const suggestion = suggestTransformer(transformer.action);
44
+ ctx.errors.push({
45
+ path: `${base}.action`,
46
+ message: `Unknown transformer action "${transformer.action}"`,
47
+ hint: `The runtime skips an unknown transformer and passes the value through unchanged.${suggestion ? ` Did you mean "${suggestion}"?` : ""} See the transformers list in plitzi://data-sources.`
48
+ });
49
+ return;
50
+ }
51
+ const params = transformer.params;
52
+ const unknown = Object.keys(params).filter((key) => !(key in spec.params));
53
+ if (spec.strictParams && unknown.length > 0) warnOnce(ctx, `Transformer "${transformer.action}" at ${base} got unknown param(s) ${unknown.map((k) => `"${k}"`).join(", ")} — the runtime ignores them. Valid params: ${Object.keys(spec.params).join(", ") || "(none)"}.`);
54
+ for (const [key, param] of Object.entries(spec.params)) {
55
+ if (param.required && !(key in params)) ctx.errors.push({
56
+ path: `${base}.params.${key}`,
57
+ message: `Transformer "${transformer.action}" is missing required param "${key}"`,
58
+ hint: param.description
59
+ });
60
+ if (param.type === "select" && param.options && key in params && !param.options.includes(params[key])) ctx.errors.push({
61
+ path: `${base}.params.${key}`,
62
+ message: `Transformer "${transformer.action}" param "${key}" is "${params[key]}", not one of its options`,
63
+ hint: `Use one of: ${param.options.join(", ")}.`,
64
+ validValues: param.options
65
+ });
66
+ }
67
+ });
68
+ };
69
+ //#endregion
70
+ export { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers };
@@ -0,0 +1,35 @@
1
+ //#region src/modules/mcp/tools/shared/validator/context.ts
2
+ var VAR_REF = /\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g;
3
+ var CSS_VAR = /var\(\s*--([A-Za-z_][\w-]*)\s*\)/g;
4
+ var RAW_CODE_TYPES = /* @__PURE__ */ new Set([
5
+ "blockJsx",
6
+ "blockHtml",
7
+ "custom"
8
+ ]);
9
+ var warnOnce = (ctx, message) => {
10
+ if (!ctx.warned.has(message)) {
11
+ ctx.warned.add(message);
12
+ ctx.warnings.push(message);
13
+ }
14
+ };
15
+ var checkVarRefs = (text, path, ctx) => {
16
+ for (const match of text.matchAll(VAR_REF)) {
17
+ const name = match[1];
18
+ if (!ctx.schemaVars.has(name)) warnOnce(ctx, `Unknown variable {{${name}}} at ${path}: not a space schema variable or a page route param. Read plitzi://schema-variables, or use a route param from the page skeleton (routeParams).`);
19
+ }
20
+ };
21
+ var checkStyleVarRefs = (text, path, ctx) => {
22
+ for (const match of text.matchAll(CSS_VAR)) {
23
+ const name = match[1];
24
+ if (!ctx.styleVars.has(name)) {
25
+ const tokens = [...ctx.styleVars];
26
+ warnOnce(ctx, `Unknown style variable var(--${name}) at ${path}: not a design token in this space. ${tokens.length > 0 ? `Available tokens: ${tokens.slice(0, 30).join(", ")}${tokens.length > 30 ? ", …" : ""}.` : "Read plitzi://style-variables for the valid token names."}`);
27
+ }
28
+ }
29
+ };
30
+ var checkObservedName = (value, observed, kind, resource, path, ctx) => {
31
+ if (!value || observed.size === 0 || observed.has(value)) return;
32
+ warnOnce(ctx, `${kind} "${value}" at ${path} was not seen in this space. Verify against ${resource}; it may still be valid.`);
33
+ };
34
+ //#endregion
35
+ export { RAW_CODE_TYPES, checkObservedName, checkStyleVarRefs, checkVarRefs, warnOnce };