UNPKG

acs-framework-cli

Version:

🚀 CLI inteligente para configurar automáticamente el Augmented Context Standard (ACS) Framework. Context-as-Code que convierte tu conocimiento en un activo versionado.

85 lines (71 loc) • 1.98 kB
const fs = require('fs-extra'); const path = require('path'); const os = require('os'); /** * GESTOR DE PREFERENCIAS PERSISTENTES * Evita preguntar lo mismo cada vez al usuario */ class UserPreferences { constructor() { this.prefsPath = path.join(os.homedir(), '.acs-preferences.json'); this.preferences = null; } async load() { try { if (await fs.pathExists(this.prefsPath)) { this.preferences = await fs.readJson(this.prefsPath); return this.preferences; } } catch (error) { // Ignorar errores de lectura } this.preferences = { comfortLevel: null, defaultPriority: null, teamContext: null, skipOnboarding: false, lastUsed: null }; return this.preferences; } async save(newPrefs) { try { this.preferences = { ...this.preferences, ...newPrefs, lastUsed: new Date().toISOString() }; await fs.writeJson(this.prefsPath, this.preferences, { spaces: 2 }); return true; } catch (error) { // Ignorar errores de escritura (no bloquear la experiencia) return false; } } hasPreferences() { return this.preferences && this.preferences.comfortLevel && this.preferences.lastUsed; } isRecentUser() { if (!this.preferences || !this.preferences.lastUsed) return false; const lastUsed = new Date(this.preferences.lastUsed); const daysSinceLastUse = (Date.now() - lastUsed.getTime()) / (1000 * 60 * 60 * 24); return daysSinceLastUse < 30; // Considerado "reciente" si usó en los últimos 30 días } getPreferences() { return this.preferences || {}; } async reset() { try { if (await fs.pathExists(this.prefsPath)) { await fs.remove(this.prefsPath); } this.preferences = null; return true; } catch (error) { return false; } } } module.exports = UserPreferences;