rosie-cli
Version:
AI-powered command-line interface tool that uses OpenAI's API to help you interact with your computer through natural language
52 lines (51 loc) • 1.63 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigManager = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const os_1 = __importDefault(require("os"));
class ConfigManager {
constructor() {
// Store config in user's home directory
this.configPath = path_1.default.join(os_1.default.homedir(), '.rosie-config.json');
this.config = this.loadConfig();
}
loadConfig() {
try {
if (fs_1.default.existsSync(this.configPath)) {
const configData = fs_1.default.readFileSync(this.configPath, 'utf-8');
return JSON.parse(configData);
}
}
catch (error) {
console.error('Error loading config:', error);
}
return {};
}
saveConfig() {
try {
fs_1.default.writeFileSync(this.configPath, JSON.stringify(this.config, null, 2));
}
catch (error) {
console.error('Error saving config:', error);
}
}
getOpenAIKey() {
return this.config.openai_key;
}
setOpenAIKey(key) {
this.config.openai_key = key;
this.saveConfig();
}
getActiveConversationId() {
return this.config.active_conversation_id;
}
setActiveConversationId(id) {
this.config.active_conversation_id = id;
this.saveConfig();
}
}
exports.ConfigManager = ConfigManager;