writ

package
v0.1.0-dev.20260823032042 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package writ implements the writ CLI commands.

Index

Constants

This section is empty.

Variables

View Source
var LayerOrder = []string{"base", "team", "personal"}

LayerOrder defines the processing order for repository layers. Layers are processed in this order, with later layers overriding earlier ones.

Functions

func CollectLayerSources

func CollectLayerSources() ([]tree.LayerSource, error)

CollectLayerSources gathers all configured repository layers and expands them into source/target pairs. Returns sources ordered: base/System, base/Home, team/System, team/Home, personal/System, personal/Home (if configured/exist).

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates the root writ command with all subcommands.

Returns:

  • *cobra.Command: configured writ command with target flag and all subcommands

func PartitionByScope

func PartitionByScope(sources []tree.LayerSource) map[string][]tree.LayerSource

PartitionByScope groups layer sources by their TargetName ("System", "Home"). Sources within each partition retain their original ordering. Returns an empty map when sources is empty.

Parameters:

  • sources: flat list of layer sources from CollectLayerSources

Returns:

  • map[string][]tree.LayerSource: sources keyed by TargetName

func TargetHome

func TargetHome() string

TargetHome returns the deployment target for Home-scoped sources.

The configured value wins when set, which is what makes a deployment addressable somewhere other than the operator's own home — a staging tree, or a test sandbox. Home itself is resolved, never injected: the account database outranks the environment (see xdg), so `HOME` cannot move a deployment and this key is the only thing that can.

Returns:

  • `string`: `writ.targets.home` when set, else the user's home directory.

func TargetSystem

func TargetSystem() string

TargetSystem returns the deployment target for System-scoped sources.

The default is `/`, which is correct on Unix and **wrong on Windows**, where a leading separator with no volume is drive-relative and therefore resolves against whatever drive the process is standing on. Fixing that default is [step 58]; this accessor exists so the fix lands in one place, and so a caller that cannot wait — a test, or a staging deployment — can name the root explicitly today.

[step 58]: ../../../docs/plans/extract-starlark-from-op/phase-8/steps/58-windows-system-target-root.md

Returns:

  • `string`: `writ.targets.system` when set, else `/`.

Types

type AdoptConfig

type AdoptConfig struct {
	Config

	// Files to adopt.
	Files []string

	// Layer to adopt into (personal, team, base).
	Layer string

	// LayerPath is the resolved path to the layer directory.
	LayerPath string

	// Project to adopt into.
	Project string

	// FromReceipt adopts from a lore receipt.
	FromReceipt bool
}

AdoptConfig contains all settings for an adopt operation.

type Config

type Config struct {
	// Tool is "writ" or "lore".
	Tool string

	// Sources
	LayerSources []tree.LayerSource
	SourceRoot   string // single-repo mode (when no layers configured)
	TargetRoot   string

	// Selection
	Projects []string
	Segments segment.Segments

	// Behavior
	DryRun         bool
	Verbose        bool
	ConflictPolicy op.ConflictPolicy

	// Data for templates
	TemplateData map[string]any

	// Identities for decryption
	Identities []age.Identity

	// Signing key (optional)
	SigningKey *age.X25519Identity
}

Config contains all resolved settings for a lifecycle operation. This is the common base; specific operations extend it.

func (*Config) SegmentMap

func (c *Config) SegmentMap() map[string]string

SegmentMap returns the segments as a string map for template data.

type DecommissionConfig

type DecommissionConfig struct {
	Config

	// Prune empty parent directories after file removal.
	Prune bool
}

DecommissionConfig contains all settings for a decommission operation.

type DeployConfig

type DeployConfig struct {
	Config

	// AllowDirty permits planning against layers with uncommitted changes.
	AllowDirty bool
}

DeployConfig contains all settings for a deploy operation.

type StatusConfig

type StatusConfig struct {
	Config

	// JSONOutput outputs JSON instead of human-readable text.
	JSONOutput bool
}

StatusConfig contains all settings for a status report.

type TargetSpec

type TargetSpec struct {
	SourceDir  string // "System" or "Home"
	TargetRoot string // "/" or "$HOME"
}

TargetSpec defines a source directory within a repo and its deployment target.

func TargetOrder

func TargetOrder() []TargetSpec

TargetOrder defines the processing order for targets within each repo. System files are deployed before Home files.

type UpgradeConfig

type UpgradeConfig struct {
	Config

	// Force upgrades even if target has local modifications.
	Force bool
}

UpgradeConfig contains all settings for an upgrade operation.

Directories

Path Synopsis
Package adopt plans the `writ adopt` batch graph.
Package adopt plans the `writ adopt` batch graph.
Package decommission removes deployed files through the sealed graph model (phase-8 step 47 slice 2).
Package decommission removes deployed files through the sealed graph model (phase-8 step 47 slice 2).
Package deploy plans and executes writ deployments on the sealed graph model (phase-8 step 47 slice 1).
Package deploy plans and executes writ deployments on the sealed graph model (phase-8 step 47 slice 1).
Package identity provides age identity loading for writ.
Package identity provides age identity loading for writ.
Package migrate implements dotfile migration analysis and execution.
Package migrate implements dotfile migration analysis and execution.
Package readback derives "what has writ deployed" from the store's graph and trace documents (phase-8 step 47 slice 1).
Package readback derives "what has writ deployed" from the store's graph and trace documents (phase-8 step 47 slice 1).
Package secret implements the writ secret family: SOPS lifecycle operations scoped to registered layers.
Package secret implements the writ secret family: SOPS lifecycle operations scoped to registered layers.
Package segment provides segment-based directory matching for writ.
Package segment provides segment-based directory matching for writ.
Package snapshot provides git worktree-based snapshots for hermetic planning.
Package snapshot provides git worktree-based snapshots for hermetic planning.
Package status reports what should be present, where it should have come from, and what's missing or different (phase-8 step 47 slice 3 — `writ status` replaces `writ reconcile`).
Package status reports what should be present, where it should have come from, and what's missing or different (phase-8 step 47 slice 3 — `writ status` replaces `writ reconcile`).
Package tree builds deployment trees from source and target specifications.
Package tree builds deployment trees from source and target specifications.
Package upgrade regenerates deployed copied files (templates, secrets, copies) from their current sources (phase-8 step 47 slice 2).
Package upgrade regenerates deployed copied files (templates, secrets, copies) from their current sources (phase-8 step 47 slice 2).
Package verify implements `writ verify` — publisher-signature verification for graph and trace documents (phase-8 step 46).
Package verify implements `writ verify` — publisher-signature verification for graph and trace documents (phase-8 step 46).

Jump to

Keyboard shortcuts

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