Add self-update: sleeperagent update + Codex-style startup offer - #19
Merged
Conversation
New internal/update package: resolves the latest release via the /releases/latest redirect (no API rate limits), compares semver against the ldflags-stamped version, downloads the platform asset, verifies it against checksums.txt, and atomically swaps the executable (Windows parks the running exe as .old, swept up on next start by CleanupOld). `sleeperagent update [--check]` runs it explicitly. Release builds also offer it at startup: run/attach-existing from a real terminal check at most once a day (cached in the state dir), prompt [Y/n] before the session launches, and never block startup on a slow or offline network. Skipped for dev builds and non-TTY runs; opt out with [update] check=false or SLEEPERAGENT_NO_UPDATE_CHECK=1. A declined or failed update never touches the existing binary. Tests: unit coverage for version compare, redirect resolution, archive extraction, checksum rejection, the Windows .old dance, and cache throttling; a new integration test drives the real CLI against a fake release server end to end (report, install, swap, tamper rejection). CI now runs the suite via test/run_all.sh (its hand-kept list had drifted) and stamps the test binary so the update test can run; the pty/interactive tests export SLEEPERAGENT_NO_UPDATE_CHECK so the startup prompt can never reach real GitHub from a test pty. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Updating currently means re-downloading a release and re-running
install --force(orgo install). Codex CLI's flow is better: check for a newer version at startup, ask, and self-update onY. This brings that to sleeperagent, and adds an explicitsleeperagent updatecommand that permanently answers "how do I update this machine?"What
internal/update: resolves the latest release from the/releases/latestredirect (no API token, no rate limits), semver-compares against the goreleaser-stampedmain.version, downloads the platform asset (sleeperagent_<ver>_<os>_<arch>.tar.gz|zip), verifies sha256 against the release'schecksums.txt, and atomically replaces the executable. On Windows the running exe is parked as<exe>.oldand cleaned up on the next start.sleeperagent update [--check]— explicit update;--checkonly reports.run/attach-existingfrom a real terminal check at most once a day (cached in the state dir), promptUpdate now? [Y/n]before the session takes the terminal, and continue on the current version after updating. Never blocks startup: 3s timeout, silent on failure, skipped fordevbuilds and non-TTY runs.[update] check = falsein config.toml, orSLEEPERAGENT_NO_UPDATE_CHECK=1.CI
dead_sessionand both interactive tests); it now runstest/run_all.shdirectly and stamps the test binary with a version so the update test can run.SLEEPERAGENT_NO_UPDATE_CHECKso the startup prompt can never reach real GitHub from a test (this actually bitintegration_pty.shduring development — it stalled on the prompt against the real v0.4.0 release).Testing
dev, pre-release suffixes, git-describe strings), redirect resolution, tar.gz/zip extraction, checksum rejection, missing-checksum rejection, the Windows.oldswap, cache throttling.test/integration_update.shdrives the real CLI against a fake release server:--checkreports without installing,updateswaps the executable (verified by executing the swapped-in payload), and a tampered asset is refused with the original binary untouched.go test ./...green on Windows.🤖 Generated with Claude Code