@mettamatt/code-reasoning
Version:
Enhanced MCP server for code reasoning using sequential thinking methodology, optimized for programming tasks
85 lines (84 loc) • 2.13 kB
JavaScript
/**
* @fileoverview Configuration manager for code-reasoning server
*
* This module provides a singleton configuration manager that handles
* configuration settings for the code-reasoning server in memory.
*/
/**
* Singleton config manager for the server
*/
class ConfigManager {
config;
initialized = false;
constructor() {
// Initialize with default config
this.config = this.getDefaultConfig();
}
/**
* Initialize configuration
*/
async init() {
if (this.initialized)
return;
try {
// In-memory only configuration, no filesystem operations needed
this.initialized = true;
}
catch (error) {
console.error('Failed to initialize config:', error);
// Fall back to default config in memory
this.config = this.getDefaultConfig();
this.initialized = true;
}
}
/**
* Create default configuration
*/
getDefaultConfig() {
return {
maxThoughtLength: 20000,
timeoutMs: 60000,
maxThoughts: 20,
debug: false,
promptsEnabled: true,
};
}
/**
* Get the entire config
*/
async getConfig() {
await this.init();
return { ...this.config };
}
/**
* Get a specific configuration value
*/
async getValue(key) {
await this.init();
return this.config[key];
}
/**
* Set a specific configuration value
*/
async setValue(key, value) {
await this.init();
this.config[key] = value;
}
/**
* Update multiple configuration values at once
*/
async updateConfig(updates) {
await this.init();
this.config = { ...this.config, ...updates };
return { ...this.config };
}
/**
* Reset configuration to defaults
*/
async resetConfig() {
this.config = this.getDefaultConfig();
return { ...this.config };
}
}
// Export singleton instance
export const configManager = new ConfigManager();