workspace

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package workspace prepares bounded, reviewable edits outside source control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateScratch added in v1.4.0

func CreateScratch(cwd string) (string, error)

CreateScratch allocates an empty directory without registering file edits.

Types

type File

type File struct {
	Exists bool        `json:"exists"`
	Digest string      `json:"digest,omitempty"`
	Mode   fs.FileMode `json:"mode,omitempty"`
}

type Manifest

type Manifest struct {
	Version int             `json:"version"`
	ID      string          `json:"id"`
	Root    string          `json:"root"`
	Files   map[string]File `json:"files"`
}

type Receipt

type Receipt struct {
	Snapshot string   `json:"snapshot"`
	Pending  string   `json:"pending,omitempty"`
	Temp     string   `json:"temp,omitempty"`
	Applied  []string `json:"applied"`
	Complete bool     `json:"complete"`
}

type Snapshot

type Snapshot struct {
	Manifest
	RequestVersion int             `json:"request_version,omitempty"`
	After          map[string]File `json:"after"`
	Diff           string          `json:"diff"`
}

func (Snapshot) Request

func (s Snapshot) Request() string

type Workspace

type Workspace struct {
	Dir  string `json:"directory"`
	Tree string `json:"tree"`
	Manifest
}

func Load

func Load(cwd, id string) (*Workspace, error)

func Prepare

func Prepare(cwd, source string, names []string) (*Workspace, error)

func (*Workspace) Apply

func (w *Workspace) Apply(id string, authorize func(Snapshot) error) (receipt Receipt, result error)

Apply verifies the entire batch before writing, then journals each replacement. The caller must validate human authorization for the supplied snapshot.

func (*Workspace) ReadSnapshot

func (w *Workspace) ReadSnapshot(id string) (Snapshot, error)

func (*Workspace) Snapshot

func (w *Workspace) Snapshot() (string, error)

Jump to

Keyboard shortcuts

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