Setting Up the Repository
This page takes you from nothing to a clone of the v2 engine that builds, runs its specs and serves the starter game. Everything on it was run on Linux with Bun 1.4.4 and Chromium; the commands are the same on macOS, and on Windows inside WSL or Git Bash.
What you need
| Tool | Why | Version |
|---|---|---|
| Git | the code, branches, git log -S |
any recent one |
| Bun | installs the dependencies, runs build.ts and every script in package.json |
package.json lists bun ^1.4.4 as a development dependency; CI installs the latest |
| Node and npm | npm pack and npm publish when you release |
.nvmrc says v25 |
| Chrome or Chromium | the browser Cypress drives | any current one; CI uses Chrome |
| A network connection | bun install, and the specs load their pictures and sounds from https://datadyne.hyuchia.com/monogatari/assets |
On Linux without a desktop, Cypress starts a virtual display (Xvfb) by itself, so Xvfb has to be installed.
You don’t need Yarn: the starter game’s dist/package.json runs its tools directly, with bun run or npm run (see The Starter Game and Desktop Hosts).
Get the code
git clone https://github.com/Monogatari/Monogatari.git
cd Monogatari
git switch developv2 work happens on develop; master holds the latest release. After a release both point at its commit, tagged with the version (v2.9.0). How a Change Gets In explains the branches. If you’ll send changes, fork the repository on GitHub first and clone your fork instead.
Install the dependencies
bun installIt installs about 350 packages into node_modules/, and Cypress’s install script downloads the Cypress app into ~/.cache/Cypress/<version>/ the first time. Check it with:
bunx cypress verifywhich ends with Verified Cypress!. If it says Cypress isn’t installed (because the cache was cleared, or install scripts were skipped), run bunx cypress install.
bun pm untrusted lists one install script Bun didn’t run, @tsparticles/engine’s. It only prints a thank-you message and checks for conflicting particle libraries; the engine doesn’t need it.
Build once
bun run buildbuild runs clean (deletes dist/engine/core, dist/types and lib), lint (ESLint and the house style, on every hand-written script), check (tsc --noEmit) and then bun build.ts, which builds the ES module, the browser bundle, the stylesheet, the debug module and the type declarations. It takes a few seconds and ends with:
📝 Building type declarations...
✅ Type declarations built successfully
🎉 Build completed successfully!Then run git status. On a clean checkout it prints nothing: the build is reproducible, and the repository commits its output. If it lists files under dist/engine/, dist/types/ or lib/, the branch you’re on has bundles older than its source; that’s worth reporting, not committing with an unrelated change. Building and Packaging explains every step.
Run a spec
bunx cypress run --browser chromium --spec cypress/e2e/actions/dialog.spec.jsCypress serves the repository folder itself, opens dist/index.html in Chromium and runs the spec without a window. dialog.spec.js has 56 tests and takes about a minute. Use --browser chrome where Google Chrome is installed. Testing the Engine has the rest.
Play the starter game
dist/ is a complete game. Serve it with any static server and open it in a browser:
cd dist
python3 -m http.server 8080Then open http://localhost:8080. The game also opens from the file (dist/index.html), but a served game is what players get and what the docs support: the service worker, audio effects, save pictures and preloading need it (see What works opened from a file).
dist/ has its own development server, serve.ts, which cd dist && bun run serve starts on port 5100. It serves the files and reloads the page when one changes, including the engine bundle that bun run watch rewrites (details).
The dev loop
You edit src/, rebuild the part you changed, and reload the game (or rerun the spec, which always loads the files on disk).
| You changed | Rebuild with | Time here |
|---|---|---|
TypeScript in src/ |
bun build.ts --browser (writes dist/engine/core/monogatari.js) |
under a second |
CSS in src/ |
bun build.ts --css (writes dist/engine/core/monogatari.css) |
under a second |
debug/index.js |
bun build.ts --debug |
under a second |
| Anything, before you commit | bun run build |
about 7 s |
--module builds lib/ and --types the declarations, always with the project’s TypeScript (5.9.3, from node_modules), whatever tsc your PATH has. bun build.ts with no flag builds all five without linting or type-checking.
bun run watch does the first three rows by itself: it builds monogatari.js, monogatari.css and debug.js, then rebuilds each one, with the same options, when a file it comes from changes (bun run watch:js and bun run watch:css watch only one). A build error is printed and the watch goes on. With bun run serve running in dist/ as well, the page reloads after each rebuild. The watch doesn’t rebuild lib/ or the declarations: bun run build does, before you commit.
Check before you commit
The same three commands CI runs (What CI runs):
bun run lint # ESLint and the house style, on every script
bun run check # tsc --noEmit
bunx cypress run --browser chromium --spec <the specs your change touches>Then bun run build and commit the rebuilt files with your change.
Set up your editor
.editorconfigasks for two-space indentation, LF line endings and UTF-8, and every file follows it.- ESLint’s flat config is
eslint.config.mjs, with the house style from@aegis-framework/eslint-config(see Reading the Code). An editor with the ESLint extension shows its problems as you type and can fix most of them on save; otherwise,bunx eslint . --fixbefore you commit. - TypeScript settings are in
tsconfig.jsonand coversrc/only. The Cypress specs anddebug/index.jsare plain JavaScript.
When something doesn’t work
bun run testorbunx cypress runsays the browser isn’t found:bun run testlooks for Google Chrome, then Chromium. Pass the one you have (--browser chromium,--browser chrome,--browser firefox), or list what Cypress sees withbunx cypress info.- Specs fail with timeouts on images: the specs need
datadyne.hyuchia.com. Checkcurl -I https://datadyne.hyuchia.com/monogatari/assets/images/christmas.pnganswers200. - Two specs fail on the
v2.8.1tag: “Show Scene: Shows the correct background on when both scene and background are used” and “Load Screen: Gives priority to the last known background”. They’re test bugs, fixed in 2.9.0 and explained in stage 1 of the learning path. Ondevelopthe whole suite passes. git statusshows changed bundles after a build: see Build once.