checkpoint

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package checkpoint snapshots the working tree into a hidden per-project git repo so users can rewind code to any prior turn. The shadow repo is separate from any real .git: its GIT_DIR lives under ~/.bee/checkpoints, its work-tree is the project root, and it excludes the project's own .git while honoring the project .gitignore. Conversation rewind is handled elsewhere (session.Fork).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RestoreResult

type RestoreResult struct {
	TargetSHA string // state restored to
	UndoSHA   string // pre-restore state, kept so rewind is reversible
	ShortStat string // git --shortstat between undo and target
}

RestoreResult reports the outcome of a rewind.

type Snapshot

type Snapshot struct {
	MsgID string
	SHA   string
	Label string
	Time  time.Time
}

Snapshot is one recorded code state, keyed by the message that drove the turn.

type Store

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

Store is a shadow git repo bound to one project root.

func Open

func Open(projectRoot string) (*Store, error)

Open returns the shadow store for projectRoot, initializing it on first use.

func (*Store) DiffStat

func (s *Store) DiffStat(from, to string) (string, error)

DiffStat returns a one-line --shortstat between two snapshot shas. An empty from compares against the empty tree (useful for the first snapshot).

func (*Store) List

func (s *Store) List() ([]Snapshot, error)

List returns recorded snapshots newest first.

func (*Store) Prune

func (s *Store) Prune(keep int) error

Prune keeps the newest keep snapshots, drops undo refs older than 24h, and gcs unreferenced objects. Best-effort; failures are returned but partial.

func (*Store) Restore

func (s *Store) Restore(msgID string) (RestoreResult, error)

Restore rewinds the work-tree to msgID's snapshot. The current state is captured first (refs/bee/undo) so the rewind itself is reversible. Tracked files revert; files created since the snapshot are removed; gitignored paths are left untouched (clean has no -x).

func (*Store) Snapshot

func (s *Store) Snapshot(msgID, label string) (string, error)

Snapshot records the current work-tree as the code state for msgID and returns the short sha. An unchanged tree reuses the existing commit.

func (*Store) SnapshotFor

func (s *Store) SnapshotFor(msgID string) (string, bool)

SnapshotFor returns the short sha recorded for msgID, if any.

Jump to

Keyboard shortcuts

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