fmt: applied uniform formatting across refactored vault code

This commit is contained in:
2026-06-03 11:15:11 -06:00
parent a3f278544a
commit 9efd6a2690
4 changed files with 46 additions and 38 deletions
+14 -11
View File
@@ -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) {
+20 -8
View File
@@ -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 {
+8 -12
View File
@@ -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,
}
}
+4 -7
View File
@@ -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,