Docs / user-guide

Kitty user guide

Source: docs/user-guide.md

This guide explains how to write an implemented gamecomposer.yml manifest and drive its lifecycle with the kitty CLI. Download and install options are in INSTALL.md. It describes the code at commit 321e188. The config command was executed against both bundled examples to confirm the manifest format and flag surface; no up / end-to-end play session was run for this guide, so playability is not claimed. The authoritative schema is specs/game-compose.schema.json; where this guide disagrees with it, the schema wins.

1. Before you start

Item What to expect
Manifest file apiVersion: gamecomposer.dev/v0.2 in gamecomposer.yml by default. Use --file/-f to pick another path.
CLI pip install -e . (from source) installs the kitty command via pyproject.toml; requires Python 3.10+, PyYAML, and jsonschema. kitty --help shows the exact flags. See INSTALL.md for the packaged channels.
Kiri runtime Must be installed and started. The adapter finds kiri on PATH or in the standard install locations; kiri version and kiri ps prove the engine is up. It calls the Kiri CLI, never the Docker CLI.
Guest OS Only Linux container environments launch. windows, macos, and steamos are accepted by the schema but rejected by preflight before launch.
Sources Either a project-relative path or an HTTPS url with sha256. URL assets are downloaded and verified on up; config never downloads.
Player browser-local outputs publish a loopback URL (http://127.0.0.1:<port>/) that up opens unless --no-open is set. This is local browser play, not remote streaming.

No Docker installation is required or used. Kiri is Docker-API-compatible and builds container images through its own CLI, but there is no user-managed Docker daemon, Compose file, or image to install.

2. The gamecomposer.yml manifest

Complete example

This is the shape the validator requires: a top-level apiVersion, name, runtime.engine: kiri, and one or more named services. Every field below is present in the real root manifest and the NES example.

apiVersion: gamecomposer.dev/v0.2
name: color-arcade
runtime:
  engine: kiri

services:
  nes:
    console:
      platform: nes
      model: NES-compatible
    environment:
      os: linux
      build: ./image
      command: ["/usr/bin/env"]
      args: []
      workingDir: /gamecomposer
      env: {}
    emulator:
      source:
        url: https://unpkg.com/jsnes@2.1.0/dist/jsnes.min.js
        sha256: 84946f0dae4bcf3b2dfebe84ad3bfeb1dbcb413bd9b1a69e1f45910a95fd7b41
        maxBytes: 1048576
      executable: /usr/local/bin/python
      args: ["/opt/player/serve.py", "{game}"]
    game:
      title: 8-Bit Table Tennis
      platform: nes
      source:
        url: https://github.com/mike42/8bit-table-tennis/releases/download/v1.0/table_tennis_v1.0.nes
        sha256: 05122457672f95fcf2ee518c3f37e506617725c2d031100b1b1c8b7785068ea3
        maxBytes: 1048576
    controls:
      gamepads: 1
      mapping:
        a: south
        b: east
        start: start
        select: back
        dpad: dpad
    resources:
      cpus: 1
      memory: 256MiB
    storage:
      saves: ./data/saves
      writable: ./data/user
    network:
      mode: bridge
    outputs:
      video: browser-local
      audio: browser-local
      port: 8080
    lifecycle:
      restart: never
      stopGraceSeconds: 3

Field reference

All service fields below are required unless marked optional. Unknown fields are rejected.

Field Meaning
apiVersion Must be the literal gamecomposer.dev/v0.2.
name Project label (1–80 characters).
runtime.engine Must be kiri.
services.<id> Key must match ^[a-z][a-z0-9_-]{0,62}$; 1–64 services.
depends_on (optional) Other service ids; start order is topological and selection includes transitive dependencies. Cycles and unknown references fail validation.
console.platform / .model (optional) Console label for the service.
environment.os linux works; windows, macos, steamos pass the schema but fail preflight.
environment.image or environment.build Exactly one. build is a ./ directory containing a Dockerfile; the adapter builds a local image with Kiri on first up.
environment.command / .args / .workingDir / .env Executable argument vector, its extra arguments, guest working directory, and guest environment variables. Arguments are passed as a vector, never a shell string.
emulator.source A path or url source (see below).
emulator.executable / .args Guest executable and arguments. {game} and {emulator} are replaced with the resolved guest mount paths.
game.title / .platform (optional) / .source Game label and its path or url source.
controls.gamepads Requested count, 0–8. A non-zero value requires a browser-local player; Kiri gamepad passthrough is unverified.
controls.mapping Descriptive button-to-action map; it does not pair or forward a physical controller.
resources.cpus / .memory CPU limit and memory string such as 256MiB, passed to Kiri.
storage.saves / .writable ./ paths inside the project; created on up, mounted into the guest, and preserved by down. They must not overlap.
network.mode none or bridge. bridge is required for a browser-local player.
outputs.video / .audio browser-local or none; port (optional) is the published loopback port, default 8080.
lifecycle.restart / .stopGraceSeconds Restart policy and stop timeout passed to Kiri.

Local path vs HTTPS url sources

  • Local path: source: { path: ./roms/my-game.nes }. The value must start with ./, cannot contain .. or absolute segments, must stay inside the manifest directory, and (for emulator/game files) must exist. environment.build must additionally be a directory containing a Dockerfile.
  • HTTPS URL: source: { url: https://.../asset.nes, sha256: <64 hex chars> }. The URL must be HTTPS with no embedded credentials, sha256 is required, and maxBytes is optional (default 2 GiB, hard cap 8 GiB).
  • up downloads URL sources into <project>/.gamecomposer/cache/<sha256>/<filename>, verifies the digest, and mounts them read-only. A mismatch or oversized download aborts the launch. config performs no downloads.
  • Mixing source styles (local emulator with URL game, or the reverse) is supported because each source is resolved independently.

Config, resources, controls, storage, and outputs

  • config here means the manifest's environment/emulator/game settings, not the kitty config command.
  • resources and network become Kiri run flags; storage becomes two bind mounts plus the GAMECOMPOSER_SAVE_DIR / GAMECOMPOSER_USER_DIR guest variables.
  • A browser-local output publishes 127.0.0.1::<port> only. The browser does the rendering and input; the container serves the pinned page, loader, and ROM.
  • See specs/game-compose.schema.json for exact types and limits, and PLATFORM-MATRIX.md for the host/Kiri boundary.

3. Lifecycle with kitty

kitty [--file MANIFEST] [--no-open] config [SERVICE ...]
kitty [--file MANIFEST] [--no-open] up [SERVICE ...]
kitty [--file MANIFEST] ps|status|logs|stop|down [SERVICE ...]

Run from the directory containing gamecomposer.yml, or pass --file PATH (short form -f). Service names are manifest keys; when you select one, its depends_on ancestors are included automatically.

config — inspect without launching

kitty config
kitty --file examples/snes/gamecomposer.yml config nes

Parses YAML or JSON, validates against the JSON Schema, checks dependency references and cycles, resolves project paths, and prints the normalized manifest as JSON. It starts no Kiri process and downloads no asset. With service names, only those services (plus dependencies) appear in the output.

up — start services

kitty up
kitty --no-open up nes

Validates the manifest, resolves assets, builds the guest image if environment.build is set, creates the save/user directories, starts the Kiri containers in dependency order, and prints a line per service with its state and (for browser outputs) the loopback player URL. Re-running up on an unchanged, already-running service is idempotent. If the manifest changed since the container was created, up asks you to run down first. A started container whose player URL cannot be published is an error, and the last 2000 characters of its logs are printed. --no-open leaves the URL in the terminal instead of opening a browser.

ps / status — observe

kitty ps
kitty status nes

Reports absent, running, or the observed container state per selected service, with the player URL when running. ps and status are aliases.

logs — read service output

kitty logs nes

Prints each selected service's Kiri logs under a --- <service> --- heading.

stop / down — tear down

kitty stop nes
kitty down

stop halts selected services in reverse dependency order but keeps the containers. It refuses to stop a service while an active dependent remains, so prerequisite ordering cannot be broken. down additionally removes the managed containers. Both preserve the declared saves and user-data directories for a later up. Containers are labelled gamecomposer.managed=true with the project id, service, and config fingerprint so commands only touch their own manifest's services.

Exit codes

0 success; 1 runtime/OS failure (Kiri error, failed download, capability rejection); 2 invalid input or manifest error (bad flag, schema/path/cycle error, unknown service).

4. Worked examples

NES — pinned JSNES loader and homebrew ROM

kitty --file examples/nes/gamecomposer.yml config
kitty --file examples/nes/gamecomposer.yml up

The NES manifest builds its guest from examples/nes/image and serves a browser-local JSNES player. Both the loader and the 8-Bit Table Tennis ROM are HTTPS URLs with SHA-256 digests.

SNES — EmulatorJS and Kit’s Rooftop Run

kitty --file examples/snes/gamecomposer.yml config
kitty --file examples/snes/gamecomposer.yml up

The SNES example pins EmulatorJS 4.2.3 and a homebrew ROM. Its page loads the core and WebAssembly from cdn.emulatorjs.org, so the host browser needs internet access even though the assets served by the container are local. See that example's README for attribution and license provenance.

Both examples are included and config was verified for each; neither is evidence of playability until a launch → input → display run is recorded.

5. Troubleshooting

Symptom What to check
kitty not found Install a packaged channel from INSTALL.md or the project (python -m pip install -e .); the console scripts are declared in pyproject.toml.
manifest validation failed: ... Check apiVersion, all required service fields, unknown keys, and that service ids match the required pattern. The message names the failing field path.
... must start with './' / escapes the manifest directory Local paths must be ./-relative and cannot use .. or absolute paths.
... is missing or is not a file/directory environment.build must be a directory with a Dockerfile; emulator/game paths must be existing files.
sha256 is required / SHA-256 mismatch URL sources need a 64-hex sha256; a mismatch aborts the launch rather than using the file.
download exceeds declared maxBytes Raise maxBytes in the manifest (up to the 8 GiB cap) or use a smaller asset.
Kiri CLI is required Install and start Kiri; confirm kiri version and kiri ps work.
requests guest OS '...' Only os: linux launches; other schema-accepted OS values are reserved.
needs network.mode: bridge / requests gamepads without a browser player Set network.mode: bridge for browser outputs, and use browser-local outputs when gamepads > 0.
has changed configuration; run down before up The container's config fingerprint differs from the manifest; run down, then up.
cannot stop selected services while active dependents remain Stop or down the dependents first, or select them too.
started without a published player URL Read the printed logs; check outputs.port and browser-output settings.
No display, audio, or controller input That is an end-to-end issue, not a manifest issue. See PLAYER-UX.md and acceptance.md.

6. Verification status and limits

  • Implemented and exercised for this guide: the CLI flag surface (kitty --help) and config on examples/nes/gamecomposer.yml and examples/snes/gamecomposer.yml, both returning normalized JSON without starting a process.
  • Not exercised here: up, Kiri launches, asset downloads, browser rendering, audio, controller input, and saves. No playability claim is made.
  • The implemented lifecycle is in gamecomposer/cli.py, gamecomposer/api.py, gamecomposer/core.py, and gamecomposer/runtime.py. Review findings R2 and R5 are resolved with these artifacts in REVIEW-NOTES.md.
  • Normative details live in specs/game-compose.schema.json, docs/GAMECOMPOSER-SPEC.md (contract), docs/PLATFORM-MATRIX.md (OS/Kiri), and docs/PLAYER-UX.md (player target).

Back to all docs