Commit graph

2505 commits

Author SHA1 Message Date
Paul Gauthier
1fcb090ff6 Refactor coder.get_tracked_files to coder.repo.get_tracked_files in test_coder.py and add test_get_commit_message_no_strip_unmatched_quotes in test_repo.py. 2023-07-21 14:36:26 -03:00
Paul Gauthier
e9090f8d61 Refactored creating a Coder object and getting tracked files in test_repo.py. 2023-07-21 14:32:20 -03:00
Paul Gauthier
b9dc419f19 Refactor test_get_commit_message_strip_quotes to use a mocked send_with_retries function and set the return value of the mocked function. 2023-07-21 14:30:33 -03:00
Paul Gauthier
1733fe4c90 aider: To match the return value of mock_send with commit_message = response.choices[0].message.content, modify the return value of mock_send in the test_get_commit_message function in the tests/test_repo.py file.
# Aider chat conversation:

USER: in `test_get_commit_message`, the mock_send return value needs to match the commit_message = response.choices[0].message.content

ASSISTANT: To match the return value of `mock_send` with `commit_message = response.choices[0].message.content`, we need to modify the return value of `mock_send` in the `test_get_commit_message` function in the `tests/test_repo.py` file.

The `send_with_retries` function returns a tuple where the second element is the response from the OpenAI API. The response is expected to be an object with a `choices` attribute, which is a list of objects, each with a `message` attribute, which in turn has a `content` attribute.

So, we need to return a mock response object that has these attributes. Here's how to do it:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        mock_send.return_value = (
            None,
            "a good commit message"
        )
=======
        mock_response = MagicMock()
        mock_response.choices = [MagicMock()]
        mock_response.choices[0].message.content = "a good commit message"
        mock_send.return_value = (
            None,
            mock_response
        )
>>>>>>> UPDATED
```

This change will make the `mock_send` function return a mock response object that has the same structure as the actual response from the OpenAI API, allowing the `get_commit_message` method to correctly extract the commit message.
2023-07-21 14:29:15 -03:00
Paul Gauthier
4a8add1b5d Refactor get_tracked_files method to be called on self.coder.repo instead of self.coder. 2023-07-21 14:28:06 -03:00
Paul Gauthier
a789de9433 Refactor test_get_commit_message to use the correct import and handle the return value of mock_send correctly. 2023-07-21 14:27:31 -03:00
Paul Gauthier
6f3b498228 aider: Set the return value of the mocked function aider.sendchat.send_with_retries to "a good commit message" in the test_get_commit_message test.
# Aider chat conversation:

USER: do the todo

ASSISTANT: To complete the TODO, we need to mock the return value of the function `aider.sendchat.send_with_retries`. This can be done by setting the `return_value` attribute of the mock object `mock_send`.

Here is the change:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
    @patch("aider.sendchat.send_with_retries")
    def test_get_commit_message(self, mock_send):
        # TODO: make aider.sendchat.send_with_retries return "a good commit message"

        repo = AiderRepo(InputOutput(), None)
        # Call the get_commit_message method with dummy diff and context
        result = repo.get_commit_message("dummy diff", "dummy context")

        # Assert that the returned message is the expected one
        self.assertEqual(result, "a good commit_message")
=======
    @patch("aider.sendchat.send_with_retries")
    def test_get_commit_message(self, mock_send):
        # Set the return value of the mocked function
        mock_send.return_value = "a good commit message"

        repo = AiderRepo(InputOutput(), None)
        # Call the get_commit_message method with dummy diff and context
        result = repo.get_commit_message("dummy diff", "dummy context")

        # Assert that the returned message is the expected one
        self.assertEqual(result, "a good commit message")
>>>>>>> UPDATED
```
Please let me know if you need further changes.
2023-07-21 14:24:49 -03:00
Paul Gauthier
ebd8d9725b wip 2023-07-21 14:24:19 -03:00
Paul Gauthier
28578217da move tests to test_sendchat.py 2023-07-21 14:17:14 -03:00
Paul Gauthier
d0be8d4cbd cleanup 2023-07-21 14:09:38 -03:00
Paul Gauthier
0ac6957d04 noop 2023-07-21 14:07:30 -03:00
Paul Gauthier
4f94f720b5 cleanup 2023-07-21 14:05:30 -03:00
Paul Gauthier
5a163237b4 noop 2023-07-21 13:59:49 -03:00
Paul Gauthier
317412f854 noop 2023-07-21 13:56:48 -03:00
Paul Gauthier
01ea691957 Update commands to use the underlying repo 2023-07-21 13:01:48 -03:00
Paul Gauthier
74875eac6e sssh 2023-07-21 12:58:23 -03:00
Paul Gauthier
14b24dc2fd works 2023-07-21 12:57:01 -03:00
Paul Gauthier
296e7614c4 wip 2023-07-21 12:06:32 -03:00
Paul Gauthier
23beb7cb5d wip 2023-07-21 11:49:19 -03:00
Paul Gauthier
289887d94f refactor send_with_retries 2023-07-21 11:22:59 -03:00
Paul Gauthier
e34e6ff897 wip 2023-07-21 11:14:15 -03:00
Paul Gauthier
6d044485f3 Merge branch 'main' into chat-history 2023-07-21 07:44:09 -03:00
Paul Gauthier
0d6abde253 copy 2023-07-21 07:41:30 -03:00
Paul Gauthier
568be3812b Fix last_keyboard_interrupt in benchmark 2023-07-20 13:25:15 -03:00
Paul Gauthier
567aaea834 Updated HISTORY 2023-07-20 12:06:00 -03:00
Paul Gauthier
d6a4b24306 Exit with 2 ^C in 2 seconds 2023-07-20 11:14:24 -03:00
Paul Gauthier
842ea95de2 Exit with 2 ^C in 3 seconds 2023-07-20 11:13:39 -03:00
Paul Gauthier
a1f2fc4482 Merge branch 'main' into chat-history 2023-07-20 09:55:26 -03:00
Paul Gauthier
bd1811db4d space 2023-07-20 09:53:26 -03:00
Paul Gauthier
750f8a45c6 Changed Discord chat badge to a blue "Join Discord" badge.
# Aider chat conversation:
2023-07-20 09:52:54 -03:00
Paul Gauthier
d7fd4eb8c7 aider: Centered the SVG image and added a Discord badge below it linking to https://discord.gg/SqzfE6bw.
# Aider chat conversation:

USER: center the svg image and place a discord badge below it linking to https://discord.gg/SqzfE6bw

ASSISTANT: To center the SVG image and place a Discord badge below it, we need to modify the README.md file. Here are the changes:

<source>markdown
README.md
<<<<<<< ORIGINAL
![aider screencast](assets/screencast.svg)

- [Discord](https://discord.gg/SqzfE6bw)
=======
<p align="center">
  <img src="assets/screencast.svg" alt="aider screencast">
</p>

<p align="center">
  <a href="https://discord.gg/SqzfE6bw">
    <img src="https://img.shields.io/discord/308323056592486420?logo=discord" alt="chat on Discord">
  </a>
</p>
>>>>>>> UPDATED
</source>

This change centers the SVG image and places a Discord badge below it. The badge links to the provided Discord URL.
2023-07-20 09:51:16 -03:00
Paul Gauthier
46083802c7 cleanup 2023-07-20 09:49:40 -03:00
Paul Gauthier
2d0f789cb9 aider: Increment the version by 0.0.1 and add "-dev" after the version bump.
# Aider chat conversation:

USER: why is it thinking that 0.9.0 is newer than 0.9.0-dev

ASSISTANT: The version comparison is being done using the `packaging.version.parse` function. This function follows the PEP 440 version identification and comparison rules. According to PEP 440, a version like "0.9.0-dev" is considered a pre-release of "0.9.0", and therefore "0.9.0" is considered newer.

If you want "0.9.0-dev" to be considered newer than "0.9.0", you would need to change the version comparison logic. However, this would be against the standard Python versioning rules and is not recommended.

If you still want to proceed with this, please confirm and I will provide the necessary changes.

USER: I added these *read-write* files: scripts/versionbump.py

ASSISTANT: I understand that you want to modify the version comparison logic in your scripts. However, I would like to clarify where exactly you want this change to be made.

The file `scripts/versionbump.py` does not seem to have any version comparison logic that would consider "0.9.0
^C KeyboardInterrupt

USER: instead of adding -dev into the version after the bump, can you instead increment the version by 0.0.1 and then add dev

ASSISTANT: Sure, we can modify the `scripts/versionbump.py` script to increment the version by 0.0.1 and then add "-dev" to it. Here's how we can do it:

1. After the new version is parsed, we can increment the patch version by 1.
2. Then, we can add "-dev" to this incremented version.

Here's the change:

```python
scripts/versionbump.py
<<<<<<< ORIGINAL
    new_version = version.parse(new_version_str)

    with open("aider/__init__.py", "r") as f:
        content = f.read()
=======
    new_version = version.parse(new_version_str)
    incremented_version = version.Version(f"{new_version.major}.{new_version.minor}.{new_version.micro + 1}")

    with open("aider/__init__.py", "r") as f:
        content = f.read()
>>>>>>> UPDATED
```

```python
scripts/versionbump.py
<<<<<<< ORIGINAL
    updated_dev_content = re.sub(
        r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content
    )
=======
    updated_dev_content = re.sub(
        r'__version__ = ".+?"', f'__version__ = "{incremented_version}-dev"', content
    )
>>>>>>> UPDATED
```

This will increment the patch version by 0.0.1 and then add "-dev" to it after the version bump.
2023-07-20 09:48:11 -03:00
Paul Gauthier
6cb8f4e762 stop passing content to update_cur_messages 2023-07-20 09:41:38 -03:00
Paul Gauthier
993bfa6e4c cleanup 2023-07-20 09:39:27 -03:00
Paul Gauthier
ea15aa72fa cleanup 2023-07-20 09:34:09 -03:00
Paul Gauthier
25c03535cc aider: Replace deprecated pkg_resources.parse_version with packaging.version.parse for version comparison in aider/versioncheck.py.
# Aider chat conversation:

USER:     warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

ASSISTANT: It seems like you're concerned about the deprecation warning from the `pkg_resources` module. We can replace the usage of `pkg_resources` with `packaging.version` for version comparison.

Here are the changes needed in the `aider/versioncheck.py` file:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL
import pkg_resources

...

if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(
    current_version
):
    return
=======
import packaging.version

...

if packaging.version.parse(latest_version) <= packaging.version.parse(
    current_version
):
    return
>>>>>>> UPDATED
```

This change replaces the deprecated `pkg_resources.parse_version` with `packaging.version.parse` for version comparison.

USER: InvalidEditBlock: edit failed!

aider/versioncheck.py does not contain the *exact sequence* of ORIGINAL lines you specified.
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The ORIGINAL block needs to be EXACTLY the same as the lines in aider/versioncheck.py with nothing missing!

aider/versioncheck.py does not contain these 8 exact lines in a row:
```
import pkg_resources

...

if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(
    current_version
):
    return
```

ASSISTANT: I apologize for the confusion. Let's try again with the correct sequence of lines from the `aider/versioncheck.py` file:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL
import pkg_resources

...

        if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(
            current_version
        ):
            return
=======
import packaging.version

...

        if packaging.version.parse(latest_version) <= packaging.version.parse(
            current_version
        ):
            return
>>>>>>> UPDATED
```

This change replaces the deprecated `pkg_resources.parse_version` with `packaging.version.parse` for version comparison.
2023-07-20 08:45:58 -03:00
Paul Gauthier
8627b39c97 Updated HISTORY 2023-07-20 08:44:50 -03:00
Paul Gauthier
cc59b10a73 wire into main 2023-07-20 08:43:03 -03:00
Paul Gauthier
12cf19010f Refactor check_version function to accept a print_cmd argument and update print statements accordingly.
# Aider chat conversation:
2023-07-20 08:37:44 -03:00
Paul Gauthier
fe9bcef676 Add support for printing the Python executable name in the upgrade message.
# Aider chat conversation:
2023-07-20 08:36:26 -03:00
Paul Gauthier
4b133929c8 aider: Add print statement with upgrade command in check_version function.
# Aider chat conversation:

USER: also print the command the user should use to upgrade

ASSISTANT: To print the command the user should use to upgrade, we can add a print statement in the `check_version` function in the `aider/versioncheck.py` file. This print statement will provide the command to upgrade the `aider-chat` package using pip.

Here is the code:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL
import requests
import pkg_resources
import aider

from aider.dump import dump

def check_version():
    response = requests.get('https://pypi.org/pypi/aider-chat/json')
    data = response.json()
    latest_version = data['info']['version']
    current_version = pkg_resources.get_distribution('aider-chat').version

    if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version):
        return

    print(f"Running aider version {current_version}, newer version available: {latest_version}")

if __name__ == "__main__":
    check_version()
=======
import requests
import pkg_resources
import aider

from aider.dump import dump

def check_version():
    response = requests.get('https://pypi.org/pypi/aider-chat/json')
    data = response.json()
    latest_version = data['info']['version']
    current_version = pkg_resources.get_distribution('aider-chat').version

    if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version):
        return

    print(f"Running aider version {current_version}, newer version available: {latest_version}")
    print("To upgrade, run: pip install --upgrade aider-chat")

if __name__ == "__main__":
    check_version()
>>>>>>> UPDATED
```

This will print the command `pip install --upgrade aider-chat` when a newer version is available. The user can then copy this command and run it in their terminal to upgrade the `aider-chat` package.
2023-07-20 08:34:54 -03:00
Paul Gauthier
e94f85b61e Refactor version check to include the package name in the URL and print the current version.
# Aider chat conversation:
2023-07-20 08:33:18 -03:00
Paul Gauthier
cf8f76533d aider: Refactored versioncheck.py to use the PyPI JSON API instead of web scraping.
# Aider chat conversation:

USER: can we use a json api not scrape?

ASSISTANT: Yes, we can use the PyPI JSON API to get the information about the latest version of the package.

We will modify the `aider/versioncheck.py` file.

Here are the steps:

1. Send a GET request to the PyPI JSON API for the `aider` package.
2. Parse the JSON response to find the latest version number.
3. Compare this version number with the current version of `aider` installed in the system.
4. Print a message indicating whether a newer version is available.

Here is the code:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL
import requests
from bs4 import BeautifulSoup
import pkg_resources

def check_version():
    response = requests.get('https://pypi.org/project/aider/')
    soup = BeautifulSoup(response.text, 'html.parser')
    latest_version = soup.find('h1', {'class': 'package-header__name'}).text.split()[-1]
    current_version = pkg_resources.get_distribution('aider').version

    if pkg_resources.parse_version(latest_version) > pkg_resources.parse_version(current_version):
        print(f"A newer version of 'aider' is available: {latest_version}")
    else:
        print("You are using the latest version of 'aider'.")

if __name__ == "__main__":
    check_version()
=======
import requests
import pkg_resources

def check_version():
    response = requests.get('https://pypi.org/pypi/aider/json')
    data = response.json()
    latest_version = data['info']['version']
    current_version = pkg_resources.get_distribution('aider').version

    if pkg_resources.parse_version(latest_version) > pkg_resources.parse_version(current_version):
        print(f"A newer version of 'aider' is available: {latest_version}")
    else:
        print("You are using the latest version of 'aider'.")

if __name__ == "__main__":
    check_version()
>>>>>>> UPDATED
```

This version of the script uses the PyPI JSON API, which is more reliable and faster than web scraping.
2023-07-20 08:24:46 -03:00
Paul Gauthier
51943b68e2 aider: Added a script to check the latest version of the 'aider' package on PyPI and compare it with the current installed version.
# Aider chat conversation:

USER: write a script that checks pypi to see if a newer version of aider is available

ASSISTANT: To accomplish this, we will use the `requests` and `bs4` (BeautifulSoup) libraries in Python to scrape the PyPI website for the latest version of the `aider` package.

We will add this script to the `aider/versioncheck.py` file.

Here are the steps:

1. Import the necessary libraries.
2. Define a function that sends a GET request to the PyPI page for the `aider` package.
3. Parse the HTML response to find the latest version number.
4. Compare this version number with the current version of `aider` installed in the system.
5. Print a message indicating whether a newer version is available.

Here is the code:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL

=======
import requests
from bs4 import BeautifulSoup
import pkg_resources

def check_version():
    response = requests.get('https://pypi.org/project/aider/')
    soup = BeautifulSoup(response.text, 'html.parser')
    latest_version = soup.find('h1', {'class': 'package-header__name'}).text.split()[-1]
    current_version = pkg_resources.get_distribution('aider').version

    if pkg_resources.parse_version(latest_version) > pkg_resources.parse_version(current_version):
        print(f"A newer version of 'aider' is available: {latest_version}")
    else:
        print("You are using the latest version of 'aider'.")

if __name__ == "__main__":
    check_version()
>>>>>>> UPDATED
```

Please note that this script assumes that `requests`, `bs4`, and `pkg_resources` are installed in your Python environment. If not, you can install them using pip:

```bash
pip install requests beautifulsoup4 setuptools
```
2023-07-20 08:24:11 -03:00
Paul Gauthier
7d9d163561 Added new files to the git repo: aider/versioncheck.py 2023-07-20 08:22:05 -03:00
Paul Gauthier
7778d9a72d Merge branch 'main' into retry-edit-errors 2023-07-20 08:16:21 -03:00
Paul Gauthier
fab04efc53 Updated HISTORY 2023-07-20 08:16:16 -03:00
Paul Gauthier
405aeaaa61 updated ctags doc 2023-07-20 07:53:08 -03:00
Paul Gauthier
4bc35a7376 Ask GPT to retry if original block is not found 2023-07-19 17:24:53 -03:00