mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-18 02:06:36 +00:00
* Fix: Install only selected MCP servers and ensure valid empty backups This commit addresses two separate issues: 1. **MCP Installation:** The `install` command was installing all MCP servers instead of only the ones selected by the user. The `_install` method in `setup/components/mcp.py` was iterating through all available servers, not the user's selection. This has been fixed to respect the `selected_mcp_servers` configuration. A new test has been added to verify this fix. 2. **Backup Creation:** The `create_backup` method in `setup/core/installer.py` created an invalid `.tar.gz` file when the backup source was empty. This has been fixed to ensure that a valid, empty tar archive is always created. A test was added for this as well. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * Fix: Correct installer validation for MCP and MCP Docs components This commit fixes a validation issue in the installer where it would incorrectly fail after a partial installation of MCP servers. The `MCPComponent` validation logic was checking for all "required" servers, regardless of whether they were selected by the user. This has been corrected to only validate the servers that were actually installed, by checking against the list of installed servers stored in the metadata. The metadata storage has also been fixed to only record the installed servers. The `MCPDocsComponent` was failing validation because it was not being registered in the metadata if no documentation files were installed. This has been fixed by ensuring the post-installation hook runs even when no files are copied. New tests have been added for both components to verify the corrected logic. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * Fix: Allow re-installation of components and correct validation logic This commit fixes a bug that prevented new MCP servers from being installed on subsequent runs of the installer. It also fixes the validation logic that was causing failures after a partial installation. The key changes are: 1. A new `is_reinstallable` method has been added to the base `Component` class. This allows certain components (like the `mcp` component) to be re-run even if they are already marked as installed. 2. The installer logic has been updated to respect this new method. 3. The `MCPComponent` now correctly stores only the installed servers in the metadata. 4. The validation logic for `MCPComponent` and `MCPDocsComponent` has been corrected to prevent incorrect failures. New tests have been added to verify all aspects of the new logic. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * feat: Display authors in UI header and update author info This commit implements the user's request to display author names and emails in the UI header of the installer. The key changes are: 1. The `__email__` field in `SuperClaude/__init__.py` has been updated to include both authors' emails. 2. The `display_header` function in `setup/utils/ui.py` has been modified to read the author and email information and display it. 3. A new test has been added to `tests/test_ui.py` to verify the new UI output. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * feat: Version bump to 4.1.0 and various fixes This commit prepares the project for the v4.1.0 release. It includes a version bump across all relevant files and incorporates several bug fixes and feature enhancements from recent tasks. Key changes in this release: - **Version Bump**: The project version has been updated from 4.0.9 to 4.1.0 in all configuration files, documentation, and source code. - **Installer Fixes**: - Components can now be marked as `reinstallable`, allowing them to be re-run on subsequent installations. This fixes a bug where new MCP servers could not be added. - The validation logic for `mcp` and `mcp_docs` components has been corrected to avoid incorrect failures. - A bug in the backup creation process that created invalid empty archives has been fixed. - **UI Enhancements**: - Author names and emails are now displayed in the installer UI header. - **Metadata Updates**: - Mithun Gowda B has been added as an author. - **New Tests**: - Comprehensive tests have been added for the installer logic, MCP components, and UI changes to ensure correctness and prevent regressions. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * fix: Resolve dependencies for partial installs and other fixes This commit addresses several issues, the main one being a dependency resolution failure during partial installations. Key changes: - **Dependency Resolution**: The installer now correctly resolves the full dependency tree when a user requests to install a subset of components. This fixes the "Unknown component: core" error. - **Component Re-installation**: A new `is_reinstallable` flag allows components like `mcp` to be re-run on subsequent installs, enabling the addition of new servers. - **Validation Logic**: The validation for `mcp` and `mcp_docs` has been corrected to avoid spurious failures. - **UI and Metadata**: Author information has been added to the UI header and source files. - **Version Bump**: The project version has been updated to 4.1.0. - **Tests**: New tests have been added to cover all the above changes. Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> * fix: Installer fixes and version bump to 4.1.0 This commit includes a collection of fixes for the installer logic, UI enhancements, and a version bump to 4.1.0. Key changes: - **Dependency Resolution**: The installer now correctly resolves the full dependency tree for partial installations, fixing the "Unknown component: core" error. - **Component Re-installation**: A new `is_reinstallable` flag allows components like `mcp` to be re-run to add new servers. - **MCP Installation**: The non-interactive installation of the `mcp` component now correctly prompts the user to select servers. - **Validation Logic**: The post-installation validation logic has been corrected to only validate components from the current session and to use the correct list of installed servers. - **UI & Metadata**: Author information has been added to the UI and source files. - **Version Bump**: The project version has been updated from 4.0.9 to 4.1.0 across all files. - **Tests**: New tests have been added to cover all the bug fixes. * feat: Add --authors flag and multiple installer fixes This commit introduces the `--authors` flag to display author information and includes a collection of fixes for the installer logic. Key changes: - **New Feature**: Added an `--authors` flag that displays the names, emails, and GitHub usernames of the project authors. - **Dependency Resolution**: Fixed a critical bug where partial installations would fail due to unresolved dependencies. - **Component Re-installation**: Added a mechanism to allow components to be "reinstallable", fixing an issue that prevented adding new MCP servers on subsequent runs. - **MCP Installation**: The non-interactive installation of the `mcp` component now correctly prompts for server selection. - **Validation Logic**: Corrected the post-installation validation to prevent spurious errors. - **Version Bump**: The project version has been updated to 4.1.0. - **Metadata**: Author and GitHub information has been added to the source files. - **UI**: The installer header now displays author information. - **Tests**: Added new tests for all new features and bug fixes. * Add Docker support and framework enhancements - Add serena-docker.json MCP configuration - Update MCP configs and installer components - Enhance CLI commands with new functionality - Add symbols utility for framework operations - Improve UI and logging components --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Jules <jules-ai-assistant@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Mithun Gowda B <mithungowda.b7411@gmail.com>
313 lines
10 KiB
Python
313 lines
10 KiB
Python
"""
|
|
Auto-update checker for SuperClaude Framework
|
|
Checks PyPI for newer versions and offers automatic updates
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import time
|
|
import subprocess
|
|
from pathlib import Path
|
|
from typing import Optional, Tuple
|
|
from packaging import version
|
|
import urllib.request
|
|
import urllib.error
|
|
from datetime import datetime, timedelta
|
|
|
|
from .ui import display_info, display_warning, display_success, Colors
|
|
from .logger import get_logger
|
|
|
|
|
|
class UpdateChecker:
|
|
"""Handles automatic update checking for SuperClaude"""
|
|
|
|
PYPI_URL = "https://pypi.org/pypi/SuperClaude/json"
|
|
CACHE_FILE = Path.home() / ".claude" / ".update_check"
|
|
CHECK_INTERVAL = 86400 # 24 hours in seconds
|
|
TIMEOUT = 2 # seconds
|
|
|
|
def __init__(self, current_version: str):
|
|
"""
|
|
Initialize update checker
|
|
|
|
Args:
|
|
current_version: Current installed version
|
|
"""
|
|
self.current_version = current_version
|
|
self.logger = get_logger()
|
|
|
|
def should_check_update(self, force: bool = False) -> bool:
|
|
"""
|
|
Determine if we should check for updates based on last check time
|
|
|
|
Args:
|
|
force: Force check regardless of last check time
|
|
|
|
Returns:
|
|
True if update check should be performed
|
|
"""
|
|
if force:
|
|
return True
|
|
|
|
if not self.CACHE_FILE.exists():
|
|
return True
|
|
|
|
try:
|
|
with open(self.CACHE_FILE, 'r') as f:
|
|
data = json.load(f)
|
|
last_check = data.get('last_check', 0)
|
|
|
|
# Check if 24 hours have passed
|
|
if time.time() - last_check > self.CHECK_INTERVAL:
|
|
return True
|
|
|
|
except (json.JSONDecodeError, KeyError):
|
|
return True
|
|
|
|
return False
|
|
|
|
def save_check_timestamp(self):
|
|
"""Save the current timestamp as last check time"""
|
|
self.CACHE_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
data = {}
|
|
if self.CACHE_FILE.exists():
|
|
try:
|
|
with open(self.CACHE_FILE, 'r') as f:
|
|
data = json.load(f)
|
|
except:
|
|
pass
|
|
|
|
data['last_check'] = time.time()
|
|
|
|
with open(self.CACHE_FILE, 'w') as f:
|
|
json.dump(data, f)
|
|
|
|
def get_latest_version(self) -> Optional[str]:
|
|
"""
|
|
Query PyPI for the latest version of SuperClaude
|
|
|
|
Returns:
|
|
Latest version string or None if check fails
|
|
"""
|
|
try:
|
|
# Create request with timeout
|
|
req = urllib.request.Request(
|
|
self.PYPI_URL,
|
|
headers={'User-Agent': 'SuperClaude-Updater'}
|
|
)
|
|
|
|
# Set timeout for the request
|
|
with urllib.request.urlopen(req, timeout=self.TIMEOUT) as response:
|
|
data = json.loads(response.read().decode())
|
|
latest = data.get('info', {}).get('version')
|
|
|
|
if self.logger:
|
|
self.logger.debug(f"Latest PyPI version: {latest}")
|
|
|
|
return latest
|
|
|
|
except (urllib.error.URLError, urllib.error.HTTPError, json.JSONDecodeError) as e:
|
|
if self.logger:
|
|
self.logger.debug(f"Failed to check PyPI: {e}")
|
|
return None
|
|
except Exception as e:
|
|
if self.logger:
|
|
self.logger.debug(f"Unexpected error checking updates: {e}")
|
|
return None
|
|
|
|
def compare_versions(self, latest: str) -> bool:
|
|
"""
|
|
Compare current version with latest version
|
|
|
|
Args:
|
|
latest: Latest version string
|
|
|
|
Returns:
|
|
True if update is available
|
|
"""
|
|
try:
|
|
return version.parse(latest) > version.parse(self.current_version)
|
|
except Exception:
|
|
return False
|
|
|
|
def detect_installation_method(self) -> str:
|
|
"""
|
|
Detect how SuperClaude was installed (pip, pipx, etc.)
|
|
|
|
Returns:
|
|
Installation method string
|
|
"""
|
|
# Check pipx first
|
|
try:
|
|
result = subprocess.run(
|
|
['pipx', 'list'],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=2
|
|
)
|
|
if 'SuperClaude' in result.stdout or 'superclaude' in result.stdout:
|
|
return 'pipx'
|
|
except:
|
|
pass
|
|
|
|
# Check if pip installation exists
|
|
try:
|
|
result = subprocess.run(
|
|
[sys.executable, '-m', 'pip', 'show', 'SuperClaude'],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=2
|
|
)
|
|
if result.returncode == 0:
|
|
# Check if it's a user installation
|
|
if '--user' in result.stdout or Path.home() in Path(result.stdout):
|
|
return 'pip-user'
|
|
return 'pip'
|
|
except:
|
|
pass
|
|
|
|
return 'unknown'
|
|
|
|
def get_update_command(self) -> str:
|
|
"""
|
|
Get the appropriate update command based on installation method
|
|
|
|
Returns:
|
|
Update command string
|
|
"""
|
|
method = self.detect_installation_method()
|
|
|
|
commands = {
|
|
'pipx': 'pipx upgrade SuperClaude',
|
|
'pip-user': 'pip install --upgrade --user SuperClaude',
|
|
'pip': 'pip install --upgrade SuperClaude',
|
|
'unknown': 'pip install --upgrade SuperClaude'
|
|
}
|
|
|
|
return commands.get(method, commands['unknown'])
|
|
|
|
def show_update_banner(self, latest: str, auto_update: bool = False) -> bool:
|
|
"""
|
|
Display update available banner
|
|
|
|
Args:
|
|
latest: Latest version available
|
|
auto_update: Whether to auto-update without prompting
|
|
|
|
Returns:
|
|
True if user wants to update
|
|
"""
|
|
update_cmd = self.get_update_command()
|
|
|
|
# Display banner
|
|
print(f"\n{Colors.CYAN}+================================================+{Colors.RESET}")
|
|
print(f"{Colors.CYAN}║{Colors.YELLOW} 🚀 Update Available: {self.current_version} → {latest} {Colors.CYAN}║{Colors.RESET}")
|
|
print(f"{Colors.CYAN}║{Colors.GREEN} Run: {update_cmd:<30} {Colors.CYAN}║{Colors.RESET}")
|
|
print(f"{Colors.CYAN}+================================================+{Colors.RESET}\n")
|
|
|
|
if auto_update:
|
|
return True
|
|
|
|
# Check if running in non-interactive mode
|
|
if not sys.stdin.isatty():
|
|
return False
|
|
|
|
# Prompt user
|
|
try:
|
|
response = input(f"{Colors.YELLOW}Would you like to update now? (y/N): {Colors.RESET}").strip().lower()
|
|
return response in ['y', 'yes']
|
|
except (EOFError, KeyboardInterrupt):
|
|
return False
|
|
|
|
def perform_update(self) -> bool:
|
|
"""
|
|
Execute the update command
|
|
|
|
Returns:
|
|
True if update succeeded
|
|
"""
|
|
update_cmd = self.get_update_command()
|
|
|
|
print(f"{Colors.CYAN}🔄 Updating SuperClaude...{Colors.RESET}")
|
|
|
|
try:
|
|
result = subprocess.run(
|
|
update_cmd.split(),
|
|
capture_output=False,
|
|
text=True
|
|
)
|
|
|
|
if result.returncode == 0:
|
|
display_success("Update completed successfully!")
|
|
print(f"{Colors.YELLOW}Please restart SuperClaude to use the new version.{Colors.RESET}")
|
|
return True
|
|
else:
|
|
display_warning("Update failed. Please run manually:")
|
|
print(f" {update_cmd}")
|
|
return False
|
|
|
|
except Exception as e:
|
|
display_warning(f"Could not auto-update: {e}")
|
|
print(f"Please run manually: {update_cmd}")
|
|
return False
|
|
|
|
def check_and_notify(self, force: bool = False, auto_update: bool = False) -> bool:
|
|
"""
|
|
Main method to check for updates and notify user
|
|
|
|
Args:
|
|
force: Force check regardless of last check time
|
|
auto_update: Automatically update if available
|
|
|
|
Returns:
|
|
True if update was performed
|
|
"""
|
|
# Check if we should skip based on environment variable
|
|
if os.getenv('SUPERCLAUDE_NO_UPDATE_CHECK', '').lower() in ['true', '1', 'yes']:
|
|
return False
|
|
|
|
# Check if auto-update is enabled via environment
|
|
if os.getenv('SUPERCLAUDE_AUTO_UPDATE', '').lower() in ['true', '1', 'yes']:
|
|
auto_update = True
|
|
|
|
# Check if enough time has passed
|
|
if not self.should_check_update(force):
|
|
return False
|
|
|
|
# Get latest version
|
|
latest = self.get_latest_version()
|
|
if not latest:
|
|
return False
|
|
|
|
# Save timestamp
|
|
self.save_check_timestamp()
|
|
|
|
# Compare versions
|
|
if not self.compare_versions(latest):
|
|
return False
|
|
|
|
# Show banner and potentially update
|
|
if self.show_update_banner(latest, auto_update):
|
|
return self.perform_update()
|
|
|
|
return False
|
|
|
|
|
|
def check_for_updates(current_version: str = None, **kwargs) -> bool:
|
|
"""
|
|
Convenience function to check for updates
|
|
|
|
Args:
|
|
current_version: Current installed version (defaults to reading from setup)
|
|
**kwargs: Additional arguments passed to check_and_notify
|
|
|
|
Returns:
|
|
True if update was performed
|
|
"""
|
|
if current_version is None:
|
|
from setup import __version__
|
|
current_version = __version__
|
|
checker = UpdateChecker(current_version)
|
|
return checker.check_and_notify(**kwargs) |