Skip to content

✨ feat: split into engine, apps and CLI packages - #2

Open
vtempest wants to merge 1 commit into
masterfrom
claude/fervent-edison-g0r21w
Open

vtempest wants to merge 1 commit into
masterfrom
claude/fervent-edison-g0r21w

Conversation

@vtempest

Copy link
Copy Markdown
Collaborator

Automate-Automata was one SvelteKit app with the simulation living inside a 612-line Svelte component. This splits it into a Bun workspace: an engine anyone can depend on, a UI layer, and three ways to run it — web, Android and the terminal.

Packages

npm what it owns
packages/complexity-automata complexity-automata The engine. No DOM, no timers, no dependencies.
packages/complexity-automata-cli complexity-automata-cli The terminal animation (automata).
packages/complexity-automata-svelte complexity-automata-svelte Canvas view, rule switches, intro screen, saved-universe shelf.
apps/web — SvelteKit shell → static build → Cloudflare.
apps/android — Capacitor wrapper; webDir points at ../web/build.

complexity-automata

Rules parse from B3/S23 notation, rule numbers, or names (highlife, replicator, fredkin, …). The 18-bit rule number makes all 262,144 universes addressable by an integer. Adds toroidal wrapping, a seeded RNG so a universe is reproducible on any platform, typed-array cells and colours, stagnation detection, twelve demos, a pattern catalogue including fractal seeds, and an Autopilot that tours random rules and moves on whenever one stops evolving.

Colour is inheritance: a cell born beside living cells takes the average of their colours, so colonies drift into their own hues and collisions fade into blends.

Saving universes

A universe is its rule plus its live cells, stored as Life RLE — the encoding conwaylife.com uses — so saved universes open in other Life software and patterns from elsewhere load here. Three ways out: a JSON file, a URL-safe share string for ?u= links, and a UniverseLibrary over any key/value store (localStorage in the browser, ~/.complexity-automata/universes.json in the CLI).

complexity-automata-cli

Truecolor half-blocks, two grid rows per terminal line for square pixels. Demos, patterns, rule tours, keyboard control (space n a r c p d s +/- q), an intro screen cut out of the running grid, saved universes, and a --print mode that renders one frame to stdout for pipes and CI. Falls back to the 256-colour palette, mono blocks or plain ASCII; honours NO_COLOR and never colours a non-TTY.

Apps

The web app is client-rendered and static, with ?demo=, ?intro=0, ?cell= and ?u= parameters. The Android app ships that exact build/ directory through Capacitor, so the two can never drift apart; renamed to Complexity Automata, version 3.0.0.

Testing

  • 86 tests across the three packages (46 engine, 35 CLI, 5 canvas) — blinkers, blocks, a glider's four-generation displacement, rule round-trips, RLE round-trips, library persistence, determinism under a fixed seed, every demo at terminal and phone dimensions.
  • Both TypeScript packages typecheck clean; all three build.
  • The built web app was driven in headless Chromium at phone size: no console errors, demos switch, and a saved universe survives a reload and reopens correctly.
  • The CLI was run under a pty: it enters and restores the alternate screen buffer, and quits on q.
  • cap sync android copies the web build into the Android project.
  • CI workflow added covering all of the above.

Not run here: the Gradle APK assembly, which needs a JDK and the Android SDK.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DPssgQtTm138yEbfJm6Ham


Generated by Claude Code

Automate-Automata was one SvelteKit app with the simulation living inside a
612-line Svelte component. This splits it into a Bun workspace: an engine
anyone can depend on, a UI layer, and three ways to run it — web, Android and
the terminal.

packages/complexity-automata (npm: complexity-automata)
  The engine, with no DOM, no timers and no dependencies. Rules parse from
  B3/S23 notation, rule numbers or names; the 18-bit rule number makes all
  262,144 universes addressable. Adds toroidal wrapping, a seeded RNG so a
  universe is reproducible, typed-array cells and colours, stagnation
  detection, twelve demos, a pattern catalogue with fractal seeds, and
  universe save/load as Life RLE — JSON, a URL-safe share string, or a
  UniverseLibrary over any key/value store.

packages/complexity-automata-cli (npm: complexity-automata-cli)
  Terminal animation in truecolor half-blocks, two grid rows per line. Demos,
  patterns, rule tours, keyboard control, saved universes in
  ~/.complexity-automata, and a --print mode that writes one frame to stdout
  for pipes and CI.

packages/complexity-automata-svelte (npm: complexity-automata-svelte)
  The canvas view, the rule as eighteen switches, the demo picker, the intro
  screen and the saved-universe shelf. Painting goes through an offscreen
  buffer at one pixel per cell, so a redraw costs cells rather than screen
  pixels.

apps/web
  SvelteKit shell around the component. Static, client-rendered, with
  ?demo=, ?intro=0, ?cell= and ?u= (shared universe) URL parameters.

apps/android
  The same build wrapped by Capacitor: webDir points at ../web/build, so the
  app ships exactly what Cloudflare serves. Renamed to Complexity Automata,
  version 3.0.0.

86 tests across the three packages, plus a CI workflow that typechecks,
tests, builds all three and verifies the Capacitor copy step.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DPssgQtTm138yEbfJm6Ham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants