fix: Add bold formatting to announcement messages

feat: Add bold formatting to commit message output
refactor: Simplify tool_output method in io.py
This commit is contained in:
Paul Gauthier 2024-08-09 19:26:22 -04:00 committed by Paul Gauthier (aider)
parent 06934a9c2d
commit 9cf672b428
3 changed files with 10 additions and 5 deletions

View file

@ -390,8 +390,10 @@ class Coder:
self.linter.set_linter(lang, cmd) self.linter.set_linter(lang, cmd)
def show_announcements(self): def show_announcements(self):
bold = True
for line in self.get_announcements(): for line in self.get_announcements():
self.io.tool_output(line) self.io.tool_output(line, bold=bold)
bold = False
def find_common_root(self): def find_common_root(self):
if len(self.abs_fnames) == 1: if len(self.abs_fnames) == 1:

View file

@ -15,6 +15,7 @@ from pygments.lexers import MarkdownLexer, guess_lexer_for_filename
from pygments.token import Token from pygments.token import Token
from pygments.util import ClassNotFound from pygments.util import ClassNotFound
from rich.console import Console from rich.console import Console
from rich.style import Style as RichStyle
from rich.text import Text from rich.text import Text
from .dump import dump # noqa: F401 from .dump import dump # noqa: F401
@ -402,7 +403,7 @@ class InputOutput:
style = dict(style=self.tool_error_color) if self.tool_error_color else dict() style = dict(style=self.tool_error_color) if self.tool_error_color else dict()
self.console.print(message, **style) self.console.print(message, **style)
def tool_output(self, *messages, log_only=False): def tool_output(self, *messages, log_only=False, bold=False):
if messages: if messages:
hist = " ".join(messages) hist = " ".join(messages)
hist = f"{hist.strip()}" hist = f"{hist.strip()}"
@ -410,8 +411,10 @@ class InputOutput:
if not log_only: if not log_only:
messages = list(map(Text, messages)) messages = list(map(Text, messages))
style = dict(style=self.tool_output_color) if self.tool_output_color else dict() style = dict(color=self.tool_output_color) if self.tool_output_color else dict()
self.console.print(*messages, **style) style["reverse"] = bold
style = RichStyle(**style)
self.console.print(*messages, style=style)
def append_chat_history(self, text, linebreak=False, blockquote=False, strip=True): def append_chat_history(self, text, linebreak=False, blockquote=False, strip=True):
if blockquote: if blockquote:

View file

@ -130,7 +130,7 @@ class GitRepo:
self.repo.git.commit(cmd) self.repo.git.commit(cmd)
commit_hash = self.repo.head.commit.hexsha[:7] commit_hash = self.repo.head.commit.hexsha[:7]
self.io.tool_output(f"Commit {commit_hash} {commit_message}") self.io.tool_output(f"Commit {commit_hash} {commit_message}", bold=True)
# Restore the env # Restore the env