castella-a2ui
БесплатноЗапускает вложенные скриптыНе проверенRender A2UI JSON as native Castella widgets. Parse A2UI messages, handle actions, progressive rendering, data binding, and connect to A2UI-enabled agents.
Об этом скилле
Castella A2UI Integration
A2UI (Agent-to-User Interface) enables AI agents to generate rich, interactive UIs by outputting JSON component descriptions. Castella renders these natively across desktop, web, and terminal platforms.
When to use: "render A2UI JSON", "A2UI component", "A2UIRenderer", "A2UI data binding", "A2UI streaming", "connect to A2UI agent", "updateDataModel", "A2UIClient"
Quick Start
Render A2UI JSON to a Castella widget:
from castella import App
from castella.a2ui import A2UIRenderer, A2UIComponent
from castella.frame import Frame
renderer = A2UIRenderer()
widget = renderer.render_json({
"components": [
{"id": "root", "component": "Column", "children": {"explicitList": ["text1"]}},
{"id": "text1", "component": "Text", "text": {"literalString": "Hello A2UI!"}}
],
"rootId": "root"
})
App(Frame("A2UI Demo", 800, 600), widget).run()
Core Concepts
A2UIRenderer
The main class for converting A2UI messages to Castella widgets:
from castella.a2ui import A2UIRenderer, UserAction
def on_action(action: UserAction):
print(f"Action: {action.name}")
print(f"Source: {action.source_component_id}")
print(f"Context: {action.context}")
renderer = A2UIRenderer(on_action=on_action)
Value Types
A2UI uses typed values for properties:
# Literal values (static)
{"text": {"literalString": "Hello"}}
{"value": {"literalNumber": 42}}
{"checked": {"literalBoolean": True}}
# Data binding (dynamic, JSON Pointer RFC 6901)
{"text": {"path": "/user/name"}}
{"value": {"path": "/counter"}}
Helper functions:
from castella.a2ui import literal, binding
literal("Hello") # {"literalString": "Hello"}
literal(42) # {"literalNumber": 42}
literal(True) # {"literalBoolean": True}
binding("/counter") # {"path": "/counter"}
Supported Components
| A2UI Component | Castella Widget | Notes |
|---|---|---|
| Text | Text | usageHint: h1-h5, body, caption |
| Button | Button | action with context |
| TextField | Input/MultilineInput | usageHint: password, multiline |
| CheckBox | CheckBox | Two-way binding |
| Slider | Slider | min/max range |
| DateTimeInput | DateTimeInput | Date/time picker |
| ChoicePicker | RadioButtons/Column | Single/multiple selection |
| Image | NetImage | URL-based images |
| Icon | Text | Material Icons → emoji |
| Divider | Spacer | Horizontal/vertical |
| Row | Row | Horizontal layout |
| Column | Column | Vertical layout |
| Card | Column | Container with styling |
| List | Column | TemplateChildren support |
| Tabs | Tabs | Tabbed navigation |
| Modal | Modal | Overlay dialog |
| Markdown | Markdown | Rich text (Castella extension) |
See references/components.md for detailed component reference.
Data Binding
Bind widget values to a data model using JSON Pointer paths:
a2ui_json = {
"components": [
{"id": "root", "component": "Column", "children": {"explicitList": ["greeting"]}},
{"id": "greeting", "component": "Text", "text": {"path": "/message"}}
],
"rootId": "root"
}
# Provide initial data
initial_data = {"/message": "Hello, World!"}
widget = renderer.render_json(a2ui_json, initial_data=initial_data)
Actions
Handle user interactions via actions:
{
"id": "submit_btn",
"component": "Button",
"text": {"literalString": "Submit"},
"action": {"name": "submit", "context": ["/formData"]}
}
Action handler receives UserAction:
def on_action(action: UserAction):
print(action.name) # "submit"
print(action.source_component_id) # "submit_btn"
print(action.context) # ["/formData"]
updateDataModel
Update bound values dynamically:
renderer.handle_message({
"updateDataModel": {
"surfaceId": "default",
"data": {"/message": "Updated message!"}
}
})
A2UIComponent (Reactive)
Wrap surface in A2UIComponent for automatic UI updates:
from castella.a2ui import A2UIComponent
renderer.render_json(a2ui_json, initial_data=initial_data)
surface = renderer.get_surface("default")
component = A2UIComponent(surface) # Auto-updates on data changes
App(Frame("A2UI", 800, 600), component).run()
TemplateChildren (Dynamic Lists)
Render lists from data arrays:
a2ui_json = {
"components": [
{"id": "root", "component": "Column", "children": {"explicitList": ["user_list"]}},
{"id": "user_list", "component": "List", "children": {
"path": "/users", # JSON Pointer to array
"componentId": "user_item" # Template component
}},
{"id": "user_item", "component": "Text", "text": {"path": "name"}} # Relative path
],
"rootId": "root"
}
initial_data = {"/users": [{"name": "Alice"}, {"name": "Bob"}, {"name": "Charlie"}]}
widget = renderer.render_json(a2ui_json, initi
Установить castella-a2ui в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл castella-a2ui?
Render A2UI JSON as native Castella widgets. Parse A2UI messages, handle actions, progressive rendering, data binding, and connect to A2UI-enabled agents.
Как установить скилл castella-a2ui?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл castella-a2ui запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic