--- name: edgegap-chat-canvas description: 'Chat canvases + Edgegap: make a browser game written in a chat app as one HTML file (a Claude artifact, a ChatGPT file or canvas, a Gemini Canvas) online multiplayer on Edgegap, one authoritative server per match with an optional matchmaker, while the file still plays in the chat preview. Load this when someone made, or wants to make, a game with Claude, ChatGPT or Gemini in the chat (artifact, canvas, "single HTML file it wrote") and wants online play, friends joining, Find Match or real servers, or asks how to prompt so the game can go online later. Has the prompt that keeps every rule between /* RULES:BEGIN */ and /* RULES:END */ markers, checks and fix prompts, getting the file out of each chat, a split script (block to an ES module for the server, CI sync check), the online page, a direct ?server= path, CI image build, tests. Verified samples: netcode-sample-claude-star-snatch, -chatgpt-turf-painters, -gemini-bomb-tag. Grok: edgegap-grok; other AI tools: edgegap-vibe-coded.' metadata: version: "0.3.3" --- # Edgegap for chat-canvas games: the chat writes one HTML file, Edgegap runs the matches A chat app (a **Claude artifact** on claude.ai, a **ChatGPT** file or canvas on chatgpt.com, a **Gemini Canvas** on gemini.google.com) produces a game as **one HTML file** that plays in the chat's preview. That shape is the whole problem: the server needs the rules as a module of their own, and the preview needs everything in one file. The answer is to ask for the rules between two exact marker lines and copy that block out with a script. The file keeps playing in the chat and can go back into the chat for more changes; the server runs the identical rules. ``` chat app ──writes──> artifact/.html (one file, solo vs bots, plays in the preview) │ /* RULES:BEGIN */ ... /* RULES:END */ tools/split-artifact.mjs ──copies the block──> client/rules.js (ES module, generated, checked in CI) │ page ──?server= or Find match──> Edgegap ──> one Node.js server per match: runs rules.js at 60 Hz, <──────────── wss://.pr.edgegap.net: ── fills seats with bots, stops itself after the match ``` **Verified on Edgegap** with [netcode-sample-claude-star-snatch](https://github.com/edgegap/netcode-sample-claude-star-snatch) (2026-11-20; tags `before` = Claude's artifact unchanged, then the online work on `main`): Claude (Opus 5.5, default settings) wrote Star Snatch from one prompt as a published artifact that played in the preview; the split script produced the server's rules with no hand edits to the block; two browser tabs joined one Edgegap deployment through `?server=` and played a match, and the server stopped itself; through the matchmaker, two headless players and then two browser tabs clicking Find match were put on one deployment in about 15 s, and it stopped itself 11 s after the match. [references/star-snatch.md](references/star-snatch.md) has the run, file by file. - ChatGPT, [netcode-sample-chatgpt-turf-painters](https://github.com/edgegap/netcode-sample-chatgpt-turf-painters) (2026-11-20, Free plan, default model): ChatGPT wrote Turf Painters as one HTML file with the markers on the first try, but its bots never moved and its `createWorld()` added the players itself; one follow-up prompt fixed both (tag `before` is the fixed file, the commit before it ChatGPT's first). The split needed no edits to the block. Direct `?server=` (two tabs, self-stop 96 s after start) and the shared matchmaker (end-to-end test PASS, two tabs with Find match on one deployment, self-stop within about 30 s of both leaving). [references/chatgpt.md](references/chatgpt.md). - Gemini Canvas, [netcode-sample-gemini-bomb-tag](https://github.com/edgegap/netcode-sample-gemini-bomb-tag) (2026-11-20, free account, model picker on Auto, the Canvas tool): with the prompt that already asks for an empty `createWorld()`, a start spot per `addPlayer()`, `setInput()` for every player and bots driven inside `step()`, Gemini's first answer was right: no fix prompt. Direct `?server=` (two tabs, self-stop) and the shared matchmaker (end-to-end test PASS, two tabs with Find match on one deployment, self-stop about 20 s after both left). [references/gemini.md](references/gemini.md). Each chat has its own way of handing over the file; Phase 0 step 5 covers all three. ## Who you are talking to Often someone who made a game by chatting and has never run a server. Speak in outcomes ("each match gets its own server near its players and shuts down when the match ends, so you pay only while people play"), do the engineering yourself, and hand over only the account steps (registry secrets in GitHub, creating the matchmaker). Keep the prompts in `PROMPTS.md`: they are how the game gets changed later in the chat. ## Phase 0: Get a game whose rules can leave the file 1. **Game fit** (`edgegap-vibe-coded` Phase 0 table): drift, pushing, collecting, slow projectiles and turn-based play feel fine with no client prediction; precise platforming, rhythm and instant-hit aiming do not. Change the idea before the chat writes it. 2. **New game: prompt with the markers.** Use the prompt in [references/prompts.md](references/prompts.md) §1c: it is the §1 prompt plus the four server requirements learned from the ChatGPT run, and it worked first time in Gemini Canvas. In ChatGPT start with "Use canvas." (§1b); in Gemini pick **Canvas** under **+**. The gameplay sentences are the developer's; the architecture part stays word for word: every rule between the exact lines `/* RULES:BEGIN */` and `/* RULES:END */`, nothing from the browser inside, no `export`, a plain-data world, the six functions (`createWorld`, `addPlayer`, `removePlayer`, `setInput`, `step` returning events, `botInput` from positions only). 3. **Existing artifact without markers:** ask the chat to restructure it with prompt §2 (same file, same look, rules moved into the block). Check the game still plays in the preview before going on. 4. **Play it, then check three things before saving** (ChatGPT's first Turf Painters file failed two of them): the bots move in the preview; `createWorld()` returns a world with no players and `addPlayer()` gives each new player its own start spot, so a server can add any ids; `step()` either drives the bots itself or the page feeds them `botInput()` through a `setInput()` that accepts bots. If one fails, send prompt §3 in [references/prompts.md](references/prompts.md) rather than editing the block. 5. **Get the file out**, unchanged, as `artifact/.html` in a new git repo; commit and tag `before` (commit the chat's first file before it if a fix prompt was needed, so the history shows both). - **Claude:** open the artifact, then download it or copy its code. If you drive claude.ai from a browser tool, reading the artifact through Claude's own artifact tools (when the agent has them) returns the exact file; copying from the rendered page does not. - **ChatGPT:** the answer is a file card (**Open** shows the preview, which has a download button) or a canvas. Ask for "the complete HTML file in one code block" in the same message and use **Copy code**: in the verified run, the download button of the fixed file did nothing and ChatGPT no longer had the file one message later (uploading the first file back and asking again worked). A browser tool's page-text read can be filtered; the clipboard after **Copy code** is exact. - **Gemini Canvas:** **Export > Download code** in the Canvas toolbar saves the HTML file in one click (verified); **Code** shows the source. - Record the model and plan shown in the chat in `PROMPTS.md`, with every prompt verbatim. ✅ Check: the file plays solo in the chat preview with moving bots, and `grep -c "RULES:BEGIN\|RULES:END" artifact/.html` prints `2`. ## Phase 1: Split, server, online page, local tests 1. **Split.** Copy [assets/split-artifact.mjs](assets/split-artifact.mjs) to `tools/`, then `node tools/split-artifact.mjs artifact/.html --page`. It writes `client/rules.js` (the block + `export { ...every top-level name }`) and, once, `client/index.html` (the artifact with the block removed and its `