# Speech kits

> List, describe, change, preview, copy, delete, export, import and manage prop images for speech bubble outfits (kits) through kit.*.

A speech kit is a pictured outfit for the speech bubble: its paper, tail, controls and ornaments drawn as pixel art. Residents wear one through `speech.kit` (one resident with `resident.set`, all residents with `settings.set`). The `kit.*` operations read, edit, preview, export and import the kits themselves. They are in the **Library** MCP group.

```sh title="Terminal"
pixling kit list
pixling kit describe steam
pixling kit set steam '{"for":"app","parts":{"gauge":{"visible":false}}}'
pixling kit preview steam.mine
```

The third line copies the built-in `steam` kit to the user's `steam.mine`, hides its `gauge` ornament there, and wears `steam.mine` for every resident. The last line writes a preview PNG under `importFolder.previews`.

## Kits and where they live

| `origin` | Kits | Changed by `kit.set` | `kit.delete` |
| --- | --- | --- | --- |
| `builtIn` | Shipped with Pixling (`note`, `quiet-card`, `steam`, `steam-metal`, `pocket-meter`, `postage-stamp`, `timber-plaque`, `glass-case`) | Copied to `<id>.mine` on the first change | Refused (`kitNotYours`) |
| `user` | The user's own: copies, duplicates and imports (the id holds a `.`) | In place | Deleted |

- **One copy per kit.** Every change made from a built-in kit lands in the same `<id>.mine`. A further copy comes from `kit.duplicate`.
- **A copy follows its kit.** `<id>.mine` stores only its changes (`derivedFrom` names the kit). When `kit.delete` removes a user kit that others were copied from, each copy first becomes a standalone kit that looks the same; if one cannot, nothing is deleted (`kitInUse`).
- **Stored locally.** Kits stay on the Mac. No call reaches the network.

## List and describe

`kit.list` takes no arguments and returns `{kits}`, one row a kit:

| Field | Meaning |
| --- | --- |
| `id` | What `kit`, `speech.kit` and `kit.*` name |
| `title` | The name the outfit tiles show |
| `origin` | `builtIn` or `user` |
| `derivedFrom` | The kit a copy changes, else `null` |
| `revision` | Changes whenever the kit or the kit it changes does |
| `motion` | `lively`, `reactive` (nothing loops at rest) or `still` (nothing moves) |
| `glassMax` | The most see-through the kit allows, else `null` |
| `notes` | Present only when the kit is read with something left out |

`kit.describe {kit}` returns the kit as it is drawn now:

| Field | Meaning |
| --- | --- |
| `parts` | One row a part: `id`, `role`, `takes`, `sheet`, `sheets`, `scale`, `visible`, `hidable`, plus placement fields where present |
| `colours` | Editable colors: `key`, `title`, `colour` (`#RRGGBB` or `null`) and `kitColour` |
| `textColour` | Effective text color (`#RRGGBB`) used for contrast checks |
| `sheets` | Sprite sheets in the kit: `name`, `width`, `height`, `frames`, `slicing` and `animations` |
| `presets` | Named sets of changes: `name`, `title` |
| `motion`, `forms`, `derivedFrom`, `revision` | As drawn; `forms` lists the kit's shapes for short or lone bubbles |
| `notes` | What reading it left out and why (empty when whole) |

A part hidden by a change is still listed, with `visible: false`, so it can be shown again. Each part's optional placement fields include `shown`, `anchor`, `pivot`, `x`, `y`, `layer`, `order`, `host`, `side` and `offset`.

## Change a kit

```json title="MCP request (pixling_kit_set)"
{
  "kit": "steam",
  "for": "app",
  "parts": {
    "gauge": { "visible": false },
    "valve": { "anchor": "topLeft", "x": 4, "y": -2, "layer": "top", "order": 30 }
  },
  "colours": { "brass": "#8FA3B0" }
}
```

```json title="MCP result"
{ "kit": "steam.mine", "forked": true, "worn": true }
```

| Argument | Takes |
| --- | --- |
| `kit` | Required. A kit id from `kit.list` |
| `parts` | Part id → part fields below, or `null` to drop that part's changes |
| `colours` | Color key → `#RRGGBB`, or `null` for the kit's own |
| `motion` | `lively`, `reactive` or `still` |
| `preset` | A preset name from `kit.describe`, applied before the rest of the call |
| `frameSpec` | Frame layout override (`nineSlice` or `modular`), or `null` to clear |
| `props` | Prop id (`a-z`, `0-9`, `.`, `-`, 1–32 chars) → prop object, or `null` to remove |
| `clearProps` | When `true`, removes all custom props before applying `props` |
| `surfaceMaterials` | Pixel-PBR finish per slot (`plate`, `frame`, `part:<id>`, `prop:<id>`), or slot `null` to clear |
| `for` | Where the kit written is worn: `app` (all residents' `speech.kit`) or one resident selector |

Give at least one field besides `kit` and `for`. The result is `{kit, forked, worn}`: `kit` is the kit written (the copy's id when the call copied a built-in kit), `forked` is `true` on that first change, and `worn` is `true` when the copy was worn where `for` says. A change to a user kit wears nothing new. Without `for`, the call only edits; wear the kit with `settings.set` or `resident.set`.

Over MCP, `for: app` needs the **App settings** group and `for: <resident>` the **Placement** group: with that group turned off, the call is refused with `toolFamilyOff` and `path: "for"`, and the same call without `for` still goes through.

### Part fields

| Field | Value | Parts that take it |
| --- | --- | --- |
| `visible` | `true` or `false` | Ornaments; `body`, `header`, `seat`, `tail` |
| `shown` | `always`, `hover` or `never` | Slots (`fold` is never hidden) |
| `sheet`, `scale` | A sheet name of the kit, a whole number | Every part but a painted `tail` |
| `anchor`, `pivot` | `topLeft`, `top`, `topRight`, `left`, `centre`, `right`, `bottomLeft`, `bottom`, `bottomRight` | Ornaments and slots |
| `x`, `y` | Dots from the anchor | Ornaments and slots |
| `layer`, `order` | `behind`, `paper`, `content` or `top`; a whole number (higher stands above) | Ornaments and slots |
| `side` | `wanted`, `top`, `left`, `bottom` or `right` | `tail` |
| `offset` | `wanted`, `centre`, `{"start": n}` or `{"end": n}` (dots from that end of the edge) | `tail` |
| `host` | `paper`, `header`, `history` or another slot's id | Slots |

Which fields a part takes is its `takes` in `kit.describe`. A field the part does not take, a part the kit does not have, a color that fails contrast checks, a reserved prop id, or a missing preset refuses the whole call with `kitRefused`, `path` naming it, and `reason` giving the rule or measured ratio. Nothing is written.

### Frame, props and materials

- **`frameSpec`** overrides how the paper frame is sliced (`nineSlice` with `insets`, or `modular` with corner/edge/center sheets). The tool input schema lists every field.
- **`props`** places custom prop art (`visual.sheet` referencing a `speech-props/<sha256>.png` asset imported via `kit.propImport`), with normalized `placement.anchor` (`{u, v}`), `layer` (`behindCard`, `onBackdrop`, `onFrame`, `overChat`), `zIndex`, `pointer`, `visibleWhen` conditions, and `hooks`. Reserved fixed part ids (such as `badge`, `paper`, `tail`) are refused.
- **`surfaceMaterials`** applies Pixel-PBR finishes per slot (`texture`, `metalness`, `roughness`, `bevel`, `lightMode`, `sampling` and rim settings), matching the schema of `kit.set`.

## Preview and prop images

- **`kit.preview {kit, mode?, text?, residentName?, width?, scale?, for?}`** renders a one-shot offscreen PNG of the kit into `importFolder.previews` (`kit-<id>-<mode>.png`) and returns `{kit, revision, mode, path, relativePath, width, height, logicalSize, paperRect, dot, propRects}`. `mode` is `message` (default) or `question`; `width` is `160`–`480` pt (default `248`); `scale` is `1` or `2` (default `2`).
- **`kit.propList`** lists imported prop images stored in `speech-props/` with their `sheet` (`speech-props/<sha256>.png`), `sha256`, `label`, `width`, `height` and `bytes`.
- **`kit.propImport {file, label?}`** copies a PNG from `importFolder.path` (bare file name, never a path; max 512×512 px, 65,536 dots) into the content-addressed prop store and returns `{sheet, sha256, label, width, height, bytes}`. Use `sheet` in `kit.set`'s `props` or `frameSpec`.

## Copy, delete, export and import

- **`kit.duplicate {kit, name?}`** copies any kit as a user kit and returns `{kit}` with the new id (`steam.copy`, then `steam.copy-2`). `name` is 1 to 60 characters. Without it, a copy of a built-in kit is named `<name> (copy)` and a copy of a user kit keeps its name.
- **`kit.delete {kit}`** deletes one user kit and returns `{kit, deleted: true}`. Residents that wore it keep the stored name and draw the plain speech bubble. It is annotated as destructive. If a copy made over it cannot stand alone looking the same, nothing is deleted (`kitInUse`).
- **Long ids.** A generated id (`.mine`, `.copy`, `.import`, `-2`) longer than 64 characters keeps the start of the kit's id and a short hash of it, the same every time.
- **`kit.export {kit, folder?, overwrite?, flatten?}`** writes any built-in (including `note`) or user kit into `importFolder.path/<folder>` (default `<kit>`) with `kit.json`, `parts/*.png` and any referenced `speech-props/<sha256>.png`. Use it to inspect a working `kit.json` before authoring a custom kit. Set `flatten: true` to materialize a derived copy as a standalone kit, or `overwrite: true` to replace an existing folder.
- **`kit.import {folder, replace?}`** imports a kit folder (`kit.json` and `parts/`) from `importFolder.path` by bare folder name, never a path. `sheets.*.bytes`/`sha256` and `sheets.*.attachment.bytes`/`sha256` may be omitted (Pixling computes them from the PNGs while enforcing size limits), and colors in `kit.json` accept `#RRGGBB`, `#RRGGBBAA` or `{red, green, blue, alpha?}` (0–255 integers). Pass `replace: true` to update an existing user kit atomically in place (`replaced: true`) instead of creating `<id>.import-2`.

## CLI: `pixling kit`

```sh title="Terminal"
pixling kit set steam.mine '{"colours":{"brass":"#8FA3B0"},"motion":"still"}'
pixling kit set steam.mine '{"parts":{"gauge":{"visible":false},"valve":null}}'
pixling kit preview steam.mine --mode message --text 'Hello!'
pixling kit export quiet-card quiet-card-src --flatten
pixling kit import quiet-card-src --replace
pixling kit prop-import badge.png
pixling kit prop-list
pixling kit duplicate steam --name 'Brass days'
pixling kit delete steam.copy
```

`kit set <kit> [input]` takes the same JSON patch object as MCP (`parts`, `colours`, `motion`, `preset`, `frameSpec`, `props`, `surfaceMaterials`, `for`) inline, from `@file.json`, or from standard input (`-` or piped), allowing multi-part edits in one call. `--json` prints the result document.

## Refusals

| `detail` | `code` | When |
| --- | --- | --- |
| `kitNotFound` | `targetNotFound` | No kit of that id |
| `kitNotYours` | `rejected` | `kit.delete` of a built-in kit |
| `kitRefused` | `rejected` | The kit refuses the change; `path` names the field, `reason` gives the rule or contrast ratio |
| `kitInUse` | `rejected` | `kit.delete` or `kit.import --replace` would break a copy derived from this kit |
| `residentNotFound` | `targetNotFound` | The resident in `for` left the desk during the call; nothing was written |
| `toolFamilyOff` | `rejected` | Over MCP, `for` names a group turned off (`path: "for"`) |
| `kitUnreadable` | `rejected` | The kit or imported folder cannot be read; `reason` names the field or file |
| `tooManyKits` | `rejected` | The user already has 64 kits |
| `folderNotFound`, `pathNotInImportFolder` | `rejected` | `kit.import`/`kit.export`/`kit.propImport` could not find the item, or received a path |
| `folderExists` | `rejected` | `kit.export` target folder already exists and `overwrite` is `false` |
| `fileNotFound`, `propInvalid`, `tooManyProps` | `rejected` | `kit.propImport` file is missing, not a valid PNG within limits, or prop store is full |
| `notReady` | `unavailable` | The desk is starting, or this build keeps no kits |
| `cannotWrite` | `internalFailure` | Writing failed; nothing changed |

Every refusal carries a `hint`. A resident named in `for` follows the usual selector and [binding rules](/docs/connect/own-a-resident/).

## Related

- [Resident settings](/docs/reference/resident-settings/): Wear a kit on one resident with resident.set speech.kit.
- [App settings](/docs/reference/settings/): Wear a kit on every resident with settings.set speech.kit.
