From b4ba159f27771d3413d3d442ada446397c2c1fa3 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 3 Sep 2024 12:39:41 -0700 Subject: [PATCH] feat: add tool_warning method and warning color option --- aider/io.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/aider/io.py b/aider/io.py index a6dfa9b2d..0249d9af5 100644 --- a/aider/io.py +++ b/aider/io.py @@ -176,6 +176,7 @@ class InputOutput: user_input_color="blue", tool_output_color=None, tool_error_color="red", + tool_warning_color="yellow", encoding="utf-8", dry_run=False, llm_history_file=None, @@ -189,6 +190,7 @@ class InputOutput: self.user_input_color = user_input_color if pretty else None self.tool_output_color = tool_output_color if pretty else None self.tool_error_color = tool_error_color if pretty else None + self.tool_warning_color = tool_warning_color if pretty else None self.input = input self.output = output @@ -543,6 +545,25 @@ class InputOutput: style = dict() self.console.print(message, **style) + def tool_warning(self, message="", strip=True): + if message.strip(): + if "\n" in message: + for line in message.splitlines(): + self.append_chat_history(line, linebreak=True, blockquote=True, strip=strip) + else: + if strip: + hist = message.strip() + else: + hist = message + self.append_chat_history(hist, linebreak=True, blockquote=True) + + message = Text(message) + if self.pretty and self.tool_warning_color: + style = dict(style=self.tool_warning_color) + else: + style = dict() + self.console.print(message, **style) + def tool_output(self, *messages, log_only=False, bold=False): if messages: hist = " ".join(messages)