@plitzi/sdk-mcp 0.39.4 → 0.39.7
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 +42 -0
- package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +8 -0
- package/dist/modules/mcp/catalogs/pluginCatalog.js +35 -1
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +9 -0
- package/dist/modules/mcp/server.js +9 -3
- package/dist/modules/mcp/tools/index.js +5 -1
- package/dist/modules/mcp/tools/releases.d.ts +3 -0
- package/dist/modules/mcp/tools/releases.js +60 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +19 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @plitzi/sdk-mcp
|
|
2
2
|
|
|
3
|
+
## 0.39.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 081d94e: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [081d94e]
|
|
10
|
+
- @plitzi/plitzi-sdk@0.39.7
|
|
11
|
+
- @plitzi/sdk-server@0.39.7
|
|
12
|
+
- @plitzi/sdk-authoring@0.39.7
|
|
13
|
+
- @plitzi/sdk-kernel@0.39.7
|
|
14
|
+
- @plitzi/sdk-schema@0.39.7
|
|
15
|
+
- @plitzi/sdk-shared@0.39.7
|
|
16
|
+
- @plitzi/sdk-style@0.39.7
|
|
17
|
+
|
|
18
|
+
## 0.39.6
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @plitzi/plitzi-sdk@0.39.6
|
|
23
|
+
- @plitzi/sdk-server@0.39.6
|
|
24
|
+
- @plitzi/sdk-authoring@0.39.6
|
|
25
|
+
- @plitzi/sdk-kernel@0.39.6
|
|
26
|
+
- @plitzi/sdk-schema@0.39.6
|
|
27
|
+
- @plitzi/sdk-shared@0.39.6
|
|
28
|
+
- @plitzi/sdk-style@0.39.6
|
|
29
|
+
|
|
30
|
+
## 0.39.5
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 4427674: 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 [4427674]
|
|
37
|
+
- @plitzi/plitzi-sdk@0.39.5
|
|
38
|
+
- @plitzi/sdk-server@0.39.5
|
|
39
|
+
- @plitzi/sdk-authoring@0.39.5
|
|
40
|
+
- @plitzi/sdk-kernel@0.39.5
|
|
41
|
+
- @plitzi/sdk-schema@0.39.5
|
|
42
|
+
- @plitzi/sdk-shared@0.39.5
|
|
43
|
+
- @plitzi/sdk-style@0.39.5
|
|
44
|
+
|
|
3
45
|
## 0.39.4
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
|
@@ -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
|
-
|
|
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`) \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_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";
|
|
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";
|
|
@@ -150,6 +150,15 @@ When you do hold several refs to open (e.g. from a skeleton), read them together
|
|
|
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
|
|
@@ -60,7 +60,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
60
60
|
...entitlements ? { entitlements } : {}
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, runE2eTests, saveData, getActivity, getRenderCredential } = adapters;
|
|
63
|
+
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, runE2eTests, saveData, getActivity, getRenderCredential, releases } = adapters;
|
|
64
64
|
const write = {
|
|
65
65
|
userId: grant?.userId,
|
|
66
66
|
batch: randomUUID(),
|
|
@@ -81,7 +81,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
81
81
|
const getSpace = () => spacePromise ??= loadSpace();
|
|
82
82
|
const server = new McpServer({
|
|
83
83
|
name: "plitzi-mcp",
|
|
84
|
-
version: "0.39.
|
|
84
|
+
version: "0.39.7"
|
|
85
85
|
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
86
86
|
const { getChanges } = adapters;
|
|
87
87
|
registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
|
|
@@ -103,7 +103,13 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
103
103
|
...getActivity ? { activity: (query) => getActivity(requireSpaceId(), query, {
|
|
104
104
|
userId: grant?.userId,
|
|
105
105
|
origin: "mcp"
|
|
106
|
-
}, signal) } : {}
|
|
106
|
+
}, signal) } : {},
|
|
107
|
+
...releases ? { releases: {
|
|
108
|
+
domains: () => releases.domains(requireSpaceId()),
|
|
109
|
+
history: (domain) => releases.history(requireSpaceId(), domain),
|
|
110
|
+
publish: (asked) => releases.publish(requireWritableSpaceId(), asked, write),
|
|
111
|
+
rollback: (asked) => releases.rollback(requireWritableSpaceId(), asked, write)
|
|
112
|
+
} } : {}
|
|
107
113
|
});
|
|
108
114
|
const spacelessContext = (tool) => ({
|
|
109
115
|
space: emptySpace(),
|
|
@@ -6,6 +6,7 @@ import { describeOperationTool } from "./describeOperation.js";
|
|
|
6
6
|
import { addPageTool, bindAttributeTool, placeComponentTool, setAttributesTool, setClassesTool } from "./intents.js";
|
|
7
7
|
import { lookTool } from "./look.js";
|
|
8
8
|
import { read, readShape, readTool } from "./read.js";
|
|
9
|
+
import { publishTool, releasesTool, rollbackTool } from "./releases.js";
|
|
9
10
|
import { renderTool } from "./render.js";
|
|
10
11
|
import { search, searchShape, searchTool } from "./search.js";
|
|
11
12
|
import { testTool } from "./test.js";
|
|
@@ -27,6 +28,9 @@ var tools = [
|
|
|
27
28
|
lookTool,
|
|
28
29
|
tryFunctionTool,
|
|
29
30
|
testTool,
|
|
30
|
-
activityTool
|
|
31
|
+
activityTool,
|
|
32
|
+
releasesTool,
|
|
33
|
+
publishTool,
|
|
34
|
+
rollbackTool
|
|
31
35
|
];
|
|
32
36
|
export { apply, applyShape, operation, read, readShape, search, searchShape, tools };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineTool } from "./shared/tool.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/modules/mcp/tools/releases.ts
|
|
4
|
+
/**
|
|
5
|
+
* A space's releases, for an agent as for a person: what each domain serves and what a rollback would put
|
|
6
|
+
* back, a domain's history, a publish and a rollback — held on the platform to the same rules as the builder's Publish
|
|
7
|
+
* (who may publish, the plan, the revision's tests), a refusal answered in its words.
|
|
8
|
+
*/
|
|
9
|
+
var environment = z.enum([
|
|
10
|
+
"main",
|
|
11
|
+
"development",
|
|
12
|
+
"staging",
|
|
13
|
+
"production"
|
|
14
|
+
]);
|
|
15
|
+
var notWired = {
|
|
16
|
+
done: false,
|
|
17
|
+
reason: "This deployment keeps no releases for its spaces"
|
|
18
|
+
};
|
|
19
|
+
var releasesTool = defineTool({
|
|
20
|
+
name: "plitzi_releases",
|
|
21
|
+
title: "Space releases",
|
|
22
|
+
description: "Every domain of the space with the revision it serves, where its site is (Plitzi, or a copy on a provider) and what it asks, and what a rollback would put back — or, with `domain`, that domain’s releases, newest first: what each put on it, who, when, publish or rollback.",
|
|
23
|
+
inputShape: { domain: z.string().optional().describe("One domain’s history; every domain when left out") },
|
|
24
|
+
access: "read",
|
|
25
|
+
documents: false,
|
|
26
|
+
run: async ({ domain }, ctx) => {
|
|
27
|
+
if (!ctx.releases) return notWired;
|
|
28
|
+
return domain ? ctx.releases.history(domain) : { domains: await ctx.releases.domains() };
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var publishTool = defineTool({
|
|
32
|
+
name: "plitzi_publish",
|
|
33
|
+
title: "Publish a revision",
|
|
34
|
+
description: "Point a domain at a revision, recorded as a release: named, it stays on it; left out, it follows its environment’s latest — each revision kept there afterwards shows on it. Live at once for the visitors of that domain: publish only what the person asked to be published.",
|
|
35
|
+
inputShape: {
|
|
36
|
+
domain: z.string().describe("One of the space’s domains"),
|
|
37
|
+
environment: environment.describe("The revision’s environment; `main` serves the draft as it is saved"),
|
|
38
|
+
revision: z.number().int().positive().optional().describe("The revision it stays on; left out, it follows the environment’s latest"),
|
|
39
|
+
deploy: z.boolean().optional().describe("A domain whose site a provider holds: deploy it when the revision needs one (refused otherwise)")
|
|
40
|
+
},
|
|
41
|
+
access: "write",
|
|
42
|
+
documents: false,
|
|
43
|
+
run: (asked, ctx) => ctx.releases ? ctx.releases.publish(asked) : notWired
|
|
44
|
+
});
|
|
45
|
+
var rollbackTool = defineTool({
|
|
46
|
+
name: "plitzi_rollback",
|
|
47
|
+
title: "Roll a domain back",
|
|
48
|
+
description: "Put back on a domain what it served right before its latest release — or the version `to` names from its history. Never refused by plan. Feature flags and the space’s data stay as they are.",
|
|
49
|
+
inputShape: {
|
|
50
|
+
domain: z.string().describe("One of the space’s domains"),
|
|
51
|
+
to: z.object({
|
|
52
|
+
environment,
|
|
53
|
+
revision: z.number().int().nonnegative()
|
|
54
|
+
}).optional().describe("A version from its history; what it served right before its latest release when left out")
|
|
55
|
+
},
|
|
56
|
+
access: "write",
|
|
57
|
+
documents: false,
|
|
58
|
+
run: (asked, ctx) => ctx.releases ? ctx.releases.rollback(asked) : notWired
|
|
59
|
+
});
|
|
60
|
+
export { publishTool, releasesTool, rollbackTool };
|
|
@@ -4,7 +4,7 @@ import { ResourceProxy } from '../../proxy';
|
|
|
4
4
|
import { PreviewClient, ScreenshotClient, ScreenshotImage, Env, Persisters } from '../../types';
|
|
5
5
|
import { McpUiToolMeta } from '@modelcontextprotocol/ext-apps';
|
|
6
6
|
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
import { ActionRunReport } from '@plitzi/sdk-shared';
|
|
7
|
+
import { ActionRunReport, Environment, SpaceDomainRelease, SpaceReleaseOutcome, SpaceReleases } from '@plitzi/sdk-shared';
|
|
8
8
|
import { SpaceActivityPage, SpaceActivityQuery } from '@plitzi/sdk-shared/activity';
|
|
9
9
|
/** Everything a tool needs at call time: the loaded space, the target environment, and the persisters (only the
|
|
10
10
|
* write tools use them). Built by whoever hosts the tools — the MCP server, or a host calling them in-process — so
|
|
@@ -34,6 +34,24 @@ export interface ToolContext {
|
|
|
34
34
|
renderCredential?: () => Promise<string | undefined>;
|
|
35
35
|
/** What happened on the space after a cursor, waited for — when the host wired it. Only plitzi_activity uses it. */
|
|
36
36
|
activity?: (query: SpaceActivityQuery) => Promise<SpaceActivityPage>;
|
|
37
|
+
/** The space's releases, bound to it and to the member the agent acts for — when the host wired them. Only
|
|
38
|
+
* plitzi_releases, plitzi_publish and plitzi_rollback use them. */
|
|
39
|
+
releases?: {
|
|
40
|
+
domains: () => Promise<SpaceDomainRelease[]>;
|
|
41
|
+
history: (domain: string) => Promise<SpaceReleases>;
|
|
42
|
+
publish: (asked: {
|
|
43
|
+
domain: string;
|
|
44
|
+
environment: Environment;
|
|
45
|
+
revision?: number;
|
|
46
|
+
}) => Promise<SpaceReleaseOutcome>;
|
|
47
|
+
rollback: (asked: {
|
|
48
|
+
domain: string;
|
|
49
|
+
to?: {
|
|
50
|
+
environment: Environment;
|
|
51
|
+
revision: number;
|
|
52
|
+
};
|
|
53
|
+
}) => Promise<SpaceReleaseOutcome>;
|
|
54
|
+
};
|
|
37
55
|
}
|
|
38
56
|
/** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
|
|
39
57
|
* PNG, so a vision-capable agent (or MCP client) sees the render directly. */
|
package/dist/server.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { createServer } from './createServer';
|
|
|
8
8
|
export { buildMCPPipeline } from './pipeline';
|
|
9
9
|
export { createMcpServer, handleMcp, serveMcp, readMcpBody } from './modules/mcp/handler';
|
|
10
10
|
export { createHttpPreviewClient } from './modules/mcp/previewClient';
|
|
11
|
-
export { pluginCatalog, stringDeclarations } from './modules/mcp/catalogs/pluginCatalog';
|
|
11
|
+
export { pluginCatalog, pluginStylesheets, stringDeclarations } from './modules/mcp/catalogs/pluginCatalog';
|
|
12
12
|
export { createHttpScreenshotClient } from './modules/mcp/screenshotClient';
|
|
13
13
|
export { createLocalScreenshotClient, resolveLocalBrowser } from './modules/mcp/localScreenshotClient';
|
|
14
14
|
export type { LocalScreenshotClientConfig } from './modules/mcp/localScreenshotClient';
|
package/dist/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createServer } from "./createServer.js";
|
|
|
3
3
|
import { buildMCPPipeline } from "./pipeline.js";
|
|
4
4
|
import { handleMcp, readMcpBody, serveMcp } from "./modules/mcp/handler.js";
|
|
5
5
|
import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
|
|
6
|
-
import { pluginCatalog, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
6
|
+
import { pluginCatalog, pluginStylesheets, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
7
7
|
import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
|
|
8
8
|
import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
|
|
9
|
-
export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };
|
|
9
|
+
export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, pluginStylesheets, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-mcp",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.7",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
50
|
-
"@plitzi/plitzi-sdk": "0.39.
|
|
51
|
-
"@plitzi/sdk-authoring": "0.39.
|
|
52
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
53
|
-
"@plitzi/sdk-schema": "0.39.
|
|
54
|
-
"@plitzi/sdk-server": "0.39.
|
|
55
|
-
"@plitzi/sdk-shared": "0.39.
|
|
56
|
-
"@plitzi/sdk-style": "0.39.
|
|
50
|
+
"@plitzi/plitzi-sdk": "0.39.7",
|
|
51
|
+
"@plitzi/sdk-authoring": "0.39.7",
|
|
52
|
+
"@plitzi/sdk-kernel": "0.39.7",
|
|
53
|
+
"@plitzi/sdk-schema": "0.39.7",
|
|
54
|
+
"@plitzi/sdk-server": "0.39.7",
|
|
55
|
+
"@plitzi/sdk-shared": "0.39.7",
|
|
56
|
+
"@plitzi/sdk-style": "0.39.7",
|
|
57
57
|
"ejs": "^7.0.2",
|
|
58
58
|
"esbuild": "^0.28.2",
|
|
59
59
|
"zod": "^4.6.7"
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"@vitest/coverage-v8": "^5.1.0",
|
|
72
72
|
"eslint": "^9.39.5",
|
|
73
73
|
"eslint-plugin-import": "^2.32.0",
|
|
74
|
-
"jsdom": "^31.0.
|
|
74
|
+
"jsdom": "^31.0.1",
|
|
75
75
|
"react": "^19.3.1",
|
|
76
76
|
"react-dom": "^19.3.1",
|
|
77
77
|
"tsx": "^4.23.15",
|
|
78
78
|
"typescript": "^6.0.3",
|
|
79
|
-
"vite": "^8.3.
|
|
79
|
+
"vite": "^8.3.8",
|
|
80
80
|
"vite-plugin-dts": "^5.1.2",
|
|
81
81
|
"vitest": "^5.1.0"
|
|
82
82
|
},
|