Working on Monogatari
IMPORTANT
This section is the one part of the docs that assumes a computer with the repository's toolchain: Git, Bun and Node, a browser Cypress can drive, and a terminal to run them in. Making a game never needs any of it. A game is a folder of files you edit and open in a browser, on a phone or tablet if that's what you have: start with Start Here for that.
These pages are for maintainers of Monogatari v2: you cloned the repository to fix a bug in the engine, add an action or a component, or get a 2.8.x release out. They assume you know JavaScript or TypeScript and the web platform, and nothing about this engine. They explain how the repository is put together, how the engine works in code, why it’s built the way it is, and how to check a change before it goes in. Everything on them was checked against, and run on, the v2.8.1 tag.
If you write your own actions or components for a game, without changing the engine, Extending Monogatari is the section for you.
Start with the learning path
Becoming a Maintainer takes you through this section in seven stages, from a fresh clone to the work a maintainer does. Each stage says what to read, gives you something to do, and ends with a check you can run:
- Run everything: build the engine, run the Cypress specs, play the starter game, and find out why two specs fail on the tag.
- Trace one click from the game screen to the line it shows, through the engine’s events and a breakpoint.
- Reproduce a real bug, then fix it: check out the commit before the 2.8.1 fix, watch its spec fail, and fix it.
- Add an action and a component as built-ins, with a spec that rolls back and loads.
- Learn rollback and saving deeply: what
revert()undoes, what it can’t, and what a save holds. - Review changes, break a rule on purpose, and find the ones nothing checks.
- Build, release and check the docs: the package, the zip, and the docs lint.
After the path, you can fix a bug in any part of v2 without breaking it, add an action or a component with a Cypress spec and docs, review someone else’s change, and cut a 2.8.x release.
Where to start
- Becoming a Maintainer The path above, one stage at a time.
- Setting Up the Repository The tools, the first build, the specs, and a dev loop that works.
- Architecture Diagrams of booting, a statement, a click, a rollback, a save and a load.
- How Each Part Works Each part of the engine walked through in code, with exercises.
- Debugging the Engine The console, debug levels, error dialogs, breakpoints and bisecting.
- Releasing a 2.8.x Patch From the version number to the zip on storage.monogatari.io.
The engine’s parts
The map below is the v2 engine as it sits in the repository. Select a part to see what it holds and which files to open. Repository Layout covers the folders, Architecture shows how the parts work together, and How Each Part Works walks through each one in code.
- Monogatari v2
- Engine object
- Entry points
- Booting
- Settings
- Running the script
- Matching
- Running
- Proceeding
- Rollback
- Reverting
- State and history
- Globals
- Saves
- Saving
- Loading
- Migrations
- Adapters
- Actions
- Text
- Media
- Components
- Screens
- Menus
- From actions
- Look and text
- Styles
- Translations
- Errors
- FancyError
- Debug module
- Around the engine
- Starter game
- Build
- Specs
- Libraries
- Engine object
The map names pages without linking them (a map can’t link to a page of these docs); every one of them is in the list below.
The pages in this section
- Becoming a Maintainer: the learning path, from a fresh clone to reviews and releases.
- Setting Up the Repository: the tools, installing, the first build, the specs, the dev loop.
- Repository Layout: every top-level folder and file,
src/,dist/and the committed build output. - Reading the Code: where to start, the engine object’s regions, the two sides of an action, naming, search recipes.
- Architecture: booting, the statement pipeline, a click, rollback, saving and loading, components.
- How Each Part Works: one page per part of the engine, walked through in code, with exercises:
- Testing the Engine: the Cypress specs, the custom commands, writing a spec, the known failures, CI.
- Debugging the Engine: reproducing, the console, debug levels, error dialogs, breakpoints, bisecting.
- Building and Packaging: every step of
bun run build, the outputs, the npm package. - The Starter Game and Desktop Hosts:
dist/, serving it, the web release, Electron and Electrobun. - Writing and Publishing the Docs: the rules these docs follow, and how they’re checked and published.
- Contributing Translations: translating the engine’s interface into another language.
- How a Change Gets In: triage, the
developandmasterbranches, commits, the pull request. - Reviewing a Change: the review checklist, with what checks each item.
- Releasing a 2.8.x Patch: version, build, tag, npm, the zip, the GitHub release, the docs.
- Design Decisions and Why: the decisions that shape the code, their recorded reasons and their costs.
- Glossary: every engine term, with the page that explains it.