UNPKG

ccguard

Version:

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

46 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HistoryManager = void 0; class HistoryManager { storage; maxRecords; static DEFAULT_MAX_RECORDS = 50; constructor(storage, maxRecords = HistoryManager.DEFAULT_MAX_RECORDS) { this.storage = storage; this.maxRecords = maxRecords; } async addOperation(record) { const history = await this.storage.getOperationHistory() || { records: [], maxRecords: this.maxRecords, lastUpdated: new Date().toISOString() }; const newRecord = { ...record, timestamp: new Date().toISOString() }; // Add new record and trim to max size history.records.unshift(newRecord); if (history.records.length > history.maxRecords) { history.records = history.records.slice(0, history.maxRecords); } history.lastUpdated = new Date().toISOString(); await this.storage.saveOperationHistory(history); } async getRecentOperations(limit) { const history = await this.storage.getOperationHistory(); if (!history) return []; return limit ? history.records.slice(0, limit) : history.records; } async clearHistory() { const history = { records: [], maxRecords: this.maxRecords, lastUpdated: new Date().toISOString() }; await this.storage.saveOperationHistory(history); } } exports.HistoryManager = HistoryManager; //# sourceMappingURL=HistoryManager.js.map