class CapabilityBuilder:
    def __init__(self):
        self.registered_capabilities = {}
        self.dependencies = {}
        self.configurations = {}
        self.version_history = {}

    def register_capability(self, name, version, dependencies=None):
        """
        Register a new capability with its dependencies and version.
        
        Args:
            name (str): Name of the capability
            version (str): Version number of the capability
            dependencies (dict): Dictionary of dependencies and their versions
            
        Returns:
            bool: True if registration was successful, False otherwise
        """
        if not dependencies:
            dependencies = {}
            
        # Validate dependencies
        for dep in dependencies:
            if dep not in self.dependencies:
                raise ValueError(f"Dependency {dep} is not registered")
                
        self.registered_capabilities[name] = {
            "version": version,
            "dependencies": dependencies
        }
        return True

    def auto_detect_from_file(self, file_path):
        """
        Automatically detect capabilities from a file and register them.
        
        Args:
            file_path (str): Path to the capability file
            
        Returns:
            bool: True if capabilities were detected and registered, False otherwise
        """
        try:
            # Import module from file path
            import importlib
            spec = importlib.util.spec_from_file_location("capability", file_path)
            module = importlib.module_from_spec(spec)
            spec.loader.exec_module(module)
            
            # Check for capabilities in the module
            if hasattr(module, "CAPABILITY_NAME"):
                capability_name = module.CAPABILITY_NAME
                capability_class = getattr(module, capability_name)
                
                # Get version from module or class
                version = getattr(module, "VERSION", "1.0.0")
                
                # Register the capability
                self.register_capability(capability_name, version)
                return True
                
            else:
                raise ValueError("Module does not contain a CAPABILITY_NAME attribute")
        except Exception as e:
            print(f"Error detecting capabilities from {file_path}: {e}")
            return False

    def validate_dependencies(self):
        """
        Validate that all dependencies for registered capabilities are satisfied.
        
        Returns:
            bool: True if all dependencies are satisfied, False otherwise
        """
        for name, details in self.registered_capabilities.items():
            for dep, required_version in details["dependencies"].items():
                if dep not in self.dependencies or \
                   self.dependencies[dep].version < required_version:
                    return False
        return True

    def set_global_config(self, config_name, value):
        """
        Set global configurations that affect all capabilities.
        
        Args:
            config_name (str): Name of the configuration parameter
            value: Value to set for the configuration
            
        Returns:
            bool: True if configuration was set successfully, False otherwise
        """
        self.configurations[config_name] = value
        return True

    def resolve_dependency_versions(self):
        """
        Resolve and update versions of all dependencies based on registered capabilities.
        
        Returns:
            bool: True if dependency versions were updated successfully, False otherwise
        """
        for name, details in self.registered_capabilities.items():
            for dep in details["dependencies"]:
                # This is a simplified version; actual implementation would depend on the 
                # specific dependency management system being used
                pass
                
        return True

    def get_version_number(self):
        """
        Generate and return the next available version number based on semantic versioning.
        
        Returns:
            str: Version string in x.y.z format
        """
        # Simple implementation; actual version tracking would be more complex
        last_version = self.version_history.get("current", "0.0.0")
        parts = list(map(int, last_version.split('.')))
        parts[-1] += 1
        new_version = '.'.join(map(str, parts))
        self.version_history["current"] = new_version
        return new_version

    def build_capability(self, capability_name):
        """
        Build a specific capability from its registered details.
        
        Args:
            capability_name (str): Name of the capability to build
            
        Returns:
            bool: True if building was successful, False otherwise
        """
        # Validate capability exists
        if capability_name not in self.registered_capabilities:
            raise ValueError(f"Capability {capability_name} is not registered")
            
        # Check dependencies
        if not self.validate_dependencies():
            raise RuntimeError("Some dependencies are not satisfied")
            
        # Build process
        try:
            # Get the capability class or module
            # This would involve loading the capability's code and compiling it
            # The exact implementation depends on how capabilities are structured
            
            return True
        except Exception as e:
            print(f"Error building capability {capability_name}: {e}")
            return False

# Example usage:

builder = CapabilityBuilder()

# Register a new capability
builder.register_capability("math_operations", "1.0.0", {
    "numpy": ">=1.20",
    "pandas": ">=1.3"
})

# Automatically detect capabilities from a file
builder.auto_detect_from_file("path/to/math_capabilities.py")

# Set global configurations
builder.set_global_config("logging_level", "INFO")
builder.set_global_config("enable_debug_mode", True)

# Validate all dependencies are satisfied
builder.validate_dependencies()

# Resolve dependency versions
builder.resolve_dependency_versions()

# Get next version number
new_version = builder.get_version_number()

# Build a specific capability
success = builder.build_capability("math_operations")