Commit 5a21b75
committed
feat: Simplify configuration from 8+ env vars to zero-config auto-detection
## Problem
Users had to export 8+ environment variables every time:
- CODEGRAPH_LOCAL_MODEL (long HuggingFace cache paths)
- CODEGRAPH_EMBEDDING_PROVIDER
- CODEGRAPH_OLLAMA_URL
- CODEGRAPH_MODEL
- CODEGRAPH_CONTEXT_WINDOW
- CODEGRAPH_TEMPERATURE
- RUST_LOG
- PATH updates
This was error-prone, tedious, and a terrible user experience.
## Solution
Implemented comprehensive configuration system with:
### 1. Auto-Detection
- Automatically finds ONNX models in HuggingFace cache
- Detects if Ollama is running on localhost:11434
- Uses sensible defaults for all settings
- Zero configuration required for most users
### 2. ConfigManager (`config_manager.rs`)
- Smart configuration loader with precedence:
1. Environment variables (.env file or exports)
2. Config file (.codegraph.toml or ~/.codegraph/config.toml)
3. Auto-detection
4. Sensible defaults
- Auto-detects ONNX models: `find_onnx_model_in_cache()`
- Checks Ollama availability: `check_ollama_available()`
- Loads .env from current dir or ~/.codegraph.env
- Comprehensive validation
### 3. Configuration Files
- `.env.example`: One-line setup (CODEGRAPH_EMBEDDING_PROVIDER=auto)
- `.codegraph.toml.example`: Full configuration example with docs
- Both files support all options with helpful comments
### 4. Documentation
- `SIMPLIFIED_CONFIG.md`: Complete migration guide
- Before/after comparison (8 exports → 0-1)
- Quick start guides for different workflows
- Troubleshooting section
## Key Features
- **Zero-config mode**: Just `cargo run -- index .`
- **Auto-detection**: Finds ONNX models in HF cache automatically
- **Flexible**: Supports .env, TOML config, or env vars
- **Backward compatible**: All existing env vars still work
- **Context-only mode**: Perfect for Claude/GPT-4 agents (fastest)
- **Local LLM mode**: One-line enable with CODEGRAPH_MODEL
## Usage Examples
### Before (8 exports):
```bash
export CODEGRAPH_LOCAL_MODEL=/Users/you/.cache/huggingface/hub/models--Qdrant--all-MiniLM-L6-v2-onnx/snapshots/abc123
export CODEGRAPH_EMBEDDING_PROVIDER=onnx
export CODEGRAPH_OLLAMA_URL=http://localhost:11434
export CODEGRAPH_MODEL="hf.co/unsloth/Qwen2.5-Coder-14B-Instruct-128K-GGUF:Q4_K_M"
export CODEGRAPH_CONTEXT_WINDOW=128000
export CODEGRAPH_TEMPERATURE=0.1
export RUST_LOG=info
export PATH="$HOME/.local/bin:$PATH"
cargo run -- index .
```
### After (0 exports):
```bash
cargo run -- index .
```
### After (.env file):
```bash
echo "CODEGRAPH_EMBEDDING_PROVIDER=auto" > .env
cargo run -- index .
```
## Files Changed
- `crates/codegraph-core/src/config_manager.rs`: New ConfigManager with auto-detection
- `crates/codegraph-core/src/lib.rs`: Export config_manager module
- `crates/codegraph-core/Cargo.toml`: Add dotenv and dirs dependencies
- `.env.example`: Extended with simplified CodeGraph configuration
- `.codegraph.toml.example`: Complete example configuration file
- `SIMPLIFIED_CONFIG.md`: Comprehensive migration and usage guide
## Impact
- Reduces configuration complexity by 90%
- Eliminates need to know HuggingFace cache paths
- Works out-of-the-box for most users
- Maintains full flexibility for power users
- Dramatically improves onboarding experience
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 7782583 commit 5a21b75
File tree
6 files changed
+1137
-3
lines changed- crates/codegraph-core
- src
6 files changed
+1137
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
4 | 52 | | |
5 | 53 | | |
6 | 54 | | |
| |||
33 | 81 | | |
34 | 82 | | |
35 | 83 | | |
36 | | - | |
37 | | - | |
| 84 | + | |
| 85 | + | |
38 | 86 | | |
39 | 87 | | |
40 | 88 | | |
| |||
0 commit comments