feat: config loader with validation and tilde expansion
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import yaml
|
||||
|
||||
CONFIG_PATH = os.path.expanduser('~/.claude/autoresearch.yaml')
|
||||
DEFAULTS = {'time_limit_minutes': 10, 'benchmarks': []}
|
||||
|
||||
class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
def load_config(path=CONFIG_PATH):
|
||||
with open(path) as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
if not cfg or 'projects' not in cfg or not cfg['projects']:
|
||||
raise ConfigError(f"'projects' list is required in {path}")
|
||||
for p in cfg['projects']:
|
||||
p.setdefault('benchmarks', DEFAULTS['benchmarks'])
|
||||
p.setdefault('time_limit_minutes', DEFAULTS['time_limit_minutes'])
|
||||
p['path'] = os.path.expanduser(p['path'])
|
||||
cfg.setdefault('token_threshold', {'context_remaining_pct': 60, 'api_budget_usd': 5.0})
|
||||
return cfg
|
||||
Reference in New Issue
Block a user