Skip to main content

matrixcode_core/command/handlers/
skills.rs

1//! /skills 命令处理器
2
3use std::future::Future;
4use std::pin::Pin;
5
6use crate::command::{BackendContext, Command};
7
8pub struct Skills;
9
10impl Command for Skills {
11    fn name(&self) -> &'static str {
12        "skills"
13    }
14
15    fn help(&self) -> Option<&'static str> {
16        Some("列出可用技能")
17    }
18
19    fn execute<'a>(
20        &'a self,
21        ctx: &'a mut BackendContext<'_>,
22    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> {
23        Box::pin(async move {
24            if ctx.skills.is_empty() {
25                let _ = ctx
26                    .event_tx
27                    .send(crate::AgentEvent::progress("无可用技能".to_string(), None))
28                    .await;
29            } else {
30                let mut info = "🎯 可用技能:\n\n".to_string();
31                for skill in ctx.skills {
32                    info.push_str(&format!("  • {} - {}\n", skill.name, skill.description));
33                }
34                let _ = ctx
35                    .event_tx
36                    .send(crate::AgentEvent::progress(info, None))
37                    .await;
38            }
39            false
40        })
41    }
42}