refactor: Initialize Commands instance in Coder

This commit is contained in:
Paul Gauthier (aider) 2024-08-01 14:45:57 -03:00
parent 70fbe10643
commit b5e51d138e
2 changed files with 6 additions and 4 deletions

View file

@ -21,7 +21,7 @@ from rich.console import Console, Text
from rich.markdown import Markdown from rich.markdown import Markdown
from aider import __version__, models, prompts, urls, utils from aider import __version__, models, prompts, urls, utils
from aider.commands import Commands from aider.commands import Commands, SwitchCoder
from aider.history import ChatSummary from aider.history import ChatSummary
from aider.io import InputOutput from aider.io import InputOutput
from aider.linter import Linter from aider.linter import Linter
@ -204,7 +204,6 @@ class Coder:
code_theme="default", code_theme="default",
stream=True, stream=True,
use_git=True, use_git=True,
voice_language=None,
cur_messages=None, cur_messages=None,
done_messages=None, done_messages=None,
max_chat_history_tokens=None, max_chat_history_tokens=None,
@ -216,6 +215,7 @@ class Coder:
aider_commit_hashes=None, aider_commit_hashes=None,
map_mul_no_files=8, map_mul_no_files=8,
verify_ssl=True, verify_ssl=True,
commands=None,
): ):
if not fnames: if not fnames:
fnames = [] fnames = []
@ -268,7 +268,7 @@ class Coder:
self.show_diffs = show_diffs self.show_diffs = show_diffs
self.commands = Commands(self.io, self, voice_language, verify_ssl=verify_ssl) self.commands = commands or Commands(self.io, self)
self.repo = repo self.repo = repo
if use_git and self.repo is None: if use_git and self.repo is None:

View file

@ -473,6 +473,8 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
commit_prompt=args.commit_prompt, commit_prompt=args.commit_prompt,
) )
commands = Commands(io, None, args.voice_language, verify_ssl=args.verify_ssl)
try: try:
coder = Coder.create( coder = Coder.create(
main_model=main_model, main_model=main_model,
@ -491,7 +493,6 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
code_theme=args.code_theme, code_theme=args.code_theme,
stream=args.stream, stream=args.stream,
use_git=args.git, use_git=args.git,
voice_language=args.voice_language,
max_chat_history_tokens=args.max_chat_history_tokens, max_chat_history_tokens=args.max_chat_history_tokens,
restore_chat_history=args.restore_chat_history, restore_chat_history=args.restore_chat_history,
auto_lint=args.auto_lint, auto_lint=args.auto_lint,
@ -499,6 +500,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
lint_cmds=lint_cmds, lint_cmds=lint_cmds,
test_cmd=args.test_cmd, test_cmd=args.test_cmd,
verify_ssl=args.verify_ssl, verify_ssl=args.verify_ssl,
commands=commands,
) )
except ValueError as err: except ValueError as err: