checkpoint

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	ID         string    `json:"id"`
	FilePath   string    `json:"file_path"`
	OldContent string    `json:"old_content"`
	NewContent string    `json:"new_content"`
	Timestamp  time.Time `json:"timestamp"`
	ToolCall   string    `json:"tool_call"`
}

Checkpoint represents a saved file state before a tool edit.

type Manager

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

Manager manages file checkpoints for undo support.

func NewManager

func NewManager(maxCheckpoints int) *Manager

NewManager creates a new checkpoint manager with the given max limit.

func (*Manager) Clear

func (m *Manager) Clear()

Clear removes all checkpoints.

func (*Manager) Last

func (m *Manager) Last() *Checkpoint

Last returns the most recent checkpoint, or nil if empty.

func (*Manager) List

func (m *Manager) List() []Checkpoint

List returns all checkpoints (most recent last).

func (*Manager) Revert

func (m *Manager) Revert(id string) (*Checkpoint, error)

Revert rolls back to a specific checkpoint by ID, writing OldContent back to the file. It also removes all checkpoints newer than the target.

func (*Manager) Save

func (m *Manager) Save(filePath, oldContent, newContent, toolCall string) Checkpoint

Save records a checkpoint before a file edit.

func (*Manager) Undo

func (m *Manager) Undo() (*Checkpoint, error)

Undo rolls back the most recent checkpoint by writing OldContent back to the file.

Jump to

Keyboard shortcuts

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