chore: improve ZSH compatibility#1591
Conversation
62caaa1 to
3336fab
Compare
| # 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]}" |
There was a problem hiding this comment.
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:]]}"| # 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
Is this helpful? React 👍 or 👎 to let us know.
| }; | ||
|
|
||
| eprintln!("{}", TitleFormat::error(message.to_string()).display()); | ||
| println!("{}", TitleFormat::error(message.to_string()).display()); |
There was a problem hiding this comment.
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.
| println!("{}", TitleFormat::error(message.to_string()).display()); | |
| eprintln!("{}", TitleFormat::error(message.to_string()).display()); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
…I and shell plugin
5117b7c to
4e98e80
Compare
| 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) { |
There was a problem hiding this comment.
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
Is this helpful? React 👍 or 👎 to let us know.
| # Set buffer to the last command for continued interaction | ||
| BUFFER="${_FORGE_CONVERSATION_PATTERN}${_FORGE_RESET_COMMAND}" |
There was a problem hiding this comment.
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.
| # 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
Is this helpful? React 👍 or 👎 to let us know.
--agentto CLI:resetcommandOpen Issues