Skip to main content

Undo

Struct Undo 

Source
pub struct Undo { /* private fields */ }
Expand description

A handle on one project’s undo history.

Implementations§

Source§

impl Undo

Source

pub fn dir_name() -> &'static str

Source

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.

Source

pub fn discover(start: &Path) -> Result<Option<Undo>>

Walk up from start to find an existing .undo directory.

Source

pub fn rows(&self) -> Result<Vec<Row>>

Read every row in order. Malformed lines are skipped defensively.

Source

pub fn checkpoint(&self, label: &str) -> Result<String>

Mark a point in time. Returns the checkpoint id.

Source

pub fn current_checkpoint(&self) -> Result<Option<String>>

Source

pub fn workdir(&self) -> &Path

The project root (the directory containing .undo).

Source

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.

Source

pub fn record(&self, effect: Effect, agent: Option<String>) -> Result<()>

Record an arbitrary effect (used by the MCP/NAPI layer for http/exec).

Source

pub fn status(&self) -> Result<Status>

Source

pub fn log(&self) -> Result<Vec<Row>>

Source

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.

Source

pub fn can_redo(&self) -> bool

Source

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.

Source

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.

Source

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).

Auto Trait Implementations§

§

impl Freeze for Undo

§

impl RefUnwindSafe for Undo

§

impl Send for Undo

§

impl Sync for Undo

§

impl Unpin for Undo

§

impl UnsafeUnpin for Undo

§

impl UnwindSafe for Undo

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.