Commit graph

2687 commits

Author SHA1 Message Date
Paul Gauthier
e7692fc9d1 added apt update 2023-07-16 18:27:51 -03:00
Paul Gauthier
9c40fc3415 Path.cwd 2023-07-16 18:27:17 -03:00
Paul Gauthier
6f7936e5f8 Merge branch 'main' into gitignore 2023-07-16 18:06:01 -03:00
Paul Gauthier
d349693205 copy 2023-07-16 17:36:19 -03:00
Paul Gauthier
e7f35e2cf7 Apparently prompt toolkit can not express control-enter? 2023-07-16 14:26:49 -03:00
Paul Gauthier
dbf3b09c06 copy 2023-07-16 14:18:57 -03:00
Paul Gauthier
36af2a51af Change keybinding from ControlJ to ControlM for inserting a new line.
# Aider chat conversation:
2023-07-16 14:15:18 -03:00
Paul Gauthier
6244df8352 aider: get_input now treats control+enter as a newline with prompt toolkit KeyBindings.
# Aider chat conversation:

USER: can we have `get_input` treat control+enter as a newline with prompt toolkit KeyBindings

ASSISTANT: To implement this feature, we need to modify the `get_input` method in the `InputOutput` class in the `aider/io.py` file. We will use the `KeyBindings` class from `prompt_toolkit.keys` to bind the `Control+Enter` key combination to insert a newline.

Here are the changes:

```python
aider/io.py
<<<<<<< ORIGINAL
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt
=======
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt
from prompt_toolkit.keys import Keys
from prompt_toolkit.key_binding import KeyBindings
>>>>>>> UPDATED

```python
aider/io.py
<<<<<<< ORIGINAL
            session = PromptSession(**session_kwargs)
=======
            kb = KeyBindings()

            @kb.add(Keys.ControlJ, eager=True)
            def _(event):
                event.current_buffer.insert_text('\n')

            session = PromptSession(key_bindings=kb, **session_kwargs)
>>>>>>> UPDATED
```

This code creates a new `KeyBindings` instance and adds a binding for `Control+Enter` (represented by `Keys.ControlJ`) to insert a newline. Then, it passes this key bindings instance to the `PromptSession` constructor.
2023-07-16 14:12:01 -03:00
Paul Gauthier
668b8841e2 outdent toc 2023-07-16 13:56:46 -03:00
Paul Gauthier
7df07c7ae7 aider: Add a table of contents to the docs/install.md file.
# Aider chat conversation:

USER: add a table of contents

ASSISTANT: To add a table of contents to the `docs/install.md` file, we need to add a list of links to the headers in the document.

Here is how to do it:

<source>markdown
docs/install.md
<<<<<<< ORIGINAL
# Installing aider

## pip install aider-chat
=======
# Installing aider

- [Installing aider](#installing-aider)
  - [pip install aider-chat](#pip-install-aider-chat)
  - [Provide your OpenAI API key](#provide-your-openai-api-key)
  - [Install git](#install-git)
  - [Install universal ctags (optional)](#install-universal-ctags-optional)
  - [Add aider to your editor (optional)](#add-aider-to-your-editor-optional)

## pip install aider-chat
>>>>>>> UPDATED
</source>

This change adds a table of contents at the beginning of the document, with links to each of the main sections. The links use the header text, converted to lowercase and with spaces replaced by hyphens, as the target of the link. This is the standard way that markdown generates ids for headers, so these links will jump to the correct section when clicked.
2023-07-16 13:55:10 -03:00
Paul Gauthier
5dc7bc055e Whitelist more /cmds for no dirty commit 2023-07-16 13:42:36 -03:00
Paul Gauthier
180ca7c464 test_main_git_ignore 2023-07-16 12:56:55 -03:00
Paul Gauthier
0f14947a4c test_check_gitignore 2023-07-16 12:49:27 -03:00
Paul Gauthier
1e0443cc86 better test 2023-07-16 12:36:19 -03:00
Paul Gauthier
7d8069d778 test_setup_git works 2023-07-16 12:33:56 -03:00
Paul Gauthier
7096f7287c simplify with make_repo 2023-07-16 12:30:40 -03:00
Paul Gauthier
108abe4a49 aider: Replace all subprocess.run(git calls that are making new repos and setting config with make_repo calls.
# Aider chat conversation:

USER: replace all the `subprocess.run(git` calls that are making new repos and setting config with `make_repo` calls

ASSISTANT: To replace all the `subprocess.run(git` calls that are making new repos and setting config with `make_repo` calls, we need to modify the `tests/test_main.py` file.

Here are the changes:

```python
tests/test_main.py
<<<<<<< ORIGINAL
        subprocess.run(["git", "init"])
        subprocess.run(["git", "config", "user.email", "dummy@example.com"])
        subprocess.run(["git", "config", "user.name", "Dummy User"])
=======
        from tests.utils import make_repo
        make_repo()
>>>>>>> UPDATED
```

```python
tests/test_main.py
<<<<<<< ORIGINAL
        subprocess.run(["git", "init"])
        subprocess.run(["git", "config", "user.email", "dummy@example.com"])
        subprocess.run(["git", "config", "user.name", "Dummy User"])
=======
        from tests.utils import make_repo
        make_repo()
>>>>>>> UPDATED
```

```python
tests/test_main.py
<<<<<<< ORIGINAL
        subprocess.run(["git", "init"])
        subprocess.run(["git", "config", "user.email", "dummy@example.com"])
        subprocess.run(["git", "config", "user.name", "Dummy User"])
=======
        from tests.utils import make_repo
        make_repo()
>>>>>>> UPDATED
```

Please note that you need to import the `make_repo` function from `tests.utils` in each test where it's used.
2023-07-16 12:26:31 -03:00
Paul Gauthier
611e21e457 Merge branch 'main' into gitignore 2023-07-16 12:25:23 -03:00
Paul Gauthier
4447f61dc6 refac make_repo 2023-07-16 12:25:18 -03:00
Paul Gauthier
67554196f3 Merge branch 'main' into gitignore 2023-07-16 12:21:16 -03:00
Paul Gauthier
10b327d487 copy 2023-07-16 12:21:01 -03:00
Paul Gauthier
bcbfa0babd copy 2023-07-16 12:20:03 -03:00
Paul Gauthier
4b8211554a set version to 0.9.0-dev 2023-07-16 09:47:35 -03:00
Paul Gauthier
a57c651c05 version bump to 0.9.0 2023-07-16 09:47:24 -03:00
Paul Gauthier
a3f3a18ee0 Updated HISTORY 2023-07-16 09:47:03 -03:00
Paul Gauthier
a9cca05680 Added GitTemporaryDirectory 2023-07-16 09:39:07 -03:00
Paul Gauthier
86cea01434 aider: Change the relative import to an absolute import for the IgnorantTemporaryDirectory class in test_repomap.py.
# Aider chat conversation:

USER: ImportError: Failed to import test module: test_repomap
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/runner/work/aider/aider/tests/test_repomap.py", line 8, in <module>
    from .utils import IgnorantTemporaryDirectory
ImportError: attempted relative import with no known parent package

ASSISTANT: The error message indicates that Python is unable to find the `utils` module when it's being imported in `test_repomap.py`. This is because the import statement is using a relative import with the dot (`.`) prefix, which is not working in this context.

To fix this, we need to change the relative import to an absolute import. This means we need to specify the full path to the `utils` module from the project's root directory.

Here is the change you need to make:

```python
tests/test_repomap.py
<<<<<<< ORIGINAL
from .utils import IgnorantTemporaryDirectory
=======
from tests.utils import IgnorantTemporaryDirectory
>>>>>>> UPDATED
```

This change tells Python to import the `IgnorantTemporaryDirectory` class from the `utils` module located in the `tests` directory, which is an absolute path from the project's root directory.
2023-07-16 09:05:18 -03:00
Paul Gauthier
cdf35cd122 refac 2023-07-16 09:02:35 -03:00
Paul Gauthier
50c8a96edd wip 2023-07-16 08:18:05 -03:00
Paul Gauthier
c8d69f84ce aider: Add test for setup_git function.
# Aider chat conversation:

USER: add tests for `setup_git`

ASSISTANT: To add tests for the `setup_git` function, we need to modify the `tests/test_main.py` file. We will add a new test function `test_setup_git` in the `TestMain` class.

Here is the change:

```python
tests/test_main.py
<<<<<<< ORIGINAL
    def test_main_args(self):
        with patch("aider.main.Coder.create") as MockCoder:
            # --yes will just ok the git repo without blocking on input
            # following calls to main will see the new repo already
            main(["--no-auto-commits", "--yes"], input=DummyInput())
            _, kwargs = MockCoder.call_args
            assert kwargs["auto_commits"] is False
=======
    def test_main_args(self):
        with patch("aider.main.Coder.create") as MockCoder:
            # --yes will just ok the git repo without blocking on input
            # following calls to main will see the new repo already
            main(["--no-auto-commits", "--yes"], input=DummyInput())
            _, kwargs = MockCoder.call_args
            assert kwargs["auto_commits"] is False

    def test_setup_git(self):
        with patch("aider.main.git.Repo.init") as MockRepoInit:
            MockRepoInit.return_value = git.Repo(self.tempdir)
            git_root = setup_git(None, self.io)
            self.assertEqual(git_root, self.tempdir)
            MockRepoInit.assert_called_once_with(self.tempdir)
>>>>>>> UPDATED
```

In the new test `test_setup_git`, we are mocking the `git.Repo.init` function to return a git repository at `self.tempdir`. Then we call `setup_git` with `None` as the `git_root` and check if it returns `self.tempdir` as the new `git_root`. We also check if `git.Repo.init` was called once with `self.tempdir` as the argument.
2023-07-15 13:37:39 -07:00
Paul Gauthier
b0ec8205f3 Add pattern to .gitignore if user confirms, by appending it to the existing content of the file.
# Aider chat conversation:
2023-07-15 13:36:57 -07:00
Paul Gauthier
c08527dbbc refac; added check_gitignore 2023-07-15 13:34:58 -07:00
Paul Gauthier
e9806bb84f Merge branch 'main' into gitignore 2023-07-15 10:59:33 -07:00
Paul Gauthier
9785ede960 copy 2023-07-15 10:59:16 -07:00
Paul Gauthier
adf123c30e aider: Added table of contents to the faq.md file.
# Aider chat conversation:

USER: add a table of contents

ASSISTANT: To add a table of contents to the `faq.md` file, we need to add a list of links to the sections at the top of the file. Each link should be in the format `[Section Name](#section-name)`, where `Section Name` is the name of the section and `section-name` is the section name in lowercase with spaces replaced by hyphens.

Here is the *edit block* for this change:

<source>markdown
docs/faq.md
<<<<<<< ORIGINAL
# Frequently asked questions

## How does aider use git?
=======
# Frequently asked questions

- [How does aider use git?](#how-does-aider-use-git)
- [GPT-4 vs GPT-3.5](#gpt-4-vs-gpt-35)
- [Aider isn't editing my files?](#aider-isnt-editing-my-files)
- [Can I use aider with other LLMs, local LLMs, etc?](#can-i-use-aider-with-other-llms-local-llms-etc)
- [Can I change the system prompts that aider uses?](#can-i-change-the-system-prompts-that-aider-uses)
- [Can I run aider in Google Colab?](#can-i-run-aider-in-google-colab)

## How does aider use git?
>>>>>>> UPDATED
</source>
2023-07-15 10:53:12 -07:00
Paul Gauthier
7a2c954eb7 Updated HISTORY 2023-07-15 10:36:02 -07:00
Paul Gauthier
8622ffaf4c Added faq entry 2023-07-15 10:34:55 -07:00
Paul Gauthier
1b10751585 More informative retry messages 2023-07-15 10:19:48 -07:00
Paul Gauthier
9f7f6607c2 copy 2023-07-14 21:22:49 -07:00
Paul Gauthier
843c51c35e copy 2023-07-14 21:21:00 -07:00
Paul Gauthier
9d9de4d02e added git faq 2023-07-14 21:16:18 -07:00
Paul Gauthier
e6996da018 fix tests for windows 2023-07-14 20:28:33 -07:00
Paul Gauthier
6f460bd050 wip 2023-07-14 20:10:10 -07:00
Paul Gauthier
fb444d9954 aider: Refactored open calls in aider/main.py to use Path.read_text() and Path.write_text() with encoding='utf-8'.
# Aider chat conversation:

USER: add encoding=utf-8 to all that

ASSISTANT: To add the encoding declaration to the `aider/main.py` file, we need to add `# -*- coding: utf-8 -*-` at the top of the file.

Here is the proposed change:

^C KeyboardInterrupt

USER: add encoding=utf-8 to those open calls

ASSISTANT: To specify the encoding as utf-8 in the open calls in the `aider/main.py` file, we need to add `encoding='utf-8'` to each open call.

Here are the proposed changes:

```python
aider/main.py
<<<<<<< ORIGINAL
    if git_root:
        gitignore_file = Path(git_root) / ".gitignore"
        if gitignore_file.exists():
            with open(gitignore_file, "r") as file:
                content = file.read()
            if ".aider*" not in content:
                with open(gitignore_file, "a") as file:
                    file.write("\n.aider*")
        else:
            with open(gitignore
^C KeyboardInterrupt

USER: actually use Path.read_text and be sure to encoding=utf-8

ASSISTANT: To use `Path.read_text()` with `encoding='utf-8'` in the `aider/main.py` file, we need to replace the `open()` calls with `Path.read_text()` and `Path.write_text()`.

Here are the proposed changes:

```python
aider/main.py
<<<<<<< ORIGINAL
    if git_root:
        gitignore_file = Path(git_root) / ".gitignore"
        if gitignore_file.exists():
            with open(gitignore_file, "r") as file:
                content = file.read()
            if ".aider*" not in content:
                with open(gitignore_file, "a") as file:
                    file.write("\n.aider*")
        else:
            with open(gitignore_file, "w") as file:
                file.write(".aider*")
=======
    if git_root:
        gitignore_file = Path(git_root) / ".gitignore"
        if gitignore_file.exists():
            content = gitignore_file.read_text(encoding='utf-8')
            if ".aider*" not in content:
                gitignore_file.write_text("\n.aider*", encoding='utf-8', append=True)
        else:
            gitignore_file.write_text(".aider*", encoding='utf-8')
>>>>>>> UPDATED
```

This code will open the `.gitignore` file in the git root directory, check if `.aider*` is present, and if not, append it to the file. If the `.gitignore` file does not exist, it will create one and add `.aider*` to it. The encoding is specified as utf-8.
2023-07-14 20:06:34 -07:00
Paul Gauthier
90df92bffa aider: Add .aider* to .gitignore if it is not already present.
# Aider chat conversation:

USER: do the TODO

ASSISTANT: To complete the TODO task in the `aider/main.py` file, we need to check if `.aider*` is in `.gitignore`, and if not, add it.

Here are the steps to do this:

1. Open the `.gitignore` file in the root directory of the git repository.
2. Read the contents of the file.
3. Check if `.aider*` is present in the file.
4. If not, append `.aider*` to the file and save it.

However, the code in `aider/main.py` does not currently have the ability to modify files. We need to add a function to handle this.

Here is the proposed change:

```python
aider/main.py
<<<<<<< ORIGINAL
    if git_root:
        # TODO: check if .aider* is in .gitignore, add it if not
        pass
=======
    if git_root:
        gitignore_file = Path(git_root) / ".gitignore"
        if gitignore_file.exists():
            with open(gitignore_file, "r") as file:
                content = file.read()
            if ".aider*" not in content:
                with open(gitignore_file, "a") as file:
                    file.write("\n.aider*")
        else:
            with open(gitignore_file, "w") as file:
                file.write(".aider*")
>>>>>>> UPDATED
```

This code will open the `.gitignore` file in the git root directory, check if `.aider*` is present, and if not, append it to the file. If the `.gitignore` file does not exist, it will create one and add `.aider*` to it.
2023-07-14 20:05:11 -07:00
Paul Gauthier
84da88feec Updated HISTORY 2023-07-14 20:00:57 -07:00
Paul Gauthier
78d9d014f2 fix bug blocking addition of subdir filename mentions 2023-07-14 20:00:04 -07:00
Paul Gauthier
16a21d9844 added failing test for mention 2023-07-14 19:53:49 -07:00
Paul Gauthier
edbec5498e update benchmark driver 2023-07-13 20:02:58 -07:00
Paul Gauthier
743d3f0d1c copy 2023-07-13 19:44:59 -07:00