style: Applied consistent formatting to agent changes

This commit is contained in:
2025-10-10 14:48:10 -06:00
parent 4bf338f91a
commit f822546971
3 changed files with 82 additions and 77 deletions
+11 -9
View File
@@ -7,9 +7,9 @@ use crate::{
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use inquire::{validator::Validation, Text}; use inquire::{validator::Validation, Text};
use std::{fs::read_to_string, path::Path};
use rust_embed::Embed; use rust_embed::Embed;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fs::read_to_string, path::Path};
const DEFAULT_AGENT_NAME: &str = "rag"; const DEFAULT_AGENT_NAME: &str = "rag";
@@ -34,22 +34,24 @@ pub struct Agent {
impl Agent { impl Agent {
pub fn install_builtin_agents() -> Result<()> { pub fn install_builtin_agents() -> Result<()> {
info!("Installing built-in agents in {}", Config::agents_data_dir().display()); info!(
"Installing built-in agents in {}",
Config::agents_data_dir().display()
);
for file in AgentAssets::iter() { for file in AgentAssets::iter() {
debug!("Processing agent file: {}", file.as_ref()); debug!("Processing agent file: {}", file.as_ref());
let embedded_file = AgentAssets::get(&file).ok_or_else(|| { let embedded_file = AgentAssets::get(&file)
anyhow!( .ok_or_else(|| anyhow!("Failed to load embedded agent file: {}", file.as_ref()))?;
"Failed to load embedded agent file: {}",
file.as_ref()
)
})?;
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) }; let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
let file_path = Config::agents_data_dir().join(file.as_ref()); let file_path = Config::agents_data_dir().join(file.as_ref());
if file_path.exists() { if file_path.exists() {
debug!("Agent file already exists, skipping: {}", file_path.display()); debug!(
"Agent file already exists, skipping: {}",
file_path.display()
);
continue; continue;
} }
+10 -7
View File
@@ -3,6 +3,7 @@ use crate::{
utils::*, utils::*,
}; };
use crate::config::ensure_parent_exists;
use crate::mcp::{MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX}; use crate::mcp::{MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX};
use crate::parsers::{bash, python}; use crate::parsers::{bash, python};
use anyhow::{anyhow, bail, Context, Result}; use anyhow::{anyhow, bail, Context, Result};
@@ -20,7 +21,6 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use strum_macros::AsRefStr; use strum_macros::AsRefStr;
use crate::config::ensure_parent_exists;
#[derive(Embed)] #[derive(Embed)]
#[folder = "assets/functions/"] #[folder = "assets/functions/"]
@@ -120,7 +120,10 @@ pub struct Functions {
impl Functions { impl Functions {
fn install_global_tools() -> Result<()> { fn install_global_tools() -> Result<()> {
info!("Installing global built-in functions in {}", Config::functions_dir().display()); info!(
"Installing global built-in functions in {}",
Config::functions_dir().display()
);
for file in FunctionAssets::iter() { for file in FunctionAssets::iter() {
debug!("Processing function file: {}", file.as_ref()); debug!("Processing function file: {}", file.as_ref());
@@ -130,16 +133,16 @@ impl Functions {
} }
let embedded_file = FunctionAssets::get(&file).ok_or_else(|| { let embedded_file = FunctionAssets::get(&file).ok_or_else(|| {
anyhow!( anyhow!("Failed to load embedded function file: {}", file.as_ref())
"Failed to load embedded function file: {}",
file.as_ref()
)
})?; })?;
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) }; let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
let file_path = Config::functions_dir().join(file.as_ref()); let file_path = Config::functions_dir().join(file.as_ref());
if file_path.exists() { if file_path.exists() {
debug!("Function file already exists, skipping: {}", file_path.display()); debug!(
"Function file already exists, skipping: {}",
file_path.display()
);
continue; continue;
} }