Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

a2ui-generate-pydantic-models

БесплатноЗапускает вложенные скриптыНе проверен

Automated generator for strongly typed Pydantic v2 data models and basic catalogs across any A2UI protocol version (v0.8, v0.9, v0.9.1, v1.0, etc.).

a2ui-projectот a2ui-project★ 19 155 звёзд на GitHub

Об этом скилле

A2UI Pydantic Model Generation Skill

This skill provides an automated code generation tool that produces strongly typed Pydantic v2 data models and basic catalog definitions for python/a2ui_core directly from the schemas and catalogs in specification/<version>/.


Agent Execution Steps

When given a prompt like "Generate Pydantic model classes for A2UI spec v1.0":

  1. Extract the target version parameter from the prompt (e.g. v1.0 -> v1.0).

  2. Execute the generator script exactly once for that target version:

    uv run python .agents/skills/a2ui-generate-pydantic-models/scripts/codegen_pydantic.py --version <TARGET_VERSION>
    

    (Replace <TARGET_VERSION> with the single requested version, e.g. --version v1.0).

  3. Format generated Python code:

    cd python/a2ui_core
    uv run pyink .
    
  4. Verify the generated files by running pytest:

    cd python/a2ui_core
    uv run pytest tests/test_codegen_pydantic.py
    
  5. Stop and report completion to the user.


Generated Output Files per Version

When executed for a target version <version> (e.g. v1.0 -> v1_0), the script generates:

  1. python/a2ui_core/src/a2ui/core/schema/<version>/:
    • constants.py
    • common_types.py: strongly typed shared models and the COMMON_TYPES_DEFS manifest, which maps each spec $defs name to its symbol in spec order. No spec schema is copied verbatim; the published common types schema is rebuilt from these symbols.
      • Type aliases such as ComponentId, Child, ChildList and the Dynamic* unions are registered as Annotated[..., Field(description=...)] with the spec descriptions, so the runtime JSON schema generator needs no per-def special cases. Dynamic unions list their members in spec order.
      • When a Dynamic* def constrains its function-call branch with a returnType const, the branch is Annotated[FunctionCall, ReturnType("<type>")], which validates the return type and emits the spec's allOf in both modes. Any other branch shape fails generation.
      • Every model extends SpecBaseModel (hand-written in schema/common_types.py) and has no generated methods. Keywords that fields cannot produce are declared in the model config as json_schema_extra=SchemaKeywords(...): it drops additionalProperties where the spec leaves it out and adds returnType, unevaluatedProperties, title, allowedParents and oneOf required-alternatives (see _SPEC_KEYWORDS). The keywords apply only to the declaring model, not to subclasses. SpecBaseModel validates a declared oneOf whose branches only list required fields (for example FunctionResponse's value/error), requiring exactly one branch.
      • Only composition that references the catalog's function union is limited to spec_schema() (SchemaKeywords(..., spec_only=True)), which the published common types schema uses: v0.9's FunctionCall oneOf, v1.0's FunctionCall allOf over FunctionCommon and anyFunction (replace=True, since the spec def is pure composition), and v0.9's precise args shape (a schema-only JsonSchemaAs annotation requested through the x-python-type property override). Catalogs keep the flat model shape there. References inside declared keywords are the markers def_ref("<Def>") and catalog_functions() from the internal a2ui.core.schema._json_schema module, which the schema builder resolves to $refs. FunctionCall itself is a flat model that validates any call without the catalog.
      • Nested object properties with their own properties become helper models named <Parent><Property> (for example ComponentCommonMetadata, IndexSystemFunctionArgs, FunctionResponseError), which schemas inline. Wrapper unions such as Action are TypeAliasTypes, so fields reference them by def name. Each branch gets a <Def><Property>Wrapper model, and a branch property that is an object becomes <Def><Property> (ActionEvent, ActionEventWrapper, ActionFunctionCallWrapper). A generated name that collides with a def, a base symbol or another helper fails generation.
      • A def that the spec leaves open (no additionalProperties and no unevaluatedProperties: false) allows extra keys. ComponentCommon is the exception (_SUBCLASSED_DEFS): generated catalog components subclass it and must stay closed.
      • Optional fields are typed X | None so they can be absent. SpecBaseModel rejects an explicit null for such a field unless X accepts null itself (Any), under both the spec name and the Python field name; it does not change the JSON schema. Catalog components inherit this rule through ComponentCommon. v0.9's FunctionCall.args also rejects null values.
      • Primitive defs such as CallId are TypeAliasTypes, so local references keep their $ref. References from other documents to a primitive def map to its Python type through _CROSS_DOCUMENT_REF_TYPES in engine.py.
Полный SKILL.md на GitHub

Установить a2ui-generate-pydantic-models в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

scripts/__init__.pyscripts/catalog_generators.pyscripts/codegen_pydantic.pyscripts/engine.pyscripts/schema_generators.pyscripts/utils.py

FAQ

Что делает скилл a2ui-generate-pydantic-models?

Automated generator for strongly typed Pydantic v2 data models and basic catalogs across any A2UI protocol version (v0.8, v0.9, v0.9.1, v1.0, etc.).

Как установить скилл a2ui-generate-pydantic-models?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл a2ui-generate-pydantic-models запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить a2ui-generate-pydantic-models с