@keemakr/ui-sdk 2.0.0-dev-20261012161109 → 2.0.0-dev-20261115054516

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 (113) hide show
  1. package/README.md +356 -15
  2. package/catalog.json +5459 -0
  3. package/dist/allowed-days.d.ts +29 -0
  4. package/dist/allowed-days.js +79 -0
  5. package/dist/app-press.d.ts +35 -0
  6. package/dist/app-press.js +105 -0
  7. package/dist/badges.d.ts +65 -0
  8. package/dist/badges.js +96 -0
  9. package/dist/build.d.ts +4 -0
  10. package/dist/build.js +200 -5
  11. package/dist/calendar.d.ts +24 -7
  12. package/dist/calendar.js +113 -18
  13. package/dist/catalog.d.ts +71 -0
  14. package/dist/catalog.js +175 -0
  15. package/dist/cells.d.ts +31 -0
  16. package/dist/cells.js +45 -0
  17. package/dist/chart.d.ts +20 -0
  18. package/dist/chart.js +38 -0
  19. package/dist/chat-blocks.d.ts +186 -0
  20. package/dist/chat-blocks.js +390 -0
  21. package/dist/check-cli.d.ts +9 -0
  22. package/dist/check-cli.js +145 -0
  23. package/dist/check.d.ts +166 -0
  24. package/dist/check.js +408 -0
  25. package/dist/cli.js +9 -3
  26. package/dist/composer.d.ts +36 -0
  27. package/dist/composer.js +35 -0
  28. package/dist/conform.d.ts +21 -0
  29. package/dist/conform.js +321 -0
  30. package/dist/dataset-view.d.ts +160 -0
  31. package/dist/dataset-view.js +699 -0
  32. package/dist/dataset.d.ts +331 -0
  33. package/dist/dataset.js +625 -0
  34. package/dist/date-format.d.ts +64 -0
  35. package/dist/date-format.js +132 -0
  36. package/dist/define.d.ts +15 -1
  37. package/dist/define.js +3 -1
  38. package/dist/drawer.d.ts +22 -0
  39. package/dist/drawer.js +21 -0
  40. package/dist/edit.d.ts +60 -0
  41. package/dist/edit.js +60 -0
  42. package/dist/filters.d.ts +54 -0
  43. package/dist/filters.js +81 -0
  44. package/dist/focus.d.ts +33 -0
  45. package/dist/focus.js +60 -0
  46. package/dist/form.d.ts +148 -0
  47. package/dist/form.js +193 -0
  48. package/dist/heatmap.d.ts +36 -0
  49. package/dist/heatmap.js +56 -0
  50. package/dist/icon.d.ts +20 -0
  51. package/dist/icon.js +53 -0
  52. package/dist/index.d.ts +59 -7
  53. package/dist/index.js +33 -3
  54. package/dist/markdown-links.d.ts +29 -0
  55. package/dist/markdown-links.js +99 -0
  56. package/dist/media.d.ts +22 -0
  57. package/dist/media.js +66 -0
  58. package/dist/negotiate.d.ts +375 -0
  59. package/dist/negotiate.js +1339 -0
  60. package/dist/node-limits.d.ts +587 -0
  61. package/dist/node-limits.js +546 -0
  62. package/dist/nodes.d.ts +23 -1
  63. package/dist/nodes.js +47 -3
  64. package/dist/page.d.ts +307 -0
  65. package/dist/page.js +482 -0
  66. package/dist/player.d.ts +46 -0
  67. package/dist/player.js +86 -0
  68. package/dist/published/index.d.ts +4 -0
  69. package/dist/published/index.js +18 -0
  70. package/dist/published/v1.1.0/schema.d.ts +439 -0
  71. package/dist/published/v1.1.0/schema.js +405 -0
  72. package/dist/published/v1.4.0/dataset-view.d.ts +160 -0
  73. package/dist/published/v1.4.0/dataset-view.js +702 -0
  74. package/dist/published/v1.4.0/dataset.d.ts +331 -0
  75. package/dist/published/v1.4.0/dataset.js +628 -0
  76. package/dist/published/v1.4.0/schema.d.ts +1132 -0
  77. package/dist/published/v1.4.0/schema.js +1410 -0
  78. package/dist/reach.d.ts +66 -0
  79. package/dist/reach.js +152 -0
  80. package/dist/schema.d.ts +5109 -208
  81. package/dist/schema.js +2695 -145
  82. package/dist/section.d.ts +66 -0
  83. package/dist/section.js +81 -0
  84. package/dist/stacked-bar.d.ts +34 -0
  85. package/dist/stacked-bar.js +20 -0
  86. package/dist/stat.d.ts +28 -0
  87. package/dist/stat.js +31 -0
  88. package/dist/stories.d.ts +63 -0
  89. package/dist/stories.js +297 -0
  90. package/dist/table-row.d.ts +24 -0
  91. package/dist/table-row.js +23 -0
  92. package/dist/tabs.d.ts +36 -0
  93. package/dist/tabs.js +83 -0
  94. package/dist/testkit.d.ts +49 -0
  95. package/dist/testkit.js +74 -0
  96. package/dist/timeline.d.ts +5 -0
  97. package/dist/timeline.js +35 -0
  98. package/dist/ui-build.d.ts +46 -0
  99. package/dist/ui-build.js +61 -0
  100. package/dist/ui-nodes.d.ts +195 -0
  101. package/dist/ui-nodes.js +197 -0
  102. package/dist/ui.d.ts +61 -0
  103. package/dist/ui.js +22 -0
  104. package/examples/campaigns/README.md +22 -1
  105. package/examples/campaigns/approvals/index.ts +23 -0
  106. package/examples/campaigns/approvals/launch.ts +38 -0
  107. package/examples/campaigns/brief/index.ts +23 -0
  108. package/examples/campaigns/brief/ready.ts +43 -0
  109. package/examples/campaigns/demo-approvals.ts +35 -0
  110. package/examples/campaigns/demo-brief.ts +23 -0
  111. package/examples/campaigns/entry.json +72 -1
  112. package/examples/campaigns/tsconfig.json +8 -1
  113. package/package.json +34 -1
package/README.md CHANGED
@@ -54,21 +54,48 @@ export default defineScreen({
54
54
  Folder names are screen identities. For example, `ui/campaigns/campaign/screen.ts` is the
55
55
  `campaign` screen. Screen folder names must be unique across the module.
56
56
 
57
- ## 4. Link out, count steps, ask for approval
58
-
59
- - A press is an `action`, or a link target: `navigate` (another screen of this module),
60
- `chat_new` (a new chat, `prompt` prefilled and never sent), `table` (`key` as your manifest
61
- declares it) or `work` (a work item `id`). There is no URL target: a screen cannot link to an
62
- arbitrary address. Core resolves `table` and `work` for the viewer; one it cannot resolve renders
63
- disabled. A pager's `onPage` and a select's `onChange` stay `action` or `navigate`.
64
- - A `progress` step may carry `done`, `total` and a link `target`, for rows such as "Running now".
65
- Send a `text` node when there is nothing to list; `steps` needs at least one.
66
- - `chart` with `chartType: 'funnel'` takes one series whose values are the steps, in category
67
- order, none negative. Name a step you cannot count in `missing`: it shows a dash and no bar,
68
- never a 0, and name it once. Only a funnel accepts `missing`.
69
- - Any decision a person must make in your pack goes through core approvals: declare the capability
70
- `approval_required`. Home shows every open approval, so a pack keeps no approval queue of its
71
- own, and a screen does not answer one.
57
+ ## 4. Optional workspace presentation
58
+
59
+ Screens use the document layout unless they opt into a platform-owned workspace. A workspace can
60
+ place page actions in a pinned footer and promote one keyed root section into a responsive right
61
+ rail. The module declares meaning; each Keemakr client owns widths, breakpoints and styling.
62
+
63
+ ```ts
64
+ load: async () => ({
65
+ version: 1,
66
+ title: 'Account review',
67
+ actions: [
68
+ {
69
+ type: 'button',
70
+ label: 'Save review',
71
+ onPress: { kind: 'action', action: 'save_review' },
72
+ },
73
+ ],
74
+ presentation: {
75
+ layout: 'workspace',
76
+ actionPlacement: 'footer',
77
+ rightRail: {
78
+ sectionKey: 'history',
79
+ label: 'Review history',
80
+ collapsible: true,
81
+ },
82
+ },
83
+ children: [
84
+ { type: 'text', value: 'Current review' },
85
+ {
86
+ type: 'section',
87
+ key: 'history',
88
+ title: 'History',
89
+ layout: 'stack',
90
+ columns: 1,
91
+ children: [{ type: 'text', value: 'Version 1' }],
92
+ },
93
+ ],
94
+ }),
95
+ ```
96
+
97
+ `rightRail.sectionKey` must identify exactly one keyed section in the screen's root `children`.
98
+ Older screens require no changes and keep header actions plus the normal document flow.
72
99
 
73
100
  ## 5. Generate before Eve runs
74
101
 
@@ -93,3 +120,317 @@ calls the module runtime. Availability controls UI placement. Existing authentic
93
120
  still control who may enter Dashboard or a Kee client.
94
121
 
95
122
  See [`examples/campaigns`](./examples/campaigns) for one complete in-memory example.
123
+
124
+ ## 6. Check that each app can draw your screen
125
+
126
+ An app parses a screen with the ui-sdk inside the sdk it was built with, frozen the day it shipped,
127
+ and it does not draw every node. Before core sends a screen, it reads the app from `X-Kee-Client`
128
+ and fits the screen to that app:
129
+
130
+ - each node the app cannot draw becomes a `text` or `markdown` line that says what the node said
131
+ (a pager, a select or an alert button stops being pressable); times in that line are written in
132
+ the screen's `timeZone` (the Company's when your screen names none, a calendar's own first),
133
+ and in UTC only when there is no zone;
134
+ - a value the app's parse refuses is folded to one it takes (an `info` or `accent` tone becomes
135
+ `default`; a date field's `min` and `max` are dropped), or the node becomes its text line;
136
+ - a control whose safety the app would lose (a form's `submit.confirm`, a `disabled` flag) becomes
137
+ "Open this in the web app to finish this step.", or is dropped from its list of controls, so
138
+ nothing acts without asking.
139
+
140
+ A table cell no released app draws yet (a `sparkline`, a `meter`, a `secondary` line under a text
141
+ or badge cell) reaches every app as a plain text cell: the sparkline's `label`, the meter's
142
+ `valueLabel` or percent, and no second line.
143
+
144
+ Every value the app refuses is fitted, however many there are: a 500-row table with an `info`
145
+ badge in each row reaches the app as a 500-row table with `default` badges. Only a screen nothing
146
+ can fit becomes one line.
147
+
148
+ | App | Parses with | Draws |
149
+ | ------------------- | ------------ | ---------------------------------------------------------------------------------------- |
150
+ | web (0.1.0, 0.2.0) | ui-sdk 1.4.0 | Every node, breadcrumbs, disabled buttons, row sections, every field kind, form confirms |
151
+ | mobile 0.2.0 | ui-sdk 1.1.0 | The 15 nodes of 1.1.0, and none of those features |
152
+ | mobile 0.2.3 and on | ui-sdk 1.4.0 | The 15 nodes of 1.1.0, breadcrumbs, disabled buttons, every field kind, form confirms |
153
+ | desktop | (floor) | Renders no module screens |
154
+ | no `X-Kee-Client` | this package | Keemakr's own web app: every node, as sent |
155
+
156
+ On dev and stage (never in production), a web build that installed the @dev sdk channel says
157
+ it parses this package (`web/0.2.0+abc1234.ui-current`) and gets every node as sent, so a new node
158
+ can be tried on the dev web app before a stable sdk carries it (`CHANNEL_BUILDS`,
159
+ `nodeSetForClaim`). Production web builds get the row above.
160
+
161
+ `CLIENT_RELEASES` holds the full table. Test against it with the testkit:
162
+
163
+ ```ts
164
+ import { assertDrawableOn, renderForClients } from '@keemakr/ui-sdk/testkit';
165
+
166
+ // Fails, naming each node and client, when a target client would get a fallback.
167
+ assertDrawableOn(await screen.load(ctx), ['web']);
168
+
169
+ // Accept the fallback, and assert on the tree that client gets.
170
+ const [mobile] = assertDrawableOn(tree, ['mobile'], { allowFallback: true });
171
+ ```
172
+
173
+ With no targets, the testkit checks every app that renders module screens (web and mobile). An app
174
+ named alone is checked at every release it has, so `['mobile']` covers mobile 0.2.0 as well as the
175
+ newest build. Name a version with `claim: 'current'` (`{ client: 'web', version: '0.2.0', claim:
176
+ 'current' }`) to see what a dev-channel web build gets on dev and stage.
177
+
178
+ ### Stories: try a screen with sample data
179
+
180
+ A `*.stories.ts` file holds sample pages in one format: each story is a screen tree and the
181
+ datasets it places, declared as a module declares them.
182
+
183
+ ```ts
184
+ import { defineStories, sampleRows, sampleAnswer } from '@keemakr/ui-sdk/stories';
185
+
186
+ export default defineStories({
187
+ title: 'Leads',
188
+ stories: [{ name: 'Leads as a table', tree, datasets: [leads] }],
189
+ });
190
+
191
+ sampleRows(leads, 400); // 400 synthetic rows: the same on every run
192
+ sampleRows(leads, 5, 'long_text'); // every text value as long as a dataset allows
193
+ sampleRows(leads, 5, 'error'); // rows the platform refuses: the view's error state
194
+ sampleAnswer(leads, rows, { limit: 25 }); // one page, as a module answers a query
195
+ ```
196
+
197
+ `defineStories` throws a `StoryError` naming the story when a tree or a dataset does not pass the
198
+ schema, or a tree places a dataset the story does not declare. The rows are made up from a fixed
199
+ word list, so a story never holds real data.
200
+
201
+ ## 7. Return the new screen from an action
202
+
203
+ An action runs on your runtime, and by default the client then asks core to load the screen
204
+ again: two more round trips before the person sees the change. An action can return the screen
205
+ itself, as `load` would return it now, for the same screen and the same params the action ran
206
+ with:
207
+
208
+ ```ts
209
+ export default defineScreen({
210
+ load: async (ctx, params) => buildScreen(ctx, params),
211
+ actions: {
212
+ approve: async (ctx, input, params) => {
213
+ await approve(ctx, input);
214
+ return { toast: 'Approved', tree: await buildScreen(ctx, params) };
215
+ },
216
+ },
217
+ });
218
+ ```
219
+
220
+ - A client that knows `tree` draws it and does not call `load`. A client built before this field
221
+ ignores it and reloads, because `refresh` stays `true`. Send `tree` and leave `refresh` alone.
222
+ - `navigate` wins over `tree`. To show another page of the screen, return `navigate`, as before.
223
+ - Core sends the tree through the same checks as a loaded one: every node the client cannot draw
224
+ becomes a fallback (section 6), and the cards for `pending_request` slots come beside it in
225
+ `pendingRequests`. Test the tree with `assertDrawableOn(result.tree, ['web'])`.
226
+ - A tree that does not validate is dropped, and the client reloads: the action has already run, so core does not fail it for a tree that only saves a reload.
227
+ - When core answers a retried action from its log, it sends no tree, and the client reloads.
228
+
229
+ ## 8. Show a live count beside a menu entry
230
+
231
+ A surface can show a count beside its name in the side menu ("My Day 21", "Accounts 8 red"). Opt
232
+ in on the surface:
233
+
234
+ ```ts
235
+ export default defineSurface({ label: 'Accounts', badge: true, availableOn: ['client'] });
236
+ ```
237
+
238
+ Then answer `POST /screens/badges` in your screens channel, behind the same grant check as
239
+ `/screens/:screen/load`. Core sends the opted-in surfaces the person may open, and keeps only
240
+ those in your answer:
241
+
242
+ ```ts
243
+ import { answerBadges, defineBadges } from '@keemakr/ui-sdk';
244
+
245
+ const badges = defineBadges(async (ctx, surfaces) => ({
246
+ 'my-day': { count: await countMyDay(ctx) },
247
+ accounts: { count: 8, tone: 'destructive', label: '8 red' },
248
+ }));
249
+
250
+ POST('/screens/badges', async (req) => {
251
+ const auth = await authorize(req);
252
+ if (!auth.ok) return auth.res;
253
+ const { status, body } = await answerBadges(badges, auth.ctx, await bodyOf(req));
254
+ return json(status, body);
255
+ }),
256
+ ```
257
+
258
+ - `count` is a whole number from 0 to 999999. A menu draws more than 999 as "999+", and draws
259
+ nothing for 0 unless you give a `label`.
260
+ - `label` (up to 24 characters) is drawn in place of the count and read out after the name
261
+ ("Accounts, 8 red"). Put the meaning in it: `tone` only colours it.
262
+ - Core asks about once a minute per person, waits about two seconds, and draws no badge when you
263
+ are slow, fail, or have no such route (404). Answer from stored state.
264
+ - A person's own screen action makes their next menu read ask again sooner.
265
+
266
+ ## 9. Look up a node, and its limits
267
+
268
+ `@keemakr/ui-sdk/catalog.json` lists every node a screen may hold, generated from the schema this
269
+ package validates with:
270
+
271
+ - `schema`: one JSON Schema 2020-12 document. `$defs.ScreenTree` is a whole screen and
272
+ `$defs.<type>` each node, so an editor, a linter or an agent can check a tree without running
273
+ this package. Checks written as code (a tab key used twice, a field that needs another) are not
274
+ in it: core's own parse still decides.
275
+ - `nodes.<type>`: the first release that has the node, whether it holds children, whether Kee may
276
+ draw it in a chat reply, what the newest release of each app does with it (`draws`, `fallback`,
277
+ or `core` when core draws it into plain blocks first), and its size caps.
278
+ - `chatBlocks`: the blocks a chat reply may hold, their caps and the keys a chat block may not
279
+ hold.
280
+ - `catalogId`: `kee/1+<hash>`. Two catalogs with one id accept exactly the same trees.
281
+
282
+ The size caps are also exported as `NODE_LIMITS` (per node) and `SCREEN_LIMITS` (the screen's own
283
+ fields). Trim to them rather than copying the numbers, so a changed cap reaches your Pack with the
284
+ next release:
285
+
286
+ ```ts
287
+ import { NODE_LIMITS } from '@keemakr/ui-sdk';
288
+
289
+ const value = summary.slice(0, NODE_LIMITS.text.value); // 5000
290
+ const rows = leads.slice(0, NODE_LIMITS.table.rows); // 500
291
+ ```
292
+
293
+ A path names fields with dots (`columns[].label`); `[]` steps into an array's items, `{}` into a
294
+ map's values, and `@<value>` into the variant whose `type` or `kind` is that value
295
+ (`NODE_LIMITS.table['rows[].cells{}@badge.value']`). A cap is the most characters of a string,
296
+ items of an array or keys of a map.
297
+ Numeric ranges (`dataset.limit` is 1 to 100) are not caps, so they are not in `NODE_LIMITS`: read
298
+ them from `schema` (`minimum`, `maximum`, `default`).
299
+
300
+ ## 10. Build a tree with the typed builders
301
+
302
+ `@keemakr/ui-sdk/ui` has one builder per node, generated from the catalog, and `ui.screen` for the
303
+ tree. A builder sets `type` (and `ui.screen` sets `version`), applies the schema's defaults, and
304
+ returns plain JSON: the same tree core reads after it parses a hand-written one, so nothing core
305
+ receives changes. A value the schema refuses throws a `UiBuildError` that names the field path,
306
+ where you built the node, instead of core refusing the whole screen later:
307
+
308
+ ```ts
309
+ import { defineScreen } from '@keemakr/ui-sdk';
310
+ import { ui, UiBuildError } from '@keemakr/ui-sdk/ui';
311
+
312
+ export default defineScreen({
313
+ load: async () =>
314
+ ui.screen({
315
+ title: 'Leads',
316
+ children: [
317
+ ui.table({
318
+ columns: [{ key: 'name', label: 'Name' }],
319
+ rows: (await listLeads()).map((lead) => ({
320
+ key: lead.id,
321
+ cells: { name: { kind: 'text', value: lead.name } },
322
+ })),
323
+ empty: 'No leads yet',
324
+ }),
325
+ ],
326
+ }),
327
+ });
328
+
329
+ try {
330
+ ui.text({ value: tooLong });
331
+ } catch (error) {
332
+ if (error instanceof UiBuildError) console.log(error.path, error.issues[0]?.limit); // value 5000
333
+ }
334
+ ```
335
+
336
+ `error.path` is the first refused field, from the node the builder makes (`rows[3].cells.name.value`;
337
+ from the screen for `ui.screen`, `children[0].value`). `error.issues` lists every refused field, with
338
+ `limit` set when the value is past a size cap (the same number `NODE_LIMITS` holds; a number past its
339
+ range has none). A builder checks its node with the schema core reads it with, a `section`'s or a
340
+ `tabs`' children included; `ui.screen` checks the whole tree and adds the rules that span nodes (a
341
+ seek must name a recording on the screen). Each builder's doc comment lists the node's top-level
342
+ caps, so an editor shows them as you type.
343
+
344
+ ## 11. Let core keep a screen for a repeat load
345
+
346
+ Most of a screen's load time is the round trip to your runtime. A screen whose data can be a little
347
+ old may let core keep the tree it last drew for a person, and answer that person's next load of the
348
+ same screen, with the same params, from it while core loads the screen again in the background:
349
+
350
+ ```ts
351
+ export default defineScreen({
352
+ cache: { max_age_s: 60 },
353
+ load: async (ctx, params) => ({ version: 1, title: 'Accounts', children: [] }),
354
+ });
355
+ ```
356
+
357
+ - Write `cache` as a literal inside `export default defineScreen({ ... })`: the build reads it
358
+ without running your code and copies it into the screen's `screenRegistry` entry in
359
+ `entry.json`. `max_age_s` is a whole number from 1 to 3600.
360
+ - A kept tree is one person's, for their role and department standing at the time; core never
361
+ shows it to anyone else, and checks the person's access on every load before it.
362
+ - A screen action, a dataset row added through core, or a job status read (the screen polling
363
+ `/screens/:screen/jobs/:id`) that reports the job ended, on any of your screens, drops all your
364
+ module's kept trees, so the next load is fresh. A job nobody polls to its end drops nothing. Any
365
+ write to the company's records (`kee.records.*`, from any agent or person) drops every kept tree
366
+ of the company. Other writes your agent makes on its own (its own store, a connector) are not
367
+ seen: `max_age_s` is how stale such a screen may get.
368
+ - Leave `cache` out for a screen that must always be current (a live queue, a countdown). Without
369
+ it core never keeps the screen. Core keeps nothing unless the company has screen caching on.
370
+
371
+ ## 12. Check a screen or a page before you publish it
372
+
373
+ `@keemakr/ui-sdk/check` is the one checker every publish runs: this package's CLI and CI action,
374
+ core's MCP tools (`ui_tree_validate`, `ui_tree_lint`) and the page builder's gate. It is pure (no
375
+ network), takes a screen tree or a page that wraps one (`{ tree }`), and returns findings, each
376
+ with a rule id, a severity, the field path and a fix:
377
+
378
+ ```ts
379
+ import { checkPage, fixPage } from '@keemakr/ui-sdk/check';
380
+
381
+ const { ok, findings } = checkPage(tree, {
382
+ // Optional: what the company has installed. With it, a dataset node naming another dataset is
383
+ // `binding.dataset_unknown` and a press calling an undeclared action `binding.action_undeclared`.
384
+ bindings: { datasets: ['leads'], actions: ['approve'] },
385
+ });
386
+ // findings[0]: { rule: 'limit.exceeded', severity: 'error', path: 'children[0].text', ... }
387
+ ```
388
+
389
+ Errors (`schema.*`, `limit.exceeded`, `binding.*`) block a publish; warnings (`reach.fallback`,
390
+ `workaround.*`, `a11y.*`, `catalog.mismatch`) are shown. `fixPage` makes the fixes marked
391
+ `fixable` (an empty text spacer becomes a `divider`, a text with a warning sign an `alert`, a
392
+ markdown node holding one link a `link`) on a copy. `CHECK_RULES` lists every rule.
393
+
394
+ From a terminal or CI, on JSON files:
395
+
396
+ ```sh
397
+ npx keemakr-ui check [--json] [--github] [--fix] [--bindings bindings.json] [--client web|mobile[@version]] page.json
398
+ npx keemakr-ui check --rules
399
+ ```
400
+
401
+ It exits 1 when a file has an error, 0 on warnings alone and 2 on a usage error. `--fix` writes
402
+ the safe fixes back to the file. In GitHub Actions, the composite action in the keemakr
403
+ repository (`uses: fsztpartners/keemakr/packages/ui-sdk/ci-action@<sha>`, inputs `files`,
404
+ `bindings`, `sdk-version`, `working-directory`) runs it with `--github`, so each finding is annotated
405
+ on the run.
406
+
407
+ ## 13. The page format
408
+
409
+ A page made in the UI builder (by a person, by Kee or by an agent) has one shape, defined in
410
+ `@keemakr/ui-sdk/page`: a thin envelope over a screen tree. Everything that writes or reads a page
411
+ (the builder, Kee's page skill, export and import) uses exactly this.
412
+
413
+ ```ts
414
+ import { pageDocumentSchema, stampNodeIds } from '@keemakr/ui-sdk/page';
415
+
416
+ const page = pageDocumentSchema.parse({
417
+ format: 'keemakr.page',
418
+ formatVersion: 1,
419
+ catalogId: 'kee/1+…', // the catalog the page was built against (catalog.json)
420
+ kind: 'page', // or 'template'
421
+ title: 'Leads',
422
+ tree: { version: 1, title: 'Leads', children: [{ type: 'heading', value: 'Leads', level: 1 }] },
423
+ bindings: [{ kind: 'dataset', dataset: 'leads' }], // optional, defaults to []
424
+ });
425
+ ```
426
+
427
+ - The envelope is strict; the `tree` is not parsed by it. A tree the screen schema refuses is
428
+ still a page, so saving keeps the work; `checkPage` (section 12) says what is wrong, and only a
429
+ push or a pack submission is refused for it.
430
+ - `bindings` are what the page may read and call: an installed dataset by name, a declared action
431
+ by its stable id.
432
+ - Every node of a stored page has a stable `id` (1-64 of `A-Z a-z 0-9 _ -`, unique in the page),
433
+ so an edit names the node it changes, never its position. `stampNodeIds(page, newId)` returns a
434
+ copy where each node without an id (or with a duplicate or malformed one) gets one from `newId`,
435
+ and every other id is kept. Ids stay in the stored page; they are not part of the screen node
436
+ schemas a renderer is handed.