from __future__ import annotations

import argparse
import asyncio
import sys
from pathlib import Path

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

import sync_state_machine.domain  # noqa: F401
from sync_state_machine.pipeline.copy_data_pipeline import CopyDataPipeline


async def _main() -> None:
    parser = argparse.ArgumentParser(description="Run standalone JSONL->JSONL copy pipeline in sync_state_machine")
    parser.add_argument("--source-dir", required=True, help="Source JSONL directory")
    parser.add_argument("--target-dir", required=True, help="Target JSONL directory")
    parser.add_argument("--node-types", nargs="*", default=None, help="Optional node type whitelist")
    args = parser.parse_args()

    pipeline = CopyDataPipeline(
        source_dir=Path(args.source_dir),
        target_dir=Path(args.target_dir),
        node_types=args.node_types,
    )
    stats = await pipeline.run()
    print("\n[Standalone Result]", stats)


if __name__ == "__main__":
    asyncio.run(_main())
