#!/usr/bin/env python3
"""Backward-compatible wrapper for deploying the Codex adapter.

v0.20 keeps Codex adapter templates in the repository, but deploys the usable
adapter files to a Codex home outside the checkout.
"""

from __future__ import annotations

import argparse
import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent
if str(REPO_ROOT) not in sys.path:
    sys.path.insert(0, str(REPO_ROOT))

from scripts.deploy_adapters import deploy_codex, print_result


def main() -> int:
    parser = argparse.ArgumentParser(description="Deploy Codex native adapter")
    parser.add_argument("--target", type=Path, help="Codex home target; defaults to $CODEX_HOME or ~/.codex")
    parser.add_argument("--force", action="store_true", help="overwrite existing files and create .bak backups")
    parser.add_argument("--skip-skills", action="store_true", help="do not copy canonical skills into target/skills")
    parser.add_argument("--include-config", action="store_true", help="also copy config.toml; off by default to avoid overwriting global Codex config")
    parser.add_argument("--dry-run", action="store_true", help="show files that would be written")
    args = parser.parse_args()

    result = deploy_codex(
        target=args.target,
        force=args.force,
        skip_skills=args.skip_skills,
        include_config=args.include_config,
        dry_run=args.dry_run,
    )
    print_result(result)
    print()
    print("Note: this no longer writes repository-local .codex files by default.")
    print("Run Codex from this repository after deployment:")
    if args.include_config:
        print("  codex --profile deep-research")
    else:
        print("  codex")
        print("Note: config.toml is not copied by default. Use --include-config only if you want the bundled profile.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
