UNPKG

ccguard

Version:

Automated enforcement of net-negative LOC, complexity constraints, and quality standards for Claude code

57 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GuardManager = void 0; class GuardManager { storage; configLoader; constructor(storage, configLoader) { this.storage = storage; this.configLoader = configLoader; } async isEnabled() { const state = await this.storage.getGuardState(); return state?.enabled ?? true; // Default to enabled } async enable() { const state = { enabled: true, lastUpdated: new Date().toISOString(), }; await this.storage.saveGuardState(state); } async disable() { const state = { enabled: false, lastUpdated: new Date().toISOString(), }; await this.storage.saveGuardState(state); } async getSessionStats() { return await this.storage.getSessionStats(); } async updateSessionStats(linesAdded, linesRemoved) { const current = await this.storage.getSessionStats(); const updated = { totalLinesAdded: (current?.totalLinesAdded ?? 0) + linesAdded, totalLinesRemoved: (current?.totalLinesRemoved ?? 0) + linesRemoved, netChange: 0, // Will calculate below operationCount: (current?.operationCount ?? 0) + 1, lastUpdated: new Date().toISOString(), }; updated.netChange = updated.totalLinesAdded - updated.totalLinesRemoved; await this.storage.saveSessionStats(updated); return updated; } async resetStats() { const stats = { totalLinesAdded: 0, totalLinesRemoved: 0, netChange: 0, operationCount: 0, lastUpdated: new Date().toISOString(), }; await this.storage.saveSessionStats(stats); } } exports.GuardManager = GuardManager; //# sourceMappingURL=GuardManager.js.map