Documentation
¶
Index ¶
- func FormatDiff(diff *SnapshotDiff, snapshotName string) string
- func FormatList(snapshots []*WorkspaceSnapshot) string
- type FileDiff
- type FileState
- type Patch
- type SnapshotDiff
- type SnapshotStore
- func (s *SnapshotStore) Capture(projectDir, name, description string) (*WorkspaceSnapshot, error)
- func (s *SnapshotStore) Delete(id string) error
- func (s *SnapshotStore) Diff(snapshotID string, projectDir string) (*SnapshotDiff, error)
- func (s *SnapshotStore) Get(id string) (*WorkspaceSnapshot, error)
- func (s *SnapshotStore) List() ([]*WorkspaceSnapshot, error)
- func (s *SnapshotStore) Prune() error
- func (s *SnapshotStore) Restore(snapshotID string, projectDir string) error
- func (s *SnapshotStore) Save(snapshot *WorkspaceSnapshot) error
- type Tracker
- type WorkspaceSnapshot
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
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
func (s *SnapshotStore) Get(id string) (*WorkspaceSnapshot, error)
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.
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.