use crate::prompts::ARCHITECT_PROMPT;
use crate::tools::ToolRegistry;
use crate::traits::{
AgentConfig, AgentError, AgentOutput, Result, SpecializedAgent, ToolDefinition, Usage,
};
use async_trait::async_trait;
use std::sync::Arc;
pub struct ArchitectAgent {
#[allow(dead_code)] tool_registry: Arc<ToolRegistry>,
}
impl ArchitectAgent {
pub fn new(tool_registry: Arc<ToolRegistry>) -> Self {
Self { tool_registry }
}
pub fn default_agent() -> Self {
Self::new(Arc::new(ToolRegistry::with_defaults()))
}
}
#[async_trait]
impl SpecializedAgent for ArchitectAgent {
fn name(&self) -> &str {
"architect"
}
fn description(&self) -> &str {
"Expert software architect for system design and architectural decisions"
}
fn system_prompt(&self) -> &str {
ARCHITECT_PROMPT
}
fn tools(&self) -> Vec<ToolDefinition> {
vec![
ToolDefinition::new("read_file", "Read contents of a file").with_parameters(
serde_json::json!({
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path to the file to read"
}
},
"required": ["path"]
}),
),
ToolDefinition::new("search_code", "Search for patterns in the codebase")
.with_parameters(serde_json::json!({
"type": "object",
"properties": {
"pattern": {
"type": "string",
"description": "Search pattern (regex supported)"
},
"path": {
"type": "string",
"description": "Directory to search in"
}
},
"required": ["pattern"]
})),
ToolDefinition::new("list_directory", "List files in a directory").with_parameters(
serde_json::json!({
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Directory path"
},
"recursive": {
"type": "boolean",
"description": "Whether to list recursively"
}
},
"required": ["path"]
}),
),
]
}
async fn run(&self, input: &str, _config: &AgentConfig) -> Result<AgentOutput> {
tracing::info!("Architect agent processing: {}", input);
Ok(AgentOutput {
output: format!(
"Architect analysis for: {}\n\n[This is a placeholder - implement LLM integration]",
input
),
data: None,
tool_calls: vec![],
usage: Usage::default(),
metadata: [("agent".to_string(), "architect".to_string())]
.into_iter()
.collect(),
})
}
async fn run_streaming(
&self,
_input: &str,
_config: &AgentConfig,
) -> Result<Box<dyn futures::Stream<Item = Result<String>> + Send + Unpin>> {
Err(AgentError::Other(
"Streaming not yet implemented".to_string(),
))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_architect_agent_creation() {
let agent = ArchitectAgent::default_agent();
assert_eq!(agent.name(), "architect");
assert!(!agent.tools().is_empty());
}
}