From f0233455d2e0e0f301493bcb39c0b406ce8531a7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:34:18 -0700 Subject: [PATCH 01/20] feat: update model warning prompt to offer documentation link --- aider/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aider/main.py b/aider/main.py index 85305cc34..c2346bbd5 100644 --- a/aider/main.py +++ b/aider/main.py @@ -607,9 +607,10 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F if problem: io.tool_output("You can skip this check with --no-show-model-warnings") io.tool_output() + try: - if not io.confirm_ask("Proceed anyway?"): - return 1 + if io.confirm_ask("Open documentation url for more info?", subject=urls.model_warnings): + pass # ai have this launch the url in a browser! except KeyboardInterrupt: return 1 From 4ac838631348815722bd5f2204cf5a57e6c978c4 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:34:19 -0700 Subject: [PATCH 02/20] feat: add browser launch for model warnings documentation --- aider/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index c2346bbd5..751756f38 100644 --- a/aider/main.py +++ b/aider/main.py @@ -6,6 +6,7 @@ import re import sys import threading import traceback +import webbrowser from pathlib import Path import git @@ -610,7 +611,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F try: if io.confirm_ask("Open documentation url for more info?", subject=urls.model_warnings): - pass # ai have this launch the url in a browser! + webbrowser.open(urls.model_warnings) except KeyboardInterrupt: return 1 From e9beb1336c2c59e4044c1248045d8efe067b77fd Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:34:24 -0700 Subject: [PATCH 03/20] style: fix line length in model warnings confirmation prompt --- aider/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index 751756f38..8fc0ab4cd 100644 --- a/aider/main.py +++ b/aider/main.py @@ -610,7 +610,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F io.tool_output() try: - if io.confirm_ask("Open documentation url for more info?", subject=urls.model_warnings): + if io.confirm_ask( + "Open documentation url for more info?", subject=urls.model_warnings + ): webbrowser.open(urls.model_warnings) except KeyboardInterrupt: return 1 From 7e574bc2142d8bd2ed3d113b072c6903c8ecb1af Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:40:56 -0700 Subject: [PATCH 04/20] refactor: improve documentation URL handling and error messages --- aider/main.py | 9 +++++++-- aider/models.py | 3 --- aider/urls.py | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aider/main.py b/aider/main.py index 8fc0ab4cd..902b68c39 100644 --- a/aider/main.py +++ b/aider/main.py @@ -607,13 +607,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F problem = models.sanity_check_models(io, main_model) if problem: io.tool_output("You can skip this check with --no-show-model-warnings") - io.tool_output() try: if io.confirm_ask( "Open documentation url for more info?", subject=urls.model_warnings ): webbrowser.open(urls.model_warnings) + io.tool_output() except KeyboardInterrupt: return 1 @@ -830,7 +830,11 @@ def check_and_load_imports(io, verbose=False): except Exception as err: io.tool_error(str(err)) io.tool_output("Error loading required imports. Did you install aider properly?") - io.tool_output("https://aider.chat/docs/install/install.html") + if io.confirm_ask( + "Open documentation url for more info?", subject=urls.install_properly + ): + webbrowser.open(urls.install_properly) + sys.exit(1) installs[str(key)] = True @@ -867,6 +871,7 @@ def load_slow_imports(swallow=True): raise e + if __name__ == "__main__": status = main() sys.exit(status) diff --git a/aider/models.py b/aider/models.py index 602d1d05d..b56c28086 100644 --- a/aider/models.py +++ b/aider/models.py @@ -1042,9 +1042,6 @@ def sanity_check_model(io, model): for match in possible_matches: io.tool_output(f"- {match}") - if show: - io.tool_output(f"For more info, see: {urls.model_warnings}") - return show diff --git a/aider/urls.py b/aider/urls.py index 6ccf46012..52ed0ec10 100644 --- a/aider/urls.py +++ b/aider/urls.py @@ -10,3 +10,4 @@ llms = "https://aider.chat/docs/llms.html" large_repos = "https://aider.chat/docs/faq.html#can-i-use-aider-in-a-large-mono-repo" github_issues = "https://github.com/Aider-AI/aider/issues/new" git_index_version = "https://github.com/Aider-AI/aider/issues/211" +install_properly = "https://aider.chat/docs/troubleshooting/imports.html" From aeca62bcf6cf1316b664d9445855d7175826d832 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:41:04 -0700 Subject: [PATCH 05/20] fix: remove unused import of urls module --- aider/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/models.py b/aider/models.py index b56c28086..f0d9b7131 100644 --- a/aider/models.py +++ b/aider/models.py @@ -13,7 +13,6 @@ import json5 import yaml from PIL import Image -from aider import urls from aider.dump import dump # noqa: F401 from aider.llm import litellm From 52f697e5138689b2ce656e4d21c218ba8d94b1ba Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:41:11 -0700 Subject: [PATCH 06/20] style: remove extra blank line before main block --- aider/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index 902b68c39..eb1ebf3ab 100644 --- a/aider/main.py +++ b/aider/main.py @@ -871,7 +871,6 @@ def load_slow_imports(swallow=True): raise e - if __name__ == "__main__": status = main() sys.exit(status) From 9e0e68caf9bd55647fe90eae8029c6cf6176184b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:41:39 -0700 Subject: [PATCH 07/20] copy --- aider/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index eb1ebf3ab..707dc3eee 100644 --- a/aider/main.py +++ b/aider/main.py @@ -1,4 +1,3 @@ -# ai import configparser import json import os From 763724ed4e07a6b8de30b3d0f56be176a9c69c28 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:42:44 -0700 Subject: [PATCH 08/20] docs: add comment about prompting user for URL opening --- aider/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aider/main.py b/aider/main.py index 707dc3eee..ca5219667 100644 --- a/aider/main.py +++ b/aider/main.py @@ -366,6 +366,7 @@ def sanity_check_repo(repo, io): io.tool_error("Aider only works with git repos with version number 1 or 2.") io.tool_output("You may be able to convert your repo: git update-index --index-version=2") io.tool_output("Or run aider --no-git to proceed without using git.") + #ai ask if the user wants to open the url! io.tool_output(urls.git_index_version) return False From fe3dbba1d9429601171011ac848f118aa46e6807 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:42:46 -0700 Subject: [PATCH 09/20] feat: add browser URL launch with user confirmation prompt --- aider/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index ca5219667..53251f7a0 100644 --- a/aider/main.py +++ b/aider/main.py @@ -367,7 +367,8 @@ def sanity_check_repo(repo, io): io.tool_output("You may be able to convert your repo: git update-index --index-version=2") io.tool_output("Or run aider --no-git to proceed without using git.") #ai ask if the user wants to open the url! - io.tool_output(urls.git_index_version) + if io.confirm_ask("Open documentation url for more info?", subject=urls.git_index_version): + webbrowser.open(urls.git_index_version) return False io.tool_error("Unable to read git repository, it may be corrupt?") From 31babf39cd17aa8ee5f49582f7f9ee5a9ccfae99 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:42:50 -0700 Subject: [PATCH 10/20] style: fix comment spacing in sanity_check_repo function --- aider/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index 53251f7a0..d6a578b77 100644 --- a/aider/main.py +++ b/aider/main.py @@ -366,7 +366,7 @@ def sanity_check_repo(repo, io): io.tool_error("Aider only works with git repos with version number 1 or 2.") io.tool_output("You may be able to convert your repo: git update-index --index-version=2") io.tool_output("Or run aider --no-git to proceed without using git.") - #ai ask if the user wants to open the url! + # ai ask if the user wants to open the url! if io.confirm_ask("Open documentation url for more info?", subject=urls.git_index_version): webbrowser.open(urls.git_index_version) return False From cd1496f91bb1f45d29a3581188e25a29def30400 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:51:49 -0700 Subject: [PATCH 11/20] copy --- aider/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index d6a578b77..fe5d32dd5 100644 --- a/aider/main.py +++ b/aider/main.py @@ -366,7 +366,6 @@ def sanity_check_repo(repo, io): io.tool_error("Aider only works with git repos with version number 1 or 2.") io.tool_output("You may be able to convert your repo: git update-index --index-version=2") io.tool_output("Or run aider --no-git to proceed without using git.") - # ai ask if the user wants to open the url! if io.confirm_ask("Open documentation url for more info?", subject=urls.git_index_version): webbrowser.open(urls.git_index_version) return False From 4f52ad385a9468a7d70898c2e48f294525206ea4 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 30 Oct 2024 11:52:09 -0700 Subject: [PATCH 12/20] copy --- aider/website/HISTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/aider/website/HISTORY.md b/aider/website/HISTORY.md index 58794dced..598c87056 100644 --- a/aider/website/HISTORY.md +++ b/aider/website/HISTORY.md @@ -32,6 +32,7 @@ cog.out(text) - New `--no-fancy-input` switch disables prompt toolkit input, now still available with `--no-pretty`. - Properly support all o1 models, regardless of provider. - Improved handling of API errors, especially when accessing the weak model. +- Aider wrote 70% of the code in this release. ### Aider v0.60.1 From 15a0eb976f9aa4591fde0ca4cf5bd8cd6e0da169 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:04 -0700 Subject: [PATCH 13/20] test: update git index version test to check confirm_ask call --- tests/basic/test_sanity_check_repo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 9573ea130..5814cb5cc 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -125,7 +125,10 @@ def test_git_index_version_greater_than_2(create_repo, mock_io): "You may be able to convert your repo: git update-index --index-version=2" ) mock_io.tool_output.assert_any_call("Or run aider --no-git to proceed without using git.") - mock_io.tool_output.assert_any_call("https://github.com/Aider-AI/aider/issues/211") + mock_io.confirm_ask.assert_any_call( + "Open documentation url for more info?", + subject=urls.git_index_version + ) def test_bare_repository(create_repo, mock_io, tmp_path): From 63330aa833d473aed2e4113c35616901ee485fe9 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:08 -0700 Subject: [PATCH 14/20] style: fix line wrapping in test file --- tests/basic/test_sanity_check_repo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 5814cb5cc..221a52ac0 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -126,8 +126,7 @@ def test_git_index_version_greater_than_2(create_repo, mock_io): ) mock_io.tool_output.assert_any_call("Or run aider --no-git to proceed without using git.") mock_io.confirm_ask.assert_any_call( - "Open documentation url for more info?", - subject=urls.git_index_version + "Open documentation url for more info?", subject=urls.git_index_version ) From ee4decc50be97d03260ea4f25f7347cd997d63e4 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:21 -0700 Subject: [PATCH 15/20] fix: add missing urls import in test_sanity_check_repo.py --- tests/basic/test_sanity_check_repo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 221a52ac0..92223cafb 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -6,6 +6,8 @@ from unittest import mock import pytest from git import GitError, Repo +from aider import urls + from aider.main import sanity_check_repo From 71a8b286dc1a4d23545ce7d1f65db507ba0f3331 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:25 -0700 Subject: [PATCH 16/20] style: fix linting issues in test_sanity_check_repo.py --- tests/basic/test_sanity_check_repo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 92223cafb..051c01e8d 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -7,7 +7,6 @@ import pytest from git import GitError, Repo from aider import urls - from aider.main import sanity_check_repo From 920e8da57cfe54eebca42130b8b9863d7b1b4f8f Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:48 -0700 Subject: [PATCH 17/20] test: mock webbrowser.open in git index version test --- tests/basic/test_sanity_check_repo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 051c01e8d..97ca1cc95 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -7,6 +7,7 @@ import pytest from git import GitError, Repo from aider import urls +import webbrowser from aider.main import sanity_check_repo @@ -100,7 +101,8 @@ def test_detached_head_state(create_repo, mock_io): mock_io.tool_output.assert_not_called() -def test_git_index_version_greater_than_2(create_repo, mock_io): +@mock.patch('webbrowser.open') +def test_git_index_version_greater_than_2(mock_browser, create_repo, mock_io): repo_path, repo = create_repo # Set the git index version to 3 set_git_index_version(str(repo_path), 3) From a70b364842dd4ca31cb7c6523033105509ff53b1 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 11:59:52 -0700 Subject: [PATCH 18/20] style: fix import order and quote style in test file --- tests/basic/test_sanity_check_repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index 97ca1cc95..dff3a7dca 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -1,13 +1,13 @@ import os import shutil import struct +import webbrowser from unittest import mock import pytest from git import GitError, Repo from aider import urls -import webbrowser from aider.main import sanity_check_repo @@ -101,7 +101,7 @@ def test_detached_head_state(create_repo, mock_io): mock_io.tool_output.assert_not_called() -@mock.patch('webbrowser.open') +@mock.patch("webbrowser.open") def test_git_index_version_greater_than_2(mock_browser, create_repo, mock_io): repo_path, repo = create_repo # Set the git index version to 3 From bce586f510793a4dddf91103e88816c865fb4dbf Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 12:00:12 -0700 Subject: [PATCH 19/20] fix: remove unused webbrowser import in test file --- tests/basic/test_sanity_check_repo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/basic/test_sanity_check_repo.py b/tests/basic/test_sanity_check_repo.py index dff3a7dca..3ba18e2f3 100644 --- a/tests/basic/test_sanity_check_repo.py +++ b/tests/basic/test_sanity_check_repo.py @@ -1,7 +1,6 @@ import os import shutil import struct -import webbrowser from unittest import mock import pytest From d81c421bfe2b7ff58142b8183b9b334800125c23 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 30 Oct 2024 12:04:43 -0700 Subject: [PATCH 20/20] test: mock webbrowser.open in test setup --- tests/basic/test_main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index 8b718131c..6fa4a9ed6 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -32,6 +32,8 @@ class TestMain(TestCase): os.environ["HOME"] = self.homedir_obj.name self.input_patcher = patch("builtins.input", return_value=None) self.mock_input = self.input_patcher.start() + self.webbrowser_patcher = patch("webbrowser.open") + self.mock_webbrowser = self.webbrowser_patcher.start() def tearDown(self): os.chdir(self.original_cwd) @@ -40,6 +42,7 @@ class TestMain(TestCase): os.environ.clear() os.environ.update(self.original_env) self.input_patcher.stop() + self.webbrowser_patcher.stop() def test_main_with_empty_dir_no_files_on_command(self): main(["--no-git", "--exit"], input=DummyInput(), output=DummyOutput())