From 67a1d7231c0ca6fcf2e66e38af1e75fa48914952 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 28 May 2023 11:16:08 -0700 Subject: [PATCH] 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. --- aider/commands.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 666b3dac8..8e31d2e83 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -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 - - 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) def cmd_exit(self, args): "Exit the application"