feat: module 06 parser

First Part II module. The cumulative reference adds a second engine
(src/engine/puzzle: grid, lexer, parser) beside Part I's; nouns and
properties are data in src/content/words.json, and the engine names only
IS/AND/NOT/TEXT and the base rule TEXT IS PUSH. Rules are recompiled from
the board on every change; rules() is a sorted set. Adds the M6 scenarios
and tests (rows, columns, shared IS, AND distribution, stacked text, base
rule), the HOT word as a data-only Expansion Drop, the lesson with the
Part II bridge, and the Rust LevelDef shape in harness.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-29 03:33:53 +01:00
1 parent e04dc1a11f
commit 68fe9834c3
55 files changed
+5679 -1

No files matched your search

@@ -0,0 +1,32 @@
/// <reference types="vite/client" />
// Content: the cards and the Baba Is You words. Only this directory (and the card
// data in `cards/`) may name specific cards, or specific Baba Is You nouns.
//
// From Module 5 every card is a JSON file in `cards/` at the package root, in the
// course's card format (`course/schema/card.schema.json`). The functions that were
// card effects in Modules 2–4 are gone: the engine interprets the data.
// `start-module` copies the course's card files into `cards/`; add your own there.
//
// `import.meta.glob` is Vite's (Vitest runs on Vite): it imports every matching
// JSON file when this module loads, so no file system code is needed.
import type { CardDef, puzzle } from "../engine";
import wordList from "./words.json";
const files = import.meta.glob<CardDef>("../../cards/*.json", { eager: true, import: "default" });
/** Every card in `cards/`, in file-name order. */
export function cards(): CardDef[] {
return Object.keys(files)
.sort()
.map((path) => files[path]);
}
/**
* Part II: the words of Baba Is You the parser can read, besides the engine's own
* (`IS`, `AND`, `NOT`, `TEXT`). Nouns and properties are data: a new word is one
* more entry in `words.json` in this directory.
*/
export function words(): puzzle.WordDef[] {
return wordList as puzzle.WordDef[];
}
@@ -0,0 +1,15 @@
[
{ "name": "BABA", "role": "noun" },
{ "name": "ROCK", "role": "noun" },
{ "name": "WALL", "role": "noun" },
{ "name": "FLAG", "role": "noun" },
{ "name": "LAVA", "role": "noun" },
{ "name": "KEY", "role": "noun" },
{ "name": "DOOR", "role": "noun" },
{ "name": "SKULL", "role": "noun" },
{ "name": "WATER", "role": "noun" },
{ "name": "YOU", "role": "property" },
{ "name": "WIN", "role": "property" },
{ "name": "PUSH", "role": "property" },
{ "name": "STOP", "role": "property" }
]