diff --git a/crates/goose-cli/src/commands/mod.rs b/crates/goose-cli/src/commands/mod.rs index 850f19a39..f0107e8fb 100644 --- a/crates/goose-cli/src/commands/mod.rs +++ b/crates/goose-cli/src/commands/mod.rs @@ -2,3 +2,4 @@ pub mod agent_version; pub mod configure; pub mod info; pub mod mcp; +pub mod update; diff --git a/crates/goose-cli/src/commands/update.rs b/crates/goose-cli/src/commands/update.rs new file mode 100644 index 000000000..158932f91 --- /dev/null +++ b/crates/goose-cli/src/commands/update.rs @@ -0,0 +1,34 @@ +use std::process::Command; + +use anyhow::Result; + +const DOWNLOAD_SCRIPT_URL: &str = + "https://github.com/block/goose/releases/download/stable/download_cli.sh"; + +pub fn update(canary: bool, reconfigure: bool) -> Result<()> { + // Get the download script from github + let curl_output = Command::new("curl") + .arg("-fsSL") + .arg(DOWNLOAD_SCRIPT_URL) + .output()?; + + if !curl_output.status.success() { + anyhow::bail!( + "Failed to download update script: {}", + std::str::from_utf8(&curl_output.stderr)? + ); + } + + let shell_str = std::str::from_utf8(&curl_output.stdout)?; + + let update = Command::new("bash") + .arg("-c") + .arg(shell_str) + .env("CANARY", canary.to_string()) + .env("CONFIGURE", reconfigure.to_string()) + .spawn()?; + + update.wait_with_output()?; + + Ok(()) +} diff --git a/crates/goose-cli/src/main.rs b/crates/goose-cli/src/main.rs index c438caf93..2fb39dbcb 100644 --- a/crates/goose-cli/src/main.rs +++ b/crates/goose-cli/src/main.rs @@ -157,6 +157,23 @@ enum Command { /// List available agent versions Agents(AgentCommand), + + /// Update the Goose CLI version + #[command(about = "Update the goose CLI version")] + Update { + /// Update to canary version + #[arg( + short, + long, + help = "Update to canary version", + long_help = "Update to the latest canary version of the goose CLI, otherwise updates to the latest stable version." + )] + canary: bool, + + /// Enforce to re-configure Goose during update + #[arg(short, long, help = "Enforce to re-configure goose during update")] + reconfigure: bool, + }, } #[derive(clap::ValueEnum, Clone, Debug)] @@ -234,6 +251,13 @@ async fn main() -> Result<()> { cmd.run()?; return Ok(()); } + Some(Command::Update { + canary, + reconfigure, + }) => { + goose_cli::commands::update::update(canary, reconfigure)?; + return Ok(()); + } None => { Cli::command().print_help()?; println!(); diff --git a/documentation/docs/guides/updating-goose.md b/documentation/docs/guides/updating-goose.md index 312555de9..7fb81c70a 100644 --- a/documentation/docs/guides/updating-goose.md +++ b/documentation/docs/guides/updating-goose.md @@ -1,6 +1,7 @@ --- sidebar_position: 2 --- + # Updating Goose import Tabs from '@theme/Tabs'; @@ -12,10 +13,15 @@ import Link from "@docusaurus/Link"; To update Goose to the latest stable version, reinstall using the instructions below ::: - - You can update Goose by running the [installation](/docs/getting-started/installation) script again: + You can update Goose by simply running: + + ```sh + goose update + ``` + + Or you can run the [installation](/docs/getting-started/installation) script again: ```sh curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | CONFIGURE=false bash @@ -49,4 +55,3 @@ To update Goose to the latest stable version, reinstall using the instructions b All configuration settings will remain the same, with Goose updated to the latest version. -