Add MAM uninstaller script (remove.sh) and integrate into installer copy block
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# remove.sh — Multi-Agent Mux (MAM) Orchestration Uninstaller
|
||||
# ==============================================================================
|
||||
# Safely removes MAM orchestration skills, virtual environment, and metadata.
|
||||
# Leaves pre-existing user configurations and files untouched.
|
||||
# ==============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
TARGET_DIR=""
|
||||
FORCE=0
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-y|--yes|--force)
|
||||
FORCE=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
TARGET_DIR="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$TARGET_DIR" ]; then
|
||||
TARGET_DIR="$(pwd)"
|
||||
fi
|
||||
|
||||
echo "===================================================================="
|
||||
echo "⚡ Starting Multi-Agent Mux (MAM) Uninstallation"
|
||||
echo "📂 Target Workspace: $TARGET_DIR"
|
||||
echo "===================================================================="
|
||||
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "❌ Error: Target directory '$TARGET_DIR' does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$TARGET_DIR"
|
||||
|
||||
# Check if there is anything to remove
|
||||
assets_to_check=(
|
||||
".agents/skills/lib.sh"
|
||||
".agents/skills/multi-agent-mux-create"
|
||||
".agents/skills/multi-agent-mux-delegate-job"
|
||||
".agents/skills/multi-agent-mux-monitor"
|
||||
".agents/skills/multi-agent-mux-resume"
|
||||
".agents/skills/multi-agent-mux-status"
|
||||
".agents/skills/multi-agent-mux-stop"
|
||||
".venv"
|
||||
".mam"
|
||||
"AGENT.md"
|
||||
"AGENT.ko.md"
|
||||
"MESSAGING.md"
|
||||
"BOOTSTRAP.md"
|
||||
"BOOTSTRAP.ko.md"
|
||||
"INSTRUCTION.md"
|
||||
".env"
|
||||
)
|
||||
|
||||
any_exist=0
|
||||
for asset in "${assets_to_check[@]}"; do
|
||||
if [ -e "$asset" ] || [ -h "$asset" ]; then
|
||||
any_exist=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $any_exist -eq 0 ]; then
|
||||
echo "ℹ️ No MAM assets detected in '$TARGET_DIR'. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Request confirmation if not forced
|
||||
if [ $FORCE -eq 0 ]; then
|
||||
echo "⚠️ WARNING: This will permanently remove the MAM orchestration skills, "
|
||||
echo " virtual environment (.venv), local metadata (.mam), and docs."
|
||||
echo " (Your own custom files inside .agents/ will NOT be touched)."
|
||||
read -p "❓ Are you sure you want to proceed? [y/N]: " -r response
|
||||
if [[ ! "$response" =~ ^[yY](es)?$ ]]; then
|
||||
echo "❌ Uninstallation cancelled by user."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
delete_asset() {
|
||||
local asset="$1"
|
||||
if [ -e "$asset" ] || [ -h "$asset" ]; then
|
||||
echo "🗑️ Removing: $asset"
|
||||
rm -rf "$asset"
|
||||
fi
|
||||
}
|
||||
|
||||
# 1. Remove MAM skills
|
||||
delete_asset ".agents/skills/lib.sh"
|
||||
delete_asset ".agents/skills/multi-agent-mux-create"
|
||||
delete_asset ".agents/skills/multi-agent-mux-delegate-job"
|
||||
delete_asset ".agents/skills/multi-agent-mux-monitor"
|
||||
delete_asset ".agents/skills/multi-agent-mux-resume"
|
||||
delete_asset ".agents/skills/multi-agent-mux-status"
|
||||
delete_asset ".agents/skills/multi-agent-mux-stop"
|
||||
|
||||
# Remove empty parent dirs under .agents to avoid littering
|
||||
if [ -d ".agents/skills" ]; then
|
||||
rmdir ".agents/skills" 2>/dev/null || true
|
||||
fi
|
||||
if [ -d ".agents" ]; then
|
||||
rmdir ".agents" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 2. Remove virtual environment & metadata
|
||||
delete_asset ".venv"
|
||||
delete_asset ".mam"
|
||||
|
||||
# 3. Remove configuration files (optionally keep or confirm .env)
|
||||
# Since .env might contain custom keys, we confirm unless forced.
|
||||
if [ -f ".env" ]; then
|
||||
if [ $FORCE -eq 1 ]; then
|
||||
delete_asset ".env"
|
||||
else
|
||||
read -p "❓ Do you want to remove '.env' configuration file? [y/N]: " -r response
|
||||
if [[ "$response" =~ ^[yY](es)?$ ]]; then
|
||||
delete_asset ".env"
|
||||
else
|
||||
echo "ℹ️ Preserving .env configuration."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
delete_asset ".env.example"
|
||||
|
||||
# 4. Remove runtime documentation
|
||||
delete_asset "AGENT.md"
|
||||
delete_asset "AGENT.ko.md"
|
||||
delete_asset "MESSAGING.md"
|
||||
delete_asset "BOOTSTRAP.md"
|
||||
delete_asset "BOOTSTRAP.ko.md"
|
||||
delete_asset "INSTRUCTION.md"
|
||||
|
||||
# Remove this uninstaller file itself (if we are in the target root)
|
||||
if [ -f "remove.sh" ] && [ "$(realpath "remove.sh")" = "$(realpath "$0")" ]; then
|
||||
echo "🗑️ Removing uninstaller: remove.sh"
|
||||
rm -f "remove.sh"
|
||||
fi
|
||||
|
||||
echo "===================================================================="
|
||||
echo "🎉 Uninstallation complete!"
|
||||
echo "===================================================================="
|
||||
Reference in New Issue
Block a user