layout

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package layout is the single source of truth for where asset files live inside a file-based vault (git or path), across storage format versions.

Format v1 stores every version under the asset directory:

assets/{name}/list.txt
assets/{name}/{version}/...

Format v2 materializes the latest version directly at the asset directory so the vault is usable in place (point an editor, Obsidian, or .claude/skills at assets/{name}), and keeps the immutable version archive under .sx alongside the audit and usage logs:

assets/{name}/...                     (latest version, materialized copy)
.sx/versions/{name}/list.txt
.sx/versions/{name}/{version}/...    (immutable archive)

The manifest's schema_version selects the layout: 1 → v1, 2 → v2. All methods return vault-root-relative paths; callers join them with the root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

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

Layout computes storage paths for one vault format version. The zero value is not valid; obtain one via ForVersion or Detect.

func Detect

func Detect(vaultRoot string) (Layout, error)

Detect determines the storage format of the vault rooted at vaultRoot.

The manifest's schema_version is authoritative when sx.toml exists. Vaults without a manifest are classified by directory shape — see manifest.DetectShapeVersion.

func ForVersion

func ForVersion(v Version) (Layout, error)

ForVersion returns the layout for a storage format version.

func (Layout) AssetDir

func (l Layout) AssetDir(name string) string

AssetDir is the vault-relative directory for an asset. In v1 it contains version directories and list.txt; in v2 it contains the materialized latest version's files.

func (Layout) AssetsRoot

func (l Layout) AssetsRoot() string

AssetsRoot is the vault-relative directory containing asset directories.

func (Layout) MetadataPath

func (l Layout) MetadataPath(name, version string) string

MetadataPath is the vault-relative path of a stored version's metadata.toml.

func (Layout) SourcePathRel

func (l Layout) SourcePathRel(name, version string) string

SourcePathRel is the slash-separated vault-relative path recorded in manifest and lock source-path entries for a stored version. It always points at the immutable version directory, never the mutable v2 root view, so pinned resolution and caching stay stable across publishes.

func (Layout) Version

func (l Layout) Version() Version

Version returns the storage format version this layout computes paths for.

func (Layout) VersionDir

func (l Layout) VersionDir(name, version string) string

VersionDir is the vault-relative directory for one stored version of an asset. In v2 this is the immutable archive copy.

func (Layout) VersionListPath

func (l Layout) VersionListPath(name string) string

VersionListPath is the vault-relative path of an asset's list.txt.

func (Layout) VersionsDir

func (l Layout) VersionsDir(name string) string

VersionsDir is the vault-relative directory holding an asset's version directories and its list.txt.

type Version

type Version int

Version identifies a vault storage format.

const (
	// V1 is the legacy layout: all versions under assets/{name}/.
	V1 Version = 1

	// V2 is the latest-at-root layout: materialized latest under
	// assets/{name}/, archive under .sx/versions/{name}/.
	V2 Version = 2
)

Jump to

Keyboard shortcuts

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