snapshot

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDiff added in v0.2.0

func FormatDiff(diff *SnapshotDiff, snapshotName string) string

FormatDiff produces a human-readable summary of a snapshot diff.

func FormatList added in v0.2.0

func FormatList(snapshots []*WorkspaceSnapshot) string

FormatList produces a human-readable listing of snapshots.

Types

type FileDiff

type FileDiff struct {
	File      string `json:"file"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Status    string `json:"status"` // added, deleted, modified
}

FileDiff represents a diff for a single file between two snapshots.

type FileState added in v0.2.0

type FileState struct {
	Path    string      `json:"path"`
	Content []byte      `json:"content"`
	Mode    os.FileMode `json:"mode"`
	ModTime time.Time   `json:"mod_time"`
	Hash    string      `json:"hash"`
}

FileState captures the state of a single file.

type Patch

type Patch struct {
	Hash      string    `json:"hash"`
	Message   string    `json:"message"`
	Files     []string  `json:"files"`
	Timestamp time.Time `json:"timestamp"`
}

Patch represents a recorded snapshot with its changed files.

type SnapshotDiff added in v0.2.0

type SnapshotDiff struct {
	Added     []string `json:"added"`
	Modified  []string `json:"modified"`
	Deleted   []string `json:"deleted"`
	Unchanged int      `json:"unchanged"`
}

SnapshotDiff represents the difference between a snapshot and the current workspace.

type SnapshotStore added in v0.2.0

type SnapshotStore struct {
	Dir          string
	MaxSnapshots int
	// contains filtered or unexported fields
}

SnapshotStore manages workspace snapshots on disk.

func NewSnapshotStore added in v0.2.0

func NewSnapshotStore(dir string) *SnapshotStore

NewSnapshotStore creates a new SnapshotStore with the given directory. If dir is empty, defaults to ".hawk/snapshots/".

func (*SnapshotStore) Capture added in v0.2.0

func (s *SnapshotStore) Capture(projectDir, name, description string) (*WorkspaceSnapshot, error)

Capture takes a snapshot of the given project directory.

func (*SnapshotStore) Delete added in v0.2.0

func (s *SnapshotStore) Delete(id string) error

Delete removes a snapshot by ID.

func (*SnapshotStore) Diff added in v0.2.0

func (s *SnapshotStore) Diff(snapshotID string, projectDir string) (*SnapshotDiff, error)

Diff compares a snapshot to the current workspace state.

func (*SnapshotStore) Get added in v0.2.0

Get retrieves a specific snapshot by ID.

func (*SnapshotStore) List added in v0.2.0

func (s *SnapshotStore) List() ([]*WorkspaceSnapshot, error)

List returns all snapshots sorted by date (newest first).

func (*SnapshotStore) Prune added in v0.2.0

func (s *SnapshotStore) Prune() error

Prune removes the oldest snapshots when over MaxSnapshots.

func (*SnapshotStore) Restore added in v0.2.0

func (s *SnapshotStore) Restore(snapshotID string, projectDir string) error

Restore restores a snapshot to the given project directory.

func (*SnapshotStore) Save added in v0.2.0

func (s *SnapshotStore) Save(snapshot *WorkspaceSnapshot) error

Save serializes a snapshot and writes it to disk as compressed JSON.

type Tracker

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

Tracker maintains a shadow git repository that records every file change the agent makes. Supports point-in-time restore and selective revert.

func New

func New(projectDir string) *Tracker

New creates a Tracker for the given project directory.

func (*Tracker) Cleanup

func (t *Tracker) Cleanup(maxAge time.Duration) error

Cleanup runs garbage collection on the shadow repo.

func (*Tracker) Diff

func (t *Tracker) Diff(from, to string) ([]FileDiff, error)

Diff returns the list of changed files between two snapshot hashes.

func (*Tracker) History

func (t *Tracker) History(limit int) ([]Patch, error)

History returns the last N snapshots.

func (*Tracker) Init

func (t *Tracker) Init() error

Init initializes the shadow git repository if it doesn't exist.

func (*Tracker) Restore

func (t *Tracker) Restore(hash string) error

Restore resets the project directory to the state at the given snapshot.

func (*Tracker) Track

func (t *Tracker) Track(message string) (string, error)

Track takes a snapshot of the current project state. Returns the commit hash.

type WorkspaceSnapshot added in v0.2.0

type WorkspaceSnapshot struct {
	ID          string               `json:"id"`
	Name        string               `json:"name"`
	Description string               `json:"description"`
	Files       map[string]FileState `json:"files"`
	GitBranch   string               `json:"git_branch"`
	GitCommit   string               `json:"git_commit"`
	CreatedAt   time.Time            `json:"created_at"`
	Size        int64                `json:"size"`
	FileCount   int                  `json:"file_count"`
}

WorkspaceSnapshot captures the full state of a project at a point in time.

Jump to

Keyboard shortcuts

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