Skip to main content

zeph_commands/handlers/
skill.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Skill command handlers: `/skill`, `/skills`, `/feedback`.
5//!
6//! These handlers delegate to `AgentAccess` methods which in turn call the
7//! `_as_string` variants in `zeph-core`. The clone-before-await pattern in the
8//! `AgentAccess` impl ensures the returned futures are `Send`-safe.
9
10use std::future::Future;
11use std::pin::Pin;
12
13use crate::context::CommandContext;
14use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
15
16/// Load, manage, and create skills.
17///
18/// Subcommands: `stats`, `versions`, `activate`, `approve`, `reset`, `trust`,
19/// `block`, `unblock`, `install`, `remove`, `create`, `scan`, `reject`.
20pub struct SkillCommand;
21
22impl CommandHandler<CommandContext<'_>> for SkillCommand {
23    fn name(&self) -> &'static str {
24        "/skill"
25    }
26
27    fn description(&self) -> &'static str {
28        "Load and display a skill body, or manage skill lifecycle"
29    }
30
31    fn args_hint(&self) -> &'static str {
32        "<name|subcommand>"
33    }
34
35    fn category(&self) -> SlashCategory {
36        SlashCategory::Skills
37    }
38
39    fn handle<'a>(
40        &'a self,
41        ctx: &'a mut CommandContext<'_>,
42        args: &'a str,
43    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
44        Box::pin(async move {
45            let result = ctx.agent.handle_skill(args).await?;
46            Ok(CommandOutput::Message(result))
47        })
48    }
49}
50
51/// List loaded skills.
52///
53/// Subcommands: (none) list all; `confusability` show pairs with high embedding similarity.
54pub struct SkillsCommand;
55
56impl CommandHandler<CommandContext<'_>> for SkillsCommand {
57    fn name(&self) -> &'static str {
58        "/skills"
59    }
60
61    fn description(&self) -> &'static str {
62        "List loaded skills (grouped by category when available)"
63    }
64
65    fn category(&self) -> SlashCategory {
66        SlashCategory::Skills
67    }
68
69    fn handle<'a>(
70        &'a self,
71        ctx: &'a mut CommandContext<'_>,
72        args: &'a str,
73    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
74        Box::pin(async move {
75            let result = ctx.agent.handle_skills(args).await?;
76            Ok(CommandOutput::Message(result))
77        })
78    }
79}
80
81/// Submit feedback for a skill invocation.
82pub struct FeedbackCommand;
83
84impl CommandHandler<CommandContext<'_>> for FeedbackCommand {
85    fn name(&self) -> &'static str {
86        "/feedback"
87    }
88
89    fn description(&self) -> &'static str {
90        "Submit feedback for a skill"
91    }
92
93    fn args_hint(&self) -> &'static str {
94        "<skill> <message>"
95    }
96
97    fn category(&self) -> SlashCategory {
98        SlashCategory::Skills
99    }
100
101    fn handle<'a>(
102        &'a self,
103        ctx: &'a mut CommandContext<'_>,
104        args: &'a str,
105    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
106        Box::pin(async move {
107            let result = ctx.agent.handle_feedback_command(args).await?;
108            Ok(CommandOutput::Message(result))
109        })
110    }
111}