pub struct Undo { /* private fields */ }Expand description
A handle on one project’s undo history.
Implementations§
Source§impl Undo
impl Undo
pub fn dir_name() -> &'static str
Sourcepub fn init(workdir: &Path) -> Result<Undo>
pub fn init(workdir: &Path) -> Result<Undo>
Create a fresh .undo under workdir, and protect the user from
committing captured secrets by adding .undo/ to .gitignore.
Sourcepub fn discover(start: &Path) -> Result<Option<Undo>>
pub fn discover(start: &Path) -> Result<Option<Undo>>
Walk up from start to find an existing .undo directory.
Sourcepub fn rows(&self) -> Result<Vec<Row>>
pub fn rows(&self) -> Result<Vec<Row>>
Read every row in order. Malformed lines are skipped defensively.
Sourcepub fn checkpoint(&self, label: &str) -> Result<String>
pub fn checkpoint(&self, label: &str) -> Result<String>
Mark a point in time. Returns the checkpoint id.
pub fn current_checkpoint(&self) -> Result<Option<String>>
Sourcepub fn track(&self, path: &Path) -> Result<Vec<Effect>>
pub fn track(&self, path: &Path) -> Result<Vec<Effect>>
Capture a path (and, if it’s a directory, everything under it) before the agent changes it. Returns the effects recorded. New forward activity here invalidates any pending redo.
Sourcepub fn record(&self, effect: Effect, agent: Option<String>) -> Result<()>
pub fn record(&self, effect: Effect, agent: Option<String>) -> Result<()>
Record an arbitrary effect (used by the MCP/NAPI layer for http/exec).
pub fn status(&self) -> Result<Status>
pub fn log(&self) -> Result<Vec<Row>>
Sourcepub fn diff(&self) -> Result<Vec<DiffEntry>>
pub fn diff(&self) -> Result<Vec<DiffEntry>>
A PR-style diff of everything changed since the last checkpoint, built from undo’s captured before-state vs. the current files.
pub fn can_redo(&self) -> bool
Sourcepub fn rollback(&self, target: Option<&str>) -> Result<RollbackReport>
pub fn rollback(&self, target: Option<&str>) -> Result<RollbackReport>
Reverse every effect recorded after target (or the latest checkpoint if
None). The journal is only truncated if all inverses succeed; on any
hard failure it’s left intact so a retry is safe.
Sourcepub fn redo(&self) -> Result<RedoReport>
pub fn redo(&self) -> Result<RedoReport>
Undo the last rollback: restore the agent’s changes and re-extend the journal so you can roll back again.
Sourcepub fn revert(&self, path: &Path) -> Result<Option<String>>
pub fn revert(&self, path: &Path) -> Result<Option<String>>
Selective undo: reverse just one file, leaving every other change in
place. Reverts the most recent effect recorded for path and removes it
from the journal. Returns a description, or None if nothing was tracked
for that path. Directories aren’t selectable (use rollback).