Home · Developers · Guides · Configuration

Foundations

Configuration

Layered config: defaults + user yaml

Nova Coder uses a layered, validated configuration system built on Pydantic. Configuration can come from YAML files, environment variables, or programmatic overrides.

Configuration Layers

Layers are loaded in order, with later layers overriding earlier ones:

  1. defaults.yaml, built-in defaults
  2. system.yaml, machine-wide settings
  3. user.yaml, user preferences
  4. workspace.yaml, project-specific settings
  5. Environment variables (NOVACODER_*)
  6. Programmatic overrides passed to create_app()

Default Configuration

The default configuration lives in @config/defaults.yaml:

model:
  provider: ollama
  model: deepseek-coder
  temperature: 0.7

workspace:
  index_on_start: true
  exclude_patterns:
    - .git
    - __pycache__

memory:
  database: sqlite

tools:
  shell: false
  git: true
  python: true
  docker: false
  require_approval: true

agents:
  planner: true
  coder: true
  reviewer: true

Pydantic Models

Configuration is validated by these models:

  • AppConfig, top-level configuration
  • ModelConfig, AI provider settings
  • WorkspaceConfig, project scanning settings
  • MemoryConfig, memory backend settings
  • ToolsConfig, tool permissions
  • AgentsConfig, enabled agents
  • LoggingConfig, logging settings

Loading Configuration

from novacoder.config import ConfigLoader

loader = ConfigLoader()
config = loader.load()

print(config.model.provider)
print(config.workspace.index_on_start)

Environment Variables

Pydantic Settings reads environment variables with the NOVACODER_ prefix and __ as a nested delimiter:

export NOVACODER_MODEL__PROVIDER=openai
export NOVACODER_MODEL__API_KEY=sk-...

Web UI Configuration Editor

The React dashboard exposes the full AppConfig through a structured form in addition to the JSON editor:

  • Component: novacoder/web/react/src/components/ConfigForm.tsx
  • Page: novacoder/web/react/src/pages/Settings.tsx
  • Endpoint: PUT /api/system/config with { updates: draft }

ConfigForm recursively renders all top-level AppConfig sections as collapsible cards with type-aware controls for string, number, boolean, primitive array, and nested object values. It falls back to a JSON textarea for non-primitive arrays or unsupported shapes. This makes configuration editing safer and more discoverable than editing raw JSON.

Path Configuration Environment Variables

Nova Coder supports comprehensive path configuration through environment variables, allowing you to customize where the application stores its data and configuration files.

Data Directory Configuration:

# Set the main application data directory
export NOVACODER_DATA_DIR=/custom/path/novacoder

Memory Database Path:

# Set the memory database path explicitly
export NOVACODER_MEMORY__DB_PATH=/custom/path/memory.db

Default Paths: If no environment variables are set, Nova Coder uses the following default paths:

  • Data directory: ~/.config/novacoder/
  • Memory database: ~/.config/novacoder/memory.db

Example Usage:

# Use a custom data directory for development
NOVACODER_DATA_DIR=/tmp/novacoder_dev novacoder serve

# Use a custom memory database for testing
NOVACODER_MEMORY__DB_PATH=/tmp/test_memory.db novacoder doctor

Path Configuration in Code:

from novacoder.config.settings import AppConfig
from novacoder.memory.memory import MemoryStore

# Environment variables are automatically respected
config = AppConfig()
print(f"Data dir: {config.data_dir}")  # Uses NOVACODER_DATA_DIR if set

# Memory store also respects environment variables
memory_store = MemoryStore()  # Uses NOVACODER_MEMORY__DB_PATH if set

Programmatic Overrides

from novacoder.app import create_app

app = create_app(overrides={
    "model": {"provider": "openai"},
    "workspace": {"index_on_start": False},
    "tools": {"shell": True, "require_approval": False},
})

Workspace Settings

The workspace section controls project scanning and indexing:

  • project_path, path to the project root (null defaults to the current working directory).
  • index_on_start, when true, WorkspaceService scans the project during application startup.
  • incremental, when true, subsequent scans only re-read files whose hashes have changed.
  • exclude_patterns, glob patterns for directories and files to skip. Supports */?/[seq] via fnmatch, and ** for recursive matching.
  • max_file_size, files larger than this many bytes are skipped.
workspace:
  project_path: null
  index_on_start: true
  incremental: true
  exclude_patterns:
    - .git
    - __pycache__
    - node_modules
    - "*.pyc"
    - "test_*.py"
    - "**/*.log"
  max_file_size: 1000000

Tools Permissions

The tools section controls both tool registration and safety gates:

  • shell, enables run_shell (requires run_shell_commands permission).
  • git, enables the git tool suite (requires access_git permission).
  • python, enables run_python (requires run_shell_commands permission).
  • docker, enables run_docker (requires run_shell_commands and network_access permissions).
  • db, enables query_database (requires database_access permission).
  • ssh, enables ssh_command (requires ssh_access permission).
  • k8s, enables kubectl (requires kubernetes_access permission).
  • require_approval, when true, every tool with declared permissions is gated by an approval callback before run() is called.

PermissionsService builds a PermissionChecker from these flags and injects it into ToolService at boot time.

ConfigService

ConfigService is a kernel service that loads configuration during boot:

from novacoder.config.service import ConfigService

service = ConfigService(overrides={})
service.initialize()
config = service.config

Configuration by Key

provider = config_service.get("model.provider", default="ollama")

Configuration Validation

The ConfigService includes comprehensive settings validation to prevent invalid configurations from causing runtime errors:

from novacoder.config.service import ConfigService

service = ConfigService()
service.initialize()

# Validate settings
settings = {
    "api": {"base_url": "http://localhost:8000", "timeout": 30},
    "ai": {"model": "gpt-4", "temperature": 0.7, "max_tokens": 2048},
    "workspace": {"index_on_start": True, "max_file_size": 1048576},
    "memory": {"max_entries": 1000, "ttl": 3600}
}

is_valid, errors = service.validate_settings(settings)
if not is_valid:
    for error in errors:
        print(f"Validation error: {error}")

Validation Rules:

  • API Settings:
    • base_url must be a string
    • timeout must be a positive number
  • AI Settings:
    • model must be a string
    • temperature must be a number between 0 and 2
    • max_tokens must be a positive integer
  • Workspace Settings:
    • index_on_start must be a boolean
    • max_file_size must be a positive integer
  • Memory Settings:
    • max_entries must be a positive integer
    • ttl must be a positive integer

Configuration Import/Export

The ConfigService supports importing and exporting configuration to YAML files:

from novacoder.config.service import ConfigService
from pathlib import Path

service = ConfigService()
service.initialize()

# Export configuration
export_path = Path("/tmp/novacoder_config.yaml")
service.export_settings(export_path, include_profiles=True)

# Import configuration (replace existing)
success, errors = service.import_settings(export_path, merge=False)
if not success:
    print(f"Import failed: {errors}")

# Import configuration (merge with existing)
success, errors = service.import_settings(export_path, merge=True)
if not success:
    print(f"Import failed: {errors}")

Export Features:

  • Exports main configuration and custom configuration
  • Option to include profiles in the export
  • Saves to YAML format for easy editing
  • Creates parent directories if they don't exist

Import Features:

  • Validates imported settings before applying
  • Supports both replace and merge modes
  • Deep merge for nested configuration structures
  • Returns success status and error messages

Configuration Profiles

The ConfigService supports multiple configuration profiles for different use cases:

from novacoder.config.service import ConfigService

service = ConfigService()
service.initialize()

# Create a new profile
service.create_profile("development", "Development environment configuration")

# List available profiles
profiles = service.list_profiles()
for name, description in profiles.items():
    print(f"{name}: {description}")

# Load a profile
success, error = service.load_profile("development")
if not success:
    print(f"Failed to load profile: {error}")

# Delete a profile
deleted = service.delete_profile("development")
if deleted:
    print("Profile deleted successfully")

Profile Features:

  • Create profiles with descriptions
  • Save current configuration as a profile
  • Load profiles to switch configurations
  • List all available profiles
  • Delete profiles when no longer needed
  • Profiles stored in custom_config.json under the profiles key

Profile Use Cases:

  • Development Profile: Local development settings
  • Production Profile: Production environment settings
  • Testing Profile: Testing environment settings
  • Team Profile: Shared team configuration

Development Instructions

Adding a New Configuration Section

  1. Define a Pydantic model in novacoder/config/settings.py.
  2. Add it as a field on AppConfig with a default factory.
  3. Add sensible defaults to config/defaults.yaml.
  4. Update this wiki page and any services that consume the new section.

Example: Adding a New Section

from pydantic import BaseModel

class CacheConfig(BaseModel):
    enabled: bool = True
    ttl: int = 3600

class AppConfig(BaseSettings):
    cache: CacheConfig = Field(default_factory=CacheConfig)

Testing Configuration

from novacoder.config import ConfigLoader

loader = ConfigLoader()
config = loader.load({"cache": {"ttl": 60}})
assert config.cache.ttl == 60

Validation

Pydantic will raise ValidationError for invalid types. Wrap loading in ConfigLoader.load() to convert it into a ValueError with a clear message.

Best Practices

  • Store secrets in environment variables, not YAML files.
  • Keep project-specific settings in workspace.yaml.
  • Use overrides in tests to avoid side effects.
  • Validate any custom config fields by extending the Pydantic models.

Web API Configuration UI

Nova Coder provides a web-based configuration interface that allows users to manage API and model settings through the browser.

Configuration Page

The web interface includes a dedicated Configuration page accessible from the sidebar with the following features:

  • API Configuration Form: Configure API host, port, and optional authentication token
  • Model Configuration Form: Configure AI provider, model name, and custom base URL
  • Connection Testing: Test API connectivity with current settings before saving
  • Real-time Updates: Configuration changes take effect immediately after saving
  • Full Configuration View: Read-only display of all configuration sections

API Configuration Endpoints

POST /api/config/update

Update configuration settings for a specific section:

curl -X POST http://localhost:8000/api/config/update \
  -H "Content-Type: application/json" \
  -d '{
    "section": "api",
    "updates": {
      "host": "0.0.0.0",
      "port": 8000,
      "token": "optional_token"
    }
  }'

Request Model:

  • section: Configuration section to update (api, model, workspace, memory, tools, agents, plugins, logging, security)
  • updates: Dictionary of key-value pairs to update in the specified section

Response:

{
  "success": true,
  "message": "Configuration section 'api' updated successfully",
  "updated": {
    "host": "0.0.0.0",
    "port": 8000,
    "token": "optional_token"
  }
}

Configuration Validation

The web interface includes comprehensive client-side validation:

  • API Configuration:
    • Host: Required field, must be a valid hostname or IP address
    • Port: Required field, must be between 1-65535
    • Token: Optional field, if provided must be 16-256 characters with alphanumeric characters, hyphens, and underscores only
  • Model Configuration:
    • Provider: Required field, must be a valid AI provider name
    • Model: Required field, must be a valid model identifier
    • Base URL: Optional field, if provided must be a valid URL
  • Connection Testing: Validates API connectivity before saving changes
  • Error Display: Validation errors are displayed inline with the corresponding form fields

Configuration Import/Export

The web interface provides configuration backup and restore functionality:

Export Configuration

Export the current configuration to a JSON file for backup:

// Client-side export function
async function exportConfiguration(){
  const cfg=await api('/api/config');
  const configJson=JSON.stringify(cfg,null,2);
  const blob=new Blob([configJson],{type:'application/json'});
  const url=URL.createObjectURL(blob);
  const a=document.createElement('a');
  a.href=url;
  a.download=`novacoder-config-${new Date().toISOString().split('T')[0]}.json`;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url);
}

Features:

  • Exports all configuration sections to a single JSON file
  • Filename includes date for easy identification
  • Pretty-printed JSON for readability
  • Automatic browser download

Import Configuration

Import configuration from a JSON file:

// Client-side import function
async function importConfiguration(){
  const fileInput=$('config-import-file');
  if(!fileInput.files||!fileInput.files[0]){
    return;
  }
  const file=fileInput.files[0];
  const reader=new FileReader();
  reader.onload=async(e)=>{
    try{
      const config=JSON.parse(e.target.result);
      if(!confirm('This will overwrite your current configuration. Are you sure?'))return;
      const validSections=['api','model','workspace','memory','tools','agents','plugins','logging','security'];
      let allSuccess=true;
      for(const section of validSections){
        if(config[section]){
          const res=await apiWithRetry('/api/config/update',{
            method:'POST',
            headers:{'Content-Type':'application/json'},
            body:JSON.stringify({section,updates:config[section]})
          });
          if(!res.success){
            allSuccess=false;
            showError(`Import ${section}`,new Error(res.error||'Failed to import section'));
          }
        }
      }
      if(allSuccess){
        alert('Configuration imported successfully');
        renderConfig();
      }else{
        alert('Configuration imported with some errors. Check console for details.');
      }
    }catch(err){
      showError('Import Configuration',err);
    }finally{
      fileInput.value='';
    }
  };
  reader.readAsText(file);
}

Features:

  • Imports configuration from JSON file
  • Section-based import for granular control
  • User confirmation before overwriting existing configuration
  • Error handling for each section
  • Success/failure feedback
  • Automatic UI refresh after successful import

Valid Configuration Sections:

  • api - API host, port, and token settings
  • model - AI provider, model, and base URL settings
  • workspace - Project scanning and indexing settings
  • memory - Memory backend settings
  • tools - Tool permissions and settings
  • agents - Agent configuration
  • plugins - Plugin settings
  • logging - Logging configuration
  • security - Security settings

Usage:

  1. Click "Export Configuration" to download current configuration as JSON
  2. Store the exported file as a backup
  3. To restore, click "Import Configuration" and select the JSON file
  4. Confirm the import operation
  5. Configuration is applied section by section
  6. UI refreshes to reflect the imported configuration

Configuration Persistence

Configuration changes made through the web interface are saved to user.yaml in the configuration directory (~/.config/novacoder/ by default). This ensures that changes persist across application restarts.

Usage

  1. Navigate to the Configuration page in the web interface
  2. Fill in the desired configuration values
  3. Click "Test Connection" (for API settings) to verify connectivity
  4. Click "Save Configuration" to apply changes
  5. The configuration is immediately updated and persisted

Source: wiki/configuration.md · rendered 2026-11-10