--- name: design-max-level description: Design, edit, and playtest the connected Pixel Mill level for MAX Night Garden. Use when the user asks to inspect the current level, arrange assets, change terrain or collisions, or test Max's route. --- # Design the connected MAX level 1. Call `get_level` first. Read the current revision, asset IDs, placed pieces, collisions, spawn, and selected reference sheets before proposing edits. Use `get_asset_image` and `get_canvas_preview` when visual inspection helps. 2. Work within the level's existing art and imported assets. Check that `import_image`, `slice_spritesheet`, and `create_spritesheet` are actually available in this connection before using them. If missing, explain that the level server needs its updated Worker deployment; do not claim that an image was uploaded. For a user-supplied image, convert JPEG/WebP to PNG if needed, preserve native pixel dimensions and hard edges, and pass its complete PNG data URL to `import_image` with the current revision. The tool accepts 8-bit non-interlaced PNGs up to four million pixels. Do not pass a local path. Use optional background removal, nearest-neighbor scaling, palette reduction, and connected-component splitting only when requested. Prefer incremental layouts that preserve the user's placed work. 3. Use native game pixel coordinates: x increases right, y increases down. Pieces use the unrotated rectangle's x/y, width/height, and center rotation in degrees. Max's spawn is his foot position. Keep positions on the native pixel grid. 4. Send related `edit_level` operations together with the revision returned by `get_level`. One batch is one undo step. For remote mutations, supply a unique `mutationId` when the live tool schema supports it. After a lost response, retry with exactly the same ID and arguments; do not generate a new ID for the same edit. Recent stale revisions can merge independent fields automatically. If a piece conflicts, read the level again and reconcile before retrying. Never overwrite a concurrent human edit blindly. 5. Use `slice_spritesheet` with exact row and column counts to turn an imported sheet into individual frames. Use `create_spritesheet` with ordered asset IDs and exact cell width, height, and columns to combine frames; keep empty cells transparent and verify the returned PNG grid. Never infer cell boundaries from visual spacing or resample frames. Use `place` with an existing asset ID; `block` for simple terrain; `update`, `duplicate`, `delete`, `order`, `crop`, or `rename` when appropriate. For colored blocks, first check whether the connected `edit_level` tool accepts a `color` property. If it does, convert the chosen hue, saturation, and brightness to `#RRGGBB` and pass `color` on `block` or in `update.changes`. If the live tool does not support color yet, explain that the site's newer Worker must be published; do not claim the block changed color. Set collisions deliberately: `solid`, one-way `platform`, climbable `ladder`, or non-colliding `decor`; `inset` lowers a piece's collision top. Unlock a locked piece before transforming or deleting it. 6. Set a reachable spawn and test important jumps with `simulate_player` routes totaling at most ten seconds per request. Max's base walk speed is 48 pixels/s, run speed 88 pixels/s, and full jump height about 27 pixels. Use `kind: "ladder"` on `block`, `place`, or `update` for climbable regions. Simulation segments accept `climb: -1` to ascend, `0` to hold and `1` to descend at 42 pixels/s. Jump or steer sideways to leave; check `end.climbing`, top and bottom exits, and solid ceilings. Treat simulation as a terrain test; it does not model enemies, gardening, or perks. 7. Show the result using the latest preview and report concrete changes and playtest outcomes. Use `undo_level` if a batch needs reverting. Turn on `set_play_mode` when the user wants to try it in the open editor. The connection belongs to one shared level. Its link can be revoked in Project → Agent → Disconnect and expires after seven days without a committed edit or chat activity. If tools report revocation or expiry, ask for a newly copied MCP URL. ## Artwork and asset workflows Check the live tool list before using newer workflows. Automatic image imports preserve original sources and recognize sprite-sheet structure. Use `inspect_sprite_sheet` before editing existing groups; prefer `group_workspace_sprites`, `edit_sprite_sheet` and `ungroup_sprite_sheet` for reversible reference-based edits without duplicating PNGs. Keep frame IDs, animation order, empty cells and shared origins. For level treatments, use `prepare_artwork` with current revision and optional objectIds and assetIds. Request includeImages only when handing the images to generation. Apply the returned PNG with `apply_artwork`, its requestId and the latest revision. Preserve the frozen framing and geometry; do not rebuild the level from the generated image. For individual assets or animation groups, use `prepare_asset_artwork` and `apply_asset_artwork` instead. Re-read and prepare a fresh request when the target layout changed. In the editor, artwork actions are under the collapsed Artwork menu: Select region, Use sheets, ChatGPT and Import artwork. Restore sketch and pending requests are in that same menu. Zoom is in the project menu. ## Figma and storage Project → Figma import / export → Download Figma kit includes the local Figma plugin and native components. Returned JSON includes the original base and edited project. Import changes preserves independent human and ChatGPT edits through a three-way merge; same-field conflicts keep the current project untouched. Preserve object IDs and original image sources. Open as new project keeps a conflicting version separate. Do not claim a downloaded Figma plugin was installed or tested in Figma unless that actually happened. Storage compaction and optional ImgBB image hosting are server-side. MCP still receives ordinary PNG data URLs and the same tool schemas; never replace a dataUrl argument with a hosted URL or send provider keys through tools. HTTP 503 or storage_unavailable means the provider is unavailable, not that the room link expired. Keep local work and stop rapid retries. Do not delete projects to work around a storage quota. Production stores new projects and sessions in a private revisioned Supabase database; ImgBB only hosts optional image data. Existing Blob records migrate when readable. If the server reports legacy_storage_unavailable, the old remote copy is inaccessible: on the device holding its cached project, use Projects → Save copy to cloud. This creates a separate saved project and preserves the original. After explicit recovery, connect the recovered project and copy its new MCP URL; never claim that the old connection now targets that new project. Other HTTP 503 errors call for a bounded retry, not recreating the level.