1use super::*;
2
3pub fn auto_mounts(workspace_dir: &Path, existing_mounts: &[MountSpec]) -> Result<Vec<MountSpec>> {
4 let sources = discover_skill_sources(Some(workspace_dir))?;
5 let mut mounts = Vec::new();
6
7 for source in sources {
8 if !source.host_root.exists() {
9 continue;
10 }
11 if existing_mounts
12 .iter()
13 .any(|mount| source.host_root.starts_with(&mount.host))
14 {
15 continue;
16 }
17 if mounts
18 .iter()
19 .any(|mount: &MountSpec| mount.host == source.host_root)
20 {
21 continue;
22 }
23 mounts.push(MountSpec {
24 host: source.host_root,
25 guest: source.guest_root,
26 read_only: true,
27 });
28 }
29
30 Ok(mounts)
31}
32
33pub async fn execute_activate_skill(args: Value, runtime: &ToolRuntime) -> ToolResult {
34 let Some(registry) = &runtime.skills else {
35 return ToolResult {
36 content: "Error: no skills are available".to_string(),
37 is_error: true,
38 };
39 };
40
41 let name = match require_str(&args, "name") {
42 Ok(value) => value,
43 Err(error) => return error,
44 };
45
46 if !registry.has_skill(&name) {
47 return ToolResult {
48 content: format!("Error: unknown skill '{}'", name),
49 is_error: true,
50 };
51 }
52
53 let already_active = {
54 let mut activated = runtime.activated_skills.lock().await;
55 let already_active = activated.contains(&name);
56 if !already_active {
57 activated.insert(name.clone());
58 }
59 already_active
60 };
61
62 registry.activate(&name, already_active)
63}