Implement dynamic version loading system

- 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
This commit is contained in:
NomenAK 2025-08-23 14:10:11 +02:00
parent 4831319a10
commit 9abaa10366
15 changed files with 57 additions and 30 deletions

View File

@ -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"

View File

@ -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}")

View File

@ -1 +1 @@
4.0.7
4.0.7

View File

@ -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():

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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

View File

@ -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)
})

View File

@ -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)
})

View File

@ -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

View File

@ -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

View File

@ -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)
}

View File

@ -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)