/** * CLI Configuration Management */ import Configstore from 'configstore'; import { OllamaConfig } from '@fsfalmansour/neohub-core'; interface CLIConfig { ollama: OllamaConfig; user?: { id: string; email: string; apiKey?: string; }; preferences: { autoContext: boolean; maxContextFiles: number; theme: 'auto' | 'dark' | 'light'; }; } const DEFAULT_CONFIG: CLIConfig = { ollama: { baseUrl: 'http://localhost:11434', model: 'deepseek-coder:33b', timeout: 60000, }, preferences: { autoContext: true, maxContextFiles: 10, theme: 'auto', }, }; export class ConfigManager { private store: Configstore; constructor() { this.store = new Configstore('neohub', DEFAULT_CONFIG); } /** * Get full configuration */ getConfig(): CLIConfig { return this.store.all as CLIConfig; } /** * Get Ollama configuration */ getOllamaConfig(): OllamaConfig { return this.store.get('ollama') as OllamaConfig; } /** * Set Ollama configuration */ setOllamaConfig(config: Partial): void { const current = this.getOllamaConfig(); this.store.set('ollama', { ...current, ...config }); } /** * Get user configuration */ getUser(): CLIConfig['user'] | undefined { return this.store.get('user') as CLIConfig['user'] | undefined; } /** * Set user configuration */ setUser(user: CLIConfig['user']): void { this.store.set('user', user); } /** * Get preferences */ getPreferences(): CLIConfig['preferences'] { return this.store.get('preferences') as CLIConfig['preferences']; } /** * Set preference */ setPreference( key: K, value: CLIConfig['preferences'][K] ): void { this.store.set(`preferences.${key}`, value); } /** * Reset to defaults */ reset(): void { this.store.clear(); this.store.all = DEFAULT_CONFIG; } /** * Get config file path */ getConfigPath(): string { return this.store.path; } }