installer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package installer runs the staging-verify-activate install transaction with temp-then-rename atomicity under an exclusive lock.

Index

Constants

View Source
const (
	PrefAuto    = "auto"
	PrefSymlink = "symlink"
	PrefCopy    = "copy"
)

Mode-preference strings accepted on the command line and in the manifest. PrefAuto is the default: it prefers a symlink and falls back to a copy where symlinks are unsupported. Only ModeSymlink or ModeCopy is ever recorded as the resolved mode — never "auto".

View Source
const DefaultModePref = PrefAuto

DefaultModePref is the install-mode preference applied when neither the command line nor the manifest specifies one (FR-022, FR-023).

Variables

This section is empty.

Functions

func CleanupStaging

func CleanupStaging(roots ...string) (int, error)

CleanupStaging removes orphaned staging temp directories left under the given roots by an interrupted install, so a crash never leaves torn state behind (FR-024, SC-007). It returns the number of entries removed.

Types

type Installer

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

Installer runs the staging-verify-activate transaction over the store, cache, and git runner.

func New

func New(g git.Runner, c *cache.Cache, s *store.Store) *Installer

New builds an Installer. The git runner may be nil for local-only installs.

func (*Installer) Discover

func (i *Installer) Discover(ctx context.Context, req Request) (discovery.Skill, error)

Discover materializes the source and discovers the skill without activating it, for pre-flight checks such as learning the skill name or detecting a manifest conflict. Materialized git content is cached, so a following Install reuses it.

func (*Installer) DiscoverAll added in v0.1.0

func (i *Installer) DiscoverAll(ctx context.Context, req Request, opts discovery.Options) (discovery.Result, error)

DiscoverAll materializes req's source (cache/clone, honoring Offline) then recursively scans it for skills. It is read-only: no staging, activation, or manifest/lock writes. Used by source inspection, search, and the add pre-flight (contracts/discovery.md).

func (*Installer) Install

func (i *Installer) Install(ctx context.Context, req Request) (Result, error)

Install materializes, verifies, and activates the requested skill (FR-015, FR-018, FR-019, FR-020). It verifies content before activating into any agent directory, failing closed on a checksum mismatch.

type Mode

type Mode string

Mode is the actual activation method recorded for an installed skill. The requested preference may be "auto", but only symlink or copy is ever recorded (FR-020).

const (
	ModeSymlink Mode = "symlink"
	ModeCopy    Mode = "copy"
)

Install modes.

func (Mode) Valid

func (m Mode) Valid() bool

Valid reports whether m is a recognized install mode.

type Request

type Request struct {
	Ref         source.Ref
	Revision    resolver.Revision
	Name        string // declared manifest key; must match frontmatter name
	Path        string // explicit in-repo subpath (optional)
	Agents      []agent.Agent
	Scope       Scope
	ModePref    string // symlink | copy | auto
	ProjectRoot string
	Home        string
	// Offline forbids network fetches; material must already be cached (FR-026).
	Offline bool
	// ExpectContentHash, when set, must equal the materialized content hash or
	// the install fails closed (used by frozen restore, FR-015/FR-037).
	ExpectContentHash string
}

Request is everything needed to install one skill.

type Result

type Result struct {
	Skill         discovery.Skill
	ContentHash   string
	SkillFileHash string
	Mode          Mode              // representative mode (the first agent's)
	Modes         map[string]string // agentID -> actual mode used
	Agents        []string
	ActivePath    string            // project-relative active entry (empty for global scope)
	Targets       map[string]string // agentID -> recorded dir (relative for project scope)
	Warnings      []string
}

Result is the outcome of a successful install, sufficient to build a lock entry.

type Scope

type Scope string

Scope selects whether a skill installs into the current project or the user-global location (FR-028).

const (
	ScopeProject Scope = "project"
	ScopeGlobal  Scope = "global"
)

Install scopes.

func (Scope) Valid

func (s Scope) Valid() bool

Valid reports whether s is a recognized scope.

Jump to

Keyboard shortcuts

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