Commit graph

546 commits

Author SHA1 Message Date
Paul Gauthier
70d01f5434 aider: Implemented find_common_root method to set self.root to the most specific directory that all the file paths in self.fnames have in common.
# Context:
USER: thanks, i used that.
ASSISTANT: You're welcome! If you have any more questions or need further assistance, feel free to ask.

USER: implement the find_common_root method. it should set self.root to be the most specific directory which all the self.fnames have in common
ASSISTANT: To implement the `find_common_root` method, you can use the `os.path.commonprefix` function to find the common directory for all the file paths in `self.fnames`. Here's the implementation:

```python
aider/coder.py
<<<<<<< ORIGINAL
    def find_common_root(self):
        pass
=======
    def find_common_root(self):
        import os

        common_prefix = os.path.commonprefix(list(self.fnames))
        self.root = os.path.dirname(common_prefix)
        self.console.print(f"[red]Common root directory: {self.root}")
>>>>>>> UPDATED
```

This will set `self.root` to the most specific directory that all the file paths in `self.fnames` have in common.
2023-05-10 09:12:14 -07:00
Paul Gauthier
9ab1a0d513 updated readme 2023-05-09 21:29:53 -07:00
Paul Gauthier
4aec6a9ba0 updated readme 2023-05-09 21:24:32 -07:00
Paul Gauthier
77ca367bcb updated readme 2023-05-09 21:21:21 -07:00
Paul Gauthier
1b602111fe updated readme 2023-05-09 21:20:06 -07:00
Paul Gauthier
d1b9705356 updated readme 2023-05-09 21:14:50 -07:00
Paul Gauthier
cbd0ae1462 updated readme 2023-05-09 21:09:12 -07:00
Paul Gauthier
f708314f3a updated readme 2023-05-09 21:07:32 -07:00
Paul Gauthier
2ebff9d1a5 updated readme 2023-05-09 21:06:06 -07:00
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
0c7f16afbf updated readme 2023-05-09 19:42:47 -07:00
Paul Gauthier
b6fbaf1c33 avoid repainting the live view when it is done 2023-05-09 18:03:23 -07:00
Paul Gauthier
3f949e63a0 aider: Updated FileContentCompleter to split files into words on non-alphanums.
# Context:
USER: have FileContentCompleter(Completer) split the files into words on non-alphanums. so each word is a contiguous sequence of alphanums. non-alphanums are ignored, and only used to split.
ASSISTANT: To achieve this, you can update the regular expression used in the `re.split()` function inside the `FileContentCompleter` class. You can use the `\W+` pattern to split the content based on non-alphanumeric characters.

Here's the change:

```python
aider/getinput.py
<<<<<<< ORIGINAL
            for word in re.split(r"\W+", content):
=======
            for word in re.split(r'\W+', content):
>>>>>>> UPDATED
```

This change will ensure that the content is split into words based on non-alphanumeric characters, and each word will be a contiguous sequence of alphanumerics.
2023-05-09 17:53:29 -07:00
Paul Gauthier
3425adee28 updated readme 2023-05-09 16:32:06 -07:00
Paul Gauthier
88fc820cc3 updated readme 2023-05-09 16:19:52 -07:00
Paul Gauthier
7cc87e2afe stronger past tense prompt 2023-05-09 16:10:31 -07:00
Paul Gauthier
93df7ec661 updated readme 2023-05-09 15:59:01 -07:00
Paul Gauthier
8d90d3d4fc updated readme 2023-05-09 15:55:03 -07:00
Paul Gauthier
4c97799b42 handle piped input for canned asciinema demos 2023-05-09 14:39:57 -07:00
Paul Gauthier
9b734cb149 aider: Color non-tty printing green using Rich in get_input function
# Context:
USER: use rich to color the non tty printing green
ASSISTANT: To color the non-tty printing green using Rich, you can update the `get_input` function in the `aider/getinput.py` file as follows:

```python
aider/getinput.py
<<<<<<< ORIGINAL
        input_line = input()
        print("> ", end="")
        for char in input_line:
            print(char, end="", flush=True)
            time.sleep(random.uniform(0.05, 0.1))
        print()
        print()
=======
        input_line = input()
        console.print("> ", end="", style="green")
        for char in input_line:
            console.print(char, end="", style="green", flush=True)
            time.sleep(random.uniform(0.05, 0.1))
        console.print()
        console.print()
>>>>>>> UPDATED
```

This change replaces the standard `print` function with `console.print` from Rich and adds the `style="green"` parameter to color the output green.
2023-05-09 14:23:02 -07:00
Paul Gauthier
c3f1aa6286 wip: Add rich console to getinput.py and reduce sleep time. 2023-05-09 14:22:11 -07:00
Paul Gauthier
351c8206ee Add blank line after input prompt in get_input function. 2023-05-09 14:19:43 -07:00
Paul Gauthier
659ce00c40 aider: Add typing simulation to get_input function.
# Context:
USER: in this case, have it still print the "> " followed by the inputted line. but write and flush one character at a time, with small random delays in between so it looks like typing
ASSISTANT: To achieve this, you can use the `time` module to introduce small random delays and print the characters one by one. Here's the change you need to make in the `get_input` function:

```python
aider/getinput.py
<<<<<<< ORIGINAL
import sys

def get_input(history_file, fnames):
    if not sys.stdin.isatty():
        return input()
=======
import sys
import time
import random

def get_input(history_file, fnames):
    if not sys.stdin.isatty():
        input_line = input()
        print("> ", end="")
        for char in input_line:
            print(char, end="", flush=True)
            time.sleep(random.uniform(0.05, 0.2))
        print()
        return input_line
>>>>>>> UPDATED
```

This change imports the `time` and `random` modules. When the input is coming from a file, it reads the input line, prints the "> " prompt, and then prints each character in the input line with a small random delay between 0.05 and 0.2 seconds, simulating typing.
2023-05-09 14:16:47 -07:00
Paul Gauthier
c3eb968ec4 aider: Detect if stdin is coming from a file and use normal input() if so
# Context:
USER: have get_input detect if stdin is coming from a file not a terminal, if so just use normal python input() to read a line
ASSISTANT: To detect if stdin is coming from a file and not a terminal, you can use `sys.stdin.isatty()`. If it returns `False`, it means the input is coming from a file. In that case, you can use the normal `input()` function to read a line. Here's the change you need to make in the `get_input` function:

```python
aider/getinput.py
<<<<<<< ORIGINAL
def get_input(history_file, fnames):
=======
import sys

def get_input(history_file, fnames):
    if not sys.stdin.isatty():
        return input()
>>>>>>> UPDATED
```

This change imports the `sys` module and checks if the input is coming from a file. If it is, the function returns the input using the normal `input()` function.
2023-05-09 14:15:04 -07:00
Paul Gauthier
b1fa3b91f9 aider: Saving dirty files before chat
# Context:
USER: move that import up with the others
ASSISTANT: To move the import statement to the top with the other imports, make the following change:

```python
aider/getinput.py
<<<<<<< ORIGINAL
from prompt_toolkit.styles import Style

from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import FileHistory
=======
import re
from prompt_toolkit.styles import Style

from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import FileHistory
>>>>>>> UPDATED

```

This change moves the `import re` statement to the top with the other import statements.
2023-05-09 14:13:41 -07:00
Paul Gauthier
a87de46371 aider: Split file content into words based on non-alphanumeric characters using re module in FileContentCompleter.
# Context:
USER: have FileContentCompleter(Completer) split the files into words on non-alphanums. so each word is a contiguous sequence of alphanums. non-alphanums are ignored, and only used to split.
ASSISTANT: To make the `FileContentCompleter` split the file content into words based on non-alphanumeric characters, you can use the `re` module to split the content. Here's the change you need to make:

```python
aider/getinput.py
<<<<<<< ORIGINAL
            for word in content.split():
=======
            import re
            for word in re.split(r'\W+', content):
>>>>>>> UPDATED
```

This change imports the `re` module and uses the `re.split()` function with the pattern `\W+` to split the content into words based on non-alphanumeric characters.
2023-05-09 14:12:49 -07:00
Paul Gauthier
0fdd5d101b added aider: prefix to gpt generated edits 2023-05-09 14:06:26 -07:00
Paul Gauthier
a7490cdb24 updated readme 2023-05-09 14:01:15 -07:00
Paul Gauthier
581d405a72 updated readme 2023-05-09 13:52:26 -07:00
Paul Gauthier
220ec4c2c7 updated readme 2023-05-09 13:50:17 -07:00
Paul Gauthier
fb4f57941a updated readme 2023-05-09 13:46:59 -07:00
Paul Gauthier
507df10f1d updated readme 2023-05-09 13:43:54 -07:00
Paul Gauthier
1bd5086020 updated readme 2023-05-09 13:36:48 -07:00
Paul Gauthier
227c5e368a stronger prompt for past tense commit messages 2023-05-09 13:34:36 -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
e6a1a677a4 updated readme 2023-05-09 13:08:57 -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
8df0971b4f WIP: Updated commit_system prompt to instruct user to speak in past tense. 2023-05-09 12:50:45 -07:00
Paul Gauthier
15d48ff34c updated readme with asciinema 2023-05-09 12:48:57 -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
e72ea5f2f0 updated readme 2023-05-09 12:12:16 -07:00