#!/usr/bin/env python3 """Remove ~/.local/bin/myclaude if it is a symlink to this repo's .venv/bin/myclaude.""" from __future__ import annotations import os import sys def main() -> int: root = os.path.normpath(os.environ.get("ROOT_DIR", os.getcwd())) link = os.path.expanduser("~/.local/bin/myclaude") want = os.path.normpath(os.path.join(root, ".venv", "bin", "myclaude")) if not os.path.islink(link): if os.path.lexists(link): print("Skip: not a symlink, leaving untouched") else: print("Nothing to remove") return 0 target = os.readlink(link) if not os.path.isabs(target): target = os.path.join(os.path.dirname(link), target) target = os.path.normpath(target) if target == want: os.unlink(link) print("Removed", link) return 0 print("Skip: points to", target, "(not this repo's", want + ")") return 0 if __name__ == "__main__": sys.exit(main())