Skip to content

Commit b7df143

Browse files
echobtfactorydroid
andauthored
feat(cortex-tui): add interactive /agents command for agent management (#220)
- Add new agents builder module with TUI selectors for: - Listing all agents (built-in + project + global) - Creating new agents (project/global, AI/manual) - Permission selection for new agents - Confirmation flow for agent creation - Update ModalType to include Agents variant - Update command executor to open Agents modal - Add InteractiveAction handling for agents workflow - Add agent creation state fields to AppState - Add helper methods for saving agents and injecting chat events - Support both TOML and Markdown frontmatter agent files This provides a TUI interface similar to /settings for agent management, allowing users to list, select, and create custom agents directly from the command line interface. Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 1c5978c commit b7df143

9 files changed

Lines changed: 1028 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cortex-tui/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ async-trait = { workspace = true }
3535
# Serialization
3636
serde = { workspace = true }
3737
serde_json = { workspace = true }
38+
serde_yaml = { workspace = true }
39+
toml = { workspace = true }
3840

3941
# Error handling
4042
anyhow = { workspace = true }

cortex-tui/src/app.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ pub struct AppState {
607607
pub analytics_enabled: bool,
608608
/// Current operation mode (Build/Plan/Spec)
609609
pub operation_mode: OperationMode,
610+
// Agent creation state
611+
/// Agent creation location (project or global)
612+
pub agent_creation_location: Option<crate::interactive::builders::AgentLocation>,
613+
/// Agent creation method mode ("ai" or "manual_name")
614+
pub agent_creation_mode: Option<String>,
615+
/// Agent creation configuration in progress
616+
pub agent_creation_config: Option<crate::interactive::builders::NewAgentConfig>,
610617
}
611618

612619
impl AppState {
@@ -687,6 +694,10 @@ impl AppState {
687694
telemetry_enabled: false,
688695
analytics_enabled: false,
689696
operation_mode: OperationMode::default(),
697+
// Agent creation state
698+
agent_creation_location: None,
699+
agent_creation_mode: None,
700+
agent_creation_config: None,
690701
}
691702
}
692703

cortex-tui/src/commands/executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl CommandExecutor {
8181
"palette" | "cmd" => CommandResult::OpenModal(ModalType::CommandPalette),
8282
"init" => self.cmd_init(cmd),
8383
"commands" | "cmds" => CommandResult::Async("commands:list".to_string()),
84-
"agents" | "subagents" => CommandResult::Async("agents:list".to_string()),
84+
"agents" | "subagents" => CommandResult::OpenModal(ModalType::Agents),
8585
"copy" | "cp" => CommandResult::Message(
8686
"To copy text from Cortex:\n\n\
8787
- Hold SHIFT while selecting text with mouse\n\
@@ -1137,7 +1137,7 @@ mod tests {
11371137
let result = executor.execute_str("/agents");
11381138
assert!(matches!(
11391139
result,
1140-
CommandResult::Async(ref s) if s == "agents:list"
1140+
CommandResult::OpenModal(ModalType::Agents)
11411141
));
11421142
}
11431143

cortex-tui/src/commands/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn register_builtin_commands(registry: &mut CommandRegistry) {
263263
registry.register(CommandDef::new(
264264
"agents",
265265
&["subagents"],
266-
"List all available custom agents",
266+
"List and manage custom agents",
267267
"/agents",
268268
CommandCategory::General,
269269
false,

cortex-tui/src/commands/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ pub enum ModalType {
154154
Login,
155155
/// Upgrade modal for self-update
156156
Upgrade,
157+
/// Agents manager modal for listing and creating agents
158+
Agents,
157159
}
158160

159161
impl ModalType {
@@ -178,6 +180,7 @@ impl ModalType {
178180
ModalType::McpManager => "MCP Servers",
179181
ModalType::Login => "Login",
180182
ModalType::Upgrade => "Upgrade",
183+
ModalType::Agents => "Agents",
181184
}
182185
}
183186
}

0 commit comments

Comments
 (0)