#!/usr/bin/env python3
"""Generate a fusion plan for two skills."""

from __future__ import annotations

import argparse
from pathlib import Path


def _name(path_or_name: str) -> str:
    path = Path(path_or_name)
    return path.name if path.exists() else path_or_name


def plan_skill_fusion(skill_a: str, skill_b: str, out: Path | str) -> Path:
    a = _name(skill_a)
    b = _name(skill_b)
    content = f"""# Fusion Plan

## Source skills

- `{a}`
- `{b}`

## Keep

- Preserve the clearer workflow and the stricter output contract.
- Preserve all passing eval cases from both skills.

## Rename

- Proposed replacement: `[TODO: new skill name]`
- Alias strategy: keep old names as deprecated/tombstone entries until routing tests pass.

## Merge

- Combine non-overlapping use cases.
- Merge trigger evals into one fixed golden trigger set.
- Deduplicate references and scripts.

## Drop

- Duplicate examples.
- Outdated trigger phrases.
- Any wrapper content that forks the core workflow.

## Migration

- Mark one or both source skills as `deprecated`.
- Set `deprecated_by` to the replacement skill.
- Add migration notes with `scripts/generate_migration_guide.py`.
- Re-run `scripts/release_gate.py` and routing simulation before removal.
"""
    out_path = Path(out)
    out_path.parent.mkdir(parents=True, exist_ok=True)
    out_path.write_text(content, encoding="utf-8")
    return out_path


def main() -> int:
    parser = argparse.ArgumentParser(description="Plan skill fusion")
    parser.add_argument("skill_a")
    parser.add_argument("skill_b")
    parser.add_argument("--out", required=True)
    args = parser.parse_args()
    path = plan_skill_fusion(args.skill_a, args.skill_b, args.out)
    print(f"Wrote {path.resolve()}")
    return 0


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