@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/agent-skills",
3
- "version": "0.3.3-next.76.gc7cfa44",
3
+ "version": "0.8.2",
4
4
  "description": "Finds the agent skills that AntelopeJS packages ship, so every tool that loads them sees the same ones.",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -40,12 +40,6 @@
40
40
  "provenance": true,
41
41
  "registry": "https://registry.npmjs.org/"
42
42
  },
43
- "scripts": {
44
- "typecheck": "tsc -p .",
45
- "prepack": "node scripts/pack-skills.mjs",
46
- "postpack": "node scripts/pack-skills.mjs --clean",
47
- "release": "release-it"
48
- },
49
43
  "devDependencies": {
50
44
  "@types/node": "^24.0.0",
51
45
  "release-it": "^19.2.4",
@@ -54,5 +48,10 @@
54
48
  },
55
49
  "engines": {
56
50
  "node": ">=20.19"
51
+ },
52
+ "gitHead": "609c269e4e8002683baa84ca5e7d3fafc809a8a4",
53
+ "scripts": {
54
+ "typecheck": "tsc -p .",
55
+ "release": "release-it"
57
56
  }
58
- }
57
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dms-best-practices
3
- description: Enforces the rules for building AntelopeJS DMS pages (every page a tree of DMS blocks, custom code only for the missing block, `.meta()` on every custom block), decides when to leave DMS blocks and proposes that deviation to the user, and runs the design-fidelity protocol. Use when creating or changing any DMS page, dashboard or screen, before writing a CustomComponent or Vue for one, or when the user provides a design, mockup, Figma frame or screenshot to reproduce.
3
+ description: Enforces the rules for building AntelopeJS DMS pages (every page a tree of DMS blocks, custom code only for the missing block, `.meta()` on every custom block), finds the DMS module or block feature a need already has before anything is built (mails, tenants and SaaS, translated fields, archiving) and proposes installing a missing module, decides when to leave DMS blocks and proposes that deviation to the user, and runs the design-fidelity protocol. Use when creating or changing any DMS page, dashboard or screen, before building a feature or business logic in a DMS project (sending an email, tenants or subscriptions, translatable fields, archiving rows), before writing a CustomComponent or Vue for one, or when the user provides a design, mockup, Figma frame or screenshot to reproduce. Not for a question about one block option or DataType (dms-pages).
4
4
  ---
5
5
 
6
6
  # DMS best practices
@@ -13,10 +13,31 @@ Three facts about the project change the steps below. **dms-builder-mcp** _Detec
13
13
  - **Safe mode** is on (the builder tools are the only way to write), or not.
14
14
  - **The asking tool**: `ask_user` in the dms-assistant chat, your harness's question tool elsewhere, else one closed question in chat.
15
15
 
16
+ ## Before you build
17
+
18
+ Run this before any feature, a page or business logic alike. Most needs already have a DMS module or a block feature, and a home-made copy loses its admin pages, permissions and upgrades.
19
+
20
+ 1. **List what the project has**: the `@antelopejs/*` dependencies of `package.json`, the modules of `antelope.config.*`, and the synced skills (**skills**). A table is `@RegisterTable("<table>", "<schema>") class X extends Table` with `@Field("<type>") declare <name>: <T>` fields and an inherited `_id` (no primary-key decorator), read and written through `GetModel(BasicDataModel(X))`. From `@antelopejs/interface-database-decorators`: `Table` and `Field` from `/table`, `RegisterTable` from `/schema`, `GetModel` and `BasicDataModel` from `/model`. **database-decorators-interface** has the rest.
21
+ 2. **Match the need.** The table holds the needs most often rebuilt. For any other, the module catalog is the resolver's `list` (**interface**): each `dms-*` interface there is a module's contract.
22
+
23
+ | Need | Use |
24
+ | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | An email, its template, its sends | `@antelopejs/dms-mailing`: a mail is a template, sent with `SendTemplate` and shipped with `DeclareTemplate` (`@antelopejs/interface-dms-mailing`) |
26
+ | Tenants, workspaces, SaaS, plans, subscriptions, billing | `@antelopejs/dms-saas` |
27
+ | An image or file on a record | `@antelopejs/dms-media` (`AssetType`) |
28
+ | A procedure run on a schedule, a webhook or a data event | `@antelopejs/dms-automation` |
29
+ | Translated interface texts, translations for another app | `@antelopejs/dms-lang` |
30
+ | A field in several languages | `@Localized()` on a field of a `Table.with(LocalizationModifier)` (`@antelopejs/interface-database-decorators/modifiers/localization`); the DMS form edits each locale |
31
+ | Archive and restore rows instead of deleting them | `@ArchiveField()` on a `@Field("boolean")` of the `Table`, and `TableViewRoutes.Archive` / `Restore`: both from `@antelopejs/interface-dms/base`, not the decorators |
32
+ | Status tabs, saved views, kanban, footer totals | `TableView` options (**dms-page-design**) |
33
+
34
+ 3. **Installed**: load that module's skill, or its contract through **interface**, and build on it. **Absent**: never build a copy. Open with one question, asked with the asking tool, whether you may install it, and show no code or command before it. On yes, run `ajs project modules add @antelopejs/<module>` and build on it.
35
+ 4. **Before adding a field, column, route or custom code to a block**, read what the block already offers: `builder_catalog` with the builder MCP, else the block's TSDoc through **interface**: `contract dms base/<block>` (`base/table-view`) lists what it re-exports from each file, and `contract dms base/<block>/<file>` (`base/table-view/meta`, `base/table-view/routes`) prints that file.
36
+
16
37
  ## The rules
17
38
 
18
39
  1. **A page is always blocks.** Describe every page on the backend as a tree of DMS blocks: `PeriodSelector`, `Grid` / `GridRow`, `KpiCard`, `TableView`, `Form`, … Each static field and each `.child()` is a line in the roles editor, a `.watch()` target, a `periodScope` subscriber and a node the builder can move. One block that draws the whole screen loses all of that.
19
- 2. **Custom = the missing block only.** When a part has no DMS equivalent, build **that block** as a `CustomComponent` and keep everything around it (toolbar, filters, stats, tables) as DMS blocks on the backend.
40
+ 2. **Custom = the missing block only.** When a part has no DMS equivalent, build **that block** as a `CustomComponent` and keep everything around it (toolbar, filters, stats, tables) as DMS blocks on the backend. A whole custom page too, as _Custom pages are blocks_ says.
20
41
  3. **Every custom block carries `.meta()`.** `.meta({ name, description, icon })` in its backend declaration, `name` and `description` as `$` i18n keys added to every locale file. Without it the roles editor shows the raw component name. Every other text (page names, titles, labels) is a `$` key too.
21
42
 
22
43
  ```ts
@@ -45,6 +66,12 @@ A custom block is a deviation, and you **propose** it: the user decides, after t
45
66
  | The user asked for pixel perfect on **this** element | Another element of the page is custom: a custom block never pulls its neighbours along |
46
67
  | A measured constraint (performance, data volume) the block cannot meet | The constraint is a guess, not a measurement |
47
68
 
69
+ ## Custom pages are blocks
70
+
71
+ A **custom page** is a page the user designs rather than one a table generates: a mockup's `custom: true` sketch ([SPEC.md](../dms-mockup/SPEC.md) _Custom pages_) or a custom page asked for directly. Build it as a tree of DMS blocks (`TableView`, `KpiCard` / `StatGroup`, `Card`, `ResourceForm`, a `ChartCard`, …), and only the parts no block draws as `CustomComponent`s, each through the path below, with its `.meta()` and a permissioned `.action()` per action it takes. A page whose one block is a full-page `CustomComponent` is never the result.
72
+
73
+ An order details page, say, becomes a header with a status badge, a `TableView` of the items with a totals row (`footer.summary`), and `Card`s for the customer and the shipping. Only a timeline, when no block draws it, is a `CustomComponent`.
74
+
48
75
  ## Before any custom block
49
76
 
50
77
  Run this path before writing a `CustomComponent` or its Vue, one element at a time:
@@ -38,6 +38,16 @@ installed engine doesn't support it — explain the limitation instead of retryi
38
38
  `list`, `select`, `count`, `new`, `edit`, `delete`, `archive`, `restore`,
39
39
  `exportStart`, `exportStatus`, `exportDownload`) are rejected with `invalid_config`.
40
40
 
41
+ ## Column presentation
42
+
43
+ `builder_add_field`, `builder_configure_field`, `builder_create_resource` `fields` and `builder_map_resources` `fields[]` also take, in Safe mode too:
44
+
45
+ - `display: { type, options? }`, a cell display: `identity`, `pills`, `relative_date`, `indicator`, `status_pill`, `two_line`, `progress`, `sparkline`, `duration`, `bytes`, `string` or `mono`. Options are checked per display: a bad one is `invalid_config` naming it (`builder_map_resources` skips the relation with a `relation_skipped` warning). On a mapped column it is a badge or a price, or a cell display over a column with neither.
46
+ - `group` (a form group id), `isVisible`, `size` (> 0), `cellWrap`, `description`.
47
+ - In `builder_configure_field`'s patch each may be `null` to remove it.
48
+
49
+ `builder_configure_column_groups { resource, groups }` writes the class's `@ColumnGroup`, the groups of the add, edit and details forms: `groups` is `{ [id]: { label, description?, orientation?, order? } | null }`, a group sent replaces its id, `null` removes it, a group left out stays. `builder_resource_structure` reads fields' presentation and `columnGroups` back.
50
+
41
51
  **Displaying a resource on a page is a builder step**: create and populate the
42
52
  resource, then `builder_add_block` a `TableView` with `controller` = the resource `ref`
43
53
  and display options in `config`. Relation columns work via `$ref` (see
@@ -7,7 +7,7 @@ description: Drives the AntelopeJS DMS builder MCP tools (builder_catalog, build
7
7
 
8
8
  The DMS builder edits the project's own TypeScript: a page is a `PageController` class, a block a static field or `.child()` call, a resource a `Table` + `DataController` + model. Every builder operation is **atomic and typecheck-gated**: on success it returns the file changes; on `typecheck_failed` nothing is written.
9
9
 
10
- Load **dms-best-practices** first and follow it: it decides what a page is made of and runs the design-fidelity protocol. This skill covers driving the builder tools.
10
+ Load **dms-best-practices** first and follow it: it decides what a page is made of and runs the design-fidelity protocol. A data page follows **dms-page-design**, which also picks where each table's details and forms open. This skill covers driving the builder tools.
11
11
 
12
12
  ## Detect what the project has
13
13
 
@@ -24,7 +24,7 @@ Settle these three before the first edit. They decide every later branch.
24
24
 
25
25
  - **PageRef** = the page's route, e.g. `/charts/revenue`.
26
26
  - **BlockPath** = `<pageRef>#<name>[/<childId>...]`: `#<name>` is a top-level block; each `/<childId>` descends into a container's child.
27
- - **CategoryRef** = a dotted id, e.g. `pages.charts` (top-level pages under `pages.*`; module pages under `modules.<id>.*`). Take exact refs from `builder_list_pages`, never guess.
27
+ - **CategoryRef** = a dotted id, e.g. `pages.charts` (a category under the built-in Pages; module pages under `modules.<id>.*`). A sidebar section's ref is just its name, e.g. `sales`, not `pages.sales`. `builder_list_pages` answers `{ pages, categories }`: each page carries `section`, the ref of the section it shows under, and each section in `categories` carries `section: true`. Take exact refs from it, never guess.
28
28
  - **ResourceRef** = a data resource's id, its `/api/<name>` route segment. **FieldPath** = `<resourceRef>#<fieldName>`. Take refs from `builder_list_resources`.
29
29
  - **QueryRef** = `<pageRef>@<queryName>`, e.g. `/catalog/books@inStockCount`. Take refs from `builder_page_structure`'s `queries`.
30
30
 
@@ -41,7 +41,7 @@ Settle these three before the first edit. They decide every later branch.
41
41
  3. **Create a page** with `builder_create_page` (a real `CategoryRef`); it returns `{ ref, filepath }`. Then give the user the URL `navigate_to_page` answers for it, so they can watch it fill in.
42
42
  4. **Build the blocks.** A whole page, or a set of blocks, goes in one `builder_compose_page` call: the blocks as an ordered tree, each data block with its `query` inline. Preview it first (`"preview": true`), as **dms-page-design** _Build a page in one call_ says. For one block, `builder_add_block`: omit `parent` for a top-level block or pass a container's BlockPath; `name` unique among siblings. A controller-leading block (catalog `controllerArg: true`, e.g. `TableView`) takes `controller` = the resource `ref`; other types refuse it.
43
43
  5. **Configure or rearrange.** `builder_configure_block` merges options (`replace: true` overwrites); `builder_configure_table_view` sets a table's displays, views and footer. Children change only through `builder_add_block`, `builder_move_block` and `builder_remove_block` (which removes the subtree).
44
- 6. **Pages and categories.** `builder_configure_page` edits displayName, icon, order and description; `builder_delete_page` removes a page and its barrel import; `builder_create_category`, `builder_configure_category` and `builder_delete_category` manage categories. A category delete is refused with `referential_integrity` while a page references it.
44
+ 6. **Pages and categories.** `builder_configure_page` edits displayName, icon, order, description, `hidden` and `category` (a move changes the page's ref and route); `builder_delete_page` removes a page and its barrel import; `builder_create_category`, `builder_configure_category` and `builder_delete_category` manage categories; `builder_create_category` with `section: true` writes a sidebar section (a `RootCategory`, `type: "label"`), as a mockup's `categories` need, where a plain call writes a collapsible category. A category delete is refused with `referential_integrity` while a page references it.
45
45
  7. **Verify.** A typecheck-clean edit can still fail at runtime (a `fetchUrl` that 404s). Before the write, the `builder_compose_page` preview answers each block's data status. After it, `query_logs` shows the host's reload and runtime output, and `navigate_to_page` answers the page's dashboard URL (`unknown_route` until the reload registers the page); it drives no browser. Open that URL with your browser tool when you have one and look at every block; without one, give the URL to the user and ask them to check it. The step is done when every block the change touched shows data and the logs show no error from it.
46
46
 
47
47
  On the code path, verify with the project's typecheck (the `typecheck` MCP tool, or the project's own script), then open the page in the browser as **dms-pages** _Verify in the browser_ says.
@@ -52,7 +52,7 @@ A **resource** is the data a table or form shows: a `Table` + `Model` and a `Dat
52
52
 
53
53
  A **query** is a derived-data endpoint on a page: an aggregate or one point per group, backed by a generated model method. Its `response` matches the block: `value` for a `KpiCard`, `card` for a `ChartCard`, `items` for a `TopListCard`, `series` for a bare chart. Run `builder_query_templates` and `builder_preview_query` first, add it with `builder_add_query` on the page that shows it, and wire the returned `route` as the block's `fetchUrl`.
54
54
 
55
- [REFERENCE.md](REFERENCE.md) has the resource and query workflows, field rules, `$param` binding and opaque queries.
55
+ Fields take per-column presentation (`display`, `group`, `isVisible`, `size`, `cellWrap`, `description`) and `builder_configure_column_groups` writes form groups, in Safe mode too: see REFERENCE.md _Column presentation_. [REFERENCE.md](REFERENCE.md) has the resource and query workflows, field rules, `$param` binding and opaque queries.
56
56
 
57
57
  ## Theme and branding
58
58
 
@@ -63,7 +63,8 @@ On the code path, edit the theme yourself in the `app/app.config.ts` of the proj
63
63
  ## Errors
64
64
 
65
65
  - `typecheck_failed`: read `diagnostics`, fix the `config` or `type`, retry. Nothing was written.
66
- - `invalid_config`, `duplicate_name`, `not_found`: fix the input.
66
+ - A refusal that names a read-only connection (a `writable: true` mapping, a `ResourceForm` in `new` or `edit` mode, a `TableView` that serves write routes): follow **dms-external-database** _Connection access_.
67
+ - `invalid_config`, `duplicate_name`, `not_found`: fix the input. A value refused as not one of an enum's allowed values (the error lists them): pick the closest allowed value yourself, send it and mention the substitution in your reply (a badge tone `pink` becomes `warning`); ask the user only when none is close.
67
68
  - `stale`: the page changed under you; read it again with `builder_page_structure` and retry.
68
69
  - `builder_unavailable`, `request_failed`: the builder engine is unreachable or does not implement the operation (`HTTP 400` means `unknown_op`). Explain the limitation; retry nothing.
69
70
  - `opaque_target`, `unsupported`: the builder cannot make this change. Without Safe mode, make it in code with **dms-pages**, then call `builder_refresh` (scoped to the page): it clears the builder's caches, so it reads the file again. In Safe mode, ask the user whether to turn Safe mode off for that one step; never force it.
@@ -60,6 +60,29 @@ integrator gave you:
60
60
  }
61
61
  ]
62
62
  }
63
+ },
64
+ {
65
+ "op": "ConfigureModule",
66
+ "id": "dms-database",
67
+ "entry": {
68
+ "importOverrides": [
69
+ {
70
+ "interface": "@antelopejs/interface-database",
71
+ "source": "<project database module>"
72
+ },
73
+ {
74
+ "interface": "@antelopejs/interface-database",
75
+ "source": "postgres-erp",
76
+ "id": "erp"
77
+ },
78
+ {
79
+ "interface": "@antelopejs/interface-database-catalog",
80
+ "source": "postgres-erp",
81
+ "id": "erp"
82
+ }
83
+ ],
84
+ "config": { "externalConnections": { "erp": { "access": "read" } } }
85
+ }
63
86
  }
64
87
  ]
65
88
  }
@@ -84,6 +107,11 @@ integrator gave you:
84
107
  provided it before this call. When an `environments` entry of the configuration sets an
85
108
  `exportPriority`, or a provider's priority is not a plain number, stop and ask the integrator
86
109
  which module the DMS uses.
110
+ - **Step 5** registers the connection with `dms-database`, the module whose Data browser and
111
+ write routes read its access, under the same id, after the project's own database. `access` is
112
+ always `"read"`: `builder_configure_project` refuses to raise one, and SKILL.md _Connection
113
+ access_ raises it afterwards. Leave the step out when the project has no `dms-database`
114
+ module.
87
115
 
88
116
  For MySQL, MariaDB, MongoDB and RethinkDB, step 1 changes, and the other steps name its id in
89
117
  place of `postgres-erp`.
@@ -251,7 +279,7 @@ erp · postgresql 17.5 · role erp_reader (read only) · 42 relations: 9 TableVi
251
279
 
252
280
  ## Analytics pages
253
281
 
254
- ### Sales (sales.orders)
282
+ ### Sales (sales.orders): the dashboard, first in the menu, outside the sections
255
283
 
256
284
  - Period: by ordered_at, default last-90-days vs previous-period; presets last-30-days, last-90-days, ytd, last-year, custom
257
285
  - Toolbar: PageToolbar › PeriodSelector
@@ -261,6 +289,12 @@ erp · postgresql 17.5 · role erp_reader (read only) · 42 relations: 9 TableVi
261
289
  - ChartCard › ChartBar: top 10 countries by revenue
262
290
  - TopListCard: top 10 cities by orders
263
291
 
292
+ ## Sections
293
+
294
+ - Sales (i-ph-storefront): Orders, Payments, Coupons
295
+ - Catalog (i-ph-package): Products, Categories
296
+ - Customers (i-ph-users): Customers, Reviews, Support tickets
297
+
264
298
  ## Left open
265
299
 
266
300
  - label:legacy.t_ord — no column names an order; the integrator picks one in the Builder
@@ -283,6 +317,7 @@ The proposal's values, without their rules, plus what you changed:
283
317
  "relation": "sales.customers",
284
318
  "label": "name",
285
319
  "title": "Customers",
320
+ "category": "pages.customers",
286
321
  "tableView": true,
287
322
  "writable": true,
288
323
  "fields": [
@@ -294,6 +329,8 @@ The proposal's values, without their rules, plus what you changed:
294
329
  },
295
330
  {
296
331
  "relation": "sales.orders",
332
+ "title": "Orders",
333
+ "category": "pages.sales",
297
334
  "tableView": true,
298
335
  "writable": false,
299
336
  "tabs": { "column": "status" },
@@ -332,6 +369,8 @@ The proposal's values, without their rules, plus what you changed:
332
369
  change it: a price with a `currency` the schema or the integrator names, a badge only over a
333
370
  native enum's labels. A proposed price with no `currency` draws euros: send it a `currency`,
334
371
  or `null`. Send `tabs` as a column name (`{ "column": "status" }`). `null` turns either off.
372
+ - `category` is the ref `builder_create_category` answered for the page's section, made with
373
+ this call's `module`. Left out, a new page goes in the connection's category.
335
374
  - Key columns are added for you.
336
375
  - A relation column's target must be in the same call, with a `label`, or mapped in the module
337
376
  before.
@@ -38,7 +38,9 @@ read only. Nothing is written before the integrator approves your plan.
38
38
 
39
39
  Call `database_connections`.
40
40
 
41
- - **A connection is listed** with an `engine`: use its id and go to 2.
41
+ - **A connection is listed** with an `engine`: use its id and go to 2. Its `access` is the one
42
+ the integrator chose, in dms-assistant's onboarding or as they connected it: read it from
43
+ `builder_mapping` or `builder_analyse_database`, as _Connection access_ says.
42
44
  - **An entry answers `error`**: say what it says (an owned instance, the catalog not enabled, a
43
45
  role that cannot read) and stop.
44
46
  - **A database tool answers `unreachable_connection`**: the DMS MCP reaches only the catalog
@@ -51,19 +53,20 @@ Call `database_connections`.
51
53
  (`mysql-erp`, `mongodb-erp`, `rethinkdb-erp`), generated module `erp-tables`, variable
52
54
  `ERP_DATABASE_URL`, and for MongoDB `ERP_DATABASE_NAME`. Ask the integrator for the version of
53
55
  the engine's module to install (`@antelopejs/postgres`, `@antelopejs/mysql` for MySQL and
54
- MariaDB alike, `@antelopejs/mongodb`, `@antelopejs/rethinkdb`): you cannot look it up. The user
55
- approves the diff. Safe mode refuses `builder_configure_project`: ask the integrator to turn it
56
- off for this one call.
56
+ MariaDB alike, `@antelopejs/mongodb`, `@antelopejs/rethinkdb`): you cannot look it up. Ask
57
+ the read-or-write question of _Connection access_ when it says to. The user approves the diff. Safe mode
58
+ refuses `builder_configure_project`: ask the integrator to turn it off for this one call.
57
59
  - Then tell the integrator to put the URL in `.env` (`ERP_DATABASE_URL=postgres://…`,
58
60
  `mysql://…/<database>` for MySQL and MariaDB, `mongodb://…`, or `rethinkdb://…/<database>`;
59
61
  for MongoDB also `ERP_DATABASE_NAME`), or in the builder's _Database_ workspace when the
60
62
  project has one, which writes it there, and to restart the project. Every deployed
61
63
  environment needs the same variables, set where that environment keeps its secrets, never in
62
64
  git.
63
- - Recommend an account that can only read for the analysis: a PostgreSQL role with SELECT, a
64
- MySQL or MariaDB account granted SELECT on the database directly (the module does not see a
65
- grant through a role), a MongoDB user with the built-in `read` role, a RethinkDB user with
66
- `read` permission.
65
+ - Recommend an account that can only read: a PostgreSQL role with SELECT, a MySQL or MariaDB
66
+ account granted SELECT on the database directly (the module does not see a grant through a
67
+ role), a MongoDB user with the built-in `read` role, a RethinkDB user with `read`
68
+ permission. On read & write, the account also needs write privileges on the tables the
69
+ dashboard changes.
67
70
  - Stop here: the connection exists only after the restart.
68
71
 
69
72
  The builder and you each have a connection to the database, under the same id: the builder for
@@ -110,15 +113,20 @@ profile of the whole database again: the Builder did it.
110
113
  catalog reads types from a sample, and every reference comes from a name and a `CheckReference`,
111
114
  never from the database. An embedded document is one field: its subfields are not mappable, and
112
115
  neither is an array of ids as a relation.
113
- - **Editable.** Every TableView is proposed read-only. Make one editable only where the integrator
114
- wants it; show `writes` beside it, so a read-only role in this environment is visible.
116
+ - **Editable.** On `read`, every TableView is read-only. On `read-write`, propose each table's
117
+ write actions as **dms-page-design** _Records, forms and links_ decides from its `writes` and
118
+ its shape, and show them in the plan beside `writes` for the integrator to confirm or drop.
119
+ Map the relations that keep a write action `writable: true`. A relation whose `writes` forbids
120
+ the action stays `writable: false`, with the reason shown.
115
121
  - **Pages people can work with.** Load the `dms-page-design` skill. For every TableView, plan
116
122
  from its columns and their profiles (types, traits, distinct counts), as _Name every page_
117
123
  and _Tables_ there say: a title, an icon and a description; the tabs, saved views, display
118
- modes, footer totals and KPI cards its shape supports. Decide each from that shape, and
119
- leave out what it does not support. You never read a row's values.
120
- - **The analytics dashboard,** which the analysis does not make. Every run ends with one,
121
- first in the menu, even when the integrator only asked for the tables. Plan it from the data:
124
+ modes, footer totals and KPI cards its shape supports; where its details and forms open, as
125
+ _Records, forms and links_ there picks. Decide each from that shape, and leave out what it
126
+ does not support. You never read a row's values.
127
+ - **The analytics dashboard,** which the analysis does not make. Every run plans and builds
128
+ one, even when the integrator only asked for the tables, as `dms-page-design` _The analytics
129
+ dashboard_ says. Plan it from the data:
122
130
  1. **Inspect.** For each relation, read from the proposal its row count, its `time-axis`
123
131
  columns, its `measure` columns, and its `enum-like` columns with their distinct counts
124
132
  and, for a native enum, the labels its schema declares (`database_describe`). That shape
@@ -137,11 +145,14 @@ profile of the whole database again: the Builder did it.
137
145
  _Period_ there sets it.
138
146
  - **The minimum.** Your plan, and the pages you write, meet all of these:
139
147
  - one analytics dashboard, first in the connection's menu (`order: 0`), opened by a toolbar
140
- with a period selector when the data has dates;
148
+ with a period selector when the data has dates, its KPI cards and charts each reading a
149
+ query over a mapped relation;
141
150
  - every page with a title in the owner's words, an icon and a description, never the raw
142
151
  relation name;
143
152
  - every table given the tabs, views, display modes, footer totals and KPI cards its data
144
153
  supports, as `dms-page-design` _Tables_ decides;
154
+ - 6 or more pages grouped into sections, as `dms-page-design` _Group pages into sections_
155
+ says;
145
156
  - at least 3 different chart kinds on it when the data has the shapes for them;
146
157
  - the default period `dms-page-design` _Period_ sets;
147
158
  - every page built with one `builder_compose_page` call, previewed first, and every block whose
@@ -152,8 +163,8 @@ profile of the whole database again: the Builder did it.
152
163
  never as pages.
153
164
 
154
165
  Write your plan (`ExitPlanMode` in plan mode, a message otherwise) in the format of REFERENCE.md _Plan_: what you change in the
155
- proposal and why, the questions and the analytics pages that answer them, the open items you
156
- leave, and what is not possible yet.
166
+ proposal and why, the questions and the analytics pages that answer them, the sections, the
167
+ open items you leave, and what is not possible yet.
157
168
 
158
169
  ## 4. Validate
159
170
 
@@ -162,36 +173,47 @@ again. Write nothing before they approve it (**Run** in the dms-assistant chat).
162
173
 
163
174
  ## 5. Apply
164
175
 
165
- Work in this order, so the most visible result lands first: map the tables, build the
166
- dashboard and check it, then add KPI rows above tables, then any second analytics page.
176
+ Work in this order, so the most visible result lands first: create the sections, map the
177
+ tables into them, build the dashboard and check it, then add KPI rows above tables, then any
178
+ second analytics page.
167
179
 
168
- 1. `builder_map_resources` in batches of 3 or 4 relations per call, TableViews and stats-only
180
+ 1. The sections you planned: one `builder_create_category` per section, `module` set to the
181
+ generated module (a category of another module cannot hold its pages). Keep each section's
182
+ ref.
183
+ 2. `builder_map_resources` in batches of 3 or 4 relations per call, TableViews and stats-only
169
184
  relations alike; the relations decided against go in `excluded` on the first call
170
185
  (REFERENCE.md _Mapping_). One call with every relation of a large database can abort.
171
186
  - Send the proposal's choices as they stand where you changed nothing, except `display`,
172
187
  which you leave out (REFERENCE.md _Mapping_), plus per resource
173
- the `title`, `icon`, `description` and `tableOptions` you planned.
188
+ the `title`, `icon`, `description` and `tableOptions` you planned, and as `category` the
189
+ ref of its page's section.
174
190
  - On `invalid_config`, fix the choice it names and call again: a refused call writes nothing.
175
191
  When the same choice is refused twice, drop it (send the relation without that display or
176
192
  option) and say so in your report, rather than trying more variants.
177
193
  - It answers each relation's `ref`, which queries name it by, `category`, the connection's
178
194
  category ref (`pages.<connection>`), and `leftOut`: carry those into your report.
179
- 2. Per analytics page, one `builder_compose_page` call with `create` (`name`, `displayName`,
195
+ 3. Per analytics page, the dashboard first and never skipped, one `builder_compose_page` call with `create` (`name`, `displayName`,
180
196
  `module` set to the generated module, `category` set to the `category` MapResources
181
197
  answered, an icon, a description, and `order: 0` for the dashboard, 1, 2… for the next
182
198
  ones) and every block in the order `dms-page-design` lays out, each data block with its
183
199
  query inline. Preview first, then write, as `dms-page-design` _Build a page in one call_
184
200
  says.
185
201
  - Queries read the mapped resources by their refs (`<connection>/<schema>/<relation>`).
186
- 3. Per table page that gets KPI cards above its table, one `builder_compose_page` call with
202
+ 4. Per table page that gets KPI cards above its table, one `builder_compose_page` call with
187
203
  `placement: { "before": "table" }`, previewed first. When MapResources answers `page_not_written`
188
204
  for a relation's table options, none of them was written: send them all again with
189
205
  `builder_configure_table_view`, the refused one fixed or left out. Tabs it dropped stay off:
190
206
  say so in your report.
191
207
 
208
+ The main dashboard stays in the connection's category, outside every section; a section's own
209
+ dashboard takes that section's ref as `category`.
210
+
192
211
  To change a relation later, read its current choices with `builder_mapping`, then call
193
212
  `builder_map_resources` with that relation alone, its included columns as they are and only your
194
- change made: a mapped relation is rewritten from the choices sent, and its page follows.
213
+ change made: a mapped relation is rewritten from the choices sent, and its page is updated where
214
+ it is. A remap with no `title` keeps the page's current title: send `title` only to rename the
215
+ page. Send `category` only to move the page to another section:
216
+ its route changes (a `route_changed` warning), and nothing redirects the old one.
195
217
 
196
218
  ## 6. Check
197
219
 
@@ -209,13 +231,52 @@ change made: a mapped relation is rewritten from the choices sent, and its page
209
231
  Then report:
210
232
 
211
233
  - what the builder mapped by its rules, and what you changed;
212
- - the pages made, with each analytics page's default period,
213
- and per table the features you gave it and why;
234
+ - the dashboard: its route, and each KPI card and chart with the aggregate it reads;
235
+ - the pages made, with each analytics page's default period, the section each table page
236
+ sits in, and per table the features you gave it and why;
214
237
  - every block that still shows no data, and why;
215
238
  - what was left out and why;
216
239
  - the open items left, which the integrator finds in the builder's _Database_ workspace;
217
240
  - the variable every deployment must set.
218
241
 
242
+ ## Connection access
243
+
244
+ A connection's access is `"read"` (the default) or `"read-write"`: what the project lets the
245
+ dashboard write to the database. `builder_analyse_database` and `builder_mapping` answer it at
246
+ the top level as `access`, and each resource's `writes` (`{ insert, update, delete }`) says what
247
+ the database account may do in that relation. This holds in every flow over a connected
248
+ database: a mockup, a page built through the builder or in code.
249
+
250
+ - **On `read`**: propose no write action (add, edit, delete, archive, restore, duplicate,
251
+ `archiveMode`, a draggable kanban, a `ResourceForm` not in `mode: "view"`), and map every
252
+ relation `writable: false`. A mockup over the connection writes `data`, and the validator
253
+ refuses those options there ([SPEC.md](../dms-mockup/SPEC.md) _Connection access_).
254
+ - **On `read-write`**: propose the write actions of each table, as **dms-page-design** _Records,
255
+ forms and links_ decides, in every flow: a mockup, a page built through the builder or in
256
+ code, with or without dms-assistant.
257
+ - **The access is already chosen** when the connection was made in dms-assistant's onboarding:
258
+ its popup asks "read only" or "read & write" when the pasted account can write, and writes
259
+ the answer as the connection's `access`. Read it from `builder_mapping` or
260
+ `builder_analyse_database`, and never ask again or lower it.
261
+ - **Connecting without that popup** (the MCP alone): ask "only read, or also change rows?". The
262
+ connect batch writes `access: "read"` either way. On read & write, raise it as below once
263
+ `database_connections` lists the connection after the restart.
264
+ - **The integrator asks for add, edit or delete on a `read` connection**: say the connection is
265
+ read-only, and ask for an explicit OK. Propose none unasked. On yes:
266
+ 1. Call `builder_set_connection_access` with
267
+ `{ "connection": "<id>", "access": "read-write" }`. Its first call answers
268
+ `confirmation_required` and writes nothing; the same call repeated within 10 minutes runs
269
+ it. Safe mode refuses it: ask the integrator to turn Safe mode off for this one call.
270
+ 2. Remap each relation with `writable: true` (a later change, as _5. Apply_ says), then add
271
+ the actions **dms-page-design** _Records, forms and links_ decides. In a mockup, set
272
+ `data.access` to `read-write` and add them to the spec.
273
+ - Refused because the account may write nothing (`invalid_config`): tell the integrator to
274
+ grant the account write privileges on those tables. A relation the account still cannot
275
+ write maps `writable: false` with a `relation_read_only` warning: report it.
276
+ - The builder reads the new access at once. The running backend applies it to the write
277
+ routes when it restarts, which `ajs project dev` does on its own.
278
+ - Raise an access only on the integrator's explicit OK.
279
+
219
280
  ## Guardrails
220
281
 
221
282
  - Never write a URL, password or token into a tool call, the config or a page.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dms-mockup
3
- description: Mocks up AntelopeJS DMS apps in mockups/<name>/spec.json before any page is built: interviews the user, matches every wish to a DMS block or a custom sketch, and applies the user's annotations on the mockup. Use when the user wants to mock up, sketch or prototype a DMS app or page, start an app from scratch, or has commented on a mockup.
3
+ description: Mocks up AntelopeJS DMS apps in mockups/<name>/spec.json before any page is built: interviews the user, matches every wish to a DMS block or a custom sketch, and applies the user's annotations on the mockup. Use when the user wants to mock up, sketch or prototype a DMS app or page, from scratch or over an existing database, or has commented on a mockup.
4
4
  ---
5
5
 
6
6
  # DMS mockups
@@ -14,7 +14,7 @@ The mockup is done when the user approves it. Building the real pages from it is
14
14
  - **The block catalog.** With the builder MCP (`builder_catalog` among your tools, see **dms-builder-mcp**), `builder_catalog`. Without it, the catalog of the running DMS (`GET /api/block-preview/types`, or the spec schema at `GET /api/mockup/schema`), else the schema file `@antelopejs/dms` ships ([SPEC.md](SPEC.md) _Schema_). The running DMS lists the blocks of the installed modules too; the file lists the core blocks only.
15
15
  - **The preview.** `/mockup?name=<name>` answers while `ajs project dev` runs. When it does not, write and validate the spec all the same, show the user each page as a text outline (one line per block, sketches marked _Custom_), and tell them `ajs project dev` turns it into a live preview.
16
16
  - **Annotations.** When `mockup_annotations` is among your tools, it lists them and `mockup_resolve_annotation` resolves one. Without them, use the HTTP API of the running DMS, else edit `mockups/<name>/annotations.json` directly ([SPEC.md](SPEC.md) _annotations.json_).
17
- - **Writing the spec.** When `mockup_write_spec` and `mockup_patch_spec` are among your tools, every write of the spec goes through them: `mockup_write_spec` for a first draft or a rewrite, `mockup_patch_spec` (RFC 6902 operations) for a targeted change. Both validate and write `spec.json` only, and Safe mode allows them, as it allows `mockup_resolve_annotation`. Without them, write the file directly.
17
+ - **Writing the spec.** When `mockup_write_spec` and `mockup_patch_spec` are among your tools, every write of the spec goes through them: `mockup_write_spec` creates the mockup (and rewrites it only when the user asks to start over), `mockup_patch_spec` (RFC 6902 operations) makes every other change. Both validate and write `spec.json` only, and Safe mode allows them, as it allows `mockup_resolve_annotation` and `mockup_read_spec`. `mockup_read_spec` (`{ mockup, path? }`, `path` a JSON pointer, the whole spec when left out) is read-only: read only the parts you need with it, and never probe the spec with JSON-patch `test` operations or temporary keys. Without them, write the file directly.
18
18
  - **The asking tool**: `ask_user` in the dms-assistant chat, your harness's question tool elsewhere (`AskUserQuestion` in Claude Code), else one closed question in chat. Batch questions: up to 4 per call.
19
19
 
20
20
  ## 1. Interview
@@ -27,9 +27,9 @@ Collect the user's **wishes**: each thing a screen must show or let someone do.
27
27
  - the actions: create, edit, approve, export, …;
28
28
  - a reference: a screenshot, a Figma frame, another product. When there is one, frame it once as **dms-best-practices** _Design-fidelity protocol_ step 1 says.
29
29
 
30
- When the project already has a database or resources (`builder_list_resources`, `database_connections`), read their names and fields first, never their rows, and ask only what they do not answer. Data pages follow **dms-page-design**: its shapes, layout and naming rules decide the blocks of an analytics or table page.
30
+ When the project already has a database or resources (`builder_list_resources`, `database_connections`), read their names and fields first, never their rows, and ask only what they do not answer. Over a database, read the Builder's **proposal** too: `builder_mapping` for the relations a module maps, else `builder_analyse_database` (`detail` naming the relations you mock up), and its `access`. Data pages follow **dms-page-design**: its shapes, layout, naming and _Tables_ rules decide the blocks of an analytics or table page, and _Group pages into sections_ the menu. A mockup over a database always has the dashboard of **dms-page-design** _The analytics dashboard_, asked for or not: its KPI cards and charts read fixtures that stand for aggregates of the relations' measures, time axes and category columns.
31
31
 
32
- The interview is done when every page has a purpose, its data and its actions, and every wish names the page it lives on.
32
+ The interview is done when every page has a purpose, its data and its actions, every wish names the page it lives on, and a mockup over a database lists its dashboard first.
33
33
 
34
34
  ## 2. Check every wish against the catalog
35
35
 
@@ -37,26 +37,33 @@ For each wish, find the closest DMS block or composition in the catalog, with th
37
37
 
38
38
  - **A block covers it** (through its options or a composition): use it. A difference the theme or the options handle is no question.
39
39
  - **Nothing covers it, or the user asked for exactly this look**: propose the choice as **dms-best-practices** _Before any custom block_ says, with the closest DMS option beside a **sketch** of the custom part, one closed question per element or batch: _Keep the DMS block_ / _Adjust it through its options_ / _Build a custom block_. Only _Build a custom block_ puts a sketch in the spec.
40
+ - **A whole page no arrangement of blocks draws** goes through the same choice, offering a **custom page** ([SPEC.md](SPEC.md) _Custom pages_) in place of a custom block. The mockup draws it as one sketch; the build splits it into blocks.
41
+ - **A sidebar part no module provides** (a plan card, a help box) is a **sidebar widget** ([SPEC.md](SPEC.md) _Sidebar widgets_).
40
42
 
41
43
  This step is done when every wish maps to a block, a composition, or a sketch the user chose.
42
44
 
43
- ## 3. Write the spec
45
+ ## 3. Write the spec live
44
46
 
45
- Write `mockups/<name>/spec.json` with `mockup_write_spec` or as a file (`<name>` in kebab case, from the app or the area: `crm`, `stock-dashboard`), following [SPEC.md](SPEC.md):
47
+ The user watches the mockup fill in `/mockup?name=<name>`, so write it in small saves, never as one big spec: each save redraws the viewer in under a second, while one call that types the whole spec shows nothing until it ends and, when it fails validation, loses all of it. Follow [SPEC.md](SPEC.md) _Writing in steps_:
46
48
 
47
- - one entry per page, its tree in the order the page reads, every block with a name;
48
- - **fixtures** for every block that reads data, invented and never copied from a database: realistic and coherent across pages (the order total on the list matches the KPI), with a dozen rows, not two, and over existing resources the columns and types they declare;
49
- - a **sketch** for each custom part the user chose, kept to that element;
50
- - `source`, on a new spec only: `claude-code` in Claude Code, `codex` in Codex, left out when you cannot tell which harness runs you;
51
- - texts in the user's language.
49
+ 1. **Create it empty.** `mockup_write_spec` with `pages: []`, the `title`, the `categories` that **dms-page-design** _Group pages into sections_ gives the app, and the `source` (`claude-code` in Claude Code, `codex` in Codex, left out when you cannot tell which harness runs you). `<name>` is kebab case, from the app or the area: `crm`, `stock-dashboard`. Over a database, write `data` with the connection and the `access` the proposal answers ([SPEC.md](SPEC.md) _Connection access_). Give the user the link `/mockup?name=<name>` now, before any page exists. A mockup of an existing app starts empty too, never from a copy of its pages: it holds only the pages you add or convert, its sidebar shows only those and their sections, and a page with no `category` shows under the default _PAGES_ heading.
50
+ 2. **Add the pages one at a time**, each as a skeleton: one `mockup_patch_spec` with `add` at `/pages/-`, the page with its `category` and all its blocks in reading order, a sub-page right after its parent, each with an `id` and a title, and its data as `$generate` fixtures. **To change an existing page**, call `mockup_from_page` with `{ pageRef, into: "<current mockup>" }` (`pageRef` as `builder_list_pages` lists it): it brings the live page into the mockup at its real section and order, with `livePage`, `liveRoutes` and samples shaped as each block reads them, on real data by default. Then edit it with `mockup_patch_spec`. Never copy an existing page into the spec by hand. It refuses a page already in the mockup unless `replace: true`. Without `into`, `mockup_from_page` makes the page's own single-page mockup, only when the user asks for just that page. It runs only while `ajs project dev` runs. Add a new page at its menu place (`/pages/<i>`, with its `category`), not at the end by default.
51
+ 3. **Fill each page section by section**: 2 or 3 related blocks per patch (the KPI row, then the table, then the form). Never one call per block, never the whole spec in one call.
52
+ 4. **Data.** Use `$generate` with the default 8 rows. Write hand values only where a figure must read true: a KPI headline, a total repeated on another page. Every block's data, hand-written or generated, sits in the page's `fixtures`, shaped as [SPEC.md](SPEC.md) _Fixture shapes_ says for its block, and the block reads it with `fetchUrl: "fixture:<key>"`: never inline a series or a list of items in a block's options (`staticItems`, `staticDataset`), which nests the payload deep enough to break its JSON, and never dig through `node_modules` for a block's data shape: the table says it. Date hand-written rows that should look recent in the last 30 days, as `$generate` dates are. A `KpiCard` or `ChartCard` fixture gets a `delta` or `previousValue` only on a page with a `PeriodSelector`: the built card shows no change figure elsewhere, so leave them out, or add a `PeriodSelector` when the user wants change figures. Keep entities, names and figures coherent across pages, and over existing resources use the columns and types they declare.
53
+ 5. **Tables.** Give each `TableView` its `caption` and every feature **dms-page-design** _Tables_ gives its data, written as [SPEC.md](SPEC.md) _Tables_ says: badges and prices as column `display` (a rating 1 to 5 is a `badge`, 1 and 2 `error`, 3 `warning`, 4 and 5 `success`, never a cell display), status tabs as `tabsFrom`, the board, cards or groups with the default display, and the saved views. Over a database, write what the proposal holds: a column it draws as a badge is a badge, its relation's `tabs` are `tabsFrom`, a price is a price. The proposal shows how many values a badge draws, never which: write that many items, each a value of the column's fixture, toned as _Tables_ says, or a native enum's labels when the schema declares them.
54
+ 6. **Links, sub-pages and forms.** The mockup clicks through like the app: write every detail page, form and link that **dms-page-design** _Records, forms and links_ decides, as [SPEC.md](SPEC.md) _Links and sub-pages_, _Table forms_ and _Archive mode_ say. On a `read` connection the tables write nothing; on `read-write`, propose each table's add, edit, delete or archive actions as **dms-page-design** _Records, forms and links_ decides from the proposal's `writes`, with the `formContainer` it picks, as **dms-external-database** _Connection access_ says.
55
+ 7. **Sketches.** One per custom part the user chose, kept to that element, as [SPEC.md](SPEC.md) _Sketches_ says. A sketch or a custom page that leads to another page links to it with `<a href="page:<id>">`. Draw each empty, error or loading design the part must handle as a state, so the build handles it too.
56
+ 8. **A failed patch** costs only that patch: its `errors` name the nodes. Fix it and send it again, never rewrite the spec. A value refused as not one of an enum's allowed values (the error lists them): pick the closest allowed value yourself, send it, and say in your reply which value you replaced with which (a `refunded` badge tone `pink` becomes `warning`); ask the user only when none is close. A call refused because its input "could not be parsed as JSON" never reached the mockup: never send that payload again as it was. Send the same change as two smaller patches, the page's `fixtures` in one and its blocks in the other, or half its blocks in each.
52
57
 
53
- Validate it: `mockup_write_spec` answers its `errors`; otherwise `GET /api/mockup/<name>` answers every issue with the JSON pointer of its node ([SPEC.md](SPEC.md) _Validation_); without a running DMS, check the file against the schema. The step is done when the spec has no issue. Then give the user the link: `/mockup?name=<name>` on the running DMS.
58
+ Texts are in the user's language. Without `mockup_write_spec` and `mockup_patch_spec`, edit `spec.json` in the same order, one save per step: the file empty first, then each page, then each section.
59
+
60
+ Validate every save: `mockup_write_spec` and `mockup_patch_spec` answer their `errors`; otherwise `GET /api/mockup/<name>` answers every issue with the JSON pointer of its node ([SPEC.md](SPEC.md) _Validation_); without a running DMS, check the file against the schema. The step is done when the last save has no issue and every page of the interview exists, with its sub-pages and, over a database, the dashboard first with no `category`.
54
61
 
55
62
  ## 4. Iterate on annotations
56
63
 
57
64
  When the user says they commented, or asks what is left, list the open annotations. For each one:
58
65
 
59
- 1. Find the node its path names, and the wish behind it.
66
+ 1. Find the node it is pinned on, and the wish behind it. `mockup_annotations` answers each annotation's block with its JSON pointer and its node: patch from those, and read only the parts of the spec you still need with `mockup_read_spec`, never the whole file and never by probing with `test` operations or temporary keys. Without it, use the file tools, never a shell command: Safe mode refuses shell commands.
60
67
  2. Change the spec. A request the DMS blocks cannot meet goes through step 2 again, never straight to a sketch.
61
68
  3. Resolve the annotation, and note what changed for the report.
62
69