@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,18 @@
1
+ import { schemaVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { z } from "zod";
4
+ //#region src/modules/mcp/tools/operations/schema/variables/deleteVariable.ts
5
+ var deleteVariableOp = z.object({
6
+ type: z.literal("deleteVariable"),
7
+ name: z.string().describe("Name of the schema variable to delete")
8
+ }).describe("Delete a space-level schema variable by name.");
9
+ var deleteVariable = (space, env, op) => {
10
+ space.schema.variables = space.schema.variables.filter((v) => v.name !== op.name);
11
+ return {
12
+ ...empty(),
13
+ deleted: 1,
14
+ staleResources: [schemaVarsUri(env)]
15
+ };
16
+ };
17
+ //#endregion
18
+ export { deleteVariable, deleteVariableOp };
@@ -0,0 +1,42 @@
1
+ import { schemaVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { scalar } from "../shared.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/schema/variables/upsertVariable.ts
6
+ var upsertVariableOp = z.object({
7
+ type: z.literal("upsertVariable"),
8
+ name: z.string().describe("Variable name; referenced in content as {{name}}"),
9
+ variableType: z.string().describe("Runtime type (text|number|...); NOT the `type` discriminator"),
10
+ value: scalar,
11
+ category: z.string().optional(),
12
+ subValues: z.array(z.object({
13
+ when: z.unknown(),
14
+ value: scalar
15
+ })).optional()
16
+ }).describe("Create or update a space-level schema variable (a {{name}} value shared across the space).");
17
+ var upsertVariable = (space, env, op) => {
18
+ const variable = {
19
+ name: op.name,
20
+ category: op.category ?? "general",
21
+ type: op.variableType,
22
+ value: op.value,
23
+ subValues: op.subValues ?? []
24
+ };
25
+ const idx = space.schema.variables.findIndex((v) => v.name === op.name);
26
+ if (idx >= 0) {
27
+ space.schema.variables[idx] = variable;
28
+ return {
29
+ ...empty(),
30
+ updated: 1,
31
+ staleResources: [schemaVarsUri(env)]
32
+ };
33
+ }
34
+ space.schema.variables.push(variable);
35
+ return {
36
+ ...empty(),
37
+ created: 1,
38
+ staleResources: [schemaVarsUri(env)]
39
+ };
40
+ };
41
+ //#endregion
42
+ export { upsertVariable, upsertVariableOp };
@@ -0,0 +1,109 @@
1
+ import { findElementByRef, findPageByRef, generateObjectId, indexAddElement, indexReRefElement, resolveRef, spaceIndex } from "../../../helpers/space.js";
2
+ import { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../../../helpers/uris.js";
3
+ import { fail } from "../../../helpers/opResult.js";
4
+ import { isValidIdRef, makeIdRef } from "@plitzi/sdk-schema/helpers/idRef";
5
+ //#region src/modules/mcp/tools/operations/schema/write.ts
6
+ var ID_REF_HINT = "Start with a letter, then letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"food_item\"). The ref becomes the element idRef, which the runtime embeds in source names like `apiContainer_<idRef>.field` and in interaction targets — a dot would split those paths (an underscore is fine: the FIRST `_` separates the type from the idRef, and element types carry none, so extra underscores are unambiguous).";
7
+ var TAKEN_HINT = "An idRef must be unique across the space — pick a different ref, or address the existing element by this ref.";
8
+ /** Every ref in an element input tree (the element plus its nested children) — each becomes a new element's idRef. */
9
+ var collectInputRefs = (input) => [input.ref, ...(input.children ?? []).flatMap(collectInputRefs)];
10
+ /** Validate a ref that is about to become an element's idRef: the charset, then whether anything already answers
11
+ * to it. The charset rule is sdk-schema's `isValidIdRef` — never a regex restated here, so the MCP cannot drift
12
+ * from what the builder and the schema validator enforce.
13
+ *
14
+ * Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
15
+ * a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
16
+ * shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
17
+ * run the same rule twice. Null when the ref is usable.
18
+ *
19
+ * Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
20
+ * charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
21
+ var guardNewRef = (space, ref, field) => {
22
+ if (!isValidIdRef(ref)) return fail(field, `"${ref}" is not a valid idRef`, ID_REF_HINT);
23
+ if (findElementByRef(space.schema, ref) || findPageByRef(space.schema, ref)) return fail(field, `"${ref}" is already used by another element in this space`, TAKEN_HINT);
24
+ return null;
25
+ };
26
+ var removeFromParent = (space, child) => {
27
+ const parent = child.definition.parentId ? space.schema.flat[child.definition.parentId] : void 0;
28
+ if (parent?.definition.items) parent.definition.items = parent.definition.items.filter((id) => id !== child.id);
29
+ };
30
+ var placeChild = (parent, childId, index) => {
31
+ const items = parent.definition.items ?? (parent.definition.items = []);
32
+ if (index === void 0 || index < 0 || index >= items.length) items.push(childId);
33
+ else items.splice(index, 0, childId);
34
+ };
35
+ var writeInitialState = (el, input, merge) => {
36
+ const current = el.definition.initialState ?? {};
37
+ const next = { ...current };
38
+ if (input.styleVariant !== void 0) if (merge) {
39
+ const merged = { ...current.styleVariant };
40
+ for (const [cls, selectors] of Object.entries(input.styleVariant)) merged[cls] = {
41
+ ...merged[cls],
42
+ ...selectors
43
+ };
44
+ next.styleVariant = merged;
45
+ } else next.styleVariant = input.styleVariant;
46
+ if (input.visibility !== void 0) next.visibility = input.visibility;
47
+ el.definition.initialState = next;
48
+ };
49
+ var createElement = (space, page, input, parent, index) => {
50
+ const id = generateObjectId();
51
+ const { subType, ...props } = {
52
+ subType: input.subType,
53
+ ...input.props
54
+ };
55
+ const styleSelectors = { base: (input.style?.base ?? []).join(" ") };
56
+ for (const [slot, classes] of Object.entries(input.style?.slots ?? {})) styleSelectors[slot] = classes.join(" ");
57
+ const el = {
58
+ id,
59
+ idRef: input.ref,
60
+ attributes: subType === void 0 ? props : {
61
+ subType,
62
+ ...props
63
+ },
64
+ definition: {
65
+ rootId: page.id,
66
+ parentId: parent.id,
67
+ label: input.label ?? input.ref,
68
+ type: input.type,
69
+ items: [],
70
+ styleSelectors
71
+ }
72
+ };
73
+ space.schema.flat[id] = el;
74
+ placeChild(parent, id, index);
75
+ indexAddElement(space.schema, el, page.id);
76
+ if (input.initialState) writeInitialState(el, input.initialState, false);
77
+ for (const child of input.children ?? []) createElement(space, page, child, el, void 0);
78
+ };
79
+ /** The idRef an element is wired by, minting one when it has none. Interactions are keyed by idRef, so an element
80
+ * that is about to host or be targeted by a flow must have one — rather than make the agent assign it with a
81
+ * separate patchElement, the MCP gives it a free `<type>-<n>` ref (unique across the space) and proceeds. An
82
+ * element that already has an idRef keeps it. Mutates the element in place and returns the ref. */
83
+ var ensureIdRef = (space, el) => {
84
+ if (el.idRef) return el.idRef;
85
+ const index = spaceIndex(space.schema);
86
+ el.idRef = makeIdRef(el.definition.type, (candidate) => index.elementByRef.has(candidate) || index.pageByRef.has(candidate));
87
+ indexReRefElement(space.schema, el);
88
+ return el.idRef;
89
+ };
90
+ /** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
91
+ * target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
92
+ * target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
93
+ * that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
94
+ var resolveTargetRef = (space, elementId) => {
95
+ const el = space.schema.flat[elementId] ?? findElementByRef(space.schema, elementId);
96
+ return el ? ensureIdRef(space, el) : elementId;
97
+ };
98
+ /** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
99
+ * element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
100
+ * errors as patchElement without repeating them. */
101
+ var resolveElement = (space, env, pageRef, ref) => {
102
+ const page = findPageByRef(space.schema, pageRef);
103
+ if (!page) return { error: fail("pageRef", `Page "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs`) };
104
+ const el = resolveRef(space.schema, page, ref);
105
+ if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "Use an existing element ref or id") };
106
+ return { el };
107
+ };
108
+ //#endregion
109
+ export { ID_REF_HINT, collectInputRefs, createElement, ensureIdRef, folderUri, foldersUri, guardNewRef, pageUri, pagesUri, placeChild, removeFromParent, resolveElement, resolveTargetRef, schemaVarsUri, settingsUri, writeInitialState };
@@ -0,0 +1,21 @@
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/definitions/deleteDefinition.ts
6
+ var deleteDefinitionOp = z.object({
7
+ type: z.literal("deleteDefinition"),
8
+ ref: z.string().describe("Class ref of the definition to delete")
9
+ }).describe("Delete a style class definition by ref (does not detach it from elements that still list it).");
10
+ var deleteDefinition = (space, env, op) => {
11
+ const guard = guardKind(space.style, op.ref, "class");
12
+ if (guard) return guard;
13
+ for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.ref);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [defUri(env, op.ref), defsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteDefinition, deleteDefinitionOp };
@@ -0,0 +1,28 @@
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { definitionToAI } from "../translator.js";
4
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
5
+ import { patchCssShape } from "../shared.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/style/definitions/patchDefinition.ts
8
+ var patchDefinitionOp = z.object({
9
+ type: z.literal("patchDefinition"),
10
+ ref: z.string().describe("Existing class ref to patch"),
11
+ ...patchCssShape
12
+ }).describe("Partially update an existing style class: the CSS you pass is merged (a null value removes that property, others are kept). Never creates — use upsertDefinition for that.");
13
+ var patchDefinition = (space, env, op) => {
14
+ const guard = guardKind(space.style, op.ref, "class");
15
+ if (guard) return guard;
16
+ const existing = definitionToAI(space.style, op.ref);
17
+ if (!existing) return fail("ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
18
+ const { type, ref, slots: slotsPatch, ...basePatch } = op;
19
+ const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
20
+ writeStyleItem(space.style, ref, base, slots, "class", void 0);
21
+ return {
22
+ ...empty(),
23
+ updated: 1,
24
+ staleResources: [defUri(env, ref), defsUri(env)]
25
+ };
26
+ };
27
+ //#endregion
28
+ export { patchDefinition, patchDefinitionOp };
@@ -0,0 +1,24 @@
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/style/definitions/upsertDefinition.ts
7
+ var upsertDefinitionOp = z.object({
8
+ type: z.literal("upsertDefinition"),
9
+ ref: z.string().describe("Class name you choose (kebab-case), or an existing class ref to fully replace"),
10
+ ...upsertCssShape
11
+ }).describe("Create a reusable style class (CSS), or fully replace it when ref exists. Apply it by attaching ref to an element via its style.base. Use patchDefinition to change only some CSS.");
12
+ var upsertDefinition = (space, env, op) => {
13
+ const { type, ref, slots, ...base } = op;
14
+ const guard = guardKind(space.style, ref, "class");
15
+ if (guard) return guard;
16
+ writeStyleItem(space.style, ref, base, slots, "class", void 0);
17
+ return {
18
+ ...empty(),
19
+ updated: 1,
20
+ staleResources: [defUri(env, ref), defsUri(env)]
21
+ };
22
+ };
23
+ //#endregion
24
+ export { upsertDefinition, upsertDefinitionOp };
@@ -0,0 +1,21 @@
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.ts
6
+ var deleteGlobalStyleOp = z.object({
7
+ type: z.literal("deleteGlobalStyle"),
8
+ componentType: z.string().describe("Element type whose site-wide style to remove")
9
+ }).describe("Remove the site-wide style for an element type (elements of that type keep their own classes).");
10
+ var deleteGlobalStyle = (space, env, op) => {
11
+ const guard = guardKind(space.style, op.componentType, "element");
12
+ if (guard) return guard;
13
+ for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.componentType);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [globalUri(env, op.componentType), globalsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteGlobalStyle, deleteGlobalStyleOp };
@@ -0,0 +1,28 @@
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { globalStyleToAI } from "../translator.js";
4
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
5
+ import { patchCssShape } from "../shared.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.ts
8
+ var patchGlobalStyleOp = z.object({
9
+ type: z.literal("patchGlobalStyle"),
10
+ componentType: z.string().describe("Element type whose global style to merge into; affects ALL of that type"),
11
+ ...patchCssShape
12
+ }).describe("Partially update the site-wide style for an element type: CSS is merged (a null value removes a property). Never creates — use upsertGlobalStyle for that.");
13
+ var patchGlobalStyle = (space, env, op) => {
14
+ const guard = guardKind(space.style, op.componentType, "element");
15
+ if (guard) return guard;
16
+ const existing = globalStyleToAI(space.style, op.componentType);
17
+ if (!existing) return fail("componentType", `No global style for "${op.componentType}"`, "patchGlobalStyle only updates an existing global; use upsertGlobalStyle to create one");
18
+ const { type, componentType, slots: slotsPatch, ...basePatch } = op;
19
+ const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
20
+ writeStyleItem(space.style, componentType, base, slots, "element", componentType);
21
+ return {
22
+ ...empty(),
23
+ updated: 1,
24
+ staleResources: [globalUri(env, componentType), globalsUri(env)]
25
+ };
26
+ };
27
+ //#endregion
28
+ export { patchGlobalStyle, patchGlobalStyleOp };
@@ -0,0 +1,24 @@
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.ts
7
+ var upsertGlobalStyleOp = z.object({
8
+ type: z.literal("upsertGlobalStyle"),
9
+ componentType: z.string().describe("Element type to style site-wide (e.g. \"button\"); affects ALL of that type"),
10
+ ...upsertCssShape
11
+ }).describe("Create or fully replace the site-wide style for an element TYPE — its CSS applies to every element of that type. To style one element only, use upsertDefinition + attach it. Use patchGlobalStyle for a partial change.");
12
+ var upsertGlobalStyle = (space, env, op) => {
13
+ const { type, componentType, slots, ...base } = op;
14
+ const guard = guardKind(space.style, componentType, "element");
15
+ if (guard) return guard;
16
+ writeStyleItem(space.style, componentType, base, slots, "element", componentType);
17
+ return {
18
+ ...empty(),
19
+ updated: 1,
20
+ staleResources: [globalUri(env, componentType), globalsUri(env)]
21
+ };
22
+ };
23
+ //#endregion
24
+ export { upsertGlobalStyle, upsertGlobalStyleOp };
@@ -0,0 +1,21 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.ts
6
+ var deleteIdStyleOp = z.object({
7
+ type: z.literal("deleteIdStyle"),
8
+ targetId: z.string().describe("DOM id whose id rule to remove (without the # prefix)")
9
+ }).describe("Remove the id rule (`#id`) for a single element (the element keeps its own classes).");
10
+ var deleteIdStyle = (space, env, op) => {
11
+ const guard = guardKind(space.style, op.targetId, "id");
12
+ if (guard) return guard;
13
+ for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.targetId);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [idUri(env, op.targetId), idsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteIdStyle, deleteIdStyleOp };
@@ -0,0 +1,28 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { idStyleToAI } from "../translator.js";
4
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
5
+ import { patchCssShape } from "../shared.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.ts
8
+ var patchIdStyleOp = z.object({
9
+ type: z.literal("patchIdStyle"),
10
+ targetId: z.string().describe("DOM id whose id rule to merge into (without the # prefix)"),
11
+ ...patchCssShape
12
+ }).describe("Partially update the CSS of an id rule (`#id`): CSS is merged (a null value removes a property). Never creates — use upsertIdStyle for that.");
13
+ var patchIdStyle = (space, env, op) => {
14
+ const guard = guardKind(space.style, op.targetId, "id");
15
+ if (guard) return guard;
16
+ const existing = idStyleToAI(space.style, op.targetId);
17
+ if (!existing) return fail("targetId", `No id rule for "${op.targetId}"`, "patchIdStyle only updates an existing id rule; use upsertIdStyle to create one");
18
+ const { type, targetId, slots: slotsPatch, ...basePatch } = op;
19
+ const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
20
+ writeStyleItem(space.style, targetId, base, slots, "id", void 0);
21
+ return {
22
+ ...empty(),
23
+ updated: 1,
24
+ staleResources: [idUri(env, targetId), idsUri(env)]
25
+ };
26
+ };
27
+ //#endregion
28
+ export { patchIdStyle, patchIdStyleOp };
@@ -0,0 +1,24 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.ts
7
+ var upsertIdStyleOp = z.object({
8
+ type: z.literal("upsertIdStyle"),
9
+ targetId: z.string().describe("DOM id of the element to style (without the # prefix); matches its `id` attribute"),
10
+ ...upsertCssShape
11
+ }).describe("Create or fully replace the CSS for a single element addressed by its DOM id (`#id`). The element must carry that `id` attribute. To style by reusable class instead, use upsertDefinition. Use patchIdStyle for a partial change.");
12
+ var upsertIdStyle = (space, env, op) => {
13
+ const { type, targetId, slots, ...base } = op;
14
+ const guard = guardKind(space.style, targetId, "id");
15
+ if (guard) return guard;
16
+ writeStyleItem(space.style, targetId, base, slots, "id", void 0);
17
+ return {
18
+ ...empty(),
19
+ updated: 1,
20
+ staleResources: [idUri(env, targetId), idsUri(env)]
21
+ };
22
+ };
23
+ //#endregion
24
+ export { upsertIdStyle, upsertIdStyleOp };
@@ -0,0 +1,27 @@
1
+ import { deleteDefinitionOp } from "./definitions/deleteDefinition.js";
2
+ import { patchDefinitionOp } from "./definitions/patchDefinition.js";
3
+ import { upsertDefinitionOp } from "./definitions/upsertDefinition.js";
4
+ import { deleteGlobalStyleOp } from "./globalStyles/deleteGlobalStyle.js";
5
+ import { patchGlobalStyleOp } from "./globalStyles/patchGlobalStyle.js";
6
+ import { upsertGlobalStyleOp } from "./globalStyles/upsertGlobalStyle.js";
7
+ import { deleteIdStyleOp } from "./idStyles/deleteIdStyle.js";
8
+ import { patchIdStyleOp } from "./idStyles/patchIdStyle.js";
9
+ import { upsertIdStyleOp } from "./idStyles/upsertIdStyle.js";
10
+ import { deleteStyleVariableOp } from "./variables/deleteStyleVariable.js";
11
+ import { upsertStyleVariableOp } from "./variables/upsertStyleVariable.js";
12
+ //#region src/modules/mcp/tools/operations/style/operations.ts
13
+ var styleOps = {
14
+ upsertDefinition: upsertDefinitionOp,
15
+ patchDefinition: patchDefinitionOp,
16
+ deleteDefinition: deleteDefinitionOp,
17
+ upsertGlobalStyle: upsertGlobalStyleOp,
18
+ patchGlobalStyle: patchGlobalStyleOp,
19
+ deleteGlobalStyle: deleteGlobalStyleOp,
20
+ upsertIdStyle: upsertIdStyleOp,
21
+ patchIdStyle: patchIdStyleOp,
22
+ deleteIdStyle: deleteIdStyleOp,
23
+ upsertStyleVariable: upsertStyleVariableOp,
24
+ deleteStyleVariable: deleteStyleVariableOp
25
+ };
26
+ //#endregion
27
+ export { styleOps };
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ //#region src/modules/mcp/tools/operations/style/shared.ts
3
+ var cssMap = z.record(z.string(), z.union([z.string(), z.number()])).describe("kebab-case CSS props; use var(--name) for tokens and {{name}} for schema vars");
4
+ var displayModeCss = z.object({
5
+ desktop: cssMap.optional(),
6
+ tablet: cssMap.optional(),
7
+ mobile: cssMap.optional()
8
+ });
9
+ var definitionSlot = displayModeCss.extend({
10
+ states: z.record(z.string(), displayModeCss).optional(),
11
+ variants: z.record(z.string(), displayModeCss).optional()
12
+ });
13
+ var cssPatchMap = z.record(z.string(), z.union([
14
+ z.string(),
15
+ z.number(),
16
+ z.null()
17
+ ])).describe("kebab-case CSS props; a value of null removes the property, others are merged onto the existing CSS");
18
+ var displayModeCssPatch = z.object({
19
+ desktop: cssPatchMap.optional(),
20
+ tablet: cssPatchMap.optional(),
21
+ mobile: cssPatchMap.optional()
22
+ });
23
+ var definitionSlotPatch = displayModeCssPatch.extend({
24
+ states: z.record(z.string(), displayModeCssPatch).optional(),
25
+ variants: z.record(z.string(), displayModeCssPatch).optional()
26
+ });
27
+ var styleCategory = z.enum([
28
+ "color",
29
+ "spacing",
30
+ "shadow",
31
+ "custom"
32
+ ]);
33
+ var themeValue = z.union([
34
+ z.string(),
35
+ z.number(),
36
+ z.object({
37
+ light: z.string().optional(),
38
+ dark: z.string().optional(),
39
+ default: z.string().optional()
40
+ })
41
+ ]);
42
+ var upsertCssShape = {
43
+ desktop: cssMap.optional(),
44
+ tablet: cssMap.optional(),
45
+ mobile: cssMap.optional(),
46
+ states: z.record(z.string(), displayModeCss).optional(),
47
+ variants: z.record(z.string(), displayModeCss).optional(),
48
+ slots: z.record(z.string(), definitionSlot).optional()
49
+ };
50
+ var patchCssShape = {
51
+ desktop: cssPatchMap.optional(),
52
+ tablet: cssPatchMap.optional(),
53
+ mobile: cssPatchMap.optional(),
54
+ states: z.record(z.string(), displayModeCssPatch).optional(),
55
+ variants: z.record(z.string(), displayModeCssPatch).optional(),
56
+ slots: z.record(z.string(), definitionSlotPatch).optional()
57
+ };
58
+ //#endregion
59
+ export { displayModeCss, displayModeCssPatch, patchCssShape, styleCategory, themeValue, upsertCssShape };
@@ -0,0 +1,101 @@
1
+ //#region src/modules/mcp/tools/operations/style/translator.ts
2
+ var DISPLAY_MODES = [
3
+ "desktop",
4
+ "tablet",
5
+ "mobile"
6
+ ];
7
+ var isClassDefinition = (item) => item.type === "class";
8
+ var definitionRefs = (style) => {
9
+ const refs = /* @__PURE__ */ new Set();
10
+ for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isClassDefinition(item)) refs.add(name);
11
+ return Array.from(refs).sort();
12
+ };
13
+ var fillSlot = (target, mode, block) => {
14
+ if (block.default && Object.keys(block.default).length > 0) target[mode] = block.default;
15
+ if (block.states) {
16
+ for (const [state, obj] of Object.entries(block.states)) if (Object.keys(obj).length > 0) {
17
+ (target.states ??= {})[state] ??= {};
18
+ target.states[state][mode] = obj;
19
+ }
20
+ }
21
+ if (block.variants) {
22
+ for (const [name, variant] of Object.entries(block.variants)) if (variant.default && Object.keys(variant.default).length > 0) {
23
+ (target.variants ??= {})[name] ??= {};
24
+ target.variants[name][mode] = variant.default;
25
+ }
26
+ }
27
+ };
28
+ var projectItem = (style, ref, accept) => {
29
+ const def = { ref };
30
+ let found = false;
31
+ for (const mode of DISPLAY_MODES) {
32
+ const item = style.platform[mode][ref];
33
+ if (!item || !accept(item)) continue;
34
+ found = true;
35
+ for (const [slot, block] of Object.entries(item.attributes)) if (slot === "base") fillSlot(def, mode, block);
36
+ else fillSlot((def.slots ??= {})[slot] ??= {}, mode, block);
37
+ }
38
+ return found ? def : void 0;
39
+ };
40
+ var definitionToAI = (style, ref) => projectItem(style, ref, isClassDefinition);
41
+ var definitionVariantNames = (style, ref) => {
42
+ const def = definitionToAI(style, ref);
43
+ if (!def) return;
44
+ const result = {};
45
+ const baseVariants = Object.keys(def.variants ?? {});
46
+ if (baseVariants.length > 0) result.base = baseVariants.sort();
47
+ for (const [slot, slotDef] of Object.entries(def.slots ?? {})) {
48
+ const variants = Object.keys(slotDef.variants ?? {});
49
+ if (variants.length > 0) result[slot] = variants.sort();
50
+ }
51
+ return Object.keys(result).length > 0 ? result : void 0;
52
+ };
53
+ var globalStylesForType = (style, componentType) => {
54
+ const isGlobal = (item) => item.type === "element" && item.componentType === componentType;
55
+ const refs = /* @__PURE__ */ new Set();
56
+ for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isGlobal(item)) refs.add(name);
57
+ const globals = [];
58
+ for (const ref of Array.from(refs).sort()) {
59
+ const def = projectItem(style, ref, isGlobal);
60
+ if (def) globals.push({
61
+ ...def,
62
+ appliesToType: componentType
63
+ });
64
+ }
65
+ return globals;
66
+ };
67
+ var globalStyleToAI = (style, componentType) => {
68
+ const def = projectItem(style, componentType, (item) => item.type === "element" && item.componentType === componentType);
69
+ return def ? {
70
+ ...def,
71
+ appliesToType: componentType
72
+ } : void 0;
73
+ };
74
+ var globalStyleTypes = (style) => {
75
+ const types = /* @__PURE__ */ new Set();
76
+ for (const mode of DISPLAY_MODES) for (const item of Object.values(style.platform[mode])) if (item.type === "element" && item.componentType) types.add(item.componentType);
77
+ return Array.from(types).sort();
78
+ };
79
+ var idStyleIds = (style) => {
80
+ const ids = /* @__PURE__ */ new Set();
81
+ for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (item.type === "id") ids.add(name);
82
+ return Array.from(ids).sort();
83
+ };
84
+ var idStyleToAI = (style, targetId) => {
85
+ const def = projectItem(style, targetId, (item) => item.type === "id");
86
+ return def ? {
87
+ ...def,
88
+ targetId
89
+ } : void 0;
90
+ };
91
+ var styleVariablesToAI = (style) => {
92
+ const data = {};
93
+ for (const [category, group] of Object.entries(style.variables)) data[category] = Object.entries(group).map(([name, value]) => ({
94
+ name,
95
+ reference: `var(--${name})`,
96
+ value
97
+ }));
98
+ return data;
99
+ };
100
+ //#endregion
101
+ export { definitionRefs, definitionToAI, definitionVariantNames, globalStyleToAI, globalStyleTypes, globalStylesForType, idStyleIds, idStyleToAI, isClassDefinition, styleVariablesToAI };
@@ -0,0 +1,21 @@
1
+ import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { styleCategory } from "../shared.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.ts
6
+ var deleteStyleVariableOp = z.object({
7
+ type: z.literal("deleteStyleVariable"),
8
+ category: styleCategory,
9
+ name: z.string().describe("Token name without the -- prefix")
10
+ }).describe("Delete a design token by category + name.");
11
+ var deleteStyleVariable = (space, env, op) => {
12
+ const group = space.style.variables[op.category];
13
+ if (group) Reflect.deleteProperty(group, op.name);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [styleVarUri(env, op.category), styleVarsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteStyleVariable, deleteStyleVariableOp };
@@ -0,0 +1,22 @@
1
+ import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { styleCategory, themeValue } from "../shared.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.ts
6
+ var upsertStyleVariableOp = z.object({
7
+ type: z.literal("upsertStyleVariable"),
8
+ category: styleCategory,
9
+ name: z.string().describe("Token name without the -- prefix; referenced in CSS as var(--name)"),
10
+ value: themeValue
11
+ }).describe("Create or update a design token (referenced in CSS as var(--name); value may differ per light/dark).");
12
+ var upsertStyleVariable = (space, env, op) => {
13
+ const group = space.style.variables[op.category] ??= {};
14
+ group[op.name] = op.value;
15
+ return {
16
+ ...empty(),
17
+ updated: 1,
18
+ staleResources: [styleVarUri(env, op.category), styleVarsUri(env)]
19
+ };
20
+ };
21
+ //#endregion
22
+ export { upsertStyleVariable, upsertStyleVariableOp };