Skip to content

fix(command-list): deduplicate agent names in list commands porcelain output#3011

Merged
tusharmath merged 2 commits intomainfrom
agent-selection
Apr 14, 2026
Merged

fix(command-list): deduplicate agent names in list commands porcelain output#3011
tusharmath merged 2 commits intomainfrom
agent-selection

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 14, 2026

Summary

Fix :muse, :sage, and :forge ZSH commands failing with "command not found" by removing duplicate entries from list commands --porcelain output.

Context

AppCommand::Forge, AppCommand::Muse, and AppCommand::Sage are REPL shortcut variants that switch agents. In on_show_commands, they were being emitted twice: once by the AppCommand::iter() loop (as COMMAND) and again by the agent-info loop (as AGENT). The ZSH shell plugin's _forge_action_default used grep to find the command row, received two matching lines, and ended up with command_type = "AGENT\nCOMMAND" — a multi-line string that failed the [[ "${command_type:l}" == "agent" ]] check, causing the "command not found" error.

Changes

  • Added is_agent_switch() method to AppCommand in model.rs that returns true for Forge, Muse, and Sage
  • Updated on_show_commands in ui.rs to filter out agent-switch shorthands from the COMMAND loop, so they appear exactly once — as AGENT — in the porcelain output

Testing

# Verify no duplicates in output
forge list commands --porcelain | grep -E "^(forge|muse|sage)\b"
# Expected: exactly 3 lines, all typed AGENT

# In ZSH with the shell plugin loaded:
:muse   # should set muse as active agent
:sage   # should set sage as active agent
:forge  # should set forge as active agent

Fixes #3009

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 14, 2026
@tusharmath tusharmath changed the title fix(command-list): exclude agent-switch shorthands from command loop to prevent duplicate entries fix(command-list): deduplicate agent names in list commands porcelain output Apr 14, 2026
@tusharmath tusharmath merged commit b0074b8 into main Apr 14, 2026
8 checks passed
@tusharmath tusharmath deleted the agent-selection branch April 14, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][SOLVED]: Command ':sage' and :forge not found after update

1 participant