diffsandbox

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 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 Change

type Change struct {
	ID        string
	Path      string // relative file path
	Type      ChangeType
	Content   string // new content (for Create/Modify)
	Original  string // original content (for Modify, used for diff)
	Timestamp time.Time
}

Change represents a single proposed file modification.

type ChangeType

type ChangeType int

ChangeType identifies the kind of file modification.

const (
	// ChangeCreate represents creating a new file.
	ChangeCreate ChangeType = iota
	// ChangeModify represents modifying an existing file.
	ChangeModify
	// ChangeDelete represents deleting a file.
	ChangeDelete
)

func (ChangeType) String

func (ct ChangeType) String() string

String returns a human-readable name for the change type.

type Sandbox

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

Sandbox accumulates proposed changes without modifying the filesystem.

func New

func New(rootDir string) *Sandbox

New creates a sandbox rooted at the given directory.

func (*Sandbox) Apply

func (s *Sandbox) Apply() error

Apply writes all pending changes to the actual filesystem. Each file write is atomic: content is written to a temp file then renamed.

func (*Sandbox) ApplyFile

func (s *Sandbox) ApplyFile(path string) error

ApplyFile applies only a single file's changes.

func (*Sandbox) Changes

func (s *Sandbox) Changes() []*Change

Changes returns all pending changes in insertion order.

func (*Sandbox) Diff

func (s *Sandbox) Diff() string

Diff returns the unified diff of all accumulated changes.

func (*Sandbox) DiffFile

func (s *Sandbox) DiffFile(path string) string

DiffFile returns the diff for a single file.

func (*Sandbox) Discard

func (s *Sandbox) Discard()

Discard removes all pending changes without applying.

func (*Sandbox) DiscardFile

func (s *Sandbox) DiscardFile(path string)

DiscardFile removes a single file's pending changes.

func (*Sandbox) HasChanges

func (s *Sandbox) HasChanges() bool

HasChanges returns true if there are any pending changes.

func (*Sandbox) ProposeCreate

func (s *Sandbox) ProposeCreate(path string, content string) *Change

ProposeCreate stages a new file creation.

func (*Sandbox) ProposeDelete

func (s *Sandbox) ProposeDelete(path string) *Change

ProposeDelete stages a file deletion.

func (*Sandbox) ProposeModify

func (s *Sandbox) ProposeModify(path string, newContent string) (*Change, error)

ProposeModify stages a file modification. Reads the original content from disk.

func (*Sandbox) SortedPaths

func (s *Sandbox) SortedPaths() []string

SortedPaths returns all pending paths in sorted order.

func (*Sandbox) Stats

func (s *Sandbox) Stats() SandboxStats

Stats returns change statistics.

func (*Sandbox) Summary

func (s *Sandbox) Summary() string

Summary returns a brief description of pending changes.

type SandboxStats

type SandboxStats struct {
	FilesCreated  int
	FilesModified int
	FilesDeleted  int
	LinesAdded    int
	LinesRemoved  int
}

SandboxStats holds statistics about pending changes.

Jump to

Keyboard shortcuts

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