use ai_agent::{Agent, tools::skill::register_skills_from_dir};
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("--- Example 17: Use External Skill with Agent ---\n");
register_skills_from_dir(Path::new("examples/skills"));
println!("Skills registered from examples/skills/");
use ai_agent::tools::skill::get_skill;
if let Some(skill) = get_skill("singer") {
println!("Skill 'singer' loaded: {}", skill.metadata.description);
}
println!("\n--- Agent using Skill tool ---\n");
let agent =
Agent::new(&std::env::var("AI_MODEL").unwrap_or_else(|_| "claude-sonnet-4-6".to_string()))
.max_turns(10);
agent.set_system_prompt(
"You have access to a Skill tool. When user asks to use a skill, invoke it with Skill tool. \
The Skill tool will return the skill content. Read the skill content and use appropriate tools (like Bash) to execute the commands in the skill."
);
let result = agent
.query("Please sing a song using the 'singer' skill. Execute the skill's commands.")
.await?;
println!("--- Agent Response ---\n");
println!("{}", result.text.trim());
println!("\n=== done ===");
Ok(())
}