ccguard
Version:
Automated enforcement of net-negative LOC, complexity constraints, and quality standards for Claude code
88 lines • 3.01 kB
TypeScript
import { ProjectSnapshot, SnapshotDiff } from './types';
import { Storage } from '../storage/Storage';
export declare class SnapshotManager {
private fileScanner;
private storage;
private baselineSnapshot;
private lastValidSnapshot;
private static readonly STORAGE_KEYS;
constructor(rootDir: string, storage: Storage, ignoreEmptyLines?: boolean);
/**
* Initialize or update baseline snapshot for the session
* In snapshot mode, this sets the LOC threshold
*/
initializeBaseline(sessionId: string): Promise<ProjectSnapshot>;
/**
* Get or create baseline snapshot
*/
getBaseline(sessionId: string): Promise<ProjectSnapshot>;
/**
* Take a lightweight snapshot of specific files before an operation
*/
takeOperationSnapshot(sessionId: string, affectedFiles: string[]): Promise<ProjectSnapshot>;
/**
* Take a snapshot after an operation completes
*/
takePostOperationSnapshot(sessionId: string, affectedFiles: string[]): Promise<ProjectSnapshot>;
/**
* Update the last valid snapshot (after successful validation)
*/
updateLastValidSnapshot(snapshot: ProjectSnapshot): Promise<void>;
/**
* Compare two snapshots and calculate the difference
*/
compareSnapshots(before: ProjectSnapshot, after: ProjectSnapshot): SnapshotDiff;
/**
* Check if current state exceeds threshold from baseline
* In snapshot mode, the baseline LOC IS the threshold
*/
checkThreshold(sessionId: string, currentSnapshot: ProjectSnapshot, allowedPositiveLines: number): Promise<{
exceeded: boolean;
current: number;
baseline: number;
delta: number;
}>;
/**
* Check if current LOC exceeds snapshot baseline threshold
* Used in snapshot mode where baseline LOC is the threshold
*/
checkSnapshotThreshold(sessionId: string, currentLoc: number): Promise<{
exceeded: boolean;
current: number;
baseline: number;
delta: number;
}>;
/**
* Get the current snapshot baseline threshold
*/
getSnapshotBaseline(sessionId: string): Promise<number | null>;
/**
* Get last valid snapshot
*/
getLastValidSnapshot(): ProjectSnapshot | null;
/**
* Get or restore the current valid state for a session
*/
getCurrentValidLoc(sessionId: string): Promise<number | null>;
/**
* Convert a ProjectSnapshot to a JSON-serializable format
*/
private toSerializable;
/**
* Convert a serialized snapshot back to ProjectSnapshot format
*/
private fromSerializable;
/**
* Calculate total LOC from file snapshots
*/
private calculateTotalLoc;
/**
* Detect new files created since last snapshot
*/
private detectNewFiles;
/**
* Restore last valid snapshot from storage if not already loaded
*/
private restoreLastValidSnapshot;
}
//# sourceMappingURL=SnapshotManager.d.ts.map