"""Coding agent configuration — paths and version."""

from __future__ import annotations

import os
from pathlib import Path

APP_NAME = "pi-coding-agent"
CONFIG_DIR_NAME = ".pi"
VERSION = "0.58.3"
ENV_AGENT_DIR = "PI_CODING_AGENT_DIR"


def get_agent_dir() -> str:
    """Get the agent configuration directory (~/.pi/agent/).

    Respects PI_CODING_AGENT_DIR env var.
    """
    env = os.environ.get(ENV_AGENT_DIR)
    if env:
        return env
    return os.path.join(Path.home(), CONFIG_DIR_NAME, "agent")


def get_sessions_dir() -> str:
    """Get the sessions directory."""
    return os.path.join(get_agent_dir(), "sessions")


def get_version() -> str:
    """Get the package version."""
    return VERSION


def get_models_path() -> str:
    """Get the custom models config path."""
    return os.path.join(get_agent_dir(), "models.json")


def get_auth_path() -> str:
    """Get the auth storage path."""
    return os.path.join(get_agent_dir(), "auth.json")


def get_settings_path() -> str:
    """Get the settings path."""
    return os.path.join(get_agent_dir(), "settings.json")


def get_tools_dir() -> str:
    """Get the custom tools directory."""
    return os.path.join(get_agent_dir(), "tools")


def get_bin_dir() -> str:
    """Get managed binaries directory (fd, rg)."""
    return os.path.join(get_agent_dir(), "bin")


def get_prompts_dir() -> str:
    """Get custom prompts directory."""
    return os.path.join(get_agent_dir(), "prompts")


def get_debug_log_path() -> str:
    """Get the debug log path."""
    return os.path.join(get_agent_dir(), f"{APP_NAME}-debug.log")
