fix(post-update): use venv-repair for instant symlink restoration #213

Merged
lmiranda merged 1 commits from fix/post-update-venv-repair into development 2026-01-27 16:56:52 +00:00

View File

@@ -1,13 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# post-update.sh - Run after pulling updates # post-update.sh - Run after pulling updates or marketplace sync
# #
# Usage: ./scripts/post-update.sh # Usage: ./scripts/post-update.sh
# #
# This script: # This script:
# 1. Updates Python dependencies for MCP servers # 1. Restores MCP venv symlinks (instant if cache exists)
# 2. Validates configuration still works # 2. Creates venvs in external cache if missing (first run only)
# 3. Reports any new manual steps from CHANGELOG # 3. Shows recent changelog updates
# #
set -euo pipefail set -euo pipefail
@@ -19,64 +19,25 @@ REPO_ROOT="$(dirname "$SCRIPT_DIR")"
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; } log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
update_mcp_server() {
local server_name="$1"
local server_path="$REPO_ROOT/mcp-servers/$server_name"
if [[ ! -d "$server_path" ]]; then
log_warn "$server_name directory not found at $server_path - skipping"
return 0
fi
if [[ ! -f "$server_path/requirements.txt" ]]; then
log_warn "$server_name has no requirements.txt - skipping"
return 0
fi
cd "$server_path"
# Create venv if missing
if [[ ! -d ".venv" ]]; then
log_info "Creating $server_name venv (was missing)..."
python3 -m venv .venv
log_success "$server_name venv created"
else
log_info "Updating $server_name dependencies..."
fi
# Install/update dependencies
source .venv/bin/activate
pip install -q --upgrade pip
pip install -q -r requirements.txt
# Install local package in editable mode if pyproject.toml exists
if [[ -f "pyproject.toml" ]]; then
pip install -q -e .
log_success "$server_name package installed (editable mode)"
fi
deactivate
cd "$REPO_ROOT"
log_success "$server_name ready"
}
check_changelog() { check_changelog() {
log_info "Checking CHANGELOG for recent updates..."
if [[ -f "$REPO_ROOT/CHANGELOG.md" ]]; then if [[ -f "$REPO_ROOT/CHANGELOG.md" ]]; then
# Show the Unreleased section local unreleased
unreleased=$(sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | grep -E '^### ' | head -1 || true)
if [[ -n "$unreleased" ]]; then
echo "" echo ""
echo "Recent changes (from CHANGELOG.md):" log_info "Recent changes (from CHANGELOG.md):"
echo "-----------------------------------" echo "-----------------------------------"
sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | head -30 sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | head -20
echo "-----------------------------------" echo "-----------------------------------"
echo "" fi
fi fi
} }
@@ -86,25 +47,28 @@ main() {
echo "==============================================" echo "=============================================="
echo "" echo ""
# Shared MCP servers at repository root (v3.0.0+) # Run venv-repair.sh to restore symlinks to external cache
update_mcp_server "gitea" # This is instant if cache exists, or does full setup on first run
update_mcp_server "netbox" if [[ -x "$SCRIPT_DIR/venv-repair.sh" ]]; then
update_mcp_server "data-platform" log_info "Restoring MCP venv symlinks..."
update_mcp_server "viz-platform" if "$SCRIPT_DIR/venv-repair.sh"; then
update_mcp_server "contract-validator" log_success "MCP venvs ready"
else
log_error "MCP venv setup failed"
log_warn "Run: $SCRIPT_DIR/setup-venvs.sh for full setup"
exit 1
fi
else
log_error "venv-repair.sh not found at $SCRIPT_DIR"
exit 1
fi
check_changelog check_changelog
echo "" echo ""
log_success "Post-update complete!" log_success "Post-update complete!"
echo "" echo ""
echo "If you see new features in the changelog that require" echo "MCP servers will work immediately on next session start."
echo "configuration changes, update your ~/.config/claude/*.env files."
} }
main "$@" main "$@"
# Clear plugin cache to ensure fresh hooks are loaded
echo "Clearing plugin cache..."
rm -rf ~/.claude/plugins/cache/leo-claude-mktplace/
echo "Cache cleared"