diff --git a/crates/goose-cli/src/commands/configure.rs b/crates/goose-cli/src/commands/configure.rs index afc8ced40a..5b56f7ab9f 100644 --- a/crates/goose-cli/src/commands/configure.rs +++ b/crates/goose-cli/src/commands/configure.rs @@ -24,23 +24,30 @@ pub async fn handle_configure() -> Result<(), Box> { ); println!(); cliclack::intro(style(" goose-configure ").on_cyan().black())?; - configure_provider_dialog().await?; - println!( - "\n {}: Run '{}' again to adjust your config or add extensions", - style("Tip").green().italic(), - style("goose configure").cyan() - ); - - // Since we are setting up for the first time, we'll also enable the developer system - ExtensionManager::set( - "developer", - ExtensionEntry { - enabled: true, - config: ExtensionConfig::Builtin { - name: "developer".to_string(), + if configure_provider_dialog().await? { + println!( + "\n {}: Run '{}' again to adjust your config or add extensions", + style("Tip").green().italic(), + style("goose configure").cyan() + ); + // Since we are setting up for the first time, we'll also enable the developer system + ExtensionManager::set( + "developer", + ExtensionEntry { + enabled: true, + config: ExtensionConfig::Builtin { + name: "developer".to_string(), + }, }, - }, - )?; + )?; + } else { + let _ = config.clear(); + println!( + "\n {}: We did not save your config, inspect your credentials\n and run '{}' again to ensure goose can connect", + style("Warning").yellow().italic(), + style("goose configure").cyan() + ); + } Ok(()) } else { @@ -74,14 +81,14 @@ pub async fn handle_configure() -> Result<(), Box> { match action { "toggle" => toggle_extensions_dialog(), "add" => configure_extensions_dialog(), - "providers" => configure_provider_dialog().await, + "providers" => configure_provider_dialog().await.and(Ok(())), _ => unreachable!(), } } } /// Dialog for configuring the AI provider and model -pub async fn configure_provider_dialog() -> Result<(), Box> { +pub async fn configure_provider_dialog() -> Result> { // Get global config instance let config = Config::global(); @@ -208,15 +215,15 @@ pub async fn configure_provider_dialog() -> Result<(), Box> { } cliclack::outro("Configuration saved successfully")?; + Ok(true) } Err(e) => { println!("{:?}", e); spin.stop("We could not connect!"); - let _ = cliclack::outro("Try rerunning configure and check your credentials."); + let _ = cliclack::outro("The provider configuration was invalid"); + Ok(false) } } - - Ok(()) } /// Configure extensions that can be used with goose diff --git a/crates/goose/src/config/base.rs b/crates/goose/src/config/base.rs index d8416b2642..15150bfa9f 100644 --- a/crates/goose/src/config/base.rs +++ b/crates/goose/src/config/base.rs @@ -138,6 +138,11 @@ impl Config { self.config_path.exists() } + /// Check if this config already exists + pub fn clear(&self) -> Result<(), ConfigError> { + Ok(std::fs::remove_file(&self.config_path)?) + } + /// Get the path to the configuration file pub fn path(&self) -> String { self.config_path.to_string_lossy().to_string() diff --git a/download_cli.sh b/download_cli.sh index 3c3ce82dc6..cfcad196a7 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -89,22 +89,18 @@ fi echo "Moving goose to $GOOSE_BIN_DIR/$OUT_FILE" mv goose "$GOOSE_BIN_DIR/$OUT_FILE" -# --- 6) Check PATH and give instructions if needed --- -if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then - echo "" - echo "Warning: $GOOSE_BIN_DIR is not in your PATH." - echo "Add it to your PATH by editing ~/.bashrc, ~/.zshrc, or similar:" - echo " export PATH=\"$GOOSE_BIN_DIR:\$PATH\"" - echo "Then reload your shell (e.g. 'source ~/.bashrc', 'source ~/.zshrc') to apply changes." - echo "" -fi - -# --- 7) Configure Goose (Optional) --- +# --- 6) Configure Goose (Optional) --- echo "" echo "Configuring Goose" echo "" "$GOOSE_BIN_DIR/$OUT_FILE" configure -echo "" -echo "Goose installed successfully! Run '$OUT_FILE session' to get started." -echo "" +# --- 7) Check PATH and give instructions if needed --- +if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then + echo "" + echo "Warning: Goose installed, but $GOOSE_BIN_DIR is not in your PATH." + echo "Add it to your PATH by editing ~/.bashrc, ~/.zshrc, or similar:" + echo " export PATH=\"$GOOSE_BIN_DIR:\$PATH\"" + echo "Then reload your shell (e.g. 'source ~/.bashrc', 'source ~/.zshrc') to apply changes." + echo "" +fi