/** * Edit log — append-only log of file mutations. Mirrors `edit_log.rs`. */ /** A single recorded file edit event. */ export interface EditLogEntry { /** Unix timestamp (ms) when the edit occurred. */ ts: number; /** Name of the tool that performed the edit. */ tool: string; /** Absolute file path that was modified. */ path: string; /** Human-readable explanation of why the edit was made. */ reason: string; /** SHA-256 hex digest of the content after the edit. */ content_sha256: string; /** Signed byte count change (+added, -removed). */ bytes_delta: number; /** Origin identifier (which agent / session context). */ origin: string; /** Session in which this edit was performed. */ session_id: string; } /** Maximum number of edit entries held in memory at once. */ export const MAX_MEMORY_ENTRIES = 10_000; /** In-memory view of a session's edit log. */ export class EditLog { entries: EditLogEntry[]; constructor() { this.entries = []; } /** Number of in-memory entries. */ get length(): number { return this.entries.length; } /** Whether the log contains no entries. */ get isEmpty(): boolean { return this.entries.length === 0; } /** Append an entry, evicting oldest beyond MAX_MEMORY_ENTRIES. */ push(entry: EditLogEntry): void { this.entries.push(entry); if (this.entries.length > MAX_MEMORY_ENTRIES) { this.entries.shift(); } } }