rewind

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("rewind manager closed")

ErrClosed is returned after Cleanup; callers should treat it as a transient no-op (RestartRewind installs a fresh Manager).

Functions

func CleanupOrphans added in v0.6.2

func CleanupOrphans()

CleanupOrphans removes leftover shadow repos from prior crashed sessions. Only deletes dirs older than the cutoff so concurrent sessions are safe.

Types

type Checkpoint

type Checkpoint struct {
	Hash    string
	Message string
	Time    time.Time
}

type FileDiff

type FileDiff struct {
	Path   string
	Status FileStatus
	Patch  string

	Original string
	Modified string
}

type FileStatus

type FileStatus int
const (
	StatusAdded FileStatus = iota
	StatusModified
	StatusDeleted
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager runs a shadow git repo in /tmp that snapshots the working dir on each user turn. Init is async; methods block on initDone until ready.

func New

func New(workingDir string) *Manager

func (*Manager) Cleanup

func (m *Manager) Cleanup()

func (*Manager) Commit

func (m *Manager) Commit(message string) error

func (*Manager) DiffFromBaseline

func (m *Manager) DiffFromBaseline() ([]FileDiff, error)

DiffFromBaseline diffs the baseline against the live working tree (not HEAD), so changes from any source — agent tools, terminal, external editor — are reflected. Returns (nil, nil) when there's no diff; errors are reserved for actual git failures.

func (*Manager) Fingerprint added in v0.6.2

func (m *Manager) Fingerprint() uint64

Fingerprint returns a 64-bit digest of the worktree's visible state (relative path, mtime, size for every non-ignored file). Doesn't hash content, so a `touch` will fire a refetch even when no diff changed.

func (*Manager) List

func (m *Manager) List() ([]Checkpoint, error)

func (*Manager) Restore

func (m *Manager) Restore(hash string) error

Restore rolls the working tree back to a checkpoint and re-baselines. Excludes MUST be loaded before Clean — otherwise Clean silently nukes gitignored files (node_modules, .env, build artifacts) on rollback.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL