@antelopejs/agent-skills 0.3.2 → 0.8.1

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.
@@ -4,7 +4,9 @@ The formats of `mockups/<name>/spec.json` and `mockups/<name>/annotations.json`,
4
4
 
5
5
  ## Schema
6
6
 
7
- `@antelopejs/dms` ships the JSON Schema of the spec at `node_modules/@antelopejs/dms/data/mockup-spec.schema.json`, and a running DMS serves the same schema, built from the blocks of the installed modules, at `GET /api/mockup/schema`. Point the spec's `$schema` at the file, so an editor checks it as the user types. When the schema and this page disagree, the schema wins. `node_modules/@antelopejs/dms/data/mockup-example/spec.json` is a two-page spec that compiles with no issue: model a new spec on it.
7
+ A running DMS serves the JSON Schema of the spec, built from the blocks of the installed modules, at `GET /api/mockup/schema`, and a two-page example spec that compiles with no issue at `GET /api/mockup/example`: model the pages on it. When the schema and this page disagree, the schema wins.
8
+
9
+ Fallback with no running DMS: `@antelopejs/dms` ships the same files at `node_modules/@antelopejs/dms/data/mockup-spec.schema.json` and `node_modules/@antelopejs/dms/data/mockup-example/spec.json`, but a project that installs its modules under `.antelope/cache` has no `node_modules/@antelopejs/dms`. When the schema file exists, point the spec's `$schema` at it, so an editor checks the spec as the user types; otherwise leave `$schema` out.
8
10
 
9
11
  ## spec.json
10
12
 
@@ -13,10 +15,14 @@ The formats of `mockups/<name>/spec.json` and `mockups/<name>/annotations.json`,
13
15
  "$schema": "../../node_modules/@antelopejs/dms/data/mockup-spec.schema.json",
14
16
  "version": 1,
15
17
  "title": "Order desk",
18
+ "categories": [
19
+ { "id": "sales", "title": "Sales", "icon": "i-ph-storefront" }
20
+ ],
16
21
  "pages": [
17
22
  {
18
23
  "id": "orders",
19
24
  "title": "Orders",
25
+ "category": "sales",
20
26
  "options": { "theme": "light", "locale": "en", "padding": true },
21
27
  "fixtures": {
22
28
  "orders": [
@@ -63,6 +69,7 @@ The formats of `mockups/<name>/spec.json` and `mockups/<name>/annotations.json`,
63
69
  "type": "TableView",
64
70
  "options": {
65
71
  "fetchUrl": "fixture:orders",
72
+ "caption": "Orders",
66
73
  "columns": {
67
74
  "customer": {
68
75
  "name": "Customer",
@@ -89,10 +96,16 @@ The formats of `mockups/<name>/spec.json` and `mockups/<name>/annotations.json`,
89
96
  }
90
97
  ```
91
98
 
92
- - `pages`: 1 to 50 pages. `options` is optional: `theme` (`light` or `dark`), `locale`, `padding` (default `true`).
93
- - `fixtures`: a key (`^[A-Za-z0-9_-]{1,64}$`) to any JSON value, the data the page's blocks read.
99
+ - `pages`: 0 to 50 pages. An empty `pages` is valid: it is how a mockup starts. `options` is optional: `theme` (`light` or `dark`), `locale`, `padding` (default `true`).
100
+ - `categories` (optional): the menu's sections, in menu order, at most 50, each `{ id, title, icon? }` with `id` in the page `id` format. A page's `category` names one; a page without one is in the default _Pages_ section, where the dashboards stay. An unknown or repeated id is an issue. The sections follow **dms-page-design** _Group pages into sections_. The viewer draws the app's own menu too: a section whose `title` is an app section's (case and spaces aside) is drawn as that section, the app's pages first, and the default section joins the app's _Pages_.
101
+ - `sidebar` (optional): the sidebar widgets, as _Sidebar widgets_ says.
102
+ - `data` (optional): the connected database the app reads, `{ connection, access? }`, as _Connection access_ says.
103
+ - `custom`, `html`, `css`, `height` and `states` (optional, per page): a custom page, as _Custom pages_ says.
104
+ - `icon`, `description` and `headerActions` (optional, per page): the page header the DMS draws above the blocks, with `title`. `icon` is an icon name (`i-ph-receipt`), `description` one line under the title, `headerActions` the header's buttons, each `{ label, icon?, color?, variant? }`. A button holds no target: what it does is decided at build. Give every page an icon and a description, as **dms-page-design** _Name every page_ says.
105
+ - `fixtures`: a key (`^[A-Za-z0-9_-]{1,64}$`) to any JSON value, the data the page's blocks read, or to a `$generate` object that the server turns into rows ([Generated fixtures](#generated-fixtures)).
94
106
  - `tree`: the page's blocks, top to bottom, in the `DmsBlockPreview` tree format below.
95
- - `livePage` and `liveRoutes` (optional, per page): set by "Edit as mockup" on a page converted from a live page, `livePage: { ref, version }` and `liveRoutes` a fixture key to the live route it stands for. **dms-mockup-build** reads them.
107
+ - `menu`, `parent` and `route` (optional, per page): a sub-page, such as a list's detail page, as _Links and sub-pages_ says.
108
+ - `livePage` and `liveRoutes` (optional, per page): set when the AI converts a live page into a mockup (`mockup_from_page`), which also fills `icon` and `description` from it, `livePage: { ref, version }` and `liveRoutes` a fixture key to the live route it stands for. **dms-mockup-build** reads them.
96
109
  - `source` (optional): what created the spec: `claude-code` or `codex` for the harness, or `chat` for the host's chat. The host can override the value the harness sets.
97
110
  - `built` (optional): written by **dms-mockup-build** after a build, `{ at, pages }`: `at` an ISO date, `pages` one `{ path, title? }` per page built, `path` its dashboard path.
98
111
 
@@ -108,9 +121,503 @@ A node is `{ type, options?, children? }`; a child also takes `id`, `slot` (a `T
108
121
  Name every child with an `id`: the builder and the roles editor key blocks by name. A block that only shows a figure can take its `static*` options (`staticValue`, `staticDelta`) in place of a fixture.
109
122
 
110
123
  - **Fixture reference.** Any string option of the form `fixture:<key>`, at any depth, reads that key of the page's `fixtures`. Use it for every `fetchUrl`, so the block draws data with no route.
111
- - **`TableView`** takes the options of `TableView.fromSource`: `fetchUrl: "fixture:<key>"` naming an array of rows, and `columns` keyed by row field, each with its `name` and its `type`, a data type id (`string`, `number`, `date`, `boolean`, `select`, …). Paging, search and sort work over the fixture; filters (tabs, quick filters, `queryParamFilters`) draw but do not narrow the rows, and a column takes no `display`.
112
- - **`ResourceForm`** takes its `fields` and `fetchUrl: "fixture:<key>"` naming the record object, with no `submitUrl`.
113
- - **Sketch.** `{ "type": "sketch", "options": { "html", "css"?, "height"?, "caption"? } }`, with no children: the static HTML and CSS of one custom part, drawn hatched, outlined and labelled _Custom_. `height` is 80 to 1200 px (default 320); `caption` (up to 200 characters) says what the part does. It runs in a sandbox with no script: the spec refuses `<script>`, embedding elements, `on*` handlers, `<meta http-equiv>`, `@import`, `javascript:` and `vbscript:` URLs, and any `url()`, `src` or `href` that is not a `data:` URL or an `#anchor`. Keep it to the element alone; the blocks around it stay blocks.
124
+ - **Page link.** Any string option of the form `page:<id>`, at any depth, links to that spec page, as _Links and sub-pages_ says.
125
+ - **`TableView`** takes the options of `TableView.fromSource`: `fetchUrl: "fixture:<key>"` naming an array of rows, a `caption`, and `columns` keyed by row field, each with its `name` and its `type`, a data type id (`string`, `number`, `date`, `boolean`, `select`, …). Paging, search, sort, tabs, quick filters, views and the board work over the fixture. A table with no `caption`, or a blank one, is an issue and its write is refused, except on a page with `livePage`. A column takes a `display`, and the table its board, tabs and views, as _Tables_ says. A table with tabs, `quickFilters` or `queryParamFilters` needs `capabilities.filter` when you write `capabilities` explicitly (the rule of `assertSourceFilters`, interface-dms `base/table-view/source.ts`); without `capabilities` the mockup compiler sets `filter: true` and validation passes.
126
+ - **`ResourceForm`** takes its `mode`, its `fields` and `fetchUrl: "fixture:<key>"` naming the record object, with no `submitUrl`. `mode` is `view` on a detail page, which shows the record read-only, `edit` on an edit page and `new` on a new page. On a table's row pages (`formContainer.pages`), a details page whose form is not in `mode: "view"`, or an edit page whose form is, is an issue.
127
+ - **Sketch.** `{ "type": "sketch", "options": { "html", "css"?, "height"?, "caption"?, "states"? } }`, with no children, as _Sketches_ says.
128
+
129
+ ## Tables
130
+
131
+ A `TableView` takes the features **dms-page-design** _Tables_ decides, in the names `TableView` gives them:
132
+
133
+ ```json
134
+ {
135
+ "id": "orders-table",
136
+ "type": "TableView",
137
+ "options": {
138
+ "fetchUrl": "fixture:orders",
139
+ "caption": "Orders",
140
+ "columns": {
141
+ "customer": { "name": "Customer", "type": "string", "sortable": true },
142
+ "status": {
143
+ "name": "Status",
144
+ "type": "select",
145
+ "filterable": true,
146
+ "display": {
147
+ "kind": "badge",
148
+ "items": [
149
+ { "value": "pending", "label": "Pending", "tone": "warning" },
150
+ { "value": "paid", "label": "Paid", "tone": "success" },
151
+ { "value": "refunded", "label": "Refunded", "tone": "error" }
152
+ ]
153
+ }
154
+ },
155
+ "total": {
156
+ "name": "Total",
157
+ "type": "number",
158
+ "sortable": true,
159
+ "display": { "kind": "price", "currency": "EUR" }
160
+ }
161
+ },
162
+ "tabsFrom": { "column": "status" },
163
+ "kanban": { "groupByField": "status" },
164
+ "defaultDisplay": "kanban",
165
+ "views": {
166
+ "items": [
167
+ {
168
+ "id": "large",
169
+ "label": "Large orders",
170
+ "count": true,
171
+ "sort": [{ "field": "total", "desc": true }]
172
+ }
173
+ ],
174
+ "layout": "strip"
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ - **Column `display`**, one of:
181
+ - a badge, `{ "kind": "badge", "items": [{ "value", "label", "tone" }] }`, on a `string` or `select` column: a `select` column carries its values this way. `tone` is `neutral`, `primary`, `secondary`, `success`, `warning`, `error` or `info`;
182
+ - a price, `{ "kind": "price", "currency": "EUR" }`, on a `number` column, with an ISO 4217 code;
183
+ - a cell display, `{ "type", "options"? }`, `type` one of `identity`, `pills`, `relative_date`, `indicator`, `status_pill`, `two_line`, `progress`, `sparkline`, `duration`, `bytes`, `string` and `mono`, such as `{ "type": "identity", "options": { "subtitleField": "email" } }`.
184
+ - **`tabsFrom`**, `{ "column" }`: "All", then one tab per badge item, in its tone. The column is `filterable` with a badge `display`, and the table has no `tabs`. Hand-written `tabs` colour a tab with `textColor` and `iconColor`; any other key, `color` included, is an issue.
185
+ - **`kanban`**, `{ "groupByField", "columnMaxHeight"? }`, on a badge, `boolean` or `status` column. Its cards do not move in a mockup.
186
+ - **`grouped`**, `{ "groupByField", "by"?, "collapsible"?, "count"? }`, on a `sortable` column; `by` is `value`, `day` or `week`, and `day` and `week` need a `date` column.
187
+ - **Cards**: `"displays": [{ "id": "table" }, { "id": "cards" }]` and `"card": { "fields": [...] }`.
188
+ - **`defaultDisplay`**, `mobileDisplay` and a view's `display` name a display the table offers: `table`, `cards`, `kanban` or `grouped`.
189
+ - **`views`**, `{ "items", "layout"?, "defaultView"?, "userViews"? }`, each view `{ "id", "label", "icon"?, "count"?, "filters"?, "sort"?, "display"?, "density"? }`: a filter `{ "accessorKey", "mode", "value" }` (`mode` `is`, `include`, `greater_than`, …) on a `filterable` column, a sort `{ "field", "desc"? }` on a `sortable` one.
190
+
191
+ The Builder's `builder_map_resources` holds the same settings under its own names; only `display` matches the proposal's shape as it is:
192
+
193
+ | Spec | `builder_map_resources` |
194
+ | ------------------------------------ | -------------------------------------- |
195
+ | the page's `title` and the `caption` | the resource's `title` |
196
+ | the page's `category` | the resource's `category`: its ref |
197
+ | `tabsFrom: { column }` | the resource's `tabs: { column }` |
198
+ | `kanban.groupByField` | `tableOptions.kanban.groupBy` |
199
+ | `grouped.groupByField` | `tableOptions.grouped.groupBy` |
200
+ | `cards` in `displays`, `card.fields` | `tableOptions.cards.fields` |
201
+ | `defaultDisplay` | `tableOptions.defaultDisplay` |
202
+ | a view filter's `accessorKey` | `tableOptions.views` filter's `column` |
203
+ | a view sort's `field` | `tableOptions.views` sort's `column` |
204
+
205
+ `mobileDisplay`, a cell display and a hand-written `tabs` have no counterpart there.
206
+
207
+ ## Links and sub-pages
208
+
209
+ A string option `page:<id>`, at any depth of a block's options, links to the spec page of that id; an id no page has is an issue. It goes wherever a block takes a URL or a route:
210
+
211
+ - a row action's or a toolbar button's `target`: `rowActions.custom[].target` and `customButtons[].target`, `{ "type": "page", "url": "page:<id>" }`;
212
+ - a tab's `to`, a `NavCardGrid` or `TopListCard` item's `to`, a `StatGroup` cell's `to`, a card head action's `to`;
213
+ - a `Form`'s `backTo` and `redirectOnSuccess`;
214
+ - an `<a href="page:<id>">` in a sketch, as _Sketches_ says.
215
+
216
+ A sub-page is a page with a `parent`, the `id` of another page (no loop): a list's detail page, or a custom form page. `"menu": false` leaves it out of the sidebar, which lights its nearest listed parent while it is open. `"route": ":<name>"` (it needs a `parent`) makes it show one row: on it, `fixture:<key>` naming an ancestor's rows reads the row whose `_id`, else `id`, is the parameter, and the first row stands in when no link names one. A sub-page reads the fixtures of its ancestors it does not hold itself.
217
+
218
+ ```json
219
+ {
220
+ "version": 1,
221
+ "pages": [
222
+ {
223
+ "id": "orders",
224
+ "title": "Orders",
225
+ "fixtures": {
226
+ "orders": {
227
+ "$generate": {
228
+ "fields": {
229
+ "_id": "id",
230
+ "customer": "company",
231
+ "total": { "money": [40, 900] }
232
+ }
233
+ }
234
+ }
235
+ },
236
+ "tree": [
237
+ {
238
+ "id": "orders-table",
239
+ "type": "TableView",
240
+ "options": {
241
+ "fetchUrl": "fixture:orders",
242
+ "caption": "Orders",
243
+ "columns": {
244
+ "customer": { "name": "Customer", "type": "string" },
245
+ "total": { "name": "Total", "type": "number" }
246
+ },
247
+ "rowClick": "single",
248
+ "rowActions": {
249
+ "custom": [
250
+ {
251
+ "label": "Open",
252
+ "icon": "i-ph-arrow-right",
253
+ "isDefault": true,
254
+ "target": { "type": "page", "url": "page:order" }
255
+ }
256
+ ]
257
+ },
258
+ "customButtons": [
259
+ {
260
+ "label": "Report",
261
+ "icon": "i-ph-chart-bar",
262
+ "target": { "type": "page", "url": "page:report" }
263
+ }
264
+ ]
265
+ }
266
+ }
267
+ ]
268
+ },
269
+ {
270
+ "id": "order",
271
+ "title": "Order",
272
+ "menu": false,
273
+ "parent": "orders",
274
+ "route": ":id",
275
+ "tree": [
276
+ {
277
+ "id": "order-form",
278
+ "type": "ResourceForm",
279
+ "options": {
280
+ "mode": "view",
281
+ "fetchUrl": "fixture:orders",
282
+ "backTo": "page:orders",
283
+ "fields": [
284
+ { "id": "customer", "label": "Customer", "type": "string" },
285
+ { "id": "total", "label": "Total", "type": "number" }
286
+ ]
287
+ }
288
+ }
289
+ ]
290
+ },
291
+ {
292
+ "id": "report",
293
+ "title": "Order report",
294
+ "menu": false,
295
+ "parent": "orders",
296
+ "tree": []
297
+ }
298
+ ]
299
+ }
300
+ ```
301
+
302
+ A row action's link passes the row's id, read at the table's `rowIdKey` (`_id` by default). `"rowClick": "single"` with a custom row action marked `isDefault: true` opens it on a click on the row. A link from a page with a route to its own sub-page with a route keeps the row; any other link opens the sample row.
303
+
304
+ ## Table forms
305
+
306
+ A mockup table is read-only: an action is on only when `rowActions` writes it, `add`, `edit` or `details`, each `true` or a row action config such as `{ "rule": { "field": "status", "equals": "draft" } }`. `formContainer` says where the forms open, as in the real `TableView`; **dms-page-design** _Records, forms and links_ picks it:
307
+
308
+ - `{ "type": "modal", "size"? }`, the default when `formContainer` is left out, `size` `sm` to `5xl` or `full` (default `xl`), or `{ "type": "drawer", "direction"? }`, from the `bottom` (the default) or the `right`: the add, edit and details forms are generated from the table's columns, the details form read-only, as the real `TableView`'s, and saving keeps nothing. `pages.new`, `pages.edit` and `pages.details` take their `displayName` and `description` only.
309
+ - `{ "type": "page", "pages": { ... } }`: each action on opens a spec page, `{ "urlSlug": "page:<id>", "customPage": true }`, which holds the custom form or the detail view, a `ResourceForm` in the page's `mode`. The edit and details pages need a `route`.
310
+
311
+ ```json
312
+ {
313
+ "version": 1,
314
+ "pages": [
315
+ {
316
+ "id": "orders",
317
+ "title": "Orders",
318
+ "fixtures": {
319
+ "orders": [{ "_id": "o1", "customer": "Acme", "total": 120 }]
320
+ },
321
+ "tree": [
322
+ {
323
+ "id": "orders-table",
324
+ "type": "TableView",
325
+ "options": {
326
+ "fetchUrl": "fixture:orders",
327
+ "caption": "Orders",
328
+ "columns": {
329
+ "customer": { "name": "Customer", "type": "string" },
330
+ "total": { "name": "Total", "type": "number" }
331
+ },
332
+ "rowActions": { "add": true, "edit": true, "details": true },
333
+ "formContainer": {
334
+ "type": "page",
335
+ "pages": {
336
+ "new": { "urlSlug": "page:order-new", "customPage": true },
337
+ "edit": { "urlSlug": "page:order-edit", "customPage": true },
338
+ "details": { "urlSlug": "page:order", "customPage": true }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ ]
344
+ },
345
+ {
346
+ "id": "order-new",
347
+ "title": "New order",
348
+ "menu": false,
349
+ "parent": "orders",
350
+ "tree": []
351
+ },
352
+ {
353
+ "id": "order-edit",
354
+ "title": "Edit order",
355
+ "menu": false,
356
+ "parent": "orders",
357
+ "route": ":id",
358
+ "tree": []
359
+ },
360
+ {
361
+ "id": "order",
362
+ "title": "Order",
363
+ "menu": false,
364
+ "parent": "orders",
365
+ "route": ":id",
366
+ "tree": [
367
+ {
368
+ "id": "order-details",
369
+ "type": "ResourceForm",
370
+ "options": {
371
+ "mode": "view",
372
+ "fetchUrl": "fixture:orders",
373
+ "fields": [
374
+ { "id": "customer", "label": "Customer", "type": "string" },
375
+ { "id": "total", "label": "Total", "type": "number" }
376
+ ]
377
+ }
378
+ }
379
+ ]
380
+ }
381
+ ]
382
+ }
383
+ ```
384
+
385
+ ### Field groups and sections
386
+
387
+ A column's `group` and the table's `columnGroups` group the generated forms' fields, as `@Column({ group })` and `@ColumnGroup(id, config)` do: each group `{ label, description?, orientation?, order? }`, keyed by its id, gathered where its first column stands. A generated form has no sections.
388
+
389
+ ```json
390
+ {
391
+ "id": "customers-table",
392
+ "type": "TableView",
393
+ "options": {
394
+ "fetchUrl": "fixture:customers",
395
+ "caption": "Customers",
396
+ "columns": {
397
+ "name": { "name": "Name", "type": "string", "order": 1 },
398
+ "email": {
399
+ "name": "Email",
400
+ "type": "string",
401
+ "order": 2,
402
+ "group": "contact"
403
+ },
404
+ "phone": {
405
+ "name": "Phone",
406
+ "type": "string",
407
+ "order": 3,
408
+ "group": "contact"
409
+ }
410
+ },
411
+ "columnGroups": {
412
+ "contact": { "label": "Contact", "orientation": "horizontal" }
413
+ },
414
+ "rowActions": { "add": true, "edit": true, "details": true },
415
+ "formContainer": { "type": "drawer", "direction": "right" }
416
+ }
417
+ }
418
+ ```
419
+
420
+ A `ResourceForm` or a `Form` takes `sections`, each `{ id, label, description?, icon?, fields }`, with `sectionNav` `side`, `jump` or `none`, and field groups `{ id, label?, fields }` among a section's `fields`:
421
+
422
+ ```json
423
+ {
424
+ "id": "customer-details",
425
+ "type": "ResourceForm",
426
+ "options": {
427
+ "mode": "view",
428
+ "fetchUrl": "fixture:customers",
429
+ "sectionNav": "jump",
430
+ "sections": [
431
+ {
432
+ "id": "general",
433
+ "label": "General",
434
+ "icon": "i-ph-identification-card",
435
+ "fields": [
436
+ { "id": "name", "label": "Name", "type": "string" },
437
+ {
438
+ "id": "contact",
439
+ "label": "Contact",
440
+ "fields": [
441
+ { "id": "email", "label": "Email", "type": "string" },
442
+ { "id": "phone", "label": "Phone", "type": "string" }
443
+ ]
444
+ }
445
+ ]
446
+ }
447
+ ]
448
+ }
449
+ }
450
+ ```
451
+
452
+ ## Archive mode
453
+
454
+ `"archiveMode": true` draws the table as the real one in archive mode: a _Show archived_ toggle, Archive and Edit on the rows not archived, Restore on the archived ones. It draws no Duplicate or Delete. A row is archived when its `isArchived` is `true`; a fixture with no `isArchived` gets its last quarter archived. `archivedCountLabel` is the count while the archived rows show, `{count}` standing for their number. `rowActions.archive` or `rowActions.restore` at `false` turns one off. Either turned on without `archiveMode` is an issue.
455
+
456
+ ```json
457
+ {
458
+ "id": "invoices-table",
459
+ "type": "TableView",
460
+ "options": {
461
+ "fetchUrl": "fixture:invoices",
462
+ "caption": "Invoices",
463
+ "columns": {
464
+ "number": { "name": "Number", "type": "string" },
465
+ "total": { "name": "Total", "type": "number" }
466
+ },
467
+ "archiveMode": true,
468
+ "archivedCountLabel": "{count} archived invoices",
469
+ "rowActions": { "edit": true, "details": true },
470
+ "formContainer": { "type": "drawer", "direction": "right" }
471
+ }
472
+ }
473
+ ```
474
+
475
+ ## Connection access
476
+
477
+ A mockup over a connected database names the connection and its access at the top level, `access` being `read` (the default) or `read-write`, as `builder_mapping` answers it:
478
+
479
+ ```json
480
+ {
481
+ "version": 1,
482
+ "title": "CRM desk",
483
+ "data": { "connection": "crm", "access": "read" },
484
+ "pages": []
485
+ }
486
+ ```
487
+
488
+ With `read`, each option that writes rows is an issue at its pointer, and the save is refused: on a `TableView`, `rowActions` `add`, `edit`, `delete`, `archive`, `restore` or `duplicate` turned on, `archiveMode: true` and `kanban.draggable: true`; a `ResourceForm` in any `mode` but `view`. `rowActions.details` and an action at `false` stay allowed. With `read-write`, or no `data`, nothing is restricted. **dms-external-database** _Connection access_ says when the access may change.
489
+
490
+ ## Sketches
491
+
492
+ A sketch is the static HTML and CSS of one custom part, drawn hatched, outlined and labelled _Custom_. Keep it to the element alone; the blocks around it stay blocks.
493
+
494
+ - `html` is required; `height` is 80 to 3000 px (default 320); `caption` (up to 200 characters) says what the part does.
495
+ - It runs in a sandbox with no script: the spec refuses `<script>`, embedding elements, `on*` handlers, `<meta http-equiv>`, `@import`, `javascript:` and `vbscript:` URLs, any `url()` or `src` that is not a `data:` URL, any `href` that is not a `data:` URL, an `#anchor` or a page link, and any `target` the sketch writes.
496
+ - **Page link.** `<a href="page:<id>">`, on an HTML `<a>`, links to that spec page; an id no page has is an issue at the sketch's `html`. The link is followed in the viewer's Preview only: while editing, a click on the sketch selects it.
497
+ - **States.** `states` maps a name to another markup of the same part, drawn in place of `html` with the same `css`, `height` and `caption`: its empty, error or loading design. A name matches `^[a-z][a-z0-9-]{0,31}$` and is not `default`, which is `html` itself; a sketch holds at most 8 states. Each is checked as `html` is, page links included. The viewer's _State_ picker draws one, and a comment pinned while a state is drawn keeps its `state`.
498
+
499
+ ```json
500
+ {
501
+ "version": 1,
502
+ "pages": [
503
+ {
504
+ "id": "orders",
505
+ "title": "Orders",
506
+ "tree": [
507
+ {
508
+ "id": "delivery",
509
+ "type": "sketch",
510
+ "options": {
511
+ "html": "<ol class=\"steps\"><li>Ordered</li><li>Packed</li></ol><a href=\"page:order\">Open the order</a>",
512
+ "css": ".steps{display:flex;gap:12px}",
513
+ "height": 160,
514
+ "caption": "Delivery journey",
515
+ "states": {
516
+ "empty": "<p>No delivery yet.</p>",
517
+ "error": "<p role=\"alert\">The carrier did not answer.</p>"
518
+ }
519
+ }
520
+ }
521
+ ]
522
+ },
523
+ {
524
+ "id": "order",
525
+ "title": "Order",
526
+ "menu": false,
527
+ "parent": "orders",
528
+ "tree": []
529
+ }
530
+ ]
531
+ }
532
+ ```
533
+
534
+ ## Custom pages
535
+
536
+ A page with `"custom": true` is one whole-page sketch, drawn inside the real layout, and the build splits it into blocks (**dms-best-practices** _Custom pages are blocks_): the sidebar and the page header stay the dashboard's own, fed by its `title`, `icon`, `description` and `headerActions`. It takes the sketch's `html` (required), `css`, `height` (80 to 3000 px, default 800) and `states` at the page's level, under the rules of _Sketches_, and its `tree` is absent or `[]`. An `html`, `css`, `height` or `states` on a page of blocks is an issue. A comment on a custom page is a comment on the page.
537
+
538
+ ```json
539
+ {
540
+ "version": 1,
541
+ "pages": [
542
+ {
543
+ "id": "board",
544
+ "title": "Board",
545
+ "icon": "i-ph-kanban",
546
+ "custom": true,
547
+ "html": "<div class=\"lanes\"><section><h2>To do</h2><a href=\"page:card\">Fix the invoice</a></section></div>",
548
+ "css": ".lanes{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}",
549
+ "height": 1200,
550
+ "states": { "empty": "<p>No card yet.</p>" }
551
+ },
552
+ {
553
+ "id": "card",
554
+ "title": "Card",
555
+ "menu": false,
556
+ "parent": "board",
557
+ "tree": []
558
+ }
559
+ ]
560
+ }
561
+ ```
562
+
563
+ ## Sidebar widgets
564
+
565
+ `sidebar.widgets` sketches up to 10 widgets of the dashboard's sidebar that no module provides yet, such as a plan card or a help box, drawn in order below the dashboard's own widgets on every page. Each is `{ id, title?, html, css?, height? }`: `id` matches `^[a-z0-9][a-z0-9-]{0,63}$` and is unique among the widgets, `title` is its caption, `height` is 80 to 1200 px (default 120), and `html` and `css` follow the rules of _Sketches_. A widget cannot be selected or commented in the viewer: edit it in `spec.json`.
566
+
567
+ ```json
568
+ {
569
+ "version": 1,
570
+ "sidebar": {
571
+ "widgets": [
572
+ {
573
+ "id": "plan",
574
+ "title": "Your plan",
575
+ "html": "<div class=\"plan\"><strong>Pro</strong><span>3 of 10 seats left</span></div>",
576
+ "css": ".plan{display:flex;flex-direction:column;gap:4px;padding:10px}",
577
+ "height": 96
578
+ }
579
+ ]
580
+ },
581
+ "pages": []
582
+ }
583
+ ```
584
+
585
+ ## Generated fixtures
586
+
587
+ A fixture value `{ "$generate": { "rows"?: number, "fields": { "<key>": <Kind> } } }` makes the server fill the rows, so you type the field list and not the data. `rows` is 1 to 200, default 8. The rows are the same on every read for one mockup, page and key.
588
+
589
+ `Kind` is one of:
590
+
591
+ - `"id"`, `"name"`, `"email"`, `"company"`, `"city"`, `"text"`, `"date"` (in the last 30 days, so a "This week" view has rows), `"boolean"`;
592
+ - `{ "number": [min, max] }` or `{ "money": [min, max] }`;
593
+ - a non-empty array of strings: one value per row (use it for statuses and categories).
594
+
595
+ ```json
596
+ "fixtures": {
597
+ "orders": {
598
+ "$generate": {
599
+ "fields": {
600
+ "_id": "id",
601
+ "customer": "company",
602
+ "total": { "money": [40, 900] },
603
+ "status": ["paid", "pending", "refunded"]
604
+ }
605
+ }
606
+ }
607
+ }
608
+ ```
609
+
610
+ `fixture:orders` then reads 8 rows. A value that must read true (a KPI headline, a total another page repeats) is a plain JSON fixture or a `static*` option. A hand-written date stays as written.
611
+
612
+ ## Writing in steps
613
+
614
+ A mockup is written live, in saves small enough to show a change each. A save redraws the preview in under a second.
615
+
616
+ 1. Create the mockup empty, with its menu sections when it has them: `mockup_write_spec` with `{ "mockup": "<name>", "spec": { "version": 1, "title": "Order desk", "source": "claude-code", "categories": [{ "id": "sales", "title": "Sales", "icon": "i-ph-storefront" }], "pages": [] } }`. Each page added then names its `category`.
617
+ 2. Add a page as a skeleton, its blocks titled and its data generated: `mockup_patch_spec` with `{ "mockup": "<name>", "patch": [{ "op": "add", "path": "/pages/-", "value": { "id": "orders", "title": "Orders", "fixtures": { "orders": { "$generate": { "fields": { "customer": "company", "total": { "money": [40, 900] } } } } }, "tree": [{ "id": "orders-table", "type": "TableView", "options": { "fetchUrl": "fixture:orders", "caption": "Orders", "columns": { "customer": { "name": "Customer", "type": "string" }, "total": { "name": "Total", "type": "number" } } } }] } }] }`.
618
+ 3. Fill a section: one patch of 2 or 3 operations on the blocks that belong together, `replace` on a node's `options` or `add` at `/pages/<i>/tree/-`, `<i>` the page's index.
619
+
620
+ A patch applies whole or not at all: a failed one leaves the spec as it was, so fix it and send it again. After an `add` or `remove` that shifts a node, re-read the pointers you still use.
114
621
 
115
622
  ## Validation
116
623