Skip to content

Add auto-update feature behind opt-in global setting#981

Closed
gtrrz-victor wants to merge 6 commits intomainfrom
add-auto-aupdate
Closed

Add auto-update feature behind opt-in global setting#981
gtrrz-victor wants to merge 6 commits intomainfrom
add-auto-aupdate

Conversation

@gtrrz-victor
Copy link
Copy Markdown
Contributor

@gtrrz-victor gtrrz-victor commented Apr 18, 2026

Example

Screenshot 2026-04-21 at 5 00 01 pm

Summary

  • When the existing daily version check flags an outdated release, the CLI prints the usual notification and then asks "Install the new version now? [Y/n]".
  • Accepting runs whatever command versioncheck.updateCommand(current) resolves to (brew upgrade --cask entire[@nightly], mise upgrade entire, scoop update entire/cli, or the curl-pipe-bash fallback). stdin/stdout/stderr stream through so installer prompts and progress reach the user.
  • Declining skips the upgrade; the 24h version-check cache keeps the prompt from repeating more than once per day.
  • Guardrails: stdout must be a TTY, CI must be empty, ENTIRE_NO_AUTO_UPDATE=1 is a kill switch.

Test plan

  • mise run check green locally (unit + integration + canary)
  • Unit: TTY gate, CI gate, kill-switch, user-declines, happy path, installer failure
  • Manual end-to-end on a real outdated brew install (reviewer)
  • Windows scoop path verification (deferred)

Non-goals

  • No silent auto-install mode — prompt is always interactive.
  • No persisted preference / subcommands — kill-switch env is the escape hatch.
  • No self-built binary download; shells out to the native installer.

See docs/architecture/auto-update.md.

🤖 Generated with Claude Code


Note

Medium Risk
Adds an interactive flow that can shell out to OS installer commands (e.g., brew/sh/cmd) and also introduces git diff subprocess usage for checkpoint carry-forward detection, so behavior now depends on external tooling and environment conditions.

Overview
When the daily version check detects the CLI is outdated, it now prompts interactively to install the update and (on confirmation) runs the resolved installer command via a subprocess, with guardrails for non-TTY, CI, and ENTIRE_NO_AUTO_UPDATE.

Checkpoint carry-forward detection is adjusted to first consult git diff --quiet (with a short timeout) before byte-level hashing, preventing false “remaining changes” when Git clean/smudge filters like core.autocrlf normalize line endings; corresponding tests and an auto-update architecture doc are added.

Reviewed by Cursor Bugbot for commit 39034c3. Configure here.

Soph and others added 3 commits April 10, 2026 14:04
Entire-Checkpoint: 5e0e77648a11
The call chain from PostCommit passes an unbounded context, so
workingTreeMatchesCommit could block forever on a hung git process.
Thread the caller's context through and wrap it with a 5s timeout,
matching the pattern used by resolveWorktreeBranchGit for similar
local git operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 8b5b4eca788e
Offers codex-style "update now?" UX once per day after the existing
version check detects a newer release. Default stays off so nothing
changes for users who haven't opted in.

- New ~/.config/entire/settings.json with `auto_update: off|prompt|auto`
  (default off).
- install.sh now records install provenance at ~/.config/entire/install.json
  so "auto" mode can trust the resolved installer command. Legacy path
  heuristic remains the fallback for notification-only.
- `entire auto-update {status|enable|disable|set <mode>}` manages the flag.
- `entire update [--yes] [--check-only]` runs the installer on demand.
- Guardrails: TTY + non-CI + kill-switch (ENTIRE_NO_AUTO_UPDATE) required;
  "auto" additionally requires provenance-resolved command, a 24h release
  soak, and 24h backoff after any failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: a5512c4eb581
Copilot AI review requested due to automatic review settings April 18, 2026 17:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in, machine-wide auto-update mechanism to Entire CLI by introducing global settings + installer provenance so the CLI can safely resolve the correct updater command (brew/scoop/install.sh) and optionally execute it after the daily version check.

Changes:

  • Introduce global settings at ~/.config/entire/settings.json with auto_update modes (off|prompt|auto) and add entire auto-update ... management command.
  • Add entire update [--yes] [--check-only] and implement provenance-based update command resolution via ~/.config/entire/install.json (with legacy executable-path fallback).
  • Extend version check flow to fetch full release metadata and optionally trigger auto-update; add guardrail/backoff/soak logic and tests.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
scripts/install.sh Writes install provenance (~/.config/entire/install.json) after successful install.
docs/architecture/install-provenance.md Documents provenance file format and update-command mapping.
docs/architecture/auto-update.md Documents auto-update settings, guardrails, and behavior.
cmd/entire/cli/versioncheck/versioncheck.go Switches version fetch to return GitHubRelease, adds provenance-based update command resolution.
cmd/entire/cli/versioncheck/types.go Extends cache + release types; adds InstallProvenance and new cache fields.
cmd/entire/cli/versioncheck/autoupdate.go Implements auto-update execution path + RunUpdateNow.
cmd/entire/cli/versioncheck/autoupdate_test.go Adds tests for auto-update guardrails/soak/backoff and manual update path.
cmd/entire/cli/versioncheck/versioncheck_test.go Updates existing tests for new release-fetch APIs; adds provenance-based update hint tests.
cmd/entire/cli/settings/global.go Adds global settings read/write helpers + validation.
cmd/entire/cli/settings/global_test.go Tests global settings defaults, persistence, and validation.
cmd/entire/cli/auto_update.go Adds `entire auto-update {status
cmd/entire/cli/auto_update_test.go Tests auto-update CLI command behavior and persistence.
cmd/entire/cli/update.go Adds entire update command wrapper around RunUpdateNow.
cmd/entire/cli/update_test.go Tests entire update --check-only output using seeded provenance.
cmd/entire/cli/root.go Registers new auto-update and update commands.
cmd/entire/cli/strategy/content_overlap.go Uses git diff --quiet to avoid CRLF normalization false-positives when deciding carry-forward files.
cmd/entire/cli/strategy/content_overlap_test.go Adds regression test for core.autocrlf normalized working tree.

Comment thread cmd/entire/cli/versioncheck/autoupdate.go Outdated
Comment thread cmd/entire/cli/versioncheck/autoupdate.go Outdated
Comment thread scripts/install.sh Outdated
Comment thread cmd/entire/cli/versioncheck/versioncheck.go Outdated
runErr := runInstaller(ctx, cmdStr)
recordUpdateAttempt(ctx, runErr == nil)
if runErr != nil {
fmt.Fprintf(w, "Update failed: %v\n", runErr)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaybeAutoUpdate is documented as being silent on error paths, but when runInstaller fails it prints Update failed: ... to w. This can add unexpected user-facing output on failures; if the goal is “never interrupt the CLI”, consider logging the error and returning without printing (or only printing in prompt mode).

Suggested change
fmt.Fprintf(w, "Update failed: %v\n", runErr)
logging.Debug(ctx, "auto-update: installer failed", "error", runErr.Error(), "command", cmdStr)

Copilot uses AI. Check for mistakes.
Comment thread cmd/entire/cli/versioncheck/autoupdate.go Outdated
Comment thread cmd/entire/cli/versioncheck/autoupdate.go Outdated
Comment thread cmd/entire/cli/versioncheck/versioncheck.go Outdated
Comment thread cmd/entire/cli/versioncheck/autoupdate.go Outdated
gtrrz-victor and others added 2 commits April 18, 2026 19:31
# Conflicts:
#	cmd/entire/cli/versioncheck/versioncheck.go
#	cmd/entire/cli/versioncheck/versioncheck_test.go
#	scripts/install.sh
Replaces the tri-state mode, global settings file, and two dedicated
subcommands with a single interactive confirm right after the existing
"version available" notification. Declining skips; accepting runs the
same command the notification already prints. The 24h version-check
cache prevents the prompt from repeating more than once per day.

Removed:
- `entire auto-update {status|enable|disable|set}` subcommand
- `entire update [--yes|--check-only]` subcommand
- `GlobalSettings` / ~/.config/entire/settings.json file
- `auto_update` tri-state (off | prompt | auto)
- 24h release soak, failed-attempt retry cooldown
- `VersionCache.LastUpdateAttempt*`, `GitHubRelease.PublishedAt`

Kept:
- TTY + CI + `ENTIRE_NO_AUTO_UPDATE` kill-switch guardrails
- `sh -c` / `cmd /C` installer exec with streamed stdio
- Test seams for `runInstaller`, `stdoutIsTerminal`, `confirmUpdate`

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: e6958d9551ac
@gtrrz-victor gtrrz-victor marked this pull request as ready for review April 21, 2026 15:00
@gtrrz-victor gtrrz-victor requested a review from a team as a code owner April 21, 2026 15:00
@gtrrz-victor
Copy link
Copy Markdown
Contributor Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 39034c3. Configure here.

// Show notification and offer an interactive upgrade when outdated
if isOutdated(currentVersion, latestVersion) {
printNotification(w, currentVersion, latestVersion)
MaybeAutoUpdate(ctx, w, currentVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing CheckAndNotify tests lack auto-update guard

Medium Severity

The new MaybeAutoUpdate call in CheckAndNotify means existing tests like TestCheckAndNotify_PrintsNotificationWhenOutdated now reach the real confirmUpdate / realConfirmUpdate code path. setupCheckAndNotifyTest never sets ENTIRE_NO_AUTO_UPDATE, never mocks stdoutIsTerminal, and never mocks confirmUpdate. The only thing preventing an interactive huh prompt from hanging these tests is the assumption that term.IsTerminal(os.Stdout.Fd()) returns false under go test — which is environment-dependent and fragile. Setting t.Setenv(envKillSwitch, "1") in setupCheckAndNotifyTest (or mocking the seams) would make the tests robust regardless of TTY state.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 39034c3. Configure here.

@gtrrz-victor
Copy link
Copy Markdown
Contributor Author

Superseded by #997 — rebuilt on top of latest main with a clean single-commit history (drops the two unrelated content_overlap commits).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants