#!/usr/bin/env python3
"""ACS menu bar app with local commit agent.

Manages a lightweight commit agent that discovers local repos, asks the
remote ACS daemon for LLM-generated commit messages, and commits+pushes.

Usage:
    ./commits-tray --url http://apricot.local:8200
    ./commits-tray --url http://apricot.local:8200 --repos ~/Code --cycle 300
"""

import argparse
import os
import sys
from pathlib import Path

_script_dir = os.path.dirname(os.path.abspath(__file__))
_tray_dir = os.path.join(_script_dir, "src", "auto_commit_service", "tray")
sys.path.insert(0, _tray_dir)

from app import run_tray  # noqa: E402


def main():
    parser = argparse.ArgumentParser(description="ACS menu bar app + local commit agent")
    parser.add_argument(
        "--url", "-u",
        default="http://apricot.local:8200",
        help="Remote ACS daemon URL for LLM + recording (default: http://apricot.local:8200)",
    )
    parser.add_argument(
        "--repos", "-r",
        nargs="+",
        default=None,
        help="Base paths to scan for local git repos (default: ~/Code)",
    )
    parser.add_argument(
        "--cycle", "-c",
        type=int,
        default=300,
        help="Seconds between commit cycles (default: 300)",
    )
    args = parser.parse_args()

    repos_paths = [Path(p).expanduser() for p in args.repos] if args.repos else None
    run_tray(daemon_url=args.url, repos_paths=repos_paths, cycle_seconds=args.cycle)


if __name__ == "__main__":
    main()
