This document provides a concise overview of ShellGame's architecture after the shell integration and CLI orchestration refactor.
Detailed descriptions:
docs/protocols/SHELL_PROTOCOL.md(wrapper contract / env variables / hooks)
- Single source of truth for shell integration (bash/fish) without duplication.
- Separate Click parsing from game orchestration (testability, less "god-file").
- Centralize tracking (time/attempts/hints) into state layer.
- Preserve UX rules (teleport notice, paging intro, unified Enter prompt, hint semantics).
- User runs
shellgame. - If the process is not "wrapped" (
SHELLGAME_WRAPPERis not set), ShellGame launches a wrapped subshell (bash/fish) that:- loads the integration script,
- suppresses banner/greeting,
- re-runs
shellgameinside the wrapper.
- Inside the wrapper,
shellgame:- loads or initializes state and workspace,
- shows the current level assignment,
- sets shell context (env variables),
- teleports to start directory if needed (only when cwd actually changed).
src/shellgame/cli/commands.py- Click group + commands (
hint,submit,status,reset,repeat,show,remove, …) - thin delegation to
GameSession - holds singletons (for testing)
- contains UX helper
_teleport_notice(destination: Path)— signature must not change
- Click group + commands (
src/shellgame/core/session.pyGameSession: "what the game does"- boot decision (whether to launch subshell)
- init/show/hint/submit/reset/repeat/status/remove
- enforcement of start directory + teleport (notice callback injected from CLI)
src/shellgame/cli/subshell.py- generates integration script from templates using
string.Template - injects hook code at runtime
- launches subshell with suppression:
- bash:
--noprofile --norc -i --rcfile <tempfile> - fish: override
fish_greetingfor session
- bash:
- generates integration script from templates using
src/shellgame/cli/hooks.py- generates bash/fish hook code (e.g., wrapper for
cd) - injected into templates via
subshell.py
- generates bash/fish hook code (e.g., wrapper for
src/shellgame/ui/display.py- Rich panels, notes, unified prompt
Stiskněte Enter pro pokračování... - paging of intro levels (
X.0) via delimiter--- - progressive hint system +
--repeatsemantics + "no more hints" panel
- Rich panels, notes, unified prompt
src/shellgame/state/manager.pyGameState(Pydantic) + atomic saving- per-level tracking:
level_attemptslevel_hints_usedlevel_started_at
- level completion into
levels_complete[level_id](time, hints, attempts, timestamp)
src/shellgame/levels/*- registry/loader/base + concrete levels in
levels/sections/ - answer validation is the level's responsibility (
validate(...)) - start directory declared by level; enforcement in session layer
- registry/loader/base + concrete levels in
_teleport_notice(destination: Path)remains incommands.py(signature unchanged).- Teleport notice shown only if cwd actually changed.
- Bash/fish startup must not display user banners/greetings per wrapper rules.
- Single "Press Enter to continue":
Display.wait_for_continue()with text:Stiskněte Enter pro pokračování...
- Intro levels (
.0) are paged via---and wait for Enter between pages. hintis progressive;hint --repeatonly reprints (without consuming) and must not spam footers.
- Shell wrappers/templates:
src/shellgame/cli/subshell.py,src/shellgame/cli/templates/ - Hook logic (cd wrapper):
src/shellgame/cli/hooks.py - Game action orchestration:
src/shellgame/core/session.py - Click flags/args/text:
src/shellgame/cli/commands.py - UI text/panels/hints/paging:
src/shellgame/ui/display.py - Persistence + tracking:
src/shellgame/state/manager.py - Gameplay rules/validation:
src/shellgame/levels/sections/section*.py