feat: poker phase 2 — session recap (.md) generation, export, hands browser
Completes the poker copilot loop: talk through a session -> structured capture
-> generated writeup in Brian's format, remembered + exportable.
- poker.generate_recap(): LLM produces Brian's .md log (Session Header, Money
Flow, Overview, Timeline, Key Hands w/ assessments, Villain Notes, Confidence
Bank, Scar Notes, Mental Game, Final Assessment) from the session's structured
data + the linked chat conversation; stored on poker_sessions.recap_md
- sessions now capture chat_session_id (via tool ctx) to pull the right convo;
list_recent_hands() for browsing
- generate_recap tool ("write up the recap")
- web: /recap/{id} (renders the md) + /recap/{id}/download (.md attachment) +
/hands browser (recent hands -> /hand/{id}); nav links added (desktop + mobile)
- tests: recap generation (stubbed), recent-hands listing
Verified live: recap for the Meadows session rendered + downloaded; all pages 200.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,27 @@ def test_record_hand_tool_parses_and_stores(lyra, monkeypatch):
|
||||
assert h["result"] == -300
|
||||
|
||||
|
||||
def test_generate_recap(lyra, monkeypatch):
|
||||
poker = lyra
|
||||
from lyra import llm
|
||||
monkeypatch.setattr(llm, "complete",
|
||||
lambda messages, backend=None, model=None: "# Recap\n## Final Assessment\nGood session.")
|
||||
sid = poker.start_session(venue="Meadows", stakes="1/3", buy_in=300)
|
||||
poker.log_hand(position="BTN", hole_cards="AKs", result=180, tag="confidence")
|
||||
poker.end_session(540, session_id=sid)
|
||||
out = poker.generate_recap(session_id=sid)
|
||||
assert out["id"] == sid and "Final Assessment" in out["markdown"]
|
||||
assert "Recap" in poker.get_session(sid)["recap_md"]
|
||||
|
||||
|
||||
def test_list_recent_hands(lyra):
|
||||
poker = lyra
|
||||
poker.start_session(stakes="1/3", buy_in=300)
|
||||
poker.log_hand(position="CO", hole_cards="QQ", result=-50)
|
||||
hh = poker.list_recent_hands()
|
||||
assert hh and hh[0]["hole_cards"] == "QQ" and hh[0]["stakes"] == "1/3"
|
||||
|
||||
|
||||
def test_poker_tools_dispatch(lyra):
|
||||
from lyra import tools
|
||||
assert "started" in tools.dispatch("start_session", {"stakes": "1/3", "buy_in": 300})
|
||||
|
||||
Reference in New Issue
Block a user