@plitzi/sdk-mcp 0.38.23 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +180 -1
  2. package/dist/createServer.js +1 -0
  3. package/dist/modules/mcp/catalogs/index.d.ts +1 -1
  4. package/dist/modules/mcp/catalogs/index.js +2 -2
  5. package/dist/modules/mcp/catalogs/pluginCatalog.js +5 -1
  6. package/dist/modules/mcp/handler.d.ts +3 -1
  7. package/dist/modules/mcp/handler.js +32 -2
  8. package/dist/modules/mcp/helpers/guide/index.d.ts +3 -0
  9. package/dist/modules/mcp/helpers/guide/index.js +19 -0
  10. package/dist/modules/mcp/helpers/{guide.d.ts → guide/instructions.d.ts} +0 -1
  11. package/dist/modules/mcp/helpers/guide/instructions.js +106 -0
  12. package/dist/modules/mcp/helpers/guide/logic.d.ts +2 -0
  13. package/dist/modules/mcp/helpers/guide/logic.js +166 -0
  14. package/dist/modules/mcp/helpers/guide/practice.d.ts +2 -0
  15. package/dist/modules/mcp/helpers/guide/practice.js +123 -0
  16. package/dist/modules/mcp/helpers/guide/reference.d.ts +2 -0
  17. package/dist/modules/mcp/helpers/guide/reference.js +249 -0
  18. package/dist/modules/mcp/helpers/guide/server.d.ts +2 -0
  19. package/dist/modules/mcp/helpers/guide/server.js +252 -0
  20. package/dist/modules/mcp/helpers/guide/structure.d.ts +2 -0
  21. package/dist/modules/mcp/helpers/guide/structure.js +187 -0
  22. package/dist/modules/mcp/helpers/guide/styling.d.ts +2 -0
  23. package/dist/modules/mcp/helpers/guide/styling.js +118 -0
  24. package/dist/modules/mcp/helpers/guide/values.d.ts +2 -0
  25. package/dist/modules/mcp/helpers/guide/values.js +6 -0
  26. package/dist/modules/mcp/helpers/space.d.ts +5 -2
  27. package/dist/modules/mcp/helpers/space.js +5 -4
  28. package/dist/modules/mcp/resources/core.js +1 -1
  29. package/dist/modules/mcp/resources/index.d.ts +1 -1
  30. package/dist/modules/mcp/resources/primer.d.ts +0 -11
  31. package/dist/modules/mcp/resources/primer.js +46 -1
  32. package/dist/modules/mcp/resources/register.js +1 -1
  33. package/dist/modules/mcp/server.js +17 -8
  34. package/dist/modules/mcp/tools/apply/index.d.ts +19 -0
  35. package/dist/modules/mcp/tools/index.js +2 -0
  36. package/dist/modules/mcp/tools/operations/actions/document.d.ts +3 -0
  37. package/dist/modules/mcp/tools/operations/actions/document.js +5 -2
  38. package/dist/modules/mcp/tools/operations/actions/index.d.ts +6 -0
  39. package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +3 -0
  40. package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +3 -0
  41. package/dist/modules/mcp/tools/operations/index.d.ts +64 -0
  42. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +13 -0
  43. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +13 -0
  44. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +25 -1
  45. package/dist/modules/mcp/tools/render.d.ts +13 -0
  46. package/dist/modules/mcp/tools/renderWidget.d.ts +13 -0
  47. package/dist/modules/mcp/tools/shared/lintDraft.js +5 -0
  48. package/dist/modules/mcp/tools/shared/tool.d.ts +6 -0
  49. package/dist/modules/mcp/tools/shared/validator/connectors.js +0 -1
  50. package/dist/modules/mcp/tools/shared/validator/css.js +6 -1
  51. package/dist/modules/mcp/tools/test.d.ts +23 -0
  52. package/dist/modules/mcp/tools/test.js +85 -0
  53. package/dist/modules/mcp/types/aiSchema.d.ts +2 -0
  54. package/dist/modules/mcp/types/previewTypes.d.ts +3 -2
  55. package/dist/modules/mcp/types/toolTypes.d.ts +5 -0
  56. package/dist/preview/createPreview.js +4 -2
  57. package/package.json +8 -8
  58. package/dist/modules/mcp/helpers/guide.js +0 -1138
package/CHANGELOG.md CHANGED
@@ -1,5 +1,184 @@
1
1
  # @plitzi/sdk-mcp
2
2
 
3
+ ## 0.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 587c35b: A team of agents on one project (`plitzi run`, `plitzi task`), the page tools those agents measure with, tests kept in
8
+ the space, and what authoring and the elements learnt from the runs. Each command and option is in the CLI's README;
9
+ how the runs work, in `docs/en/agent-runs.md`.
10
+
11
+ ## To do when you upgrade
12
+ - **Node 24.** `engines` is `^24.22.1 || >=26.12.1`; Node 22 is no longer supported (`plitzi doctor` says it,
13
+ `doctor --fix` raises an older project's `engines`).
14
+ - **`createServer({ outbound: { privateOrigins } })` replaces `allowPrivatePluginHosts`:** a space's requests reach no
15
+ private address but the origins named (`privateOrigins: ['http://localhost:9000']`).
16
+ - **Job queues from 0.38.20 or before are recreated, not upgraded:** `createMongoJobQueue` / `createMysqlJobQueue` empty
17
+ or drop the old `action_jobs` / `action_kv` and make them again; `mysqlJobSchemaUpgrades` is gone.
18
+ - **`PLITZI_KV_FILE` is `PLITZI_STATE_DIR`**, a folder holding the server's `kv` and job queue.
19
+ - **A social provider's `fetchProfile` takes `{ accessToken, idToken, nonce }`**, and `createSocialAuth(...).start` is
20
+ async.
21
+ - **A `DraftStore` of a deployment's own keeps `inspected`** beside `reusable`, or a test session renders without the
22
+ state bridge.
23
+ - **`navigation.navigate(url, { external, replace })`** takes an object where it took `navigate(url, true)`.
24
+ - **`window.__plitzi.setSource` / `setAttribute` may answer `{ refused }`**: read it before treating the answer as written.
25
+ - **Renamed:** `stepText` → `e2eStepText` (a run's `said` is the step in words); `OverQuotaNotice` → `QuotaNotice` and
26
+ its classes `plitzi-quota-notice…`; `sightOf` / `sightText` come from `@plitzi/sdk-shared/devTools/sight`.
27
+ - **`SchemaVariables` and `StyleVariables` draw no add button of their own:** the holder passes `adding`, `onAddingEnd`
28
+ and optionally `empty`.
29
+ - **A page handed to `runE2eTest`** has `selectOption`, `position` in `click`/`hover` and `evaluate(fn, arg)`, as a
30
+ Playwright locator: a hand-written page adds them.
31
+ - **Journey steps play as the page commands do:** `scroll` with `dx`/`dy` scrolls the element's content, `waitFor`
32
+ waits 10 s, `type` replaces a field's value.
33
+ - **Authoring refuses more:** two flows of one element naming a step alike (`step-duplicate`), `visible` written as an
34
+ expression (`visible-expression`), a step condition naming a source by id alone (`condition-short-source`).
35
+ `navbar` / `navbarItem` are no longer read by `specFromSpace`.
36
+ - **`/robots.txt` ends naming its sitemap** unless the space's own text does.
37
+ - **The CLI's part of a project is `.plitzi/`** (it was split with `plitzi/`): `plitzi doctor --fix` moves it, and a
38
+ tsconfig names `.plitzi/**/*`.
39
+ - **`plitzi upgrade`** brings the new scripts (`start:preview`, the visual suite's server on 8400, `test`), the ignores
40
+ for `.plitzi/plitzi-reports/` and the skills. `test` runs the project's own tests, so red tests now fail
41
+ `plitzi verify` and a run's checks.
42
+ - **Reports to Plitzi live in `.plitzi/plitzi-reports/`**, committed: a run's in `runs/<run>/`, an agent's in
43
+ `agents/<date>/`. The old files are read no more.
44
+ - **The CLI's surface is smaller — one command for each thing.** Old names and flags are refused naming the new one;
45
+ `plitzi upgrade skills --write` updates the agents' skills. The main moves: `run plan` / `run rehearse` →
46
+ `run open --dry-run [--rehearse]`; `run extend` → `run open <stage>`; `run purge` → `run abort`; `task take` →
47
+ `task next <task>`; `task ask` / `block` / `note` → `task tell --ask | --blocked | --handoff`; `task wait` / `release`
48
+ → `task claim --wait | --release`; `task request` → `task propose --file`; `task check --before | --mutate` →
49
+ `task prove`; `run feedback` → `run report --plitzi`; `functions pull|push` → `space pull|push functions`;
50
+ `runtime push` → `space push runtime`; `page shot --live` / `--clip` → `--fresh` / `--within`; `PLITZI_TASK_TOKEN` →
51
+ `PLITZI_TOKEN`.
52
+ - **Research and reviews are cards on one board:** `task spike` and the separate UI review are gone; a card's `review`
53
+ names its roles in order. Runs opened before keep working.
54
+ - **Page commands:** `page check --expect` fails only on what it expects; every page command reads at 900 px tall
55
+ (`--height`); a page that sends a guest away is read signed in as the project's account (`--as`, `--guest`).
56
+ - **`create --from`** names page files by the page's name; a space's functions are pushed without their tests.
57
+
58
+ ## A space's tests (`@plitzi/sdk-authoring`, `@plitzi/sdk-shared`, `@plitzi/plitzi-builder`, `@plitzi/sdk-mcp`)
59
+ - **Tests are part of the space's document** (`Schema.tests`): unit tests (element checks) and journeys (what a visitor
60
+ does), authored in code, edited in the builder's Tests area, played on the canvas or the server. See
61
+ `docs/en/space-tests.md`.
62
+ - **Journeys play signed in as test accounts** (`tests.accounts`), carry tags, can be held and stopped
63
+ (`runE2eTest`'s `beforeStep`), and hold element checks (`e2e.expectCheck`).
64
+ - **`plitzi test [id…]`** runs a project's tests; **`plitzi_test`** lets an agent run them over the MCP. What a plan
65
+ allows (`journeysPerSpace`, `serverRunsPerMonth`) is in its entitlements; a `canTest` grant writes tests alone.
66
+
67
+ ## Several agents on one project (`@plitzi/cli`)
68
+ - **A run is a kanban:** a lead plans, reviews and closes; developers, testers, designers and scouts take cards with
69
+ `task next`, each in its own copy of the project; every card is reviewed by the roles it names, step by step.
70
+ Nothing reaches the project until a person applies the run (`run finish --apply`).
71
+ - **Files are owned by imports:** one agent per file, shared files taken by turns or changed by agreement
72
+ (`task propose`), merged line by line, checked on the whole result.
73
+ - **The run keeps itself going:** a keeper starts the agents work is waiting for, and holds
74
+ starts after the harness's limit or repeated quick exits until the lead allows them (`run hold`, `run allow`).
75
+ - **`run monitor`:** the run live in a terminal — board, flow, agents, spend, activity — with an emergency panel (`!`)
76
+ to pause, resume, hold or allow agents.
77
+ - **A change mid-run says what it reaches:** `run open <stage> --dry-run` and `run amend --dry-run` name the approved
78
+ tasks, tasks at work and tests each change touches, read off the import graph.
79
+ - **Reviews see what goes in:** a review taken says whether the task merges with the run's newer work and, if not, the
80
+ failing lines; `task show <file> --merged` and `task look --merged` read and serve the merge;
81
+ `task look --alone <element> --with '{…}'` draws a component or plugin no page places yet. A step's time stops while
82
+ its reviewer proves or looks.
83
+ - **Proofs:** `task prove --before` (what each acceptance line proves against the run before the task) and
84
+ `--mutate` (whether a task's tests catch a broken change, with a control run).
85
+ - **The finish:** `run finish` checks the whole result and stops at the first failing line; `--every-line` reports
86
+ them all. The run then leaves its reports in `.plitzi/plitzi-reports/runs/<run>/`.
87
+ - **A report to Plitzi holds nothing of the person or the project:** a run's `feedback.md` writes over names, emails,
88
+ addresses, IPs, the project's files, tasks and elements, leaves out what was said of the project alone, and lists
89
+ quoted passages for the person to read before sending. `plitzi feedback` carries no project name, asks the developer
90
+ before anything of the project goes in, and `plitzi feedback --check <file>` names what a filled report still holds.
91
+
92
+ ## Page tools (`@plitzi/cli`, `@plitzi/sdk-authoring`)
93
+ - **`page measure`** reads what an element draws (`--only drawn`, `box-*`, `attr:<name>`, `accessible-name`,
94
+ `scroll-*`, custom properties) and holds bounds and positions (`--expect "width<=44px"`, `"a.bottom + 8 <= b.top"`).
95
+ - **`page play`** plays steps — `drag … hold`, `scroll page 1500`, `click <el> 30%,60%` — reads what is drawn, not
96
+ what is in the DOM, and `--motion` plays animations moving. A press is made once and waits for the page to take it.
97
+ - **`page check`** says what a visitor cannot reach, text cut or spilling, canvases left blank, the server's error page
98
+ when the space does not author, and holds a text whole (`=`) or in part (`~`).
99
+ - **`page shot`** waits for canvases, pictures hovers (`--hover`, `--frames`) and parts (`--within`), and says what it
100
+ could not picture.
101
+ - **Every page command reads a page as one visitor from the same flags** (`--as`, `--guest`, `--width`, `--height`,
102
+ `--fresh`), with a browser driver of the CLI's own.
103
+
104
+ ## Authoring (`@plitzi/sdk-authoring`)
105
+ - **New checks:** a server provider the page server cannot read (`server-query-unresolved`) or that reads browser state
106
+ (`server-when-unknown`), an action without `runtime: 'server'` (`server-source-in-browser`), class overrides,
107
+ messages arriving while a flow runs, unused plugins.
108
+ - **New authoring:** `focus('field')`, a factory for every trigger, the scroll family's sides, `pagesIn(...)` to
109
+ register pages by folder, channel topics with a choice, a plugin's imported stylesheets read for its tokens.
110
+ - **An element drawn alone:** a server started with `PLITZI_PREVIEW_FILE` gets a page for one element at
111
+ `/plitzi-preview` (`withPreview`, `SpacePreviewError`) — what `task look --alone` uses.
112
+
113
+ ## Elements and the SDK (`@plitzi/sdk-elements`, `@plitzi/plitzi-sdk`, `@plitzi/sdk-shared`)
114
+ - **Navigation:** `navigate` can replace the address, and a navigation inside the site leaves the scroll as a page
115
+ load would.
116
+ - **Providers:** a `when` holds the same in the browser and on the page server; a server provider can read another
117
+ site's address while the page is built.
118
+ - **Plans and roles in the contract:** entitlements (`TSpaceEntitlements`), the space role (`TSpaceAccess`), the quota
119
+ warning at 80% (`render.quotaNear`) and the "Made with Plitzi" badge (`PlitziBadge`).
120
+ - **Fixes:** a binding's `sourceTo` is the previous value; an element with no tag and no `visible` draws nothing;
121
+ placeholder words never reach a page; notifications stay open for a visitor who asked for less motion.
122
+
123
+ ## Server (`@plitzi/sdk-server`, `@plitzi/sdk-auth`, `@plitzi/sdk-mcp`)
124
+ - **`/sitemap.xml`** for every space, and `/robots.txt` naming it.
125
+ - **Accounts:** terms accepted at sign-up (MySQL schema version 7), single sign-on with any OpenID Connect issuer
126
+ (`createOidcProvider`), providers resolved at run time, a password that may not sign in, `/auth/continue` with a step
127
+ of the deployment's own, a signed-out visitor never signed back in by a stale answer.
128
+ - **Policy adapters:** metering can hold a page back (503), decide the badge and `noindex`; the MCP can cap tool calls
129
+ and names the space's plan; realtime admits spaces per deployment.
130
+ - **Dev server:** a removed plugin folder is unregistered (`PluginRegistry.unregister`), and a space that does not
131
+ author is said whole, with no stack.
132
+
133
+ ## The builder (`@plitzi/plitzi-builder`)
134
+ - **A Tests area** with journeys played beside the page at the journey's device, and element checks.
135
+ - **One way to build a panel**, a header grouped by what its controls do, and the layout's mask dimming only what the
136
+ layout draws.
137
+ - **Plans and roles shown:** what the role allows (`useSpaceAccess`), what the plan leaves out shown locked, the plan
138
+ and its spend in the header; pages left out of the sitemap marked.
139
+
140
+ ## Dev tools (`@plitzi/sdk-dev-tools`)
141
+ - **`element(id).visible` is what a visitor sees** (`sightOf`), with why not; `element(id).resolved` says what each
142
+ binding gave; a refused server action is a `refused` step.
143
+ - **Report what you see** in the Run tab of a run's preview, and the panel docks at the bottom under 900 px.
144
+
145
+ ## The workspace
146
+ - **No file past 600 lines of code** (`max-lines`), and ESLint's `quotes` rule is gone — Prettier writes them.
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies [587c35b]
151
+ - @plitzi/plitzi-sdk@0.39.0
152
+ - @plitzi/sdk-server@0.39.0
153
+ - @plitzi/sdk-authoring@0.39.0
154
+ - @plitzi/sdk-schema@0.39.0
155
+ - @plitzi/sdk-shared@0.39.0
156
+ - @plitzi/sdk-style@0.39.0
157
+
158
+ ## 0.38.24
159
+
160
+ ### Patch Changes
161
+
162
+ - 5858b9f: ## Server
163
+
164
+ - **`ctx.oauth.callbackUrl()`** (`@plitzi/sdk-server`) — PZ-161. The address providers send a visitor back to, as this
165
+ run's `connect` hands it to them: for a page that shows whoever sets up the app what to register, instead of
166
+ rebuilding the platform's rule. Refused in a run no visitor's request started when the deployment fixed no
167
+ `functions.oauth.callbackOrigin`.
168
+ - **In production the project's server fixes no OAuth callback** (`@plitzi/sdk-server`). 0.38.23's loopback default
169
+ applied wherever `PUBLIC_URL` was not HTTPS — a container behind a proxy sent providers to its own
170
+ `http://127.0.0.1:8080`. Now loopback is the default while developing only; in production the callback is on the
171
+ address each visitor's request came on (the site's domain, from `Host` and `X-Forwarded-Proto`), and the server says
172
+ to register that domain's `/fn/oauth/callback`.
173
+
174
+ - Updated dependencies [5858b9f]
175
+ - @plitzi/plitzi-sdk@0.38.24
176
+ - @plitzi/sdk-server@0.38.24
177
+ - @plitzi/sdk-authoring@0.38.24
178
+ - @plitzi/sdk-schema@0.38.24
179
+ - @plitzi/sdk-shared@0.38.24
180
+ - @plitzi/sdk-style@0.38.24
181
+
3
182
  ## 0.38.23
4
183
 
5
184
  ### Patch Changes
@@ -3813,7 +3992,7 @@ author`, `plitzi_validate`/`plitzi_apply`, `plitzi explain` and the builder's pr
3813
3992
  - **Devices are listed by device, not by session.** `GET /devices/sessions` groups sessions by what they were created
3814
3993
  from and answers this device apart; a browser that signed in forty times is one row saying "40 sessions". The list
3815
3994
  had shipped and drawn every session — 1,218 for one account a test suite signs in as — inside a box that scrolled.
3816
- - **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on carlos-mbp`,
3995
+ - **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on dev-laptop`,
3817
3996
  `Plitzi Desktop on studio`), a browser and its system, an automated client (Playwright, headless Chrome) — never a
3818
3997
  raw user agent. Sessions record their address and **when they were last used** (at most every five minutes, on the
3819
3998
  lookup a request already makes). A sign-in deletes the account's dead sessions.
@@ -3,6 +3,7 @@ import { createHttpServer, makeHandler } from "@plitzi/sdk-server/kernel";
3
3
  //#region src/createServer.ts
4
4
  var noPlugins = {
5
5
  register: () => void 0,
6
+ unregister: () => void 0,
6
7
  invalidate: () => Promise.resolve()
7
8
  };
8
9
  /** The server this package makes: the lean MCP pipeline over the bare context — no render template, caches
@@ -1,4 +1,4 @@
1
- export { BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_UTILITIES, applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties, cssShorthands, elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, reconcileParams, suggestCssProperty, transformerCatalog } from '@plitzi/sdk-authoring';
1
+ export { BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_UTILITIES, ambiguousShorthands, applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties, cssShorthands, elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, reconcileParams, suggestCssProperty, transformerCatalog } from '@plitzi/sdk-authoring';
2
2
  export type { BuiltinParam, CssPatch, ElementSemantics, ParamSpec, TransformerInfo } from '@plitzi/sdk-authoring';
3
3
  export * from './observed';
4
4
  export * from './registry';
@@ -1,4 +1,4 @@
1
1
  import { buildDataSourceCatalog, buildInteractionCatalog, observedDataSources, observedInteractionActions } from "./observed.js";
2
2
  import { buildTypeRegistry } from "./registry.js";
3
- import { applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties as cssProperties$1, cssShorthands, elementCatalog as elementCatalog$1, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, reconcileParams, suggestCssProperty } from "@plitzi/sdk-authoring";
4
- export { applyBuiltinCallback, applyElementCallback, applyUtility, buildDataSourceCatalog, buildInteractionCatalog, buildTypeRegistry, cssProperties$1 as cssProperties, cssShorthands, elementCatalog$1 as elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, observedDataSources, observedInteractionActions, reconcileParams, suggestCssProperty };
3
+ import { ambiguousShorthands, applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties as cssProperties$1, cssShorthands, elementCatalog as elementCatalog$1, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, reconcileParams, suggestCssProperty } from "@plitzi/sdk-authoring";
4
+ export { ambiguousShorthands, applyBuiltinCallback, applyElementCallback, applyUtility, buildDataSourceCatalog, buildInteractionCatalog, buildTypeRegistry, cssProperties$1 as cssProperties, cssShorthands, elementCatalog$1 as elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getUtility, hiddenParams, isCssProperty, observedDataSources, observedInteractionActions, reconcileParams, suggestCssProperty };
@@ -56,14 +56,18 @@ var entryFromManifest = (type, manifest) => {
56
56
  const initialStateTargets = pathsOf(bindingsAllowed?.initialState);
57
57
  const pluginBase = (pluginSchema?.defaultStyle)?.style?.base?.default;
58
58
  const defaultStyle = stringDeclarations(pluginBase);
59
+ const attributes = keysOf(pluginSchema?.attributes);
60
+ const declaredContent = pluginSchema?.contentAttributes;
61
+ const contentAttributes = Array.isArray(declaredContent) ? declaredContent.filter((name) => typeof name === "string" && attributes.includes(name)) : [];
59
62
  return {
60
63
  label,
61
64
  description,
62
65
  category: strOrUndefined(manifest.definition.category),
63
66
  custom: true,
64
- attributes: keysOf(pluginSchema?.attributes),
67
+ attributes,
65
68
  styleSelectors: keysOf(elementDef?.styleSelectors),
66
69
  ...defaultStyle ? { defaultStyle } : {},
70
+ ...contentAttributes.length > 0 ? { contentAttributes } : {},
67
71
  ...attributesTargets || initialStateTargets ? { bindingsAllowed: {
68
72
  attributes: attributesTargets,
69
73
  initialState: initialStateTargets
@@ -17,6 +17,8 @@ export type McpRequestOptions = {
17
17
  proxy?: ResourceProxy;
18
18
  };
19
19
  export declare const readMcpBody: (req: IncomingMessage) => Promise<unknown>;
20
- export declare const serveMcp: (raw: IncomingMessage, res: ServerResponse, server: McpServer) => Promise<string | undefined>;
20
+ export declare const serveMcp: (raw: IncomingMessage, res: ServerResponse, server: McpServer, admitToolCalls?: (calls: number) => Promise<{
21
+ error: string;
22
+ } | undefined>) => Promise<string | undefined>;
21
23
  export declare const handleMcp: (raw: IncomingMessage, res: ServerResponse, req: SSRRequest, adapters: SSRAdapters, options?: McpRequestOptions) => Promise<string | undefined>;
22
24
  export { createMcpServer };
@@ -19,7 +19,31 @@ var operationOf = (body) => {
19
19
  if (Array.isArray(body)) return `batch(${body.length})`;
20
20
  if (typeof body === "object" && body !== null && "method" in body && typeof body.method === "string") return body.method;
21
21
  };
22
- var serveMcp = async (raw, res, server) => {
22
+ var messagesOf = (body) => (Array.isArray(body) ? body : [body]).filter((message) => typeof message === "object" && message !== null);
23
+ var toolCallsIn = (body) => messagesOf(body).filter((message) => message.method === "tools/call").length;
24
+ /**
25
+ * A refused request's answer: every call it made reads the refusal as its result (`isError`), which is what an agent
26
+ * shows and acts on — a transport error would read as the server being down.
27
+ */
28
+ var refuseToolCalls = (res, body, error) => {
29
+ const answers = messagesOf(body).filter((message) => message.id !== void 0).map((message) => ({
30
+ jsonrpc: "2.0",
31
+ id: message.id,
32
+ ...message.method === "tools/call" ? { result: {
33
+ content: [{
34
+ type: "text",
35
+ text: error
36
+ }],
37
+ isError: true
38
+ } } : { error: {
39
+ code: -32e3,
40
+ message: error
41
+ } }
42
+ }));
43
+ res.writeHead(200, { "Content-Type": "application/json" });
44
+ res.end(JSON.stringify(Array.isArray(body) ? answers : answers[0] ?? null));
45
+ };
46
+ var serveMcp = async (raw, res, server, admitToolCalls) => {
23
47
  res.setHeader("Access-Control-Allow-Origin", "*");
24
48
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
25
49
  res.setHeader("Access-Control-Allow-Headers", "*");
@@ -68,6 +92,12 @@ var serveMcp = async (raw, res, server) => {
68
92
  res.end(JSON.stringify({ error: "Invalid JSON body" }));
69
93
  return;
70
94
  }
95
+ const calls = toolCallsIn(body);
96
+ const refusal = calls > 0 ? await admitToolCalls?.(calls) : void 0;
97
+ if (refusal) {
98
+ refuseToolCalls(res, body, refusal.error);
99
+ return operationOf(body);
100
+ }
71
101
  await transport.handleRequest(raw, res, body);
72
102
  return operationOf(body);
73
103
  } finally {
@@ -78,6 +108,6 @@ var handleMcp = async (raw, res, req, adapters, options = {}) => serveMcp(raw, r
78
108
  adapters,
79
109
  getGrant: () => adapters.getGrant?.(req) ?? Promise.resolve(void 0),
80
110
  ...options
81
- }));
111
+ }), adapters.admitToolCalls ? (calls) => adapters.admitToolCalls?.(req, calls) ?? Promise.resolve(void 0) : void 0);
82
112
  //#endregion
83
113
  export { createMcpServer, handleMcp, readMcpBody, serveMcp };
@@ -0,0 +1,3 @@
1
+ export { guideQuickstart, serverInstructions, widgetsOnlyInstructions } from './instructions';
2
+ /** The full reference, `plitzi://guide`: its sections in order, each a module. */
3
+ export declare const guideText: string;
@@ -0,0 +1,19 @@
1
+ import { logicGuide } from "./logic.js";
2
+ import { practiceGuide } from "./practice.js";
3
+ import { referenceGuide } from "./reference.js";
4
+ import { serverGuide } from "./server.js";
5
+ import { structureGuide } from "./structure.js";
6
+ import { stylingGuide } from "./styling.js";
7
+ import { guideQuickstart, serverInstructions, widgetsOnlyInstructions } from "./instructions.js";
8
+ //#region src/modules/mcp/helpers/guide/index.ts
9
+ /** The full reference, `plitzi://guide`: its sections in order, each a module. */
10
+ var guideText = [
11
+ referenceGuide,
12
+ stylingGuide,
13
+ logicGuide,
14
+ serverGuide,
15
+ structureGuide,
16
+ practiceGuide
17
+ ].join("");
18
+ //#endregion
19
+ export { guideQuickstart, guideText, serverInstructions, widgetsOnlyInstructions };
@@ -1,4 +1,3 @@
1
1
  export declare const serverInstructions: string;
2
2
  export declare const widgetsOnlyInstructions: string;
3
3
  export declare const guideQuickstart: string;
4
- export declare const guideText: string;
@@ -0,0 +1,106 @@
1
+ import { GLOBALS } from "./values.js";
2
+ //#region src/modules/mcp/helpers/guide/instructions.ts
3
+ var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles a quickstart of the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Every element has ONE name and it IS its id ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) — the same name is the runtime wiring key, so a provider source is `<type>_<name>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS elements by label/type/attribute and hands you the name to write ops against; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. CMS / API integrations (Strapi, WordPress, Contentful, any REST service) go through a CONNECTOR: a manifest you author declaring the base URL, endpoints and auth template, which the SERVER executes — read plitzi://connector-presets for working ones and plitzi://connectors/{env} for this space’s. You never see or create the credential; the space owner attaches it, and the connector saves without one. An apiContainer reads through it only with runtime:\"server\". Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Build pages people can use without sight: screen readers and browser agents (Claude in Chrome) work a page through its accessibility tree, so every control needs words and clicks go on buttons and links — see Accessibility in plitzi://guide, and plitzi_look (its accessibility outline, the default view) to check. On a space people edit too, plitzi_activity says — and waits for — what they changed since you last looked. What the person asks to change on this space is changed HERE, on the space as Plitzi keeps it — no project. A project is the Plitzi CLI’s (a self-hosted space in code, or one taken out with plitzi create --from and sent back with plitzi space push): an edit here while one is out makes that push refuse until it pulls — tell the person. A job for a team of agents is never several agents on one space here: it is done on a project (plitzi create --from, then plitzi run start) and pushed once. Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
4
+ var widgetsOnlyInstructions = "Plitzi widget server (widgets-only connection). This connection carries NO Plitzi space: nothing can be read or edited in one, and the space tools are not offered here — do not look for them. What it does do is build self-contained UI widgets fully offline, with no backend, account or setup: call plitzi_render to SHOW the user a real rendered layout (card, hero, pricing table, checklist, form, gallery) instead of describing one. Read plitzi://render/guide first — the element/prop table, the style model and a worked example; plitzi://render/types lists every element type you can author (plitzi_read fetches both). To change a widget you already rendered, call plitzi_render again with patch:true and its renderId. If the user wants to edit their real Plitzi space from here, that is a reconnection they make: the integration must be re-authorized and granted a space (the consent screen lists theirs) — you cannot do it from this connection, and no retry will change it.";
5
+ var guideQuickstart = `# Plitzi AI MCP — quickstart
6
+ This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
7
+
8
+ A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch**: the **element schema** (tree of
9
+ pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
10
+ **definition** and attach it via the element's \`style.base\` in the same batch.
11
+
12
+ **Big spaces:** a primer section may arrive as \`{elided:true, bytes, entries, read}\` instead of its contents —
13
+ the space outgrew what one cold-start read can carry. \`read\` is the resource that serves that exact section whole
14
+ (\`plitzi://definitions/{env}\`, \`plitzi://interactions/{env}\`, …). Read the ones your task needs; nothing is
15
+ missing, it is one round-trip away.
16
+
17
+ **Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
18
+ with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
19
+ per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
20
+ \`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
21
+ concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
22
+
23
+ **Names & wiring:** an element has ONE name and it is its id (letters, numbers, hyphens and underscores,
24
+ **starting with a letter — no dots**). It is also the runtime wiring key: a provider's source is
25
+ \`<type>_<name>\`, and interactions target by it. A dot would split that path; an **underscore is fine** — the first
26
+ \`_\` separates the type from the name (element types have none), so \`list_food_item\` reads unambiguously as type
27
+ \`list\`, name \`food_item\`.
28
+
29
+ **Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
30
+ vars. **Write plain CSS** — shorthands (\`border\`, \`padding\`, \`margin\`, \`gap\`, \`overflow\`, \`flex\`, \`background\`,
31
+ \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-row\`/\`grid-column\`, \`place-*\`, \`outline\`, \`columns\`,
32
+ \`list-style\`, \`text-decoration\`) are expanded to their longhands for you, so \`border: 1px solid red\` is stored as
33
+ \`border-top-color\`/\`border-top-width\`/\`border-top-style\`/… That is also how you read them back. Flex layout is
34
+ still \`display: flex\` + \`flex-direction\`/\`align-items\`/…, not a \`flex\` value. Mind a type's \`defaultStyle\`
35
+ (\`text\` is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
36
+
37
+ **Motion:** animate only \`opacity\` and \`transform\` — they stay smooth while the page loads; an animated blur,
38
+ shadow, size, \`top\`/\`left\` or \`background-position\` stutters on every visitor's machine. Good practices in
39
+ \`plitzi://guide\` (Motion).
40
+
41
+ **Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
42
+ A source \`<type>_<name>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
43
+ (the global sources ${GLOBALS} are bindable anywhere). \`apiContainer.mockData\` is builder-only; set a
44
+ real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
45
+ from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
46
+ a QueryBuilder RuleGroup gating the binding.
47
+
48
+ **Fewer elements, same page:** a \`link\` or \`button\` says its words itself — \`content\`, with an icon beside them
49
+ as \`icon\` (\`iconPlacement\` before/after, its class on the \`icon\` slot) — never a \`text\` or \`fontAwesome\` child;
50
+ a text child also ignores the box's colour and hover. Chrome on several pages is a **layout**; the nav item of the page being shown is marked by the
51
+ \`current\` state of its class, not by a copy of the header per page. Sibling rows of data are one \`repeatElement\`; a
52
+ block repeated with other words is a **component** (\`upsertComponent { fromRef }\`). \`plitzi_apply\` (with or
53
+ without \`dryRun\`) answers with **\`suggestions\`** for what the batch could have written shorter, each with the elements
54
+ it saves — never blocking; take them unless the copies are about to diverge.
55
+
56
+ **Interactions** (\`upsertInteractionFlow\`): a \`trigger\` node first, then callbacks/utilities **in order** (links
57
+ computed for you). Node types: \`callback\` (an element's own callback — \`elementId\` is that element), \`globalCallback\`
58
+ (a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
59
+ (category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
60
+ \`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
61
+ **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<name>.item.name }}"\`).
62
+ Steps read the page as it is when they run; a refiring trigger is ignored unless \`whileRunning: "queue"\` (or
63
+ \`"latest"\`: the newest firing stops the running one); keyboard
64
+ shortcuts are the \`onKey\` trigger (\`keys: "shift+f, escape"\`).
65
+
66
+ **CMS / API integrations** (\`upsertConnector\`): a **connector** is a manifest declaring a provider's base URL,
67
+ endpoints, auth template and filter operators, executed by the **server** — so integrating Strapi, WordPress,
68
+ Contentful or any REST API is configuration, not code. Read \`plitzi://connector-presets\` (working manifests + every
69
+ template token) and \`plitzi://connectors/{env}\` (this space's). **You never create or see credentials** — write the
70
+ manifest with \`{{credential.token}}\` and no \`connection.credential\`; it saves, and the space owner attaches the
71
+ secret in the builder. To consume one, an \`apiContainer\` needs **\`runtime: "server"\`** plus \`connector\`,
72
+ \`resource\`, optional \`endpoint\`/\`filters\`/\`limit\`/\`singleRecord\`/\`pagination\`; it then publishes
73
+ \`apiContainer_<name>.records\` (or \`.record\`) \`.pageInfo .isEmpty .hasError\` to its **descendants**. Full worked
74
+ flow — list page, detail page, paging, writes — in \`plitzi://guide\`.
75
+
76
+ **Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
77
+ slugs prepend the path). A \`:name\` segment (\`"posts/:postId"\`) is a route param, readable as \`{{name}}\` and as the
78
+ source \`navigation.routeParams.name\` → build dynamic pages this way. To move between pages **prefer the \`Link\`
79
+ element** (\`mode\` "page"/"internal"/"external"; its words are its \`content\`, and it can wrap any children too) over
80
+ a \`navigate\` interaction.
81
+
82
+ **Feature flags:** what a person switches on (a beta, a rollout) is \`upsertFlag\` plus \`flag: "x"\` / \`"!x"\` on the
83
+ element or page — not \`visible\`. Read anywhere as \`{{ flags.x }}\`.
84
+
85
+ **Accessible by default:** screen readers and browser agents (Claude in Chrome) read the accessibility tree, so every
86
+ button/link needs words (an icon-only button a \`title\`), every field a \`label\` (\`hideLabel: true\` hides it), every
87
+ image an \`alt\` or \`decorative: true\`; clicks go on a \`button\`/\`link\`, never a container; headings step down one
88
+ level at a time. \`plitzi_look\` shows the tree and what has no name.
89
+
90
+ **Everything the space holds is public.** Its pages, variables, attributes, flow params and mock data ship to every
91
+ visitor's browser, and a file on a public bucket of its CDN is served to anyone who has its address. A key, a token or
92
+ data only some visitors may read never goes in any of them: a secret is a credential the owner attaches (a connector, an
93
+ action or a function names it, never carries it), and data for some visitors only comes from a \`runtime: "server"\`
94
+ provider or an action that checks who is asking.
95
+
96
+ **Touched elements must be malformation-free.** Editing an element also checks its CURRENT stored content and BLOCKS
97
+ the save on any \`Pre-existing malformation in element …\` error (a broken transformer, a malformed step, an attribute
98
+ it never reads) — even parts you did not touch. These are NOT from your change (the message says so); fix them in the
99
+ SAME batch and re-apply (the check runs on the result, so the fix unblocks it). \`Pre-existing issue\` warnings advise
100
+ but do not block. A broken tree your batch leaves ANYWHERE (an element orphaned by a delete) blocks it too. Each
101
+ problem leads with its \`[code]\`, and its hint says what to write instead.
102
+
103
+ Read \`plitzi://guide\` before anything above is unclear.
104
+ `;
105
+ //#endregion
106
+ export { guideQuickstart, serverInstructions, widgetsOnlyInstructions };
@@ -0,0 +1,2 @@
1
+ /** What an element reads and does: bindings, interactions, and what is public. */
2
+ export declare const logicGuide: string;