selfupdate

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package selfupdate owns the on-disk install layout and the self-update mechanics behind the `self install|update|uninstall|doctor` commands. It is a plain internal package (like internal/agentskill): the cli layer (cli/selfcmd) builds a Config from the invocation environment and calls the operations here, which do the file/network work and return result structs; no cli-facing formatting lives here.

The model is a single installed binary on PATH plus a manifest. The binary sits at a stable name on PATH (~/.local/bin/digitalx on unix, %LOCALAPPDATA%\bin\digitalx.exe on windows) — a real file, not a symlink (Windows file symlinks need admin/Developer Mode). <home>/install.json records what was installed (version, sha256, provenance, aliases) and is what gates self update. self update replaces the binary in place with github.com/minio/selfupdate, which also handles the Windows running-exe swap.

An install may additionally carry ALIASES — extra command names on PATH in the same directory that run the same binary (a relative symlink on unix, a second copy on windows, since an unprivileged Windows install has no usable file symlink). Layout.LegacyBinName is the one alias name this package manages, so the `korbit` command keeps working on an install that has it. install and update keep every alias current; uninstall removes them with the primary.

Two generations of names

The binary, the CLI home, the artifact cache, and the databases inside a home each have a current name and an earlier one, and both keep working. MIGRATION.md is the user-facing contract for how they coexist; the command names are implemented in alias.go. Three invariants split the work between the verbs, and every one of them is load bearing:

  • self update leaves the COMMAND LAYOUT correct — digitalx is the real file with the current bytes, and an owned korbit name points at it — including on a run that finds nothing to update (repairLayout). repairLayout ships inside the release being downloaded, so an install still running the korbit-era binary gains digitalx on its SECOND update run; MIGRATION.md documents that two-run upgrade.
  • NOTHING here moves or renames a directory, or a file inside one. No verb does, and no flag asks for it: install (and therefore the install one-liner) repairs the command layout, update swaps a binary, doctor is read-only by contract, and a CLI home under the earlier directory name is simply used as it is, indefinitely. A user who wants the current directory name performs the move themselves (MIGRATION.md spells it out).
  • A home's DIRECTORY NAME and the FILE NAMES inside it are one unit (config.LegacyLayout): a home named `.korbit-cli` holds the earlier filenames, and every other directory holds the current ones. A directory renamed without its files would be a full home the CLI reads as empty, which is the state doctor reports as a problem.

Trust is TLS + sha256 + a release signature: self update fetches the release checksums.txt and verifies the downloaded archive's sha256 against it before the swap, and — gated by a release-signing certificate published on the trusted docs host (a different host than the GitHub release, so it defends against a compromised release) — verifies the detached RSA signature over checksums.txt. See verify.go for the full policy (including the empty-cert kill switch and why any fetch failure is fatal).

What a release names for itself

The archive to download and the binary basename inside it come from the release's own release-manifest.json rather than from constants compiled into this binary, so a later release can rename either without stranding installs made before it. The manifest is listed in checksums.txt, so the one signature over that file authenticates it too — no second key, no second host. resolveTarget in release.go holds the policy, including the fallback to the compiled-in names.

Index

Constants

View Source
const (
	FieldManaged = "managed" // the managed-install / manifest check
	FieldBinary  = "binary"  // the installed-binary check
	FieldAlias   = "alias"   // the alias-command-name check
	FieldPath    = "path"    // the on-PATH check
	FieldHome    = "home"    // the CLI-home directory check
)

Diagnosis field names, one per line `self doctor` reports. A DoctorProblem carries the same tag as the line it belongs to, so the text view can print the problem + fix inline under its diagnosis and an agent can key off it.

View Source
const (
	SigVerified = "verified"
	SigDisabled = "disabled"
)

SigVerified / SigDisabled are the outcomes verifyChecksumsSignature reports (surfaced in UpdateResult.SignatureCheck): the release signature was verified against the published cert, or verification was disabled by an empty cert.

View Source
const DefaultReleaseCertURL = "https://docs.digitalx.miraeasset.com/release-signing-cert.pem"

DefaultReleaseCertURL is where self update fetches the release-signing certificate to verify a release's checksums.txt signature. It is served from the managed docs host — deliberately a different, access-controlled host than the GitHub release it authenticates — so the pin defends against a compromised release even though the archive, its checksums, and the signature all come from GitHub. See verify.go for the fetch/verify policy.

View Source
const DefaultRepo = "digitalx-official/digitalx-cli"

DefaultRepo is the public release repository self update resolves against.

View Source
const MethodManagedScript = "managed-script"

MethodManagedScript is the manifest `method` for an install created by the managed install script / `self install`. It is the only method self update operates on; any other provenance (go install, Homebrew, a hand-downloaded archive, a dev build) is refused with guidance.

Variables

View Source
var LegacyEnvHome = func() string {
	if legacy, ok := envalias.LegacyName(config.EnvHome); ok {
		return legacy
	}
	return config.EnvHome
}()

LegacyEnvHome is the accepted older spelling of the home-relocating environment variable, derived from the canonical name so the two cannot drift from what config.Home actually reads.

Functions

func BareVersion added in v1.3.0

func BareVersion(tag string) string

BareVersion is the inverse of normalizeTag: a release tag reduced to the spelling the CLI names ITSELF by everywhere — `--version`, the User-Agent (internal/version), the install manifest, the self-command results — which is the tag without its leading "v", because that is the exact string the release build injects into internal/version.

Both spellings are needed and neither can replace the other: a release is ADDRESSED by its tag (every download URL is built from it) and REPORTED by its bare version. That is also why they must never meet in a raw comparison — "1.2.0" and "v1.2.0" are the same release, and a `==` between them says they are not. Put every version through this before comparing or reporting it.

The "v" is dropped only ahead of a digit, so a version that is not a v-prefixed number — the "dev" build included — comes back untouched.

func Fields

func Fields() []string

Fields lists every diagnosis tag doctor reports against, in report order, so a renderer covers them all without repeating the list and the user-facing contract (MIGRATION.md) can be checked against it.

Types

type AliasStatus

type AliasStatus struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	Target  string `json:"target,omitempty"`
	Present bool   `json:"present"`
	// Valid reports whether the alias actually runs the primary binary: on unix
	// its symlink resolves to it, and for a plain copy its bytes are the ones the
	// manifest recorded. A present-but-invalid alias is the dangerous case — the
	// command exists, so nothing looks wrong, and it silently runs some other
	// binary or a version behind.
	Valid bool `json:"valid"`
}

AliasStatus is one alias command name and where it currently points. Target is the symlink target when the alias is a symlink (unix) and empty when it is a plain copy (windows). Present is false when the manifest records the alias but nothing is there — a broken command the user must repair.

type Config

type Config struct {
	// Getenv reads the process environment (DIGITALX_CLI_HOME and the legacy
	// KORBIT_CLI_HOME, HOME/USERPROFILE, LOCALAPPDATA, PATH). Injectable so
	// tests point it at a temp dir.
	Getenv func(string) string
	// Now is the local clock in unix-ms, stamped into the manifest's installedAt.
	Now func() int64
	// Doer is the HTTP client self update / version resolution run through
	// (nil is fine for install/uninstall/doctor, which touch no network).
	Doer Doer
	// GOOS / GOARCH are the target platform (runtime.GOOS/GOARCH in production;
	// injectable so the path layout can be tested for another OS on this host).
	GOOS   string
	GOARCH string
	// Version is the running binary's version (internal/version.Version). A "dev"
	// value marks an unmanaged source build and is refused.
	Version string
	// Repo is the release repository (owner/name); empty means DefaultRepo.
	Repo string
	// ReleaseCertURL is the URL of the release-signing certificate on the trusted
	// docs host; empty means DefaultReleaseCertURL. Injectable so tests point it
	// at a stub endpoint.
	ReleaseCertURL string
	// PathConfirm is asked once per PATH location that needs the installer's entry
	// (each shell rc file on unix; the User PATH on windows) and returns whether to
	// apply it. nil means non-interactive (no TTY reachable) — PATH wiring then only
	// prints guidance instead of editing dotfiles (unix) / keeps the silent write
	// (windows). The cli layer wires a /dev/tty-backed confirm that renders the
	// addition's diff preview and defaults an empty answer to yes.
	PathConfirm func(add PathAddition) (bool, error)
	// HomeDBNames are the databases a CLI home holds, each under the two
	// filenames it can carry (see HomeDBName). The names belong to their owners —
	// internal/journal, internal/sandbox, the monitor command — which this
	// package must not import, so the cli layer supplies them. Empty means the
	// caller supplied none, and the file-layout diagnosis is then skipped rather
	// than guessed at.
	HomeDBNames []HomeDBName
	// Progress is the human progress/instruction sink (stderr). It is never the
	// result: everything an agent needs is in the returned struct.
	Progress io.Writer
	// Logger is the optional operational logger for the fragile network/filesystem
	// path (release resolution, each fetch, the signature/checksum verdicts, the
	// in-place binary swap, manifest writes, PATH edits). nil = silent (resolved
	// via logging.Or in log). It is distinct from Progress: Progress is program
	// output, Logger is the level-gated --debug/--log-level telemetry.
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Config is the injected environment one self-management operation runs against, so the whole package is unit-testable against a temp home, a stub HTTP client, and a fixed clock.

func (Config) AliasPaths

func (c Config) AliasPaths() []string

AliasPaths returns the on-disk path of every extra command name this install OWNS (alias.go) — exactly what Uninstall removes alongside the primary binary, so the interactive front-end can show it before asking.

func (Config) AssertManaged

func (c Config) AssertManaged() error

AssertManaged reports whether this is a managed install self uninstall can operate on (the running binary is the one the managed install script placed, with a matching manifest). The interactive front-end calls it BEFORE asking any removal question or clearing keys, so a non-managed install is refused before any destructive work — Uninstall re-checks it under the lock as a backstop.

func (Config) Doctor

func (c Config) Doctor() (*DoctorReport, error)

Doctor inspects the install and reports its health without changing anything.

func (Config) Install

func (c Config) Install() (*InstallResult, error)

Install copies the running binary to the stable PATH location, wires PATH, and writes the manifest. It is RECONCILING, not linear: re-running it converges a broken install to healthy (a deleted binary, a lost PATH entry, a corrupt manifest, a leftover temp file, …) and tolerates any subset already correct. It is the binary side of the `curl … | sh` repair path, so it assumes nothing about the prior on-disk state. Because the install script is version-pinned, Install records THIS binary's version.

It touches the COMMAND LAYOUT only: no directory is moved, renamed, replaced, or pruned, and no file inside a CLI home is renamed. An existing ~/.korbit-cli is simply the home (config.Home), for as long as the user leaves it there.

func (Config) Layout

func (c Config) Layout() Layout

Layout returns the path layout for this configuration.

func (Config) OnPath

func (c Config) OnPath() bool

OnPath reports whether the install dir is already effectively on PATH, so PATH wiring would be a no-op. Read-only; the dry-run report uses it to tell "already on PATH" apart from "wired on disk but not yet in this shell" (both of which leave PathAdditions empty).

func (Config) PathAdditions

func (c Config) PathAdditions() []PathAddition

PathAdditions returns the pending "add the installer's PATH line" edits, one per location that does not yet carry the installer's entry (each shell rc file lacking the managed block on unix; the User PATH on windows), each with a diff preview. Empty when the install dir is already on PATH or every location already has the entry. It edits nothing — the interactive front-end renders the previews, asks per location, and applies only what the user accepts.

func (Config) PathEdits

func (c Config) PathEdits() []PathEdit

PathEdits returns the pending "undo the installer's PATH change" edits, one per location that currently carries the installer's entry (each shell rc file with the managed block on unix; the User PATH on windows), each with a diff preview. Empty when there is nothing to undo. It edits nothing.

func (Config) Uninstall

func (c Config) Uninstall(opts UninstallOptions) (*UninstallResult, error)

Uninstall removes the parts of a managed install the caller selected, all under one lock. It refuses on a non-managed install before touching anything. Once past the lock it never returns an error — every problem is recorded in the result (Failed/Warnings) so a partial removal is always fully reported.

func (Config) Update

func (c Config) Update(ctx context.Context, opts UpdateOptions) (*UpdateResult, error)

Update resolves the target release (latest, or opts.TargetVersion when set), and — unless opts.DryRun — downloads it, verifies the release checksums.txt against the release signature (verify.go), verifies the archive's sha256 against that checksums.txt, and replaces the installed binary in place (minio/selfupdate, which re-verifies the exact bytes against the passed checksum and handles the Windows running-exe swap), then updates the manifest. It refuses on a non-managed or dev build (ProvenanceError).

type DiffLine

type DiffLine struct {
	Num  int    `json:"num,omitempty"`
	Text string `json:"text"`
}

DiffLine is one line of a pending PATH-undo edit shown to the user before it is applied. Num is the 1-based line number in the file, or 0 for a location that is not a file (the Windows User PATH), where only Text (the entry) is shown.

type DoctorProblem

type DoctorProblem struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

DoctorProblem is one thing wrong with the install: which diagnosis it belongs to (Field) and a message that states the problem AND its fix.

type DoctorReport

type DoctorReport struct {
	Managed          bool   `json:"managed"`
	Method           string `json:"method,omitempty"`
	RunningVersion   string `json:"runningVersion"`
	InstalledVersion string `json:"installedVersion,omitempty"`
	RunningFrom      string `json:"runningFrom"`
	Executable       string `json:"executable"`
	ExecutableValid  bool   `json:"executableValid"`
	ExecutableDir    string `json:"executableDir"`
	OnPath           bool   `json:"onPath"`
	// LegacyLayout marks the shape where the binary on PATH carries only the
	// alias name (Layout.LegacyBinName) and the primary name is not on disk. It is
	// a HEALTHY install, not a problem: self update installs the primary name and
	// keeps the alias pointing at it, on any run — a new release is not needed
	// (see repairLayout).
	LegacyLayout bool `json:"legacyLayout,omitempty"`
	// Home is the CLI home in use; LegacyHome is the home an installation made
	// under the earlier product name carries, reported only when it exists.
	Home       string `json:"home"`
	LegacyHome string `json:"legacyHome,omitempty"`
	// Aliases is the state of each extra command name this install carries, in the
	// order the manifest records them.
	Aliases  []AliasStatus   `json:"aliases,omitempty"`
	Problems []DoctorProblem `json:"problems"`
	// Notes are informational observations that are NOT problems: a state that
	// works as it is, but that a verb would tidy up (an install running only
	// under the alias name, an unmanaged file at the alias name). They never
	// affect OK(), so `self doctor` still exits 0.
	Notes []string `json:"notes,omitempty"`
}

DoctorReport is the read-only install-health report from `self doctor`. It diagnoses the same states self install repairs, but never mutates. Each Problem is attached to the diagnosis it concerns and states both what is wrong and how to fix it.

func (DoctorReport) OK

func (r DoctorReport) OK() bool

OK reports whether the install is healthy (managed, executable valid, on PATH, no problems). The cli layer maps a false to a non-zero exit. Notes are excluded by design: they describe supported states, not faults.

func (DoctorReport) Problem

func (r DoctorReport) Problem(field string) string

Problem returns the message for the given diagnosis field, or "" if that diagnosis is healthy.

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer performs an HTTP request. *http.Client satisfies it, as does the CLI's shared apiclient.Doer; tests inject a stub. Declared locally so the package does not depend on internal/apiclient.

type FailedRemoval

type FailedRemoval struct {
	Path   string `json:"path"`
	Reason string `json:"reason"`
}

FailedRemoval is one thing uninstall could not remove or edit, with why — so the summary tells the user exactly what is left and what to do about it.

type HomeDBName

type HomeDBName struct {
	Current string
	Legacy  string
}

HomeDBName is one database a CLI home holds, as the home-relative path it takes under each of the two filename layouts: `journal.db` and `korbit-cli.db`, `sandbox/sandbox.db` and `sandbox/korbit-sandbox.db`. Both are written with forward slashes, the way a user reads them.

Which spelling a home reads is decided by the home's own directory name alone (config.LegacyLayout), so a home holding the OTHER spelling holds data nothing in it will open — the one file-layout state doctor reports. The names live with their owners (internal/journal, internal/sandbox, the monitor command), which this package must not import, so the cli layer supplies them through Config.HomeDBNames.

type InstallResult

type InstallResult struct {
	Version    string     `json:"version"`
	Executable string     `json:"executable"`
	SHA256     string     `json:"sha256"`
	Repaired   []string   `json:"repaired"` // healed states (always present; [] when clean)
	Path       PathResult `json:"path"`
	Warnings   []string   `json:"warnings,omitempty"`
	// Aliases are the extra command names now pointing at the installed binary
	// (see alias.go). Absent on a fresh install, which creates none.
	Aliases []string `json:"aliases,omitempty"`
	// Next lists follow-up steps for the user — today only a variable worth
	// renaming.
	Next []string `json:"next,omitempty"`
}

InstallResult is what `self install` reports: the version installed, the binary path it settled, what it had to repair (empty on a clean first install), and the PATH outcome. Everything the caller needs is here — nothing important is only on stderr.

type Layout

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

Layout computes the install paths from the environment. Paths derive from two roots: the CLI home (config.Home — the manifest + lock) and the OS user home (the installed binary dir), so $DIGITALX_CLI_HOME relocates the manifest without moving the installed binary.

func (Layout) AliasPath

func (l Layout) AliasPath(name string) string

AliasPath is where the alias named name sits: in the install dir, next to the primary binary.

func (Layout) BinName

func (l Layout) BinName() string

BinName is the installed binary/stored binary's filename: digitalx, or digitalx.exe on Windows. It is the fixed canonical name (not the possibly-renamed program basename) so the installed binary is predictable.

func (Layout) CurrentHomeDir

func (l Layout) CurrentHomeDir() string

CurrentHomeDir and LegacyHomeDir are the two standard CLI home locations under the OS user home — ~/.digitalx-cli and ~/.korbit-cli. They are what Home() chooses between when nothing pins the home, and are named separately because the health report reasons about BOTH (Home() only ever returns one). Neither need exist.

func (Layout) ExecutableDir

func (l Layout) ExecutableDir() string

ExecutableDir is the directory on PATH the active binary is copied into: ~/.local/bin on unix, %LOCALAPPDATA%\bin (= %USERPROFILE%\AppData\Local\bin) on Windows.

func (Layout) ExecutablePath

func (l Layout) ExecutablePath() string

ExecutablePath is the active binary's stable path on PATH.

func (Layout) Home

func (l Layout) Home() string

Home is the CLI home: $DIGITALX_CLI_HOME (or the legacy $KORBIT_CLI_HOME) when set, else ~/.digitalx-cli, falling back to an existing ~/.korbit-cli. The manifest and the lock live under it.

It applies config.Home's rule, but resolves the user home through this Layout's own userHome — so the home and the installed-binary directory always mean the SAME user home, and a caller that redirects the environment (an agent with its own HOME, a test) gets a consistent layout rather than a manifest under one user's home and a binary under another's.

A pinned path is normalized exactly as config.Home normalizes it, so this package and the rest of the CLI reason about one spelling of one directory.

func (Layout) HomeEnvVar

func (l Layout) HomeEnvVar() string

HomeEnvVar returns the name of the environment variable that pins the CLI home in this environment, or "" when nothing does. The canonical name wins, matching config.Home. A caller uses it to refuse to move a home the user placed deliberately, and to name the variable in its advice.

func (Layout) LegacyBinName

func (l Layout) LegacyBinName() string

LegacyBinName is the alias command name an install may carry alongside the primary binary: korbit, or korbit.exe on Windows. An install that has it on PATH keeps it working — pointed at the primary binary — so both command names run the same version.

func (Layout) LegacyExecutablePath

func (l Layout) LegacyExecutablePath() string

LegacyExecutablePath is where the LegacyBinName alias sits — next to the primary binary, so one PATH entry serves both command names.

func (Layout) LegacyHomeDir

func (l Layout) LegacyHomeDir() string

LegacyHomeDir is the CLI home an installation made under the earlier product name carries; see CurrentHomeDir.

func (Layout) LockPath

func (l Layout) LockPath() string

LockPath is the advisory lock serializing install/update/uninstall against a concurrent digitalx-cli process mutating the same store.

func (Layout) ManifestPath

func (l Layout) ManifestPath() string

ManifestPath is the install manifest: <home>/install.json.

type Manifest

type Manifest struct {
	Method      string `json:"method"` // MethodManagedScript
	Executable  string `json:"executable"`
	Version     string `json:"version"`
	OS          string `json:"os"`
	Arch        string `json:"arch"`
	SHA256      string `json:"sha256"`
	Repo        string `json:"repo"`
	InstalledAt string `json:"installedAt"` // unix-ms as a string
	// Aliases are the extra command names in the install dir that run the same
	// binary (see Layout.LegacyBinName). Absent on an install that has none, so
	// self doctor treats a listed-but-missing alias as a broken install and
	// self uninstall knows exactly which extra names to remove.
	Aliases []string `json:"aliases,omitempty"`
}

Manifest is the durable record of a managed install, written to <home>/install.json by self install / self update. Its presence (plus the running binary being the installed binary on PATH) is what gates self update to managed installs; when it is absent the install was done some other way (Homebrew, go install, a hand-downloaded archive) and self update refuses with method-specific guidance.

type PathAddition

type PathAddition struct {
	Location string     `json:"location"`
	Context  []DiffLine `json:"context,omitempty"`
	Added    []DiffLine `json:"added"`
	NewFile  bool       `json:"newFile,omitempty"`
}

PathAddition is a pending "add the installer's PATH line" at one location: a shell rc file that will receive the managed block (unix), or the User PATH (windows). Context are unchanged trailing lines of the current file, shown for orientation above the change; Added are the lines that would be appended, for a diff preview before applying (the inverse of PathEdit's removal). NewFile is true when the rc file does not exist yet, so the block creates it. For the Windows User PATH there is no file: Context is empty and Added is the single entry to add (Num 0).

type PathEdit

type PathEdit struct {
	// Location is the rc file path (unix) or a human label for the User PATH
	// (windows).
	Location string `json:"location"`
	// Lines are the removed lines, most-to-least specific as they appear; for a
	// file each carries its line number, for the User PATH a single entry (Num 0).
	Lines []DiffLine `json:"lines"`
}

PathEdit is a pending "undo the installer's PATH change" at one location: a shell rc file that carries the managed block (unix), or the User PATH (windows). Lines are the parts that would be removed, for a diff preview before applying.

type PathResult

type PathResult struct {
	Dir    string `json:"dir"`
	OnPath bool   `json:"onPath"`
	// Action is what was done: "already-on-path", "edited-shell-rc" (unix, on a
	// yes prompt), "added-user-path" (windows), or "instructions" (non-interactive
	// or declined — the user must add it themselves; see Hint).
	Action string   `json:"action"`
	Files  []string `json:"files,omitempty"` // shell rc files edited (unix)
	Hint   string   `json:"hint,omitempty"`  // the manual step / follow-up
}

PathResult reports how PATH was handled for the installed binary directory during install. It rides the install result so a stdout-only consumer learns whether a manual step is still needed.

type ProvenanceError

type ProvenanceError struct {
	Message  string
	Guidance string
}

ProvenanceError marks a self update refused because the running binary is not a managed-script install (Homebrew, go install, a hand-downloaded archive, a dev build). Message is the reason; Guidance is the method-specific fix. The cli layer maps it to a config-class error so an agent branches on it.

func (*ProvenanceError) Error

func (e *ProvenanceError) Error() string

type UninstallOptions

type UninstallOptions struct {
	// RemoveBinary removes the installed binary, every alias command name the
	// manifest records, the install manifest, and any leftover swap file. A binary
	// that cannot delete itself (the locked running .exe on Windows) is reported in
	// Failed instead.
	RemoveBinary bool
	// RemoveData removes the CLI-home data files in DataPaths (config.json, the
	// journal) and, when the home is then empty, the home dir. Key material is
	// cleared first via ClearKeys.
	RemoveData bool
	// RemoveCaches removes the regenerable sandbox artifacts in Artifacts.
	RemoveCaches bool

	// Artifacts are the regenerable sandbox artifact dirs (resolved by the caller).
	// Removed only under RemoveCaches; non-existent entries ignored.
	Artifacts []string
	// DataPaths are the CLI-home data files to remove under RemoveData (config +
	// journal + sidecars). The key registry/vault are removed by ClearKeys instead.
	DataPaths []string
	// EditPaths are the PATH locations (from PathEdits) the user accepted undoing.
	EditPaths []string

	// ClearKeys clears every key's material from its backend and removes the key
	// files, returning removed lines + warnings. Called under the lock before
	// deleting DataPaths (RemoveData only); nil = skip. It lives in the cli layer
	// because it needs the key manager; running it here keeps every destructive
	// step under the one lock and in one returned result.
	ClearKeys func() (removed, warnings []string)
	// StopSandbox stops a sandbox running under the default state dir before its
	// caches are removed (RemoveCaches only); nil = skip. A stop error is a warning.
	StopSandbox func() error
}

UninstallOptions selects what Uninstall removes. The interactive front-end (the cli layer) resolves the candidate paths, shows the previews, collects the user's choices, and passes them here; this layer does the filesystem work under one lock and reports the outcome.

type UninstallResult

type UninstallResult struct {
	// Removed lists files/dirs actually deleted (binary, manifest, data files,
	// caches, the emptied CLI home) plus a line per cleared API key.
	Removed []string `json:"removed,omitempty"`
	// Edited lists the PATH locations whose installer change was undone (a shell rc
	// file's managed block, or the User PATH entry).
	Edited []string `json:"edited,omitempty"`
	// Failed lists things that could not be removed/edited, with a reason (a locked
	// binary, a permission error, a non-empty dir, a failed edit).
	Failed []FailedRemoval `json:"failed,omitempty"`
	// KeptPaths lists PATH locations left as-is (the user declined, or none was
	// selected) so the summary can tell the user to edit them by hand. Set by the
	// cli layer, which knows what was offered vs accepted.
	KeptPaths []string `json:"keptPaths,omitempty"`
	// Warnings are non-fatal problems that aren't a specific failed removal (a
	// sandbox that could not be stopped, a home-containing cache refused).
	Warnings []string `json:"warnings,omitempty"`
}

UninstallResult reports what `self uninstall` did. Each piece is chosen by the caller (the interactive selection lives in the cli layer); an empty field means that piece was not selected or nothing of it existed.

type UpdateOptions

type UpdateOptions struct {
	// TargetVersion pins the release to install (--tag); empty resolves the
	// latest.
	TargetVersion string
	// DryRun changes nothing on disk (--dry-run).
	DryRun bool
}

UpdateOptions are the choices `self update` takes from its flags.

type UpdateResult

type UpdateResult struct {
	// PreviousVersion is the version the running binary carries and
	// LatestVersion the one the resolved release carries, BOTH in the bare
	// spelling the CLI reports itself by (`1.2.0`, what `--version` prints), never
	// the release tag (`v1.2.0`) the download URLs are built from — see
	// BareVersion. Carrying one spelling is what makes the pair comparable: equal
	// values mean the install is already on the resolved release, and that is how
	// the text summary and a --json consumer alike tell "already current" from "an
	// update is available".
	PreviousVersion string `json:"previousVersion"`
	LatestVersion   string `json:"latestVersion"`
	Updated         bool   `json:"updated"`
	CheckedOnly     bool   `json:"checkedOnly"`
	Executable      string `json:"executable,omitempty"`
	SHA256          string `json:"sha256,omitempty"`
	// SignatureCheck records how the release signature was handled: SigVerified
	// (verified against the published cert) or SigDisabled (the docs host served
	// an empty cert — the kill switch). Set for an applied update and for a dry
	// run, which verifies the same way; empty when there was no release to check
	// (already-latest), so an agent can audit from --json output whether the
	// binary it runs was signature-verified.
	SignatureCheck string `json:"signatureCheck,omitempty"`
	// Archive is the release asset this platform's binary came from, or — under
	// CheckedOnly — would come from. The release declares it
	// (release-manifest.json), so it need not be the name this binary was
	// compiled with and a caller cannot infer it. Empty when no release was
	// resolved.
	Archive string `json:"archive,omitempty"`
	// Aliases are the extra command names now pointing at the updated binary (see
	// alias.go). Absent on an install that carries none.
	Aliases []string `json:"aliases,omitempty"`
	// LayoutRepaired lists the command-name fixes this run made without an update
	// to apply: creating the primary binary name on an install that only ever had
	// the alias name, or recreating/repointing an alias that was missing or ran
	// something other than the installed binary (see planLayout). Absent when the
	// layout was already correct. Updated stays false for a run that only
	// repaired the layout — no new version was installed.
	//
	// Under CheckedOnly (--dry-run) these are the fixes a real run WOULD make;
	// nothing on disk was touched. The pair (checkedOnly, layoutRepaired) is what
	// distinguishes the two, the same way checkedOnly governs updated.
	LayoutRepaired []string `json:"layoutRepaired,omitempty"`
	// Warnings are non-fatal problems with an otherwise applied update.
	Warnings []string `json:"warnings,omitempty"`
}

UpdateResult reports the outcome of `self update`. Updated is false when already current or when only checking (--dry-run); CheckedOnly marks the dry-run case.

Jump to

Keyboard shortcuts

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