@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +156 -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 -1139
package/CHANGELOG.md CHANGED
@@ -1,5 +1,160 @@
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
+
3
158
  ## 0.38.24
4
159
 
5
160
  ### Patch Changes
@@ -3837,7 +3992,7 @@ author`, `plitzi_validate`/`plitzi_apply`, `plitzi explain` and the builder's pr
3837
3992
  - **Devices are listed by device, not by session.** `GET /devices/sessions` groups sessions by what they were created
3838
3993
  from and answers this device apart; a browser that signed in forty times is one row saying "40 sessions". The list
3839
3994
  had shipped and drawn every session — 1,218 for one account a test suite signs in as — inside a box that scrolled.
3840
- - **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`,
3841
3996
  `Plitzi Desktop on studio`), a browser and its system, an automated client (Playwright, headless Chrome) — never a
3842
3997
  raw user agent. Sessions record their address and **when they were last used** (at most every five minutes, on the
3843
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;
@@ -0,0 +1,166 @@
1
+ import { GLOBALS, OTHER_TRANSFORMERS } from "./values.js";
2
+ //#region src/modules/mcp/helpers/guide/logic.ts
3
+ /** What an element reads and does: bindings, interactions, and what is public. */
4
+ var logicGuide = `## Data bindings
5
+ Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
6
+ by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
7
+ - \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
8
+ - \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
9
+ Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed a
10
+ provider's records into a list element:
11
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
12
+ "binding": { "to": "items", "source": "apiContainer_products.records" } }\`.
13
+
14
+ **What an \`apiContainer\` publishes** depends on where it reads. Through a connector (\`runtime: "server"\`) it is the
15
+ fixed shape under *Connectors* — \`.records\` or \`.record\`, \`.pageInfo\`, … With a browser \`query\` it is the
16
+ response: \`.data\` (the parsed body — an API answering \`{ "items": [...] }\` is read as
17
+ \`apiContainer_<name>.data.items\`) and \`.status\` (the HTTP status) — and a \`"server"\` provider with only a
18
+ \`query\` (a JSON file the deployment serves) answers in that same shape, so moving it to the server changes no
19
+ binding. Fed by a server **action**, it is the action's output at the root (\`apiContainer_<name>.items\`, never
20
+ \`.data.items\`). All add \`.isLoading\` (true while asked again too), \`.isEmpty\`,
21
+ \`.hasError\` and \`.errorMessage\`.
22
+
23
+ **Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
24
+ \`<type>_<name>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
25
+ its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
26
+ to it resolves to nothing at runtime. So to consume \`apiContainer_products.records\`, the bound element must live under
27
+ that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
28
+ (\`list_<name>.item.<field>\`). The global sources — ${GLOBALS} — have no \`<type>_<name>\` head and are
29
+ bindable anywhere. Binding an element to an element source outside its
30
+ provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
31
+ \`plitzi_apply\` treats it as an **error and rejects the batch** — move the element under the
32
+ provider, or bind a source that is in scope.
33
+
34
+ **mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
35
+ builder**; the published runtime fetches real data instead. Never rely on mockData as the production source — give
36
+ the provider a real source: a **connector** with \`runtime: "server"\` (see *Connectors*, the right answer whenever
37
+ the API needs a token or the content should be in the HTML), or a browser-side \`query\`/\`method\` for a public URL.
38
+
39
+ **\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
40
+ \`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
41
+ action is silently skipped** and the raw value passes through. Use the **exact** action names from
42
+ \`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
43
+ value is the **\`{{source}}\`** token (NOT \`{{value}}\`) — undefined until the source has a value, so \`{{ source|default('…') }}\` covers the wait; \`{{sourceTo}}\` is the field's previous value. Example —
44
+ show a number with units:
45
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
46
+ "binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
47
+ "transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
48
+ The others: ${OTHER_TRANSFORMERS} — each one's purpose and params are in \`plitzi://data-sources/{env}\`.
49
+ Transformer \`params\` values are strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
50
+ skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
51
+ validated.
52
+
53
+ **\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
54
+ the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
55
+ (operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
56
+ and/or). The guard is validated structurally. Example — only bind when a flag is set:
57
+ \`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
58
+
59
+ ## Interactions
60
+ An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
61
+ it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
62
+ you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
63
+
64
+ **Each step reads the page as it is when it runs**: a \`when\` or a \`{{ state.x }}\` after a \`setState\` sees the new
65
+ value, and one after a \`delay\` sees what changed meanwhile. To act on the value from BEFORE a write, put the reading
66
+ step first. A step's \`when\` asks an earlier step only for what it publishes (\`plitzi://explain/<action>\` lists it):
67
+ a run's \`<step>.status\` (\`runServerAction\` only), a sign-in's \`<step>.ok\` — any other key is refused
68
+ (\`condition-field-unpublished\`). **A trigger fired again while its flow runs is ignored** (no double submit); set
69
+ \`"whileRunning": "queue"\` on the trigger node for a stream of events that must each run in order (\`"parallel"\` runs
70
+ them at once, \`"latest"\` stops the running flow — its server action or request too — for a search as you type).
71
+ **Keyboard shortcuts** are a trigger every element has: \`onKey\` with param \`keys\` — \`"f"\`, \`"shift+f"\`,
72
+ \`"mod+k"\` (⌘ on a Mac, Ctrl elsewhere), \`"plus, ="\`, \`"escape"\`. Heard on the whole page while the element is
73
+ mounted, ignored while someone types in a field; the flow reads the key pressed as \`{{ <trigger id>.key }}\`.
74
+
75
+ **Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
76
+ **wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
77
+ - \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
78
+ - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's name (the flow host by
79
+ default, or another element to act on). Every element
80
+ registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
81
+ \`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
82
+ selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
83
+ for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
84
+ \`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
85
+ **undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
86
+ \`setState\` has **no** \`type\` param (that belongs to the global one below). Beside it every element registers
87
+ **\`toggleState\`** — the same write with **no \`value\`**: it stores the OPPOSITE of what is there
88
+ (\`category\`, \`key\`, \`revertOnFinish\`). That is how expand/collapse is authored — **one step on one trigger**,
89
+ never two \`setState\` branches under complementary \`when\` conditions: every step reads the page as it is when it
90
+ runs, so the second sees what the first wrote and flips it back. An element type may also register its own extra
91
+ callbacks.
92
+ - \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
93
+ \`space\`), \`setState\`/\`toggleState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`login\`/\`logout\`/
94
+ \`refreshDetails\` (\`auth\`), \`runServerAction\`/\`cancelServerAction\` (\`actions\`). Its \`elementId\` is the
95
+ **source module id**, never the host element — a node that stored the host element's name here would resolve to
96
+ nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
97
+ builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
98
+ \`placement:"top-right"\`, \`appearance:"success"\`) for any params you leave out. Use **only** the params each
99
+ callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
100
+ \`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
101
+ \`globalCallbacks\` in \`plitzi://interactions/{env}\`.
102
+ - **Two \`setState\`s (and two \`toggleState\`s) — do not mix them:** the **element** \`setState\` (nodeType
103
+ \`callback\`, on an element, category/key/value/revertOnFinish) changes THAT element's attribute/state and is what
104
+ you want to change a button's label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`,
105
+ source \`state\`, key/type/value) writes \`runtime.state.<key>\`. They share a name but have different node types
106
+ AND different params, and \`toggleState\` splits the same way: on an element (category/key/revertOnFinish) it flips
107
+ that element's own field; on source \`state\` (key) it flips \`runtime.state.<key>\`. Pick the element one when
108
+ nothing outside the element needs to know it is open; pick the state one when something else binds to it.
109
+ - \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
110
+ names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
111
+ \`webHook\` (\`url\`, \`method\`, …), \`copyToClipboard\` (\`text\`). See \`utilities\` in
112
+ \`plitzi://interactions/{env}\`.
113
+
114
+ **A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
115
+ it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<name>.<path>\`, or a
116
+ module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
117
+ a click on a row can show \`addNotification\` with \`content: "{{ list_<name>.item.name }}"\` — the clicked row's field.
118
+ The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
119
+ element repoints these tokens to the copies' names automatically, along with the element's bindings.
120
+
121
+ **Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
122
+ tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
123
+ \`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
124
+
125
+ Tools:
126
+ - \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
127
+ trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
128
+ the notification defaults):
129
+ \`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
130
+ { "nodeType": "trigger", "action": "onClick", "title": "Click" },
131
+ { "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
132
+ "params": { "content": "Saved!" } } ] }\`.
133
+ - \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
134
+
135
+ **Disable vs delete a step — do not confuse them (three different intents):**
136
+ - **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
137
+ with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
138
+ - **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
139
+ - **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
140
+
141
+ So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
142
+ never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
143
+ *remove* something, and **confirm with the user before deleting** a step or a flow.
144
+
145
+ Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
146
+ \`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
147
+ node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
148
+ \`enabled\`), so a follow-up patch/delete needs no extra read.
149
+
150
+ ## What is public — and where a secret goes
151
+ A space is served to anyone who opens it, and everything it is made of goes with it:
152
+
153
+ - **The documents.** Every page, layout and component, every schema and style variable, every attribute, binding,
154
+ flow param and \`mockData\` reaches the visitor's browser with the page. Hiding an element (\`visible: false\`, a
155
+ flag, a condition) does not remove it from what is sent.
156
+ - **The files.** A file on one of the space's public buckets is on the internet at its address, signed in or not —
157
+ for pictures, fonts and data every visitor may see.
158
+
159
+ So a secret — an API key, a token, a password — never goes in a document or a public file. It is a **credential**,
160
+ created by the space owner in the builder, which a connector, an action or a function **names** and never carries.
161
+ Data only some visitors may read comes from a \`runtime: "server"\` provider or a server action whose \`access\` checks
162
+ who is asking — never from a public file or a document the page filters on the client.
163
+
164
+ `;
165
+ //#endregion
166
+ export { logicGuide };
@@ -0,0 +1,2 @@
1
+ /** Good practice: motion, accessibility and semantics. */
2
+ export declare const practiceGuide: string;