This article is about:
- Modular settings configuration system design
- Settings registry and access control patterns
- Architecture of the settings abstraction layer
The settings are organized into categories (LLM, paths, tool calling, UI) with centralized management through SettingsRegistry.
Warning
Although called a "registry", the current implementation do not follow all the archetypes expected in a registry pattern. In particular, there is no dynamic registration of settings categories at this point (this is static in )
Settings are organized into separate modules:
- LLMSettings: API configuration for language model interactions
- PathSettings: File and directory path management
- ToolCallingSettings: Behavior control for tool execution
- UISettings: User interface preferences including language selection
Each category follows the same pattern with Pydantic models for validation and default values.
The SettingsRegistry class provides centralized management:
- Access Control: Enforces normal, protected, and read-only access levels
- Validation: Uses Pydantic for type checking and constraint validation
- Search: Implements staged search (exact, category, regex, fuzzy matching)
- Import/Export: Supports TOML, JSON, and YAML formats
Three access levels control setting modification:
NORMAL: Standard settings that can be changed freelyPROTECTED: Sensitive settings requiring explicit force flagREAD_ONLY: System-computed values that cannot be modified
Settings integrate with the i18n system for display names and descriptions. See docs/articles/devs/i18n_support.md for details.
Settings commands are exposed through the chat interface via SettingsCommands class. See hatchling/core/chat/settings_commands.py for implementation.
Settings are automatically persisted to configuration files and can be imported/exported in multiple formats.
hatchling/config/settings.py: Root settings aggregationhatchling/config/settings_registry.py: Central registry implementationhatchling/config/*_settings.py: Individual category implementationshatchling/core/chat/settings_commands.py: Command interface