- launcher _BACKENDS 加 dsh:profile 透传、zstd 会话列表(session/title 或首条用户消息)、 --resume 透传、DSH_HOME 环境变量与 expanduser - entrypoints/cli/completion/打包/卸载全触点 + TestDsh 用例(裸跑/版本/透传/列表/缺 bin)
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Remove ~/.local/bin/{myagents,myclaude,mykimi,mycodex,myhermes} symlinks to this repo's venv."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
_COMMANDS = ("myagents", "myclaude", "mykimi", "mycodex", "myhermes", "mycursor", "mydsh")
|
|
|
|
|
|
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())
|