Files
myagents/scripts/rm_user_local_myagents.py
T
Zhengshou Lai 10530479d0 feat: 添加 mycodex 入口,支持 OpenAI Codex CLI
- 在 launcher 中注册 codex 后端,兼容 ~/.codex/sessions 日期嵌套目录

- 解析 session_meta.payload.cwd 过滤当前目录会话

- 添加 myagents codex 子命令与 mycodex 独立入口、补全及 Makefile 链接

- 更新 pyproject.toml 控制台脚本与 README 文档

- 补充 codex 相关单元测试,45 tests passed
2026-07-07 08:40:16 +08:00

63 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Remove ~/.local/bin/{myagents,myclaude,mykimi,mycodex} symlinks to this repo's venv."""
from __future__ import annotations
import os
import sys
_COMMANDS = ("myagents", "myclaude", "mykimi", "mycodex")
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
# Clean up legacy completion files from the old manual install location.
legacy_comp_dir = os.path.expanduser("~/.local/bin/completions")
for command in _COMMANDS:
for filename in (f"_{command}", f"{command}.bash"):
path = os.path.join(legacy_comp_dir, filename)
if os.path.isfile(path):
os.unlink(path)
print("Removed legacy completion", path)
removed += 1
if removed == 0 and skipped == 0:
print("Nothing to remove")
return 0
if __name__ == "__main__":
sys.exit(main())