//! Skills management methods use std::sync::Arc; use zclaw_types::Result; use super::Kernel; impl Kernel { /// Get the skills registry pub fn skills(&self) -> &Arc { &self.skills } /// List all discovered skills pub async fn list_skills(&self) -> Vec { self.skills.list().await } /// Refresh skills from a directory pub async fn refresh_skills(&self, dir: Option) -> Result<()> { if let Some(path) = dir { self.skills.add_skill_dir(path).await?; } else if let Some(ref skills_dir) = self.config.skills_dir { self.skills.add_skill_dir(skills_dir.clone()).await?; } Ok(()) } /// Get the configured skills directory pub fn skills_dir(&self) -> Option<&std::path::PathBuf> { self.config.skills_dir.as_ref() } /// Create a new skill in the skills directory pub async fn create_skill(&self, manifest: zclaw_skills::SkillManifest) -> Result<()> { let skills_dir = self.config.skills_dir.as_ref() .ok_or_else(|| zclaw_types::ZclawError::InvalidInput( "Skills directory not configured".into() ))?; self.skills.create_skill(skills_dir, manifest).await } /// Update an existing skill pub async fn update_skill( &self, id: &zclaw_types::SkillId, manifest: zclaw_skills::SkillManifest, ) -> Result { let skills_dir = self.config.skills_dir.as_ref() .ok_or_else(|| zclaw_types::ZclawError::InvalidInput( "Skills directory not configured".into() ))?; self.skills.update_skill(skills_dir, id, manifest).await } /// Delete a skill pub async fn delete_skill(&self, id: &zclaw_types::SkillId) -> Result<()> { let skills_dir = self.config.skills_dir.as_ref() .ok_or_else(|| zclaw_types::ZclawError::InvalidInput( "Skills directory not configured".into() ))?; self.skills.delete_skill(skills_dir, id).await } /// Execute a skill with the given ID and input pub async fn execute_skill( &self, id: &str, context: zclaw_skills::SkillContext, input: serde_json::Value, ) -> Result { // Inject LLM completer into context for PromptOnly skills let mut ctx = context; if ctx.llm.is_none() { ctx.llm = Some(self.llm_completer.clone()); } self.skills.execute(&zclaw_types::SkillId::new(id), &ctx, input).await } }