feat: session modes (Talk/Cash) + live session HUD

Lyra now switches register based on what she's doing at the table instead of
being a wishy-washy companion mid-session.

Modes (lyra/modes.py):
- Talk (default companion) + Cash (live cash copilot); a mode = prompt card +
  tool allow-list. Tool gating via tools.specs(allow=).
- Two-register Cash voice: act-first one-line logging when fed facts; full warm
  companion voice for strategy / tilt / mental game.
- mode persisted per chat session (new sessions.mode column); auto-switch into
  Cash when start_session fires; UI forces cloud backend in Cash (tools only
  fire there).

Stack tracking + HUD:
- log_stack tool + poker_stack_log table; live net while sitting (stack - buy-in).
- poker.hud() bundle; /session HUD page (stack sparkline, hands, villains, notes,
  stats) polling /session/data every 5s; Talk/Cash switcher + Session nav.

Endpoints: /session, /session/data, GET/POST /sessions/{id}/mode, /modes.
tests/test_modes.py (gating, mode roundtrip, stack/HUD); 36 tests green. v0.3.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-19 05:28:15 +00:00
parent d9f5055ec1
commit dfb6425395
14 changed files with 829 additions and 32 deletions
+14 -3
View File
@@ -43,9 +43,18 @@ reflected), and keeps a permanent **journal**.
## Poker copilot
She runs in **modes** (`lyra/modes.py`). 💬 **Talk** is the default companion
(journaling + read-only poker lookups). ♠ **Cash** is the live copilot: she gets
the full session toolset and a two-register voice — quiet and act-first when
you're feeding her facts to log (stack, a hand, a read → one-line confirm, no
narration), but fully present and warm when you ask for strategy or you're tilting
/ card-dead / steaming. Opening a session auto-switches her into Cash mode.
Talk to her during a session; she drives tools behind the scenes:
- **Session tracking** — `start_session`, `add_buyin`, `end_session` → net, hours, $/hr.
- **Stack tracking** — `log_stack` records your stack as the night goes → live net
while you're still sitting, and a stack-over-time sparkline on the HUD.
- **Hand histories** — vomit rough shorthand ("AKs btn, 3bet, flop A72…"), she
reconstructs a structured, **replayable** hand (unknown cards = `x`, never invented).
- **Villain file** — named opponents auto-build persistent dossiers; basic stats
@@ -56,9 +65,11 @@ Talk to her during a session; she drives tools behind the scenes:
## Web app (served by `lyra-web`, default `:7078`)
`/` chat (Markdown, model picker, 👍/👎 rating) · `/logs` live activity · `/self`
read-her-mind (mood, drives, reflections) · `/journal` her thoughts · `/hands`
recorded hands → `/hand/{id}` replayer · `/recap/{id}` session writeup (+ `.md` export).
`/` chat (Markdown, model picker, 👍/👎 rating, **Talk/Cash mode switcher**) ·
`/session` **live session HUD** (stack + sparkline, hands, villains, notes; mobile
Session tab) · `/logs` live activity · `/self` read-her-mind (mood, drives,
reflections) · `/journal` her thoughts · `/hands` recorded hands → `/hand/{id}`
replayer · `/recap/{id}` session writeup (+ `.md` export).
👍/👎 ratings on replies and thoughts are stored as `(context, content, rating)`
a fine-tune / preference dataset built passively (`/ratings/export` → JSONL).