Commit graph

119 commits

Author SHA1 Message Date
Paul Gauthier
e7604a6545 aider output is red; better commit prompt 2023-05-09 21:05:13 -07:00
Paul Gauthier
448002bd0d all aider output should be red 2023-05-09 19:43:53 -07:00
Paul Gauthier
b6fbaf1c33 avoid repainting the live view when it is done 2023-05-09 18:03:23 -07:00
Paul Gauthier
4c97799b42 handle piped input for canned asciinema demos 2023-05-09 14:39:57 -07:00
Paul Gauthier
0fdd5d101b added aider: prefix to gpt generated edits 2023-05-09 14:06:26 -07:00
Paul Gauthier
66b8c19c1c WIP: Add ask parameter to show_diffs in coder.py. 2023-05-09 13:22:23 -07:00
Paul Gauthier
60879d3168 WIP: Changed prefix text and added new line to all_content. 2023-05-09 13:21:37 -07:00
Paul Gauthier
ceeb1d8610 Send gpt the list of files in the repo too 2023-05-09 13:18:57 -07:00
Paul Gauthier
1ba8e59c53 Add files listing to files_content when self.repo is not None in get_files_messages method.
# Context:
USER: in get_files_messages(self): if self.repo is not none, then get a listing of the files in the repo and add it to all_content
ASSISTANT: To add a listing of the files in the repo to `all_content` when `self.repo` is not `None`, you can modify the `get_files_messages` method as follows:

```python
aider/coder.py
<<<<<<< ORIGINAL
    def get_files_messages(self):

        files_content = prompts.files_content_prefix
        files_content += self.get_files_content()

        all_content = files_content
=======
    def get_files_messages(self):

        files_content = prompts.files_content_prefix
        files_content += self.get_files_content()

        if self.repo is not None:
            tracked_files = set(self.repo.git.ls_files().splitlines())
            files_listing = "\n".join(tracked_files)
            files_content += f"\n\nFiles in the repo:\n{files_listing}\n"

        all_content = files_content
>>>>>>> UPDATED
```

This change adds a conditional block to check if `self.repo` is not `None` and then retrieves the list of tracked files in the repo. It then adds the files listing to `files_content` before assigning it to `all_content`.
2023-05-09 13:15:22 -07:00
Paul Gauthier
e2b5c6074f lint 2023-05-09 13:10:38 -07:00
Paul Gauthier
2391c2e49b lint 2023-05-09 13:09:05 -07:00
Paul Gauthier
540c0b10b9 Add --show-diffs parameter and only print diffs if it is set to True.
# Context:
USER: add a --show-diffs parameter  which defaults to false. allow an env var to override the default. pass this to Coder.__init__() and use it to set a self.show_diffs. only self.console.print(Text(diffs)) if it is true.
ASSISTANT: To add a `--show-diffs` parameter with a default value of `False` and allow an environment variable to override the default, we will make changes to `aider/main.py`. We will also pass this value to `Coder.__init__()` and use it to set `self.show_diffs`. Finally, we will only print the diffs if `self.show_diffs` is `True`.

Here are the changes:

```python
aider/main.py
<<<<<<< ORIGINAL
        default=bool(int(os.environ.get(f"{env_prefix}COMMIT_DIRTY", 0))),
    )
    args = parser.parse_args()
=======
        default=bool(int(os.environ.get(f"{env_prefix}COMMIT_DIRTY", 0))),
    )
    parser.add_argument(
        "--show-diffs",
        action="store_true",
        help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)",
        default=bool(int(os.environ.get(f"{env_prefix}SHOW_DIFFS", 0))),
    )
    args = parser.parse_args()
>>>>>>> UPDATED
```

```python
aider/main.py
<<<<<<< ORIGINAL
    coder = Coder(args.model, fnames, pretty, args.history_file)
=======
    coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs)
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
    def __init__(self, main_model, files, pretty, history_file):
=======
    def __init__(self, main_model, files, pretty, history_file, show_diffs):
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
        self.pretty = pretty
=======
        self.pretty = pretty
        self.show_diffs = show_diffs
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
        self.console.print(Text(diffs))
=======
        if self.show_diffs:
            self.console.print(Text(diffs))
>>>>>>> UPDATED
```

These changes will add the `--show-diffs` parameter and only print the diffs if the parameter is set to `True`.
2023-05-09 13:04:43 -07:00
Paul Gauthier
0782e50f6d WIP: Refactor Coder class constructor to remove default value for history_file parameter. 2023-05-09 12:59:21 -07:00
Paul Gauthier
875d9f8c9b Added yes defaults 2023-05-09 12:48:50 -07:00
Paul Gauthier
8654a4201f WIP: Change output file name from "tmp.last-edit.md" to ".aider.last.md". 2023-05-09 12:42:27 -07:00
Paul Gauthier
97cf30b0f0 WIP: Fix GitPython issue with GitDB in coder.py. 2023-05-09 12:41:38 -07:00
Paul Gauthier
0cfbabb03b Handle InvalidGitRepositoryError by replacing list comprehension with for loop and try-except.
# Context:
USER: unroll the list comprehension so we can try/catch the exception below which is thrown for files not in any git repo

  File "/Users/gauthier/Projects/aider/aider/coder.py", line 68, in <genexpr>
    git.Repo(fname, search_parent_directories=True).git_dir
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/tmp/try-aider/.venv/lib/python3.11/site-packages/git/repo/base.py", line 265, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /Users/gauthier/tmp/try-aider/tmp.py

ASSISTANT: To unroll the list comprehension and handle the exception, we can replace it with a for loop and use try-except to catch the `InvalidGitRepositoryError`.

```python
aider/coder.py
<<<<<<< ORIGINAL
        repo_paths = list(
            git.Repo(fname, search_parent_directories=True).git_dir
            for fname in self.fnames
        )
=======
        repo_paths = []
        for fname in self.fnames:
            try:
                repo_path = git.Repo(fname, search_parent_directories=True).git_dir
                repo_paths.append(repo_path)
            except git.exc.InvalidGitRepositoryError:
                pass
>>>>>>> UPDATED
```

This change will catch the `InvalidGitRepositoryError` and continue processing the remaining files.
2023-05-09 11:31:52 -07:00
Paul Gauthier
132e0a687f WIP: Refactor imports and remove unused code in coder.py. 2023-05-09 11:30:34 -07:00
Paul Gauthier
984e2f78ce moved into subdir 2023-05-09 10:52:18 -07:00
Renamed from coder.py (Browse further)