state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package state persists agentsync's last-applied hashes and marketplace/plugin pinning to ~/.agentsync/.state/targets.json.

Index

Constants

View Source
const SchemaVersion = 1

Variables

This section is empty.

Functions

func Save

func Save(path string, t *Targets) error

Save serializes t to path atomically (iox.AtomicWrite).

Types

type FileEntry

type FileEntry struct {
	SHA256    string    `json:"sha256"`
	Mode      uint32    `json:"mode"`
	AppliedAt time.Time `json:"applied_at"`
	SourceID  string    `json:"source_id"` // canonical file that produced this dest
}

FileEntry tracks one fully-managed destination file. Key format: "<agent>:<scope>:<project>:<dest_path>"

type KeyEntry

type KeyEntry struct {
	SHA256    string    `json:"sha256"`
	AppliedAt time.Time `json:"applied_at"`
	SourceID  string    `json:"source_id"`
}

KeyEntry tracks one managed JSON-pointer-addressable key inside a shared destination file. Key format: "<agent>:<scope>:<project>:<file>:<json_pointer>"

type Marketplace

type Marketplace struct {
	URL       string    `json:"url"`
	Ref       string    `json:"ref"`
	HeadSHA   string    `json:"head_sha"`
	FetchedAt time.Time `json:"fetched_at"`
}

type PluginEntry

type PluginEntry struct {
	Version     string `json:"version"`
	ManifestSHA string `json:"manifest_sha"`
	Enabled     bool   `json:"enabled"`
}

type Targets

type Targets struct {
	SchemaVersion int                    `json:"schema_version"`
	Files         map[string]FileEntry   `json:"files,omitempty"`
	Keys          map[string]KeyEntry    `json:"keys,omitempty"`
	Marketplaces  map[string]Marketplace `json:"marketplaces,omitempty"`
	Plugins       map[string]PluginEntry `json:"plugins,omitempty"`
}

Targets is the root state document.

func Load

func Load(path string) (*Targets, error)

Load reads targets.json from path. If the file is missing, returns a fresh state at the current SchemaVersion.

func New

func New() *Targets

New returns a fresh empty Targets at SchemaVersion.

Jump to

Keyboard shortcuts

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