main
Ray Publish 0.2.0 641533a 11d ago
#!/usr/bin/env python3
"""Remove only unchanged files installed by this package; preserve local edits."""
import argparse,os
from pathlib import Path
root=Path(__file__).resolve().parents[1]
p=argparse.ArgumentParser();p.add_argument('--home',type=Path);args=p.parse_args()
home=args.home or Path.home();codex=home/'.codex' if args.home else Path(os.environ.get('CODEX_HOME',str(home/'.codex')))
for base in [home/'.claude/skills',codex/'skills']:
 for source in sorted((root/'skills').iterdir()):
  target=base/source.name
  for file in source.rglob('*'):
   out=target/file.relative_to(source)
   if file.is_file() and out.is_file() and out.read_bytes()==file.read_bytes():out.unlink()
  if target.exists():
   for d in sorted([p for p in target.rglob('*') if p.is_dir()]+[target],key=lambda p:len(p.parts),reverse=True):
    if not any(d.iterdir()):d.rmdir()