| 1 | //! `/subagents` compatibility command. |
| 2 | |
| 3 | use crate::commands::traits::{CommandInfo, RegisterCommand}; |
| 4 | use crate::tui::app::App; |
| 5 | use codewhale_localization::MessageId; |
| 6 | |
| 7 | use super::CommandResult; |
| 8 | |
| 9 | pub(in crate::commands) const COMMAND_INFO: CommandInfo = CommandInfo { |
| 10 | name: "subagents", |
| 11 | aliases: &["agents", "zhinengti"], |
| 12 | usage: "/subagents [list]", |
| 13 | description_id: MessageId::CmdSubagentsDescription, |
| 14 | }; |
| 15 | |
| 16 | pub(in crate::commands) struct SubagentsCmd; |
| 17 | |
| 18 | impl RegisterCommand for SubagentsCmd { |
| 19 | fn info() -> &'static CommandInfo { |
| 20 | &COMMAND_INFO |
| 21 | } |
| 22 | |
| 23 | fn execute(app: &mut App, arg: Option<&str>) -> CommandResult { |
| 24 | // `list` prints the roster into the transcript instead of opening the |
| 25 | // modal, so a session transcript (and `exec`, which has no modal at |
| 26 | // all) carries the same agent history the TUI shows (#5479 spec 5). |
| 27 | match arg.map(str::trim).unwrap_or_default() { |
| 28 | "" => super::core::subagents(app), |
| 29 | "list" | "roster" | "ls" => super::core::subagents_roster(app), |
| 30 | other => CommandResult::error(format!( |
| 31 | "Unknown /agents argument {other:?}. Usage: /agents [list]" |
| 32 | )), |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 |