Skip to main content

zeph_commands/handlers/
acp.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! `/acp` slash command handler.
5
6use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12/// Inspect ACP server configuration (`/acp dirs`, `/acp auth-methods`, `/acp status`).
13pub struct AcpCommand;
14
15impl CommandHandler<CommandContext<'_>> for AcpCommand {
16    fn name(&self) -> &'static str {
17        "/acp"
18    }
19
20    fn description(&self) -> &'static str {
21        "Inspect ACP server configuration (dirs, auth-methods, status)"
22    }
23
24    fn args_hint(&self) -> &'static str {
25        "[dirs | auth-methods | status]"
26    }
27
28    fn category(&self) -> SlashCategory {
29        SlashCategory::Integration
30    }
31
32    fn feature_gate(&self) -> Option<&'static str> {
33        Some("acp")
34    }
35
36    fn requires_auth(&self) -> bool {
37        true
38    }
39
40    fn handle<'a>(
41        &'a self,
42        ctx: &'a mut CommandContext<'_>,
43        args: &'a str,
44    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
45        use tracing::Instrument as _;
46        let span = tracing::info_span!("commands.acp.handle");
47        Box::pin(
48            async move { Ok(CommandOutput::Message(ctx.agent.handle_acp(args).await?)) }
49                .instrument(span),
50        )
51    }
52}
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn name_matches_slash_acp() {
60        assert_eq!(AcpCommand.name(), "/acp");
61    }
62
63    #[test]
64    fn category_is_integration() {
65        assert_eq!(AcpCommand.category(), SlashCategory::Integration);
66    }
67
68    #[test]
69    fn feature_gate_is_acp() {
70        assert_eq!(AcpCommand.feature_gate(), Some("acp"));
71    }
72
73    #[test]
74    fn description_and_args_hint_non_empty() {
75        assert!(!AcpCommand.description().is_empty());
76        assert!(!AcpCommand.args_hint().is_empty());
77    }
78
79    #[test]
80    fn acp_requires_auth() {
81        assert!(AcpCommand.requires_auth());
82    }
83}