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 inquire::{validator::Validation, Text};
use std::{fs::read_to_string, path::Path};
use rust_embed::Embed;
use serde::{Deserialize, Serialize};
use std::{fs::read_to_string, path::Path};
const DEFAULT_AGENT_NAME: &str = "rag";
@@ -34,22 +34,24 @@ pub struct Agent {
impl Agent {
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() {
debug!("Processing agent file: {}", file.as_ref());
let embedded_file = AgentAssets::get(&file).ok_or_else(|| {
anyhow!(
"Failed to load embedded agent file: {}",
file.as_ref()
)
})?;
let embedded_file = AgentAssets::get(&file)
.ok_or_else(|| anyhow!("Failed to load embedded agent file: {}", file.as_ref()))?;
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
let file_path = Config::agents_data_dir().join(file.as_ref());
if file_path.exists() {
debug!("Agent file already exists, skipping: {}", file_path.display());
debug!(
"Agent file already exists, skipping: {}",
file_path.display()
);
continue;
}
+10 -7
View File
@@ -3,6 +3,7 @@ use crate::{
utils::*,
};
use crate::config::ensure_parent_exists;
use crate::mcp::{MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX};
use crate::parsers::{bash, python};
use anyhow::{anyhow, bail, Context, Result};
@@ -20,7 +21,6 @@ use std::{
path::{Path, PathBuf},
};
use strum_macros::AsRefStr;
use crate::config::ensure_parent_exists;
#[derive(Embed)]
#[folder = "assets/functions/"]
@@ -120,7 +120,10 @@ pub struct Functions {
impl Functions {
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() {
debug!("Processing function file: {}", file.as_ref());
@@ -130,16 +133,16 @@ impl Functions {
}
let embedded_file = FunctionAssets::get(&file).ok_or_else(|| {
anyhow!(
"Failed to load embedded function file: {}",
file.as_ref()
)
anyhow!("Failed to load embedded function file: {}", file.as_ref())
})?;
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
let file_path = Config::functions_dir().join(file.as_ref());
if file_path.exists() {
debug!("Function file already exists, skipping: {}", file_path.display());
debug!(
"Function file already exists, skipping: {}",
file_path.display()
);
continue;
}