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::{Command, BackendContext};
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>(&'a self, ctx: &'a mut BackendContext<'_>) 
20        -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> 
21    {
22        Box::pin(async move {
23            if ctx.skills.is_empty() {
24                let _ = ctx.event_tx.send(crate::AgentEvent::progress(
25                    "无可用技能".to_string(),
26                    None,
27                )).await;
28            } else {
29                let mut info = "🎯 可用技能:\n\n".to_string();
30                for skill in ctx.skills {
31                    info.push_str(&format!("  • {} - {}\n", skill.name, skill.description));
32                }
33                let _ = ctx.event_tx.send(crate::AgentEvent::progress(info, None)).await;
34            }
35            false
36        })
37    }
38}