snapshot

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package snapshot provides automatic working tree snapshots using git plumbing.

Snapshots are stored as named refs under refs/aura/snapshots/<pid>/ in the user's repository, scoped by PID to prevent collisions between concurrent aura instances. Each snapshot captures the complete working tree state (tracked + untracked files, respecting .gitignore) without disturbing the user's staging area or branch history.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles snapshot lifecycle within a git repository.

func NewManager

func NewManager(dir string) *Manager

NewManager creates a snapshot manager for the given directory. Returns nil if the directory is not inside a git repository.

func (*Manager) Create

func (m *Manager) Create(message string, messageIndex int) (*Snapshot, error)

Create captures the current working tree state as a snapshot. The message is the user's input text for display in the picker. messageIndex is the builder.Len() before user messages are added.

func (*Manager) DiffStat

func (m *Manager) DiffStat(fromHash, toHash string) (string, error)

DiffStat returns a short diff stat between two snapshot hashes.

func (*Manager) Git

func (m *Manager) Git(args ...string) error

Git runs a git command in the repo directory.

func (*Manager) GitEnv

func (m *Manager) GitEnv(env []string, args ...string) error

GitEnv runs a git command with custom environment variables.

func (*Manager) GitOutput

func (m *Manager) GitOutput(args ...string) (string, error)

GitOutput runs a git command and returns trimmed stdout.

func (*Manager) GitOutputEnv

func (m *Manager) GitOutputEnv(env []string, args ...string) (string, error)

GitOutputEnv runs a git command with custom env and returns trimmed stdout.

func (*Manager) List

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

List returns all snapshots in chronological order (oldest first).

func (*Manager) Prune

func (m *Manager) Prune() error

Prune removes all snapshot refs. Called on session end or /clear.

func (*Manager) RestoreCode

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

RestoreCode restores the working tree to the state captured in the snapshot. Does NOT modify the user's staging area or branch.

type Snapshot

type Snapshot struct {
	// Ref is the git ref name (e.g. "refs/aura/snapshots/<pid>/0001").
	Ref string

	// Hash is the full commit SHA.
	Hash string

	// Message is the user's input text that triggered this turn.
	Message string

	// CreatedAt is when the snapshot was taken.
	CreatedAt time.Time

	// MessageIndex is the conversation message count at snapshot time.
	// Used for "messages only" rewind — truncate history to this index.
	MessageIndex int
}

Snapshot represents a point-in-time working tree capture.

func (Snapshot) PickerDescription

func (s Snapshot) PickerDescription() string

PickerDescription returns the secondary text (relative timestamp).

func (Snapshot) PickerLabel

func (s Snapshot) PickerLabel(turnNumber int) string

PickerLabel returns the label shown in the /undo picker. Format: "Turn 5 — refactor the auth module".

Jump to

Keyboard shortcuts

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