@zaisma/cli 0.70.0 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/skill/SKILL.md CHANGED
@@ -52,6 +52,7 @@ The building blocks, each optional:
52
52
  - **Rooms and a game server:** `Zaisma.joinRoom()` puts players in a room run by the game's server, which holds the official state and checks every move. It runs on Zaisma or on the developer's own server (`npx @zaisma/game-server@1`). Reference: `references/game-server.md`; how to make it hold up on a weak connection: `references/multiplayer.md`.
53
53
  - **Player accounts and passes:** guests play at once; `Zaisma.player.getPass()` gives a signed pass any server can check; a game can ask a guest to sign in with `Zaisma.player.signIn()`. Reference: `references/sdk.md`.
54
54
  - **Cloud saves:** a signed-in player's localStorage and IndexedDB follow them to every device with no code. `references/saves.md` says when and what to save.
55
+ - **Pieces:** shared building blocks a game is made from, so its effort goes into what makes it its own. `npx @zaisma/cli pieces add <name>` adds one with what it needs, never a second copy; `npx @zaisma/cli pieces --json` answers what each one gives, its settings and its hooks. A piece is changed through its settings and hooks, never its files. Anyone publishes pieces, for any engine. Reference: `references/pieces.md`.
55
56
  - **A database** for the game, from its game server: `query_database`, `batch_database`.
56
57
  - **Items and the buy sheet:** `set_item`, `Zaisma.items.buy()`, purchases delivered to the game or its server.
57
58
  - **Backgrounds:** an image or a shader behind Zaisma's glass on the game's page (`set_background`, `check_shader`).
@@ -90,6 +91,7 @@ Every name in the API, MCP, SDK and game server says what it holds, its kind and
90
91
  | `references/loading.md` (`zaisma://loading`) | The game is more than a few MB, or `performance_check` says its first frame is slow. |
91
92
  | `references/phones.md` (`zaisma://phones`) | The game should play on phones or tablets. |
92
93
  | `references/saves.md` (`zaisma://saves`) | The game keeps progress. |
94
+ | `references/pieces.md` (`zaisma://pieces`) | Adding a shared piece to the game, moving one to a newer version, changing one through its settings and hooks, or making a piece for other games. |
93
95
  | `references/sdk.md` (`zaisma://sdk`) | Writing code that calls `Zaisma.*` in the game. |
94
96
  | `references/game-server.md` (`zaisma://game-server`) | Writing the game server, running it on the developer's own server, or testing with play-locally. |
95
97
  | `references/errors.md` (`zaisma://errors`) | An error code isn't clear from its answer. |
@@ -917,7 +917,7 @@ A player sits in one of your game's rooms at a time, as on Steam: joining anothe
917
917
 
918
918
  Games and servers get the same with no key at `GET https://rooms.zaisma.com/v1/players/<player_id>` (open to any site, up to 300 a minute per address, answers cacheable for 5 minutes), and in games with `Zaisma.player.getProfile(playerId)`. A player pass proves only who the player is: an account's carries no name, so your server looks the name up there (the Node game server does it for you). It also says how an account's chat reaches, never its age: `who_reads_my_chat` (`friends`, `my_age_band` or `everyone`: the player's own choice; `nobody` while their chat is stopped), `chat_reading_enabled` (whether they read others' chat), an opaque `chat_group_id` (`chat_group_…`, their age band's, different in every game: only `everyone` crosses it), `network_seal` (their network, sealed for Zaisma's witness rule alone and different in every pass) and `who_can_chat`, v1's setting, still sent as a stricter stand-in for servers that don't read `who_reads_my_chat`; and its friends and blocks as opaque tags, never their player IDs: `player_tag_id` (its own, different in every game), `friend_player_tag_ids` (its friends', up to 200) and `block_player_tag_ids` (accounts it has a block with, either way, up to 100). Your server asks `passesAreFriends(first, second)`, `passesHaveBlockBetween(first, second)` and `canChat(first, second)` from `@zaisma/game-server` with two checked passes, before passing chat between them. Inside games, `Zaisma.friends.list()` gives a signed-in player their friends playing this game, with their rooms, and `Zaisma.friends.sendRequest(playerId)` offers a friend request that Zaisma asks the player about first, answering `{ status }`: `sent`, `cancelled`, `already_friends` or `not_taking_requests` (see "Friends in your game" in the README). A game never sees a request; two players who become friends get each other's tags in their next passes.
919
919
 
920
- In games, `Zaisma.player.getPass()` gives this tab's player and their pass (`{ id, name, kind, pass, expiresAt }`) to send to your own server. `Zaisma.invite(room)` opens Zaisma's invite sheet on the game page (the room's QR code, link and code), or on your own site the share sheet or a copied link; it works only right after the player taps or presses a key in the game, so call it from that tap's handler, and it fails with `error.code` `"needs_player_tap"` otherwise. It answers `"opened"`, or `"failed"` when the page couldn't open it; on your own site `"shared"` from the share sheet, `"copied"` the link, `"cancelled"` the share sheet, or `"failed"` (`InviteStatus`; treat a value you don't know as `"failed"`). A game that shows its own player list reads its room's players and draws it, with `room.mute`, `room.unmute`, `room.block` and `room.report` behind its own buttons; the Zaisma overlay keeps its own list for every game, and no call opens it. On touch screens the Zaisma button stays in the top right corner over your game and takes presses there, so keep that corner free of your own buttons on phones and tablets. The reference is `packages/sdk/zaisma.d.ts`, served beside the SDK as `_zaisma/v1.d.ts`.
920
+ In games, `Zaisma.player.getPass()` gives this tab's player and their pass (`{ id, name, kind, pass, expiresAt }`) to send to your own server. `Zaisma.invite(room)` opens Zaisma's invite sheet on the game page (the room's QR code, link and code), or on your own site the share sheet or a copied link; it works only right after the player taps or presses a key in the game, so call it from that tap's handler, and it fails with `error.code` `"needs_player_tap"` otherwise. It answers `"opened"`, or `"failed"` when the page couldn't open it; on your own site `"shared"` from the share sheet, `"copied"` the link, `"cancelled"` the share sheet, or `"failed"` (`InviteStatus`; treat a value you don't know as `"failed"`). A game that shows its own player list reads its room's players and draws it, with `room.mute`, `room.unmute`, `room.block` and `room.report` behind its own buttons; the guide keeps its own list for every game, and no call opens it. On touch screens the Zaisma button stays in the top right corner over your game and takes presses there, so keep that corner free of your own buttons on phones and tablets. The reference is `packages/sdk/zaisma.d.ts`, served beside the SDK as `_zaisma/v1.d.ts`.
921
921
 
922
922
  ### Chat
923
923
 
@@ -1358,7 +1358,7 @@ On your own server, the Node runner runs the same hooks. It needs `ZAISMA_KEY` s
1358
1358
 
1359
1359
  ### When Zaisma covers your game
1360
1360
 
1361
- Zaisma puts nothing over a running game by default, but the player can open one of its sheets (buying, Players, Report), and a card can come over the game's corner (Still there?, Keep your progress). The SDK says when, so a game can pause or hold its input:
1361
+ Zaisma puts nothing over a running game by default, but the player can open the guide beside it (the Z in the corner, or Shift Tab) or one of its sheets (buying, Report), and a notice can come along the game's top edge (Still there?, Keep your progress). The SDK says when, so a game can pause or hold its input:
1362
1362
 
1363
1363
  - `Zaisma.page.coveredBy` is `"sheet"` while one of Zaisma's sheets is open over the game: the player is busy with it, so pausing makes sense. While a sheet is open, Still there? waits, since the player is there.
1364
1364
  - `"card"` while one of its cards is over the game's corner: the game stays in view and playable.
@@ -1373,6 +1373,24 @@ Zaisma.page.on("coveredBy", (coveredBy) => {
1373
1373
  });
1374
1374
  ```
1375
1375
 
1376
+ ### The game's two calls on Zaisma's page
1377
+
1378
+ A game owns everything inside itself, in its own look: its menus, its rooms and codes, muting and kicking. Two things it can hand to the guide beside it:
1379
+
1380
+ - `Zaisma.page.openPlayerCard(playerId)`: Zaisma's player card for a player in the room the game is in, on that player's press in your game (a Card button on a scoreboard). It shows who they are, how the player knows them, Add friend, and Mute, Block and Report side by side. Only a player in the game's room, and only right after the player's own press, as `Zaisma.invite` does; anything else does nothing.
1381
+ - `Zaisma.page.leave()`: ends play from your own menu, after your own confirm. The player lands on the game's page, where the guide's Leave lands.
1382
+
1383
+ Each answers a promise; off Zaisma's page (your own site, a local test without a page) each fails with `not_on_zaisma`, and `openPlayerCard` with `bad_player_id` for something that isn't a player's id.
1384
+
1385
+ ```js
1386
+ cardButton.onclick = () => Zaisma.page.openPlayerCard(player.id);
1387
+ quitConfirm.onclick = () => Zaisma.page.leave();
1388
+ ```
1389
+
1390
+ ### Zaisma's own sound
1391
+
1392
+ The player sets one volume and a mute for every game in the guide's Settings, and a volume of their own for voices (`room.voice`), kept on their account. Zaisma applies them to the game's audio itself, Web Audio and audio and video elements alike, on top of the game's own settings: a game needs to do nothing, and a game's own volume slider keeps working within Zaisma's.
1393
+
1376
1394
  ## Selling with the buy sheet
1377
1395
 
1378
1396
  Players buy a game's priced items through Zaisma's buy sheet. The developer connects their own Stripe account (Stripe Connect Standard): they are the seller, every sale is a direct charge on their account, the money goes to them, and Zaisma takes no fee. Stripe's own fees apply. The sheet and the receipt show the account's `business_name` and `support_email`. Until an account is connected and can take payments, the sheet answers `stripe_not_connected` or `stripe_cannot_take_payments`, and setting a price answers `next_steps` pointing at `get_stripe_account`.
@@ -1694,7 +1712,7 @@ Before a build reaches testers, try its online play on your own computer: `npx @
1694
1712
  | `background` | landscape, 1.3 to 2.4 times as wide as tall | 3840 by 2160 | 1600 wide |
1695
1713
  | `phone_background` | portrait, 1.6 to 2.4 times as tall as wide | 1440 by 3120 | 1600 tall |
1696
1714
 
1697
- The cover is your game's card everywhere players browse: we show it alone, with no title over or under it, so put your game's name or logo on it. A square cover is optional and as wide as it is tall. The gallery is yours: any picture of the game, made or captured, with or without words on it, held only for safety and fake rewards like every picture; a listed game has at least one. Tag a capture of the game as it plays a screenshot (`is_screenshot`), and the game page shows the tag; players can report a picture tagged Screenshot that isn't one, and an upheld report counts against the account's standing. A share picture is optional: wherever a link to your game or one of its rooms is shared (chats, social sites, search results), it unfolds into a card with your share picture, or your cover when there isn't one, the game's title and "Play now in your browser." (a room link says "Join my match in" the title and "Tap to join in your browser."). It's landscape: 1200 by 630 shows best, and the card fits it inside that size. PNG, JPEG or WebP, checked from the file itself; SVG and other types are refused. Up to 10 MB, each kind at least its size above and at most 8,192 px on a side, one cover, one square cover, one share picture and up to 8 gallery pictures. Zaisma keeps each approved picture at the widths pages ask for, up to 3840, never wider than it is. Each image's `review_status` is `pending` until it's checked, usually within a minute, then shows at `https://zaisma.com/img/:id`; a newly approved cover replaces the old one of its kind. Until then only you can see it. One that isn't approved is `rejected`, with its `review_reason`.
1715
+ The cover is your game's card everywhere players browse: we show it alone, with no title over or under it, so put your game's name or logo on it. A square cover is optional and as wide as it is tall: it's your game's picture wherever a game is shown small (a player's card in the guide, a search's games), where a wide cover's title can't be read; without one, the middle of your cover shows there. The gallery is yours: any picture of the game, made or captured, with or without words on it, held only for safety and fake rewards like every picture; a listed game has at least one. Tag a capture of the game as it plays a screenshot (`is_screenshot`), and the game page shows the tag; players can report a picture tagged Screenshot that isn't one, and an upheld report counts against the account's standing. A share picture is optional: wherever a link to your game or one of its rooms is shared (chats, social sites, search results), it unfolds into a card with your share picture, or your cover when there isn't one, the game's title and "Play now in your browser." (a room link says "Join my match in" the title and "Tap to join in your browser."). It's landscape: 1200 by 630 shows best, and the card fits it inside that size. PNG, JPEG or WebP, checked from the file itself; SVG and other types are refused. Up to 10 MB, each kind at least its size above and at most 8,192 px on a side, one cover, one square cover, one share picture and up to 8 gallery pictures. Zaisma keeps each approved picture at the widths pages ask for, up to 3840, never wider than it is. Each image's `review_status` is `pending` until it's checked, usually within a minute, then shows at `https://zaisma.com/img/:id`; a newly approved cover replaces the old one of its kind. Until then only you can see it. One that isn't approved is `rejected`, with its `review_reason`.
1698
1716
 
1699
1717
  **What's checked.** No AI reads a game's covers, gallery pictures, title or description. A picture is approved as soon as image matching has checked it for known abuse material (when matching can't answer, a person looks, usually within a day); new words apply at once. These are the lines covers and titles keep, checked against what's visibly there, never taste; players report one that breaks them, and a person at Zaisma decides:
1700
1718
 
@@ -1881,7 +1899,7 @@ Files are stored once, by their SHA-256, and shared by every version that has th
1881
1899
  - Same rules as zips: `index.html` at the top, no hidden files, no pre-compressed `.gz` or `.br` files, only the file types games use. Up to 20,000 files per version and 500 MB per file, at any size per game: see Storage for what an account can keep. Up to 100 versions per game a day.
1882
1900
  - Each version is scanned. Image matching also checks the pictures stored inside engine packs (Godot `.pck`, `.glb`, `.data`, `.dat`, `.bin`, `.wasm`); one it can't read, like a GPU texture, isn't held for it. An update sends only new pictures and videos through image matching (one checked in the last 30 days isn't sent again), so it's checked in seconds however big the game is.
1883
1901
  - A version most of whose files another developer sent first (leaving out engines, libraries and asset packs many developers share) is held with `matches_another_developers_game` until a person looks, usually within a day; your own games never count. If it's your game on another account, or you have permission, say so with `message_zaisma`. When a person finds it's a re-upload, the original developer hears, with your username.
1884
- - One that passes waits as a draft with a private preview link for you and your AI, `https://zaisma.com/p/<secret>`, that works even while the game is a draft or private. Every call answers a fresh one, each working for a day (`preview_url_expires_at`); to show a version to anyone else, make a tester link. It opens the version inside the real game page, details first, then Play with the Zaisma overlay, as players will meet it; `https://zaisma.com/p/<secret>/game` opens the bare game alone, for quick test loops. Either way it plays at the game's fixed preview address, `https://<slug>--preview.zaismausercontent.com/`, so a game address never holds a key, and preview saves stay in that address's own browser storage, from one build to the next. A preview link doesn't join rooms: build and test multiplayer with `npx @zaisma/cli play-locally` (the same game server, SDK and game page, on your computer, with no review), and before release test it once on Zaisma's rooms through a tester link on a published version of the game while it's private (`add_tester_link` with `version_choice` `live`). That checks what only Zaisma's rooms have: the game server's CPU limits, real networks and regions, the chat filter, and rooms restarting under players.
1902
+ - One that passes waits as a draft with a private preview link for you and your AI, `https://zaisma.com/p/<secret>`, that works even while the game is a draft or private. Every call answers a fresh one, each working for a day (`preview_url_expires_at`); to show a version to anyone else, make a tester link. It opens the version inside the real game page, details first, then Play with the guide, as players will meet it; `https://zaisma.com/p/<secret>/game` opens the bare game alone, for quick test loops. Either way it plays at the game's fixed preview address, `https://<slug>--preview.zaismausercontent.com/`, so a game address never holds a key, and preview saves stay in that address's own browser storage, from one build to the next. A preview link doesn't join rooms: build and test multiplayer with `npx @zaisma/cli play-locally` (the same game server, SDK and game page, on your computer, with no review), and before release test it once on Zaisma's rooms through a tester link on a published version of the game while it's private (`add_tester_link` with `version_choice` `live`). That checks what only Zaisma's rooms have: the game server's CPU limits, real networks and regions, the chat filter, and rooms restarting under players.
1885
1903
  - A version can use only files you sent yourself: a file another developer sent counts as missing for you until you send it once too (storage still keeps one copy), so a file's hash neither gets someone else's file nor says whether Zaisma has it.
1886
1904
  - Publishing makes it the version players get. We keep the live version plus the last 5 that passed, for rolling back.
1887
1905
  - Drafts nobody publishes are deleted after 30 days, and files no version uses after a day. Held and rejected versions are kept.
@@ -1920,7 +1938,7 @@ A minute after a version passes the scan, Zaisma has opened it in headless Chrom
1920
1938
 
1921
1939
  ### Checking a game
1922
1940
 
1923
- Before uploading, the check says everything in a game that Zaisma would refuse, or that won't work inside Zaisma's game frame, each with how to fix it. It's the same check everywhere (`packages/cli/check.mjs`): `zaisma check <folder>` on a folder, with no key and nothing sent; the MCP's `check_game` with the same files as `upload_files`; and this call. `zaisma upload` runs it first.
1941
+ Before uploading, the check says everything in a game that Zaisma would refuse, or that won't work inside Zaisma's game frame, each with how to fix it. It's the same check everywhere (`packages/cli/check.mjs`): `zaisma check <folder>` on a folder, with no key and nothing sent; the MCP's `check_game` with the same files as `upload_files`; and this call. `zaisma upload` runs it first. The command leaves type files (`.d.ts`) out of what it checks and sends, since they never run: a piece carries one as its reference ([`docs/PIECES.md`](PIECES.md)).
1924
1942
 
1925
1943
  | Call | What it does |
1926
1944
  | --- | --- |
@@ -2032,6 +2050,12 @@ The files a version needed before its first frame in its run in Chrome are prelo
2032
2050
  | `zaisma saves restore <slug> <player_id> <save_copy_id>` | Make an earlier version the save again | `POST /games/:slug/saves/:player_id/copies/:id/restore` |
2033
2051
  | `zaisma export <slug> [--folder <folder>]` | Save everything about the game in a folder (`./<slug>-export` unless `--folder` says), with the database also as a ready `database.sqlite` | `GET /games/:slug/export/download` |
2034
2052
  | `zaisma skill [--folder <folder>] [--project] [--yes]` | Install the Zaisma skill into the AI tools on this computer, or update the copies it installed (see Teaching your AI) | none, it writes files on this computer |
2053
+ | `zaisma pieces [--folder <folder>]` | The game's pieces, the shared building blocks it's made from ([`docs/PIECES.md`](PIECES.md)): each one's name, version, kind, standard, licence and needs, its settings and hooks, where to import it from, and whether its files were changed by hand | none, it reads the game's folder |
2054
+ | `zaisma pieces add <source> [--folder <folder>] [--dry-run]` | Add a piece with what it needs: a folder, the `.tgz` that `npm pack` makes, or a name on npm with an optional range. A piece the game already has is left exactly as it is; a version that doesn't fit stops with both versions named and nothing added. A piece's code is never run | none, it writes the game's folder (a name is fetched from npm) |
2055
+ | `zaisma pieces update <name> [--version <range>] [--from <source>] [--discard-edits] [--folder <folder>] [--dry-run]` | Move one of the game's pieces to another version: only the one named, and only when everything else in the game accepts it | none, it writes the game's folder |
2056
+ | `zaisma pieces remove <name> [--discard-edits] [--folder <folder>] [--dry-run]` | Take one piece out of the game, unless another of its pieces needs it; what it needed and nothing needs now is named, never removed | none, it writes the game's folder |
2057
+ | `zaisma pieces newer [--folder <folder>]` | Which of the game's pieces have a newer version on npm, the newest the rest of the game accepts, and what holds it back; it changes nothing | none, it asks npm |
2058
+ | `zaisma pieces check <folder> [--fix]` | Check a piece you're making before you publish it: its `piece.json`, the files it lists, that every import is a listed file or a stated need, and the `package.json` beside it. `--fix` writes `piece.json.js` again from `piece.json` | none, it reads the piece's folder |
2035
2059
 
2036
2060
  - **Closed, like the API.** A command takes only its own flags and arguments: anything else is refused before anything is sent, with the flags it does take. Choices (`visibility`, `--screen`, `--kind`, `--category`, `--match-update-mode`) are checked first too, with the valid list. A flag that takes a value takes it as `--flag value` or `--flag=value`. Renamed commands and flags say their new name (`zaisma show` is now `zaisma visibility`; `--notes`, `--publish` and `--at` are `--patch-notes`, `--publish-when-approved` and `--scheduled-publish-at`).
2037
2061
  - **`--json` on every command** prints the API's answer as-is, compact, and nothing else on stdout: the same data the MCP gets. On failure it prints the API's `{ "error": { code, message, field, fix, message_for_people, retry_after_sec, help_url } }`, or the same shape without `message_for_people` for the command's own errors (below), where `field` is the flag (`--game`) or argument (`slug`) at fault. `upload --json` prints the version's last answer (`GET /games/:slug/versions/:id`) and sends its progress to stderr; `forum --json` with no topic or search prints both tabs' answers, as `{ "yours": …, "messages": … }`. Without `--json`, the command prints lines for people, and errors go to stderr as `zaisma: <message> <fix> (<code>)`.
@@ -2057,7 +2081,7 @@ Exit codes, the same for every command:
2057
2081
  | 3 | `held` | upload: the version is held for a person at Zaisma to look at, usually within a day. |
2058
2082
  | 4 | `rejected` | upload: the version was rejected. Its review_reason and findings say why and how to fix it. |
2059
2083
  | 5 | `still_scanning` | upload: the version was still being scanned after 10 minutes. Check it later with zaisma versions <slug>. |
2060
- | 6 | `problems_found` | check: something in the game won't work on Zaisma as it is, and the upload command doesn't fix it; or the shader doesn't compile, is too slow or flashes. The problems say what and how to fix it. |
2084
+ | 6 | `problems_found` | check: something in the game won't work on Zaisma as it is, and the upload command doesn't fix it; or the shader doesn't compile, is too slow or flashes; or pieces check: the piece wouldn't add or would break in a game. The problems say what and how to fix it. |
2061
2085
 
2062
2086
  Errors only the command answers with, beside the API's own codes (it also uses `unknown_field`, `missing_field`, `no_key`, `internal_error` and the `bad_<field>` codes of the choices it checks):
2063
2087
 
@@ -2091,3 +2115,20 @@ Errors only the command answers with, beside the API's own codes (it also uses `
2091
2115
  | `unexpected_answer` | Zaisma answered without JSON, like a page from a network in between. |
2092
2116
  | `skill_not_ours` | skill: a zaisma skill this command didn't install is already in that folder, so nothing was written; field names the folder. |
2093
2117
  | `install_not_confirmed` | skill: nothing was installed, since nobody answered the question: give --yes to install without it. |
2118
+ | `bad_piece_statement` | pieces: a piece's piece.json isn't one: field names what's wrong in it. |
2119
+ | `piece_statement_newer` | pieces: a piece's piece.json is written for a newer command than this one: run the newest. |
2120
+ | `bad_piece_source` | pieces: what was given isn't a piece's folder, its .tgz or a name on npm, or its archive can't be trusted. |
2121
+ | `piece_not_found` | pieces: there's no such piece or version where it was looked for. |
2122
+ | `piece_source_unreachable` | pieces: npm couldn't be reached, so nothing was changed. |
2123
+ | `piece_already_added` | pieces add: the game already has this piece at another version; a piece moves to another version only with pieces update. |
2124
+ | `piece_not_added` | pieces update, pieces remove: the game has no such piece. |
2125
+ | `piece_version_clash` | pieces: two pieces need versions of the same thing that don't overlap, so nothing was changed; the error says both versions and the ways out. |
2126
+ | `piece_need_unmet` | pieces: something a piece needs wasn't found, so nothing was changed. |
2127
+ | `piece_edited` | pieces update, pieces remove: the piece's files in the game were changed by hand; --discard-edits loses the edits. |
2128
+ | `piece_source_needed` | pieces update: the piece came from a folder or a .tgz, so --from must say where the new version is. |
2129
+ | `piece_not_updatable` | pieces update: a template is copied once and is the game's own. |
2130
+ | `piece_not_removable` | pieces remove: a template's files are the game's own. |
2131
+ | `piece_still_needed` | pieces remove: another of the game's pieces needs this one, so nothing was changed. |
2132
+ | `template_file_exists` | pieces add: a template would write over a file the game already has, so nothing was changed. |
2133
+ | `bad_pieces_record` | pieces: the game's pieces/pieces.json can't be read. |
2134
+ | `pieces_record_newer` | pieces: the game's pieces/pieces.json was written by a newer command than this one: run the newest. |
@@ -151,6 +151,7 @@ Every ID Zaisma makes says its kind in its value: `<kind>_<random>`, the kind in
151
151
  | `ncmec_report` (a report to NCMEC's CyberTipline; never shown outside Zaisma) | `ncmec_report_…` |
152
152
  | `admin_change` (a change the admin's AI asked for, waiting for the admin's passkey tap; never shown outside Zaisma) | `admin_change_…` |
153
153
  | `inbox_notice` (a notice in an account's inbox: from Zaisma, or a game the account follows) | `inbox_notice_…` |
154
+ | `room_invite` (a friend's invite into the room they're in, waiting in the other's bell for a day) | `room_invite_…` |
154
155
 
155
156
  `ID_KINDS` (`packages/core/src/ids.ts`) is this list, and a test keeps the two in step; a new kind is added to both in the same change. Accounts' and guests' player IDs are both `player_…`, in their passes and everywhere the SDK and game server show them; an account's never changes, and Zaisma's own account ID (the sign-in's) never leaves Zaisma. The developer API and MCP still name a game by its `slug`, the link name developers know. Not IDs, and kept as they are: a `slug`, a `room_code` (six letters players type), API keys (`zsk_…`, a format secret scanners know), connected apps' access and refresh tokens (`zat_…`, `zrt_…`), webhook signing secrets (`whsec_…`, Standard Webhooks' form) and file hashes (`sha256`).
156
157
 
@@ -284,6 +285,7 @@ One name per concept. The API and MCP column is snake_case; the SDK and game ser
284
285
  | A chat message: a line a player typed, sent with room.chat through the room to the players who may read it, after the game server's onChat and Zaisma's chat filter | `chat_messages` on a player report (`from_player_id`, the reported player's or `null`, `text`, `sent_at`); Zaisma's own code: `reports.reported_chat_json`, `ReportedChatMessage`, `REPORTED_CHAT_LIMITS` | `room.chat(text, { toPlayerIds })` answers `{ sentAt }` (`ChatSent`); the `chat` event's `ChatMessage`: `fromPlayerId`, `text`, `hasSwearing`, `hasSlur`, `sentAt`; game server `onChat(state, player, room, chatInfo)` with `ChatInfo` `{ text, toPlayerIds }`, answering a `ChatAnswer` (`true`, `false`, `{ toPlayerIds }`); option `adultChatFilterEnabled`; `CHAT_ROOM_LIMITS` (`maximumChatMessageCount`, `chatWindowDurationMs`); wire messages `chat`, `chat_sent`, `chat_stopped` with a `chatNumber`; error codes `chat_stopped` (with `reason`, `stopped_by_game` for onChat), `chat_not_allowed`, `chat_empty`, `chat_too_long`, `chat_too_fast`, `chat_not_here` |
285
286
  | Anyone under 18 types only where two independent players read it: who counts, and a player's network for it (never shown to a game) | Zaisma's own code: `CHAT_WITNESS_LIMITS` (`minimumWitnessCount`, `minimumWitnessAccountAgeDays`, `minimumWitnessCountedDayCount`), `isEstablishedWitness`, `independentWitnessCount`, `WitnessReader`; a network is `v4:<address>` or `v6:<the /56>` (`networkOfAddress`, `networkOf`, `sealNetwork`, `openNetworkSeal`); the filter's answer in rooms adds `readerPlayerIds` and `isEveryReaderNeeded` | player pass claim `network_seal`; `deliverChat`'s `isEveryReaderNeeded` |
286
287
  | Voice in a room: a player's voice going through Cloudflare's media server to the players who may hear it, by chat's rules; who hears whom is decided by Zaisma, never the game | `who_hears_my_voice` (`friends`, `my_age_band`, `everyone`, outside the presets, starting where `who_reads_my_chat` is), `voice_hearing_enabled`; a game's `microphone_enabled` (off by default: only then may its frame use the microphone; `bad_microphone_enabled`); `voice_size_bytes` and the meter share `voice`; Zaisma's own code: `VOICE_LIMITS`, `voicePulls`, `accounts.who_hears_my_voice`, `voice_sessions` | `room.voice` (`join`, `leave`, `setMicrophoneMuted`, `setSpeakerVolume(playerId, volumePct)`, `setSpeakerPan(playerId, panPct)`, `audioNodeOf`, `speakerPlayerIds`, `canTalk`), events `speaking` and `voiceSpeakers`; `room.canTalk`; `canVoiceChat(speaker, listener)`; errors `microphone_refused`, `voice_not_allowed`, `voice_unavailable`, `voice_not_here` |
288
+ | The guide: Zaisma's one panel about you on every page and beside every game, its places and the player card; Zaisma's own sound for every game; a friend's invite into a room | Zaisma's own code: `accounts.game_volume_pct`, `accounts.game_sound_enabled`, `accounts.voice_volume_pct` (`/guide/sound`), `room_invites` (`sender_account_id`, `recipient_account_id`, `sent_at_ms`, `shown_at_ms`; `/guide/invite`, its `server_url` for a room on the game's own server and its `invite_status`; error `bad_server_url`), the presence answer's `invites` (`sender_name`, `game_title`, `room_link_path`), the guide's inbox (`/guide/dismiss` with `inbox_notice_id`, its `inbox_notice_status` `archived`, error `no_inbox_notice`; `/guide/clear`, its `cleared_notice_count`), `GUIDE_PLACES`, `GUIDE_PAGES`, `zaismaGuide`, `zaismaSound` | `Zaisma.page.openPlayerCard(playerId)`, `Zaisma.page.leave()`; the page's messages `zaisma:open-player-card`, `zaisma:leave`, `zaisma:sound` (`gameVolumePct`, `isGameSoundOn`, `voiceVolumePct`) and `zaisma:sound-request` |
287
289
  | A voice group: the players who hear one another only, like a team or a squad's radio; heard speakers: whom one player hears, for proximity; how many voices a player hears at once, the loudest past it | | `room.setVoiceGroup(playerId, groupName)`, `room.setHeardSpeakers(listenerPlayerId, speakerPlayerIds)`, `room.setHeardSpeakerCount(count)`, `VOICE_ROOM_LIMITS` |
288
290
  | A voice channel: voice for players of a game on its own server, joined with a voice ticket the server signs with the game's ticket secret | `create_ticket_secret`, `ticket_secret`, `has_ticket_secret`; errors `voice_ticket_required`, `voice_ticket_refused`; Zaisma's own code: `games.sealed_ticket_secret` | `voiceTicket(playerPass, channelName, ticketSecret, voiceTicketOptions)`, `VoiceTicketClaims` (`ticket_kind` `voice`, `channel_name`, `voice_group_name`, `heard_speaker_ids`, `heard_speaker_count`), `room.voice.join({ ticket })`, `room.voice.updateTicket` |
289
291
  | A report's voice clip: the last 30 seconds of voice the reporter heard, from their game; only Zaisma hears it | Zaisma's own code: `reports.reported_audio_key`, `reportAudioKey` | `voiceClipBase64` on a report a game sends |
@@ -443,6 +445,12 @@ One name per concept. The API and MCP column is snake_case; the SDK and game ser
443
445
  | Whether a purchase, and its refund, reached the game, its game server or your own server | `handled_at` and `refund_handled_at` on a `purchase` (ISO time, `null` until then); `unhandled_purchases` (completed purchases not handled, and refunded or charged-back ones handled but not yet told, oldest first, at most 50 purchases and 50 refunds) in `get_player_items`; `mark_purchase_handled` (`POST …/purchases/:purchase_id/handled`); webhook events `purchase_completed` and `purchase_refunded` with `purchase` (`null` in every other event); errors `already_handled`, `handled_by_server` | `Zaisma.items.unhandled()` answers `Purchase[]` `{ id, itemName, itemKind, itemCount, purchaseSource, purchaseStatus, gameAccountId, paidMinorUnits, currencyCode, purchasedAt, refundedAt, receipt }`; `Zaisma.items.markHandled(purchaseId)`, errors `bad_purchase_id`, `no_purchase`, `already_handled`, `handled_by_server`, `slow_down` |
444
446
  | A purchase, or its refund, arriving at the game or its game server | | `Zaisma.items.on("purchase", listener)` and `Zaisma.items.on("refund", listener)` (`ItemsEvents`, `off` to stop), each listener gets a `Purchase`; `onPurchase(state, player, room, purchase)` and `onRefund(state, player, room, purchase)` on the game server (`Purchase`, `PurchaseHandling`, `purchaseHandling` on a `Transport`); the room message `{ type: "zaisma:purchase", purchaseId, receipt? }` the SDK sends to a game server's rooms after a purchase |
445
447
  | What a request to a game server can fail with | | `RequestErrorCode`: `bad_request`, `too_big`, `bad_pass`, `bad_player_token`, `account_needed`, `game_not_open_to_player`, `game_unavailable`, `no_request_handler`, `game_server_error`, `hosting_paused`, `rented_share_used`, `slow_down`, `bad_origin`, `busy` |
448
+ | A shared building block a game is made from, what it states about itself, its kind and the standard it's built on ([`docs/PIECES.md`](PIECES.md)) | in a `piece.json` (a piece's statement) and the upload command's answers: `statement_version_number`, `name`, `kind` (`foundation`, `extension`, `game_system`, `template`), `standard` (a name on npm), `summary`, `license`, `entry_path`, `server_entry_path`, `file_paths`, `server_file_paths`; where a game imports it from: `import_path`, `server_import_path`, `import_map`; a game's `standards` and `new_standards`; errors `bad_piece_statement`, `piece_statement_newer`, `bad_piece_source`, `piece_not_found`, `piece_source_unreachable`, `piece_already_added`, `piece_not_added`, `template_file_exists` | |
449
+ | A piece's version, apart from a game's (`version_id`), and a library's that isn't a piece | `piece_version`, `library_version` (semver, like `1.0.0`); `earlier_piece_version` and `earlier_library_version` on an update; `newest_piece_version`, `newest_accepted_piece_version`, `newest_library_version`, `newest_accepted_library_version` and `held_back_by_names` from `pieces newer`; errors `piece_source_needed`, `piece_not_updatable`, `piece_not_removable` | |
450
+ | What a piece needs and the versions it accepts | `needs`, each `{ name, version_range, kind }`, `kind` one of `piece`, `library`, `engine`; an answer's `kept_names` (left as they are), `engine_needs` (each `{ name, version_range, needed_by_name }`) and `no_longer_needed_names`; errors `piece_version_clash`, `piece_need_unmet`, `piece_still_needed` | |
451
+ | A piece's settings and hooks: everything a game changes it through | `settings`, each `{ name, value_kind, default_value, minimum_number, maximum_number, maximum_character_count, choices, summary }`, `value_kind` one of `number`, `integer`, `boolean`, `choice`, `text`, `color`, and `default_value` of the type `value_kind` names; `hooks`, each `{ name, hook_kind, summary }`, `hook_kind` one of `event`, `decision` | `@zaisma/piece`: `openPiece`, `openSettings`, `openHooks`; a piece's `settings` (`get`, `set`, `reset`, `values`, `list`, `onChange` with `{ name, newValue, earlierValue }`) and `hooks` (`on`, `off`, `list`), each name in camelCase (`jump_height_m` is `jumpHeightM`); the piece's own `tell`, `ask` and `refuse`; `PieceError` (`pieceName`, `code`, `field`, `fix`), its codes `unknown_setting`, `bad_setting`, `unknown_hook`, `bad_hook`, `wrong_hook_kind` |
452
+ | Where a game's piece came from, whether its files are as they were added, and the game's record of its pieces | `source_kind` (`folder`, `tarball`, `npm`), `files_sha256`, `is_edited`, `is_dry_run`; `pieces/pieces.json`: `record_version_number`, `pieces` (each `{ statement, source_kind, files_sha256 }`), `libraries`; errors `piece_edited`, `bad_pieces_record`, `pieces_record_newer` | |
453
+ | A maker's check of a piece before publishing it | `is_ready`, `problems`, each `{ code, problem_kind, message, path, fix }`, `problem_kind` `refused` or `note`; codes `bad_piece_statement`, `piece_statement_newer`, `missing_file`, `stale_statement_module`, `package_disagrees`, `unlisted_import`, `undeclared_need`, `file_not_uploadable`, `no_reference`, `no_readme` | |
446
454
  | What an error or a review reason is, and its other parts | `code`; `message`, `field`, `fix`, `retry_after_sec` (inside `error` only); `content_rule` (inside `review_reason` and `findings` only) | `code` (on the error only) |
447
455
 
448
456
  ## Adding a field, option or tool
@@ -0,0 +1,251 @@
1
+ <!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
2
+
3
+ # Pieces
4
+
5
+ A piece is a shared building block a game is made from: a body that already walks, input for every device, save and load, a sky, online play. A game adds the pieces it wants and spends its effort on what makes it its own. Every piece is optional, and no game is locked into any of them.
6
+
7
+ Pieces are open. Anyone publishes one, for any engine or kind of game. Zaisma's own are added, updated and checked exactly as a stranger's are: nothing in the command knows any piece, standard or publisher by name. Zaisma's are MIT licensed, in [`pieces/`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces).
8
+
9
+ This page is the frame every piece stands on: what a piece states about itself, how it's added to a game, how its versions move, and how its settings and hooks are opened.
10
+
11
+ ## The layers
12
+
13
+ | Kind | What it is |
14
+ | --- | --- |
15
+ | `foundation` | A standard everything else fits: a skeleton, a body, input, save and load, lighting, a networking core. |
16
+ | `extension` | Plugs into one foundation: a kind of sync, a camera style, a way to move, an ability. |
17
+ | `game_system` | A genre's part: a round timer, a combo counter, an inventory. |
18
+ | `template` | A genre's systems wired together, with no style of their own. It's copied into a game once and is then the game's own. |
19
+
20
+ ## Standards
21
+
22
+ Every piece names the **standard** it's built on, so pieces made to fit one set of foundations are never mistaken for pieces made to fit another. A standard is whatever its keeper says it is: a set of foundations for three.js, a base for Godot, a skeleton alone.
23
+
24
+ A standard's name is a name on npm, like `@studio/standard`. Two makers' standards can never share a name, and whoever holds the name on npm keeps the standard. A piece built on someone else's standard names it the same way; a small standard can be one piece, named after itself. Zaisma's are in [Zaisma's pieces](#zaismas-pieces): one standard among any that people publish.
25
+
26
+ Adding a piece built on a standard the game didn't have says so, plainly. Nothing stops it: a game chooses its pieces.
27
+
28
+ ## Adding pieces to a game
29
+
30
+ ```
31
+ npx @zaisma/cli pieces add @studio/dash-move # by its name on npm, the newest version
32
+ npx @zaisma/cli pieces add @studio/dash-move@^1.2 # or the newest within a range
33
+ npx @zaisma/cli pieces add ./my-piece # a piece's folder
34
+ npx @zaisma/cli pieces add ./my-piece-1.0.0.tgz # or the .tgz that npm pack makes of it
35
+ npx @zaisma/cli pieces add @studio/dash-move --dry-run # what it would bring, changing nothing
36
+ npx @zaisma/cli pieces # what the game has
37
+ ```
38
+
39
+ Run them in the game's folder (the one with its `index.html`, or its source for a game that's built), or give `--folder`. Each takes `--json`.
40
+
41
+ A piece's files go in `pieces/<name>/` with its `piece.json`, its game server files (when it has any) in `zaisma-server/pieces/<name>/`, where a game server on Zaisma can import them and players are never served them, and the game's record of its pieces in `pieces/pieces.json`. Commit all three.
42
+
43
+ **What adding does, always:**
44
+
45
+ - **What a piece needs is stated, and comes with it.** Every piece states what it needs and which versions it accepts; adding brings what's missing, and says what it brought.
46
+ - **Never a second copy.** A piece the game already has, at a version the new piece accepts, is left exactly as it is.
47
+ - **Never moved by itself.** A piece changes version only when you run `pieces update` for it.
48
+ - **A clash stops everything, plainly.** When the game has a version the new piece doesn't accept, nothing is added, and the error (`piece_version_clash`) says both versions and the two ways out: move the one in the game, or use a version of the new piece that accepts it. Two pieces being added that need versions of the same thing with no overlap stop the same way.
49
+ - **A library isn't doubled either.** A piece may need a library that isn't a piece (three.js). A game that has it in its own `package.json` uses its own; one outside the accepted range is a clash like any other. A game without it gets the library's browser files in `pieces/<library>/`, and the command prints the import map its page needs.
50
+ - **An engine is stated, never brought.** A piece for an engine that isn't a library on npm (Godot) says which versions it needs; the command says so and leaves the engine to the game.
51
+ - **A piece's code is never run.** Adding copies the files a piece lists and nothing else: no install scripts, no links, no path outside the game's folder. A piece from npm is checked against npm's own hash of it first.
52
+
53
+ **Using one:** import it from where it was added, as the command prints:
54
+
55
+ ```js
56
+ import { createDash } from "./pieces/@studio/dash-move/index.js";
57
+ ```
58
+
59
+ Each piece's `index.d.ts` is its reference, with every call, setting, hook and error explained, and its `README.md` shows it in use. An AI reads those two and never needs the piece's insides. `zaisma pieces --json` answers every piece's settings and hooks too.
60
+
61
+ **A page with no bundler** needs an import map before its scripts when a piece brought a library, so the pieces find it. `zaisma pieces` prints it:
62
+
63
+ ```html
64
+ <script type="importmap">{"imports":{"three":"./pieces/three/build/three.module.js"}}</script>
65
+ ```
66
+
67
+ **Uploading:** `zaisma check` and `zaisma upload` leave every `.d.ts` out of what they check and send, since type files never run. Uploading through the MCP's `upload_files`, leave them out the same way.
68
+
69
+ ## Moving a version
70
+
71
+ ```
72
+ npx @zaisma/cli pieces newer # what has a newer version on npm, and what holds it back
73
+ npx @zaisma/cli pieces update @studio/dash-move # move one to the newest
74
+ npx @zaisma/cli pieces update @studio/dash-move --version "^1.4"
75
+ npx @zaisma/cli pieces update @studio/dash-move --from ./dash-move-1.5.0.tgz # one that didn't come from npm
76
+ npx @zaisma/cli pieces remove @studio/dash-move
77
+ ```
78
+
79
+ - **A version moves when the game chooses,** one piece at a time: `pieces update` moves the piece named and nothing else. What its new version needs and the game lacks is brought; a piece the game has that it no longer accepts is a clash, with the ways out.
80
+ - **Only when everything else accepts it.** If another piece in the game needs a range the new version is outside, nothing moves, and the error names that piece. `pieces newer` shows this before you try: the newest version, the newest the rest of the game accepts, and which pieces hold it back.
81
+ - **Removing** takes one piece out, unless another needs it (`piece_still_needed`). What it needed stays: the answer names what no piece needs any more, for you to remove or keep.
82
+ - **A template is the game's own** once copied: it has no version to move and nothing to remove, and it no longer holds the versions of the pieces it brought.
83
+
84
+ ## Settings and hooks
85
+
86
+ **A piece is never edited by a game.** Everything a game would change is a setting or a hook, so the piece can move to a newer version and keep the game's changes. A super jump is a setting turned up while playing. If a game would have to copy a piece to change it, the piece is missing a hook: tell its maker.
87
+
88
+ Every piece states its settings and hooks in its `piece.json`, so they're read without opening its code:
89
+
90
+ - A **setting** is a number or an integer with its range, `true` or `false`, one of a few choices, text, or a colour, with a default. Every setting can be changed while playing.
91
+ - A **hook** is a point where the piece calls the game's code. An `event` tells the game something happened. A `decision` asks the game before something happens, and what the game answers is what happens.
92
+
93
+ Pieces written in JavaScript open them the same way, through [`@zaisma/piece`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/piece): a create call takes `{ settings, hooks }` beside its own arguments and gives back an object with `settings` and `hooks` on it.
94
+
95
+ ```js
96
+ const dash = createDash({ settings: { dashSpeedMPerSec: 18 }, hooks: { dashed: () => playWhoosh() } });
97
+
98
+ dash.settings.set({ dashCooldownSec: 0.2 }); // while playing
99
+ dash.settings.get("dashCooldownSec"); // 0.2
100
+ dash.settings.list(); // every setting: what it takes, its default, what it is now
101
+ dash.hooks.on("beforeDash", (dashDistanceM) => (isSlowed ? dashDistanceM / 2 : dashDistanceM));
102
+ ```
103
+
104
+ In code a name is in the language's own style (`dash_speed_m_per_sec` is `dashSpeedMPerSec` in JavaScript). A setting or hook the piece doesn't have is refused, with the ones it does have in the error's `fix`; so is a value outside what a setting takes.
105
+
106
+ `zaisma pieces` marks a piece whose files were changed by hand, and `pieces update` and `pieces remove` refuse to lose the edits until you say `--discard-edits`.
107
+
108
+ ## Zaisma's pieces
109
+
110
+ | Piece | Kind and standard | Gives | Needs |
111
+ | --- | --- | --- | --- |
112
+ | `@zaisma/piece` | `foundation`, its own small standard `@zaisma/piece` | How a JavaScript piece opens its settings and hooks, the same in every piece, in a browser and on a game server. A game never adds it by name: it comes with any piece that needs it. | nothing |
113
+
114
+ Zaisma's foundations are built on the standard `@zaisma/standard`; the skeleton and its animation names are a small standard of their own, `@zaisma/skeleton`, so another maker's standard can build on just that.
115
+
116
+ ## Making a piece
117
+
118
+ A piece is a folder with a `piece.json` at its top, its statement: what it is, the standard it's built on, what it needs, and its settings and hooks. The command, and anything else that lists pieces, reads only this.
119
+
120
+ ```json
121
+ {
122
+ "statement_version_number": 1,
123
+ "name": "@studio/dash-move",
124
+ "piece_version": "1.0.0",
125
+ "kind": "extension",
126
+ "standard": "@studio/standard",
127
+ "summary": "A dash for the character: a burst of speed with a cooldown.",
128
+ "license": "MIT",
129
+ "entry_path": "index.js",
130
+ "server_entry_path": null,
131
+ "file_paths": ["index.js", "index.d.ts", "piece.json.js", "README.md", "LICENSE.txt"],
132
+ "server_file_paths": [],
133
+ "needs": [
134
+ { "name": "@studio/body", "version_range": "^1.0.0", "kind": "piece" },
135
+ { "name": "@zaisma/piece", "version_range": "^1.0.0", "kind": "piece" },
136
+ { "name": "three", "version_range": ">=0.160.0 <1.0.0", "kind": "library" }
137
+ ],
138
+ "settings": [
139
+ { "name": "dash_speed_m_per_sec", "value_kind": "number", "default_value": 14, "minimum_number": 1, "maximum_number": 60, "maximum_character_count": null, "choices": null, "summary": "How fast a dash moves the character." },
140
+ { "name": "dash_cooldown_sec", "value_kind": "number", "default_value": 1.5, "minimum_number": 0, "maximum_number": 30, "maximum_character_count": null, "choices": null, "summary": "How long before the character can dash again." }
141
+ ],
142
+ "hooks": [
143
+ { "name": "before_dash", "hook_kind": "decision", "summary": "Asked before each dash with its distance in metres; answer another distance to change it, or 0 to stop it." },
144
+ { "name": "dashed", "hook_kind": "event", "summary": "Told when a dash ends." }
145
+ ]
146
+ }
147
+ ```
148
+
149
+ ### What a piece states
150
+
151
+ Every field is there every time, and an unknown one is refused, so a typo never passes quietly.
152
+
153
+ | Field | What it holds |
154
+ | --- | --- |
155
+ | `statement_version_number` | The format this file is written in: `1`. A command that meets a higher number says to run the newest command instead of guessing. |
156
+ | `name` | The piece's name, as npm takes them. |
157
+ | `piece_version` | Its version: three numbers, like `1.0.0`. Follow semver: a change that breaks games raises the first number. |
158
+ | `kind` | `foundation`, `extension`, `game_system` or `template`. |
159
+ | `standard` | The standard it's built on, by its name on npm ([Standards](#standards)). |
160
+ | `summary` | A sentence or two on what it gives a game, up to 400 characters. |
161
+ | `license` | The licence it's under, as SPDX names it: `MIT`, `Apache-2.0`. |
162
+ | `entry_path` | The file a game starts from (in JavaScript, the one it imports); `null` for a piece with only game server files. |
163
+ | `server_entry_path` | The file a game server imports; `null` for a piece with no game server files. |
164
+ | `file_paths` | Every file a game gets, each by its path inside the piece: forward slashes, nothing hidden (no part starting with a dot) and nothing in `node_modules`. The `piece.json` always comes too and isn't listed. A template's are copied into the game's own folder. |
165
+ | `server_file_paths` | Every file a game server gets. A file both sides share is listed in both. Empty for a template, whose game server files are the game's own, under `zaisma-server/` in `file_paths`. |
166
+ | `needs` | What it needs: each `{ name, version_range, kind }`. |
167
+ | `settings` | Its settings: each `{ name, value_kind, default_value, minimum_number, maximum_number, maximum_character_count, choices, summary }`. Empty for a template. |
168
+ | `hooks` | Its hooks: each `{ name, hook_kind, summary }`. Empty for a template. |
169
+
170
+ **A need** is `{ name, version_range, kind }`. `version_range` is a semver range like `^1.0.0`, `>=0.160.0 <1.0.0` or `1.x || 2.x`. `kind` says what it is:
171
+
172
+ | Need `kind` | What it is |
173
+ | --- | --- |
174
+ | `piece` | Another piece, by its name. Brought when the game lacks it. |
175
+ | `library` | A library on npm that isn't a piece. The game's own is used when its `package.json` has one; else its browser files are brought. |
176
+ | `engine` | An engine that isn't a library on npm, by its name in lowercase (`godot`). Stated to the developer, never brought or checked. |
177
+
178
+ **A setting** names what it holds and its unit, in lowercase with underscores ([`docs/NAMING.md`](naming.md)): `jump_height_m`, `shadows_enabled`. Its `value_kind` says what it takes, and the fields that don't apply to that kind are `null`:
179
+
180
+ | `value_kind` | `default_value` | Also given |
181
+ | --- | --- | --- |
182
+ | `number` | a number | `minimum_number` and `maximum_number`: every number has a range |
183
+ | `integer` | a whole number | `minimum_number` and `maximum_number` |
184
+ | `boolean` | `true` or `false` | |
185
+ | `choice` | one of `choices` | `choices`: 2 to 50 lowercase words |
186
+ | `text` | text | `maximum_character_count` |
187
+ | `color` | six hex digits in lowercase, like `"#3fa9f5"` | |
188
+
189
+ A setting can be changed while playing. What can only be given once, when the piece is made, is an argument of its create call instead, explained in its reference.
190
+
191
+ **A hook** is `{ name, hook_kind, summary }`, `hook_kind` being `event` (the piece tells the game) or `decision` (the piece asks, and the game's answer is what happens). What a hook is called with is in the piece's reference.
192
+
193
+ ### Its code
194
+
195
+ What makes a piece good to build on:
196
+
197
+ - **Files that run as they are,** with no build step. In JavaScript: plain ES modules that import the piece's own files, its needs, and nothing else.
198
+ - **Needs imported from where a game has them.** A game holds `@studio/dash-move` at `pieces/@studio/dash-move/`, so from there a piece of the same scope is `../body/index.js`, one of another scope `../../@zaisma/piece/index.js`, and one with no scope `../../round-timer/index.js`. A library is imported by its name (`three`).
199
+ - **One statement.** A JavaScript piece reads its own settings and hooks from `./piece.json.js`, the statement as a module, and opens them with `@zaisma/piece` (its [README](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/piece/README.md) shows how). List `piece.json.js` in `file_paths`; `zaisma pieces check <folder> --fix` writes it from `piece.json`, and a piece whose two disagree is refused.
200
+ - **An `index.d.ts`** with every call, setting, hook and error explained and an example: it's what an AI reads.
201
+ - **Closed inputs and plain errors:** an unknown setting or argument is refused, and every error has a stable `code`, the `field` at fault and a `fix`.
202
+ - **Names that say what they hold** ([`docs/NAMING.md`](naming.md)).
203
+ - **No file without an extension** in a piece for a game whose folder is uploaded as it is: Zaisma's upload takes none, so a licence travels as `LICENSE.txt`.
204
+
205
+ ### Check and publish
206
+
207
+ ```
208
+ npx @zaisma/cli pieces check ./my-piece # before publishing
209
+ npx @zaisma/cli pieces check ./my-piece --fix # and write piece.json.js again from piece.json
210
+ ```
211
+
212
+ The check reads the statement and the files it lists, and runs nothing. It ends with exit code 6 when the piece wouldn't add or would break in a game:
213
+
214
+ | Problem | Kind | What it found |
215
+ | --- | --- | --- |
216
+ | `bad_piece_statement` | refused | The piece.json isn't one: the message names the field. |
217
+ | `piece_statement_newer` | refused | The piece.json is written for a newer command than this one. |
218
+ | `missing_file` | refused | The piece.json lists a file that isn't there, or the file is a link. |
219
+ | `stale_statement_module` | refused | piece.json.js isn't piece.json as a module any more; --fix writes it again. |
220
+ | `package_disagrees` | refused | The package.json beside it has another name or version, or leaves a listed file out of what npm packs. |
221
+ | `unlisted_import` | refused | A file imports a file of the piece's own that the piece.json doesn't list, so a game wouldn't get it. |
222
+ | `undeclared_need` | refused | A file imports another piece or a library that isn't in needs. |
223
+ | `file_not_uploadable` | note | A file is of a type Zaisma's upload doesn't take, so a game whose folder is uploaded as it is can't hold the piece. |
224
+ | `no_reference` | note | The file a game imports has no .d.ts beside it: it's what an AI reads to use the piece without opening its code. |
225
+ | `no_readme` | note | There's no README.md among the piece's files. |
226
+
227
+ Publish it with `npm publish`, its `package.json` giving the same name and version as its `piece.json` and packing every file it lists; anyone adds it by name. A piece that isn't on npm is added from its folder or its `.tgz`.
228
+
229
+ ## Errors
230
+
231
+ The command's errors, each with a `fix`:
232
+
233
+ | Code | What happened |
234
+ | --- | --- |
235
+ | `bad_piece_statement` | A piece's `piece.json` isn't one: `field` names what's wrong in it. |
236
+ | `piece_statement_newer` | A piece's `piece.json` is written for a newer command than this one: run the newest. |
237
+ | `bad_piece_source` | What was given isn't a piece's folder, its `.tgz` or a name on npm, or its archive can't be trusted. |
238
+ | `piece_not_found` | There's no such piece or version where it was looked for. |
239
+ | `piece_source_unreachable` | npm couldn't be reached, so nothing was changed. |
240
+ | `piece_already_added` | `pieces add`: the game already has this piece at another version; a piece moves to another version only with `pieces update`. |
241
+ | `piece_not_added` | `pieces update`, `pieces remove`: the game has no such piece. |
242
+ | `piece_version_clash` | Two pieces need versions of the same thing that don't overlap, so nothing was changed; the error says both versions and the ways out. |
243
+ | `piece_need_unmet` | Something a piece needs wasn't found, so nothing was changed. |
244
+ | `piece_edited` | `pieces update`, `pieces remove`: the piece's files in the game were changed by hand; `--discard-edits` loses the edits. |
245
+ | `piece_source_needed` | `pieces update`: the piece came from a folder or a `.tgz`, so `--from` must say where the new version is. |
246
+ | `piece_not_updatable` | `pieces update`: a template is copied once and is the game's own. |
247
+ | `piece_not_removable` | `pieces remove`: a template's files are the game's own. |
248
+ | `piece_still_needed` | `pieces remove`: another of the game's pieces needs this one, so nothing was changed. |
249
+ | `template_file_exists` | `pieces add`: a template would write over a file the game already has, so nothing was changed. |
250
+ | `bad_pieces_record` | The game's `pieces/pieces.json` can't be read. |
251
+ | `pieces_record_newer` | The game's `pieces/pieces.json` was written by a newer command than this one: run the newest. |
@@ -236,7 +236,7 @@ const server: Server;
236
236
 
237
237
  ```ts
238
238
  /**
239
- * Invite friends. On Zaisma it opens Zaisma's invite sheet, the same as the Zaisma overlay's Share: the
239
+ * Invite friends. On Zaisma it opens Zaisma's invite sheet, the same as the guide's Share: the
240
240
  * room's QR code, link and code, Copy and the share sheet ("opened", or "failed" when the page couldn't
241
241
  * open it). On your own site it opens the share sheet on phones, otherwise copies the room's invite link
242
242
  * (the game's page without a room). Call it from a button in your game, like on a "waiting for players"
@@ -346,7 +346,7 @@ const versions: Versions;
346
346
  ```ts
347
347
  /**
348
348
  * Whether Zaisma's page covers the game right now, so a game can pause or hold the player's input while it does.
349
- * coveredBy is "sheet" while one of Zaisma's sheets is open over the game (buying, the Zaisma overlay, Report: the player is
349
+ * coveredBy is "sheet" while one of Zaisma's sheets is open over the game (buying, the guide, Report: the player is
350
350
  * busy with it), "card" while one of its cards is over the game's corner (Still there?, Keep your progress; the
351
351
  * game stays in view and playable), and null otherwise. Always null outside Zaisma's page (your own site, a
352
352
  * local test). Listen for "coveredBy" to hear each change.
@@ -761,10 +761,26 @@ interface ItemForSale {
761
761
  ### Page
762
762
 
763
763
  ```ts
764
- /** Whether Zaisma's page covers the game ({@link page}). */
764
+ /** Whether Zaisma's page covers the game ({@link page}), and the game's two calls on it. */
765
765
  interface Page {
766
766
  /** "sheet", "card" or null: what of Zaisma's is over the game now. Read-only. */
767
767
  readonly coveredBy: CoveredBy;
768
+ /**
769
+ * Opens Zaisma's player card for a player in the game's room, on that player's press in your game (a Card button on a scoreboard): who they are, how
770
+ * the player knows them, Add friend, Mute, Block and Report. Only a player in the room the game is in; the guide beside the game shows it. It opens
771
+ * only right after the player's own press, as Zaisma.invite does: called at any other time, nothing opens.
772
+ * Fails with error.code "bad_player_id" for something that isn't a player's id, and "not_on_zaisma" off Zaisma's page.
773
+ * @example
774
+ * cardButton.onclick = () => Zaisma.page.openPlayerCard(player.id);
775
+ */
776
+ openPlayerCard(playerId: string): Promise<void>;
777
+ /**
778
+ * Ends play from the game's own menu, after its own confirm: the player lands on the game's page, where the guide's Leave lands. Fails with
779
+ * error.code "not_on_zaisma" off Zaisma's page, where the game ends play its own way.
780
+ * @example
781
+ * quitConfirm.onclick = () => Zaisma.page.leave();
782
+ */
783
+ leave(): Promise<void>;
768
784
  /** Listen for "coveredBy": called with the new value each time it changes. A wrong name fails with error.code "unknown_event". */
769
785
  on(event: "coveredBy", listener: (coveredBy: CoveredBy) => void): Page;
770
786
  off(event: "coveredBy", listener: (coveredBy: CoveredBy) => void): Page;