From 5ebf8649a6886a1613382aa074d83c05fab5ded2 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Wed, 3 Jun 2026 11:15:11 -0600 Subject: [PATCH] fmt: applied uniform formatting across refactored vault code --- src/config/request_context.rs | 25 ++++++++++++++----------- src/graph/validator.rs | 28 ++++++++++++++++++++-------- src/vault/mod.rs | 20 ++++++++------------ src/vault/utils.rs | 11 ++++------- 4 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/config/request_context.rs b/src/config/request_context.rs index cf1f68b..c85faf5 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -14,8 +14,8 @@ use super::{ use super::{MessageContentToolCalls, prompts}; use crate::client::{Model, ModelType, list_models}; use crate::function::{ - FunctionDeclaration, Functions, ToolCallTracker, ToolResult, - skill::SKILL_FUNCTION_PREFIX, user_interaction::USER_FUNCTION_PREFIX, + FunctionDeclaration, Functions, ToolCallTracker, ToolResult, skill::SKILL_FUNCTION_PREFIX, + user_interaction::USER_FUNCTION_PREFIX, }; use crate::mcp::{ MCP_DESCRIBE_META_FUNCTION_NAME_PREFIX, MCP_INVOKE_META_FUNCTION_NAME_PREFIX, @@ -910,7 +910,10 @@ impl RequestContext { match &app.secrets_provider { None => { items.push(("secrets_provider", "local".to_string())); - items.push(("vault_password_file", display_path(&app.vault_password_file()))); + items.push(( + "vault_password_file", + display_path(&app.vault_password_file()), + )); } Some(provider) => { items.push(("secrets_provider", provider.to_string())); @@ -1930,13 +1933,11 @@ impl RequestContext { super::map_completion_values(values) } ".macro" => super::map_completion_values(paths::list_macros()), - ".skill" => { - super::map_completion_values(vec![ - "loaded".to_string(), - "load".to_string(), - "unload".to_string(), - ]) - } + ".skill" => super::map_completion_values(vec![ + "loaded".to_string(), + "load".to_string(), + "unload".to_string(), + ]), ".starter" => match &self.agent { Some(agent) => agent .conversation_starters() @@ -2568,7 +2569,9 @@ impl RequestContext { pub async fn load_skill_repl(&mut self, name: &str, abort_signal: AbortSignal) -> Result<()> { if !self.app.config.function_calling_support { - bail!("Skills require function calling, which is disabled. Enable function calling in your config then try again."); + bail!( + "Skills require function calling, which is disabled. Enable function calling in your config then try again." + ); } if !paths::has_skill(name) { diff --git a/src/graph/validator.rs b/src/graph/validator.rs index d92dc20..c209c29 100644 --- a/src/graph/validator.rs +++ b/src/graph/validator.rs @@ -1008,7 +1008,10 @@ mod tests { #[test] fn llm_node_skill_in_graph_set_passes() { let mut graph = graph_with( - vec![("l", llm_node("l", None, Some("end"))), ("end", end_node("end"))], + vec![ + ("l", llm_node("l", None, Some("end"))), + ("end", end_node("end")), + ], "l", ); graph.enabled_skills = Some(vec!["code-review".into(), "git-master".into()]); @@ -1031,7 +1034,10 @@ mod tests { #[test] fn llm_node_skill_not_in_graph_set_errors() { let mut graph = graph_with( - vec![("l", llm_node("l", None, Some("end"))), ("end", end_node("end"))], + vec![ + ("l", llm_node("l", None, Some("end"))), + ("end", end_node("end")), + ], "l", ); graph.enabled_skills = Some(vec!["code-review".into()]); @@ -1043,10 +1049,10 @@ mod tests { assert!(!result.is_valid()); assert!( - result.errors.iter().any(|e| e - .message - .contains("'git-master'") - && e.message.contains("graph-level")), + result + .errors + .iter() + .any(|e| e.message.contains("'git-master'") && e.message.contains("graph-level")), "expected git-master subset error, got: {:?}", result.errors ); @@ -1055,7 +1061,10 @@ mod tests { #[test] fn llm_node_empty_skill_name_errors() { let mut graph = graph_with( - vec![("l", llm_node("l", None, Some("end"))), ("end", end_node("end"))], + vec![ + ("l", llm_node("l", None, Some("end"))), + ("end", end_node("end")), + ], "l", ); graph.enabled_skills = Some(vec!["code-review".into()]); @@ -1079,7 +1088,10 @@ mod tests { #[test] fn llm_node_skill_when_no_graph_set_is_permitted_by_validator() { let mut graph = graph_with( - vec![("l", llm_node("l", None, Some("end"))), ("end", end_node("end"))], + vec![ + ("l", llm_node("l", None, Some("end"))), + ("end", end_node("end")), + ], "l", ); if let NodeType::Llm(ref mut n) = graph.nodes.get_mut("l").unwrap().node_type { diff --git a/src/vault/mod.rs b/src/vault/mod.rs index 9cebd75..bc3ad0d 100644 --- a/src/vault/mod.rs +++ b/src/vault/mod.rs @@ -162,18 +162,14 @@ impl Vault { SupportedProvider::AwsSecretsManager { .. } => Some( "Try `aws sso login` (for SSO setups) or `aws configure` (for static keys), then retry.", ), - SupportedProvider::GcpSecretManager { .. } => Some( - "Try `gcloud auth application-default login`, then retry.", - ), - SupportedProvider::AzureKeyVault { .. } => Some( - "Try `az login`, then retry.", - ), - SupportedProvider::Gopass { .. } => Some( - "Make sure `gopass init` has been run and `gopass` is on your PATH.", - ), - SupportedProvider::OnePassword { .. } => Some( - "Try `op signin`, then retry.", - ), + SupportedProvider::GcpSecretManager { .. } => { + Some("Try `gcloud auth application-default login`, then retry.") + } + SupportedProvider::AzureKeyVault { .. } => Some("Try `az login`, then retry."), + SupportedProvider::Gopass { .. } => { + Some("Make sure `gopass init` has been run and `gopass` is on your PATH.") + } + SupportedProvider::OnePassword { .. } => Some("Try `op signin`, then retry."), SupportedProvider::Local { .. } => None, } } diff --git a/src/vault/utils.rs b/src/vault/utils.rs index 9445666..023fadf 100644 --- a/src/vault/utils.rs +++ b/src/vault/utils.rs @@ -2,6 +2,7 @@ use crate::config::ensure_parent_exists; use crate::vault::{SECRET_RE, Vault}; use anyhow::Result; use anyhow::anyhow; +use gman::SecretError; use gman::providers::SupportedProvider; use gman::providers::aws_secrets_manager::AwsSecretsManagerProvider; use gman::providers::azure_key_vault::AzureKeyVaultProvider; @@ -14,7 +15,6 @@ use inquire::validator::Validation; use inquire::{Confirm, Password, PasswordDisplayMode, Select, Text, min_length, required}; use std::path::PathBuf; use std::process::Command; -use gman::SecretError; pub fn ensure_password_file_initialized(local_provider: &mut LocalProvider) -> Result<()> { let vault_password_file = local_provider @@ -322,9 +322,7 @@ fn advisory_preflight(label: &str, cli: &str, args: &[&str]) { if !stderr.trim().is_empty() { eprintln!(" {}", stderr.trim()); } - eprintln!( - " Setup will continue. Fix authentication before using --add-secret etc." - ); + eprintln!(" Setup will continue. Fix authentication before using --add-secret etc."); } Err(_) => { eprintln!( @@ -375,9 +373,8 @@ pub fn interpolate_secrets(content: &str, vault: &Vault) -> Result<(String, Vec< String::new() } Some(SecretError::AuthFailed { .. }) => { - let base = format!( - "Failed to fetch secret '{name}' from vault: {e}" - ); + let base = + format!("Failed to fetch secret '{name}' from vault: {e}"); let msg = match vault.auth_hint() { Some(hint) => format!("{base}\n\nHint: {hint}"), None => base,