app-anything GitHub

Write a creator

A creator turns a built .aapkg into artifacts for one platform. The working examples are the builtin creators: creators/web (the smallest complete one), creators/desktop (a plugin that drives an external toolchain), and creators/mobile.

1. Declare the plugin

A creator package provides a module decorated with @creator and exposes itself through an entry point:

[project.entry-points."app_anything.creators"]
web = "app_anything_create_web:WebCreator"

The core never imports you; it discovers you. Apply the contract suite in app_anything.sdk.testing (see tests/contract/test_builtins.py) so your creator is exercised the same way the builtin ones are.

2. Offer capabilities and targets

@creator(
    CreatorMeta(
        id="web",
        version="0.1.0",
        targets=("web",),
        capabilities=CapabilitySet(
            Capability(CapabilityId("ui.static"), Support.FULL),
            Capability(CapabilityId("backend.wasm"), Support.FULL),
        ),
    )
)
class WebCreator:
    ...

Offers drive target assessment: check --target web and create compare what the package requires with what you offer. Partial support carries a note (the AA602 shape); Support.NONE refuses the target.

3. Create from the package

def create(self, request: CreatorRequest, toolchain: Toolchain) -> CreatorResult:
    package = read_package(request.package_path)
    ...
    return CreatorResult(artifacts=(Artifact(...),), notes=())

Validate what you read — the package schema is public — and report through CreatorResult.artifacts, never by printing. A missing toolchain raises ToolchainMissing, which the CLI maps to exit code 3: the user's machine lacks something, your code is not wrong.

4. Keep the runner conformant

A creator that supervises backends itself (like the desktop runner) must pass the same conformance cases as the Python host — see run the conformance suite. The cases are language-neutral on purpose.

Rendered from docs/how-to/write-a-creator.md on main.