cortena-ui 1.3.0 → 1.4.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.
- package/README.md +74 -3
- package/dist/a2ui/catalogue-doc.d.ts +44 -0
- package/dist/a2ui/catalogue-doc.js +169 -0
- package/dist/a2ui/catalogue-doc.js.map +1 -0
- package/dist/a2ui/catalogue.d.ts +44 -0
- package/dist/a2ui/catalogue.js +942 -0
- package/dist/a2ui/catalogue.js.map +1 -0
- package/dist/a2ui/index.d.ts +7 -0
- package/dist/a2ui/message.d.ts +232 -0
- package/dist/a2ui/message.js +365 -0
- package/dist/a2ui/message.js.map +1 -0
- package/dist/a2ui/renderer.d.ts +46 -0
- package/dist/a2ui/renderer.js +252 -0
- package/dist/a2ui/renderer.js.map +1 -0
- package/dist/a2ui/views.d.ts +80 -0
- package/dist/a2ui/views.js +596 -0
- package/dist/a2ui/views.js.map +1 -0
- package/dist/a2ui.d.ts +8 -0
- package/dist/a2ui.js +7 -0
- package/dist/chart.d.ts +9 -0
- package/dist/chart.js +9 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +63 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +15 -0
- package/dist/components/alert.js +64 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.d.ts +18 -0
- package/dist/components/avatar.js +40 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +47 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +71 -0
- package/dist/components/breadcrumb.js +123 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-link.d.ts +28 -0
- package/dist/components/button-link.js +24 -0
- package/dist/components/button-link.js.map +1 -0
- package/dist/components/button.d.ts +24 -0
- package/dist/components/button.js +65 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +28 -0
- package/dist/components/calendar.js +123 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +32 -0
- package/dist/components/card.js +57 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart/chart.d.ts +71 -0
- package/dist/components/chart/chart.js +167 -0
- package/dist/components/chart/chart.js.map +1 -0
- package/dist/components/chart/container.d.ts +88 -0
- package/dist/components/chart/container.js +189 -0
- package/dist/components/chart/container.js.map +1 -0
- package/dist/components/chart/data.js +128 -0
- package/dist/components/chart/data.js.map +1 -0
- package/dist/components/chart/index.d.ts +9 -0
- package/dist/components/chart/index.js +10 -0
- package/dist/components/chart/nivo-charts.js +225 -0
- package/dist/components/chart/nivo-charts.js.map +1 -0
- package/dist/components/chart/nivo-lazy.js +50 -0
- package/dist/components/chart/nivo-lazy.js.map +1 -0
- package/dist/components/chart/nivo-theme.d.ts +156 -0
- package/dist/components/chart/nivo-theme.js +161 -0
- package/dist/components/chart/nivo-theme.js.map +1 -0
- package/dist/components/chart/recharts-charts.js +276 -0
- package/dist/components/chart/recharts-charts.js.map +1 -0
- package/dist/components/chart/recharts-lazy.js +58 -0
- package/dist/components/chart/recharts-lazy.js.map +1 -0
- package/dist/components/chart/recharts-parts.d.ts +10 -0
- package/dist/components/chart/recharts-parts.js +25 -0
- package/dist/components/chart/recharts-parts.js.map +1 -0
- package/dist/components/chart/tokens.d.ts +62 -0
- package/dist/components/chart/tokens.js +192 -0
- package/dist/components/chart/tokens.js.map +1 -0
- package/dist/components/chart/types.d.ts +114 -0
- package/dist/components/chart/types.js +27 -0
- package/dist/components/chart/types.js.map +1 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js +24 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +17 -0
- package/dist/components/chip.js +47 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/combobox.d.ts +76 -0
- package/dist/components/combobox.js +201 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +50 -0
- package/dist/components/command.js +117 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/data-table/data-table.d.ts +65 -0
- package/dist/components/data-table/data-table.js +588 -0
- package/dist/components/data-table/data-table.js.map +1 -0
- package/dist/components/data-table/export.d.ts +23 -0
- package/dist/components/data-table/export.js +95 -0
- package/dist/components/data-table/export.js.map +1 -0
- package/dist/components/data-table/features.d.ts +66 -0
- package/dist/components/data-table/features.js +103 -0
- package/dist/components/data-table/features.js.map +1 -0
- package/dist/components/data-table/index.d.ts +8 -0
- package/dist/components/data-table/parts.d.ts +79 -0
- package/dist/components/data-table/parts.js +400 -0
- package/dist/components/data-table/parts.js.map +1 -0
- package/dist/components/data-table/system-columns.js +84 -0
- package/dist/components/data-table/system-columns.js.map +1 -0
- package/dist/components/data-table/types.d.ts +172 -0
- package/dist/components/data-table/use-data-table.d.ts +19 -0
- package/dist/components/data-table/use-data-table.js +171 -0
- package/dist/components/data-table/use-data-table.js.map +1 -0
- package/dist/components/data-table/use-server-source.js +200 -0
- package/dist/components/data-table/use-server-source.js.map +1 -0
- package/dist/components/date-field.d.ts +54 -0
- package/dist/components/date-field.js +235 -0
- package/dist/components/date-field.js.map +1 -0
- package/dist/components/date-picker.d.ts +42 -0
- package/dist/components/date-picker.js +125 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +36 -0
- package/dist/components/dialog.js +97 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +54 -0
- package/dist/components/dropdown-menu.js +191 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/dropzone.d.ts +48 -0
- package/dist/components/dropzone.js +185 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.d.ts +22 -0
- package/dist/components/empty-state.js +46 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/error-banner.d.ts +17 -0
- package/dist/components/error-banner.js +52 -0
- package/dist/components/error-banner.js.map +1 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.js +133 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/components/form.js +103 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +26 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/kbd.d.ts +11 -0
- package/dist/components/kbd.js +20 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +14 -0
- package/dist/components/label.js +28 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-skeleton.d.ts +22 -0
- package/dist/components/loading-skeleton.js +123 -0
- package/dist/components/loading-skeleton.js.map +1 -0
- package/dist/components/markdown.d.ts +44 -0
- package/dist/components/markdown.js +231 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page-header.d.ts +26 -0
- package/dist/components/page-header.js +53 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/popover.d.ts +29 -0
- package/dist/components/popover.js +74 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +22 -0
- package/dist/components/progress.js +49 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +20 -0
- package/dist/components/radio-group.js +29 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/scroll-area.d.ts +25 -0
- package/dist/components/scroll-area.js +39 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/section-card.d.ts +29 -0
- package/dist/components/section-card.js +55 -0
- package/dist/components/section-card.js.map +1 -0
- package/dist/components/segmented.d.ts +27 -0
- package/dist/components/segmented.js +32 -0
- package/dist/components/segmented.js.map +1 -0
- package/dist/components/select.d.ts +62 -0
- package/dist/components/select.js +97 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +19 -0
- package/dist/components/separator.js +23 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +35 -0
- package/dist/components/sheet.js +131 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.d.ts +12 -0
- package/dist/components/skeleton.js +22 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/sortable-list.d.ts +67 -0
- package/dist/components/sortable-list.js +206 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/spinner.d.ts +29 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/status-dot.d.ts +26 -0
- package/dist/components/status-dot.js +47 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/switch.d.ts +21 -0
- package/dist/components/switch.js +21 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +24 -0
- package/dist/components/tabs.js +60 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +19 -0
- package/dist/components/textarea.js +47 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +47 -0
- package/dist/components/toast.js +106 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toolbar.d.ts +19 -0
- package/dist/components/toolbar.js +45 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/components/tooltip.d.ts +28 -0
- package/dist/components/tooltip.js +59 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/core.d.ts +44 -0
- package/dist/core.js +44 -0
- package/dist/data-table.d.ts +9 -0
- package/dist/data-table.js +7 -0
- package/dist/form.d.ts +7 -0
- package/dist/form.js +7 -0
- package/dist/hooks/use-cortena-theme.d.ts +98 -0
- package/dist/hooks/use-cortena-theme.js +145 -0
- package/dist/hooks/use-cortena-theme.js.map +1 -0
- package/dist/index.d.ts +75 -2678
- package/dist/index.js +66 -8598
- package/dist/lib/cn.d.ts +10 -0
- package/dist/lib/cn.js +15 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/render.d.ts +23 -0
- package/dist/lib/render.js +20 -0
- package/dist/lib/render.js.map +1 -0
- package/dist/lib/shakeable.js +39 -0
- package/dist/lib/shakeable.js.map +1 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +3 -0
- package/dist/sortable-list.d.ts +3 -0
- package/dist/sortable-list.js +3 -0
- package/package.json +37 -14
- package/src/a2ui/catalogue.ts +140 -103
- package/src/a2ui/views.tsx +5 -2
- package/src/components/alert.tsx +1 -1
- package/src/components/badge.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/chart/chart.tsx +72 -25
- package/src/components/chart/container.tsx +24 -39
- package/src/components/chart/index.tsx +4 -2
- package/src/components/chart/nivo-charts.tsx +41 -13
- package/src/components/chart/nivo-lazy.tsx +52 -0
- package/src/components/chart/recharts-charts.tsx +98 -3
- package/src/components/chart/recharts-lazy.tsx +72 -0
- package/src/components/chart/recharts-parts.tsx +34 -0
- package/src/components/chart/tokens.ts +1 -1
- package/src/components/chart/types.ts +14 -0
- package/src/components/chip.tsx +1 -1
- package/src/components/combobox.tsx +2 -2
- package/src/components/data-table/export.ts +18 -2
- package/src/components/data-table/features.ts +77 -45
- package/src/components/data-table/parts.tsx +15 -0
- package/src/components/data-table/use-data-table.ts +7 -2
- package/src/components/data-table/use-server-source.ts +17 -4
- package/src/components/date-field.tsx +1 -1
- package/src/components/error-banner.tsx +1 -1
- package/src/components/field.tsx +2 -2
- package/src/components/form.tsx +2 -2
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/markdown.tsx +5 -4
- package/src/components/sheet.tsx +2 -2
- package/src/components/sortable-list.tsx +2 -2
- package/src/components/textarea.tsx +1 -1
- package/src/components/toast.tsx +1 -1
- package/src/entries/a2ui.ts +11 -0
- package/src/entries/chart.ts +10 -0
- package/src/entries/core.ts +91 -0
- package/src/entries/data-table.ts +9 -0
- package/src/entries/form.ts +24 -0
- package/src/entries/markdown.ts +9 -0
- package/src/entries/sortable-list.ts +13 -0
- package/src/index.ts +32 -98
- package/src/lib/shakeable.ts +33 -0
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,6 +8,66 @@ with the tokens, from this repo's `packages/ui`.
|
|
|
8
8
|
Intent and decisions: `cortena-docs/cortenaUI&Design/02-ui-components.md`.
|
|
9
9
|
Consuming it: `../../CONSUMING.md`, section "cortena-ui".
|
|
10
10
|
|
|
11
|
+
## Entry points
|
|
12
|
+
|
|
13
|
+
The root barrel is the convenient path and exports everything:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Button, DataTable, Chart } from "cortena-ui";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
It tree-shakes. `"sideEffects": false` for JavaScript, no component module runs
|
|
20
|
+
anything at import time, and the build is unbundled — `dist` keeps `src`'s
|
|
21
|
+
module graph one-for-one rather than flattening it into chunks a bundler has to
|
|
22
|
+
unpick. An app importing only `Button` carries **37.7 kB** of cortena-ui and its
|
|
23
|
+
dependencies, React excluded; on 1.3.1 the same import carried 2,479 kB.
|
|
24
|
+
|
|
25
|
+
For a size-critical bundle — an MCP app inlined into a single HTML file, a
|
|
26
|
+
widget with a hard cap — import the area entry and do not depend on the
|
|
27
|
+
consumer's bundler getting tree-shaking right:
|
|
28
|
+
|
|
29
|
+
| entry | what it holds | what it costs |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| `cortena-ui/core` | primitives, overlays, light form controls, `cn`, `useCortenaTheme` | nothing heavy |
|
|
32
|
+
| `cortena-ui/form` | `Form`, `useForm`, `zodResolver`, date pickers, `Dropzone` | react-hook-form, zod, react-day-picker, react-dropzone |
|
|
33
|
+
| `cortena-ui/data-table` | `DataTable` and its parts | TanStack Table and Virtual; exceljs on the first export |
|
|
34
|
+
| `cortena-ui/chart` | `Chart`, themed Recharts primitives | an engine on the first chart drawn, not on import |
|
|
35
|
+
| `cortena-ui/markdown` | `Markdown` | react-markdown, remark-gfm, rehype-sanitize |
|
|
36
|
+
| `cortena-ui/a2ui` | the A2UI catalogue and renderer | most of the package, by design |
|
|
37
|
+
| `cortena-ui/sortable-list` | `SortableList`, `SortableHandle`, `arrayMove` | dnd-kit |
|
|
38
|
+
|
|
39
|
+
Each component has exactly one home, so the barrel re-exports every entry
|
|
40
|
+
without an ambiguous name. **Adding a component means adding it to its area
|
|
41
|
+
entry in `src/entries/`, not to `src/index.ts`.**
|
|
42
|
+
|
|
43
|
+
`SortableList` has its own entry for a specific reason rather than a stylistic
|
|
44
|
+
one: `@dnd-kit/core` and `@dnd-kit/sortable` declare no `"sideEffects"` in their
|
|
45
|
+
package.json, so a bundler must assume importing them does something observable
|
|
46
|
+
and keeps them whether or not anything is used. Every other dependency here
|
|
47
|
+
declares itself side-effect free and shakes out on its own.
|
|
48
|
+
|
|
49
|
+
Measured numbers, and how to re-measure them, are in `../../CONSUMING.md`,
|
|
50
|
+
"Bundle size". `pnpm bundle:probe` prints the table.
|
|
51
|
+
|
|
52
|
+
## Keeping it tree-shakeable
|
|
53
|
+
|
|
54
|
+
The whole thing turns on one property: **no module-level statement may do work
|
|
55
|
+
a bundler cannot skip.** It is easy to break by accident and produces no error
|
|
56
|
+
when broken — the app builds, renders and passes its tests at five times the
|
|
57
|
+
size — so two things guard it.
|
|
58
|
+
|
|
59
|
+
- `src/lib/shakeable.ts`, for a module-scope constant built by a call whose
|
|
60
|
+
*arguments* contain calls: `tableFeatures({ filteredRowModel: createFilteredRowModel() })`,
|
|
61
|
+
a `z.enum(...).describe(...)` chain, `Object.freeze` over a spread. A bundler
|
|
62
|
+
evaluates arguments even when the call around them is annotated pure, so the
|
|
63
|
+
work goes behind a thunk and the thunk call is annotated instead. Nothing is
|
|
64
|
+
deferred at runtime; only the bundler sees a difference.
|
|
65
|
+
- A bare `/* @__PURE__ */` where the arguments are literals: `cva(...)`,
|
|
66
|
+
`cn(...)`, `React.createContext(...)`.
|
|
67
|
+
|
|
68
|
+
`test/bundle-probe.test.mjs` builds real consumer apps and fails on a
|
|
69
|
+
regression; `test/chart-bundle.test.tsx` says which line caused it.
|
|
70
|
+
|
|
11
71
|
## Rules for components in this package
|
|
12
72
|
|
|
13
73
|
- **Every visual value is a token.** `pnpm lint:design` runs the same
|
|
@@ -115,7 +175,9 @@ from `@a2ui/*` is installed, so `vitest.config.ts` has no entry for it.
|
|
|
115
175
|
pnpm check # types
|
|
116
176
|
pnpm lint:design # no literals where a token exists; no dangling var()
|
|
117
177
|
pnpm build # dist/ via tsdown (ESM + d.ts); also runs on prepack
|
|
118
|
-
pnpm test #
|
|
178
|
+
pnpm test # the browser suite, then the bundle budgets
|
|
179
|
+
pnpm test:bundle # bundle budgets alone (builds first, then real Vite apps)
|
|
180
|
+
pnpm bundle:probe # the size table, printed, without asserting anything
|
|
119
181
|
pnpm guide # three-theme guide on a local Vite server
|
|
120
182
|
pnpm a2ui:catalogue # dist-a2ui/catalogue.json + .md from the A2UI catalogue
|
|
121
183
|
```
|
|
@@ -125,20 +187,29 @@ From the repo root the same are `pnpm ui:check`, `ui:build`, `ui:test`, `ui:guid
|
|
|
125
187
|
## Layout
|
|
126
188
|
|
|
127
189
|
```
|
|
128
|
-
src/index.ts
|
|
190
|
+
src/index.ts the barrel: a union of the area entries, nothing else
|
|
191
|
+
src/entries/*.ts the area entries behind the subpaths; a component's
|
|
192
|
+
export line goes in exactly one of them
|
|
129
193
|
src/components/*.tsx one file per component, shadcn shape, Base UI primitives
|
|
130
194
|
src/a2ui/ A2UI catalogue, React renderer and doc generator
|
|
131
195
|
src/lib/cn.ts clsx + tailwind-merge
|
|
196
|
+
src/lib/shakeable.ts the thunk that keeps module-scope work tree-shakeable
|
|
132
197
|
src/styles/index.css what consumers import after the tokens: animation
|
|
133
198
|
utilities and the Base UI data-attribute variants
|
|
199
|
+
scripts/bundle-probe.mjs builds a consumer app per entry and weighs it
|
|
134
200
|
test/ browser tests; setup.css is the consumer recipe verbatim
|
|
201
|
+
*.test.mjs are the Node-side bundle budgets
|
|
135
202
|
guide/ Vite app: ?theme=light|dark|system frames, or all three
|
|
136
203
|
```
|
|
137
204
|
|
|
138
205
|
## Releasing
|
|
139
206
|
|
|
140
207
|
```bash
|
|
141
|
-
pnpm ui:check && pnpm ui:test
|
|
208
|
+
pnpm ui:check && pnpm ui:test # browser suite, then the bundle budgets
|
|
142
209
|
cd packages/ui && npm version minor && npm publish # prepack builds dist/
|
|
143
210
|
git push --follow-tags
|
|
144
211
|
```
|
|
212
|
+
|
|
213
|
+
If the bundle numbers moved, re-run `pnpm bundle:probe` and update the table in
|
|
214
|
+
`../../CONSUMING.md`. A size regression is not a cosmetic detail here: the MCP
|
|
215
|
+
app documents travel inside a tool result and are capped at 512 kB.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { A2UIComponentSpec } from "./message.js";
|
|
3
|
+
import { A2UICatalogue, A2UIGroup } from "./catalogue.js";
|
|
4
|
+
//#region src/a2ui/catalogue-doc.d.ts
|
|
5
|
+
/** A JSON Schema object, as far as this module cares. */
|
|
6
|
+
export type JsonSchema = Record<string, unknown>;
|
|
7
|
+
export interface A2UIComponentDoc {
|
|
8
|
+
name: string;
|
|
9
|
+
group: A2UIGroup;
|
|
10
|
+
summary: string;
|
|
11
|
+
/** Whether the component takes a `children` list. */
|
|
12
|
+
children: "none" | "many";
|
|
13
|
+
/** Event names the component raises through `onAction`. */
|
|
14
|
+
events: string[];
|
|
15
|
+
/** JSON Schema of the resolved properties, derived from the zod schema. */
|
|
16
|
+
props: JsonSchema;
|
|
17
|
+
/** Property names that must be present. */
|
|
18
|
+
required: string[];
|
|
19
|
+
/** A complete, renderable example: the components and any data they bind to. */
|
|
20
|
+
example: {
|
|
21
|
+
components: A2UIComponentSpec[];
|
|
22
|
+
data?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface A2UICatalogueDoc {
|
|
26
|
+
catalogueId: string;
|
|
27
|
+
protocol: string;
|
|
28
|
+
generator: string;
|
|
29
|
+
components: A2UIComponentDoc[];
|
|
30
|
+
}
|
|
31
|
+
/** Build the machine-readable catalogue document. */
|
|
32
|
+
export declare function buildCatalogueDoc(catalogue?: A2UICatalogue): A2UICatalogueDoc;
|
|
33
|
+
/**
|
|
34
|
+
* Render the catalogue document as markdown.
|
|
35
|
+
*
|
|
36
|
+
* The output is written to be pasted into a system prompt: one table per
|
|
37
|
+
* component listing every property with its type, whether it is required and
|
|
38
|
+
* what it means, then a fenced example an agent can copy.
|
|
39
|
+
*/
|
|
40
|
+
export declare function catalogueMarkdown(doc?: A2UICatalogueDoc): string;
|
|
41
|
+
/** Turn an entry's example into the messages an agent would actually send. */
|
|
42
|
+
export declare function exampleMessages(component: A2UIComponentDoc): unknown[];
|
|
43
|
+
//#endregion
|
|
44
|
+
//# sourceMappingURL=catalogue-doc.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { A2UI_CATALOGUE_ID, defaultCatalogue } from "./catalogue.js";
|
|
3
|
+
import { A2UI_VERSION } from "./message.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/a2ui/catalogue-doc.ts
|
|
6
|
+
/**
|
|
7
|
+
* Catalogue documentation generator.
|
|
8
|
+
*
|
|
9
|
+
* Emits a machine-readable description of the catalogue — every component's
|
|
10
|
+
* name, group, summary, property schema, events and a worked example — plus a
|
|
11
|
+
* markdown rendering of the same thing.
|
|
12
|
+
*
|
|
13
|
+
* This exists so the "Rich Content" system-prompt section can be *generated*
|
|
14
|
+
* from the catalogue rather than written beside it (DESIGN-34). A prompt that
|
|
15
|
+
* describes a component the renderer does not have, or omits one it does, is
|
|
16
|
+
* the failure `05-agent-ui.md` calls out; the only way to prevent it is for
|
|
17
|
+
* both to come from one object.
|
|
18
|
+
*
|
|
19
|
+
* `pnpm a2ui:catalogue` writes `dist-a2ui/catalogue.json` and `.md`.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* zod 4 ships `toJSONSchema`; zod 3 does not.
|
|
23
|
+
*
|
|
24
|
+
* The package's zod peer allows both, so this is checked rather than assumed —
|
|
25
|
+
* emitting `{}` for every component would produce a doc that passes every test
|
|
26
|
+
* and teaches an agent nothing, which is the silent-success failure this whole
|
|
27
|
+
* package's lint exists to avoid.
|
|
28
|
+
*/
|
|
29
|
+
function toJsonSchema(schema) {
|
|
30
|
+
const converter = z.toJSONSchema;
|
|
31
|
+
if (typeof converter !== "function") throw new Error("Generating the A2UI catalogue doc needs zod 4 (z.toJSONSchema). The installed zod is 3.x.");
|
|
32
|
+
return converter(schema, {
|
|
33
|
+
io: "input",
|
|
34
|
+
unrepresentable: "any"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** Build the machine-readable catalogue document. */
|
|
38
|
+
function buildCatalogueDoc(catalogue = defaultCatalogue) {
|
|
39
|
+
const components = Object.values(catalogue).map((entry) => {
|
|
40
|
+
const schema = toJsonSchema(entry.props);
|
|
41
|
+
const properties = schema.properties ?? {};
|
|
42
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
43
|
+
return {
|
|
44
|
+
name: entry.name,
|
|
45
|
+
group: entry.group,
|
|
46
|
+
summary: entry.summary,
|
|
47
|
+
children: entry.children,
|
|
48
|
+
events: [...entry.events],
|
|
49
|
+
props: properties,
|
|
50
|
+
required,
|
|
51
|
+
example: {
|
|
52
|
+
components: entry.example.components,
|
|
53
|
+
...entry.example.data ? { data: entry.example.data } : {}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
57
|
+
return {
|
|
58
|
+
catalogueId: A2UI_CATALOGUE_ID,
|
|
59
|
+
protocol: A2UI_VERSION,
|
|
60
|
+
generator: "cortena-ui/a2ui",
|
|
61
|
+
components
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const GROUP_ORDER = [
|
|
65
|
+
"layout",
|
|
66
|
+
"text",
|
|
67
|
+
"input",
|
|
68
|
+
"feedback",
|
|
69
|
+
"data"
|
|
70
|
+
];
|
|
71
|
+
const GROUP_TITLE = {
|
|
72
|
+
layout: "Layout",
|
|
73
|
+
text: "Text and media",
|
|
74
|
+
input: "Inputs and actions",
|
|
75
|
+
feedback: "Feedback",
|
|
76
|
+
data: "Data"
|
|
77
|
+
};
|
|
78
|
+
/** One-line type summary for a JSON Schema property, for the markdown table. */
|
|
79
|
+
function describeType(schema) {
|
|
80
|
+
if (typeof schema !== "object" || schema === null) return "any";
|
|
81
|
+
const node = schema;
|
|
82
|
+
if (Array.isArray(node.enum)) return node.enum.map((value) => JSON.stringify(value)).join(" \\| ");
|
|
83
|
+
if (Array.isArray(node.anyOf) || Array.isArray(node.oneOf)) return (node.anyOf ?? node.oneOf).map((option) => describeType(option)).join(" \\| ");
|
|
84
|
+
if (node.const !== void 0) return JSON.stringify(node.const);
|
|
85
|
+
if (node.type === "array") return `${describeType(node.items)}[]`;
|
|
86
|
+
if (typeof node.type === "string") return node.type;
|
|
87
|
+
if (Array.isArray(node.type)) return node.type.join(" \\| ");
|
|
88
|
+
return "any";
|
|
89
|
+
}
|
|
90
|
+
function escapeCell(text) {
|
|
91
|
+
return text.replace(/\|/g, "\\|").replace(/\n+/g, " ").trim();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Render the catalogue document as markdown.
|
|
95
|
+
*
|
|
96
|
+
* The output is written to be pasted into a system prompt: one table per
|
|
97
|
+
* component listing every property with its type, whether it is required and
|
|
98
|
+
* what it means, then a fenced example an agent can copy.
|
|
99
|
+
*/
|
|
100
|
+
function catalogueMarkdown(doc = buildCatalogueDoc()) {
|
|
101
|
+
const lines = [];
|
|
102
|
+
lines.push("# A2UI catalogue — cortena-ui");
|
|
103
|
+
lines.push("");
|
|
104
|
+
lines.push(`Protocol \`${doc.protocol}\`, catalogue \`${doc.catalogueId}\`. Generated from the catalogue definition in \`cortena-ui\`; do not edit by hand.`);
|
|
105
|
+
lines.push("");
|
|
106
|
+
lines.push("A surface is described by three message kinds: `createSurface` names it, `updateComponents` sends the component tree, `updateDataModel` sends the data those components bind to. Any property may be a literal or a `{ \"path\": \"/pointer\" }` binding into the data model. A component takes children through `children`, either a list of ids or `{ \"componentId\": \"…\", \"path\": \"/items\" }` to repeat one component per array item.");
|
|
107
|
+
lines.push("");
|
|
108
|
+
lines.push(`${doc.components.length} components:`);
|
|
109
|
+
lines.push("");
|
|
110
|
+
for (const group of GROUP_ORDER) {
|
|
111
|
+
const inGroup = doc.components.filter((component) => component.group === group);
|
|
112
|
+
if (inGroup.length === 0) continue;
|
|
113
|
+
lines.push(`## ${GROUP_TITLE[group]}`);
|
|
114
|
+
lines.push("");
|
|
115
|
+
for (const component of inGroup) {
|
|
116
|
+
lines.push(`### ${component.name}`);
|
|
117
|
+
lines.push("");
|
|
118
|
+
lines.push(component.summary);
|
|
119
|
+
lines.push("");
|
|
120
|
+
lines.push(`Children: ${component.children === "many" ? "yes" : "no"}. Events: ${component.events.length > 0 ? component.events.map((e) => `\`${e}\``).join(", ") : "none"}.`);
|
|
121
|
+
lines.push("");
|
|
122
|
+
const propertyNames = Object.keys(component.props);
|
|
123
|
+
if (propertyNames.length > 0) {
|
|
124
|
+
lines.push("| Property | Type | Required | Description |");
|
|
125
|
+
lines.push("| --- | --- | --- | --- |");
|
|
126
|
+
for (const name of propertyNames) {
|
|
127
|
+
const schema = component.props[name];
|
|
128
|
+
const description = typeof schema?.description === "string" ? schema.description : "";
|
|
129
|
+
lines.push(`| \`${name}\` | ${escapeCell(describeType(schema))} | ${component.required.includes(name) ? "yes" : "no"} | ${escapeCell(description)} |`);
|
|
130
|
+
}
|
|
131
|
+
lines.push("");
|
|
132
|
+
}
|
|
133
|
+
lines.push("```json");
|
|
134
|
+
lines.push(JSON.stringify(exampleMessages(component), null, 2));
|
|
135
|
+
lines.push("```");
|
|
136
|
+
lines.push("");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
140
|
+
}
|
|
141
|
+
/** Turn an entry's example into the messages an agent would actually send. */
|
|
142
|
+
function exampleMessages(component) {
|
|
143
|
+
const messages = [{
|
|
144
|
+
version: "v0.9",
|
|
145
|
+
createSurface: {
|
|
146
|
+
surfaceId: "demo",
|
|
147
|
+
root: component.example.components[0]?.id ?? "root"
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
version: "v0.9",
|
|
151
|
+
updateComponents: {
|
|
152
|
+
surfaceId: "demo",
|
|
153
|
+
components: component.example.components
|
|
154
|
+
}
|
|
155
|
+
}];
|
|
156
|
+
if (component.example.data) messages.push({
|
|
157
|
+
version: "v0.9",
|
|
158
|
+
updateDataModel: {
|
|
159
|
+
surfaceId: "demo",
|
|
160
|
+
path: "/",
|
|
161
|
+
value: component.example.data
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return messages;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { buildCatalogueDoc, catalogueMarkdown, exampleMessages };
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=catalogue-doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue-doc.js","names":[],"sources":["../../src/a2ui/catalogue-doc.ts"],"sourcesContent":["/**\n * Catalogue documentation generator.\n *\n * Emits a machine-readable description of the catalogue — every component's\n * name, group, summary, property schema, events and a worked example — plus a\n * markdown rendering of the same thing.\n *\n * This exists so the \"Rich Content\" system-prompt section can be *generated*\n * from the catalogue rather than written beside it (DESIGN-34). A prompt that\n * describes a component the renderer does not have, or omits one it does, is\n * the failure `05-agent-ui.md` calls out; the only way to prevent it is for\n * both to come from one object.\n *\n * `pnpm a2ui:catalogue` writes `dist-a2ui/catalogue.json` and `.md`.\n */\n\nimport { z } from \"zod\";\nimport { A2UI_CATALOGUE_ID, defaultCatalogue, type A2UICatalogue, type A2UIGroup } from \"./catalogue\";\nimport { A2UI_VERSION, type A2UIComponentSpec } from \"./message\";\n\n/** A JSON Schema object, as far as this module cares. */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface A2UIComponentDoc {\n name: string;\n group: A2UIGroup;\n summary: string;\n /** Whether the component takes a `children` list. */\n children: \"none\" | \"many\";\n /** Event names the component raises through `onAction`. */\n events: string[];\n /** JSON Schema of the resolved properties, derived from the zod schema. */\n props: JsonSchema;\n /** Property names that must be present. */\n required: string[];\n /** A complete, renderable example: the components and any data they bind to. */\n example: { components: A2UIComponentSpec[]; data?: Record<string, unknown> };\n}\n\nexport interface A2UICatalogueDoc {\n catalogueId: string;\n protocol: string;\n generator: string;\n components: A2UIComponentDoc[];\n}\n\n/**\n * zod 4 ships `toJSONSchema`; zod 3 does not.\n *\n * The package's zod peer allows both, so this is checked rather than assumed —\n * emitting `{}` for every component would produce a doc that passes every test\n * and teaches an agent nothing, which is the silent-success failure this whole\n * package's lint exists to avoid.\n */\nfunction toJsonSchema(schema: z.ZodType<unknown>): JsonSchema {\n const converter = (z as unknown as { toJSONSchema?: (s: unknown, o?: unknown) => JsonSchema })\n .toJSONSchema;\n if (typeof converter !== \"function\") {\n throw new Error(\n \"Generating the A2UI catalogue doc needs zod 4 (z.toJSONSchema). The installed zod is 3.x.\",\n );\n }\n return converter(schema, { io: \"input\", unrepresentable: \"any\" });\n}\n\n/** Build the machine-readable catalogue document. */\nexport function buildCatalogueDoc(catalogue: A2UICatalogue = defaultCatalogue): A2UICatalogueDoc {\n const components = Object.values(catalogue)\n .map((entry): A2UIComponentDoc => {\n const schema = toJsonSchema(entry.props as unknown as z.ZodType<unknown>);\n const properties = (schema.properties ?? {}) as JsonSchema;\n const required = Array.isArray(schema.required) ? (schema.required as string[]) : [];\n return {\n name: entry.name,\n group: entry.group,\n summary: entry.summary,\n children: entry.children,\n events: [...entry.events],\n props: properties,\n required,\n example: {\n components: entry.example.components,\n ...(entry.example.data ? { data: entry.example.data } : {}),\n },\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n\n return {\n catalogueId: A2UI_CATALOGUE_ID,\n protocol: A2UI_VERSION,\n generator: \"cortena-ui/a2ui\",\n components,\n };\n}\n\nconst GROUP_ORDER: A2UIGroup[] = [\"layout\", \"text\", \"input\", \"feedback\", \"data\"];\n\nconst GROUP_TITLE: Record<A2UIGroup, string> = {\n layout: \"Layout\",\n text: \"Text and media\",\n input: \"Inputs and actions\",\n feedback: \"Feedback\",\n data: \"Data\",\n};\n\n/** One-line type summary for a JSON Schema property, for the markdown table. */\nfunction describeType(schema: unknown): string {\n if (typeof schema !== \"object\" || schema === null) {\n return \"any\";\n }\n const node = schema as JsonSchema;\n if (Array.isArray(node.enum)) {\n return node.enum.map((value) => JSON.stringify(value)).join(\" \\\\| \");\n }\n if (Array.isArray(node.anyOf) || Array.isArray(node.oneOf)) {\n const options = (node.anyOf ?? node.oneOf) as unknown[];\n return options.map((option) => describeType(option)).join(\" \\\\| \");\n }\n if (node.const !== undefined) {\n return JSON.stringify(node.const);\n }\n if (node.type === \"array\") {\n return `${describeType(node.items)}[]`;\n }\n if (typeof node.type === \"string\") {\n return node.type;\n }\n if (Array.isArray(node.type)) {\n return node.type.join(\" \\\\| \");\n }\n return \"any\";\n}\n\nfunction escapeCell(text: string): string {\n return text.replace(/\\|/g, \"\\\\|\").replace(/\\n+/g, \" \").trim();\n}\n\n/**\n * Render the catalogue document as markdown.\n *\n * The output is written to be pasted into a system prompt: one table per\n * component listing every property with its type, whether it is required and\n * what it means, then a fenced example an agent can copy.\n */\nexport function catalogueMarkdown(doc: A2UICatalogueDoc = buildCatalogueDoc()): string {\n const lines: string[] = [];\n lines.push(\"# A2UI catalogue — cortena-ui\");\n lines.push(\"\");\n lines.push(\n `Protocol \\`${doc.protocol}\\`, catalogue \\`${doc.catalogueId}\\`. Generated from the catalogue definition in \\`cortena-ui\\`; do not edit by hand.`,\n );\n lines.push(\"\");\n lines.push(\n \"A surface is described by three message kinds: `createSurface` names it, `updateComponents` sends the component tree, `updateDataModel` sends the data those components bind to. Any property may be a literal or a `{ \\\"path\\\": \\\"/pointer\\\" }` binding into the data model. A component takes children through `children`, either a list of ids or `{ \\\"componentId\\\": \\\"…\\\", \\\"path\\\": \\\"/items\\\" }` to repeat one component per array item.\",\n );\n lines.push(\"\");\n lines.push(`${doc.components.length} components:`);\n lines.push(\"\");\n\n for (const group of GROUP_ORDER) {\n const inGroup = doc.components.filter((component) => component.group === group);\n if (inGroup.length === 0) {\n continue;\n }\n lines.push(`## ${GROUP_TITLE[group]}`);\n lines.push(\"\");\n for (const component of inGroup) {\n lines.push(`### ${component.name}`);\n lines.push(\"\");\n lines.push(component.summary);\n lines.push(\"\");\n lines.push(\n `Children: ${component.children === \"many\" ? \"yes\" : \"no\"}. Events: ${\n component.events.length > 0 ? component.events.map((e) => `\\`${e}\\``).join(\", \") : \"none\"\n }.`,\n );\n lines.push(\"\");\n const propertyNames = Object.keys(component.props);\n if (propertyNames.length > 0) {\n lines.push(\"| Property | Type | Required | Description |\");\n lines.push(\"| --- | --- | --- | --- |\");\n for (const name of propertyNames) {\n const schema = component.props[name] as JsonSchema | undefined;\n const description =\n typeof schema?.description === \"string\" ? schema.description : \"\";\n lines.push(\n `| \\`${name}\\` | ${escapeCell(describeType(schema))} | ${\n component.required.includes(name) ? \"yes\" : \"no\"\n } | ${escapeCell(description)} |`,\n );\n }\n lines.push(\"\");\n }\n lines.push(\"```json\");\n lines.push(JSON.stringify(exampleMessages(component), null, 2));\n lines.push(\"```\");\n lines.push(\"\");\n }\n }\n return `${lines.join(\"\\n\").trimEnd()}\\n`;\n}\n\n/** Turn an entry's example into the messages an agent would actually send. */\nexport function exampleMessages(component: A2UIComponentDoc): unknown[] {\n const root = component.example.components[0]?.id ?? \"root\";\n const messages: unknown[] = [\n { version: \"v0.9\", createSurface: { surfaceId: \"demo\", root } },\n { version: \"v0.9\", updateComponents: { surfaceId: \"demo\", components: component.example.components } },\n ];\n if (component.example.data) {\n messages.push({\n version: \"v0.9\",\n updateDataModel: { surfaceId: \"demo\", path: \"/\", value: component.example.data },\n });\n }\n return messages;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAS,aAAa,QAAwC;CAC5D,MAAM,YAAa,EAChB;CACH,IAAI,OAAO,cAAc,YACvB,MAAM,IAAI,MACR,2FACF;CAE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
6
|
+
/** The five families the doc and the prompt group components by. */
|
|
7
|
+
export type A2UIGroup = "layout" | "text" | "input" | "feedback" | "data";
|
|
8
|
+
/** A ready-to-render example: the components, plus any data model they bind to. */
|
|
9
|
+
export interface A2UIExample {
|
|
10
|
+
/** Components for this entry. The first is the one being demonstrated. */
|
|
11
|
+
components: A2UIComponentSpec[];
|
|
12
|
+
/** Seed data for `{ path }` bindings used by the example. */
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface A2UICatalogueEntry<P = unknown> {
|
|
16
|
+
/** The name an agent writes in `component`. */
|
|
17
|
+
name: string;
|
|
18
|
+
group: A2UIGroup;
|
|
19
|
+
/** One sentence, used verbatim in the generated prompt section. */
|
|
20
|
+
summary: string;
|
|
21
|
+
/** Schema of the resolved properties. */
|
|
22
|
+
props: z.ZodType<P>;
|
|
23
|
+
/** Event names this component can raise through `onAction`. */
|
|
24
|
+
events: readonly string[];
|
|
25
|
+
/** `many` takes a `children` list; `none` ignores one. */
|
|
26
|
+
children: "none" | "many";
|
|
27
|
+
example: A2UIExample;
|
|
28
|
+
view: A2UIView<P>;
|
|
29
|
+
}
|
|
30
|
+
export type A2UICatalogue = Readonly<Record<string, A2UICatalogueEntry<never>>>;
|
|
31
|
+
/**
|
|
32
|
+
* The catalogue an agent draws from, and the renderer's default.
|
|
33
|
+
*
|
|
34
|
+
* A host may narrow it (hand the renderer a subset) but should not widen it
|
|
35
|
+
* with components the prompt does not describe: an agent can only usefully
|
|
36
|
+
* emit what `catalogue-doc.ts` told it about.
|
|
37
|
+
*/
|
|
38
|
+
export declare const defaultCatalogue: A2UICatalogue;
|
|
39
|
+
/** Catalogue id an agent may echo in `createSurface.catalogId`. */
|
|
40
|
+
export declare const A2UI_CATALOGUE_ID = "https://cortena.ai/a2ui/catalogues/cortena-ui/v1.json";
|
|
41
|
+
/** Every component name in the catalogue, sorted. */
|
|
42
|
+
export declare function catalogueNames(catalogue?: A2UICatalogue): string[];
|
|
43
|
+
//#endregion
|
|
44
|
+
//# sourceMappingURL=catalogue.d.ts.map
|