fix: improve installer handling (#712)

This commit is contained in:
Bradley Axen
2025-01-23 12:06:28 -08:00
committed by GitHub
parent 9de5f1a515
commit 902dc86de1
3 changed files with 43 additions and 35 deletions
+28 -21
View File
@@ -24,23 +24,30 @@ pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
);
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<dyn Error>> {
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<dyn Error>> {
pub async fn configure_provider_dialog() -> Result<bool, Box<dyn Error>> {
// Get global config instance
let config = Config::global();
@@ -208,15 +215,15 @@ pub async fn configure_provider_dialog() -> Result<(), Box<dyn Error>> {
}
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
+5
View File
@@ -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()
+10 -14
View File
@@ -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