@plitzi/sdk-mcp 0.38.24 → 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 +156 -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 -1139
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/modules/mcp/helpers/guide/styling.ts
|
|
2
|
+
/** Styling: classes and selectors, variants and state, variables, tokens and fonts. */
|
|
3
|
+
var stylingGuide = `## Styling (crosses both schemas)
|
|
4
|
+
- **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
|
|
5
|
+
it from \`defaultStyle\` on the type in \`plitzi://types\` (the primer includes it). Do not assume \`display: block\`:
|
|
6
|
+
\`text\`, for one, defaults to \`display: inline\`, so margins/width/vertical padding behave differently. If you need
|
|
7
|
+
block/flex layout on such an element, set \`display\` explicitly in your definition rather than relying on a default.
|
|
8
|
+
- **Images: preserve aspect ratio.** Setting only \`width\` and \`height\` (or forcing both) distorts an image. Change
|
|
9
|
+
one dimension and let the other be \`auto\`, or set \`aspect-ratio\` with \`object-fit: cover\`/\`contain\`, so the
|
|
10
|
+
image scales without stretching.
|
|
11
|
+
- **Font size and line height move together.** When you change \`font-size\`, set \`line-height\` in the same edit
|
|
12
|
+
(prefer a unitless ratio like \`1.5\`, which tracks the font size). Changing one without the other leaves cramped or
|
|
13
|
+
loosely-spaced text — they are a joint change, not two separate ones.
|
|
14
|
+
- A definition lives in the **style schema**; an element's \`style.base\` (element schema) is the link that applies
|
|
15
|
+
it. Styling an element = upsertDefinitions + upsertElement with that ref in \`style.base\`, in one batch.
|
|
16
|
+
- **Repeating siblings**: when a set of siblings shares a shape and differs only in data (a list, cards, rows,
|
|
17
|
+
steps), use \`repeatElement\` — the template once with \`{{item.field}}\` placeholders plus \`items\`, which
|
|
18
|
+
creates the wrapper and numbers each row's refs (\`step-1\`, \`step-2\`…). A list inside each row is the same op:
|
|
19
|
+
the wrapping node carries \`repeat: { items: "{{item.<list>}}", template: … }\` and its refs number both levels
|
|
20
|
+
(\`blk-2-3\`). Copy-pasting the subtree N times costs N times the tokens and drifts.
|
|
21
|
+
- CSS keys are **kebab-case** (\`background-color\`). camelCase is rejected — read \`plitzi://css-properties\`.
|
|
22
|
+
- **Write normal CSS — shorthands are accepted and expanded for you.** \`border\`, \`border-{side}\`,
|
|
23
|
+
\`border-width\`/\`-color\`/\`-style\`, \`border-radius\`, \`padding\`, \`margin\`, \`inset\`, \`gap\`, \`overflow\`,
|
|
24
|
+
\`flex\`, \`flex-flow\`, \`background\`, \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-template\`,
|
|
25
|
+
\`grid-area\`, \`grid-row\`, \`grid-column\`, \`place-content\`, \`place-items\`, \`place-self\`, \`outline\`,
|
|
26
|
+
\`columns\`, \`list-style\`, \`text-decoration\` — the full list is in \`plitzi://css-properties\` under
|
|
27
|
+
\`shorthands\`. They **persist as longhand keys** (that is what a read gives back), so a breakpoint/state/variant
|
|
28
|
+
can still override one property at a time.
|
|
29
|
+
- \`border: 1px solid red\` → \`border-top-width: 1px\`, \`border-top-style: solid\`, \`border-top-color: red\`, …
|
|
30
|
+
for all four sides. A shorthand also RESETS what it omits, so \`border: none\` clears a width a previous
|
|
31
|
+
definition set.
|
|
32
|
+
- Comma-separated layers are kept per longhand: \`transition: opacity 200ms, transform 300ms\` →
|
|
33
|
+
\`transition-property: opacity, transform\` + \`transition-duration: 200ms, 300ms\`.
|
|
34
|
+
- A \`background\` with a bare \`var(--x)\` part is refused: what the variable holds decides the longhand —
|
|
35
|
+
\`background-color\` for a colour, \`background-image\` for a gradient or a picture. A var() inside one
|
|
36
|
+
(\`linear-gradient(…, var(--x))\`) is read as it is.
|
|
37
|
+
- In a **patch**, a shorthand replaces the longhands it controls (\`padding: 8px\` overwrites a previous
|
|
38
|
+
\`padding-left\`), and \`"border": null\` removes all twelve border longhands.
|
|
39
|
+
- **Flex layout is not a \`flex\` value**: set \`display: flex\` **plus** \`flex-direction\`, \`align-items\`,
|
|
40
|
+
\`justify-content\` as separate properties.
|
|
41
|
+
- CSS is grouped by breakpoint: \`desktop\`, \`tablet\`, \`mobile\`.
|
|
42
|
+
- Reference a style variable in CSS as \`var(--name)\`; a schema variable in a prop as \`{{name}}\`.
|
|
43
|
+
- \`element.style.base\` is a **list** of definition refs; other slots go under \`element.style.slots\` — the slots
|
|
44
|
+
\`plitzi://explain/{type}\` lists, never custom CSS on the SDK's own class names. A \`markdown\` or a \`richText\`
|
|
45
|
+
has a slot per part of the document it writes (\`heading\`, \`heading2\`, \`paragraph\`, \`link\`, \`code\`,
|
|
46
|
+
\`codeBlockFrame\`…); a \`formControl\` its \`input\` box, the \`field\` inside it, \`label\`, \`requiredMark\`, \`error\`;
|
|
47
|
+
a \`pagination\` its \`previous\`, \`page\`, \`next\` (the page shown is the class's \`current\` state).
|
|
48
|
+
- **An element can attach SEVERAL classes at once, and they all apply.** \`style.base\` holds a list, and each
|
|
49
|
+
non-base slot holds its own — every attached definition contributes CSS, and they **cascade** (a later class, then a
|
|
50
|
+
global/id rule, overrides an earlier one on the same property). So when a style looks wrong, the culprit may be
|
|
51
|
+
ANY attached class, not the one you just edited: read the element's \`resolvedStyle\` (it inlines the CSS of every
|
|
52
|
+
class it attaches, keyed by ref) together with its \`globalStyles\`/\`idStyle\` and the type's \`defaultStyle\`, and
|
|
53
|
+
fix the class that actually sets the property — do not just pile another class on top.
|
|
54
|
+
- **Three kinds of style live in the style schema — do not confuse them:**
|
|
55
|
+
- **Definitions** = reusable CSS **classes** (\`upsertDefinition\`/\`patchDefinition\`/\`deleteDefinition\`, keyed by a
|
|
56
|
+
class \`ref\`). Attach one to an element via \`style.base\` to style **that** element (and anything else that opts in).
|
|
57
|
+
This is the **default** way to style one element. Declaring MORE than one class in a batch? Use
|
|
58
|
+
\`upsertDefinitions\` — one op carrying \`{ "<class>": { desktop: … }, … }\`, same result as the run of
|
|
59
|
+
\`upsertDefinition\` it replaces, without repeating the envelope once per class.
|
|
60
|
+
- **Global styles** = the CSS equivalent of a bare element selector like \`button { … }\`
|
|
61
|
+
(\`upsertGlobalStyle\`/\`patchGlobalStyle\`/\`deleteGlobalStyle\`, keyed by \`componentType\`). They style **every**
|
|
62
|
+
element of that type at once. Use these for site-wide intent — e.g. "all buttons rounded":
|
|
63
|
+
\`{ "type": "upsertGlobalStyle", "componentType": "button", "desktop": { "border-radius": "9999px" } }\`.
|
|
64
|
+
- **Id styles** = the CSS equivalent of an id selector like \`#hero { … }\`
|
|
65
|
+
(\`upsertIdStyle\`/\`patchIdStyle\`/\`deleteIdStyle\`, keyed by \`targetId\`). They style the **single** element whose
|
|
66
|
+
DOM \`id\` attribute equals \`targetId\` — so the element must carry that \`id\` (set it in its props). Prefer a
|
|
67
|
+
**definition** for one element; reach for an id style only when a specific, uniquely-identified node must be
|
|
68
|
+
targeted by id: \`{ "type": "upsertIdStyle", "targetId": "hero", "desktop": { "min-height": "100vh" } }\`.
|
|
69
|
+
- The three share one name space, so an op refuses a name held by another kind (guards against a typo silently
|
|
70
|
+
rewriting every element of a type, or converting a class into an id rule). If refused, you targeted the wrong
|
|
71
|
+
kind — switch tools or rename.
|
|
72
|
+
|
|
73
|
+
## Style variants & element state
|
|
74
|
+
A **variant** is a named CSS override on a definition (e.g. a button class with a \`primary\` variant). It takes two
|
|
75
|
+
steps across the two schemas:
|
|
76
|
+
- **Declare** the variant CSS on the class (style schema): \`upsertDefinition\`/\`patchDefinition\` with
|
|
77
|
+
\`variants: { "primary": { "desktop": { "background-color": "#111" } } }\` (per slot under \`slots.<slot>.variants\`).
|
|
78
|
+
- **Apply** it to an element (element schema): \`initialState.styleVariant\` =
|
|
79
|
+
\`{ "<class-ref>": { "base": "primary" } }\` — a slot name instead of \`base\` targets that slot; an array applies
|
|
80
|
+
several. Set it via \`upsertElement\`/\`patchElement\`.
|
|
81
|
+
An element read reports \`availableVariants\` (which variant each attached class offers) and the element's current
|
|
82
|
+
\`initialState\`, so you can see a button **has** a \`primary\` variant and whether it uses it. If the user asks for a
|
|
83
|
+
variant that does not exist yet, **create it (upsertDefinition variants) and apply it in the same batch**.
|
|
84
|
+
- \`initialState.visibility\` (boolean) sets whether the element starts shown or hidden.
|
|
85
|
+
- The \`hidden\` state of a class is how it looks while hidden — where it goes and where it comes from. With a
|
|
86
|
+
\`transition\` that includes \`display 200ms allow-discrete\`, it fades or slides in and out instead of blinking.
|
|
87
|
+
|
|
88
|
+
**Ancestor conditions** — a class that changes inside an ANCESTOR (\`.toolbar .icon\`), or while that ancestor is
|
|
89
|
+
hovered or in a variant (\`.card:hover .icon\`, a collapsed sidebar hiding its labels) is \`ancestors\` on that class,
|
|
90
|
+
keyed by a class the ancestor wears: \`ancestors: { "toolbar": { "desktop": { … } }, "card": { "states": { "hover":
|
|
91
|
+
{ "desktop": { … } } } }, "sidebar": { "variants": { "collapsed": … } } }\`.
|
|
92
|
+
Any ancestor counts, not only the parent; the class's own states and variants win over these. Never customCss for it.
|
|
93
|
+
\`">"\` keys the parent, whatever it wears — a component's part reacting to what it sits in.
|
|
94
|
+
|
|
95
|
+
**Pseudo-elements and conditions** sit beside \`states\` in a definition and in each of its variants:
|
|
96
|
+
\`pseudos: { "after": { "desktop": { "content": "\\"→\\"" }, "states": { "hover": { "desktop": { … } } } } }\`
|
|
97
|
+
(\`before\`/\`after\` are drawn only with a quoted \`content\`; also \`selection\`, \`marker\`, \`placeholder\`,
|
|
98
|
+
\`first-letter\`, \`first-line\`), and \`conditions: { "motion-reduce": { "desktop": { … } }, "container (max-width:
|
|
99
|
+
30rem)": { … } }\` (the nearest ancestor whose class sets \`container-type\`). A patch keeps the ones it does not name;
|
|
100
|
+
\`null\` removes one. A state beyond \`hover\`/\`focus-visible\`/\`current\`: \`expanded\` (an open trigger), \`first\`,
|
|
101
|
+
\`last\`, \`odd\`, \`even\`.
|
|
102
|
+
|
|
103
|
+
## Variables, design tokens and fonts
|
|
104
|
+
- **Schema variables** are space-wide values a prop reads as \`{{name}}\`: \`upsertVariable { name, variableType,
|
|
105
|
+
value, category?, subValues? }\` (\`variableType\` is the runtime type — \`text\`, \`number\`, … — not the op's
|
|
106
|
+
\`type\`), \`deleteVariable { name }\`.
|
|
107
|
+
- **Design tokens** are CSS values a definition reads as \`var(--name)\`: \`upsertStyleVariable { category, name,
|
|
108
|
+
value }\` with \`category\` one of \`color\`, \`spacing\`, \`shadow\`, \`custom\` and \`name\` without the \`--\`. A
|
|
109
|
+
\`value\` may be one string or \`{ light, dark }\`, so a colour follows the theme. \`deleteStyleVariable\` removes one.
|
|
110
|
+
Reach for a token whenever a value repeats across classes — a hardcoded colour is a colour the theme cannot change.
|
|
111
|
+
- **Fonts**: a \`font-family\` only renders in its face when the space loads that family. \`upsertFont { family,
|
|
112
|
+
source, fallback, weights? }\` declares one — \`source\` \`google\` needs nothing else, \`remote\` a \`stylesheet\` or
|
|
113
|
+
\`files\` URL, \`system\` loads nothing. \`deleteFont { family }\` stops loading it; rules that still name it render
|
|
114
|
+
in their fallback.
|
|
115
|
+
|
|
116
|
+
`;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { stylingGuide };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BUILTIN_TRANSFORMERS, GLOBAL_SOURCES } from "@plitzi/sdk-authoring";
|
|
2
|
+
//#region src/modules/mcp/helpers/guide/values.ts
|
|
3
|
+
var GLOBALS = GLOBAL_SOURCES.map((source) => `\`${source}\``).join(", ");
|
|
4
|
+
var OTHER_TRANSFORMERS = Object.keys(BUILTIN_TRANSFORMERS).filter((action) => action !== "twigTemplate").map((action) => `\`${action}\``).join(", ");
|
|
5
|
+
//#endregion
|
|
6
|
+
export { GLOBALS, OTHER_TRANSFORMERS };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AIElementDetail } from '../types';
|
|
2
2
|
import { ActionEntry, ActionTaskDescriptor, ComponentCatalog, ConnectorEntry, DataDraft, Element, FunctionsDraft, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
|
|
3
|
+
import { TSpaceEntitlements } from '@plitzi/sdk-shared/network';
|
|
3
4
|
/** The working view the tools read and mutate: the two Plitzi schemas (elements + style), which the platform
|
|
4
5
|
* stores and persists as separate documents (Space model / Style model), plus the space's `connectors` — a third
|
|
5
6
|
* store (one row per connector) that a provider element points into by identifier. `catalog` is read-only
|
|
@@ -20,6 +21,8 @@ export interface Space {
|
|
|
20
21
|
* is. Absent when the deployment offers no data: then there is nothing to read and every data op is refused. */
|
|
21
22
|
data?: DataDraft;
|
|
22
23
|
catalog?: ComponentCatalog;
|
|
24
|
+
/** What the space's plan includes, read-only like `catalog`: absent on a deployment that sells no plans. */
|
|
25
|
+
entitlements?: TSpaceEntitlements;
|
|
23
26
|
/**
|
|
24
27
|
* The whole document, when `schema` is a view of one tree of it — a component's, which an op addressed to a
|
|
25
28
|
* component edits as if it were the space's only tree. What a new name has to be free of is still all of it.
|
|
@@ -145,9 +148,9 @@ export declare const unauthorizedSpaceMessage: string;
|
|
|
145
148
|
export declare class NoSpaceError extends Error {
|
|
146
149
|
constructor();
|
|
147
150
|
}
|
|
148
|
-
export declare const readOnlyGrantMessage: string;
|
|
151
|
+
export declare const readOnlyGrantMessage: (reason?: string) => string;
|
|
149
152
|
/** Raised when a write runs under a grant that carries no write authority. Like NoSpaceError this is a STATE of
|
|
150
153
|
* the connection rather than a failed call, so the host renders it as a result the agent can act on. */
|
|
151
154
|
export declare class ReadOnlyGrantError extends Error {
|
|
152
|
-
constructor();
|
|
155
|
+
constructor(reason?: string);
|
|
153
156
|
}
|
|
@@ -8,7 +8,8 @@ var cloneSpace = (space) => ({
|
|
|
8
8
|
...space.functions ? { functions: structuredClone(space.functions) } : {},
|
|
9
9
|
...space.data ? { data: structuredClone(space.data) } : {},
|
|
10
10
|
...space.actionTasks ? { actionTasks: space.actionTasks } : {},
|
|
11
|
-
...space.catalog ? { catalog: space.catalog } : {}
|
|
11
|
+
...space.catalog ? { catalog: space.catalog } : {},
|
|
12
|
+
...space.entitlements ? { entitlements: space.entitlements } : {}
|
|
12
13
|
});
|
|
13
14
|
var emptySpace = () => ({
|
|
14
15
|
schema: {
|
|
@@ -290,12 +291,12 @@ var NoSpaceError = class extends Error {
|
|
|
290
291
|
this.name = "NoSpaceError";
|
|
291
292
|
}
|
|
292
293
|
};
|
|
293
|
-
var readOnlyGrantMessage =
|
|
294
|
+
var readOnlyGrantMessage = (reason) => `This connection may READ this space but not change it: ${reason ?? "the member who authorized it does not have permission to edit this space. To edit, the user must reconnect the integration and grant edit access"}. Every write tool will fail the same way, do not retry them — reads still work.`;
|
|
294
295
|
/** Raised when a write runs under a grant that carries no write authority. Like NoSpaceError this is a STATE of
|
|
295
296
|
* the connection rather than a failed call, so the host renders it as a result the agent can act on. */
|
|
296
297
|
var ReadOnlyGrantError = class extends Error {
|
|
297
|
-
constructor() {
|
|
298
|
-
super(readOnlyGrantMessage);
|
|
298
|
+
constructor(reason) {
|
|
299
|
+
super(readOnlyGrantMessage(reason));
|
|
299
300
|
this.name = "ReadOnlyGrantError";
|
|
300
301
|
}
|
|
301
302
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../helpers/uris.js";
|
|
2
|
-
import { guideText } from "../helpers/guide.js";
|
|
2
|
+
import { guideText } from "../helpers/guide/index.js";
|
|
3
3
|
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
4
4
|
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
5
5
|
import { envelope } from "./envelope.js";
|
|
@@ -4,7 +4,7 @@ export { connectorSummaries } from './connectors';
|
|
|
4
4
|
export { registerResources } from './register';
|
|
5
5
|
export { resourceErrorMessage } from './canonical';
|
|
6
6
|
export { RENDER_GUIDE_URI, RENDER_TYPES_URI } from './renderGuide';
|
|
7
|
-
export { buildTypeRegistry, cssProperties, cssShorthands, expandShorthand, isCssProperty, suggestCssProperty } from '../catalogs';
|
|
7
|
+
export { ambiguousShorthands, buildTypeRegistry, cssProperties, cssShorthands, expandShorthand, isCssProperty, suggestCssProperty } from '../catalogs';
|
|
8
8
|
export type { TypeInfo, TypePropInfo, TypeRegistry } from '../catalogs';
|
|
9
9
|
export * from '../tools/operations/schema/translator';
|
|
10
10
|
export * from '../tools/operations/style/translator';
|
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import { Space } from '../helpers';
|
|
2
2
|
import { Env, ResourceEnvelope } from '../types';
|
|
3
|
-
/** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
|
|
4
|
-
*
|
|
5
|
-
* Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
|
|
6
|
-
* large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
|
|
7
|
-
* plitzi://guide) to keep the bundle small.
|
|
8
|
-
*
|
|
9
|
-
* Past `SPACE_BUDGET` the summaries themselves stop being cheap, and the tail is replaced by pointers. Nothing is
|
|
10
|
-
* lost by that: the primer is an aggregate of reads an agent can make one at a time, and every section here names
|
|
11
|
-
* the resource that answers it in full — eliding one costs a round-trip, never information.
|
|
12
|
-
*
|
|
13
|
-
* Returns undefined when the URI is not the primer. */
|
|
14
3
|
export declare const readPrimerResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { componentSummariesToAI } from "../helpers/components.js";
|
|
2
2
|
import { componentsUri, connectorsUri, dataSourcesUri, defsUri, flagsUri, foldersUri, fontsUri, interactionsUri, layoutsUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarsUri, typesUri } from "../helpers/uris.js";
|
|
3
|
-
import { guideQuickstart } from "../helpers/guide.js";
|
|
3
|
+
import { guideQuickstart } from "../helpers/guide/instructions.js";
|
|
4
4
|
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
5
5
|
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
6
6
|
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
@@ -69,9 +69,52 @@ var fit = (sections, budget) => {
|
|
|
69
69
|
* the resource that answers it in full — eliding one costs a round-trip, never information.
|
|
70
70
|
*
|
|
71
71
|
* Returns undefined when the URI is not the primer. */
|
|
72
|
+
/**
|
|
73
|
+
* The space's plan, in one line an agent reads before it plans work: what the plan is called and, by the plan that
|
|
74
|
+
* includes them, what it does not include — so an agent does not build a custom domain or a function the space cannot
|
|
75
|
+
* ship, and tells the person which plan would. Capability names, not prose: the refusal carries the words.
|
|
76
|
+
*/
|
|
77
|
+
var planOf = ({ tierLabel, capabilities, journeysPerSpace, serverRunsPerMonth }) => {
|
|
78
|
+
const notIncluded = {};
|
|
79
|
+
for (const [name, { included, requires }] of Object.entries(capabilities)) if (!included && requires) (notIncluded[requires] ??= []).push(name);
|
|
80
|
+
return {
|
|
81
|
+
name: tierLabel,
|
|
82
|
+
...Object.keys(notIncluded).length > 0 ? { notIncluded } : {},
|
|
83
|
+
...journeysPerSpace === null ? {} : { journeysPerSpace },
|
|
84
|
+
...serverRunsPerMonth === null ? {} : { journeysPlayedOnTheServerAMonth: serverRunsPerMonth }
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/** How many of each kind the primer names; past it, how many more — `plitzi_test` lists them whole. */
|
|
88
|
+
var TESTS_NAMED = 40;
|
|
89
|
+
/**
|
|
90
|
+
* The space's own tests, by id and title: what a change must leave passing before a snapshot — an element check names
|
|
91
|
+
* its element, a journey the page it starts on. Whole, and how they stand, from `plitzi_test { action: 'list' }`.
|
|
92
|
+
*/
|
|
93
|
+
var testsOf = (schema) => {
|
|
94
|
+
const checks = schema.tests?.unit ?? [];
|
|
95
|
+
const journeys = schema.tests?.e2e ?? [];
|
|
96
|
+
if (checks.length + journeys.length === 0) return;
|
|
97
|
+
const past = (kind, count) => count > TESTS_NAMED ? { [`more${kind}`]: count - TESTS_NAMED } : {};
|
|
98
|
+
return {
|
|
99
|
+
elementChecks: checks.slice(0, TESTS_NAMED).map(({ id, title, element }) => ({
|
|
100
|
+
id,
|
|
101
|
+
title,
|
|
102
|
+
element
|
|
103
|
+
})),
|
|
104
|
+
journeys: journeys.slice(0, TESTS_NAMED).map(({ id, title, page }) => ({
|
|
105
|
+
id,
|
|
106
|
+
title,
|
|
107
|
+
page
|
|
108
|
+
})),
|
|
109
|
+
...past("ElementChecks", checks.length),
|
|
110
|
+
...past("Journeys", journeys.length),
|
|
111
|
+
read: "plitzi_test { action: 'list' }"
|
|
112
|
+
};
|
|
113
|
+
};
|
|
72
114
|
var readPrimerResource = (space, env, uri) => {
|
|
73
115
|
if (uri !== primerUri(env)) return;
|
|
74
116
|
const interactionCatalog = buildInteractionCatalog(space.schema);
|
|
117
|
+
const tests = testsOf(space.schema);
|
|
75
118
|
const dataSourceCatalog = buildDataSourceCatalog(space.schema);
|
|
76
119
|
const { bundle, elided } = fit([
|
|
77
120
|
{
|
|
@@ -155,6 +198,8 @@ var readPrimerResource = (space, env, uri) => {
|
|
|
155
198
|
], SPACE_BUDGET);
|
|
156
199
|
return envelope({
|
|
157
200
|
guide: guideQuickstart,
|
|
201
|
+
...space.entitlements ? { plan: planOf(space.entitlements) } : {},
|
|
202
|
+
...tests ? { tests } : {},
|
|
158
203
|
cssProperties,
|
|
159
204
|
cssShorthands,
|
|
160
205
|
...bundle,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { changesUri } from "../helpers/uris.js";
|
|
2
|
-
import { guideText } from "../helpers/guide.js";
|
|
2
|
+
import { guideText } from "../helpers/guide/index.js";
|
|
3
3
|
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
4
4
|
import { envelope, jsonContents } from "./envelope.js";
|
|
5
5
|
import { resourceErrorMessage } from "./canonical.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { registerApps } from "./apps/index.js";
|
|
2
2
|
import { isCallToolResult } from "./helpers/callToolResult.js";
|
|
3
3
|
import { NoSpaceError, ReadOnlyGrantError, emptySpace, emptySpaceMessage, noSpaceErrorCode, readOnlyGrantErrorCode } from "./helpers/space.js";
|
|
4
|
-
import { serverInstructions, widgetsOnlyInstructions } from "./helpers/guide.js";
|
|
4
|
+
import { serverInstructions, widgetsOnlyInstructions } from "./helpers/guide/instructions.js";
|
|
5
5
|
import { createMcpLog } from "./helpers/log.js";
|
|
6
6
|
import { proxyForTool } from "./proxy/config.js";
|
|
7
7
|
import { registerResources } from "./resources/register.js";
|
|
@@ -26,12 +26,17 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
26
26
|
};
|
|
27
27
|
const requireWritableSpaceId = () => {
|
|
28
28
|
const id = requireSpaceId();
|
|
29
|
-
if (!grant?.canWrite) throw new ReadOnlyGrantError();
|
|
29
|
+
if (!grant?.canWrite) throw new ReadOnlyGrantError(grant?.readOnlyReason);
|
|
30
|
+
return id;
|
|
31
|
+
};
|
|
32
|
+
const requireTestableSpaceId = () => {
|
|
33
|
+
const id = requireSpaceId();
|
|
34
|
+
if (!grant?.canWrite && !grant?.canTest) throw new ReadOnlyGrantError(grant?.readOnlyReason);
|
|
30
35
|
return id;
|
|
31
36
|
};
|
|
32
37
|
const loadSpace = async () => {
|
|
33
38
|
const id = requireSpaceId();
|
|
34
|
-
const [schema, style, catalog, connectors, actions, actionTasks, functions, data] = await Promise.all([
|
|
39
|
+
const [schema, style, catalog, connectors, actions, actionTasks, functions, data, entitlements] = await Promise.all([
|
|
35
40
|
adapters.getSchema?.(id, MCP_ENV),
|
|
36
41
|
adapters.getStyle?.(id, MCP_ENV),
|
|
37
42
|
adapters.getComponentCatalog?.(id, MCP_ENV).catch(() => void 0),
|
|
@@ -39,7 +44,8 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
39
44
|
adapters.getActions?.(id).catch(() => void 0),
|
|
40
45
|
adapters.getActionTasks?.(id).catch(() => void 0),
|
|
41
46
|
adapters.getFunctions?.(id).catch(() => void 0),
|
|
42
|
-
adapters.getData?.(id).catch(() => void 0)
|
|
47
|
+
adapters.getData?.(id).catch(() => void 0),
|
|
48
|
+
adapters.getEntitlements?.(id).catch(() => void 0)
|
|
43
49
|
]);
|
|
44
50
|
if (!schema || !style) throw new Error(emptySpaceMessage);
|
|
45
51
|
return {
|
|
@@ -50,10 +56,11 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
50
56
|
actions: actions ?? [],
|
|
51
57
|
actionTasks,
|
|
52
58
|
...functions ? { functions } : {},
|
|
53
|
-
...data ? { data } : {}
|
|
59
|
+
...data ? { data } : {},
|
|
60
|
+
...entitlements ? { entitlements } : {}
|
|
54
61
|
};
|
|
55
62
|
};
|
|
56
|
-
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, saveData, getActivity } = adapters;
|
|
63
|
+
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, runE2eTests, saveData, getActivity } = adapters;
|
|
57
64
|
const write = {
|
|
58
65
|
userId: grant?.userId,
|
|
59
66
|
batch: randomUUID(),
|
|
@@ -67,13 +74,14 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
67
74
|
saveAction: saveAction ? (entry) => saveAction(requireWritableSpaceId(), entry) : void 0,
|
|
68
75
|
deleteAction: deleteAction ? (id) => deleteAction(requireWritableSpaceId(), id) : void 0,
|
|
69
76
|
saveFunctions: saveFunctions ? (files, base) => saveFunctions(requireWritableSpaceId(), files, base, write) : void 0,
|
|
70
|
-
saveData: saveData ? (files, base) => saveData(requireWritableSpaceId(), files, base, write) : void 0
|
|
77
|
+
saveData: saveData ? (files, base) => saveData(requireWritableSpaceId(), files, base, write) : void 0,
|
|
78
|
+
tests: saveSchema ? (schema) => saveSchema(requireTestableSpaceId(), MCP_ENV, schema, write) : void 0
|
|
71
79
|
};
|
|
72
80
|
let spacePromise;
|
|
73
81
|
const getSpace = () => spacePromise ??= loadSpace();
|
|
74
82
|
const server = new McpServer({
|
|
75
83
|
name: "plitzi-mcp",
|
|
76
|
-
version: "0.
|
|
84
|
+
version: "0.39.0"
|
|
77
85
|
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
78
86
|
const { getChanges } = adapters;
|
|
79
87
|
registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
|
|
@@ -90,6 +98,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
90
98
|
screenshot,
|
|
91
99
|
proxy: proxyForTool(proxy, tool.name),
|
|
92
100
|
...tryFunction ? { tryFunction: (task, params) => tryFunction(requireWritableSpaceId(), task, params, write) } : {},
|
|
101
|
+
...runE2eTests ? { runE2eTests: (ids) => runE2eTests(requireTestableSpaceId(), ids) } : {},
|
|
93
102
|
...getActivity ? { activity: (query) => getActivity(requireSpaceId(), query, {
|
|
94
103
|
userId: grant?.userId,
|
|
95
104
|
origin: "mcp"
|
|
@@ -255,6 +255,7 @@ export declare const applyShape: {
|
|
|
255
255
|
sessionStorage: "sessionStorage";
|
|
256
256
|
}>>;
|
|
257
257
|
transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
|
+
keptState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
259
|
paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
259
260
|
userProvider: z.ZodOptional<z.ZodString>;
|
|
260
261
|
tokenStorage: z.ZodOptional<z.ZodEnum<{
|
|
@@ -278,6 +279,18 @@ export declare const applyShape: {
|
|
|
278
279
|
strict: "strict";
|
|
279
280
|
}>>;
|
|
280
281
|
sessionRevalidateSeconds: z.ZodOptional<z.ZodNumber>;
|
|
282
|
+
siteName: z.ZodOptional<z.ZodString>;
|
|
283
|
+
language: z.ZodOptional<z.ZodString>;
|
|
284
|
+
favicon: z.ZodOptional<z.ZodString>;
|
|
285
|
+
shareImage: z.ZodOptional<z.ZodString>;
|
|
286
|
+
themeColor: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
287
|
+
light: z.ZodOptional<z.ZodString>;
|
|
288
|
+
dark: z.ZodOptional<z.ZodString>;
|
|
289
|
+
}, z.core.$strip>]>>;
|
|
290
|
+
robotsTxt: z.ZodOptional<z.ZodString>;
|
|
291
|
+
blockAiCrawlers: z.ZodOptional<z.ZodBoolean>;
|
|
292
|
+
viewTransitions: z.ZodOptional<z.ZodBoolean>;
|
|
293
|
+
withheldPage: z.ZodOptional<z.ZodString>;
|
|
281
294
|
channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
282
295
|
access: z.ZodObject<{
|
|
283
296
|
mode: z.ZodEnum<{
|
|
@@ -1626,6 +1639,9 @@ export declare const applyShape: {
|
|
|
1626
1639
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
1627
1640
|
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
1628
1641
|
label: z.ZodOptional<z.ZodString>;
|
|
1642
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
1643
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
1644
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
1629
1645
|
}, z.core.$strip>>>;
|
|
1630
1646
|
nodes: z.ZodArray<z.ZodObject<{
|
|
1631
1647
|
id: z.ZodString;
|
|
@@ -1665,6 +1681,9 @@ export declare const applyShape: {
|
|
|
1665
1681
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
1666
1682
|
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
1667
1683
|
label: z.ZodOptional<z.ZodString>;
|
|
1684
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
1685
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
1686
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
1668
1687
|
}, z.core.$strip>>>>;
|
|
1669
1688
|
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1670
1689
|
id: z.ZodString;
|
|
@@ -8,6 +8,7 @@ import { lookTool } from "./look.js";
|
|
|
8
8
|
import { read, readShape, readTool } from "./read.js";
|
|
9
9
|
import { renderTool } from "./render.js";
|
|
10
10
|
import { search, searchShape, searchTool } from "./search.js";
|
|
11
|
+
import { testTool } from "./test.js";
|
|
11
12
|
import { tryFunctionTool } from "./tryFunction.js";
|
|
12
13
|
//#region src/modules/mcp/tools/index.ts
|
|
13
14
|
/** The MCP tool registry — the single source the server registers from. Adding a tool is: create its file with a
|
|
@@ -25,6 +26,7 @@ var tools = [
|
|
|
25
26
|
renderTool,
|
|
26
27
|
lookTool,
|
|
27
28
|
tryFunctionTool,
|
|
29
|
+
testTool,
|
|
28
30
|
activityTool
|
|
29
31
|
];
|
|
30
32
|
//#endregion
|
|
@@ -45,6 +45,9 @@ export declare const actionField: z.ZodObject<{
|
|
|
45
45
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
46
46
|
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
47
47
|
label: z.ZodOptional<z.ZodString>;
|
|
48
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
48
51
|
}, z.core.$strip>;
|
|
49
52
|
export declare const actionNode: z.ZodObject<{
|
|
50
53
|
id: z.ZodString;
|
|
@@ -49,8 +49,11 @@ var actionField = z.object({
|
|
|
49
49
|
z.number(),
|
|
50
50
|
z.boolean()
|
|
51
51
|
]).optional(),
|
|
52
|
-
label: z.string().optional()
|
|
53
|
-
|
|
52
|
+
label: z.string().optional(),
|
|
53
|
+
maxLength: z.number().optional(),
|
|
54
|
+
min: z.number().optional(),
|
|
55
|
+
max: z.number().optional()
|
|
56
|
+
}).describe("One typed value; a text past maxLength, a number outside min/max is refused");
|
|
54
57
|
var actionNode = z.object({
|
|
55
58
|
id: z.string(),
|
|
56
59
|
title: z.string(),
|
|
@@ -20,6 +20,9 @@ export declare const actionOps: {
|
|
|
20
20
|
required: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
21
21
|
defaultValue: import('zod').ZodOptional<import('zod').ZodUnion<readonly [import('zod').ZodString, import('zod').ZodNumber, import('zod').ZodBoolean]>>;
|
|
22
22
|
label: import('zod').ZodOptional<import('zod').ZodString>;
|
|
23
|
+
maxLength: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
24
|
+
min: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
25
|
+
max: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
23
26
|
}, import('zod/v4/core').$strip>>>;
|
|
24
27
|
nodes: import('zod').ZodArray<import('zod').ZodObject<{
|
|
25
28
|
id: import('zod').ZodString;
|
|
@@ -60,6 +63,9 @@ export declare const actionOps: {
|
|
|
60
63
|
required: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
61
64
|
defaultValue: import('zod').ZodOptional<import('zod').ZodUnion<readonly [import('zod').ZodString, import('zod').ZodNumber, import('zod').ZodBoolean]>>;
|
|
62
65
|
label: import('zod').ZodOptional<import('zod').ZodString>;
|
|
66
|
+
maxLength: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
67
|
+
min: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
68
|
+
max: import('zod').ZodOptional<import('zod').ZodNumber>;
|
|
63
69
|
}, import('zod/v4/core').$strip>>>>;
|
|
64
70
|
nodes: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodObject<{
|
|
65
71
|
id: import('zod').ZodString;
|
|
@@ -18,6 +18,9 @@ export declare const patchActionOp: z.ZodObject<{
|
|
|
18
18
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
20
20
|
label: z.ZodOptional<z.ZodString>;
|
|
21
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
21
24
|
}, z.core.$strip>>>>;
|
|
22
25
|
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
23
26
|
id: z.ZodString;
|
|
@@ -19,6 +19,9 @@ export declare const upsertActionOp: z.ZodObject<{
|
|
|
19
19
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
20
20
|
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
21
21
|
label: z.ZodOptional<z.ZodString>;
|
|
22
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
22
25
|
}, z.core.$strip>>>;
|
|
23
26
|
nodes: z.ZodArray<z.ZodObject<{
|
|
24
27
|
id: z.ZodString;
|