bashcrawl¶
Bashcrawl's direction is to become the ultimate open home for all things terminal learning: data, tools, resources and transparency, with a fantasy dungeon in your shell and a free browser trainer built from the same content, for everyone (constitution ยง1).
How to work in Bashcrawl, the terminal-teaching dungeon crawl: exact commands, layout, conventions and the invariants the gates enforce; canonical for every agent and contributor.
What this repo is¶
Bashcrawl (v3.2) teaches real POSIX terminal commands through a fantasy dungeon crawl. The filesystem is the game: directories are rooms, files named scroll are the lessons, and executable scripts (treasure, potion, spell, statue, ghost, monster, goblet) are encounters. It serves learners at a real terminal or in the browser, and the people who author rooms and courses. The parts:
- Terminal-core (
entrance/,help.sh+src/help/,lib/): pure POSIX shell, no dependencies, played with realcd/ls/cat. - Web trainer (
web/): a React 19 + Vite + TypeScript app (web/src/) over a classic-script engine (web/assets/js/) with four doors โ Learn, Story, Practice Arcade, Reference. Its data is exported from the game byscripts/export_static_web.py;npm run buildwritesweb/dist/(gitignored), whichpages.ymldeploys. - TermForge (
termforge/): the zero-dependency terminal framework the web emulator was extracted into โ the kernel (termforge/core/), node hosts (tty HUD, telnet, hub) and apps. - Learning platform (
courses/): Markdown lessons whose objectives are TermForge rules, served by thecurriculum,masteryandexplainplugins on every surface. - Playtest harness (
src/playtest/): an MCP server that lets an AI agent play the real bash game in a sandboxed PTY, plus a recorder and scorer. - Launcher (
bin/bashcrawl): one optional, bash 3.2-compatible dispatch table for every surface.
A change is done when the CI gates below pass locally, every committed projection is regenerated, and the nearest README or doc is updated. The layer model is docs/PLATFORM.md; the full component map is docs/ARCHITECTURE.md.
Stack & commands¶
Bash (3.2-compatible) for the game; Python 3.10+ (pyyaml, mcp) for the web export, validators and harness; Node โฅ 22.22 for the web app (the engine suites and hosts need only Node โฅ 20.16). The Makefile is canonical and exports BASHCRAWL_ROOT and PYTHONPATH=src:test; make help and the generated docs/generated/make-targets.md list every target.
make setup # play: chmod the encounters, then `cd entrance && cat scroll`
make venv # .venv with requirements.txt + requirements-dev.txt
make web-install # npm install (Node >= 22.22, always-latest ranges, no lockfile)
make web-dev # web-build, then the Vite dev server at http://127.0.0.1:5173
make validate-contracts # registries <-> filesystem <-> walkthrough <-> runtime handlers
make test # pytest unit + integration
make test-js # TermForge suites (node --test, zero deps)
make web-test # web-build + bundle/handler parity + eslint + vitest + vite build
make lint # shellcheck + yamllint + markdownlint + ruff
make lint-js # node --check on every tracked *.js
make web-bundle # build: web-build + vite build -> web/dist, with /version + /healthz (what Pages serves)
CI (ci.yml) runs exactly those gates: make lint + make lint-js + npm run lint, then make validate-contracts + make test + make test-js + make web-test on Node 24, plus a stock macOS /bin/bash 3.2 smoke. A fresh-clone run (git clone . /tmp/x && cd /tmp/x && make validate-contracts web-test test test-js) is what CI sees.
Single test (pytest is configured in pyproject.toml under [tool.pytest.ini_options]: suites test/unit and test/integration, markers unit, integration, slow, bash, a 60 s timeout):
cd test
export PYTHONPATH="$PWD/../src:$PWD" BASHCRAWL_ROOT="$PWD/.."
python3 -m pytest unit/test_static_web.py -v
Play, inspect and playtest:
bash help.sh # contextual help; also: help.sh commands | map
bash lib/reset.sh --dry # preview a game-state reset (then drop --dry)
bin/bashcrawl courses # the catalogue; bin/bashcrawl lab ID copies a lab
make tty-demo # the full-screen HUD (ARGS="--no-hud" for the stream)
make telnet-demo # telnet://127.0.0.1:2323 (make telnet-hub: MUD mode)
make doctor # [ OK ]/[WARN]/[CRIT] per surface, exit 0/1/2
make agent-sandbox ARGS="--json" # throwaway dungeon for an agent (--pty, --blind)
PYTHONPATH=src python3 -m playtest.mcp_server # MCP: bashcrawl_start/observe/command/state/stop
make playtest # blank-slate Claude playtest via MCP, then score
make generate-contract-docs # rewrite docs/generated/ (--check runs in validate-contracts)
make playtest needs the claude CLI and CLAUDE_CODE_OAUTH_TOKEN (it skips without them). make playtest-grok uses OpenCode SuperGrok OAuth (~/.local/share/opencode/auth.json, refreshed against auth.x.ai), with XAI_API_KEY as fallback only; python3 -m playtest.xai_auth status|login inspects or device-logs-in. MCP bashcrawl_state returns the room listing, scroll, inventory and HP, and bashcrawl_start context=true attaches a compact HUD to every reply; blank-slate playtests use neither and learn from the screen only.
Layout¶
| Path | What lives there |
|---|---|
entrance/ |
The dungeon: rooms, scrolls, encounters; hidden areas ship as dotted dirs |
courses/ |
One directory per course: course.md, NN-lesson.md, lab/ |
src/help/ |
The bash help engine and the YAML content registries (data/*.yaml) |
src/playtest/ |
The MCP playtest harness (Python) |
lib/, setup.sh, help.sh |
Shared shell libs, the chmod setup, the help shim |
bin/bashcrawl |
The launcher |
termforge/ |
The framework: core/ (source of truth), node/ hosts, apps/, motion/, test/ |
web/ |
The trainer: src/ (React app), assets/js/ (engine), data/ (generated), index.html |
public/ |
Vite's publicDir, copied into web/dist as is: the favicon, .nojekyll and the fleet feedback widget (fleet-feedback*.js, vendored) |
components/ |
FeedbackButton.tsx, the feedback kit's React adapter (vendored), mounted by web/src/chrome/Feedback.tsx |
motion/ |
All art, as ASCII Motion .asciimtn files |
scripts/ |
Export, vendoring, validators, generators, lint and test runners |
test/ |
pytest unit + integration suites and datasets |
docs/ |
Guides, schemas, the component map; docs/generated/ is generated |
tools/ |
Vendored hub tools (unwrap-prose.py, docs_index.py) โ never edit |
Conventions¶
- Backlog of record: GitHub Issues with the fleet labels. Pick up issues labelled
agent:ready; never touchagent:holdorhuman-review. - Definition of Done: the checklist in
.github/PULL_REQUEST_TEMPLATE/pull_request_template.md, plus the CI gates above green locally. - Decisions: none are recorded as ADRs yet; add
docs/adr/NNNN-slug.mdfor anything hard to reverse. - Commits: Conventional Commits (
feat fix docs style refactor test chore perf ci build). Branches:feature/,fix/,docs/,refactor/,test/orchore/offmain. - Changelog: release-please writes
CHANGELOG.mdfrom the Conventional Commit titles onmain; never hand-edit it. - Markdown: one paragraph per line. Check with
python3 tools/unwrap-prose.py --check --exclude '(^|/)SCHEMA\.md$' --exclude '(^|/)CHANGELOG\.md$'(--writein place of--checkfixes), the same call CI'smarkdown-onelinemakes, and it pushes the fix otherwise.CHANGELOG.mdis excluded on purpose: it is release-please's file. - Formatting: Prettier with the hub's
.prettierrc;.prettierignorekeeps it off generated, vendored and release-please files.npm run format:checkcoversweb/srcandvite.config.mts. It is not a CI gate yet: the one-time reformat of that tree lands in its own PR, so never runnpm run formatinside an unrelated change. - Never: push to
maindirectly, commit a lockfile or secrets, suppress type errors, leave empty exception handlers, or hand-edit generated or vendored files:web/data/*.json,web/assets/js/vendor/termforge/,termforge/core/art.js,web/assets/js/{fx-clips,art-clips}.js,docs/generated/,web/dist/,tools/, and the feedback kit'spublic/fleet-feedback*.jsandcomponents/FeedbackButton.tsx(the hub'stools/fanout.sh --kit feedback --upgraderefreshes them). - Dependabot owns dependency updates.
Where to edit¶
| Change | Edit here | Do not edit |
|---|---|---|
| Rooms, scrolls, encounters | entrance/ + src/help/data/*.yaml |
web/data/*.json, docs/generated/ |
| Courses and lessons | courses/<id>/ โ see docs/authoring-courses.md |
web/data/courses.json |
| Badges, ranks, bestiary, trials, skills, review cards | src/help/data/progression.yaml (badges are TermForge rules) |
JS literals |
| Emulator kernel + platform services | termforge/core/ (dual-mode, brand-neutral) |
web/assets/js/vendor/termforge/ |
| Game features (arena, daily, โฆ) | web/assets/js/plugins/<id>.js + GAME_PLUGINS in runtime.js + a <script> in web/index.html |
a second copy of a command |
| Game commands, presenter models, arcade games | web/assets/js/runtime.js, hud.js, arcade.js (GAMES), vim.js |
an engine file turned ES module |
| Web UI (screens, HUD panes, effects, sound) | web/src/; tokens in web/src/styles/tokens.css, reactions in web/src/fx/effects.ts, sounds in web/src/audio/sfx.ts |
colour literals or z-index numbers outside tokens.css; the log's children (a DomSink paints them) |
| Feedback widget (where reports go, report links, the button's place) | web/src/chrome/Feedback.tsx, --bc-bottom-chrome in web/src/app/AppShell.tsx + app.css |
public/fleet-feedback*.js, components/FeedbackButton.tsx (change the kit in the hub) |
| Art | motion/*.asciimtn + src/help/data/motion.yaml |
string literals in code |
| TermForge apps | termforge/apps/registry.js (one entry per app) |
if-chains in the hosts |
| Launcher / playtest harness | bin/bashcrawl / src/playtest/ |
Game content¶
- Hidden areas (
entrance/.chapel/,.vault/,.scrap/,.rift/) are unlocked withmv; their visible names andentrance/workshop/are gitignored player state. Reset withbash lib/reset.sh --drythenbash lib/reset.shโ nevergit checkout -- entrance/. - Game executables:
#!/usr/bin/env bash, the 14-line "wandered out of bounds" header, no strict mode, plain-text heredocs (no ANSI), and they never mutate git-tracked files. State is$I/$HPplus untracked flags (touch .statue_defeated). - Infra scripts (
setup.sh,help.sh,lib/*.sh) useset -euo pipefail,lib/colors.shandlib/log.shโ exceptlib/playrc.sh, the rcfilebashcrawl playsources into the player's interactive shell, where strict mode would break the game. - macOS bash 3.2:
sed -i.bak(never baresed -i), no GNU-only flags, auto-detectlscolour flags. Lint shellchecks every*.shand every executable underentrance/(severity=error). - A new encounter basename goes in
ENCOUNTERSinsetup.sh, or./setup.shwill notchmod +xit. - New room: directory + depth-graded
scroll+ chmod'd encounters + the unlockmvin a prerequisite treasure +src/help/data/*.yaml+test/datasets/walkthrough.json+lib/reset.shif it can be unlocked; thenmake generate-contract-docs && make validate-contracts && make web-test. See.github/instructions/rooms.instructions.md. - Scroll grades (
.github/instructions/scrolls.instructions.md): entrance = pure ASCII, 80 columns,===dividers; cellar/armoury = Unicode box-drawing and emoji,####headers; hidden areas = Markdown. - Courses: every objective needs a
solution(termforge/test/courses.test.jsreplays them from a fresh lab and fails if a lesson is unwinnable or already complete); course files are tracked content, so checkgit check-ignore(*.tmpis ignored repo-wide).
Web and TermForge rules¶
- The engine stays classic.
web/assets/js/**is classic/CJS scripts shared with the node hosts; never make one an ES module, and the rootpackage.jsonmust never declare"type": "module".web/index.htmlloads them in a fixed order thatscripts/validate_static_web.pyenforces (the order). - Edit
termforge/core/, never the vendor mirror. New core files keep the dual-mode wrapper (nonode:*, no DOM), stay brand-neutral (content-separation.test.js), and are listed inweb/index.htmlbeforeruntime.js. - Committed projections:
web/data/*.jsonand the vendor mirror are committed; after content ortermforge/core/changes runmake web-buildand commit the result โmake web-testfails CI when they are stale. - The handlers literal:
this.handlers = { โฆ }inruntime.jsstays one static literal (exactly onethis.handlers = {in the file), onekey: ref,per line, bare refs only; everydemo: trueentry insrc/help/data/runtime_commands.yamlmust appear there (validate_runtime_commands.py). - Plugin order is hook order: curriculum, then
GAME_PLUGINSin order (postExecuteorder matters: achievements โ daily โ progress's rank-up โ nudge's "Stuck?" line), then mastery and explain. - Mini-games are seed world + goal predicate + scoring over a scoped bare
Runtime; never reimplement command behaviour. A new Vim Catacombs level is anarcade.yamlvim_levelsentry whosesolutionwins at exactlyparand steps on no spike (arcade-vim.test.js). - Design tokens: colour literals and numeric
z-indexlive only inweb/src/styles/tokens.css(theme.test.ts); read a colour in code withcolorOf(role); everything that moves is gated onprefers-reduced-motion. - Art is drawn only through
Shell#art(name)/<ArtClip name>, never string literals (art.test.jsscansweb/srctoo). - The reader layer (
web/src/terminal/prose.ts,log-decor.ts) never rewrites text โprose.test.tsround-trips every scroll byte for byte; teach the classifier a convention rather than converting a scroll to Markdown. - Prompt words that open screens (
journal,menu,hero,options,title, โฆ) go inGameStore.intercept(), not aruntime.jshandler. Never useAnimatePresence mode="wait"; under jsdom assert store state, not a dialog's absence. - Saves are additive: never rename or drop keys of the story save
bashcrawl-web-state-v1(game-save.test.js);termforge/test/fixtures/save/save-v1-legacy.jsonis write-once; thelearn/masteryslices are owned and sanitized by their plugins. EverylocalStoragekey is listed in docs/ARCHITECTURE.md. - Goldens (
termforge/test/fixtures/transcripts/) are the emulator's behaviour contract: a fixture diff is a claimed behaviour change, regenerated only withnode termforge/test/tools/record-goldens.js --update. - Registries in
src/help/data/*.yamlare the single source of truth for the help system, the web export and the docs;progression.yamlandcourses/are validated bymake validate-contracts(a Python mirror of the rule heads, parity-tested againstcore/rules.js).
Fleet context¶
Member of the bamr87 fleet: a submodule of bamr87/bamr87 (registry _data/projects.yml, standards in its specs/). Commit and push here first; the hub bumps its pointer afterwards. The loops that act on this repo: the hub's shared standard-ci.yml gate (the standard job in ci.yml), the hub's fleet-pulse doctor and issue pipeline (draft PRs and issues, never merges), the markdown-oneline prose kit, and this repo's own claude.yml (@claude mentions) and weekly blank-slate-audit.yml playtest.
Standard deviations¶
none
Governance¶
Read docs/constitution.md before changing anything: it is the highest-precedence rule set here and wins over this file when they disagree. It changes only through a numbered record in docs/amendments/, ratified by the maintainer merging the PR; agents propose, never merge. Every user-facing feature has a stable id in features/features.yml with status, location and the PRD requirement ids it serves; the PRD's "Feature catalog" block is generated from it (python3 <bamr87/bamr87>/tools/governance_lint.py prd-sync . --write; check with โฆ check .). Never hand-edit that block or CHANGELOG.md.