Remove MetaBot coupling from uninstall and workspace init.

Keep silent cleanup of legacy metabot stubs; drop METABOT_HOME symlink.
This commit is contained in:
Zhengshou Lai
2026-08-11 17:23:23 +08:00
parent 18154020a3
commit 3d40e27a93
3 changed files with 39 additions and 17 deletions
-1
View File
@@ -19,7 +19,6 @@ stderr_console = Console(stderr=True)
_LINK_MAP: dict[str, list[str]] = {
"myacademia": ["path_myacademia"],
"myslides": ["path_myslides", "MYSLIDES_ROOT"],
"metabot": ["METABOT_HOME"],
"mytoolkit": ["path_mytoolkit", "MYTOOLKIT_ROOT"],
"mywebpage": ["path_mywebpage", "MYWEBPAGE_ROOT"],
}
+37 -15
View File
@@ -1,7 +1,8 @@
"""``uninstall`` — remove CLI entry points; keep config/workspace by default.
Also removes leftover metabot stubs if present. ``--all`` deletes ~/.xiaohe,
~/.metabot and ~/.mytoolkit; workspace is never touched.
Also removes leftover legacy stubs (metabot / mb / mm / doubao-tts) if present.
``--all`` deletes ~/.xiaohe, ~/.mytoolkit and leftover ~/.metabot;
workspace is never touched.
"""
import os
@@ -17,12 +18,30 @@ stderr_console = Console(stderr=True)
console = Console()
BIN_NAMES = (
"xiaohe", "myagents", "myclaude", "mykimi", "mycodex", "myhermes",
"mycursor", "mytoolkit", "metabot", "mb", "mm", "doubao-tts",
"xiaohe",
"myagents",
"myclaude",
"mykimi",
"mycodex",
"myhermes",
"mycursor",
"mytoolkit",
)
METABOT_COMPLETIONS = (
"mb", "mm", "metabot", "doubao-tts",
"_mb", "_mm", "_metabot", "_doubao-tts",
LEGACY_BIN_NAMES = (
"metabot",
"mb",
"mm",
"doubao-tts",
)
LEGACY_COMPLETIONS = (
"mb",
"mm",
"metabot",
"doubao-tts",
"_mb",
"_mm",
"_metabot",
"_doubao-tts",
)
PY_PACKAGES = ("mytoolkit", "myagents")
@@ -91,20 +110,23 @@ def uninstall_cmd(remove_all: bool, yes: bool) -> None:
console.print(
" - CLI entry points: xiaohe, myclaude, mykimi, mycodex, myhermes,"
)
console.print(" mycursor, myagents, mytoolkit")
console.print(
" mycursor, myagents, mytoolkit, metabot, mb, mm, doubao-tts"
" - legacy leftovers if present: metabot, mb, mm, doubao-tts"
)
console.print(" - shell completions for the above")
console.print(" - desktop launcher (Xiaohe Agent.app / Xiaohe Agent.desktop)")
console.print(" - pip packages: mytoolkit, myagents")
if remove_all:
console.print(" - [red]~/.xiaohe (settings, secrets, keys)[/red]")
console.print(" - [red]~/.metabot (Feishu bot config)[/red]")
console.print(" - [red]~/.mytoolkit (mytoolkit config, incl. keys)[/red]")
console.print(
" - [red]~/.metabot (legacy leftover, if present)[/red]"
)
console.print("[bold]Will keep:[/bold]")
if not remove_all:
console.print(" - ~/.xiaohe (settings, keys)")
console.print(" - ~/.metabot and ~/.mytoolkit (bot/tool configs)")
console.print(" - ~/.mytoolkit (tool configs)")
console.print(f" - workspace: {get_workspace_root(create=False)}")
console.print(" - rc-file edits (PATH line, ANTHROPIC_* exports) and the claude CLI")
@@ -115,8 +137,8 @@ def uninstall_cmd(remove_all: bool, yes: bool) -> None:
# Deleting these dirs destroys settings and every saved credential —
# always require the full confirmation chain, even with --yes.
if not click.confirm(
"This also deletes ~/.xiaohe, ~/.metabot and ~/.mytoolkit — config, "
"bot config and ALL saved API keys. Continue?",
"This also deletes ~/.xiaohe, ~/.mytoolkit and any leftover "
"~/.metabot config and ALL saved API keys. Continue?",
default=False,
err=True,
):
@@ -136,9 +158,9 @@ def uninstall_cmd(remove_all: bool, yes: bool) -> None:
# Entry-point scripts in ~/.local/bin (defensive: pip removes its own).
local_bin = home / ".local" / "bin"
for name in BIN_NAMES:
for name in (*BIN_NAMES, *LEGACY_BIN_NAMES):
_remove_path(local_bin / name, removed)
for name in METABOT_COMPLETIONS:
for name in LEGACY_COMPLETIONS:
_remove_path(local_bin / "completions" / name, removed)
comp_dir = local_bin / "completions"
if comp_dir.is_dir() and not any(comp_dir.iterdir()):
@@ -151,8 +173,8 @@ def uninstall_cmd(remove_all: bool, yes: bool) -> None:
if remove_all:
_remove_path(home / ".xiaohe", removed)
_remove_path(home / ".metabot", removed)
_remove_path(home / ".mytoolkit", removed)
_remove_path(home / ".metabot", removed)
for warning in warnings:
stderr_console.print(f"[yellow]warning: {warning}[/yellow]")
+2 -1
View File
@@ -53,6 +53,7 @@ class TestUninstall:
assert not (local_bin / "completions").exists() # empty dir cleaned
assert not (fake_home / "Desktop" / "Xiaohe Agent.app").exists()
assert (fake_home / ".xiaohe" / "agent" / "config.json").is_file()
# Legacy leftover dir kept unless --all
assert (fake_home / ".metabot" / "bots.json").is_file()
assert (fake_home / ".mytoolkit" / "config.json").is_file()
assert (fake_home / "workspace").is_dir()
@@ -64,7 +65,7 @@ class TestUninstall:
)
assert result.exit_code == 0
assert not (fake_home / ".xiaohe").exists()
assert not (fake_home / ".metabot").exists()
assert not (fake_home / ".metabot").exists() # legacy leftover
assert not (fake_home / ".mytoolkit").exists()
assert (fake_home / "workspace").is_dir() # workspace never touched