mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
wip: Changed chat history format and added italics to some messages.
This commit is contained in:
parent
1a76815998
commit
bddef03323
2 changed files with 21 additions and 17 deletions
|
@ -113,7 +113,7 @@ class Coder:
|
||||||
if new_files:
|
if new_files:
|
||||||
self.io.tool(f"Files not tracked in {repo.git_dir}:")
|
self.io.tool(f"Files not tracked in {repo.git_dir}:")
|
||||||
for fn in new_files:
|
for fn in new_files:
|
||||||
self.io.tool(f" {fn}")
|
self.io.tool(f" - {fn}")
|
||||||
if self.io.confirm_ask("Add them?"):
|
if self.io.confirm_ask("Add them?"):
|
||||||
for relative_fname in new_files:
|
for relative_fname in new_files:
|
||||||
repo.git.add(relative_fname)
|
repo.git.add(relative_fname)
|
||||||
|
|
|
@ -66,7 +66,7 @@ class InputOutput:
|
||||||
self.console = Console(force_terminal=True, no_color=True)
|
self.console = Console(force_terminal=True, no_color=True)
|
||||||
|
|
||||||
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
self.append_chat_history(f'\n# New session started at {current_time}', False)
|
self.append_chat_history(f'\n# Aider chat started at {current_time}\n\n')
|
||||||
|
|
||||||
def canned_input(self, show_prompt):
|
def canned_input(self, show_prompt):
|
||||||
console = Console()
|
console = Console()
|
||||||
|
@ -103,8 +103,8 @@ class InputOutput:
|
||||||
show += "\n"
|
show += "\n"
|
||||||
show += "> "
|
show += "> "
|
||||||
|
|
||||||
if not sys.stdin.isatty():
|
#if not sys.stdin.isatty():
|
||||||
return self.canned_input(show)
|
# return self.canned_input(show)
|
||||||
|
|
||||||
inp = ""
|
inp = ""
|
||||||
multiline_input = False
|
multiline_input = False
|
||||||
|
@ -137,7 +137,7 @@ class InputOutput:
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
prefix = "####"
|
prefix = "#### > "
|
||||||
if inp:
|
if inp:
|
||||||
hist = inp.splitlines()
|
hist = inp.splitlines()
|
||||||
else:
|
else:
|
||||||
|
@ -145,9 +145,10 @@ class InputOutput:
|
||||||
|
|
||||||
hist = f" \n{prefix} ".join(hist)
|
hist = f" \n{prefix} ".join(hist)
|
||||||
|
|
||||||
hist = f"""---
|
hist = f"""
|
||||||
|
---
|
||||||
{prefix} {hist}"""
|
{prefix} {hist}"""
|
||||||
self.append_chat_history(hist, True)
|
self.append_chat_history(hist, linebreak=True)
|
||||||
|
|
||||||
return inp
|
return inp
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ class InputOutput:
|
||||||
|
|
||||||
def ai_output(self, content):
|
def ai_output(self, content):
|
||||||
hist = '\n' + content.strip() + '\n\n'
|
hist = '\n' + content.strip() + '\n\n'
|
||||||
self.append_chat_history(hist, False)
|
self.append_chat_history(hist)
|
||||||
|
|
||||||
def confirm_ask(self, question, default="y"):
|
def confirm_ask(self, question, default="y"):
|
||||||
if self.yes:
|
if self.yes:
|
||||||
|
@ -163,8 +164,8 @@ class InputOutput:
|
||||||
else:
|
else:
|
||||||
res = prompt(question + " ", default=default)
|
res = prompt(question + " ", default=default)
|
||||||
|
|
||||||
hist = f"_{question.strip()} {res.strip()}_"
|
hist = f"{question.strip()} {res.strip()}"
|
||||||
self.append_chat_history(hist, True)
|
self.append_chat_history(hist, linebreak=True, italics=True)
|
||||||
|
|
||||||
if not res or not res.strip():
|
if not res or not res.strip():
|
||||||
return
|
return
|
||||||
|
@ -176,15 +177,15 @@ class InputOutput:
|
||||||
else:
|
else:
|
||||||
res = prompt(question + " ", default=default)
|
res = prompt(question + " ", default=default)
|
||||||
|
|
||||||
hist = f"_{question.strip()} {res.strip()}_"
|
hist = f"{question.strip()} {res.strip()}"
|
||||||
self.append_chat_history(hist, True)
|
self.append_chat_history(hist, linebreak=True, italics=True)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def tool_error(self, message):
|
def tool_error(self, message):
|
||||||
if message.strip():
|
if message.strip():
|
||||||
hist = f"_{message.strip()}_"
|
hist = f"{message.strip()}"
|
||||||
self.append_chat_history(hist, True)
|
self.append_chat_history(hist, linebreak=True, italics=True)
|
||||||
|
|
||||||
message = Text(message)
|
message = Text(message)
|
||||||
self.console.print(message, style="red")
|
self.console.print(message, style="red")
|
||||||
|
@ -192,13 +193,16 @@ class InputOutput:
|
||||||
def tool(self, *messages):
|
def tool(self, *messages):
|
||||||
if messages:
|
if messages:
|
||||||
hist = " ".join(messages)
|
hist = " ".join(messages)
|
||||||
hist = f"_{hist.strip()}_"
|
hist = f"{hist.strip()}"
|
||||||
self.append_chat_history(hist, True)
|
self.append_chat_history(hist, linebreak=True, italics=True)
|
||||||
|
|
||||||
messages = list(map(Text, messages))
|
messages = list(map(Text, messages))
|
||||||
self.console.print(*messages)
|
self.console.print(*messages)
|
||||||
|
|
||||||
def append_chat_history(self, text, linebreak):
|
def append_chat_history(self, text, linebreak=False, italics=False):
|
||||||
|
if italics:
|
||||||
|
text = text.strip()
|
||||||
|
text = f'_{text}_'
|
||||||
if linebreak:
|
if linebreak:
|
||||||
text = text.rstrip()
|
text = text.rstrip()
|
||||||
text = text + " \n"
|
text = text + " \n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue