Commit graph

1478 commits

Author SHA1 Message Date
Paul Gauthier
32289bc40f fixed bug caught in tests 2023-05-26 15:50:35 -07:00
Paul Gauthier
7fe7f1e279 fix 2023-05-26 15:48:26 -07:00
Paul Gauthier
6b5c93f046 refac 2023-05-26 15:45:26 -07:00
Paul Gauthier
a7aa95b18c aider: Fixed indentation for get_git_root() function and following lines.
# Context:
USER: fix the indentation!
ASSISTANT: I apologize for the indentation issue. Here's the corrected version of the `aider/main.py` file:

```python
aider/main.py
<<<<<<< ORIGINAL
def main(args=None, input=None, output=None):
    if args is None:
        args = sys.argv[1:]

    load_dotenv()
    env_prefix = "AIDER_"
    def get_git_root():
    try:
        repo = git.Repo(search_parent_directories=True)
        return repo.working_tree_dir
    except git.InvalidGitRepositoryError:
        return None

default_config_files = [
    os.path.expanduser("~/.aider.conf.yml"),
]

git_root = get_git_root()
if git_root:
    default_config_files.insert(0, os.path.join(git_root, ".aider.conf.yml"))
=======
def main(args=None, input=None, output=None):
    if args is None:
        args = sys.argv[1:]

    load_dotenv()
    env_prefix = "AIDER_"

    def get_git_root():
        try:
            repo = git.Repo(search_parent_directories=True)
            return repo.working_tree_dir
        except git.InvalidGitRepositoryError:
            return None

    default_config_files = [
        os.path.expanduser("~/.aider.conf.yml"),
    ]

    git_root = get_git_root()
    if git_root:
        default_config_files.insert(0, os.path.join(git_root, ".aider.conf.yml"))
>>>>>>> UPDATED
```

This update fixes the indentation for the `get_git_root()` function and the following lines.
2023-05-26 15:44:49 -07:00
Paul Gauthier
05e976a2b6 aider: Set default configuration file path to prefer Git repository root and fallback to user's home directory.
# Context:
USER: give them both, preferring the git one
ASSISTANT: To set the default configuration file path to prefer the Git repository root and fallback to the user's home directory, update the `aider/main.py` file with the following changes:

```python
aider/main.py
<<<<<<< ORIGINAL
git_root = get_git_root()
if git_root:
    default_config_file = os.path.join(git_root, ".aider.conf.yml")
else:
    default_config_file = os.path.expanduser("~/.aider.conf.yml")
=======
default_config_files = [
    os.path.expanduser("~/.aider.conf.yml"),
]

git_root = get_git_root()
if git_root:
    default_config_files.insert(0, os.path.join(git_root, ".aider.conf.yml"))

>>>>>>> UPDATED
```

```python
aider/main.py
<<<<<<< ORIGINAL
parser = configargparse.ArgumentParser(
    description="aider - chat with GPT about your code",
    add_config_file_help=True,
    default_config_files=[default_config_file],
)
=======
parser = configargparse.ArgumentParser(
    description="aider - chat with GPT about your code",
    add_config_file_help=True,
    default_config_files=default_config_files,
)
>>>>>>> UPDATED
```

These changes will set the `default_config_files` list to include both the Git repository root and the user's home directory, with preference given to the Git repository root.
2023-05-26 15:43:49 -07:00
Paul Gauthier
e17265c998 aider: Set default config file path based on whether the current working directory is part of a Git repository or not.
# Context:
USER: where does configargparse look for the config file?
ASSISTANT: `configargparse` looks for the configuration file in the locations specified by the `add_config_file_help` and `default_config_files` arguments when creating an `ArgumentParser` instance. If these arguments are not provided, it does not look for a configuration file by default.

To specify the locations for the configuration file, you can do the following:

```python
parser = configargparse.ArgumentParser(
    description="aider - chat with GPT about your code",
    add_config_file_help=True,
    default_config_files=["./config.ini", "/etc/aider/config.ini"],
)
```

In this example, `configargparse` will look for the configuration file in the current directory with the name `config.ini` and in the `/etc/aider/` directory with the same name. If a configuration file is found, the values from the file will be used as default values for the arguments.
USER: can it search parent dirs for the conf file
ASSISTANT: Yes, `configargparse` can search parent directories for the configuration file. You can use a loop to generate a list of configuration file paths in parent directories and pass it to the `default_config_files` argument. Here's an example:

```python
import os

def generate_config_paths(filename):
    config_paths = []
    current_dir = os.path.abspath(os.getcwd())

    while True:
        config_path = os.path.join(current_dir, filename)
        config_paths.append(config_path)

        parent_dir = os.path.dirname(current_dir)
        if parent_dir == current_dir:
            break

        current_dir = parent_dir

    return config_paths

config_file_name = "config.ini"
config_paths = generate_config_paths(config_file_name)

parser = configargparse.ArgumentParser(
    description="aider - chat with GPT about your code",
    add_config_file_help=True,
    default_config_files=config_paths,
)
```

This code will generate a list of configuration file paths in parent directories with the given `config_file_name` and pass it to the `default_config_files` argument. `configargparse` will search for the configuration file in the specified paths.
USER: nah. instead, see if cwd is part of a git repo. if so, make the default be the working dir of the repo/.aider.conf.yml, otherwise expand ~/.aider.conf.yml
ASSISTANT: To achieve this, you can use the `git` command to check if the current working directory is part of a Git repository and then set the default configuration file path accordingly. Here's how you can do it:

```python
import os
import subprocess

def get_git_root():
    try:
        git_root = subprocess.check_output(["git", "rev-parse", "--
^C KeyboardInterrupt
USER: use import git
ASSISTANT: To use the `git` Python library, first, make sure it's installed. You can install it using pip:

```
pip install GitPython
```

Then, you can modify the code to use the `git` library to check if the current working directory is part of a Git repository and set the default configuration file path accordingly:

```python
import os
import git
import configargparse

def get_git_root():
    try:
        repo = git.Repo(search_parent_directories=True)
        return repo.working_tree_dir
    except git.InvalidGitRepositoryError:

^C KeyboardInterrupt
USER: as an edit block
ASSISTANT: First, install the `GitPython` library if you haven't already:

```
pip install GitPython
```

Then, update the `aider/main.py` file with the following changes:

```python
aider/main.py
<<<<<<< ORIGINAL
import sys
import configargparse
from dotenv import load_dotenv
from aider.coder import Coder
from aider.io import InputOutput
=======
import os
import sys
import git
import configargparse
from dotenv import load_dotenv
from aider.coder import Coder
from aider.io import InputOutput
>>>>>>> UPDATED

```

```python
aider/main.py
<<<<<<< ORIGINAL
parser = configargparse.ArgumentParser(description="aider - chat with GPT about your code")
=======
def get_git_root():
    try:
        repo = git.Repo(search_parent_directories=True)
        return repo.working_tree_dir
    except git.InvalidGitRepositoryError:
        return None

git_root = get_git_root()
if git_root:
    default_config_file = os.path.join(git_root, ".aider.conf.yml")
else:
    default_config_file = os.path.expanduser("~/.aider.conf.yml")

parser = configargparse.ArgumentParser(
    description="aider - chat with GPT about your code",
    add_config_file_help=True,
    default_config_files=[default_config_file],
)
>>>>>>> UPDATED
```

These changes will import the `git` library and define a `get_git_root()` function to find the Git repository root. The default configuration file path will be set to either the repository root with `.aider.conf.yml` or the user's home directory with `.aider.conf.yml`.
2023-05-26 15:42:44 -07:00
Paul Gauthier
80c195b323 aider: Removed ${env_prefix}XXXX info from help strings in aider/main.py.
# Context:
USER: don't include the ${env_prefix}XXXX info in the help strings. configargparse adds that info to the help message automatically
ASSISTANT: I will remove the `${env_prefix}XXXX` info from the help strings in the `aider/main.py` file.

```python
aider/main.py
<<<<<<< ORIGINAL
        help=(
            "Specify the chat input history file (default: .aider.input.history,"
            f" ${env_prefix}INPUT_HISTORY_FILE)"
        ),
=======
        help="Specify the chat input history file (default: .aider.input.history)",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=(
            "Specify the chat history file (default: .aider.chat.history.md,"
            f" ${env_prefix}CHAT_HISTORY_FILE)"
        ),
=======
        help="Specify the chat history file (default: .aider.chat.history.md)",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=f"Specify the model to use for the main chat (default: gpt-4, ${env_prefix}MODEL)",
=======
        help="Specify the model to use for the main chat (default: gpt-4)",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=f"Disable pretty, colorized output (${env_prefix}PRETTY)",
=======
        help="Disable pretty, colorized output",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=f"Disable auto commit of changes (${env_prefix}AUTO_COMMITS)",
=======
        help="Disable auto commit of changes",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)",
=======
        help="Show diffs when committing changes (default: False)",
>>>>>>> UPDATED

```python
aider/main.py
<<<<<<< ORIGINAL
        help=(
            "Add ctags to the chat to help GPT understand the codebase (default: False,"
            f" ${env_prefix}CTAGS)"
        ),
=======
        help="Add ctags to the chat to help GPT understand the codebase (default: False)",
>>>>>>> UPDATED
2023-05-26 13:07:19 -07:00
Paul Gauthier
17184dd2df added configargparse 2023-05-26 13:04:48 -07:00
Paul Gauthier
a886ea472b Stronger prompting to only modify full files, not parts of the repo map 2023-05-26 12:59:08 -07:00
Paul Gauthier
4e557baad4 cleaned up /exit, normalized /help 2023-05-26 12:21:43 -07:00
Paul Gauthier
c40d763bce aider: Added /exit command to aider/commands.py.
# Context:
USER: add an /exit command which calls sys.exit
ASSISTANT: To add an `/exit` command, we need to modify the `commands.py` file to add a new command method and update the `is_command` and `run` methods to recognize and execute the new command. We also need to import `sys` to use `sys.exit()`.

Here are the changes:

```python
aider/commands.py
<<<<<<< ORIGINAL
from . import io
=======
import sys
from . import io
>>>>>>> UPDATED
```

```python
aider/commands
^C KeyboardInterrupt
USER: I added the content of these additional files: aider/commands.py
ASSISTANT: I apologize for the confusion. Here are the changes to add the `/exit` command to the `aider/commands.py` file:

```python
aider/commands.py
<<<<<<< ORIGINAL
import os
import git
import subprocess
import shlex
=======
import sys
import os
import git
import subprocess
import shlex
>>>>>>> UPDATED
```

```python
aider/commands.py
<<<<<<< ORIGINAL
        commands = ["/help"]
=======
        commands = ["/help", "/exit"]
>>>>>>> UPDATED
```

```python
aider/commands.py
<<<<<<< ORIGINAL
        else:
            self.io.tool_error(f"Error: {first_word} is not a valid command.")
=======
        elif first_word == "/exit":
            self.cmd_exit()
        else:
            self.io.tool_error(f"Error: {first_word} is not a valid command.")
>>>>>>> UPDATED
```

```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_ls(self, args):
        "List all known files and those included in the chat session"
=======
    def cmd_exit(self):
        "Exit the application"
        sys.exit()

    def cmd_ls(self, args):
        "List all known files and those included in the chat session"
>>>>>>> UPDATED
```

These changes will add the `/exit` command to the list of commands, recognize it when entered, and call the `cmd_exit` method to exit the application using `sys.exit()`.
2023-05-26 12:16:59 -07:00
Paul Gauthier
7cc9cdfb21 Merge remote-tracking branch 'origin/main' 2023-05-26 07:11:55 -07:00
Paul Gauthier
38a49beea8 copy 2023-05-26 07:11:46 -07:00
paul-gauthier
ecea4aae35
Update ctags.md 2023-05-25 22:33:02 -07:00
Paul Gauthier
be8b9c1f52 Merge remote-tracking branch 'origin/main' 2023-05-25 21:47:06 -07:00
Paul Gauthier
34ac7bcf09 copy 2023-05-25 21:46:24 -07:00
paul-gauthier
b32dd26743
Update ctags.md 2023-05-25 21:01:41 -07:00
Paul Gauthier
436e15eab2 copy 2023-05-25 19:50:15 -07:00
Paul Gauthier
58ff867d1a copy 2023-05-25 19:36:48 -07:00
Paul Gauthier
0108c3c0f7 copy 2023-05-25 19:18:11 -07:00
Paul Gauthier
30eab47432 copy 2023-05-25 19:12:31 -07:00
Paul Gauthier
23c4e654e1 copy 2023-05-25 19:09:59 -07:00
Paul Gauthier
c3f8583220 copy 2023-05-25 13:27:55 -07:00
Paul Gauthier
28fd7b05b4 copy 2023-05-25 13:24:06 -07:00
Paul Gauthier
5cd4c1c41b copy 2023-05-25 13:23:43 -07:00
Paul Gauthier
f0c001f791 copy 2023-05-25 13:21:39 -07:00
Paul Gauthier
790a0cc3e3 copy 2023-05-25 11:58:15 -07:00
Paul Gauthier
3813e85fce copy 2023-05-25 11:39:54 -07:00
Paul Gauthier
0923f16044 copy 2023-05-25 11:33:26 -07:00
Paul Gauthier
023726db11 copy 2023-05-25 11:24:34 -07:00
Paul Gauthier
94b216ab0f copy 2023-05-25 10:52:33 -07:00
Paul Gauthier
ead85e8e96 copy 2023-05-25 10:46:26 -07:00
Paul Gauthier
599a3b2730 wip 2023-05-25 10:45:57 -07:00
Paul Gauthier
959f577aba wip 2023-05-25 10:01:01 -07:00
Paul Gauthier
ce50da1611 Merge branch 'main' into call-graph 2023-05-25 09:09:41 -07:00
Paul Gauthier
96c63dfb66 copy 2023-05-25 09:02:45 -07:00
Paul Gauthier
46dc24afce Merge branch 'main' into call-graph 2023-05-25 08:54:03 -07:00
Paul Gauthier
4f1ec79220 Improved RateLimitError message 2023-05-25 08:53:55 -07:00
Paul Gauthier
f70aea7cd1 noop 2023-05-25 08:49:40 -07:00
Paul Gauthier
1aa9cde119 Merge branch 'main' into call-graph 2023-05-25 08:29:09 -07:00
Paul Gauthier
61c0892f58 bumped version 2023-05-25 08:28:57 -07:00
Paul Gauthier
d13a794b8d Merge branch 'main' into dynamic-map 2023-05-25 08:27:42 -07:00
Paul Gauthier
451e95523d Merge branch 'main' into call-graph 2023-05-25 08:27:18 -07:00
Paul Gauthier
e79b855ccf copy 2023-05-25 06:41:34 -07:00
Paul Gauthier
da8a85fea6 wip 2023-05-25 06:39:40 -07:00
Paul Gauthier
407e47b6ed wip 2023-05-24 22:26:48 -07:00
Paul Gauthier
a1b5206345 wip 2023-05-24 22:04:43 -07:00
Paul Gauthier
43b79b0c2d refac 2023-05-24 21:39:36 -07:00
Paul Gauthier
3ecf008478 refac 2023-05-24 21:31:08 -07:00
Paul Gauthier
60031ecd29 fixed bug found by testing 2023-05-24 19:09:05 -07:00