"""staging -> 生产目录 promote 流程"""

from __future__ import annotations

import logging
import shutil
from pathlib import Path

from tool_agent.router.status import SourceType

logger = logging.getLogger(__name__)


class Promoter:
    """将通过验证的工具从 staging 提升到生产目录"""

    async def promote(self, staging_path: Path, source_type: SourceType, tools_dir: Path) -> Path:
        target_subdir = "local" if source_type == SourceType.LOCAL else "docker"
        target = tools_dir / target_subdir / staging_path.name
        shutil.copytree(staging_path, target, dirs_exist_ok=True)
        logger.info(f"Promoted {staging_path.name} -> {target}")
        return target
