"""
Export context packs as a .cursorrules file for Cursor IDE.

Cursor reads .cursorrules from the project root to customize
AI assistant behavior. This exporter produces that file.
"""

from __future__ import annotations

from aura.schema import SCHEMA_VERSION, ContextPack


def export_cursorrules(packs: list[ContextPack]) -> str:
    """
    Export context packs as a .cursorrules file.

    Args:
        packs: Context packs to include (typically just 'developer')

    Returns:
        .cursorrules file content
    """
    lines: list[str] = []
    lines.append(f"# Generated by aura v{SCHEMA_VERSION}")
    lines.append("# https://github.com/WozGeek/BettaAura")
    lines.append("")

    for pack in packs:
        lines.append(pack.to_cursorrules())

    return "\n".join(lines)


def export_cursorrules_to_file(packs: list[ContextPack], output_dir: str = ".") -> str:
    """Export and write .cursorrules to disk. Returns file path."""
    from pathlib import Path

    content = export_cursorrules(packs)
    path = Path(output_dir) / ".cursorrules"
    path.write_text(content)
    return str(path)
