Skip to content

feat(cli): add reasonix update self-update command#3095

Open
lanshi17 wants to merge 16 commits into
esengine:main-v2from
lanshi17:feat/cli-update-command
Open

feat(cli): add reasonix update self-update command#3095
lanshi17 wants to merge 16 commits into
esengine:main-v2from
lanshi17:feat/cli-update-command

Conversation

@lanshi17
Copy link
Copy Markdown
Contributor

@lanshi17 lanshi17 commented Jun 4, 2026

Summary

Add a CLI self-update command (reasonix update) that downloads and applies the latest release from GitHub Releases, addressing the lack of an in-place upgrade mechanism for direct-download users.

Closes #3059

Changes

New files

File Purpose
internal/update/update.go Core self-update logic — GitHub Releases API fetch, semver comparison, SHA256 checksum verification, tar.gz/zip extraction, atomic binary replacement via minio/selfupdate
internal/update/update_test.go Tests for pure functions (normalizeVersion, parseSHA256SUMS, checkSHA256, extractFromTarGz, sumsAssetURL, assetName)
internal/cli/update.go CLI command handler — flag parsing (--dry-run), proxy-aware HTTP client, progress display

Modified files

File Change
internal/cli/cli.go Added "update", "upgrade" case to the command switch
internal/i18n/i18n.go Added 13 update-related message fields to Messages struct
internal/i18n/messages_en.go English translations + reasonix update in usage text
internal/i18n/messages_zh.go Chinese translations + reasonix update in usage text
go.mod / go.sum Added github.com/minio/selfupdate v0.6.0, golang.org/x/mod v0.36.0

Usage

reasonix update              # check + download + apply
reasonix update --dry-run    # check only, no download
reasonix upgrade             # alias

How it works

  1. Queries api.github.com/repos/esengine/DeepSeek-Reasonix/releases/latest
  2. Compares semver against the running version (golang.org/x/mod/semver)
  3. Downloads the platform-matching archive (.tar.gz for Linux/macOS, .zip for Windows)
  4. Verifies SHA256 against the release's SHA256SUMS file
  5. Extracts and atomically replaces the binary (github.com/minio/selfupdate)

Design decisions

  • Reuses existing dependencies (minio/selfupdate, golang.org/x/mod/semver) already in the desktop module — now promoted to the CLI module
  • Git-describe version parsing: handles git describe output like desktop-v1.0.0-105-gf3894d6f by extracting the vX.Y.Z segment
  • Dev builds (version = "dev") are safely rejected with a clear message
  • Pre-release tags are flagged with a warning
  • Proxy-aware: respects the user's network.proxy_* config via netclient
  • i18n: English + Chinese translations, catalog completeness enforced by existing TestCatalogsComplete

Testing

$ go test ./internal/update/ -v
=== RUN   TestNormalizeVersion        --- PASS
=== RUN   TestParseSHA256SUMS         --- PASS
=== RUN   TestCheckSHA256             --- PASS
=== RUN   TestExtractFromTarGz        --- PASS
=== RUN   TestSumsAssetURL            --- PASS
=== RUN   TestAssetName               --- PASS

$ go test ./internal/i18n/ -v
=== RUN   TestCatalogsComplete        --- PASS
$ reasonix update --dry-run
有新版本可用: desktop-v1.0.0-105-gf3894d6f → v1.1.0

lanshi17 added 15 commits June 4, 2026 13:57
Commands now run in the project directory (c.cpRoot), not wherever the
process started. Matches the bash tool's behavior where cmd.Dir is set
to the workspace directory.
TUI:
- Shell commands show first 10 lines after collapse instead of 'N lines'
- Ctrl+B toggles between preview and full output for the most recent shell command
- Input box border turns green and status shows 'Shell' mode tag when typing !

Desktop:
- Shell tool cards auto-expand showing first 10 lines of output
- 'show all N lines' button to reveal full output
- Cmd+B / Ctrl+B toggles the most recent shell card
- Composer caret changes to $ and border turns green in shell mode
- ShellExpandProvider context coordinates global toggle hotkey
- toggleShellOutput now caps expanded output at shellExpandMaxLines (200)
  to prevent huge transcript entries from hanging the TUI or pushing the
  input box off-screen.
- Added shellExpandMaxLines constant alongside shellPreviewLines.
- Ensured innerW fallback when width is very small.
- Mouse left-click on the '… N more lines (click/Ctrl+B)' hint line
  toggles shell output expand/collapse
- Hint text updated to mention click alongside Ctrl+B
- ShellModeHint updated: 'click output to expand' / '点击输出展开'
- Avoids tmux Ctrl+B conflict — mouse click works everywhere
Upstream changed App.ctrl to activeCtrl() for multi-tab support.
- TUI: check empty command before entering tuiRunning state, show usage
  notice directly instead of calling RunShell which would return without
  emitting TurnDone, leaving the TUI stuck in 'thinking' state.
- Desktop: show notice directly for bare !, skip empty RunShell round-trip.
When Esc cancels a running shell command, the cancel may complete
synchronously (the process is killed and runGuarded finishes before
the TUI re-enters the event loop). In that case, ctrl.Running() is
already false and the TUI can transition to idle immediately instead
of waiting for a TurnDone event that may have already been consumed.
Add a CLI self-update command that downloads and applies the latest
release from GitHub Releases:

- `reasonix update` checks for a newer version and replaces the
  running binary in-place (SHA256-verified, atomic via minio/selfupdate)
- `reasonix update --dry-run` reports availability without downloading
- `reasonix upgrade` as a convenience alias

The update flow:
1. Queries GitHub Releases API for the latest release
2. Compares semver against the running version
3. Downloads the platform-matching archive (.tar.gz or .zip)
4. Verifies SHA256 against the release's SHA256SUMS
5. Extracts and atomically replaces the binary

Version parsing handles git-describe output (e.g.
`desktop-v1.0.0-105-gf3894d6f`) by extracting the vX.Y.Z segment.
Dev builds are rejected with a clear message.

Proxy-aware: respects the user's network.proxy_* config via netclient.

Closes esengine#3059
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 添加 reasonix update / reasonix upgrade 自更新命令

1 participant