memory settings implementation

This commit is contained in:
Storme-bit
2026-04-17 23:13:36 -07:00
parent 1cc7b62d79
commit 77275cf476
7 changed files with 254 additions and 206 deletions

View File

@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');
const { ORCHESTRATION } = require('@nexusai/shared');
const SETTINGS_PATH = path.join(__dirname, '../../data/settings.json');
const DEFAULTS = {
recentEpisodeLimit: ORCHESTRATION.RECENT_EPISODE_LIMIT,
semanticLimit: ORCHESTRATION.SEMANTIC_LIMIT,
scoreThreshold: ORCHESTRATION.SCORE_THRESHOLD,
};
function load() {
try {
const raw = fs.readFileSync(SETTINGS_PATH, 'utf8');
return { ...DEFAULTS, ...JSON.parse(raw) };
} catch {
return { ...DEFAULTS }; // file doesn't exist yet — use defaults
}
}
function save(updates) {
const current = load();
const next = { ...current, ...updates };
fs.mkdirSync(path.dirname(SETTINGS_PATH), { recursive: true });
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(next, null, 2));
return next;
}
module.exports = { load, save, DEFAULTS };