Edit a game's files in a workshop
klyo_game_patchEdits a game's text files (html, htm, js, mjs, css, json, svg, txt, xml, webmanifest) without a ZIP. Target: a game's slug or a waiting-room package's upload_id. The first edit opens a WORKSHOP: a copy of the game next to the version players have, with its own preview address. Players keep playing the previous version until you release the new one (klyo_release_version for a game, klyo_publish_game for a package); the owner sees it in the studio as “New version waiting”. Each item of edits has a path and one of three: old_string with new_string (an exact fragment that must occur once, or add replace_all), content (the whole file or a new file), or delete: true. For a file that exists, pass expected_hash from klyo_game_files: if someone changed the file in the meantime you get a conflict and nothing is saved. The changes of one call are applied all or none. Every changed file goes through the klyo check (malicious code, third-party ads, nothing from outside klyo), and the whole game once more before release. Send an image, sound, font or large file (up to 20 MB) with the ticket from klyo_upload_package and reference it in the edit with from_upload (no base64). GAME FROM SCRATCH: nowa (plansza, zrecznosciowa, logiczna) instead of a target creates a package from the Klyo Kit skeleton and applies edits right away; the response carries upload_id. UNDO: before every edit a checkpoint auto-N is created (it is in the response); revert goes back to it or to a named checkpoint, discard abandons the whole workshop for good; players see none of this. Limits: a file from content up to 1 MB, a call up to 256 KB and 20 edits, 3 open workshops per account; a workshop with no changes for 7 days expires, and the version players have stays untouched.
Examples: • Change the board colour in style.css of my game czworki • In js/gra.js of slice-rush change the speed from 4 to 6 • Add a levels.json file with three levels to the package in the waiting room
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nowa | No | A game from scratch, without a ZIP: in the same call a package is created from the Klyo Kit skeleton (as in klyo_game_scaffold) and `edits` change it right away (you overwrite skeleton files without `expected_hash`). The response carries `upload_id` for the next calls. Instead of `slug` and `upload_id`. Values: `plansza` (board game with turns), `zrecznosciowa` (arcade), `logiczna` (puzzle). | |
| slug | No | Game address (from klyo_my_games). Give this or `upload_id`. | |
| edits | No | Changes; applied all or none. Each: `path` and one of three: `old_string` with `new_string`, `content` or `delete: true`. | |
| revert | No | Return the workshop to a checkpoint (`auto-N` from an edit response or a name from `checkpoint`; the list is in klyo_game_files). Stands alone, without `edits`. The state before the revert is saved as a checkpoint too. Players see nothing: this is not a release rollback. | |
| discard | No | Abandon the workshop: the game loses the waiting version from the workshop (the version players have is untouched), a package returns to the files from its ZIP. Stands alone, without `edits`. | |
| upload_id | No | A waiting-room package, when there is no game yet; klyo_publish_game later releases it with these edits. | |
| checkpoint | No | A named workshop checkpoint (for example premium-ui-v1): a snapshot of the state BEFORE the changes of this call; may stand alone, without `edits`. An automatic `auto-N` checkpoint is created before every edit anyway. |