From a525a1b543287ca5ce8747d504fd4adcf610d203 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 18 May 2023 10:13:50 -0700 Subject: [PATCH] Ask to add /run output to the chat --- aider/commands.py | 19 ++++++++++++++++--- aider/prompts.py | 10 ++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 8b3562977..a8524f9e4 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -13,7 +13,7 @@ class Commands: self.coder = coder def is_command(self, inp): - if inp[0] == '/': + if inp[0] == "/": return True def help(self): @@ -230,12 +230,25 @@ class Commands: "Run the supplied command in a subprocess and combine stdout and stderr into a single string" try: parsed_args = shlex.split(args) - result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + result = subprocess.run( + parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True + ) combined_output = result.stdout - print(combined_output) except Exception as e: self.io.tool_error(f"Error running command: {e}") + print(combined_output) + + ok = 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 + def cmd_ls(self, args): "List all known files and those included in the chat session" diff --git a/aider/prompts.py b/aider/prompts.py index bd3752495..e17b69c1d 100644 --- a/aider/prompts.py +++ b/aider/prompts.py @@ -105,3 +105,13 @@ undo_command_reply = ( ) added_files = "Please note that I shared content of these additional files: {fnames}" + + +run_output = """I ran this command: + +{command} + +Which produced this output: + +{output} +"""