lynx-a2ui
Convert natural-language UI requests into A2UI v0.9 JSON protocol messages that an A2UI renderer can consume.
lynx-community · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add lynx-community/skills --skill lynx-a2ui技能说明
name: lynx-a2ui description: Convert natural-language UI requests into A2UI v0.9 JSON protocol messages that an A2UI renderer can consume.
A2UI Generator
Use this skill when an agent must turn a natural-language request into A2UI protocol data for rendering. The output is data only: a JSON array of A2UI v0.9 messages.
Generation Workflow
- Fetch the latest catalog from the URL in the Catalog Source section.
- Read
catalogId, component schemas, function schemas, required fields, enum values, and examples if the fetched catalog provides them. - Build the UI from the protocol rules, catalog schema, hard rules, and example patterns embedded in this skill.
- Translate the user's intent into a data model and a flat component graph that validates against the latest fetched catalog.
- Emit only the final JSON array of A2UI messages.
This skill is self-contained for third-party agent platforms. Do not rely on repository-local files.
Protocol Reference
A2UI is a JSON-based streaming UI protocol. The agent describes an interface by emitting declarative JSON messages. The renderer instantiates only trusted components from the active catalog. There is no arbitrary code: never emit JavaScript, HTML, CSS, event handlers, scripts, or executable snippets.
Design principles:
- Prompt-first: follow the in-context schema and examples exactly.
- Safe like data, expressive like code: emit trusted component data only.
- Structure/data separation: component messages define a flat UI graph; data model messages populate or update values used by dynamic bindings.
- Progressive rendering: each valid message may be rendered as it arrives. Prefer a useful minimal UI first, then add data or refinements.
- Transport-agnostic: A2UI messages may travel over SSE, REST, WebSocket, A2A, AG UI, MCP, or another host transport.
Envelope semantics:
createSurfacecreates a surface. Once created, itssurfaceIdandcatalogIdare fixed. To change catalog or theme, delete and recreate the surface.updateDataModelsets values inside a surface's data model. It has shape{ "surfaceId": string, "path"?: string, "value"?: any }.pathdefaults to/, andvaluemay be any JSON value.updateComponentsadds or replaces component definitions for a surface. It may reference data paths, but those paths should already be populated by an earlierupdateDataModelmessage in the same response.deleteSurfaceremoves a surface.
Output Contract
Return only a pretty-printed JSON array. Do not return Markdown, prose, XML, HTML, JavaScript, CSS, code fences, comments, or trailing commas.
Each array item must be a top-level object with "version": "v0.9" and exactly
one of these message keys:
"createSurface": create a new render surface."updateDataModel": set JSON values used by bindings."updateComponents": add or replace component definitions."deleteSurface": remove an existing surface.
For a fresh UI response, emit messages in this order:
createSurfaceupdateDataModelfor any initial values read through{ "path": ... }updateComponentscontaining a component with id"root"- optional additional
updateDataModelorupdateComponentsmessages
The first fresh updateComponents message should contain exactly one root
component. Later updateComponents messages may replace or add more components
as needed. Put each message object and component object on separate lines so the
JSON remains easy to parse and validate.
Before finishing, check bracket balance: every component object closes once,
every components array closes once, every message object closes once, and the
outer array closes exactly once.
Catalog Source
Use surface id "main" unless the caller provides a different id. Before
generating A2UI JSON, fetch the latest Lynx GenUI A2UI catalog from:
"https://unpkg.com/@lynx-js/genui/a2ui/dist/catalog.json"
Treat that fetched catalog as the authoritative, dynamic type definition for the generated UI. Do not rely on a stale component list remembered from this skill. The catalog has this top-level structure:
{
"catalogId": "https://unpkg.com/@lynx-js/genui/a2ui/dist/catalog.json",
"components": {},
"functions": {}
}
Use the fetched catalogId value in createSurface.catalogId. Use only
components listed under components, only functions listed under functions,
and only props, required fields, enum values, dynamic value shapes, and action
schemas allowed by that latest catalog. If the catalog cannot be fetched, ask
for the catalog content or a reachable catalog URL before generating non-trivial
UI.
If the user supplies a different catalog URL or catalog JSON, use that catalog
instead of the default URL and keep createSurface.catalogId aligned with the
active catalog.
Example Strategy
Examples improve accuracy, but they must be catalog-aware. Use examples this way:
- Prefer examples embedded in the fetched catalog if present.
- Use the embedded examples below as reusable patterns for a form with an action, a data-bound repeated view, a chart-like data view, and an action response patch.
- Validate embedded examples against the latest catalog before borrowing their structure. Discard or adapt any example that references missing components, missing props, changed required fields, changed enum values, or functions absent from the current catalog.
- Do not paste example JSON into the final answer unless it exactly satisfies the user's request and the latest catalog.
- If no example fits, generate from the fetched schemas directly.
Hard Rules
- Output must be a JSON array of A2UI messages. No prose, Markdown, XML, code fences, comments, or trailing commas.
- Each element must include
"version": "v0.9". - Output pretty-printed JSON with 2-space indentation. Do not emit minified single-line JSON.
- For a fresh non-action response, th