@antelopejs/agent-skills 0.3.3-next.76.gc7cfa44 → 0.8.2

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.
@@ -17,39 +17,52 @@ The spec is the contract: the pages it lists, their blocks in its order, their o
17
17
 
18
18
  ## 1. Read the mockup
19
19
 
20
- Read `mockups/<name>/spec.json` and its open annotations ([SPEC.md](../dms-mockup/SPEC.md) _annotations.json_). An open annotation is a change the user still wants: ask whether to apply it first with **dms-mockup**, or to build the spec as it stands.
20
+ Read the spec with `mockup_read_spec` (`{ mockup, path? }`, read-only, allowed in Safe mode; `path` a JSON pointer, the whole spec when left out), else `mockups/<name>/spec.json` with the file tools. After this first read, read only the parts you need, and never probe the spec with JSON-patch `test` operations or temporary keys. Read its open annotations ([SPEC.md](../dms-mockup/SPEC.md) _annotations.json_). An open annotation is a change the user still wants: ask whether to apply it first with **dms-mockup**, or to build the spec as it stands.
21
21
 
22
22
  ## 2. Plan
23
23
 
24
24
  Map every spec page and node, and present the plan before you write:
25
25
 
26
26
  - **Converted page:** a spec page with `livePage: { ref, version }` was converted from the live page at `livePage.ref` (a route). Read that page with `builder_page_structure` (without the builder MCP, its page class) and plan the changes that turn it into the spec page (blocks to configure, move, remove or add), not a new `PageController`; its fixtures whose key is in the spec page's `liveRoutes` keep reading those live routes (_Live route_ below). A **live sketch**, a Custom sketch whose `id` names a block of the live page, stands for code the conversion could not express: keep that block as it is, with no component to write and no Safe mode question. Check its version first, as _Pages converted from a live page_ says: a stale page goes in the plan as stopped, with no changes. With `mockup_apply_to_page` among your tools, the plan still lists every change and says that the tool writes the page first, and that you build only the changes its `wiring` answer lists.
27
- - **Page** → a `PageController` (with `RegisterPage`, from `@antelopejs/interface-dms/page`): `id` and title from the spec page, an icon and a description as **dms-page-design** _Name every page_ says, a category the user confirms.
27
+ - **New page** (no `livePage`): built as a new page, below. A converted page (`livePage`) is built into its live page, never as a new page.
28
+ - **Page** → a `PageController` (with `RegisterPage`, from `@antelopejs/interface-dms/page`): `id`, title, `icon` and `description` from the spec page (pass `icon` and `description` to `builder_create_page`; when the spec page has none, choose them as **dms-page-design** _Name every page_ says), and the category its `category` names.
29
+ - **Sub-page** (`parent`) → a page registered under its parent's route, its `route` as the parameter (`urlSlug: "orders/:id"`), with `parent` naming the parent's page class, in the parent's category; `menu: false` → `hidden: true`, left out of the menu. The builder writes neither a route parameter nor a `parent`: write the page class with **dms-pages**, then build its blocks as any page's. A `fixture:<key>` on it that reads an ancestor's rows reads the one record its parameter names (`{{params.id}}`).
30
+ - **Sections** (`categories`) → one sidebar section per mockup category, in the spec's order, its `name` the section's `id`, its `displayName`, `icon` and `order` from the spec: `builder_create_category` with `section: true` (and the pages' `module`), never a plain category, which loses the section; without the builder, a `RootCategory(id, { displayName, icon, order, type: "label" })` with **dms-pages**. A section whose `title` is an existing category's (`builder_list_pages`), case and spaces aside, is that category: its pages go there and no category is created. A page with no `category` goes in the category the project's pages use already. A spec of 6 or more pages with no `categories` gets the sections **dms-page-design** _Group pages into sections_ gives it, listed in the plan.
31
+ - **Dashboard:** a build over a database always builds the dashboard **dms-page-design** _The analytics dashboard_ requires, from the spec's dashboard page, each KPI card and chart bound to a query over a mapped relation. A spec over a database with no dashboard gets one in the plan, laid out as that skill says.
32
+ - **Header buttons** (`headerActions` of the spec page) → `DefaultLayout({ headerActions: [...] })` in the page TypeScript, each button's `label`, `icon`, `color` and `variant` from the spec plus a real `target` (a page link, a quick action, a drawer or an API call): the builder cannot write a page's layout. A target the spec and the conversation do not settle is a question for the user; never invent one. On a converted page, `mockup_apply_to_page` writes `title`, `icon` and `description` itself and lists the header buttons as a `wiring` entry (`reason: "header-actions"`); keep the live page's `hideHeader` as it is.
28
33
  - **Block** → the same `type` and options. Keep each child's `id` as the block's name; a child whose `id` names a block option (a `ChartCard`'s `chart`) becomes that option.
34
+ - **Page link** (`page:<id>` in any option) → the real route of the page built from that spec page; a row's link to a page with a route fills the parameter from the row's `rowIdKey` (`/orders/{{row._id}}`). `rowClick` and `isDefault` stay as written.
29
35
  - **Live route:** on a converted page, a `fixture:<key>` whose key is in the page's `liveRoutes` reads that route: the block's fetch option (such as `fetchUrl`) takes it in place of the fixture's `static*` option, and a live `TableView` or `ResourceForm` keeps its `controller`; a block the spec adds follows the _Fixture_ rules. This comes before the _Fixture_, `TableView` and `ResourceForm` rules.
30
36
  - **Fixture**, or a `static*` option → the real data it stands for, by the first that holds:
31
37
  1. an existing resource or route serves it (`builder_list_resources`, the project's controllers): bind to it;
32
- 2. rows of one entity: a new resource (`builder_create_resource`), its fields and types read from the fixture's rows, seeded with those rows only when the user wants sample data;
38
+ 2. rows of one entity (a `$generate` fixture is one: its `fields` are the entity's fields): a new resource (`builder_create_resource`), its fields and types read from the fixture's rows or its `fields`, seeded with those rows only when the user wants sample data;
33
39
  3. a figure, a series or a ranking: a query on that resource (`builder_add_query`) whose `response` matches the block, as **dms-builder-mcp** _Data resources and queries_ says.
34
40
  A fixture none of these can serve goes in the plan as a question.
35
- - **`TableView` over a fixture** → a `TableView` bound to the resource (`controller` = its ref), its columns from the spec's `columns`.
36
- - **`ResourceForm` over a fixture** → a `ResourceForm` on the resource, with the spec's fields.
37
- - **Sketch** → a `CustomComponent` (from `@antelopejs/interface-dms/base/custom`) with `.meta({ name, description, icon })`, its Vue drawn from the sketch's HTML and CSS with the DMS UI components and theme variables, its data from a route. In Safe mode this is out of reach: ask whether to turn Safe mode off for these components, or to leave each one as a `Placeholder` named after its caption.
41
+ - **`TableView` over a fixture** → a `TableView` bound to the resource (`controller` = its ref), its columns from the spec's `columns`, with every badge, price, tab, board, card and view the mockup shows. A table over a relation of a connected database is mapped with `builder_map_resources`, as **dms-external-database** _Apply_ says: leave out each badge the Builder proposes (it writes the real values and tones, where the spec's items are fixture values), send a price with its `currency`, and turn `tabsFrom` into the resource's `tabs` and the board, groups, cards, `defaultDisplay` and `views` into `tableOptions`, renamed as [SPEC.md](../dms-mockup/SPEC.md) _Tables_ says, with its section's ref as `category` and the spec page's `title`. Another table takes the spec's displays as they are, its board and views through `builder_configure_table_view`. A colour or display the builder cannot write (a badge the Builder does not propose over a column with no native enum, a `mobileDisplay`) is a question in the plan, never dropped. Build a column's cell display (`display: { type, options }` such as `mono`, `two_line`, `identity`), `group`, `isVisible`, `size` and `cellWrap` through the builder in Safe mode too: in `builder_map_resources` `fields` at mapping time, else `builder_configure_field` (or `builder_add_field`, `builder_create_resource` `fields`), as **dms-builder-mcp** _Column presentation_ says. Build the spec's `columnGroups` with `builder_configure_column_groups`. A rating stays a badge, never a cell display. An `invalid_config` or `relation_skipped` on a display is a question in the plan, never dropped.
42
+ - **Table forms** (`rowActions`, `formContainer`) → the same actions on the real table, and `false` for each of `add`, `edit` and `details` the spec leaves out: the real `TableView` turns an absent one on. A table with no `formContainer` showed a modal: write `{ "type": "modal" }`, as **dms-page-design** _Records, forms and links_ says. `modal` and `drawer` stay as written, `size` and `direction` included, `details: true` in them being the table's own read-only details view, with no page to build. With `page`, each `urlSlug: "page:<id>"` becomes that page's slug relative to the table's page (`new`, `:id/edit`, `:id`), `customPage: true` kept, and the form page is a _Sub-page_ registered at that slug (`orders/new`). The add and edit forms save through the table's data controller. Write them with `builder_configure_block` on the table, or in the page class.
43
+ - **Archive mode** (`archiveMode`, `archivedCountLabel`) → the same options on the real table, its resource's archive field `isArchived` (`@ArchiveField`).
44
+ - **Connection** (`data`) → the spec's `access` checked against the one `builder_mapping` answers for its `connection`. A spec at `read-write` over a `read` connection goes in the plan as a question, as **dms-external-database** _Connection access_ says; build no write action before it is settled. At `read-write`, the table's actions the spec draws are built on relations mapped `writable: true`, as **dms-external-database** _Editable_ says; one whose `writes` forbids an action the spec draws goes in the plan as a question.
45
+ - **`ResourceForm` over a fixture** → a `ResourceForm` on the resource, with the spec's fields and `mode` (`view` on a details page, read-only).
46
+ - **Sketch** → a `CustomComponent` (from `@antelopejs/interface-dms/base/custom`) with `.meta({ name, description, icon })`, its Vue drawn from the sketch's HTML and CSS with the DMS UI components and theme variables, its data from a route. It draws every one of the sketch's `states` where the page meets it (no rows, a failed request, loading) and the default `html` where the data is there; each `<a href="page:<id>">` is a link to that page's real route (_Page link_). In Safe mode this is out of reach: ask whether to turn Safe mode off for these components, or to leave each one as a `Placeholder` named after its caption.
47
+ - **Custom page** (`custom: true`) → a _Page_ built as **dms-best-practices** _Custom pages are blocks_ says: split the page's `html` into its parts, each a block, and only a part no block draws a `CustomComponent`, built from its markup, `css` and `states` as a _Sketch_ is. Its title, icon, description and header buttons are the page's own. Safe mode as for a _Sketch_, each such part a `Placeholder` named after it.
48
+ - **Sidebar widget** (`sidebar.widgets`) → a Vue component of the module's frontend layer, drawn from the widget's `html` and `css` as a _Sketch_ is, registered with `sdk.registerComponent`, and a plugin (`sdk.registerPlugin`) whose `defineDmsPlugin` calls `useSidebarWidgets().register({ id, component, position: SidebarWidgetPosition.BELOW_SEARCH_BAR })`, in the spec's order (`order`). It receives `collapsed` and draws nothing on the folded rail. The docs are `https://dms.antelopejs.com/docs/extending-the-dashboard/widgets-and-overlays`. In Safe mode this is out of reach: ask whether to turn Safe mode off for it or to leave it out, and report it left out.
38
49
 
39
50
  The plan lists per page:
40
51
 
41
52
  - **Build (`builder_compose_page`):** for a new page, `builder_create_page`, then one `builder_compose_page` call with the whole tree; for a converted page, the block changes on `livePage.ref`, through `mockup_apply_to_page` first when you have it; without the builder MCP, the page class.
42
- - **Blocks:** in the spec's order, with their options.
53
+ - **Sections (`categories`):** the categories to create, and each page's.
54
+ - **Blocks:** in the spec's order, with their options; each table with its displays, tabs, board, views and forms; each link with its real route.
55
+ - **Sub-pages:** each with its parent, its slug and whether the menu lists it.
43
56
  - **Data (`liveRoutes`):** per fixture, its route from `liveRoutes` on a converted page, else the resource or query it binds to; the resources and queries to create.
44
- - **Components (`CustomComponent`):** a `CustomComponent` for each sketch other than a live sketch, or its `Placeholder` in Safe mode.
57
+ - **Components (`CustomComponent`):** a `CustomComponent` for each sketch other than a live sketch and each part of a custom page no block draws, or its `Placeholder` in Safe mode, with the states each one draws; the sidebar widgets, once for the app.
45
58
 
46
59
  Write nothing before the user approves it.
47
60
 
48
61
  ## 3. Build
49
62
 
50
- Per page, in the spec's order:
63
+ Create the sections first, then each page, in the spec's order:
51
64
 
52
- - **Builder MCP:** for a new page, `builder_create_page`, then one `builder_compose_page` call with the page's whole tree, previewed first (`"preview": true`) as **dms-page-design** _Build a page in one call_ says. Create the resources and queries the page reads before the page.
65
+ - **Builder MCP:** for a new page, `builder_create_page`, then one `builder_compose_page` call with the page's whole tree, previewed first (`"preview": true`) as **dms-page-design** _Build a page in one call_ says. Create the resources and queries the page reads before the page. A page whose table maps a database relation is written by `builder_map_resources` instead: add its other blocks with `builder_compose_page` on that page's `pageRef` and a `placement`.
53
66
  - **Code:** write the page class, its routes and DataControllers with **dms-pages**, then run the typecheck. Page code imports from `@antelopejs/interface-dms` and the other interface packages **dms-pages** names, never from `@antelopejs/dms`, which exports no page API.
54
67
  - **Custom components:** with **dms-pages**, after the builder's write; then `builder_refresh` on the page when the builder MCP answers.
55
68
 
@@ -57,7 +70,7 @@ A page is built when it typechecks and, checked as **dms-builder-mcp** _Verify_
57
70
 
58
71
  ### Pages converted from a live page
59
72
 
60
- `livePage.version` is the `version` (a hash of the page's source file) that `builder_page_structure` answered at conversion. Compare it with the `version` of `builder_page_structure` on `livePage.ref` for every converted page, when you plan and again before the first write of the build, resources and queries included. A different `version` means the page changed in code since "Edit as mockup": the page is **stale**. Write nothing to it, and ask the user one question that says so and offers to convert it again (`mockup_from_page` with `{ pageRef: livePage.ref, replace: true }`, which discards the mockup's edits) or to build anyway. After a new conversion, start again at step 1. Build anyway only on the user's explicit go: read the structure again and apply the mockup's edits by block name only. The spec's other pages build as planned. Without the builder MCP there is no `version` to compare: build through the code and tell the user the page could not be checked.
73
+ `livePage.version` is the `version` (a hash of the page's source file) that `builder_page_structure` answered at conversion. Compare it with the `version` of `builder_page_structure` on `livePage.ref` for every converted page, when you plan and again before the first write of the build, resources and queries included. A different `version` means the page changed in code since its conversion: the page is **stale**. Write nothing to it, and ask the user one question that says so and offers to convert it again (`mockup_from_page` with `{ pageRef: livePage.ref, replace: true }`, which discards the mockup's edits) or to build anyway. After a new conversion, start again at step 1. Build anyway only on the user's explicit go: read the structure again and apply the mockup's edits by block name only. The spec's other pages build as planned. Without the builder MCP there is no `version` to compare: build through the code and tell the user the page could not be checked.
61
74
 
62
75
  **With `mockup_apply_to_page`** among your tools, call it for each converted page before any other write for that page, its resources and queries included: `mockup_apply_to_page({ mockup: "<name>", page: "<spec page id>" })`. It checks the version again itself; your compare before the first write of the build stays.
63
76
 
@@ -83,11 +96,11 @@ Without the tool, write the page yourself. An existing block whose fixture key i
83
96
 
84
97
  Every write of yours to a converted page, a `wiring` entry included, updates the page at `livePage.ref`, never another: no `builder_create_page`. Move a live sketch's neighbours around it, never the block itself. A builder tool's `stale` answer (your read of the structure is outdated): read the page again with `builder_page_structure` and retry. A builder tool's `not_found` answer for the page: ask the user; never create it.
85
98
 
86
- After the last round of step 4, stamp each converted page you wrote yourself (a `wiring` entry, a fix, or the whole page without the tool) with its new version; a page only `mockup_apply_to_page` wrote, answering `stamped: true`, keeps the tool's stamp. Read the version with a fresh `builder_page_structure` and write it with `mockup_patch_spec`: `{ "mockup": "<name>", "patch": [{ "op": "replace", "path": "/pages/<i>/livePage/version", "value": "<version>" }] }`, `<i>` the page's index in the spec. Without `mockup_patch_spec`, set that field in `spec.json`. Without the builder MCP, stamp nothing.
99
+ After the last round of step 4, stamp each converted page you wrote yourself (a `wiring` entry, a fix, or the whole page without the tool) with its new version; a page only `mockup_apply_to_page` wrote, answering `stamped: true`, keeps the tool's stamp. Read the version with a fresh `builder_page_structure` and write it with `mockup_patch_spec`: `{ "mockup": "<name>", "patch": [{ "op": "replace", "path": "/pages/<i>/livePage/version", "value": "<version>" }] }`, `<i>` the page's index in the spec. Without `mockup_patch_spec`, set that field in `spec.json`. Without the builder MCP, stamp nothing. A patch refused for a value outside an enum's allowed values: pick the closest allowed value the error lists, send it, and mention the substitution in your report; ask the user only when none is close.
87
100
 
88
101
  ## 4. Verify and fix
89
102
 
90
- A **round** verifies pages, then fixes what failed. Keep going while a page fails, up to **three rounds**: round 1 verifies every page of the plan, each later round the pages that failed before and every page a fix changed, and after the third verify you fix nothing more. A page passes when its last verify, leaving out the lines of its live sketches, finds no failure (with `page_verify`, `ok` or failing only on those lines) and no difference from the mockup, or only differences the user accepted. A page of the plan that was never built, or does not typecheck, fails with that error. A **difference** is a block missing, extra or out of order, another type, another option (title, format, variant, span, columns), a sketch whose component looks otherwise, or a block empty on the real page. Values that differ because real data replaced a fixture are no difference; a block empty where its fixture had data is one. A live sketch's lines are never differences nor fix targets: its sketch with no counterpart, its live block in `extraPageBlocks` or in a failure line. Report them under the live sketches kept, outside `<n>`.
103
+ A **round** verifies pages, then fixes what failed. Keep going while a page fails, up to **three rounds**: round 1 verifies every page of the plan, each later round the pages that failed before and every page a fix changed, and after the third verify you fix nothing more. A page passes when its last verify, leaving out the lines of its live sketches, finds no failure (with `page_verify`, `ok` or failing only on those lines) and no difference from the mockup, or only differences the user accepted. A page of the plan that was never built, or does not typecheck, fails with that error. Over a database, the dashboard fails when it is missing or when a KPI card or chart on it reads no query over a mapped relation (a `static*` value or a fixture left). A **difference** is a block missing, extra or out of order, another type, another option (title, format, variant, span, columns, a column's display, the tabs, a display mode, a view), a link, a sub-page or a form the mockup has and the real page lacks, a sketch or a custom page whose component looks otherwise, lacks one of its states or links elsewhere, a custom page built as one full-page `CustomComponent`, a sidebar widget missing or drawn otherwise, or a block empty on the real page. Values that differ because real data replaced a fixture are no difference; a block empty where its fixture had data is one. A live sketch's lines are never differences nor fix targets: its sketch with no counterpart, its live block in `extraPageBlocks` or in a failure line. Report them under the live sketches kept, outside `<n>`.
91
104
 
92
105
  **With `page_verify`**, per page:
93
106
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dms-page-design
3
- description: Designs AntelopeJS DMS pages that show data. Use when building or changing an analytics, stats or dashboard page or a table page, choosing a chart or a KPI for some data, picking a page's period, naming a page and its icon, or deciding how a table displays (badges, prices, relation labels, status tabs, saved views, kanban, cards, footer totals, KPI cards above the table).
3
+ description: Designs AntelopeJS DMS pages that show data. Use when building or changing an analytics, stats or dashboard page or a table page, choosing a chart or a KPI for some data, picking a page's period, naming a page and its icon, grouping an app's pages into menu sections, giving a list its details view and forms, linking pages together, or deciding how a table displays (badges, prices, relation labels, status tabs, saved views, kanban, cards, footer totals, KPI cards above the table).
4
4
  ---
5
5
 
6
6
  # Designing data pages
@@ -53,6 +53,23 @@ arguments are in `dms-builder-mcp`, the code in `dms-pages`.
53
53
  - Grouping by a foreign key shows ids. Group by the relation's own columns only; a breakdown by
54
54
  a related entity's name goes under _Not possible yet_ in your report.
55
55
 
56
+ ## The analytics dashboard
57
+
58
+ An app over an external database always has an analytics dashboard, asked for or not: every
59
+ plan, mockup and build over that data proposes and builds it.
60
+
61
+ - It holds `KpiCard`s and charts over real aggregates of the relations: sums of their measures
62
+ and row counts, over their time axis and their category columns. A build reads each one
63
+ through a query on a mapped relation, never a `static*` value; a mockup's fixtures stand for
64
+ those queries.
65
+ - It is laid out as _Lay out an analytics page_ says and sits first in the menu (`order: 0`),
66
+ outside every section.
67
+ - An app of 3 or more sections may also give each section a dashboard of its own, first in
68
+ that section.
69
+
70
+ An app over a database is not done without that dashboard, or with one whose figures are not
71
+ aggregates of the data.
72
+
56
73
  ## Lay out an analytics page
57
74
 
58
75
  Add the blocks in this order. Every analytics page has items 1 to 4.
@@ -115,6 +132,22 @@ never a title.
115
132
  Set them with `builder_create_page` on new pages, per resource in `builder_map_resources`
116
133
  (`title`, `icon`, `description`, `order`), or with `builder_configure_page` afterwards.
117
134
 
135
+ ## Group pages into sections
136
+
137
+ An app of 6 or more pages is grouped into 2 to 5 **sections** by job, each titled in the
138
+ owner's words with an icon of its own: Sales (Orders, Payments, Coupons), Catalog (Products,
139
+ Categories), Customers (Customers, Reviews, Support tickets). Each section holds 2 to 6 pages;
140
+ a page with no partner joins the nearest section. The main dashboard sits on top, outside every
141
+ section: it stays in the category it is created in. A section's own dashboard (_The analytics
142
+ dashboard_) sits first in its section. An app of fewer pages has no sections. You decide the sections; the user edits them.
143
+ A page that belongs in a section the project has already goes there: in a mockup, a section of
144
+ that exact title, which the viewer draws as the app's own.
145
+
146
+ A section is a menu category: `builder_create_category` (`name`, `displayName`, `icon`,
147
+ `order`, `module`, and `section: true` for a sidebar section, a `RootCategory`) answers its `ref`, which `builder_create_page` takes as `category`,
148
+ `builder_map_resources` per resource as `category` (create the section first, in the tables'
149
+ `module`), and `builder_configure_page` in `{ "category": "<ref>" }` to move a page there.
150
+
118
151
  ## Tables
119
152
 
120
153
  A table page is a working tool: the reader finds a row, sees its state, and acts. Read the
@@ -124,6 +157,9 @@ rule below names the shape that earns the feature; decide from the columns' type
124
157
  distinct counts, never from the relation's name. You never read a row's values: a value you
125
158
  name comes from the schema, as a native enum's label.
126
159
 
160
+ **Caption.** Every table has a caption, the title above its rows: its page's title for the
161
+ page's main table, the question it answers otherwise ("Orders awaiting shipment").
162
+
127
163
  **Columns.** A primary key gets no display and is never a row's label. A boolean keeps its
128
164
  default display (no badge). A column that a view filters on, a tab splits on, or a footer
129
165
  `where` reads must be `filterable` in the mapping; one that a view sorts on, `sortable`.
@@ -142,6 +178,7 @@ with none, send `"display": null`, which leaves it a number. A relation
142
178
  column (a `customer_id`, an `order_id`) is titled by its target ("Customer") and shows the
143
179
  target's label, never the raw number: map the target relation with a label first, then send
144
180
  the relation column as a relation. Raw id columns stay off the list. A `display` you do send, and the relation's `tabs`, go in `builder_map_resources`.
181
+ A cell display (`mono`, `two_line`, `identity`, `progress`...), `group`, `isVisible`, `size` and `cellWrap` go in the same `fields`, else `builder_configure_field`: no code needed, Safe mode included.
145
182
 
146
183
  **Tabs.** A single-choice column with 2 to 6 values that splits the rows into states people
147
184
  work through (a status, a stage) gives tabs when the column is drawn as a badge, by the
@@ -159,8 +196,9 @@ first, the highest amount first). Each view has a short label that states the qu
159
196
  top, and `count: true` when the number itself matters. Keep views and tabs from repeating each
160
197
  other: views for questions that cross columns or dates, tabs for the plain split by state.
161
198
 
162
- **Display modes.** Offer another display when the data reads better that way, and make it the
163
- default only when it is the main way to work the table:
199
+ **Display modes.** Offer another display when the data reads better that way. The default
200
+ display (`defaultDisplay`) is the kanban for a status workflow, the cards for a catalogue whose
201
+ rows carry an image, and the table otherwise:
164
202
 
165
203
  - **Kanban** (`kanban.groupBy`) when a single-choice status or stage column drawn as a badge
166
204
  (by the Builder or over a native enum) describes a flow
@@ -182,13 +220,86 @@ that number is what the reader checks ("Refunded"). Never sum a unit price, a ra
182
220
  amount, rows waiting, a share of a status, the last two over a native enum label), put a `GridRow` of 3 or 4 `KpiCard`s above the
183
221
  `TableView`, each answering one question the table's reader asks ("Revenue this month",
184
222
  "Awaiting shipment", "Refund rate"), with the series and `compare` rules above. A lookup list
185
- (a reference table, tags, settings) gets none.
223
+ (a reference table, tags, settings) gets none. A card's change figure (`delta`, `previousValue`) shows only on a page with a `PeriodSelector`: on a table page without one the card shows no change figure; add a `PeriodSelector` only when the user wants change figures.
186
224
 
187
225
  Set displays, views and footer per resource as `tableOptions` in `builder_map_resources`, or on
188
226
  an existing page with `builder_configure_table_view`. Through `builder_configure_table_view`
189
- a refused choice comes back as `invalid_config` with the setting it names: fix that one and
227
+ a refused choice comes back as `invalid_config` with the setting it names (for an enum value, the allowed ones: take the closest yourself and mention it in your reply, as **dms-builder-mcp** _Errors_ says): fix that one and
190
228
  send again. Through `builder_map_resources` it comes back as a `page_not_written` warning.
191
229
 
230
+ ## Records, forms and links
231
+
232
+ An app clicks through: from a figure to its rows, from a row to its record, and back.
233
+
234
+ - **A record needs a details view.** A list whose records the reader acts on (opens, edits,
235
+ approves, follows up) gets one; a lookup list (tags, settings, reference data) gets none.
236
+ - **Pick each table's details view and its add and edit forms.** When the user named none,
237
+ pick the most usable one per table from the tables below, and state each choice in your plan
238
+ or summary ("Customers: details, add and edit in a right drawer"). A mockup shows
239
+ it, so the user can change it. The real `TableView` with no `formContainer` opens a page per
240
+ form: write the chosen container explicitly, with `builder_configure_block` on the table or
241
+ in the page class.
242
+
243
+ | Details view | When |
244
+ | ----------------------------------------------------------- | ----------------------------------------------- |
245
+ | `{ "type": "modal" }`, `size` `sm` to `full` (default `xl`) | about 8 fields or fewer, a quick look |
246
+ | `{ "type": "drawer", "direction": "right" }` | reading a row while the list stays in view |
247
+ | `{ "type": "drawer" }` (`direction: "bottom"`, the default) | wide content, such as line items or a sub-table |
248
+ | `{ "type": "page" }`, a generated page | a long record, or one people share by link |
249
+
250
+ | Add and edit forms | When |
251
+ | -------------------------------------------- | ----------------------- |
252
+ | `{ "type": "modal" }` | up to about 6 fields |
253
+ | `{ "type": "drawer", "direction": "right" }` | 7 to 15 fields |
254
+ | `{ "type": "page" }`, a generated page | long or sectioned forms |
255
+
256
+ One table has one `formContainer`: when its details view and its forms point at different
257
+ containers, take the one for the forms when people edit rows, else the one for the details.
258
+
259
+ - **Group the fields.** Related fields (contact, address, billing) share a group. A generated
260
+ form groups the columns `@ColumnGroup(id, config)` and `@Column({ group })` declare; a mockup
261
+ writes a column's `group` and the table's `columnGroups`. A `ResourceForm` or a `Form` takes
262
+ `sections` (`{ id, label, description?, icon?, fields }`) with `sectionNav` `side`, `jump` or
263
+ `none`, and field groups `{ id, label?, fields }` inside them.
264
+ - **A custom details page is the user's call.** A details page of blocks, such as a `StatGroup`
265
+ or `KpiCard`s above a `ResourceForm` in `mode: "view"`, or the record's related lists, is
266
+ never chosen unasked. When it would clearly help, suggest it in one sentence ("a details page
267
+ could show the order's KPIs above the record, want it?") and build it only on a yes: a
268
+ sub-page of the list, left out of the menu, that opens on a click on its row, built as
269
+ **dms-best-practices** _Custom pages are blocks_ says.
270
+ - **Turn on only the actions the reader takes.** A connected database's table writes only on a
271
+ `read-write` connection, as **dms-external-database** _Connection access_ says. On one,
272
+ propose each table's write actions from its `writes` and its shape, and the integrator
273
+ confirms them in the plan:
274
+ - **Transactions are never erased.** Sales, orders and their lines, invoices, credit notes,
275
+ refunds, stock movements: no delete and no archive, whatever `writes` allows. Add and edit
276
+ where `writes` allows them and the reader records them by hand (an order's status, a
277
+ note).
278
+ - **Logs stay read-only.** Payments, log, event, history and audit tables: no write action.
279
+ - **Entities and lookups** (customers, products, categories, tags) get add and edit where
280
+ `writes.insert` and `writes.update` allow them.
281
+ - **Delete only a row nothing depends on**: where `writes.delete` allows it and no other
282
+ table references this one through a foreign key (an incoming relation in the analysis or
283
+ in `database_describe`). A referenced table gets no delete; it gets the archive below
284
+ when it has an archive column, and neither otherwise.
285
+ - An action `writes` forbids is not proposed; the plan says which and why, and why a table
286
+ gets no delete or archive.
287
+ - **Archive in place of delete** when records must not be erased but may leave the lists
288
+ (people, products, a referenced lookup), never on a transaction:
289
+ `archiveMode: true` on the `TableView` gives Archive and Restore: archive, edit and duplicate
290
+ on active rows, restore and delete on archived ones, behind a _Show archived_ toggle. The
291
+ archive field is `isArchived` (`@ArchiveField` in code). Only on a table that writes rows, so
292
+ over a connected database only on `read-write`, and only where the table has an archive
293
+ column (`archived`, `is_archived`, `archived_at`). A table with none gets no archive.
294
+ - **Link pages together.** Every summary links to what it summarises: a KPI or a card to the
295
+ table it counts, a dashboard tile to its page, a detail page back to its list, a toolbar
296
+ button to the page it opens. `KpiCard` takes no link: a figure that links is a `StatGroup`
297
+ cell (`to`), or sits in a `Card` whose head action (`actions: [{ label, to }]`) opens the
298
+ table.
299
+
300
+ A mockup writes these as [SPEC.md](../dms-mockup/SPEC.md) _Links and sub-pages_, _Table
301
+ forms_ and _Archive mode_ say.
302
+
192
303
  ## Build a page in one call, and check it first
193
304
 
194
305
  Build every page, or every set of blocks added to a page, with one `builder_compose_page` call:
@@ -31,7 +31,7 @@ export class RecipesPage extends PageController("recipes", {
31
31
  }) {}
32
32
  ```
33
33
 
34
- `options` is the `MenuOptions` shape: `displayName`, `icon`, `module` and/or `category` (at least one; a module page's explicit category descends from the module's root), `urlSlug` (defaults to the id), `order`, `description`, `hidden`, `type`, plus auth options (`publicAccess`, `authOnly`, `memberAccess`, `permission`, `noComponentPermissions`, `ownerOnly`; see **dms-auth**). `ownerOnly: true` opens the page to the platform owner only, as on a module page: no role can be granted it, and the Roles editor does not list it. `Category(id, options)` returns a `CategoryInfo` for a page's `category`; `RegisterModule({ id, … })` creates a module root that pages join with `module: "<id>"`. Module pages live under `/modules/<moduleId>/<urlSlug>` and are **owner-only by design**: a screen for regular users goes under `pagesCategory` or a normal `Category`.
34
+ `options` is the `MenuOptions` shape: `displayName`, `icon`, `module` and/or `category` (at least one; a module page's explicit category descends from the module's root), `urlSlug` (defaults to the id), `order`, `description`, `hidden`, `type`, plus auth options (`publicAccess`, `authOnly`, `memberAccess`, `permission`, `noComponentPermissions`, `ownerOnly`; see **dms-auth**). `ownerOnly: true` opens the page to the platform owner only, as on a module page: no role can be granted it, and the Roles editor does not list it. `Category(id, options)` returns a `CategoryInfo` for a page's `category`; `RootCategory(id, { displayName, icon, order, type: "label" })` returns one for a sidebar section, a heading of its own beside Pages, Modules and Settings (`pages`, `modules` and `settings` are reserved ids); `RegisterModule({ id, … })` creates a module root that pages join with `module: "<id>"`. Module pages live under `/modules/<moduleId>/<urlSlug>` and are **owner-only by design**: a screen for regular users goes under `pagesCategory` or a normal `Category`.
35
35
 
36
36
  ## Composing blocks
37
37
 
@@ -73,7 +73,7 @@ export class SubmitRecipePage extends PageController("submit-recipe", {
73
73
 
74
74
  Blocks pull data from URLs. Declare routes with the `@antelopejs/interface-api` decorators (`Controller`, `Get`, `Post`, `@Parameter`, `@JSONBody`); return a plain object for 200 or throw `new HTTPResult(status, body)`. `GetModel(Model)` (from `@antelopejs/interface-database-decorators`) gives `get`, `getAll`, `insert`, `update` and `delete`. Routes under a controller that a page or DataController wraps **inherit** its auth (see **dms-auth**). A route declared on a page class is served under `/dms/pages`, not at the page's own path: name it with `pageRoutePath(slug, "/route")` from `@antelopejs/interface-dms/page` in a `fetchUrl` or `submitUrl`. A plain `Controller` the frontend calls sits under `/api/<module>/`.
75
75
 
76
- A **`TableView` is normally backed by a `DataController`**: a class `extends DataController(TableClass, TableViewRoutes.All, Controller("/path"))` registered with `@RegisterDataController()` (both from `@antelopejs/interface-data-api`). `TableClass` is a `Table` declared with `@RegisterTable(name, schema)` from `@antelopejs/interface-database-decorators`. `TableViewRoutes` (from `@antelopejs/interface-dms/base/table-view`) has the presets `Get`, `List`, `Select`, `Count`, `New`, `Edit`, `Delete`, `Archive`, `Restore` and `All`. Field decorators: `@Column`, `@Select`, `@Exported`, `@ArchiveField`, `@Searchable` from `@antelopejs/interface-dms/base` (plus class-level `@ColumnGroup(id, config)`), `@Listable` and `@Sortable` from `@antelopejs/interface-data-api/metadata`. Read a real one first: `@antelopejs/interface-dms/data-controllers` (`members`); guide in `docs/components/data-controller`. Database rows carry **`_id`** as the primary key: return and type it as `_id`.
76
+ A **`TableView` is normally backed by a `DataController`**: a class `extends DataController(TableClass, TableViewRoutes.All, Controller("/path"))` registered with `@RegisterDataController()` (both from `@antelopejs/interface-data-api`). `TableClass` is a `Table` declared with `@RegisterTable(name, schema)` from `@antelopejs/interface-database-decorators`. `TableViewRoutes` (from `@antelopejs/interface-dms/base/table-view`) has the presets `Get`, `List`, `Select`, `Count`, `New`, `Edit`, `Delete`, `Archive`, `Restore` and `All`. Field decorators: `@Column`, `@Select`, `@Exported`, `@ArchiveField`, `@Searchable` from `@antelopejs/interface-dms/base` (plus class-level `@ColumnGroup(id, config)`), `@Listable` and `@Sortable` from `@antelopejs/interface-data-api/metadata`. Read a real one first: `@antelopejs/interface-dms/data-controllers` (`members`); guide in `docs/components/data-controller`. Database rows carry **`_id`** as the primary key: return and type it as `_id`. A table's details view and forms open where **dms-page-design** _Records, forms and links_ decides (`formContainer`), and a table over a connected database writes only as **dms-external-database** _Connection access_ allows.
77
77
 
78
78
  ## DataTypes
79
79