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 ¶
- type Manager
- func (m *Manager) Create(message string, messageIndex int) (*Snapshot, error)
- func (m *Manager) DiffStat(fromHash, toHash string) (string, error)
- func (m *Manager) Git(args ...string) error
- func (m *Manager) GitEnv(env []string, args ...string) error
- func (m *Manager) GitOutput(args ...string) (string, error)
- func (m *Manager) GitOutputEnv(env []string, args ...string) (string, error)
- func (m *Manager) List() ([]Snapshot, error)
- func (m *Manager) Prune() error
- func (m *Manager) RestoreCode(hash string) error
- type Snapshot
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 ¶
NewManager creates a snapshot manager for the given directory. Returns nil if the directory is not inside a git repository.
func (*Manager) Create ¶
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) GitOutputEnv ¶
GitOutputEnv runs a git command with custom env and returns trimmed stdout.
func (*Manager) RestoreCode ¶
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 ¶
PickerDescription returns the secondary text (relative timestamp).
func (Snapshot) PickerLabel ¶
PickerLabel returns the label shown in the /undo picker. Format: "Turn 5 — refactor the auth module".