From 9abaa10366f2491ba563a5a25a4a185289e6d367 Mon Sep 17 00:00:00 2001 From: NomenAK Date: Sat, 23 Aug 2025 14:10:11 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Implement=20dynamic=20version=20loa?= =?UTF-8?q?ding=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert all hardcoded versions to dynamic loading from VERSION file - Reduce version update locations from 50+ to just 3 files - Add proper fallback handling for version reading - Update all CLI commands to use dynamic __version__ - Streamline future version management process This change makes version bumping much simpler - only need to update: 1. VERSION file 2. package.json 3. pyproject.toml --- SuperClaude/__init__.py | 8 +++++++- SuperClaude/__main__.py | 9 ++++++--- VERSION | 2 +- setup/cli/base.py | 8 +++++++- setup/cli/commands/backup.py | 5 +++-- setup/cli/commands/install.py | 3 ++- setup/cli/commands/uninstall.py | 3 ++- setup/cli/commands/update.py | 2 +- setup/components/agents.py | 7 ++++--- setup/components/commands.py | 9 +++++---- setup/components/core.py | 9 +++++---- setup/components/mcp.py | 5 +++-- setup/components/mcp_docs.py | 5 +++-- setup/components/modes.py | 5 +++-- setup/utils/updater.py | 7 +++++-- 15 files changed, 57 insertions(+), 30 deletions(-) diff --git a/SuperClaude/__init__.py b/SuperClaude/__init__.py index 5e8c1a9..436ba19 100644 --- a/SuperClaude/__init__.py +++ b/SuperClaude/__init__.py @@ -11,7 +11,13 @@ Usage: SuperClaude --help """ -__version__ = "4.0.7" +from pathlib import Path + +# Read version from VERSION file +try: + __version__ = (Path(__file__).parent.parent / "VERSION").read_text().strip() +except Exception: + __version__ = "4.0.7" # Fallback __author__ = "NomenAK, Mithun Gowda B" __email__ = "anton.knoery@gmail.com" __license__ = "MIT" diff --git a/SuperClaude/__main__.py b/SuperClaude/__main__.py index 27b239b..1e81ba9 100644 --- a/SuperClaude/__main__.py +++ b/SuperClaude/__main__.py @@ -98,7 +98,8 @@ Examples: parents=[global_parser] ) - parser.add_argument("--version", action="version", version="SuperClaude 4.0.7") + from SuperClaude import __version__ + parser.add_argument("--version", action="version", version=f"SuperClaude {__version__}") subparsers = parser.add_subparsers( dest="operation", @@ -208,8 +209,9 @@ def main() -> int: try: from setup.utils.updater import check_for_updates # Check for updates in the background + from SuperClaude import __version__ updated = check_for_updates( - current_version="4.0.7", + current_version=__version__, auto_update=getattr(args, 'auto_update', False) ) # If updated, suggest restart @@ -226,7 +228,8 @@ def main() -> int: # No operation provided? Show help manually unless in quiet mode if not args.operation: if not args.quiet: - display_header("SuperClaude Framework v4.0.7", "Unified CLI for all operations") + from SuperClaude import __version__ + display_header(f"SuperClaude Framework v{__version__}", "Unified CLI for all operations") print(f"{Colors.CYAN}Available operations:{Colors.RESET}") for op, desc in get_operation_modules().items(): print(f" {op:<12} {desc}") diff --git a/VERSION b/VERSION index d356c34..43beb40 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.7 \ No newline at end of file +4.0.7 diff --git a/setup/cli/base.py b/setup/cli/base.py index 51f806a..751bc98 100644 --- a/setup/cli/base.py +++ b/setup/cli/base.py @@ -4,7 +4,13 @@ SuperClaude CLI Base Module Base class for all CLI operations providing common functionality """ -__version__ = "4.0.7" +from pathlib import Path + +# Read version from VERSION file +try: + __version__ = (Path(__file__).parent.parent.parent / "VERSION").read_text().strip() +except Exception: + __version__ = "4.0.7" # Fallback def get_command_info(): diff --git a/setup/cli/commands/backup.py b/setup/cli/commands/backup.py index edbb881..5c3ef93 100644 --- a/setup/cli/commands/backup.py +++ b/setup/cli/commands/backup.py @@ -234,7 +234,7 @@ def display_backup_list(backups: List[Dict[str, Any]]) -> None: def create_backup_metadata(install_dir: Path) -> Dict[str, Any]: """Create metadata for the backup""" metadata = { - "backup_version": "4.0.7", + "backup_version": __version__, "created": datetime.now().isoformat(), "install_dir": str(install_dir), "components": {}, @@ -513,8 +513,9 @@ def run(args: argparse.Namespace) -> int: # Display header if not args.quiet: + from setup.cli.base import __version__ display_header( - "SuperClaude Backup v3.0", + f"SuperClaude Backup v{__version__}", "Backup and restore SuperClaude installations" ) diff --git a/setup/cli/commands/install.py b/setup/cli/commands/install.py index 00c62b2..247e619 100644 --- a/setup/cli/commands/install.py +++ b/setup/cli/commands/install.py @@ -559,8 +559,9 @@ def run(args: argparse.Namespace) -> int: # Display header if not args.quiet: + from setup.cli.base import __version__ display_header( - "SuperClaude Installation v3.0", + f"SuperClaude Installation v{__version__}", "Installing SuperClaude framework components" ) diff --git a/setup/cli/commands/uninstall.py b/setup/cli/commands/uninstall.py index d87417d..07d1870 100644 --- a/setup/cli/commands/uninstall.py +++ b/setup/cli/commands/uninstall.py @@ -785,8 +785,9 @@ def run(args: argparse.Namespace) -> int: # Display header if not args.quiet: + from setup.cli.base import __version__ display_header( - "SuperClaude Uninstall v3.0", + f"SuperClaude Uninstall v{__version__}", "Removing SuperClaude framework components" ) diff --git a/setup/cli/commands/update.py b/setup/cli/commands/update.py index 1d4a0d2..30150f5 100644 --- a/setup/cli/commands/update.py +++ b/setup/cli/commands/update.py @@ -405,7 +405,7 @@ def run(args: argparse.Namespace) -> int: # Display header if not args.quiet: display_header( - "SuperClaude Update v4.0.7", + f"SuperClaude Update v{__version__}", "Updating SuperClaude framework components" ) diff --git a/setup/components/agents.py b/setup/components/agents.py index c7c696c..b96fe8f 100644 --- a/setup/components/agents.py +++ b/setup/components/agents.py @@ -6,6 +6,7 @@ from typing import Dict, List, Tuple, Optional, Any from pathlib import Path from ..core.base import Component +from setup import __version__ class AgentsComponent(Component): @@ -19,7 +20,7 @@ class AgentsComponent(Component): """Get component metadata""" return { "name": "agents", - "version": "4.0.7", + "version": __version__, "description": "14 specialized AI agents with domain expertise and intelligent routing", "category": "agents" } @@ -29,7 +30,7 @@ class AgentsComponent(Component): return { "components": { "agents": { - "version": "4.0.7", + "version": __version__, "installed": True, "agents_count": len(self.component_files), "install_directory": str(self.install_component_subdir) @@ -63,7 +64,7 @@ class AgentsComponent(Component): # Add component registration self.settings_manager.add_component_registration("agents", { - "version": "4.0.7", + "version": __version__, "category": "agents", "agents_count": len(self.component_files), "agents_list": self.component_files diff --git a/setup/components/commands.py b/setup/components/commands.py index 61cbb06..6ee45fb 100644 --- a/setup/components/commands.py +++ b/setup/components/commands.py @@ -6,6 +6,7 @@ from typing import Dict, List, Tuple, Optional, Any from pathlib import Path from ..core.base import Component +from setup import __version__ class CommandsComponent(Component): """SuperClaude slash commands component""" @@ -18,7 +19,7 @@ class CommandsComponent(Component): """Get component metadata""" return { "name": "commands", - "version": "4.0.7", + "version": __version__, "description": "SuperClaude slash command definitions", "category": "commands" } @@ -28,14 +29,14 @@ class CommandsComponent(Component): return { "components": { "commands": { - "version": "4.0.7", + "version": __version__, "installed": True, "files_count": len(self.component_files) } }, "commands": { "enabled": True, - "version": "4.0.7", + "version": __version__, "auto_update": False } } @@ -58,7 +59,7 @@ class CommandsComponent(Component): # Add component registration to metadata self.settings_manager.add_component_registration("commands", { - "version": "4.0.7", + "version": __version__, "category": "commands", "files_count": len(self.component_files) }) diff --git a/setup/components/core.py b/setup/components/core.py index cfbe522..e6820d9 100644 --- a/setup/components/core.py +++ b/setup/components/core.py @@ -8,6 +8,7 @@ import shutil from ..core.base import Component from ..services.claude_md import CLAUDEMdService +from setup import __version__ class CoreComponent(Component): """Core SuperClaude framework files component""" @@ -20,7 +21,7 @@ class CoreComponent(Component): """Get component metadata""" return { "name": "core", - "version": "4.0.7", + "version": __version__, "description": "SuperClaude framework documentation and core files", "category": "core" } @@ -29,7 +30,7 @@ class CoreComponent(Component): """Get metadata modifications for SuperClaude""" return { "framework": { - "version": "4.0.7", + "version": __version__, "name": "SuperClaude", "description": "AI-enhanced development framework for Claude Code", "installation_type": "global", @@ -37,7 +38,7 @@ class CoreComponent(Component): }, "superclaude": { "enabled": True, - "version": "4.0.7", + "version": __version__, "profile": "default", "auto_update": False } @@ -58,7 +59,7 @@ class CoreComponent(Component): # Add component registration to metadata self.settings_manager.add_component_registration("core", { - "version": "4.0.7", + "version": __version__, "category": "core", "files_count": len(self.component_files) }) diff --git a/setup/components/mcp.py b/setup/components/mcp.py index 7fb3a80..4a3bc52 100644 --- a/setup/components/mcp.py +++ b/setup/components/mcp.py @@ -21,6 +21,7 @@ except ImportError: LOCKING_AVAILABLE = None from ..core.base import Component +from setup import __version__ from ..utils.ui import display_info, display_warning @@ -102,7 +103,7 @@ class MCPComponent(Component): """Get component metadata""" return { "name": "mcp", - "version": "4.0.7", + "version": __version__, "description": "MCP server configuration management via .claude.json", "category": "integration" } @@ -348,7 +349,7 @@ class MCPComponent(Component): metadata_mods = { "components": { "mcp": { - "version": "4.0.7", + "version": __version__, "installed": True, "servers_configured": len(self.selected_servers), "configured_servers": self.selected_servers diff --git a/setup/components/mcp_docs.py b/setup/components/mcp_docs.py index 9217864..f31e782 100644 --- a/setup/components/mcp_docs.py +++ b/setup/components/mcp_docs.py @@ -6,6 +6,7 @@ from typing import Dict, List, Tuple, Optional, Any from pathlib import Path from ..core.base import Component +from setup import __version__ from ..services.claude_md import CLAUDEMdService @@ -34,7 +35,7 @@ class MCPDocsComponent(Component): """Get component metadata""" return { "name": "mcp_docs", - "version": "4.0.7", + "version": __version__, "description": "MCP server documentation and usage guides", "category": "documentation" } @@ -135,7 +136,7 @@ class MCPDocsComponent(Component): metadata_mods = { "components": { "mcp_docs": { - "version": "4.0.7", + "version": __version__, "installed": True, "files_count": len(self.component_files), "servers_documented": self.selected_servers diff --git a/setup/components/modes.py b/setup/components/modes.py index 338567d..d1b52a0 100644 --- a/setup/components/modes.py +++ b/setup/components/modes.py @@ -6,6 +6,7 @@ from typing import Dict, List, Tuple, Optional, Any from pathlib import Path from ..core.base import Component +from setup import __version__ from ..services.claude_md import CLAUDEMdService @@ -20,7 +21,7 @@ class ModesComponent(Component): """Get component metadata""" return { "name": "modes", - "version": "4.0.7", + "version": __version__, "description": "SuperClaude behavioral modes (Brainstorming, Introspection, Task Management, Token Efficiency)", "category": "modes" } @@ -69,7 +70,7 @@ class ModesComponent(Component): metadata_mods = { "components": { "modes": { - "version": "4.0.7", + "version": __version__, "installed": True, "files_count": len(self.component_files) } diff --git a/setup/utils/updater.py b/setup/utils/updater.py index 608a12d..ae46557 100644 --- a/setup/utils/updater.py +++ b/setup/utils/updater.py @@ -295,16 +295,19 @@ class UpdateChecker: return False -def check_for_updates(current_version: str = "4.0.7", **kwargs) -> bool: +def check_for_updates(current_version: str = None, **kwargs) -> bool: """ Convenience function to check for updates Args: - current_version: Current installed version + 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) \ No newline at end of file