Coverage for src / osiris_cli / session_summary.py: 0%
15 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-27 17:41 +0200
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-27 17:41 +0200
1#!/usr/bin/env python3
2"""
3Session summary helpers.
5When Gemini CLI exits it generates summaries of the last run so users always
6have a record of what happened. We adopt a similar pattern for Osiris CLI by
7writing markdown summaries derived from the event history.
8"""
10from __future__ import annotations
12from pathlib import Path
13from datetime import datetime
14from typing import Optional
16from .config import CONFIG_DIR
17from .event_history import EventHistory
20SUMMARY_DIR = CONFIG_DIR / "session_summaries"
23def write_session_summary(history: EventHistory, agent_name: str) -> Optional[Path]:
24 """Persist the current event history to disk and return the file path."""
25 if not history.events:
26 return None
28 SUMMARY_DIR.mkdir(parents=True, exist_ok=True)
29 timestamp = datetime.utcnow().strftime("%Y%m%d_%H%M%S")
30 filename = SUMMARY_DIR / f"{agent_name}_{timestamp}.md"
31 filename.write_text(history.to_markdown(), encoding="utf-8")
32 return filename