@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,449 @@
1
+ //#region src/modules/mcp/helpers/guide.ts
2
+ var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Refs accept a semantic idRef ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) or the raw id — the idRef is ALSO the runtime wiring key, so a provider source is `<type>_<idRef>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is kebab-case and ATOMIC (shorthands like border/padding expanded; compound ones like flex/background/font rejected — use longhands); style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS refs by label/type/attribute; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers).";
3
+ var guideQuickstart = `# Plitzi AI MCP — quickstart
4
+ This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
5
+
6
+ A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch**: the **element schema** (tree of
7
+ pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
8
+ **definition** and attach it via the element's \`style.base\` in the same batch.
9
+
10
+ **Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
11
+ with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
12
+ per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
13
+ \`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
14
+ concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
15
+
16
+ **Refs & wiring:** a ref is the semantic \`idRef\` (letters, numbers, hyphens and underscores, **starting with a
17
+ letter — no dots**) or the raw id. The idRef is the runtime wiring key: a provider's source is \`<type>_<idRef>\`, and
18
+ interactions target by it. A dot would split that path; an **underscore is fine** — the first \`_\` separates the type
19
+ from the idRef (element types have none), so \`list_food_item\` reads unambiguously as type \`list\`, idRef \`food_item\`.
20
+
21
+ **Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
22
+ vars. Shorthands \`border\`/\`padding\`/\`margin\`/\`gap\` are expanded for you. Write **atomically — no compound
23
+ shorthands** (\`flex\`, \`background\`, \`font\`, \`transition\`, \`grid\` are rejected/warned): use their longhands, and
24
+ express flex layout as \`display: flex\` + \`flex-direction\`/\`align-items\`/… Mind a type's \`defaultStyle\` (\`text\`
25
+ is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
26
+
27
+ **Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
28
+ A source \`<type>_<idRef>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
29
+ (module sources state/space/navigation/auth/collection are global). \`apiContainer.mockData\` is builder-only; set a
30
+ real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
31
+ from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
32
+ a QueryBuilder RuleGroup gating the binding.
33
+
34
+ **Interactions** (\`upsertInteractionFlow\`): a \`trigger\` node first, then callbacks/utilities **in order** (links
35
+ computed for you). Node types: \`callback\` (an element's own callback — \`elementId\` is that element), \`globalCallback\`
36
+ (a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
37
+ (category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
38
+ \`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
39
+ **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<idRef>.item.name }}"\`).
40
+
41
+ **Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
42
+ slugs prepend the path). A \`:name\` segment (\`"posts/:postId"\`) is a route param, readable as \`{{name}}\` and as the
43
+ source \`navigation.routeParams.name\` → build dynamic pages this way. To move between pages **prefer the \`Link\`
44
+ element** (a container: \`mode\` "page"/"internal"/"external") over a \`navigate\` interaction.
45
+
46
+ **Touched resources must be malformation-free.** Editing an element/definition also checks its CURRENT stored content
47
+ and BLOCKS the save on any \`Pre-existing malformation in <resource>\` error (a broken transformer, malformed node,
48
+ invalid CSS) — even parts you did not touch. These are NOT from your change (the message says so); fix them in the
49
+ SAME batch and re-apply (the check runs on the result, so the fix unblocks it). \`Pre-existing issue\` warnings advise
50
+ but do not block.
51
+
52
+ Read \`plitzi://guide\` before anything above is unclear.
53
+ `;
54
+ var guideText = `# Plitzi AI MCP — usage guide
55
+
56
+ A Plitzi space is **two separate schemas** you edit together:
57
+ - **Element schema** — the tree of pages and elements (their type, label, props, and which style classes they use).
58
+ - **Style schema** — reusable **definitions** (CSS classes), design tokens (variables), theme.
59
+
60
+ They are stored and persisted independently, but a single \`plitzi_apply\` batch may touch **both atomically**.
61
+ To style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**
62
+ it via the element's \`style.base\` (element schema). Example — "rename button X to PEPE and make it red":
63
+ \`\`\`json
64
+ { "operations": [
65
+ { "type": "upsertDefinition", "ref": "btn-x", "desktop": { "color": "red" } },
66
+ { "type": "upsertElement", "pageRef": "home",
67
+ "element": { "ref": "X", "type": "button", "label": "PEPE", "style": { "base": ["btn-x"] } } }
68
+ ] }
69
+ \`\`\`
70
+
71
+ Reads are cheap by design — treat them like a filesystem: **list** to navigate, **read one item** for detail.
72
+ Never download a whole tree you do not need.
73
+
74
+ ## Resources (read)
75
+ - \`plitzi://primer/{env}\` — **cold-start bundle**: guide + types + css-properties + page/definition/variable
76
+ **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only — open a
77
+ page skeleton or element for its tree/detail.
78
+ - \`plitzi://guide\` — this guide.
79
+ - \`plitzi://types\` — element types **observed in this space** (ground truth): props, slots, subTypes, plus each
80
+ type's \`label\`, \`description\` (what it is FOR) and \`category\`, and a \`source\` (\`builtin\` | \`plugin\` | \`unknown\`).
81
+ Read the descriptions to pick the right type — e.g. \`apiContainer\` fetches backend data into the frontend,
82
+ \`link\` navigates between pages, \`list\` repeats a template over a data array. \`plugin\` types are custom elements.
83
+ - \`plitzi://css-properties\` — valid kebab-case CSS property keys.
84
+ - \`plitzi://schema/{env}/pages\` — page **summaries** (ref, label, elementCount, folder). No element trees.
85
+ - \`plitzi://folders/{env}\` — page **folders** (the sidebar tree): ref, name, slug, parentId. \`/{ref}\` for one.
86
+ - \`plitzi://schema/{env}/pages/{ref}\` — one page as a **skeleton tree**: each node is \`ref/type/label\` **plus the
87
+ style classes it attaches** (\`base\`, and \`slots\` for non-base slots) — names only, no CSS. So you can map every
88
+ element to its class in a single page read, without opening each element just to learn which class it uses.
89
+ - \`plitzi://schema/{env}/pages/{ref}/styles\` — **every style the page uses in one read**: the class definitions its
90
+ elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.
91
+ Reach for this to recolor/restyle a whole page — it needs no shared class-name prefix and no per-element reads.
92
+ - \`plitzi://schema/{env}/elements/{ref}\` — one element in **full detail** (props, style, parentRef, childRefs).
93
+ Its \`resolvedStyle\` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you
94
+ can see and edit its style without a separate definition read. Its \`globalStyles\` lists the **global element
95
+ selectors** that also affect it (the CSS equivalent of \`button { … }\`, keyed by the type they target) — every
96
+ element of that type inherits them. Edit a global only through the global-style tools (never per element). If the
97
+ element carries a DOM \`id\` that an id rule matches, its \`idStyle\` (\`#id\`) is inlined too.
98
+ - \`plitzi://definitions/{env}\` — the **names** of every style definition.
99
+ - \`plitzi://definitions/{env}/{ref}\` — one definition's CSS.
100
+ - \`plitzi://global-styles/{env}\` — element **types** that have a site-wide global style. \`/{componentType}\` for one.
101
+ - \`plitzi://id-styles/{env}\` — DOM **ids** that have an id rule (\`#id\`) targeting a single element. \`/{targetId}\` for one.
102
+ - \`plitzi://style-variables/{env}\` — design tokens by category. \`/{category}\` for one.
103
+ - \`plitzi://schema-variables/{env}\` — space-level values referenced in props as \`{{name}}\`.
104
+ - \`plitzi://settings/{env}\` — space-level settings: the global \`customCss\` and the state/auth (user-provider) config.
105
+ - \`plitzi://interactions/{env}\` — interaction **actions** observed in this space (grouped by node type): the
106
+ vocabulary for interaction flows.
107
+ - \`plitzi://data-sources/{env}\` — data-source **paths** and binding targets observed in this space: the
108
+ vocabulary for data bindings.
109
+
110
+ The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
111
+
112
+ Data resources return \`{ stateVersion, data }\`. Keep \`stateVersion\` for optimistic concurrency.
113
+
114
+ **Reuse what you already know — don't re-scan an unchanged page.** A page read (\`plitzi://schema/{env}/pages/{ref}\`)
115
+ returns a \`stateVersion\` that is an **aggregate of the whole page**: it changes if and only if some element on the
116
+ page changed. Its skeleton \`tree\` also carries a \`stateVersion\` **per node**, identical to the one a direct element
117
+ read or search hit returns for that element. So when you come back to a page you already inspected:
118
+ 1. Re-read just the page skeleton and compare its top-level \`stateVersion\` to the one you held. **Same → nothing
119
+ changed since your read; skip re-reading and re-searching the tree** and act on what you already know.
120
+ 2. If it differs, diff the per-node \`stateVersion\`s against the ones you cached and \`plitzi_read\` **only the nodes
121
+ that changed** — never re-search or re-read the whole tree.
122
+
123
+ This is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space
124
+ concurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time
125
+ check below on the strength of a cached hash — the guarantee that no concurrent edit is lost comes only from
126
+ \`expectedResourceVersions\` on \`plitzi_apply\`, which re-validates against the live data at write time.
127
+
128
+ ## Navigating (files analogy)
129
+ Pages and containers are folders; elements are files. **Prefer \`plitzi_search\` (especially with \`include: "detail"\`)
130
+ over reading elements one by one** — it jumps straight to elements by label/type/attribute and each hit already
131
+ carries the element's \`uri\`, \`stateVersion\`, \`pageUri\`, \`parentRef\` and tree \`path\`, so you can edit it (with
132
+ optimistic concurrency) **without a follow-up read**. \`include: "detail"\` additionally inlines each hit's props/style
133
+ **and** its \`resolvedStyle\` (the CSS behind its classes) — so a search-then-edit is the efficient path and a manual
134
+ element read is the exception. Search also matches **pages** by name/slug (returned under \`pages\`, each with its uri +
135
+ stateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under \`definitions\`.
136
+ When you do hold several refs to open (e.g. from a skeleton), read them together with \`plitzi_read\` rather than one at a time.
137
+
138
+ ## Tools (write)
139
+ - \`plitzi_validate\` — check a batch, returns teachable errors/warnings. Writes nothing. Also reports **pre-existing
140
+ malformations** in any resource the batch touches (see below).
141
+ - \`plitzi_apply\` — validate → apply → persist atomically. Rejects the whole batch on any error or conflict. Pass
142
+ \`dryRun: true\` to apply in memory only and get the same result back (changed versions + full element detail)
143
+ without persisting — inspect it, then re-run without \`dryRun\` to commit.
144
+ - \`plitzi_search\` — find elements (and pages/definitions) across the space.
145
+ - \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
146
+ ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
147
+ so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.
148
+
149
+ ## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)
150
+ Three ways to read, each for a different moment — pick by what you have in hand:
151
+ - **MCP resources** (the \`plitzi://…\` catalog above) — the **browsable index**. List them to discover what exists, or
152
+ open one by URI when you are exploring. This is the passive catalog, not a tool.
153
+ - **\`plitzi_search\`** — you know *what* you want but not its **ref/uri** ("the hero button"). Search finds it by
154
+ label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
155
+ - **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
156
+ content in one batch. It is the tool form of opening resources, for when you have the addresses.
157
+ Rule of thumb: **discover → resources**, **find a ref → plitzi_search**, **fetch known uris → plitzi_read**. Never
158
+ hand-build a URI to guess your way to an element — search for it instead.
159
+
160
+ Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
161
+ they created or updated** — each with its own \`uri\` and \`stateVersion\` (\`elements: [...]\`) so a follow-up edit of
162
+ the same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only
163
+ uri+stateVersion — re-read them if you need their new content. The operation shapes are in each tool's input
164
+ schema (discriminated by \`type\`).
165
+
166
+ ## Addressing
167
+ Refs are the semantic \`idRef\` (e.g. \`"hero-cta"\`) or the element's **raw id** — both resolve. Creating an element
168
+ stores the \`ref\` you chose as its **idRef**.
169
+
170
+ The idRef is not just an alias — it is the **wiring key the runtime uses**. A provider registers its data source as
171
+ \`<type>_<idRef>\`, so a \`source\` you write against a ref resolves to that element at runtime with no id translation.
172
+ Rules for a **new** ref (both are enforced; a violation fails the batch):
173
+ - Charset \`[A-Za-z0-9_-]\`, **starting with a letter** (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split the
174
+ \`<type>_<idRef>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
175
+ allowed**: the FIRST \`_\` separates \`<type>\` from \`<idRef>\` and element types are camelCase with none, so
176
+ underscores inside the idRef are unambiguous (\`list_food_item\` → type \`list\`, idRef \`food_item\`).
177
+ - **Unique across the space**; creating a ref that is taken is rejected (address the existing element instead).
178
+
179
+ An idRef is **optional** on an element — one built in the builder may not have it. The consequence is specific: an
180
+ element without an idRef **publishes no data source** and **holds no interactions**, because the runtime keys
181
+ everything by idRef and the raw id is never a fallback. You do not have to fix this by hand: writing an
182
+ interaction **mints an idRef for you** — the element that hosts the flow, and any element a node targets, is given
183
+ a free \`<type>-<n>\` ref if it lacks one, and the flow is wired to it. A node target you write may be a raw id; it
184
+ is normalised to that element's idRef. (To make an element a data-source **provider** to bind against, give it an
185
+ idRef explicitly with \`patchElement\`, or create it with the \`ref\` you want — a created element stores its ref as
186
+ its idRef.)
187
+
188
+ **Renaming** an idRef moves the wiring key: every binding source and interaction target across the space that
189
+ pointed at the old name is repointed with it, so the element stays wired. You do not have to rewrite them.
190
+
191
+ ## Styling (crosses both schemas)
192
+ - **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
193
+ it from \`defaultStyle\` on the type in \`plitzi://types\` (the primer includes it). Do not assume \`display: block\`:
194
+ \`text\`, for one, defaults to \`display: inline\`, so margins/width/vertical padding behave differently. If you need
195
+ block/flex layout on such an element, set \`display\` explicitly in your definition rather than relying on a default.
196
+ - **Images: preserve aspect ratio.** Setting only \`width\` and \`height\` (or forcing both) distorts an image. Change
197
+ one dimension and let the other be \`auto\`, or set \`aspect-ratio\` with \`object-fit: cover\`/\`contain\`, so the
198
+ image scales without stretching.
199
+ - **Font size and line height move together.** When you change \`font-size\`, set \`line-height\` in the same edit
200
+ (prefer a unitless ratio like \`1.5\`, which tracks the font size). Changing one without the other leaves cramped or
201
+ loosely-spaced text — they are a joint change, not two separate ones.
202
+ - A definition lives in the **style schema**; an element's \`style.base\` (element schema) is the link that applies
203
+ it. Styling an element = upsertDefinition + upsertElement with that ref in \`style.base\`, in one batch.
204
+ - CSS keys are **kebab-case** (\`background-color\`). camelCase is rejected — read \`plitzi://css-properties\`.
205
+ - Common **shorthands are accepted** and expanded for you: \`border\`, \`border-{side}\`, \`border-radius\`,
206
+ \`padding\`, \`margin\`, \`inset\`, \`gap\` (they persist as their longhand keys).
207
+ - **Write CSS atomically — no multi-value compound shorthands.** Plitzi stores each property on its own so a
208
+ breakpoint/state/variant can override just that one, so \`flex\`, \`background\`, \`font\`, \`transition\`,
209
+ \`animation\`, \`grid\`, \`place-*\`, \`outline\`, \`columns\` are **rejected** (or warned) — use their longhands
210
+ instead: \`background\` → \`background-color\`/\`background-image\`/…, \`font\` → \`font-size\`/\`font-weight\`/
211
+ \`line-height\`, \`flex: 1\` → \`flex-grow\`/\`flex-shrink\`/\`flex-basis\`. **Flex layout is not a \`flex\` value**: set
212
+ \`display: flex\` **plus** \`flex-direction\`, \`align-items\`, \`justify-content\` as separate properties.
213
+ - CSS is grouped by breakpoint: \`desktop\`, \`tablet\`, \`mobile\`.
214
+ - Reference a style variable in CSS as \`var(--name)\`; a schema variable in a prop as \`{{name}}\`.
215
+ - \`element.style.base\` is a **list** of definition refs; other slots go under \`element.style.slots\`.
216
+ - **An element can attach SEVERAL classes at once, and they all apply.** \`style.base\` holds a list, and each
217
+ non-base slot holds its own — every attached definition contributes CSS, and they **cascade** (a later class, then a
218
+ global/id rule, overrides an earlier one on the same property). So when a style looks wrong, the culprit may be
219
+ ANY attached class, not the one you just edited: read the element's \`resolvedStyle\` (it inlines the CSS of every
220
+ class it attaches, keyed by ref) together with its \`globalStyles\`/\`idStyle\` and the type's \`defaultStyle\`, and
221
+ fix the class that actually sets the property — do not just pile another class on top.
222
+ - **Three kinds of style live in the style schema — do not confuse them:**
223
+ - **Definitions** = reusable CSS **classes** (\`upsertDefinition\`/\`patchDefinition\`/\`deleteDefinition\`, keyed by a
224
+ class \`ref\`). Attach one to an element via \`style.base\` to style **that** element (and anything else that opts in).
225
+ This is the **default** way to style one element.
226
+ - **Global styles** = the CSS equivalent of a bare element selector like \`button { … }\`
227
+ (\`upsertGlobalStyle\`/\`patchGlobalStyle\`/\`deleteGlobalStyle\`, keyed by \`componentType\`). They style **every**
228
+ element of that type at once. Use these for site-wide intent — e.g. "all buttons rounded":
229
+ \`{ "type": "upsertGlobalStyle", "componentType": "button", "desktop": { "border-radius": "9999px" } }\`.
230
+ - **Id styles** = the CSS equivalent of an id selector like \`#hero { … }\`
231
+ (\`upsertIdStyle\`/\`patchIdStyle\`/\`deleteIdStyle\`, keyed by \`targetId\`). They style the **single** element whose
232
+ DOM \`id\` attribute equals \`targetId\` — so the element must carry that \`id\` (set it in its props). Prefer a
233
+ **definition** for one element; reach for an id style only when a specific, uniquely-identified node must be
234
+ targeted by id: \`{ "type": "upsertIdStyle", "targetId": "hero", "desktop": { "min-height": "100vh" } }\`.
235
+ - The three share one name space, so an op refuses a name held by another kind (guards against a typo silently
236
+ rewriting every element of a type, or converting a class into an id rule). If refused, you targeted the wrong
237
+ kind — switch tools or rename.
238
+
239
+ ## Style variants & element state
240
+ A **variant** is a named CSS override on a definition (e.g. a button class with a \`primary\` variant). It takes two
241
+ steps across the two schemas:
242
+ - **Declare** the variant CSS on the class (style schema): \`upsertDefinition\`/\`patchDefinition\` with
243
+ \`variants: { "primary": { "desktop": { "background-color": "#111" } } }\` (per slot under \`slots.<slot>.variants\`).
244
+ - **Apply** it to an element (element schema): \`initialState.styleVariant\` =
245
+ \`{ "<class-ref>": { "base": "primary" } }\` — a slot name instead of \`base\` targets that slot; an array applies
246
+ several. Set it via \`upsertElement\`/\`patchElement\`.
247
+ An element read reports \`availableVariants\` (which variant each attached class offers) and the element's current
248
+ \`initialState\`, so you can see a button **has** a \`primary\` variant and whether it uses it. If the user asks for a
249
+ variant that does not exist yet, **create it (upsertDefinition variants) and apply it in the same batch**.
250
+ - \`initialState.visibility\` (boolean) sets whether the element starts shown or hidden.
251
+
252
+ ## Data bindings
253
+ Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
254
+ by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
255
+ - \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
256
+ - \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
257
+ Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed an API
258
+ list into a list element:
259
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
260
+ "binding": { "to": "items", "source": "apiContainer_x.data" } }\`.
261
+
262
+ **Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
263
+ \`<type>_<idRef>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
264
+ its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
265
+ to it resolves to nothing at runtime. So to consume \`apiContainer_products.data\`, the bound element must live under
266
+ that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
267
+ (\`list_<idRef>.item.<field>\`). Module sources (no \`<type>_<idRef>\` head — \`state\`, \`space\`, \`navigation\`,
268
+ \`auth\`, \`collection\`) are global and bindable anywhere. Binding an element to an element source outside its
269
+ provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
270
+ \`plitzi_validate\`/\`plitzi_apply\` treat it as an **error and reject the batch** — move the element under the
271
+ provider, or bind a source that is in scope.
272
+
273
+ **mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
274
+ builder**; the published runtime fetches the real \`query\` instead. Never rely on mockData as the production source —
275
+ set a real \`query\`/\`method\` so the binding has data at runtime.
276
+
277
+ **\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
278
+ \`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
279
+ action is silently skipped** and the raw value passes through. Use the **exact** action names from
280
+ \`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
281
+ value is the **\`{{source}}\`** token (NOT \`{{value}}\`); \`{{sourceTo}}\` is the field's previous value. Example —
282
+ show a number with units:
283
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
284
+ "binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
285
+ "transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
286
+ Other transformers: \`dateConverter\` (format a date/timestamp), \`capitalize\`, \`stringToArray\` (split on a
287
+ separator), \`arrayMap\` (remap the keys of each object in an array), \`staticValue\`. Transformer \`params\` values are
288
+ strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
289
+ skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
290
+ validated.
291
+
292
+ **\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
293
+ the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
294
+ (operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
295
+ and/or). The guard is validated structurally. Example — only bind when a flag is set:
296
+ \`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
297
+
298
+ ## Interactions
299
+ An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
300
+ it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
301
+ you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
302
+
303
+ **Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
304
+ **wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
305
+ - \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
306
+ - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's ref (the flow host by
307
+ default, or another element to act on); give its ref or raw id and it is normalised to the idRef. Every element
308
+ registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
309
+ \`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
310
+ selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
311
+ for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
312
+ \`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
313
+ **undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
314
+ \`setState\` has **no** \`type\` param (that belongs to the global one below). An element type may also register its
315
+ own extra callbacks.
316
+ - \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
317
+ \`space\`), \`setState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`authLogin\`/\`authLogout\`/
318
+ \`authRefreshDetails\` (\`auth\`), \`addCollectionRecord\`/\`updateCollectionRecord\`/\`removeCollectionRecord\`
319
+ (\`collection\`). Its \`elementId\` is the **source module id**, never the host element — a node that stored the host
320
+ idRef here would resolve to nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
321
+ builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
322
+ \`placement:"top-right"\`, \`appeareance:"success"\`) for any params you leave out. Use **only** the params each
323
+ callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
324
+ \`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
325
+ \`globalCallbacks\` in \`plitzi://interactions/{env}\`.
326
+ - **Two \`setState\`s — do not mix them:** the **element** \`setState\` (nodeType \`callback\`, on an element,
327
+ category/key/value/revertOnFinish) changes THAT element's attribute/state and is what you want to change a button's
328
+ label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`, source \`state\`, key/type/value)
329
+ writes \`runtime.state.<key>\`. They share a name but have different node types AND different params.
330
+ - \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
331
+ names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
332
+ \`webHook\` (\`url\`, \`method\`, …). See \`utilities\` in \`plitzi://interactions/{env}\`.
333
+
334
+ **A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
335
+ it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<idRef>.<path>\`, or a
336
+ module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
337
+ a click on a row can show \`addNotification\` with \`content: "{{ list_<idRef>.item.name }}"\` — the clicked row's field.
338
+ The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
339
+ element repoints these tokens to the new idRefs automatically, along with the element's bindings.
340
+
341
+ **Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
342
+ tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
343
+ \`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
344
+
345
+ Tools:
346
+ - \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
347
+ trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
348
+ the notification defaults):
349
+ \`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
350
+ { "nodeType": "trigger", "action": "onClick", "title": "Click" },
351
+ { "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
352
+ "params": { "content": "Saved!" } } ] }\`.
353
+ - \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
354
+
355
+ **Disable vs delete a step — do not confuse them (three different intents):**
356
+ - **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
357
+ with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
358
+ - **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
359
+ - **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
360
+
361
+ So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
362
+ never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
363
+ *remove* something, and **confirm with the user before deleting** a step or a flow.
364
+
365
+ Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
366
+ \`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
367
+ node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
368
+ \`enabled\`), so a follow-up patch/delete needs no extra read.
369
+
370
+ ## Pages & folders
371
+ - **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a
372
+ clean, stable route (e.g. \`"pricing"\` or \`"posts/:postId"\`). Omit it and the page ref is used as the slug,
373
+ and \`plitzi_validate\`/\`plitzi_apply\` warn so you remember to set a meaningful one.
374
+ - **A page slug is RELATIVE — do NOT start it with \`/\`.** The runtime prepends the leading slash (and any folder
375
+ path) itself, so a leading slash doubles it. Write \`"pricing"\`, not \`"/pricing"\`. (upsertPage strips a leading
376
+ slash for you, but write it relative.)
377
+ - **Dynamic pages — route params.** A slug segment written \`:name\` (e.g. \`"posts/:postId"\`) is a **route param**,
378
+ exactly like React Router. On that page it is readable **two ways**: as \`{{name}}\` inside a prop, and as the
379
+ data-binding source **\`navigation.routeParams.name\`** (the \`navigation\` module source, global — bindable
380
+ anywhere). So a blog is a \`"posts"\` list page plus a \`"posts/:postId"\` detail page whose \`apiContainer\` query
381
+ binds \`navigation.routeParams.postId\` to fetch that one post. (\`navigation.queryParams.<name>\` exposes \`?query=\`
382
+ string params the same way.)
383
+ - **Navigate with the \`Link\` element, not an interaction.** \`link\` is a **container** — it wraps any children and
384
+ navigates on click, so it is the default way to move between pages. Its \`mode\`: \`"page"\` links to another space
385
+ page (set \`href\` to the target page, folder path resolved for you); \`"internal"\` takes a path inside the space and
386
+ resolves \`{{token}}\` templates in it, so a row's "view" link is \`mode:"internal", href:"posts/{{postId}}"\`;
387
+ \`"external"\` is a full URL. \`target\` is \`self\`/\`blank\`/\`parent\`/\`top\`. Reach for the \`navigate\` globalCallback
388
+ only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) — for a plain link,
389
+ use \`link\`.
390
+
391
+ Pages can be grouped into **folders** (the sidebar tree). A folder is \`{ ref, name, slug, parentId? }\`; its \`ref\`
392
+ **is its id** (there is no separate idRef), and that id is what a page and a nested folder reference.
393
+ - **Folder slugs PREPEND to the page URL — this is how nested URLs are built.** The full path is each ancestor
394
+ folder's slug plus the page slug, joined by \`/\`: a page at slug \`"1-1-1"\` inside \`folder-1\` > \`folder-1-1\`
395
+ resolves to \`/folder-1/folder-1-1/1-1-1\`. So a folder slug is part of the route; keep folder slugs relative too.
396
+ - Create/rename/move a folder with \`upsertFolder\` (the \`ref\` you pass on create becomes its id — pick a stable one
397
+ like \`"blog"\`). Nest it under another with \`parentId\` (a folder ref); \`parentId: null\` moves it back to the root.
398
+ - Put a page in a folder with \`upsertPage\`'s \`folder\` (a folder ref). A page's \`folder\` is always either **empty
399
+ (root)** or an **existing folder id**: \`folder: null\` or \`folder: ""\` moves it to the root, and any other value
400
+ must resolve to a folder that already exists or is created earlier in the same batch — an unknown folder is
401
+ rejected, never stored.
402
+ - \`deleteFolder\` removes a folder and **promotes its contents up one level** — its child folders and its pages move
403
+ to its parent (or the root). A folder cannot be nested under itself or one of its descendants.
404
+ - **Disable a page** with \`upsertPage\`'s \`enabled: false\`; \`enabled: true\` re-enables it (defaults to enabled, and
405
+ a page read reports its current \`enabled\`). Disabling only affects the **published SDK runtime** — the page stops
406
+ being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to
407
+ a disabled page. This does not delete it — \`deletePage\` does.
408
+
409
+ ## Settings
410
+ Space-level configuration lives in \`plitzi://settings/{env}\` and is edited with a single **\`patchSettings\`** op
411
+ (merge — only the fields you pass change):
412
+ - \`customCss\` — **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules
413
+ (\`@keyframes\`, \`@font-face\`, resets). To style an element, write a **definition** and attach it — never customCss.
414
+ - \`keepState\` / \`stateStorage\` — persist element state across reloads (\`localStorage\`/\`sessionStorage\`).
415
+ - **User provider / auth**: \`userProvider\` (\`auth0\`|\`basic\`|\`custom\`|\`""\` to disable), \`auth0Domain\`,
416
+ \`auth0ClientId\`, \`tokenStorage\`, and the \`loginUrl\`/\`userUrl\`/\`refreshUrl\`/\`logoutUrl\` + \`detailsPath\`/
417
+ \`tokenPath\`/\`expirationTimePath\` mapping. Example — inject a keyframe globally:
418
+ \`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
419
+
420
+ ## Semantics
421
+ - **props are fully replaced** on \`upsertElement\`: send every prop you want to keep. To change only some props,
422
+ use **\`patchElement\`** — it merges \`props\`/\`style\` onto the existing element (listed keys change, \`null\` unsets
423
+ a key, everything else is preserved) and never creates. Combined with \`plitzi_search\` (which returns the ref +
424
+ stateVersion), a targeted edit is two calls with no read.
425
+ - **definition CSS is fully replaced** on \`upsertDefinition\`: send every property you want to keep. To change only
426
+ some declarations, use **\`patchDefinition\`** — it merges CSS per breakpoint/state/variant/slot onto the existing
427
+ definition (listed keys change, \`null\` removes a property, everything else is preserved) and never creates.
428
+ Example — recolor one definition without resending it: \`{ "type": "patchDefinition", "ref": "btn-x",
429
+ "desktop": { "background-color": "#111" } }\`.
430
+ - **Atomic batches**: if any operation fails, \`plitzi_apply\` persists nothing.
431
+ - **Every resource you touch must be malformation-free — pre-existing errors block the save.** When your batch edits
432
+ an element (or a definition/global/id style), the validator also checks the resource's **current stored content**
433
+ for malformations — a broken transformer action, a malformed interaction node, invalid CSS — even in parts your
434
+ edit does not touch. Such a finding is reported as a \`Pre-existing malformation in <resource>: …\` **error**, and
435
+ \`plitzi_apply\` rejects the batch until it is fixed. These are **not caused by your change** (the message says so)
436
+ — do not be confused; fix them **in the same batch** and re-apply. Because the check runs on the resulting state,
437
+ including the fix in your batch is exactly what unblocks the save. (Advisory issues — an unobserved source/action
438
+ name that may still be a valid plugin, a binding target a plugin manifest does not list — come back as
439
+ \`Pre-existing issue …\` **warnings** and do not block.)
440
+ - **Optimistic concurrency — read before you write, and prove your read is current.** Editing a resource means you
441
+ read it first, so you hold its \`stateVersion\`. **Always pass \`expectedResourceVersions\`** (URI → the stateVersion
442
+ you read) for every resource your batch changes. If another agent edited it in the meantime, the live version no
443
+ longer matches and apply is **rejected with a conflict** — nothing persists. Then re-read the reported resources
444
+ (their new content + version) and retry on top of the fresh state. This is exactly how a file editor forces a
445
+ re-read after a stale write: it is what keeps concurrent agents from silently overwriting each other's changes, so
446
+ never omit it "to save a call".
447
+ `;
448
+ //#endregion
449
+ export { guideQuickstart, guideText, serverInstructions };
@@ -0,0 +1,123 @@
1
+ import { applyBuiltinCallback } from "../catalogs/builtinCallbacks.js";
2
+ import { applyElementCallback } from "../catalogs/builtinElementCallbacks.js";
3
+ import { applyUtility } from "../catalogs/builtinUtilities.js";
4
+ import { generateObjectId } from "./space.js";
5
+ //#region src/modules/mcp/helpers/interactions.ts
6
+ var BINDING_CATEGORIES = [
7
+ "attributes",
8
+ "style",
9
+ "initialState"
10
+ ];
11
+ var NULLISH_ELEMENT_IDS = /* @__PURE__ */ new Set([
12
+ "undefined",
13
+ "null",
14
+ ""
15
+ ]);
16
+ var isNonEmptyObject = (value) => value !== void 0 && Object.keys(value).length > 0;
17
+ var nodeToAI = (node) => {
18
+ const ai = {
19
+ id: node.id,
20
+ title: node.title,
21
+ nodeType: node.type,
22
+ action: node.action
23
+ };
24
+ if (isNonEmptyObject(node.params)) ai.params = node.params;
25
+ if (!node.enabled) ai.enabled = false;
26
+ if (node.when !== void 0) ai.when = node.when;
27
+ if (node.elementId && node.elementId !== node.id) ai.elementId = node.elementId;
28
+ if (isNonEmptyObject(node.preview)) ai.preview = node.preview;
29
+ return ai;
30
+ };
31
+ var orderFlow = (nodes) => {
32
+ const byId = new Map(nodes.map((n) => [n.id, n]));
33
+ const head = nodes.find((n) => !n.beforeNode || !byId.has(n.beforeNode)) ?? nodes[0];
34
+ const ordered = [];
35
+ const seen = /* @__PURE__ */ new Set();
36
+ let current = head;
37
+ while (current && !seen.has(current.id)) {
38
+ seen.add(current.id);
39
+ ordered.push(current);
40
+ current = current.afterNode ? byId.get(current.afterNode) : void 0;
41
+ }
42
+ for (const node of nodes) if (!seen.has(node.id)) ordered.push(node);
43
+ return ordered;
44
+ };
45
+ var flowsFromInteractions = (interactions) => {
46
+ if (!interactions || Object.keys(interactions).length === 0) return [];
47
+ const byFlow = /* @__PURE__ */ new Map();
48
+ for (const node of Object.values(interactions)) {
49
+ const key = node.flowId || node.id;
50
+ const list = byFlow.get(key);
51
+ if (list) list.push(node);
52
+ else byFlow.set(key, [node]);
53
+ }
54
+ const flows = [];
55
+ for (const [flowId, nodes] of byFlow) flows.push({
56
+ flowId,
57
+ nodes: orderFlow(nodes).map(nodeToAI)
58
+ });
59
+ return flows;
60
+ };
61
+ var newNodeId = () => `node_${generateObjectId()}`;
62
+ /** Materialize an ordered list of nodes into the stored linked-node map for ONE flow: assign ids where missing,
63
+ * set flowId to the trigger id, and recompute beforeNode/afterNode from the order. `ownerId` is the default
64
+ * source element for callbacks that name none. */
65
+ var materializeFlow = (nodes, ownerId) => {
66
+ const ids = nodes.map((node) => node.id || newNodeId());
67
+ const flowId = ids[0];
68
+ const record = {};
69
+ nodes.forEach((node, i) => {
70
+ let params = node.params ?? {};
71
+ const supplied = NULLISH_ELEMENT_IDS.has(node.elementId ?? "") ? void 0 : node.elementId;
72
+ let elementId = node.nodeType === "utility" ? null : supplied ?? ownerId;
73
+ if (node.nodeType === "globalCallback") {
74
+ const builtin = applyBuiltinCallback(node.action, params);
75
+ if (builtin.source) {
76
+ elementId = builtin.source;
77
+ params = builtin.params;
78
+ }
79
+ } else if (node.nodeType === "callback") params = applyElementCallback(node.action, params).params;
80
+ else if (node.nodeType === "utility") params = applyUtility(node.action, params).params;
81
+ const interaction = {
82
+ id: ids[i],
83
+ title: node.title,
84
+ type: node.nodeType,
85
+ action: node.action,
86
+ params,
87
+ preview: node.preview ?? {},
88
+ elementId,
89
+ beforeNode: i > 0 ? ids[i - 1] : "",
90
+ afterNode: i < ids.length - 1 ? ids[i + 1] : "",
91
+ flowId,
92
+ enabled: node.enabled ?? true
93
+ };
94
+ if (node.when !== void 0) interaction.when = node.when;
95
+ record[ids[i]] = interaction;
96
+ });
97
+ return {
98
+ flowId,
99
+ record
100
+ };
101
+ };
102
+ var bindingToAI = (binding) => {
103
+ const ai = {
104
+ id: binding.id,
105
+ to: binding.to,
106
+ source: binding.source
107
+ };
108
+ if (binding.transformers && binding.transformers.length > 0) ai.transformers = binding.transformers;
109
+ if (binding.when !== void 0) ai.when = binding.when;
110
+ if (binding.enabled === false) ai.enabled = false;
111
+ return ai;
112
+ };
113
+ var bindingsToAI = (bindings) => {
114
+ if (!bindings) return;
115
+ const result = {};
116
+ for (const category of BINDING_CATEGORIES) {
117
+ const list = bindings[category];
118
+ if (list && list.length > 0) result[category] = list.map(bindingToAI);
119
+ }
120
+ return Object.keys(result).length > 0 ? result : void 0;
121
+ };
122
+ //#endregion
123
+ export { BINDING_CATEGORIES, NULLISH_ELEMENT_IDS, bindingToAI, bindingsToAI, flowsFromInteractions, materializeFlow, newNodeId };
@@ -0,0 +1,54 @@
1
+ //#region src/modules/mcp/helpers/log.ts
2
+ var MCP_DEBUG = process.env.MCP_DEBUG === "1";
3
+ var summarize = (value, max = 300) => {
4
+ if (value === void 0) return;
5
+ let json;
6
+ try {
7
+ json = JSON.stringify(value);
8
+ } catch {
9
+ return "[unserializable]";
10
+ }
11
+ return json.length > max ? `${json.slice(0, max)}…` : json;
12
+ };
13
+ var errorText = (error) => error instanceof Error ? error.message : String(error);
14
+ var consoleRender = (event) => {
15
+ const kind = event.kind === "tool" ? "tools/call" : "resources/read";
16
+ const detail = event.argsSummary ? ` ${event.argsSummary}` : "";
17
+ const status = event.ok ? "ok" : `ERROR ${event.error ?? ""}`;
18
+ console.log(`[mcp] ${kind} ${event.name}${detail} ${Math.round(event.durationMs)}ms ${status}`);
19
+ };
20
+ var noop = () => void 0;
21
+ var inertLog = {
22
+ toolCall: noop,
23
+ resourceRead: noop
24
+ };
25
+ /** Build the request-log sink for one MCP server. Dispatches structured events to the consumer's `logger` when
26
+ * provided; otherwise renders to the console when MCP_DEBUG=1; otherwise a no-op. */
27
+ var createMcpLog = (logger) => {
28
+ if (!logger && !MCP_DEBUG) return inertLog;
29
+ const emit = (event) => {
30
+ if (logger) logger(event);
31
+ else consoleRender(event);
32
+ };
33
+ return {
34
+ toolCall: (name, args, ms, error) => emit({
35
+ kind: "tool",
36
+ name,
37
+ durationMs: ms,
38
+ ok: !error,
39
+ ...error ? { error: errorText(error) } : {},
40
+ ...summarize(args) !== void 0 ? { argsSummary: summarize(args) } : {},
41
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
42
+ }),
43
+ resourceRead: (uri, ms, error) => emit({
44
+ kind: "resource",
45
+ name: uri,
46
+ durationMs: ms,
47
+ ok: !error,
48
+ ...error ? { error: errorText(error) } : {},
49
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
50
+ })
51
+ };
52
+ };
53
+ //#endregion
54
+ export { createMcpLog };