ccguard
Version:
Automated enforcement of net-negative LOC, complexity constraints, and quality standards for Claude code
60 lines • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HotConfigLoader = void 0;
class HotConfigLoader {
baseConfigLoader;
storage;
constructor(baseConfigLoader, storage) {
this.baseConfigLoader = baseConfigLoader;
this.storage = storage;
}
async getConfig() {
// Get base config from file
const baseConfig = this.baseConfigLoader.getConfig();
// Get hot config overrides
const hotConfig = await this.storage.getHotConfig();
if (!hotConfig) {
return baseConfig;
}
// Deep merge hot config over base config
return this.mergeConfigs(baseConfig, hotConfig);
}
async updateConfig(updates) {
const current = await this.storage.getHotConfig() || {
lastUpdated: new Date().toISOString()
};
const updated = {
...current,
...updates,
lastUpdated: new Date().toISOString()
};
await this.storage.saveHotConfig(updated);
}
async clearHotConfig() {
await this.storage.delete('hot-config');
}
isFileWhitelisted(filePath) {
return this.baseConfigLoader.isFileWhitelisted(filePath);
}
reloadConfig() {
this.baseConfigLoader.reloadConfig();
}
mergeConfigs(base, hot) {
const result = {
enforcement: {
...base.enforcement,
...(hot.enforcement || {}),
},
whitelist: base.whitelist, // Don't allow hot config to change whitelist
};
// Handle thresholds separately to ensure proper typing
if (base.thresholds || hot.thresholds) {
result.thresholds = {
allowedPositiveLines: hot.thresholds?.allowedPositiveLines ?? base.thresholds?.allowedPositiveLines ?? 0,
};
}
return result;
}
}
exports.HotConfigLoader = HotConfigLoader;
//# sourceMappingURL=HotConfigLoader.js.map