Expand description
Undo stack for file mutations. Undo stack for file mutations.
Snapshots file contents before Write/Edit/Delete tool execution. Each turn’s mutations are grouped into a single undo entry.
§How it works
- Before any file mutation, the current file contents are snapshotted
- All mutations in a single turn are grouped into one undo entry
/undorestores all files from the most recent entry- Stack depth is unlimited — undo as many turns as needed
§What gets tracked
- Write: snapshots the file if it existed (for overwrite), or marks as “created”
- Edit: snapshots the file before the edit
- Delete: snapshots the file contents before deletion
Git checkpointing provides a separate safety net via git stash-style
snapshots before each turn. /undo is faster (in-memory) but git
checkpoints survive process crashes.
Structs§
- Undo
Entry - A snapshot of file states before a turn’s mutations.
- Undo
Stack - Stack of undo entries, one per turn.
Functions§
- extract_
file_ path - Extract the target file path from tool arguments.
- is_
mutating_ tool - Check if a tool name is a file-mutating tool that should be snapshotted.