Skip to content

Treat messages starting with / as slash commands #369

@SwanX1

Description

@SwanX1

Describe the feature or problem you'd like to solve

Currently only matching slash commands are treated as commands, instead of prompts, causing misspelled or unaliased commands to be sent as prompts, causing useless requests.

Branched off of issue #357.

Proposed solution

Addressing the problem pointed out by @EvanBoyle.
Instead of treating every message that starts with a slash as a command, look at the first N characters:

  • If the message doesn't start with a /, send it as a prompt
  • If the message starts with a /, but contains another / until the next whitespace, send it as a prompt
    This is treating most UNIX paths that will be sent (and are meant to be sent) as a prompt, for example /home/user/.zshrc doesn't exist. What should I do?
  • If the message starts with a / but the command is the most commonly used UNIX root paths, i.e. /var, /etc, /usr, etc., treat it as a prompt.
  • Otherwise display an error that the command isn't recognized, instead of sending the potentially misspelled command as a prompt.

Optionally, allow to prepend a whitespace to a message to allow to send messages detected as commands, as prompts, and point that out in the error when the command isn't recognized.

Example prompts or workflows

> /eixt
Command /eixt not recognized.
> /tmp doesn't exist on my computer.
[LLM RESPONSE]
> /home/user
[LLM RESPONSE]
>  /login
[LLM RESPONSE]

Additional context

Treating all messages that start with / as slash commands could be problematic, since this would also match anyone pasting in unix-like paths at the beginning of their message. If you feel strongly about this @SwanX1 please do open a separate issue as this one will get closed out when my PR merges.

Originally posted by @EvanBoyle in #357

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions