import os
import sys
from pathlib import Path

from pydantic import BaseModel


def _default_db_path() -> Path:
    """Return the platform-specific default path to the Devin CLI sessions database."""
    if sys.platform == "win32":
        appdata = os.environ.get("APPDATA")
        if appdata:
            return Path(appdata) / "devin" / "cli" / "sessions.db"
        return Path.home() / "AppData" / "Roaming" / "devin" / "cli" / "sessions.db"
    return Path.home() / ".local" / "share" / "devin" / "cli" / "sessions.db"


class DevinConfig(BaseModel):
    """Configuration for the Devin session source."""

    db_path: Path = _default_db_path()
    export_cli: str = "devin-session-export"
    current_session_cli: str = "current-devin-session"
