mergeable configs + cleanup (#8378)

This commit is contained in:
Jack Amadeo
2026-04-28 16:26:31 -04:00
committed by GitHub
parent 05fa969b17
commit 23d3db445f
10 changed files with 552 additions and 660 deletions
-3
View File
@@ -387,10 +387,7 @@ derive_utoipa!(IconTheme as IconThemeSchema);
super::routes::status::system_info,
super::routes::status::diagnostics,
super::routes::mcp_ui_proxy::mcp_ui_proxy,
super::routes::config_management::backup_config,
super::routes::config_management::recover_config,
super::routes::config_management::validate_config,
super::routes::config_management::init_config,
super::routes::config_management::upsert_config,
super::routes::config_management::remove_config,
super::routes::config_management::read_config,
@@ -515,33 +515,6 @@ pub async fn get_canonical_model_info(
})
}
#[utoipa::path(
post,
path = "/config/init",
responses(
(status = 200, description = "Config initialization check completed", body = String),
(status = 500, description = "Internal server error")
)
)]
pub async fn init_config() -> Result<Json<String>, ErrorResponse> {
let config = Config::global();
if config.exists() {
return Ok(Json("Config already exists".to_string()));
}
// Use the shared function to load init-config.yaml
match goose::config::base::load_init_config_from_workspace() {
Ok(init_values) => {
config.initialize_if_empty(init_values)?;
Ok(Json("Config initialized successfully".to_string()))
}
Err(_) => Ok(Json(
"No init-config.yaml found, using default configuration".to_string(),
)),
}
}
#[utoipa::path(
post,
path = "/config/permissions",
@@ -566,59 +539,6 @@ pub async fn upsert_permissions(
Ok(Json("Permissions updated successfully".to_string()))
}
#[utoipa::path(
post,
path = "/config/backup",
responses(
(status = 200, description = "Config file backed up", body = String),
(status = 500, description = "Internal server error")
)
)]
pub async fn backup_config() -> Result<Json<String>, ErrorResponse> {
let config_path = Paths::config_dir().join("config.yaml");
if !config_path.exists() {
return Err(ErrorResponse::not_found("Config file does not exist"));
}
let file_name = config_path
.file_name()
.ok_or_else(|| ErrorResponse::internal("Invalid config file path"))?;
let mut backup_name = file_name.to_os_string();
backup_name.push(".bak");
let backup = config_path.with_file_name(backup_name);
std::fs::copy(&config_path, &backup)?;
Ok(Json(format!("Copied {:?} to {:?}", config_path, backup)))
}
#[utoipa::path(
post,
path = "/config/recover",
responses(
(status = 200, description = "Config recovery attempted", body = String),
(status = 500, description = "Internal server error")
)
)]
pub async fn recover_config() -> Result<Json<String>, ErrorResponse> {
let config = Config::global();
// Force a reload which will trigger recovery if needed
let values = config.all_values()?;
let recovered_keys: Vec<String> = values.keys().cloned().collect();
if recovered_keys.is_empty() {
Ok(Json("Config recovery completed, but no data was recoverable. Starting with empty configuration.".to_string()))
} else {
Ok(Json(format!(
"Config recovery completed. Recovered {} keys: {}",
recovered_keys.len(),
recovered_keys.join(", ")
)))
}
}
#[utoipa::path(
get,
path = "/config/validate",
@@ -942,9 +862,6 @@ pub fn routes(state: Arc<AppState>) -> Router {
"/config/canonical-model-info",
post(get_canonical_model_info),
)
.route("/config/init", post(init_config))
.route("/config/backup", post(backup_config))
.route("/config/recover", post(recover_config))
.route("/config/validate", get(validate_config))
.route("/config/permissions", post(upsert_permissions))
.route("/config/custom-providers", post(create_custom_provider))
@@ -77,29 +77,6 @@
}
}
},
"/config/backup": {
"post": {
"tags": [
"super::routes::config_management"
],
"operationId": "backup_config",
"responses": {
"200": {
"description": "Config file backed up",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
},
"500": {
"description": "Internal server error"
}
}
}
},
"/config/extensions": {
"get": {
"tags": [
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -12,7 +12,7 @@ pub mod signup_openrouter;
pub mod signup_tetrate;
pub use crate::agents::ExtensionConfig;
pub use base::{Config, ConfigError};
pub use base::{merge_config_values, Config, ConfigError};
pub use declarative_providers::DeclarativeProviderConfig;
pub use experiments::ExperimentManager;
pub use extensions::{