mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
change most aider messages to bright_black instead of red; use that for errors
This commit is contained in:
parent
f7b58b780b
commit
8abf56ae94
2 changed files with 49 additions and 35 deletions
|
@ -45,14 +45,14 @@ class Coder:
|
||||||
self.main_model = main_model
|
self.main_model = main_model
|
||||||
if main_model == "gpt-3.5-turbo":
|
if main_model == "gpt-3.5-turbo":
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[red bold]This tool will almost certainly fail to work with {main_model}"
|
f"[red]This tool will almost certainly fail to work with {main_model}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.set_repo(fnames)
|
self.set_repo(fnames)
|
||||||
|
|
||||||
if not self.repo:
|
if not self.repo:
|
||||||
self.console.print(
|
self.console.print(
|
||||||
"[red bold]No suitable git repo, will not automatically commit edits."
|
"[red]No suitable git repo, will not automatically commit edits."
|
||||||
)
|
)
|
||||||
self.find_common_root()
|
self.find_common_root()
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class Coder:
|
||||||
def find_common_root(self):
|
def find_common_root(self):
|
||||||
common_prefix = os.path.commonpath(list(self.abs_fnames))
|
common_prefix = os.path.commonpath(list(self.abs_fnames))
|
||||||
self.root = os.path.dirname(common_prefix)
|
self.root = os.path.dirname(common_prefix)
|
||||||
self.console.print(f"[red]Common root directory: {self.root}")
|
self.console.print(f"[bright_black]Common root directory: {self.root}")
|
||||||
|
|
||||||
def set_repo(self, cmd_line_fnames):
|
def set_repo(self, cmd_line_fnames):
|
||||||
if not cmd_line_fnames:
|
if not cmd_line_fnames:
|
||||||
|
@ -73,7 +73,7 @@ class Coder:
|
||||||
repo_paths = []
|
repo_paths = []
|
||||||
for fname in abs_fnames:
|
for fname in abs_fnames:
|
||||||
if not fname.exists():
|
if not fname.exists():
|
||||||
self.console.print(f"[red]Creating {fname}")
|
self.console.print(f"[bright_black]Creating {fname}")
|
||||||
fname.touch()
|
fname.touch()
|
||||||
try:
|
try:
|
||||||
repo_path = git.Repo(fname, search_parent_directories=True).git_dir
|
repo_path = git.Repo(fname, search_parent_directories=True).git_dir
|
||||||
|
@ -83,10 +83,10 @@ class Coder:
|
||||||
num_repos = len(set(repo_paths))
|
num_repos = len(set(repo_paths))
|
||||||
|
|
||||||
if num_repos == 0:
|
if num_repos == 0:
|
||||||
self.console.print("[red bold]Files are not in a git repo.")
|
self.console.print("[red]Files are not in a git repo.")
|
||||||
return
|
return
|
||||||
if num_repos > 1:
|
if num_repos > 1:
|
||||||
self.console.print("[red bold]Files are in different git repos.")
|
self.console.print("[red]Files are in different git repos.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# https://github.com/gitpython-developers/GitPython/issues/427
|
# https://github.com/gitpython-developers/GitPython/issues/427
|
||||||
|
@ -98,7 +98,7 @@ class Coder:
|
||||||
for fname in abs_fnames:
|
for fname in abs_fnames:
|
||||||
if fname.is_dir():
|
if fname.is_dir():
|
||||||
continue
|
continue
|
||||||
self.console.print(f"[red]Loading {fname}")
|
self.console.print(f"[bright_black]Loading {fname}")
|
||||||
|
|
||||||
fname = fname.resolve()
|
fname = fname.resolve()
|
||||||
self.abs_fnames.add(str(fname))
|
self.abs_fnames.add(str(fname))
|
||||||
|
@ -109,20 +109,24 @@ class Coder:
|
||||||
new_files.append(relative_fname)
|
new_files.append(relative_fname)
|
||||||
|
|
||||||
if new_files:
|
if new_files:
|
||||||
self.console.print(f"[red]Files not tracked in {repo.git_dir}:")
|
self.console.print(f"[bright_black]Files not tracked in {repo.git_dir}:")
|
||||||
for fn in new_files:
|
for fn in new_files:
|
||||||
self.console.print(f"[red] {fn}")
|
self.console.print(f"[bright_black] {fn}")
|
||||||
if Confirm.ask("[red bold]Add them?", console=self.console, default="y"):
|
if Confirm.ask(
|
||||||
|
"[bright_black]Add them?", console=self.console, default="y"
|
||||||
|
):
|
||||||
for relative_fname in new_files:
|
for relative_fname in new_files:
|
||||||
repo.git.add(relative_fname)
|
repo.git.add(relative_fname)
|
||||||
self.console.print(f"[red]Added {relative_fname} to the git repo")
|
self.console.print(
|
||||||
|
f"[bright_black]Added {relative_fname} to the git repo"
|
||||||
|
)
|
||||||
show_files = ", ".join(new_files)
|
show_files = ", ".join(new_files)
|
||||||
commit_message = (
|
commit_message = (
|
||||||
f"Initial commit: Added new files to the git repo: {show_files}"
|
f"Initial commit: Added new files to the git repo: {show_files}"
|
||||||
)
|
)
|
||||||
repo.git.commit("-m", commit_message, "--no-verify")
|
repo.git.commit("-m", commit_message, "--no-verify")
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[red]Committed new files with message: {commit_message}"
|
f"[bright_black]Committed new files with message: {commit_message}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.console.print("[red]Skipped adding new files to the git repo.")
|
self.console.print("[red]Skipped adding new files to the git repo.")
|
||||||
|
@ -183,7 +187,7 @@ class Coder:
|
||||||
self.num_control_c += 1
|
self.num_control_c += 1
|
||||||
if self.num_control_c >= 2:
|
if self.num_control_c >= 2:
|
||||||
break
|
break
|
||||||
self.console.print("[bold red]^C again to quit")
|
self.console.print("[red]^C again to quit")
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -264,7 +268,7 @@ class Coder:
|
||||||
message=commit_message,
|
message=commit_message,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.console.print("[red bold]No changes found in tracked files.")
|
self.console.print("[red]Warning: no changes found in tracked files.")
|
||||||
saved_message = prompts.files_content_gpt_no_edits
|
saved_message = prompts.files_content_gpt_no_edits
|
||||||
|
|
||||||
self.done_messages += self.cur_messages
|
self.done_messages += self.cur_messages
|
||||||
|
@ -355,11 +359,9 @@ class Coder:
|
||||||
|
|
||||||
if full_path not in self.abs_fnames:
|
if full_path not in self.abs_fnames:
|
||||||
if not Path(full_path).exists():
|
if not Path(full_path).exists():
|
||||||
question = f"[red]Allow creation of new file {path}?"
|
question = f"[bright_black]Allow creation of new file {path}?"
|
||||||
else:
|
else:
|
||||||
question = (
|
question = f"[bright_black]Allow edits to {path} which was not previously provided?"
|
||||||
f"[red]Allow edits to {path} which was not previously provided?"
|
|
||||||
)
|
|
||||||
if not Confirm.ask(question, console=self.console, default="y"):
|
if not Confirm.ask(question, console=self.console, default="y"):
|
||||||
self.console.print(f"[red]Skipping edit to {path}")
|
self.console.print(f"[red]Skipping edit to {path}")
|
||||||
continue
|
continue
|
||||||
|
@ -368,13 +370,15 @@ class Coder:
|
||||||
self.abs_fnames.add(full_path)
|
self.abs_fnames.add(full_path)
|
||||||
|
|
||||||
if self.repo and Confirm.ask(
|
if self.repo and Confirm.ask(
|
||||||
f"[red]Add {path} to git?", console=self.console, default="y"
|
f"[bright_black]Add {path} to git?",
|
||||||
|
console=self.console,
|
||||||
|
default="y",
|
||||||
):
|
):
|
||||||
self.repo.git.add(full_path)
|
self.repo.git.add(full_path)
|
||||||
|
|
||||||
edited.add(path)
|
edited.add(path)
|
||||||
if utils.do_replace(full_path, original, updated):
|
if utils.do_replace(full_path, original, updated):
|
||||||
self.console.print(f"[red]Applied edit to {path}")
|
self.console.print(f"[bright_black]Applied edit to {path}")
|
||||||
else:
|
else:
|
||||||
self.console.print(f"[red]Failed to apply edit to {path}")
|
self.console.print(f"[red]Failed to apply edit to {path}")
|
||||||
|
|
||||||
|
@ -449,11 +453,13 @@ class Coder:
|
||||||
if ask:
|
if ask:
|
||||||
self.last_modified = self.get_last_modified()
|
self.last_modified = self.get_last_modified()
|
||||||
|
|
||||||
self.console.print("[red]Files have uncommitted changes.\n")
|
self.console.print("[bright_black]Files have uncommitted changes.\n")
|
||||||
self.console.print(f"[red]Suggested commit message:\n{commit_message}\n")
|
self.console.print(
|
||||||
|
f"[bright_black]Suggested commit message:\n{commit_message}\n"
|
||||||
|
)
|
||||||
|
|
||||||
res = Prompt.ask(
|
res = Prompt.ask(
|
||||||
"[red]Commit before the chat proceeds? \[y/n/commit message]", # noqa: W605
|
"[bright_black]Commit before the chat proceeds? \[y/n/commit message]", # noqa: W605
|
||||||
console=self.console,
|
console=self.console,
|
||||||
default="y",
|
default="y",
|
||||||
).strip()
|
).strip()
|
||||||
|
@ -470,7 +476,7 @@ class Coder:
|
||||||
full_commit_message = commit_message + "\n\n" + context
|
full_commit_message = commit_message + "\n\n" + context
|
||||||
repo.git.commit("-m", full_commit_message, "--no-verify")
|
repo.git.commit("-m", full_commit_message, "--no-verify")
|
||||||
commit_hash = repo.head.commit.hexsha[:7]
|
commit_hash = repo.head.commit.hexsha[:7]
|
||||||
self.console.print(f"[red]{commit_hash} {commit_message}")
|
self.console.print(f"[bright_black]{commit_hash} {commit_message}")
|
||||||
|
|
||||||
self.last_modified = self.get_last_modified()
|
self.last_modified = self.get_last_modified()
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Commands:
|
||||||
)
|
)
|
||||||
self.coder.repo.git.commit("-m", commit_message, "--no-verify")
|
self.coder.repo.git.commit("-m", commit_message, "--no-verify")
|
||||||
commit_hash = self.coder.repo.head.commit.hexsha[:7]
|
commit_hash = self.coder.repo.head.commit.hexsha[:7]
|
||||||
self.console.print(f"[red]{commit_hash} {commit_message}")
|
self.console.print(f"[bright_black]{commit_hash} {commit_message}")
|
||||||
return
|
return
|
||||||
|
|
||||||
self.coder.commit()
|
self.coder.commit()
|
||||||
|
@ -108,7 +108,7 @@ class Commands:
|
||||||
return
|
return
|
||||||
self.coder.repo.git.reset("--hard", "HEAD~1")
|
self.coder.repo.git.reset("--hard", "HEAD~1")
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[red]{last_commit.message.strip()}\n"
|
f"[bright_black]{last_commit.message.strip()}\n"
|
||||||
f"The above commit {self.coder.last_aider_commit_hash} "
|
f"The above commit {self.coder.last_aider_commit_hash} "
|
||||||
"was reset and removed from git.\n"
|
"was reset and removed from git.\n"
|
||||||
)
|
)
|
||||||
|
@ -151,12 +151,16 @@ class Commands:
|
||||||
matched_files = [file for file in files if word in file]
|
matched_files = [file for file in files if word in file]
|
||||||
if not matched_files:
|
if not matched_files:
|
||||||
if self.coder.repo is not None:
|
if self.coder.repo is not None:
|
||||||
create_file = Confirm.ask(f"[red]No files matched '{word}'. Do you want to create the file and add it to git?")
|
create_file = Confirm.ask(
|
||||||
|
f"[bright_black]No files matched '{word}'. Do you want to create the file and add it to git?"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
create_file = Confirm.ask(f"[red]No files matched '{word}'. Do you want to create the file?")
|
create_file = Confirm.ask(
|
||||||
|
f"[bright_black]No files matched '{word}'. Do you want to create the file?"
|
||||||
|
)
|
||||||
|
|
||||||
if create_file:
|
if create_file:
|
||||||
with open(os.path.join(self.coder.root, word), 'w') as new_file:
|
with open(os.path.join(self.coder.root, word), "w") as new_file:
|
||||||
pass
|
pass
|
||||||
matched_files = [word]
|
matched_files = [word]
|
||||||
if self.coder.repo is not None:
|
if self.coder.repo is not None:
|
||||||
|
@ -171,7 +175,9 @@ class Commands:
|
||||||
)
|
)
|
||||||
if abs_file_path not in self.coder.abs_fnames:
|
if abs_file_path not in self.coder.abs_fnames:
|
||||||
self.coder.abs_fnames.add(abs_file_path)
|
self.coder.abs_fnames.add(abs_file_path)
|
||||||
self.console.print(f"[red]Added {matched_file} to the chat")
|
self.console.print(
|
||||||
|
f"[bright_black]Added {matched_file} to the chat"
|
||||||
|
)
|
||||||
added_fnames.append(matched_file)
|
added_fnames.append(matched_file)
|
||||||
else:
|
else:
|
||||||
self.console.print(f"[red]{matched_file} is already in the chat")
|
self.console.print(f"[red]{matched_file} is already in the chat")
|
||||||
|
@ -204,7 +210,9 @@ class Commands:
|
||||||
for matched_file in matched_files:
|
for matched_file in matched_files:
|
||||||
relative_fname = os.path.relpath(matched_file, self.coder.root)
|
relative_fname = os.path.relpath(matched_file, self.coder.root)
|
||||||
self.coder.abs_fnames.remove(matched_file)
|
self.coder.abs_fnames.remove(matched_file)
|
||||||
self.console.print(f"[red]Removed {relative_fname} from the chat")
|
self.console.print(
|
||||||
|
f"[bright_black]Removed {relative_fname} from the chat"
|
||||||
|
)
|
||||||
|
|
||||||
def cmd_ls(self, args):
|
def cmd_ls(self, args):
|
||||||
"List files and show their chat status"
|
"List files and show their chat status"
|
||||||
|
@ -221,11 +229,11 @@ class Commands:
|
||||||
other_files.append(file)
|
other_files.append(file)
|
||||||
|
|
||||||
if chat_files:
|
if chat_files:
|
||||||
self.console.print("[red]Files in chat:\n")
|
self.console.print("[bright_black]Files in chat:\n")
|
||||||
for file in chat_files:
|
for file in chat_files:
|
||||||
self.console.print(f"[red] {file}")
|
self.console.print(f"[bright_black] {file}")
|
||||||
|
|
||||||
if other_files:
|
if other_files:
|
||||||
self.console.print("\n[red]Repo files not in the chat:\n")
|
self.console.print("\n[bright_black]Repo files not in the chat:\n")
|
||||||
for file in other_files:
|
for file in other_files:
|
||||||
self.console.print(f"[red] {file}")
|
self.console.print(f"[bright_black] {file}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue