writ

package
v0.1.0-dev.20260223223859 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package writ implements the writ CLI commands.

Index

Constants

View Source
const CurrentVersion = "6"

CurrentVersion is the graph format version.

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 BuildTree

func BuildTree(g *op.Graph, cfg *Config, reg *op.ActionRegistry) (manifests []string, err error)

BuildTree walks the source directories and populates the graph with file nodes. This processes layers in order (base → team → personal) with collision detection. Returns discovered manifest source paths instead of creating nodes for them.

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 ConfigureEngine

func ConfigureEngine(cfg *Config) (*execution.GraphExecutor, error)

ConfigureEngine creates and configures an execution engine for the graph.

func NewGraph

func NewGraph(cfg *Config) *op.Graph

NewGraph creates a op.Graph with common fields populated for writ.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates the root writ command with all subcommands.

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 AdoptGraphBuilder

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

AdoptGraphBuilder builds execution graphs for adopt operations.

func NewAdoptGraphBuilder

func NewAdoptGraphBuilder(cfg *AdoptConfig) *AdoptGraphBuilder

NewAdoptGraphBuilder creates a new adopt graph builder.

func (*AdoptGraphBuilder) Build

func (b *AdoptGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph 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
	ConflictResolution execution.ConflictResolution

	// 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

	// Force decommission even with unsigned state.
	Force bool

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

DecommissionConfig contains all settings for a decommission operation.

type DecommissionGraphBuilder

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

DecommissionGraphBuilder builds execution graphs for decommission operations.

func NewDecommissionGraphBuilder

func NewDecommissionGraphBuilder(cfg *DecommissionConfig, view *execution.StateView, reg *op.ActionRegistry) *DecommissionGraphBuilder

NewDecommissionGraphBuilder creates a new decommission graph builder.

func (*DecommissionGraphBuilder) Build

func (b *DecommissionGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph for a decommission operation.

type DeployConfig

type DeployConfig struct {
	Config
}

DeployConfig contains all settings for a deploy operation.

type DeployGraphBuilder

type DeployGraphBuilder struct {
	Planner *lore.Planner // nil means skip manifest resolution
	// contains filtered or unexported fields
}

DeployGraphBuilder builds execution graphs for deploy operations.

func NewDeployGraphBuilder

func NewDeployGraphBuilder(cfg *DeployConfig, reg *op.ActionRegistry) *DeployGraphBuilder

NewDeployGraphBuilder creates a new deploy graph builder.

func (*DeployGraphBuilder) Build

func (b *DeployGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph for a deploy operation.

type GraphBuilder

type GraphBuilder interface {
	Build() (*op.Graph, error)
}

GraphBuilder is the interface for all graph builders.

type MigrateGraphBuilder

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

MigrateGraphBuilder builds execution graphs for migrate operations.

func NewMigrateGraphBuilder

func NewMigrateGraphBuilder(cfg *Config, sourcePath string) *MigrateGraphBuilder

NewMigrateGraphBuilder creates a new migrate graph builder.

func (*MigrateGraphBuilder) Build

func (b *MigrateGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph for a migrate operation.

type ReconcileConfig

type ReconcileConfig struct {
	Config

	// CheckDrift enables drift detection for copied files.
	CheckDrift bool

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

ReconcileConfig contains all settings for a reconcile operation.

type ReconcileGraphBuilder

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

ReconcileGraphBuilder builds execution graphs for reconcile operations.

func NewReconcileGraphBuilder

func NewReconcileGraphBuilder(cfg *ReconcileConfig) *ReconcileGraphBuilder

NewReconcileGraphBuilder creates a new reconcile graph builder.

func (*ReconcileGraphBuilder) Build

func (b *ReconcileGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph for a reconcile operation.

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.

type UpgradeGraphBuilder

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

UpgradeGraphBuilder builds execution graphs for upgrade operations.

func NewUpgradeGraphBuilder

func NewUpgradeGraphBuilder(cfg *UpgradeConfig, view *execution.StateView) *UpgradeGraphBuilder

NewUpgradeGraphBuilder creates a new upgrade graph builder.

func (*UpgradeGraphBuilder) Build

func (b *UpgradeGraphBuilder) Build() (*op.Graph, error)

Build creates an execution graph for an upgrade operation.

type VerifyResult

type VerifyResult int

VerifyResult indicates the outcome of signature verification.

const (
	VerifyOK VerifyResult = iota
	VerifyUnsigned
	VerifyInvalid
	VerifyMissing
)

VerifyOK indicates the signature matched, VerifyUnsigned means no signature was present, VerifyInvalid means the signature failed verification, and VerifyMissing means the expected signature data was absent.

func VerifyGraphSignature

func VerifyGraphSignature(g *op.Graph, identities []age.Identity) (VerifyResult, error)

VerifyGraphSignature verifies the graph signature using the provided identities. Returns the verification result and any error encountered.

func (VerifyResult) String

func (r VerifyResult) String() string

String returns a human-readable description of the verify result.

Directories

Path Synopsis
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 reconcile implements drift detection and repair for writ deployments.
Package reconcile implements drift detection and repair for writ deployments.
Package secrets handles encryption/decryption operations via SOPS.
Package secrets handles encryption/decryption operations via SOPS.
Package segment provides segment-based directory matching for writ.
Package segment provides segment-based directory matching for writ.
Package tree builds deployment trees from source and target specifications.
Package tree builds deployment trees from source and target specifications.

Jump to

Keyboard shortcuts

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