{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package update\n\nPackage update implements self-update against the public GitHub Releases repo (memcode-ai/memcode — the same source the curl|sh installer uses). Three surfaces: \\`memcode upgrade\\` (explicit, synchronous, replaces the running binary after checksum verification), the silent startup self-update (Auto — same daily cadence, stages the new binary in the background; the running session is untouched and the next launch runs it; MEMCODE\\_AUTO\\_UPDATE=off keeps it manual), and a passive \"update available\" notice (cached in ~/.memcode/update-check.json, never blocks, never nags a dev build).\n\n## Constants\n\n```go\nconst EnvAutoUpdate = \"MEMCODE_AUTO_UPDATE\"\n```\nEnvAutoUpdate opts OUT of the silent startup self-update (\"0\" | \"false\" | \"off\" | \"no\"): the daily check then only surfaces the passive notice, like before. Machine-scoped — set it in the global env file, like every knob.\n\n```go\nconst ReleaseRepo = \"memcode-ai/memcode\"\n```\nReleaseRepo is the public binary repo (goreleaser's release target).\n\n## Functions\n\n```go\nfunc AssetName() string\n```\nAssetName is the goreleaser archive name for this platform, e.g. \"memcode\\_Darwin\\_arm64.tar.gz\" or \"memcode\\_Windows\\_x86\\_64.zip\".\n\n```go\nfunc Auto(ctx context.Context) string\n```\nAuto is the startup self-update: BackgroundNotice's activist sibling, on the same daily cadence and the same silence contract (run it on a goroutine; boot never waits on it; a failed check or install must never surface as an error). When a newer release exists it downloads, checksum-verifies, and atomically swaps the binary ON DISK — the running session keeps its inode and is untouched; the next launch runs the new version. The returned line (printed after the TUI releases the terminal) reports what happened: the staged version, or the manual nudge when auto-update is off, mid-install elsewhere, or the install failed. Concurrent sessions single-flight through a lock file, and the release just staged is remembered in the check cache so still-running old binaries don't each re-download it. The kill-switch story for shipped policy bugs: cut a release, the fleet converges on next launch — no user action.\n\n```go\nfunc BackgroundNotice(ctx context.Context) string\n```\nBackgroundNotice refreshes the cache when stale (one network call per 24h) and returns the update line, or \"\". Errors are silent — a failed check must never surface in the product. Intended to run on a goroutine.\n\n```go\nfunc IsNewer(current, latest string) bool\n```\nIsNewer reports whether latest is a strictly newer semver than current. Pre-release/build suffixes (\"-dev+abc\") are stripped before comparing; a malformed version compares as not-newer (never upgrade on garbage input).\n\n```go\nfunc LatestVersion(ctx context.Context) (string, error)\n```\nLatestVersion returns the newest release tag (e.g. \"v0.3.1\").\n\n```go\nfunc NoticeFromCache() string\n```\nNoticeFromCache is the zero-network variant: reads only the cached check. Safe to call from anywhere (version output, doctor).\n\n```go\nfunc ReexecStaged()\n```\nReexecStaged replaces the current process with the already-staged newer binary, so \"the next launch runs it\" is THIS launch. Cache-only and instant: no network, no version probe — the staged marker is written only after a checksum-verified install. No-op on Windows (no exec) and for dev builds. Loop-proof twice over: the re-exec'd binary IS the staged version (IsNewer fails), and MEMCODE\\_REEXEC guards the pathological case.\n\n```go\nfunc SyncUpdate(ctx context.Context)\n```\nSyncUpdate is the boot contract: CHECK, UPDATE, RESTART — every launch. A bounded (3s) latest-version check; when a newer release exists it is downloaded, checksum-verified, installed over the binary, and the process re-execs into it before the TUI ever starts. Offline/rate-limited checks fall back to running whatever is already staged. Dev builds, MEMCODE\\_AUTO\\_UPDATE=off, and Windows (no exec — prints the restart nudge) opt out of the swap.\n\n```go\nfunc Upgrade(ctx context.Context, out io.Writer) (string, error)\n```\nUpgrade downloads the latest release, verifies its sha256 against checksums.txt, and atomically replaces the running binary. Progress goes to out. Returns the version installed (\"\" when already up to date).\n\n","path":"github.com/memcode-ai/memcode/internal/update","name":"update","synopsis":"Package update implements self-update against the public GitHub Releases repo (memcode-ai/memcode — the same source the curl|sh installer uses).","isRedistributable":true}
