overrides

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package overrides applies a resolved override declaration to a skill's upstream content (spec 023): whole-file replacement, unified-diff patches, and prepend/append layering, in that fixed order.

The pipeline is a deterministic function of its inputs — the same upstream content, declaration, and input files always produce the same bytes — which is what lets the result be committed and reproduced from a clone (FR-009).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(skillDir, repoRoot string, spec Spec) error

Apply transforms skillDir in place, resolving override inputs against repoRoot. Stages run in the fixed order replace → patch → layer (FR-004): replace establishes the file that ships, patch adjusts that file, and layering goes last so appended content is never itself patched.

The whole operation is all-or-nothing (FR-011). Work happens on a staged copy and is swapped in only after every stage succeeds, so a patch that stops applying leaves the previously materialized content exactly as it was — never half-transformed.

func Materialize

func Materialize(src, repoRoot string, spec Spec) (string, func(), error)

Materialize copies src into a scratch directory and transforms the copy, returning the transformed directory and a cleanup to run when the caller is done with it. An empty declaration hands back src itself with a no-op cleanup, so a caller needs no special case.

It exists because two callers need the *result* rather than an in-place transformation: the installer, which must not write to the shared clone cache or to a local source the user owns, and the reconcile path, which hashes what would ship before deciding whether to ship it. Both must see identical bytes, so they run the identical pipeline.

Types

type Spec

type Spec struct {
	Replace map[string]string
	Patch   []string
	Prepend []string
	Append  []string
}

Spec is a resolved override declaration with repo-relative input paths.

func (Spec) Empty

func (s Spec) Empty() bool

Empty reports whether the declaration transforms nothing, in which case Apply leaves the tree untouched and the skill keeps its upstream hash.

func (Spec) Inputs

func (s Spec) Inputs() []string

Inputs returns every repo-relative file the declaration references, in a stable order: replace sources sorted by target, then patch, prepend, and append in declared order. Order must never depend on map iteration, since the same list feeds the identity digest (Constitution I).

Jump to

Keyboard shortcuts

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