From aedd6ed8d00956d3517f141ca4511caec153a530 Mon Sep 17 00:00:00 2001 From: Arseniy Pavlenko Date: Thu, 3 Aug 2023 23:37:44 +0300 Subject: [PATCH 01/31] Update base_coder.py It fixes 2 exceptions on Azure GPT-4 1) Traceback (most recent call last): File "/opt/homebrew/bin//aider", line 8, in sys.exit(main()) File "/opt/homebrew/lib/python3.10/site-packages/aider/main.py", line 523, in main coder.run() File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 339, in run new_user_message = self.run_loop() File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 423, in run_loop return self.send_new_user_message(inp) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 456, in send_new_user_message interrupted = self.send(messages, functions=self.functions) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 580, in send self.show_send_output_stream(completion) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 680, in show_send_output_stream sys.stdout.write(text) UnboundLocalError: local variable 'text' referenced before assignment 2) Traceback (most recent call last): File "/opt/homebrew/bin//aider", line 8, in sys.exit(main()) File "/opt/homebrew/lib/python3.10/site-packages/aider/main.py", line 523, in main coder.run() File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 339, in run new_user_message = self.run_loop() File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 423, in run_loop return self.send_new_user_message(inp) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 456, in send_new_user_message interrupted = self.send(messages, functions=self.functions) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 580, in send self.show_send_output_stream(completion) File "/opt/homebrew/lib/python3.10/site-packages/aider/coders/base_coder.py", line 656, in show_send_output_stream if chunk.choices[0].finish_reason == "length": IndexError: list index out of range --- aider/coders/base_coder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 07a0974b9..83597e075 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -653,6 +653,10 @@ class Coder: live.start() for chunk in completion: + text = '' + if len(chunk.choices) == 0: + continue + if chunk.choices[0].finish_reason == "length": raise ExhaustedContextWindow() From 0328e0b4c129398349027657f656bdcacb7b97c7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 4 Aug 2023 07:27:43 -0300 Subject: [PATCH 02/31] copy --- docs/faq.md | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 58ce94a46..2314329ef 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -107,26 +107,16 @@ In these cases, here are some things you might try: ## Can I use aider with other LLMs, local LLMs, etc? -Aider does not officially support use with LLMs other than OpenAI's gpt-3.5-turbo and gpt-4 -and their variants. -This is because while it's "easy" to connect aider to a new LLM, it's "hard" -to actually teach new LLMs to *edit* code. +Aider only has experimental support for LLMs other than OpenAI's GPT-3.5 and GPT-4. This is for two reasons: -GPT-3.5 is just barely able to understand how to modify existing source code files, -and GPT-4 is quite good at it. -Getting them working that well was a significant undertaking, involving -[specific code editing prompts and backends for each model and extensive benchmarking](https://aider.chat/docs/benchmarks.html). -Officially supporting new LLMs will probably require a similar effort to tailor the -prompts and editing backends. +- GPT-3.5 is just barely capable of *editing code* to provide aider's interactive "pair programming" style workflow. None of the other models seem to be as capable as GPT-3.5. +- Just "hooking up" aider to a new model by connecting to its API is almost certainly not enough to get it working in a useful way. Getting aider working well with GPT-3.5 and GPT-4 was a significant undertaking, involving [specific code editing prompts and backends for each model and extensive benchmarking](https://aider.chat/docs/benchmarks.html). Officially supporting each new LLM will probably require a similar effort to tailor the prompts and editing backends. -That said, aider does provide some features to experiment with other models. -Numerous users have already done experiments with numerous models. -So far, no one has reported much success in working with them the way aider -can work with GPT-3.5 and GPT-4. +That said, aider does provide features to experiment with other models. Numerous users have already done experiments with numerous models. None of these experiments have yet identified other models that look like they are capable of working with aider. -Once we see signs that a *particular* model is capable of code editing, -it would be reasonable for aider to attempt to officially support such a model. -Until then, aider will simply maintain experimental support for using alternative models. +Once we see signs that a *particular* model is capable of code editing, it would be reasonable for aider to attempt to officially support such a model. Until then, aider will simply maintain experimental support for using alternative models. + +There are ongoing discussions about [LLM integrations in the aider discord](https://discord.com/channels/1131200896827654144/1133060780649087048). ### OpenAI API compatible LLMs @@ -141,7 +131,7 @@ Here are some [LocalAI](https://github.com/go-skynet/LocalAI) and [SimpleAI](https://github.com/lhenault/simpleAI) -look like relevant tools to serve local models via a compatible API: +look like relevant tools to serve local models via a compatible API. ### Azure From fcce0c2c396ce8b973d6e7a027d19679c7a4f4fc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 4 Aug 2023 07:40:29 -0300 Subject: [PATCH 03/31] copy --- docs/faq.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 2314329ef..789adecb5 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -118,14 +118,13 @@ Once we see signs that a *particular* model is capable of code editing, it would There are ongoing discussions about [LLM integrations in the aider discord](https://discord.com/channels/1131200896827654144/1133060780649087048). +Here are some [GitHub issues which may contain relevant information](https://github.com/paul-gauthier/aider/issues?q=is%3Aissue+%23172). + ### OpenAI API compatible LLMs If you can make the model accessible via an OpenAI compatible API, you can use `--openai-api-base` to connect to a different API endpoint. -Here are some -[GitHub issues which may contain relevant information](https://github.com/paul-gauthier/aider/issues?q=is%3Aissue+%22openai-api-base%22+). - ### Local LLMs [LocalAI](https://github.com/go-skynet/LocalAI) From 03ac5202dd141b19cb08351603e638d30cdffffd Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 6 Aug 2023 19:51:44 -0300 Subject: [PATCH 04/31] Handle a pending summarization --- aider/coders/base_coder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 07a0974b9..b10e79b3b 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -365,8 +365,8 @@ class Coder: if not self.summarizer.too_big(self.done_messages): return - assert self.summarizer_thread is None - assert self.summarized_done_messages is None + self.summarize_end() + if self.verbose: self.io.tool_output("Starting to summarize chat history.") From 4f8627e81fe5825ffece27c39aba147a939ca33e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:06:14 -0300 Subject: [PATCH 05/31] Add script to fetch and display a shared aider chat transcript. --- share/index.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 share/index.md diff --git a/share/index.md b/share/index.md new file mode 100644 index 000000000..66ec37ba2 --- /dev/null +++ b/share/index.md @@ -0,0 +1,29 @@ + +# Shared aider chat transcript + +A user has shared the following transcript of a pair programming chat session +created using aider. + +
+
+ + From 49b1b228bd2a5d468ac069d28425708fd1f38c8a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:06:35 -0300 Subject: [PATCH 06/31] aider: Add script tag to load marked.min.js from CDN. # Aider chat conversation: USER: also load https://cdn.jsdelivr.net/npm/marked/marked.min.js ASSISTANT: To load the `marked.min.js` library from the CDN, we need to add a script tag in the `index.md` file. Here is the change: ```markdown share/index.md <<<<<<< ORIGINAL From 8e1a1f588633381ac48f3f2940405b4c365f6f05 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:12:45 -0300 Subject: [PATCH 09/31] aider: Add condition to convert non-raw GitHub gist URLs into raw URLs. # Aider chat conversation: USER: if the mdurl is a non-raw github gist like this `https://gist.github.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b` pull out the hash and turn into a raw url like this: `https://gist.githubusercontent.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b/raw/4fd2ac290d164100e51206fb6874e9ac20644fcd` ASSISTANT: To implement this change, we need to modify the `share/index.md` file. We will add a condition to check if the `mdurl` parameter is a non-raw GitHub gist URL. If it is, we will extract the gist ID and convert it into a raw URL. Here is the proposed change: ```markdown share/index.md <<<<<<< ORIGINAL var conv = urlParams.get('mdurl'); if (!conv) { return; } fetch(conv) ======= var conv = urlParams.get('mdurl'); if (!conv) { return; } // Check if the URL is a non-raw GitHub gist var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/; var match = gistRegex.exec(conv); if (match) { // If it is, convert it into a raw URL conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw'; } fetch(conv) >>>>>>> UPDATED ``` This change adds a regular expression to match non-raw GitHub gist URLs. If the `mdurl` parameter matches this pattern, the gist ID is extracted and used to construct a raw URL. The fetch operation then uses this raw URL instead of the original URL. --- share/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/index.md b/share/index.md index 03784289c..c3776e1d5 100644 --- a/share/index.md +++ b/share/index.md @@ -15,6 +15,13 @@ window.onload = function() { if (!conv) { return; } + // Check if the URL is a non-raw GitHub gist + var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/; + var match = gistRegex.exec(conv); + if (match) { + // If it is, convert it into a raw URL + conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw'; + } fetch(conv) .then(response => response.text()) .then(markdown => { From 0f682570a4a5148283704af7d4dd2d9293b6d6a2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:16:56 -0300 Subject: [PATCH 10/31] aider: Fix the issue with forming the raw URL for a non-raw GitHub gist by including the username in the URL. # Aider chat conversation: USER: if the mdurl is a non-raw github gist like this `https://gist.github.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b` pull out the h ash and turn into a raw url like this: `https://gist.githubusercontent.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b/raw/4fd2ac290d1 64100e51206fb6874e9ac20644fcd`. Right now it's not including the username (paul-gauthier) portion in the raw url ASSISTANT: To fix this issue, we need to modify the JavaScript code in the `share/index.md` file. The current code is not correctly forming the raw URL for a non-raw GitHub gist. It's missing the username in the raw URL. Here is the step-by-step plan: 1. Modify the regular expression to capture the username and the gist hash. 2. Update the raw URL formation to include the captured username. Here is the *edit block* for the change: ```markdown share/index.md <<<<<<< ORIGINAL var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/; var match = gistRegex.exec(conv); if (match) { // If it is, convert it into a raw URL conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw'; } ======= var gistRegex = /^https:\/\/gist\.github\.com\/([^\/]+)\/([a-f0-9]+)$/; var match = gistRegex.exec(conv); if (match) { // If it is, convert it into a raw URL conv = 'https://gist.githubusercontent.com/' + match[1] + '/' + match[2] + '/raw'; } >>>>>>> UPDATED ``` This change will correctly form the raw URL for a non-raw GitHub gist by including the username in the URL. --- share/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/index.md b/share/index.md index c3776e1d5..19cb5b104 100644 --- a/share/index.md +++ b/share/index.md @@ -16,11 +16,11 @@ window.onload = function() { return; } // Check if the URL is a non-raw GitHub gist - var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/; + var gistRegex = /^https:\/\/gist\.github\.com\/([^\/]+)\/([a-f0-9]+)$/; var match = gistRegex.exec(conv); if (match) { // If it is, convert it into a raw URL - conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw'; + conv = 'https://gist.githubusercontent.com/' + match[1] + '/' + match[2] + '/raw'; } fetch(conv) .then(response => response.text()) From 68f043bd96d450191681697fcb28c715dd05b4ab Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:30:14 -0300 Subject: [PATCH 11/31] copy --- share/index.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/share/index.md b/share/index.md index 19cb5b104..c5a841645 100644 --- a/share/index.md +++ b/share/index.md @@ -4,6 +4,40 @@ A user has shared the following transcript of a pair programming chat session created using aider. +Aider is a command line tool that lets you pair program with GPT-3.5 or +GPT-4, to edit code stored in your local git repository. +You can start a new project or work with an existing repo. +And you can fluidly switch back and forth between a coding chat where you ask +GPT to edit the code and your own editor to make changes yourself. +Aider makes sure edits from you and GPT are committed to the git repo +with sensible commit messages. + + +## Transcript format + +
+ +> This is output from the aider tool. + +#### These are chat messages written by the user. + +Chat responses from GPT are in a blue font like this, +and often include colorized "diffs" where GPT is making changes +to the source code in the repo. +Here's a sample edit block that switches from printing "hello" to "goodbye": + +```python +hello.py +<<<<<<< ORIGINAL +print("hello") +======= +print("goodbye") +>>>>>>> UPDATED +``` +
+ +## Shared chat transcript +
From 14c683bfdfeb00c2dc4a55183300bb081d4cb555 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:33:06 -0300 Subject: [PATCH 12/31] more specific selector --- share/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/index.md b/share/index.md index c5a841645..30394c8c4 100644 --- a/share/index.md +++ b/share/index.md @@ -38,7 +38,7 @@ print("goodbye") ## Shared chat transcript -
+
@@ -67,7 +67,7 @@ window.onload = function() { return line; }).join('\n'); var html = marked.parse(markdown); - var divElement = document.querySelector('.chat-transcript'); + var divElement = document.querySelector('#shared-transcript'); divElement.innerHTML = html; }) .catch(error => { From b12899f8f3b2389f65ce1e2a6fed5e9ed4ff041e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 11:35:20 -0300 Subject: [PATCH 13/31] copy --- assets/css/style.scss | 4 ++++ share/index.md | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/css/style.scss b/assets/css/style.scss index 47cd764ba..9c6a1cd09 100644 --- a/assets/css/style.scss +++ b/assets/css/style.scss @@ -41,6 +41,10 @@ color: #00FFFF; } +.chat-transcript h1 { + display: none; +} + .chat-transcript h4 { color: #32FF32; border-top: 1px solid #32FF32; diff --git a/share/index.md b/share/index.md index 30394c8c4..ea0edfd0e 100644 --- a/share/index.md +++ b/share/index.md @@ -22,9 +22,8 @@ with sensible commit messages. #### These are chat messages written by the user. Chat responses from GPT are in a blue font like this, -and often include colorized "diffs" where GPT is making changes -to the source code in the repo. -Here's a sample edit block that switches from printing "hello" to "goodbye": +and often include colorized "diffs" where GPT is editing code: + ```python hello.py From 94e5aeac6264a81271f63bbf0159b7632bd9b919 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 7 Aug 2023 13:00:21 -0300 Subject: [PATCH 14/31] copy --- share/index.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/share/index.md b/share/index.md index ea0edfd0e..b323163d3 100644 --- a/share/index.md +++ b/share/index.md @@ -3,15 +3,8 @@ A user has shared the following transcript of a pair programming chat session created using aider. - Aider is a command line tool that lets you pair program with GPT-3.5 or GPT-4, to edit code stored in your local git repository. -You can start a new project or work with an existing repo. -And you can fluidly switch back and forth between a coding chat where you ask -GPT to edit the code and your own editor to make changes yourself. -Aider makes sure edits from you and GPT are committed to the git repo -with sensible commit messages. - ## Transcript format From 3c0720ff1c87a25e415b5df84e99020b0d5c43aa Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:00:21 -0300 Subject: [PATCH 15/31] Fix corner case of undefined `text` when using --no-pretty --- aider/coders/base_coder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index b10e79b3b..ae704b522 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -672,11 +672,11 @@ class Coder: if text: self.partial_response_content += text except AttributeError: - pass + text = None if self.pretty: self.live_incremental_response(live, False) - else: + elif text: sys.stdout.write(text) sys.stdout.flush() finally: From 445785a3a1cf482e61a5c64f5851bb267111fe7e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:04:16 -0300 Subject: [PATCH 16/31] Updated HISTORY --- HISTORY.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 6cf4e3304..949ccb031 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,10 @@ ### main branch -- Fixed /commit bug from repo refactor, added test coverage +- Added a progress bar when initially creating a repo map. +- Fix corner case of pending chat history summarization when dirty committing. +- Fix corner case of undefined `text` when using `--no-pretty`. +- Fixed /commit bug from repo refactor, added test coverage. ### v0.11.0 From 9cb1a9b1863d56e89886df7d5267ad288fb2c274 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:38:37 -0300 Subject: [PATCH 17/31] cleanup --- aider/coders/base_coder.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 1a83a479b..6b821ba9e 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -653,7 +653,6 @@ class Coder: live.start() for chunk in completion: - text = '' if len(chunk.choices) == 0: continue From 75d8115597640e92e52af21aec9cc7c1eb027fec Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:53:14 -0300 Subject: [PATCH 18/31] copy --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cf5e4e959..d3163c1dd 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # aider is GPT powered coding in your terminal -`aider` is a command-line chat tool that allows you to write and edit -code with OpenAI's GPT models. You can ask GPT to help you start -a new project, or modify code in your existing git repo. -Aider makes it easy to -[git commit, diff & undo changes](https://aider.chat/docs/faq.html#how-does-aider-use-git) -proposed by GPT without copy/pasting. -It also has features that [help GPT-4 understand and modify larger codebases](https://aider.chat/docs/ctags.html). +Aider is a command line tool that lets you pair program with GPT-3.5/GPT-4, +to edit code stored in your local git repository. +You can start a new project or work with an existing repo. +And you can fluidly switch back and forth between a coding chat where you ask +GPT to edit the code and your own editor to make changes yourself. +Aider makes sure edits from you and GPT are +[committed to git](https://aider.chat/docs/faq.html#how-does-aider-use-git) +with sensible commit messages. +Aider is unique in that it [works well with pre-existing, larger codebases](https://aider.chat/docs/ctags.html).

aider screencast @@ -43,7 +45,7 @@ $ aider hello.js Using git repo: .git Added hello.js to the chat. -hello.js> write a js app that prints hello world +hello.js> write a js script that prints hello world ``` ## Example chat transcripts From 3698b122151015da97344a3162dd31f8a8b10970 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:55:42 -0300 Subject: [PATCH 19/31] copy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3163c1dd..ec9c3288c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# aider is GPT powered coding in your terminal +# aider is AI pair programming in your terminal Aider is a command line tool that lets you pair program with GPT-3.5/GPT-4, to edit code stored in your local git repository. From 737c2e0b5f60f80d36d3a404ebecb796d5fb9508 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:59:57 -0300 Subject: [PATCH 20/31] aider: Check that the latest commit message contains the filename. # Aider chat conversation: USER: do the todo ASSISTANT: To complete the TODO task in the `test_new_file_commit_message` function, we need to check that the latest commit message contains the filename. We can do this by getting the latest commit message from the git repository and checking if the filename is in it. Here is the change needed in the `tests/test_coder.py` file: python tests/test_coder.py <<<<<<< ORIGINAL # TODO: check that the latest commit message contains str(fname) ======= # Get the latest commit message commit_message = repo.head.commit.message # Check that the latest commit message contains the filename self.assertIn(str(fname), commit_message) >>>>>>> UPDATED --- tests/test_coder.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_coder.py b/tests/test_coder.py index 72b247727..8689f863f 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -22,6 +22,23 @@ class TestCoder(unittest.TestCase): def tearDown(self): self.patcher.stop() + def test_new_file_commit_message(self): + with GitTemporaryDirectory(): + repo = git.Repo() + fname = Path("foo.txt") + + io = InputOutput(yes=True) + # Initialize the Coder object with the mocked IO and mocked repo + coder = Coder.create(models.GPT4, None, io, fnames=[str(fname)]) + + self.assertTrue(fname.exists()) + + # Get the latest commit message + commit_message = repo.head.commit.message + # Check that the latest commit message contains the filename + self.assertIn(str(fname), commit_message) + + def test_allowed_to_edit(self): with GitTemporaryDirectory(): repo = git.Repo(Path.cwd()) From 20c7eb549c22f23a99fd6fc9a2b0592d4e1b7141 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 08:01:15 -0300 Subject: [PATCH 21/31] aider: Mocked `get_commit_message` to return "I added str(fname)". # Aider chat conversation: USER: mock `get_commit_message` to return "I added str(fname)" ASSISTANT: To mock the `get_commit_message` method to return "I added str(fname)", we need to modify the `test_new_file_commit_message` function in the `tests/test_coder.py` file. Here is the change needed: python tests/test_coder.py <<<<<<< ORIGINAL # Get the latest commit message commit_message = repo.head.commit.message # Check that the latest commit message contains the filename self.assertIn(str(fname), commit_message) ======= # Mock the get_commit_message method to return "I added str(fname)" repo.get_commit_message = MagicMock(return_value=f"I added {str(fname)}") # Get the latest commit message commit_message = repo.get_commit_message() # Check that the latest commit message is "I added str(fname)" self.assertEqual(commit_message, f"I added {str(fname)}") >>>>>>> UPDATED --- tests/test_coder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index 8689f863f..9f37dc022 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -33,10 +33,12 @@ class TestCoder(unittest.TestCase): self.assertTrue(fname.exists()) + # Mock the get_commit_message method to return "I added str(fname)" + repo.get_commit_message = MagicMock(return_value=f"I added {str(fname)}") # Get the latest commit message - commit_message = repo.head.commit.message - # Check that the latest commit message contains the filename - self.assertIn(str(fname), commit_message) + commit_message = repo.get_commit_message() + # Check that the latest commit message is "I added str(fname)" + self.assertEqual(commit_message, f"I added {str(fname)}") def test_allowed_to_edit(self): From 88d7e2ed09bed6a42abcb056810f8a1e1152fe90 Mon Sep 17 00:00:00 2001 From: Joshua Vial Date: Tue, 8 Aug 2023 22:58:31 +1200 Subject: [PATCH 22/31] disabling GIT_EDITOR when calling /git --- aider/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aider/commands.py b/aider/commands.py index b6d214006..463b69f91 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -350,8 +350,9 @@ class Commands: combined_output = None try: parsed_args = shlex.split("git " + args) + env = dict(GIT_EDITOR="true", **subprocess.os.environ) result = subprocess.run( - parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True + parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=env ) combined_output = result.stdout except Exception as e: From fe4462704203350ead7f861240074d07efd53700 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 08:02:56 -0300 Subject: [PATCH 23/31] copy --- _layouts/default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_layouts/default.html b/_layouts/default.html index 771b6635a..8e4956b1a 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -20,7 +20,7 @@