#!/usr/bin/env python3
"""Sync finance rule spreadsheet assets from the built-in catalog."""

from __future__ import annotations

import sys
from pathlib import Path

SERVER_SRC = Path(__file__).resolve().parents[1] / "src"
if str(SERVER_SRC) not in sys.path:
    sys.path.insert(0, str(SERVER_SRC))

from app.db.session import get_session_factory  # noqa: E402
from app.services.agent_foundation import AgentFoundationService  # noqa: E402


def main() -> None:
    db = get_session_factory()()
    try:
        count = AgentFoundationService(db).sync_finance_rule_assets_from_catalog()
        db.commit()
        print(f"Synced {count} finance rule asset(s) from catalog.")
    finally:
        db.close()


if __name__ == "__main__":
    main()
