checkpoint

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExternalFileMapping

type ExternalFileMapping struct {
	OriginalPath     string `json:"original_path"`
	FirstTrackedTurn int    `json:"first_tracked_turn"`
}

ExternalFileMapping tracks files outside the workdir

type Manager

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

Manager handles checkpoint creation and restoration using a shadow git repository

func NewManager

func NewManager(checkpointDir, workdir string, excludePatterns []string, maxFileSizeKB int) (*Manager, error)

NewManager creates a checkpoint manager whose shadow git repository lives in checkpointDir. That directory belongs to the session, so a checkpoint made by one turn is still there for the next, and it must sit outside workdir: the repository snapshots workdir with "git add -A", which would otherwise try to snapshot itself.

func (*Manager) Cleanup

func (m *Manager) Cleanup() error

Cleanup removes the checkpoint directory

func (*Manager) CurrentTurn

func (m *Manager) CurrentTurn() int

CurrentTurn returns the current turn number

func (*Manager) Diff

func (m *Manager) Diff(turnNum int, path string) (string, error)

Diff returns the diff between current state and a turn

func (*Manager) Enabled

func (m *Manager) Enabled() bool

Enabled returns whether checkpoints are enabled

func (*Manager) EndTurn

func (m *Manager) EndTurn() error

EndTurn commits all changes to the shadow git (called after all tool calls complete)

func (*Manager) GetModifiedFiles

func (m *Manager) GetModifiedFiles() []string

GetModifiedFiles returns a list of all files modified since turn-0 (session start) This uses git to find files that have been changed during this session

func (*Manager) Initialize

func (m *Manager) Initialize() error

Initialize sets up the shadow git repository

func (*Manager) IsExternalPath

func (m *Manager) IsExternalPath(path string) bool

IsExternalPath checks if a path is outside the workdir

func (*Manager) List

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

List returns information about all checkpoints

func (*Manager) Restore

func (m *Manager) Restore(turnNum int) ([]string, error)

Restore restores files to the state after a given turn

func (*Manager) RestoreFile

func (m *Manager) RestoreFile(path string) ([]byte, error)

RestoreFile restores a single file to its state at turn 0 (initial state) Returns the content that was restored, or error if file wasn't tracked

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(enabled bool)

SetEnabled enables or disables checkpoints

func (*Manager) StartTurn

func (m *Manager) StartTurn() int

StartTurn increments the turn counter (called before processing tool calls)

func (*Manager) TrackExternalFile

func (m *Manager) TrackExternalFile(path string) error

TrackExternalFile copies a file from outside workdir to external-files/

func (*Manager) Workdir

func (m *Manager) Workdir() string

Workdir returns the workspace directory

type TurnInfo

type TurnInfo struct {
	Turn         int      `json:"turn"`
	FilesChanged []string `json:"files_changed"`
	IsRestore    bool     `json:"is_restore,omitempty"`
	RestoredTo   int      `json:"restored_to,omitempty"`
}

TurnInfo contains information about a checkpoint turn

Jump to

Keyboard shortcuts

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