Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupOrphans ¶ added in v0.6.3
func CleanupOrphans()
CleanupOrphans removes leftover shadow repos from prior sessions that didn't get a chance to clean up (e.g. SIGKILL). Only deletes dirs whose mtime is older than the cutoff so concurrently-running sessions are safe.
Types ¶
type FileDiff ¶
type FileDiff struct {
Path string
Status FileStatus
Patch string
// Original is the file's content at the baseline (empty when added).
Original string
// Modified is the file's content in the current working tree (empty when deleted).
Modified string
}
FileDiff represents a diff for a single file
type FileStatus ¶
type FileStatus int
FileStatus represents the status of a file in the diff
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 — New returns immediately and methods block on a ready channel until the shadow repo is set up. The shadow repo works in any directory, with or without an existing user .git.
func New ¶
New starts a rewind manager for the given working directory. The shadow repo is initialized in a goroutine; methods block on it via the ready channel. Failures during init surface as errors from those methods, so the caller never has to deal with a nil Manager.
func (*Manager) DiffFromBaseline ¶
DiffFromBaseline returns the diff between the baseline and the current working tree. The right-hand side is taken from the live working tree (not HEAD), so changes from any source — agent tools, the user's terminal, an external editor — are reflected.
Returns (nil, nil) when the working tree matches the baseline (no diff). Errors are reserved for actual git failures so callers can distinguish.
func (*Manager) Fingerprint ¶ added in v0.6.3
Fingerprint returns a 64-bit digest of the worktree's visible state (relative path, mtime, size for every non-ignored file). Used by the server's polling loop to gate FilesChanged/DiffsChanged emits — when the digest is unchanged we skip the events entirely. Always skips .git and gitignored entries; doesn't hash content, so a `touch` will fire a refetch even when no diff actually changed (the client just gets an empty diff back).
func (*Manager) List ¶
func (m *Manager) List() ([]Checkpoint, error)
func (*Manager) Restore ¶
Restore rolls the working tree back to a checkpoint and re-baselines so "diff from baseline" thereafter means "since the restore." Excludes are loaded before Clean so gitignored files (node_modules, .env, build artifacts) are preserved — without that guard, Clean would silently nuke them on rollback.