Contributing
How to work on the code, and how to add a new animation
DeskPets is a personal project, but changes are welcome. If you are unsure whether something fits, open an issue first.
Set up
You can work on DeskPets from Windows, macOS, or Linux. Everything goes through pixi, and the same commands work on all three. Don’t use bare python or pip.
pixi run -e pets pets # run the app
pixi run -e dev test # full test suite (about a minute)
pixi run -e dev test -m "not slow" # quick subset while editing
pixi run check # frame QA over every art sequenceOn a Linux machine without a desktop session (a server or a container), run the tests under a virtual display: xvfb-run -a pixi run -e dev test.
The main pixi environments are split on purpose: pets for the runtime, dev for the tests, build for packaging, and the default one for the art tools. The lockfile covers Windows, macOS (Apple Silicon and Intel), and Linux. After changing pixi.toml, run pixi lock so every system re-solves. Don’t add unnecessary runtime dependencies, and if a dependency is only for one system, put it in a target table (as pyobjc is for macOS) and mirror it into dev and build. A test checks this.
Every pull request runs the quick test subset on Windows, macOS (both chips), and Linux in GitHub Actions. A change has to pass on all four.
Ground rules
- Thresholds, intervals, and timings live in
src/config.pyor the atlas JSON, never inline in the UI code. - Telemetry stays on its worker thread. Don’t touch widgets or call
psutilfrom anywhere else. - System-specific code stays in
src/core/platform/(windows.py,macos.py,linux.py). Nothing else may importctypesor the macOS bindings, or checksys.platform. A test enforces this. If a widget needs something system-specific, add a hook to the platform seam with a do-nothing default, rather than anifin the widget. - A test that can’t run on some system is skipped with a reason, never deleted. The gates live in
tests/_env.py. - Input detection stays idle-time only. Don’t add a keyboard hook.
- Art revisions are additive. New art goes in a new
revision-NN/folder, and nothing is overwritten.
Add an animation
This is the full path for a new sequence, from prompt to a pet that plays it. Steps 2, 3, and 8 use local tools that aren’t published yet. See What is not in the repo. Until they are, open an issue and we can work out the packing together.
The art
- Generate the strip. Follow Generating sprites with Codex: eight equal slots on
#00FF00, at most five flat colors, Layla left and Chico right. - Clean it. Keep the green source. Make a transparent version, remove the green fringe on the edges, and keep both in
01-generated-sequence/. - Extract the frames into
02-extracted-frames/, one tight crop per frame. - Register the frames. Put each on a 320 × 320 canvas, with one shared scale for the whole sequence, the body midpoint at x = 160 (measured on the largest connected shape, so a detached glyph can’t skew it), and a ground baseline at y = 291. Airborne and rolling sequences keep their vertical motion.
- Look at it. Build a preview GIF and watch the loop. For a jump, check by eye that the frames genuinely leave the baseline, so the animation has a sense of lift. The automated check can’t judge that.
- Run the gate:
pixi run check <Sequence>. Fix anything that blocks (exit code 1), and review warnings by eye. - Write the spec in
04-integration-notes/:sequence-spec.jsonwith frame order, timings, loop behavior, and the registration used, plus a short README. Run the gate again once the spec exists. - Pack it into the atlas.
- Make a named backup of the current atlas PNG and JSON first.
- Scale the registered frames with nearest-neighbor sampling to 192 pixels wide, pad them to 192 × 208, and place them in the grid.
- Check that every other row is still pixel-identical, unused cells are transparent, and the hashes agree.
- Update the PNG and the JSON together.
- Validate the atlas:
pixi run -e pets pets --validate.
The code
- Name the state in
src/core/state_machine.py, and give it a priority there. If the art may not exist yet, add it toOPTIONAL_STATESso the app still starts without the row. - Add its card text to
STATE_PRESENTATIONinsrc/config.py: the title, subtitle, accent color, and glyph. - Decide what triggers it. Wire the rule into the state machine, or leave it unassigned so it is only reachable from the tray’s Poke the pets menu, like the sad animation today.
- Try it. Run
pixi run -e pets pets --demoto cycle through every available animation, and use Poke the pets in the tray. - Test it. Run
pixi run -e dev test. Add or update tests for the new state, and keep the existing ones passing. - Update the records. Add the sequence to the registry in
CLAUDE.mdandAGENTS.md, and to the table on Pets and states if it is visible to users.