# KB Configuration

Configuration directory for Knowledge Base project using Nickel schemas.

## Structure

```
.kb-config/
├── README.md           # This file
├── core/               # Core KB configuration
│   └── kb.ncl          # Main KB config
├── platform/           # Platform-specific configs
│   ├── dev.ncl         # Development mode
│   ├── prod.ncl        # Production mode
│   └── test.ncl        # Testing mode
└── targets/            # Target-specific configs (generated)
    ├── kb-cli.json
    ├── kb-mcp.json
    └── kb-core.json
```

## Pattern

Follows the typedialog + provisioning pattern:

1. **Schemas** define types and contracts (`schemas/kb/`)
2. **Defaults** provide base values
3. **Mode overlays** adjust for environment (dev/prod/test)
4. **User customization** overrides for specific needs
5. **Composition** merges layers using Nickel helpers

## Usage

```bash
# Validate configuration
just nickel::validate .kb-config/core/kb.ncl

# Export to JSON for targets
nickel export --format json .kb-config/core/kb.ncl > .kb-config/targets/kb-core.json

# Use in Rust
let config = KbConfig::from_file(".kb-config/targets/kb-core.json")?;
```

## Modes

### Development (`dev.ncl`)
- Filesystem storage only
- Local embeddings (fastembed)
- Debug logging
- Fast iteration

### Production (`prod.ncl`)
- Hybrid storage (filesystem + SurrealDB)
- Cloud embeddings (OpenAI/Claude)
- Production logging
- Performance optimized

### Testing (`test.ncl`)
- In-memory storage
- No embeddings
- Verbose logging
- Test fixtures

## Configuration Layers

```
Base Schema (contracts.ncl)
    ↓
Default Values (defaults.ncl)
    ↓
Mode Overlay (dev/prod/test)
    ↓
User Customization (kb.ncl)
    ↓
Exported JSON (targets/*.json)
```

## See Also

- [Nickel Schemas](../schemas/kb/) - Type definitions
- [Configuration Guide](../docs/config/overview.md) - User documentation
- [ADR-001: Nickel vs TOML](../docs/architecture/adrs/001-nickel-vs-toml.md) - Decision rationale
