Documentation
¶
Overview ¶
Package update provides version checking and self-update functionality.
Index ¶
- Constants
- func CheckForUpdateAsync(currentVersion string) <-chan *UpdateInfo
- func CompareVersions(v1, v2 string) int
- func CountReleasesBehind(currentVersion string, releases []Release) int
- func DetectHomebrewManagedInstall() (execPath string, upgradeCmd string, managed bool, err error)
- func DownloadAndExtractBinary(downloadURL string) ([]byte, error)
- func FetchChangelog() (string, error)
- func FormatChangelogForDisplay(entries []ChangelogEntry) string
- func GetAssetURLForPlatform(release *Release, goos, goarch string) string
- func HomebrewUpgradeHint(execPath string) (string, bool)
- func InvalidateCache()
- func NormalizeReleaseTag(version string) string
- func PerformUpdate(downloadURL string) error
- func SetCheckInterval(hours int)
- func ShouldNudge(info *UpdateInfo) bool
- func UpdateBridgePy() error
- type Asset
- type ChangelogEntry
- type Release
- type UpdateCache
- type UpdateInfo
Constants ¶
const ( // GitHubRepo is the repository to check for updates GitHubRepo = "asheshgoplani/agent-deck" // CacheFileName stores the last update check result CacheFileName = "update-cache.json" // DefaultCheckInterval is the default check interval (1 hour) // Can be overridden via config.toml [updates] check_interval_hours DefaultCheckInterval = 1 * time.Hour )
const NudgeThreshold = 5
NudgeThreshold is the minimum "releases behind" count that triggers the startup nudge. Users with fewer releases to catch up on see the usual (quieter) update banner, not the nudge.
const SkipUpdateCheckEnv = "AGENTDECK_SKIP_UPDATE_CHECK"
SkipUpdateCheckEnv is the env var that fully disables update checking. Set AGENTDECK_SKIP_UPDATE_CHECK=1 in CI, in automation, or for users on locked-down networks.
Variables ¶
This section is empty.
Functions ¶
func CheckForUpdateAsync ¶
func CheckForUpdateAsync(currentVersion string) <-chan *UpdateInfo
CheckForUpdateAsync checks for updates in the background Returns a channel that will receive the result
func CompareVersions ¶
CompareVersions compares two semantic versions Returns: -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2
func CountReleasesBehind ¶ added in v1.7.62
CountReleasesBehind returns how many entries in `releases` are strictly newer than `currentVersion`. The "v" prefix is tolerated on both sides. If `currentVersion` is ahead of every release (or matches the newest), the result is 0 — never negative.
func DetectHomebrewManagedInstall ¶ added in v0.19.18
DetectHomebrewManagedInstall resolves the current executable path and reports whether it is managed by Homebrew.
func DownloadAndExtractBinary ¶ added in v0.21.0
DownloadAndExtractBinary downloads a release tarball and returns the binary bytes.
func FetchChangelog ¶ added in v0.8.86
FetchChangelog fetches the CHANGELOG.md from GitHub
func FormatChangelogForDisplay ¶ added in v0.8.86
func FormatChangelogForDisplay(entries []ChangelogEntry) string
FormatChangelogForDisplay formats changelog entries for terminal display
func GetAssetURLForPlatform ¶ added in v0.21.0
GetAssetURLForPlatform returns the download URL for a specific OS/arch combination.
func HomebrewUpgradeHint ¶ added in v0.19.18
HomebrewUpgradeHint returns the recommended Homebrew upgrade command when the binary path points into a known Homebrew Cellar location.
func InvalidateCache ¶ added in v1.7.2
func InvalidateCache()
InvalidateCache removes the update cache file so the next check fetches fresh data from GitHub. This should be called after a successful update to prevent stale "update available" banners.
func NormalizeReleaseTag ¶ added in v1.7.21
NormalizeReleaseTag ensures a version string is prefixed with "v" so it matches GitHub release tags (e.g., "1.7.4" -> "v1.7.4", "v1.7.4" -> "v1.7.4").
func PerformUpdate ¶
PerformUpdate downloads and installs the latest version
func SetCheckInterval ¶ added in v0.8.2
func SetCheckInterval(hours int)
SetCheckInterval sets the update check interval from config
func ShouldNudge ¶ added in v1.7.62
func ShouldNudge(info *UpdateInfo) bool
ShouldNudge decides whether the startup nudge should render. Returns true only when there is a real update available AND the user is more than NudgeThreshold releases behind AND AGENTDECK_SKIP_UPDATE_CHECK is not set. Nil info is safe — returns false.
func UpdateBridgePy ¶ added in v0.18.0
func UpdateBridgePy() error
UpdateBridgePy refreshes the installed bridge.py from the embedded runtime template. This keeps bridge behavior in sync with the currently running binary.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
}
Asset represents a release asset (binary download)
type ChangelogEntry ¶ added in v0.8.86
ChangelogEntry represents a single version's changelog
func GetChangesBetweenVersions ¶ added in v0.8.86
func GetChangesBetweenVersions(entries []ChangelogEntry, currentVersion, latestVersion string) []ChangelogEntry
GetChangesBetweenVersions returns changelog entries between two versions (exclusive of current, inclusive of latest)
func ParseChangelog ¶ added in v0.8.86
func ParseChangelog(content string) []ChangelogEntry
ParseChangelog parses CHANGELOG.md and returns entries for versions
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
Assets []Asset `json:"assets"`
}
Release represents a GitHub release
func FetchLatestRelease ¶ added in v0.21.0
FetchLatestRelease fetches the latest release from GitHub (exported for remote update).
func FetchReleaseByTag ¶ added in v1.7.21
FetchReleaseByTag fetches a specific release from GitHub by its tag. The tag may be supplied with or without the leading "v".
type UpdateCache ¶
type UpdateCache struct {
CheckedAt time.Time `json:"checked_at"`
LatestVersion string `json:"latest_version"`
CurrentVersion string `json:"current_version"`
DownloadURL string `json:"download_url"`
ReleaseURL string `json:"release_url"`
ReleasesBehind int `json:"releases_behind,omitempty"`
}
UpdateCache stores the last check result
type UpdateInfo ¶
type UpdateInfo struct {
Available bool
CurrentVersion string
LatestVersion string
DownloadURL string
ReleaseURL string
// ReleasesBehind is the number of published releases newer than the
// current version, capped at recentReleasesLimit. Populated when the
// full /releases listing is fetched alongside /releases/latest.
ReleasesBehind int
}
UpdateInfo contains information about an available update
func CachedUpdateInfo ¶ added in v1.7.62
func CachedUpdateInfo(currentVersion string) (*UpdateInfo, error)
CachedUpdateInfo returns the update info from the on-disk cache without touching the network. Used by `agent-deck --version` to annotate the banner instantly (never blocks on a GitHub call). Returns (nil, nil) if there is no cache yet; err only on corruption.
func CheckForUpdate ¶
func CheckForUpdate(currentVersion string, forceCheck bool) (*UpdateInfo, error)
CheckForUpdate checks if a new version is available Uses cache to avoid hitting GitHub API too frequently