Skip to content
nullthronePublic

About

LexVM. A modular virtual machine and runtime interpreter for text-based interactive fiction.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

34 Commits

Folders and files

Repository files navigation

๐Ÿ•ฏ๏ธ LexVM

Text adventures for your pocket ยท Textabenteuer fรผr die Hosentasche

A ScummVM-inspired engine for text adventures.
Plays offline on your phone. Written by humans or LLMs, proven winnable by machines.

โ–ถ๏ธ Play now ยท ๐Ÿ“ฅ Offline version ยท ๐Ÿ“ Create your own ยท โ˜• Support

CI Pages License: MIT Ko-fi

๐ŸŽฎ What is LexVM?

LexVM is a player for text adventures that runs in the browser and works offline. Like ScummVM, one deterministic engine runs many games. Each game is a content pack: a file of declarative data with no code in it, written in YAML, compiled to JSON and verified by tools that prove it can be won and has no dead ends. Because a content pack is plain data with a closed vocabulary, a large language model (LLM) can write one from the specification alone.

The player is built for phones in portrait mode and tablets in airplane mode: tap objects, pick verbs, follow the story. If you prefer the classic way, type commands in German or English.

๐Ÿ—บ๏ธ Now playing

Adventure Language Length
๐Ÿ•ต๏ธ Die letzte Nacht der Reichsmark
Ein Hamburger Kriminalfall, Juni 1948. The night before the currency reform, a dock worker vanishes, accused of stealing cigarettes. Clues, interrogations and a city full of hoarded goods.
๐Ÿ‡ฉ๐Ÿ‡ช Deutsch ~65 min Noir
๐Ÿ”‘ The Locked Study
A short LexVM demo. Your uncle has vanished and his study is locked.
๐Ÿ‡ฌ๐Ÿ‡ง English ~7 min Demo

Want more? Write your own or propose one.

๐Ÿ“ฑ Play offline

The player is a progressive web app (PWA). Open it once while online; after that it works without a network connection, airplane mode included.

Device How to install
๐ŸŽ iPhone, iPad Open the link in Safari, tap Share, then Add to Home Screen. Start it once from the home screen while online.
๐Ÿค– Android Open the link in Chrome, open the menu and tap Install app (or Add to Home screen).
๐Ÿ’ป Desktop (Chrome, Edge) Click the install icon in the address bar.

๐Ÿ“ฅ Or download the single-file offline version: one HTML file that contains the player and all bundled adventures.

Open it in any current browser, from a laptop or a USB stick. It makes no network requests. Its saves are stored separately from the installed app. On iPhone and iPad, prefer the home-screen install: Safari only keeps storage of installed web apps reliably.

โœจ Features

  • ๐Ÿ‘† Tap-first play. Objects in the text are tappable; an action sheet offers the verbs that make sense (SCUMM-inspired). Exits and dialogue choices are buttons in the thumb zone.
  • โŒจ๏ธ Optional text parser for German and English (nimm den Schlรผssel, use key with door).
  • ๐Ÿ›Ÿ Forgiving by design. No losing endings, no dead ends: verified automatically for every adventure.
  • ๐Ÿ’ก Progressive hints, from a gentle nudge to the solution, one step at a time.
  • ๐Ÿ’พ Autosave and undo. A save is the game state plus the command log, so it survives updates to an adventure.
  • ๐Ÿ“– Book typography with serif type and sepia, light and dark themes.
  • ๐Ÿ”’ Offline and private. No accounts, no tracking, no network access at runtime. Saves stay on your device.
  • ๐Ÿงฉ Bring your own adventure. Import a content pack (.yaml or .lexpack.json) straight into the player.

๐Ÿงช Proven winnable

Every adventure has to pass lexvm check before it ships:

  1. ๐Ÿ“ Schema and semantics: every id, exit, flag and text reference resolves.
  2. ๐ŸŽฌ Walkthrough replay: the included solution is played from the first command to a winning ending.
  3. ๐Ÿ”ญ State-space exploration: every reachable game state is searched to prove that you can always still win, using only what the app offers to tap.
  4. โฑ๏ธ Play-time estimate: word counts, reading speed and decision time give an expected length, checked against the adventure's target.

This is what makes LLM-written adventures trustworthy: a model can make up a story, but it cannot talk its way past the verifier.

๐Ÿ“ Create your own adventure

A content pack is a directory of YAML files that follows the content pack specification. Write one by hand, or let an LLM write it:

  1. ๐Ÿ’ฌ Prompt kit, any LLM, no API key. In the player, open Create your own, copy the prompt into the LLM chat of your choice, describe your idea, then import the result into the player. The player validates it and shows the exact problems to paste back into the chat. The prompt is also in prompts/oneshot.md.
  2. ๐Ÿค– CLI with the Anthropic API. lexvm generate runs a staged generation (concept โ†’ puzzle chart โ†’ world โ†’ logic) with an automatic validate-and-repair loop. It needs an API key in ANTHROPIC_API_KEY.

Either way, check the result before you share it:

npm run lexvm -- check packs/my-pack

๐Ÿ“š Details: authoring guide and generation pipeline.

๐Ÿ› ๏ธ Developer quickstart

Requirements: Node.js 22 (see .nvmrc) and npm.

git clone https://github.com/nullthrone/lexvm.git
cd lexvm
npm ci
npm run dev                                  # player with hot reload
npm test                                     # unit tests (Vitest)
npm run check:packs                          # verify all content packs
npm run lexvm -- play packs/locked-study     # play the demo in the terminal
Script Purpose
npm run dev Compile the content packs, then start the Vite dev server for the player.
npm run build Production build of the player into apps/web/dist (PWA and lexvm-offline.html).
npm test Unit tests.
npm run e2e End-to-end tests with Playwright on phone viewports (run npx playwright install chromium once).
npm run lint / npm run format Biome lint and format.
npm run typecheck TypeScript checks for all workspaces.
npm run check:packs lexvm check for every content pack in packs/.
npm run prompts Regenerate prompts/oneshot.md from the templates, spec and guide.
npm run lexvm -- <command> Run the CLI from source.

CLI commands (npm run lexvm -- <command> --help for options):

Command Purpose
validate Schema and semantic checks.
build Compile content packs to .lexpack.json and a catalog.
check validate plus walkthrough replay, state-space exploration and play-time estimate.
play Play a content pack in the terminal.
new Scaffold a new content pack.
schema Write the JSON Schema of the content pack format.
prompt Assemble the prompt kit.
generate Generate a content pack with the Anthropic API.

๐Ÿงญ Repository layout

apps/web/          Player: PWA, vanilla TypeScript, Vite, hand-written service worker
packages/engine/   Engine: zod schema, compiler, runtime, parser, verifier (no DOM, no Node APIs)
packages/cli/      lexvm CLI
packs/             Content packs, one directory per pack (YAML sources, design notes)
prompts/           Prompt kit for LLMs (templates/ is the source; oneshot.md is generated)
schema/            JSON Schema generated from the zod schema
docs/              Specification, authoring guides, architecture, ADRs
.github/           CI, Pages deployment, releases, issue forms, labels and milestones as code

๐Ÿ—๏ธ Architecture

flowchart LR
  AUTHOR["Author or LLM"] -->|writes| SRC["Content pack source<br/>packs/*/*.yaml"]
  SRC --> COMP["Compiler and validator<br/>zod schema + semantic checks"]
  COMP -->|diagnostics| AUTHOR
  COMP --> PACK["*.lexpack.json<br/>normalised JSON"]
  PACK --> ENG["Engine<br/>pure, deterministic step()"]
  UI["Player (PWA)<br/>taps and parser"] -->|command| ENG
  ENG -->|output and view| UI
  CLI["CLI<br/>lexvm play"] -->|command| ENG
  ENG -->|output| CLI
  PACK --> VER["Verifier<br/>walkthrough replay +<br/>state-space exploration"]
  VER -->|drives| ENG
Loading

The engine is a pure function step(pack, state, command): no clock, no randomness, no I/O. Game state is plain JSON. The same commands always produce the same game, which makes saves small (state plus command log), bugs reproducible from a command log, and exhaustive verification possible. See docs/architecture.md and the architecture decision records.

๐Ÿšฆ Status

LexVM is at v0.1, in development. The content pack format is lexvm-pack/1; it may still change before v1.0, following the versioning rules in the specification.

Milestone Scope
๐ŸŸข v0.1 Playable Engine, tap-first PWA on GitHub Pages (offline), first German adventure, verifier, LLM pipeline
๐ŸŸก v0.2 Authoring & Polish In-browser pack workshop, auto-map, accessibility audit, parser coverage, save slots
โšช v0.3 Community Pipeline Pack proposals that become generation PRs, automated LLM playtests, pack catalog, provenance
โšช v1.0 Stable Format Frozen lexvm-pack/1 with a compatibility promise, documentation site, security review

Progress: milestones and changelog.

๐Ÿš€ Deployment

Every push to main builds the player and deploys it to GitHub Pages (.github/workflows/pages.yml). Pushing a tag v* creates a GitHub Release with lexvm-offline.html, the compiled content packs and a SHA256SUMS.txt attached (.github/workflows/release.yml).

One-time repository settings for maintainers:

  • Settings โ†’ Pages โ†’ Build and deployment โ†’ Source = GitHub Actions, so the Pages workflow can deploy.
  • Settings โ†’ Code security โ†’ Private vulnerability reporting = enabled, which SECURITY.md relies on.

๐Ÿค Contributing

Contributions are welcome: play and report bugs, write adventures, work on the engine, the player or the docs, or translate. Start with CONTRIBUTING.md. This project follows the Code of Conduct. Report security issues privately as described in SECURITY.md.

โ˜• Support

LexVM is free and stays free. If you enjoy it, you can buy the maintainer a coffee on Ko-fi.

๐Ÿ“œ License

The code is licensed under the MIT License. Each content pack declares its own content license (an SPDX identifier in pack.yaml). The demo pack locked-study is CC0-1.0; Die letzte Nacht der Reichsmark is CC-BY-4.0. See packs/README.md.

About

LexVM. A modular virtual machine and runtime interpreter for text-based interactive fiction.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages