| 1 | # The dot whale's core |
| 2 | |
| 3 | This package holds the source the Codewhale terminal draws its whale from, and |
| 4 | the conformance check for the Rust particle simulation used by the ambient |
| 5 | cameo. There is no companion process: each terminal draws the whale locally |
| 6 | from its own session (founder decision 290). |
| 7 | |
| 8 | ## What is here |
| 9 | |
| 10 | | Path | What it is | |
| 11 | | --- | --- | |
| 12 | | `src/core/dot-field.ts`, `dot-forms.ts`, `dot-body.ts`, `dot-pixel-body.ts` | The whale: activity, time and options in, 980 dots and their colours out. A pure function, with no clock or random numbers of its own. | |
| 13 | | `src/core/pet-engine.ts` | The reducer that turns a session's typed activity metadata into the activity the dot field draws. It accepts no prompt, reply or tool text. | |
| 14 | | `src/core/pet-telemetry.ts`, `signal.ts`, `model.ts`, `pet-sim.ts` | What the reducer imports: 400 ms activity buckets, the event model, and the TypeScript particle simulation. | |
| 15 | | `scripts/build-pet.mjs` | Type-checks the sources and writes the bundle the terminal embeds. | |
| 16 | | `scripts/build-dot-bodies.py` | Regenerates the two authored bodies from `public/whale.png` and `assets/pixel-whale.svg`. | |
| 17 | | `tape.tsv`, `tapes/`, `rs/`, `tui/`, `run-tape.ts`, `verify.sh` | Conformance between `pet-sim.ts` and the Rust simulation in `crates/tui/src/tui/ambient_life/pet_sim.rs`. | |
| 18 | |
| 19 | The terminal loads the bundle in an embedded QuickJS runtime |
| 20 | (`crates/tui/src/tui/pet_watch/dots.rs`) and reads two exports from it: |
| 21 | `PetDotField` and `PetEngineTelemetry`. |
| 22 | |
| 23 | ## Build and check |
| 24 | |
| 25 | Requires Node 22.13 or later. No network call, credential or provider is used. |
| 26 | |
| 27 | ```sh |
| 28 | npm --prefix pet ci --ignore-scripts |
| 29 | npm --prefix pet run check |
| 30 | ``` |
| 31 | |
| 32 | `check` type-checks the sources, regenerates the bundle in memory, fails if |
| 33 | the committed copy at `crates/tui/src/tui/pet_watch/pet-native.js` differs, and |
| 34 | runs the tests. After changing anything under `src/core`, regenerate the |
| 35 | committed copy: |
| 36 | |
| 37 | ```sh |
| 38 | npm --prefix pet run sync |
| 39 | ``` |
| 40 | |
| 41 | The bundle is committed so the Rust build needs no Node compiler. |
| 42 | |
| 43 | ```sh |
| 44 | cargo fetch --locked --manifest-path pet/tui/Cargo.toml |
| 45 | cd pet |
| 46 | ./verify.sh |
| 47 | ``` |
| 48 | |
| 49 | `./verify.sh` compares the TypeScript and Rust simulations checkpoint by |
| 50 | checkpoint and builds the small ratatui widget. It fails for a missing tool or |
| 51 | a failed build. |
| 52 | |
| 53 | ## What was removed |
| 54 | |
| 55 | The shared companion (`codewhale pet serve`), its HTTP protocol, sound, replay |
| 56 | recording and export, the browser appearance studio, source selection, the |
| 57 | session importer and the live recorder are gone. Files an older version left |
| 58 | under `~/.codewhale/pet-shared` are not read and are not deleted. |
| 59 | |
| 60 | ## Licence |
| 61 | |
| 62 | The signal model and telemetry bucketer come from Whalesong. Their Apache-2.0 |
| 63 | [license](LICENSE) and [notice](NOTICE) are retained. Rust files imported from |
| 64 | the product keep that repository's licence. |
| 65 |