Skip to content

Refactor llm.lua for plain text output and exit code handling#79

Merged
corepunch merged 37 commits into
mainfrom
feature/walkthrough-tests
Jul 15, 2026
Merged

Refactor llm.lua for plain text output and exit code handling#79
corepunch merged 37 commits into
mainfrom
feature/walkthrough-tests

Conversation

@corepunch

Copy link
Copy Markdown
Owner

No description provided.

corepunch added 30 commits July 13, 2026 21:34
Refactor llm.lua to output plain text directly to stdout instead of JSON, using exit codes (0 = success, 1 = error) for status signaling. Updates PLAYING.md documentation to reflect new output format and command usage patterns. Adds support for limehouse-killings and blackwood-horror games. Includes minor ZIL fixes (CR→CRLF) and removes redundant bootstrap print statement.
Make parser vocabulary robust and add a Limehouse golden-path test. Key changes:
- Compiler: preserve exact ZIL word spelling (hyphens) for SYNONYM/ADJECTIVE output (zilscript/compiler/fields.lua) and add unit test.
- Bootstrap: restore saved vocabulary/address map for SAVE v2, fix TELL numeric printing and PTSIZE nil guard (zilscript/bootstrap.lua).
- Limehouse content: parser-friendly fixes (synonyms/adjectives, guarded one-time flags, OPENBIT on containers, cipher-book puzzle, ASK/TELL topics, ACCUSE syntax, exits).
- Tests/Makefile: add tests/test_limehouse_walkthrough.lua, integrate target, and adjust LLM tests.
- Docs: strengthen play-as-you-build, vocabulary, and testing guidance in skills/.
6 rooms described 'door' but had no door object, causing 'There's no door here'. Added door objects with action handlers, moved door descriptions from room LDESCs to door object LDESCs, added scenery PSEUDO objects for operating theater instruments/benches, and updated skills docs with an explicit door rule.
- Create LEATHER-ROLL container object for lockpick set (fixes 'examine roll' parsing)
- Add LANTERN as synonym for LANTERN object, MAZE/MAZES for HEDGES
- Build scripts/check-vocab.lua: validates FDESC/LDESC nouns are in SYNONYM/ADJECTIVE
- Add make lint-zil target
- Update skills/05, skills/README, WRITING_ADVENTURES.md with vocabulary contract rules
TRUNK-F EXAMINE text promised 'a letter' inside the trunk but no letter
object existed. Added TRUNK-LETTER object inside TRUNK with READ text,
and changed TRUNK flags to CONTBIT OPENBIT SEARCHBIT so contents are
accessible.
- TRUNK-F was referenced by the TRUNK object but never defined, causing
  the ZIL linker to error before FINALIZE_SYNTAX() — every command failed
  with 'There was no verb in that sentence!'
- PRINT-ITEMS passed <NEXT? <FIRST? OBJ>> to recursion instead of
  <NEXT? .ITEM>, so only the first inventory item was ever displayed
- Add missing TRUNK-F action routine (was blocking parser entirely)
- Fix PRINT-ITEMS inventory iteration bug
- Add game-tester agent config with PLAYING.md reference
- Add Basic Commands table to PLAYING.md
- Add check-vocab test and related scripts
- Update dungeon.zil, OBJECTS.md, tests, and skills docs
The IF clause in room exits (e.g., SOUTH TO STUDY IF STUDY-UNLOCKED)
was compiled as a bare UEXIT because the global variable evaluated
to nil at bootstrap time, skipping CEXIT encoding entirely.

Root cause: the compiler emitted flag = STUDY_UNLOCKED which Lua
evaluated to nil, making the table key absent. The bootstrap handler
then treated it as unconditional.

Fix:
- fields.lua: for identifier conditions in IF clauses, emit
  GLOBAL_FLAG_REF wrapper that always returns a table (never nil)
- bootstrap.lua: add GLOBAL_FLAG_REF, global flag slot tables
- Direction handler: detect deferred global refs, allocate slot
- VALUE(): lookup global by slot at runtime
… rules

Bug fixes (492/492 tests still pass):
- Critical: V-GO routines now check CIPHER-SOLVED for library exits
- Critical: INSPECTOR synonyms, ASK syntax, ARTICLEBIT for NPC parsing
- Critical: TRUNK-LETTER renamed to 'folded note' to avoid disambiguation loop
- High: ASK SYNTAX maps to V-TELL, WINE-CABINET hyphenated synonym, DOCTOR synonym
- Medium: LOOK AT/SEARCH syntax, remove stray POTS from greenhouse GLOBAL
- Low: drawer 'closed' instead of 'ajar', keyring guarded behind HUDSON-KEY-GIVEN

Skills docs: added 6 new implementation rules covering V-GO conditional exits,
NPC vocabulary, same-DESC collisions, dynamic room state fidelity, and NPC-gift guards
Merge DESK-DRAWER object logic into DRAWER-F routine, removing redundant object definition. Update PATIENT-FILE location and consolidate drawer interaction handling. Add post-game behavior for green candles (extinguished state). Fix basement stairs directional description and add NDESCBIT flags to heavy door, sealed door, and candles for proper description handling. Add SANITARIUM adjective for clarity.
- Add missing BACK() runtime opcode (reverse of REST) to fix
  intermittent nil global 'BACK' crash in ORPHAN_MERGE
- Add PRE-HELLO-CHAPEL preaction + SYNTAX override so bare 'hello'
  routes to Patient-189 in the chapel
- Add CUT to CHAINS-F verb check so 'cut chains with scalpel' works
- Fix SYNTAX() to defer when PREACTION function isn't loaded yet
…, and playtest regression tests

- Added SAY HELLO syntax and Patient 189 multi-stage conversation with topic globals (MORDECAI, TREATMENT, IDENTITY, SANITARIUM)
- Implemented PATIENT-LORE tracking system across straitjacket, wall scratches, mirror, patient file, and Patient 189 interactions
- Enhanced ending resolution: relic + serum + syringe combination with lore-dependent outcome
- Improved scenery handlers (brass plaque, child drawing, filing cabinets) and ambient descriptions
- Added isolated playtest regression tests for safe-key, say-ending, give-relic, something, scenery, and lore
- Added test-horror-playtest-regressions Makefile target, wired into test-horror-all
- Updated Zork1 test assertions and check-commands for parser changes
- Expanded skill docs (world model/puzzle architecture, content writing/NPC layer)
- Updated game-tester agent instructions
- Added blackwood-horror-bugs.md tracking document
…om Lurking Horror comparison

Add sections on parser depth (pronouns, GWIM, OOPS, disambiguation),
NPC autonomy and dialogue trees, sound system, unique death messages,
progressive hint tiers, prose tonal range in horror, clock-driven
mechanical gameplay, multi-step tool chains, and expanded verb coverage.
03: NPC autonomy (pathfinding, dialogue trees, corruption arcs),
    object interaction tool chains, clock-driven mechanical depth
04: parser depth (pronouns, GWIM, OOPS), NPC dialogue trees,
    unique death text, expanded tonal range in horror
05: pronoun resolution with THIS-IS-IT, autonomous NPC movement
    with clock daemons, mechanical stateful clock daemons
    (battery drain, exposure, temperature decay)
Detailed player experience analysis covering atmosphere, parser quality,
world model, NPC behavior, puzzle design, and 12 documented bugs in the
AdventureArena ZIL runtime port. Game is unplayable due to CLOCKER
save/restore indexing issues, movement crashes, and memory corruption.
Deterministic routine/property registration across save/restore.
CLOCKER routine pointers remain valid across persisted turns.
Correct ZIL truth semantics: numeric 0 is now false.
Number and length-prefixed string parsing for login commands.
Corrected ITABLE allocation to prevent clock/parser memory overlap.
Added MAP-DIRECTIONS, MAP-CONTENTS, pseudo-table, MOD, safe sound.
Fixed room-action RARG? context lowering.
Nil expressions no longer print as literal nil.
57 compiler tests, 63 LLM persistence tests validating save/restore
routine pointer stability. Zork I walkthrough and Zork II suite pass.
Fix 12 parser/interaction bugs, lock study door, update tests,
fix CEXIT exit encoding, add TRUNK-F routine, fix PRINT-ITEMS.
…ng, container tree, TELL articles

- Rewrite P? macro to emit VQ-prefixed verb atoms instead of nil wildcards,
  fixing the dream sequence where every command matched as LISTEN
  (fixes 'It sounds like supplication' soft-lock)
- Avoid direction property numbers colliding with numeric pseudo-objects
  like IT in DECL_OBJECT/DIRECTIONS
- Initialize object sibling/child tables for correct FIRST?/NEXT? traversal
- Add TELL_A, TELL_THE, TELL_CTHE article printing support
- Add getobj nil guard for invalid object IDs
- Add cross-process tests for NPC dialogue, dream sequence, and screen state
13 of 16 Round 1+R2 bugs confirmed fixed: CLOCKER, movement, look
hangs, west/w parsing, dream P? predicate, NPC dialogue, memory
dumps, serial number, hacker triple desc, help/hello, score/time.

2 remaining issues: dream creature daemon (QUEUE overflow into
adjacent memory), inventory CHILD_TBL/SIBLING_TBL address stale
after save/restore. Game is now largely playable (zero crashes,
50+ turn stability).
- Add SET_HEADER runtime function for release/serial number display
- Compile SET-HEADER, VERB-SYNONYM, PREP-SYNONYM as direct statements
- Defer synonym aliases until after all object vocabulary is registered
- Fixes serial number display (was showing nil bytes)
When the previous command hit a YES? prompt (quit/restart), the
saved coroutine cannot be resumed. Recreate the prompt state in
the fresh coroutine before delivering the y/n answer.
run_command used zsh -lc shell wrapper which fails on Ubuntu CI
where zsh is not installed. io.popen already uses /bin/sh -c,
so no shell wrapper is needed.
@corepunch
corepunch merged commit d6ffcb1 into main Jul 15, 2026
1 check passed
@corepunch
corepunch deleted the feature/walkthrough-tests branch July 15, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant