@antelopejs/agent-skills 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @antelopejs/agent-skills
2
2
 
3
- Finds the agent skills that AntelopeJS packages ship. The Claude Code and Codex plugin of [AntelopeJS/agent-skills](https://github.com/AntelopeJS/agent-skills) and the dms-ai assistant both call it, so they see the same skills.
3
+ Finds the agent skills that AntelopeJS packages ship. The Claude Code and Codex plugin of [AntelopeJS/agent-skills](https://github.com/AntelopeJS/agent-skills) and the dms-assistant module both call it, so they see the same skills.
4
4
 
5
5
  A package ships skills by declaring `antelopeJs.skills` in its `package.json`: directories (relative to the package root) whose subdirectories each hold a `SKILL.md`. This package decides which packages count and which copy of each wins. Reading the skills inside the directories, and naming them, stays with the caller.
6
6
 
@@ -30,6 +30,16 @@ A module or dependency with a readable manifest and a name reserves that name ev
30
30
 
31
31
  Only packages with at least one skill directory are returned. A skill directory outside its package is dropped and reported through `onWarning`. A missing or malformed `package.json` reads as absent and never throws.
32
32
 
33
+ ## Workflow skills
34
+
35
+ The package also carries the DMS workflow skills of the `antelopejs` plugin (`dms-pages`, `dms-best-practices`, `dms-builder-mcp`, `dms-page-design`, `dms-external-database`, `dms-mockup`, `dms-mockup-build`), copied from `plugin/skills/` when it is packed. They teach building in the DMS and ship with no module, so a runtime that loads them gives its agent the same guidance as the plugin.
36
+
37
+ ```js
38
+ import { workflowSkillsDir } from "@antelopejs/agent-skills";
39
+ ```
40
+
41
+ `workflowSkillsDir` is the absolute path of their directory: one subdirectory per skill, each holding a `SKILL.md`. The package does not declare them in `antelopeJs.skills`, so the plugin's sync never links them a second time into a project that installs this package. A source checkout has the directory only while the package is packed.
42
+
33
43
  ## Requirements
34
44
 
35
45
  Node.js 20.19 or later. The package is an ES module with no dependencies and no top-level `await`, so a CommonJS caller loads it with `require()`.
package/index.d.ts CHANGED
@@ -56,3 +56,12 @@ export interface CollectSkillPackagesInput {
56
56
  export function collectSkillPackages(
57
57
  input: CollectSkillPackagesInput,
58
58
  ): SkillPackage[];
59
+
60
+ /**
61
+ * Absolute path of the DMS workflow skills (`dms-pages`, `dms-builder-mcp`,
62
+ * `dms-mockup`, …) of the `antelopejs` plugin, copied into the published
63
+ * package: one directory per skill, each holding a `SKILL.md`. A caller loads
64
+ * them like the skills of {@link collectSkillPackages}. A source checkout has
65
+ * no such directory until the package is packed.
66
+ */
67
+ export declare const workflowSkillsDir: string;
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readFileSync, realpathSync } from "node:fs";
2
2
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { fileURLToPath } from "node:url";
3
4
 
4
5
  const MANIFEST_FILE = "package.json";
5
6
  const NODE_MODULES_DIR = "node_modules";
@@ -279,3 +280,13 @@ export function collectSkillPackages(input) {
279
280
  }
280
281
  return found;
281
282
  }
283
+
284
+ /**
285
+ * The DMS workflow skills of the `antelopejs` plugin, copied into this package
286
+ * when it is packed: one directory per skill, each holding a `SKILL.md`.
287
+ * @type {string}
288
+ */
289
+ export const workflowSkillsDir = join(
290
+ dirname(fileURLToPath(import.meta.url)),
291
+ "skills",
292
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/agent-skills",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
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",
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "index.mjs",
23
23
  "index.d.ts",
24
+ "skills",
24
25
  "LICENSE",
25
26
  "README.md"
26
27
  ],
@@ -41,6 +42,8 @@
41
42
  },
42
43
  "scripts": {
43
44
  "typecheck": "tsc -p .",
45
+ "prepack": "node scripts/pack-skills.mjs",
46
+ "postpack": "node scripts/pack-skills.mjs --clean",
44
47
  "release": "release-it"
45
48
  },
46
49
  "devDependencies": {
@@ -0,0 +1,143 @@
1
+ # dms-best-practices reference
2
+
3
+ Material for [SKILL.md](SKILL.md): mapping design elements to DMS blocks, the `preview_blocks` call with a sketch variant, the Safe mode question, and the text fallback. The block catalog is the source of truth: `builder_catalog` with the builder MCP, `ListBlockTypes()` from `@antelopejs/interface-dms/base/block-types`, or https://dms.antelopejs.com/docs/components (one page per block).
4
+
5
+ ## Design element → DMS block
6
+
7
+ | In the design | DMS block | Usual visible differences |
8
+ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
9
+ | Big number with a trend arrow | `KpiCard` (`variant: "stat"` for the compact look) | Sparkline is a line, not bars |
10
+ | Several small figures in a strip | `StatGroup` (`layout: "joined"` or `"cards"`) | One shared card vs separate tiles |
11
+ | Chart with a headline value | `ChartCard` + a chart (`ChartArea`, `ChartLine`, `ChartColumn`…) | Legend placement, comparison style |
12
+ | Bare chart | `ChartLine` / `ChartArea` / `ChartBar` / `ChartColumn` / `ChartDonut` / `ChartPie` / `ChartRadialBar` / `ChartHeatmap` / `ChartScatter` / `ChartRadar` / `ChartMixed` / `ChartRangeArea` / `ChartCandlestick` | Axis labels, tooltip look |
13
+ | Ranked list, leaderboard | `TopListCard` | Bar position, rank badge style |
14
+ | Date range picker | `PeriodSelector` (`variant: "segmented"` for pills) | Preset labels |
15
+ | Live / pause switch | `LiveToggle` | Pill vs segmented |
16
+ | Context bar of a page with a period or live data | `pageToolbar()` (a `PageToolbar` holding the `LiveToggle` and `PeriodSelector`) | Leading blocks, `size` |
17
+ | Table, list with actions | `TableView` over a DataController (`displays` for cards / kanban) | Column widths, row height (`density`) |
18
+ | Detail facts of a record | `KeyValueList` | Value alignment |
19
+ | Recent events, audit log | `ActivityFeed` | Day separators vs relative times |
20
+ | Usage bar, quota | `Meter` | Bar thickness (`size`) |
21
+ | Notice, alert strip | `Banner` | Wash vs flat background |
22
+ | Strip under the dashboard header, across pages | `RegisterLayoutBanner` (backend): the app's pages by default, `scope: "everywhere"` for a workspace-wide state | Not inside `/modules` unless scoped `everywhere` |
23
+ | Empty / first-run screen | `EmptyState` (or `Guard` around blocks) | Illustration vs icon well |
24
+ | Links to sub-pages as cards | `NavCardGrid` | Card height |
25
+ | Code snippet | `CodeBlock` | Theme of the highlighting |
26
+ | Panel with a title and actions | `Card` | Head layout |
27
+ | Settings card with rows | `Section` + `FieldRow` | Label column width (`layout`) |
28
+ | Form, settings form | `Form` / `ResourceForm` | Field layout (`fieldsOrientation`, sections) |
29
+ | Tabs | `Tab` (`variant: "pill" \| "link"`) | Tab style |
30
+ | Columns / rows of panels | `Grid` + `GridRow`, `HStack` / `VStack` / `Spacer` | Exact gutters |
31
+
32
+ Nothing matches — a canvas, a map, a bespoke visualization — → a custom block, under the rules of SKILL.md.
33
+
34
+ ## `preview_blocks`
35
+
36
+ `preview_blocks({ title, description?, label?, tree?, sketch?, reference?, variants?: [{ label, tree?, sketch? }] })` — non-blocking; it renders the real blocks next to the reference image (in the dms-assistant chat, as an attachment card the user opens; elsewhere, show the user what the tool answers), one tab for the main view (named by `label`, default "Proposed") and one per variant. Every view needs a `tree`, a `sketch` or both (both are drawn side by side). `reference` is `{ attachmentId?, url?, caption? }`: `attachmentId` is the file name of an image the user attached in the dms-assistant chat, or `"latest"`; `url` is a same-origin path. `tree` is one `PreviewNode` or a list: `{ type, options?, children? }`, children also taking `id`, `slot` and `colSpan`. Use `static*` options (`staticValue`, `staticDataset`, `staticItems`, `items`) so the preview shows data without a route; URL options must be relative paths. `TableView` and `ResourceForm` need a backend class and render as a notice — describe them in the question instead.
37
+
38
+ A variant holds a `tree` (the DMS block with other options), a `sketch` (`{ html, css?, caption?, height? }`: static HTML and CSS standing for the custom block you would build, `height` in px from 80 to 1200, default 320), or both, so the user compares it with the DMS option before any Vue exists. Keep a sketch to the element alone: static markup with no script, event handler, `@import` or external URL (the tool refuses them with `invalid_sketch`), images as `data:` URLs, and the `--sketch-*` theme variables the tool describes for colors, so it follows light and dark mode.
39
+
40
+ ```ts
41
+ preview_blocks({
42
+ title: "Revenue tile",
43
+ description: "Your tile as a DMS KPI card, adjusted, and as a custom block",
44
+ label: "DMS KpiCard",
45
+ tree: {
46
+ type: "KpiCard",
47
+ options: {
48
+ title: "Revenue",
49
+ valueFormat: "currency",
50
+ currencyCode: "EUR",
51
+ staticValue: 48200,
52
+ staticDelta: 12.4,
53
+ showDelta: true,
54
+ showSparkline: true,
55
+ staticSparkline: [31, 34, 33, 38, 41, 39, 44, 48],
56
+ },
57
+ },
58
+ reference: { attachmentId: "latest", caption: "Your design" },
59
+ variants: [
60
+ {
61
+ label: "DMS, compact",
62
+ tree: {
63
+ type: "KpiCard",
64
+ options: { title: "Revenue", variant: "stat", staticValue: 48200 },
65
+ },
66
+ },
67
+ {
68
+ label: "Custom sketch",
69
+ sketch: {
70
+ html: "<div class='tile'><span>Revenue</span><strong>€48,200</strong><div class='bars'><i style='height:40%'></i><i style='height:70%'></i><i style='height:100%'></i></div></div>",
71
+ css: ".tile{padding:16px;border:1px solid;border-radius:8px}.bars{display:flex;gap:4px;height:32px;align-items:end}.bars i{width:8px;background:currentColor}",
72
+ caption: "Bars under the figure, as in your design",
73
+ },
74
+ },
75
+ ],
76
+ });
77
+ // then, with the asking tool (ask_user in the dms-assistant chat)
78
+ ask_user({
79
+ questions: [
80
+ {
81
+ header: "Revenue tile",
82
+ question: "Keep the DMS KPI card, adjust it, or build a custom block?",
83
+ options: [
84
+ {
85
+ label: "Keep the DMS block",
86
+ description:
87
+ "KpiCard as previewed; themed, permissioned, editable in the builder",
88
+ },
89
+ {
90
+ label: "Adjust it through its options",
91
+ description:
92
+ "Same block, e.g. the compact variant; tell me what to change",
93
+ },
94
+ {
95
+ label: "Build a custom block",
96
+ description:
97
+ "A Vue component matching the sketch, declared with .meta(); the rest stays blocks",
98
+ },
99
+ ],
100
+ },
101
+ ],
102
+ });
103
+ ```
104
+
105
+ ## Safe mode: a custom block is out of reach
106
+
107
+ The builder tools cannot write Vue. Show the closest composition with `preview_blocks` (the text table when it is missing), then:
108
+
109
+ ```ts
110
+ ask_user({
111
+ questions: [
112
+ {
113
+ header: "Seat map",
114
+ question:
115
+ "Safe mode cannot build a custom block. Use the closest DMS composition, or turn Safe mode off for this block only?",
116
+ options: [
117
+ {
118
+ label: "Use the DMS composition",
119
+ description: "A Grid of KpiCard per zone, as previewed",
120
+ },
121
+ {
122
+ label: "Turn Safe mode off for this block",
123
+ description:
124
+ "Only the seat map becomes custom, with .meta(); then Safe mode again",
125
+ },
126
+ ],
127
+ },
128
+ ],
129
+ });
130
+ ```
131
+
132
+ ## Text fallback (no `preview_blocks`)
133
+
134
+ One table per batch of components, then one closed question per row:
135
+
136
+ | Your design | DMS block | Visible difference |
137
+ | --------------------------------------------- | ---------------------------------- | --------------------------------- |
138
+ | Revenue tile with bars under the figure | `KpiCard` with a sparkline | A line instead of bars |
139
+ | Orders table with avatars in the first column | `TableView` with `IdentityDisplay` | None beyond spacing — no question |
140
+
141
+ > Revenue tile: keep the DMS block, adjust it through its options, or build a custom block?
142
+
143
+ When the custom option is hard to picture, add its sketch as a short markup snippet under the table (a few lines of HTML, no styling detail). Leave rows whose only difference is theme-level (colors, spacing, fonts) out of the questions.
@@ -0,0 +1,86 @@
1
+ ---
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.
4
+ ---
5
+
6
+ # DMS best practices
7
+
8
+ Three rules hold for every page, a path runs before any custom block, and a protocol runs whenever a design is involved. They keep each part of a screen a permission of its own, editable by the builder, and driven by the theme. **dms-pages** has the code APIs and **dms-builder-mcp** the builder tools; this skill decides what to build.
9
+
10
+ Three facts about the project change the steps below. **dms-builder-mcp** _Detect what the project has_ tells how to settle them:
11
+
12
+ - **The builder MCP** answers (`builder_catalog` is among your tools), or not. **The preview** is a tool of its own: `preview_blocks` is among your tools, or not (an older DMS serves it to the dms-assistant chat only).
13
+ - **Safe mode** is on (the builder tools are the only way to write), or not.
14
+ - **The asking tool**: `ask_user` in the dms-assistant chat, your harness's question tool elsewhere, else one closed question in chat.
15
+
16
+ ## The rules
17
+
18
+ 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.
20
+ 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
+
22
+ ```ts
23
+ // Good: blocks around the one custom block, which carries its metadata
24
+ static period = PeriodSelector({ id: "api" });
25
+ static kpis = Grid().child("row", GridRow()
26
+ .child("calls", KpiCard({ title: "$api.routes.calls", fetchUrl: "/api/routes/calls", periodScope: "api" })));
27
+ static graph = CustomComponent("ApiRouteGraph")
28
+ .options({ fetchUrl: "/api/routes/graph", periodScope: "api" })
29
+ .meta({ name: "$api.routes.graph.name", description: "$api.routes.graph.description", icon: "i-ph-graph" });
30
+
31
+ // Bad: one component draws the period picker, the KPIs and the graph; no .meta()
32
+ static screen = CustomComponent("ApiRoutesScreen");
33
+ ```
34
+
35
+ `CustomComponent` comes from `@antelopejs/interface-dms/base/custom` (not the `base` barrel); `.meta()` takes `Partial<ComponentMetadata>` (`name`, `description?`, `icon?`). Every DMS factory sets its own metadata; a custom block is the one place you must.
36
+
37
+ ## When to leave DMS blocks
38
+
39
+ A custom block is a deviation, and you **propose** it: the user decides, after the path below. It is worth proposing only when one of these holds:
40
+
41
+ | Leave DMS blocks when | Stay on DMS blocks when |
42
+ | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
43
+ | No block covers the need, even through its options or a composition of blocks | The difference is spacing, color, radius, font or a minor layout the theme or the block's options handle |
44
+ | The interaction model differs: a drag-and-drop canvas, real-time collaborative editing | The DMS block only "looks slightly different" from the mockup |
45
+ | 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
+ | A measured constraint (performance, data volume) the block cannot meet | The constraint is a guess, not a measurement |
47
+
48
+ ## Before any custom block
49
+
50
+ Run this path before writing a `CustomComponent` or its Vue, one element at a time:
51
+
52
+ 1. **Search the catalog.** With the builder MCP, `builder_catalog`; otherwise the block catalog of the running DMS (`GET /api/block-preview/types`), else `ListBlockTypes()` from `@antelopejs/interface-dms/base/block-types` or the exports of `@antelopejs/interface-dms/base`. Try the block's options first, then a composition of blocks (`Card` + `KeyValueList`, `ChartCard` + a chart, `Grid` of `KpiCard`).
53
+ 2. **Show the comparison.** When `preview_blocks` is among your tools, call it with the closest DMS option as `tree`, the user's design as `reference`, and a **sketch variant** of the custom block, then show the user what it answers. Without it, write the text table of [REFERENCE.md](REFERENCE.md). When the page belongs to a mockup, the sketch goes in the spec instead (**dms-mockup**).
54
+ 3. **Ask.** One closed question with the asking tool, three options: _Keep the DMS block_ / _Adjust it through its options_ / _Build a custom block_.
55
+ 4. **Build.** On _Adjust_, change the block's options and preview again. Only on _Build a custom block_, build that block alone, under the rules above, with `.meta()`; the rest of the page stays blocks.
56
+
57
+ In **Safe mode** step 4 is out of reach, since the builder tools cannot write Vue: say so, offer the closest DMS composition, and ask whether to turn Safe mode off for that one block.
58
+
59
+ The path is done when the user has answered for the element. [REFERENCE.md](REFERENCE.md) has worked calls and the fallback table.
60
+
61
+ ## Design-fidelity protocol
62
+
63
+ Run it whenever the user hands you a design, mockup or screenshot. When the user wants to iterate on the design before any page exists, run **dms-mockup** instead: it applies this protocol inside the spec.
64
+
65
+ 1. **Frame once.** Before building, ask **one** question with the asking tool:
66
+ - _Pixel perfect_: reproduce the design, custom blocks allowed where nothing matches;
67
+ - _DMS equivalents_: map every component to its closest DMS block silently; an element no block or composition covers still goes through the path;
68
+ - _Component by component_ (**recommended**): decide each visible difference together.
69
+ 2. **Map** every component of the design to its closest DMS block ([REFERENCE.md](REFERENCE.md) has the mapping table). Differences the right-hand column of the table above lists never trigger a question.
70
+ 3. **Decide.** _Component by component_: run [the path](#before-any-custom-block) for each visible difference (layout, a missing element, another chart kind), batching several components in one preview and one question. _Pixel perfect_ answers step 3 of the path for every element, so skip that question but still run step 1: only the parts no block or composition matches become custom.
71
+ 4. **Build** under the rules above.
72
+
73
+ The protocol is done when every visibly different component has an answer and every custom block in the page carries `.meta()`.
74
+
75
+ ## Checklist before handing back
76
+
77
+ A `docs/<path>` link is `https://dms.antelopejs.com/docs/<path>`.
78
+
79
+ - Every page field and child is a DMS block, except custom blocks the user chose through the path.
80
+ - Every `CustomComponent` has `.meta({ name, description, icon })` with `$` keys present in every locale file.
81
+ - Every automation node a module registers names itself, its description and each schema property's `title` and `description` with `$` keys present in every locale file (`docs/building/backend-services`, Texts in the builder).
82
+ - An automation action with side effects (email, notification, write) declares `dryRun(input, ctx)`: it checks the input as `execute` would and acts on nothing, so a builder Test run sends nothing (`docs/building/backend-services`, Test runs).
83
+ - Locale values escape vue-i18n's special characters as literals (`{'@'}`, `{'{'}`, `{'}'}`, `{'|'}`): a raw `@` or brace breaks the message's compilation (`docs/building/localization`, Special characters).
84
+ - Data comes from routes (`fetchUrl`) rather than options computed at registration; a custom block reads its route with `useApiData` (server-rendered, refreshed with the page) and writes with `$authFetch`.
85
+ - Publish tenant data with the tenant id: a `PublishMessage` about one workspace's data passes `{ tenantId }`, or it wakes the page of every workspace.
86
+ - Verified live, as **dms-builder-mcp** _Verify_ says, or in the browser without the MCP (**dms-project**). The build typechecks `src/` only.
@@ -0,0 +1,116 @@
1
+ # dms-builder-mcp reference
2
+
3
+ ## Data resources (Table + DataAPI)
4
+
5
+ A **resource** is the data layer a table/form displays: a Database `Table`+`Model`
6
+ and a matching `DataAPI` controller at `/api/<name>`, generated as decorator classes
7
+ kept in sync — never hand-write them. The resource ops (and the `controller` binding
8
+ they feed) require a builder engine version that implements them: if one returns
9
+ `request_failed` (the host answered `unknown_op`) or `builder_unavailable`, the
10
+ installed engine doesn't support it — explain the limitation instead of retrying.
11
+
12
+ 1. **Read first.** `builder_list_resources`; `builder_resource_structure <ref>` for
13
+ fields + `version` hash. Hand-edited or relation fields come back `opaque` —
14
+ the builder tools cannot reconfigure those.
15
+ 2. **Create** with `builder_create_resource` (`name`, `fields`, optional `seeds` — each
16
+ seed row supplies its own `_id`; never declare `_id`, it is auto-managed). It
17
+ scaffolds a `<name>/{database,data-api,index}.ts` folder and wires the nearest barrel.
18
+ - `location` — where the folder goes (omit for `src/<name>/`): a dir string
19
+ relative to the src root, `{ category: <CategoryRef> }` (mirrors that category's
20
+ page placement; prefer for a resource shared by one section), or
21
+ `{ page: <PageRef> }` (nests beside that page; prefer for a one-page resource).
22
+ Pass exact refs from `builder_list_pages`, never guess.
23
+ - `routes` — which DataAPI endpoints to expose (omit for the full set): `list`,
24
+ `get`, `create`, `edit`, `delete`, `select` (relation-picker options), `archive`
25
+ (soft delete + undo), `export`. Pass a subset whenever a resource is not a full
26
+ CRUD table — a singleton edit form wants `["get","edit"]`, a read-only listing
27
+ `["list","get"]` — and keep the view in sync: drop the `TableView` `rowActions`
28
+ whose routes you left out, or bind a `Form` instead for a singleton.
29
+ 3. **Edit fields** with `builder_add_field` / `builder_configure_field <ref>#<field>` /
30
+ `builder_remove_field`; field name is immutable (rename = remove + add). **Delete**
31
+ with `builder_delete_resource` (refused in Safe mode): removes the files, unwires the barrel, and by default
32
+ clears the resource's database table so a name reuse re-seeds cleanly rather than
33
+ showing stale rows (`keepData: true` to keep them).
34
+ 4. **Fields are semantic aspects, not decorators:** `dataType`, `label`, `listable`
35
+ (default true), `searchable`, `sortable`, `filterable`, `access`
36
+ (`read`|`readwrite`, default `readwrite`), `required`, `indexed`, `order`. Names
37
+ colliding with a DataController route or model property (`_id`, `model`, `get`,
38
+ `list`, `select`, `count`, `new`, `edit`, `delete`, `archive`, `restore`,
39
+ `exportStart`, `exportStatus`, `exportDownload`) are rejected with `invalid_config`.
40
+
41
+ **Displaying a resource on a page is a builder step**: create and populate the
42
+ resource, then `builder_add_block` a `TableView` with `controller` = the resource `ref`
43
+ and display options in `config`. Relation columns work via `$ref` (see
44
+ "DataType, component and reference values" in SKILL.md).
45
+
46
+ ## Queries (computed data a DataAPI can't serve)
47
+
48
+ A **query** is a derived-data endpoint on a _page_: a GET route serving an aggregate or one
49
+ point per group, backed by a generated method on the resource's model. The DataAPI serves
50
+ rows; a query serves what a KPI card, a chart or a ranked list reads.
51
+
52
+ 1. **Read the templates.** `builder_query_templates` returns each template's `id`, what it
53
+ computes, its `output` kind, and its `params` schema. Never guess an id or a param key —
54
+ an unrecognised key is rejected.
55
+ 2. **Add the query** with `builder_add_query` on the page that will display it (not the
56
+ resource's page). It compiles the template into a model method and a page route in one
57
+ atomic op and returns `{ query, route }`.
58
+ 3. **Wire the block to it.** `route` is the full URL — pass it as the card's `fetchUrl`.
59
+ There is no reference sentinel for queries yet, so wire the returned string; if you later
60
+ move the endpoint, update the card in the same turn.
61
+ 4. **Read back** with `builder_page_structure` — a page's `queries` array reports each one's
62
+ `name`, `endpoint`, `resource`, `modelMethod`, `template` and `params`.
63
+ 5. **Reconfigure / remove** with `builder_configure_query` (only the keys you patch change)
64
+ and `builder_remove_query` (drops the route, and the model method once nothing calls it).
65
+
66
+ **Params** are documented by each template's own `params` schema from
67
+ `builder_query_templates` — every key, every value shape, down to the enums. Read it rather
68
+ than guessing; an unrecognised key is rejected.
69
+
70
+ The one idea worth stating here, because it is what makes a query reusable: a filter value
71
+ can be **bound to a request parameter** instead of baked into the chain
72
+ (`{ "$param": { "name": "min" } }`), so one query answers `?min=25` and `?min=100`
73
+ rather than needing a query per threshold. Bake the value in when it is part of what the
74
+ query _means_ (in-stock rows), bind it when the caller chooses (a price threshold). The
75
+ `name`/`in` you give a `$param` shape the route, not the model: the route reads the value
76
+ from that source and hands it to the model method, whose own parameter is named for you.
77
+
78
+ ```json
79
+ {
80
+ "page": "/catalog/books",
81
+ "name": "inStockValue",
82
+ "resource": "book",
83
+ "template": "aggregate",
84
+ "params": {
85
+ "op": "sum",
86
+ "field": "price",
87
+ "where": [{ "field": "inStock", "op": "eq", "value": true }]
88
+ }
89
+ }
90
+ ```
91
+
92
+ → `{ "query": "/catalog/books@inStockValue", "route": "/catalog/books/stats/in-stock-value" }`,
93
+ serving `{ "value": 110.48 }`.
94
+
95
+ **What you don't have to manage.** The route is auth-gated by the page, automatically —
96
+ a query is never public. Queries wanting the identical chain share one model method, and a
97
+ query whose chain diverges from a method others still use gets its own rather than editing
98
+ theirs — which is why a `modelMethod` may not match its query's name (`inStockCount2`). All
99
+ of that is handled for you: reconfiguring or removing one query never changes what another
100
+ page's query returns.
101
+
102
+ **Endpoints are a default, not a namespace.** `/stats/<kebab-name>` unless you pass
103
+ `endpoint`; any path is fine as long as it starts with `/` and the page doesn't already
104
+ serve it. One coupling: a `$param` with `in: "param"` reads a path segment, so its
105
+ `endpoint` must declare a matching `:name` (`in: "query"`, the default, needs nothing).
106
+
107
+ **Opaque queries.** Read-back is purely structural: the builder recognizes a query by its
108
+ shape, so anything it can parse it can edit. A query is opaque **only when it no longer
109
+ parses** — not merely because a human touched it. An in-grammar edit (a changed threshold, an
110
+ added filter) is simply re-read and stays editable. `opaqueReason` is `unparseable_route` (the
111
+ GET wrapper isn't the `return { value: await model.m(...) }` shape) or `unparseable_chain` (the
112
+ model method isn't a chain any template accepts — hand-written differently, edited out of the
113
+ grammar, or emitted by a newer builder). `builder_configure_query` refuses an opaque query with
114
+ `opaque_target`, but it stays visible and `builder_remove_query` still works: the builder can
115
+ always remove what it cannot edit. To reshape an opaque query, edit its code with dms-pages (outside Safe mode), then `builder_refresh` to clear the builder's caches — or bring
116
+ its body back within the chain grammar and the builder picks it up again.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: dms-builder-mcp
3
+ description: Drives the AntelopeJS DMS builder MCP tools (builder_catalog, builder_add_block, builder_compose_page, …), whose typechecked operations change a project's pages, and detects whether the project has them. Use when adding, configuring, moving or removing DMS blocks, pages or categories through the builder, changing the dashboard's brand colours, logo or theme, when Safe mode is on, or when a builder tool answers an error.
4
+ ---
5
+
6
+ # Building DMS pages through the builder MCP
7
+
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
+
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.
11
+
12
+ ## Detect what the project has
13
+
14
+ Settle these three before the first edit. They decide every later branch.
15
+
16
+ 1. **The builder MCP.** Look for `builder_catalog` among your tools. Claude Code prefixes MCP tools with their server (`mcp__dms__builder_catalog`); the bare name is what counts. When it is missing:
17
+ - The project's `.mcp.json` names a `dms` server, but the tools are absent: the DMS writes that entry under `ajs project dev`, and the tools answer only while it runs. Ask the user to start `ajs project dev`, then to reload the MCP servers (`/mcp` in Claude Code).
18
+ - Codex reads its MCP servers from its `config.toml`, never from `.mcp.json`: the user declares `[mcp_servers.dms]` there, with the absolute path of the project's `node_modules/.cache/dms/mcp-bridge.cjs`, as https://dms.antelopejs.com/docs/ai-and-claude-code/mcp-server shows, then restarts Codex.
19
+ - No such entry, or the user wants to go on without the dev server: **code path**. Edit the TypeScript yourself with **dms-pages**, then verify as _Verify_ below says.
20
+ 2. **Safe mode.** It is `mcp.access: "safe"` in the dms config; the default, `"full"`, is what a plain harness gets, and the dms-assistant chat runs safe. In Safe mode the DMS MCP refuses its project tools (`builder_configure_project`, `builder_delete_resource`). The server cannot stop your harness from editing files, so the rule is yours to hold: write only through the builder tools, never by a file edit. A step they cannot do (_Errors_ below) goes to the user.
21
+ 3. **The asking tool.** In the dms-assistant chat, `ask_user` asks the user a closed question. Elsewhere, use your harness's own question tool (`AskUserQuestion` in Claude Code), or ask one closed question in chat.
22
+
23
+ ## Addressing
24
+
25
+ - **PageRef** = the page's route, e.g. `/charts/revenue`.
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.
28
+ - **ResourceRef** = a data resource's id, its `/api/<name>` route segment. **FieldPath** = `<resourceRef>#<fieldName>`. Take refs from `builder_list_resources`.
29
+ - **QueryRef** = `<pageRef>@<queryName>`, e.g. `/catalog/books@inStockCount`. Take refs from `builder_page_structure`'s `queries`.
30
+
31
+ ## DataType, component and reference values
32
+
33
+ - A config field the catalog marks `x-dataType` (a Form field's `type`, a TableView column `type`, a resource field's `dataType`) takes a **DataType value** `{ $dataType: "<id>", config: {…} }`, an id from `builder_catalog`'s `dataTypes`. Pass no raw `$expr`: Safe mode refuses it.
34
+ - A config field marked `x-component` holds a nested block (a ChartCard's `chart`): pass `{ $block: { type: "<type>", config: {…} } }` with a `type` from `builder_catalog`.
35
+ - A builder-generated resource class named inside config (a relation column's `dataApiController`) takes a **reference value** `{ $ref: { resource: "<ref>", as?: "dataApi" | "table" | "model" } }` (default `dataApi`). The resource must exist. `$ref` is validated and allowed in Safe mode.
36
+
37
+ ## Workflow
38
+
39
+ 1. **Catalog first.** `builder_catalog` with no arguments returns every valid block `type` with its `container` / `controllerArg` flags, every DataType id and `reservedFieldNames`. Use only the types it lists. Then call it with `blocks: ["TableView", …]` and `dataTypes: ["select", …]` for the full schema of the entries you will use.
40
+ 2. **Read before you write.** `builder_list_pages` finds a page or category; `builder_page_structure <pageRef>` gives the block tree, `editable` flags and the `version` hash. Model new blocks on an existing page.
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
+ 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
+ 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.
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
+
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.
48
+
49
+ ## Data resources and queries
50
+
51
+ A **resource** is the data a table or form shows: a `Table` + `Model` and a `DataAPI` controller at `/api/<name>`, generated as decorator classes kept in sync. Create it with the builder, then `builder_add_block` a `TableView` with `controller` = the resource `ref`.
52
+
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
+
55
+ [REFERENCE.md](REFERENCE.md) has the resource and query workflows, field rules, `$param` binding and opaque queries.
56
+
57
+ ## Theme and branding
58
+
59
+ Brand colours, logos and the other design tokens belong to the theme, never to a page's blocks. `builder_get_theme` reads it; `builder_set_theme` changes it; `builder_create_theme_layer` first makes the frontend layer that holds it when the project has none. All three work in Safe mode. Read the theme before you set it, and change only what the user asked.
60
+
61
+ On the code path, edit the theme yourself in the `app/app.config.ts` of the project's frontend layer: `branding.logo` for the logos (files in the layer's `public/`), `ui.colors` for the palette (`primary: "violet"`, or a brand palette declared in a stylesheet of the layer), as https://dms.antelopejs.com/docs/extending-the-dashboard/theming-and-branding says.
62
+
63
+ ## Errors
64
+
65
+ - `typecheck_failed`: read `diagnostics`, fix the `config` or `type`, retry. Nothing was written.
66
+ - `invalid_config`, `duplicate_name`, `not_found`: fix the input.
67
+ - `stale`: the page changed under you; read it again with `builder_page_structure` and retry.
68
+ - `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
+ - `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.
70
+
71
+ ## Guardrails
72
+
73
+ - Read the full schema of each block type before you add one; use only its listed config keys. Read `builder_query_templates` before adding a query.
74
+ - Every block and child has a name, unique among its siblings.
75
+ - A card showing an aggregate reads a query, never a DataAPI route.