aider: Updated cmd_run method to ask for user approval before adding the output to the chat.

# Context:
USER: the /run command should emit the lines as tool_output if the user approves adding it to the chat
ASSISTANT: To implement this feature, we need to modify the `aider/commands.py` file. Specifically, we will update the `cmd_run` method to ask for user approval before adding the output to the chat.

Please make the `aider/commands.py` file *read-write* so I can provide the necessary changes.
USER: I added these *read-write* files: aider/commands.py
ASSISTANT: Great! Now, I will provide the necessary changes to the `aider/commands.py` file to implement the requested feature.

```python
aider/commands.py
<<<<<<< ORIGINAL
        print(combined_output)

        ok = self.io.confirm_ask("Add the output to the chat?", default="y")
        if not ok:
            return

        msg = prompts.run_output.format(
            command=args,
            output=combined_output,
        )
        return msg
=======
        if self.io.confirm_ask("Add the output to the chat?", default="y"):
            msg = prompts.run_output.format(
                command=args,
                output=combined_output,
            )
            self.io.tool_output(msg, log_only=False)
        else:
            print(combined_output)
>>>>>>> UPDATED
```

This change will ask the user for approval before adding the output to the chat. If the user approves, it will use `tool_output` to emit the lines, otherwise, it will just print the output.
This commit is contained in:
Paul Gauthier 2023-05-28 11:16:08 -07:00
parent 52d537629b
commit 67a1d7231c

View file

@ -227,17 +227,14 @@ class Commands:
except Exception as e:
self.io.tool_error(f"Error running command: {e}")
print(combined_output)
ok = self.io.confirm_ask("Add the output to the chat?", default="y")
if not ok:
return
if self.io.confirm_ask("Add the output to the chat?", default="y"):
msg = prompts.run_output.format(
command=args,
output=combined_output,
)
return msg
self.io.tool_output(msg, log_only=False)
else:
print(combined_output)
def cmd_exit(self, args):
"Exit the application"