Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package state persists per-project dump records in the user's application data directory so delta dumps can know the last commit a project was dumped from, without polluting the repository itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProjectKey

func GetProjectKey(absPath string) string

GetProjectKey returns a stable 16-hex-char key for an absolute project path.

func SavePreferences

func SavePreferences(prefs Preferences) error

SavePreferences writes user preferences atomically.

func StatePath

func StatePath() (string, error)

StatePath returns the JSON state file location in the user's config directory: ~/.config/sift/state.json on Linux, %APPDATA% on Windows.

Types

type AppState

type AppState struct {
	Projects map[string]DumpRecord `json:"projects"`
}

AppState holds the dump record of every project that has been dumped, keyed by GetProjectKey.

func Load

func Load() (*AppState, error)

Load reads the state file, returning an empty state when it does not exist.

func (*AppState) Get

func (s *AppState) Get(key string) (DumpRecord, bool)

Get returns the dump record for a project key, if present.

func (*AppState) Record

func (s *AppState) Record(key, commitHash, commitMsg string, files, tokens int)

Record stores a new dump record for key.

func (*AppState) Save

func (s *AppState) Save() error

Save writes the state to disk atomically so a crash never truncates it.

type DumpRecord

type DumpRecord struct {
	LastCommitHash string    `json:"last_commit_hash"`
	LastCommitMsg  string    `json:"last_commit_msg"`
	DumpTimestamp  time.Time `json:"dump_timestamp"`
	FilesDumped    int       `json:"files_dumped"`
	TokensDumped   int       `json:"tokens_dumped"`
}

DumpRecord describes the most recent dump of a project.

type Preferences

type Preferences struct {
	UITheme string `json:"ui_theme,omitempty"`
}

Preferences contains user-level interactive preferences that should survive picker sessions but do not belong to a project's dump history.

func LoadPreferences

func LoadPreferences() (Preferences, error)

LoadPreferences loads user preferences. Missing preferences are normal and return the zero-value preference set.

Jump to

Keyboard shortcuts

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