update

package
v0.0.82 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkipUpdateEnvVar = "TERM_LLM_SKIP_UPDATE_CHECK"
	RepoOwner        = "samsaffron"
	RepoName         = "term-llm"
)

Variables

View Source
var UpdateCheckCmd = &cobra.Command{
	Use:    updateCheckCommandArg,
	Short:  "internal update check",
	Hidden: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		if os.Getenv(SkipUpdateEnvVar) == "" {
			os.Setenv(SkipUpdateEnvVar, "1")
		}
		return PerformUpdateCheck(cmd.Context())
	},
}

UpdateCheckCmd is the hidden command for background update checks

Functions

func CompareVersionStrings

func CompareVersionStrings(a, b string) (int, bool)

CompareVersionStrings compares two version strings Returns -1 if a < b, 0 if equal, 1 if a > b

func IsVersionOutdated

func IsVersionOutdated(current, latest string) bool

IsVersionOutdated returns true if current is older than latest

func LaunchBackgroundUpdateCheck

func LaunchBackgroundUpdateCheck() error

LaunchBackgroundUpdateCheck spawns a background process to check for updates

func NormalizeVersion

func NormalizeVersion(v string) string

NormalizeVersion strips v prefix and any non-numeric suffixes

func PerformUpdateCheck

func PerformUpdateCheck(ctx context.Context) error

PerformUpdateCheck fetches the latest release and updates state

func RunUpgrade

func RunUpgrade(ctx context.Context, currentVersion, targetVersion string, stdout, stderr io.Writer) error

RunUpgrade performs the upgrade to the specified version (or latest if empty)

func SaveState

func SaveState(state *State) error

func SetupUpdateChecks

func SetupUpdateChecks(rootCmd *cobra.Command, version string)

SetupUpdateChecks initializes update checking on CLI startup

func ShouldCheckForUpdates

func ShouldCheckForUpdates(state *State) bool

ShouldCheckForUpdates returns true if enough time has passed since last check

func WarnIfOutdated

func WarnIfOutdated(currentVersion string, state *State)

WarnIfOutdated prints a warning if a newer version is available

Types

type ReleaseInfo

type ReleaseInfo struct {
	TagName string `json:"tag_name"`
}

ReleaseInfo contains information about a GitHub release. Only TagName is populated by FetchLatestRelease (redirect-based detection).

func FetchLatestRelease

func FetchLatestRelease(ctx context.Context) (*ReleaseInfo, error)

FetchLatestRelease gets the latest release tag from GitHub by following the releases/latest redirect. This avoids the GitHub API rate limit (60 req/hour for unauthenticated requests).

type State

type State struct {
	LastChecked     time.Time `json:"lastChecked"`
	LatestVersion   string    `json:"latestVersion"`
	LastError       string    `json:"lastError,omitempty"`
	NotifiedVersion string    `json:"notifiedVersion,omitempty"`
	LastNotified    time.Time `json:"lastNotified,omitempty"`
}

func LoadState

func LoadState() (*State, error)

Jump to

Keyboard shortcuts

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