Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use goose::config::extensions::{
get_all_extension_names, get_all_extensions, get_enabled_extensions, get_extension_by_name,
name_to_key, remove_extension, set_extension, set_extension_enabled,
};
use goose::config::paths::Paths;
use goose::config::permission::PermissionLevel;
use goose::config::signup_tetrate::TetrateAuth;
use goose::config::{
Expand Down Expand Up @@ -195,15 +196,17 @@ pub async fn handle_configure() -> anyhow::Result<()> {
}
Ok(())
} else {
let config_dir = Paths::config_dir().display().to_string();

println!();
println!(
"{}",
style("This will update your existing config file").dim()
style("This will update your existing config files").dim()
);
println!(
"{} {}",
style(" if you prefer, you can edit it directly at").dim(),
config.path()
style(" if you prefer, you can edit them directly at").dim(),
config_dir
);
println!();

Expand Down Expand Up @@ -486,7 +489,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
} else {
config.set_param(&key.name, Value::String(env_value))?;
}
let _ = cliclack::log::info(format!("Saved {} to config file", key.name));
let _ = cliclack::log::info(format!("Saved {} to {}", key.name, config.path()));
}
}
None => {
Expand Down Expand Up @@ -648,7 +651,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
// Update config with new values only if the test succeeds
config.set_param("GOOSE_PROVIDER", Value::String(provider_name.to_string()))?;
config.set_param("GOOSE_MODEL", Value::String(model.clone()))?;
cliclack::outro("Configuration saved successfully")?;
print_config_file_saved()?;
Ok(true)
}
Err(e) => {
Expand Down Expand Up @@ -709,7 +712,11 @@ pub fn toggle_extensions_dialog() -> anyhow::Result<()> {
);
}

cliclack::outro("Extension settings updated successfully")?;
let config = Config::global();
cliclack::outro(format!(
"Extension settings saved successfully to {}",
config.path()
))?;
Ok(())
}

Expand Down Expand Up @@ -1123,6 +1130,8 @@ pub fn configure_extensions_dialog() -> anyhow::Result<()> {
_ => unreachable!(),
};

print_config_file_saved()?;

Ok(())
}

Expand Down Expand Up @@ -1178,6 +1187,8 @@ pub fn remove_extension_dialog() -> anyhow::Result<()> {
cliclack::outro(format!("Removed {} extension", style(name).green()))?;
}

print_config_file_saved()?;

Ok(())
}

Expand Down Expand Up @@ -1216,6 +1227,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
)
.interact()?;

let mut should_print_config_path = true;

match setting_type {
"goose_mode" => {
configure_goose_mode_dialog()?;
Expand All @@ -1225,6 +1238,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
}
"tool_permission" => {
configure_tool_permissions_dialog().await.and(Ok(()))?;
// No need to print config file path since it's already handled.
should_print_config_path = false;
}
"tool_output" => {
configure_tool_output_dialog()?;
Expand All @@ -1241,6 +1256,10 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
_ => unreachable!(),
};

if should_print_config_path {
print_config_file_saved()?;
}

Ok(())
}

Expand Down Expand Up @@ -1547,6 +1566,11 @@ pub async fn configure_tool_permissions_dialog() -> anyhow::Result<()> {
tool.name, permission_label
))?;

cliclack::outro(format!(
"Changes saved to {}",
permission_manager.get_config_path().display()
))?;

Ok(())
}

Expand Down Expand Up @@ -1893,5 +1917,18 @@ pub fn configure_custom_provider_dialog() -> anyhow::Result<()> {
"add" => add_provider(),
"remove" => remove_provider(),
_ => unreachable!(),
}
}?;

print_config_file_saved()?;

Ok(())
}

fn print_config_file_saved() -> anyhow::Result<()> {
let config = Config::global();
cliclack::outro(format!(
"Configuration saved successfully to {}",
config.path()
))?;
Ok(())
}
4 changes: 2 additions & 2 deletions crates/goose-cli/src/commands/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub fn handle_info(verbose: bool) -> Result<()> {

// Get paths using a stored reference to the global config
let config = Config::global();
let config_file = config.path();
let config_dir = Paths::config_dir().display().to_string();

// Define the labels and their corresponding path values once.
let paths = [
("Config file:", config_file.to_string()),
("Config dir:", config_dir),
("Sessions dir:", sessions_dir.display().to_string()),
("Logs dir:", logs_dir.display().to_string()),
];
Expand Down
5 changes: 5 additions & 0 deletions crates/goose/src/config/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ impl PermissionManager {
self.get_permission(SMART_APPROVE_PERMISSION, principal_name)
}

/// Retrieves the config file path.
pub fn get_config_path(&self) -> &Path {
self.config_path.as_path()
}

/// Helper function to retrieve the permission level for a specific permission category and tool.
fn get_permission(&self, name: &str, principal_name: &str) -> Option<PermissionLevel> {
// Check if the permission category exists in the map
Expand Down
Loading