use crate::prompts::CTO_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 CtoAgent {
#[allow(dead_code)] tool_registry: Arc<ToolRegistry>,
}
impl CtoAgent {
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 CtoAgent {
fn name(&self) -> &str {
"cto"
}
fn description(&self) -> &str {
"Technical leadership agent for code quality, best practices, and strategic decisions"
}
fn system_prompt(&self) -> &str {
CTO_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" }
},
"required": ["path"]
})),
ToolDefinition::new("search_code", "Search for patterns in codebase")
.with_parameters(serde_json::json!({
"type": "object",
"properties": {
"pattern": { "type": "string", "description": "Search pattern" },
"path": { "type": "string", "description": "Directory to search" }
},
"required": ["pattern"]
})),
ToolDefinition::new("git_diff", "Get git diff for review")
.with_parameters(serde_json::json!({
"type": "object",
"properties": {
"target": { "type": "string", "description": "Branch or commit to diff against" }
}
})),
ToolDefinition::new("run_tests", "Run test suite")
.with_parameters(serde_json::json!({
"type": "object",
"properties": {
"path": { "type": "string", "description": "Test path or pattern" },
"verbose": { "type": "boolean", "description": "Show verbose output" }
}
}))
.with_confirmation(true),
ToolDefinition::new("analyze_dependencies", "Analyze project dependencies")
.with_parameters(serde_json::json!({
"type": "object",
"properties": {
"check_updates": { "type": "boolean", "description": "Check for updates" },
"check_vulnerabilities": { "type": "boolean", "description": "Check for security issues" }
}
})),
]
}
async fn run(&self, input: &str, _config: &AgentConfig) -> Result<AgentOutput> {
tracing::info!("CTO agent processing: {}", input);
Ok(AgentOutput {
output: format!(
"CTO analysis for: {}\n\n[This is a placeholder - implement LLM integration]",
input
),
data: None,
tool_calls: vec![],
usage: Usage::default(),
metadata: [("agent".to_string(), "cto".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_cto_agent_creation() {
let agent = CtoAgent::default_agent();
assert_eq!(agent.name(), "cto");
assert!(!agent.tools().is_empty());
}
}