mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: improve installer handling (#712)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user