update

package
v0.1.4425 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 43 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 update keeps magpie current. Builds are published as GitHub releases of yetone/magpie-releases; usemagpie.ai/api/latest describes the newest one: its version, notes, and every file with its SHA-256.

The macOS app replaces its own bundle: the new zip is downloaded, checked against its hash, unpacked, and accepted only if it is signed by the same team as the app already installed. A bare binary (the terminal build, and the desktop app on Windows and Linux) replaces itself the same way, minus the signature.

Index

Constants

View Source
const (
	StepDownload  = "download"  // the bytes coming in
	StepRetry     = "retry"     // the connection broke off or stalled: waiting to try again
	StepVerify    = "verify"    // the file checked against its SHA-256
	StepUnpack    = "unpack"    // the Mac's zip unpacked
	StepSignature = "signature" // the Mac app's signature checked
)

The steps an update made under WithStep's ctx goes through, in order. After the download its percent says nothing, and a Mac's unpack and signature check take seconds: each says its name instead (esir_tech on Discord, a percent that sat still).

View Source
const ComEnv = "MAGPIE_COM"

ComEnv is set by magpie.com for the app it runs: the standard handles it hands over are the terminal's console or a redirection, and its console is the one to borrow (cli's console_windows.go).

View Source
const MaxNotes = 40

MaxNotes is how many releases' notes are shown at most: magpie releases often, and a long-unopened one would have pages of them.

View Source
const NoInstallEnv = "MAGPIE_NO_INSTALL"

NoInstallEnv, set to 1, keeps a magpie run from Downloads there.

View Source
const Quiet = 72 * time.Hour

Quiet is how long a dismissal of the pill holds: the Stable channel's soak.

View Source
const Site = "https://usemagpie.ai"

Site is magpie's home; its /api/latest is the update feed.

View Source
const StableMaxNotes = 1500

StableMaxNotes is MaxNotes on the Stable and Daily channels, where an update is a week or a day of releases and its notes are read as one list (ssharpcc on X): every one of them, as far as the site keeps them.

Variables

View Source
var AskFolder func(suggest string, check func(dir string) error) string

AskFolder, when set, asks the user where to install the download, offering suggest, a folder: it answers the folder chosen, which check has accepted, or "" when the user would rather not install (the download then runs where it is). Unset, the suggestion is taken.

View Source
var BackCounts = []int{10, 20, 50, 100}

BackCounts are the ranges Settings' What's new offers besides the notes since the last update: this version and that many before it (Linka on Discord).

View Source
var ErrCanceled = errors.New("the update was canceled")

ErrCanceled is the administrator's password prompt dismissed.

View Source
var ErrDownloadFolder = errors.New("downloads land in this folder")

ErrDownloadFolder is a folder chosen to install in that downloads land in: the copy there would be taken for a download again.

View Source
var ErrNeedsAdmin = errors.New("only an administrator can write to this folder")

ErrNeedsAdmin is a folder chosen to install in that only an administrator can write to.

View Source
var ErrNoAdmin = errors.New("no administrator prompt")

ErrNoAdmin is no administrator to be had: the system has no prompt for one, or it couldn't be shown. What was to run as one didn't run.

View Source
var GUI bool

GUI says this binary has the desktop app in it. Off the Mac that app is a single binary too, and it updates from its own build, not the terminal one.

View Source
var Launchers = map[string][]string{"claude-magpie": {"claude", "run"}}

Launchers are the launchers magpie puts beside its command, each name with the arguments it runs magpie with.

Functions

func AddLauncher added in v0.1.3147

func AddLauncher(name string, args ...string) (string, error)

AddLauncher writes the launcher name, which runs magpie with args, beside the magpie command a terminal runs, putting that there first when it isn't (AddCLI). A file of the user's own by that name is left as it is. It answers the launcher's path.

func Alive added in v0.1.550

func Alive(pid int) bool

Alive reports whether the process pid is still running.

func AppAsset

func AppAsset() string

AppAsset and BinaryAsset name the files this machine would install.

func AsAdmin added in v0.1.2068

func AsAdmin(why, script string) error

AsAdmin runs a shell script as root, after the system's password prompt, which says why (on a Mac). ErrCanceled is the prompt dismissed.

func AwaitPredecessor added in v0.1.3

func AwaitPredecessor()

AwaitPredecessor blocks, for a while at most, until the magpie that relaunched this one has exited; on Windows its WebView2 too (awaitGone).

func BinaryAsset

func BinaryAsset() string

func Bundle

func Bundle() string

Bundle is the .app the running binary lives in, or "" when it is not in one.

func CanElevate added in v0.1.38

func CanElevate() bool

CanElevate reports whether this system can ask for the administrator's password: always on a Mac, with polkit on Linux, not on Windows.

func CanRunElevated added in v0.1.1174

func CanRunElevated() bool

CanRunElevated reports whether RunElevated can ask for an administrator here: only on Windows, where an agent's npm may live under Program Files.

func Channel

func Channel() string

Channel is Settings' Update channel: settings.UpdateStable, the update feed asked for a version a week, the newest that had been out three days as the week began (Monday 00:00 UTC); settings.UpdateDaily, a version a day, the newest out by 20:00 UTC that passed its tests (the Test run on its commit) and has every file; either one with an urgent release (a security hole, a ban risk, lost data) as soon as it is out. "" is every version, and so is a value magpie doesn't know. usemagpie.ai chooses both from the release list (site/worker.js, "The Stable channel" and "The Daily channel"); a release is urgent when a line of its notes starts with "**Urgent release:**".

func CheckMirror added in v0.1.775

func CheckMirror(prefix string) error

CheckMirror says what is wrong with a mirror prefix, nil when it is one.

func CheckMirrorURL added in v0.1.1008

func CheckMirrorURL(prefix string) error

CheckMirrorURL is CheckMirror for one typed into Settings: a full https:// address (a download over http would be read by anyone between, though the checksum still guards what is installed).

func CheckProxy added in v0.1.775

func CheckProxy(proxy string) error

CheckProxy says what is wrong with a proxy address, nil when it is one.

func ClearBlocked added in v0.1.1013

func ClearBlocked()

ClearBlocked forgets the note: the version started after all.

func CopiedCLI added in v0.1.709

func CopiedCLI() string

CopiedCLI is the command's path when it's a plain copied file rather than install.sh's link, or "" when it's absent, a link, or not a regular file. A bare Lstat — nothing is run, nothing is written — so the app's window can ask on every launch. It can't tell a stale copy from a current one (that needs the copy's version, which only `magpie update` may read), so what the window says off it is advice with a dismiss, not a warning that knows. Only on the Mac; on Linux the app and the command are one file.

func DropShellFunction added in v0.1.1654

func DropShellFunction(name string) error

DropShellFunction takes the function name out of every profile magpie put it in.

func DropShellFunctionAt added in v0.1.1663

func DropShellFunctionAt(ps []ShellProfile, name string) error

DropShellFunctionAt takes the function name out of the profiles ps.

func EnsureCompanion added in v0.1.1679

func EnsureCompanion(exe string) error

EnsureCompanion writes the magpie.com that runs exe beside it when a terminal runs magpie from that folder (on PATH, or a magpie.com or magpie.cmd there), or brings one there up to this version. Nothing in a build without the launcher, or when it is as it should be already.

func Executable added in v0.1.3

func Executable() (string, error)

Executable is the running binary, symlinks resolved.

func Feed

func Feed() string

Feed is where the newest release is described. MAGPIE_UPDATE_FEED points it elsewhere, for testing an update against a local server.

func ForgetInstallDir added in v0.1.3148

func ForgetInstallDir() error

ForgetInstallDir does nothing: only Windows records where it installed.

func ForgetOldStaging added in v0.1.2120

func ForgetOldStaging(bundle string)

ForgetOldStaging has LaunchServices forget the apps updates before #3965 left on its list: the new version unpacked as .magpie-update/app/magpie.app and the old one moved aside to .magpie-update/old.app, beside bundle or in magpie's cache. Their folders are gone, but Spotlight listed each as another magpie. It runs once, and nothing waits on it.

func Forward added in v0.1.2133

func Forward(from, to string) error

Forward opens the installed magpie at to with this one's arguments, and waits for it to say it is up; the caller then quits. A restart to update waits on this one for that word (MAGPIE_STARTED): it is passed on once the installed one has said it. When to can't be started, this one runs on.

func Homebrew added in v0.1.126

func Homebrew(exe string) bool

Homebrew is whether exe was installed by Homebrew (brew install magpie), which keeps it in its Cellar and has to be the one to upgrade it: a binary replaced under it leaves brew thinking the old version is there.

func InLang added in v0.1.627

func InLang(md, lang string) string

InLang is a release's notes in lang, as the site cuts them (a site from before it did, or a feed elsewhere, hands them whole): "zh" the Chinese where there is some, else the English, everything above the marker. Notes from before the marker are English alone, in any language.

func Install

func Install(staged, bundle string) error

Install swaps the staged app in for bundle. The running copy keeps going until it quits; the next launch is the new one. Where the folder is not magpie's to change the error is a permission one (NeedsAdmin), and InstallAsAdmin can do it instead.

func InstallAsAdmin added in v0.1.38

func InstallAsAdmin(staged, bundle string) error

InstallAsAdmin is Install with the administrator's password, asked for by the system.

func InstallBinary added in v0.1.3

func InstallBinary(staged, exe string) error

InstallBinary swaps a staged binary in for exe, the running one, which keeps going until it exits.

func InstallBinaryAsAdmin added in v0.1.38

func InstallBinaryAsAdmin(staged, exe string) error

InstallBinaryAsAdmin is InstallBinary with the administrator's password.

func InstallBinaryAside added in v0.1.1013

func InstallBinaryAside(staged, exe string) (string, error)

InstallBinaryAside is InstallBinary, saying where the running exe was moved to on Windows ("" elsewhere), for RelaunchBinary to put it back should the new version not start. A download this computer won't start (Smart App Control, #894) isn't put in: a *BlockedError, and the download removed.

func InstallDir added in v0.1.3148

func InstallDir(picked string) string

InstallDir is the folder a folder picked in AskFolder's dialog means: itself when it is named magpie, else a magpie folder inside it, as installers do.

func Installable added in v0.1.3148

func Installable(dir string) error

Installable says why dir can't be installed in, nil when it can: a file is written into it and removed, and the folders made for that are removed again, so a folder looked at and then not chosen isn't left.

Only the folders this call made itself are removed, one by one from the deepest up and only while empty, so a folder that was there already is never taken: a folder whose Stat fails for any reason but "not there" (no permission to look, a share that doesn't answer) is unknown, and the check refuses rather than make or remove anything.

func Launcher added in v0.1.3147

func Launcher(name string) string

Launcher is where the launcher name is, "" when magpie hasn't put one on the PATH: in the folder the magpie command is found in.

func LauncherFile added in v0.1.3147

func LauncherFile(goos, name string) string

LauncherFile is the file name of the launcher name on goos.

func Mirror added in v0.1.775

func Mirror(ctx context.Context) string

Mirror is the mirror downloads under ctx go through, "" for none.

func MirrorOf added in v0.1.1008

func MirrorOf(err error) string

MirrorOf is the mirror a download error came through, "" when it is no mirror's.

func MostNotes added in v0.1.1602

func MostNotes() int

MostNotes is how many releases' notes are shown at most on the channel Settings name.

func NeedsAdmin added in v0.1.38

func NeedsAdmin(err error) bool

NeedsAdmin reports whether err is magpie not being allowed to change the folder it lives in, which the administrator's password gets past.

func Network added in v0.1.1626

func Network(err error) bool

Network reports whether err is a download the network broke off, which trying again may get through.

func Newer

func Newer(a, b string) bool

Newer reports whether version a comes after b. A pre-release comes before the release it leads up to.

func NotesFeed added in v0.1.606

func NotesFeed() string

NotesFeed is where the notes of past releases are listed: beside the update feed, on magpie's site. MAGPIE_NOTES_FEED points it elsewhere.

func OpenBeside added in v0.1.1354

func OpenBeside(bundle string, window, quiet bool) error

OpenBeside opens bundle now, a new instance beside this one (open -n), tried again while open fails: a restart that hands the gateway over (internal/handoff) starts the new version before this one quits. With window, its window; else its menu bar icon only, as Relaunch, in the background as Relaunch's when quiet or with no window.

func Picked

func Picked() bool

Picked is whether the update feed picks the version (Stable or Daily) rather than offering every one: only the site knows a picked release.

func Program added in v0.1.1144

func Program() (string, error)

Program is this magpie by a path that stays put: what a link, or an agent's config that starts magpie, should name (cliProgram).

func Reexec added in v0.1.191

func Reexec(exe string, args, env []string) error

Reexec runs exe in this process's place with args and env: the same process, in the same terminal or under the same service manager, now running the new version (magpie web's restart to update).

func Relaunch

func Relaunch(bundle string, window, quiet bool) error

Relaunch opens bundle again once this process (pid) has exited: with its window when window is set, else only its menu bar icon (`tray`, as a login launch), which a restart by itself uses while no window was up. Each try, and what it came to, is written to relaunch.log in magpie's own folder. quiet, the restart is one magpie made by itself: the app opens in the background (open -g), as it does too with no window, so it takes no focus from the app the user is in (relaunchOpen).

func RelaunchArgs added in v0.1.458

func RelaunchArgs(window bool, view string) []string

RelaunchArgs is what RelaunchBinary starts magpie with: `gui [view]` for the window, `tray` for the tray icon alone.

func RelaunchBinary added in v0.1.3

func RelaunchBinary(exe, old string, window bool, view string) error

RelaunchBinary starts exe again: with its window on view when window is set (the window was open), else as the tray app alone, as autostart starts it. The new process waits for this one to exit before it takes the gateway's port; see AwaitPredecessor. With old, where this one was moved aside to (Windows), it waits for the new one to say it is up, and when it can't start puts old back and says so (a *BlockedError): this one then runs on rather than quitting.

func ReleasePage added in v0.1.741

func ReleasePage(version string) string

ReleasePage is version's page on GitHub, where its notes are when the site can't give them (#661).

func Released

func Released(v string) bool

Released reports whether v is a release version rather than a build from source ("dev", "0bcb2cc-dirty", git describe's "v0.1.0-3-g0bcb2cc"); only releases update themselves.

func RemoveLauncher added in v0.1.3147

func RemoveLauncher(name string) (string, error)

RemoveLauncher takes the launcher name out, where magpie wrote it.

func RemoveOld added in v0.1.92

func RemoveOld(exe string)

RemoveOld removes what earlier updates moved aside of exe, those no longer running.

func RemoveStaleNew added in v0.1.107

func RemoveStaleNew(exe string)

RemoveStaleNew removes a download of exe's next build (stagedFiles) that is no newer than exe: exe over again (the update a magpie left running from before it downloaded once more), or an older version a swap never put in. A newer one, which a magpie still running may yet put in, stays.

func ReplaceBinary

func ReplaceBinary(ctx context.Context, rel *Release) error

ReplaceBinary puts the release's build for this binary where the running one is.

func Replaced added in v0.1.107

func Replaced(exe string, started os.FileInfo) bool

Replaced reports whether exe is no longer the binary that was there when this process looked (started, from os.Stat): another magpie installed an update over it, and this one runs from where it was moved aside.

func Respawn

func Respawn(extra ...string) error

Respawn starts this program again with the arguments it was started with and extra (NAME=value) added to its environment, detached. The new process waits for this one to exit, as a relaunch does (AwaitPredecessor).

func RunElevated added in v0.1.1174

func RunElevated(context.Context, string, []string, ...string) ([]byte, error)

RunElevated is Windows' alone.

func Settle added in v0.1.2133

func Settle() (from, to string)

Settle installs the desktop app run from a download folder (see above), and says what to open instead of running on here: from is this exe and to the installed one, both "" when this one runs on. Anything that goes wrong leaves this one running, as before.

func Settled added in v0.1.2133

func Settled()

Settled clears, in the installed magpie Forward opened, what magpie left beside the exe it was installed from: what updates moved aside there, an update downloaded for it (magpie.exe.new), and the magpie.com or magpie.cmd magpie wrote there to run it, which the `magpie` on PATH is now. A file it didn't write, or wrote for another program, is left.

func ShellFunction added in v0.1.1654

func ShellFunction(name string, body ShellBody) ([]string, error)

ShellFunction puts the function name, as body gives it for each shell, in the profile of every shell the user has, or brings one there up to date. It says the profiles that have it now. A profile that can't be read is left as it is: what it holds is unknown.

func ShellFunctionAt added in v0.1.1663

func ShellFunctionAt(ps []ShellProfile, name string, body func(kind string) string) ([]string, error)

ShellFunctionAt is ShellFunction for the profiles ps of another home, which the caller names: a WSL distro's, opened from Windows, whose shells this magpie doesn't run in. body takes the shell's kind alone.

func ShellFunctionIn added in v0.1.1654

func ShellFunctionIn(name string) []string

ShellFunctionIn says the profiles that hold the function name.

func ShellFunctionInAt added in v0.1.1663

func ShellFunctionInAt(ps []ShellProfile, name string) []string

ShellFunctionInAt says which of the profiles ps hold the function name.

func ShellQuote added in v0.1.2068

func ShellQuote(s string) string

ShellQuote quotes s for /bin/sh.

func ShowNotes added in v0.1.606

func ShowNotes(last, current string, existed bool) (after string, show bool)

ShowNotes decides, as magpie starts on current having last run as last ("" when it never said), whether to show what changed since, and from which version on (exclusive). Only an upgrade between releases shows: not a fresh install, the same version again, a downgrade, or a build from source. A magpie from before versions were kept has no last; when it was already in use (existed) its own version's notes are shown, from "", which Between takes as upto's alone.

func Source

func Source() string

Source is Settings' update source, "" when it is automatic: the usemagpie.ai feed, then GitHub when the feed can't be reached (fallback.go). settings.UpdateSourceSite never goes to GitHub, and settings.UpdateSourceGitHub never to usemagpie.ai (RootSir and Sakugar_ on X: the site's download is slow). Whichever it is, the release goes through Release.verify: the same ed25519 signature over SHA256SUMS, the version inside it and every file's hash from it. MAGPIE_UPDATE_FEED, a test's feed, is never overridden by it.

func Stable added in v0.1.1602

func Stable() bool

Stable is whether Settings' Update channel is Stable.

func Stage

func Stage(ctx context.Context, rel *Release, bundle string) (string, error)

Stage downloads the app in rel and unpacks it next to the installed bundle, ready for Install. It returns the unpacked app, a bundle whose folder is named stagedName.

func StageBinary added in v0.1.3

func StageBinary(ctx context.Context, rel *Release) (string, error)

StageBinary downloads the release's build for this binary out of sight (binaryStage), ready for InstallBinary.

func StaleCLI added in v0.1.709

func StaleCLI(appVersion string) string

StaleCLI is the path of a `magpie` command that is a copied file behind the app, or "" when there's nothing to say. install.sh links the command to magpie.app's binary so it follows every GUI update for free; a command that arrived as a copy — an older installer, a hand cp, or the standalone magpie-cli build — keeps running its own build once the app moves on, and a command behind the app is a stale build: one that predates the WebDAV short-write check (#531) truncated a remote backup on `magpie webdav now`, wedging the sync.

A copy is only worth mentioning when it actually trails the app, so this reads the copy's version and stays quiet when it is at or ahead of appVersion, or isn't a release at all (a build from source, or one that won't run — none of those is a stale release to nag about). Reading the version runs the old binary, and that isn't read-only: magpie's start-up runs its migrations before `version` answers. So only `magpie update`, which the user started, asks this — the app's window uses CopiedCLI and its advice can be dismissed instead. magpie doesn't rewrite the user's PATH — the fix is theirs: re-run install.sh, or link it by hand, which is what the advice says. Only on the Mac, where the app and the command are two places; on Linux they are one file.

func StartBeside added in v0.1.1354

func StartBeside(exe string, window bool, view string) error

StartBeside starts exe now, beside this process, as RelaunchBinary's args say: the new version of a restart that hands the gateway over. It isn't told to wait for this one (MAGPIE_REPLACES): it takes the gateway from it while it runs.

func StripInstall added in v0.1.606

func StripInstall(md string) string

StripInstall takes a release's "Install" section (in any language) out of its notes: the download links, which mean nothing to a magpie that just updated itself. The section runs to the next heading of its level or above.

func Stuck added in v0.1.38

func Stuck(bundle string) string

Stuck says why the app at bundle cannot be replaced where it is, or "" when it can: opened from its disk image, or moved aside by macOS (App Translocation) because it was never moved out of Downloads.

func TildeHome added in v0.1.1654

func TildeHome(p string) string

TildeHome is p with the home as ~, for a message.

func UrgentIn

func UrgentIn(notes string) bool

UrgentIn is whether a release's notes mark it urgent, as the site reads them (site/worker.js, urgentIn).

func WithMirror added in v0.1.775

func WithMirror(ctx context.Context, prefix string) context.Context

WithMirror has the downloads made under ctx go through the mirror prefix; "off" goes through none, whatever Settings say, and "" leaves ctx as it is.

func WithProgress added in v0.1.17

func WithProgress(ctx context.Context, f func(done, total int64)) context.Context

WithProgress has downloads made under ctx report how far along they are; total is 0 while the size is unknown.

func WithProxy added in v0.1.775

func WithProxy(ctx context.Context, proxy string) context.Context

WithProxy has the update feed and the downloads asked under ctx go through proxy (http://, https://, socks5://, socks5h://; host:port is http; "direct" for none), over Settings' Proxy and the environment's.

func WithStep added in v0.1.3201

func WithStep(ctx context.Context, f func(step string)) context.Context

WithStep has an update made under ctx say each step it starts.

func Writable

func Writable(dir string) bool

Writable reports whether magpie may replace what lives in dir.

Types

type Asset

type Asset struct {
	URL    string `json:"url"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
	// API is GitHub's API address of the file, asked when URL is busy
	// (apiroute.go); a feed without it has it looked up from URL.
	API string `json:"api,omitempty"`
	// GitHub is the file's github.com address when URL is another (the
	// site's copy on R2): where a download goes on when URL fails, and
	// what a mirror the user gave is put in front of.
	GitHub string `json:"github,omitempty"`
	// contains filtered or unexported fields
}

Asset is one downloadable file of a release.

type Behind

type Behind struct {
	Base string `json:"base"`
	// Hushed is when the pill was last dismissed: the quiet runs from it.
	// (0.1.3879 to 0.1.4181 kept "since", the first newer version seen,
	// and held the pill for it; a note of theirs is for their own version,
	// so it is never read as a dismissal.)
	Hushed time.Time `json:"hushed,omitempty"`
	// Urgent is the newest version known to be urgent, "" for none.
	Urgent string `json:"urgent,omitempty"`
}

Behind is what is kept of being behind, for the version running (Base).

func NoteBehind

func NoteBehind(current, latest string, urgent bool) Behind

NoteBehind notes that latest is out while current runs: an urgent latest is kept until current has caught up with it. Being behind starts no quiet; only a dismissal does. A note that can't be read loses a dismissal (the pill shows), and the urgent one is read again from the next check's notes.

func NoteUrgent

func NoteUrgent(current, version string) Behind

NoteUrgent notes that version, newer than current, is urgent.

func QuietAgain

func QuietAgain(current string, now time.Time) Behind

QuietAgain starts the quiet over: the pill was dismissed.

func ReadBehind

func ReadBehind(current string) Behind

ReadBehind is the note for current.

func Unhush

func Unhush(current string) Behind

Unhush lifts a dismissal: Settings' Show again.

func (Behind) Lit

func (b Behind) Lit(current string, now time.Time) bool

Lit is whether the pill may light at now: it was never dismissed, the quiet after a dismissal has passed, or an urgent release newer than current is out.

type Blocked added in v0.1.1013

type Blocked struct {
	Version string    `json:"version"`
	Error   string    `json:"error"`
	Policy  bool      `json:"policy,omitempty"` // application control (Smart App Control)
	At      time.Time `json:"at"`
}

Blocked is a version this computer refused to start, and why.

func NoteBlocked added in v0.1.1013

func NoteBlocked(version string, err error) Blocked

NoteBlocked notes that version couldn't start here.

func ReadBlocked added in v0.1.1013

func ReadBlocked(current string) *Blocked

ReadBlocked is the version noted as refused here, while it is newer than current; once current has caught up (put in by hand), the note goes.

type BlockedError added in v0.1.1013

type BlockedError struct {
	Err error
}

BlockedError is a new version that couldn't be started on this computer. Nothing of it is left in place: the version running is still the one installed.

func (*BlockedError) Error added in v0.1.1013

func (e *BlockedError) Error() string

func (*BlockedError) Policy added in v0.1.1013

func (e *BlockedError) Policy() bool

Policy is whether Windows' code integrity refused the program: Smart App Control, App Control for Business (WDAC), AppLocker or a software restriction policy, which the user can't let through from magpie.

func (*BlockedError) Unwrap added in v0.1.1013

func (e *BlockedError) Unwrap() error

type CLI added in v0.1.1003

type CLI struct {
	Exe     string     `json:"exe"`               // this app's program, which it should run
	Command string     `json:"command,omitempty"` // the default shell's
	Ours    bool       `json:"ours"`
	Version string     `json:"version,omitempty"` // the other one's, when it can be read without running it
	Dir     string     `json:"dir,omitempty"`     // where Add puts it; "" when no folder on PATH can take it
	Stuck   string     `json:"stuck,omitempty"`   // translocated, read-only: why it can't be linked from where it is
	Shells  []CLIShell `json:"shells"`
	Windows bool       `json:"windows,omitempty"`
	Shim    string     `json:"shim,omitempty"` // Windows: the magpie.cmd Add writes beside an app not named magpie.exe, which runs it, in a build with no magpie.com (com.go)
}

CLI is what `magpie` runs in a terminal opened now.

func AddCLI added in v0.1.1003

func AddCLI(shell string) (*CLI, error)

AddCLI puts this app's magpie on the PATH: of every shell whose PATH has the folder ReadCLI names (shell ""), or of the one shell named, by linking it in ~/.local/bin and adding that folder to the shell's profile. The launchers magpie keeps (Launchers: claude-magpie) go beside it, so they are there with nothing more asked.

func ReadCLI added in v0.1.1003

func ReadCLI() *CLI

ReadCLI says what `magpie` runs in each shell. It asks each shell for its PATH, a few seconds at most.

type CLIShell added in v0.1.1003

type CLIShell struct {
	Name    string `json:"name"`              // zsh, bash, fish, PowerShell, cmd
	Default bool   `json:"default,omitempty"` // the one a terminal opens
	Known   bool   `json:"known"`             // its PATH could be read
	Command string `json:"command,omitempty"` // the magpie it runs, "" none
	Ours    bool   `json:"ours"`              // and that is this app
	Profile string `json:"profile,omitempty"` // the file a pick of it writes, ~ for the home; "" none
	HasDir  bool   `json:"hasDir,omitempty"`  // its PATH has CLI.Dir, so Add reaches it without its profile
}

CLIShell is one shell's `magpie`.

type ExitError added in v0.1.1174

type ExitError struct{ Code uint32 }

ExitError is a command RunElevated ran that ended with a code other than 0; winget's are HRESULTs (0x8A150019).

func (*ExitError) Error added in v0.1.1174

func (e *ExitError) Error() string

type MirrorError added in v0.1.1008

type MirrorError struct {
	Mirror string // the prefix the download went through
	Err    error
}

MirrorError is a download that failed through a mirror: the mirror didn't answer, answered with something other than the file, or sent a file whose hash isn't the feed's (never installed). Downloading from GitHub itself may still work, which the GUI offers.

func (*MirrorError) Error added in v0.1.1008

func (e *MirrorError) Error() string

func (*MirrorError) Unwrap added in v0.1.1008

func (e *MirrorError) Unwrap() error

type NetError added in v0.1.1626

type NetError struct {
	File string
	Err  error
}

NetError is a download the network broke off: the connection failed or dropped part way. It names the file and the cause, never the address: GitHub's redirect is a signed URL, hundreds of characters of signature and token that say nothing to the user.

func (*NetError) Error added in v0.1.1626

func (e *NetError) Error() string

func (*NetError) Unwrap added in v0.1.1626

func (e *NetError) Unwrap() error

type Note added in v0.1.606

type Note struct {
	Version string `json:"version"` // no v
	Notes   string `json:"notes"`   // markdown, its Install section taken out
	URL     string `json:"url,omitempty"`
	// Pending: a release after the one running, up to the update waiting
	Pending bool `json:"pending,omitempty"`
}

Note is one release's notes, as the app shows them after an update.

func Back added in v0.1.1433

func Back(notes []Note, upto string, n int) []Note

Back keeps upto and the n releases before it, newest first: n+1 releases counted before any is dropped, so a release whose notes are empty once its Install section is out still counts as one. A release newer than upto, or one listed twice, isn't counted.

func Between added in v0.1.606

func Between(notes []Note, after, upto string) []Note

Between keeps the notes of the releases after after up to and including upto, newest first, at most MostNotes; with after "" only upto's. Each one's Install section is taken out, and one left empty is dropped.

func NotesBack added in v0.1.1433

func NotesBack(ctx context.Context, upto string, n int, lang string) ([]Note, error)

NotesBack asks the site for the notes of upto and the n releases before it, newest first, in lang. The site is asked for those alone (limit); one from before it took a limit sends them all, and Back keeps n+1.

func NotesBetween added in v0.1.606

func NotesBetween(ctx context.Context, after, upto, lang string) ([]Note, error)

NotesBetween asks the site for the notes of every release after after (none when "") up to and including upto, newest first, in lang (see InLang).

func NotesBetweenTotal added in v0.1.2764

func NotesBetweenTotal(ctx context.Context, after, upto, lang string) ([]Note, int, error)

NotesBetweenTotal is NotesBetween with how many releases there are in all before MostNotes keeps the newest, so a list cut short can say so (sujingshen on X: 156 releases behind read "40 releases").

type Packaged added in v0.1.2366

type Packaged struct {
	Manager string `json:"manager"`           // pacman, dpkg, rpm, homebrew or nix
	Package string `json:"package,omitempty"` // the package's name, when known
}

Packaged is the package manager that installed a magpie binary, which then has to be the one to update it. magpie replacing a file a package owns (pkexec over /usr/bin/magpie from the AUR's magpie-bin, shuhai on Discord) leaves the manager's database naming an older version and a file that no longer matches it, and the manager's next upgrade, which can be a version older than the one magpie put in, writes over it again.

func PackagedBy added in v0.1.2366

func PackagedBy(exe string) *Packaged

PackagedBy says which package manager installed exe (the running binary, symlinks resolved), nil when none did.

func (*Packaged) Command added in v0.1.2366

func (p *Packaged) Command() string

Command is what updates the package, "" when there is no one command (Nix: a profile or a system configuration). magpie is in no distribution's own repository, so a pacman package is the AUR's, which pacman alone doesn't upgrade: its AUR helper does.

func (*Packaged) Name added in v0.1.2366

func (p *Packaged) Name() string

Name is the manager as its users call it.

func (*Packaged) Say added in v0.1.2366

func (p *Packaged) Say() string

Say is the sentence a terminal is told: who updates this magpie, and how.

type Release

type Release struct {
	Version string           `json:"version"` // "0.2.0", no v
	Notes   string           `json:"notes"`   // markdown
	URL     string           `json:"url"`     // the release page
	Assets  map[string]Asset `json:"assets"`  // by file name
	// Signed is what vouches for Assets' hashes (signed.go).
	Signed *Signed `json:"signed,omitempty"`
}

Release is one published version.

func Latest

func Latest(ctx context.Context) (*Release, error)

Latest asks the feed for the newest release, its notes in English.

func LatestEvery

func LatestEvery(ctx context.Context, lang string) (*Release, error)

LatestEvery is LatestIn on every version, whatever Settings' channel: what Stable's "up to date" leaves out, the newest release out.

func LatestIn added in v0.1.627

func LatestIn(ctx context.Context, lang string) (*Release, error)

LatestIn asks the feed for the newest release, its notes in lang (see InLang): the app's language, which What's new follows. On Settings' Stable channel it is Stable's release (see Stable).

func LatestStable

func LatestStable(ctx context.Context) (*Release, error)

LatestStable is the Stable channel's release, whatever Settings' channel: what a fresh install compares itself with, to stay on Stable when it is Stable's version (the site's Stable download). Only the site knows it, so a failed feed is never answered from GitHub.

type ShellBody added in v0.1.1654

type ShellBody func(kind, prog string) string

ShellBody is a function's text for one shell: "posix" (zsh, bash), "fish" or "powershell"; prog is this magpie, by a path that stays put.

type ShellProfile added in v0.1.1663

type ShellProfile struct {
	Kind   string // posix, fish, powershell
	Path   string
	Create bool // made when it isn't there: the shell a terminal opens
}

ShellProfile is one shell's profile a function goes in.

type Signed

type Signed struct {
	Sums string `json:"sums"`
	Sig  string `json:"sig"`
}

Signed is a release's SHA256SUMS as published and its ed25519 signature (base64).

Directories

Path Synopsis
magpie.com runs on Windows only (main_windows.go).
magpie.com runs on Windows only (main_windows.go).

Jump to

Keyboard shortcuts

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