@plitzi/sdk-mcp 0.39.3 → 0.39.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 (106) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +39 -39
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +2 -1
  5. package/dist/modules/mcp/answerBudgets.d.ts +29 -0
  6. package/dist/modules/mcp/answerBudgets.js +37 -0
  7. package/dist/modules/mcp/apps/example/view/index.tsx +0 -1
  8. package/dist/modules/mcp/apps/render/view/index.tsx +0 -1
  9. package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +8 -0
  10. package/dist/modules/mcp/catalogs/pluginCatalog.js +35 -1
  11. package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
  12. package/dist/modules/mcp/helpers/guide/reference.js +16 -2
  13. package/dist/modules/mcp/helpers/guide/structure.d.ts +1 -1
  14. package/dist/modules/mcp/helpers/guide/structure.js +1 -0
  15. package/dist/modules/mcp/helpers/opResult.d.ts +3 -1
  16. package/dist/modules/mcp/helpers/opResult.js +3 -1
  17. package/dist/modules/mcp/localScreenshotClient.d.ts +10 -0
  18. package/dist/modules/mcp/localScreenshotClient.js +46 -16
  19. package/dist/modules/mcp/previewClient.js +2 -2
  20. package/dist/modules/mcp/resources/canonical.js +2 -2
  21. package/dist/modules/mcp/server.d.ts +1 -1
  22. package/dist/modules/mcp/server.js +10 -3
  23. package/dist/modules/mcp/tools/activity.js +2 -2
  24. package/dist/modules/mcp/tools/apply/dispatch.js +7 -1
  25. package/dist/modules/mcp/tools/apply/index.d.ts +25 -1
  26. package/dist/modules/mcp/tools/apply/index.js +21 -5
  27. package/dist/modules/mcp/tools/describeOperation.js +1 -1
  28. package/dist/modules/mcp/tools/index.js +5 -1
  29. package/dist/modules/mcp/tools/intents.js +26 -4
  30. package/dist/modules/mcp/tools/look.d.ts +1 -0
  31. package/dist/modules/mcp/tools/look.js +2 -1
  32. package/dist/modules/mcp/tools/operations/actions/deleteAction.js +1 -1
  33. package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -3
  34. package/dist/modules/mcp/tools/operations/actions/upsertAction.js +1 -1
  35. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +1 -1
  36. package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +2 -2
  37. package/dist/modules/mcp/tools/operations/data/index.js +3 -3
  38. package/dist/modules/mcp/tools/operations/functions/index.js +2 -2
  39. package/dist/modules/mcp/tools/operations/index.d.ts +97 -4
  40. package/dist/modules/mcp/tools/operations/index.js +1 -0
  41. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -1
  42. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -1
  43. package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +2 -2
  44. package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +8 -8
  45. package/dist/modules/mcp/tools/operations/schema/elements/addSpec.d.ts +29 -0
  46. package/dist/modules/mcp/tools/operations/schema/elements/addSpec.js +118 -0
  47. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -2
  48. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +4 -4
  49. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +2 -2
  50. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +2 -0
  51. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -3
  52. package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +1 -1
  53. package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -2
  54. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +1 -1
  55. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +1 -1
  56. package/dist/modules/mcp/tools/operations/schema/index.d.ts +1 -0
  57. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +4 -4
  58. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -1
  59. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +25 -1
  60. package/dist/modules/mcp/tools/operations/schema/operations.js +2 -0
  61. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -2
  62. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
  63. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +4 -0
  64. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +14 -7
  65. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +8 -1
  66. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +9 -6
  67. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +3 -2
  68. package/dist/modules/mcp/tools/operations/schema/write.js +3 -3
  69. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +2 -1
  70. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +1 -1
  71. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -2
  72. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +1 -1
  73. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +2 -1
  74. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +1 -1
  75. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +2 -1
  76. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +1 -1
  77. package/dist/modules/mcp/tools/operations/style/validate.js +6 -6
  78. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +3 -2
  79. package/dist/modules/mcp/tools/operations/style/write.js +1 -1
  80. package/dist/modules/mcp/tools/releases.d.ts +3 -0
  81. package/dist/modules/mcp/tools/releases.js +60 -0
  82. package/dist/modules/mcp/tools/render.d.ts +24 -1
  83. package/dist/modules/mcp/tools/renderWidget.d.ts +24 -1
  84. package/dist/modules/mcp/tools/search.js +1 -1
  85. package/dist/modules/mcp/tools/shared/agentHtml.d.ts +8 -0
  86. package/dist/modules/mcp/tools/shared/agentHtml.js +18 -0
  87. package/dist/modules/mcp/tools/shared/lintDraft.js +1 -0
  88. package/dist/modules/mcp/tools/shared/look.d.ts +2 -0
  89. package/dist/modules/mcp/tools/shared/look.js +15 -8
  90. package/dist/modules/mcp/tools/shared/repeats.d.ts +1 -1
  91. package/dist/modules/mcp/tools/shared/repeats.js +1 -1
  92. package/dist/modules/mcp/tools/shared/tool.d.ts +21 -1
  93. package/dist/modules/mcp/tools/shared/validator/connectors.js +3 -0
  94. package/dist/modules/mcp/tools/shared/validator/css.js +2 -0
  95. package/dist/modules/mcp/tools/shared/validator/elements.js +3 -0
  96. package/dist/modules/mcp/tools/shared/validator/index.js +39 -0
  97. package/dist/modules/mcp/tools/shared/validator/interactions.js +1 -0
  98. package/dist/modules/mcp/tools/shared/validator/refs.js +3 -0
  99. package/dist/modules/mcp/tools/tryFunction.js +2 -2
  100. package/dist/modules/mcp/types/aiSchema.d.ts +3 -0
  101. package/dist/modules/mcp/types/previewTypes.d.ts +9 -1
  102. package/dist/options.d.ts +1 -1
  103. package/dist/preview/createPreview.js +38 -7
  104. package/dist/server.d.ts +1 -1
  105. package/dist/server.js +2 -2
  106. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @plitzi/sdk-mcp
2
2
 
3
+ ## 0.39.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @plitzi/plitzi-sdk@0.39.6
8
+ - @plitzi/sdk-server@0.39.6
9
+ - @plitzi/sdk-authoring@0.39.6
10
+ - @plitzi/sdk-kernel@0.39.6
11
+ - @plitzi/sdk-schema@0.39.6
12
+ - @plitzi/sdk-shared@0.39.6
13
+ - @plitzi/sdk-style@0.39.6
14
+
15
+ ## 0.39.5
16
+
17
+ ### Patch Changes
18
+
19
+ - 4427674: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
20
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
21
+ - Updated dependencies [4427674]
22
+ - @plitzi/plitzi-sdk@0.39.5
23
+ - @plitzi/sdk-server@0.39.5
24
+ - @plitzi/sdk-authoring@0.39.5
25
+ - @plitzi/sdk-kernel@0.39.5
26
+ - @plitzi/sdk-schema@0.39.5
27
+ - @plitzi/sdk-shared@0.39.5
28
+ - @plitzi/sdk-style@0.39.5
29
+
30
+ ## 0.39.4
31
+
32
+ ### Patch Changes
33
+
34
+ - 35415a1: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
35
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
36
+ - Updated dependencies [35415a1]
37
+ - @plitzi/plitzi-sdk@0.39.4
38
+ - @plitzi/sdk-server@0.39.4
39
+ - @plitzi/sdk-authoring@0.39.4
40
+ - @plitzi/sdk-kernel@0.39.4
41
+ - @plitzi/sdk-schema@0.39.4
42
+ - @plitzi/sdk-shared@0.39.4
43
+ - @plitzi/sdk-style@0.39.4
44
+
3
45
  ## 0.39.3
4
46
 
5
47
  ### Patch Changes
package/README.md CHANGED
@@ -67,21 +67,21 @@ operations, their lint, the draft's render — with the first preview it is aske
67
67
 
68
68
  The server is stateless: it resolves the space per request and reads and writes through adapters you supply.
69
69
 
70
- | Adapter | Required | Purpose |
71
- |---|---|---|
72
- | `getGrant(req)` | yes | The space this request operates on **and whether the caller may change it** (`{ spaceId, scope, userId?, client?, canWrite }` — `client`, the application an agent grant was given to, rides every write as `SSRWriteContext.client`), decoded from the verified `Authorization` bearer. You own the JWT secret and the authorization model, so both are decided on your side. Return `undefined` for a missing or invalid token. |
73
- | `getSchema(spaceId, env)` | yes | The element schema the tools read and mutate. |
74
- | `getStyle(spaceId, env)` | yes | The full style document, including `platform`/`mode`. |
75
- | `saveSchema(spaceId, env, schema)` | for writes | Persist a mutated schema. Without it, `plitzi_apply` reports `persisted: false` and leads its warnings with what was NOT saved. |
76
- | `saveStyle(spaceId, env, style)` | for writes | Persist a mutated style document. |
77
- | `getChanges(spaceId, env, query)` | no | The space's change history, for the `plitzi://changes` resources. Writes arrive with an `SSRWriteContext` (`userId`, one `batch` per tool call) so a consumer can record them. |
78
- | `getActivity(spaceId, query, reader, signal)` | no | What happened on the space after a cursor — the draft changed, a version went out, an action failed (`SpaceActivityPage`, `@plitzi/sdk-shared/activity`) — waiting up to `query.wait` seconds; `reader` is the member the agent acts for with `origin: 'mcp'`, whose own writes are left out unless `mine`, and `signal` ends the wait with the call. Without it there is no `plitzi_activity`. Only an `agent` grant reaches it. |
79
- | `getOfflineData(spaceId, env, rev)` | for preview | Read side of draft-preview. Only the preview endpoint calls it. |
80
- | `getComponentCatalog(spaceId, env)` | no | The element types the space's plugins add, for the catalog resources. |
81
- | `getConnectors` / `saveConnector` / `deleteConnector` | for connectors | The space's connector manifests, read and written by the connector operations. |
82
- | `getActions` / `getActionTasks` / `saveAction` / `deleteAction` | for actions | The space's server actions, and the catalog of tasks a step may run — the deployment's, the space's own functions and its plugins' server halves, each with its `origin` (`deployment`, `space` or `plugin`). |
83
- | `getFunctions` / `saveFunctions` / `tryFunction` | for functions | The space's functions: read for `plitzi://functions/{env}`, saved (built and checked, refused from an older copy) by `upsertFunctionFile` / `deleteFunctionFile`, and run by `plitzi_try_function`. |
84
- | `getData` / `saveData` | for data | The space's data — JSON its server providers read as `/data/<file>`: read for `plitzi://data/{env}`, saved whole (each file checked, refused from an older copy) by `upsertDataFile` / `deleteDataFile`. |
70
+ | Adapter | Required | Purpose |
71
+ | --------------------------------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72
+ | `getGrant(req)` | yes | The space this request operates on **and whether the caller may change it** (`{ spaceId, scope, userId?, client?, canWrite }` — `client`, the application an agent grant was given to, rides every write as `SSRWriteContext.client`), decoded from the verified `Authorization` bearer. You own the JWT secret and the authorization model, so both are decided on your side. Return `undefined` for a missing or invalid token. |
73
+ | `getSchema(spaceId, env)` | yes | The element schema the tools read and mutate. |
74
+ | `getStyle(spaceId, env)` | yes | The full style document, including `platform`/`mode`. |
75
+ | `saveSchema(spaceId, env, schema)` | for writes | Persist a mutated schema. Without it, `plitzi_apply` reports `persisted: false` and leads its warnings with what was NOT saved. |
76
+ | `saveStyle(spaceId, env, style)` | for writes | Persist a mutated style document. |
77
+ | `getChanges(spaceId, env, query)` | no | The space's change history, for the `plitzi://changes` resources. Writes arrive with an `SSRWriteContext` (`userId`, one `batch` per tool call) so a consumer can record them. |
78
+ | `getActivity(spaceId, query, reader, signal)` | no | What happened on the space after a cursor — the draft changed, a version went out, an action failed (`SpaceActivityPage`, `@plitzi/sdk-shared/activity`) — waiting up to `query.wait` seconds; `reader` is the member the agent acts for with `origin: 'mcp'`, whose own writes are left out unless `mine`, and `signal` ends the wait with the call. Without it there is no `plitzi_activity`. Only an `agent` grant reaches it. |
79
+ | `getOfflineData(spaceId, env, rev)` | for preview | Read side of draft-preview. Only the preview endpoint calls it. |
80
+ | `getComponentCatalog(spaceId, env)` | no | The element types the space's plugins add, for the catalog resources. |
81
+ | `getConnectors` / `saveConnector` / `deleteConnector` | for connectors | The space's connector manifests, read and written by the connector operations. |
82
+ | `getActions` / `getActionTasks` / `saveAction` / `deleteAction` | for actions | The space's server actions, and the catalog of tasks a step may run — the deployment's, the space's own functions and its plugins' server halves, each with its `origin` (`deployment`, `space` or `plugin`). |
83
+ | `getFunctions` / `saveFunctions` / `tryFunction` | for functions | The space's functions: read for `plitzi://functions/{env}`, saved (built and checked, refused from an older copy) by `upsertFunctionFile` / `deleteFunctionFile`, and run by `plitzi_try_function`. |
84
+ | `getData` / `saveData` | for data | The space's data — JSON its server providers read as `/data/<file>`: read for `plitzi://data/{env}`, saved whole (each file checked, refused from an older copy) by `upsertDataFile` / `deleteDataFile`. |
85
85
 
86
86
  Schema and style are read as **separate documents** on purpose: `getOfflineData` is SSR-shaped and strips
87
87
  `style.platform`, which the style resources need.
@@ -104,14 +104,14 @@ What MCP itself serves is `McpOptions` (`src/options.ts`), the **second** argume
104
104
  `mcpExtensions(options)` for a page server — never a section of the server config, which a page-only deployment
105
105
  types its renderer with.
106
106
 
107
- | Option | Default | Purpose |
108
- |---|---|---|
109
- | `path` | `/mcp` | Where MCP answers inside a server that also serves pages. A dedicated MCP server owns its whole origin and ignores it. |
110
- | `renderStreaming` | `true` | Whether the `plitzi_render` view paints from the tool arguments while the host still streams them. `false` keeps the view blank until the finished widget arrives. |
111
- | `proxy` | off | `McpProxyOptions`: with a `secret`, every external URL a render authored is rewritten to this server's signed endpoint (`path`, default `/__proxy`) and fetched here — the origins a widget needs cannot be declared ahead. `baseUrl`, `maxBytes` (8 MiB), `ttl` (7 days), `tools` (`['plitzi_render']`), `enabled`. |
112
- | `previewClient` | off | `{ url, secret? }`: the SSR `/preview` endpoint, for an MCP server that runs apart from the renderer. Without it `plitzi_look` and `plitzi_apply`'s `look` report `PREVIEW_UNAVAILABLE`. |
113
- | `screenshot` | off | `{ serviceUrl, renderBaseUrl }`: the browser service a look renders an image or an accessibility outline through, and the SSR base it navigates to. Without it a look answers the HTML, and says so. |
114
- | `oauth` | off | OAuth 2.1 for remote connectors — see [OAuth](#oauth). |
107
+ | Option | Default | Purpose |
108
+ | ----------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `path` | `/mcp` | Where MCP answers inside a server that also serves pages. A dedicated MCP server owns its whole origin and ignores it. |
110
+ | `renderStreaming` | `true` | Whether the `plitzi_render` view paints from the tool arguments while the host still streams them. `false` keeps the view blank until the finished widget arrives. |
111
+ | `proxy` | off | `McpProxyOptions`: with a `secret`, every external URL a render authored is rewritten to this server's signed endpoint (`path`, default `/__proxy`) and fetched here — the origins a widget needs cannot be declared ahead. `baseUrl`, `maxBytes` (8 MiB), `ttl` (7 days), `tools` (`['plitzi_render']`), `enabled`. |
112
+ | `previewClient` | off | `{ url, secret? }`: the SSR `/preview` endpoint, for an MCP server that runs apart from the renderer. Without it `plitzi_look` and `plitzi_apply`'s `look` are refused with `not-allowed`. |
113
+ | `screenshot` | off | `{ serviceUrl, renderBaseUrl }`: the browser service a look renders an image or an accessibility outline through, and the SSR base it navigates to. Without it a look answers the HTML, and says so. |
114
+ | `oauth` | off | OAuth 2.1 for remote connectors — see [OAuth](#oauth). |
115
115
 
116
116
  ```ts
117
117
  createServer({ adapters }, { screenshot: { serviceUrl, renderBaseUrl }, proxy: { secret } });
@@ -119,17 +119,17 @@ createServer({ adapters }, { screenshot: { serviceUrl, renderBaseUrl }, proxy: {
119
119
 
120
120
  ## Tools
121
121
 
122
- | Tool | Access | What it does |
123
- |---|---|---|
124
- | `plitzi_search` | read | Find elements, pages, styles and bindings; returns ready-made URIs |
125
- | `plitzi_read` | read | Read one or more resources in detail by URI |
126
- | `plitzi_apply` | write | Apply a batch of operations and persist; answers with its `effects` — every change it made, read off the space before and after — and its suggestions. `dryRun` checks it without saving, and `look` renders the page as the batch leaves it (HTML, a PNG or the accessibility outline) |
127
- | `plitzi_set_attributes`, `plitzi_set_classes`, `plitzi_bind_attribute`, `plitzi_place_component`, `plitzi_add_page` | write | One change by its intention — an element's attributes, classes added or removed, a binding, a component placed, a page — by the element's ref alone, saved as `plitzi_apply` saves it, answered with its `effects`, whether it was `saved`, and what was already so |
128
- | `plitzi_describe_operation` | read | One operation's schema by its type, or the list of every type |
129
- | `plitzi_look` | read | See a saved page: its accessibility outline (default), its HTML, or a PNG (desktop, mobile or both) |
130
- | `plitzi_render` | read | Render a self-contained UI widget, offline, with no space |
131
- | `plitzi_try_function` | write | Run one task of the space's functions against the draft, in the sandbox: its value, logs and error |
132
- | `plitzi_activity` | read | What happened on the space since a cursor — edits by people and other agents, versions out, actions failing — waited for up to 50 s; the agent's own writes left out and counted |
122
+ | Tool | Access | What it does |
123
+ | ------------------------------------------------------------------------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
124
+ | `plitzi_search` | read | Find elements, pages, styles and bindings; returns ready-made URIs |
125
+ | `plitzi_read` | read | Read one or more resources in detail by URI |
126
+ | `plitzi_apply` | write | Apply a batch of operations and persist; answers with its `effects` — every change it made, read off the space before and after — and its suggestions. `dryRun` checks it without saving, and `look` renders the page as the batch leaves it (HTML, a PNG or the accessibility outline) |
127
+ | `plitzi_set_attributes`, `plitzi_set_classes`, `plitzi_bind_attribute`, `plitzi_place_component`, `plitzi_add_page` | write | One change by its intention — an element's attributes, classes added or removed, a binding, a component placed, a page — by the element's ref alone, saved as `plitzi_apply` saves it, answered with its `effects`, whether it was `saved`, and what was already so |
128
+ | `plitzi_describe_operation` | read | One operation's schema by its type, or the list of every type |
129
+ | `plitzi_look` | read | See a saved page: its accessibility outline (default), its HTML, or a PNG (desktop, mobile or both) |
130
+ | `plitzi_render` | read | Render a self-contained UI widget, offline, with no space |
131
+ | `plitzi_try_function` | write | Run one task of the space's functions against the draft, in the sandbox: its value, logs and error |
132
+ | `plitzi_activity` | read | What happened on the space since a cursor — edits by people and other agents, versions out, actions failing — waited for up to 50 s; the agent's own writes left out and counted |
133
133
 
134
134
  The server advertises each tool's access as its `readOnlyHint` annotation, so a host can run a read without asking
135
135
  and ask before a write.
@@ -231,11 +231,11 @@ MCP server, [self-hosting/07](../../examples/self-hosting/07-ssr-preview) is the
231
231
 
232
232
  ## Entry points
233
233
 
234
- | Import | Carries |
235
- |---|---|
236
- | `@plitzi/sdk-mcp/server` | The dedicated MCP server and its clients. What an MCP deployment wires. |
237
- | `@plitzi/sdk-mcp` | Everything above plus the pipeline stages, `createPreview` and the tool engine. |
238
- | `@plitzi/sdk-mcp/render` | `plitzi_render`'s widget render alone — no MCP server, no SSR, no OAuth — for a project's own agent. |
234
+ | Import | Carries |
235
+ | ------------------------- | -------------------------------------------------------------------------------------------------------- |
236
+ | `@plitzi/sdk-mcp/server` | The dedicated MCP server and its clients. What an MCP deployment wires. |
237
+ | `@plitzi/sdk-mcp` | Everything above plus the pipeline stages, `createPreview` and the tool engine. |
238
+ | `@plitzi/sdk-mcp/render` | `plitzi_render`'s widget render alone — no MCP server, no SSR, no OAuth — for a project's own agent. |
239
239
  | `@plitzi/sdk-mcp/preview` | `previewStage` alone, for the page server that mounts it; the preview itself is loaded by the first one. |
240
240
 
241
241
  The split is about weight, not taste: ESM re-exports load eagerly, so the barrel pulls the draft-preview path and
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { createWidgetProxyStage } from './stages/proxy';
12
12
  export { createPreview } from './preview/createPreview';
13
13
  export { createMcpServer, handleMcp, serveMcp, readMcpBody, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, resolveLocalBrowser, outlineOfSnapshot, outlineOfTree, unnamedControls } from './modules/mcp';
14
14
  export { apply, search, read, applyShape, searchShape, readShape, operation, tools } from './modules/mcp/tools';
15
+ export { ANSWER_BUDGETS, HOST_ANSWERS } from './modules/mcp/answerBudgets';
15
16
  export type { McpServerContext, McpRequestOptions, PreviewClient, PreviewRequestBody, PreviewResult, HttpPreviewClientConfig, ScreenshotClient, ScreenshotImage, ScreenshotResult, AccessibilityNode, AccessibilityOutline, CaptureView, UnnamedControl, Viewport, HttpScreenshotClientConfig } from './modules/mcp';
16
17
  export type { ApplyInput, SearchInput, SearchResponse, SearchHit, ReadInput, ReadResponse, ReadHit, WriteResponse, WriteElement, Persisters, Operation, ToolDef, ToolContext } from './modules/mcp/tools';
17
18
  export type { Space } from './modules/mcp/helpers';
package/dist/index.js CHANGED
@@ -15,5 +15,6 @@ import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
15
15
  import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
16
16
  import { outlineOfSnapshot, outlineOfTree, unnamedControls } from "./modules/mcp/accessibilityOutline.js";
17
17
  import { tools } from "./modules/mcp/tools/index.js";
18
+ import { ANSWER_BUDGETS, HOST_ANSWERS } from "./modules/mcp/answerBudgets.js";
18
19
  import { createOAuthGuardStage, createOAuthStage } from "@plitzi/sdk-server/oauth";
19
- export { apply, applyShape, buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpOnlyStage, createMcpServer, createMcpStage, createOAuthGuardStage, createOAuthStage, createPreview, createServer, createWidgetProxyStage, handleMcp, mcpExtensions, operation, outlineOfSnapshot, outlineOfTree, previewStage, read, readMcpBody, readShape, resolveLocalBrowser, search, searchShape, serveMcp, tools, unnamedControls };
20
+ export { ANSWER_BUDGETS, HOST_ANSWERS, apply, applyShape, buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpOnlyStage, createMcpServer, createMcpStage, createOAuthGuardStage, createOAuthStage, createPreview, createServer, createWidgetProxyStage, handleMcp, mcpExtensions, operation, outlineOfSnapshot, outlineOfTree, previewStage, read, readMcpBody, readShape, resolveLocalBrowser, search, searchShape, serveMcp, tools, unnamedControls };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Each answer's ceiling in tokens (four characters each), measured when it was set and a tenth more. Raised when an
3
+ * answer grows because it says what an agent needs — said in the change; what is cut is what is said twice, never a
4
+ * field. The answers made from the space alone are held on `largeSpace(30, 100, 200)` by `tests/answerBudgets.test.ts`;
5
+ * those a host makes — the activity it reads, the page it renders — are held where the host runs them, against this
6
+ * table (`HOST_ANSWERS`): Plitzi's in `plitzi-sdk-server`'s e2e.
7
+ */
8
+ export declare const ANSWER_BUDGETS: {
9
+ readonly 'plitzi://primer': 13400;
10
+ readonly 'plitzi://schema/\u2026/pages/{ref}': 4000;
11
+ readonly 'plitzi://schema/\u2026/elements/{ref}': 100;
12
+ readonly 'plitzi://definitions': 540;
13
+ readonly 'plitzi://types': 1560;
14
+ readonly 'plitzi://global-styles': 50;
15
+ readonly 'plitzi://interactions': 5100;
16
+ readonly 'plitzi://style-variables': 50;
17
+ readonly plitzi_search: 5110;
18
+ readonly 'plitzi_search include detail': 9340;
19
+ readonly plitzi_describe_operation: 230;
20
+ readonly 'plitzi_describe_operation upsertElement': 910;
21
+ readonly plitzi_render: 32;
22
+ readonly plitzi_activity: 448;
23
+ readonly plitzi_look: 7250;
24
+ readonly 'plitzi_look html': 29150;
25
+ readonly 'plitzi_look image': 30;
26
+ readonly plitzi_test: 2720;
27
+ };
28
+ /** The answers this package cannot make alone: a host measures them, on its own adapters. */
29
+ export declare const HOST_ANSWERS: readonly ["plitzi_activity", "plitzi_look", "plitzi_look html", "plitzi_look image", "plitzi_test"];
@@ -0,0 +1,37 @@
1
+ // src/modules/mcp/answerBudgets.ts
2
+ /**
3
+ * Each answer's ceiling in tokens (four characters each), measured when it was set and a tenth more. Raised when an
4
+ * answer grows because it says what an agent needs — said in the change; what is cut is what is said twice, never a
5
+ * field. The answers made from the space alone are held on `largeSpace(30, 100, 200)` by `tests/answerBudgets.test.ts`;
6
+ * those a host makes — the activity it reads, the page it renders — are held where the host runs them, against this
7
+ * table (`HOST_ANSWERS`): Plitzi's in `plitzi-sdk-server`'s e2e.
8
+ */
9
+ var ANSWER_BUDGETS = {
10
+ "plitzi://primer": 13400,
11
+ "plitzi://schema/…/pages/{ref}": 4e3,
12
+ "plitzi://schema/…/elements/{ref}": 100,
13
+ "plitzi://definitions": 540,
14
+ "plitzi://types": 1560,
15
+ "plitzi://global-styles": 50,
16
+ "plitzi://interactions": 5100,
17
+ "plitzi://style-variables": 50,
18
+ plitzi_search: 5110,
19
+ "plitzi_search include detail": 9340,
20
+ plitzi_describe_operation: 230,
21
+ "plitzi_describe_operation upsertElement": 910,
22
+ plitzi_render: 32,
23
+ plitzi_activity: 448,
24
+ plitzi_look: 7250,
25
+ "plitzi_look html": 29150,
26
+ "plitzi_look image": 30,
27
+ plitzi_test: 2720
28
+ };
29
+ /** The answers this package cannot make alone: a host measures them, on its own adapters. */
30
+ var HOST_ANSWERS = [
31
+ "plitzi_activity",
32
+ "plitzi_look",
33
+ "plitzi_look html",
34
+ "plitzi_look image",
35
+ "plitzi_test"
36
+ ];
37
+ export { ANSWER_BUDGETS, HOST_ANSWERS };
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-refresh/only-export-components -- one bundled entry: components cannot move out. */
2
1
  import { useApp, useHostStyles } from '@modelcontextprotocol/ext-apps/react';
3
2
  import { useState } from 'react';
4
3
  import { createRoot } from 'react-dom/client';
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-refresh/only-export-components -- one bundled entry: components cannot move out. */
2
1
  import { useApp, useHostStyles } from '@modelcontextprotocol/ext-apps/react';
3
2
  import PlitziSdk from '@plitzi/plitzi-sdk';
4
3
  import { Component, useEffect, useRef, useState } from 'react';
@@ -18,3 +18,11 @@ export declare const stringDeclarations: (block: Record<string, unknown> | undef
18
18
  export declare const pluginCatalog: (plugins: Record<string, {
19
19
  resource: string;
20
20
  }> | undefined) => Promise<ComponentCatalog>;
21
+ /**
22
+ * The stylesheets a space's plugins publish (`assets` of type `style` in each manifest), as their text: what
23
+ * `suggestSpace` is handed as `stylesheets`, so a token only a plugin's CSS reads is not said unused — the same text
24
+ * authoring reads from a project's `src/plugins/`. Read through the same cache as the catalog.
25
+ */
26
+ export declare const pluginStylesheets: (plugins: Record<string, {
27
+ resource: string;
28
+ }> | undefined) => Promise<string[]>;
@@ -96,4 +96,38 @@ var pluginCatalog = async (plugins) => {
96
96
  for (const [type, entry] of entries.flat()) catalog[type] = entry;
97
97
  return catalog;
98
98
  };
99
- export { pluginCatalog, stringDeclarations };
99
+ var stylesheetCache = /* @__PURE__ */ new Map();
100
+ /** One stylesheet a plugin publishes, as text — cached as its manifest is, and null when its host does not answer. */
101
+ var fetchStylesheet = async (url) => {
102
+ const cached = stylesheetCache.get(url);
103
+ if (cached && cached.expiresAt > Date.now()) return cached.text;
104
+ let text = null;
105
+ try {
106
+ const res = await fetch(url);
107
+ text = res.ok ? await res.text() : null;
108
+ } catch {
109
+ text = null;
110
+ }
111
+ stylesheetCache.set(url, {
112
+ text,
113
+ expiresAt: Date.now() + MANIFEST_TTL_MS
114
+ });
115
+ return text;
116
+ };
117
+ /**
118
+ * The stylesheets a space's plugins publish (`assets` of type `style` in each manifest), as their text: what
119
+ * `suggestSpace` is handed as `stylesheets`, so a token only a plugin's CSS reads is not said unused — the same text
120
+ * authoring reads from a project's `src/plugins/`. Read through the same cache as the catalog.
121
+ */
122
+ var pluginStylesheets = async (plugins) => {
123
+ if (!plugins) return [];
124
+ return (await Promise.all(Object.values(plugins).map(async ({ resource }) => {
125
+ const manifest = await fetchManifest(resource);
126
+ const styles = Object.values(manifest?.assets ?? {}).filter((asset) => asset.type === "style");
127
+ return Promise.all(styles.map((asset) => {
128
+ const src = asset.url ?? (asset.src ? `${resource}/${asset.src}` : void 0);
129
+ return src ? fetchStylesheet(src) : Promise.resolve(null);
130
+ }));
131
+ }))).flat().filter((text) => text !== null);
132
+ };
133
+ export { pluginCatalog, pluginStylesheets, stringDeclarations };
@@ -1,2 +1,2 @@
1
1
  /** The guide's start: what to read, the tools, and how an element is addressed, made, moved and deleted. */
2
- export declare const referenceGuide = "# Plitzi AI MCP \u2014 usage guide\n\nA Plitzi space is **two separate schemas** you edit together:\n- **Element schema** \u2014 the tree of pages and elements (their type, label, props, and which style classes they use).\n- **Style schema** \u2014 reusable **definitions** (CSS classes), design tokens (variables), theme.\n\nThey are stored and persisted independently, but a single `plitzi_apply` batch may touch **both atomically**.\nTo style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**\nit via the element's `style.base` (element schema). Example \u2014 \"rename button X to PEPE and make it red\":\n```json\n{ \"operations\": [\n { \"type\": \"upsertDefinition\", \"ref\": \"btn-x\", \"desktop\": { \"color\": \"red\" } },\n { \"type\": \"upsertElement\", \"pageRef\": \"home\",\n \"element\": { \"ref\": \"X\", \"type\": \"button\", \"label\": \"PEPE\", \"style\": { \"base\": [\"btn-x\"] } } }\n] }\n```\n\nReads are cheap by design \u2014 treat them like a filesystem: **list** to navigate, **read one item** for detail.\nNever download a whole tree you do not need.\n\n## Resources (read)\n- `plitzi://primer/{env}` \u2014 **cold-start bundle**: guide + types + css-properties + page/definition/variable\n **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only \u2014 open a\n page skeleton or element for its tree/detail.\n- `plitzi://guide` \u2014 this guide.\n- `plitzi://types` \u2014 element types **observed in this space** (ground truth): props, slots, subTypes, plus each\n type's `label`, `description` (what it is FOR) and `category`, and a `source` (`builtin` | `plugin` | `unknown`).\n Read the descriptions to pick the right type \u2014 e.g. `apiContainer` fetches backend data into the frontend,\n `link` navigates between pages, `list` repeats a template over a data array. `plugin` types are the elements\n of the plugins the space installed: added by their type, like a built-in.\n- `plitzi://css-properties` \u2014 valid kebab-case CSS property keys.\n- `plitzi://explain/{name}` \u2014 what a name means: an element type's attributes, triggers, callbacks and what it writes\n on its node; a step's params and what it publishes; what a trigger hands its flow; a style state; a problem code's\n fix. `plitzi://explain/steps` (or elements, triggers, codes, transformers, states) lists every one of a kind.\n- `plitzi://schema/{env}/pages` \u2014 page **summaries** (ref, label, elementCount, folder). No element trees.\n- `plitzi://schema/{env}/layouts` \u2014 the shared **layout shells** (header/sidebar/footer) and the pages rendered\n inside each. Read one like a page. See *Shared layouts* below.\n- `plitzi://schema/{env}/components` \u2014 the space's **components** (reusable subtrees): their props, slots, root and\n how many places render each. Read one like a page. See *Components* below.\n- `plitzi://folders/{env}` \u2014 page **folders** (the sidebar tree): ref, name, slug, parentId. `/{ref}` for one.\n- `plitzi://schema/{env}/pages/{ref}` \u2014 one page as a **skeleton tree**: each node is `ref/type/label` **plus the\n style classes it attaches** (`base`, and `slots` for non-base slots) \u2014 names only, no CSS. So you can map every\n element to its class in a single page read, without opening each element just to learn which class it uses.\n- `plitzi://schema/{env}/pages/{ref}/styles` \u2014 **every style the page uses in one read**: the class definitions its\n elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.\n Reach for this to recolor/restyle a whole page \u2014 it needs no shared class-name prefix and no per-element reads.\n- `plitzi://schema/{env}/elements/{ref}` \u2014 one element in **full detail** (props, style, parentRef, childRefs).\n Its `resolvedStyle` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you\n can see and edit its style without a separate definition read. Its `globalStyles` lists the **global element\n selectors** that also affect it (the CSS equivalent of `button { \u2026 }`, keyed by the type they target) \u2014 every\n element of that type inherits them. Edit a global only through the global-style tools (never per element). If the\n element carries a DOM `id` that an id rule matches, its `idStyle` (`#id`) is inlined too.\n- `plitzi://definitions/{env}` \u2014 the **names** of every style definition.\n- `plitzi://definitions/{env}/{ref}` \u2014 one definition's CSS.\n- `plitzi://global-styles/{env}` \u2014 element **types** that have a site-wide global style. `/{componentType}` for one.\n- `plitzi://id-styles/{env}` \u2014 DOM **ids** that have an id rule (`#id`) targeting a single element. `/{targetId}` for one.\n- `plitzi://style-variables/{env}` \u2014 design tokens by category. `/{category}` for one.\n- `plitzi://fonts/{env}` \u2014 the font **families the space loads**, with their source and fallback. `/{family}` for one.\n- `plitzi://schema-variables/{env}` \u2014 space-level values referenced in props as `{{name}}`.\n- `plitzi://flags/{env}` \u2014 the space's **feature flags**, each a default and its rules (see **Feature flags**).\n- `plitzi://settings/{env}` \u2014 space-level settings: the global `customCss` and the state/auth (user-provider) config.\n- `plitzi://interactions/{env}` \u2014 interaction **actions** observed in this space (grouped by node type): the\n vocabulary for interaction flows.\n- `plitzi://data-sources/{env}` \u2014 data-source **paths** and binding targets observed in this space: the\n vocabulary for data bindings.\n- `plitzi://connector-presets` \u2014 working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain\n REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.\n Space-independent. Read it before writing a connector by hand.\n- `plitzi://connectors/{env}` \u2014 the **connectors this space has**: for each, its read/write endpoint names, its\n filter operators and its published fields. `/{ref}` opens one manifest in full. See *Connectors* below.\n- `plitzi://actions/{env}` \u2014 the **server actions this space has**: what starts each one, who may run it, and the\n input/output contract a caller is held to. `/{ref}` opens one flow in full. See *Server actions* below.\n- `plitzi://actions/{env}/tasks` \u2014 the **server tasks this deployment can run**, each with its params: the steps an\n action may be built from.\n- `plitzi://functions/{env}` \u2014 the space's **functions**, its own server code: which files, and the tasks, routes and\n hosts they declare. `plitzi://functions/{env}/{+path}` reads one file whole. See *Functions* below.\n- `plitzi://data/{env}` \u2014 the space's **data**: JSON files its server providers read, never served.\n `plitzi://data/{env}/{+path}` reads one, parsed. See *Data* below.\n- `plitzi://changes/{env}` \u2014 the space's **change history**, read-only and newest first: who made each change (a\n person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before\n and after. `/{id}` for the history of one of them \u2014 how you find what changed an element you are asked about, or\n review what you or another agent just did.\n- `plitzi://render/guide`, `plitzi://render/types` \u2014 the manual and the type table for `plitzi_render` (offline\n widgets, not this space).\n\nThe style resources also answer under the `plitzi://schema/{env}/\u2026` root as aliases \u2014 `plitzi://schema/{env}/definitions/{ref}`, `plitzi://schema/{env}/style-variables/{category}`, `plitzi://schema/{env}/schema-variables` \u2014 but prefer the ready-made `uri` from search / a write response over hand-building either form.\n\nData resources return `{ stateVersion, data }`. Keep `stateVersion` for optimistic concurrency.\n\n**Reuse what you already know \u2014 don't re-scan an unchanged page.** A page read (`plitzi://schema/{env}/pages/{ref}`)\nreturns a `stateVersion` that is an **aggregate of the whole page**: it changes if and only if some element on the\npage changed. Its skeleton `tree` also carries a `stateVersion` **per node**, identical to the one a direct element\nread or search hit returns for that element. So when you come back to a page you already inspected:\n1. Re-read just the page skeleton and compare its top-level `stateVersion` to the one you held. **Same \u2192 nothing\n changed since your read; skip re-reading and re-searching the tree** and act on what you already know.\n2. If it differs, diff the per-node `stateVersion`s against the ones you cached and `plitzi_read` **only the nodes\n that changed** \u2014 never re-search or re-read the whole tree.\n\nThis is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space\nconcurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time\ncheck below on the strength of a cached hash \u2014 the guarantee that no concurrent edit is lost comes only from\n`expectedResourceVersions` on `plitzi_apply`, which re-validates against the live data at write time.\n\n## Navigating (files analogy)\nPages and containers are folders; elements are files. **Prefer `plitzi_search` (especially with `include: \"detail\"`)\nover reading elements one by one** \u2014 it jumps straight to elements by label/type/attribute and each hit already\ncarries the element's `uri`, `stateVersion`, `pageUri`, `parentRef` and tree `path`, so you can edit it (with\noptimistic concurrency) **without a follow-up read**. `include: \"detail\"` additionally inlines each hit's props/style\n**and** its `resolvedStyle` (the CSS behind its classes) \u2014 so a search-then-edit is the efficient path and a manual\nelement read is the exception. Search also matches **pages** by name/slug (returned under `pages`, each with its uri +\nstateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under `definitions`.\nWhen you do hold several refs to open (e.g. from a skeleton), read them together with `plitzi_read` rather than one at a time.\n\n## Tools\n- `plitzi_apply` \u2014 validate \u2192 apply \u2192 persist atomically. Rejects the whole batch on any error or conflict, and\n reports **pre-existing malformations** in any resource the batch touches (see below) and `suggestions` (see\n *Suggestions*). Pass `dryRun: true` to check and apply in memory only \u2014 the same answer, nothing persisted \u2014 and\n `look` (`\"html\"`, `\"image\"`, `\"accessibility\"` or `\"both\"`, with `pageRef` and `viewport`) to see the page\n as the batch leaves it in the same call. Check and look with `dryRun`, then send the same operations without it.\n `effects` is what the batch did, read off the space before and after it \u2014 every element, attribute, class and\n setting it changed, one line each: read it, not your batch, for what is now so. `Nothing changed` and `NOT saved`\n lead the warnings when they are so.\n- **By intention**, a few parameters and the element named by its ref alone \u2014 the page is found, the operations\n written, the batch checked and saved as `plitzi_apply` saves it, and the answer its `effects`, whether it was\n `saved`, and what was already so:\n `plitzi_set_attributes { ref, set, unset }`, `plitzi_set_classes { ref, add, remove }` (the classes it wears and\n you do not name stay), `plitzi_bind_attribute { ref, to, source }`, `plitzi_place_component { component, ref, into,\n props }`, `plitzi_add_page { ref, slug, layout }`. One of them when it says the whole change; anything else is one\n batch of `plitzi_apply`.\n- `plitzi_describe_operation` \u2014 one operation's schema by its `type` (every field, which are required); without a\n type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an\n operation does not have is refused naming the one meant (`\"prop\" (did you mean \"props\"?)`), and a type spelt with\n other capitals is read as the catalog spells it and said in `warnings`. The same batch refused twice is not run a\n third time (`REPEATED_BATCH`) \u2014 change what the errors name, or ask the person.\n- `plitzi_search` \u2014 find elements (and pages/definitions) across the space.\n- `plitzi_read` \u2014 read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the\n ready-made uris from search / a write response; each result is `{ uri, stateVersion, data }` or a teachable error,\n so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.\n- `plitzi_look { pageRef, view, viewport }` \u2014 see a saved page. `view`: `\"accessibility\"` (default) reads it as a\n screen reader and a browser agent (Claude in Chrome) do \u2014 an outline of roles and names, every control and picture\n with no name listed in `unnamed`, as text and far cheaper than an image; `\"html\"` its markup; `\"image\"` a PNG,\n the way to SEE overflow and misalignment (desktop, mobile or `both`); `\"both\"` image and outline. A change not\n saved yet is seen with `plitzi_apply`'s `dryRun` and `look`, the same views. It needs the SSR render service\n (`PREVIEW_UNAVAILABLE` without it); without a browser, an image or an outline falls back to the HTML, said.\n- `plitzi_activity { after, wait }` \u2014 what happened on the space since you last looked: the draft changed (a person\n in the builder, another agent, the autofix \u2014 `seq` is its place in `plitzi://changes/{env}`), a version went\n out, a server action failed or was refused. The first call, without `after`, answers the latest and a `cursor`;\n pass it back as `after` and the call waits up to `wait` seconds (45, at most 50) until something happens. Your own\n writes are left out and counted (`skippedMine`; `mine: true` keeps them). On a space people edit too, call it\n before a write that rests on what you read earlier.\n- `plitzi_render` \u2014 a different job: show the user a self-contained widget built offline. It never touches the space.\n\n## Suggestions \u2014 the same page with fewer elements\n`plitzi_apply` (with or without `dryRun`) answers with `suggestions`: lines like `[content-attribute] \u2026 (saves 4\nelements)`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said \u2014 what the\nspace already had is not repeated on every batch \u2014 and none of them blocks anything: the page renders as written.\n- `repeated-on-pages` \u2014 the same block at the edge of several pages: put it in a **layout** once (a block only some\n pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the\n page being shown: the `current` state marks it (see *Pages & folders*).\n- `repeated-shape` \u2014 one structure written again with other words: a **component** with props\n (`upsertComponent { fromRef }` turns one copy into it), or, for sibling rows of data, one `repeatElement`/`list`.\n A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill\n from a template of their own or render on the server are controls written alike, and are not offered. Copies apart\n that read different sources are one component still: each instance binds its own to a `json` prop.\n- `content-attribute` \u2014 a `button` or `link` whose children are only a `text` and/or a `fontAwesome`: its words\n are its own `content` and the icon its `icon`. What the text's class adds (`white-space: nowrap`) moves to the\n box's class \u2014 never the class itself; the icon's class goes in the `icon` slot.\n- `custom-css-class`, `custom-css-sdk-default`, `custom-css-notifications` \u2014 `customCss` that a class's\n `states`/`ancestors`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.\n- `heavy-animation` \u2014 keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter\n while the page loads. Lighter, not shorter \u2014 see **Motion \u2014 good practices**.\n- `unused-class`, `unused-token`, `unused-component` \u2014 declared and read by nothing: remove it\n (`deleteDefinition`, `deleteStyleVariable`, `deleteComponent`), or use it where it was meant to go. Said\n when a batch leaves one behind.\n- `element-color-inherited` \u2014 the space's `elements` giving a type `color: inherit` or the page's own colour,\n which every element \u2014 a link's words included \u2014 takes by itself: remove it, and name the colour once on the page.\n- `literal-colour` \u2014 a class painted from the palette typing out a token's light value: `var(--token)` when it\n should follow the scheme; a token of one value when it must stay the same in both.\n`plitzi://explain/<code>` explains each. Take one unless the copies are about to diverge; one left on purpose is\nquieted on an element it names \u2014 `quiet: [\"repeated-shape\"]` on `upsertElement`/`patchElement` (`null` removes it)\n\u2014 and is not offered again, here, in the builder or in authoring. Suggestions' codes only.\n\n## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)\nThree ways to read, each for a different moment \u2014 pick by what you have in hand:\n- **MCP resources** (the `plitzi://\u2026` catalog above) \u2014 the **browsable index**. List them to discover what exists, or\n open one by URI when you are exploring. This is the passive catalog, not a tool.\n- **`plitzi_search`** \u2014 you know *what* you want but not its **ref/uri** (\"the hero button\"). Search finds it by\n label/type/attribute and hands back the uri + stateVersion (and, with `include:\"detail\"`, the full element).\n- **`plitzi_read`** \u2014 you **already hold one or more uris** (from search or a write response) and want their\n content in one batch. It is the tool form of opening resources, for when you have the addresses.\nRule of thumb: **discover \u2192 resources**, **find a name \u2192 plitzi_search**, **fetch known uris \u2192 plitzi_read**. Never\nhand-build a URI to guess your way to an element \u2014 search for it instead.\n\nWrite tools return what **changed** (`{ uri, stateVersion }`) plus counts, and the **full detail of every element\nthey created or updated** \u2014 each with its own `uri` and `stateVersion` (`elements: [...]`) so a follow-up edit of\nthe same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only\nuri+stateVersion \u2014 re-read them if you need their new content. The operation shapes are in each tool's input\nschema (discriminated by `type`).\n\n## Addressing\nEvery element and page has **one name, and that name is its id**. You choose it, you address it by it, and the\nruntime wires by it \u2014 there is no second key and nothing to translate. Creating an element with\n`\"ref\": \"products-api\"` stores it under exactly that.\n\nThat name is the **wiring key**: a provider registers its data source as `<type>_<name>`, so a `source` you write\nagainst a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the\nbatch):\n- Charset `[A-Za-z0-9_-]`, **starting with a letter** and not ending in `-` (e.g. `\"products-api\"`, `\"food_item\"`). A `.` would split\n the `<type>_<name>.<field>` source path and the interaction target lookup, so **no dots**. An **underscore is\n allowed**: the FIRST `_` separates `<type>` from the name and element types are camelCase with none, so\n underscores inside a name are unambiguous (`list_food_item` \u2192 type `list`, name `food_item`).\n- **Unique across the space**; a name that is taken is rejected (address the existing element instead).\n\n**Never invent a name for something that already exists** \u2014 read it. Every read hands you the name back\n(`plitzi_search`, a page skeleton, a write response), and that is the string every op takes.\n\n**Where an element renders** is its `runtime`, settable on `upsertElement`/`patchElement`: `\"shared\"` (the\ndefault, both sides), `\"client\"` (browser only) or `\"server\"` (SSR only). It matters for one thing above all \u2014 an\n`apiContainer` reads through a **connector** only when it is `\"server\"` (see *Connectors*). An element read\nreports it only when it is set. The page server resolves `\"server\"` elements of a page and its layouts only, never\ninside a component \u2014 one there is refused; put the provider on the page and hand the component its rows as a prop.\n\n**Renaming** (`patchElement` with `rename`) moves the one key: the parent's child list, every binding source and\nevery interaction target across the space that named the old one is repointed with it, so nothing comes unwired.\nYou do not have to rewrite them.\n\n## Elements \u2014 create, move, delete\n- `upsertElement` creates an element (or replaces one by name) under `parentRef` \u2014 the page root when omitted \u2014 and\n builds a whole subtree in one op through nested `children`. `patchElement` changes an existing one in place.\n- `moveElement { pageRef, ref, toParentRef, position }` moves or reorders one: `position` `\"inside\"` (the default)\n nests it in `toParentRef`; `\"before\"`/`\"after\"` make it that element's sibling. Its subtree moves with it.\n- `deleteElement { pageRef, ref }` removes an element **and everything under it**. A binding or an interaction\n elsewhere that named one of them is left pointing at nothing, and the save reports it \u2014 delete them in the same\n batch. Destructive: confirm first.\n- `flag` on `upsertElement` / `patchElement` gates an element on a feature flag (`\"newCheckout\"` or\n `\"!newCheckout\"`) \u2014 not a visibility: gated off it is not rendered at all. See **Feature flags**.\n- **A compound element is written with its parts**, as `children` of the same `upsertElement`: a `carousel` holds a\n `carouselTrack` (the slides go in it), a `tabContainer` a `tabContainerHeader` and a `tabContainerBody`, a\n `dropdown` a `dropdownPopup`. Without its part it shows nothing (`part-missing`); a part anywhere else breaks the\n page (`outside-ancestor`).\n- **A dropdown places its popup**: the popup's class is its look, never its place (`popup-position-set`) \u2014\n `popupPlacement`, the offsets and `popupWidth: \"trigger\"` are the dropdown's; the `openDropdown`,\n `closeDropdown` and `toggleDropdown` steps open and close it. The open tab is a class's `current` state\n (`aria-selected`), never `active` (the press): `plitzi://explain/<type>` says what each element writes on its node.\n\n";
2
+ export declare const referenceGuide = "# Plitzi AI MCP \u2014 usage guide\n\nA Plitzi space is **two separate schemas** you edit together:\n- **Element schema** \u2014 the tree of pages and elements (their type, label, props, and which style classes they use).\n- **Style schema** \u2014 reusable **definitions** (CSS classes), design tokens (variables), theme.\n\nThey are stored and persisted independently, but a single `plitzi_apply` batch may touch **both atomically**.\nTo style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**\nit via the element's `style.base` (element schema). Example \u2014 \"rename button X to PEPE and make it red\":\n```json\n{ \"operations\": [\n { \"type\": \"upsertDefinition\", \"ref\": \"btn-x\", \"desktop\": { \"color\": \"red\" } },\n { \"type\": \"upsertElement\", \"pageRef\": \"home\",\n \"element\": { \"ref\": \"X\", \"type\": \"button\", \"label\": \"PEPE\", \"style\": { \"base\": [\"btn-x\"] } } }\n] }\n```\n\nReads are cheap by design \u2014 treat them like a filesystem: **list** to navigate, **read one item** for detail.\nNever download a whole tree you do not need.\n\n## Resources (read)\n- `plitzi://primer/{env}` \u2014 **cold-start bundle**: guide + types + css-properties + page/definition/variable\n **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only \u2014 open a\n page skeleton or element for its tree/detail.\n- `plitzi://guide` \u2014 this guide.\n- `plitzi://types` \u2014 element types **observed in this space** (ground truth): props, slots, subTypes, plus each\n type's `label`, `description` (what it is FOR) and `category`, and a `source` (`builtin` | `plugin` | `unknown`).\n Read the descriptions to pick the right type \u2014 e.g. `apiContainer` fetches backend data into the frontend,\n `link` navigates between pages, `list` repeats a template over a data array. `plugin` types are the elements\n of the plugins the space installed: added by their type, like a built-in.\n- `plitzi://css-properties` \u2014 valid kebab-case CSS property keys.\n- `plitzi://explain/{name}` \u2014 what a name means: an element type's attributes, triggers, callbacks and what it writes\n on its node; a step's params and what it publishes; what a trigger hands its flow; a style state; a problem code's\n fix. `plitzi://explain/steps` (or elements, triggers, codes, transformers, states) lists every one of a kind.\n- `plitzi://schema/{env}/pages` \u2014 page **summaries** (ref, label, elementCount, folder). No element trees.\n- `plitzi://schema/{env}/layouts` \u2014 the shared **layout shells** (header/sidebar/footer) and the pages rendered\n inside each. Read one like a page. See *Shared layouts* below.\n- `plitzi://schema/{env}/components` \u2014 the space's **components** (reusable subtrees): their props, slots, root and\n how many places render each. Read one like a page. See *Components* below.\n- `plitzi://folders/{env}` \u2014 page **folders** (the sidebar tree): ref, name, slug, parentId. `/{ref}` for one.\n- `plitzi://schema/{env}/pages/{ref}` \u2014 one page as a **skeleton tree**: each node is `ref/type/label` **plus the\n style classes it attaches** (`base`, and `slots` for non-base slots) \u2014 names only, no CSS. So you can map every\n element to its class in a single page read, without opening each element just to learn which class it uses.\n- `plitzi://schema/{env}/pages/{ref}/styles` \u2014 **every style the page uses in one read**: the class definitions its\n elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.\n Reach for this to recolor/restyle a whole page \u2014 it needs no shared class-name prefix and no per-element reads.\n- `plitzi://schema/{env}/elements/{ref}` \u2014 one element in **full detail** (props, style, parentRef, childRefs).\n Its `resolvedStyle` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you\n can see and edit its style without a separate definition read. Its `globalStyles` lists the **global element\n selectors** that also affect it (the CSS equivalent of `button { \u2026 }`, keyed by the type they target) \u2014 every\n element of that type inherits them. Edit a global only through the global-style tools (never per element). If the\n element carries a DOM `id` that an id rule matches, its `idStyle` (`#id`) is inlined too.\n- `plitzi://definitions/{env}` \u2014 the **names** of every style definition.\n- `plitzi://definitions/{env}/{ref}` \u2014 one definition's CSS.\n- `plitzi://global-styles/{env}` \u2014 element **types** that have a site-wide global style. `/{componentType}` for one.\n- `plitzi://id-styles/{env}` \u2014 DOM **ids** that have an id rule (`#id`) targeting a single element. `/{targetId}` for one.\n- `plitzi://style-variables/{env}` \u2014 design tokens by category. `/{category}` for one.\n- `plitzi://fonts/{env}` \u2014 the font **families the space loads**, with their source and fallback. `/{family}` for one.\n- `plitzi://schema-variables/{env}` \u2014 space-level values referenced in props as `{{name}}`.\n- `plitzi://flags/{env}` \u2014 the space's **feature flags**, each a default and its rules (see **Feature flags**).\n- `plitzi://settings/{env}` \u2014 space-level settings: the global `customCss` and the state/auth (user-provider) config.\n- `plitzi://interactions/{env}` \u2014 interaction **actions** observed in this space (grouped by node type): the\n vocabulary for interaction flows.\n- `plitzi://data-sources/{env}` \u2014 data-source **paths** and binding targets observed in this space: the\n vocabulary for data bindings.\n- `plitzi://connector-presets` \u2014 working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain\n REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.\n Space-independent. Read it before writing a connector by hand.\n- `plitzi://connectors/{env}` \u2014 the **connectors this space has**: for each, its read/write endpoint names, its\n filter operators and its published fields. `/{ref}` opens one manifest in full. See *Connectors* below.\n- `plitzi://actions/{env}` \u2014 the **server actions this space has**: what starts each one, who may run it, and the\n input/output contract a caller is held to. `/{ref}` opens one flow in full. See *Server actions* below.\n- `plitzi://actions/{env}/tasks` \u2014 the **server tasks this deployment can run**, each with its params: the steps an\n action may be built from.\n- `plitzi://functions/{env}` \u2014 the space's **functions**, its own server code: which files, and the tasks, routes and\n hosts they declare. `plitzi://functions/{env}/{+path}` reads one file whole. See *Functions* below.\n- `plitzi://data/{env}` \u2014 the space's **data**: JSON files its server providers read, never served.\n `plitzi://data/{env}/{+path}` reads one, parsed. See *Data* below.\n- `plitzi://changes/{env}` \u2014 the space's **change history**, read-only and newest first: who made each change (a\n person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before\n and after. `/{id}` for the history of one of them \u2014 how you find what changed an element you are asked about, or\n review what you or another agent just did.\n- `plitzi://render/guide`, `plitzi://render/types` \u2014 the manual and the type table for `plitzi_render` (offline\n widgets, not this space).\n\nThe style resources also answer under the `plitzi://schema/{env}/\u2026` root as aliases \u2014 `plitzi://schema/{env}/definitions/{ref}`, `plitzi://schema/{env}/style-variables/{category}`, `plitzi://schema/{env}/schema-variables` \u2014 but prefer the ready-made `uri` from search / a write response over hand-building either form.\n\nData resources return `{ stateVersion, data }`. Keep `stateVersion` for optimistic concurrency.\n\n**Reuse what you already know \u2014 don't re-scan an unchanged page.** A page read (`plitzi://schema/{env}/pages/{ref}`)\nreturns a `stateVersion` that is an **aggregate of the whole page**: it changes if and only if some element on the\npage changed. Its skeleton `tree` also carries a `stateVersion` **per node**, identical to the one a direct element\nread or search hit returns for that element. So when you come back to a page you already inspected:\n1. Re-read just the page skeleton and compare its top-level `stateVersion` to the one you held. **Same \u2192 nothing\n changed since your read; skip re-reading and re-searching the tree** and act on what you already know.\n2. If it differs, diff the per-node `stateVersion`s against the ones you cached and `plitzi_read` **only the nodes\n that changed** \u2014 never re-search or re-read the whole tree.\n\nThis is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space\nconcurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time\ncheck below on the strength of a cached hash \u2014 the guarantee that no concurrent edit is lost comes only from\n`expectedResourceVersions` on `plitzi_apply`, which re-validates against the live data at write time.\n\n## Navigating (files analogy)\nPages and containers are folders; elements are files. **Prefer `plitzi_search` (especially with `include: \"detail\"`)\nover reading elements one by one** \u2014 it jumps straight to elements by label/type/attribute and each hit already\ncarries the element's `uri`, `stateVersion`, `pageUri`, `parentRef` and tree `path`, so you can edit it (with\noptimistic concurrency) **without a follow-up read**. `include: \"detail\"` additionally inlines each hit's props/style\n**and** its `resolvedStyle` (the CSS behind its classes) \u2014 so a search-then-edit is the efficient path and a manual\nelement read is the exception. Search also matches **pages** by name/slug (returned under `pages`, each with its uri +\nstateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under `definitions`.\nWhen you do hold several refs to open (e.g. from a skeleton), read them together with `plitzi_read` rather than one at a time.\n\n## Tools\n- `plitzi_apply` \u2014 validate \u2192 apply \u2192 persist atomically. Rejects the whole batch on any error or conflict, and\n reports **pre-existing malformations** in any resource the batch touches (see below) and `suggestions` (see\n *Suggestions*). Pass `dryRun: true` to check and apply in memory only \u2014 the same answer, nothing persisted \u2014 and\n `look` (`\"html\"`, `\"image\"`, `\"accessibility\"` or `\"both\"`, with `pageRef` and `viewport`) to see the page\n as the batch leaves it in the same call. Check and look with `dryRun`, then send the same operations without it.\n `effects` is what the batch did, read off the space before and after it \u2014 every element, attribute, class and\n setting it changed, one line each: read it, not your batch, for what is now so. `Nothing changed` and `NOT saved`\n lead the warnings when they are so.\n- **By intention**, a few parameters and the element named by its ref alone \u2014 the page is found, the operations\n written, the batch checked and saved as `plitzi_apply` saves it, and the answer its `effects`, whether it was\n `saved`, and what was already so:\n `plitzi_set_attributes { ref, set, unset }`, `plitzi_set_classes { ref, add, remove }` (the classes it wears and\n you do not name stay), `plitzi_bind_attribute { ref, to, source }`, `plitzi_place_component { component, ref, into,\n props }`, `plitzi_add_page { ref, slug, layout }`. One of them when it says the whole change; anything else is one\n batch of `plitzi_apply`.\n- `plitzi_describe_operation` \u2014 one operation's schema by its `type` (every field, which are required); without a\n type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an\n operation does not have is refused naming the one meant (`\"prop\" (did you mean \"props\"?)`), and a type spelt with\n other capitals is read as the catalog spells it and said in `warnings`. The same batch refused twice is not run a\n third time (`repeated`) \u2014 change what the errors name, or ask the person.\n- `plitzi_search` \u2014 find elements (and pages/definitions) across the space.\n- `plitzi_read` \u2014 read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the\n ready-made uris from search / a write response; each result is `{ uri, stateVersion, data }` or a teachable error,\n so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.\n- `plitzi_look { pageRef, view, viewport }` \u2014 see a saved page. `view`: `\"accessibility\"` (default) reads it as a\n screen reader and a browser agent (Claude in Chrome) do \u2014 an outline of roles and names, every control and picture\n with no name listed in `unnamed`, as text and far cheaper than an image; `\"html\"` its markup; `\"image\"` a PNG,\n the way to SEE overflow and misalignment (desktop, mobile or `both`); `\"both\"` image and outline. A change not\n saved yet is seen with `plitzi_apply`'s `dryRun` and `look`, the same views. It needs the SSR render service\n (refused `not-allowed` without it); without a browser, an image or an outline falls back to the HTML, said.\n- `plitzi_activity { after, wait }` \u2014 what happened on the space since you last looked: the draft changed (a person\n in the builder, another agent, the autofix \u2014 `seq` is its place in `plitzi://changes/{env}`), a version went\n out, a server action failed or was refused. The first call, without `after`, answers the latest and a `cursor`;\n pass it back as `after` and the call waits up to `wait` seconds (45, at most 50) until something happens. Your own\n writes are left out and counted (`skippedMine`; `mine: true` keeps them). On a space people edit too, call it\n before a write that rests on what you read earlier.\n- `plitzi_releases { domain? }`, `plitzi_publish { domain, environment, revision?, deploy? }`, `plitzi_rollback { domain, to? }`\n \u2014 the space's releases: what each domain serves, where its site is (`where`: Plitzi, or a copy on a\n provider) and what it asks (`asks`), and what a rollback would put back, one domain's history,\n pointing a domain at a revision (its environment's latest unless named; `main` serves the draft), and putting back\n what it served right before its latest release. A publish is live at once for that domain's visitors: publish only\n what the person asked for. Held to who may publish, the plan and the revision's tests, a refusal answered as\n `{ done: false, reason }`; a rollback is never refused by plan. Feature flags and the space's data stay as they are.\n On a domain whose site a provider holds, a publish that needs a deploy is refused with why unless `deploy: true`;\n the answer's `deployId` is the deploy it queued.\n- `plitzi_render` \u2014 a different job: show the user a self-contained widget built offline. It never touches the space.\n\n## Suggestions \u2014 the same page with fewer elements\n`plitzi_apply` (with or without `dryRun`) answers with `suggestions`: lines like `[content-attribute] \u2026 (saves 4\nelements)`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said \u2014 what the\nspace already had is not repeated on every batch \u2014 and none of them blocks anything: the page renders as written.\n- `repeated-on-pages` \u2014 the same block at the edge of several pages: put it in a **layout** once (a block only some\n pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the\n page being shown: the `current` state marks it (see *Pages & folders*).\n- `repeated-shape` \u2014 one structure written again with other words: a **component** with props\n (`upsertComponent { fromRef }` turns one copy into it), or, for sibling rows of data, one `repeatElement`/`list`.\n A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill\n from a template of their own or render on the server are controls written alike, and are not offered. Copies apart\n that read different sources are one component still: each instance binds its own to a `json` prop.\n- `content-attribute` \u2014 a `button` or `link` whose children are only a `text` and/or a `fontAwesome`: its words\n are its own `content` and the icon its `icon`. What the text's class adds (`white-space: nowrap`) moves to the\n box's class \u2014 never the class itself; the icon's class goes in the `icon` slot.\n- `custom-css-class`, `custom-css-sdk-default`, `custom-css-notifications` \u2014 `customCss` that a class's\n `states`/`ancestors`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.\n- `heavy-animation` \u2014 keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter\n while the page loads. Lighter, not shorter \u2014 see **Motion \u2014 good practices**.\n- `unused-class`, `unused-token`, `unused-component` \u2014 declared and read by nothing: remove it\n (`deleteDefinition`, `deleteStyleVariable`, `deleteComponent`), or use it where it was meant to go. Said\n when a batch leaves one behind.\n- `element-color-inherited` \u2014 the space's `elements` giving a type `color: inherit` or the page's own colour,\n which every element \u2014 a link's words included \u2014 takes by itself: remove it, and name the colour once on the page.\n- `literal-colour` \u2014 a class painted from the palette typing out a token's light value: `var(--token)` when it\n should follow the scheme; a token of one value when it must stay the same in both.\n`plitzi://explain/<code>` explains each. Take one unless the copies are about to diverge; one left on purpose is\nquieted on an element it names \u2014 `quiet: [\"repeated-shape\"]` on `upsertElement`/`patchElement` (`null` removes it)\n\u2014 and is not offered again, here, in the builder or in authoring. Suggestions' codes only.\n\n## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)\nThree ways to read, each for a different moment \u2014 pick by what you have in hand:\n- **MCP resources** (the `plitzi://\u2026` catalog above) \u2014 the **browsable index**. List them to discover what exists, or\n open one by URI when you are exploring. This is the passive catalog, not a tool.\n- **`plitzi_search`** \u2014 you know *what* you want but not its **ref/uri** (\"the hero button\"). Search finds it by\n label/type/attribute and hands back the uri + stateVersion (and, with `include:\"detail\"`, the full element).\n- **`plitzi_read`** \u2014 you **already hold one or more uris** (from search or a write response) and want their\n content in one batch. It is the tool form of opening resources, for when you have the addresses.\nRule of thumb: **discover \u2192 resources**, **find a name \u2192 plitzi_search**, **fetch known uris \u2192 plitzi_read**. Never\nhand-build a URI to guess your way to an element \u2014 search for it instead.\n\nWrite tools return what **changed** (`{ uri, stateVersion }`) plus counts, and the **full detail of every element\nthey created or updated** \u2014 each with its own `uri` and `stateVersion` (`elements: [...]`) so a follow-up edit of\nthe same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only\nuri+stateVersion \u2014 re-read them if you need their new content. The operation shapes are in each tool's input\nschema (discriminated by `type`).\n\n## Addressing\nEvery element and page has **one name, and that name is its id**. You choose it, you address it by it, and the\nruntime wires by it \u2014 there is no second key and nothing to translate. Creating an element with\n`\"ref\": \"products-api\"` stores it under exactly that.\n\nThat name is the **wiring key**: a provider registers its data source as `<type>_<name>`, so a `source` you write\nagainst a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the\nbatch):\n- Charset `[A-Za-z0-9_-]`, **starting with a letter** and not ending in `-` (e.g. `\"products-api\"`, `\"food_item\"`). A `.` would split\n the `<type>_<name>.<field>` source path and the interaction target lookup, so **no dots**. An **underscore is\n allowed**: the FIRST `_` separates `<type>` from the name and element types are camelCase with none, so\n underscores inside a name are unambiguous (`list_food_item` \u2192 type `list`, name `food_item`).\n- **Unique across the space**; a name that is taken is rejected (address the existing element instead).\n\n**Never invent a name for something that already exists** \u2014 read it. Every read hands you the name back\n(`plitzi_search`, a page skeleton, a write response), and that is the string every op takes.\n\n**Where an element renders** is its `runtime`, settable on `upsertElement`/`patchElement`: `\"shared\"` (the\ndefault, both sides), `\"client\"` (browser only) or `\"server\"` (SSR only). It matters for one thing above all \u2014 an\n`apiContainer` reads through a **connector** only when it is `\"server\"` (see *Connectors*). An element read\nreports it only when it is set. The page server resolves `\"server\"` elements of a page and its layouts only, never\ninside a component \u2014 one there is refused; put the provider on the page and hand the component its rows as a prop.\n\n**Renaming** (`patchElement` with `rename`) moves the one key: the parent's child list, every binding source and\nevery interaction target across the space that named the old one is repointed with it, so nothing comes unwired.\nYou do not have to rewrite them.\n\n## Elements \u2014 create, move, delete\n- `upsertElement` creates an element (or replaces one by name) under `parentRef` \u2014 the page root when omitted \u2014 and\n builds a whole subtree in one op through nested `children`. `patchElement` changes an existing one in place.\n- `addSpec { pageRef, parentRef, spec, classes }` adds a tree written as the authoring skill writes one \u2014 what\n `container({ \u2026 })` returns, as JSON, and the `styles(name, { \u2026 })` it names \u2014 checked by authoring itself: the\n same words in a project and here. Every `id` in it must be new to the space. With `replaces: ref` instead of\n `parentRef` it takes that element's place, and that element and all under it go: the spec may name their ids\n again, so an element is rewritten in the same words it was written in.\n- `moveElement { pageRef, ref, toParentRef, position }` moves or reorders one: `position` `\"inside\"` (the default)\n nests it in `toParentRef`; `\"before\"`/`\"after\"` make it that element's sibling. Its subtree moves with it.\n- `deleteElement { pageRef, ref }` removes an element **and everything under it**. A binding or an interaction\n elsewhere that named one of them is left pointing at nothing, and the save reports it \u2014 delete them in the same\n batch. Destructive: confirm first.\n- `flag` on `upsertElement` / `patchElement` gates an element on a feature flag (`\"newCheckout\"` or\n `\"!newCheckout\"`) \u2014 not a visibility: gated off it is not rendered at all. See **Feature flags**.\n- **A compound element is written with its parts**, as `children` of the same `upsertElement`: a `carousel` holds a\n `carouselTrack` (the slides go in it), a `tabContainer` a `tabContainerHeader` and a `tabContainerBody`, a\n `dropdown` a `dropdownPopup`. Without its part it shows nothing (`part-missing`); a part anywhere else breaks the\n page (`outside-ancestor`).\n- **A dropdown places its popup**: the popup's class is its look, never its place (`popup-position-set`) \u2014\n `popupPlacement`, the offsets and `popupWidth: \"trigger\"` are the dropdown's; the `openDropdown`,\n `closeDropdown` and `toggleDropdown` steps open and close it. The open tab is a class's `current` state\n (`aria-selected`), never `active` (the press): `plitzi://explain/<type>` says what each element writes on its node.\n\n";
@@ -133,7 +133,7 @@ When you do hold several refs to open (e.g. from a skeleton), read them together
133
133
  type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an
134
134
  operation does not have is refused naming the one meant (\`"prop" (did you mean "props"?)\`), and a type spelt with
135
135
  other capitals is read as the catalog spells it and said in \`warnings\`. The same batch refused twice is not run a
136
- third time (\`REPEATED_BATCH\`) — change what the errors name, or ask the person.
136
+ third time (\`repeated\`) — change what the errors name, or ask the person.
137
137
  - \`plitzi_search\` — find elements (and pages/definitions) across the space.
138
138
  - \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
139
139
  ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
@@ -143,13 +143,22 @@ When you do hold several refs to open (e.g. from a skeleton), read them together
143
143
  with no name listed in \`unnamed\`, as text and far cheaper than an image; \`"html"\` its markup; \`"image"\` a PNG,
144
144
  the way to SEE overflow and misalignment (desktop, mobile or \`both\`); \`"both"\` image and outline. A change not
145
145
  saved yet is seen with \`plitzi_apply\`'s \`dryRun\` and \`look\`, the same views. It needs the SSR render service
146
- (\`PREVIEW_UNAVAILABLE\` without it); without a browser, an image or an outline falls back to the HTML, said.
146
+ (refused \`not-allowed\` without it); without a browser, an image or an outline falls back to the HTML, said.
147
147
  - \`plitzi_activity { after, wait }\` — what happened on the space since you last looked: the draft changed (a person
148
148
  in the builder, another agent, the autofix — \`seq\` is its place in \`plitzi://changes/{env}\`), a version went
149
149
  out, a server action failed or was refused. The first call, without \`after\`, answers the latest and a \`cursor\`;
150
150
  pass it back as \`after\` and the call waits up to \`wait\` seconds (45, at most 50) until something happens. Your own
151
151
  writes are left out and counted (\`skippedMine\`; \`mine: true\` keeps them). On a space people edit too, call it
152
152
  before a write that rests on what you read earlier.
153
+ - \`plitzi_releases { domain? }\`, \`plitzi_publish { domain, environment, revision?, deploy? }\`, \`plitzi_rollback { domain, to? }\`
154
+ — the space's releases: what each domain serves, where its site is (\`where\`: Plitzi, or a copy on a
155
+ provider) and what it asks (\`asks\`), and what a rollback would put back, one domain's history,
156
+ pointing a domain at a revision (its environment's latest unless named; \`main\` serves the draft), and putting back
157
+ what it served right before its latest release. A publish is live at once for that domain's visitors: publish only
158
+ what the person asked for. Held to who may publish, the plan and the revision's tests, a refusal answered as
159
+ \`{ done: false, reason }\`; a rollback is never refused by plan. Feature flags and the space's data stay as they are.
160
+ On a domain whose site a provider holds, a publish that needs a deploy is refused with why unless \`deploy: true\`;
161
+ the answer's \`deployId\` is the deploy it queued.
153
162
  - \`plitzi_render\` — a different job: show the user a self-contained widget built offline. It never touches the space.
154
163
 
155
164
  ## Suggestions — the same page with fewer elements
@@ -229,6 +238,11 @@ You do not have to rewrite them.
229
238
  ## Elements — create, move, delete
230
239
  - \`upsertElement\` creates an element (or replaces one by name) under \`parentRef\` — the page root when omitted — and
231
240
  builds a whole subtree in one op through nested \`children\`. \`patchElement\` changes an existing one in place.
241
+ - \`addSpec { pageRef, parentRef, spec, classes }\` adds a tree written as the authoring skill writes one — what
242
+ \`container({ … })\` returns, as JSON, and the \`styles(name, { … })\` it names — checked by authoring itself: the
243
+ same words in a project and here. Every \`id\` in it must be new to the space. With \`replaces: ref\` instead of
244
+ \`parentRef\` it takes that element's place, and that element and all under it go: the spec may name their ids
245
+ again, so an element is rewritten in the same words it was written in.
232
246
  - \`moveElement { pageRef, ref, toParentRef, position }\` moves or reorders one: \`position\` \`"inside"\` (the default)
233
247
  nests it in \`toParentRef\`; \`"before"\`/\`"after"\` make it that element's sibling. Its subtree moves with it.
234
248
  - \`deleteElement { pageRef, ref }\` removes an element **and everything under it**. A binding or an interaction
@@ -1,2 +1,2 @@
1
1
  /** How a space is put together: shared layouts, components, pages and folders, and its settings. */
2
- export declare const structureGuide = "## Shared layouts \u2014 the chrome a page does NOT contain\nA page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout\ncontainer**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.\n\nIt is a **root of its own** \u2014 a `layoutContainer` element that no page owns and that is not in the page list \u2014 and\na page points at it with two attributes:\n- `layout` \u2014 the shell's ref. This is the whole of \"which chrome do I render inside\".\n- `layoutContainer` \u2014 the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.\n\nSo a page with `layout: \"main-layout\"` renders `main-layout`'s whole tree, with its own elements dropped into the\none container it named. Two pages naming the same shell share every element of it \u2014 **editing the shell changes\nevery page that uses it**, which is the point and also the thing to say out loud before you touch one.\n\n**Reading them.**\n- `plitzi://schema/{env}/layouts` lists the shells: `ref`, `label`, `usedBy` (the pages), `slots`, `elementCount`.\n- Every page in `plitzi://schema/{env}/pages` carries `layout` and `layoutSlot` when it has them.\n- Read a shell exactly like a page: `plitzi://schema/{env}/pages/{layoutRef}` for its skeleton,\n `.../pages/{layoutRef}/styles` for its classes. `plitzi_search` reports a layout's elements with the layout as\n their `pageRef`.\n\n**Writing them.** Every element/binding/interaction op takes the shell's ref as its `pageRef` \u2014 there is no separate\nvocabulary:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"main-layout\", \"parentRef\": \"sidebar\",\n \"element\": { \"ref\": \"upgrade-card\", \"type\": \"container\", \"children\": [ \u2026 ] } }\n```\n- `upsertLayout` creates a shell (`ref`, `label`, `subType`). Put the chrome in it with `upsertElement`, including\n an empty container to serve as the slot.\n- `upsertPage { layout, layoutContainer }` attaches a page to it; `layout: null` detaches. A `layoutContainer` that\n is not an element of that shell is refused \u2014 stored, it would render the page's body where nobody sees it.\n- `deleteLayout` removes a shell and everything in it, and is **refused while any page still renders inside it**\n (the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.\n\n**Only some pages?** A block that only some of a layout's pages carry (a newsletter band on two of ten) is not\nchrome: make it a **component** and place it on those pages.\n\n**Where does this element belong?** If the user asks for something \"on every page\" \u2014 a nav item, a banner, a footer\nlink, an upgrade prompt in the sidebar \u2014 it belongs in the LAYOUT, not in the page you happen to have open. Check\nthe page's `layout` first; if the element you are looking for is not in the page's own tree, it is in the shell.\n\n## Components \u2014 a subtree written once, placed anywhere\nA **component** is a reusable subtree: a product card, a pricing tier, a testimonial \u2014 written once and placed on\nany page as an **instance**. It is part of the space, so it is published, versioned and copied with it. Its tree is\nnot inside any page: it is a root of its own, like a layout, and **editing it changes every instance** \u2014 say so\nbefore you touch one.\n\nIt is not a **snippet**. The builder's *Save as snippet* keeps a copy of a block as a file people drop onto pages, and\neach drop is the page's own from then on. No operation here writes one: when someone wants a block that stays the same\neverywhere, that is a component.\n\nIt is **closed**. Inside, a binding or a template reads **`props`** \u2014 what each instance hands in \u2014 and the globals\n(`state`, `auth`, `navigation`, `theme`, `variables`, `computed`), never the page an instance sits on. A\ncomponent that needs a list row's record gets it as a prop: the INSTANCE binds it (`item: \"{{ list_rows.item }}\"`),\nthe component reads `{{ props.item.name }}`.\n\n**Reading them.** `plitzi://schema/{env}/components` lists them: `ref`, `label`, `props`, `slots`, `rootRef`,\n`instances`. Read one like a page: `plitzi://schema/{env}/pages/{componentRef}` (and `/styles`).\n\n**Writing them.**\n- `upsertComponent { ref, label?, props?, slots? }` declares one \u2014 with nothing in it but its root, `{ref}-root`, a\n container \u2014 or updates the declaration of one that exists (`props` is REPLACED whole). Fill it with every\n element/binding/interaction op you already know, with **`pageRef: \"<componentRef>\"`**:\n ```json\n { \"type\": \"upsertElement\", \"pageRef\": \"product-card\", \"parentRef\": \"product-card-root\",\n \"element\": { \"ref\": \"product-card-title\", \"type\": \"heading\" } }\n ```\n- `upsertComponent { ref, fromRef, instanceRef }` makes a component OF an element that already exists: the element\n and everything inside it become the component, and an instance named `instanceRef` takes its place, so the page\n renders what it did. The way to turn a repeated block into one.\n- A **prop** is `{ type, description, required?, default?, options? }`, `type` one of `text`, `textarea`,\n `number`, `boolean`, `select` (with `options`), `scalar`, `json`. Its name is read as `{{ props.<name> }}`, so\n letters, digits and `_` \u2014 and never one an instance already has (`referenceId`, `referenceType`, `slot`\u2026).\n- A **slot** is an element of the component's tree (usually an empty container) an instance fills with children.\n- `deleteComponent { ref }` removes one nothing places; while instances remain it is refused, naming them.\n\n**Placing one** is an element: a `reference` whose props say which component and hand in its props, one attribute each:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"shop\", \"parentRef\": \"grid\",\n \"element\": { \"ref\": \"lamp-card\", \"type\": \"reference\",\n \"props\": { \"referenceType\": \"component\", \"referenceId\": \"product-card\", \"title\": \"Lamp\" },\n \"children\": [ { \"ref\": \"lamp-buy\", \"type\": \"button\", \"props\": { \"content\": \"Buy\", \"slot\": \"product-card-actions\" } } ] } }\n```\nA required prop left out, a prop the component does not declare, a value of the wrong kind or a child naming a slot\nthe component does not have is reported by `plitzi_apply`'s `dryRun` \u2014 fix it before applying.\n\n## Pages & folders\n- **A page behind a feature flag**: `upsertPage { flag: \"labs\" }` answers 404 while the flag is off (see **Feature\n flags**); `flag: null` removes it.\n- **Always set a `slug` when creating a page** (`upsertPage`) \u2014 it is the page's URL path and good practice for a\n clean, stable route (e.g. `\"pricing\"` or `\"posts/:postId\"`). Omit it and the page ref is used as the slug,\n and `plitzi_apply` warns so you remember to set a meaningful one.\n- **A page slug is RELATIVE \u2014 do NOT start it with `/`.** The runtime prepends the leading slash (and any folder\n path) itself, so a leading slash doubles it. Write `\"pricing\"`, not `\"/pricing\"`. (upsertPage strips a leading\n slash for you, but write it relative.)\n- **Dynamic pages \u2014 route params.** A slug segment written `:name` (e.g. `\"posts/:postId\"`) is a **route param**,\n exactly like React Router. On that page it is readable **two ways**: as `{{name}}` inside a prop, and as the\n data-binding source **`navigation.routeParams.name`** (the `navigation` module source, global \u2014 bindable\n anywhere). So a blog is a `\"posts\"` list page plus a `\"posts/:postId\"` detail page whose `apiContainer` query\n binds `navigation.routeParams.postId` to fetch that one post. (`navigation.queryParams.<name>` exposes `?query=`\n string params the same way.)\n- **Navigate with the `Link` element, not an interaction.** `link` is a **container** \u2014 it wraps any children and\n navigates on click, so it is the default way to move between pages. Its `mode`: `\"page\"` links to another space\n page (set `href` to the target page, folder path resolved for you); `\"internal\"` takes a path inside the space and\n resolves `{{token}}` templates in it, so a row's \"view\" link is `mode:\"internal\", href:\"posts/{{postId}}\"`;\n `\"external\"` is a full URL. `target` is `self`/`blank`/`parent`/`top`. Reach for the `navigate` globalCallback\n only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) \u2014 for a plain link,\n use `link`.\n- **A link's words are its `content`, and an icon beside them its `icon`** \u2014 `{ \"type\": \"link\", \"props\": { \"mode\":\n \"page\", \"href\": \"pricing\", \"content\": \"Pricing\", \"icon\": \"fa-solid fa-arrow-right\", \"iconPlacement\": \"after\" } }`\n (a `button` takes the same two). The icon's class goes in the element's `icon` slot (`style.slots.icon`). With\n children too, `contentPlacement` puts the words `before` or `after` them. A `text` or `fontAwesome` inside is\n one element more, and a text keeps a colour of its own instead of the link's (and its hover).\n- **The link to the page being shown marks itself**: it carries `aria-current=\"page\"`, and its class's `current`\n state says how it looks \u2014 `{ \"type\": \"patchDefinition\", \"ref\": \"nav-link\", \"states\": { \"current\": { \"desktop\": {\n \"color\": \"var(--primary)\" } } } }`. So a header written once in a layout lights the right item on every page; never\n copy the header per page to style one item. A link for a section \u2014 a journal and its articles \u2014 takes\n `\"current\": \"section\"` in its props: current on every page under its path too (`aria-current=\"true\"`), the same\n state dressing it. The same state dresses any chosen one of a set: a pressed toggle (`aria-pressed` \u2014 a theme\n toggle's option slot) and a selected tab.\n- **A section of a page** is an element with an `anchor` (its `id` in the DOM: lowercase, digits, `-`; one per\n page, layouts included; not inside a list row or a component). A link lands on it with `hash`:\n `{ \"mode\": \"page\", \"href\": \"home\", \"hash\": \"plans\" }` goes to `/#plans` and scrolls there, from any page.\n\nPages can be grouped into **folders** (the sidebar tree). A folder is `{ ref, name, slug, parentId? }`; its `ref`\n**is its id**, and that id is what a page and a nested folder reference.\n- **Folder slugs PREPEND to the page URL \u2014 this is how nested URLs are built.** The full path is each ancestor\n folder's slug plus the page slug, joined by `/`: a page at slug `\"1-1-1\"` inside `folder-1` > `folder-1-1`\n resolves to `/folder-1/folder-1-1/1-1-1`. So a folder slug is part of the route; keep folder slugs relative too.\n- Create/rename/move a folder with `upsertFolder` (the `ref` you pass on create becomes its id \u2014 pick a stable one\n like `\"blog\"`). Nest it under another with `parentId` (a folder ref); `parentId: null` moves it back to the root.\n- Put a page in a folder with `upsertPage`'s `folder` (a folder ref). A page's `folder` is always either **empty\n (root)** or an **existing folder id**: `folder: null` or `folder: \"\"` moves it to the root, and any other value\n must resolve to a folder that already exists or is created earlier in the same batch \u2014 an unknown folder is\n rejected, never stored.\n- `deleteFolder` removes a folder and **promotes its contents up one level** \u2014 its child folders and its pages move\n to its parent (or the root). A folder cannot be nested under itself or one of its descendants.\n- **Disable a page** with `upsertPage`'s `enabled: false`; `enabled: true` re-enables it (defaults to enabled, and\n a page read reports its current `enabled`). Disabling only affects the **published SDK runtime** \u2014 the page stops\n being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to\n a disabled page. This does not delete it \u2014 `deletePage` does.\n- **A page that fills the window** (a dashboard, a board) takes `upsertPage`'s `documentScroll: \"locked\"`: the\n document holds still and only parts with `overflow: auto` scroll, so a finger on a tablet no longer drags and\n bounces the page. `\"noBounce\"` keeps the scroll without the rubber band; `null` undoes either. Never an\n `html, body` rule in `customCss`: that holds every page, and the site the space is a widget on.\n\n## Settings\nSpace-level configuration lives in `plitzi://settings/{env}` and is edited with a single **`patchSettings`** op\n(merge \u2014 only the fields you pass change):\n- `customCss` \u2014 **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules\n (`@keyframes`, `@font-face`, resets). To style an element, write a **definition** and attach it \u2014 never customCss.\n- `notifications` \u2014 how the toasts an `addNotification` step shows look: colours (`background`, `text`,\n `success`, `danger`, `warning`, `info`), shape (`radius`, `font`, `fontSize`, `fontWeight`, `lineHeight`,\n `minHeight`, `border`, `shadow`, `padding`) and the parts inside (`iconSize`, `iconGap`, `closeColor`,\n `closeOpacity`, `progressHeight`), one CSS value each \u2014 a token follows the theme: `{ \"type\": \"patchSettings\",\n \"notifications\": { \"background\": \"var(--card)\", \"iconSize\": \"18px\" } }`. Merged field by field, `null` removes one.\n It is stored as rules inside `customCss` but reads and changes apart from it: never write a `.Toastify__*` rule\n yourself.\n- `keepState` / `stateStorage` \u2014 keep the runtime state (`state.<key>`, what `setState` writes) across reloads,\n in `localStorage`/`sessionStorage`, filed under whoever is signed in. It is the space's setting \u2014 pages do not\n take one. `transientState` lists the top-level keys never kept (a filter, a demo, a panel left open) \u2014 or\n `keptState` the only ones kept, when few are (a dismissed notice); one of the two. Do not\n reset kept state from `onPageLoad` instead \u2014 it is restored later than that and undoes half of the reset.\n `paintedState` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go\n in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.\n `browserState` lists the kept keys that are the BROWSER's, not the account's (the cookie consent): signing in, out\n or as somebody else forgets the rest, never these. Never what belongs to an account.\n- **User provider / auth**: `userProvider` \u2014 `basic` for any HTTP+JSON backend, the name of a provider registered\n in the page, or `\"\"` for none \u2014 plus `tokenStorage`, the `loginUrl`/`userUrl`/`refreshUrl`/`logoutUrl`\n endpoints and the `detailsPath`/`tokenPath`/`refreshTokenPath`/`expirationTimePath` mapping that says where the\n values sit in their responses. `sessionHintCookie` is worth setting whenever the backend can: it names a readable\n cookie carrying only expiries, which is what lets a page answer \"nobody is signed in\" without a request.\n A space served by a self-hosted `createServer({ auth })` declares none of these: that server tells its pages where\n they sign in, and only what the space declares overrides it.\n On the Plitzi platform, `userProvider: \"server\"` signs visitors in with their Plitzi account on the space's own\n host: a `link` with `mode: \"external\"` to `/auth/sign-in?return=/` starts it, `authLogout` ends it.\n- `visitorRoles` \u2014 what each visitor role gives, `{ \"author\": [\"postPublish\"] }`: the permissions an action's\n `access: { mode: \"role\" }` and a page's `can()` ask for. A visitor holds ONLY the permissions of their roles here,\n never their account's. Who holds a role is given by email in the builder's Settings \u2192 Visitors \u2014 never in the\n space's `settings`.\n- `channels` \u2014 the realtime channels, by topic pattern (see **Realtime channels**). Merged pattern by pattern;\n `null` removes one.\n Example \u2014 inject a keyframe globally:\n `{ \"type\": \"patchSettings\", \"customCss\": \"@keyframes spin { to { transform: rotate(360deg); } }\" }`.\n\n";
2
+ export declare const structureGuide = "## Shared layouts \u2014 the chrome a page does NOT contain\nA page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout\ncontainer**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.\n\nIt is a **root of its own** \u2014 a `layoutContainer` element that no page owns and that is not in the page list \u2014 and\na page points at it with two attributes:\n- `layout` \u2014 the shell's ref. This is the whole of \"which chrome do I render inside\".\n- `layoutContainer` \u2014 the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.\n\nSo a page with `layout: \"main-layout\"` renders `main-layout`'s whole tree, with its own elements dropped into the\none container it named. Two pages naming the same shell share every element of it \u2014 **editing the shell changes\nevery page that uses it**, which is the point and also the thing to say out loud before you touch one.\n\n**Reading them.**\n- `plitzi://schema/{env}/layouts` lists the shells: `ref`, `label`, `usedBy` (the pages), `slots`, `elementCount`.\n- Every page in `plitzi://schema/{env}/pages` carries `layout` and `layoutSlot` when it has them.\n- Read a shell exactly like a page: `plitzi://schema/{env}/pages/{layoutRef}` for its skeleton,\n `.../pages/{layoutRef}/styles` for its classes. `plitzi_search` reports a layout's elements with the layout as\n their `pageRef`.\n\n**Writing them.** Every element/binding/interaction op takes the shell's ref as its `pageRef` \u2014 there is no separate\nvocabulary:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"main-layout\", \"parentRef\": \"sidebar\",\n \"element\": { \"ref\": \"upgrade-card\", \"type\": \"container\", \"children\": [ \u2026 ] } }\n```\n- `upsertLayout` creates a shell (`ref`, `label`, `subType`). Put the chrome in it with `upsertElement`, including\n an empty container to serve as the slot.\n- `upsertPage { layout, layoutContainer }` attaches a page to it; `layout: null` detaches. A `layoutContainer` that\n is not an element of that shell is refused \u2014 stored, it would render the page's body where nobody sees it.\n- `deleteLayout` removes a shell and everything in it, and is **refused while any page still renders inside it**\n (the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.\n\n**Only some pages?** A block that only some of a layout's pages carry (a newsletter band on two of ten) is not\nchrome: make it a **component** and place it on those pages.\n\n**Where does this element belong?** If the user asks for something \"on every page\" \u2014 a nav item, a banner, a footer\nlink, an upgrade prompt in the sidebar \u2014 it belongs in the LAYOUT, not in the page you happen to have open. Check\nthe page's `layout` first; if the element you are looking for is not in the page's own tree, it is in the shell.\n\n## Components \u2014 a subtree written once, placed anywhere\nA **component** is a reusable subtree: a product card, a pricing tier, a testimonial \u2014 written once and placed on\nany page as an **instance**. It is part of the space, so it is published, versioned and copied with it. Its tree is\nnot inside any page: it is a root of its own, like a layout, and **editing it changes every instance** \u2014 say so\nbefore you touch one.\n\nIt is not a **snippet**. The builder's *Save as snippet* keeps a copy of a block as a file people drop onto pages, and\neach drop is the page's own from then on. No operation here writes one: when someone wants a block that stays the same\neverywhere, that is a component.\n\nIt is **closed**. Inside, a binding or a template reads **`props`** \u2014 what each instance hands in \u2014 and the globals\n(`state`, `auth`, `navigation`, `theme`, `variables`, `computed`), never the page an instance sits on. A\ncomponent that needs a list row's record gets it as a prop: the INSTANCE binds it (`item: \"{{ list_rows.item }}\"`),\nthe component reads `{{ props.item.name }}`.\n\n**Reading them.** `plitzi://schema/{env}/components` lists them: `ref`, `label`, `props`, `slots`, `rootRef`,\n`instances`. Read one like a page: `plitzi://schema/{env}/pages/{componentRef}` (and `/styles`).\n\n**Writing them.**\n- `upsertComponent { ref, label?, props?, slots? }` declares one \u2014 with nothing in it but its root, `{ref}-root`, a\n container \u2014 or updates the declaration of one that exists (`props` is REPLACED whole). Fill it with every\n element/binding/interaction op you already know, with **`pageRef: \"<componentRef>\"`**:\n ```json\n { \"type\": \"upsertElement\", \"pageRef\": \"product-card\", \"parentRef\": \"product-card-root\",\n \"element\": { \"ref\": \"product-card-title\", \"type\": \"heading\" } }\n ```\n- `upsertComponent { ref, fromRef, instanceRef }` makes a component OF an element that already exists: the element\n and everything inside it become the component, and an instance named `instanceRef` takes its place, so the page\n renders what it did. The way to turn a repeated block into one.\n- A **prop** is `{ type, description, required?, default?, options? }`, `type` one of `text`, `textarea`,\n `number`, `boolean`, `select` (with `options`), `scalar`, `json`. Its name is read as `{{ props.<name> }}`, so\n letters, digits and `_` \u2014 and never one an instance already has (`referenceId`, `referenceType`, `slot`\u2026).\n- A **slot** is an element of the component's tree (usually an empty container) an instance fills with children.\n- `deleteComponent { ref }` removes one nothing places; while instances remain it is refused, naming them.\n\n**Placing one** is an element: a `reference` whose props say which component and hand in its props, one attribute each:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"shop\", \"parentRef\": \"grid\",\n \"element\": { \"ref\": \"lamp-card\", \"type\": \"reference\",\n \"props\": { \"referenceType\": \"component\", \"referenceId\": \"product-card\", \"title\": \"Lamp\" },\n \"children\": [ { \"ref\": \"lamp-buy\", \"type\": \"button\", \"props\": { \"content\": \"Buy\", \"slot\": \"product-card-actions\" } } ] } }\n```\nA required prop left out, a prop the component does not declare, a value of the wrong kind or a child naming a slot\nthe component does not have is reported by `plitzi_apply`'s `dryRun` \u2014 fix it before applying.\n\n## Pages & folders\n- **A page's own look** \u2014 its background, its padding \u2014 is a class on the page itself: `upsertPage { ref, style: { base: [\"page-dark\"] } }` (the element tools edit what is inside it).\n- **A page behind a feature flag**: `upsertPage { flag: \"labs\" }` answers 404 while the flag is off (see **Feature\n flags**); `flag: null` removes it.\n- **Always set a `slug` when creating a page** (`upsertPage`) \u2014 it is the page's URL path and good practice for a\n clean, stable route (e.g. `\"pricing\"` or `\"posts/:postId\"`). Omit it and the page ref is used as the slug,\n and `plitzi_apply` warns so you remember to set a meaningful one.\n- **A page slug is RELATIVE \u2014 do NOT start it with `/`.** The runtime prepends the leading slash (and any folder\n path) itself, so a leading slash doubles it. Write `\"pricing\"`, not `\"/pricing\"`. (upsertPage strips a leading\n slash for you, but write it relative.)\n- **Dynamic pages \u2014 route params.** A slug segment written `:name` (e.g. `\"posts/:postId\"`) is a **route param**,\n exactly like React Router. On that page it is readable **two ways**: as `{{name}}` inside a prop, and as the\n data-binding source **`navigation.routeParams.name`** (the `navigation` module source, global \u2014 bindable\n anywhere). So a blog is a `\"posts\"` list page plus a `\"posts/:postId\"` detail page whose `apiContainer` query\n binds `navigation.routeParams.postId` to fetch that one post. (`navigation.queryParams.<name>` exposes `?query=`\n string params the same way.)\n- **Navigate with the `Link` element, not an interaction.** `link` is a **container** \u2014 it wraps any children and\n navigates on click, so it is the default way to move between pages. Its `mode`: `\"page\"` links to another space\n page (set `href` to the target page, folder path resolved for you); `\"internal\"` takes a path inside the space and\n resolves `{{token}}` templates in it, so a row's \"view\" link is `mode:\"internal\", href:\"posts/{{postId}}\"`;\n `\"external\"` is a full URL. `target` is `self`/`blank`/`parent`/`top`. Reach for the `navigate` globalCallback\n only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) \u2014 for a plain link,\n use `link`.\n- **A link's words are its `content`, and an icon beside them its `icon`** \u2014 `{ \"type\": \"link\", \"props\": { \"mode\":\n \"page\", \"href\": \"pricing\", \"content\": \"Pricing\", \"icon\": \"fa-solid fa-arrow-right\", \"iconPlacement\": \"after\" } }`\n (a `button` takes the same two). The icon's class goes in the element's `icon` slot (`style.slots.icon`). With\n children too, `contentPlacement` puts the words `before` or `after` them. A `text` or `fontAwesome` inside is\n one element more, and a text keeps a colour of its own instead of the link's (and its hover).\n- **The link to the page being shown marks itself**: it carries `aria-current=\"page\"`, and its class's `current`\n state says how it looks \u2014 `{ \"type\": \"patchDefinition\", \"ref\": \"nav-link\", \"states\": { \"current\": { \"desktop\": {\n \"color\": \"var(--primary)\" } } } }`. So a header written once in a layout lights the right item on every page; never\n copy the header per page to style one item. A link for a section \u2014 a journal and its articles \u2014 takes\n `\"current\": \"section\"` in its props: current on every page under its path too (`aria-current=\"true\"`), the same\n state dressing it. The same state dresses any chosen one of a set: a pressed toggle (`aria-pressed` \u2014 a theme\n toggle's option slot) and a selected tab.\n- **A section of a page** is an element with an `anchor` (its `id` in the DOM: lowercase, digits, `-`; one per\n page, layouts included; not inside a list row or a component). A link lands on it with `hash`:\n `{ \"mode\": \"page\", \"href\": \"home\", \"hash\": \"plans\" }` goes to `/#plans` and scrolls there, from any page.\n\nPages can be grouped into **folders** (the sidebar tree). A folder is `{ ref, name, slug, parentId? }`; its `ref`\n**is its id**, and that id is what a page and a nested folder reference.\n- **Folder slugs PREPEND to the page URL \u2014 this is how nested URLs are built.** The full path is each ancestor\n folder's slug plus the page slug, joined by `/`: a page at slug `\"1-1-1\"` inside `folder-1` > `folder-1-1`\n resolves to `/folder-1/folder-1-1/1-1-1`. So a folder slug is part of the route; keep folder slugs relative too.\n- Create/rename/move a folder with `upsertFolder` (the `ref` you pass on create becomes its id \u2014 pick a stable one\n like `\"blog\"`). Nest it under another with `parentId` (a folder ref); `parentId: null` moves it back to the root.\n- Put a page in a folder with `upsertPage`'s `folder` (a folder ref). A page's `folder` is always either **empty\n (root)** or an **existing folder id**: `folder: null` or `folder: \"\"` moves it to the root, and any other value\n must resolve to a folder that already exists or is created earlier in the same batch \u2014 an unknown folder is\n rejected, never stored.\n- `deleteFolder` removes a folder and **promotes its contents up one level** \u2014 its child folders and its pages move\n to its parent (or the root). A folder cannot be nested under itself or one of its descendants.\n- **Disable a page** with `upsertPage`'s `enabled: false`; `enabled: true` re-enables it (defaults to enabled, and\n a page read reports its current `enabled`). Disabling only affects the **published SDK runtime** \u2014 the page stops\n being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to\n a disabled page. This does not delete it \u2014 `deletePage` does.\n- **A page that fills the window** (a dashboard, a board) takes `upsertPage`'s `documentScroll: \"locked\"`: the\n document holds still and only parts with `overflow: auto` scroll, so a finger on a tablet no longer drags and\n bounces the page. `\"noBounce\"` keeps the scroll without the rubber band; `null` undoes either. Never an\n `html, body` rule in `customCss`: that holds every page, and the site the space is a widget on.\n\n## Settings\nSpace-level configuration lives in `plitzi://settings/{env}` and is edited with a single **`patchSettings`** op\n(merge \u2014 only the fields you pass change):\n- `customCss` \u2014 **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules\n (`@keyframes`, `@font-face`, resets). To style an element, write a **definition** and attach it \u2014 never customCss.\n- `notifications` \u2014 how the toasts an `addNotification` step shows look: colours (`background`, `text`,\n `success`, `danger`, `warning`, `info`), shape (`radius`, `font`, `fontSize`, `fontWeight`, `lineHeight`,\n `minHeight`, `border`, `shadow`, `padding`) and the parts inside (`iconSize`, `iconGap`, `closeColor`,\n `closeOpacity`, `progressHeight`), one CSS value each \u2014 a token follows the theme: `{ \"type\": \"patchSettings\",\n \"notifications\": { \"background\": \"var(--card)\", \"iconSize\": \"18px\" } }`. Merged field by field, `null` removes one.\n It is stored as rules inside `customCss` but reads and changes apart from it: never write a `.Toastify__*` rule\n yourself.\n- `keepState` / `stateStorage` \u2014 keep the runtime state (`state.<key>`, what `setState` writes) across reloads,\n in `localStorage`/`sessionStorage`, filed under whoever is signed in. It is the space's setting \u2014 pages do not\n take one. `transientState` lists the top-level keys never kept (a filter, a demo, a panel left open) \u2014 or\n `keptState` the only ones kept, when few are (a dismissed notice); one of the two. Do not\n reset kept state from `onPageLoad` instead \u2014 it is restored later than that and undoes half of the reset.\n `paintedState` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go\n in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.\n `browserState` lists the kept keys that are the BROWSER's, not the account's (the cookie consent): signing in, out\n or as somebody else forgets the rest, never these. Never what belongs to an account.\n- **User provider / auth**: `userProvider` \u2014 `basic` for any HTTP+JSON backend, the name of a provider registered\n in the page, or `\"\"` for none \u2014 plus `tokenStorage`, the `loginUrl`/`userUrl`/`refreshUrl`/`logoutUrl`\n endpoints and the `detailsPath`/`tokenPath`/`refreshTokenPath`/`expirationTimePath` mapping that says where the\n values sit in their responses. `sessionHintCookie` is worth setting whenever the backend can: it names a readable\n cookie carrying only expiries, which is what lets a page answer \"nobody is signed in\" without a request.\n A space served by a self-hosted `createServer({ auth })` declares none of these: that server tells its pages where\n they sign in, and only what the space declares overrides it.\n On the Plitzi platform, `userProvider: \"server\"` signs visitors in with their Plitzi account on the space's own\n host: a `link` with `mode: \"external\"` to `/auth/sign-in?return=/` starts it, `authLogout` ends it.\n- `visitorRoles` \u2014 what each visitor role gives, `{ \"author\": [\"postPublish\"] }`: the permissions an action's\n `access: { mode: \"role\" }` and a page's `can()` ask for. A visitor holds ONLY the permissions of their roles here,\n never their account's. Who holds a role is given by email in the builder's Settings \u2192 Visitors \u2014 never in the\n space's `settings`.\n- `channels` \u2014 the realtime channels, by topic pattern (see **Realtime channels**). Merged pattern by pattern;\n `null` removes one.\n Example \u2014 inject a keyframe globally:\n `{ \"type\": \"patchSettings\", \"customCss\": \"@keyframes spin { to { transform: rotate(360deg); } }\" }`.\n\n";
@@ -86,6 +86,7 @@ A required prop left out, a prop the component does not declare, a value of the
86
86
  the component does not have is reported by \`plitzi_apply\`'s \`dryRun\` — fix it before applying.
87
87
 
88
88
  ## Pages & folders
89
+ - **A page's own look** — its background, its padding — is a class on the page itself: \`upsertPage { ref, style: { base: ["page-dark"] } }\` (the element tools edit what is inside it).
89
90
  - **A page behind a feature flag**: \`upsertPage { flag: "labs" }\` answers 404 while the flag is off (see **Feature
90
91
  flags**); \`flag: null\` removes it.
91
92
  - **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a