diff --git a/aider/coder.py b/aider/coder.py index a5730d160..9c47b9f13 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -76,7 +76,7 @@ class Coder: if self.repo: rel_repo_dir = os.path.relpath(self.repo.git_dir, os.getcwd()) - self.io.tool("Using git repo:", rel_repo_dir) + self.io.tool_output("Using git repo:", rel_repo_dir) else: self.io.tool_error("No suitable git repo, will not automatically commit edits.") self.find_common_root() @@ -93,7 +93,7 @@ class Coder: else: self.root = os.getcwd() - self.io.tool(f"Common root directory: {self.root}") + self.io.tool_output(f"Common root directory: {self.root}") def set_repo(self, cmd_line_fnames): if not cmd_line_fnames: @@ -103,7 +103,7 @@ class Coder: for fname in cmd_line_fnames: fname = Path(fname) if not fname.exists(): - self.io.tool(f"Creating empty file {fname}") + self.io.tool_output(f"Creating empty file {fname}") fname.parent.mkdir(parents=True, exist_ok=True) fname.touch() @@ -116,7 +116,7 @@ class Coder: if fname.is_dir(): continue - self.io.tool(f"Added {fname} to the chat") + self.io.tool_output(f"Added {fname} to the chat") fname = fname.resolve() self.abs_fnames.add(str(fname)) @@ -145,18 +145,18 @@ class Coder: if new_files: rel_repo_dir = os.path.relpath(repo.git_dir, os.getcwd()) - self.io.tool(f"Files not tracked in {rel_repo_dir}:") + self.io.tool_output(f"Files not tracked in {rel_repo_dir}:") for fn in new_files: - self.io.tool(f" - {fn}") + self.io.tool_output(f" - {fn}") if self.io.confirm_ask("Add them?"): for relative_fname in new_files: repo.git.add(relative_fname) - self.io.tool(f"Added {relative_fname} to the git repo") + self.io.tool_output(f"Added {relative_fname} to the git repo") show_files = ", ".join(new_files) commit_message = f"Added new files to the git repo: {show_files}" repo.git.commit("-m", commit_message, "--no-verify") commit_hash = repo.head.commit.hexsha[:7] - self.io.tool(f"Commit {commit_hash} {commit_message}") + self.io.tool_output(f"Commit {commit_hash} {commit_message}") else: self.io.tool_error("Skipped adding new files to the git repo.") return @@ -258,7 +258,7 @@ class Coder: self.cur_messages = [] if inp.strip(): - self.io.tool("Use up-arrow to retry previous command:", inp) + self.io.tool_output("Use up-arrow to retry previous command:", inp) return if not inp: @@ -296,7 +296,7 @@ class Coder: dict(role="assistant", content=content), ] - self.io.tool() + self.io.tool_output() if interrupted: return @@ -366,7 +366,7 @@ class Coder: return for rel_fname in mentioned_rel_fnames: - self.io.tool(rel_fname) + self.io.tool_output(rel_fname) if not self.io.confirm_ask("Add these files to the chat?"): return @@ -476,9 +476,9 @@ class Coder: edited.add(path) if utils.do_replace(full_path, original, updated, self.dry_run): if self.dry_run: - self.io.tool(f"Dry run, did not apply edit to {path}") + self.io.tool_output(f"Dry run, did not apply edit to {path}") else: - self.io.tool(f"Applied edit to {path}") + self.io.tool_output(f"Applied edit to {path}") else: self.io.tool_error(f"Failed to apply edit to {path}") @@ -574,7 +574,7 @@ class Coder: raise ValueError(f"Invalid value for 'which': {which}") if self.show_diffs or ask: - # don't use io.tool() because we don't want to log or further colorize + # don't use io.tool_output() because we don't want to log or further colorize print(diffs) context = self.get_context_from_history(history) @@ -588,9 +588,9 @@ class Coder: if ask: if which == "repo_files": - self.io.tool("Git repo has uncommitted changes.") + self.io.tool_output("Git repo has uncommitted changes.") else: - self.io.tool("Files have uncommitted changes.") + self.io.tool_output("Files have uncommitted changes.") res = self.io.prompt_ask( "Commit before the chat proceeds [y/n/commit message]?", @@ -598,7 +598,7 @@ class Coder: ).strip() self.last_asked_for_commit_time = self.get_last_modified() - self.io.tool() + self.io.tool_output() if res.lower() in ["n", "no"]: self.io.tool_error("Skipped commmit.") @@ -611,7 +611,7 @@ class Coder: full_commit_message = commit_message + "\n\n" + context repo.git.commit("-m", full_commit_message, "--no-verify") commit_hash = repo.head.commit.hexsha[:7] - self.io.tool(f"Commit {commit_hash} {commit_message}") + self.io.tool_output(f"Commit {commit_hash} {commit_message}") return commit_hash, commit_message diff --git a/aider/commands.py b/aider/commands.py index 00fd36182..666b3dac8 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -37,7 +37,7 @@ class Commands: if cmd_method: return cmd_method(args) else: - self.io.tool(f"Error: Command {cmd_name} not found.") + self.io.tool_output(f"Error: Command {cmd_name} not found.") def run(self, inp): words = inp.strip().split() @@ -110,7 +110,7 @@ class Commands: self.io.tool_error("The last commit was not made by aider in this chat session.") return self.coder.repo.git.reset("--hard", "HEAD~1") - self.io.tool( + self.io.tool_output( f"{last_commit.message.strip()}\n" f"The above commit {self.coder.last_aider_commit_hash} " "was reset and removed from git.\n" @@ -131,7 +131,7 @@ class Commands: commits = f"{self.coder.last_aider_commit_hash}~1" diff = self.coder.get_diffs(commits, self.coder.last_aider_commit_hash) - # don't use io.tool() because we don't want to log or further colorize + # don't use io.tool_output() because we don't want to log or further colorize print(diff) def completions_add(self, partial): @@ -177,7 +177,7 @@ class Commands: abs_file_path = os.path.abspath(os.path.join(self.coder.root, matched_file)) if abs_file_path not in self.coder.abs_fnames: self.coder.abs_fnames.add(abs_file_path) - self.io.tool(f"Added {matched_file} to the chat") + self.io.tool_output(f"Added {matched_file} to the chat") added_fnames.append(matched_file) else: self.io.tool_error(f"{matched_file} is already in the chat") @@ -214,7 +214,7 @@ class Commands: for matched_file in matched_files: relative_fname = os.path.relpath(matched_file, self.coder.root) self.coder.abs_fnames.remove(matched_file) - self.io.tool(f"Removed {relative_fname} from the chat") + self.io.tool_output(f"Removed {relative_fname} from the chat") def cmd_run(self, args): "Run a shell command and optionally add the output to the chat" @@ -258,14 +258,14 @@ class Commands: other_files.append(file) if chat_files: - self.io.tool("Files in chat:\n") + self.io.tool_output("Files in chat:\n") for file in chat_files: - self.io.tool(f" {file}") + self.io.tool_output(f" {file}") if other_files: - self.io.tool("\nRepo files not in the chat:\n") + self.io.tool_output("\nRepo files not in the chat:\n") for file in other_files: - self.io.tool(f" {file}") + self.io.tool_output(f" {file}") def cmd_help(self, args): "Show help about all commands" @@ -275,6 +275,6 @@ class Commands: cmd_method = getattr(self, cmd_method_name, None) if cmd_method: description = cmd_method.__doc__ - self.io.tool(f"{cmd} {description}") + self.io.tool_output(f"{cmd} {description}") else: - self.io.tool(f"{cmd} No description available.") + self.io.tool_output(f"{cmd} No description available.") diff --git a/aider/io.py b/aider/io.py index 7a8fc8966..9f600aff6 100644 --- a/aider/io.py +++ b/aider/io.py @@ -217,7 +217,7 @@ class InputOutput: style = dict(style=self.tool_error_color) if self.tool_error_color else dict() self.console.print(message, **style) - def tool(self, *messages, log_only=False): + def tool_output(self, *messages, log_only=False): if messages: hist = " ".join(messages) hist = f"{hist.strip()}" diff --git a/aider/main.py b/aider/main.py index 6203e0543..5cbf53c27 100644 --- a/aider/main.py +++ b/aider/main.py @@ -182,12 +182,12 @@ def main(args=None, input=None, output=None): if args.verbose: show = parser.format_values() - io.tool(show) - io.tool("Option settings:") + io.tool_output(show) + io.tool_output("Option settings:") for arg, val in sorted(vars(args).items()): - io.tool(f" - {arg}: {val}") + io.tool_output(f" - {arg}: {val}") - io.tool(*sys.argv, log_only=True) + io.tool_output(*sys.argv, log_only=True) if not args.openai_api_key: io.tool_error("No OpenAI API key provided. Use --openai-api-key or env OPENAI_API_KEY.") @@ -216,7 +216,7 @@ def main(args=None, input=None, output=None): coder.update_files(content, inp="") return - io.tool("Use /help to see in-chat commands.") + io.tool_output("Use /help to see in-chat commands.") coder.run()