mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
- Project setup with tsup, vitest, ESM support - Domain entities: Session, Project - Value objects: FileData, FileAST, FileMeta, ChatMessage, ToolCall, ToolResult, UndoEntry - Service interfaces: IStorage, ILLMClient, ITool, IIndexer, IToolRegistry - Shared: Config (zod), IpuaroError, utils (hash, tokens), Result type - CLI with placeholder commands (start, init, index) - 91 unit tests with 100% coverage - Fix package scope @puaros -> @samiyev in CLAUDE.md
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
/**
|
|
* Represents an undo entry for file changes.
|
|
*/
|
|
|
|
export interface UndoEntry {
|
|
/** Unique identifier */
|
|
id: string
|
|
/** Timestamp when change was made */
|
|
timestamp: number
|
|
/** File path that was modified */
|
|
filePath: string
|
|
/** Content before the change */
|
|
previousContent: string[]
|
|
/** Content after the change */
|
|
newContent: string[]
|
|
/** Human-readable description of the change */
|
|
description: string
|
|
/** Tool call ID that made this change */
|
|
toolCallId?: string
|
|
}
|
|
|
|
export function createUndoEntry(
|
|
id: string,
|
|
filePath: string,
|
|
previousContent: string[],
|
|
newContent: string[],
|
|
description: string,
|
|
toolCallId?: string,
|
|
): UndoEntry {
|
|
return {
|
|
id,
|
|
timestamp: Date.now(),
|
|
filePath,
|
|
previousContent,
|
|
newContent,
|
|
description,
|
|
toolCallId,
|
|
}
|
|
}
|
|
|
|
export function canUndo(entry: UndoEntry, currentContent: string[]): boolean {
|
|
return arraysEqual(entry.newContent, currentContent)
|
|
}
|
|
|
|
function arraysEqual(a: string[], b: string[]): boolean {
|
|
if (a.length !== b.length) {
|
|
return false
|
|
}
|
|
return a.every((line, i) => line === b[i])
|
|
}
|