mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
More pretty
This commit is contained in:
parent
008bb1cffa
commit
e01d05c614
1 changed files with 17 additions and 5 deletions
22
coder.py
22
coder.py
|
@ -7,6 +7,7 @@ import traceback
|
||||||
import argparse
|
import argparse
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.live import Live
|
from rich.live import Live
|
||||||
|
from rich.text import Text
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
@ -51,7 +52,7 @@ class Coder:
|
||||||
|
|
||||||
self.check_for_local_edits(True)
|
self.check_for_local_edits(True)
|
||||||
|
|
||||||
self.console = Console()
|
self.console = Console(record=True)
|
||||||
|
|
||||||
def files_modified(self):
|
def files_modified(self):
|
||||||
for fname, mtime in self.fnames.items():
|
for fname, mtime in self.fnames.items():
|
||||||
|
@ -91,7 +92,9 @@ class Coder:
|
||||||
return
|
return
|
||||||
self.console.print("[bold red]^C again to quit")
|
self.console.print("[bold red]^C again to quit")
|
||||||
|
|
||||||
print()
|
###
|
||||||
|
self.console.print(f"[green]> {inp.strip()}")
|
||||||
|
self.console.print()
|
||||||
|
|
||||||
readline.write_history_file(history_file)
|
readline.write_history_file(history_file)
|
||||||
return inp
|
return inp
|
||||||
|
@ -126,6 +129,9 @@ class Coder:
|
||||||
self.cur_messages = []
|
self.cur_messages = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
html = self.console.export_html()
|
||||||
|
Path("tmp.html").write_text(html)
|
||||||
|
|
||||||
inp = self.get_input()
|
inp = self.get_input()
|
||||||
if inp is None:
|
if inp is None:
|
||||||
return
|
return
|
||||||
|
@ -164,8 +170,8 @@ class Coder:
|
||||||
dict(role="assistant", content=content),
|
dict(role="assistant", content=content),
|
||||||
]
|
]
|
||||||
|
|
||||||
print()
|
self.console.print()
|
||||||
print()
|
|
||||||
try:
|
try:
|
||||||
edited = self.update_files(content, inp)
|
edited = self.update_files(content, inp)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -265,6 +271,12 @@ class Coder:
|
||||||
md = Markdown(resp, style="blue", code_theme="default")
|
md = Markdown(resp, style="blue", code_theme="default")
|
||||||
live.update(md)
|
live.update(md)
|
||||||
|
|
||||||
|
live.update(Text(""))
|
||||||
|
live.stop()
|
||||||
|
|
||||||
|
md = Markdown(resp, style="blue", code_theme="default")
|
||||||
|
self.console.print(md)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
|
@ -315,7 +327,7 @@ class Coder:
|
||||||
new_content = "\n".join(new_content) + "\n"
|
new_content = "\n".join(new_content) + "\n"
|
||||||
|
|
||||||
fname.write_text(new_content)
|
fname.write_text(new_content)
|
||||||
self.console.print("Applied edit to", fname)
|
self.console.print(f"Applied edit to {fname}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def do_gpt_powered_replace(self, fname, edit, request):
|
def do_gpt_powered_replace(self, fname, edit, request):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue