feat(update): nudge is install-aware and agent-aware

Closes #8319 (closed)

What

Make the post-command "update available" nudge more useful in two ways:

  1. Install-method aware. Inspect os.Executable() (with symlinks resolved) and, when the binary is under a known Homebrew prefix (/opt/homebrew/, /usr/local/Cellar/, /home/linuxbrew/.linuxbrew/) or a go install location ($GOPATH/bin/ or $HOME/go/bin/), include the exact upgrade command in the message. Other paths fall back to release-notes URL only.

  2. Agent aware. When BuildInfo.CodingAgent is non-empty — i.e. one of the agents detected since v1.98.0 in internal/api/coding_agent.go — render the nudge as a single bracketed line agents can relay to their users:

    [glab] Update available: v1.60.0 → v1.62.1 (installed via homebrew). Suggested upgrade command: `brew upgrade glab`. Release notes: https://gitlab.com/gitlab-org/cli/-/releases/v1.62.1

    Otherwise render a multi-line, colored human format with a prominent version diff and a Run: line.

Why

Coding agents do not independently check whether glab is up to date — they simply pass through (or drop) what the binary prints. The previous prose message reads as decorative noise and is frequently swallowed, so a user driving glab through an agent can run an outdated version for months without finding out. Branching on CodingAgent also reinforces the existing agent-detection signal.

See the issue (#8319 (closed)) for the full rationale, design table, and acceptance criteria.

Out of scope (deliberate)

  • No change to the trigger, the 24h throttle, ShouldSkipUpdate, or the silentSuccess behaviour on automatic checks.
  • No new config keys, no structured status file.
  • No detection for snap / apt / dnf / scoop / winget — happy to follow up if there's demand.

Test plan

  • go test ./internal/commands/update/... — all pass (existing + new tests for both formats and both install-method states).

  • golangci-lint run ./... — clean.

  • Smoke-tested all four variants with a synthetic -X main.version=v1.50.0 build:

    • human + homebrew path: prints the four-line block with Run: brew upgrade glab
    • human + unknown path: prints three lines (no Run: line)
    • CLAUDECODE=1 + homebrew path: prints the [glab] Update available: single line with Suggested upgrade command:
    • CLAUDECODE=1 + unknown path: prints the single line with release-notes only
  • Claude Code on behalf of swiskow

Merge request reports

Loading