Skip to content

Commit dd78f04

Browse files
committed
feat: add upgrade command
1 parent 96be4f8 commit dd78f04

13 files changed

Lines changed: 373 additions & 57 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,37 +120,21 @@ jobs:
120120

121121
- name: Generate release notes
122122
run: |
123-
cat > release-notes.md <<- NOTES
123+
cat > release-notes.md <<'NOTES'
124124
## Install
125125
126-
### Build from source
126+
### Linux / macOS
127127
128-
\`\`\`bash
129-
git clone https://github.com/${{ github.repository }}.git
130-
cd devo
131-
cargo build --release
128+
```bash
129+
curl -fsSL https://raw.githubusercontent.com/7df-lab/devo/main/install.sh | sh
130+
```
132131
133-
# Linux / macOS
134-
./target/release/devo onboard
135-
136-
# Windows
137-
.\\target\\release\\devo onboard
138-
\`\`\`
139-
140-
### Prebuilt binary
141-
142-
Download the archive for your platform from the Assets section below, extract it, and place the \`devo\` (or \`devo.exe\` on Windows) binary somewhere in your \`PATH\`.
143-
144-
Supported platforms:
145-
- Linux x86_64 (\`x86_64-unknown-linux-musl\`)
146-
- Linux ARM64 (\`aarch64-unknown-linux-musl\`)
147-
- macOS Intel (\`x86_64-apple-darwin\`)
148-
- macOS Apple Silicon (\`aarch64-apple-darwin\`)
149-
- Windows x86_64 (\`x86_64-pc-windows-msvc\`)
132+
### Windows
150133
134+
```powershell
135+
irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
136+
```
151137
---
152-
153-
Full changelog at [commits](https://github.com/${{ github.repository }}/commits/${{ github.ref_name }}).
154138
NOTES
155139
156140
- name: Create release

README.ja.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ Windows:
117117
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
118118
```
119119

120+
既存のインストールを最新 release にアップグレードするには:
121+
122+
```bash
123+
devo upgrade
124+
```
125+
126+
アップグレードコマンドは同じプラットフォーム用インストーラーを実行し、
127+
インストーラーは `Version: v0.1.12 -> v0.1.15` のようにバージョン遷移を表示します。
128+
120129
<details>
121130
<summary>オフラインインストール</summary>
122131

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ Windows:
126126
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
127127
```
128128

129+
Upgrade an existing installation to the latest release:
130+
131+
```bash
132+
devo upgrade
133+
```
134+
135+
The upgrade command runs the same platform installer, and the installer prints
136+
the version transition, for example `Version: v0.1.12 -> v0.1.15`.
137+
129138
<details>
130139
<summary>Offline Installation</summary>
131140

README.ru.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ Windows:
129129
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
130130
```
131131

132+
Обновление существующей установки до последнего release:
133+
134+
```bash
135+
devo upgrade
136+
```
137+
138+
Команда обновления запускает тот же установщик для текущей платформы, а
139+
установщик выводит переход версии, например `Version: v0.1.12 -> v0.1.15`.
140+
132141
<details>
133142
<summary>Офлайн-установка</summary>
134143

README.zh-Hans.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ Windows:
115115
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
116116
```
117117

118+
将现有安装升级到最新 release:
119+
120+
```bash
121+
devo upgrade
122+
```
123+
124+
升级命令会执行同一套平台安装器,安装器会打印版本变化,例如
125+
`Version: v0.1.12 -> v0.1.15`
126+
118127
<details>
119128
<summary>离线安装</summary>
120129

README.zh-Hant.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ Windows:
115115
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
116116
```
117117

118+
將現有安裝升級到最新 release:
119+
120+
```bash
121+
devo upgrade
122+
```
123+
124+
升級命令會執行同一套平台安裝器,安裝器會列印版本變化,例如
125+
`Version: v0.1.12 -> v0.1.15`
126+
118127
<details>
119128
<summary>離線安裝</summary>
120129

apps/web/content/docs/install.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ Preinstall the local Hugging Face model used by semantic `code_search`:
3131
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1 | iex
3232
```
3333

34+
## Upgrade
35+
36+
Upgrade an existing installation to the latest release:
37+
38+
```bash
39+
devo upgrade
40+
```
41+
42+
The upgrade command runs the same platform installer. The installer prints the
43+
version transition, for example `Version: v0.1.12 -> v0.1.15`.
44+
3445
The model is installed under
3546
`<DEVO_HOME>/local-models/minishlab--potion-code-16M`.
3647

apps/web/content/docs/install.zh.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ curl.exe -fsSL https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1 |
3131
$env:DEVO_INSTALL_CODE_SEARCH_MODEL = "1"; irm https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1 | iex
3232
```
3333

34+
## 升级
35+
36+
将现有安装升级到最新 release:
37+
38+
```bash
39+
devo upgrade
40+
```
41+
42+
升级命令会执行同一套平台安装器。安装器会打印版本变化,例如
43+
`Version: v0.1.12 -> v0.1.15`
44+
3445
模型会安装到 `<DEVO_HOME>/local-models/minishlab--potion-code-16M`
3546

3647
## 从源码构建

crates/cli/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ use tracing_subscriber::filter::LevelFilter;
2121
mod agent_command;
2222
mod doctor_command;
2323
mod prompt_command;
24+
mod upgrade_command;
2425

2526
use agent_command::run_agent;
2627
use doctor_command::run_doctor;
2728
use prompt_command::PromptOutputFormat;
2829
use prompt_command::run_prompt;
30+
use upgrade_command::run_upgrade;
2931

3032
/// Top-level `devo` command that dispatches to interactive agent mode or one
3133
/// of the supporting runtime subcommands.
@@ -162,6 +164,7 @@ async fn run_cli() -> Result<()> {
162164
let _logging = install_logging(&cli)?;
163165
run_doctor().await
164166
}
167+
Some(Command::Upgrade) => run_upgrade(),
165168
Some(Command::Resume { session_id }) => {
166169
maybe_print_startup_update(&cli).await;
167170
let _logging = install_logging(&cli)?;
@@ -225,6 +228,8 @@ enum Command {
225228
},
226229
/// Diagnose configuration, provider connectivity, and system health.
227230
Doctor,
231+
/// Upgrade Devo to the latest released version.
232+
Upgrade,
228233
/// Start the runtime server process.
229234
#[command(hide = true)]
230235
Server {
@@ -467,6 +472,16 @@ mod tests {
467472
}
468473
}
469474

475+
#[test]
476+
fn cli_parses_upgrade_subcommand() {
477+
let cli = Cli::try_parse_from(["devo", "upgrade"]).expect("parse upgrade");
478+
479+
match cli.command {
480+
Some(Command::Upgrade) => {}
481+
other => panic!("expected upgrade command, got {other:?}"),
482+
}
483+
}
484+
470485
#[test]
471486
fn exit_messages_includes_usage_and_resume_hint() {
472487
let session_id = SessionId::new();

crates/cli/src/upgrade_command.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
use std::process::Command;
2+
3+
use anyhow::Context;
4+
use anyhow::Result;
5+
use anyhow::bail;
6+
7+
#[cfg(not(windows))]
8+
const INSTALL_SH_URL: &str = "https://raw.githubusercontent.com/7df-lab/devo/main/install.sh";
9+
#[cfg(windows)]
10+
const INSTALL_PS1_URL: &str = "https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1";
11+
12+
pub fn run_upgrade() -> Result<()> {
13+
run_platform_upgrade()
14+
}
15+
16+
#[cfg(not(windows))]
17+
fn run_platform_upgrade() -> Result<()> {
18+
let status = Command::new("sh")
19+
.arg("-c")
20+
.arg(unix_upgrade_script())
21+
.status()
22+
.context("run install.sh for devo upgrade")?;
23+
24+
if !status.success() {
25+
bail!("devo upgrade failed with status {status}");
26+
}
27+
28+
Ok(())
29+
}
30+
31+
#[cfg(not(windows))]
32+
fn unix_upgrade_script() -> String {
33+
format!(
34+
r#"set -eu
35+
command -v curl >/dev/null 2>&1 || {{
36+
printf '%s\n' "Error: 'curl' is required but not installed." >&2
37+
exit 1
38+
}}
39+
tmp_dir="$(mktemp -d "${{TMPDIR:-/tmp}}/devo-upgrade.XXXXXX")"
40+
trap 'rm -rf "$tmp_dir"' EXIT INT TERM
41+
curl -fsSL '{INSTALL_SH_URL}' -o "$tmp_dir/install.sh"
42+
sh "$tmp_dir/install.sh"
43+
"#
44+
)
45+
}
46+
47+
#[cfg(windows)]
48+
fn run_platform_upgrade() -> Result<()> {
49+
use std::process::Stdio;
50+
51+
let parent_pid = std::process::id();
52+
Command::new("powershell.exe")
53+
.args([
54+
"-NoProfile",
55+
"-ExecutionPolicy",
56+
"Bypass",
57+
"-Command",
58+
&windows_upgrade_script(parent_pid),
59+
])
60+
.stdin(Stdio::null())
61+
.spawn()
62+
.context("start install.ps1 for devo upgrade")?;
63+
64+
println!("Started devo upgrade with install.ps1.");
65+
println!("The installer will continue after this devo.exe process exits.");
66+
Ok(())
67+
}
68+
69+
#[cfg(windows)]
70+
fn windows_upgrade_script(parent_pid: u32) -> String {
71+
format!(
72+
r#"$ErrorActionPreference = 'Stop'
73+
$parent = Get-Process -Id {parent_pid} -ErrorAction SilentlyContinue
74+
if ($parent) {{
75+
Wait-Process -Id {parent_pid}
76+
}}
77+
$script = Invoke-WebRequest -UseBasicParsing -Uri '{INSTALL_PS1_URL}'
78+
Invoke-Expression $script.Content
79+
"#
80+
)
81+
}

0 commit comments

Comments
 (0)