from __future__ import annotations import json from pathlib import Path from typing import Any, Dict DATA_DIR = Path(__file__).parent.joinpath("data") DATA_DIR.mkdir(exist_ok=True) def append_game_history(game_id, entry): file = DATA_DIR / f"{game_id}.jsonl" with file.open("a", encoding="utf-8") as f: f.write(json.dumps(entry)) f.write("\n")