@plitzi/sdk-mcp 0.38.23 → 0.39.0
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.
- package/CHANGELOG.md +180 -1
- package/dist/createServer.js +1 -0
- package/dist/modules/mcp/catalogs/index.d.ts +1 -1
- package/dist/modules/mcp/catalogs/index.js +2 -2
- package/dist/modules/mcp/catalogs/pluginCatalog.js +5 -1
- package/dist/modules/mcp/handler.d.ts +3 -1
- package/dist/modules/mcp/handler.js +32 -2
- package/dist/modules/mcp/helpers/guide/index.d.ts +3 -0
- package/dist/modules/mcp/helpers/guide/index.js +19 -0
- package/dist/modules/mcp/helpers/{guide.d.ts → guide/instructions.d.ts} +0 -1
- package/dist/modules/mcp/helpers/guide/instructions.js +106 -0
- package/dist/modules/mcp/helpers/guide/logic.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/logic.js +166 -0
- package/dist/modules/mcp/helpers/guide/practice.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/practice.js +123 -0
- package/dist/modules/mcp/helpers/guide/reference.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/reference.js +249 -0
- package/dist/modules/mcp/helpers/guide/server.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/server.js +252 -0
- package/dist/modules/mcp/helpers/guide/structure.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/structure.js +187 -0
- package/dist/modules/mcp/helpers/guide/styling.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/styling.js +118 -0
- package/dist/modules/mcp/helpers/guide/values.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/values.js +6 -0
- package/dist/modules/mcp/helpers/space.d.ts +5 -2
- package/dist/modules/mcp/helpers/space.js +5 -4
- package/dist/modules/mcp/resources/core.js +1 -1
- package/dist/modules/mcp/resources/index.d.ts +1 -1
- package/dist/modules/mcp/resources/primer.d.ts +0 -11
- package/dist/modules/mcp/resources/primer.js +46 -1
- package/dist/modules/mcp/resources/register.js +1 -1
- package/dist/modules/mcp/server.js +17 -8
- package/dist/modules/mcp/tools/apply/index.d.ts +19 -0
- package/dist/modules/mcp/tools/index.js +2 -0
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +5 -2
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +6 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +64 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +13 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +13 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +25 -1
- package/dist/modules/mcp/tools/render.d.ts +13 -0
- package/dist/modules/mcp/tools/renderWidget.d.ts +13 -0
- package/dist/modules/mcp/tools/shared/lintDraft.js +5 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +6 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +0 -1
- package/dist/modules/mcp/tools/shared/validator/css.js +6 -1
- package/dist/modules/mcp/tools/test.d.ts +23 -0
- package/dist/modules/mcp/tools/test.js +85 -0
- package/dist/modules/mcp/types/aiSchema.d.ts +2 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +3 -2
- package/dist/modules/mcp/types/toolTypes.d.ts +5 -0
- package/dist/preview/createPreview.js +4 -2
- package/package.json +8 -8
- package/dist/modules/mcp/helpers/guide.js +0 -1138
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { GLOBALS, OTHER_TRANSFORMERS } from "./values.js";
|
|
2
|
+
//#region src/modules/mcp/helpers/guide/logic.ts
|
|
3
|
+
/** What an element reads and does: bindings, interactions, and what is public. */
|
|
4
|
+
var logicGuide = `## Data bindings
|
|
5
|
+
Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
|
|
6
|
+
by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
|
|
7
|
+
- \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
|
|
8
|
+
- \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
|
|
9
|
+
Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed a
|
|
10
|
+
provider's records into a list element:
|
|
11
|
+
\`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
|
|
12
|
+
"binding": { "to": "items", "source": "apiContainer_products.records" } }\`.
|
|
13
|
+
|
|
14
|
+
**What an \`apiContainer\` publishes** depends on where it reads. Through a connector (\`runtime: "server"\`) it is the
|
|
15
|
+
fixed shape under *Connectors* — \`.records\` or \`.record\`, \`.pageInfo\`, … With a browser \`query\` it is the
|
|
16
|
+
response: \`.data\` (the parsed body — an API answering \`{ "items": [...] }\` is read as
|
|
17
|
+
\`apiContainer_<name>.data.items\`) and \`.status\` (the HTTP status) — and a \`"server"\` provider with only a
|
|
18
|
+
\`query\` (a JSON file the deployment serves) answers in that same shape, so moving it to the server changes no
|
|
19
|
+
binding. Fed by a server **action**, it is the action's output at the root (\`apiContainer_<name>.items\`, never
|
|
20
|
+
\`.data.items\`). All add \`.isLoading\` (true while asked again too), \`.isEmpty\`,
|
|
21
|
+
\`.hasError\` and \`.errorMessage\`.
|
|
22
|
+
|
|
23
|
+
**Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
|
|
24
|
+
\`<type>_<name>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
|
|
25
|
+
its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
|
|
26
|
+
to it resolves to nothing at runtime. So to consume \`apiContainer_products.records\`, the bound element must live under
|
|
27
|
+
that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
|
|
28
|
+
(\`list_<name>.item.<field>\`). The global sources — ${GLOBALS} — have no \`<type>_<name>\` head and are
|
|
29
|
+
bindable anywhere. Binding an element to an element source outside its
|
|
30
|
+
provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
|
|
31
|
+
\`plitzi_apply\` treats it as an **error and rejects the batch** — move the element under the
|
|
32
|
+
provider, or bind a source that is in scope.
|
|
33
|
+
|
|
34
|
+
**mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
|
|
35
|
+
builder**; the published runtime fetches real data instead. Never rely on mockData as the production source — give
|
|
36
|
+
the provider a real source: a **connector** with \`runtime: "server"\` (see *Connectors*, the right answer whenever
|
|
37
|
+
the API needs a token or the content should be in the HTML), or a browser-side \`query\`/\`method\` for a public URL.
|
|
38
|
+
|
|
39
|
+
**\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
|
|
40
|
+
\`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
|
|
41
|
+
action is silently skipped** and the raw value passes through. Use the **exact** action names from
|
|
42
|
+
\`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
|
|
43
|
+
value is the **\`{{source}}\`** token (NOT \`{{value}}\`) — undefined until the source has a value, so \`{{ source|default('…') }}\` covers the wait; \`{{sourceTo}}\` is the field's previous value. Example —
|
|
44
|
+
show a number with units:
|
|
45
|
+
\`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
|
|
46
|
+
"binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
|
|
47
|
+
"transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
|
|
48
|
+
The others: ${OTHER_TRANSFORMERS} — each one's purpose and params are in \`plitzi://data-sources/{env}\`.
|
|
49
|
+
Transformer \`params\` values are strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
|
|
50
|
+
skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
|
|
51
|
+
validated.
|
|
52
|
+
|
|
53
|
+
**\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
|
|
54
|
+
the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
|
|
55
|
+
(operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
|
|
56
|
+
and/or). The guard is validated structurally. Example — only bind when a flag is set:
|
|
57
|
+
\`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
|
|
58
|
+
|
|
59
|
+
## Interactions
|
|
60
|
+
An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
|
|
61
|
+
it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
|
|
62
|
+
you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
|
|
63
|
+
|
|
64
|
+
**Each step reads the page as it is when it runs**: a \`when\` or a \`{{ state.x }}\` after a \`setState\` sees the new
|
|
65
|
+
value, and one after a \`delay\` sees what changed meanwhile. To act on the value from BEFORE a write, put the reading
|
|
66
|
+
step first. A step's \`when\` asks an earlier step only for what it publishes (\`plitzi://explain/<action>\` lists it):
|
|
67
|
+
a run's \`<step>.status\` (\`runServerAction\` only), a sign-in's \`<step>.ok\` — any other key is refused
|
|
68
|
+
(\`condition-field-unpublished\`). **A trigger fired again while its flow runs is ignored** (no double submit); set
|
|
69
|
+
\`"whileRunning": "queue"\` on the trigger node for a stream of events that must each run in order (\`"parallel"\` runs
|
|
70
|
+
them at once, \`"latest"\` stops the running flow — its server action or request too — for a search as you type).
|
|
71
|
+
**Keyboard shortcuts** are a trigger every element has: \`onKey\` with param \`keys\` — \`"f"\`, \`"shift+f"\`,
|
|
72
|
+
\`"mod+k"\` (⌘ on a Mac, Ctrl elsewhere), \`"plus, ="\`, \`"escape"\`. Heard on the whole page while the element is
|
|
73
|
+
mounted, ignored while someone types in a field; the flow reads the key pressed as \`{{ <trigger id>.key }}\`.
|
|
74
|
+
|
|
75
|
+
**Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
|
|
76
|
+
**wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
|
|
77
|
+
- \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
|
|
78
|
+
- \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's name (the flow host by
|
|
79
|
+
default, or another element to act on). Every element
|
|
80
|
+
registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
|
|
81
|
+
\`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
|
|
82
|
+
selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
|
|
83
|
+
for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
|
|
84
|
+
\`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
|
|
85
|
+
**undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
|
|
86
|
+
\`setState\` has **no** \`type\` param (that belongs to the global one below). Beside it every element registers
|
|
87
|
+
**\`toggleState\`** — the same write with **no \`value\`**: it stores the OPPOSITE of what is there
|
|
88
|
+
(\`category\`, \`key\`, \`revertOnFinish\`). That is how expand/collapse is authored — **one step on one trigger**,
|
|
89
|
+
never two \`setState\` branches under complementary \`when\` conditions: every step reads the page as it is when it
|
|
90
|
+
runs, so the second sees what the first wrote and flips it back. An element type may also register its own extra
|
|
91
|
+
callbacks.
|
|
92
|
+
- \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
|
|
93
|
+
\`space\`), \`setState\`/\`toggleState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`login\`/\`logout\`/
|
|
94
|
+
\`refreshDetails\` (\`auth\`), \`runServerAction\`/\`cancelServerAction\` (\`actions\`). Its \`elementId\` is the
|
|
95
|
+
**source module id**, never the host element — a node that stored the host element's name here would resolve to
|
|
96
|
+
nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
|
|
97
|
+
builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
|
|
98
|
+
\`placement:"top-right"\`, \`appearance:"success"\`) for any params you leave out. Use **only** the params each
|
|
99
|
+
callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
|
|
100
|
+
\`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
|
|
101
|
+
\`globalCallbacks\` in \`plitzi://interactions/{env}\`.
|
|
102
|
+
- **Two \`setState\`s (and two \`toggleState\`s) — do not mix them:** the **element** \`setState\` (nodeType
|
|
103
|
+
\`callback\`, on an element, category/key/value/revertOnFinish) changes THAT element's attribute/state and is what
|
|
104
|
+
you want to change a button's label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`,
|
|
105
|
+
source \`state\`, key/type/value) writes \`runtime.state.<key>\`. They share a name but have different node types
|
|
106
|
+
AND different params, and \`toggleState\` splits the same way: on an element (category/key/revertOnFinish) it flips
|
|
107
|
+
that element's own field; on source \`state\` (key) it flips \`runtime.state.<key>\`. Pick the element one when
|
|
108
|
+
nothing outside the element needs to know it is open; pick the state one when something else binds to it.
|
|
109
|
+
- \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
|
|
110
|
+
names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
|
|
111
|
+
\`webHook\` (\`url\`, \`method\`, …), \`copyToClipboard\` (\`text\`). See \`utilities\` in
|
|
112
|
+
\`plitzi://interactions/{env}\`.
|
|
113
|
+
|
|
114
|
+
**A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
|
|
115
|
+
it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<name>.<path>\`, or a
|
|
116
|
+
module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
|
|
117
|
+
a click on a row can show \`addNotification\` with \`content: "{{ list_<name>.item.name }}"\` — the clicked row's field.
|
|
118
|
+
The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
|
|
119
|
+
element repoints these tokens to the copies' names automatically, along with the element's bindings.
|
|
120
|
+
|
|
121
|
+
**Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
|
|
122
|
+
tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
|
|
123
|
+
\`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
|
|
124
|
+
|
|
125
|
+
Tools:
|
|
126
|
+
- \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
|
|
127
|
+
trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
|
|
128
|
+
the notification defaults):
|
|
129
|
+
\`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
|
|
130
|
+
{ "nodeType": "trigger", "action": "onClick", "title": "Click" },
|
|
131
|
+
{ "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
|
|
132
|
+
"params": { "content": "Saved!" } } ] }\`.
|
|
133
|
+
- \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
|
|
134
|
+
|
|
135
|
+
**Disable vs delete a step — do not confuse them (three different intents):**
|
|
136
|
+
- **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
|
|
137
|
+
with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
|
|
138
|
+
- **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
|
|
139
|
+
- **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
|
|
140
|
+
|
|
141
|
+
So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
|
|
142
|
+
never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
|
|
143
|
+
*remove* something, and **confirm with the user before deleting** a step or a flow.
|
|
144
|
+
|
|
145
|
+
Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
|
|
146
|
+
\`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
|
|
147
|
+
node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
|
|
148
|
+
\`enabled\`), so a follow-up patch/delete needs no extra read.
|
|
149
|
+
|
|
150
|
+
## What is public — and where a secret goes
|
|
151
|
+
A space is served to anyone who opens it, and everything it is made of goes with it:
|
|
152
|
+
|
|
153
|
+
- **The documents.** Every page, layout and component, every schema and style variable, every attribute, binding,
|
|
154
|
+
flow param and \`mockData\` reaches the visitor's browser with the page. Hiding an element (\`visible: false\`, a
|
|
155
|
+
flag, a condition) does not remove it from what is sent.
|
|
156
|
+
- **The files.** A file on one of the space's public buckets is on the internet at its address, signed in or not —
|
|
157
|
+
for pictures, fonts and data every visitor may see.
|
|
158
|
+
|
|
159
|
+
So a secret — an API key, a token, a password — never goes in a document or a public file. It is a **credential**,
|
|
160
|
+
created by the space owner in the builder, which a connector, an action or a function **names** and never carries.
|
|
161
|
+
Data only some visitors may read comes from a \`runtime: "server"\` provider or a server action whose \`access\` checks
|
|
162
|
+
who is asking — never from a public file or a document the page filters on the client.
|
|
163
|
+
|
|
164
|
+
`;
|
|
165
|
+
//#endregion
|
|
166
|
+
export { logicGuide };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { MOTION_ENTERS, MOTION_LOOPS } from "@plitzi/sdk-authoring";
|
|
2
|
+
//#region src/modules/mcp/helpers/guide/practice.ts
|
|
3
|
+
/** Good practice: motion, accessibility and semantics. */
|
|
4
|
+
var practiceGuide = `## Motion — good practices
|
|
5
|
+
A preset first: an element's \`motion\` field (\`upsertElement\`/\`patchElement\`) —
|
|
6
|
+
\`{ "enter": "fade-up", "on": "view" }\`, \`"stagger": 60\` for its children one by one, \`"easing"\`/\`"distance"\` (px) for a reference's own curve and travel, \`"loop": "float"\` — is
|
|
7
|
+
played by the SDK, cheap and stilled for reduced motion. \`on\`: \`load\` (default), \`view\` (once, the first time it
|
|
8
|
+
comes into view, then it stays) or \`scroll\` (follows the scroll both ways — it fades back out as the reader scrolls
|
|
9
|
+
up past it; only for an effect that is about the scroll itself). Enters: ${MOTION_ENTERS.join(", ")}; loops:
|
|
10
|
+
${MOTION_LOOPS.join(", ")}. Beyond them, keyframes go in \`customCss\` (\`patchSettings\`), a
|
|
11
|
+
definition names them (\`animation\`). Only \`opacity\` and
|
|
12
|
+
\`transform\` (\`translate\`, \`scale\`, \`rotate\`) animate off the main thread: they stay smooth while the page
|
|
13
|
+
hydrates and on a slow phone. Anything else repaints or lays the page out again on every frame, and freezes while the
|
|
14
|
+
page's scripts run.
|
|
15
|
+
- Slide, grow, fade with \`transform\` and \`opacity\` — never \`left\`, \`top\`, \`width\`, \`height\` or
|
|
16
|
+
\`margin\`. Something travelling across a box is \`transform: translate(%)\` on an element as large as the box.
|
|
17
|
+
- No animated blur: no \`filter: blur()\` in an entrance or a loop, no \`backdrop-filter\` over moving content. A soft
|
|
18
|
+
shape is a \`radial-gradient\` fading to transparent.
|
|
19
|
+
- Fake the expensive ones: a growing shadow is a second shadow on a pseudo-element whose \`opacity\` changes; a
|
|
20
|
+
pulsing glow is a static gradient whose \`opacity\` or \`scale\` changes.
|
|
21
|
+
- Decoration that must animate something else (a custom property, \`background-position\`) starts paused and runs
|
|
22
|
+
once the page is hydrated: \`.glow { animation: glow 8s linear infinite paused; } [data-hydrated] .glow {
|
|
23
|
+
animation-play-state: running; }\` in \`customCss\`. That is for loops: an entrance of its own that plays once
|
|
24
|
+
(\`transform\`/\`opacity\` only) plays from the first paint with \`backwards\`, never gated on \`[data-hydrated]\`.
|
|
25
|
+
- Entrances: \`opacity\` + a small \`translateY\`, under ~600ms, staggered by tens of ms.
|
|
26
|
+
- One slow ambient loop per screen at most — not one per card: \`infinite\` runs on every visitor's battery.
|
|
27
|
+
- Name what transitions (\`transition: transform 200ms, opacity 200ms\`), never \`all\`; \`will-change\` only on the
|
|
28
|
+
few elements about to move.
|
|
29
|
+
- Reduced motion is the SDK's: it cuts every animation to an instant for whoever asks — never write that reset.
|
|
30
|
+
|
|
31
|
+
## Accessibility — pages people, screen readers and browser agents can all use
|
|
32
|
+
A page is read three ways: seen, heard through a screen reader, and worked by a **browser agent** (Claude in Chrome)
|
|
33
|
+
— which finds the controls it can press in the same **accessibility tree** a screen reader walks. A control that
|
|
34
|
+
tree names nothing is invisible to both, however it looks. So build every page to be operable without sight:
|
|
35
|
+
- **Every control has words.** A \`button\` is named by its \`content\` and the words inside it; an icon-only one needs a
|
|
36
|
+
\`title\` (also its tooltip), and one whose words do not say what it does (a key hint, a count) a \`label\`. A \`link\` is named by what it holds, or \`label\` (set it on a link wrapping a whole card).
|
|
37
|
+
A \`formControl\` is named by its \`label\` — keep it and set \`hideLabel: true\` when the design shows what the field
|
|
38
|
+
is (a swatch, a search box); a \`placeholder\` names only a field typed into, and only until something is typed.
|
|
39
|
+
- **Every picture says what it shows** (\`alt\`), or is marked \`decorative: true\` when the words beside it already say
|
|
40
|
+
it. A \`fontAwesome\` icon is decoration (hidden) unless its \`label\` gives it a meaning of its own.
|
|
41
|
+
- **Only controls are clicked.** A click flow belongs on a \`button\` (it holds children — a whole card can be one) or
|
|
42
|
+
a \`link\` when it goes somewhere — never on a \`container\`, \`text\` or \`image\`: a keyboard cannot reach those and
|
|
43
|
+
no agent finds them. An empty backdrop that closes a panel is the exception (the panel's close button and Escape
|
|
44
|
+
are the ways everyone has).
|
|
45
|
+
- **State is said, not only styled.** A toggle sets \`ariaPressed\`, a button that opens a panel \`ariaExpanded\`
|
|
46
|
+
(bind them like any attribute) — an "active" class alone is invisible to both readers. A button that shows and
|
|
47
|
+
hides a panel names it in \`controls\` (\`aria-controls\`, the panel's anchor), and words that change while a
|
|
48
|
+
visitor reads them — a count, a total, a status — sit in a \`container\` with \`live: "polite"\` (\`aria-live\`).
|
|
49
|
+
- **A dropdown opens from a \`button\`** among its children, outside the popup (an avatar, a "⋯": the button holds it and
|
|
50
|
+
has a \`title\`). The dropdown marks it and moves the focus in and out; a box or an icon alone opens nothing from a
|
|
51
|
+
keyboard.
|
|
52
|
+
- **An illustration** built from elements (a mock of a page, art) is a \`container\` with \`decorative: true\`: both
|
|
53
|
+
readers skip it. Keep controls out of it.
|
|
54
|
+
- **The page has an outline.** Headings go down one level at a time (h1 → h2 → h3; size them with their class, not
|
|
55
|
+
their level). Landmarks are containers with a tag — \`header\`, \`nav\`, \`main\`, \`aside\`, \`footer\` — and a
|
|
56
|
+
\`label\` when a page has two of one kind; a \`section\` with a \`label\` is a region an assistant can jump to.
|
|
57
|
+
- **What comes built in:** modals and dialogs are \`dialog\`s named by their title, take the focus, keep Tab inside
|
|
58
|
+
and close on Escape; tabs are a tab list worked with the arrow keys; a field that breaks a rule is marked invalid and
|
|
59
|
+
described by its message; the pager marks the current page. Nothing to add for those.
|
|
60
|
+
- **A canvas is a picture** to both readers. A plugin that draws (a chart, a board, a map) also renders what it shows
|
|
61
|
+
as real elements — a list, a table — with a button for every action; one hidden until focused cannot be clicked by an
|
|
62
|
+
agent that clicks by position, so offer a visible "list view".
|
|
63
|
+
The linter warns about these (\`control-without-name\`, \`image-without-alt\`, \`click-on-static-element\`,
|
|
64
|
+
\`dropdown-without-control\`, \`heading-level-skipped\`, \`label-ignored\`, \`control-in-decorative\`) on every element
|
|
65
|
+
you touch; fix them in the same batch. Then look:
|
|
66
|
+
\`plitzi_look\` shows the page as those readers get it, and lists what has no name.
|
|
67
|
+
|
|
68
|
+
## Semantics
|
|
69
|
+
- **props are fully replaced** on \`upsertElement\`: send every prop you want to keep. To change only some props,
|
|
70
|
+
use **\`patchElement\`** — it merges \`props\`/\`style\` onto the existing element (listed keys change, \`null\` unsets
|
|
71
|
+
a key, everything else is preserved) and never creates. Combined with \`plitzi_search\` (which returns the ref +
|
|
72
|
+
stateVersion), a targeted edit is two calls with no read.
|
|
73
|
+
- **definition CSS is fully replaced** on \`upsertDefinition\`: send every property you want to keep. To change only
|
|
74
|
+
some declarations, use **\`patchDefinition\`** — it merges CSS per breakpoint/state/variant/slot onto the existing
|
|
75
|
+
definition (listed keys change, \`null\` removes a property, everything else is preserved) and never creates.
|
|
76
|
+
Example — recolor one definition without resending it: \`{ "type": "patchDefinition", "ref": "btn-x",
|
|
77
|
+
"desktop": { "background-color": "#111" } }\`.
|
|
78
|
+
- **Atomic batches**: if any operation fails, \`plitzi_apply\` persists nothing.
|
|
79
|
+
- **Every element you touch must be malformation-free — pre-existing errors block the save.** When your batch edits
|
|
80
|
+
an element, the result is read by the same linter every writer of a space is held to, and the element's **current
|
|
81
|
+
stored content** with it — a broken transformer action, a malformed step, an attribute it never reads — even in
|
|
82
|
+
parts your edit does not touch. Such a finding is reported as a \`Pre-existing malformation in element …\` **error**, and
|
|
83
|
+
\`plitzi_apply\` rejects the batch until it is fixed. These are **not caused by your change** (the message says so)
|
|
84
|
+
— do not be confused; fix them **in the same batch** and re-apply. Because the check runs on the resulting state,
|
|
85
|
+
including the fix in your batch is exactly what unblocks the save. (Advisory issues — an unobserved source/action
|
|
86
|
+
name that may still be a valid plugin, a binding target a plugin manifest does not list — come back as
|
|
87
|
+
\`Pre-existing issue …\` **warnings** and do not block.) Elements you do not touch are not held against you — except
|
|
88
|
+
that a broken tree your batch leaves anywhere (an element orphaned by a delete) is refused.
|
|
89
|
+
- **Optimistic concurrency — read before you write, and prove your read is current.** Editing a resource means you
|
|
90
|
+
read it first, so you hold its \`stateVersion\`. **Always pass \`expectedResourceVersions\`** (URI → the stateVersion
|
|
91
|
+
you read) for every resource your batch changes. If another agent edited it in the meantime, the live version no
|
|
92
|
+
longer matches and apply is **rejected with a conflict** — nothing persists. Then re-read the reported resources
|
|
93
|
+
(their new content + version) and retry on top of the fresh state. This is exactly how a file editor forces a
|
|
94
|
+
re-read after a stale write: it is what keeps concurrent agents from silently overwriting each other's changes, so
|
|
95
|
+
never omit it "to save a call".
|
|
96
|
+
|
|
97
|
+
## The space's own tests — \`plitzi_test\`
|
|
98
|
+
A space keeps its tests in its document, and **a snapshot and a publish wait for them**: what you change must leave them
|
|
99
|
+
passing. Two kinds — the builder calls them **element checks** (unit) and **journeys** (e2e: what a visitor does, from
|
|
100
|
+
start to end — not an interaction's flow). \`plitzi_test { action: 'list' }\` says them and how the element checks
|
|
101
|
+
stand; \`run\` plays the journeys on the draft, where the deployment has a browser — one play at a time per space, each
|
|
102
|
+
journey counted against the plan's month (a refusal says why, and when it comes back). Write them whole with \`set\`:
|
|
103
|
+
- \`unit\`: \`{ id, title, element, given: { state, sources }, expect: [{ kind: 'visible' | 'attribute' | 'style' |
|
|
104
|
+
'variant' | 'state', … }] }\` — one element resolved for a state, no browser.
|
|
105
|
+
- \`e2e\`: \`{ id, title, page, width, steps: [{ kind: 'click', element }, { kind: 'expectText', element, text }, …] }\`
|
|
106
|
+
— a visitor's steps on a page, elements by id (a list's copy \`row:3\`), what must hold between them; \`type\` names
|
|
107
|
+
a form control and writes in its field; \`click\`/\`hover\` take \`point: { x, y }\`, percent of the element's box —
|
|
108
|
+
what a canvas draws (a map's marker); \`page\` may be a wrong address the space's own not-found page answers.
|
|
109
|
+
\`{ kind: 'expectCheck', check: '<unit id>' }\` holds an element check for the state the journey reached;
|
|
110
|
+
\`given: { state: { … } }\` starts it with a state; \`as: '<account>'\` plays it signed in as a test account;
|
|
111
|
+
\`tags: ['sign-in']\` sorts many (lower case words) — \`run\` with \`tags\` plays only those carrying one.
|
|
112
|
+
- \`accounts\`: \`{ id, email?, roles? }\` — who a journey plays as, declared here alone: no real account and no
|
|
113
|
+
password, so what the page asks the API it asks as a guest — a page for signed-in visitors, a role's view. Its roles
|
|
114
|
+
are the space's visitor roles (\`settings.visitorRoles\`), what it may is what they give; one removed since is warned.
|
|
115
|
+
The primer names both kinds' ids and titles.
|
|
116
|
+
A batch that leaves a test unreadable — an element it presses removed, the page it starts on renamed — says so in its
|
|
117
|
+
warnings ("This change leaves a test of the space unreadable…"): fix the test in the same batch, or say why.
|
|
118
|
+
When a test fails over a change the user asked for, say so and fix the test with them — never delete it to pass.
|
|
119
|
+
The plan keeps a number of journeys per space (Free one): a \`set\` that adds past it is refused, naming the plan that
|
|
120
|
+
keeps more — tell the user; never remove a journey of theirs to make room.
|
|
121
|
+
`;
|
|
122
|
+
//#endregion
|
|
123
|
+
export { practiceGuide };
|
|
@@ -0,0 +1,2 @@
|
|
|
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.\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";
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
//#region src/modules/mcp/helpers/guide/reference.ts
|
|
2
|
+
/** The guide's start: what to read, the tools, and how an element is addressed, made, moved and deleted. */
|
|
3
|
+
var referenceGuide = `# Plitzi AI MCP — usage guide
|
|
4
|
+
|
|
5
|
+
A Plitzi space is **two separate schemas** you edit together:
|
|
6
|
+
- **Element schema** — the tree of pages and elements (their type, label, props, and which style classes they use).
|
|
7
|
+
- **Style schema** — reusable **definitions** (CSS classes), design tokens (variables), theme.
|
|
8
|
+
|
|
9
|
+
They are stored and persisted independently, but a single \`plitzi_apply\` batch may touch **both atomically**.
|
|
10
|
+
To style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**
|
|
11
|
+
it via the element's \`style.base\` (element schema). Example — "rename button X to PEPE and make it red":
|
|
12
|
+
\`\`\`json
|
|
13
|
+
{ "operations": [
|
|
14
|
+
{ "type": "upsertDefinition", "ref": "btn-x", "desktop": { "color": "red" } },
|
|
15
|
+
{ "type": "upsertElement", "pageRef": "home",
|
|
16
|
+
"element": { "ref": "X", "type": "button", "label": "PEPE", "style": { "base": ["btn-x"] } } }
|
|
17
|
+
] }
|
|
18
|
+
\`\`\`
|
|
19
|
+
|
|
20
|
+
Reads are cheap by design — treat them like a filesystem: **list** to navigate, **read one item** for detail.
|
|
21
|
+
Never download a whole tree you do not need.
|
|
22
|
+
|
|
23
|
+
## Resources (read)
|
|
24
|
+
- \`plitzi://primer/{env}\` — **cold-start bundle**: guide + types + css-properties + page/definition/variable
|
|
25
|
+
**summaries** in one read. Fetch this first instead of the individual resources below. Summaries only — open a
|
|
26
|
+
page skeleton or element for its tree/detail.
|
|
27
|
+
- \`plitzi://guide\` — this guide.
|
|
28
|
+
- \`plitzi://types\` — element types **observed in this space** (ground truth): props, slots, subTypes, plus each
|
|
29
|
+
type's \`label\`, \`description\` (what it is FOR) and \`category\`, and a \`source\` (\`builtin\` | \`plugin\` | \`unknown\`).
|
|
30
|
+
Read the descriptions to pick the right type — e.g. \`apiContainer\` fetches backend data into the frontend,
|
|
31
|
+
\`link\` navigates between pages, \`list\` repeats a template over a data array. \`plugin\` types are the elements
|
|
32
|
+
of the plugins the space installed: added by their type, like a built-in.
|
|
33
|
+
- \`plitzi://css-properties\` — valid kebab-case CSS property keys.
|
|
34
|
+
- \`plitzi://explain/{name}\` — what a name means: an element type's attributes, triggers, callbacks and what it writes
|
|
35
|
+
on its node; a step's params and what it publishes; what a trigger hands its flow; a style state; a problem code's
|
|
36
|
+
fix. \`plitzi://explain/steps\` (or elements, triggers, codes, transformers, states) lists every one of a kind.
|
|
37
|
+
- \`plitzi://schema/{env}/pages\` — page **summaries** (ref, label, elementCount, folder). No element trees.
|
|
38
|
+
- \`plitzi://schema/{env}/layouts\` — the shared **layout shells** (header/sidebar/footer) and the pages rendered
|
|
39
|
+
inside each. Read one like a page. See *Shared layouts* below.
|
|
40
|
+
- \`plitzi://schema/{env}/components\` — the space's **components** (reusable subtrees): their props, slots, root and
|
|
41
|
+
how many places render each. Read one like a page. See *Components* below.
|
|
42
|
+
- \`plitzi://folders/{env}\` — page **folders** (the sidebar tree): ref, name, slug, parentId. \`/{ref}\` for one.
|
|
43
|
+
- \`plitzi://schema/{env}/pages/{ref}\` — one page as a **skeleton tree**: each node is \`ref/type/label\` **plus the
|
|
44
|
+
style classes it attaches** (\`base\`, and \`slots\` for non-base slots) — names only, no CSS. So you can map every
|
|
45
|
+
element to its class in a single page read, without opening each element just to learn which class it uses.
|
|
46
|
+
- \`plitzi://schema/{env}/pages/{ref}/styles\` — **every style the page uses in one read**: the class definitions its
|
|
47
|
+
elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.
|
|
48
|
+
Reach for this to recolor/restyle a whole page — it needs no shared class-name prefix and no per-element reads.
|
|
49
|
+
- \`plitzi://schema/{env}/elements/{ref}\` — one element in **full detail** (props, style, parentRef, childRefs).
|
|
50
|
+
Its \`resolvedStyle\` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you
|
|
51
|
+
can see and edit its style without a separate definition read. Its \`globalStyles\` lists the **global element
|
|
52
|
+
selectors** that also affect it (the CSS equivalent of \`button { … }\`, keyed by the type they target) — every
|
|
53
|
+
element of that type inherits them. Edit a global only through the global-style tools (never per element). If the
|
|
54
|
+
element carries a DOM \`id\` that an id rule matches, its \`idStyle\` (\`#id\`) is inlined too.
|
|
55
|
+
- \`plitzi://definitions/{env}\` — the **names** of every style definition.
|
|
56
|
+
- \`plitzi://definitions/{env}/{ref}\` — one definition's CSS.
|
|
57
|
+
- \`plitzi://global-styles/{env}\` — element **types** that have a site-wide global style. \`/{componentType}\` for one.
|
|
58
|
+
- \`plitzi://id-styles/{env}\` — DOM **ids** that have an id rule (\`#id\`) targeting a single element. \`/{targetId}\` for one.
|
|
59
|
+
- \`plitzi://style-variables/{env}\` — design tokens by category. \`/{category}\` for one.
|
|
60
|
+
- \`plitzi://fonts/{env}\` — the font **families the space loads**, with their source and fallback. \`/{family}\` for one.
|
|
61
|
+
- \`plitzi://schema-variables/{env}\` — space-level values referenced in props as \`{{name}}\`.
|
|
62
|
+
- \`plitzi://flags/{env}\` — the space's **feature flags**, each a default and its rules (see **Feature flags**).
|
|
63
|
+
- \`plitzi://settings/{env}\` — space-level settings: the global \`customCss\` and the state/auth (user-provider) config.
|
|
64
|
+
- \`plitzi://interactions/{env}\` — interaction **actions** observed in this space (grouped by node type): the
|
|
65
|
+
vocabulary for interaction flows.
|
|
66
|
+
- \`plitzi://data-sources/{env}\` — data-source **paths** and binding targets observed in this space: the
|
|
67
|
+
vocabulary for data bindings.
|
|
68
|
+
- \`plitzi://connector-presets\` — working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain
|
|
69
|
+
REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.
|
|
70
|
+
Space-independent. Read it before writing a connector by hand.
|
|
71
|
+
- \`plitzi://connectors/{env}\` — the **connectors this space has**: for each, its read/write endpoint names, its
|
|
72
|
+
filter operators and its published fields. \`/{ref}\` opens one manifest in full. See *Connectors* below.
|
|
73
|
+
- \`plitzi://actions/{env}\` — the **server actions this space has**: what starts each one, who may run it, and the
|
|
74
|
+
input/output contract a caller is held to. \`/{ref}\` opens one flow in full. See *Server actions* below.
|
|
75
|
+
- \`plitzi://actions/{env}/tasks\` — the **server tasks this deployment can run**, each with its params: the steps an
|
|
76
|
+
action may be built from.
|
|
77
|
+
- \`plitzi://functions/{env}\` — the space's **functions**, its own server code: which files, and the tasks, routes and
|
|
78
|
+
hosts they declare. \`plitzi://functions/{env}/{+path}\` reads one file whole. See *Functions* below.
|
|
79
|
+
- \`plitzi://data/{env}\` — the space's **data**: JSON files its server providers read, never served.
|
|
80
|
+
\`plitzi://data/{env}/{+path}\` reads one, parsed. See *Data* below.
|
|
81
|
+
- \`plitzi://changes/{env}\` — the space's **change history**, read-only and newest first: who made each change (a
|
|
82
|
+
person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before
|
|
83
|
+
and after. \`/{id}\` for the history of one of them — how you find what changed an element you are asked about, or
|
|
84
|
+
review what you or another agent just did.
|
|
85
|
+
- \`plitzi://render/guide\`, \`plitzi://render/types\` — the manual and the type table for \`plitzi_render\` (offline
|
|
86
|
+
widgets, not this space).
|
|
87
|
+
|
|
88
|
+
The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
|
|
89
|
+
|
|
90
|
+
Data resources return \`{ stateVersion, data }\`. Keep \`stateVersion\` for optimistic concurrency.
|
|
91
|
+
|
|
92
|
+
**Reuse what you already know — don't re-scan an unchanged page.** A page read (\`plitzi://schema/{env}/pages/{ref}\`)
|
|
93
|
+
returns a \`stateVersion\` that is an **aggregate of the whole page**: it changes if and only if some element on the
|
|
94
|
+
page changed. Its skeleton \`tree\` also carries a \`stateVersion\` **per node**, identical to the one a direct element
|
|
95
|
+
read or search hit returns for that element. So when you come back to a page you already inspected:
|
|
96
|
+
1. Re-read just the page skeleton and compare its top-level \`stateVersion\` to the one you held. **Same → nothing
|
|
97
|
+
changed since your read; skip re-reading and re-searching the tree** and act on what you already know.
|
|
98
|
+
2. If it differs, diff the per-node \`stateVersion\`s against the ones you cached and \`plitzi_read\` **only the nodes
|
|
99
|
+
that changed** — never re-search or re-read the whole tree.
|
|
100
|
+
|
|
101
|
+
This is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space
|
|
102
|
+
concurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time
|
|
103
|
+
check below on the strength of a cached hash — the guarantee that no concurrent edit is lost comes only from
|
|
104
|
+
\`expectedResourceVersions\` on \`plitzi_apply\`, which re-validates against the live data at write time.
|
|
105
|
+
|
|
106
|
+
## Navigating (files analogy)
|
|
107
|
+
Pages and containers are folders; elements are files. **Prefer \`plitzi_search\` (especially with \`include: "detail"\`)
|
|
108
|
+
over reading elements one by one** — it jumps straight to elements by label/type/attribute and each hit already
|
|
109
|
+
carries the element's \`uri\`, \`stateVersion\`, \`pageUri\`, \`parentRef\` and tree \`path\`, so you can edit it (with
|
|
110
|
+
optimistic concurrency) **without a follow-up read**. \`include: "detail"\` additionally inlines each hit's props/style
|
|
111
|
+
**and** its \`resolvedStyle\` (the CSS behind its classes) — so a search-then-edit is the efficient path and a manual
|
|
112
|
+
element read is the exception. Search also matches **pages** by name/slug (returned under \`pages\`, each with its uri +
|
|
113
|
+
stateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under \`definitions\`.
|
|
114
|
+
When you do hold several refs to open (e.g. from a skeleton), read them together with \`plitzi_read\` rather than one at a time.
|
|
115
|
+
|
|
116
|
+
## Tools
|
|
117
|
+
- \`plitzi_apply\` — validate → apply → persist atomically. Rejects the whole batch on any error or conflict, and
|
|
118
|
+
reports **pre-existing malformations** in any resource the batch touches (see below) and \`suggestions\` (see
|
|
119
|
+
*Suggestions*). Pass \`dryRun: true\` to check and apply in memory only — the same answer, nothing persisted — and
|
|
120
|
+
\`look\` (\`"html"\`, \`"image"\`, \`"accessibility"\` or \`"both"\`, with \`pageRef\` and \`viewport\`) to see the page
|
|
121
|
+
as the batch leaves it in the same call. Check and look with \`dryRun\`, then send the same operations without it.
|
|
122
|
+
\`effects\` is what the batch did, read off the space before and after it — every element, attribute, class and
|
|
123
|
+
setting it changed, one line each: read it, not your batch, for what is now so. \`Nothing changed\` and \`NOT saved\`
|
|
124
|
+
lead the warnings when they are so.
|
|
125
|
+
- **By intention**, a few parameters and the element named by its ref alone — the page is found, the operations
|
|
126
|
+
written, the batch checked and saved as \`plitzi_apply\` saves it, and the answer its \`effects\`, whether it was
|
|
127
|
+
\`saved\`, and what was already so:
|
|
128
|
+
\`plitzi_set_attributes { ref, set, unset }\`, \`plitzi_set_classes { ref, add, remove }\` (the classes it wears and
|
|
129
|
+
you do not name stay), \`plitzi_bind_attribute { ref, to, source }\`, \`plitzi_place_component { component, ref, into,
|
|
130
|
+
props }\`, \`plitzi_add_page { ref, slug, layout }\`. One of them when it says the whole change; anything else is one
|
|
131
|
+
batch of \`plitzi_apply\`.
|
|
132
|
+
- \`plitzi_describe_operation\` — one operation's schema by its \`type\` (every field, which are required); without a
|
|
133
|
+
type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an
|
|
134
|
+
operation does not have is refused naming the one meant (\`"prop" (did you mean "props"?)\`), and a type spelt with
|
|
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.
|
|
137
|
+
- \`plitzi_search\` — find elements (and pages/definitions) across the space.
|
|
138
|
+
- \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
|
|
139
|
+
ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
|
|
140
|
+
so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.
|
|
141
|
+
- \`plitzi_look { pageRef, view, viewport }\` — see a saved page. \`view\`: \`"accessibility"\` (default) reads it as a
|
|
142
|
+
screen reader and a browser agent (Claude in Chrome) do — an outline of roles and names, every control and picture
|
|
143
|
+
with no name listed in \`unnamed\`, as text and far cheaper than an image; \`"html"\` its markup; \`"image"\` a PNG,
|
|
144
|
+
the way to SEE overflow and misalignment (desktop, mobile or \`both\`); \`"both"\` image and outline. A change not
|
|
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.
|
|
147
|
+
- \`plitzi_activity { after, wait }\` — what happened on the space since you last looked: the draft changed (a person
|
|
148
|
+
in the builder, another agent, the autofix — \`seq\` is its place in \`plitzi://changes/{env}\`), a version went
|
|
149
|
+
out, a server action failed or was refused. The first call, without \`after\`, answers the latest and a \`cursor\`;
|
|
150
|
+
pass it back as \`after\` and the call waits up to \`wait\` seconds (45, at most 50) until something happens. Your own
|
|
151
|
+
writes are left out and counted (\`skippedMine\`; \`mine: true\` keeps them). On a space people edit too, call it
|
|
152
|
+
before a write that rests on what you read earlier.
|
|
153
|
+
- \`plitzi_render\` — a different job: show the user a self-contained widget built offline. It never touches the space.
|
|
154
|
+
|
|
155
|
+
## Suggestions — the same page with fewer elements
|
|
156
|
+
\`plitzi_apply\` (with or without \`dryRun\`) answers with \`suggestions\`: lines like \`[content-attribute] … (saves 4
|
|
157
|
+
elements)\`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said — what the
|
|
158
|
+
space already had is not repeated on every batch — and none of them blocks anything: the page renders as written.
|
|
159
|
+
- \`repeated-on-pages\` — the same block at the edge of several pages: put it in a **layout** once (a block only some
|
|
160
|
+
pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the
|
|
161
|
+
page being shown: the \`current\` state marks it (see *Pages & folders*).
|
|
162
|
+
- \`repeated-shape\` — one structure written again with other words: a **component** with props
|
|
163
|
+
(\`upsertComponent { fromRef }\` turns one copy into it), or, for sibling rows of data, one \`repeatElement\`/\`list\`.
|
|
164
|
+
A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill
|
|
165
|
+
from a template of their own or render on the server are controls written alike, and are not offered.
|
|
166
|
+
- \`content-attribute\` — a \`button\` or \`link\` whose children are only a \`text\` and/or a \`fontAwesome\`: its words
|
|
167
|
+
are its own \`content\` and the icon its \`icon\`. What the text's class adds (\`white-space: nowrap\`) moves to the
|
|
168
|
+
box's class — never the class itself; the icon's class goes in the \`icon\` slot.
|
|
169
|
+
- \`custom-css-class\`, \`custom-css-sdk-default\`, \`custom-css-notifications\` — \`customCss\` that a class's
|
|
170
|
+
\`states\`/\`ancestors\`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.
|
|
171
|
+
- \`heavy-animation\` — keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter
|
|
172
|
+
while the page loads. Lighter, not shorter — see **Motion — good practices**.
|
|
173
|
+
- \`unused-class\`, \`unused-token\`, \`unused-component\` — declared and read by nothing: remove it
|
|
174
|
+
(\`deleteDefinition\`, \`deleteStyleVariable\`, \`deleteComponent\`), or use it where it was meant to go. Said
|
|
175
|
+
when a batch leaves one behind.
|
|
176
|
+
- \`element-color-inherited\` — the space's \`elements\` giving a type \`color: inherit\` or the page's own colour,
|
|
177
|
+
which every element — a link's words included — takes by itself: remove it, and name the colour once on the page.
|
|
178
|
+
- \`literal-colour\` — a class painted from the palette typing out a token's light value: \`var(--token)\` when it
|
|
179
|
+
should follow the scheme; a token of one value when it must stay the same in both.
|
|
180
|
+
\`plitzi://explain/<code>\` explains each. Take one unless the copies are about to diverge; one left on purpose is
|
|
181
|
+
quieted on an element it names — \`quiet: ["repeated-shape"]\` on \`upsertElement\`/\`patchElement\` (\`null\` removes it)
|
|
182
|
+
— and is not offered again, here, in the builder or in authoring. Suggestions' codes only.
|
|
183
|
+
|
|
184
|
+
## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)
|
|
185
|
+
Three ways to read, each for a different moment — pick by what you have in hand:
|
|
186
|
+
- **MCP resources** (the \`plitzi://…\` catalog above) — the **browsable index**. List them to discover what exists, or
|
|
187
|
+
open one by URI when you are exploring. This is the passive catalog, not a tool.
|
|
188
|
+
- **\`plitzi_search\`** — you know *what* you want but not its **ref/uri** ("the hero button"). Search finds it by
|
|
189
|
+
label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
|
|
190
|
+
- **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
|
|
191
|
+
content in one batch. It is the tool form of opening resources, for when you have the addresses.
|
|
192
|
+
Rule of thumb: **discover → resources**, **find a name → plitzi_search**, **fetch known uris → plitzi_read**. Never
|
|
193
|
+
hand-build a URI to guess your way to an element — search for it instead.
|
|
194
|
+
|
|
195
|
+
Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
|
|
196
|
+
they created or updated** — each with its own \`uri\` and \`stateVersion\` (\`elements: [...]\`) so a follow-up edit of
|
|
197
|
+
the same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only
|
|
198
|
+
uri+stateVersion — re-read them if you need their new content. The operation shapes are in each tool's input
|
|
199
|
+
schema (discriminated by \`type\`).
|
|
200
|
+
|
|
201
|
+
## Addressing
|
|
202
|
+
Every element and page has **one name, and that name is its id**. You choose it, you address it by it, and the
|
|
203
|
+
runtime wires by it — there is no second key and nothing to translate. Creating an element with
|
|
204
|
+
\`"ref": "products-api"\` stores it under exactly that.
|
|
205
|
+
|
|
206
|
+
That name is the **wiring key**: a provider registers its data source as \`<type>_<name>\`, so a \`source\` you write
|
|
207
|
+
against a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the
|
|
208
|
+
batch):
|
|
209
|
+
- Charset \`[A-Za-z0-9_-]\`, **starting with a letter** and not ending in \`-\` (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split
|
|
210
|
+
the \`<type>_<name>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
|
|
211
|
+
allowed**: the FIRST \`_\` separates \`<type>\` from the name and element types are camelCase with none, so
|
|
212
|
+
underscores inside a name are unambiguous (\`list_food_item\` → type \`list\`, name \`food_item\`).
|
|
213
|
+
- **Unique across the space**; a name that is taken is rejected (address the existing element instead).
|
|
214
|
+
|
|
215
|
+
**Never invent a name for something that already exists** — read it. Every read hands you the name back
|
|
216
|
+
(\`plitzi_search\`, a page skeleton, a write response), and that is the string every op takes.
|
|
217
|
+
|
|
218
|
+
**Where an element renders** is its \`runtime\`, settable on \`upsertElement\`/\`patchElement\`: \`"shared"\` (the
|
|
219
|
+
default, both sides), \`"client"\` (browser only) or \`"server"\` (SSR only). It matters for one thing above all — an
|
|
220
|
+
\`apiContainer\` reads through a **connector** only when it is \`"server"\` (see *Connectors*). An element read
|
|
221
|
+
reports it only when it is set. The page server resolves \`"server"\` elements of a page and its layouts only, never
|
|
222
|
+
inside a component — one there is refused; put the provider on the page and hand the component its rows as a prop.
|
|
223
|
+
|
|
224
|
+
**Renaming** (\`patchElement\` with \`rename\`) moves the one key: the parent's child list, every binding source and
|
|
225
|
+
every interaction target across the space that named the old one is repointed with it, so nothing comes unwired.
|
|
226
|
+
You do not have to rewrite them.
|
|
227
|
+
|
|
228
|
+
## Elements — create, move, delete
|
|
229
|
+
- \`upsertElement\` creates an element (or replaces one by name) under \`parentRef\` — the page root when omitted — and
|
|
230
|
+
builds a whole subtree in one op through nested \`children\`. \`patchElement\` changes an existing one in place.
|
|
231
|
+
- \`moveElement { pageRef, ref, toParentRef, position }\` moves or reorders one: \`position\` \`"inside"\` (the default)
|
|
232
|
+
nests it in \`toParentRef\`; \`"before"\`/\`"after"\` make it that element's sibling. Its subtree moves with it.
|
|
233
|
+
- \`deleteElement { pageRef, ref }\` removes an element **and everything under it**. A binding or an interaction
|
|
234
|
+
elsewhere that named one of them is left pointing at nothing, and the save reports it — delete them in the same
|
|
235
|
+
batch. Destructive: confirm first.
|
|
236
|
+
- \`flag\` on \`upsertElement\` / \`patchElement\` gates an element on a feature flag (\`"newCheckout"\` or
|
|
237
|
+
\`"!newCheckout"\`) — not a visibility: gated off it is not rendered at all. See **Feature flags**.
|
|
238
|
+
- **A compound element is written with its parts**, as \`children\` of the same \`upsertElement\`: a \`carousel\` holds a
|
|
239
|
+
\`carouselTrack\` (the slides go in it), a \`tabContainer\` a \`tabContainerHeader\` and a \`tabContainerBody\`, a
|
|
240
|
+
\`dropdown\` a \`dropdownPopup\`. Without its part it shows nothing (\`part-missing\`); a part anywhere else breaks the
|
|
241
|
+
page (\`outside-ancestor\`).
|
|
242
|
+
- **A dropdown places its popup**: the popup's class is its look, never its place (\`popup-position-set\`) —
|
|
243
|
+
\`popupPlacement\`, the offsets and \`popupWidth: "trigger"\` are the dropdown's; the \`openDropdown\`,
|
|
244
|
+
\`closeDropdown\` and \`toggleDropdown\` steps open and close it. The open tab is a class's \`current\` state
|
|
245
|
+
(\`aria-selected\`), never \`active\` (the press): \`plitzi://explain/<type>\` says what each element writes on its node.
|
|
246
|
+
|
|
247
|
+
`;
|
|
248
|
+
//#endregion
|
|
249
|
+
export { referenceGuide };
|