Help us shape the future of Go! Take the 2026 Go Developer Survey

install

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentLayerGitignorePattern controls whether the repo-local Agent Layer
	// configuration directory is tracked by git.
	AgentLayerGitignorePattern = "/.agent-layer/"
	// DocsAgentLayerGitignorePattern controls whether Agent Layer project memory
	// is tracked by git.
	DocsAgentLayerGitignorePattern = "/docs/agent-layer/"
)
View Source
const (
	// DefaultDiffMaxLines is the default maximum number of diff lines shown per file.
	DefaultDiffMaxLines = 40
)
View Source
const SyncLockFileName = "sync.lock"

SyncLockFileName is the per-project sync lock file created under .agent-layer/ by internal/projectlock. It is defined here, in the package that owns the .agent-layer layout contract, so buildKnownPaths and the lock writer share a single source and the installer never reports the lock as an unknown file. internal/projectlock imports internal/install (not the reverse), so this is the cycle-safe home.

View Source
const UpgradeKeepListFileName = "upgrade-keep-list"

UpgradeKeepListFileName is the repo-local, gitignored list of paths that upgrade should treat as intentional user-owned content.

Variables

This section is empty.

Functions

func ApplyGitignoreTrackingSettings added in v0.17.3

func ApplyGitignoreTrackingSettings(content string, settings GitignoreTrackingSettings) (string, error)

ApplyGitignoreTrackingSettings updates the two tracking choices while leaving all unrelated template content intact.

func BuildUpgradePlanDiffPreviews added in v0.8.0

func BuildUpgradePlanDiffPreviews(root string, plan UpgradePlan, opts UpgradePlanDiffPreviewOptions) (map[string]DiffPreview, error)

BuildUpgradePlanDiffPreviews builds line-level diff previews for upgrade-plan text rendering.

func EncodeReleaseTemplateManifest added in v0.24.0

func EncodeReleaseTemplateManifest(versionRaw string, generatedAt time.Time, files map[string][]byte, catalogSkillPrefixes []string) ([]byte, error)

EncodeReleaseTemplateManifest encodes the ownership manifest committed for a release. files maps each destination path to its template bytes, and catalogSkillPrefixes is the complete set of catalog-skill path prefixes derived from the release's CLI skills catalog.

func EnsureGitignore added in v0.6.1

func EnsureGitignore(sys GitignoreSystem, path string, block string) error

EnsureGitignore updates or creates a .gitignore file with the given block. It merges the block into existing content, replacing any previous agent-layer block. The block should contain only the template content (ignore patterns and comments); managed markers and headers are added automatically.

func RepairGitignoreBlock added in v0.8.0

func RepairGitignoreBlock(root string, opts RepairGitignoreBlockOptions) error

RepairGitignoreBlock rewrites `.agent-layer/gitignore.block` from embedded templates, keeping any tracking choice the existing block states, and then reapplies the managed block to the repository root `.gitignore`.

func RollbackUpgradeSnapshot added in v0.8.0

func RollbackUpgradeSnapshot(root string, snapshotID string, opts RollbackUpgradeSnapshotOptions) error

RollbackUpgradeSnapshot restores a previously captured managed-file snapshot by ID.

func Run

func Run(root string, opts Options) error

Run initializes the repository with the required Agent Layer structure.

func StatuslineSourceSeedBytes added in v0.11.0

func StatuslineSourceSeedBytes(root string, source StatuslineSourceTemplate) ([]byte, error)

StatuslineSourceSeedBytes returns the bytes to seed a missing status line source under root, preferring a present legacy source file over the embedded template so a reseed never clobbers the user's migrated legacy customizations. Callers outside the install package (e.g. the wizard) use this to share the canonical seed logic rather than reading TemplatePath directly.

func ValidateGitignoreBlock added in v0.6.1

func ValidateGitignoreBlock(block string, blockPath string) (string, error)

ValidateGitignoreBlock normalizes and validates a gitignore block template. It returns the normalized block or an error if managed markers or a template hash are present.

Types

type BaselineStateSource added in v0.8.0

type BaselineStateSource string

BaselineStateSource identifies where baseline ownership evidence came from.

const (
	// BaselineStateSourceWrittenByInit indicates baseline was captured by a successful init write flow.
	BaselineStateSourceWrittenByInit BaselineStateSource = "written_by_init"
	// BaselineStateSourceWrittenByUpgrade indicates baseline was captured by an upgrade write flow.
	BaselineStateSourceWrittenByUpgrade BaselineStateSource = "written_by_overwrite"
	// BaselineStateSourceWrittenByOverwrite is a legacy name for BaselineStateSourceWrittenByUpgrade.
	BaselineStateSourceWrittenByOverwrite BaselineStateSource = BaselineStateSourceWrittenByUpgrade
)

type ConfigKeyMigration added in v0.8.0

type ConfigKeyMigration struct {
	Key  string `json:"key"`
	From string `json:"from"`
	To   string `json:"to"`
}

ConfigKeyMigration is reserved for explicit config migrations.

type DiffPreview added in v0.8.0

type DiffPreview struct {
	Path         string
	UnifiedDiff  string
	LinesAdded   int
	LinesRemoved int
}

DiffPreview is a user-facing, per-file diff preview used by upgrade prompts and plans.

type GitignoreSystem added in v0.6.1

type GitignoreSystem interface {
	ReadFile(name string) ([]byte, error)
	WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
}

GitignoreSystem is the minimal interface needed for gitignore operations.

type GitignoreTrackingSettings added in v0.17.3

type GitignoreTrackingSettings struct {
	TrackAgentLayerDir     bool
	TrackDocsAgentLayerDir bool
}

GitignoreTrackingSettings captures the user-owned tracking choices stored in the managed gitignore block.

func ParseGitignoreTrackingSettings added in v0.17.3

func ParseGitignoreTrackingSettings(content string) (GitignoreTrackingSettings, error)

ParseGitignoreTrackingSettings reads the two user-owned tracking choices from a gitignore block. A missing or commented pattern means the path is tracked.

type Options

type Options struct {
	Overwrite    bool
	Prompter     *PromptFuncs // nil means no interactive prompts.
	WarnWriter   io.Writer
	PinVersion   string
	DiffMaxLines int
	System       System
}

Options controls installer behavior.

type PromptConfigSetDefaultFunc added in v0.8.2

type PromptConfigSetDefaultFunc func(key string, manifestValue any, rationale string, field *config.FieldDef) (any, error)

PromptConfigSetDefaultFunc asks the user to confirm or customize a value for a missing required config key. It receives the key path, a default value from the migration manifest, a rationale string, and an optional field definition from the config catalog (nil when the key is not in the catalog). It returns the value to set (which may differ from the manifest value). When nil, the manifest value is used without prompting.

type PromptConfirmSkillsMigrationFunc added in v0.9.0

type PromptConfirmSkillsMigrationFunc func(flatSkills []string, conflicts []SkillsMigrationConflict) (bool, error)

PromptConfirmSkillsMigrationFunc asks the user to confirm the skills-format migration. It receives the list of flat skills to migrate and any detected conflicts. Returns true to proceed, false to abort.

type PromptDeleteUnknownAllFunc added in v0.5.4

type PromptDeleteUnknownAllFunc func(paths []string) (bool, error)

PromptDeleteUnknownAllFunc asks whether to delete all unknown paths.

type PromptDeleteUnknownFunc added in v0.5.4

type PromptDeleteUnknownFunc func(path string) (bool, error)

PromptDeleteUnknownFunc asks whether to delete a specific unknown path.

type PromptDeleteUnknownTmpAllFunc added in v0.10.0

type PromptDeleteUnknownTmpAllFunc func(paths []string) (bool, error)

PromptDeleteUnknownTmpAllFunc asks whether to delete every unknown path under .agent-layer/tmp/ as a single group, sparing the user a per-file prompt for that directory's contents.

type PromptFuncs added in v0.5.7

type PromptFuncs struct {
	OverwriteAllUnifiedPreviewFunc PromptOverwriteAllUnifiedPreviewFunc
	OverwritePreviewFunc           PromptOverwritePreviewFunc
	StatuslineSourcePreviewFunc    PromptStatuslineSourcePreviewFunc
	DeleteUnknownAllFunc           PromptDeleteUnknownAllFunc
	DeleteUnknownFunc              PromptDeleteUnknownFunc
	DeleteUnknownTmpAllFunc        PromptDeleteUnknownTmpAllFunc
	SelectUnknownsToKeepFunc       PromptSelectUnknownsToKeepFunc
	ConfigSetDefaultFunc           PromptConfigSetDefaultFunc
	ConfirmSkillsMigrationFunc     PromptConfirmSkillsMigrationFunc
}

PromptFuncs holds install prompt callbacks. A nil *PromptFuncs means headless. Overwrite mode requires unified and per-file overwrite callbacks and both delete-unknown callbacks. Optional nil callbacks keep statusline files, leave tmp untouched, select no keep-list paths, use manifest config defaults, and proceed with skills migration.

type PromptOverwriteAllUnifiedPreviewFunc added in v0.8.0

type PromptOverwriteAllUnifiedPreviewFunc func(managed []DiffPreview, memory []DiffPreview) (bool, bool, error)

PromptOverwriteAllUnifiedPreviewFunc asks whether to apply managed and memory updates in one pass.

type PromptOverwriteFunc

type PromptOverwriteFunc func(path string) (bool, error)

PromptOverwriteFunc asks whether to overwrite a given path.

type PromptOverwritePreviewFunc added in v0.8.0

type PromptOverwritePreviewFunc func(preview DiffPreview) (bool, error)

PromptOverwritePreviewFunc asks whether to overwrite a single diff preview path.

type PromptSelectUnknownsToKeepFunc added in v0.17.3

type PromptSelectUnknownsToKeepFunc func(paths []string) ([]string, error)

PromptSelectUnknownsToKeepFunc asks which unknown repo-relative paths should be persisted in the local upgrade keep list.

type PromptStatuslineSourcePreviewFunc added in v0.11.0

type PromptStatuslineSourcePreviewFunc func(preview DiffPreview) (bool, error)

PromptStatuslineSourcePreviewFunc asks whether to replace a user-owned statusline source with the embedded template version.

type RealSystem added in v0.5.7

type RealSystem struct{}

RealSystem implements System using the OS filesystem.

func (RealSystem) Chmod added in v0.13.0

func (RealSystem) Chmod(name string, mode os.FileMode) error

Chmod changes the mode of the named file or directory.

func (RealSystem) EvalSymlinks(path string) (string, error)

EvalSymlinks returns the path after evaluating symbolic links.

func (RealSystem) LookupEnv added in v0.8.0

func (RealSystem) LookupEnv(key string) (string, bool)

LookupEnv returns the value and presence of an environment variable.

func (RealSystem) Lstat added in v0.8.7

func (RealSystem) Lstat(name string) (os.FileInfo, error)

Lstat returns a FileInfo describing the named file without following symlinks.

func (RealSystem) MkdirAll added in v0.5.7

func (RealSystem) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path, along with any necessary parents.

func (RealSystem) ReadFile added in v0.5.7

func (RealSystem) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns the contents.

func (RealSystem) Readlink(name string) (string, error)

Readlink returns the destination of a symbolic link.

func (RealSystem) RemoveAll added in v0.5.7

func (RealSystem) RemoveAll(path string) error

RemoveAll removes path and any children it contains.

func (RealSystem) Rename added in v0.8.0

func (RealSystem) Rename(oldpath string, newpath string) error

Rename renames (moves) oldpath to newpath.

func (RealSystem) Stat added in v0.5.7

func (RealSystem) Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file.

func (RealSystem) Symlink(oldname string, newname string) error

Symlink creates newname as a symbolic link to oldname.

func (RealSystem) WalkDir added in v0.5.7

func (RealSystem) WalkDir(root string, fn fs.WalkDirFunc) error

WalkDir walks the file tree rooted at root.

func (RealSystem) WriteFileAtomic added in v0.5.7

func (RealSystem) WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to a file atomically by writing to a temp file and renaming.

type RepairGitignoreBlockOptions added in v0.8.0

type RepairGitignoreBlockOptions struct {
	System System
}

RepairGitignoreBlockOptions controls gitignore-block repair behavior.

type RollbackUpgradeSnapshotOptions added in v0.8.0

type RollbackUpgradeSnapshotOptions struct {
	System System
}

RollbackUpgradeSnapshotOptions controls manual rollback behavior.

type SkillsMigrationConflict added in v0.9.0

type SkillsMigrationConflict struct {
	SkillName string
	FlatPath  string
	DirPath   string
	Reason    string
}

SkillsMigrationConflict describes a flat-format skill that conflicts with an existing directory-format skill (different content at both locations).

type StatuslineSourceTemplate added in v0.11.0

type StatuslineSourceTemplate struct {
	RelPath       string
	TemplatePath  string
	LegacyRelPath string
	Perm          os.FileMode
}

StatuslineSourceTemplate describes an editable provider status line source.

func StatuslineSourceTemplates added in v0.11.0

func StatuslineSourceTemplates() []StatuslineSourceTemplate

StatuslineSourceTemplates returns the canonical editable status line sources.

type System added in v0.5.7

type System interface {
	Chmod(name string, mode os.FileMode) error
	EvalSymlinks(path string) (string, error)
	Lstat(name string) (os.FileInfo, error)
	Stat(name string) (os.FileInfo, error)
	ReadFile(name string) ([]byte, error)
	Readlink(name string) (string, error)
	LookupEnv(key string) (string, bool)
	MkdirAll(path string, perm os.FileMode) error
	RemoveAll(path string) error
	Rename(oldpath string, newpath string) error
	Symlink(oldname string, newname string) error
	WalkDir(root string, fn fs.WalkDirFunc) error
	WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
}

System abstracts filesystem operations needed by the installer. This interface is intentionally package-local per Decision edefea6 to enable parallel-safe unit tests without shared global state. Other packages (dispatch, sync) define their own System interfaces with operations specific to their needs.

type UpgradeChange added in v0.8.0

type UpgradeChange struct {
	Path string `json:"path"`
}

UpgradeChange describes a single template delta entry.

type UpgradeMigrationEntry added in v0.8.0

type UpgradeMigrationEntry struct {
	ID              string                 `json:"id"`
	Kind            string                 `json:"kind"`
	Rationale       string                 `json:"rationale"`
	SourceAgnostic  bool                   `json:"source_agnostic"`
	Status          UpgradeMigrationStatus `json:"status"`
	SkipReason      string                 `json:"skip_reason,omitempty"`
	From            string                 `json:"from,omitempty"`
	To              string                 `json:"to,omitempty"`
	Path            string                 `json:"path,omitempty"`
	Key             string                 `json:"key,omitempty"`
	Value           json.RawMessage        `json:"value,omitempty"`
	Breaking        bool                   `json:"breaking,omitempty"`
	BreakingNotice  string                 `json:"breaking_notice,omitempty"`
	BreakingDetails []string               `json:"breaking_details,omitempty"`
}

UpgradeMigrationEntry is a deterministic migration-plan/apply record.

type UpgradeMigrationReport added in v0.8.0

type UpgradeMigrationReport struct {
	TargetVersion         string                       `json:"target_version,omitempty"`
	MinPriorVersion       string                       `json:"min_prior_version,omitempty"`
	ManifestPath          string                       `json:"manifest_path,omitempty"`
	SourceVersion         string                       `json:"source_version"`
	SourceVersionOrigin   UpgradeMigrationSourceOrigin `json:"source_version_origin"`
	SourceResolutionNotes []string                     `json:"source_resolution_notes,omitempty"`
	Entries               []UpgradeMigrationEntry      `json:"entries"`
}

UpgradeMigrationReport contains deterministic migration planning/execution data for upgrade output.

type UpgradeMigrationSourceOrigin added in v0.8.0

type UpgradeMigrationSourceOrigin string

UpgradeMigrationSourceOrigin identifies where migration source-version evidence came from.

const (
	// UpgradeMigrationSourceUnknown means source version could not be determined.
	UpgradeMigrationSourceUnknown UpgradeMigrationSourceOrigin = "unknown"
	// UpgradeMigrationSourcePin means source version came from .agent-layer/al.version.
	UpgradeMigrationSourcePin UpgradeMigrationSourceOrigin = "pin_file"
	// UpgradeMigrationSourceBaseline means source version came from managed baseline state.
	UpgradeMigrationSourceBaseline UpgradeMigrationSourceOrigin = "managed_baseline"
	// UpgradeMigrationSourceSnapshot means source version came from latest upgrade snapshot pin entry.
	UpgradeMigrationSourceSnapshot UpgradeMigrationSourceOrigin = "upgrade_snapshot"
	// UpgradeMigrationSourceManifestMatch means source version was inferred from embedded manifest fingerprint matching.
	UpgradeMigrationSourceManifestMatch UpgradeMigrationSourceOrigin = "manifest_match"
)

type UpgradeMigrationStatus added in v0.8.0

type UpgradeMigrationStatus string

UpgradeMigrationStatus describes migration execution/planning status.

const (
	// UpgradeMigrationStatusPlanned means migration is eligible to run.
	UpgradeMigrationStatusPlanned UpgradeMigrationStatus = "planned"
	// UpgradeMigrationStatusApplied means migration mutated repository state during apply.
	UpgradeMigrationStatusApplied UpgradeMigrationStatus = "applied"
	// UpgradeMigrationStatusNoop means migration ran but made no changes (already migrated/idempotent).
	UpgradeMigrationStatusNoop UpgradeMigrationStatus = "no_op"
	// UpgradeMigrationStatusSkippedUnknownSource means migration requires a known source version but source is unknown.
	UpgradeMigrationStatusSkippedUnknownSource UpgradeMigrationStatus = "skipped_unknown_source"
	// UpgradeMigrationStatusSkippedSourceTooOld means migration requires a newer prior version than the resolved source.
	UpgradeMigrationStatusSkippedSourceTooOld UpgradeMigrationStatus = "skipped_source_too_old"
)

type UpgradePinAction added in v0.8.0

type UpgradePinAction string

UpgradePinAction identifies the pin transition kind in an upgrade plan.

const (
	// UpgradePinActionNone means the current pin already matches the target pin.
	UpgradePinActionNone UpgradePinAction = "none"
	// UpgradePinActionSet means the repo currently has no pin and the plan sets one.
	UpgradePinActionSet UpgradePinAction = "set"
	// UpgradePinActionUpdate means the repo pin changes from one value to another.
	UpgradePinActionUpdate UpgradePinAction = "update"
	// UpgradePinActionRemove means the repo pin is removed for the target.
	UpgradePinActionRemove UpgradePinAction = "remove"
)

type UpgradePinVersionDiff added in v0.8.0

type UpgradePinVersionDiff struct {
	Current string           `json:"current"`
	Target  string           `json:"target"`
	Action  UpgradePinAction `json:"action"`
}

UpgradePinVersionDiff captures current->target pin movement for upgrade planning.

type UpgradePlan added in v0.8.0

type UpgradePlan struct {
	TemplateAdditions         []UpgradeChange         `json:"template_additions"`
	TemplateUpdates           []UpgradeChange         `json:"template_updates"`
	StatuslineSourceAdditions []UpgradeChange         `json:"statusline_source_additions"`
	StatuslineSourceUpdates   []UpgradeChange         `json:"statusline_source_updates"`
	SectionAwareUpdates       []UpgradeChange         `json:"section_aware_updates"`
	TemplateRenames           []UpgradeRename         `json:"template_renames"`
	TemplateRemovalsOrOrphans []UpgradeChange         `json:"template_removals_or_orphans"`
	ConfigKeyMigrations       []ConfigKeyMigration    `json:"config_key_migrations"`
	MigrationReport           UpgradeMigrationReport  `json:"migration_report"`
	PinVersionChange          UpgradePinVersionDiff   `json:"pin_version_change"`
	ReadinessChecks           []UpgradeReadinessCheck `json:"readiness_checks"`
}

UpgradePlan is the dry-run plan rendered by `al upgrade plan`.

func BuildUpgradePlan added in v0.8.0

func BuildUpgradePlan(root string, opts UpgradePlanOptions) (UpgradePlan, error)

BuildUpgradePlan computes a dry-run upgrade plan against the running binary's embedded templates.

type UpgradePlanDiffPreviewOptions added in v0.8.0

type UpgradePlanDiffPreviewOptions struct {
	System       System
	MaxDiffLines int
}

UpgradePlanDiffPreviewOptions controls diff preview generation for upgrade plan rendering.

type UpgradePlanOptions added in v0.8.0

type UpgradePlanOptions struct {
	TargetPinVersion string
	System           System
}

UpgradePlanOptions controls dry-run plan generation.

type UpgradeReadinessCheck added in v0.8.0

type UpgradeReadinessCheck struct {
	ID      string   `json:"id"`
	Summary string   `json:"summary"`
	Action  string   `json:"action"`
	Details []string `json:"details"`
}

UpgradeReadinessCheck captures a non-fatal pre-upgrade readiness finding for text output.

type UpgradeRename added in v0.8.0

type UpgradeRename struct {
	From string `json:"from"`
	To   string `json:"to"`
}

UpgradeRename describes a rename detected by the dry-run planner.

type UpgradeSnapshotMetadata added in v0.8.5

type UpgradeSnapshotMetadata struct {
	ID           string
	CreatedAtUTC string
	Status       string
}

UpgradeSnapshotMetadata provides lightweight snapshot listing fields.

func ListUpgradeSnapshots added in v0.8.5

func ListUpgradeSnapshots(root string, sys System) ([]UpgradeSnapshotMetadata, error)

ListUpgradeSnapshots returns metadata for all available upgrade snapshots, sorted by creation time (newest first).

Jump to

Keyboard shortcuts

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