Commit graph

1760 commits

Author SHA1 Message Date
Paul Gauthier
3ff798aa5b aider: Changed create_temp_repo function to include files from the docs subdir while still excluding files with test in the filename.
# Context:
USER: will that pickup the files in the docs subdir?
ASSISTANT: You're right, my previous solution doesn't handle files in the `docs` subdir. To include files from the `docs` subdir while still excluding files with `test` in the filename, you can modify the `create_temp_repo` function in the `scripts/benchmark.py` file as follows:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
    # Add all copied files to the repo, excluding those with 'test' in the filename
    for item in os.listdir(tempdir):
        if "test" not in item:
            repo.git.add(item)
=======
    # Add all copied files to the repo, excluding those with 'test' in the filename
    for root, _, files in os.walk(tempdir):
        for file in files:
            if "test" not in file:
                repo.git.add(os.path.join(root, file))
>>>>>>> UPDATED
```

This change will use `os.walk` to traverse the directory tree, including the `docs` subdir, and add files to the repository one by one, excluding those with `test` in the filename.
2023-06-23 14:02:25 -07:00
Paul Gauthier
c26079e633 aider: Added ability to exclude files with 'test' in the filename when adding files to the repo.
# Context:
USER: instead of adding all the files to the repo, add all the files except those with `test` in the filename
ASSISTANT: To exclude files with `test` in the filename, you can modify the `create_temp_repo` function in the `scripts/benchmark.py` file. Here's the updated code:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
    # Add all copied files to the repo
    repo.git.add(A=True)
=======
    # Add all copied files to the repo, excluding those with 'test' in the filename
    for item in os.listdir(tempdir):
        if "test" not in item:
            repo.git.add(item)
>>>>>>> UPDATED
```

This change will add files to the repository one by one, excluding those with `test` in the filename.
2023-06-23 14:01:55 -07:00
Paul Gauthier
6142488741 refac 2023-06-23 14:00:36 -07:00
Paul Gauthier
c21ef8dd92 more flexible multiline invocation 2023-06-23 14:00:22 -07:00
Paul Gauthier
55fb2ffe52 aider: Added create_temp_repo function to create a temporary git repo with copied files and .docs subdir.
# Context:
USER: make a script which takes a dirname on the cmd line.
make a tempdir, copy all the files from the dirname into the tempdir
copy the .docs subdir into the tempdir, but as `docs` without the leading .
make a new git repo in the tempdir using GitPython
add all the copied files to the repo, commit with msg "initial"

ASSISTANT: I will create a new script called `create_temp_repo.py` in the `scripts` directory. This script will take a directory name as a command-line argument, create a temporary
^C KeyboardInterrupt
USER: code it in benchmark.py
ASSISTANT: First, let's import the required libraries at the beginning of `scripts/benchmark.py`:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
=======
import os
import shutil
import sys
from tempfile import TemporaryDirectory
from git import Repo
>>>>>>> UPDATED
```

Now, let's add a new function called `create_temp_repo` in `scripts/benchmark.py`:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
=======
def create_temp_repo(dirname):
    with TemporaryDirectory() as tempdir:
        # Copy all files from dirname to tempdir
        for item in os.listdir(dirname):
            s = os.path.join(dirname, item)
            d = os.path.join(tempdir, item)
            if os.path.isdir(s):
                shutil.copytree(s, d, False, None)
            else:
                shutil.copy2(s, d)

        # Copy .docs subdir to tempdir as 'docs'
        docs_src = os.path.join(dirname, ".docs")
        docs_dst = os.path.join(tempdir, "docs")
        shutil.copytree(docs_src, docs_dst, False, None)

        # Create a new git repo in tempdir
        repo = Repo.init(tempdir)

        # Add all copied files to the repo
        repo.git.add(A=True)

        # Commit with message "initial"
        repo.git.commit(m="initial")

    return tempdir
>>>>>>> UPDATED
```

Finally, let's call the `create_temp_repo` function with the command-line argument in the `__main__` block:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
=======
if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: python benchmark.py <dirname>")
        sys.exit(1)

    dirname = sys.argv[1]
    temp_repo_path = create_temp_repo(dirname)
    print(f"Temporary repo created at: {temp_repo_path}")
>>>>>>> UPDATED
```

Now, you can run the script with the command `python scripts/benchmark.py <dirname>`, where `<dirname>` is the directory you want to create a temporary repo for.
2023-06-23 13:55:04 -07:00
Paul Gauthier
fb2f3ba6c2 Added new files to the git repo: scripts/benchmark.py 2023-06-23 13:50:19 -07:00
Paul Gauthier
b5b0c1cbc2 Added --no-git 2023-06-23 13:44:24 -07:00
Paul Gauthier
5c432592cd compute cost 2023-06-23 13:40:32 -07:00
Paul Gauthier
d2b9cb9e98 added --no-stream 2023-06-23 13:29:09 -07:00
Paul Gauthier
7e18fb7f5f Help for --cmd 2023-06-23 11:03:33 -07:00
Paul Gauthier
eceef49947 Use --cmd as short form 2023-06-23 11:02:19 -07:00
Paul Gauthier
a77e4419cc aider: Added a --command,-c option to specify the command to pass to coder.run().
# Context:
USER: add a --command,-c option which takes a string to pass to coder.run(with_message=args.command)
ASSISTANT: No changes are needed.
2023-06-23 11:01:05 -07:00
Paul Gauthier
dfdc6a382a /drop with no args drops all files 2023-06-23 10:14:51 -07:00
Paul Gauthier
f32580caf2 red if exhausted 2023-06-23 10:13:13 -07:00
Paul Gauthier
f9599f87a2 print -> tool_output 2023-06-23 10:12:19 -07:00
Paul Gauthier
803423cc6a prettier /tokens output 2023-06-23 10:10:45 -07:00
Paul Gauthier
949a633e95 Handle complete context blowout more gracefully 2023-06-23 10:01:01 -07:00
Paul Gauthier
41b7a70347 fix test after merge 2023-06-23 07:55:03 -07:00
Paul Gauthier
fc6dd1877c Merge branch 'main' into edit-formats 2023-06-23 07:54:24 -07:00
Paul Gauthier
e261963acd fix for issue #25 2023-06-23 07:44:46 -07:00
Paul Gauthier
07ced21325 do not autocommit on dryrun 2023-06-22 19:22:53 -07:00
Paul Gauthier
15a0cdd6c9 aider: Added a --command,-c option to pass a string to coder.run().
# Context:
USER: add a --command,-c option which takes a string to pass to coder.run(with_message=args.command)
ASSISTANT: No changes are needed.
2023-06-22 19:02:22 -07:00
Paul Gauthier
cf3637dd5c roughed in run(with_message) 2023-06-22 18:55:23 -07:00
Paul Gauthier
208b3c2022 handle non-func replies 2023-06-22 18:33:22 -07:00
Paul Gauthier
4caec8dec1 reformat diff output header 2023-06-22 17:34:18 -07:00
Paul Gauthier
22a5e493a7 update files on the happy path 2023-06-22 17:32:34 -07:00
Paul Gauthier
82813d4159 rename modify_incremental_response -> render_incremental_response 2023-06-22 17:29:47 -07:00
Paul Gauthier
63f1c17a76 noop 2023-06-22 12:03:12 -07:00
Paul Gauthier
1c264eef67 noop 2023-06-22 12:03:04 -07:00
Paul Gauthier
8517681f02 Log the explanation to the chat history file 2023-06-22 12:01:34 -07:00
Paul Gauthier
3702ea3aa2 cleanup 2023-06-22 11:57:23 -07:00
Paul Gauthier
e8e2ea9d89 rename 2023-06-22 11:56:55 -07:00
Paul Gauthier
cc79f62498 repo_content_prefix = None in whole-func 2023-06-22 11:55:21 -07:00
Paul Gauthier
16a89fb5ab switch 3.5 models to use whole-func edit-format by default 2023-06-22 11:47:18 -07:00
Paul Gauthier
b5a92896ab Move the fname inside the unified diff block 2023-06-22 11:44:54 -07:00
Paul Gauthier
5043397848 respect --dry-run 2023-06-22 11:38:39 -07:00
Paul Gauthier
08764215c3 refac 2023-06-22 11:29:59 -07:00
Paul Gauthier
0f5264b196 renamed EditorPrompts -> CoderPrompts 2023-06-22 08:17:12 -07:00
Paul Gauthier
985e362544 renamed func -> wholefile_func 2023-06-22 08:15:20 -07:00
Paul Gauthier
fa1158d8a8 aider: Replaced MagicMock with custom mock_send function to set partial_response_content and return False in test_get_commit_message.
# Context:
USER: and test_get_commit_message
ASSISTANT: To make the requested change, modify the `test_get_commit_message` method in the `tests/test_coder.py` file as follows:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
        # Mock the send method to return a tuple with a message and False
        coder.send = MagicMock(return_value=("a good commit message", False))
=======
        # Mock the send method to set partial_response_content and return False
        def mock_send(*args, **kwargs):
            coder.partial_response_content = "a good commit message"
            return False

        coder.send = MagicMock(side_effect=mock_send)
>>>>>>> UPDATED
```

This will replace the original `MagicMock` with a custom `mock_send` function that sets `coder.partial_response_content` to the desired commit message and returns `False`.
2023-06-21 21:39:47 -07:00
Paul Gauthier
cf25f3a3fe aider: Replaced MagicMock with custom mock_send function to set partial_response_content and return False in test_get_commit_message_no_strip_unmatched_quotes.
# Context:
USER: same for test_get_commit_message_no_strip_unmatched_quotes
ASSISTANT: To make the requested change, modify the `test_get_commit_message_no_strip_unmatched_quotes` method in the `tests/test_coder.py` file as follows:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
        # Mock the send method to return a tuple with a message and False
        coder.send = MagicMock(return_value=('a good "commit message"', False))
=======
        # Mock the send method to set partial_response_content and return False
        def mock_send(*args, **kwargs):
            coder.partial_response_content = 'a good "commit message"'
            return False

        coder.send = MagicMock(side_effect=mock_send)
>>>>>>> UPDATED
```

This will replace the original `MagicMock` with a custom `mock_send` function that sets `coder.partial_response_content` to the desired commit message and returns `False`.
2023-06-21 21:39:20 -07:00
Paul Gauthier
9c79cbbadf aider: Set coder.partial_response_content to the good commit message in test_get_commit_message_strip_quotes.
# Context:
USER: in `test_get_commit_message_strip_quotes`, the coder.send call needs to just return False. it needs to set coder.partial_response_content= the good commit msg
ASSISTANT: To make the requested change, modify the `test_get_commit_message_strip_quotes` method in the `tests/test_coder.py` file as follows:

```python
tests/test_coder.py
<<<<<<< ORIGINAL
        # Mock the send method to return a tuple with a message and False
        coder.send = MagicMock(return_value=('"a good commit message"', False))
=======
        # Mock the send method to set partial_response_content and return False
        def mock_send(*args, **kwargs):
            coder.partial_response_content = "a good commit message"
            return False

        coder.send = MagicMock(side_effect=mock_send)
>>>>>>> UPDATED
```

This will replace the original `MagicMock` with a custom `mock_send` function that sets `coder.partial_response_content` to the desired commit message and returns `False`.
2023-06-21 21:38:38 -07:00
Paul Gauthier
2edbaa6e7a fixed tests 2023-06-21 21:36:36 -07:00
Paul Gauthier
0aafff4bc5 fixed tests 2023-06-21 21:35:50 -07:00
Paul Gauthier
4b69e2b85c fixed test 2023-06-21 21:33:51 -07:00
Paul Gauthier
e26acbae65 Make functions optional 2023-06-21 21:22:24 -07:00
Paul Gauthier
dd71b903a0 err msg 2023-06-21 21:18:16 -07:00
Paul Gauthier
eb062cc504 refac and func update_files 2023-06-21 21:17:12 -07:00
Paul Gauthier
8c1e1c7267 handle not live case 2023-06-21 21:08:22 -07:00
Paul Gauthier
f9086e66d3 better live output of multi file edits 2023-06-21 21:02:07 -07:00