@antelopejs/agent-skills 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,351 @@
1
+ # Reference: external database
2
+
3
+ ## Connecting
4
+
5
+ One `builder_configure_project` call. Replace the names, and `<version>` with the range the
6
+ integrator gave you:
7
+
8
+ ```json
9
+ {
10
+ "steps": [
11
+ {
12
+ "op": "AddModule",
13
+ "id": "postgres-erp",
14
+ "entry": {
15
+ "source": {
16
+ "type": "package",
17
+ "package": "@antelopejs/postgres",
18
+ "version": "<version>"
19
+ },
20
+ "config": { "mode": "external", "statementTimeoutMs": 30000 },
21
+ "env": { "url": "ERP_DATABASE_URL" },
22
+ "exportPriority": { "@antelopejs/interface-database": -1 }
23
+ }
24
+ },
25
+ {
26
+ "op": "CreateLocalModule",
27
+ "id": "erp-tables",
28
+ "path": "modules/erp-tables",
29
+ "connection": "erp",
30
+ "entry": {
31
+ "importOverrides": [
32
+ {
33
+ "interface": "@antelopejs/interface-database",
34
+ "source": "postgres-erp"
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ {
40
+ "op": "ConfigureModule",
41
+ "id": "dms",
42
+ "entry": {
43
+ "importOverrides": [
44
+ {
45
+ "interface": "@antelopejs/interface-database-catalog",
46
+ "source": "postgres-erp",
47
+ "id": "erp"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ {
53
+ "op": "ConfigureModule",
54
+ "id": "dms",
55
+ "entry": {
56
+ "importOverrides": [
57
+ {
58
+ "interface": "@antelopejs/interface-database",
59
+ "source": "<project database module>"
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ]
65
+ }
66
+ ```
67
+
68
+ - **Step 1** is the client's database as an external instance of its engine's module. Its URL
69
+ comes from the variable. Its `exportPriority` of -1 ranks it below the project's own database,
70
+ so a module that does not pin `@antelopejs/interface-database` keeps the project's.
71
+ - **Step 2** is the module the tables are generated into. It is bound to that instance, and
72
+ `connection` records that it holds the tables of `erp`.
73
+ - **Step 3** gives the builder and the `database_*` tools the connection `erp`, the same id for
74
+ both. It configures the module that serves the DMS MCP: `dms`. A project whose builder tools
75
+ still come from `dms-builder` and `dms-ai` takes one such step for each of them instead.
76
+ - **Step 4** keeps the DMS on the project's own database. The DMS module is the one that provides
77
+ `@antelopejs/interface-dms`. Step 2 pins `@antelopejs/interface-database` and uses the DMS, so
78
+ the DMS inherits that pin and would be reached with two bindings. Its `source` is the module
79
+ core picks by default among the modules of `antelope.config.ts` that provide
80
+ `@antelopejs/interface-database` before this call (a module's `package.json` lists what it
81
+ provides under `antelopeJs.implements`): the highest `exportPriority` for it (0 when unset),
82
+ the alphabetically first id on a tie. Never assume `mongodb`. Leave the step out when the DMS
83
+ module already pins `@antelopejs/interface-database`, provides it itself, or no module
84
+ provided it before this call. When an `environments` entry of the configuration sets an
85
+ `exportPriority`, or a provider's priority is not a plain number, stop and ask the integrator
86
+ which module the DMS uses.
87
+
88
+ For MySQL, MariaDB, MongoDB and RethinkDB, step 1 changes, and the other steps name its id in
89
+ place of `postgres-erp`.
90
+
91
+ MySQL and MariaDB share one module, `@antelopejs/mysql`, which tells them apart when it connects.
92
+ Its URL holds the database as its path: `mysql://user:password@host:3306/erp`.
93
+
94
+ ```json
95
+ {
96
+ "op": "AddModule",
97
+ "id": "mysql-erp",
98
+ "entry": {
99
+ "source": {
100
+ "type": "package",
101
+ "package": "@antelopejs/mysql",
102
+ "version": "<version>"
103
+ },
104
+ "config": { "mode": "external", "statementTimeoutMs": 30000 },
105
+ "env": { "url": "ERP_DATABASE_URL" }
106
+ }
107
+ }
108
+ ```
109
+
110
+ For MongoDB and RethinkDB, the `disabledExports` entry keeps the external instance from ever
111
+ serving the raw client other modules ask for:
112
+
113
+ ```json
114
+ {
115
+ "op": "AddModule",
116
+ "id": "mongodb-erp",
117
+ "entry": {
118
+ "source": {
119
+ "type": "package",
120
+ "package": "@antelopejs/mongodb",
121
+ "version": "<version>"
122
+ },
123
+ "config": { "mode": "external", "statementTimeoutMs": 30000 },
124
+ "env": { "url": "ERP_DATABASE_URL", "database": "ERP_DATABASE_NAME" },
125
+ "exportPriority": { "@antelopejs/interface-database": -1 },
126
+ "disabledExports": ["@antelopejs/interface-mongodb"]
127
+ }
128
+ }
129
+ ```
130
+
131
+ ```json
132
+ {
133
+ "op": "AddModule",
134
+ "id": "rethinkdb-erp",
135
+ "entry": {
136
+ "source": {
137
+ "type": "package",
138
+ "package": "@antelopejs/rethinkdb",
139
+ "version": "<version>"
140
+ },
141
+ "config": { "mode": "external", "statementTimeoutMs": 30000 },
142
+ "env": { "url": "ERP_DATABASE_URL" },
143
+ "exportPriority": { "@antelopejs/interface-database": -1 },
144
+ "disabledExports": ["@antelopejs/interface-rethinkdb"]
145
+ }
146
+ }
147
+ ```
148
+
149
+ The RethinkDB URL holds the database as its path: `rethinkdb://user:password@host:28015/erp`.
150
+
151
+ ## The proposal
152
+
153
+ `builder_analyse_database` answers it once the job is done:
154
+
155
+ ```json
156
+ {
157
+ "connection": "erp",
158
+ "module": "erp-tables",
159
+ "database": {
160
+ "engine": "postgresql 17.5",
161
+ "role": "erp_reader",
162
+ "writes": "none"
163
+ },
164
+ "resources": [
165
+ {
166
+ "relation": "sales.customers",
167
+ "tableView": { "value": true, "rule": "R6", "kind": "default" },
168
+ "writable": { "value": false, "rule": "W1", "kind": "default" },
169
+ "label": { "value": "name", "rule": "L1", "kind": "default" },
170
+ "title": { "value": "Customers", "rule": "L2", "kind": "default" },
171
+ "fields": [
172
+ {
173
+ "column": "segment",
174
+ "native": "sales.segment",
175
+ "accepts": ["string"],
176
+ "declared": { "value": "string", "rule": "F3", "kind": "fact" },
177
+ "filterable": { "value": true, "rule": "FL", "kind": "default" },
178
+ "profile": { "traits": ["enum-like"], "distinct": 4 }
179
+ }
180
+ ],
181
+ "leftOut": [
182
+ {
183
+ "column": "password_hash",
184
+ "reason": "named like a secret",
185
+ "rule": "F2"
186
+ }
187
+ ],
188
+ "writes": { "insert": false, "update": false, "delete": false }
189
+ }
190
+ ],
191
+ "excluded": [
192
+ {
193
+ "relation": "sales.people",
194
+ "reason": "SELECT is granted on some columns only",
195
+ "rule": "R1"
196
+ }
197
+ ],
198
+ "open": [
199
+ {
200
+ "id": "purpose:legacy.t_cst",
201
+ "kind": "purpose",
202
+ "relation": "legacy.t_cst",
203
+ "question": "What does legacy.t_cst hold?",
204
+ "options": ["…"],
205
+ "proposed": null,
206
+ "resource": { "relation": "legacy.t_cst", "…": "…" },
207
+ "open": [
208
+ { "id": "reference:legacy.t_cst.c05", "kind": "reference", "…": "…" }
209
+ ]
210
+ }
211
+ ]
212
+ }
213
+ ```
214
+
215
+ The rules, in the order they apply to a relation:
216
+
217
+ | Rule | When | Then |
218
+ | ---- | ------------------------------------------------- | ------------------------------------------------- |
219
+ | R1 | the catalog says unmappable | excluded |
220
+ | R4 | a framework's or a migration tool's table | excluded |
221
+ | R3 | no rows | excluded |
222
+ | R2 | no key | stats only |
223
+ | R5 | keyed by its two references | stats only: a link table |
224
+ | R6 | keyed, with a label candidate | TableView |
225
+ | R7 | keyed, no label, referenced | TableView labelled by its key, and a `label` item |
226
+ | R8 | keyed, no label, not referenced, with a time axis | stats only: events or a log |
227
+ | R9 | anything else | a `purpose` item |
228
+
229
+ For columns: F1 and F2 leave out a column no type reads and one named like a secret, F3 proposes
230
+ the first accepted declaration, F4 makes a reference the database declares a relation column
231
+ (PostgreSQL, MySQL and MariaDB), F5 one found whole by `CheckReference`. L1 chooses labels, L2 titles, FL the four flags, W1 read-only.
232
+
233
+ ## Plan
234
+
235
+ ```markdown
236
+ ## Database
237
+
238
+ erp · postgresql 17.5 · role erp_reader (read only) · 42 relations: 9 TableViews, 6 stats only, 18 excluded, 3 open
239
+
240
+ ## Changes to the Builder's proposal
241
+
242
+ - legacy.t_cst (purpose) → TableView "Customers": its comment says "clients"; label `c02`, a short unique text
243
+ - sales.events (R8, stats only) → TableView: named and commented as calendar events people edit
244
+ - sales.orders: editable, as asked; the role here writes nothing
245
+
246
+ ## Questions
247
+
248
+ - How does revenue trend, and how does it compare with last year? (sales.orders, sum of total, by ordered_at)
249
+ - Which statuses do orders end in? (sales.orders, count, by status)
250
+ - Which countries buy most? (sales.orders, sum of total, by country)
251
+
252
+ ## Analytics pages
253
+
254
+ ### Sales (sales.orders)
255
+
256
+ - Period: ordered_at runs 2024-01-03 to 2026-10-28 → default last-90-days vs previous-period; presets last-90-days, ytd, last-year, custom
257
+ - Toolbar: PageToolbar › PeriodSelector
258
+ - KPIs: revenue (sum of total) · orders (count) · units (sum of quantity), each with delta and sparkline
259
+ - ChartCard › ChartArea: revenue per month
260
+ - ChartCard › ChartDonut: orders by status (5 values)
261
+ - ChartCard › ChartBar: top 10 countries by revenue
262
+ - TopListCard: top 10 cities by orders
263
+
264
+ ## Left open
265
+
266
+ - label:legacy.t_ord — no column names an order; the integrator picks one in the Builder
267
+
268
+ ## Not possible yet
269
+
270
+ - Revenue per customer name: needs the customer's name beside each order
271
+ ```
272
+
273
+ ## Mapping
274
+
275
+ The proposal's values, without their rules, plus what you changed:
276
+
277
+ ```json
278
+ {
279
+ "module": "erp-tables",
280
+ "connection": "erp",
281
+ "resources": [
282
+ {
283
+ "relation": "sales.customers",
284
+ "label": "name",
285
+ "title": "Customers",
286
+ "tableView": true,
287
+ "writable": true,
288
+ "fields": [
289
+ { "column": "name", "searchable": true, "sortable": true },
290
+ { "column": "segment", "filterable": true },
291
+ { "column": "email" },
292
+ { "column": "created_at", "sortable": true }
293
+ ]
294
+ },
295
+ {
296
+ "relation": "sales.orders",
297
+ "tableView": true,
298
+ "writable": false,
299
+ "tabs": { "column": "status" },
300
+ "fields": [
301
+ {
302
+ "column": "status",
303
+ "filterable": true,
304
+ "display": {
305
+ "kind": "badge",
306
+ "items": [{ "value": "paid", "label": "Paid", "tone": "success" }]
307
+ }
308
+ },
309
+ { "column": "ordered_at", "sortable": true },
310
+ {
311
+ "column": "total",
312
+ "display": { "kind": "price", "currency": "USD" }
313
+ },
314
+ {
315
+ "column": "customer_code",
316
+ "relation": "sales.customers",
317
+ "label": "Customer"
318
+ }
319
+ ]
320
+ },
321
+ {
322
+ "relation": "sales.audit_log",
323
+ "tableView": false,
324
+ "writable": false,
325
+ "fields": [{ "column": "at" }, { "column": "action" }]
326
+ }
327
+ ],
328
+ "excluded": [
329
+ {
330
+ "relation": "sales.people",
331
+ "reason": "SELECT is granted on some columns only"
332
+ }
333
+ ]
334
+ }
335
+ ```
336
+
337
+ - `declared` defaults to the column's `accepts[0]`. Set it only to take another accepted
338
+ declaration, and always for a column a `field-type` item asked about: give the answer as its
339
+ `declared`.
340
+ - Send `display` (each field) and `tabs` (each relation) as the proposal has them; `null` turns
341
+ one off.
342
+ - Key columns are added for you.
343
+ - A relation column's target must be in the same call, with a `label`, or mapped in the module
344
+ before.
345
+ - Two spellings, never mixed:
346
+ - a relation is `schema.name` (`erp.audit_log`) in `relation` fields;
347
+ - a resource ref is `<connection>/<schema>/<relation>` in kebab case (`erp/erp/audit-log`) in
348
+ `builder_add_query`'s `resource`.
349
+
350
+ Every mapped relation has a ref, `tableView: false` ones included. MapResources answers each
351
+ one's ref.
@@ -0,0 +1,222 @@
1
+ ---
2
+ name: dms-external-database
3
+ description: Connects an AntelopeJS DMS project to a client's existing database, runs the builder's analysis of it, settles what the analysis could not decide from the catalog and aggregates, generates TableViews through the builder, names them and gives each the table features its data supports, and always builds an analytics dashboard first in the menu. Use when the user wants pages over a database the project does not own, PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB ("plug in our client's Postgres", "connect their MySQL database", "map their Mongo database", "generate the admin for this database", "finish the mapping the builder proposed").
4
+ ---
5
+
6
+ # Pages over a client's existing database
7
+
8
+ The Builder analyses the database by itself: from the catalog and the profiles, fixed rules
9
+ propose a mapping and name every choice's rule. Your work is what those rules cannot do: answer
10
+ the questions they left open, revisit the defaults the names and comments contradict, and plan the
11
+ analytics pages from the data. You never start from scratch.
12
+
13
+ You work through the `database_*` and `builder_*` tools of the DMS MCP only. You never read rows
14
+ of the client's database: the catalog and aggregates are what you have, and they are enough. The
15
+ database's URL lives in the project's `.env`: read neither `.env` nor the environment, print
16
+ neither, and write no credential yourself. The dms-assistant chat also refuses file tools on
17
+ `.env`; elsewhere nothing does, so this rule is yours to hold.
18
+
19
+ ## Before you start
20
+
21
+ Settle what the project has, as `dms-builder-mcp` _Detect what the project has_ says.
22
+
23
+ - **No `database_connections` or `builder_analyse_database` among your tools**: this flow needs
24
+ them, and no code edit replaces the analysis. Tell the integrator the builder MCP answers while
25
+ `ajs project dev` runs, ask them to start it and reload the MCP servers, and stop until it
26
+ answers.
27
+ - **In the dms-assistant chat**: analysing and settling run in plan mode, and the integrator
28
+ presses **Run** on your plan before anything is written.
29
+ - **Anywhere else** (Claude Code, Codex): there is no **Run** button. Present the plan, and write
30
+ nothing until the integrator approves it in the session. A mapping that removes pages, a
31
+ deletion or a project configuration change is refused once with what it would do: show that to
32
+ the integrator, and repeat the identical call only after they confirm it.
33
+
34
+ The flow is **connect → analyse → settle → validate → apply → check**. Analysing and settling
35
+ read only. Nothing is written before the integrator approves your plan.
36
+
37
+ ## 1. Connect
38
+
39
+ Call `database_connections`.
40
+
41
+ - **A connection is listed** with an `engine`: use its id and go to 2.
42
+ - **An entry answers `error`**: say what it says (an owned instance, the catalog not enabled, a
43
+ role that cannot read) and stop.
44
+ - **A database tool answers `unreachable_connection`**: the DMS MCP reaches only the catalog
45
+ connection `dms` imports. The connection exists, but step 3 of REFERENCE.md _Connecting_ is
46
+ missing: propose that step alone, with the same approval and restart.
47
+ - **Nothing is listed**: the project is not connected yet. Ask the integrator which engine the
48
+ database runs: PostgreSQL, MySQL or MariaDB, MongoDB, or RethinkDB. Propose one
49
+ `builder_configure_project` call with that engine's steps in REFERENCE.md _Connecting_. Pick
50
+ the names with the integrator, for example connection `erp`, provider module `postgres-erp`
51
+ (`mysql-erp`, `mongodb-erp`, `rethinkdb-erp`), generated module `erp-tables`, variable
52
+ `ERP_DATABASE_URL`, and for MongoDB `ERP_DATABASE_NAME`. Ask the integrator for the version of
53
+ 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.
57
+ - Then tell the integrator to put the URL in `.env` (`ERP_DATABASE_URL=postgres://…`,
58
+ `mysql://…/<database>` for MySQL and MariaDB, `mongodb://…`, or `rethinkdb://…/<database>`;
59
+ for MongoDB also `ERP_DATABASE_NAME`), or in the builder's _Database_ workspace when the
60
+ project has one, which writes it there, and to restart the project. Every deployed
61
+ environment needs the same variables, set where that environment keeps its secrets, never in
62
+ 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.
67
+ - Stop here: the connection exists only after the restart.
68
+
69
+ The builder and you each have a connection to the database, under the same id: the builder for
70
+ its analysis and mapping, you for your probing.
71
+
72
+ ## 2. Analyse
73
+
74
+ `builder_analyse_database` with the connection and the generated module.
75
+
76
+ - It answers the proposal, or, when profiling takes longer, the job's progress and `id`: call it
77
+ again with `job` until the proposal is in.
78
+ - A `schemas` open item means the database is large: ask the integrator which schemas matter and
79
+ analyse again with `schemas`. On MySQL and MariaDB a schema is a database.
80
+ - Relations the module mapped or excluded before are not proposed again. On a module mapped
81
+ already, the proposal is what is left.
82
+
83
+ Read the proposal as REFERENCE.md _The proposal_ explains: every choice has a `rule` and a `kind`.
84
+ A `fact` follows from the catalog; leave it. A `default` is a judgement; check it.
85
+
86
+ ## 3. Settle
87
+
88
+ Through the read-only tools (in plan mode, in the dms-assistant chat). Probe lightly: a targeted `database_profile` of a few
89
+ columns, a `CheckReference` in `references`, a `database_describe` of one relation. Never a
90
+ profile of the whole database again: the Builder did it.
91
+
92
+ - **Open items**, one by one:
93
+ - `purpose`: what a relation holds. Decide from its name, comment, columns and profile:
94
+ entities to list (a TableView), facts to count (stats only), or nothing to show (excluded).
95
+ The item carries the relation as it would be mapped, and in its own `open` the questions
96
+ that mapping leaves. Answer those only when you map the relation.
97
+ - `label`: which column names a row. Prefer a name or title, then a code or number people
98
+ recognise.
99
+ - `reference`: a column found almost whole in another relation's key. Check it with
100
+ `CheckReference` on the column; make it a relation column only at containment 1.
101
+ - `field-type`: a field of a document database whose sampled values have several types, none
102
+ covering enough of them (`int 60% | string 40%`). Pick the declaration that reads what
103
+ the field means, from its name and its shares, or leave it out. Unanswered, it stays out.
104
+ - Where nothing tells you, say so and leave the item open: the integrator answers it in the
105
+ builder. Do not guess.
106
+ - **Defaults worth revisiting.** For example a table rule R8 calls a log whose name and comment
107
+ say it holds entities, a label rule L1 chose that a comment contradicts, or a title taken from a
108
+ cryptic name.
109
+ - **Document databases** (MongoDB, RethinkDB) declare no field types and no references: the
110
+ catalog reads types from a sample, and every reference comes from a name and a `CheckReference`,
111
+ never from the database. An embedded document is one field: its subfields are not mappable, and
112
+ 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.
115
+ - **Pages people can work with.** Load the `dms-page-design` skill. For every TableView, plan
116
+ from its columns, profiles and categories, as _Name every page_ and _Tables_ there say: a
117
+ title, an icon and a description; the tabs, saved views, display modes, footer totals and
118
+ KPI cards its data supports. Decide each from the data, and leave out what the data does
119
+ not support.
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:
122
+ 1. **Inspect.** For each relation, read from the proposal its rows, its `time-axis` columns
123
+ with their `range`, its `measure` columns, and its `enum-like` columns with their
124
+ `categories`. Profile a column the proposal leaves without them, such as the main date
125
+ column's range. Write each range down: the period rule needs the last date.
126
+ 2. **Ask.** Write the 4 to 8 questions the owner of this data asks every week: how revenue
127
+ or volume trends, what sells, who buys, where, and how it compares with last year. Each
128
+ question names the relation, the measure (a sum of a `measure` column or a row count)
129
+ and the grouping (the time axis or a column of the same relation).
130
+ 3. **Plan pages.** The relation with a time axis, a measure and the most rows is the main
131
+ fact relation. It gets the dashboard, named for its area ("Sales", or "Overview" when it
132
+ also carries the other relations' headline figures), holding every question about it.
133
+ Another relation gets its own analytics page only when it has its own time axis and at
134
+ least 100 rows. When no relation has a time axis, the dashboard still exists: KPI cards
135
+ of counts and sums, and breakdowns by the category columns, with no period selector.
136
+ 4. **Choose blocks** for each question with `dms-page-design`, and its default period from
137
+ the main time axis's real range.
138
+ - **The minimum.** Your plan, and the pages you write, meet all of these:
139
+ - 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;
141
+ - every page with a title in the owner's words, an icon and a description, never the raw
142
+ relation name;
143
+ - every table given the tabs, views, display modes, footer totals and KPI cards its data
144
+ supports, as `dms-page-design` _Tables_ decides;
145
+ - at least 3 different chart kinds on it when the data has the shapes for them;
146
+ - a default period computed from the data's real dates, never assumed;
147
+ - every page built with one `builder_compose_page` call, previewed first, and every block whose
148
+ preview is empty, zero or failed dropped or changed;
149
+ - every page checked as `dms-builder-mcp` _Verify_ says before you report.
150
+ - **Not possible yet:** breakdowns by a related entity's name, such as revenue per customer.
151
+ Templates read one relation, so they would show ids. List them under _Not possible yet_,
152
+ never as pages.
153
+
154
+ 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.
157
+
158
+ ## 4. Validate
159
+
160
+ The integrator answers in chat or with "suggest a change". Revise the plan and present it
161
+ again. Write nothing before they approve it (**Run** in the dms-assistant chat).
162
+
163
+ ## 5. Apply
164
+
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.
167
+
168
+ 1. `builder_map_resources` in batches of 3 or 4 relations per call, TableViews and stats-only
169
+ relations alike; the relations decided against go in `excluded` on the first call
170
+ (REFERENCE.md _Mapping_). One call with every relation of a large database can abort.
171
+ - Send the proposal's choices as they stand where you changed nothing, plus per resource
172
+ the `title`, `icon`, `description` and `tableOptions` you planned.
173
+ - On `invalid_config`, fix the choice it names and call again: a refused call writes nothing.
174
+ When the same choice is refused twice, drop it (send the relation without that display or
175
+ option) and say so in your report, rather than trying more variants.
176
+ - It answers each relation's `ref`, which queries name it by, `category`, the connection's
177
+ category ref (`pages.<connection>`), and `leftOut`: carry those into your report.
178
+ 2. Per analytics page, one `builder_compose_page` call with `create` (`name`, `displayName`,
179
+ `module` set to the generated module, `category` set to the `category` MapResources
180
+ answered, an icon, a description, and `order: 0` for the dashboard, 1, 2… for the next
181
+ ones) and every block in the order `dms-page-design` lays out, each data block with its
182
+ query inline. Preview first, then write, as `dms-page-design` _Build a page in one call_
183
+ says.
184
+ - Queries read the mapped resources by their refs (`<connection>/<schema>/<relation>`).
185
+ 3. Per table page that gets KPI cards above its table, one `builder_compose_page` call with
186
+ `placement: { "before": "table" }`, previewed first. A table option MapResources refused
187
+ comes back as a warning: fix it with `builder_configure_table_view`.
188
+
189
+ To change a relation later, read its current choices with `builder_mapping`, then call
190
+ `builder_map_resources` with that relation alone, its included columns as they are and only your
191
+ change made: a mapped relation is rewritten from the choices sent, and its page follows.
192
+
193
+ ## 6. Check
194
+
195
+ - Navigate only once every page is written. Pages register when the host reloads the generated
196
+ module: under `ajs project dev` its watcher rebuilds the module after your writes.
197
+ - `navigate_to_page` for each page. If it answers `unknown_route`, the reload has not happened.
198
+ - Read `query_logs` once, for a reload error.
199
+ - Then tell the integrator the pages appear once the module reloads. Do not wait, retry or
200
+ investigate further.
201
+ - `query_logs` for registration warnings (lossy fields, unserved indexes) and for the errors of
202
+ the routes the pages called.
203
+ - On each analytics page, check every block as `dms-builder-mcp` _Verify_ says, fix or remove
204
+ each one that shows no data or an error, and check again, as in `dms-page-design` _Build a page in one call, and check it first_.
205
+
206
+ Then report:
207
+
208
+ - what the builder mapped by its rules, and what you changed;
209
+ - the pages made, with each analytics page's default period and the date range it came from,
210
+ and per table the features you gave it and why;
211
+ - every block that still shows no data, and why;
212
+ - what was left out and why;
213
+ - the open items left, which the integrator finds in the builder's _Database_ workspace;
214
+ - the variable every deployment must set.
215
+
216
+ ## Guardrails
217
+
218
+ - Never write a URL, password or token into a tool call, the config or a page.
219
+ - Never map into the project's own module: only into the module bound to the connection.
220
+ - `builder_create_resource`, `builder_add_field` and table-side `builder_configure_field` are
221
+ refused in that module: its tables are the database's.
222
+ - `builder_delete_resource` there never deletes the client's rows.
@@ -0,0 +1,65 @@
1
+ ---
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.
4
+ ---
5
+
6
+ # DMS mockups
7
+
8
+ A mockup is `mockups/<name>/spec.json` in the project: the pages of an app as trees of real DMS blocks, with **fixtures** standing in for their data and **sketch** nodes standing in for the custom parts. The dev-only `/mockup` page of the running DMS draws the spec with the real renderer and redraws it on every save, with no typecheck and no reload. The user comments on any element there; the comments land in `mockups/<name>/annotations.json`. [SPEC.md](SPEC.md) holds the file formats.
9
+
10
+ The mockup is done when the user approves it. Building the real pages from it is **dms-mockup-build**.
11
+
12
+ ## Detect what the project has
13
+
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
+ - **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
+ - **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.
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
+
20
+ ## 1. Interview
21
+
22
+ Collect the user's **wishes**: each thing a screen must show or let someone do. Ask, in as few rounds as the answers allow:
23
+
24
+ - what the app is for, and who opens it (roles);
25
+ - the pages, and for each the question it answers or the job it does;
26
+ - the data each page shows: entities, their main fields, the figures that matter;
27
+ - the actions: create, edit, approve, export, …;
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
+
30
+ When the project already has a database or resources (`builder_list_resources`, `database_connections`), read their names and fields first 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.
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.
33
+
34
+ ## 2. Check every wish against the catalog
35
+
36
+ For each wish, find the closest DMS block or composition in the catalog, with the mapping table of **dms-best-practices** [REFERENCE.md](../dms-best-practices/REFERENCE.md). Then:
37
+
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
+ - **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
+
41
+ This step is done when every wish maps to a block, a composition, or a sketch the user chose.
42
+
43
+ ## 3. Write the spec
44
+
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):
46
+
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, realistic and coherent across pages (the order total on the list matches the KPI), sized like the real data (a dozen rows, not two);
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.
52
+
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.
54
+
55
+ ## 4. Iterate on annotations
56
+
57
+ When the user says they commented, or asks what is left, list the open annotations. For each one:
58
+
59
+ 1. Find the node its path names, and the wish behind it.
60
+ 2. Change the spec. A request the DMS blocks cannot meet goes through step 2 again, never straight to a sketch.
61
+ 3. Resolve the annotation, and note what changed for the report.
62
+
63
+ Save after each batch, as one `mockup_patch_spec` call when it is among your tools: the preview redraws on its own. A patch that fails, or a spec it leaves invalid, is not written: fix it and send it again. Report the annotations you resolved and those you left open, with the question each one raises.
64
+
65
+ The mockup is done when no annotation is open and the user approves it. Then offer **dms-mockup-build**.