#!/usr/bin/env python3 """Remove ~/.local/bin/{myagents,myclaude,mykimi} symlinks to this repo's venv.""" from __future__ import annotations import os import sys _COMMANDS = ("myagents", "myclaude", "mykimi") def _remove_link(link: str, want: str) -> bool: """Remove link if it is a symlink pointing to want. Returns True if removed.""" if not os.path.islink(link): return False 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 True print("Skip:", link, "points to", target, "(not this repo's", want + ")") return False def main() -> int: root = os.path.normpath(os.environ.get("ROOT_DIR", os.getcwd())) bin_dir = os.path.expanduser("~/.local/bin") removed = 0 skipped = 0 for command in _COMMANDS: want = os.path.normpath(os.path.join(root, ".venv", "bin", command)) link = os.path.join(bin_dir, command) if _remove_link(link, want): removed += 1 elif os.path.lexists(link): print("Skip:", link, "is not a symlink, leaving untouched") skipped += 1 if removed == 0 and skipped == 0: print("Nothing to remove") return 0 if __name__ == "__main__": sys.exit(main())