Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: improve ZSH compatibility#1591

Merged
tusharmath merged 26 commits into
mainfrom
zsh-agent-selector
Sep 25, 2025
Merged

chore: improve ZSH compatibility#1591
tusharmath merged 26 commits into
mainfrom
zsh-agent-selector

Conversation

@tusharmath

@tusharmath tusharmath commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator
  • Support passing --agent to CLI
  • Reset prompt with the last command
  • Reset conversation based on user - YES/NO
  • Support a :reset command

Open Issues

  • Make Interactive mode work

@tusharmath tusharmath changed the title Zsh agent selector chore: improve ZSH compatibility Sep 24, 2025
@github-actions github-actions Bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Sep 24, 2025
Comment thread shell-plugin/forge.plugin.zsh Outdated
Comment on lines +39 to +44
# Check if the line starts with any of the supported patterns
if [[ "$BUFFER" =~ "^:([a-zA-Z][a-zA-Z0-9_-]*) (.*)$" ]]; then
_FORGE_COMMAND="${match[1]}"
input_text="${match[2]}"
elif [[ "$BUFFER" =~ "^: (.*)$" ]]; then
input_text="${match[1]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern for the second condition doesn't handle the case where a user types just : without a space. While the first pattern correctly matches :command text, the second pattern only matches : text (with a space).

Consider updating the second pattern to ^:(.*)$ to handle all input variations after the colon character, including when there's no space. This would make the pattern matching more robust and consistent with user expectations.

# More robust pattern matching
elif [[ "$BUFFER" =~ "^:(.*)$" ]]; then
    input_text="${match[1]}"
    # Trim leading space if present
    input_text="${input_text#[[:space:]]}"
Suggested change
# Check if the line starts with any of the supported patterns
if [[ "$BUFFER" =~ "^:([a-zA-Z][a-zA-Z0-9_-]*) (.*)$" ]]; then
_FORGE_COMMAND="${match[1]}"
input_text="${match[2]}"
elif [[ "$BUFFER" =~ "^: (.*)$" ]]; then
input_text="${match[1]}"
# Check if the line starts with any of the supported patterns
if [[ "$BUFFER" =~ "^:([a-zA-Z][a-zA-Z0-9_-]*) (.*)$" ]]; then
_FORGE_COMMAND="${match[1]}"
input_text="${match[2]}"
elif [[ "$BUFFER" =~ "^:(.*)$" ]]; then
input_text="${match[1]}"
# Trim leading space if present
input_text="${input_text#[[:space:]]}"

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

};

eprintln!("{}", TitleFormat::error(message.to_string()).display());
println!("{}", TitleFormat::error(message.to_string()).display());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change from eprintln! to println! for error messages breaks standard error handling conventions. Error messages should be directed to stderr (using eprintln!) rather than stdout (println!).

This modification could cause issues with scripts or tools that expect error output on the standard error stream. It may also interfere with piping or redirection in shell environments where the separation of standard output and error streams is important.

Consider reverting this change to maintain proper error handling practices.

Suggested change
println!("{}", TitleFormat::error(message.to_string()).display());
eprintln!("{}", TitleFormat::error(message.to_string()).display());

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment thread shell-plugin/forge.plugin.zsh Outdated
@openhands-ai

openhands-ai Bot commented Sep 25, 2025

Copy link
Copy Markdown

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • autofix.ci
    • ci

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1591 at branch `zsh-agent-selector`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Comment on lines 287 to +289
if command.starts_with("/agent-") {
if let Some(found_command) = self.find(command) {
let command_name = command.strip_prefix('/').unwrap();
if let Some(found_command) = self.find(command_name) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency in the command parsing logic. On line 287, the code checks for commands starting with /agent-, but the command registry has been updated to store commands without the / prefix (they're now stored as agent-*).

To maintain consistency with the new command naming convention, this check should be updated to:

- if command.starts_with("/agent-") {
+ if command.starts_with("/agent-") {
+     let command_name = command.strip_prefix('/').unwrap();

The current implementation will correctly strip the prefix for lookup, but the initial condition should ideally match the new convention to avoid confusion and potential bugs in future modifications.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +146 to +147
# Set buffer to the last command for continued interaction
BUFFER="${_FORGE_CONVERSATION_PATTERN}${_FORGE_RESET_COMMAND}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code sets BUFFER to :reset after command execution, which forces the user to reset their conversation on the next interaction. This doesn't preserve the user's workflow context.

Consider changing this line to use ${_FORGE_CONVERSATION_PATTERN}${_FORGE_USER_ACTION} instead, which would maintain the last used command type (e.g., :sage, :muse). This provides better UX by allowing users to continue with their previous interaction pattern.

Alternatively, if a neutral starting point is preferred, setting BUFFER to just ":" would allow users to start fresh without forcing a reset.

Suggested change
# Set buffer to the last command for continued interaction
BUFFER="${_FORGE_CONVERSATION_PATTERN}${_FORGE_RESET_COMMAND}"
# Set buffer to the last command for continued interaction
BUFFER="${_FORGE_CONVERSATION_PATTERN}${_FORGE_USER_ACTION}"

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@tusharmath tusharmath merged commit 580717d into main Sep 25, 2025
10 checks passed
@tusharmath tusharmath deleted the zsh-agent-selector branch September 25, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore Routine tasks like conversions, reorganization, and maintenance work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant