block-open-source / goose

Goose is a developer agent that operates from your command line to help you do the boring stuff.
https://block-open-source.github.io/goose/
Apache License 2.0
73 stars 12 forks source link

feat: give commands the ability to execute logic #63

Closed lukealvoeiro closed 2 weeks ago

lukealvoeiro commented 2 weeks ago

Current state of commands (before this PR)

Commands currently only serve autocompletion purposes. For example:

Screenshot 2024-09-11 at 5 31 14 PM

As it currently stands, commands do not trigger anything to occur when they are included in the prompt and enter is pressed.

Where does the /file command currently fall short?

The /file command is included in the string that we will sent to the LLM, which introduces some uncertainty in regard to the user intent. This is because the LLM does not reliably know what a command such as /file:src/* means.

How to remediate this?

1. ✅ Introduce a way for commands to modify their portion of the prompt that will be sent off

  1. ❌ Indicate in the system prompt that commands exist, and that we should ignore the first portion of them (the command name)

Why did I choose 1 above?

Currently, only one command exists - /file. However, we can imagine that folks may want to contribute other commands. Some of ideas of these may include:

Across these commands, we notice different user intents:

From these examples, I see there is value in

  1. Being able to execute some action based on the value of the command (/name:value)
  2. Being able to replace the string /name:value with a value determined by the command

This led me to the signature for the Command.execute method:

def execute(self, query: str) -> str:
    return ""

🤔 I don't like the above - what other options are there?

Option 1: instead of commands executing some logic, we could remove the execute method and only allow them to be used for autocompletion. We would need to make a small tweak so that only the value of the command is persisted in the prompt, not the command name itself.

Option 2: completely remove the idea of commands, and either scrap the idea of file completions entirely, or just keep the file completion around and don't have it inherit from Command

michaelneale commented 2 weeks ago

a suggestion - would it be possible to detect and suggest a command a user could explore so they can accidentally discover it? One of the benefits of goose is that you ideally don't need to know how to drive it, commands start to bring more syntax/knowledge needed, so would be nice to be able to prompt people for that so it feels organic.

lukealvoeiro commented 2 weeks ago

a suggestion - would it be possible to detect and suggest a command a user could explore so they can accidentally discover it? One of the benefits of goose is that you ideally don't need to know how to drive it, commands start to bring more syntax/knowledge needed, so would be nice to be able to prompt people for that so it feels organic.

We were probably gonna work on surfacing features to users just in time, so we could work this in (if we decide to move forward with using commands).

lukealvoeiro commented 2 weeks ago

@lifeizhou-ap I know we had some discussion topics ongoing but the rest of the team is onboard - going ahead and merging this PR and we can follow up with any changes.