feat: created built-in functions for listing, loading, and unloading skills

This commit is contained in:
2026-06-01 12:58:42 -06:00
parent aa2e627a5f
commit cdc4bd154a
5 changed files with 334 additions and 7 deletions
+6
View File
@@ -1,5 +1,6 @@
use super::rag_cache::{RagCache, RagKey};
use super::session::Session;
use super::skill_registry::SkillRegistry;
use super::todo::TodoList;
use super::tool_scope::{McpRuntime, ToolScope};
use super::{
@@ -82,6 +83,7 @@ pub struct RequestContext {
pub current_depth: usize,
pub auto_continue_count: usize,
pub todo_list: TodoList,
pub skill_registry: SkillRegistry,
pub last_continuation_response: Option<String>,
pub render_mode: RenderMode,
@@ -110,6 +112,7 @@ impl RequestContext {
current_depth: 0,
auto_continue_count: 0,
todo_list: TodoList::default(),
skill_registry: SkillRegistry::default(),
last_continuation_response: None,
render_mode: RenderMode::default(),
}
@@ -157,6 +160,7 @@ impl RequestContext {
current_depth: 0,
auto_continue_count: 0,
todo_list: TodoList::default(),
skill_registry: SkillRegistry::default(),
last_continuation_response: None,
render_mode: RenderMode::default(),
})
@@ -198,6 +202,7 @@ impl RequestContext {
current_depth: self.current_depth,
auto_continue_count: 0,
todo_list: self.todo_list.clone(),
skill_registry: self.skill_registry.clone(),
last_continuation_response: None,
render_mode: self.render_mode,
}
@@ -237,6 +242,7 @@ impl RequestContext {
current_depth,
auto_continue_count: 0,
todo_list: TodoList::default(),
skill_registry: SkillRegistry::default(),
last_continuation_response: None,
render_mode: parent.render_mode,
}
+2
View File
@@ -123,9 +123,11 @@ impl Skill {
if self.declares_tools() && !function_calling_enabled {
return false;
}
if self.declares_mcp_servers() && !mcp_enabled {
return false;
}
true
}
+13 -7
View File
@@ -6,6 +6,7 @@ use indexmap::IndexMap;
use std::collections::BTreeSet;
#[allow(dead_code)]
#[derive(Clone, Default)]
pub struct SkillRegistry {
loaded: IndexMap<String, Skill>,
}
@@ -22,13 +23,24 @@ impl SkillRegistry {
if self.loaded.contains_key(name) {
bail!("Skill '{name}' is already loaded");
}
let skill = Skill::load(name)?;
self.loaded.insert(name.to_string(), skill);
Ok(())
}
pub fn insert(&mut self, skill: Skill) -> Result<()> {
let name = skill.name().to_string();
if self.loaded.contains_key(&name) {
bail!("Skill '{name}' is already loaded");
}
self.loaded.insert(name, skill);
Ok(())
}
pub fn unload(&mut self, name: &str) -> Result<()> {
if self.loaded.shift_remove(name).is_none() {
bail!("Skill '{name}' is not loaded");
@@ -85,12 +97,6 @@ impl SkillRegistry {
}
}
impl Default for SkillRegistry {
fn default() -> Self {
Self::new()
}
}
fn parse_csv(s: Option<&str>) -> BTreeSet<String> {
let mut set = BTreeSet::new();
if let Some(raw) = s {