Files
puaros/packages/ipuaro/src/domain/value-objects/UndoEntry.ts
imfozilbek 130a8c4f24 feat(ipuaro): implement v0.1.0 foundation
- 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
2025-11-29 23:08:38 +05:00

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])
}