Skip to content

Config Manager

codebrief.utils.config_manager

Configuration management utilities.

Functions

load_config(project_root)

Load configuration from codebrief.toml or pyproject.toml.

Source code in src/codebrief/utils/config_manager.py
def load_config(project_root: Path) -> Dict[str, Any]:
    """Load configuration from codebrief.toml or pyproject.toml."""
    config_paths = [
        project_root / "codebrief.toml",
        project_root / "pyproject.toml",
    ]

    for config_path in config_paths:
        if config_path.exists():
            try:
                with config_path.open("rb") as f:
                    data = _get_toml_loader()(f)

                raw_config = {}
                if config_path.name == "pyproject.toml":
                    # Extract codebrief section from pyproject.toml
                    raw_config = data.get("tool", {}).get(CONFIG_SECTION_NAME, {})
                else:
                    # For codebrief.toml, return the whole thing
                    raw_config = data

                return _validate_and_merge_config(raw_config)

            except Exception as e:
                _warn_config_load_error(config_path, e)
                continue

    # No config found or all failed to load - return defaults
    return EXPECTED_DEFAULTS.copy()

The config manager module provides configuration management functionality for CodeBrief, handling default settings and user-defined configurations.

Overview

The config manager is responsible for:

  • Loading and managing configuration files
  • Providing default configuration values
  • Handling configuration validation
  • Managing configuration overrides

Configuration Files

CodeBrief supports configuration through:

  • Project-level configuration files
  • User-level configuration files
  • Environment variable overrides
  • Command-line argument overrides

Default Configuration

The config manager provides sensible defaults for all configuration options, ensuring that CodeBrief works out of the box without requiring extensive configuration.

  • bundler: Uses configuration for bundle settings
  • git_provider: Uses configuration for Git-related settings