Skip to content

Commit 906e65d

Browse files
dariuszkowalski-comforge-code-agenttusharmath
authored
feat(zsh): add :agent command and fix porcelain output (#1994)
Co-authored-by: ForgeCode <noreply@forgecode.dev> Co-authored-by: Tushar Mathur <tusharmath@gmail.com>
1 parent 2464160 commit 906e65d

4 files changed

Lines changed: 319 additions & 36 deletions

File tree

Cargo.lock

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

crates/forge_main/src/cli.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ impl Cli {
8787

8888
#[derive(Subcommand, Debug, Clone)]
8989
pub enum TopLevelCommand {
90+
/// Manage agents.
91+
Agent(AgentCommandGroup),
92+
9093
/// Generate shell extension scripts.
9194
#[command(hide = true)]
9295
Extension(ExtensionCommandGroup),
@@ -162,6 +165,25 @@ pub enum CmdCommand {
162165
Execute(Vec<String>),
163166
}
164167

168+
/// Command group for agent management.
169+
#[derive(Parser, Debug, Clone)]
170+
pub struct AgentCommandGroup {
171+
#[command(subcommand)]
172+
pub command: AgentCommand,
173+
174+
/// Output in machine-readable format.
175+
#[arg(long, global = true)]
176+
pub porcelain: bool,
177+
}
178+
179+
/// Agent management commands.
180+
#[derive(Subcommand, Debug, Clone)]
181+
pub enum AgentCommand {
182+
/// List available agents.
183+
#[command(alias = "ls")]
184+
List,
185+
}
186+
165187
/// Command group for listing resources.
166188
#[derive(Parser, Debug, Clone)]
167189
pub struct ListCommandGroup {

crates/forge_main/src/ui.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
342342

343343
async fn handle_subcommands(&mut self, subcommand: TopLevelCommand) -> anyhow::Result<()> {
344344
match subcommand {
345+
TopLevelCommand::Agent(agent_group) => {
346+
match agent_group.command {
347+
crate::cli::AgentCommand::List => {
348+
self.on_show_agents(agent_group.porcelain).await?;
349+
}
350+
}
351+
return Ok(());
352+
}
345353
TopLevelCommand::List(list_group) => {
346354
let porcelain = list_group.porcelain;
347355
match list_group.command {
@@ -881,7 +889,7 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
881889
Porcelain::from(&info)
882890
.skip(1)
883891
.drop_col(0)
884-
.map_col(4, |text| match text.as_deref() {
892+
.map_col(5, |text| match text.as_deref() {
885893
Some("ENABLED") => Some("Reasoning".to_string()),
886894
Some("DISABLED") => Some("Non-Reasoning".to_string()),
887895
_ => None,
@@ -1024,6 +1032,7 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
10241032
"List all available tools with their descriptions and schema [alias: t]",
10251033
),
10261034
("skill", "List all available skills"),
1035+
("agent", "Select and switch between agents [alias: a]"),
10271036
("commit", "Generate AI commit message and commit changes."),
10281037
(
10291038
"suggest",

0 commit comments

Comments
 (0)