Skip to content

mission control for agent skills

refactor: remove auto-update flow

Alvin Unreal71c7d4edc415
diff --git a/README.md b/README.md
index f70e72d..0421e4a 100644
--- a/README.md
+++ b/README.md
@@ -98,29 +98,26 @@ LazySkills previews actions before running them, and destructive actions require
## 🔄 Updates
-Keep LazySkills up to date using the built-in update command or the TUI interface.
+LazySkills can check for new releases and show the command to update your installation manually.
### CLI Update
-Run the update command directly from your terminal:
+Run the update command directly from your terminal to check for updates and get upgrade instructions:
```bash
lazyskills update
```
Options:
-* `--check`: Query if a newer version is available without downloading or printing commands. Exits 0.
+* `--check`: Query if a newer version is available. Exits 0 if status is checked cleanly.
* `--print-command`: Print the command required to upgrade on your channel (e.g. `brew upgrade`) and exit.
-* `--yes`: Automatically perform the update if supported by the installation channel (direct Unix manual binary installations only).
### TUI Update
-When a newer version of LazySkills is available, an update notification will automatically appear in the TUI footer:
+When a newer version of LazySkills is available, an update notification will appear in the TUI footer:
`· U update (vX.Y.Z available)`
-Press **`U`** (capital U) from the inventory view to open the update flow:
-* For **manual binary installs** on macOS/Linux, you can perform the update directly inside the TUI.
-* For **managed package installs** (like Homebrew, Scoop, WinGet, deb, or rpm packages), the TUI will display the specific terminal command you need to run to upgrade.
+Press **`U`** (capital U) from the inventory view to open the update info modal, which will display the release details and the specific terminal command you need to run to upgrade manually.
## ⭐ Star for a chance to win stickers
diff --git a/cmd/lazyskills/main.go b/cmd/lazyskills/main.go
index be53a28..0f73863 100644
--- a/cmd/lazyskills/main.go
+++ b/cmd/lazyskills/main.go
@@ -48,11 +48,15 @@ func run(args []string) error {
fs.SetOutput(os.Stderr)
checkOnly := fs.Bool("check", false, "only check if update is available")
printCmd := fs.Bool("print-command", false, "print upgrade command and exit")
- yes := fs.Bool("yes", false, "apply update automatically without confirmation")
+ yes := fs.Bool("yes", false, "unsupported; automatic updates have been removed")
if err := fs.Parse(args[1:]); err != nil {
return err
}
+ if *yes {
+ return fmt.Errorf("automatic updates have been removed; run lazyskills update for manual upgrade instructions")
+ }
+
ctx := context.Background()
plan, err := selfupdate.Plan(ctx, true, nil)
if err != nil {
@@ -103,29 +107,17 @@ func run(args []string) error {
}
if plan.Status == selfupdate.StatusAvailable {
- if *yes {
- if plan.CanExecute {
- fmt.Fprintf(os.Stdout, "Updating lazyskills to %s...\n", plan.Latest)
- if err := selfupdate.Apply(ctx, plan, nil); err != nil {
- return fmt.Errorf("update failed: %w", err)
- }
- fmt.Fprintln(os.Stdout, "Update applied successfully. Please restart lazyskills.")
- return nil
- } else {
- fmt.Fprintf(os.Stdout, "Auto-update not supported for install channel: %s\n%s\n", plan.Channel, plan.Reason)
- if plan.CommandPreview != "" {
- fmt.Fprintf(os.Stdout, "Command: %s\n", plan.CommandPreview)
- }
- return nil
- }
- } else {
- fmt.Fprintf(os.Stdout, "Update available: %s (current: %s)\n", plan.Latest, plan.Current)
+ fmt.Fprintf(os.Stdout, "Update available: %s (current: %s)\n", plan.Latest, plan.Current)
+ if plan.Reason != "" {
fmt.Fprintf(os.Stdout, "%s\n", plan.Reason)
- if plan.CommandPreview != "" {
- fmt.Fprintf(os.Stdout, "Command: %s\n", plan.CommandPreview)
- }
- return nil
}
+ if plan.CommandPreview != "" {
+ fmt.Fprintf(os.Stdout, "Command: %s\n", plan.CommandPreview)
+ }
+ if plan.ReleaseURL != "" {
+ fmt.Fprintf(os.Stdout, "Release URL: %s\n", plan.ReleaseURL)
+ }
+ return nil
}
fmt.Fprintln(os.Stdout, "Already up to date.")
@@ -146,7 +138,7 @@ func run(args []string) error {
return err
}
if fs.NArg() > 0 {
- return fmt.Errorf("usage: lazyskills [--cwd <path>] | lazyskills scan --json [--cwd <path>] | lazyskills update [--check] [--print-command] [--yes] | lazyskills version")
+ return fmt.Errorf("usage: lazyskills [--cwd <path>] | lazyskills scan --json [--cwd <path>] | lazyskills update [--check] [--print-command] | lazyskills version")
}
if *cwd == "" {
var err error
diff --git a/cmd/lazyskills/main_test.go b/cmd/lazyskills/main_test.go
index 08a13d0..bd281ea 100644
--- a/cmd/lazyskills/main_test.go
+++ b/cmd/lazyskills/main_test.go
@@ -3,7 +3,6 @@ package main
import (
"bytes"
"context"
- "fmt"
"io"
"os"
"strings"
@@ -25,10 +24,6 @@ func (m *mockFetcher) FetchRelease(ctx context.Context, url string) (*selfupdate
return m.release, nil
}
-func (m *mockFetcher) Download(ctx context.Context, url string) ([]byte, error) {
- return nil, fmt.Errorf("not implemented")
-}
-
func TestCLIUpdate(t *testing.T) {
t.Setenv("XDG_CACHE_HOME", t.TempDir())
oldOut := os.Stdout
@@ -81,11 +76,12 @@ func TestCLIUpdate(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
+ if strings.Contains(out, "lazyskills update --yes") {
+ t.Errorf("print-command must not advertise removed self-update command, got: %q", out)
+ }
// Default channel should be "manual" on unix, or "windows" on windows.
// Since we mock it, we just check if it returns one of the guidance/command values.
- if !strings.Contains(out, "lazyskills update") &&
- !strings.Contains(out, "To upgrade, please download") &&
- !strings.Contains(out, "Please download the release manually") {
+ if !strings.Contains(out, "To upgrade, please download") && !strings.Contains(out, "install.sh") {
t.Errorf("expected command preview or download guidance, got: %q", out)
}
@@ -98,9 +94,17 @@ func TestCLIUpdate(t *testing.T) {
t.Errorf("expected default output to mention Update available, got: %q", out)
}
- // 4. --yes with CanExecute = false check (if we mock it to a managed channel like brew)
- // We can test this by changing the channel of the executable.
- // Let's verify already up-to-date behavior.
+ // 4. Test --yes returns non-zero error before calling Plan
+ _, errYes := captureStdout([]string{"update", "--yes"})
+ if errYes == nil {
+ t.Fatal("expected error with --yes, got nil")
+ }
+ expectedErrMsg := "automatic updates have been removed; run lazyskills update for manual upgrade instructions"
+ if !strings.Contains(errYes.Error(), expectedErrMsg) {
+ t.Errorf("expected error message to contain %q, got: %v", expectedErrMsg, errYes)
+ }
+
+ // 5. Already up-to-date behavior.
buildinfo.Version = "v1.1.0"
out, err = captureStdout([]string{"update"})
if err != nil {
@@ -110,7 +114,7 @@ func TestCLIUpdate(t *testing.T) {
t.Errorf("expected already up to date, got: %q", out)
}
- // 5. Test LAZYSKILLS_NO_UPDATE_CHECK prints the disable reason instead of Already up to date
+ // 6. Test LAZYSKILLS_NO_UPDATE_CHECK prints the disable reason instead of Already up to date
os.Setenv("LAZYSKILLS_NO_UPDATE_CHECK", "1")
defer os.Setenv("LAZYSKILLS_NO_UPDATE_CHECK", "")
out, err = captureStdout([]string{"update"})
diff --git a/internal/selfupdate/selfupdate.go b/internal/selfupdate/selfupdate.go
index 8322352..f3e6e88 100644
--- a/internal/selfupdate/selfupdate.go
+++ b/internal/selfupdate/selfupdate.go
@@ -1,14 +1,9 @@
package selfupdate
import (
- "archive/tar"
- "bytes"
- "compress/gzip"
"context"
- "crypto/sha256"
"encoding/json"
"fmt"
- "io"
"net/http"
"os"
"os/exec"
@@ -25,42 +20,32 @@ type UpdateStatus string
const (
StatusAlreadyLatest UpdateStatus = "already_latest"
StatusAvailable UpdateStatus = "available"
- StatusError UpdateStatus = "error"
StatusUnknown UpdateStatus = "unknown"
)
type UpdatePlan struct {
- Current string `json:"current"`
- Latest string `json:"latest"`
- Status UpdateStatus `json:"status"`
- Channel string `json:"channel"`
- Confidence string `json:"confidence"`
- ExecutablePath string `json:"executable_path"`
- CommandPreview string `json:"command_preview"`
- CanExecute bool `json:"can_execute"`
- Reason string `json:"reason"`
- RestartRequired bool `json:"restart_required"`
- ReleaseNotes string `json:"release_notes"`
- ReleaseURL string `json:"release_url"`
- ArchiveURL string `json:"archive_url"`
- ChecksumsURL string `json:"checksums_url"`
+ Current string `json:"current"`
+ Latest string `json:"latest"`
+ Status UpdateStatus `json:"status"`
+ Channel string `json:"channel"`
+ Confidence string `json:"confidence"`
+ ExecutablePath string `json:"executable_path"`
+ CommandPreview string `json:"command_preview"`
+ Reason string `json:"reason"`
+ ReleaseNotes string `json:"release_notes"`
+ ReleaseURL string `json:"release_url"`
}
type GitHubRelease struct {
TagName string `json:"tag_name"`
HTMLURL string `json:"html_url"`
Body string `json:"body"`
- Assets []struct {
- Name string `json:"name"`
- BrowserDownloadURL string `json:"browser_download_url"`
- } `json:"assets"`
}
var DefaultPlanFetcher Fetcher
type Fetcher interface {
FetchRelease(ctx context.Context, url string) (*GitHubRelease, error)
- Download(ctx context.Context, url string) ([]byte, error)
}
type DefaultFetcher struct {
@@ -89,24 +74,6 @@ func (f *DefaultFetcher) FetchRelease(ctx context.Context, url string) (*GitHubR
return &rel, nil
}
-func (f *DefaultFetcher) Download(ctx context.Context, url string) ([]byte, error) {
- client := &http.Client{Timeout: f.Timeout}
- req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
- if err != nil {
- return nil, err
- }
- req.Header.Set("User-Agent", "lazyskills-updater")
- resp, err := client.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- if resp.StatusCode != http.StatusOK {
- return nil, fmt.Errorf("failed to download from %s: status %d", url, resp.StatusCode)
- }
- return io.ReadAll(resp.Body)
-}
-
type CacheData struct {
LastChecked time.Time `json:"last_checked"`
Release GitHubRelease `json:"release"`
@@ -282,42 +249,6 @@ func isGoPath(path string) bool {
return false
}
-func isManualInstallSafe(path string) bool {
- path = filepath.Clean(filepath.ToSlash(path))
- if strings.HasPrefix(path, "/usr/bin/") ||
- strings.HasPrefix(path, "/usr/sbin/") ||
- strings.HasPrefix(path, "/bin/") ||
- strings.HasPrefix(path, "/sbin/") ||
- strings.HasPrefix(path, "/opt/") ||
- strings.HasPrefix(path, "/var/") {
- return false
- }
- home, err := os.UserHomeDir()
- if err == nil && home != "" {
- home = filepath.Clean(filepath.ToSlash(home))
- if strings.HasPrefix(path, home+"/") {
- return true
- }
- }
- if strings.HasPrefix(path, "/usr/local/bin/") || strings.HasPrefix(path, "/usr/local/sbin/") {
- return true
- }
- tempDir := filepath.Clean(filepath.ToSlash(os.TempDir()))
- if strings.HasPrefix(path, tempDir+"/") {
- return true
- }
- if evalTempDir, err := filepath.EvalSymlinks(os.TempDir()); err == nil {
- evalTempDir = filepath.Clean(filepath.ToSlash(evalTempDir))
- if strings.HasPrefix(path, evalTempDir+"/") {
- return true
- }
- }
- if strings.HasPrefix(path, "/tmp/") {
- return true
- }
- return false
-}
-
func DetectChannel(execPath string) (string, string) {
evalPath, err := filepath.EvalSymlinks(execPath)
if err == nil {
@@ -381,6 +312,14 @@ func Plan(ctx context.Context, forceLive bool, fetcher Fetcher) (*UpdatePlan, er
return plan, nil
}
+ currClean := strings.TrimSpace(current)
+ if currClean == "dev" || currClean == "" || currClean == "(devel)" {
+ plan.Status = StatusUnknown
+ plan.Reason = "Running a development build. Rebuild from source."
+ plan.CommandPreview = "go install github.com/alvinunreal/lazyskills/cmd/lazyskills@latest"
+ return plan, nil
+ }
+
var release *GitHubRelease
if !forceLive {
if cached, err := readCache(24 * time.Hour); err == nil {
@@ -399,7 +338,7 @@ func Plan(ctx context.Context, forceLive bool, fetcher Fetcher) (*UpdatePlan, er
url := "https://api.github.com/repos/alvinunreal/lazyskills/releases/latest"
rel, err := fetcher.FetchRelease(ctx, url)
if err != nil {
- plan.Status = StatusError
+ plan.Status = StatusUnknown
plan.Reason = fmt.Sprintf("Failed to query latest release: %v", err)
return plan, err
}
@@ -411,37 +350,9 @@ func Plan(ctx context.Context, forceLive bool, fetcher Fetcher) (*UpdatePlan, er
plan.ReleaseNotes = release.Body
plan.ReleaseURL = release.HTMLURL
- osName := strings.Title(runtime.GOOS)
- archName := runtime.GOARCH
- if archName == "amd64" {
- archName = "x86_64"
- }
- archiveName := fmt.Sprintf("lazyskills_%s_%s.tar.gz", osName, archName)
- if runtime.GOOS == "windows" {
- archiveName = fmt.Sprintf("lazyskills_%s_%s.zip", osName, archName)
- }
-
- for _, asset := range release.Assets {
- if asset.Name == archiveName {
- plan.ArchiveURL = asset.BrowserDownloadURL
- } else if asset.Name == "checksums.txt" {
- plan.ChecksumsURL = asset.BrowserDownloadURL
- }
- }
-
- currClean := strings.TrimSpace(current)
- if currClean == "dev" || currClean == "" || currClean == "(devel)" {
- plan.Status = StatusAlreadyLatest
- plan.CanExecute = false
- plan.Reason = "Running a development build. Rebuild from source."
- plan.CommandPreview = "go install github.com/alvinunreal/lazyskills/cmd/lazyskills@latest"
- return plan, nil
- }
-
cmp := CompareVersions(current, release.TagName)
if cmp >= 0 {
plan.Status = StatusAlreadyLatest
- plan.CanExecute = false
plan.Reason = "You are already running the latest version."
return plan, nil
}
@@ -450,223 +361,47 @@ func Plan(ctx context.Context, forceLive bool, fetcher Fetcher) (*UpdatePlan, er
switch channel {
case "brew":
- plan.CommandPreview = "brew upgrade --cask alvinunreal/tap/lazyskills"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Homebrew managed install. Please upgrade using Homebrew."
- plan.CanExecute = false
case "go":
- plan.CommandPreview = "go install github.com/alvinunreal/lazyskills/cmd/lazyskills@latest"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Installed via Go. Please run go install to upgrade."
- plan.CanExecute = false
case "scoop":
- plan.CommandPreview = "scoop update lazyskills"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Scoop managed install. Please upgrade using Scoop."
- plan.CanExecute = false
case "winget":
- plan.CommandPreview = "winget upgrade --id alvinunreal.lazyskills"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "WinGet managed install. Please upgrade using WinGet."
- plan.CanExecute = false
case "deb":
- plan.CommandPreview = "sudo apt update && sudo apt install --only-upgrade lazyskills"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Installed via DEB package. If a repository is configured, upgrade via apt. Otherwise, download the latest DEB from the releases page: https://github.com/alvinunreal/lazyskills/releases/latest"
- plan.CanExecute = false
case "rpm":
- plan.CommandPreview = "sudo dnf upgrade lazyskills"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Installed via RPM package. If a repository is configured, upgrade via dnf/yum. Otherwise, download the latest RPM from the releases page: https://github.com/alvinunreal/lazyskills/releases/latest"
- plan.CanExecute = false
case "dev":
- plan.CommandPreview = "go install github.com/alvinunreal/lazyskills/cmd/lazyskills@latest"
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
plan.Reason = "Running a development build. Rebuild from source."
- plan.CanExecute = false
case "windows":
- plan.CommandPreview = ""
- plan.Reason = "To upgrade, please download the latest release from: " + release.HTMLURL
- plan.CanExecute = false
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
+ plan.Reason = "To upgrade, run the Windows installer or download the latest release from: " + release.HTMLURL
default:
if runtime.GOOS == "windows" {
- plan.CommandPreview = ""
- plan.Reason = "To upgrade, please download the latest release from: " + release.HTMLURL
- plan.CanExecute = false
+ _, plan.CommandPreview = RecoveryAdvice(channel, runtime.GOOS)
+ plan.Reason = "To upgrade, run the Windows installer or download the latest release from: " + release.HTMLURL
} else {
- if !isManualInstallSafe(execPath) {
- plan.CommandPreview = ""
- plan.Reason = "Update available, but automatic replacement is disabled because the executable path (" + execPath + ") is in a system directory. Please download the release manually from: " + release.HTMLURL
- plan.CanExecute = false
- } else {
- plan.CommandPreview = "lazyskills update --yes"
- plan.Reason = "Manual binary install. Can update directly."
- plan.CanExecute = true
- }
+ plan.CommandPreview = "curl -fsSL https://lazyskills.sh/install | sh -s -- -b " + shellQuote(filepath.Dir(execPath))
+ plan.Reason = "Manual binary install. Run the installer for the directory that contains your current lazyskills binary."
}
}
return plan, nil
}
-func Apply(ctx context.Context, plan *UpdatePlan, fetcher Fetcher) error {
- if !plan.CanExecute {
- return fmt.Errorf("update execution not supported for channel %q", plan.Channel)
- }
-
- if fetcher == nil {
- if DefaultPlanFetcher != nil {
- fetcher = DefaultPlanFetcher
- } else {
- fetcher = &DefaultFetcher{Timeout: 30 * time.Second}
- }
- }
-
- osName := strings.Title(runtime.GOOS)
- archName := runtime.GOARCH
- if archName == "amd64" {
- archName = "x86_64"
- }
-
- archiveName := fmt.Sprintf("lazyskills_%s_%s.tar.gz", osName, archName)
-
- archiveURL := plan.ArchiveURL
- checksumsURL := plan.ChecksumsURL
-
- if archiveURL == "" || checksumsURL == "" {
- url := "https://api.github.com/repos/alvinunreal/lazyskills/releases/latest"
- rel, err := fetcher.FetchRelease(ctx, url)
- if err != nil {
- return fmt.Errorf("failed to fetch release details for download: %v", err)
- }
- if rel.TagName != plan.Latest {
- return fmt.Errorf("release mismatch: plan latest version is %s, but fetched version was %s", plan.Latest, rel.TagName)
- }
- for _, asset := range rel.Assets {
- if asset.Name == archiveName {
- archiveURL = asset.BrowserDownloadURL
- } else if asset.Name == "checksums.txt" {
- checksumsURL = asset.BrowserDownloadURL
- }
- }
- }
-
- if archiveURL == "" {
- return fmt.Errorf("release archive asset %q not found", archiveName)
- }
- if checksumsURL == "" {
- return fmt.Errorf("release checksums asset %q not found", "checksums.txt")
- }
-
- checksumsBytes, err := fetcher.Download(ctx, checksumsURL)
- if err != nil {
- return fmt.Errorf("failed to download checksums: %v", err)
- }
-
- archiveBytes, err := fetcher.Download(ctx, archiveURL)
- if err != nil {
- return fmt.Errorf("failed to download archive: %v", err)
- }
-
- hash := sha256.Sum256(archiveBytes)
- hashStr := fmt.Sprintf("%x", hash)
-
- var expectedSHA string
- for _, line := range strings.Split(string(checksumsBytes), "\n") {
- parts := strings.Fields(line)
- if len(parts) >= 2 && parts[1] == archiveName {
- expectedSHA = parts[0]
- break
- }
- }
-
- if expectedSHA == "" {
- return fmt.Errorf("checksum for %q not found in checksums.txt", archiveName)
- }
-
- if hashStr != expectedSHA {
- return fmt.Errorf("checksum mismatch: got %s, expected %s", hashStr, expectedSHA)
- }
-
- binaryName := "lazyskills"
- binaryBytes, err := extractBinaryFromTarGz(archiveBytes, binaryName)
- if err != nil {
- return fmt.Errorf("failed to extract binary from archive: %v", err)
- }
-
- targetPath := plan.ExecutablePath
- evalPath, err := filepath.EvalSymlinks(targetPath)
- if err == nil {
- targetPath = evalPath
- }
-
- if !isManualInstallSafe(targetPath) {
- return fmt.Errorf("target path %q is in an unsafe system directory for manual replacement", targetPath)
- }
-
- var targetMode os.FileMode = 0755
- info, statErr := os.Lstat(targetPath)
- if statErr == nil {
- if !info.Mode().IsRegular() {
- return fmt.Errorf("target path %q is not a regular file", targetPath)
- }
- targetMode = info.Mode()
- }
-
- execDir := filepath.Dir(targetPath)
- dirInfo, err := os.Stat(execDir)
- if err != nil {
- return fmt.Errorf("failed to access directory %q: %w", execDir, err)
- }
- if !dirInfo.IsDir() {
- return fmt.Errorf("target path parent %q is not a directory", execDir)
- }
-
- tempFile, err := os.CreateTemp(execDir, "lazyskills-update-")
- if err != nil {
- return fmt.Errorf("failed to create temp file (directory may not be writable): %w", err)
- }
- tempPath := tempFile.Name()
- defer func() {
- _ = os.Remove(tempPath)
- }()
-
- if _, err := io.Copy(tempFile, bytes.NewReader(binaryBytes)); err != nil {
- tempFile.Close()
- return fmt.Errorf("failed to write binary to temp file: %w", err)
- }
- tempFile.Close()
-
- if err := os.Chmod(tempPath, targetMode); err != nil {
- return fmt.Errorf("failed to chmod temp file: %w", err)
- }
-
- if err := os.Rename(tempPath, targetPath); err != nil {
- return fmt.Errorf("failed to replace executable: %w", err)
- }
-
- plan.RestartRequired = true
- return nil
-}
-
-func extractBinaryFromTarGz(tarGzBytes []byte, binaryName string) ([]byte, error) {
- gzr, err := gzip.NewReader(bytes.NewReader(tarGzBytes))
- if err != nil {
- return nil, err
- }
- defer gzr.Close()
-
- tr := tar.NewReader(gzr)
- for {
- header, err := tr.Next()
- if err == io.EOF {
- break
- }
- if err != nil {
- return nil, err
- }
- if filepath.Base(header.Name) == binaryName && header.Typeflag == tar.TypeReg {
- var buf bytes.Buffer
- if _, err := io.Copy(&buf, tr); err != nil {
- return nil, err
- }
- return buf.Bytes(), nil
- }
+func shellQuote(s string) string {
+ if s == "" {
+ return "''"
}
- return nil, fmt.Errorf("binary %q not found in archive", binaryName)
+ return "'" + strings.ReplaceAll(s, "'", "'\\''") + "'"
}
// RecoveryAdvice returns a suggested manual recovery instruction and command (or download URL)
diff --git a/internal/selfupdate/selfupdate_test.go b/internal/selfupdate/selfupdate_test.go
index d9635e4..d94b306 100644
--- a/internal/selfupdate/selfupdate_test.go
+++ b/internal/selfupdate/selfupdate_test.go
@@ -1,17 +1,11 @@
package selfupdate
import (
- "archive/tar"
- "bytes"
- "compress/gzip"
"context"
- "crypto/sha256"
"encoding/json"
"fmt"
"os"
"path/filepath"
- "runtime"
- "strings"
"testing"
"time"
@@ -19,10 +13,8 @@ import (
)
type mockFetcher struct {
- release *GitHubRelease
- releaseErr error
- downloadData map[string][]byte
- downloadErr map[string]error
+ release *GitHubRelease
+ releaseErr error
}
func (m *mockFetcher) FetchRelease(ctx context.Context, url string) (*GitHubRelease, error) {
@@ -32,18 +24,6 @@ func (m *mockFetcher) FetchRelease(ctx context.Context, url string) (*GitHubRele
return m.release, nil
}
-func (m *mockFetcher) Download(ctx context.Context, url string) ([]byte, error) {
- if m.downloadErr != nil {
- if err := m.downloadErr[url]; err != nil {
- return nil, err
- }
- }
- if data, ok := m.downloadData[url]; ok {
- return data, nil
- }
- return nil, fmt.Errorf("mock download error for URL: %s", url)
-}
-
func TestCompareVersions(t *testing.T) {
tests := []struct {
v1, v2 string
@@ -132,13 +112,6 @@ func TestPlanAndCacheTTL(t *testing.T) {
HTMLURL: "https://github.com/alvinunreal/lazyskills/releases/tag/v1.1.0",
Body: "New features!",
}
- mockRel.Assets = append(mockRel.Assets, struct {
- Name string `json:"name"`
- BrowserDownloadURL string `json:"browser_download_url"`
- }{
- Name: "lazyskills_Linux_x86_64.tar.gz",
- BrowserDownloadURL: "https://github.com/downloads/archive.tar.gz",
- })
fetcher := &mockFetcher{release: mockRel}
@@ -202,198 +175,6 @@ func TestPlanAndCacheTTL(t *testing.T) {
}
os.Setenv("LAZYSKILLS_NO_UPDATE_CHECK", "")
}
-
-func TestApplyAndChecksumMismatch(t *testing.T) {
- t.Setenv("XDG_CACHE_HOME", t.TempDir())
- // Create mock binary data and tar.gz
- var binBuf bytes.Buffer
- binBuf.WriteString("dummy binary content")
- binBytes := binBuf.Bytes()
-
- var tarBuf bytes.Buffer
- gw := gzip.NewWriter(&tarBuf)
- tw := tar.NewWriter(gw)
- hdr := &tar.Header{
- Name: "lazyskills",
- Mode: 0755,
- Size: int64(len(binBytes)),
- Typeflag: tar.TypeReg,
- }
- _ = tw.WriteHeader(hdr)
- _, _ = tw.Write(binBytes)
- _ = tw.Close()
- _ = gw.Close()
- tarBytes := tarBuf.Bytes()
-
- correctHash := sha256.Sum256(tarBytes)
- correctHashStr := fmt.Sprintf("%x", correctHash)
-
- // Write temp target executable paths
- var parentDir string
- if home, err := os.UserHomeDir(); err == nil && home != "" {
- parentDir = home
- }
- tmpDir, err := os.MkdirTemp(parentDir, ".lazyskills-test-*")
- if err != nil {
- t.Fatalf("MkdirTemp failed: %v", err)
- }
- defer os.RemoveAll(tmpDir)
-
- execPath := filepath.Join(tmpDir, "lazyskills")
- _ = os.WriteFile(execPath, []byte("old binary content"), 0755)
-
- plan := &UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: StatusAvailable,
- Channel: "manual",
- ExecutablePath: execPath,
- CanExecute: true,
- }
-
- // Helper URLs
- archiveURL := "https://github.com/downloads/lazyskills_linux_amd64.tar.gz" // not exact, mock matches anyway
- checksumsURL := "https://github.com/downloads/checksums.txt"
-
- // Mock release info with asset list matching our helper URLs
- mockRel := &GitHubRelease{
- TagName: "v1.1.0",
- }
- // Match Apply's runtime-specific release asset naming.
- osName := strings.Title(runtime.GOOS)
- archName := runtime.GOARCH
- if archName == "amd64" {
- archName = "x86_64"
- }
- mockRel.Assets = append(mockRel.Assets, struct {
- Name string `json:"name"`
- BrowserDownloadURL string `json:"browser_download_url"`
- }{
- Name: fmt.Sprintf("lazyskills_%s_%s.tar.gz", osName, archName),
- BrowserDownloadURL: archiveURL,
- })
- mockRel.Assets = append(mockRel.Assets, struct {
- Name string `json:"name"`
- BrowserDownloadURL string `json:"browser_download_url"`
- }{
- Name: "checksums.txt",
- BrowserDownloadURL: checksumsURL,
- })
-
- // 1. Checksum mismatch test
- mismatchFetcher := &mockFetcher{
- release: mockRel,
- downloadData: map[string][]byte{
- checksumsURL: []byte(fmt.Sprintf("badhash1234567890abcdef lazyskills_%s_%s.tar.gz\n", osName, archName)),
- archiveURL: tarBytes,
- },
- }
-
- ctx := context.Background()
- err = Apply(ctx, plan, mismatchFetcher)
- if err == nil || !bytes.Contains([]byte(err.Error()), []byte("checksum mismatch")) {
- t.Errorf("expected checksum mismatch error, got %v", err)
- }
-
- // 2. Successful Apply test
- successFetcher := &mockFetcher{
- release: mockRel,
- downloadData: map[string][]byte{
- checksumsURL: []byte(fmt.Sprintf("%s lazyskills_%s_%s.tar.gz\n", correctHashStr, osName, archName)),
- archiveURL: tarBytes,
- },
- }
-
- err = Apply(ctx, plan, successFetcher)
- if err != nil {
- t.Fatalf("expected successful Apply, got err: %v", err)
- }
-
- if !plan.RestartRequired {
- t.Error("expected RestartRequired to be true")
- }
-
- newContent, err := os.ReadFile(execPath)
- if err != nil {
- t.Fatalf("failed to read updated executable: %v", err)
- }
- if string(newContent) != "dummy binary content" {
- t.Errorf("binary content not updated properly: got %q", string(newContent))
- }
-
- // 3. Test TOCTOU tag mismatch (when ArchiveURL is empty and latest release tag has changed)
- mismatchTagFetcher := &mockFetcher{
- release: &GitHubRelease{TagName: "v1.2.0"}, // different from plan.Latest which is "v1.1.0"
- }
- planNoURLs := &UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: StatusAvailable,
- Channel: "manual",
- ExecutablePath: execPath,
- CanExecute: true,
- }
- err = Apply(ctx, planNoURLs, mismatchTagFetcher)
- if err == nil || !strings.Contains(err.Error(), "release mismatch") {
- t.Errorf("expected release mismatch error, got %v", err)
- }
-
- // 4. Test target path is not a regular file
- dirPath := filepath.Join(tmpDir, "some-dir-target")
- _ = os.Mkdir(dirPath, 0755)
- planDir := &UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: StatusAvailable,
- Channel: "manual",
- ExecutablePath: dirPath,
- CanExecute: true,
- }
- err = Apply(ctx, planDir, successFetcher)
- if err == nil || !strings.Contains(err.Error(), "is not a regular file") {
- t.Errorf("expected is not a regular file error, got %v", err)
- }
-
- // 5. Test symlink pointing to an unsafe target must not be executable/updatable
- baseUnsafeDir, err := os.MkdirTemp("/var/tmp", "lazyskills-test-*")
- if err == nil {
- defer os.RemoveAll(baseUnsafeDir)
-
- unsafeTarget := filepath.Join(baseUnsafeDir, "opt/vendor/lazyskills")
- _ = os.MkdirAll(filepath.Dir(unsafeTarget), 0755)
- _ = os.WriteFile(unsafeTarget, []byte("unsafe binary"), 0755)
-
- safeSymlink := filepath.Join(tmpDir, "usr/local/bin/lazyskills")
- _ = os.MkdirAll(filepath.Dir(safeSymlink), 0755)
-
- err = os.Symlink(unsafeTarget, safeSymlink)
- if err == nil {
- resolved, err := filepath.EvalSymlinks(safeSymlink)
- if err != nil {
- t.Fatalf("failed to resolve symlink: %v", err)
- }
- if isManualInstallSafe(resolved) {
- t.Errorf("expected resolved path %q to be unsafe", resolved)
- }
-
- planUnsafeSymlink := &UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: StatusAvailable,
- Channel: "manual",
- ExecutablePath: safeSymlink,
- CanExecute: true,
- }
- err = Apply(ctx, planUnsafeSymlink, successFetcher)
- if err == nil || !strings.Contains(err.Error(), "unsafe system directory") {
- t.Errorf("expected unsafe system directory error for symlink target, got %v", err)
- }
- }
- } else {
- t.Logf("skipping /var/tmp symlink safety test because /var/tmp is not writeable or available: %v", err)
- }
-}
-
func TestRecoveryAdvice(t *testing.T) {
tests := []struct {
channel string
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index a8a9f02..7cb9bd3 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -105,9 +105,6 @@ type appModel struct {
updatePlan *selfupdate.UpdatePlan
updatePlanErr error
appUpdateModal bool
- updatingApp bool
- updateSuccess bool
- updateError error
}
type paneLayout struct {
@@ -189,10 +186,6 @@ type updatePlanMsg struct {
err error
}
-type appUpdateResultMsg struct {
- err error
-}
-
func Run(cwd string) error {
program := tea.NewProgram(newModel(cwd), tea.WithAltScreen())
_, err := program.Run()
diff --git a/internal/tui/update.go b/internal/tui/update.go
index c9e760e..dc4f5ea 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -1,7 +1,6 @@
package tui
import (
- "context"
"fmt"
"os"
"os/exec"
@@ -16,7 +15,6 @@ import (
"github.com/alvinunreal/lazyskills/internal/locks"
"github.com/alvinunreal/lazyskills/internal/model"
"github.com/alvinunreal/lazyskills/internal/runner"
- "github.com/alvinunreal/lazyskills/internal/selfupdate"
)
const previewRefreshDelay = 300 * time.Millisecond
@@ -159,16 +157,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.updatePlan = msg.plan
m.updatePlanErr = msg.err
m.syncViewport()
- case appUpdateResultMsg:
- m.updatingApp = false
- if msg.err != nil {
- m.updateError = msg.err
- m.updateSuccess = false
- } else {
- m.updateSuccess = true
- m.updateError = nil
- }
- m.syncViewport()
case tea.KeyMsg:
key := msg.String()
var postKeyCmd tea.Cmd
@@ -182,19 +170,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch key {
case "esc", "q":
m.appUpdateModal = false
- m.updateError = nil
- m.updateSuccess = false
m.syncViewport()
case "ctrl+c":
return m, tea.Quit
- case "enter":
- if m.updatePlan != nil && m.updatePlan.CanExecute && !m.updatingApp && !m.updateSuccess {
- m.updatingApp = true
- m.updateError = nil
- m.updateSuccess = false
- m.syncViewport()
- return m, m.applyUpdateCmd()
- }
}
return m, nil
}
@@ -512,9 +490,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.helpOpen = true
case "U":
m.appUpdateModal = true
- m.updatingApp = false
- m.updateSuccess = false
- m.updateError = nil
m.syncViewport()
case "c":
m.commands = !m.commands
@@ -1637,12 +1612,3 @@ func insertToggleActions(previews, toggleActions []actions.CommandPreview) []act
out = append(out, previews[insertAt:]...)
return out
}
-
-func (m appModel) applyUpdateCmd() tea.Cmd {
- return func() tea.Msg {
- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
- defer cancel()
- err := selfupdate.Apply(ctx, m.updatePlan, nil)
- return appUpdateResultMsg{err: err}
- }
-}
diff --git a/internal/tui/update_test.go b/internal/tui/update_test.go
index b467cd1..03a0990 100644
--- a/internal/tui/update_test.go
+++ b/internal/tui/update_test.go
@@ -2,13 +2,11 @@ package tui
import (
"fmt"
- "runtime"
"strings"
"testing"
- tea "github.com/charmbracelet/bubbletea"
-
"github.com/alvinunreal/lazyskills/internal/selfupdate"
+ tea "github.com/charmbracelet/bubbletea"
)
func TestTUIFooterUpdateNotice(t *testing.T) {
@@ -28,15 +26,14 @@ func TestTUIFooterUpdateNotice(t *testing.T) {
Current: "v1.0.0",
Latest: "v1.1.0",
Status: selfupdate.StatusAvailable,
- Channel: "manual",
}
-
footer = m.footerText(120, m.visibleRows(), m.currentActions())
if !strings.Contains(footer, "U update") || !strings.Contains(footer, "v1.1.0 available") {
t.Errorf("expected update notice in footer, got: %q", footer)
}
// 3. Notice omitted if width is too narrow
+ m.width = 40
footerNarrow := m.footerText(40, m.visibleRows(), m.currentActions())
if strings.Contains(footerNarrow, "U update") {
t.Errorf("expected update notice to be omitted in narrow viewport, got: %q", footerNarrow)
@@ -49,11 +46,11 @@ func TestTUIAppUpdateModalTransitions(t *testing.T) {
m.width = 100
m.height = 30
m.updatePlan = &selfupdate.UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: selfupdate.StatusAvailable,
- Channel: "manual",
- CanExecute: true,
+ Current: "v1.0.0",
+ Latest: "v1.1.0",
+ Status: selfupdate.StatusAvailable,
+ Channel: "manual",
+ CommandPreview: "curl -fsSL https://raw.githubusercontent.com/alvinunreal/lazyskills/main/scripts/install.sh | sh",
}
// 1. Pressing 'U' opens the modal
@@ -68,7 +65,7 @@ func TestTUIAppUpdateModalTransitions(t *testing.T) {
// 2. View of modal
viewOut := m.View()
- if !strings.Contains(viewOut, "LazySkills App Update") {
+ if !strings.Contains(viewOut, "LazySkills Update") {
t.Errorf("expected app update view header, got: %s", viewOut)
}
if !strings.Contains(viewOut, "Current Version: v1.0.0") {
@@ -78,35 +75,17 @@ func TestTUIAppUpdateModalTransitions(t *testing.T) {
t.Errorf("expected latest version in view, got: %s", viewOut)
}
- // 3. Pressing Enter starts update execution
+ // 3. Pressing Enter does not trigger any update execution command
modelTmp, cmd = m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = modelTmp.(appModel)
- if !m.updatingApp {
- t.Error("expected updatingApp to be true after pressing Enter")
- }
- if cmd == nil {
- t.Fatal("expected update command to be scheduled, got nil")
- }
-
- // 4. Update result message handler success
- modelTmp, cmd = m.Update(appUpdateResultMsg{err: nil})
- m = modelTmp.(appModel)
- if m.updatingApp {
- t.Error("expected updatingApp to be false after completion")
- }
- if !m.updateSuccess {
- t.Error("expected updateSuccess to be true after nil err result")
- }
- if m.updateError != nil {
- t.Errorf("expected no updateError, got: %v", m.updateError)
+ if cmd != nil {
+ t.Errorf("expected no command on Enter, got: %v", cmd)
}
-
- viewSuccess := m.View()
- if !strings.Contains(viewSuccess, "Update successful") {
- t.Errorf("expected success message in view, got: %s", viewSuccess)
+ if !m.appUpdateModal {
+ t.Error("expected modal to remain open on Enter")
}
- // 5. Esc closes modal
+ // 4. Esc closes modal
modelTmp, cmd = m.Update(tea.KeyMsg{Type: tea.KeyEsc})
m = modelTmp.(appModel)
if m.appUpdateModal {
@@ -125,7 +104,6 @@ func TestTUIAppUpdateModalNonActionable(t *testing.T) {
Status: selfupdate.StatusAvailable,
Channel: "brew",
Confidence: "high",
- CanExecute: false,
CommandPreview: "brew upgrade lazyskills",
Reason: "Homebrew managed install. Please upgrade using Homebrew.",
}
@@ -137,23 +115,23 @@ func TestTUIAppUpdateModalNonActionable(t *testing.T) {
t.Fatal("expected modal to open")
}
- // Check that we see the guidance command instead of an update trigger
+ // Check that we see the guidance command and the manual update text
viewOut := m.View()
- if !strings.Contains(viewOut, "Auto-update is not supported for this install channel.") {
- t.Errorf("expected unsupported guidance, got: %s", viewOut)
+ if !strings.Contains(viewOut, "A newer version of LazySkills is available.") {
+ t.Errorf("expected new version available copy, got: %s", viewOut)
+ }
+ if !strings.Contains(viewOut, "To update manually, run:") {
+ t.Errorf("expected manual update run copy, got: %s", viewOut)
}
if !strings.Contains(viewOut, "brew upgrade lazyskills") {
t.Errorf("expected command preview in guidance view, got: %s", viewOut)
}
- // Pressing Enter does not trigger update since CanExecute is false
+ // Pressing Enter does not trigger update
modelTmp, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = modelTmp.(appModel)
- if m.updatingApp {
- t.Error("should not set updatingApp to true when CanExecute is false")
- }
if cmd != nil {
- t.Error("should not return a command when CanExecute is false")
+ t.Error("should not return a command on Enter")
}
}
@@ -187,58 +165,3 @@ func TestTUIAppUpdateModalStates(t *testing.T) {
t.Errorf("expected error message to be surfaced, got: %s", viewOut)
}
}
-
-func TestTUIAppUpdateModalFailureGuidance(t *testing.T) {
- t.Setenv("XDG_CACHE_HOME", t.TempDir())
- m := newModel("")
- m.width = 100
- m.height = 30
- m.updatePlan = &selfupdate.UpdatePlan{
- Current: "v1.0.0",
- Latest: "v1.1.0",
- Status: selfupdate.StatusAvailable,
- Channel: "manual",
- CanExecute: true,
- }
-
- // 1. Simulate update start
- modelTmp, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("U")})
- m = modelTmp.(appModel)
-
- // Simulate enter to start, then failure
- modelTmp, _ = m.Update(appUpdateResultMsg{err: fmt.Errorf("network disconnect")})
- m = modelTmp.(appModel)
-
- if !m.appUpdateModal {
- t.Fatal("expected modal to remain open on failure")
- }
- if m.updateError == nil || m.updateError.Error() != "network disconnect" {
- t.Errorf("expected updateError to be set to 'network disconnect', got: %v", m.updateError)
- }
-
- viewOut := m.View()
- if !strings.Contains(viewOut, "Update failed") {
- t.Errorf("expected Update failed heading, got: %s", viewOut)
- }
- if !strings.Contains(viewOut, "network disconnect") {
- t.Errorf("expected error message in view, got: %s", viewOut)
- }
-
- // Since we are running the test on the current runtime.GOOS, we check the expected recovery command.
- _, expectedCmd := selfupdate.RecoveryAdvice("manual", runtime.GOOS)
- if !strings.Contains(viewOut, expectedCmd) {
- t.Errorf("expected recovery command %q in view, got: %s", expectedCmd, viewOut)
- }
-
- // 2. Test with a different channel: package manager "brew"
- m.updateError = nil
- m.updatePlan.Channel = "brew"
- modelTmp, _ = m.Update(appUpdateResultMsg{err: fmt.Errorf("brew failure")})
- m = modelTmp.(appModel)
-
- viewOutBrew := m.View()
- _, expectedBrewCmd := selfupdate.RecoveryAdvice("brew", runtime.GOOS)
- if !strings.Contains(viewOutBrew, expectedBrewCmd) {
- t.Errorf("expected brew recovery command %q in view, got: %s", expectedBrewCmd, viewOutBrew)
- }
-}
diff --git a/internal/tui/view.go b/internal/tui/view.go
index d4ac403..1a77391 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -2,7 +2,6 @@ package tui
import (
"fmt"
- "runtime"
"strings"
"sync"
"time"
@@ -1630,13 +1629,13 @@ func (m appModel) appUpdateModalOverlay(layout appLayout) string {
}
var sections []string
- sections = append(sections, titleStyle.Render(" LazySkills App Update "))
+ sections = append(sections, titleStyle.Render(" LazySkills Update "))
sections = append(sections, "")
plan := m.updatePlan
if m.updatePlanErr != nil {
sections = append(sections, errorStyle.Render("✗ Update check failed:"))
- sections = append(sections, wrapText(m.updatePlanErr.Error(), modalWidth-4))
+ sections = append(sections, wrapText(compat.SanitizeMetadata(m.updatePlanErr.Error()), modalWidth-4))
sections = append(sections, "")
sections = append(sections, dimStyle.Render("esc/q close"))
} else if plan == nil {
@@ -1644,63 +1643,42 @@ func (m appModel) appUpdateModalOverlay(layout appLayout) string {
sections = append(sections, "")
sections = append(sections, dimStyle.Render("esc/q close"))
} else {
- sections = append(sections, fmt.Sprintf("Current Version: %s", plan.Current))
- sections = append(sections, fmt.Sprintf("Latest Version: %s", plan.Latest))
- sections = append(sections, fmt.Sprintf("Install Channel: %s", plan.Channel))
+ sections = append(sections, fmt.Sprintf("Current Version: %s", compat.SanitizeMetadata(plan.Current)))
+ sections = append(sections, fmt.Sprintf("Latest Version: %s", compat.SanitizeMetadata(plan.Latest)))
+ sections = append(sections, fmt.Sprintf("Install Channel: %s", compat.SanitizeMetadata(plan.Channel)))
sections = append(sections, "")
- if m.updatingApp {
- sections = append(sections, runningStyle.Render("Updating... Please wait."))
- sections = append(sections, "Downloading archive and verifying checksum...")
- } else if m.updateSuccess {
- sections = append(sections, successStyle.Render("✓ Update successful!"))
- sections = append(sections, "Please restart lazyskills to apply the update.")
- sections = append(sections, "")
- sections = append(sections, dimStyle.Render("esc/q close"))
- } else if m.updateError != nil {
- sections = append(sections, errorStyle.Render("✗ Update failed:"))
- sections = append(sections, wrapText(m.updateError.Error(), modalWidth-4))
+ if plan.Status == selfupdate.StatusAlreadyLatest {
+ sections = append(sections, "You are already running the latest version.")
+ } else if plan.Status == selfupdate.StatusUnknown {
+ sections = append(sections, "Update check status is unknown.")
+ if plan.Reason != "" {
+ sections = append(sections, compat.SanitizeMetadata(plan.Reason))
+ }
+ } else {
+ sections = append(sections, "A newer version of LazySkills is available.")
sections = append(sections, "")
- var channel string
- if plan != nil {
- channel = plan.Channel
+ if plan.ReleaseNotes != "" {
+ sections = append(sections, sectionHeaderStyle.Render("Release Notes:"), truncateReleaseNotes(compat.SanitizePreviewContent(plan.ReleaseNotes), modalWidth-4), "")
}
- instruction, cmd := selfupdate.RecoveryAdvice(channel, runtime.GOOS)
- if cmd != "" {
- sections = append(sections, instruction)
- sections = append(sections, lipgloss.NewStyle().Foreground(lipgloss.Color("141")).Render(" "+cmd))
- sections = append(sections, "")
+
+ if plan.Reason != "" {
+ sections = append(sections, compat.SanitizeMetadata(plan.Reason))
}
- sections = append(sections, dimStyle.Render("enter retry · esc/q close"))
- } else {
- if plan.CanExecute {
- sections = append(sections, "A newer version is available. Would you like to update?")
+ if plan.CommandPreview != "" {
+ sections = append(sections, "To update manually, run:")
+ sections = append(sections, lipgloss.NewStyle().Foreground(lipgloss.Color("141")).Render(" "+compat.SanitizeMetadata(plan.CommandPreview)))
sections = append(sections, "")
- if plan.ReleaseNotes != "" {
- sections = append(sections, sectionHeaderStyle.Render("Release Notes:"), truncateReleaseNotes(plan.ReleaseNotes, modalWidth-4), "")
- }
- sections = append(sections, "enter start update · esc/q cancel")
- } else {
- if plan.Status == selfupdate.StatusAlreadyLatest {
- sections = append(sections, "You are already running the latest version.")
- } else if plan.Status == selfupdate.StatusUnknown {
- sections = append(sections, "Update check status is unknown.")
- sections = append(sections, plan.Reason)
- } else {
- sections = append(sections, "Auto-update is not supported for this install channel.")
- sections = append(sections, plan.Reason)
- if plan.CommandPreview != "" {
- sections = append(sections, "")
- sections = append(sections, "To upgrade, run:")
- sections = append(sections, lipgloss.NewStyle().Foreground(lipgloss.Color("141")).Render(" "+plan.CommandPreview))
- }
- }
+ }
+ if plan.ReleaseURL != "" {
+ sections = append(sections, "For more details and manual downloads, visit:")
+ sections = append(sections, lipgloss.NewStyle().Foreground(lipgloss.Color("39")).Render(" "+compat.SanitizeMetadata(plan.ReleaseURL)))
sections = append(sections, "")
- sections = append(sections, dimStyle.Render("esc/q close"))
}
}
+ sections = append(sections, dimStyle.Render("esc/q close"))
}
box := lipgloss.NewStyle().