zeph_commands/handlers/
plan.rs1use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12pub struct PlanCommand;
18
19impl CommandHandler<CommandContext<'_>> for PlanCommand {
20 fn name(&self) -> &'static str {
21 "/plan"
22 }
23
24 fn description(&self) -> &'static str {
25 "Create or manage execution plans"
26 }
27
28 fn args_hint(&self) -> &'static str {
29 "[goal|confirm|cancel|status|list|resume|retry]"
30 }
31
32 fn category(&self) -> SlashCategory {
33 SlashCategory::Planning
34 }
35
36 fn handle<'a>(
37 &'a self,
38 ctx: &'a mut CommandContext<'_>,
39 args: &'a str,
40 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
41 Box::pin(async move {
42 let input = if args.is_empty() {
44 "/plan".to_owned()
45 } else {
46 format!("/plan {args}")
47 };
48 let result = ctx.agent.handle_plan(&input).await?;
49 if result.is_empty() {
50 Ok(CommandOutput::Silent)
51 } else {
52 Ok(CommandOutput::Message(result))
53 }
54 })
55 }
56}