Generative UI for Ember 6.12 LTS and 7

A model writes the interface. Ember renders it as it streams.

The model streams a spec as JSON patches. A catalog of Joinery components and Formwright forms limits what the spec can contain. <Render> shows each patch when it arrives. The model sends data, never code or HTML.

pnpm add @ember-marquetry/joinery @ember-marquetry/ember

A recorded stream

Prompt: Show the visits of the last six months by device, and the share of each browser.

Why

Data from the model, components from your app#

A model that writes HTML can write anything. A model that writes a Marquetry spec can only select components and actions from your catalog. Each prop has a schema, so the renderer validates and repairs each element before it shows it.

It streams

Each line of the answer is one RFC 6902 patch. The page changes with each line, and an element that is not complete shows a skeleton.

It is Ember all through

.gts components, Glint types, a tracked state store, and a Generation state machine on Switchyard. No template compiles at runtime.

It is tested

Each component has a harness, and each render test ends with an axe audit. No test calls a model: the tests play recorded streams.

Patterns

Three ways to use it#

Use one pattern, or all three in one app.

A spec

The model writes a whole page or a panel. <Render> shows it, and its controls bind to the state of the spec.

A chat

A thread of messages with streamed markdown, specs, and tool calls that your components show. A tool can wait for the approval of the user.

An MCP App

A tool of an MCP server can send its own interface. Marquetry runs it in a sandboxed frame, with a strict CSP and a typed message channel.

Catalog

The catalog is the contract#

A catalog lists the components and the actions that a model can use. The same catalog writes the system prompt, validates the spec, and renders it. The Joinery catalog has every Joinery component that fits a spec, and add-ons for charts, the data table and the code block.

Add your own action to the Joinery catalog

import { z } from 'zod'
import { defineCatalog, mergeCatalogs } from '@ember-marquetry/core'
import { catalog as joinery } from '@ember-marquetry/joinery'

export const catalog = mergeCatalogs(
  joinery,
  defineCatalog({
    components: {},
    actions: {
      refresh: {
        description: 'Loads the orders of a region again.',
        params: z.strictObject({ region: z.string() }),
      },
    },
  }),
)

// On the server: the system prompt for the model.
const system = catalog.prompt()

What the model streams

{"op":"add","path":"/root","value":"page"}
{"op":"add","path":"/state/region","value":"west"}
{"op":"add","path":"/elements/page","value":{
  "type":"Card","props":{"title":"Orders"},"children":["region"]}}
{"op":"add","path":"/elements/region","value":{
  "type":"Select","props":{"label":"Region",
  "value":{"$bind":"/region"},"options":[…]}}}

See the catalog, the spec, expressions and each component in the guide.

Layout

Three levels of layout#

A model can lay out a page with parts, fill a named page template, or declare its own CSS grid areas. The validator accepts only area names and track sizes from a fixed grammar.

Parts

Stack, Grid, Split, Tabs, Card and more, with gap, columns and breakpoint props.

Templates

DashboardPage, DetailPage and WizardPage, each with named slots that the model fills.

Grid areas

GridAreas takes named areas and tracks for each breakpoint. Each child names an area that the grid declares.

See layout in the guide.

Forms

Forms on Formwright#

A Form element renders a Formwright form, and a Field element renders one of its fields. The validation comes from three sources, in this order: an app validator that the spec names, a JSON Schema in the spec, and the rules on each field.

{"op":"add","path":"/elements/form","value":{"type":"Form","props":{
  "title":"Create an account","model":{"$bind":"/signup"},
  "schema":{"type":"object","required":["terms"],
    "properties":{"age":{"type":"integer","minimum":18},"terms":{"const":true}}}},
  "children":["email","age","terms"],
  "on":{"submit":{"action":"createAccount","params":{"email":{"$state":"/signup/email"}}}}}}
{"op":"add","path":"/elements/email","value":{"type":"Field","props":{
  "for":"email","label":"Email","required":true,"format":"email"}}}

Submit is a catalog action. The model gets a value only when the action sends it. See forms in the guide.

Chat

A chat thread with interfaces in it#

<Chat> shows a thread on the Joinery message components. A part of a message is streamed markdown, a spec, a tool call or an MCP App. The markdown renderer makes Joinery components from the text, and never inserts HTML.

import { Chat } from '@ember-marquetry/chat'
import { catalog, registry } from '@ember-marquetry/joinery'
import { jsonlTransport } from '@ember-marquetry/sse'

const transport = jsonlTransport('/api/generate')

<template>
  <Chat @transport={{transport}} @catalog={{catalog}} @registry={{registry}} />
</template>

See chat and markdown in the guide.

Adapters

Use the stack that you have#

Each adapter reads one wire format and gives specs, text and tool calls. An adapter reports each value that it cannot convert. It never drops a value silently.

Package It reads
@ember-marquetry/sse JSON Lines or Server-Sent Events from your own endpoint, with fetch
@ember-marquetry/ai-sdk The UI message stream of the Vercel AI SDK
@ember-marquetry/ag-ui AG-UI 1.0 events
@ember-marquetry/a2ui A2UI v0.9.1 messages, converted to Marquetry patches

The repository has two server examples: Node and Rails.

Safety

The model sends data, not code#

A spec cannot run a script, and the renderer never inserts HTML from it. These rules apply to each spec.

See safety in the guide.

Tests

Test it with no model#

scriptedStream() gives a stream that your test controls, one patch at a time. RenderHarness finds each element of the spec, and the Joinery harnesses read the components.

import { RenderHarness, scriptedStream } from '@ember-marquetry/test-support'

const generation = new Generation({ owner: this.owner, catalog })
const stream = scriptedStream()
generation.run(stream)
stream.push({ op: 'add', path: '/root', value: 'title' })
stream.push({ op: 'add', path: '/elements/title',
  value: { type: 'Heading', props: { text: 'Orders', level: 1 } } })
await settled()

assert.dom(new RenderHarness().find('title')).hasText('Orders')
await a11yAudit()

See tests in the guide.

Install

Install#

Marquetry works with Ember 6.12 LTS and 7, in Vite and classic ember-cli apps. Add the packages that you need. The installation page has each step.

pnpm add @ember-marquetry/core @ember-marquetry/ember @ember-marquetry/joinery \
  @ember-joinery/ember @ember-joinery/primitives @ember-marquetry/sse
pnpm add --save-dev @ember-marquetry/test-support
Package What it does
@ember-marquetry/core The spec, the stream compiler, expressions, the catalog and the prompt. No framework: it runs on Node too.
@ember-marquetry/ember <Render>, the registry, the state and Generation
@ember-marquetry/joinery The catalog and the registry of Joinery components, layout parts and templates
@ember-marquetry/formwright Form, Field and Fieldset on Formwright
@ember-marquetry/chat A chat thread with specs, tool calls, approvals and MCP Apps
@ember-marquetry/markdown A parser for streamed markdown, with no HTML
@ember-marquetry/sse A fetch client for JSON Lines and Server-Sent Events
@ember-marquetry/ai-sdk The adapter for the Vercel AI SDK UI message stream
@ember-marquetry/ag-ui The adapter for AG-UI events
@ember-marquetry/a2ui The converter from A2UI v0.9.1 messages
@ember-marquetry/mcp-apps A sandboxed host for MCP Apps
@ember-marquetry/inspector A dev panel: the spec, the patches, the state and the problems
@ember-marquetry/test-support The harnesses and the scripted stream
@ember-marquetry/eslint-plugin Lint rules for catalogs: descriptions, strict schemas and safe names
@ember-marquetry/skills A skill that teaches code agents the Marquetry API
ember-marquetry The copy CLI: npx ember-marquetry add input copies the source of a component into your app

Siblings

More for Ember#

Marquetry follows the methods of its siblings, and it is built on them.

Joinery

Each shadcn/ui component for Ember, accessible to WCAG 2.2 AA. The catalog of Marquetry is its components.

Formwright

Declarative, accessible forms for Ember. The forms of a spec are Formwright forms.

Switchyard

Typed state machines for TypeScript and Ember. Generation is a Switchyard machine.

real-enums

Enums as classes for TypeScript, with members, labels and options.

harnessed

Test harnesses for components and pages: one class drives them in jsdom, Playwright, Cypress, Ember and more.