From 59db9ea0b09cf37648dc910ef7b37d3d130ea248 Mon Sep 17 00:00:00 2001 From: lmiranda Date: Tue, 27 Jan 2026 11:55:43 -0500 Subject: [PATCH] fix(post-update): use venv-repair for instant symlink restoration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the old approach (create venvs in marketplace directory) with the new venv-repair.sh approach (symlinks to external cache). This ensures post-update.sh: - Instantly restores symlinks if cache exists - Only does full pip install on first run - Works correctly after marketplace updates Flow after this fix: Update marketplace → post-update.sh → venv-repair → Session works Co-Authored-By: Claude Opus 4.5 --- scripts/post-update.sh | 98 +++++++++++++----------------------------- 1 file changed, 31 insertions(+), 67 deletions(-) diff --git a/scripts/post-update.sh b/scripts/post-update.sh index 846217a..f7bdc96 100755 --- a/scripts/post-update.sh +++ b/scripts/post-update.sh @@ -1,13 +1,13 @@ #!/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 # # This script: -# 1. Updates Python dependencies for MCP servers -# 2. Validates configuration still works -# 3. Reports any new manual steps from CHANGELOG +# 1. Restores MCP venv symlinks (instant if cache exists) +# 2. Creates venvs in external cache if missing (first run only) +# 3. Shows recent changelog updates # set -euo pipefail @@ -19,64 +19,25 @@ REPO_ROOT="$(dirname "$SCRIPT_DIR")" GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' +RED='\033[0;31m' NC='\033[0m' log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } log_success() { echo -e "${GREEN}[OK]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${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" -} +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } check_changelog() { - log_info "Checking CHANGELOG for recent updates..." - if [[ -f "$REPO_ROOT/CHANGELOG.md" ]]; then - # Show the Unreleased section - echo "" - echo "Recent changes (from CHANGELOG.md):" - echo "-----------------------------------" - sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | head -30 - echo "-----------------------------------" - echo "" + local unreleased + unreleased=$(sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | grep -E '^### ' | head -1 || true) + if [[ -n "$unreleased" ]]; then + echo "" + log_info "Recent changes (from CHANGELOG.md):" + echo "-----------------------------------" + sed -n '/## \[Unreleased\]/,/## \[/p' "$REPO_ROOT/CHANGELOG.md" | head -20 + echo "-----------------------------------" + fi fi } @@ -86,25 +47,28 @@ main() { echo "==============================================" echo "" - # Shared MCP servers at repository root (v3.0.0+) - update_mcp_server "gitea" - update_mcp_server "netbox" - update_mcp_server "data-platform" - update_mcp_server "viz-platform" - update_mcp_server "contract-validator" + # Run venv-repair.sh to restore symlinks to external cache + # This is instant if cache exists, or does full setup on first run + if [[ -x "$SCRIPT_DIR/venv-repair.sh" ]]; then + log_info "Restoring MCP venv symlinks..." + if "$SCRIPT_DIR/venv-repair.sh"; then + 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 echo "" log_success "Post-update complete!" echo "" - echo "If you see new features in the changelog that require" - echo "configuration changes, update your ~/.config/claude/*.env files." + echo "MCP servers will work immediately on next session start." } 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" -- 2.49.1