Commit graph

2344 commits

Author SHA1 Message Date
Paul Gauthier
f6be208d77 updated tests 2023-07-11 15:17:00 -07:00
Paul Gauthier
bcdf8968f1 updated tests 2023-07-11 15:15:56 -07:00
Paul Gauthier
2190435780 updated tests 2023-07-11 15:15:26 -07:00
Paul Gauthier
d97707a5c0 Added --openai-api-engine 2023-07-11 15:11:35 -07:00
Paul Gauthier
084132a5f8 refactor initialization of openai into main 2023-07-11 15:06:50 -07:00
Paul Gauthier
fa3283802a aider: Add --openai-api-type, --openai-api-version, and openai-api-deployment-id args, pass them into coder.create.
# Aider chat conversation:

USER: add --openai-api-type --openai-api-version and openai-api-deployment-id args. pass them into coder.create

ASSISTANT: To add the `--openai-api-type`, `--openai-api-version`, and `--openai-api-deployment-id` arguments and pass them into `coder.create`, we need to modify the `aider/main.py` file.

Here are the steps:

1. Add the new arguments to the argument parser in the `main` function.
2. Pass these arguments to the `coder.create` function.

Here are the changes:

```python
aider/main.py
<<<<<<< ORIGINAL
    ##########
    model_group = parser.add_argument_group("Advanced Model Settings")
    model_group.add_argument(
        "--openai-api-base",
        metavar="OPENAI_API_BASE",
        default="https://api.openai.com/v1",
        help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)",
    )
=======
    ##########
    model_group = parser.add_argument_group("Advanced Model Settings")
    model_group.add_argument(
        "--openai-api-base",
        metavar="OPENAI_API_BASE",
        default="https://api.openai.com/v1",
        help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)",
    )
    model_group.add_argument(
        "--openai-api-type",
        metavar="OPENAI_API_TYPE",
        help="Specify the OpenAI API type",
    )
    model_group.add_argument(
        "--openai-api-version",
        metavar="OPENAI_API_VERSION",
        help="Specify the OpenAI API version",
    )
    model_group.add_argument(
        "--openai-api-deployment-id",
        metavar="OPENAI_API_DEPLOYMENT_ID",
        help="Specify the OpenAI API deployment ID",
    )
>>>>>>> UPDATED
```

```python
aider/main.py
<<<<<<< ORIGINAL
    coder = Coder.create(
        main_model,
        args.edit_format,
        io,
        args.openai_api_key,
        args.openai_api_base,
        ##
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dirty_commits=args.dirty_commits,
        dry_run=args.dry_run,
        map_tokens=args.map_tokens,
        verbose=args.verbose,
        assistant_output_color=args.assistant_output_color,
        code_theme=args.code_theme,
        stream=args.stream,
        use_git=args.git,
    )
=======
    coder = Coder.create(
        main_model,
        args.edit_format,
        io,
        args.openai_api_key,
        args.openai_api_base,
        ##
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dirty_commits=args.dirty_commits,
        dry_run=args.dry_run,
        map_tokens=args.map_tokens,
        verbose=args.verbose,
        assistant_output_color=args.assistant_output_color,
        code_theme=args.code_theme,
        stream=args.stream,
        use_git=args.git,
        openai_api_type=args.openai_api_type,
        openai_api_version=args.openai_api_version,
        openai_api_deployment_id=args.openai_api_deployment_id,
    )
>>>>>>> UPDATED
```

Please note that these changes assume that the `Coder.create` method and the `Coder` class are prepared to receive and handle these new arguments. If they are not, additional changes will be needed in the `Coder` class and its subclasses.
2023-07-11 14:56:36 -07:00
Paul Gauthier
967cb1bd8d notify when preparing dirty commit; skip if /exit or /commit is input 2023-07-11 13:21:36 -07:00
Paul Gauthier
fde537cd7f aider: Fix regular expression in setup.py to remove all links, not just the internal anchor links.
# Aider chat conversation:

USER: the regex in `setup.py` is supposed to remove the list of links that appears right below the image in README. but it doesn't remove the links to aider.chat urls, just the internal anchor links. fix that.

ASSISTANT: To fix the regular expression in `setup.py` to remove all links, not just the internal anchor links, we need to modify the `setup.py` file.

Here's the change:

```python
setup.py
<<<<<<< ORIGINAL
    long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description)
    long_description = re.sub(r"\n- \[.*\]\(#.*\)", "", long_description)
=======
    long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description)
    long_description = re.sub(r"\n- \[.*\]\(.*\)", "", long_description)
>>>>>>> UPDATED
```

This change will ensure that all links, including those to `aider.chat` URLs, are removed from the `long_description`.
2023-07-11 13:08:10 -07:00
Paul Gauthier
9e143a1264 copy 2023-07-11 13:05:36 -07:00
Paul Gauthier
46686e6b0e copy 2023-07-11 12:59:14 -07:00
Paul Gauthier
d24256db60 copy 2023-07-11 12:57:07 -07:00
Paul Gauthier
490aaf55ce copy 2023-07-11 12:56:24 -07:00
Paul Gauthier
d984b1ceee copy 2023-07-11 12:53:47 -07:00
Paul Gauthier
12009688ee copy 2023-07-11 12:53:29 -07:00
Paul Gauthier
e0fdf6ce24 copy 2023-07-11 12:52:20 -07:00
Paul Gauthier
ceb84b2cdd broke out instructions, added link to neovim #84 2023-07-11 12:47:35 -07:00
paul-gauthier
7e17059b59
Merge pull request #81 from paul-gauthier/issue-73
Prioritize how to allocate code blocks to filenames in wholefile
2023-07-11 09:44:33 -07:00
Paul Gauthier
d22b1dfb32 small improvement to test 2023-07-11 09:40:54 -07:00
Paul Gauthier
1f83a89192 Merge branch 'main' into issue-73 2023-07-11 09:36:34 -07:00
paul-gauthier
36625abb71
Merge pull request #85 from paul-gauthier/issue-82
Tell git not to quote filenames in ls-files, to handle unicode filenames
2023-07-11 09:31:51 -07:00
Paul Gauthier
3294479c31 Updated HISTORY 2023-07-11 09:24:45 -07:00
Paul Gauthier
c638d305b0 Merge branch 'main' into issue-82 2023-07-11 09:24:09 -07:00
Paul Gauthier
3e3694b38a aider: Set the git user name and email in the get_tracked_files test.
# Aider chat conversation:

USER: set the git user name and email in the `get_tracked_files` test

ASSISTANT: To set the git user name and email in the `get_tracked_files` test, we need to modify the `tests/test_coder.py` file. We will add two lines of code to set the git user name and email after initializing the git repository.

Here is the change:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
        # Initialize a git repository in the temporary directory
        repo = git.Repo.init(tempdir)
=======
        # Initialize a git repository in the temporary directory and set user name and email
        repo = git.Repo.init(tempdir)
        repo.config_writer().set_value("user", "name", "Test User").release()
        repo.config_writer().set_value("user", "email", "testuser@example.com").release()
>>>>>>> UPDATED
```

This change sets the git user name to "Test User" and the email to "testuser@example.com".
2023-07-11 09:20:50 -07:00
Paul Gauthier
8d5f17898a test subdirs too 2023-07-11 09:17:55 -07:00
Paul Gauthier
cccd0d1ebe Make the tests run on windows; added test for files with quotes 2023-07-11 09:15:21 -07:00
Paul Gauthier
68c26a60ef get tracked files by traversing the tree 2023-07-11 09:08:37 -07:00
Paul Gauthier
606a36a273 copy 2023-07-11 08:44:13 -07:00
Paul Gauthier
73f5fb05e5 Make rel_repo_dir robust on windows when cwd and the repo are on different drives 2023-07-11 08:40:30 -07:00
Paul Gauthier
59a54f5f83 fix Coder.create 2023-07-11 08:21:16 -07:00
Paul Gauthier
cb5d2450ec aider: Ensure parent directory exists before creating file in test_get_tracked_files.
# Aider chat conversation:

USER: I ran this command:

 pytest -k test_get_tracked_files -s

And got this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
configfile: pytest.ini
collected 61 items / 60 deselected / 1 selected

tests/test_coder.py F

=================================== FAILURES ===================================
_______________________ TestCoder.test_get_tracked_files _______________________

self = <tests.test_coder.TestCoder testMethod=test_get_tracked_files>

    def test_get_tracked_files(self):
        # Create a temporary directory
        tempdir = Path(tempfile.mkdtemp())

        # Initialize a git repository in the temporary directory
        repo = git.Repo.init(tempdir)

        # Create three empty files and add them to the git repository
        filenames = ["README.md", "doc/fänny_dirname/README.md", "doc/systemüberblick.md"]
        for filename in filenames:
>           (tempdir / filename).touch()

tests/test_coder.py:374:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/var/folders/49/kxrdwwbx0h9bchx99397477c0000gn/T/tmpoowegb9x/doc/fänny_dirname/README.md')
mode = 438, exist_ok = True

    def touch(self, mode=0o666, exist_ok=True):
        """
        Create this file with the given access mode, if it doesn't exist.
        """

        if exist_ok:
            # First try to bump modification time
            # Implementation note: GNU touch uses the UTIME_NOW option of
            # the utimensat() / futimens() functions.
            try:
                os.utime(self, None)
            except OSError:
                # Avoid exception chaining
                pass
            else:
                return
        flags = os.O_CREAT | os.O_WRONLY
        if not exist_ok:
            flags |= os.O_EXCL
>       fd = os.open(self, flags, mode)
E       FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/49/kxrdwwbx0h9bchx99397477c0000gn/T/tmpoowegb9x/doc/fänny_dirname/README.md'

/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:1108: FileNotFoundError
=========================== short test summary info ============================
FAILED tests/test_coder.py::TestCoder::test_get_tracked_files - FileNotFoundE...
======================= 1 failed, 60 deselected in 1.53s =======================

ASSISTANT: The error message indicates that the directory `doc/fänny_dirname` does not exist when the test tries to create the file `README.md` inside it.

We need to ensure that the directory exists before creating the file. We can use the `mkdir` method of `Path` with the `parents=True` argument to create the directory and all its missing parents.

Here is the updated code:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
    def test_get_tracked_files(self):
        # Create a temporary directory
        tempdir = Path(tempfile.mkdtemp())

        # Initialize a git repository in the temporary directory
        repo = git.Repo.init(tempdir)

        # Create three empty files and add them to the git repository
        filenames = ["README.md", "doc/fänny_dirname/README.md", "doc/systemüberblick.md"]
        for filename in filenames:
            (tempdir / filename).touch()
            repo.git.add(filename)

        # Create a Coder object on the temporary directory
        coder = Coder.create(
            models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", root=tempdir
        )

        # Assert that coder.get_tracked_files() returns the three filenames
        self.assertEqual(set(coder.get_tracked_files()), set(filenames))
=======
    def test_get_tracked_files(self):
        # Create a temporary directory
        tempdir = Path(tempfile.mkdtemp())

        # Initialize a git repository in the temporary directory
        repo = git.Repo.init(tempdir)

        # Create three empty files and add them to the git repository
        filenames = ["README.md", "doc/fänny_dirname/README.md", "doc/systemüberblick.md"]
        for filename in filenames:
            file_path = tempdir / filename
            file_path.parent.mkdir(parents=True, exist_ok=True)
            file_path.touch()
            repo.git.add(str(file_path))

        # Create a Coder object on the temporary directory
        coder = Coder.create(
            models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", root=tempdir
        )

        # Assert that coder.get_tracked_files() returns the three filenames
        self.assertEqual(set(coder.get_tracked_files()), set(filenames))
>>>>>>> UPDATED
```

This code creates the parent directory of each file before creating the file. It also converts the `Path` object to a string before passing it to `repo.git.add`, because the `git` library may not accept `Path` objects.
2023-07-11 08:20:22 -07:00
Paul Gauthier
db8fb97a38 added import 2023-07-11 08:19:24 -07:00
Paul Gauthier
f1b61d49e9 aider: Added a test that creates a temporary directory, initializes a git repository there, adds three empty files, creates a Coder object on that directory, and asserts that coder.get_tracked_files() returns the three filenames.
# Aider chat conversation:

USER: make a test which creates a tempdir and inits a git repo there. it should add 3 empty files with the filenames below. the test should create a Coder on that and make sure that coder.get_tracked_files() returns the 3 filenames. Here are the filenames: README.md
doc/fänny_dirname/README.md
doc/systemüberblick.md

ASSISTANT: To create this test, we need to modify the `tests/test_coder.py` file. We will add a new test method named `test_get_tracked_files` in the `TestCoder` class. This method will create a temporary directory, initialize a git repository there, add three empty files, create a `Coder` object on that directory, and assert that `coder.get_tracked_files()` returns the three filenames.

Here is the code change:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
    if __name__ == "__main__":
        unittest.main()
=======
    def test_get_tracked_files(self):
        # Create a temporary directory
        tempdir = Path(tempfile.mkdtemp())

        # Initialize a git repository in the temporary directory
        repo = git.Repo.init(tempdir)

        # Create three empty files and add them to the git repository
        filenames = ["README.md", "doc/fänny_dirname/README.md", "doc/systemüberblick.md"]
        for filename in filenames:
            (tempdir / filename).touch()
            repo.git.add(filename)

        # Create a Coder object on the temporary directory
        coder = Coder.create(models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", root=tempdir)

        # Assert that coder.get_tracked_files() returns the three filenames
        self.assertEqual(set(coder.get_tracked_files()), set(filenames))

    if __name__ == "__main__":
        unittest.main()
>>>>>>> UPDATED
```

This code assumes that the `Coder` class has a `get_tracked_files` method that returns the filenames of the tracked files in the git repository. If such a method does not exist, it should be implemented in the `Coder` class.
2023-07-11 08:18:39 -07:00
Paul Gauthier
2f4e20658d fix the test to mock git.execute not git.ls_files 2023-07-11 08:14:01 -07:00
Paul Gauthier
7c0ac4d92f Tell git to stop quoting the paths in ls-files 2023-07-11 08:12:44 -07:00
Paul Gauthier
c4e4d071fa Handle the case where we fail to expand a dir 2023-07-11 08:12:18 -07:00
Paul Gauthier
4024713f31 Updated HISTORY 2023-07-11 07:36:04 -07:00
Paul Gauthier
d636d02d96 Merge remote-tracking branch 'origin/main' 2023-07-11 07:33:12 -07:00
Paul Gauthier
d7ba886e66 added test_update_files_live_diff 2023-07-11 07:32:31 -07:00
Paul Gauthier
aacbcd32d4 bugfix live diffs in wholefile coder 2023-07-11 07:27:49 -07:00
paul-gauthier
57ef02f92e
Update faq.md 2023-07-10 19:35:19 -07:00
paul-gauthier
338c0a56d6
Update faq.md 2023-07-10 19:31:47 -07:00
Paul Gauthier
27fbf8699f cleanup 2023-07-10 18:21:06 -07:00
Paul Gauthier
6fc276d336 prioritize how to allocate code blocks to filenames 2023-07-10 17:42:23 -07:00
Paul Gauthier
fd8a6c4e2f refactor 2023-07-10 17:03:31 -07:00
Paul Gauthier
89e19b2370 Added failing test case 2023-07-10 16:26:20 -07:00
Paul Gauthier
c20b1bb073 Merge remote-tracking branch 'origin/main' 2023-07-10 15:34:04 -07:00
Paul Gauthier
aedfa64eb9 Fix test 2023-07-10 15:33:46 -07:00
paul-gauthier
17e616d282
Merge pull request #80 from paul-gauthier/issue-57
The /add command should recurse into named subdirs per issue #57
2023-07-10 15:33:02 -07:00
Paul Gauthier
9bc450977d Remove last naive open()s 2023-07-10 15:32:23 -07:00
Paul Gauthier
baa11b0c0d cleanup 2023-07-10 15:23:25 -07:00